[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 /* 2 YUI 3.17.2 (build 9c3c78e) 3 Copyright 2014 Yahoo! Inc. All rights reserved. 4 Licensed under the BSD License. 5 http://yuilibrary.com/license/ 6 */ 7 8 YUI.add('createlink-base', function (Y, NAME) { 9 10 11 /** 12 * Adds prompt style link creation. Adds an override for the 13 * <a href="Plugin.ExecCommand.html#method_COMMANDS.createlink">createlink execCommand</a>. 14 * @class Plugin.CreateLinkBase 15 * @static 16 * @submodule createlink-base 17 * @module editor 18 */ 19 20 var CreateLinkBase = {}; 21 /** 22 * Strings used by the plugin 23 * @property STRINGS 24 * @static 25 */ 26 CreateLinkBase.STRINGS = { 27 /** 28 * String used for the Prompt 29 * @property PROMPT 30 * @static 31 */ 32 PROMPT: 'Please enter the URL for the link to point to:', 33 /** 34 * String used as the default value of the Prompt 35 * @property DEFAULT 36 * @static 37 */ 38 DEFAULT: 'http://' 39 }; 40 41 Y.namespace('Plugin'); 42 Y.Plugin.CreateLinkBase = CreateLinkBase; 43 44 Y.mix(Y.Plugin.ExecCommand.COMMANDS, { 45 /** 46 * Override for the createlink method from the <a href="Plugin.CreateLinkBase.html">CreateLinkBase</a> plugin. 47 * @for Plugin.ExecCommand.COMMANDS 48 * @method createlink 49 * @static 50 * @param {String} cmd The command executed: createlink 51 * @return {Node} Node instance of the item touched by this command. 52 */ 53 createlink: function(cmd) { 54 var inst = this.get('host').getInstance(), out, a, sel, holder, 55 url = prompt(CreateLinkBase.STRINGS.PROMPT, CreateLinkBase.STRINGS.DEFAULT); 56 57 if (url) { 58 holder = inst.config.doc.createElement('div'); 59 url = url.replace(/"/g, '').replace(/'/g, ''); //Remove single & double quotes 60 url = inst.config.doc.createTextNode(url); 61 holder.appendChild(url); 62 url = holder.innerHTML; 63 64 65 this.get('host')._execCommand(cmd, url); 66 sel = new inst.EditorSelection(); 67 out = sel.getSelected(); 68 if (!sel.isCollapsed && out.size()) { 69 //We have a selection 70 a = out.item(0).one('a'); 71 if (a) { 72 out.item(0).replace(a); 73 } 74 if (Y.UA.gecko) { 75 if (a.get('parentNode').test('span')) { 76 if (a.get('parentNode').one('br.yui-cursor')) { 77 a.get('parentNode').insert(a, 'before'); 78 } 79 } 80 } 81 } else { 82 //No selection, insert a new node.. 83 this.get('host').execCommand('inserthtml', '<a href="' + url + '">' + url + '</a>'); 84 } 85 } 86 return a; 87 } 88 }); 89 90 91 92 }, '3.17.2', {"requires": ["editor-base"]});
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |