| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,153 +0,0 @@ |
| 1 |
-tinyMCEPopup.requireLangPack(); |
|
| 2 |
- |
|
| 3 |
-var LinkDialog = {
|
|
| 4 |
- preInit : function() {
|
|
| 5 |
- var url; |
|
| 6 |
- |
|
| 7 |
- if (url = tinyMCEPopup.getParam("external_link_list_url"))
|
|
| 8 |
- document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
|
|
| 9 |
- }, |
|
| 10 |
- |
|
| 11 |
- init : function() {
|
|
| 12 |
- var f = document.forms[0], ed = tinyMCEPopup.editor; |
|
| 13 |
- |
|
| 14 |
- // Setup browse button |
|
| 15 |
- document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser', 'href', 'file', 'theme_advanced_link');
|
|
| 16 |
- if (isVisible('hrefbrowser'))
|
|
| 17 |
- document.getElementById('href').style.width = '180px';
|
|
| 18 |
- |
|
| 19 |
- this.fillClassList('class_list');
|
|
| 20 |
- this.fillFileList('link_list', 'tinyMCELinkList');
|
|
| 21 |
- this.fillTargetList('target_list');
|
|
| 22 |
- |
|
| 23 |
- if (e = ed.dom.getParent(ed.selection.getNode(), 'A')) {
|
|
| 24 |
- f.href.value = ed.dom.getAttrib(e, 'href'); |
|
| 25 |
- f.linktitle.value = ed.dom.getAttrib(e, 'title'); |
|
| 26 |
- f.insert.value = ed.getLang('update');
|
|
| 27 |
- selectByValue(f, 'link_list', f.href.value); |
|
| 28 |
- selectByValue(f, 'target_list', ed.dom.getAttrib(e, 'target')); |
|
| 29 |
- selectByValue(f, 'class_list', ed.dom.getAttrib(e, 'class')); |
|
| 30 |
- } |
|
| 31 |
- }, |
|
| 32 |
- |
|
| 33 |
- update : function() {
|
|
| 34 |
- var f = document.forms[0], ed = tinyMCEPopup.editor, e, b, href = f.href.value.replace(/ /g, '%20'); |
|
| 35 |
- |
|
| 36 |
- tinyMCEPopup.restoreSelection(); |
|
| 37 |
- e = ed.dom.getParent(ed.selection.getNode(), 'A'); |
|
| 38 |
- |
|
| 39 |
- // Remove element if there is no href |
|
| 40 |
- if (!f.href.value) {
|
|
| 41 |
- if (e) {
|
|
| 42 |
- b = ed.selection.getBookmark(); |
|
| 43 |
- ed.dom.remove(e, 1); |
|
| 44 |
- ed.selection.moveToBookmark(b); |
|
| 45 |
- tinyMCEPopup.execCommand("mceEndUndoLevel");
|
|
| 46 |
- tinyMCEPopup.close(); |
|
| 47 |
- return; |
|
| 48 |
- } |
|
| 49 |
- } |
|
| 50 |
- |
|
| 51 |
- // Create new anchor elements |
|
| 52 |
- if (e == null) {
|
|
| 53 |
- ed.getDoc().execCommand("unlink", false, null);
|
|
| 54 |
- tinyMCEPopup.execCommand("mceInsertLink", false, "#mce_temp_url#", {skip_undo : 1});
|
|
| 55 |
- |
|
| 56 |
- tinymce.each(ed.dom.select("a"), function(n) {
|
|
| 57 |
- if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
|
|
| 58 |
- e = n; |
|
| 59 |
- |
|
| 60 |
- ed.dom.setAttribs(e, {
|
|
| 61 |
- href : href, |
|
| 62 |
- title : f.linktitle.value, |
|
| 63 |
- target : f.target_list ? getSelectValue(f, "target_list") : null, |
|
| 64 |
- 'class' : f.class_list ? getSelectValue(f, "class_list") : null |
|
| 65 |
- }); |
|
| 66 |
- } |
|
| 67 |
- }); |
|
| 68 |
- } else {
|
|
| 69 |
- ed.dom.setAttribs(e, {
|
|
| 70 |
- href : href, |
|
| 71 |
- title : f.linktitle.value, |
|
| 72 |
- target : f.target_list ? getSelectValue(f, "target_list") : null, |
|
| 73 |
- 'class' : f.class_list ? getSelectValue(f, "class_list") : null |
|
| 74 |
- }); |
|
| 75 |
- } |
|
| 76 |
- |
|
| 77 |
- // Don't move caret if selection was image |
|
| 78 |
- if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') {
|
|
| 79 |
- ed.focus(); |
|
| 80 |
- ed.selection.select(e); |
|
| 81 |
- ed.selection.collapse(0); |
|
| 82 |
- tinyMCEPopup.storeSelection(); |
|
| 83 |
- } |
|
| 84 |
- |
|
| 85 |
- tinyMCEPopup.execCommand("mceEndUndoLevel");
|
|
| 86 |
- tinyMCEPopup.close(); |
|
| 87 |
- }, |
|
| 88 |
- |
|
| 89 |
- checkPrefix : function(n) {
|
|
| 90 |
- if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_email')))
|
|
| 91 |
- n.value = 'mailto:' + n.value; |
|
| 92 |
- |
|
| 93 |
- if (/^\s*www\./i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_external')))
|
|
| 94 |
- n.value = 'http://' + n.value; |
|
| 95 |
- }, |
|
| 96 |
- |
|
| 97 |
- fillFileList : function(id, l) {
|
|
| 98 |
- var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; |
|
| 99 |
- |
|
| 100 |
- l = window[l]; |
|
| 101 |
- |
|
| 102 |
- if (l && l.length > 0) {
|
|
| 103 |
- lst.options[lst.options.length] = new Option('', '');
|
|
| 104 |
- |
|
| 105 |
- tinymce.each(l, function(o) {
|
|
| 106 |
- lst.options[lst.options.length] = new Option(o[0], o[1]); |
|
| 107 |
- }); |
|
| 108 |
- } else |
|
| 109 |
- dom.remove(dom.getParent(id, 'tr')); |
|
| 110 |
- }, |
|
| 111 |
- |
|
| 112 |
- fillClassList : function(id) {
|
|
| 113 |
- var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; |
|
| 114 |
- |
|
| 115 |
- if (v = tinyMCEPopup.getParam('theme_advanced_styles')) {
|
|
| 116 |
- cl = []; |
|
| 117 |
- |
|
| 118 |
- tinymce.each(v.split(';'), function(v) {
|
|
| 119 |
- var p = v.split('=');
|
|
| 120 |
- |
|
| 121 |
- cl.push({'title' : p[0], 'class' : p[1]});
|
|
| 122 |
- }); |
|
| 123 |
- } else |
|
| 124 |
- cl = tinyMCEPopup.editor.dom.getClasses(); |
|
| 125 |
- |
|
| 126 |
- if (cl.length > 0) {
|
|
| 127 |
- lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
|
|
| 128 |
- |
|
| 129 |
- tinymce.each(cl, function(o) {
|
|
| 130 |
- lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']); |
|
| 131 |
- }); |
|
| 132 |
- } else |
|
| 133 |
- dom.remove(dom.getParent(id, 'tr')); |
|
| 134 |
- }, |
|
| 135 |
- |
|
| 136 |
- fillTargetList : function(id) {
|
|
| 137 |
- var dom = tinyMCEPopup.dom, lst = dom.get(id), v; |
|
| 138 |
- |
|
| 139 |
- lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
|
|
| 140 |
- lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_same'), '_self');
|
|
| 141 |
- lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_blank'), '_blank');
|
|
| 142 |
- |
|
| 143 |
- if (v = tinyMCEPopup.getParam('theme_advanced_link_targets')) {
|
|
| 144 |
- tinymce.each(v.split(','), function(v) {
|
|
| 145 |
- v = v.split('=');
|
|
| 146 |
- lst.options[lst.options.length] = new Option(v[0], v[1]); |
|
| 147 |
- }); |
|
| 148 |
- } |
|
| 149 |
- } |
|
| 150 |
-}; |
|
| 151 |
- |
|
| 152 |
-LinkDialog.preInit(); |
|
| 153 |
-tinyMCEPopup.onInit.add(LinkDialog.init, LinkDialog); |
| ... | ... |
@@ -1,155 +1,153 @@ |
| 1 |
-tinyMCEPopup.requireLangPack(); |
|
| 2 |
- |
|
| 3 |
-var LinkDialog = {
|
|
| 4 |
- preInit : function() {
|
|
| 5 |
- var url; |
|
| 6 |
- |
|
| 7 |
- if (url = tinyMCEPopup.getParam("external_link_list_url"))
|
|
| 8 |
- document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
|
|
| 9 |
- }, |
|
| 10 |
- |
|
| 11 |
- init : function() {
|
|
| 12 |
- var f = document.forms[0], ed = tinyMCEPopup.editor; |
|
| 13 |
- |
|
| 14 |
- // Setup browse button |
|
| 15 |
- document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser', 'href', 'file', 'theme_advanced_link');
|
|
| 16 |
- if (isVisible('hrefbrowser'))
|
|
| 17 |
- document.getElementById('href').style.width = '180px';
|
|
| 18 |
- |
|
| 19 |
- this.fillClassList('class_list');
|
|
| 20 |
- this.fillFileList('link_list', 'tinyMCELinkList');
|
|
| 21 |
- this.fillTargetList('target_list');
|
|
| 22 |
- |
|
| 23 |
- if (e = ed.dom.getParent(ed.selection.getNode(), 'A')) {
|
|
| 24 |
- f.href.value = ed.dom.getAttrib(e, 'href'); |
|
| 25 |
- f.linktitle.value = ed.dom.getAttrib(e, 'title'); |
|
| 26 |
- f.insert.value = ed.getLang('update');
|
|
| 27 |
- selectByValue(f, 'link_list', f.href.value); |
|
| 28 |
- selectByValue(f, 'target_list', ed.dom.getAttrib(e, 'target')); |
|
| 29 |
- selectByValue(f, 'class_list', ed.dom.getAttrib(e, 'class')); |
|
| 30 |
- } |
|
| 31 |
- }, |
|
| 32 |
- |
|
| 33 |
- update : function() {
|
|
| 34 |
- var f = document.forms[0], ed = tinyMCEPopup.editor, e, b; |
|
| 35 |
- |
|
| 36 |
- tinyMCEPopup.restoreSelection(); |
|
| 37 |
- e = ed.dom.getParent(ed.selection.getNode(), 'A'); |
|
| 38 |
- |
|
| 39 |
- // Remove element if there is no href |
|
| 40 |
- if (!f.href.value) {
|
|
| 41 |
- if (e) {
|
|
| 42 |
- tinyMCEPopup.execCommand("mceBeginUndoLevel");
|
|
| 43 |
- b = ed.selection.getBookmark(); |
|
| 44 |
- ed.dom.remove(e, 1); |
|
| 45 |
- ed.selection.moveToBookmark(b); |
|
| 46 |
- tinyMCEPopup.execCommand("mceEndUndoLevel");
|
|
| 47 |
- tinyMCEPopup.close(); |
|
| 48 |
- return; |
|
| 49 |
- } |
|
| 50 |
- } |
|
| 51 |
- |
|
| 52 |
- tinyMCEPopup.execCommand("mceBeginUndoLevel");
|
|
| 53 |
- |
|
| 54 |
- // Create new anchor elements |
|
| 55 |
- if (e == null) {
|
|
| 56 |
- tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
|
|
| 57 |
- |
|
| 58 |
- tinymce.each(ed.dom.select("a"), function(n) {
|
|
| 59 |
- if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
|
|
| 60 |
- e = n; |
|
| 61 |
- |
|
| 62 |
- ed.dom.setAttribs(e, {
|
|
| 63 |
- href : f.href.value, |
|
| 64 |
- title : f.linktitle.value, |
|
| 65 |
- target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null, |
|
| 66 |
- 'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null |
|
| 67 |
- }); |
|
| 68 |
- } |
|
| 69 |
- }); |
|
| 70 |
- } else {
|
|
| 71 |
- ed.dom.setAttribs(e, {
|
|
| 72 |
- href : f.href.value, |
|
| 73 |
- title : f.linktitle.value, |
|
| 74 |
- target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null, |
|
| 75 |
- 'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null |
|
| 76 |
- }); |
|
| 77 |
- } |
|
| 78 |
- |
|
| 79 |
- // Don't move caret if selection was image |
|
| 80 |
- if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') {
|
|
| 81 |
- ed.focus(); |
|
| 82 |
- ed.selection.select(e); |
|
| 83 |
- ed.selection.collapse(0); |
|
| 84 |
- tinyMCEPopup.storeSelection(); |
|
| 85 |
- } |
|
| 86 |
- |
|
| 87 |
- tinyMCEPopup.execCommand("mceEndUndoLevel");
|
|
| 88 |
- tinyMCEPopup.close(); |
|
| 89 |
- }, |
|
| 90 |
- |
|
| 91 |
- checkPrefix : function(n) {
|
|
| 92 |
- if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_email')))
|
|
| 93 |
- n.value = 'mailto:' + n.value; |
|
| 94 |
- |
|
| 95 |
- if (/^\s*www./i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_external')))
|
|
| 96 |
- n.value = 'http://' + n.value; |
|
| 97 |
- }, |
|
| 98 |
- |
|
| 99 |
- fillFileList : function(id, l) {
|
|
| 100 |
- var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; |
|
| 101 |
- |
|
| 102 |
- l = window[l]; |
|
| 103 |
- |
|
| 104 |
- if (l && l.length > 0) {
|
|
| 105 |
- lst.options[lst.options.length] = new Option('', '');
|
|
| 106 |
- |
|
| 107 |
- tinymce.each(l, function(o) {
|
|
| 108 |
- lst.options[lst.options.length] = new Option(o[0], o[1]); |
|
| 109 |
- }); |
|
| 110 |
- } else |
|
| 111 |
- dom.remove(dom.getParent(id, 'tr')); |
|
| 112 |
- }, |
|
| 113 |
- |
|
| 114 |
- fillClassList : function(id) {
|
|
| 115 |
- var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; |
|
| 116 |
- |
|
| 117 |
- if (v = tinyMCEPopup.getParam('theme_advanced_styles')) {
|
|
| 118 |
- cl = []; |
|
| 119 |
- |
|
| 120 |
- tinymce.each(v.split(';'), function(v) {
|
|
| 121 |
- var p = v.split('=');
|
|
| 122 |
- |
|
| 123 |
- cl.push({'title' : p[0], 'class' : p[1]});
|
|
| 124 |
- }); |
|
| 125 |
- } else |
|
| 126 |
- cl = tinyMCEPopup.editor.dom.getClasses(); |
|
| 127 |
- |
|
| 128 |
- if (cl.length > 0) {
|
|
| 129 |
- lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
|
|
| 130 |
- |
|
| 131 |
- tinymce.each(cl, function(o) {
|
|
| 132 |
- lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']); |
|
| 133 |
- }); |
|
| 134 |
- } else |
|
| 135 |
- dom.remove(dom.getParent(id, 'tr')); |
|
| 136 |
- }, |
|
| 137 |
- |
|
| 138 |
- fillTargetList : function(id) {
|
|
| 139 |
- var dom = tinyMCEPopup.dom, lst = dom.get(id), v; |
|
| 140 |
- |
|
| 141 |
- lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
|
|
| 142 |
- lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_same'), '_self');
|
|
| 143 |
- lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_blank'), '_blank');
|
|
| 144 |
- |
|
| 145 |
- if (v = tinyMCEPopup.getParam('theme_advanced_link_targets')) {
|
|
| 146 |
- tinymce.each(v.split(','), function(v) {
|
|
| 147 |
- v = v.split('=');
|
|
| 148 |
- lst.options[lst.options.length] = new Option(v[0], v[1]); |
|
| 149 |
- }); |
|
| 150 |
- } |
|
| 151 |
- } |
|
| 152 |
-}; |
|
| 153 |
- |
|
| 154 |
-LinkDialog.preInit(); |
|
| 155 |
-tinyMCEPopup.onInit.add(LinkDialog.init, LinkDialog); |
|
| 1 |
+tinyMCEPopup.requireLangPack(); |
|
| 2 |
+ |
|
| 3 |
+var LinkDialog = {
|
|
| 4 |
+ preInit : function() {
|
|
| 5 |
+ var url; |
|
| 6 |
+ |
|
| 7 |
+ if (url = tinyMCEPopup.getParam("external_link_list_url"))
|
|
| 8 |
+ document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
|
|
| 9 |
+ }, |
|
| 10 |
+ |
|
| 11 |
+ init : function() {
|
|
| 12 |
+ var f = document.forms[0], ed = tinyMCEPopup.editor; |
|
| 13 |
+ |
|
| 14 |
+ // Setup browse button |
|
| 15 |
+ document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser', 'href', 'file', 'theme_advanced_link');
|
|
| 16 |
+ if (isVisible('hrefbrowser'))
|
|
| 17 |
+ document.getElementById('href').style.width = '180px';
|
|
| 18 |
+ |
|
| 19 |
+ this.fillClassList('class_list');
|
|
| 20 |
+ this.fillFileList('link_list', 'tinyMCELinkList');
|
|
| 21 |
+ this.fillTargetList('target_list');
|
|
| 22 |
+ |
|
| 23 |
+ if (e = ed.dom.getParent(ed.selection.getNode(), 'A')) {
|
|
| 24 |
+ f.href.value = ed.dom.getAttrib(e, 'href'); |
|
| 25 |
+ f.linktitle.value = ed.dom.getAttrib(e, 'title'); |
|
| 26 |
+ f.insert.value = ed.getLang('update');
|
|
| 27 |
+ selectByValue(f, 'link_list', f.href.value); |
|
| 28 |
+ selectByValue(f, 'target_list', ed.dom.getAttrib(e, 'target')); |
|
| 29 |
+ selectByValue(f, 'class_list', ed.dom.getAttrib(e, 'class')); |
|
| 30 |
+ } |
|
| 31 |
+ }, |
|
| 32 |
+ |
|
| 33 |
+ update : function() {
|
|
| 34 |
+ var f = document.forms[0], ed = tinyMCEPopup.editor, e, b, href = f.href.value.replace(/ /g, '%20'); |
|
| 35 |
+ |
|
| 36 |
+ tinyMCEPopup.restoreSelection(); |
|
| 37 |
+ e = ed.dom.getParent(ed.selection.getNode(), 'A'); |
|
| 38 |
+ |
|
| 39 |
+ // Remove element if there is no href |
|
| 40 |
+ if (!f.href.value) {
|
|
| 41 |
+ if (e) {
|
|
| 42 |
+ b = ed.selection.getBookmark(); |
|
| 43 |
+ ed.dom.remove(e, 1); |
|
| 44 |
+ ed.selection.moveToBookmark(b); |
|
| 45 |
+ tinyMCEPopup.execCommand("mceEndUndoLevel");
|
|
| 46 |
+ tinyMCEPopup.close(); |
|
| 47 |
+ return; |
|
| 48 |
+ } |
|
| 49 |
+ } |
|
| 50 |
+ |
|
| 51 |
+ // Create new anchor elements |
|
| 52 |
+ if (e == null) {
|
|
| 53 |
+ ed.getDoc().execCommand("unlink", false, null);
|
|
| 54 |
+ tinyMCEPopup.execCommand("mceInsertLink", false, "#mce_temp_url#", {skip_undo : 1});
|
|
| 55 |
+ |
|
| 56 |
+ tinymce.each(ed.dom.select("a"), function(n) {
|
|
| 57 |
+ if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
|
|
| 58 |
+ e = n; |
|
| 59 |
+ |
|
| 60 |
+ ed.dom.setAttribs(e, {
|
|
| 61 |
+ href : href, |
|
| 62 |
+ title : f.linktitle.value, |
|
| 63 |
+ target : f.target_list ? getSelectValue(f, "target_list") : null, |
|
| 64 |
+ 'class' : f.class_list ? getSelectValue(f, "class_list") : null |
|
| 65 |
+ }); |
|
| 66 |
+ } |
|
| 67 |
+ }); |
|
| 68 |
+ } else {
|
|
| 69 |
+ ed.dom.setAttribs(e, {
|
|
| 70 |
+ href : href, |
|
| 71 |
+ title : f.linktitle.value, |
|
| 72 |
+ target : f.target_list ? getSelectValue(f, "target_list") : null, |
|
| 73 |
+ 'class' : f.class_list ? getSelectValue(f, "class_list") : null |
|
| 74 |
+ }); |
|
| 75 |
+ } |
|
| 76 |
+ |
|
| 77 |
+ // Don't move caret if selection was image |
|
| 78 |
+ if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') {
|
|
| 79 |
+ ed.focus(); |
|
| 80 |
+ ed.selection.select(e); |
|
| 81 |
+ ed.selection.collapse(0); |
|
| 82 |
+ tinyMCEPopup.storeSelection(); |
|
| 83 |
+ } |
|
| 84 |
+ |
|
| 85 |
+ tinyMCEPopup.execCommand("mceEndUndoLevel");
|
|
| 86 |
+ tinyMCEPopup.close(); |
|
| 87 |
+ }, |
|
| 88 |
+ |
|
| 89 |
+ checkPrefix : function(n) {
|
|
| 90 |
+ if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_email')))
|
|
| 91 |
+ n.value = 'mailto:' + n.value; |
|
| 92 |
+ |
|
| 93 |
+ if (/^\s*www\./i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_external')))
|
|
| 94 |
+ n.value = 'http://' + n.value; |
|
| 95 |
+ }, |
|
| 96 |
+ |
|
| 97 |
+ fillFileList : function(id, l) {
|
|
| 98 |
+ var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; |
|
| 99 |
+ |
|
| 100 |
+ l = window[l]; |
|
| 101 |
+ |
|
| 102 |
+ if (l && l.length > 0) {
|
|
| 103 |
+ lst.options[lst.options.length] = new Option('', '');
|
|
| 104 |
+ |
|
| 105 |
+ tinymce.each(l, function(o) {
|
|
| 106 |
+ lst.options[lst.options.length] = new Option(o[0], o[1]); |
|
| 107 |
+ }); |
|
| 108 |
+ } else |
|
| 109 |
+ dom.remove(dom.getParent(id, 'tr')); |
|
| 110 |
+ }, |
|
| 111 |
+ |
|
| 112 |
+ fillClassList : function(id) {
|
|
| 113 |
+ var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; |
|
| 114 |
+ |
|
| 115 |
+ if (v = tinyMCEPopup.getParam('theme_advanced_styles')) {
|
|
| 116 |
+ cl = []; |
|
| 117 |
+ |
|
| 118 |
+ tinymce.each(v.split(';'), function(v) {
|
|
| 119 |
+ var p = v.split('=');
|
|
| 120 |
+ |
|
| 121 |
+ cl.push({'title' : p[0], 'class' : p[1]});
|
|
| 122 |
+ }); |
|
| 123 |
+ } else |
|
| 124 |
+ cl = tinyMCEPopup.editor.dom.getClasses(); |
|
| 125 |
+ |
|
| 126 |
+ if (cl.length > 0) {
|
|
| 127 |
+ lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
|
|
| 128 |
+ |
|
| 129 |
+ tinymce.each(cl, function(o) {
|
|
| 130 |
+ lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']); |
|
| 131 |
+ }); |
|
| 132 |
+ } else |
|
| 133 |
+ dom.remove(dom.getParent(id, 'tr')); |
|
| 134 |
+ }, |
|
| 135 |
+ |
|
| 136 |
+ fillTargetList : function(id) {
|
|
| 137 |
+ var dom = tinyMCEPopup.dom, lst = dom.get(id), v; |
|
| 138 |
+ |
|
| 139 |
+ lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
|
|
| 140 |
+ lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_same'), '_self');
|
|
| 141 |
+ lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_blank'), '_blank');
|
|
| 142 |
+ |
|
| 143 |
+ if (v = tinyMCEPopup.getParam('theme_advanced_link_targets')) {
|
|
| 144 |
+ tinymce.each(v.split(','), function(v) {
|
|
| 145 |
+ v = v.split('=');
|
|
| 146 |
+ lst.options[lst.options.length] = new Option(v[0], v[1]); |
|
| 147 |
+ }); |
|
| 148 |
+ } |
|
| 149 |
+ } |
|
| 150 |
+}; |
|
| 151 |
+ |
|
| 152 |
+LinkDialog.preInit(); |
|
| 153 |
+tinyMCEPopup.onInit.add(LinkDialog.init, LinkDialog); |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,155 @@ |
| 1 |
+tinyMCEPopup.requireLangPack(); |
|
| 2 |
+ |
|
| 3 |
+var LinkDialog = {
|
|
| 4 |
+ preInit : function() {
|
|
| 5 |
+ var url; |
|
| 6 |
+ |
|
| 7 |
+ if (url = tinyMCEPopup.getParam("external_link_list_url"))
|
|
| 8 |
+ document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
|
|
| 9 |
+ }, |
|
| 10 |
+ |
|
| 11 |
+ init : function() {
|
|
| 12 |
+ var f = document.forms[0], ed = tinyMCEPopup.editor; |
|
| 13 |
+ |
|
| 14 |
+ // Setup browse button |
|
| 15 |
+ document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser', 'href', 'file', 'theme_advanced_link');
|
|
| 16 |
+ if (isVisible('hrefbrowser'))
|
|
| 17 |
+ document.getElementById('href').style.width = '180px';
|
|
| 18 |
+ |
|
| 19 |
+ this.fillClassList('class_list');
|
|
| 20 |
+ this.fillFileList('link_list', 'tinyMCELinkList');
|
|
| 21 |
+ this.fillTargetList('target_list');
|
|
| 22 |
+ |
|
| 23 |
+ if (e = ed.dom.getParent(ed.selection.getNode(), 'A')) {
|
|
| 24 |
+ f.href.value = ed.dom.getAttrib(e, 'href'); |
|
| 25 |
+ f.linktitle.value = ed.dom.getAttrib(e, 'title'); |
|
| 26 |
+ f.insert.value = ed.getLang('update');
|
|
| 27 |
+ selectByValue(f, 'link_list', f.href.value); |
|
| 28 |
+ selectByValue(f, 'target_list', ed.dom.getAttrib(e, 'target')); |
|
| 29 |
+ selectByValue(f, 'class_list', ed.dom.getAttrib(e, 'class')); |
|
| 30 |
+ } |
|
| 31 |
+ }, |
|
| 32 |
+ |
|
| 33 |
+ update : function() {
|
|
| 34 |
+ var f = document.forms[0], ed = tinyMCEPopup.editor, e, b; |
|
| 35 |
+ |
|
| 36 |
+ tinyMCEPopup.restoreSelection(); |
|
| 37 |
+ e = ed.dom.getParent(ed.selection.getNode(), 'A'); |
|
| 38 |
+ |
|
| 39 |
+ // Remove element if there is no href |
|
| 40 |
+ if (!f.href.value) {
|
|
| 41 |
+ if (e) {
|
|
| 42 |
+ tinyMCEPopup.execCommand("mceBeginUndoLevel");
|
|
| 43 |
+ b = ed.selection.getBookmark(); |
|
| 44 |
+ ed.dom.remove(e, 1); |
|
| 45 |
+ ed.selection.moveToBookmark(b); |
|
| 46 |
+ tinyMCEPopup.execCommand("mceEndUndoLevel");
|
|
| 47 |
+ tinyMCEPopup.close(); |
|
| 48 |
+ return; |
|
| 49 |
+ } |
|
| 50 |
+ } |
|
| 51 |
+ |
|
| 52 |
+ tinyMCEPopup.execCommand("mceBeginUndoLevel");
|
|
| 53 |
+ |
|
| 54 |
+ // Create new anchor elements |
|
| 55 |
+ if (e == null) {
|
|
| 56 |
+ tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
|
|
| 57 |
+ |
|
| 58 |
+ tinymce.each(ed.dom.select("a"), function(n) {
|
|
| 59 |
+ if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
|
|
| 60 |
+ e = n; |
|
| 61 |
+ |
|
| 62 |
+ ed.dom.setAttribs(e, {
|
|
| 63 |
+ href : f.href.value, |
|
| 64 |
+ title : f.linktitle.value, |
|
| 65 |
+ target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null, |
|
| 66 |
+ 'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null |
|
| 67 |
+ }); |
|
| 68 |
+ } |
|
| 69 |
+ }); |
|
| 70 |
+ } else {
|
|
| 71 |
+ ed.dom.setAttribs(e, {
|
|
| 72 |
+ href : f.href.value, |
|
| 73 |
+ title : f.linktitle.value, |
|
| 74 |
+ target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null, |
|
| 75 |
+ 'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null |
|
| 76 |
+ }); |
|
| 77 |
+ } |
|
| 78 |
+ |
|
| 79 |
+ // Don't move caret if selection was image |
|
| 80 |
+ if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') {
|
|
| 81 |
+ ed.focus(); |
|
| 82 |
+ ed.selection.select(e); |
|
| 83 |
+ ed.selection.collapse(0); |
|
| 84 |
+ tinyMCEPopup.storeSelection(); |
|
| 85 |
+ } |
|
| 86 |
+ |
|
| 87 |
+ tinyMCEPopup.execCommand("mceEndUndoLevel");
|
|
| 88 |
+ tinyMCEPopup.close(); |
|
| 89 |
+ }, |
|
| 90 |
+ |
|
| 91 |
+ checkPrefix : function(n) {
|
|
| 92 |
+ if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_email')))
|
|
| 93 |
+ n.value = 'mailto:' + n.value; |
|
| 94 |
+ |
|
| 95 |
+ if (/^\s*www./i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_external')))
|
|
| 96 |
+ n.value = 'http://' + n.value; |
|
| 97 |
+ }, |
|
| 98 |
+ |
|
| 99 |
+ fillFileList : function(id, l) {
|
|
| 100 |
+ var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; |
|
| 101 |
+ |
|
| 102 |
+ l = window[l]; |
|
| 103 |
+ |
|
| 104 |
+ if (l && l.length > 0) {
|
|
| 105 |
+ lst.options[lst.options.length] = new Option('', '');
|
|
| 106 |
+ |
|
| 107 |
+ tinymce.each(l, function(o) {
|
|
| 108 |
+ lst.options[lst.options.length] = new Option(o[0], o[1]); |
|
| 109 |
+ }); |
|
| 110 |
+ } else |
|
| 111 |
+ dom.remove(dom.getParent(id, 'tr')); |
|
| 112 |
+ }, |
|
| 113 |
+ |
|
| 114 |
+ fillClassList : function(id) {
|
|
| 115 |
+ var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; |
|
| 116 |
+ |
|
| 117 |
+ if (v = tinyMCEPopup.getParam('theme_advanced_styles')) {
|
|
| 118 |
+ cl = []; |
|
| 119 |
+ |
|
| 120 |
+ tinymce.each(v.split(';'), function(v) {
|
|
| 121 |
+ var p = v.split('=');
|
|
| 122 |
+ |
|
| 123 |
+ cl.push({'title' : p[0], 'class' : p[1]});
|
|
| 124 |
+ }); |
|
| 125 |
+ } else |
|
| 126 |
+ cl = tinyMCEPopup.editor.dom.getClasses(); |
|
| 127 |
+ |
|
| 128 |
+ if (cl.length > 0) {
|
|
| 129 |
+ lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
|
|
| 130 |
+ |
|
| 131 |
+ tinymce.each(cl, function(o) {
|
|
| 132 |
+ lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']); |
|
| 133 |
+ }); |
|
| 134 |
+ } else |
|
| 135 |
+ dom.remove(dom.getParent(id, 'tr')); |
|
| 136 |
+ }, |
|
| 137 |
+ |
|
| 138 |
+ fillTargetList : function(id) {
|
|
| 139 |
+ var dom = tinyMCEPopup.dom, lst = dom.get(id), v; |
|
| 140 |
+ |
|
| 141 |
+ lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
|
|
| 142 |
+ lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_same'), '_self');
|
|
| 143 |
+ lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_blank'), '_blank');
|
|
| 144 |
+ |
|
| 145 |
+ if (v = tinyMCEPopup.getParam('theme_advanced_link_targets')) {
|
|
| 146 |
+ tinymce.each(v.split(','), function(v) {
|
|
| 147 |
+ v = v.split('=');
|
|
| 148 |
+ lst.options[lst.options.length] = new Option(v[0], v[1]); |
|
| 149 |
+ }); |
|
| 150 |
+ } |
|
| 151 |
+ } |
|
| 152 |
+}; |
|
| 153 |
+ |
|
| 154 |
+LinkDialog.preInit(); |
|
| 155 |
+tinyMCEPopup.onInit.add(LinkDialog.init, LinkDialog); |