~andreserl/maas/precise_packaging_sru

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/button-group/button-group-debug.js

  • Committer: Andres Rodriguez
  • Date: 2013-03-08 23:21:23 UTC
  • mfrom: (145.2.21 precise.sru)
  • Revision ID: andreserl@ubuntu.com-20130308232123-tws9nffx8f6eoa0f
* debian/maas-dhcp.maas-dhcp-server.upstart: leases file should be owned
  by user/group 'dhcpd' instead of root.
* debian/control: Force dependency version for python-django to
  (>= 1.3.1-4ubuntu1.7).
* Continue to ship yui3 and raphael with MAAS.
  - debian/patches/04_precise_no_yui_root.patch: Add.
  - debian/control: Drop dependencies on yui3 and raphael.
  - debian/source/include-binaries: Add to not FTBFS
  - debian/extras/jslibs: Ship JS libraries.
  - debian/copyright: Update copyright to reflect libraries license.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.1 (build 22)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('button-group', function(Y) {
 
8
 
 
9
/**
 
10
* A Widget to create groups of buttons
 
11
*
 
12
* @module button-group
 
13
* @since 3.5.0
 
14
*/
 
15
 
 
16
var CONTENT_BOX = "contentBox",
 
17
    SELECTOR    = "button, input[type=button], input[type=reset], input[type=submit]",
 
18
    CLICK_EVENT = "click",
 
19
    CLASS_NAMES = Y.ButtonCore.CLASS_NAMES;
 
20
 
 
21
/**
 
22
* Creates a ButtonGroup
 
23
*
 
24
* @class ButtonGroup
 
25
* @extends Widget
 
26
* @param config {Object} Configuration object
 
27
* @constructor
 
28
*/
 
29
function ButtonGroup() {
 
30
    ButtonGroup.superclass.constructor.apply(this, arguments);
 
31
}
 
32
 
 
33
/* ButtonGroup extends Widget */
 
34
Y.ButtonGroup = Y.extend(ButtonGroup, Y.Widget, {
 
35
 
 
36
    /**
 
37
     * @method renderUI
 
38
     * @description Creates a visual representation of the widget based on existing parameters.
 
39
     * @public
 
40
     */
 
41
    renderUI: function() {
 
42
        this.getButtons().plug(Y.Plugin.Button);
 
43
    },
 
44
 
 
45
    /**
 
46
     * @method bindUI
 
47
     * @description Hooks up events for the widget
 
48
     * @public
 
49
     */
 
50
    bindUI: function() {
 
51
        var group = this,
 
52
            cb = group.get(CONTENT_BOX);
 
53
 
 
54
        cb.delegate(CLICK_EVENT, group._handleClick, SELECTOR, group);
 
55
    },
 
56
 
 
57
    /**
 
58
    * @method getButtons
 
59
    * @description Returns all buttons inside this this button group
 
60
    * @public
 
61
    */
 
62
    getButtons: function() {
 
63
        var cb = this.get(CONTENT_BOX);
 
64
 
 
65
        return cb.all(SELECTOR);
 
66
    },
 
67
 
 
68
    /**
 
69
    * @method getSelectedButtons
 
70
    * @description Returns all Y.Buttons instances that are selected
 
71
    * @public
 
72
    */
 
73
    getSelectedButtons: function() {
 
74
        var group = this,
 
75
            selected = [],
 
76
            buttons = group.getButtons(),
 
77
            selectedClass = ButtonGroup.CLASS_NAMES.SELECTED;
 
78
 
 
79
        buttons.each(function(node){
 
80
            if (node.hasClass(selectedClass)){
 
81
                selected.push(node);
 
82
            }
 
83
        });
 
84
 
 
85
        return selected;
 
86
    },
 
87
 
 
88
    /**
 
89
    * @method getSelectedValues
 
90
    * @description Returns the values of all Y.Button instances that are selected
 
91
    * @public
 
92
    */
 
93
    getSelectedValues: function() {
 
94
        var group = this,
 
95
            value,
 
96
            values = [],
 
97
            selected = group.getSelectedButtons(),
 
98
            selectedClass = ButtonGroup.CLASS_NAMES.SELECTED;
 
99
 
 
100
        Y.Array.each(selected, function(node){
 
101
            if (node.hasClass(selectedClass)){
 
102
                value = node.getContent();
 
103
                values.push(value);
 
104
            }
 
105
        });
 
106
 
 
107
        return values;
 
108
    },
 
109
 
 
110
    /**
 
111
    * @method _handleClick
 
112
    * @description A delegated click handler for when any button is clicked in the content box
 
113
    * @param e {Object} An event object
 
114
    * @private
 
115
    */
 
116
    _handleClick: function(e){
 
117
        var buttons,
 
118
            clickedNode = e.target,
 
119
            group = this,
 
120
            type = group.get('type'),
 
121
            selectedClass = ButtonGroup.CLASS_NAMES.SELECTED,
 
122
            isSelected = clickedNode.hasClass(selectedClass);
 
123
 
 
124
        // TODO: Anything for 'push' groups?
 
125
 
 
126
        if (type === 'checkbox') {
 
127
            clickedNode.toggleClass(selectedClass, !isSelected);
 
128
            group.fire('selectionChange', {originEvent: e});
 
129
        }
 
130
        else if (type === 'radio') {
 
131
            if (!isSelected) {
 
132
                buttons = group.getButtons(); // Todo: getSelectedButtons()? Need it to return an arraylist then.
 
133
                buttons.removeClass(selectedClass);
 
134
                clickedNode.addClass(selectedClass);
 
135
                group.fire('selectionChange', {originEvent: e});
 
136
            }
 
137
        }
 
138
    }
 
139
 
 
140
}, {
 
141
    // Y.ButtonGroup static properties
 
142
 
 
143
    /**
 
144
     * The identity of the widget.
 
145
     *
 
146
     * @property NAME
 
147
     * @type {String}
 
148
     * @default 'buttongroup'
 
149
     * @readOnly
 
150
     * @protected
 
151
     * @static
 
152
     */
 
153
    NAME: 'buttongroup',
 
154
 
 
155
    /**
 
156
    * Static property used to define the default attribute configuration of
 
157
    * the Widget.
 
158
    *
 
159
    * @property ATTRS
 
160
    * @type {Object}
 
161
    * @protected
 
162
    * @static
 
163
    */
 
164
    ATTRS: {
 
165
        type: {
 
166
            writeOnce: 'initOnly',
 
167
            value: 'radio'
 
168
        }
 
169
    },
 
170
 
 
171
    /**
 
172
     * List of class names to use for ButtonGroups
 
173
     *
 
174
     * @property CLASS_NAMES
 
175
     * @type {Object}
 
176
     * @static
 
177
     */
 
178
    CLASS_NAMES: CLASS_NAMES
 
179
});
 
180
 
 
181
 
 
182
}, '3.5.1' ,{requires:['button-plugin', 'cssbutton', 'widget']});