Changeset 1113


Ignore:
Timestamp:
11/11/08 00:24:51 (10 years ago)
Author:
ray
Message:
  • #326 make it possible to choose from different icon sets
  • #1323 allow skins to have meta information (author, etc.)
  • #1322 [SaveSubmit?] error when form action is empty
  • #1321 [SaveSubmit?] icon is in "changed" state initially
Location:
trunk
Files:
22 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r1111 r1113  
    103103{ 
    104104  _editor_skin = ""; 
     105} 
     106 
     107if ( typeof _editor_icons !== "string" ) 
     108{ 
     109  _editor_icons = ""; 
    105110} 
    106111/** 
     
    10291034  }; 
    10301035 
    1031  
    10321036   /** The button list conains the definitions of the toolbar button. Normally, there's nothing to change here :)  
    10331037   * <div style="white-space:pre">ADDING CUSTOM BUTTONS: please read below! 
     
    11051109    killword: [ "Clear MSOffice tags", ["ed_buttons_main.png",4,3], false, function(e) { e.execCommand("killword"); } ] 
    11061110  }; 
    1107  
    1108  
     1111  /** A container for additional icons that may be swapped within one button (like fullscreen) 
     1112   * @private 
     1113   */ 
     1114  this.iconList = {} 
    11091115  // initialize tooltips from the I18N module and generate correct image path 
    11101116  for ( var i in this.btnList ) 
     
    11281134 
    11291135}; 
     1136/** A plugin may require more than one icon for one button, this has to be registered in order to work with the iconsets (see FullScreen) 
     1137 *  
     1138 * @param {String} id 
     1139 * @param {String|Array} icon definition like in registerButton 
     1140 */ 
     1141Xinha.Config.prototype.registerIcon = function (id, icon) 
     1142{ 
     1143  this.iconList[id] = icon; 
     1144} 
    11301145/** ADDING CUSTOM BUTTONS 
    11311146*   --------------------- 
     
    11711186  if ( typeof id == "string" ) 
    11721187  { 
    1173     the_id = id; 
     1188    this.btnList[id] = [ tooltip, image, textMode, action, context ]; 
    11741189  } 
    11751190  else if ( typeof id == "object" ) 
    11761191  { 
    1177     the_id = id.id; 
     1192    this.btnList[id.id] = [ id.tooltip, id.image, id.textMode, id.action, id.context ]; 
    11781193  } 
    11791194  else 
     
    11811196    alert("ERROR [Xinha.Config::registerButton]:\ninvalid arguments"); 
    11821197    return false; 
    1183   } 
    1184   // check for existing id 
    1185 //  if(typeof this.customSelects[the_id] != "undefined") 
    1186 //  { 
    1187     // alert("WARNING [Xinha.Config::registerDropdown]:\nA dropdown with the same ID already exists."); 
    1188 //  } 
    1189 //  if(typeof this.btnList[the_id] != "undefined") { 
    1190     // alert("WARNING [Xinha.Config::registerDropdown]:\nA button with the same ID already exists."); 
    1191 //  } 
    1192   switch ( typeof id ) 
    1193   { 
    1194     case "string": 
    1195       this.btnList[id] = [ tooltip, image, textMode, action, context ]; 
    1196     break; 
    1197     case "object": 
    1198       this.btnList[id.id] = [ id.tooltip, id.image, id.textMode, id.action, id.context ]; 
    1199     break; 
    12001198  } 
    12011199}; 
     
    22342232  } 
    22352233  else if (!this.plugins['GetHtmlImplementation']) editor.registerPlugin('GetHtmlImplementation'); 
     2234   
     2235  if (_editor_skin) 
     2236  { 
     2237    this.skinInfo = {}; 
     2238    var skinXML = Xinha._geturlcontent(_editor_url + 'skins/' + _editor_skin + '/skin.xml', true); 
     2239    if (skinXML) 
     2240    { 
     2241      var meta = skinXML.getElementsByTagName('meta'); 
     2242      for (var i=0;i<meta.length;i++) 
     2243      { 
     2244        this.skinInfo[meta[i].getAttribute('name')] = meta[i].getAttribute('value'); 
     2245      } 
     2246      var recommendedIcons = skinXML.getElementsByTagName('recommendedIcons'); 
     2247      if (!_editor_icons && recommendedIcons.length && recommendedIcons[0].textContent) 
     2248      { 
     2249        _editor_icons = recommendedIcons[0].textContent; 
     2250      } 
     2251    } 
     2252  } 
     2253  if (_editor_icons)  
     2254  { 
     2255    var iconsXML = Xinha._geturlcontent(_editor_url + 'iconsets/' + _editor_icons + '/iconset.xml', true); 
     2256    if (iconsXML) 
     2257    { 
     2258      var icons = iconsXML.getElementsByTagName('icon'); 
     2259      var icon, id, path, type, x, y; 
     2260      function getTextContent(node) 
     2261      { 
     2262        return node.textContent || node.text; 
     2263      } 
     2264      for (var i=0;i<icons.length;i++) 
     2265      { 
     2266        icon = icons[i]; 
     2267        id = icon.getAttribute('id'); 
     2268         
     2269        if (icon.getElementsByTagName(_editor_lang).length) 
     2270        { 
     2271          icon = icon.getElementsByTagName(_editor_lang)[0]; 
     2272        } 
     2273        else 
     2274        { 
     2275          icon = icon.getElementsByTagName('default')[0]; 
     2276        } 
     2277        path = _editor_url + getTextContent(icon.getElementsByTagName('path')[0]); 
     2278        type = icon.getAttribute('type'); 
     2279        if (type == 'map') 
     2280        { 
     2281          x = parseInt(getTextContent(icon.getElementsByTagName('x')[0]), 10); 
     2282          y = parseInt(getTextContent(icon.getElementsByTagName('y')[0]), 10); 
     2283          if (this.config.btnList[id]) this.config.btnList[id][1] = [path, x, y]; 
     2284          if (this.config.iconList[id]) this.config.iconList[id] = [path, x, y]; 
     2285           
     2286        } 
     2287        else 
     2288        { 
     2289          if (this.config.btnList[id]) this.config.btnList[id][1] = path; 
     2290          if (this.config.iconList[id]) this.config.iconList[id] = path; 
     2291        } 
     2292      } 
     2293    } 
     2294  } 
    22362295   
    22372296  // create the editor framework, yah, table layout I know, but much easier 
     
    63766435 *  @param {String} url The address for the HTTPRequest 
    63776436 */ 
    6378 Xinha._geturlcontent = function(url) 
     6437Xinha._geturlcontent = function(url, returnXML) 
    63796438{ 
    63806439  var req = null; 
     
    63866445  if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status == 0 ) 
    63876446  { 
    6388     return req.responseText; 
     6447    return (returnXML) ? req.responseXML : req.responseText; 
    63896448  } 
    63906449  else 
  • trunk/modules/FullScreen/full-screen.js

    r1109 r1113  
    55  var cfg = editor.config; 
    66 
     7  cfg.registerIcon('fullscreen', [_editor_url + cfg.imgURL + 'ed_buttons_main.png',8,0]); 
     8  cfg.registerIcon('fullscreenrestore', [_editor_url + cfg.imgURL + 'ed_buttons_main.png',9,0]); 
     9   
    710  cfg.registerButton 
    811  ( 'fullscreen', 
    912    this._lc("Maximize/Minimize Editor"), 
    10     [_editor_url + cfg.imgURL + 'ed_buttons_main.png',8,0], true, 
     13    cfg.iconList.fullscreen, true, 
    1114      function(e, objname, obj) 
    1215      { 
     
    5760    e.sizeEditor(w + 'px', h + 'px',true,true); 
    5861    e._sizing = false; 
    59     if ( e._toolbarObjects.fullscreen ) e._toolbarObjects.fullscreen.swapImage([_editor_url + cfg.imgURL + 'ed_buttons_main.png',9,0]);  
     62    if ( e._toolbarObjects.fullscreen ) e._toolbarObjects.fullscreen.swapImage(cfg.iconList.fullscreenrestore);  
    6063  } 
    6164 
     
    6669    e.initSize(); 
    6770    e._sizing = false; 
    68     if ( e._toolbarObjects.fullscreen ) e._toolbarObjects.fullscreen.swapImage([_editor_url + cfg.imgURL + 'ed_buttons_main.png',8,0]);  
     71    if ( e._toolbarObjects.fullscreen ) e._toolbarObjects.fullscreen.swapImage(cfg.iconList.fullscreen);  
    6972  } 
    7073 
  • trunk/plugins/SaveSubmit/SaveSubmit.js

    r1067 r1113  
    1414        this.textarea = this.editor._textArea; 
    1515 
    16         this.image_changed = Xinha.getPluginDir("SaveSubmit")+"/img/ed_save_red.gif"; 
    17         this.image_unchanged = Xinha.getPluginDir("SaveSubmit")+"/img/ed_save_green.gif"; 
     16        cfg.registerIcon('savesubmitchanged', Xinha.getPluginDir("SaveSubmit")+"/img/ed_save_red.gif"); 
     17        cfg.registerIcon('savesubmitunchanged', Xinha.getPluginDir("SaveSubmit")+"/img/ed_save_green.gif"); 
     18 
    1819        cfg.registerButton({ 
    1920        id       : "savesubmit", 
    2021        tooltip  : self._lc("Save"), 
    21         image    : this.image_unchanged, 
     22        image    : cfg.iconList.savesubmitunchanged, 
    2223        textMode : false, 
    2324        action   :  function() { 
     
    4344} 
    4445 
    45 SaveSubmit.prototype.onGenerateOnce = function() { 
    46         this.initial_html = this.editor.getInnerHTML(); 
    47 } 
    48  
    4946SaveSubmit.prototype.onKeyPress = function(ev) { 
    5047        if ( ev.ctrlKey && this.editor.getKey(ev) == 's') { 
     
    6764} 
    6865SaveSubmit.prototype.onUpdateToolbar = function () { 
     66  if (!this.initial_html) this.initial_html = this.editor.getInnerHTML(); 
    6967        if (!this.changed) { 
    7068                if (this.getChanged()) this.setChanged(); 
     
    8179} 
    8280SaveSubmit.prototype.setChanged = function() { 
    83         this.editor._toolbarObjects.savesubmit.swapImage(this.image_changed); 
     81        this.editor._toolbarObjects.savesubmit.swapImage(this.editor.config.iconList.savesubmitchanged); 
    8482        this.editor.updateToolbar(); 
    8583} 
    8684SaveSubmit.prototype.setUnChanged = function() { 
    8785        this.changed = false; 
    88         this.editor._toolbarObjects.savesubmit.swapImage(this.image_unchanged); 
     86        this.editor._toolbarObjects.savesubmit.swapImage(this.editor.config.iconList.savesubmitunchanged); 
    8987} 
    9088SaveSubmit.prototype.changedReset = function() { 
     
    108106                content += ((i>0) ? '&' : '') + form.elements[i].name + '=' + encodeURIComponent(form.elements[i].value); 
    109107        } 
    110  
    111         Xinha._postback(editor._textArea.form.action, content, function(getback) { 
     108        var url = editor._textArea.form.action || window.location.href; 
     109        Xinha._postback(url, content, function(getback) { 
    112110 
    113111                if (getback) { 
  • trunk/plugins/SmartReplace/SmartReplace.js

    r1067 r1113  
    1515                id       : "smartreplace", 
    1616                tooltip  : this._lc("SmartReplace"), 
    17                 image    : Xinha.getPluginDir('SmartReplace')+"/img/smartquotes.gif", 
     17                image    : Xinha.getPluginDir('SmartReplace')+"/img/smartquotes.png", 
    1818                textMode : false, 
    1919                action   : function(e, objname, obj) { self.buttonPress(null, obj); } 
Note: See TracChangeset for help on using the changeset viewer.