19 include_once($ROOT_PATH.
'wysiwyg_plugin.inc');
20 require_once dirname(__FILE__).
'/../../../../core/include/init.inc';
46 wysiwyg_plugin::wysiwyg_plugin($wysiwyg);
47 $this->
_add_button(
'matrixabbr',
'MatrixAbbr',
'Insert Abbreviation',
'false',
'64');
48 $this->
_add_button(
'matrixacronym',
'MatrixAcronym',
'Insert Acronym',
'false',
'66');
63 <script type=
"text/javascript" src=
"<?php echo sq_web_path('lib').'/js/general.js' ?>"></script>
64 <script type=
"text/javascript" src=
"<?php echo sq_web_path('fudge').'/var_serialise/var_serialise.js' ?>"></script>
66 <script type=
"text/javascript" language=
"Javascript">
67 var wysiwyg_editing =
true;
70 HTMLArea.prototype._matrixInsertAbbr =
function() {
74 var currArgs =
new Object();
75 currArgs[
"title"] =
"";
77 var sel = this._getSelection();
78 var range = this._createRange(sel);
79 var text_range =
false;
82 if (sel.type && sel.type.toLowerCase() ==
"control") {
83 var control_range = this._createRange(sel);
84 var text_range = this._createTextRange(sel);
85 if (text_range != null) {
87 editor.selectNodeContents(control_range(0));
89 alert(js_translate(
'object_requires_selection'));
93 sel = this._getSelection();
94 range = this._createRange(sel);
98 var current_abbr = this.getClosest(
"abbr");
100 if (HTMLArea.is_ie) {
101 inside_html = current_abbr.innerHTML;
103 this.selectNodeContents(current_abbr);
104 inside_html = editor.getSelectedHTML();
106 this.selectNodeContents(current_abbr);
108 inside_html = editor.getSelectedHTML();
111 sel = this._getSelection();
112 range = this._createRange(sel);
117 var e =
'^(<abbr [^>]+>)(.*)</abbr>$';
118 var re =
new RegExp(e,
"i");
119 var tag_html = editor.getSelectedHTML().replace(re,
"$1");
121 var re =
new RegExp(
"\n",
"gi");
122 var tag_html = tag_html.replace(re,
"");
124 currArgs[
"title"] = current_abbr.title;
126 re =
new RegExp(
'if \\(!window\\.wysiwyg_editing\\)[\\s]+\\{[\\s]+window\\.open\\([\'"]([^\'"]+)[\'"], [\'"][0-9]+[\'"], [\'"]([^\'"]+)[\'"]\\);',
"gi");
127 results = re.exec(tag_html);
129 if (results != null) {
130 currArgs[
"title"] = results[1];
136 var para_html = inside_html.replace(/(<\/?)P/gi,
"$1p");
140 if (para_html.indexOf(
"<p") > -1) {
145 if (para_html.indexOf(
"<p") != para_html.lastIndexOf(
"<p")) {
146 alert(js_translate(
'select_one_paragraph_at_a_time'));
155 if (this._inPopup ==
true) { in_popup =
'1'; }
157 editor_<?php echo $this->
wysiwyg->name?>._object =
this;
158 var strPage =
"<?php echo $this->get_popup_href('insert_abbr.php')?>?&title=" + escape(currArgs[
"title"]) +
"&abbr=" + escape(inside_html) +
"&editor_name=" + escape(
"<?php echo $this->wysiwyg->name; ?>") +
"&in_popup=" + escape(in_popup);
160 var popup_width = 410;
163 if (HTMLArea.is_safari) popup_width += 15;
165 this._popupDialog(
"matrixInsertAbbr", strPage, popup_width, 210,
true,
function(param) {
171 if (param[
"title"] !=
"") {
173 if (param[
"abbr"] != inside_html) { inside_html = param[
"abbr"]; }
175 var html =
'<abbr title="' + param[
"title"] +
'">' + inside_html +
'</abbr>';
179 current_abbr.title = param[
"title"];
180 current_abbr.innerHTML = inside_html;
182 if (HTMLArea.is_gecko) {
183 editor.insertHTML(html, range);
184 }
else if (HTMLArea.is_ie) {
185 range.pasteHTML(html);
197 HTMLArea.prototype._matrixInsertAcronym =
function() {
201 var currArgs =
new Object();
202 currArgs[
"title"] =
"";
204 var sel = this._getSelection();
205 var range = this._createRange(sel);
206 var text_range =
false;
209 if (sel.type && sel.type.toLowerCase() ==
"control") {
210 var control_range = this._createRange(sel);
211 var text_range = this._createTextRange(sel);
212 if (text_range != null) {
214 editor.selectNodeContents(control_range(0));
216 alert(js_translate(
'object_requires_selection'));
220 sel = this._getSelection();
221 range = this._createRange(sel);
224 var inside_html =
'';
225 var current_acronym = this.getClosest(
"acronym");
226 if (current_acronym) {
227 if (HTMLArea.is_ie) {
228 inside_html = current_acronym.innerHTML;
230 this.selectNodeContents(current_acronym);
231 inside_html = editor.getSelectedHTML();
233 this.selectNodeContents(current_acronym);
235 inside_html = editor.getSelectedHTML();
238 sel = this._getSelection();
239 range = this._createRange(sel);
242 if (current_acronym) {
244 var e =
'^(<acronym [^>]+>)(.*)</acronym>$';
245 var re =
new RegExp(e,
"i");
246 var tag_html = editor.getSelectedHTML().replace(re,
"$1");
248 var re =
new RegExp(
"\n",
"gi");
249 var tag_html = tag_html.replace(re,
"");
251 currArgs[
"title"] = current_acronym.title;
253 re =
new RegExp(
'if \\(!window\\.wysiwyg_editing\\)[\\s]+\\{[\\s]+window\\.open\\([\'"]([^\'"]+)[\'"], [\'"][0-9]+[\'"], [\'"]([^\'"]+)[\'"]\\);',
"gi");
254 results = re.exec(tag_html);
256 if (results != null) {
257 currArgs[
"title"] = results[1];
263 var para_html = inside_html.replace(/(<\/?)P/gi,
"$1p");
267 if (para_html.indexOf(
"<p") > -1) {
272 if (para_html.indexOf(
"<p") != para_html.lastIndexOf(
"<p")) {
273 alert(
"Please select only one paragraph to link at a time.");
282 if (this._inPopup ==
true) { in_popup =
'1'; }
284 editor_<?php echo $this->
wysiwyg->name?>._object =
this;
285 var strPage =
"<?php echo $this->get_popup_href('insert_acronym.php')?>?&title=" + escape(currArgs[
"title"]) +
"&acronym=" + escape(inside_html) +
"&editor_name=" + escape(
"<?php echo $this->wysiwyg->name; ?>") +
"&in_popup=" + escape(in_popup);
287 var popup_width = 410;
290 if (HTMLArea.is_safari) popup_width += 15;
292 this._popupDialog(
"matrixInsertAcronym", strPage, popup_width, 210,
true,
function(param) {
298 if (param[
"title"] !=
"") {
300 if (param[
"acronym"] != inside_html) { inside_html = param[
"acronym"]; }
302 var html =
'<acronym title="' + param[
"title"] +
'">' + inside_html +
'</acronym>';
305 if (current_acronym) {
306 current_acronym.title = param[
"title"];
307 current_acronym.innerHTML = inside_html;
309 editor.insertHTML(html, range);
329 function print_plugin_button_click()
333 this._matrixInsertAbbr();
335 case "matrixacronym":
336 this._matrixInsertAcronym();
349 function print_plugin_update_toolbar()
353 if (allEnabled == null && this._tmp[
'disable_toolbar'] ==
true) {
354 this.updateToolbar(
false);
358 case "matrixacronym":
359 if (allEnabled == null && this._tmp[
'disable_toolbar'] ==
true) {
360 this.updateToolbar(
false);