~ubuntu-branches/ubuntu/precise/whoopsie-daisy/precise-proposed

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/3.4.1/build/editor-lists/editor-lists-debug.js

  • Committer: Package Import Robot
  • Author(s): Evan Dandrea
  • Date: 2012-04-18 13:04:36 UTC
  • Revision ID: package-import@ubuntu.com-20120418130436-vmt93p8fds516lws
Tags: 0.1.32
Fix failing tests on powerpc and ARM.

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('editor-lists', function(Y) {
8
 
 
9
 
 
10
 
    /**
11
 
     * Handles list manipulation inside the Editor. Adds keyboard manipulation and execCommand support. Adds overrides for the <a href="Plugin.ExecCommand.html#method_COMMANDS.insertorderedlist">insertorderedlist</a> and <a href="Plugin.ExecCommand.html#method_COMMANDS.insertunorderedlist">insertunorderedlist</a> execCommands.
12
 
     * @class Plugin.EditorLists
13
 
     * @constructor
14
 
     * @extends Base
15
 
     * @module editor
16
 
     * @submodule editor-lists
17
 
     */
18
 
    
19
 
    var EditorLists = function() {
20
 
        EditorLists.superclass.constructor.apply(this, arguments);
21
 
    }, LI = 'li', OL = 'ol', UL = 'ul', HOST = 'host';
22
 
 
23
 
    Y.extend(EditorLists, Y.Base, {
24
 
        /**
25
 
        * Listener for host's nodeChange event and captures the tabkey interaction only when inside a list node.
26
 
        * @private
27
 
        * @method _onNodeChange
28
 
        * @param {Event} e The Event facade passed from the host.
29
 
        */
30
 
        _onNodeChange: function(e) {
31
 
            var inst = this.get(HOST).getInstance(), sel, li, 
32
 
            newLi, newList, sTab, par, moved = false, tag, focusEnd = false;
33
 
 
34
 
            if (e.changedType === 'tab') {
35
 
                if (e.changedNode.test(LI + ', ' + LI + ' *')) {
36
 
                    Y.log('Overriding TAB to move lists around', 'info', 'editorLists');
37
 
                    e.changedEvent.halt();
38
 
                    e.preventDefault();
39
 
                    li = e.changedNode;
40
 
                    sTab = e.changedEvent.shiftKey;
41
 
                    par = li.ancestor(OL + ',' + UL);
42
 
                    tag = UL;
43
 
 
44
 
                    if (par.get('tagName').toLowerCase() === OL) {
45
 
                        tag = OL;
46
 
                    }
47
 
                    Y.log('ShiftKey: ' + sTab, 'info', 'editorLists');
48
 
                    
49
 
                    if (!li.test(LI)) {
50
 
                        li = li.ancestor(LI);
51
 
                    }
52
 
                    if (sTab) {
53
 
                        if (li.ancestor(LI)) {
54
 
                            Y.log('Shifting list up one level', 'info', 'editorLists');
55
 
                            li.ancestor(LI).insert(li, 'after');
56
 
                            moved = true;
57
 
                            focusEnd = true;
58
 
                        }
59
 
                    } else {
60
 
                        //li.setStyle('border', '1px solid red');
61
 
                        if (li.previous(LI)) {
62
 
                            Y.log('Shifting list down one level', 'info', 'editorLists');
63
 
                            newList = inst.Node.create('<' + tag + '></' + tag + '>');
64
 
                            li.previous(LI).append(newList);
65
 
                            newList.append(li);
66
 
                            moved = true;
67
 
                        }
68
 
                    }
69
 
                }
70
 
                if (moved) {
71
 
                    if (!li.test(LI)) {
72
 
                        li = li.ancestor(LI);
73
 
                    }
74
 
                    li.all(EditorLists.REMOVE).remove();
75
 
                    if (Y.UA.ie) {
76
 
                        li = li.append(EditorLists.NON).one(EditorLists.NON_SEL);
77
 
                    }
78
 
                    //Selection here..
79
 
                    Y.log('Selecting the new node', 'info', 'editorLists');
80
 
                    (new inst.Selection()).selectNode(li, true, focusEnd);
81
 
                }
82
 
            }
83
 
        },
84
 
        initializer: function() {
85
 
            this.get(HOST).on('nodeChange', Y.bind(this._onNodeChange, this));
86
 
        }
87
 
    }, {
88
 
        /**
89
 
        * The non element placeholder, used for positioning the cursor and filling empty items
90
 
        * @property REMOVE
91
 
        * @static
92
 
        */
93
 
        NON: '<span class="yui-non">&nbsp;</span>',
94
 
        /**
95
 
        * The selector query to get all non elements
96
 
        * @property NONSEL
97
 
        * @static
98
 
        */
99
 
        NON_SEL: 'span.yui-non',
100
 
        /**
101
 
        * The items to removed from a list when a list item is moved, currently removes BR nodes
102
 
        * @property REMOVE
103
 
        * @static
104
 
        */
105
 
        REMOVE: 'br',
106
 
        /**
107
 
        * editorLists
108
 
        * @property NAME
109
 
        * @static
110
 
        */
111
 
        NAME: 'editorLists',
112
 
        /**
113
 
        * lists
114
 
        * @property NS
115
 
        * @static
116
 
        */
117
 
        NS: 'lists',
118
 
        ATTRS: {
119
 
            host: {
120
 
                value: false
121
 
            }
122
 
        }
123
 
    });
124
 
 
125
 
    Y.namespace('Plugin');
126
 
 
127
 
    Y.Plugin.EditorLists = EditorLists;
128
 
 
129
 
 
130
 
 
131
 
}, '3.4.1' ,{skinnable:false, requires:['editor-base']});