19 include_once($ROOT_PATH.
'wysiwyg_plugin.inc');
20 require_once dirname(__FILE__).
'/../../../../core/include/init.inc';
47 wysiwyg_plugin::wysiwyg_plugin($wysiwyg);
48 $this->
_add_button(
'matrixcreateanchor',
'MatrixCreateAnchor',translate(
'insert_anchor'),
'false',
'30');
64 <script type=
"text/javascript" src=
"<?php echo sq_web_path('lib').'/js/general.js' ?>"></script>
65 <script type=
"text/javascript" src=
"<?php echo sq_web_path('fudge').'/var_serialise/var_serialise.js' ?>"></script>
67 <script type=
"text/javascript" language=
"Javascript">
68 var wysiwyg_editing =
true;
71 HTMLArea.prototype._matrixInsertAnchor =
function() {
75 var currArgs =
new Object();
76 currArgs[
"name"] =
"";
78 var sel = this._getSelection();
79 var range = this._createRange(sel);
80 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_a = this.getClosest(
"a");
100 if (HTMLArea.is_ie) {
101 inside_html = current_a.innerHTML;
103 this.selectNodeContents(current_a);
104 inside_html = editor.getSelectedHTML();
107 inside_html = editor.getSelectedHTML();
109 sel = this._getSelection();
110 range = this._createRange(sel);
114 if (typeof(visual_aid_mode) !=
'undefined' && visual_aid_mode) {
117 var copied_html = current_a.innerHTML;
118 if (HTMLArea.is_gecko) {
119 current_a.innerHTML = current_a.innerHTML.replace(/<span
id=
"wysiwyg-visual-aid-plugin-anchor"[^>]*>A[^>]*<\/span>/,
"");
120 }
else if (HTMLArea.is_ie) {
121 var e =
'<span id=wysiwyg-visual-aid-plugin-anchor[^>]*>A[^>]*<\/span>';
122 var re =
new RegExp(e,
"ig");
123 current_a.innerHTML = current_a.innerHTML.replace(re,
'');
127 var e =
'^(<a [^>]+>)(.*)</a>$';
128 var re =
new RegExp(e,
"i");
129 var tag_html = editor.getSelectedHTML().replace(re,
"$1");
131 var re =
new RegExp(
"\n",
"gi");
132 var tag_html = tag_html.replace(re,
"");
134 currArgs[
"name"] = current_a.name;
136 re =
new RegExp(
'if \\(!window\\.wysiwyg_editing\\)[\\s]+\\{[\\s]+window\\.open\\([\'"]([^\'"]+)[\'"], [\'"][0-9]+[\'"], [\'"]([^\'"]+)[\'"]\\);',
"gi");
137 results = re.exec(tag_html);
139 if (results != null) {
140 currArgs[
"name"] = results[1];
147 var para_html = inside_html.replace(/(<\/?)P/gi,
"$1p");
151 if (para_html.indexOf(
"<p") > -1) {
156 if (para_html.indexOf(
"<p") != para_html.lastIndexOf(
"<p")) {
157 alert(
"Please select only one paragraph to link at a time.");
166 if (this._inPopup ==
true) { in_popup =
'1'; }
168 editor_<?php echo $this->
wysiwyg->name?>._object =
this;
169 var strPage =
"<?php echo $this->get_popup_href('insert_anchor.php')?>?&name=" + escape(currArgs[
"name"]) +
"&editor_name=" + escape(
"<?php echo $this->wysiwyg->name; ?>") +
"&in_popup=" + escape(in_popup);
171 this._popupDialog(
"matrixInsertAnchor", strPage, 480, 300,
true,
function(param) {
175 if (typeof(visual_aid_mode) !=
'undefined' && visual_aid_mode) {
176 if (current_a != null) {
177 current_a.innerHTML = copied_html;
183 if (param[
"remove"] ==
"1") {
184 if (current_a != null) {
186 var current_html = current_a.innerHTML;
187 var anchor_inner_html = current_html;
190 if (typeof(visual_aid_mode) !=
'undefined' && visual_aid_mode) {
191 if (HTMLArea.is_gecko) {
192 current_html = current_html.replace(/\(/,
"\\\(");
193 current_html = current_html.replace(/\)/,
"\\\)");
196 anchor_inner_html = anchor_inner_html.replace(/<span
id=
"wysiwyg-visual-aid-plugin-anchor".*<\/span>/,
'');
197 }
else if (HTMLArea.is_ie) {
198 var re =
new RegExp(
"\\(",
"ig");
199 current_html = current_html.replace(re,
"\\\(");
201 re =
new RegExp(
"\\)",
"ig");
202 current_html = current_html.replace(re,
"\\\)");
204 re =
new RegExp(
"<span id=wysiwyg-visual-aid-plugin-anchor.*<\/span>",
"ig");
205 anchor_inner_html = anchor_inner_html.replace(re,
'');
209 var parent = current_a.parentNode;
210 if (HTMLArea.is_gecko) {
211 var e =
'(<a.*name="' + param[
"name"] +
'"[^>]*>)' + current_html +
'</a>';
212 }
else if (HTMLArea.is_ie) {
213 var e =
'(<a.*name="?' + param[
"name"] +
'"?[^>]*>)' + current_html +
'</a>';
215 var re =
new RegExp(e,
"ig");
216 var new_html = parent.innerHTML.replace(re, anchor_inner_html);
217 parent.innerHTML = new_html;
220 var visual_aid_tag =
"";
221 var visual_aid_style =
'padding-left: 1px; padding-right: 1px; padding-top: 1px; padding-bottom: 1px; background-color : #37DF5E; font: 10px Verdana,Tahoma,sans-serif; font-weight: bold; border-left: 1px solid; border-right: 1px solid; border-top: 1px solid; border-bottom: 1px solid;';
223 if (param[
"name"] !=
"") {
224 if (typeof(visual_aid_mode) !=
'undefined' && visual_aid_mode) {
225 visual_aid_tag =
'<span id="wysiwyg-visual-aid-plugin-anchor" style="' + visual_aid_style +
'">A "' + param[
"name"] +
'"</span>';
229 if (param[
"name"] != current_a.getAttribute(
"name")) {
230 if (HTMLArea.is_gecko) {
231 current_a.setAttribute(
"name", param[
"name"]);
232 current_a.setAttribute(
"id", param[
"name"]);
233 current_a.innerHTML = visual_aid_tag + current_a.innerHTML;
234 }
else if (HTMLArea.is_ie) {
239 var e =
'<A( id="?' + current_a.getAttribute(
"name") +
'"?){0,1} name="?' + current_a.getAttribute(
"name") +
'"?>';
240 var re =
new RegExp(e,
"gi");
241 var replacement =
'<A id="' + param[
"name"] +
'" name="' + param[
"name"] +
'">' + visual_aid_tag;
242 current_a.parentNode.innerHTML = current_a.parentNode.innerHTML.replace(re, replacement);
247 var para =
new RegExp(
"^[\n\t\s]*<P[^>]*>(.*)<\/P>",
"gim")
248 var insideP = inside_html.replace(para,
"$1");
249 if (insideP != inside_html) {
250 var html =
'<p><a name="' + param[
"name"] +
'" id="' + param[
"name"];
251 html +=
'">' + visual_aid_tag + insideP +
'</a></p>';
253 var html =
'<a name="' + param[
"name"] +
'" id="' + param[
"name"];
254 html +=
'">' + visual_aid_tag + inside_html +
'</a>';
258 html = editor.make_absolute_urls(html);
259 editor.insertHTML(html, range);
265 if (HTMLArea.is_ie) {
266 range.execCommand(
"Unselect");
268 sel.removeAllRanges();
286 function print_plugin_button_click()
289 case "matrixcreateanchor":
290 this._matrixInsertAnchor();
303 function print_plugin_update_toolbar()
306 case "matrixcreateanchor":
307 if (allEnabled == null && this._tmp[
'disable_toolbar'] ==
true) {
308 this.updateToolbar(
false);