xooie 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +6 -0
- data/vendor/assets/javascripts/xooie/addons/base.js +0 -0
- 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/tab_animation.js +0 -0
- data/vendor/assets/javascripts/xooie/event_handler.js +2 -2
- data/vendor/assets/javascripts/xooie/stylesheet.js +0 -0
- data/vendor/assets/javascripts/xooie/widgets/accordion.js +11 -31
- data/vendor/assets/javascripts/xooie/widgets/carousel.js +5 -1
- data/vendor/assets/javascripts/xooie/widgets/tab.js +37 -14
- metadata +56 -51
- checksums.yaml +0 -7
- data/vendor/assets/javascripts/xooie/addons/dropdown_accordion.js +0 -38
- data/vendor/assets/javascripts/xooie/addons/tab_automation.js +0 -150
- data/vendor/assets/javascripts/xooie/base.js +0 -214
- data/vendor/assets/javascripts/xooie/carousel.js +0 -400
- data/vendor/assets/javascripts/xooie/dialog.js +0 -132
- data/vendor/assets/javascripts/xooie/dropdown.js +0 -273
- data/vendor/assets/javascripts/xooie/tab.js +0 -125
- data/vendor/assets/javascripts/xooie.js +0 -169
@@ -1,132 +0,0 @@
|
|
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/dialog', ['jquery', 'xooie/base'], function($, Base) {
|
18
|
-
|
19
|
-
var Dialog = Base('dialog', function(){
|
20
|
-
var self = this;
|
21
|
-
|
22
|
-
this.id = Dialog._counter++;
|
23
|
-
|
24
|
-
Dialog._instances[this.id] = this;
|
25
|
-
|
26
|
-
this.root.attr('data-dialog-id', this.id);
|
27
|
-
|
28
|
-
//add accessibility attributes
|
29
|
-
this.root.find(this.options.containerSelector).attr('role', 'dialog');
|
30
|
-
|
31
|
-
this.root.addClass('xooie-dialog');
|
32
|
-
|
33
|
-
this.handlers = {
|
34
|
-
mouseup: function(event){
|
35
|
-
Dialog.close(self.id);
|
36
|
-
},
|
37
|
-
|
38
|
-
keyup: function(event){
|
39
|
-
if([13,32].indexOf(event.which) !== -1){
|
40
|
-
Dialog.close(self.id);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
};
|
44
|
-
});
|
45
|
-
|
46
|
-
Dialog.setDefaultOptions({
|
47
|
-
closeButtonSelector: '[data-role="closeButton"]',
|
48
|
-
containerSelector: '[data-role="container"]',
|
49
|
-
|
50
|
-
dialogActiveClass: 'is-dialog-active'
|
51
|
-
});
|
52
|
-
|
53
|
-
Dialog.setCSSRules({
|
54
|
-
'.xooie-dialog': {
|
55
|
-
position: 'fixed',
|
56
|
-
top: 0,
|
57
|
-
bottom: 0,
|
58
|
-
left: 0,
|
59
|
-
right: 0
|
60
|
-
}
|
61
|
-
});
|
62
|
-
|
63
|
-
Dialog.prototype.activate = function(){
|
64
|
-
this.root.addClass(this.options.dialogActiveClass);
|
65
|
-
|
66
|
-
if(Dialog._active === this) {
|
67
|
-
return;
|
68
|
-
}
|
69
|
-
|
70
|
-
if(Dialog._active){
|
71
|
-
Dialog._active.deactivate();
|
72
|
-
}
|
73
|
-
|
74
|
-
this.root.find(this.options.closeButtonSelector)
|
75
|
-
.on(this.handlers);
|
76
|
-
|
77
|
-
Dialog._active = this;
|
78
|
-
|
79
|
-
this.root.trigger('dialogActive');
|
80
|
-
};
|
81
|
-
|
82
|
-
Dialog.prototype.deactivate = function(){
|
83
|
-
this.root.removeClass(this.options.dialogActiveClass);
|
84
|
-
|
85
|
-
if (Dialog._active !== this) {
|
86
|
-
return;
|
87
|
-
}
|
88
|
-
|
89
|
-
this.root.find(this.options.closeButtonSelector)
|
90
|
-
.off(this.handlers);
|
91
|
-
|
92
|
-
Dialog._active = null;
|
93
|
-
|
94
|
-
this.root.trigger('dialogInactive');
|
95
|
-
};
|
96
|
-
|
97
|
-
Dialog._instances = [];
|
98
|
-
Dialog._counter = 0;
|
99
|
-
Dialog._active = null;
|
100
|
-
Dialog._queue = [];
|
101
|
-
|
102
|
-
Dialog.open = function(id){
|
103
|
-
//get dialog instance
|
104
|
-
var dialog = this._instances[id];
|
105
|
-
|
106
|
-
if (typeof dialog === 'undefined' || this._active === dialog){
|
107
|
-
return;
|
108
|
-
}
|
109
|
-
|
110
|
-
if (this._active) {
|
111
|
-
this._queue.push(dialog);
|
112
|
-
} else {
|
113
|
-
dialog.activate();
|
114
|
-
}
|
115
|
-
|
116
|
-
};
|
117
|
-
|
118
|
-
Dialog.close = function(){
|
119
|
-
//get dialog instance
|
120
|
-
if(!this._active) {
|
121
|
-
return;
|
122
|
-
}
|
123
|
-
|
124
|
-
this._active.deactivate();
|
125
|
-
|
126
|
-
if (this._queue.length > 0) {
|
127
|
-
this._queue.pop().activate();
|
128
|
-
}
|
129
|
-
};
|
130
|
-
|
131
|
-
return Dialog;
|
132
|
-
});
|
@@ -1,273 +0,0 @@
|
|
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/dropdown', ['jquery', 'xooie/base'], function($, Base) {
|
18
|
-
|
19
|
-
var parseWhich = function(which) {
|
20
|
-
if (typeof which === 'string') {
|
21
|
-
which = which.split(',');
|
22
|
-
return which.map(function(string){ return parseInt(string, 10); });
|
23
|
-
} else if (typeof which === 'number') {
|
24
|
-
return [which];
|
25
|
-
}
|
26
|
-
|
27
|
-
return which;
|
28
|
-
};
|
29
|
-
|
30
|
-
var Dropdown = Base('dropdown', function() {
|
31
|
-
var self = this,
|
32
|
-
handles = self.getHandle(),
|
33
|
-
expanders = self.getExpander();
|
34
|
-
|
35
|
-
this.handlers = {
|
36
|
-
off: function(event){
|
37
|
-
if ((typeof event.data.not !== 'undefined' && ($(event.data.not).is($(this)) || $(event.target).parents(event.data.not).length > 0)) || (typeof event.data.which !== 'undefined' && event.data.which.indexOf(event.which) === -1) || ($(event.target).is(self.getExpander(event.data.index)) || $(event.target).parents(self.options.dropdownExpanderSelector).length > 0) && !$(event.target).is($(this))) {
|
38
|
-
return true;
|
39
|
-
}
|
40
|
-
|
41
|
-
event.preventDefault();
|
42
|
-
|
43
|
-
self.collapse(event.data.index, event.data);
|
44
|
-
},
|
45
|
-
|
46
|
-
on: function(event){
|
47
|
-
var index = event.data.index || parseInt($(this).attr('data-dropdown-index'), 10),
|
48
|
-
delay = event.data.delay,
|
49
|
-
handle = $(this);
|
50
|
-
|
51
|
-
if ((typeof event.data.not !== 'undefined' && ($(event.data.not).is($(this)) || $(event.target).parents(event.data.not).length > 0)) || typeof event.data.which !== 'undefined' && event.data.which.indexOf(event.which) === -1) {
|
52
|
-
return true;
|
53
|
-
}
|
54
|
-
|
55
|
-
event.preventDefault();
|
56
|
-
|
57
|
-
self.expand(index, event.data);
|
58
|
-
}
|
59
|
-
};
|
60
|
-
|
61
|
-
this.timers = {
|
62
|
-
expand: [],
|
63
|
-
collapse: [],
|
64
|
-
throttle: []
|
65
|
-
};
|
66
|
-
|
67
|
-
this.addHandlers('on');
|
68
|
-
|
69
|
-
this.root.on({
|
70
|
-
dropdownExpand: function(event, index){
|
71
|
-
self.removeHandlers('on', index);
|
72
|
-
|
73
|
-
self.addHandlers('off', index);
|
74
|
-
|
75
|
-
$(this).attr('aria-selected', true);
|
76
|
-
self.getExpander(index).attr('aria-hidden', false);
|
77
|
-
},
|
78
|
-
|
79
|
-
dropdownCollapse: function(event, index){
|
80
|
-
self.removeHandlers('off', index);
|
81
|
-
|
82
|
-
self.addHandlers('on', index);
|
83
|
-
|
84
|
-
$(this).attr('aria-selected', false);
|
85
|
-
self.getExpander(index).attr('aria-hidden', true);
|
86
|
-
}
|
87
|
-
}, this.options.dropdownHandleSelector);
|
88
|
-
|
89
|
-
this.root.on('xooie-init.dropdown xooie-refresh.dropdown', function(){
|
90
|
-
handles.each(function(index){
|
91
|
-
var handle = $(this),
|
92
|
-
expander = expanders.eq(index);
|
93
|
-
|
94
|
-
|
95
|
-
handle.attr({
|
96
|
-
'data-dropdown-index': index,
|
97
|
-
'aria-selected': false
|
98
|
-
});
|
99
|
-
expander.attr({
|
100
|
-
'data-dropdown-index': index,
|
101
|
-
'aria-hidden': true
|
102
|
-
});
|
103
|
-
});
|
104
|
-
});
|
105
|
-
|
106
|
-
expanders.on('mouseover focus', function(){
|
107
|
-
var index = parseInt($(this).attr('data-dropdown-index'), 10);
|
108
|
-
|
109
|
-
if (self.timers.collapse[index]){
|
110
|
-
self.timers.collapse[index] = clearTimeout(self.timers.collapse[index]);
|
111
|
-
|
112
|
-
$(this).on('mouseleave blur', {index: index}, function(event){
|
113
|
-
self.collapse(event.data.index, 0);
|
114
|
-
$(this).unbind(event);
|
115
|
-
});
|
116
|
-
}
|
117
|
-
});
|
118
|
-
|
119
|
-
});
|
120
|
-
|
121
|
-
Dropdown.setDefaultOptions({
|
122
|
-
dropdownHandleSelector: '[data-role="dropdown-handle"]',
|
123
|
-
dropdownExpanderSelector: '[data-role="dropdown-content"]',
|
124
|
-
|
125
|
-
activeDropdownClass: 'is-dropdown-active',
|
126
|
-
|
127
|
-
throttleDelay: 300,
|
128
|
-
triggers: {
|
129
|
-
on: {
|
130
|
-
focus: {
|
131
|
-
delay: 0
|
132
|
-
}
|
133
|
-
},
|
134
|
-
off: {
|
135
|
-
blur: {
|
136
|
-
delay: 0
|
137
|
-
}
|
138
|
-
}
|
139
|
-
}
|
140
|
-
|
141
|
-
});
|
142
|
-
|
143
|
-
Dropdown.prototype.getTriggerHandle = function(triggerData, index){
|
144
|
-
var handles = this.getHandle(index);
|
145
|
-
|
146
|
-
if (triggerData.selector) {
|
147
|
-
return triggerData.selector === 'document' ? $(document) : $(triggerData.selector);
|
148
|
-
} else {
|
149
|
-
return handles;
|
150
|
-
}
|
151
|
-
};
|
152
|
-
|
153
|
-
Dropdown.prototype.addHandlers = function(state, index){
|
154
|
-
var trigger, handle, triggerData, countName;
|
155
|
-
|
156
|
-
triggerData = this.options.triggers[state];
|
157
|
-
|
158
|
-
for (trigger in triggerData) {
|
159
|
-
if (typeof triggerData[trigger].which !== 'undefined') {
|
160
|
-
triggerData[trigger].which = parseWhich(triggerData[trigger].which);
|
161
|
-
}
|
162
|
-
|
163
|
-
countName = [trigger,state,'count'].join('-');
|
164
|
-
|
165
|
-
handle = this.getTriggerHandle(triggerData[trigger], index);
|
166
|
-
|
167
|
-
handle.data(countName, handle.data(countName) + 1 || 1);
|
168
|
-
|
169
|
-
handle.on(trigger, $.extend({delay: 0, index: index}, triggerData[trigger]), this.handlers[state]);
|
170
|
-
}
|
171
|
-
};
|
172
|
-
|
173
|
-
Dropdown.prototype.removeHandlers = function(state, index){
|
174
|
-
var trigger, handle, triggerData, countName, eventCount;
|
175
|
-
|
176
|
-
triggerData = this.options.triggers[state];
|
177
|
-
|
178
|
-
for (trigger in triggerData) {
|
179
|
-
handle = this.getTriggerHandle(triggerData[trigger], index);
|
180
|
-
|
181
|
-
countName = [trigger,state,'count'].join('-');
|
182
|
-
|
183
|
-
eventCount = handle.data(countName) - 1;
|
184
|
-
|
185
|
-
if (eventCount <= 0) {
|
186
|
-
handle.unbind(trigger, this.handlers[state]);
|
187
|
-
|
188
|
-
handle.data(countName, 0);
|
189
|
-
} else {
|
190
|
-
handle.data(countName, eventCount);
|
191
|
-
}
|
192
|
-
}
|
193
|
-
};
|
194
|
-
|
195
|
-
Dropdown.prototype.getHandle = function(index){
|
196
|
-
var handles = this.root.find(this.options.dropdownHandleSelector);
|
197
|
-
|
198
|
-
return (typeof index !== 'undefined' && index >= 0) ? handles.eq(index) : handles;
|
199
|
-
};
|
200
|
-
|
201
|
-
Dropdown.prototype.getExpander = function(index){
|
202
|
-
var selectorString;
|
203
|
-
|
204
|
-
if (typeof index === 'undefined' || isNaN(index)) {
|
205
|
-
selectorString = this.options.dropdownExpanderSelector;
|
206
|
-
} else {
|
207
|
-
selectorString = this.options.dropdownExpanderSelector + '[data-dropdown-index="' + index + '"]';
|
208
|
-
}
|
209
|
-
|
210
|
-
return this.root.find(selectorString);
|
211
|
-
};
|
212
|
-
|
213
|
-
Dropdown.prototype.setState = function(index, data, active){
|
214
|
-
if (typeof index === 'undefined' || isNaN(index)) {
|
215
|
-
return;
|
216
|
-
}
|
217
|
-
|
218
|
-
var state = active ? 'expand' : 'collapse',
|
219
|
-
counterState = active ? 'collapse' : 'expand',
|
220
|
-
delay = data.delay;
|
221
|
-
|
222
|
-
this.timers[counterState][index] = clearTimeout(this.timers[counterState][index]);
|
223
|
-
|
224
|
-
if (this.timers.throttle[index] || this.timers[state][index]) {
|
225
|
-
return;
|
226
|
-
}
|
227
|
-
|
228
|
-
this.timers[state][index] = setTimeout(function(i, _state, _active, _data) {
|
229
|
-
var expander = this.getExpander(i),
|
230
|
-
handle = this.getHandle(i),
|
231
|
-
self = this;
|
232
|
-
|
233
|
-
this.timers[_state][i] = clearTimeout(this.timers[_state][i]);
|
234
|
-
|
235
|
-
expander.toggleClass(this.options.activeDropdownClass, _active);
|
236
|
-
this.getHandle(i).toggleClass(this.options.activeDropdownClass, _active);
|
237
|
-
|
238
|
-
if (_active){
|
239
|
-
handle.trigger('dropdownExpand', [i, _data]);
|
240
|
-
//this.setFocus(expander);
|
241
|
-
} else {
|
242
|
-
handle.trigger('dropdownCollapse', [i, _data]);
|
243
|
-
}
|
244
|
-
|
245
|
-
if (this.options.throttleDelay > 0){
|
246
|
-
this.timers.throttle[i] = setTimeout(function(){
|
247
|
-
self.timers.throttle[i] = clearTimeout(self.timers.throttle[i]);
|
248
|
-
}, this.options.throttleDelay);
|
249
|
-
}
|
250
|
-
|
251
|
-
}.bind(this, index, state, active, data), delay);
|
252
|
-
};
|
253
|
-
|
254
|
-
Dropdown.prototype.expand = function(index, data) {
|
255
|
-
if (!this.getHandle(index).hasClass(this.options.activeDropdownClass)) {
|
256
|
-
this.setState(index, data, true);
|
257
|
-
}
|
258
|
-
};
|
259
|
-
|
260
|
-
Dropdown.prototype.collapse = function(index, data) {
|
261
|
-
if (this.getHandle(index).hasClass(this.options.activeDropdownClass)) {
|
262
|
-
this.setState(index, data, false);
|
263
|
-
}
|
264
|
-
};
|
265
|
-
|
266
|
-
Dropdown.prototype.setFocus = function(element){
|
267
|
-
element.find('a,input,textarea,button,select,iframe,[tabindex][tabindex!=-1]')
|
268
|
-
.first()
|
269
|
-
.focus();
|
270
|
-
};
|
271
|
-
|
272
|
-
return Dropdown;
|
273
|
-
});
|
@@ -1,125 +0,0 @@
|
|
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/tab', ['jquery', 'xooie/base'], function($, Base) {
|
18
|
-
|
19
|
-
var Tab = Base('tab', function() {
|
20
|
-
var self = this;
|
21
|
-
|
22
|
-
this.createTabs();
|
23
|
-
});
|
24
|
-
|
25
|
-
Tab.setDefaultOptions({
|
26
|
-
panelSelector: '[data-role="tab-panel"]',
|
27
|
-
stripSelector: '[data-role="tab-strip"]',
|
28
|
-
controlSelector: '[data-role="tab-selector"]',
|
29
|
-
controlButtonSelector: '[data-tab-control]',
|
30
|
-
tabTemplateSelector: '[data-role="tab-template"]',
|
31
|
-
|
32
|
-
activeTabClass: 'is-tab-active'
|
33
|
-
});
|
34
|
-
|
35
|
-
$.extend(Tab.prototype, {
|
36
|
-
switchToTab: function(index, key) {
|
37
|
-
if (index !== this._currentTab && index >= 0 && index < this.getPanel().length) {
|
38
|
-
var e = $.Event('tabChange');
|
39
|
-
e.fromTab = this._currentTab;
|
40
|
-
e.toTab = index;
|
41
|
-
e.which = key;
|
42
|
-
|
43
|
-
this.getPanel(this._currentTab).removeClass(this.options.activeTabClass);
|
44
|
-
this.getTab(this._currentTab).removeClass(this.options.activeTabClass);
|
45
|
-
|
46
|
-
this.getPanel(index).addClass(this.options.activeTabClass);
|
47
|
-
this.getTab(index).addClass(this.options.activeTabClass);
|
48
|
-
|
49
|
-
this._currentTab = index;
|
50
|
-
|
51
|
-
this.root.trigger(e);
|
52
|
-
}
|
53
|
-
},
|
54
|
-
|
55
|
-
getPanel: function(index) {
|
56
|
-
var panels = this.root.find(this.options.panelSelector);
|
57
|
-
|
58
|
-
if (typeof index === 'undefined') {
|
59
|
-
return panels;
|
60
|
-
} else {
|
61
|
-
return panels.eq(index);
|
62
|
-
}
|
63
|
-
},
|
64
|
-
|
65
|
-
getTab: function(index) {
|
66
|
-
var tabs = this.root.find(this.options.controlSelector);
|
67
|
-
if (typeof index === 'undefined') {
|
68
|
-
return tabs;
|
69
|
-
} else {
|
70
|
-
return tabs.eq(index);
|
71
|
-
}
|
72
|
-
},
|
73
|
-
|
74
|
-
createTabs: function() {
|
75
|
-
var tabStrip = this.root.find(this.options.stripSelector),
|
76
|
-
template = this.root.find(this.options.tabTemplateSelector),
|
77
|
-
panels = this.getPanel(),
|
78
|
-
i, element, control,
|
79
|
-
activeTab = 0, handler, self = this;
|
80
|
-
|
81
|
-
if (template.length === 0){
|
82
|
-
return;
|
83
|
-
}
|
84
|
-
|
85
|
-
this.getTab().remove();
|
86
|
-
|
87
|
-
handler = function(event) {
|
88
|
-
var keys = [13,32];
|
89
|
-
|
90
|
-
if ([1,13,32].indexOf(event.which) !== -1){
|
91
|
-
self.switchToTab($(this).data('tab-index'), event.which);
|
92
|
-
}
|
93
|
-
};
|
94
|
-
|
95
|
-
for (i = 0; i < panels.length; i++) {
|
96
|
-
if(tabStrip.length > 0 && template.length > 0) {
|
97
|
-
element = this.render(template, {
|
98
|
-
panel_label: panels.eq(i).attr('data-tab-label'),
|
99
|
-
panel_index: i,
|
100
|
-
panel_has_next: (i < panels.length - 1)
|
101
|
-
});
|
102
|
-
|
103
|
-
if (element.is(this.options.controlButtonSelector)) {
|
104
|
-
control = element;
|
105
|
-
} else {
|
106
|
-
control = element.find(this.options.controlButtonSelector);
|
107
|
-
}
|
108
|
-
|
109
|
-
control.data('tab-index', i)
|
110
|
-
.on('mouseup keyup', handler);
|
111
|
-
|
112
|
-
tabStrip.append(element);
|
113
|
-
}
|
114
|
-
|
115
|
-
if (panels.eq(i).hasClass(this.options.activeTabClass)) {
|
116
|
-
activeTab = i;
|
117
|
-
}
|
118
|
-
}
|
119
|
-
|
120
|
-
this.switchToTab(activeTab);
|
121
|
-
}
|
122
|
-
});
|
123
|
-
|
124
|
-
return Tab;
|
125
|
-
});
|
@@ -1,169 +0,0 @@
|
|
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
|
-
var $X, Xooie;
|
18
|
-
|
19
|
-
$X = Xooie = (function(static_config) {
|
20
|
-
var config = {
|
21
|
-
modules: {},
|
22
|
-
addons: {}
|
23
|
-
},
|
24
|
-
obj = function() {
|
25
|
-
return false;
|
26
|
-
},
|
27
|
-
gcTimer = null;
|
28
|
-
|
29
|
-
function copyObj(dst, src) {
|
30
|
-
var name;
|
31
|
-
|
32
|
-
for (name in src) {
|
33
|
-
if (src.hasOwnProperty(name)) {
|
34
|
-
dst[name] = src[name];
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
function gcCallback() {
|
40
|
-
if (typeof Xooie.garbageCollect !== 'undefined') {
|
41
|
-
Xooie.garbageCollect();
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
obj.config = function(cfg) {
|
46
|
-
var name;
|
47
|
-
|
48
|
-
for (name in cfg) {
|
49
|
-
if (cfg.hasOwnProperty(name)) {
|
50
|
-
if (name === 'modules' || name == 'addons') {
|
51
|
-
copyObj(config[name], cfg[name]);
|
52
|
-
} else {
|
53
|
-
config[name] = cfg[name];
|
54
|
-
}
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
if (typeof cfg.gcInterval !== 'undefined') {
|
59
|
-
if (config.gcInterval) {
|
60
|
-
gcTimer = setInterval(gcCallback, config.gcInterval);
|
61
|
-
} else {
|
62
|
-
if (gcTimer) {
|
63
|
-
clearInterval(gcTimer);
|
64
|
-
}
|
65
|
-
gcTimer = null;
|
66
|
-
}
|
67
|
-
}
|
68
|
-
};
|
69
|
-
|
70
|
-
obj.mapName = function(name, type, root) {
|
71
|
-
if (typeof config[type][name] === 'undefined') {
|
72
|
-
return root + name;
|
73
|
-
} else {
|
74
|
-
return config[type][name];
|
75
|
-
}
|
76
|
-
};
|
77
|
-
|
78
|
-
obj.config({
|
79
|
-
gcInterval: 0
|
80
|
-
});
|
81
|
-
|
82
|
-
if (static_config) {
|
83
|
-
obj.config(static_config);
|
84
|
-
}
|
85
|
-
|
86
|
-
return obj;
|
87
|
-
}(Xooie));
|
88
|
-
|
89
|
-
define('xooie', ['jquery'], function($){
|
90
|
-
var config = Xooie.config,
|
91
|
-
mapName = Xooie.mapName,
|
92
|
-
loadedModules = {};
|
93
|
-
|
94
|
-
$X = Xooie = function(element){
|
95
|
-
element = $(element);
|
96
|
-
|
97
|
-
var widgetElements = element.find('[data-widget-type]');
|
98
|
-
|
99
|
-
if (element.is('[data-widget-type]')){
|
100
|
-
widgetElements = widgetElements.add(element);
|
101
|
-
}
|
102
|
-
|
103
|
-
widgetElements.each(function(){
|
104
|
-
var node = $(this),
|
105
|
-
module_name,
|
106
|
-
types = node.data('widgetType').split(/\s+/),
|
107
|
-
require_handler = function(Widget) {
|
108
|
-
new Widget(node);
|
109
|
-
};
|
110
|
-
|
111
|
-
for (var i = 0; i < types.length; i++) {
|
112
|
-
module_name = $X.mapName(types[i], 'modules', 'xooie/');
|
113
|
-
|
114
|
-
$X._requireShim(module_name, require_handler);
|
115
|
-
}
|
116
|
-
});
|
117
|
-
};
|
118
|
-
|
119
|
-
Xooie.config = config;
|
120
|
-
Xooie.mapName = mapName;
|
121
|
-
|
122
|
-
Xooie._requireShim = function(module, callback) {
|
123
|
-
var moduleSpec;
|
124
|
-
|
125
|
-
if (typeof loadedModules[module] === 'undefined') {
|
126
|
-
moduleSpec = loadedModules[module] = {
|
127
|
-
content: null,
|
128
|
-
loaded: false,
|
129
|
-
callbacks: []
|
130
|
-
};
|
131
|
-
|
132
|
-
require([module], function(Module) {
|
133
|
-
var i;
|
134
|
-
|
135
|
-
moduleSpec.content = Module;
|
136
|
-
moduleSpec.loaded = true;
|
137
|
-
|
138
|
-
for (i = 0; i < moduleSpec.callbacks.length; i++) {
|
139
|
-
moduleSpec.callbacks[i](Module);
|
140
|
-
}
|
141
|
-
|
142
|
-
moduleSpec.callbacks = [];
|
143
|
-
});
|
144
|
-
} else {
|
145
|
-
moduleSpec = loadedModules[module];
|
146
|
-
}
|
147
|
-
|
148
|
-
if (moduleSpec.loaded) {
|
149
|
-
callback(moduleSpec.content);
|
150
|
-
} else {
|
151
|
-
moduleSpec.callbacks.push(callback);
|
152
|
-
}
|
153
|
-
};
|
154
|
-
|
155
|
-
Xooie.registeredClasses = [];
|
156
|
-
Xooie.garbageCollect = function() {
|
157
|
-
for (var i = 0; i < this.registeredClasses.length; i++) {
|
158
|
-
this.registeredClasses[i].garbageCollect();
|
159
|
-
}
|
160
|
-
};
|
161
|
-
|
162
|
-
return Xooie;
|
163
|
-
});
|
164
|
-
|
165
|
-
require(['jquery', 'xooie'], function($, $X){
|
166
|
-
$(document).ready(function() {
|
167
|
-
$X($(this));
|
168
|
-
});
|
169
|
-
});
|