1 /** 2 * justifyCenter button. 3 * @author yiminghe@gmail.com 4 */ 5 KISSY.add("editor/plugin/justifyCenter/index", function (S, Editor, justifyCenterCmd) { 6 function exec() { 7 var editor = this.get("editor"); 8 editor.execCommand("justifyCenter"); 9 editor.focus(); 10 } 11 12 13 function justifyCenter() { 14 } 15 16 S.augment(justifyCenter, { 17 renderUI:function (editor) { 18 justifyCenterCmd.init(editor); 19 editor.addButton("justifyCenter", { 20 tooltip:"居中对齐", 21 checkable:true, 22 listeners:{ 23 click:exec, 24 afterSyncUI:function () { 25 var self = this; 26 editor.on("selectionChange", function () { 27 if (editor.get("mode") == Editor.SOURCE_MODE) { 28 return; 29 } 30 if (editor.queryCommandValue("justifyCenter")) { 31 self.set("checked", true); 32 } else { 33 self.set("checked", false); 34 } 35 }); 36 } 37 }, 38 mode:Editor.WYSIWYG_MODE 39 }); 40 } 41 }); 42 43 return justifyCenter; 44 }, { 45 requires:['editor', './cmd'] 46 });