PageRenderTime 27ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/ext-4.1.0_b3/docs/source/LabelEditor.html

https://bitbucket.org/srogerf/javascript
HTML | 94 lines | 79 code | 15 blank | 0 comment | 0 complexity | 2d62bcd38cb41db459131af3a188995d MD5 | raw file
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-ux-DataView-LabelEditor'>/**
  19. </span> * @class Ext.ux.DataView.LabelEditor
  20. * @extends Ext.Editor
  21. */
  22. Ext.define('Ext.ux.DataView.LabelEditor', {
  23. extend: 'Ext.Editor',
  24. alignment: 'tl-tl',
  25. completeOnEnter: true,
  26. cancelOnEsc: true,
  27. shim: false,
  28. autoSize: {
  29. width: 'boundEl',
  30. height: 'field'
  31. },
  32. labelSelector: 'x-editable',
  33. requires: [
  34. 'Ext.form.field.Text'
  35. ],
  36. constructor: function(config) {
  37. config.field = config.field || Ext.create('Ext.form.field.Text', {
  38. allowBlank: false,
  39. selectOnFocus:true
  40. });
  41. this.callParent([config]);
  42. },
  43. init: function(view) {
  44. this.view = view;
  45. this.mon(view, 'render', this.bindEvents, this);
  46. this.on('complete', this.onSave, this);
  47. },
  48. // initialize events
  49. bindEvents: function() {
  50. this.mon(this.view.getEl(), {
  51. click: {
  52. fn: this.onClick,
  53. scope: this
  54. }
  55. });
  56. },
  57. // on mousedown show editor
  58. onClick: function(e, target) {
  59. var me = this,
  60. item, record;
  61. if (Ext.fly(target).hasCls(me.labelSelector) &amp;&amp; !me.editing &amp;&amp; !e.ctrlKey &amp;&amp; !e.shiftKey) {
  62. e.stopEvent();
  63. item = me.view.findItemByChild(target);
  64. record = me.view.store.getAt(me.view.indexOf(item));
  65. me.startEdit(target, record.data[me.dataIndex]);
  66. me.activeRecord = record;
  67. } else if (me.editing) {
  68. me.field.blur();
  69. e.preventDefault();
  70. }
  71. },
  72. // update record
  73. onSave: function(ed, value) {
  74. this.activeRecord.set(this.dataIndex, value);
  75. }
  76. });
  77. </pre>
  78. </body>
  79. </html>