Changeset 797


Ignore:
Timestamp:
03/27/07 23:14:46 (13 years ago)
Author:
ray
Message:

some work on the loading messages.

  • added functions for adding loading messages for textareas (before Xinha has loaded)
  • moved creating of loading message into separate function
  • added translations (translators see wiki/TranslationChanges)

_getback() & _loadback(): added URL to error message

added function to calculate the page size

some changes in popups.js

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r793 r797  
    182182    h: textarea.style.height ? textarea.style.height : ( textarea.offsetHeight ? ( textarea.offsetHeight + 'px' ) : ( textarea.rows + 'em') ) 
    183183  }; 
    184   // Create the loading message elements 
    185   if ( this.config.showLoading ) 
    186   { 
    187     // Create and show the main loading message and the sub loading message for details of loading actions 
    188     // global element 
    189     var loading_message = document.createElement("div"); 
    190     loading_message.id = "loading_" + textarea.name; 
    191     loading_message.className = "loading"; 
    192     try 
    193     { 
    194       // how can i find the real width in pixels without % or em *and* with no visual errors ? 
    195       // for instance, a textarea with a style="width:100%" and the body padding > 0 result in a horizontal scrollingbar while loading 
    196       // A few lines above seems to indicate offsetWidth is not always set 
    197       loading_message.style.width = textarea.offsetWidth + 'px'; 
    198     } 
    199     catch (ex) 
    200     { 
    201       // offsetWidth seems not set, so let's use this._initial_ta_size.w, but sometimes it may be too huge width 
    202       loading_message.style.width = this._initial_ta_size.w; 
    203     } 
    204     loading_message.style.left = Xinha.findPosX(textarea) +  'px'; 
    205     loading_message.style.top = (Xinha.findPosY(textarea) + parseInt(this._initial_ta_size.h, 10) / 2) +  'px'; 
    206     // main static message 
    207     var loading_main = document.createElement("div"); 
    208     loading_main.className = "loading_main"; 
    209     loading_main.id = "loading_main_" + textarea.name; 
    210     loading_main.appendChild(document.createTextNode(Xinha._lc("Loading in progress. Please wait !"))); 
    211     // sub dynamic message 
    212     var loading_sub = document.createElement("div"); 
    213     loading_sub.className = "loading_sub"; 
    214     loading_sub.id = "loading_sub_" + textarea.name; 
    215     loading_sub.appendChild(document.createTextNode(Xinha._lc("Constructing main object"))); 
    216     loading_message.appendChild(loading_main); 
    217     loading_message.appendChild(loading_sub); 
    218     document.body.appendChild(loading_message); 
    219     this.setLoadingMessage("Constructing object"); 
     184 
     185  if ( document.getElementById("loading_" + textarea.id) || this.config.showLoading ) 
     186  { 
     187    if (!document.getElementById("loading_" + textarea.id)) 
     188    { 
     189      Xinha.createLoadingMessage(textarea); 
     190    } 
     191    this.setLoadingMessage(Xinha._lc("Constructing object")); 
    220192  } 
    221193 
     
    731703    side = 'right'; 
    732704  } 
    733   this.setLoadingMessage('Register panel ' + side); 
     705  this.setLoadingMessage('Register ' + side + ' panel '); 
    734706  var panel = this.addPanel(side); 
    735707  if ( object ) 
     
    981953Xinha.prototype._createToolbar = function () 
    982954{ 
    983   this.setLoadingMessage('Create Toolbar'); 
     955  this.setLoadingMessage(Xinha._lc('Create Toolbar')); 
    984956  var editor = this;    // to access this in nested functions 
    985957 
     
    13141286        function(ev) 
    13151287        { 
     1288          ev = Xinha.is_ie ? window.event : ev; 
     1289          editor.btnClickEvent = ev; 
    13161290          if ( obj.enabled ) 
    13171291          { 
     
    13231297            } 
    13241298            obj.cmd(editor, obj.name, obj); 
    1325             Xinha._stopEvent(Xinha.is_ie ? window.event : ev); 
     1299            Xinha._stopEvent(ev); 
    13261300          } 
    13271301        } 
     
    15021476Xinha.prototype._createStatusBar = function() 
    15031477{ 
    1504   this.setLoadingMessage('Create StatusBar'); 
     1478  this.setLoadingMessage(Xinha._lc('Create Statusbar')); 
    15051479  var statusbar = document.createElement("div"); 
    15061480  statusbar.className = "statusBar"; 
     
    15421516  var i; 
    15431517  var editor = this;  // we'll need "this" in some nested functions 
    1544    
    1545   this.setLoadingMessage("Generate Xinha object"); 
    1546    
    15471518  var url; 
     1519   
     1520  if (!document.getElementById("XinhaCoreDesign")) 
     1521  { 
     1522    Xinha.loadStyle(typeof _editor_css == "string" ? _editor_css : "Xinha.css",null,"XinhaCoreDesign"); 
     1523  } 
    15481524   
    15491525  // Now load a specific browser plugin which will implement the above for us. 
     
    16971673  // create the editor framework, yah, table layout I know, but much easier 
    16981674  // to get it working correctly this way, sorry about that, patches welcome. 
    1699  
     1675   
     1676  this.setLoadingMessage(Xinha._lc('Generate Xinha framework')); 
     1677   
    17001678  this._framework = 
    17011679  { 
     
    18751853  // Initalize size 
    18761854  editor.initSize(); 
    1877  
     1855  this.setLoadingMessage(Xinha._lc('Finishing')); 
    18781856  // Add an event to initialize the iframe once loaded. 
    18791857  editor._iframeLoadDone = false; 
     
    19311909Xinha.prototype.initSize = function() 
    19321910{ 
    1933   this.setLoadingMessage('Init editor size'); 
     1911  this.setLoadingMessage(Xinha._lc('Init editor size')); 
    19341912  var editor = this; 
    19351913  var width = null; 
     
    23742352Xinha.prototype.initIframe = function() 
    23752353{ 
    2376   this.setLoadingMessage('Init IFrame'); 
    23772354  this.disableToolbar(); 
    23782355  var doc = null; 
     
    27342711{ 
    27352712  if ( !Xinha.isSupportedBrowser ) return; 
    2736  
     2713   
     2714  Xinha.setLoadingMessage (Xinha._lc("Loading plugin $plugin="+pluginName+"$")); 
    27372715  // @todo : try to avoid the use of eval() 
    27382716  // Might already be loaded 
     
    28972875} 
    28982876 
    2899 Xinha.loadStyle = function(style, plugin) 
     2877Xinha.loadStyle = function(style, plugin, id) 
    29002878{ 
    29012879  var url = _editor_url || ''; 
    2902   if ( typeof plugin != "undefined" ) 
     2880  if ( plugin ) 
    29032881  { 
    29042882    url += "plugins/" + plugin + "/"; 
     
    29182896  link.rel = "stylesheet"; 
    29192897  link.href = url; 
     2898  if (id) link.id = id; 
    29202899  head.appendChild(link); 
    2921   //document.write("<style type='text/css'>@import url(" + url + ");</style>"); 
    2922 }; 
    2923 Xinha.loadStyle(typeof _editor_css == "string" ? _editor_css : "Xinha.css"); 
     2900}; 
     2901 
    29242902 
    29252903/*************************************************** 
     
    50905068      else 
    50915069      { 
    5092         alert('An error has occurred: ' + req.statusText); 
     5070        alert('An error has occurred: ' + req.statusText + '\nURL: ' + url); 
    50935071      } 
    50945072    } 
     
    51185096      else 
    51195097      { 
    5120         alert('An error has occurred: ' + req.statusText); 
     5098        alert('An error has occurred: ' + req.statusText + '\nURL: ' + url); 
    51215099      } 
    51225100    } 
     
    52335211    else 
    52345212    { 
     5213      Xinha.setLoadingMessage("Loading language"); 
    52355214      url = _editor_url+"lang/"+_editor_lang+".js"; 
    52365215    } 
     
    54945473    for ( var i = 0; i < plugin_names.length; i++ ) 
    54955474    { 
    5496       this.setLoadingMessage('Register plugin $plugin', 'Xinha', {'plugin': plugin_names[i]}); 
     5475      this.setLoadingMessage(Xinha._lc('Register plugin $plugin', 'Xinha', {'plugin': plugin_names[i]})); 
    54975476      this.registerPlugin(plugin_names[i]); 
    54985477    } 
     
    56265605    y = scope.document.body.clientHeight; 
    56275606  } 
     5607  return {'x':x,'y':y}; 
     5608}; 
     5609 
     5610Xinha.pageSize = function(scope) 
     5611{ 
     5612  scope = (scope) ? scope : window; 
     5613  var x,y; 
     5614  
     5615  var test1 = scope.document.body.scrollHeight; //IE Quirks 
     5616  var test2 = scope.document.documentElement.scrollHeight; // IE Standard + Moz Here quirksmode.org errs!  
     5617 
     5618  if (test1 > test2)  
     5619  { 
     5620    x = scope.document.body.scrollWidth; 
     5621    y = scope.document.body.scrollHeight; 
     5622  } 
     5623  else 
     5624  { 
     5625    x = scope.document.documentElement.scrollWidth; 
     5626    y = scope.document.documentElement.scrollHeight; 
     5627  }   
    56285628  return {'x':x,'y':y}; 
    56295629}; 
     
    57055705}; 
    57065706 
    5707 Xinha.prototype.setLoadingMessage = function(string, context, replace) 
    5708 { 
    5709   if ( !this.config.showLoading || !document.getElementById("loading_sub_" + this._textArea.name) ) 
     5707Xinha.createLoadingMessages = function(xinha_editors) 
     5708{ 
     5709  if ( Xinha.loadingMessages || !Xinha.isSupportedBrowser )  
    57105710  { 
    57115711    return; 
    57125712  } 
    5713   var elt = document.getElementById("loading_sub_" + this._textArea.name); 
    5714   elt.innerHTML = Xinha._lc(string, context, replace); 
     5713  Xinha.loadingMessages = []; 
     5714   
     5715  for (var i=0;i<xinha_editors.length;i++) 
     5716  { 
     5717     Xinha.loadingMessages.push(Xinha.createLoadingMessage(Xinha.getElementById('textarea', xinha_editors[i]))); 
     5718  } 
     5719}; 
     5720 
     5721Xinha.createLoadingMessage = function(textarea,text) 
     5722{  
     5723  if ( document.getElementById("loading_" + textarea.id) || !Xinha.isSupportedBrowser) 
     5724  { 
     5725    return; 
     5726  } 
     5727  // Create and show the main loading message and the sub loading message for details of loading actions 
     5728  // global element 
     5729  var loading_message = document.createElement("div"); 
     5730  loading_message.id = "loading_" + textarea.id; 
     5731  loading_message.className = "loading"; 
     5732   
     5733  loading_message.style.left = Xinha.findPosX(textarea) +  'px'; 
     5734  loading_message.style.top = (Xinha.findPosY(textarea) + textarea.offsetHeight / 2) - 50 +  'px'; 
     5735  loading_message.style.width =  textarea.offsetWidth +  'px'; 
     5736   
     5737  // main static message 
     5738  var loading_main = document.createElement("div"); 
     5739  loading_main.className = "loading_main"; 
     5740  loading_main.id = "loading_main_" + textarea.id; 
     5741  loading_main.appendChild(document.createTextNode(Xinha._lc("Loading in progress. Please wait!"))); 
     5742  // sub dynamic message 
     5743  var loading_sub = document.createElement("div"); 
     5744  loading_sub.className = "loading_sub"; 
     5745  loading_sub.id = "loading_sub_" + textarea.id; 
     5746  text = text ? text : Xinha._lc("Constructing object"); 
     5747  loading_sub.appendChild(document.createTextNode(text)); 
     5748  loading_message.appendChild(loading_main); 
     5749  loading_message.appendChild(loading_sub); 
     5750  document.body.appendChild(loading_message); 
     5751   
     5752  Xinha.freeLater(loading_message); 
     5753  Xinha.freeLater(loading_main); 
     5754  Xinha.freeLater(loading_sub); 
     5755   
     5756  return loading_sub; 
     5757}; 
     5758 
     5759Xinha.prototype.setLoadingMessage = function(subMessage, mainMessage) 
     5760{ 
     5761  if ( !document.getElementById("loading_sub_" + this._textArea.id) ) 
     5762  { 
     5763    return; 
     5764  } 
     5765  document.getElementById("loading_main_" + this._textArea.id).innerHTML = mainMessage ? mainMessage : Xinha._lc("Loading in progress. Please wait!"); 
     5766  document.getElementById("loading_sub_" + this._textArea.id).innerHTML = subMessage; 
     5767}; 
     5768 
     5769Xinha.setLoadingMessage = function(string) 
     5770{ 
     5771  if (!Xinha.loadingMessages) return;   
     5772  for ( var i = 0; i < Xinha.loadingMessages.length; i++ ) 
     5773  { 
     5774    Xinha.loadingMessages[i].innerHTML = string; 
     5775  } 
    57155776}; 
    57165777 
    57175778Xinha.prototype.removeLoadingMessage = function() 
    57185779{ 
    5719   if ( !this.config.showLoading || !document.getElementById("loading_" + this._textArea.name) ) 
    5720   { 
    5721     return ; 
    5722   } 
    5723   document.body.removeChild(document.getElementById("loading_" + this._textArea.name)); 
     5780  if (document.getElementById("loading_" + this._textArea.id) ) 
     5781  { 
     5782   document.body.removeChild(document.getElementById("loading_" + this._textArea.id)); 
     5783  } 
     5784}; 
     5785 
     5786Xinha.removeLoadingMessages = function(xinha_editors) 
     5787{ 
     5788  for (var i=0;i< xinha_editors.length;i++) 
     5789  { 
     5790     var main = document.getElementById("loading_" + document.getElementById(xinha_editors[i]).id); 
     5791     main.parentNode.removeChild(main); 
     5792  } 
     5793  Xinha.loadingMessages = null; 
    57245794}; 
    57255795 
  • trunk/popups/popup.js

    r740 r797  
    4545  if(window.__dlg_init_done) return true; 
    4646   
    47   if(window.opener._editor_skin != "") { 
     47  if(window.opener._editor_skin) { 
    4848    var head = document.getElementsByTagName("head")[0]; 
    4949    var link = document.createElement("link"); 
     
    5555        window.dialogArguments = opener.Dialog._arguments; 
    5656 
    57   var body = document.body; 
     57  var page = Xinha.pageSize(window); 
    5858  if ( !win_dim ) 
    5959  { 
    60    var dim = Xinha.viewportSize(window); 
    61     win_dim = {width:dim.x, height: body.scrollHeight}; 
     60    win_dim = {width:page.x, height: page.y}; 
    6261  } 
    6362  window.resizeTo(win_dim.width, win_dim.height); 
    6463 
    6564  var dim = Xinha.viewportSize(window); 
    66   window.resizeBy(0, body.scrollHeight - dim.y); 
     65 
     66  window.resizeBy(0, page.y - dim.y); 
    6767 
    6868  if(win_dim.top && win_dim.left) 
Note: See TracChangeset for help on using the changeset viewer.