Changeset 767 for trunk


Ignore:
Timestamp:
03/09/07 17:42:03 (13 years ago)
Author:
ray
Message:
  • Ticket #977 TableOperations? toolbar off-place in ext_example.html
  • Ticket #978 defining a padding for <td>s in global css affects Xinha framework
  • Ticket #979 improve checking for non-supported browsers
  • Ticket #934 SuperClean? plugin returns just quotation when executed on localhost
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Xinha.css

    r738 r767  
    11.htmlarea { background: #fff; } 
     2.htmlarea td { margin:0;padding:0; } 
    23 
    34.htmlarea .toolbar { 
     
    5556.htmlarea .toolbar .separator { 
    5657  /*position: relative;*/ 
    57   margin: 3px; 
     58  margin:0 3px; 
    5859  border-left: 1px solid ButtonShadow; 
    5960  border-right: 1px solid ButtonHighlight; 
  • trunk/XinhaCore.js

    r766 r767  
    111111Xinha.ie_version= parseFloat(Xinha.agt.substring(Xinha.agt.indexOf("msie")+5)); 
    112112Xinha.is_opera  = (Xinha.agt.indexOf("opera") != -1); 
     113Xinha.is_khtml  = (Xinha.agt.indexOf("khtml") != -1); 
     114Xinha.is_safari  = (Xinha.agt.indexOf("safari") != -1); 
    113115Xinha.opera_version = navigator.appVersion.substring(0, navigator.appVersion.indexOf(" "))*1; 
    114116Xinha.is_mac       = (Xinha.agt.indexOf("mac") != -1); 
    115117Xinha.is_mac_ie = (Xinha.is_ie && Xinha.is_mac); 
    116118Xinha.is_win_ie = (Xinha.is_ie && !Xinha.is_mac); 
    117 Xinha.is_gecko  = (navigator.product == "Gecko"); 
     119Xinha.is_gecko  = (navigator.product == "Gecko" && !Xinha.is_safari); // Safari lies! 
    118120Xinha.isRunLocally = document.URL.toLowerCase().search(/^file:/) != -1; 
    119121Xinha.is_designMode = (typeof document.designMode != 'undefined' && !Xinha.is_ie); // IE has designMode, but we're not using it 
    120 if ( Xinha.isRunLocally ) 
     122Xinha.checkSupportedBrowser = function() 
     123{ 
     124  if ( Xinha.is_gecko ) 
     125  { 
     126    if ( navigator.productSub < 20021201 ) 
     127    { 
     128      alert("You need at least Mozilla-1.3 Alpha.\nSorry, your Gecko is not supported."); 
     129      return false; 
     130    } 
     131    if ( navigator.productSub < 20030210 ) 
     132    { 
     133      alert("Mozilla < 1.3 Beta is not supported!\nI'll try, though, but it might not work."); 
     134    } 
     135  } 
     136  if ( Xinha.is_opera ) 
     137  { 
     138    alert("Sorry, Opera is not yet supported by Xinha."); 
     139  } 
     140  return Xinha.is_gecko || (Xinha.is_opera && Xinha.opera_version >= 9.1) || Xinha.ie_version >= 5.5; 
     141}; 
     142 
     143Xinha.isSupportedBrowser = Xinha.checkSupportedBrowser(); 
     144 
     145if ( Xinha.isRunLocally && Xinha.isSupportedBrowser) 
    121146{ 
    122147  alert('Xinha *must* be installed on a web server. Locally opened files (those that use the "file://" protocol) cannot properly function. Xinha will try to initialize but may not be correctly loaded.'); 
     
    127152function Xinha(textarea, config) 
    128153{ 
     154  if ( !Xinha.isSupportedBrowser ) return; 
     155   
    129156  if ( !textarea ) 
    130157  { 
     
    132159  } 
    133160 
    134   if ( Xinha.checkSupportedBrowser() ) 
    135   { 
    136     if ( typeof config == "undefined" ) 
    137     { 
    138       this.config = new Xinha.Config(); 
    139     } 
    140     else 
    141     { 
    142       this.config = config; 
    143     } 
    144     this._htmlArea = null; 
    145  
    146     if ( typeof textarea != 'object' ) 
    147     { 
    148       textarea = Xinha.getElementById('textarea', textarea); 
    149     } 
    150     this._textArea = textarea; 
    151     this._textArea.spellcheck = false; 
    152         
    153     // Before we modify anything, get the initial textarea size 
    154     this._initial_ta_size = 
    155     { 
    156       w: textarea.style.width  ? textarea.style.width  : ( textarea.offsetWidth  ? ( textarea.offsetWidth  + 'px' ) : ( textarea.cols + 'em') ), 
    157       h: textarea.style.height ? textarea.style.height : ( textarea.offsetHeight ? ( textarea.offsetHeight + 'px' ) : ( textarea.rows + 'em') ) 
    158     }; 
    159     // Create the loading message elements 
    160     if ( this.config.showLoading ) 
    161     { 
    162       // Create and show the main loading message and the sub loading message for details of loading actions 
    163       // global element 
    164       var loading_message = document.createElement("div"); 
    165       loading_message.id = "loading_" + textarea.name; 
    166       loading_message.className = "loading"; 
    167       try 
    168       { 
    169         // how can i find the real width in pixels without % or em *and* with no visual errors ? 
    170         // for instance, a textarea with a style="width:100%" and the body padding > 0 result in a horizontal scrollingbar while loading 
    171         // A few lines above seems to indicate offsetWidth is not always set 
    172         loading_message.style.width = textarea.offsetWidth + 'px'; 
    173       } 
    174       catch (ex) 
    175       { 
    176         // offsetWidth seems not set, so let's use this._initial_ta_size.w, but sometimes it may be too huge width 
    177         loading_message.style.width = this._initial_ta_size.w; 
    178       } 
    179       loading_message.style.left = Xinha.findPosX(textarea) +  'px'; 
    180       loading_message.style.top = (Xinha.findPosY(textarea) + parseInt(this._initial_ta_size.h, 10) / 2) +  'px'; 
    181       // main static message 
    182       var loading_main = document.createElement("div"); 
    183       loading_main.className = "loading_main"; 
    184       loading_main.id = "loading_main_" + textarea.name; 
    185       loading_main.appendChild(document.createTextNode(Xinha._lc("Loading in progress. Please wait !"))); 
    186       // sub dynamic message 
    187       var loading_sub = document.createElement("div"); 
    188       loading_sub.className = "loading_sub"; 
    189       loading_sub.id = "loading_sub_" + textarea.name; 
    190       loading_sub.appendChild(document.createTextNode(Xinha._lc("Constructing main object"))); 
    191       loading_message.appendChild(loading_main); 
    192       loading_message.appendChild(loading_sub); 
    193       document.body.appendChild(loading_message); 
    194       this.setLoadingMessage("Constructing object"); 
    195     } 
    196  
    197     this._editMode = "wysiwyg"; 
    198     this.plugins = {}; 
    199     this._timerToolbar = null; 
    200     this._timerUndo = null; 
    201     this._undoQueue = [this.config.undoSteps]; 
    202     this._undoPos = -1; 
    203     this._customUndo = true; 
    204     this._mdoc = document; // cache the document, we need it in plugins 
    205     this.doctype = ''; 
    206     this.__htmlarea_id_num = __xinhas.length; 
    207     __xinhas[this.__htmlarea_id_num] = this; 
    208  
    209     this._notifyListeners = {}; 
    210  
    211     // Panels 
    212     var panels =  
    213     { 
    214       right: 
    215       { 
    216         on: true, 
    217         container: document.createElement('td'), 
    218         panels: [] 
    219       }, 
    220       left: 
    221       { 
    222         on: true, 
    223         container: document.createElement('td'), 
    224         panels: [] 
    225       }, 
    226       top: 
    227       { 
    228         on: true, 
    229         container: document.createElement('td'), 
    230         panels: [] 
    231       }, 
    232       bottom: 
    233       { 
    234         on: true, 
    235         container: document.createElement('td'), 
    236         panels: [] 
    237       } 
    238     }; 
    239  
    240     for ( var i in panels ) 
    241     { 
    242       if(!panels[i].container) { continue; } // prevent iterating over wrong type 
    243       panels[i].div = panels[i].container; // legacy 
    244       panels[i].container.className = 'panels ' + i; 
    245       Xinha.freeLater(panels[i], 'container'); 
    246       Xinha.freeLater(panels[i], 'div'); 
    247     } 
    248     // finally store the variable 
    249     this._panels = panels; 
    250  
    251     Xinha.freeLater(this, '_textArea'); 
    252   } 
     161  if ( typeof config == "undefined" ) 
     162  { 
     163    this.config = new Xinha.Config(); 
     164  } 
     165  else 
     166  { 
     167    this.config = config; 
     168  } 
     169  this._htmlArea = null; 
     170 
     171  if ( typeof textarea != 'object' ) 
     172  { 
     173    textarea = Xinha.getElementById('textarea', textarea); 
     174  } 
     175  this._textArea = textarea; 
     176  this._textArea.spellcheck = false; 
     177      
     178  // Before we modify anything, get the initial textarea size 
     179  this._initial_ta_size = 
     180  { 
     181    w: textarea.style.width  ? textarea.style.width  : ( textarea.offsetWidth  ? ( textarea.offsetWidth  + 'px' ) : ( textarea.cols + 'em') ), 
     182    h: textarea.style.height ? textarea.style.height : ( textarea.offsetHeight ? ( textarea.offsetHeight + 'px' ) : ( textarea.rows + 'em') ) 
     183  }; 
     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"); 
     220  } 
     221 
     222  this._editMode = "wysiwyg"; 
     223  this.plugins = {}; 
     224  this._timerToolbar = null; 
     225  this._timerUndo = null; 
     226  this._undoQueue = [this.config.undoSteps]; 
     227  this._undoPos = -1; 
     228  this._customUndo = true; 
     229  this._mdoc = document; // cache the document, we need it in plugins 
     230  this.doctype = ''; 
     231  this.__htmlarea_id_num = __xinhas.length; 
     232  __xinhas[this.__htmlarea_id_num] = this; 
     233 
     234  this._notifyListeners = {}; 
     235 
     236  // Panels 
     237  var panels =  
     238  { 
     239    right: 
     240    { 
     241      on: true, 
     242      container: document.createElement('td'), 
     243      panels: [] 
     244    }, 
     245    left: 
     246    { 
     247      on: true, 
     248      container: document.createElement('td'), 
     249      panels: [] 
     250    }, 
     251    top: 
     252    { 
     253      on: true, 
     254      container: document.createElement('td'), 
     255      panels: [] 
     256    }, 
     257    bottom: 
     258    { 
     259      on: true, 
     260      container: document.createElement('td'), 
     261      panels: [] 
     262    } 
     263  }; 
     264 
     265  for ( var i in panels ) 
     266  { 
     267    if(!panels[i].container) { continue; } // prevent iterating over wrong type 
     268    panels[i].div = panels[i].container; // legacy 
     269    panels[i].container.className = 'panels ' + i; 
     270    Xinha.freeLater(panels[i], 'container'); 
     271    Xinha.freeLater(panels[i], 'div'); 
     272  } 
     273  // finally store the variable 
     274  this._panels = panels; 
     275 
     276  Xinha.freeLater(this, '_textArea'); 
    253277} 
    254278 
     
    14991523Xinha.prototype.generate = function () 
    15001524{ 
     1525  if ( !Xinha.isSupportedBrowser ) return; 
     1526   
    15011527  var i; 
    15021528  var editor = this;  // we'll need "this" in some nested functions 
     
    26122638Xinha.prototype.registerPlugin = function() 
    26132639{ 
     2640  if ( !Xinha.isSupportedBrowser ) return;  
     2641   
    26142642  var plugin = arguments[0]; 
    26152643 
     
    26752703Xinha.loadPlugin = function(pluginName, callback, plugin_file) 
    26762704{ 
     2705  if ( !Xinha.isSupportedBrowser ) return; 
     2706   
    26772707  // @todo : try to avoid the use of eval() 
    26782708  // Might already be loaded 
     
    27012731Xinha.loadPlugins = function(plugins, callbackIfNotReady) 
    27022732{ 
     2733  if ( !Xinha.isSupportedBrowser ) return; 
     2734   
    27032735  // Rip the ones that are loaded and look for ones that have failed 
    27042736  var retVal = true; 
     
    43764408}; 
    43774409 
    4378 Xinha.checkSupportedBrowser = function() 
    4379 { 
    4380   if ( Xinha.is_gecko ) 
    4381   { 
    4382     if ( navigator.productSub < 20021201 ) 
    4383     { 
    4384       alert("You need at least Mozilla-1.3 Alpha.\nSorry, your Gecko is not supported."); 
    4385       return false; 
    4386     } 
    4387     if ( navigator.productSub < 20030210 ) 
    4388     { 
    4389       alert("Mozilla < 1.3 Beta is not supported!\nI'll try, though, but it might not work."); 
    4390     } 
    4391   } 
    4392   if ( Xinha.is_opera ) 
    4393   { 
    4394     alert("Sorry, Opera is not yet supported by Xinha."); 
    4395   } 
    4396   return Xinha.is_gecko || (Xinha.is_opera && Xinha.opera_version >= 9.1) || Xinha.ie_version >= 5.5; 
    4397 }; 
    4398  
    43994410// selection & ranges 
    44004411 
     
    53795390Xinha.makeEditors = function(editor_names, default_config, plugin_names) 
    53805391{ 
     5392  if ( !Xinha.isSupportedBrowser ) return; 
     5393   
    53815394  if ( typeof default_config == 'function' ) 
    53825395  { 
     
    54015414Xinha.startEditors = function(editors) 
    54025415{ 
     5416  if ( !Xinha.isSupportedBrowser ) return; 
     5417   
    54035418  for ( var i in editors ) 
    54045419  { 
     
    54125427Xinha.prototype.registerPlugins = function(plugin_names) 
    54135428{ 
     5429  if ( !Xinha.isSupportedBrowser ) return; 
     5430   
    54145431  if ( plugin_names ) 
    54155432  { 
  • trunk/plugins/Equation/example.html

    r677 r767  
    2323<pre> 
    2424 
    25   &lt;!-- This block is optional configuration --&lt; 
     25  &lt;!-- This block is optional configuration --&gt; 
    2626  &lt;script type="text/javascript"&gt; 
    2727    var mathcolor = "black"; // You may change the color of the formulae (default: red) 
     
    2929    var mathfontfamily = "Arial"; //and the font (default: serif, which is good I think) 
    3030  &lt;/script&gt; 
    31   &lt;!-- THIS LOADS THE ACTUAL SCRIPT --&lt; 
    32   &lt;script type="text/javascript" src="ASCIIMathML.js"&gt;&lt;/script&gt; 
     31  &lt;!-- THIS LOADS THE ACTUAL SCRIPT, PLEASE ADJUST THE URL --&lt; 
     32  &lt;script type="text/javascript" src="/xinha/plugins/Equation/ASCIIMathML.js"&gt;&lt;/script&gt; 
    3333 
    3434 
  • trunk/plugins/SuperClean/tidy.php

    r744 r767  
    116116    ob_end_clean(); 
    117117 
    118     if(!strlen($content)) 
     118    if(strlen($content) < 4) 
    119119    { 
    120120      // Tidy on the local machine failed, try a post 
Note: See TracChangeset for help on using the changeset viewer.