xooie 0.1.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -6
- data/lib/xooie.rb +1 -3
- data/vendor/assets/javascripts/xooie/addons/base.js +211 -46
- data/vendor/assets/javascripts/xooie/addons/carousel_lentils.js +0 -0
- data/vendor/assets/javascripts/xooie/addons/carousel_pagination.js +0 -0
- data/vendor/assets/javascripts/xooie/addons/dropdown_accordion.js +0 -0
- data/vendor/assets/javascripts/xooie/addons/tab_animation.js +0 -0
- data/vendor/assets/javascripts/xooie/addons/tab_automation.js +0 -0
- data/vendor/assets/javascripts/xooie/base.js +1 -4
- data/vendor/assets/javascripts/xooie/carousel.js +5 -5
- data/vendor/assets/javascripts/xooie/dialog.js +2 -31
- data/vendor/assets/javascripts/xooie/dropdown.js +5 -17
- data/vendor/assets/javascripts/xooie/event_handler.js +83 -0
- data/vendor/assets/javascripts/xooie/helpers.js +61 -0
- data/vendor/assets/javascripts/xooie/keyboard_navigation.js +216 -0
- data/vendor/assets/javascripts/xooie/shared.js +175 -0
- data/vendor/assets/javascripts/xooie/stylesheet.js +77 -78
- data/vendor/assets/javascripts/xooie/tab.js +0 -0
- data/vendor/assets/javascripts/xooie/widgets/accordion.js +52 -0
- data/vendor/assets/javascripts/xooie/widgets/base.js +644 -0
- data/vendor/assets/javascripts/xooie/widgets/carousel.js +769 -0
- data/vendor/assets/javascripts/xooie/widgets/dialog.js +132 -0
- data/vendor/assets/javascripts/xooie/widgets/dropdown.js +283 -0
- data/vendor/assets/javascripts/xooie/widgets/tab.js +332 -0
- data/vendor/assets/javascripts/xooie/xooie.js +282 -0
- data/vendor/assets/javascripts/xooie.js +0 -0
- metadata +17 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ab042b8a8738d53a37ca8896d4cdc6a58240e40
|
4
|
+
data.tar.gz: 092d46a6f2abd0b7142c5d7325e2bcc5a86baafa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 072980e920a4abd117dbc89b6136d0baf1101c56bfe45021983afb0d5fdcd6b1bd46e9c9c0129acd184c591aed11b24150994ddba644783328b90d97a17b6eef
|
7
|
+
data.tar.gz: 9e1241ae13314e68ce0fb9b195f0924dee1120026dd5335428b08ad0e73b82e19b69db9e99c37c6d7037e92bcb04ffb161eee4c3ebf79c2d12ce2ca1595b8fdb
|
data/README.md
CHANGED
@@ -30,12 +30,6 @@ Xooie will work by just loading xooie.js on your page; all other files will be l
|
|
30
30
|
|
31
31
|
Instantiation happens automatically when the page is loaded. All HTML elements tagged with the "data-widget-type" attribute will offer the associated Xooie widget functionality.
|
32
32
|
|
33
|
-
1.x vs 0.1.x:
|
34
|
-
---
|
35
|
-
v1.0 is our official release of Xooie. All new feature development & bug fixes occur on [master](https://github.com/Comcast/Xooie) & are released from a release_1_x branch (e.g. [release_1_1](https://github.com/Comcast/Xooie/tree/release_1_1)). So if you're just getting started with Xooie, be sure to grab the latest 1.x version.
|
36
|
-
|
37
|
-
If you were already using a pre-1.0 release of Xooie, there is a [release_0_1_x branch](https://github.com/Comcast/Xooie/tree/release_0_1_x) that is updated with bug fixes only. Any 0.1.x release is from the pre-1.0 Xooie development work.
|
38
|
-
|
39
33
|
Documentation:
|
40
34
|
---
|
41
35
|
Carousel
|
data/lib/xooie.rb
CHANGED
@@ -14,63 +14,228 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
17
|
+
/**
|
18
|
+
* class Xooie.Addon
|
19
|
+
*
|
20
|
+
* The base xooie addon module. This module defines how addons function in relation to
|
21
|
+
* widgets, but contains no specific functionality.
|
22
|
+
**/
|
23
|
+
define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
|
24
|
+
/**
|
25
|
+
* Xooie.Addon@xooie-addon-init(event)
|
26
|
+
* - event (Event): A jQuery event object
|
27
|
+
*
|
28
|
+
* A jQuery special event triggered when the addon is successfully initialized. Triggers on the `root` element
|
29
|
+
* of the adodn's widget. Unlike [[Xooie.Widget@xooie-init]], this event only triggers when the addon is first instantiated.
|
30
|
+
**/
|
31
|
+
|
32
|
+
/**
|
33
|
+
* new Xooie.Addon(widget)
|
34
|
+
* - widget (Widget): An instance of [[Xooie.Widget]].
|
35
|
+
*
|
36
|
+
* Instantiating a new Addon associates the addon with the widget passed into the constructor. The addon is
|
37
|
+
* stored in the [[Xooie.Widget#addons]] collection.
|
38
|
+
**/
|
39
|
+
var Addon = function(widget) {
|
40
|
+
var self = this;
|
41
|
+
|
42
|
+
// Check to see if the module is defined:
|
43
|
+
if (typeof widget === 'undefined') {
|
44
|
+
return false;
|
45
|
+
}
|
46
|
+
|
47
|
+
// If there is already an instance of this addon instantiated for the module, return it:
|
48
|
+
if (widget.addons() && widget.addons().hasOwnProperty(this.name())) {
|
49
|
+
return widget.addons()[this.name()];
|
50
|
+
}
|
51
|
+
|
52
|
+
// Add this addon to the widget's addons collection:
|
53
|
+
widget.addons()[this.name()] = this;
|
54
|
+
|
55
|
+
widget.root().addClass(this.addonClass());
|
56
|
+
|
57
|
+
// Reference the widget:
|
58
|
+
this.widget(widget);
|
59
|
+
|
60
|
+
// Check to see if there are any additional constructors to call;
|
61
|
+
var initCheck = function(){
|
62
|
+
var i;
|
63
|
+
|
64
|
+
if (!self._extendCount || self._extendCount <= 0) {
|
65
|
+
self.widget().root().trigger(self.get('initEvent'));
|
66
|
+
self._extendCount = null;
|
67
|
+
} else {
|
68
|
+
setTimeout(initCheck, 0);
|
30
69
|
}
|
70
|
+
};
|
31
71
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
this.module = module;
|
39
|
-
|
40
|
-
//track this addon on the parent module
|
41
|
-
this.module.addons[name] = this;
|
42
|
-
|
43
|
-
//We'll need to extend the module's base properties
|
44
|
-
this.options = $.extend({}, wrapper.getDefaultOptions(), this.module.options);
|
72
|
+
if (this._extendCount > 0) {
|
73
|
+
setTimeout(initCheck, 0);
|
74
|
+
} else {
|
75
|
+
initCheck();
|
76
|
+
}
|
77
|
+
};
|
45
78
|
|
46
|
-
|
79
|
+
/**
|
80
|
+
* Xooie.Addon.defineReadOnly(name, defaultValue)
|
81
|
+
* - name (String): The name of the property to define as a read-only property.
|
82
|
+
* - defaultValue (Object): An optional default value.
|
83
|
+
*
|
84
|
+
* See [[Xooie.shared.defineReadOnly]].
|
85
|
+
**/
|
86
|
+
Addon.defineReadOnly = function(name, defaultValue){
|
87
|
+
shared.defineReadOnly(this, name, defaultValue);
|
88
|
+
};
|
47
89
|
|
48
|
-
|
90
|
+
/**
|
91
|
+
* Xooie.Addon.defineWriteOnly(name)
|
92
|
+
* - name (String): The name of the property to define as a write-only property
|
93
|
+
*
|
94
|
+
* See [[Xooie.shared.defineWriteOnly]].
|
95
|
+
**/
|
96
|
+
Addon.defineWriteOnly = function(name){
|
97
|
+
shared.defineWriteOnly(this, name);
|
98
|
+
};
|
49
99
|
|
50
|
-
|
100
|
+
/**
|
101
|
+
* Xooie.Widget.define(name[, defaultValue])
|
102
|
+
* - name (String): The name of the property to define.
|
103
|
+
* - defaultValue: An optional default value.
|
104
|
+
*
|
105
|
+
* A method that defines a property as both readable and writable. In reality it calls both [[Xooie.Addon.defineReadOnly]]
|
106
|
+
* and [[Xooie.Addon.defineWriteOnly]].
|
107
|
+
**/
|
108
|
+
Addon.define = function(name, defaultValue){
|
109
|
+
this.defineReadOnly(name, defaultValue);
|
110
|
+
this.defineWriteOnly(name);
|
111
|
+
};
|
51
112
|
|
52
|
-
|
113
|
+
/**
|
114
|
+
* Xooie.Addon.extend(constr) -> Addon
|
115
|
+
* - constr (Function): The constructor for the new [[Xooie.Addon]] class.
|
116
|
+
*
|
117
|
+
* See [[Xooie.shared.extend]].
|
118
|
+
**/
|
119
|
+
Addon.extend = function(constr){
|
120
|
+
return shared.extend(constr, this);
|
121
|
+
};
|
53
122
|
|
54
|
-
|
55
|
-
|
56
|
-
|
123
|
+
/** internal
|
124
|
+
* Xooie.Addon#_definedProps -> Array
|
125
|
+
*
|
126
|
+
* Same as [[Xooie.Widget#_definedProps]].
|
127
|
+
**/
|
128
|
+
Addon.prototype._definedProps = [];
|
129
|
+
|
130
|
+
/** internal
|
131
|
+
* Xooie.Addon#_extendCount -> Integer | null
|
132
|
+
*
|
133
|
+
* Same as [[Xooie.Widget#_extendCount]].
|
134
|
+
**/
|
135
|
+
Addon.prototype._extendCount = null;
|
136
|
+
|
137
|
+
/** internal
|
138
|
+
* Xooie.Addon#_widget -> Widget
|
139
|
+
*
|
140
|
+
* The widget for which this addon was instantiated.
|
141
|
+
**/
|
142
|
+
/**
|
143
|
+
* Xooie.Addon#widget([value]) -> Widget
|
144
|
+
* - value: an optional value to be set.
|
145
|
+
*
|
146
|
+
* The method for setting or getting [[Xooie.Addon#_widget]]. Returns the current value of
|
147
|
+
* [[Xooie.Addon#_widget]] if no value is passed or sets the value.
|
148
|
+
**/
|
149
|
+
Addon.define('widget');
|
150
|
+
|
151
|
+
/** internal
|
152
|
+
* Xooie.Addon#_name -> String
|
153
|
+
*
|
154
|
+
* The name of the addon.
|
155
|
+
**/
|
156
|
+
/**
|
157
|
+
* Xooie.Addon#name([value]) -> String
|
158
|
+
* - value: an optional value to be set.
|
159
|
+
*
|
160
|
+
* The method for setting or getting [[Xooie.Addon#_name]]. Returns the current value of
|
161
|
+
* [[Xooie.Addon#_name]] if no value is passed or sets the value.
|
162
|
+
**/
|
163
|
+
Addon.define('name', 'addon');
|
164
|
+
|
165
|
+
/** internal, read-only
|
166
|
+
* Xooie.Addon#_initEvent -> String
|
167
|
+
*
|
168
|
+
* The name of the event triggered when the addon is instantiated.
|
169
|
+
**/
|
170
|
+
/** read-only
|
171
|
+
* Xooie.Addon#initEvent() -> String
|
172
|
+
*
|
173
|
+
* The method for getting [[Xooie.Addon#_initEvent]].
|
174
|
+
**/
|
175
|
+
Addon.defineReadOnly('initEvent', 'xooie-addon-init');
|
176
|
+
|
177
|
+
/** internal, read-only
|
178
|
+
* Xooie.Addon#_addonClass -> String
|
179
|
+
*
|
180
|
+
* The class added to the widget root indicating that this addon has been instantiated.
|
181
|
+
**/
|
182
|
+
/** read-only
|
183
|
+
* Xooie.Addon#addonClass() -> String
|
184
|
+
*
|
185
|
+
* The method for getting [[Xooie.Addon#_addonClass]].
|
186
|
+
**/
|
187
|
+
Addon.defineReadOnly('addonClass', 'has-addon');
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Xooie.Addon#get(name) -> object
|
191
|
+
* - name (String): The name of the property to be retrieved.
|
192
|
+
*
|
193
|
+
* See [[Xooie.shared.get]].
|
194
|
+
**/
|
195
|
+
Addon.prototype.get = function(name) {
|
196
|
+
return shared.get(this, name);
|
197
|
+
};
|
57
198
|
|
58
|
-
|
59
|
-
|
60
|
-
|
199
|
+
/**
|
200
|
+
* Xooie.Addon#set(name, value)
|
201
|
+
* - name (String): The name of the property to be set.
|
202
|
+
* - value: The value of the property to be set.
|
203
|
+
*
|
204
|
+
* See [[Xooie.shared.set]].
|
205
|
+
**/
|
206
|
+
Addon.prototype.set = function(name, value) {
|
207
|
+
return shared.set(this, name, value);
|
208
|
+
};
|
61
209
|
|
62
|
-
|
63
|
-
|
64
|
-
|
210
|
+
/**
|
211
|
+
* Xooie.Addon#cleanup()
|
212
|
+
*
|
213
|
+
* Removes the `addonClass` from the `root` of the associated `widget` and prepares this widget to be
|
214
|
+
* garbage collected.
|
215
|
+
**/
|
216
|
+
Addon.prototype.cleanup = function() {
|
217
|
+
this.widget().root().removeClass(this.addonClass());
|
218
|
+
};
|
65
219
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
220
|
+
/** internal
|
221
|
+
* Xooie.Addon#_process_initEvent(initEvent) -> String
|
222
|
+
* - initEvent (String): The unmodified initEvent string.
|
223
|
+
*
|
224
|
+
* Adds the [[Xooie.Addon#name]] to the `initEvent`
|
225
|
+
**/
|
226
|
+
Addon.prototype._process_initEvent = function(initEvent) {
|
227
|
+
return this.name() === 'addon' ? initEvent : initEvent + '.' + this.name();
|
228
|
+
};
|
71
229
|
|
72
|
-
|
230
|
+
/** internal
|
231
|
+
* Xooie.Addon#_process_addonClass(className) -> String
|
232
|
+
* - className (String): The unmodified className string.
|
233
|
+
*
|
234
|
+
* Adds the [[Xooie.Addon#name]] to the `addonClass`
|
235
|
+
**/
|
236
|
+
Addon.prototype._process_addonClass = function(addonClass) {
|
237
|
+
return this.name() === 'addon' ? addonClass : 'has-' + this.name() + '-addon';
|
73
238
|
};
|
74
239
|
|
75
|
-
return
|
240
|
+
return Addon;
|
76
241
|
});
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -29,10 +29,7 @@ define('xooie/base', ['jquery', 'xooie', 'xooie/stylesheet'], function($, $X, St
|
|
29
29
|
};
|
30
30
|
|
31
31
|
var Base = function(name, constructor) {
|
32
|
-
var instances, defaultOptions, instanceCounter,
|
33
|
-
initEvent, refreshEvent,
|
34
|
-
instanceName, cssRules,
|
35
|
-
stylesInstance, className, Xooie;
|
32
|
+
var instances, defaultOptions, instanceCounter, initEvent, instanceName, cssRules, stylesInstance, className, Xooie;
|
36
33
|
|
37
34
|
instances = [];
|
38
35
|
|
@@ -45,7 +45,7 @@ define('xooie/carousel', ['jquery', 'xooie/base'], function($, Base) {
|
|
45
45
|
this.positionUpdaters = {
|
46
46
|
|
47
47
|
"item": function(quantity, direction) {
|
48
|
-
var items = self.content.children(
|
48
|
+
var items = self.content.children(),
|
49
49
|
bias, offset,
|
50
50
|
position = self.wrapper.scrollLeft(),
|
51
51
|
i;
|
@@ -73,7 +73,7 @@ define('xooie/carousel', ['jquery', 'xooie/base'], function($, Base) {
|
|
73
73
|
|
74
74
|
"px": function(quantity, direction) {
|
75
75
|
var position;
|
76
|
-
|
76
|
+
|
77
77
|
if (typeof direction === 'undefined') {
|
78
78
|
position = 0;
|
79
79
|
direction = 1;
|
@@ -199,7 +199,7 @@ define('xooie/carousel', ['jquery', 'xooie/base'], function($, Base) {
|
|
199
199
|
//It is possible that images may load after the carousel has instantiated/
|
200
200
|
//Also, this can be used for lazy-loading images
|
201
201
|
//TODO: This can be problematic, since it is triggering update dimensions for each image load
|
202
|
-
this.content.find('img').
|
202
|
+
this.content.find('img').on('load', this.updateDimensions.bind(this));
|
203
203
|
|
204
204
|
carouselElements = carouselElements.add(this.root);
|
205
205
|
});
|
@@ -244,7 +244,7 @@ define('xooie/carousel', ['jquery', 'xooie/base'], function($, Base) {
|
|
244
244
|
};
|
245
245
|
|
246
246
|
Carousel.prototype.currentItem = function(bias) {
|
247
|
-
var i, items = this.content.children(
|
247
|
+
var i, items = this.content.children(),
|
248
248
|
position, itemWidth;
|
249
249
|
|
250
250
|
if (typeof bias === 'undefined') {
|
@@ -366,7 +366,7 @@ define('xooie/carousel', ['jquery', 'xooie/base'], function($, Base) {
|
|
366
366
|
if (this.isScrolling) {
|
367
367
|
self.wrapper.stop(true,true);
|
368
368
|
}
|
369
|
-
|
369
|
+
|
370
370
|
callback();
|
371
371
|
|
372
372
|
};
|
@@ -17,22 +17,16 @@
|
|
17
17
|
define('xooie/dialog', ['jquery', 'xooie/base'], function($, Base) {
|
18
18
|
|
19
19
|
var Dialog = Base('dialog', function(){
|
20
|
-
var self = this
|
21
|
-
contentId;
|
20
|
+
var self = this;
|
22
21
|
|
23
22
|
this.id = Dialog._counter++;
|
24
23
|
|
25
|
-
contentId = 'modal-content-' + this.id;
|
26
|
-
|
27
24
|
Dialog._instances[this.id] = this;
|
28
25
|
|
29
26
|
this.root.attr('data-dialog-id', this.id);
|
30
27
|
|
31
|
-
this.root.find(this.options.contentSelector).attr('id', contentId);
|
32
|
-
|
33
28
|
//add accessibility attributes
|
34
|
-
this.root.find(this.options.containerSelector).attr('role', 'dialog')
|
35
|
-
.attr('aria-describedby', contentId);
|
29
|
+
this.root.find(this.options.containerSelector).attr('role', 'dialog');
|
36
30
|
|
37
31
|
this.root.addClass('xooie-dialog');
|
38
32
|
|
@@ -52,7 +46,6 @@ define('xooie/dialog', ['jquery', 'xooie/base'], function($, Base) {
|
|
52
46
|
Dialog.setDefaultOptions({
|
53
47
|
closeButtonSelector: '[data-role="closeButton"]',
|
54
48
|
containerSelector: '[data-role="container"]',
|
55
|
-
contentSelector: '[data-role="content"]',
|
56
49
|
|
57
50
|
dialogActiveClass: 'is-dialog-active'
|
58
51
|
});
|
@@ -83,8 +76,6 @@ define('xooie/dialog', ['jquery', 'xooie/base'], function($, Base) {
|
|
83
76
|
|
84
77
|
Dialog._active = this;
|
85
78
|
|
86
|
-
this.getTabbable().first().focus();
|
87
|
-
|
88
79
|
this.root.trigger('dialogActive');
|
89
80
|
};
|
90
81
|
|
@@ -103,26 +94,6 @@ define('xooie/dialog', ['jquery', 'xooie/base'], function($, Base) {
|
|
103
94
|
this.root.trigger('dialogInactive');
|
104
95
|
};
|
105
96
|
|
106
|
-
// Loosely based on jQueryUI's tabbable selector logic
|
107
|
-
Dialog.prototype.getTabbable = function () {
|
108
|
-
return this.root.find(this.options.containerSelector).find('*').filter(function (i) {
|
109
|
-
var tag, tabindex, istabbable;
|
110
|
-
|
111
|
-
tag = this.nodeName.toLowerCase();
|
112
|
-
tabindex = parseInt($(this).attr('tabindex'), 10);
|
113
|
-
|
114
|
-
if (/input|select|textarea|button|object/.test(tag)) {
|
115
|
-
istabbable = !this.disabled && (isNaN(tabindex) || tabindex > -1);
|
116
|
-
} else if ('a' === tag || 'area' === tag) {
|
117
|
-
istabbable = this.href || tabindex > -1;
|
118
|
-
} else {
|
119
|
-
istabbable = tabindex > -1;
|
120
|
-
}
|
121
|
-
|
122
|
-
return istabbable && !$(this)['area' === tag ? 'parents' : 'closest'](':hidden').length;
|
123
|
-
});
|
124
|
-
};
|
125
|
-
|
126
97
|
Dialog._instances = [];
|
127
98
|
Dialog._counter = 0;
|
128
99
|
Dialog._active = null;
|
@@ -15,7 +15,7 @@
|
|
15
15
|
*/
|
16
16
|
|
17
17
|
define('xooie/dropdown', ['jquery', 'xooie/base'], function($, Base) {
|
18
|
-
|
18
|
+
|
19
19
|
var parseWhich = function(which) {
|
20
20
|
if (typeof which === 'string') {
|
21
21
|
which = which.split(',');
|
@@ -83,10 +83,6 @@ define('xooie/dropdown', ['jquery', 'xooie/base'], function($, Base) {
|
|
83
83
|
|
84
84
|
$(this).attr('aria-selected', false);
|
85
85
|
self.getExpander(index).attr('aria-hidden', true);
|
86
|
-
},
|
87
|
-
|
88
|
-
forceCollapse: function(event, data) {
|
89
|
-
self.collapse(data.index, data);
|
90
86
|
}
|
91
87
|
}, this.options.dropdownHandleSelector);
|
92
88
|
|
@@ -154,12 +150,8 @@ define('xooie/dropdown', ['jquery', 'xooie/base'], function($, Base) {
|
|
154
150
|
}
|
155
151
|
};
|
156
152
|
|
157
|
-
Dropdown.prototype.getNamespacedTrigger = function(trigger, state){
|
158
|
-
return trigger + '.' + state + 'XooieDropdown';
|
159
|
-
};
|
160
|
-
|
161
153
|
Dropdown.prototype.addHandlers = function(state, index){
|
162
|
-
var trigger,
|
154
|
+
var trigger, handle, triggerData, countName;
|
163
155
|
|
164
156
|
triggerData = this.options.triggers[state];
|
165
157
|
|
@@ -174,14 +166,12 @@ define('xooie/dropdown', ['jquery', 'xooie/base'], function($, Base) {
|
|
174
166
|
|
175
167
|
handle.data(countName, handle.data(countName) + 1 || 1);
|
176
168
|
|
177
|
-
|
178
|
-
|
179
|
-
handle.on(nsTrigger, $.extend({delay: 0, index: index}, triggerData[trigger]), this.handlers[state]);
|
169
|
+
handle.on(trigger, $.extend({delay: 0, index: index}, triggerData[trigger]), this.handlers[state]);
|
180
170
|
}
|
181
171
|
};
|
182
172
|
|
183
173
|
Dropdown.prototype.removeHandlers = function(state, index){
|
184
|
-
var trigger,
|
174
|
+
var trigger, handle, triggerData, countName, eventCount;
|
185
175
|
|
186
176
|
triggerData = this.options.triggers[state];
|
187
177
|
|
@@ -193,9 +183,7 @@ define('xooie/dropdown', ['jquery', 'xooie/base'], function($, Base) {
|
|
193
183
|
eventCount = handle.data(countName) - 1;
|
194
184
|
|
195
185
|
if (eventCount <= 0) {
|
196
|
-
|
197
|
-
|
198
|
-
handle.unbind(nsTrigger);
|
186
|
+
handle.unbind(trigger, this.handlers[state]);
|
199
187
|
|
200
188
|
handle.data(countName, 0);
|
201
189
|
} else {
|
@@ -0,0 +1,83 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2012 Comcast
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
define('xooie/event_handler', ['jquery', 'xooie/helpers'], function($, helpers) {
|
18
|
+
|
19
|
+
var EventHandler = function(namespace) {
|
20
|
+
this.namespace = namespace;
|
21
|
+
|
22
|
+
this.handlers = {};
|
23
|
+
|
24
|
+
this._callbacks = {};
|
25
|
+
};
|
26
|
+
|
27
|
+
function format(type, namespace) {
|
28
|
+
if (typeof namespace === 'undefined') {
|
29
|
+
return type;
|
30
|
+
} else {
|
31
|
+
return type + '.' + namespace;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
EventHandler.prototype.add = function(type, method) {
|
36
|
+
var self = this,
|
37
|
+
formattedType, t;
|
38
|
+
|
39
|
+
if (helpers.isObject(type) && helpers.isUndefined(method)) {
|
40
|
+
for(t in type) {
|
41
|
+
if (helpers.isFunction(type[t])) {
|
42
|
+
this.add(t, type[t]);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
|
49
|
+
formattedType = format(type, this.namespace);
|
50
|
+
|
51
|
+
if (helpers.isUndefined(this.handlers[formattedType])) {
|
52
|
+
this.handlers[formattedType] = function(e) {
|
53
|
+
self.fire(e, this, arguments);
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
if (helpers.isUndefined(this._callbacks[type])) {
|
58
|
+
this._callbacks[type] = $.Callbacks('unique');
|
59
|
+
}
|
60
|
+
|
61
|
+
this._callbacks[type].add(method);
|
62
|
+
};
|
63
|
+
|
64
|
+
EventHandler.prototype.clear = function(type) {
|
65
|
+
delete(this.handlers[format(type, this.namespace)]);
|
66
|
+
|
67
|
+
if (!helpers.isUndefined(this._callbacks[type])) {
|
68
|
+
this._callbacks[type].empty();
|
69
|
+
}
|
70
|
+
};
|
71
|
+
|
72
|
+
EventHandler.prototype.fire = function(event, context, args) {
|
73
|
+
if (event.namespace && event.namespace !== this.namespace) {
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
|
77
|
+
if (!helpers.isUndefined(this._callbacks[event.type])) {
|
78
|
+
this._callbacks[event.type].fireWith(context, args);
|
79
|
+
}
|
80
|
+
};
|
81
|
+
|
82
|
+
return EventHandler;
|
83
|
+
});
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2012 Comcast
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
/**
|
18
|
+
* class Xooie.helpers
|
19
|
+
*
|
20
|
+
* A collection of helper methods used by Xooie modules.
|
21
|
+
**/
|
22
|
+
|
23
|
+
define('xooie/helpers', ['jquery'], function($){
|
24
|
+
var helpers = {};
|
25
|
+
/**
|
26
|
+
* Xooie.helpers.toAry(str) -> Array
|
27
|
+
* - str (String | Array): The string to be converted to an array, or an array.
|
28
|
+
*
|
29
|
+
* Converts a string to an array, or returns the passed argument if it is already an array. Used
|
30
|
+
* when parsing data attributes that can be either a space-delineated string or an array.
|
31
|
+
**/
|
32
|
+
helpers.toAry = function(str) {
|
33
|
+
if (typeof str === 'string') {
|
34
|
+
return str.split(/\s+/);
|
35
|
+
} else if (str instanceof Array) {
|
36
|
+
return str;
|
37
|
+
}
|
38
|
+
};
|
39
|
+
|
40
|
+
helpers.toInt = function(int) {
|
41
|
+
return parseInt(int, 10);
|
42
|
+
};
|
43
|
+
|
44
|
+
helpers.isArray = Array.isArray || function(ary) {
|
45
|
+
return Array.prototype.toString(ary) === '[object Array]';
|
46
|
+
};
|
47
|
+
|
48
|
+
helpers.isObject = function(obj) {
|
49
|
+
return Object.prototype.toString(obj) === '[object Object]';
|
50
|
+
};
|
51
|
+
|
52
|
+
helpers.isUndefined = function(obj) {
|
53
|
+
return obj === void 0;
|
54
|
+
};
|
55
|
+
|
56
|
+
helpers.isFunction = function(func) {
|
57
|
+
return typeof func === 'function';
|
58
|
+
};
|
59
|
+
|
60
|
+
return helpers;
|
61
|
+
});
|