Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Abbreviation/abbreviation.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Abbreviation/Attic/abbreviation.js,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Abbreviation/abbreviation.js 25 Feb 2007 19:06:08 -0000 1.2 +++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Abbreviation/abbreviation.js 24 Nov 2007 15:35:31 -0000 1.3 @@ -1,70 +1,91 @@ -function Abbreviation(_1){ -this.editor=_1; -var _2=_1.config; -var _3=this; -_2.registerButton({id:"abbreviation",tooltip:this._lc("Abbreviation"),image:_1.imgURL("ed_abbreviation.gif","Abbreviation"),textMode:false,action:function(_4){ -_3.buttonPress(_4); -}}); -_2.addToolbarElement("abbreviation","inserthorizontalrule",1); -} -Abbreviation._pluginInfo={name:"Abbreviation",version:"1.0",developer:"Udo Schmal",developer_url:"",sponsor:"L.N.Schaffrath NeueMedien",sponsor_url:"http://www.schaffrath-neuemedien.de/",c_owner:"Udo Schmal & Schaffrath-NeueMedien",license:"htmlArea"}; -Abbreviation.prototype._lc=function(_5){ -return HTMLArea._lc(_5,"Abbreviation"); -}; -Abbreviation.prototype.onGenerate=function(){ -var _6="Abbr-style"; -var _7=this.editor._doc.getElementById(_6); -if(_7==null){ -_7=this.editor._doc.createElement("link"); -_7.id=_6; -_7.rel="stylesheet"; -_7.href=_editor_url+"plugins/Abbreviation/abbreviation.css"; -this.editor._doc.getElementsByTagName("HEAD")[0].appendChild(_7); -} -}; -Abbreviation.prototype.buttonPress=function(_8,_9,_a){ -var _b=null; -var _c=_8.getSelectedHTML(); -var _d=_8._getSelection(); -var _e=_8._createRange(_d); -var _f=_8._activeElement(_d); -if(!(_f!=null&&_f.tagName.toLowerCase()=="abbr")){ -_f=_8._getFirstAncestor(_d,"abbr"); -} -if(_f!=null&&_f.tagName.toLowerCase()=="abbr"){ -_b={title:_f.title,text:_f.innerHTML}; -}else{ -_b={title:"",text:_c}; -} -_8._popupDialog("plugin://Abbreviation/abbreviation",function(_10){ -if(_10){ -var _11=_10["title"]; -if(_11==""||_11==null){ -if(_f){ -var _12=_f.innerHTML; -_f.parentNode.removeChild(_f); -_8.insertHTML(_12); -} -return; -} -try{ -var doc=_8._doc; -if(!_f){ -_f=doc.createElement("abbr"); -_f.title=_11; -_f.innerHTML=_c; -if(HTMLArea.is_ie){ -_e.pasteHTML(_f.outerHTML); -}else{ -_8.insertNodeAtSelection(_f); -} -}else{ -_f.title=_11; -} -} -catch(e){ -} -} -},_b); -}; +// Abbreviation plugin for Xinha +// Implementation by Udo Schmal & Schaffrath NeueMedien +// Original Author - Udo Schmal +// +// (c) Udo Schmal & Schaffrath NeueMedien 2004 +// Distributed under the same terms as HTMLArea itself. +// This notice MUST stay intact for use (see license.txt). +function Abbreviation(editor) { + this.editor = editor; + var cfg = editor.config; + var self = this; + + // register the toolbar buttons provided by this plugin + cfg.registerButton({ + id : "abbreviation", + tooltip : this._lc("Abbreviation"), + image : editor.imgURL("ed_abbreviation.gif", "Abbreviation"), + textMode : false, + action : function(editor) { + self.buttonPress(editor); + } + }) + cfg.addToolbarElement("abbreviation", "inserthorizontalrule", 1); +} + +Abbreviation._pluginInfo = { + name : "Abbreviation", + version : "1.0", + developer : "Udo Schmal", + developer_url : "", + sponsor : "L.N.Schaffrath NeueMedien", + sponsor_url : "http://www.schaffrath-neuemedien.de/", + c_owner : "Udo Schmal & Schaffrath-NeueMedien", + license : "htmlArea" +}; + +Abbreviation.prototype._lc = function(string) { + return Xinha._lc(string, 'Abbreviation'); +}; + +Abbreviation.prototype.onGenerate = function() { + this.editor.addEditorStylesheet(_editor_url + 'plugins/Abbreviation/abbreviation.css'); +}; + +Abbreviation.prototype.buttonPress = function(editor, context, updatecontextclass) { + var outparam = null; + var html = editor.getSelectedHTML(); + var sel = editor._getSelection(); + var range = editor._createRange(sel); + var abbr = editor._activeElement(sel); + if(!(abbr != null && abbr.tagName.toLowerCase() == "abbr")) { + abbr = editor._getFirstAncestor(sel, 'abbr'); + } + if (abbr != null && abbr.tagName.toLowerCase() == "abbr") + outparam = { title : abbr.title, + text : abbr.innerHTML}; + else + outparam = { title : '', + text : html}; + + editor._popupDialog( "plugin://Abbreviation/abbreviation", function( param ) { + if ( param ) { + var title = param["title"]; + if (title == "" || title == null) { + if (abbr) { + var child = abbr.innerHTML; + abbr.parentNode.removeChild(abbr); + editor.insertHTML(child); + } + return; + } + try { + var doc = editor._doc; + if (!abbr) { + abbr = doc.createElement("abbr"); + abbr.title = title; + abbr.innerHTML = html; + if (Xinha.is_ie) { + range.pasteHTML(abbr.outerHTML); + } else { + editor.insertNodeAtSelection(abbr); + } + } else { + abbr.title = title; + } + } + catch (e) { } + } + }, outparam); +}; \ No newline at end of file