1 /**
  2  * load editor's dialog dynamically
  3  * @author yiminghe@gmail.com
  4  */
  5 KISSY.add("editor/plugin/dialogLoader/index", function (S, Overlay, Editor) {
  6     var globalMask,
  7         loadMask = {
  8             loading:function () {
  9                 if (!globalMask) {
 10                     globalMask = new Overlay({
 11                         x:0,
 12                         width:S.UA['ie'] == 6 ? S.DOM.docWidth() : "100%",
 13                         y:0,
 14                         // 指定全局 loading zIndex 值
 15                         zIndex:Editor.baseZIndex(Editor.zIndexManager.LOADING),
 16                         prefixCls:'ks-editor-',
 17                         elCls:"ks-editor-global-loading"
 18                     });
 19                 }
 20                 globalMask.set("height", S.DOM.docHeight());
 21                 globalMask.show();
 22                 globalMask.loading();
 23             },
 24             unloading:function () {
 25                 globalMask.hide();
 26             }
 27         };
 28 
 29     return {
 30         useDialog:function (editor, name,config, args) {
 31             // restore focus in editor
 32             // make dialog remember
 33             editor.focus();
 34             if (editor.getControl(name + "/dialog")) {
 35                 setTimeout(function () {
 36                     editor.showDialog(name, args);
 37                 }, 0);
 38                 return;
 39             }
 40             loadMask.loading();
 41             S.use("editor/plugin/" + name + "/dialog", function (S, Dialog) {
 42                 loadMask.unloading();
 43                 editor.addControl(name + "/dialog", new Dialog(editor,config));
 44                 editor.showDialog(name, args);
 45             });
 46         }
 47     };
 48 }, {
 49     requires:['overlay', 'editor']
 50 });