Advertisement
eaposztrof

fckeditor "rel tag for links" hack

Oct 17th, 2012
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. # fckeditor "rel tag for links" hack by eaposztrof - iCode4Beer.com project
  3. aply to the following file: ckeditor/plugins/link/dialogs/link.js
  4. and you have beautiful rel adding <select> on the Create Link dialog.
  5.  
  6. +   115                H('advRel', 'rel');
  7. +   248                        id: 'advRel',
  8.                         type: 'select',
  9.                         label: 'The rel attribute specifies the relationship between the current document and the linked document.',
  10.                         'default': 'alternate',
  11.                         style: 'width : 100%;',
  12.                         items: [
  13.                             ['Links to an alternate version of the document (i.e. print page, translated or mirror)','alternate'],
  14.                             ['Links to the author of the document','author'],
  15.                             ['Permanent URL used for bookmarking', 'bookmark'],
  16.                             ['Links to a help document', 'help'],
  17.                             ['Links to copyright information for the document','license'],
  18.                             ['Links to an unendorsed document, like a paid link.','nofollow'],
  19.                             ['Specifies that the browser should not send a HTTP referer header if the user follows the hyperlink','noreferrer'],
  20.                             ['Specifies that the target document should be cached','prefetch'],
  21.                             ['Links to a search tool for the document','search'],
  22.                             ['The previous document in a selection','prev'],
  23.                             ['The next document in a selection', 'next'],
  24.                             ['A tag (keyword) for the current document', 'tag']
  25.                         ],
  26.                         setup: o,
  27.                         commit: r
  28.                 }, {
  29. +   783                L('advRel', 'rel');
  30.  
  31. */
  32. CKEDITOR.dialog.add('link', function (a) {
  33.     var b = function () {
  34.         var s = this.getDialog(),
  35.             t = s.getContentElement('target', 'popupFeatures'),
  36.             u = s.getContentElement('target', 'linkTargetName'),
  37.             v = this.getValue();
  38.         if (!t || !u) return;
  39.         t = t.getElement();
  40.         if (v == 'popup') {
  41.             t.show();
  42.             u.setLabel(a.lang.link.targetPopupName);
  43.         } else {
  44.             t.hide();
  45.             u.setLabel(a.lang.link.targetFrameName);
  46.             this.getDialog().setValueOf('target', 'linkTargetName', v.charAt(0) == '_' ? v : '');
  47.         }
  48.     }, c = function () {
  49.         var s = this.getDialog(),
  50.             t = ['urlOptions', 'anchorOptions', 'emailOptions'],
  51.             u = this.getValue(),
  52.             v = s.definition.getContents('upload').hidden;
  53.         if (u == 'url') {
  54.             if (a.config.linkShowTargetTab) s.showPage('target');
  55.             if (!v) s.showPage('upload');
  56.         } else {
  57.             s.hidePage('target');
  58.             if (!v) s.hidePage('upload');
  59.         }
  60.         for (var w = 0; w < t.length; w++) {
  61.             var x = s.getContentElement('info', t[w]);
  62.             if (!x) continue;
  63.             x = x.getElement().getParent().getParent();
  64.             if (t[w] == u + 'Options') x.show();
  65.             else x.hide();
  66.         }
  67.     }, d = /^mailto:([^?]+)(?:\?(.+))?$/,
  68.         e = /subject=([^;?:@&=$,\/]*)/,
  69.         f = /body=([^;?:@&=$,\/]*)/,
  70.         g = /^#(.*)$/,
  71.         h = /^((?:http|https|ftp|news):\/\/)?(.*)$/,
  72.         i = /^(_(?:self|top|parent|blank))$/,
  73.         j = /\s*window.open\(\s*this\.href\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*;\s*return\s*false;*\s*/,
  74.         k = /(?:^|,)([^=]+)=(\d+|yes|no)/gi,
  75.         l = function (s, t) {
  76.             var u = t ? t.getAttribute('_cke_saved_href') || t.getAttribute('href') : '',
  77.                 v = '',
  78.                 w = '',
  79.                 x = false,
  80.                 y = {};
  81.             if (u) {
  82.                 v = u.match(d);
  83.                 w = u.match(g);
  84.                 x = u.match(h);
  85.             }
  86.             if (v) {
  87.                 var z = u.match(e),
  88.                     A = u.match(f);
  89.                 y.type = 'email';
  90.                 y.email = {};
  91.                 y.email.address = v[1];
  92.                 z && (y.email.subject = decodeURIComponent(z[1]));
  93.                 A && (y.email.body = decodeURIComponent(A[1]));
  94.             } else if (w) {
  95.                 y.type = 'anchor';
  96.                 y.anchor = {};
  97.                 y.anchor.name = y.anchor.id = w[1];
  98.             } else if (u && x) {
  99.                 y.type = 'url';
  100.                 y.url = {};
  101.                 y.url.protocol = x[1];
  102.                 y.url.url = x[2];
  103.             } else y.type = 'url';
  104.             if (t) {
  105.                 var B = t.getAttribute('target');
  106.                 y.target = {};
  107.                 y.adv = {};
  108.                 if (!B) {
  109.                     var C = t.getAttribute('_cke_pa_onclick') || t.getAttribute('onclick'),
  110.                         D = C && C.match(j);
  111.                     if (D) {
  112.                         y.target.type = 'popup';
  113.                         y.target.name = D[1];
  114.                         var E;
  115.                         while (E = k.exec(D[2])) if (E[2] == 'yes' || E[2] == '1') y.target[E[1]] = true;
  116.                         else if (isFinite(E[2])) y.target[E[1]] = E[2];
  117.                     }
  118.                 } else {
  119.                     var F = B.match(i);
  120.                     if (F) y.target.type = y.target.name = B;
  121.                     else {
  122.                         y.target.type = 'frame';
  123.                         y.target.name = B;
  124.                     }
  125.                 }
  126.                 var G = this,
  127.                     H = function (N, O) {
  128.                         var P = t.getAttribute(O);
  129.                         if (P !== null) y.adv[N] = P || '';
  130.                     };
  131.                 H('advId', 'id');
  132.                 H('advLangDir', 'dir');
  133.                 H('advAccessKey', 'accessKey');
  134.                 H('advName', 'name');
  135.                 H('advLangCode', 'lang');
  136.                 H('advTabIndex', 'tabindex');
  137.                 H('advTitle', 'title');
  138.                 H('advContentType', 'type');
  139.                 H('advCSSClasses', 'class');
  140.                 H('advCharset', 'charset');
  141.                 H('advStyles', 'style');
  142.                 H('advRel', 'rel');
  143.             }
  144.             var I = s.document.getElementsByTag('img'),
  145.                 J = new CKEDITOR.dom.nodeList(s.document.$.anchors),
  146.                 K = y.anchors = [];
  147.             for (var L = 0; L < I.count(); L++) {
  148.                 var M = I.getItem(L);
  149.                 if (M.getAttribute('_cke_realelement') && M.getAttribute('_cke_real_element_type') == 'anchor') K.push(s.restoreRealElement(M));
  150.             }
  151.             for (L = 0; L < J.count(); L++) K.push(J.getItem(L));
  152.             for (L = 0; L < K.length; L++) {
  153.                 M = K[L];
  154.                 K[L] = {
  155.                     name: M.getAttribute('name'),
  156.                     id: M.getAttribute('id')
  157.                 };
  158.             }
  159.             this._.selectedElement = t;
  160.             return y;
  161.         }, m = function (s, t) {
  162.             if (t[s]) this.setValue(t[s][this.id] || '');
  163.         }, n = function (s) {
  164.             return m.call(this, 'target', s);
  165.         }, o = function (s) {
  166.             return m.call(this, 'adv', s);
  167.         }, p = function (s, t) {
  168.             if (!t[s]) t[s] = {};
  169.             t[s][this.id] = this.getValue() || '';
  170.         }, q = function (s) {
  171.             return p.call(this, 'target', s);
  172.         }, r = function (s) {
  173.             return p.call(this, 'adv', s);
  174.         };
  175.     return {
  176.         title: a.lang.link.title,
  177.         minWidth: 350,
  178.         minHeight: 230,
  179.         contents: [{
  180.             id: 'info',
  181.             label: a.lang.link.info,
  182.             title: a.lang.link.info,
  183.             elements: [{
  184.                 id: 'linkType',
  185.                 type: 'select',
  186.                 label: a.lang.link.type,
  187.                 'default': 'url',
  188.                 items: [
  189.                     [a.lang.common.url, 'url'],
  190.                     [a.lang.link.toAnchor, 'anchor'],
  191.                     [a.lang.link.toEmail, 'email']
  192.                 ],
  193.                 onChange: c,
  194.                 setup: function (s) {
  195.                     if (s.type) this.setValue(s.type);
  196.                 },
  197.                 commit: function (s) {
  198.                     s.type = this.getValue();
  199.                 }
  200.             }, {
  201.                 type: 'vbox',
  202.                 id: 'urlOptions',
  203.                 children: [{
  204.                     type: 'hbox',
  205.                     widths: ['25%', '75%'],
  206.                     children: [{
  207.                         id: 'protocol',
  208.                         type: 'select',
  209.                         label: a.lang.common.protocol,
  210.                         'default': 'http://',
  211.                         style: 'width : 100%;',
  212.                         items: [
  213.                             ['http://'],
  214.                             ['https://'],
  215.                             ['ftp://'],
  216.                             ['news://'],
  217.                             ['<other>', '']
  218.                         ],
  219.                         setup: function (s) {
  220.                             if (s.url) this.setValue(s.url.protocol);
  221.                         },
  222.                         commit: function (s) {
  223.                             if (!s.url) s.url = {};
  224.                             s.url.protocol = this.getValue();
  225.                         }
  226.                     }, {
  227.                         type: 'text',
  228.                         id: 'url',
  229.                         label: a.lang.common.url,
  230.                         onLoad: function () {
  231.                             this.allowOnChange = true;
  232.                         },
  233.                         onKeyUp: function () {
  234.                             var x = this;
  235.                             x.allowOnChange = false;
  236.                             var s = x.getDialog().getContentElement('info', 'protocol'),
  237.                                 t = x.getValue(),
  238.                                 u = /^(http|https|ftp|news):\/\/(?=.)/gi,
  239.                                 v = /^((javascript:)|[#\/\.])/gi,
  240.                                 w = u.exec(t);
  241.                             if (w) {
  242.                                 x.setValue(t.substr(w[0].length));
  243.                                 s.setValue(w[0].toLowerCase());
  244.                             } else if (v.test(t)) s.setValue('');
  245.                             x.allowOnChange = true;
  246.                         },
  247.                         onChange: function () {
  248.                             if (this.allowOnChange) this.onKeyUp();
  249.                         },
  250.                         validate: function () {
  251.                             var s = this.getDialog();
  252.                             if (s.getContentElement('info', 'linkType') && s.getValueOf('info', 'linkType') != 'url') return true;
  253.                             if (this.getDialog().fakeObj) return true;
  254.                             var t = CKEDITOR.dialog.validate.notEmpty(a.lang.link.noUrl);
  255.                             return t.apply(this);
  256.                         },
  257.                         setup: function (s) {
  258.                             var u = this;
  259.                             u.allowOnChange = false;
  260.                             if (s.url) u.setValue(s.url.url);
  261.                             u.allowOnChange = true;
  262.                             var t = u.getDialog().getContentElement('info', 'linkType');
  263.                             if (t && t.getValue() == 'url') u.select();
  264.                         },
  265.                         commit: function (s) {
  266.                             if (!s.url) s.url = {};
  267.                             s.url.url = this.getValue();
  268.                             this.allowOnChange = false;
  269.                         }
  270.                     }],
  271.                     setup: function (s) {
  272.                         if (!this.getDialog().getContentElement('info', 'linkType')) this.getElement().show();
  273.                     }
  274.                 }, {
  275.                         id: 'advRel',
  276.                         type: 'select',
  277.                         label: 'The rel attribute specifies the relationship between the current document and the linked document.',
  278.                         'default': 'alternate',
  279.                         style: 'width : 100%;',
  280.                         items: [
  281.                             ['Links to an alternate version of the document (i.e. print page, translated or mirror)','alternate'],
  282.                             ['Links to the author of the document','author'],
  283.                             ['Permanent URL used for bookmarking', 'bookmark'],
  284.                             ['Links to a help document', 'help'],
  285.                             ['Links to copyright information for the document','license'],
  286.                             ['Links to an unendorsed document, like a paid link.','nofollow'],
  287.                             ['Specifies that the browser should not send a HTTP referer header if the user follows the hyperlink','noreferrer'],
  288.                             ['Specifies that the target document should be cached','prefetch'],
  289.                             ['Links to a search tool for the document','search'],
  290.                             ['The previous document in a selection','prev'],
  291.                             ['The next document in a selection', 'next'],
  292.                             ['A tag (keyword) for the current document', 'tag']
  293.                         ],
  294.                         setup: o,
  295.                         commit: r
  296.                 }, {
  297.                     type: 'button',
  298.                     id: 'browse',
  299.                     hidden: 'true',
  300.                     filebrowser: 'info:url',
  301.                     label: a.lang.common.browseServer
  302.                 }]
  303.             }, {
  304.                 type: 'vbox',
  305.                 id: 'anchorOptions',
  306.                 width: 260,
  307.                 align: 'center',
  308.                 padding: 0,
  309.                 children: [{
  310.                     type: 'html',
  311.                     id: 'selectAnchorText',
  312.                     html: CKEDITOR.tools.htmlEncode(a.lang.link.selectAnchor),
  313.                     setup: function (s) {
  314.                         if (s.anchors.length > 0) this.getElement().show();
  315.                         else this.getElement().hide();
  316.                     }
  317.                 }, {
  318.                     type: 'html',
  319.                     id: 'noAnchors',
  320.                     style: 'text-align: center;',
  321.                     html: '<div>' + CKEDITOR.tools.htmlEncode(a.lang.link.noAnchors) + '</div>',
  322.                     setup: function (s) {
  323.                         if (s.anchors.length < 1) this.getElement().show();
  324.                         else this.getElement().hide();
  325.                     }
  326.                 }, {
  327.                     type: 'hbox',
  328.                     id: 'selectAnchor',
  329.                     children: [{
  330.                         type: 'select',
  331.                         id: 'anchorName',
  332.                         'default': '',
  333.                         label: a.lang.link.anchorName,
  334.                         style: 'width: 100%;',
  335.                         items: [
  336.                             ['']
  337.                         ],
  338.                         setup: function (s) {
  339.                             var v = this;
  340.                             v.clear();
  341.                             v.add('');
  342.                             for (var t = 0; t < s.anchors.length; t++) if (s.anchors[t].name) v.add(s.anchors[t].name);
  343.                             if (s.anchor) v.setValue(s.anchor.name);
  344.                             var u = v.getDialog().getContentElement('info', 'linkType');
  345.                             if (u && u.getValue() == 'email') v.focus();
  346.                         },
  347.                         commit: function (s) {
  348.                             if (!s.anchor) s.anchor = {};
  349.                             s.anchor.name = this.getValue();
  350.                         }
  351.                     }, {
  352.                         type: 'select',
  353.                         id: 'anchorId',
  354.                         'default': '',
  355.                         label: a.lang.link.anchorId,
  356.                         style: 'width: 100%;',
  357.                         items: [
  358.                             ['']
  359.                         ],
  360.                         setup: function (s) {
  361.                             var u = this;
  362.                             u.clear();
  363.                             u.add('');
  364.                             for (var t = 0; t < s.anchors.length; t++) if (s.anchors[t].id) u.add(s.anchors[t].id);
  365.                             if (s.anchor) u.setValue(s.anchor.id);
  366.                         },
  367.                         commit: function (s) {
  368.                             if (!s.anchor) s.anchor = {};
  369.                             s.anchor.id = this.getValue();
  370.                         }
  371.                     }],
  372.                     setup: function (s) {
  373.                         if (s.anchors.length > 0) this.getElement().show();
  374.                         else this.getElement().hide();
  375.                     }
  376.                 }],
  377.                 setup: function (s) {
  378.                     if (!this.getDialog().getContentElement('info', 'linkType')) this.getElement().hide();
  379.                 }
  380.             }, {
  381.                 type: 'vbox',
  382.                 id: 'emailOptions',
  383.                 padding: 1,
  384.                 children: [{
  385.                     type: 'text',
  386.                     id: 'emailAddress',
  387.                     label: a.lang.link.emailAddress,
  388.                     validate: function () {
  389.                         var s = this.getDialog();
  390.                         if (!s.getContentElement('info', 'linkType') || s.getValueOf('info', 'linkType') != 'email') return true;
  391.                         var t = CKEDITOR.dialog.validate.notEmpty(a.lang.link.noEmail);
  392.                         return t.apply(this);
  393.                     },
  394.                     setup: function (s) {
  395.                         if (s.email) this.setValue(s.email.address);
  396.                         var t = this.getDialog().getContentElement('info', 'linkType');
  397.                         if (t && t.getValue() == 'email') this.select();
  398.                     },
  399.                     commit: function (s) {
  400.                         if (!s.email) s.email = {};
  401.                         s.email.address = this.getValue();
  402.                     }
  403.                 }, {
  404.                     type: 'text',
  405.                     id: 'emailSubject',
  406.                     label: a.lang.link.emailSubject,
  407.                     setup: function (s) {
  408.                         if (s.email) this.setValue(s.email.subject);
  409.                     },
  410.                     commit: function (s) {
  411.                         if (!s.email) s.email = {};
  412.                         s.email.subject = this.getValue();
  413.                     }
  414.                 }, {
  415.                     type: 'textarea',
  416.                     id: 'emailBody',
  417.                     label: a.lang.link.emailBody,
  418.                     rows: 3,
  419.                     'default': '',
  420.                     setup: function (s) {
  421.                         if (s.email) this.setValue(s.email.body);
  422.                     },
  423.                     commit: function (s) {
  424.                         if (!s.email) s.email = {};
  425.                         s.email.body = this.getValue();
  426.                     }
  427.                 }],
  428.                 setup: function (s) {
  429.                     if (!this.getDialog().getContentElement('info', 'linkType')) this.getElement().hide();
  430.                 }
  431.             }]
  432.         }, {
  433.             id: 'target',
  434.             label: a.lang.link.target,
  435.             title: a.lang.link.target,
  436.             elements: [{
  437.                 type: 'hbox',
  438.                 widths: ['50%', '50%'],
  439.                 children: [{
  440.                     type: 'select',
  441.                     id: 'linkTargetType',
  442.                     label: a.lang.link.target,
  443.                     'default': 'notSet',
  444.                     style: 'width : 100%;',
  445.                     items: [
  446.                         [a.lang.link.targetNotSet, 'notSet'],
  447.                         [a.lang.link.targetFrame, 'frame'],
  448.                         [a.lang.link.targetPopup, 'popup'],
  449.                         [a.lang.link.targetNew, '_blank'],
  450.                         [a.lang.link.targetTop, '_top'],
  451.                         [a.lang.link.targetSelf, '_self'],
  452.                         [a.lang.link.targetParent, '_parent']
  453.                     ],
  454.                     onChange: b,
  455.                     setup: function (s) {
  456.                         if (s.target) this.setValue(s.target.type);
  457.                     },
  458.                     commit: function (s) {
  459.                         if (!s.target) s.target = {};
  460.                         s.target.type = this.getValue();
  461.                     }
  462.                 }, {
  463.                     type: 'text',
  464.                     id: 'linkTargetName',
  465.                     label: a.lang.link.targetFrameName,
  466.                     'default': '',
  467.                     setup: function (s) {
  468.                         if (s.target) this.setValue(s.target.name);
  469.                     },
  470.                     commit: function (s) {
  471.                         if (!s.target) s.target = {};
  472.                         s.target.name = this.getValue();
  473.                     }
  474.                 }]
  475.             }, {
  476.                 type: 'vbox',
  477.                 width: 260,
  478.                 align: 'center',
  479.                 padding: 2,
  480.                 id: 'popupFeatures',
  481.                 children: [{
  482.                     type: 'html',
  483.                     html: CKEDITOR.tools.htmlEncode(a.lang.link.popupFeatures)
  484.                 }, {
  485.                     type: 'hbox',
  486.                     children: [{
  487.                         type: 'checkbox',
  488.                         id: 'resizable',
  489.                         label: a.lang.link.popupResizable,
  490.                         setup: n,
  491.                         commit: q
  492.                     }, {
  493.                         type: 'checkbox',
  494.                         id: 'status',
  495.                         label: a.lang.link.popupStatusBar,
  496.                         setup: n,
  497.                         commit: q
  498.                     }]
  499.                 }, {
  500.                     type: 'hbox',
  501.                     children: [{
  502.                         type: 'checkbox',
  503.                         id: 'location',
  504.                         label: a.lang.link.popupLocationBar,
  505.                         setup: n,
  506.                         commit: q
  507.                     }, {
  508.                         type: 'checkbox',
  509.                         id: 'toolbar',
  510.                         label: a.lang.link.popupToolbar,
  511.                         setup: n,
  512.                         commit: q
  513.                     }]
  514.                 }, {
  515.                     type: 'hbox',
  516.                     children: [{
  517.                         type: 'checkbox',
  518.                         id: 'menubar',
  519.                         label: a.lang.link.popupMenuBar,
  520.                         setup: n,
  521.                         commit: q
  522.                     }, {
  523.                         type: 'checkbox',
  524.                         id: 'fullscreen',
  525.                         label: a.lang.link.popupFullScreen,
  526.                         setup: n,
  527.                         commit: q
  528.                     }]
  529.                 }, {
  530.                     type: 'hbox',
  531.                     children: [{
  532.                         type: 'checkbox',
  533.                         id: 'scrollbars',
  534.                         label: a.lang.link.popupScrollBars,
  535.                         setup: n,
  536.                         commit: q
  537.                     }, {
  538.                         type: 'checkbox',
  539.                         id: 'dependent',
  540.                         label: a.lang.link.popupDependent,
  541.                         setup: n,
  542.                         commit: q
  543.                     }]
  544.                 }, {
  545.                     type: 'hbox',
  546.                     children: [{
  547.                         type: 'text',
  548.                         widths: ['30%', '70%'],
  549.                         labelLayout: 'horizontal',
  550.                         label: a.lang.link.popupWidth,
  551.                         id: 'width',
  552.                         setup: n,
  553.                         commit: q
  554.                     }, {
  555.                         type: 'text',
  556.                         labelLayout: 'horizontal',
  557.                         widths: ['55%', '45%'],
  558.                         label: a.lang.link.popupLeft,
  559.                         id: 'left',
  560.                         setup: n,
  561.                         commit: q
  562.                     }]
  563.                 }, {
  564.                     type: 'hbox',
  565.                     children: [{
  566.                         type: 'text',
  567.                         labelLayout: 'horizontal',
  568.                         widths: ['30%', '70%'],
  569.                         label: a.lang.link.popupHeight,
  570.                         id: 'height',
  571.                         setup: n,
  572.                         commit: q
  573.                     }, {
  574.                         type: 'text',
  575.                         labelLayout: 'horizontal',
  576.                         label: a.lang.link.popupTop,
  577.                         widths: ['55%', '45%'],
  578.                         id: 'top',
  579.                         setup: n,
  580.                         commit: q
  581.                     }]
  582.                 }]
  583.             }]
  584.         }, {
  585.             id: 'upload',
  586.             label: a.lang.link.upload,
  587.             title: a.lang.link.upload,
  588.             hidden: true,
  589.             filebrowser: 'uploadButton',
  590.             elements: [{
  591.                 type: 'file',
  592.                 id: 'upload',
  593.                 label: a.lang.common.upload,
  594.                 style: 'height:40px',
  595.                 size: 29
  596.             }, {
  597.                 type: 'fileButton',
  598.                 id: 'uploadButton',
  599.                 label: a.lang.common.uploadSubmit,
  600.                 filebrowser: 'info:url',
  601.                 'for': ['upload', 'upload']
  602.             }]
  603.         }, {
  604.             id: 'advanced',
  605.             label: a.lang.link.advanced,
  606.             title: a.lang.link.advanced,
  607.             elements: [{
  608.                 type: 'vbox',
  609.                 padding: 1,
  610.                 children: [{
  611.                     type: 'hbox',
  612.                     widths: ['45%', '35%', '20%'],
  613.                     children: [{
  614.                         type: 'text',
  615.                         id: 'advId',
  616.                         label: a.lang.link.id,
  617.                         setup: o,
  618.                         commit: r
  619.                     }, {
  620.                         type: 'select',
  621.                         id: 'advLangDir',
  622.                         label: a.lang.link.langDir,
  623.                         'default': '',
  624.                         style: 'width:110px',
  625.                         items: [
  626.                             [a.lang.link.langDirNotSet, ''],
  627.                             [a.lang.link.langDirLTR, 'ltr'],
  628.                             [a.lang.link.langDirRTL, 'rtl']
  629.                         ],
  630.                         setup: o,
  631.                         commit: r
  632.                     }, {
  633.                         type: 'text',
  634.                         id: 'advAccessKey',
  635.                         width: '80px',
  636.                         label: a.lang.link.acccessKey,
  637.                         maxLength: 1,
  638.                         setup: o,
  639.                         commit: r
  640.                     }]
  641.                 }, {
  642.                     type: 'hbox',
  643.                     widths: ['45%', '35%', '20%'],
  644.                     children: [{
  645.                         type: 'text',
  646.                         label: a.lang.link.name,
  647.                         id: 'advName',
  648.                         setup: o,
  649.                         commit: r
  650.                     }, {
  651.                         type: 'text',
  652.                         label: a.lang.link.langCode,
  653.                         id: 'advLangCode',
  654.                         width: '110px',
  655.                         'default': '',
  656.                         setup: o,
  657.                         commit: r
  658.                     }, {
  659.                         type: 'text',
  660.                         label: a.lang.link.tabIndex,
  661.                         id: 'advTabIndex',
  662.                         width: '80px',
  663.                         maxLength: 5,
  664.                         setup: o,
  665.                         commit: r
  666.                     }]
  667.                 }]
  668.             }, {
  669.                 type: 'vbox',
  670.                 padding: 1,
  671.                 children: [{
  672.                     type: 'hbox',
  673.                     widths: ['45%', '55%'],
  674.                     children: [{
  675.                         type: 'text',
  676.                         label: a.lang.link.advisoryTitle,
  677.                         'default': '',
  678.                         id: 'advTitle',
  679.                         setup: o,
  680.                         commit: r
  681.                     }, {
  682.                         type: 'text',
  683.                         label: a.lang.link.advisoryContentType,
  684.                         'default': '',
  685.                         id: 'advContentType',
  686.                         setup: o,
  687.                         commit: r
  688.                     }]
  689.                 }, {
  690.                     type: 'hbox',
  691.                     widths: ['45%', '55%'],
  692.                     children: [{
  693.                         type: 'text',
  694.                         label: a.lang.link.cssClasses,
  695.                         'default': '',
  696.                         id: 'advCSSClasses',
  697.                         setup: o,
  698.                         commit: r
  699.                     }, {
  700.                         type: 'text',
  701.                         label: a.lang.link.charset,
  702.                         'default': '',
  703.                         id: 'advCharset',
  704.                         setup: o,
  705.                         commit: r
  706.                     }]
  707.                 }, {
  708.                     type: 'hbox',
  709.                     children: [{
  710.                         type: 'text',
  711.                         label: a.lang.link.styles,
  712.                         'default': '',
  713.                         id: 'advStyles',
  714.                         setup: o,
  715.                         commit: r
  716.                     }]
  717.                 }]
  718.             }]
  719.         }],
  720.         onShow: function () {
  721.             var y = this;
  722.             y.fakeObj = false;
  723.             var s = y.getParentEditor(),
  724.                 t = s.getSelection(),
  725.                 u = t.getRanges(),
  726.                 v = null,
  727.                 w = y;
  728.             if (u.length == 1) {
  729.                 var x = u[0].getCommonAncestor(true);
  730.                 v = x.getAscendant('a', true);
  731.                 if (v && v.getAttribute('href')) t.selectElement(v);
  732.                 else if ((v = x.getAscendant('img', true)) && (v.getAttribute('_cke_real_element_type') && v.getAttribute('_cke_real_element_type') == 'anchor')) {
  733.                     y.fakeObj = v;
  734.                     v = s.restoreRealElement(y.fakeObj);
  735.                     t.selectElement(y.fakeObj);
  736.                 } else v = null;
  737.             }
  738.             y.setupContent(l.apply(y, [s, v]));
  739.         },
  740.         onOk: function () {
  741.             var s = {
  742.                 href: 'javascript:void(0)/*' + CKEDITOR.tools.getNextNumber() + '*/'
  743.             }, t = [],
  744.                 u = {
  745.                     href: s.href
  746.                 }, v = this,
  747.                 w = this.getParentEditor();
  748.             this.commitContent(u);
  749.             switch (u.type || 'url') {
  750.                 case 'url':
  751.                     var x = u.url && u.url.protocol != undefined ? u.url.protocol : 'http://',
  752.                         y = u.url && u.url.url || '';
  753.                     s._cke_saved_href = y.indexOf('/') === 0 ? y : x + y;
  754.                     break;
  755.                 case 'anchor':
  756.                     var z = u.anchor && u.anchor.name,
  757.                         A = u.anchor && u.anchor.id;
  758.                     s._cke_saved_href = '#' + (z || A || '');
  759.                     break;
  760.                 case 'email':
  761.                     var B = u.email && u.email.address,
  762.                         C = u.email && encodeURIComponent(u.email.subject || ''),
  763.                         D = u.email && encodeURIComponent(u.email.body || ''),
  764.                         E = ['mailto:', B];
  765.                     if (C || D) {
  766.                         var F = [];
  767.                         E.push('?');
  768.                         C && F.push('subject=' + C);
  769.                         D && F.push('body=' + D);
  770.                         E.push(F.join('&'));
  771.                     }
  772.                     s._cke_saved_href = E.join('');
  773.                     break;
  774.                 default:
  775.             }
  776.             if (u.target) if (u.target.type == 'popup') {
  777.                 var G = ["window.open(this.href, '", u.target.name || '', "', '"],
  778.                     H = ['resizable', 'status', 'location', 'toolbar', 'menubar', 'fullscreen', 'scrollbars', 'dependent'],
  779.                     I = H.length,
  780.                     J = function (T) {
  781.                         if (u.target[T]) H.push(T + '=' + u.target[T]);
  782.                     };
  783.                 for (var K = 0; K < I; K++) H[K] = H[K] + (u.target[H[K]] ? '=yes' : '=no');
  784.                 J('width');
  785.                 J('left');
  786.                 J('height');
  787.                 J('top');
  788.                 G.push(H.join(','), "'); return false;");
  789.                 s[CKEDITOR.env.ie || CKEDITOR.env.webkit ? '_cke_pa_onclick' : 'onclick'] = G.join('');
  790.             } else {
  791.                 if (u.target.type != 'notSet' && u.target.name) s.target = u.target.name;
  792.                 t.push('_cke_pa_onclick', 'onclick');
  793.             }
  794.             if (u.adv) {
  795.                 var L = function (T, U) {
  796.                     var V = u.adv[T];
  797.                     if (V) s[U] = V;
  798.                     else t.push(U);
  799.                 };
  800.                 if (this._.selectedElement) L('advId', 'id');
  801.                 L('advLangDir', 'dir');
  802.                 L('advAccessKey', 'accessKey');
  803.                 L('advName', 'name');
  804.                 L('advLangCode', 'lang');
  805.                 L('advTabIndex', 'tabindex');
  806.                 L('advTitle', 'title');
  807.                 L('advContentType', 'type');
  808.                 L('advCSSClasses', 'class');
  809.                 L('advCharset', 'charset');
  810.                 L('advStyles', 'style');
  811.                 L('advRel', 'rel');
  812.             }
  813.             if (!this._.selectedElement) {
  814.                 var M = w.getSelection(),
  815.                     N = M.getRanges();
  816.                 if (N.length == 1 && N[0].collapsed) {
  817.                     var O = new CKEDITOR.dom.text(s._cke_saved_href, w.document);
  818.                     N[0].insertNode(O);
  819.                     N[0].selectNodeContents(O);
  820.                     M.selectRanges(N);
  821.                 }
  822.                 var P = new CKEDITOR.style({
  823.                     element: 'a',
  824.                     attributes: s
  825.                 });
  826.                 P.type = CKEDITOR.STYLE_INLINE;
  827.                 P.apply(w.document);
  828.                 if (u.adv && u.adv.advId) {
  829.                     var Q = this.getParentEditor().document.$.getElementsByTagName('a');
  830.                     for (K = 0; K < Q.length; K++) if (Q[K].href == s.href) {
  831.                         Q[K].id = u.adv.advId;
  832.                         break;
  833.                     }
  834.                 }
  835.             } else {
  836.                 var R = this._.selectedElement;
  837.                 if (CKEDITOR.env.ie && s.name != R.getAttribute('name')) {
  838.                     var S = new CKEDITOR.dom.element('<a name="' + CKEDITOR.tools.htmlEncode(s.name) + '">', w.document);
  839.                     M = w.getSelection();
  840.                     R.moveChildren(S);
  841.                     R.copyAttributes(S, {
  842.                         name: 1
  843.                     });
  844.                     S.replace(R);
  845.                     R = S;
  846.                     M.selectElement(R);
  847.                 }
  848.                 R.setAttributes(s);
  849.                 R.removeAttributes(t);
  850.                 if (R.getAttribute('name')) R.addClass('cke_anchor');
  851.                 else R.removeClass('cke_anchor');
  852.                 if (this.fakeObj) w.createFakeElement(R, 'cke_anchor', 'anchor').replace(this.fakeObj);
  853.                 delete this._.selectedElement;
  854.             }
  855.         },
  856.         onLoad: function () {
  857.             if (!a.config.linkShowAdvancedTab) this.hidePage('advanced');
  858.             if (!a.config.linkShowTargetTab) this.hidePage('target');
  859.         }
  860.     };
  861. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement