| 38 | | Abbreviation.prototype._lc = function(string) { |
| 39 | | return Xinha._lc(string, 'Abbreviation'); |
| | 38 | // Fills in the text field if the acronym is either known (i.e., in the [lang].js file) |
| | 39 | // or if we're editing an existing abbreviation. |
| | 40 | Abbreviation.prototype.fillText = function() { |
| | 41 | var editor = this.editor; |
| | 42 | var text = this.html.toUpperCase(); |
| | 43 | var abbr = Xinha.getPluginDir(this.constructor.name) + "/abbr/" + _editor_lang + ".js"; |
| | 44 | var abbrData = Xinha._geturlcontent(abbr); |
| | 45 | |
| | 46 | if (abbrData) { |
| | 47 | eval('abbrObj = ' + abbrData); |
| | 48 | if (abbrObj != "") { |
| | 49 | var dest = this.dialog.getElementById("title"); |
| | 50 | dest.value = this.title || ""; |
| | 51 | for (var i in abbrObj) { |
| | 52 | same = (i.toUpperCase()==text); |
| | 53 | if (same) |
| | 54 | dest.value = abbrObj[i]; |
| | 55 | } |
| | 56 | } |
| | 57 | } |
| | 58 | } |
| | 59 | |
| | 60 | Abbreviation.prototype.onGenerateOnce = function(editor) { |
| | 61 | this.editor.addEditorStylesheet(Xinha.getPluginDir('Abbreviation') + '/abbreviation.css'); |
| | 62 | this.methodsReady = true; //remove this? |
| | 63 | var self = Abbreviation; |
| | 64 | Xinha._getback(Xinha.getPluginDir('Abbreviation') + '/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; }); |
| 46 | | Abbreviation.prototype.buttonPress = function(editor, context, updatecontextclass) { |
| 47 | | var outparam = null; |
| 48 | | var html = editor.getSelectedHTML(); |
| | 75 | Abbreviation.prototype.prepareDialog = function(html) { |
| | 76 | var self = this; |
| | 77 | var editor = this.editor; |
| | 78 | var dialog = this.dialog = new Xinha.Dialog(editor, Abbreviation.html, 'Xinha', {width: 260, height:140}); |
| | 79 | |
| | 80 | dialog.getElementById('ok').onclick = function() { self.apply(); }; |
| | 81 | dialog.getElementById('delete').onclick = function() { self.ondelete(); }; |
| | 82 | dialog.getElementById('cancel').onclick = function() { self.dialog.hide(); }; |
| | 83 | |
| | 84 | this.dialogReady = true; |
| | 85 | } |
| | 86 | |
| | 87 | Abbreviation.prototype.show = function(editor) { |
| | 88 | var editor = this.editor; |
| | 89 | this.html = editor.getSelectedHTML(); |
| | 90 | if (!this.dialog) this.prepareDialog(); |
| | 91 | var self = this; |
| | 92 | var doc = editor._doc; |
| 62 | | editor._popupDialog( "plugin://Abbreviation/abbreviation", function( param ) { |
| 63 | | if ( param ) { |
| 64 | | var title = param["title"]; |
| 65 | | if (title == "" || title == null) { |
| 66 | | if (abbr) { |
| 67 | | var child = abbr.innerHTML; |
| 68 | | abbr.parentNode.removeChild(abbr); |
| 69 | | editor.insertHTML(child); |
| | 105 | this.dialog.getElementById("inputs").onsubmit = function() { |
| | 106 | self.apply(); |
| | 107 | return false; |
| | 108 | } |
| | 109 | |
| | 110 | this.dialog.show(); |
| | 111 | this.dialog.getElementById("title").select(); |
| | 112 | } |
| | 113 | |
| | 114 | Abbreviation.prototype.apply = function() { |
| | 115 | var editor = this.editor; |
| | 116 | var doc = editor._doc; |
| | 117 | var abbr = this.abbr; |
| | 118 | var html = this.html; |
| | 119 | var param = this.dialog.hide(); |
| | 120 | |
| | 121 | if ( param ) { |
| | 122 | var title = param["title"]; |
| | 123 | if (title == "" || title == null) { |
| | 124 | if (abbr) { |
| | 125 | var child = abbr.innerHTML; |
| | 126 | abbr.parentNode.removeChild(abbr); |
| | 127 | editor.insertHTML(child); // FIX: This doesn't work in Safari 3 |
| | 128 | } |
| | 129 | return; |
| | 130 | } |
| | 131 | try { |
| | 132 | if (!abbr) { |
| | 133 | abbr = doc.createElement("abbr"); |
| | 134 | abbr.title = title; |
| | 135 | abbr.innerHTML = html; |
| | 136 | if (Xinha.is_ie) { |
| | 137 | range.pasteHTML(abbr.outerHTML); |
| | 138 | } else { |
| | 139 | editor.insertNodeAtSelection(abbr); |