1 /**
  2  * orderedList command
  3  * @author yiminghe@gmail.com
  4  */
  5 KISSY.add("editor/plugin/orderedList/cmd", function (S, Editor, listCmd) {
  6 
  7     var insertOrderedList = "insertOrderedList",
  8         ListCommand = listCmd.ListCommand,
  9         queryActive = listCmd.queryActive,
 10         olCmd = new ListCommand("ol");
 11 
 12     return {
 13         init:function (editor) {
 14             if (!editor.hasCommand(insertOrderedList)) {
 15                 editor.addCommand(insertOrderedList, {
 16                     exec:function (editor) {
 17                         editor.focus();
 18                         olCmd.exec(editor);
 19                     }
 20                 });
 21             }
 22 
 23             var queryOl = Editor.Utils.getQueryCmd(insertOrderedList);
 24 
 25             if (!editor.hasCommand(queryOl)) {
 26                 editor.addCommand(queryOl, {
 27                     exec:function (editor) {
 28                         var selection = editor.getSelection();
 29                         if (selection && !selection.isInvalid) {
 30                             var startElement = selection.getStartElement();
 31                             var elementPath = new Editor.ElementPath(startElement);
 32                             return queryActive("ol", elementPath);
 33                         }
 34                     }
 35                 });
 36             }
 37         }
 38     };
 39 
 40 }, {
 41     requires:['editor', '../listUtils/cmd']
 42 });