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