/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
/* This file is part of version 0.96beta2 released Fri, 20 Mar 2009 11:01:14 +0100 */
function Abbreviation(c){this.editor=c;var a=c.config;var b=this;a.registerButton({id:"abbreviation",tooltip:Xinha._lc("Abbreviation","Abbreviation"),image:c.imgURL("ed_abbreviation.gif","Abbreviation"),textMode:false,action:function(d){b.show()}});a.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.fillText=function(){var editor=this.editor;var text=this.html.toUpperCase();var abbr=Xinha.getPluginDir(this.constructor.name)+"/abbr/"+_editor_lang+".js";var abbrData=Xinha._geturlcontent(abbr);if(abbrData){eval("abbrObj = "+abbrData);if(abbrObj!=""){var dest=this.dialog.getElementById("title");dest.value=this.title||"";for(var i in abbrObj){same=(i.toUpperCase()==text);if(same){dest.value=abbrObj[i]}}}}};Abbreviation.prototype.onGenerateOnce=function(b){this.editor.addEditorStylesheet(Xinha.getPluginDir("Abbreviation")+"/abbreviation.css");this.methodsReady=true;var a=Abbreviation;Xinha._getback(Xinha.getPluginDir("Abbreviation")+"/dialog.html",function(c){a.html=c;a.dialogReady=true})};Abbreviation.prototype.OnUpdateToolbar=function(a){if(!(Abbreviation.dialogReady&&Abbreviation.methodsReady)){this.editor._toolbarObjects.Abbreviation.state("enabled",false)}else{this.onUpdateToolbar=null}};Abbreviation.prototype.prepareDialog=function(c){var a=this;var d=this.editor;var b=this.dialog=new Xinha.Dialog(d,Abbreviation.html,"Xinha",{width:260,height:140});b.getElementById("ok").onclick=function(){a.apply()};b.getElementById("delete").onclick=function(){a.ondelete()};b.getElementById("cancel").onclick=function(){a.dialog.hide()};this.dialogReady=true};Abbreviation.prototype.show=function(d){var d=this.editor;this.html=d.getSelectedHTML();if(!this.dialog){this.prepareDialog()}var b=this;var f=d._doc;var e=d._getSelection();var a=d._createRange(e);var c=d._activeElement(e);if(!(c!=null&&c.tagName.toLowerCase()=="abbr")){c=d._getFirstAncestor(e,"abbr")}this.abbr=c;if(c){this.title=c.title}this.fillText();this.dialog.getElementById("inputs").onsubmit=function(){b.apply();return false};this.dialog.show();this.dialog.getElementById("title").select()};Abbreviation.prototype.apply=function(){var c=this.editor;var f=c._doc;var a=this.abbr;var b=this.html;var h=this.dialog.hide();if(h){var g=h.title;if(g==""||g==null){if(a){var i=a.innerHTML;a.parentNode.removeChild(a);c.insertHTML(i)}return}try{if(!a){a=f.createElement("abbr");a.title=g;a.innerHTML=b;if(Xinha.is_ie){range.pasteHTML(a.outerHTML)}else{c.insertNodeAtSelection(a)}}else{a.title=g}}catch(d){}}};Abbreviation.prototype.ondelete=function(){this.dialog.getElementById("title").value="";this.apply()};