Show
Ignore:
Timestamp:
06/07/08 09:08:53 (4 years ago)
Author:
ray
Message:

update to new dialog plugins: separation of code into several files to reduce loading time

Location:
branches/new-dialogs-merge/modules
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • branches/new-dialogs-merge/modules/CreateLink/link.js

    r1009 r1011  
    5050CreateLink.prototype.onGenerateOnce = function() 
    5151{ 
    52         this.prepareDialog(); 
    53         this.loadScripts(); 
     52  CreateLink.loadAssets(); 
    5453}; 
    5554 
    56 CreateLink.prototype.loadScripts = function() 
     55CreateLink.loadAssets = function() 
    5756{ 
    58   var self = this; 
    59   if(!this.methodsReady) 
    60         { 
    61                 Xinha._getback(_editor_url + 'modules/CreateLink/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 
    62                 return; 
    63         } 
    64 }; 
     57        var self = CreateLink; 
     58        if (self.loading) return; 
     59        self.loading = true; 
     60        Xinha._getback(_editor_url + 'modules/CreateLink/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; }); 
     61        Xinha._getback(_editor_url + 'modules/CreateLink/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 
     62} 
    6563 
    6664CreateLink.prototype.onUpdateToolbar = function() 
    6765{  
    68   if (!(this.dialogReady && this.methodsReady)) 
     66        if (!(CreateLink.dialogReady && CreateLink.methodsReady)) 
    6967        { 
    70           this.editor._toolbarObjects.createlink.state("enabled", false); 
     68                this.editor._toolbarObjects.createlink.state("enabled", false); 
    7169        } 
     70        else this.onUpdateToolbar = null; 
    7271}; 
    7372 
     
    7776        var editor = this.editor; 
    7877 
    79         if(!this.html) // retrieve the raw dialog contents 
    80         { 
    81                 Xinha._getback(_editor_url + 'modules/CreateLink/dialog.html', function(getback) { self.html = getback; self.prepareDialog(); }); 
    82                 return; 
    83         } 
    84  
    85         // Now we have everything we need, so we can build the dialog. 
    86                  
    87         var dialog = this.dialog = new Xinha.Dialog(editor, this.html, 'Xinha',{width:400}) 
     78        var dialog = this.dialog = new Xinha.Dialog(editor, CreateLink.html, 'Xinha',{width:400}) 
    8879        // Connect the OK and Cancel buttons 
    8980        dialog.getElementById('ok').onclick = function() {self.apply();} 
  • branches/new-dialogs-merge/modules/CreateLink/pluginMethods.js

    r1008 r1011  
    22CreateLink.prototype.show = function(a) 
    33{ 
     4  if (!this.dialog) 
     5  { 
     6    this.prepareDialog(); 
     7  }  
    48        var editor = this.editor; 
    59        this.a = a; 
  • branches/new-dialogs-merge/modules/InsertImage/insert_image.js

    r1008 r1011  
    4646InsertImage.prototype.onGenerateOnce = function() 
    4747{ 
    48         this.prepareDialog(); 
    49         this.loadScripts(); 
     48        InsertImage.loadAssets(); 
    5049}; 
    5150 
    52 InsertImage.prototype.loadScripts = function() 
     51InsertImage.loadAssets = function() 
    5352{ 
    54   var self = this; 
    55   if(!this.methodsReady) 
    56         { 
    57                 Xinha._getback(_editor_url + 'modules/InsertImage/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 
    58                 return; 
    59         } 
     53        var self = InsertImage; 
     54        if (self.loading) return; 
     55        self.loading = true; 
     56        Xinha._getback(_editor_url + 'modules/InsertImage/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; }); 
     57        Xinha._getback(_editor_url + 'modules/InsertImage/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 
    6058}; 
    61  
    6259InsertImage.prototype.onUpdateToolbar = function() 
    6360{  
    64   if (!(this.dialogReady && this.methodsReady)) 
     61  if (!(InsertImage.dialogReady && InsertImage.methodsReady)) 
    6562        { 
    6663          this.editor._toolbarObjects.insertimage.state("enabled", false); 
    6764        } 
     65  else this.onUpdateToolbar = null; 
    6866}; 
    6967 
     
    7371        var editor = this.editor; 
    7472 
    75         if(!this.html) // retrieve the raw dialog contents 
    76         { 
    77                 Xinha._getback(_editor_url + 'modules/InsertImage/dialog.html', function(getback) { self.html = getback; self.prepareDialog(); }); 
    78                 return; 
    79         } 
    80  
    81         // Now we have everything we need, so we can build the dialog. 
    82                  
    83         var dialog = this.dialog = new Xinha.Dialog(editor, this.html, 'Xinha',{width:410}) 
     73        var dialog = this.dialog = new Xinha.Dialog(editor, InsertImage.html, 'Xinha',{width:410}) 
    8474        // Connect the OK and Cancel buttons 
    8575        dialog.getElementById('ok').onclick = function() {self.apply();} 
  • branches/new-dialogs-merge/modules/InsertImage/pluginMethods.js

    r1008 r1011  
    11InsertImage.prototype.show = function(image) 
    22{ 
    3         var editor = this.editor; 
     3        if (!this.dialog) this.prepareDialog(); 
     4   
     5  var editor = this.editor; 
    46        if ( typeof image == "undefined" ) 
    57  { 
     
    6062InsertImage.prototype.apply = function() 
    6163{ 
    62  
    6364  var param = this.dialog.hide(); 
    6465  if (!param.f_url) 
  • branches/new-dialogs-merge/modules/InsertTable/insert_table.js

    r1008 r1011  
    3737        var self = this; 
    3838 
    39    editor.config.btnList.inserttable[3] = function() { self.show(); } 
     39        editor.config.btnList.inserttable[3] = function() { self.show(); } 
    4040} 
    4141 
     
    4747InsertTable.prototype.onGenerateOnce = function() 
    4848{ 
    49         this.prepareDialog(); 
    50         this.loadScripts(); 
     49        InsertTable.loadAssets(); 
    5150}; 
    52  
    53 InsertTable.prototype.loadScripts = function() 
     51InsertTable.loadAssets = function() 
    5452{ 
    55   var self = this; 
    56   if(!this.methodsReady) 
    57         { 
    58                 Xinha._getback(_editor_url + 'modules/InsertTable/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 
    59                 return; 
    60         } 
     53        var self = InsertTable; 
     54        if (self.loading) return; 
     55        self.loading = true; 
     56        Xinha._getback(_editor_url + 'modules/InsertTable/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; }); 
     57        Xinha._getback(_editor_url + 'modules/InsertTable/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 
    6158}; 
    6259 
    6360InsertTable.prototype.onUpdateToolbar = function() 
    6461{  
    65   if (!(this.dialogReady && this.methodsReady)) 
     62  if (!(InsertTable.dialogReady && InsertTable.methodsReady)) 
    6663        { 
    6764          this.editor._toolbarObjects.inserttable.state("enabled", false); 
    6865        } 
     66        else this.onUpdateToolbar = null; 
    6967}; 
    7068 
     
    7472        var editor = this.editor; 
    7573 
    76         if(!this.html) // retrieve the raw dialog contents 
    77         { 
    78                 Xinha._getback(_editor_url + 'modules/InsertTable/dialog.html', function(getback) { self.html = getback; self.prepareDialog(); }); 
    79                 return; 
    80         } 
    81  
    82         // Now we have everything we need, so we can build the dialog. 
    83                  
    84         var dialog = this.dialog = new Xinha.Dialog(editor, this.html, 'Xinha',{width:400}) 
     74        var dialog = this.dialog = new Xinha.Dialog(editor, InsertTable.html, 'Xinha',{width:400}) 
    8575        // Connect the OK and Cancel buttons 
    8676        dialog.getElementById('ok').onclick = function() {self.apply();} 
  • branches/new-dialogs-merge/modules/InsertTable/pluginMethods.js

    r1008 r1011  
    11InsertTable.prototype.show = function(image) 
    22{ 
    3         var editor = this.editor; 
     3  if (!this.dialog) this.prepareDialog(); 
     4 
     5  var editor = this.editor; 
    46 
    57  var values =