~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/createlink-base/createlink-base.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

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