]> git.wh0rd.org Git - tt-rss.git/blob - lib/dijit/_editor/plugins/TabIndent.js.uncompressed.js
update dojo to 1.7.3
[tt-rss.git] / lib / dijit / _editor / plugins / TabIndent.js.uncompressed.js
1 define("dijit/_editor/plugins/TabIndent", [
2         "dojo/_base/declare", // declare
3         "dojo/_base/kernel", // kernel.experimental
4         "../_Plugin",
5         "../../form/ToggleButton"
6 ], function(declare, kernel, _Plugin, ToggleButton){
7
8 /*=====
9         var _Plugin = dijit._editor._Plugin;
10 =====*/
11
12         // module:
13         //              dijit/_editor/plugins/TabIndent
14         // summary:
15         //              This plugin is used to allow the use of the tab and shift-tab keys
16         //              to indent/outdent list items.  This overrides the default behavior
17         //              of moving focus from/to the toolbar
18
19
20         kernel.experimental("dijit._editor.plugins.TabIndent");
21
22
23         var TabIndent = declare("dijit._editor.plugins.TabIndent", _Plugin, {
24                 // summary:
25                 //              This plugin is used to allow the use of the tab and shift-tab keys
26                 //              to indent/outdent list items.  This overrides the default behavior
27                 //              of moving focus from/to the toolbar
28
29                 // Override _Plugin.useDefaultCommand... processing is handled by this plugin, not by dijit.Editor.
30                 useDefaultCommand: false,
31
32                 // Override _Plugin.buttonClass to use a ToggleButton for this plugin rather than a vanilla Button
33                 buttonClass: ToggleButton,
34
35                 command: "tabIndent",
36
37                 _initButton: function(){
38                         // Override _Plugin._initButton() to setup listener on button click
39                         this.inherited(arguments);
40
41                         var e = this.editor;
42                         this.connect(this.button, "onChange", function(val){
43                                 e.set("isTabIndent", val);
44                         });
45
46                         // Set initial checked state of button based on Editor.isTabIndent
47                         this.updateState();
48                 },
49
50                 updateState: function(){
51                         // Overrides _Plugin.updateState().
52                         // Ctrl-m in the editor will switch tabIndent mode on/off, so we need to react to that.
53                         var disabled = this.get("disabled");
54                         this.button.set("disabled", disabled);
55                         if(disabled){
56                                 return;
57                         }
58                         this.button.set('checked', this.editor.isTabIndent, false);
59                 }
60         });
61
62         // Register this plugin.
63         _Plugin.registry["tabIndent"] = function(){
64                 return new TabIndent({command: "tabIndent"});
65         };
66
67
68         return TabIndent;
69 });