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
@@ -0,0 +1,216 @@
|
|
1
|
+
define('xooie/keyboard_navigation', ['jquery', 'xooie/helpers'], function($, helpers){
|
2
|
+
var selectors, keyboardNavigation, keybindings;
|
3
|
+
|
4
|
+
|
5
|
+
keybindings = {
|
6
|
+
37: function(event) {
|
7
|
+
moveFocus($(event.target), -1);
|
8
|
+
|
9
|
+
event.preventDefault();
|
10
|
+
},
|
11
|
+
|
12
|
+
38: function() {
|
13
|
+
|
14
|
+
},
|
15
|
+
|
16
|
+
39: function(event) {
|
17
|
+
moveFocus($(event.target), 1);
|
18
|
+
|
19
|
+
event.preventDefault();
|
20
|
+
},
|
21
|
+
|
22
|
+
40: function() {
|
23
|
+
|
24
|
+
}
|
25
|
+
};
|
26
|
+
|
27
|
+
/** internal
|
28
|
+
* Xooie.Widget._moveFocus(direction)
|
29
|
+
* - direction (Integer): Determines whether or not to increment or decrement the index. Can be 1 or -1.
|
30
|
+
*
|
31
|
+
* Moves focus to either the next or previous focusable item, if available. Focus order follows the
|
32
|
+
* tab order of the page (items without tabindex or tabindex=0 will be focused before tabindex=1). Focusable
|
33
|
+
* items with a tabindex=-1 will not be focused.
|
34
|
+
**/
|
35
|
+
function moveFocus(current, direction) {
|
36
|
+
// TODO: Clean this up. It's a mess
|
37
|
+
// TODO: Write tests.
|
38
|
+
// TODO: Add detection of new contexts
|
39
|
+
// TODO: Add recollection of last focused item
|
40
|
+
|
41
|
+
var selector, selectors, tabindex, index, target;
|
42
|
+
|
43
|
+
var tabIndicies= [];
|
44
|
+
|
45
|
+
selectors = {
|
46
|
+
unindexed: ['[data-widget-type] a[href]:visible:not(:disabled):not([tabindex])',
|
47
|
+
'[data-widget-type] button:visible:not(:disabled):not([tabindex])',
|
48
|
+
'[data-widget-type] input:visible:not(:disabled):not([tabindex])',
|
49
|
+
'[data-widget-type] select:visible:not(:disabled):not([tabindex])',
|
50
|
+
'[data-widget-type] textarea:visible:not(:disabled):not([tabindex])',
|
51
|
+
'[data-widget-type] [tabindex=0]:visible:not(:disabled)'].join(','),
|
52
|
+
indexed: function(t) {
|
53
|
+
if (t > 0) {
|
54
|
+
return '[data-widget-type] [tabindex=' + t + ']:visible:not(:disabled)';
|
55
|
+
}
|
56
|
+
},
|
57
|
+
allIndexed: '[data-widget-type] [tabindex]:visible:not(:disabled)'
|
58
|
+
};
|
59
|
+
|
60
|
+
// jquery select the current item
|
61
|
+
current = $(current);
|
62
|
+
|
63
|
+
// we may not be focused on anything. If that's the case, focus on the first focusable item
|
64
|
+
if (!current.is(selectors.unindexed) && !current.is(selectors.allIndexed)) {
|
65
|
+
// get the lowest tabindex
|
66
|
+
$(selectors.allIndexed).each(function(){
|
67
|
+
var i = helpers.toInt($(this).attr('tabindex'));
|
68
|
+
|
69
|
+
if (tabIndicies.indexOf(i) === -1 && i > 0) {
|
70
|
+
tabIndicies.push(i);
|
71
|
+
}
|
72
|
+
});
|
73
|
+
|
74
|
+
if (tabIndicies.length > 0) {
|
75
|
+
tabIndicies.sort(function(a,b) { return a-b; });
|
76
|
+
|
77
|
+
target = $(selectors.indexed(tabIndicies[0])).first();
|
78
|
+
} else {
|
79
|
+
target = $(selectors.unindexed).first();
|
80
|
+
}
|
81
|
+
|
82
|
+
if (target.length > 0) {
|
83
|
+
target.focus();
|
84
|
+
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
// get the current tabindex
|
90
|
+
tabindex = helpers.toInt(current.attr('tabindex'));
|
91
|
+
|
92
|
+
// check if tabindex is a number and not 0...
|
93
|
+
if (!tabindex) {
|
94
|
+
// if it is not, assume we're on an element that has no tab index and select other such elements
|
95
|
+
selector = selectors.unindexed;
|
96
|
+
} else {
|
97
|
+
// otherwise, select all items that are of the same tabindex
|
98
|
+
selector = selectors.indexed(tabindex);
|
99
|
+
}
|
100
|
+
|
101
|
+
// find the index of the current item
|
102
|
+
index = current.index(selector);
|
103
|
+
|
104
|
+
if (index + direction >= 0) {
|
105
|
+
// get the next/previous item
|
106
|
+
target = $(selector).eq(index + direction);
|
107
|
+
|
108
|
+
// Check to see if we have a valid target...
|
109
|
+
if (target.length > 0) {
|
110
|
+
// if it is, focus the target and return
|
111
|
+
target.focus();
|
112
|
+
|
113
|
+
return;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
// if it is not, then we have several possibilities:
|
118
|
+
|
119
|
+
// If the direction is 1 and tabindex is not a number or 0, then we are at the end of the tab order. Do nothing.
|
120
|
+
if (direction === 1 && !tabindex) {
|
121
|
+
return;
|
122
|
+
// If the direction is 1 and the tabindex is a number, then we need to check for the presence of the next tabindex
|
123
|
+
} else if (direction === 1 && !isNaN(tabindex)) {
|
124
|
+
// Loop through all elements with a tab index
|
125
|
+
$(selectors.allIndexed).each(function() {
|
126
|
+
// Build a collection of all tab indicies greater than the current tab index:
|
127
|
+
var i = helpers.toInt($(this).attr('tabindex'));
|
128
|
+
|
129
|
+
if (i > tabindex && tabIndicies.indexOf(i) === -1 && i > 0) {
|
130
|
+
tabIndicies.push(i);
|
131
|
+
}
|
132
|
+
});
|
133
|
+
|
134
|
+
// If there are tab indicies that are greater than the current one...
|
135
|
+
if (tabIndicies.length > 0) {
|
136
|
+
// sort our tab indicies ascending
|
137
|
+
tabIndicies.sort(function(a, b) { return a-b; });
|
138
|
+
|
139
|
+
// we now have our new tab index
|
140
|
+
tabindex = tabIndicies[0];
|
141
|
+
|
142
|
+
// Get the first item of the new tab index
|
143
|
+
target = $(selectors.indexed(tabindex)).first();
|
144
|
+
} else {
|
145
|
+
// Otherwise, select the first unindexed item
|
146
|
+
target = $(selectors.unindexed).first();
|
147
|
+
}
|
148
|
+
|
149
|
+
} else if (direction === -1 && isNaN(tabindex)) {
|
150
|
+
// In this case, we are at the first non-indexed focusable item. We need to find the last indexed item.
|
151
|
+
// Loop through all elements with a tab index
|
152
|
+
$(selectors.allIndexed).each(function() {
|
153
|
+
var i = helpers.toInt($(this).attr('tabindex'));
|
154
|
+
// Build a collection of all tab indicies
|
155
|
+
if (tabIndicies.indexOf(i) === -1) {
|
156
|
+
tabIndicies.push(i);
|
157
|
+
}
|
158
|
+
});
|
159
|
+
|
160
|
+
if (tabIndicies.length > 0) {
|
161
|
+
// sort our tab indicies descending
|
162
|
+
tabIndicies.sort(function(a, b) { return b-a; });
|
163
|
+
|
164
|
+
// we now have our new tab index
|
165
|
+
tabindex = tabIndicies[0];
|
166
|
+
|
167
|
+
// Select the last indexed item
|
168
|
+
target = $(selectors.indexed(tabindex)).last();
|
169
|
+
}
|
170
|
+
} else if (direction === -1 && !isNaN(tabindex) && tabindex > 0) {
|
171
|
+
$(selectors.allIndexed).each(function(){
|
172
|
+
var i = helpers.toInt($(this).attr('tabindex'));
|
173
|
+
|
174
|
+
if (i < tabindex && tabIndicies.indexOf(i) === -1 && i > 0) {
|
175
|
+
tabIndicies.push(i);
|
176
|
+
}
|
177
|
+
});
|
178
|
+
|
179
|
+
if (tabIndicies.length > 0) {
|
180
|
+
// sort our tab indicies asceding
|
181
|
+
tabIndicies.sort(function(a, b) { return a-b; });
|
182
|
+
|
183
|
+
// we now have our new tab index
|
184
|
+
tabindex = tabIndicies[0];
|
185
|
+
|
186
|
+
// Select the last indexed item
|
187
|
+
target = $(selectors.indexed(tabindex)).last();
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
if (!helpers.isUndefined(target)) {
|
192
|
+
// assuming we have a target, focus it.
|
193
|
+
target.focus();
|
194
|
+
}
|
195
|
+
|
196
|
+
}
|
197
|
+
|
198
|
+
var instantiated;
|
199
|
+
|
200
|
+
keyboardNavigation = function(){
|
201
|
+
if (instantiated) {
|
202
|
+
return instantiated;
|
203
|
+
}
|
204
|
+
|
205
|
+
$(document).on('keyup', function(event) {
|
206
|
+
if (helpers.isFunction(keybindings[event.which])) {
|
207
|
+
keybindings[event.which](event);
|
208
|
+
}
|
209
|
+
});
|
210
|
+
|
211
|
+
instantiated = this;
|
212
|
+
};
|
213
|
+
|
214
|
+
return keyboardNavigation;
|
215
|
+
|
216
|
+
});
|
@@ -0,0 +1,175 @@
|
|
1
|
+
/**
|
2
|
+
* class Xooie.shared
|
3
|
+
*
|
4
|
+
* A module that contains functionality that is used both by [[Xooie.Widget]] and [[Xooie.Addon]]
|
5
|
+
* This module exists to abstract common functionality so that it can be maintained in one place.
|
6
|
+
* It is not intended to be used independently.
|
7
|
+
**/
|
8
|
+
define('xooie/shared', ['jquery'], function($){
|
9
|
+
|
10
|
+
/** internal
|
11
|
+
* Xooie.shared.propertyDetails(name) -> Object
|
12
|
+
* - name (String): The name of the property
|
13
|
+
*
|
14
|
+
* Generates a hash of attributes that will be used in setting and getting the property.
|
15
|
+
*
|
16
|
+
* ##### Return values
|
17
|
+
*
|
18
|
+
* - **getter** (String): The name of the internal getter method for this property.
|
19
|
+
* `_get_name`
|
20
|
+
* - **setter** (String): The name of the internal setter method for this property.
|
21
|
+
* `_set_name`
|
22
|
+
* - **processor** (String): The name of the internal processor method for this property.
|
23
|
+
* `_process_name`
|
24
|
+
* - **validator** (String): The name of the internal validator method for this property.
|
25
|
+
* `_validate_name`
|
26
|
+
* **default** (String): The name of the internally stored default value for this property.
|
27
|
+
* `_default_name`
|
28
|
+
* - **value** (String): The name of the internally stored value for this property.
|
29
|
+
* `_name`
|
30
|
+
**/
|
31
|
+
function propertyDetails (name) {
|
32
|
+
return {
|
33
|
+
getter: '_get_' + name,
|
34
|
+
setter: '_set_' + name,
|
35
|
+
processor: '_process_' + name,
|
36
|
+
validator: '_validate_' + name,
|
37
|
+
defaultValue: '_default_value_' + name,
|
38
|
+
value: '_' + name
|
39
|
+
};
|
40
|
+
}
|
41
|
+
|
42
|
+
/** internal
|
43
|
+
* Xooie.shared.propertyDispatcher(name, prototype)
|
44
|
+
* - name (String): The name of the property
|
45
|
+
* - prototype (Object): The prototype of the [[Xooie.Widget]] or [[Xooie.Addon]] for which the property is being set.
|
46
|
+
*
|
47
|
+
* Gets the [[Xooie.shared.propertyDetails]] for the property, adds the `name` to the list of [[Xooie.Widget#_definedProps]]
|
48
|
+
* (or [[Xooie.Addon#_definedProps]]). Adds a method called `name` to the prototype that allows this property to be set or
|
49
|
+
* retrieved.
|
50
|
+
**/
|
51
|
+
function propertyDispatcher (name, prototype) {
|
52
|
+
var prop = propertyDetails(name);
|
53
|
+
|
54
|
+
if (typeof prototype[name] !== 'function') {
|
55
|
+
prototype._definedProps.push(name);
|
56
|
+
|
57
|
+
prototype[name] = function(value) {
|
58
|
+
if (typeof value === 'undefined') {
|
59
|
+
return this[prop.getter]();
|
60
|
+
} else {
|
61
|
+
return this[prop.setter](value);
|
62
|
+
}
|
63
|
+
};
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
var shared = {
|
68
|
+
/**
|
69
|
+
* Xooie.shared.defineReadOnly(module, name[, defaultValue])
|
70
|
+
* - module (Widget | Addon): The module on which this property will be defined.
|
71
|
+
* - name (String): The name of the property to define as a read-only property.
|
72
|
+
* - defaultValue (Object): An optional default value.
|
73
|
+
*
|
74
|
+
* Defines a read-only property that can be accessed either by [[Xooie.Widget#get]]/[[Xooie.Addon#get]] or
|
75
|
+
* calling the `{{name}}` method on the instance of the module.
|
76
|
+
**/
|
77
|
+
defineReadOnly: function(module, name, defaultValue){
|
78
|
+
var prop = propertyDetails(name);
|
79
|
+
|
80
|
+
propertyDispatcher(name, module.prototype);
|
81
|
+
|
82
|
+
//The default value is reset each time this method is called;
|
83
|
+
module.prototype[prop.defaultValue] = defaultValue;
|
84
|
+
|
85
|
+
if (typeof module.prototype[prop.getter] !== 'function') {
|
86
|
+
module.prototype[prop.getter] = function() {
|
87
|
+
var value = typeof this[prop.value] !== 'undefined' ? this[prop.value] : this[prop.defaultValue];
|
88
|
+
|
89
|
+
if (typeof this[prop.processor] === 'function') {
|
90
|
+
return this[prop.processor](value);
|
91
|
+
}
|
92
|
+
|
93
|
+
return value;
|
94
|
+
};
|
95
|
+
}
|
96
|
+
},
|
97
|
+
/**
|
98
|
+
* Xooie.shared.defineWriteOnly(module, name)
|
99
|
+
* - module (Widget | Addon): The module on which this property will be defined.
|
100
|
+
* - name (String): The name of the property to define as a write-only property
|
101
|
+
*
|
102
|
+
* Defines a write-only property that can be set using [[Xooie.Widget#set]]/[[Xooie.Addon#set]] or by passing
|
103
|
+
* a value to the `{{name}}` method on the instance of the module.
|
104
|
+
**/
|
105
|
+
defineWriteOnly: function(module, name){
|
106
|
+
var prop = propertyDetails(name);
|
107
|
+
|
108
|
+
propertyDispatcher(name, module.prototype);
|
109
|
+
|
110
|
+
if (typeof module.prototype[prop.setter] !== 'function') {
|
111
|
+
module.prototype[prop.setter] = function(value){
|
112
|
+
if (typeof this[prop.validator] !== 'function' || this[prop.validator](name)) {
|
113
|
+
this[prop.value] = value;
|
114
|
+
}
|
115
|
+
};
|
116
|
+
}
|
117
|
+
},
|
118
|
+
/**
|
119
|
+
* Xooie.shared.extend(constr, _super) -> Widget | Addon
|
120
|
+
* - constr (Function): The constructor for the new [[Xooie.Widget]] or [[Xooie.Addon]] class.
|
121
|
+
* - _super (Widget | Addon): The module which is to be extended
|
122
|
+
*
|
123
|
+
* Creates a new Xooie widget/addon class that inherits all properties from the extended class.
|
124
|
+
* Constructors for the class are called in order from the top-level constructor to the
|
125
|
+
* base constructor.
|
126
|
+
**/
|
127
|
+
extend: function(constr, module){
|
128
|
+
var newModule = (function(){
|
129
|
+
return function Child() {
|
130
|
+
module.apply(this, arguments);
|
131
|
+
constr.apply(this, arguments);
|
132
|
+
this._extendCount -= 1;
|
133
|
+
};
|
134
|
+
})();
|
135
|
+
|
136
|
+
|
137
|
+
$.extend(true, newModule, module);
|
138
|
+
$.extend(true, newModule.prototype, module.prototype);
|
139
|
+
|
140
|
+
newModule.prototype._extendCount = newModule.prototype._extendCount === null ? 1 : newModule.prototype._extendCount += 1;
|
141
|
+
|
142
|
+
return newModule;
|
143
|
+
},
|
144
|
+
/**
|
145
|
+
* Xooie.shared.get(instance, name) -> object
|
146
|
+
* - instance (Widget | Addon): The instance from which the property is to be retrieved.
|
147
|
+
* - name (String): The name of the property to be retrieved.
|
148
|
+
*
|
149
|
+
* Retrieves the value of the property. Returns `undefined` if the property has not been defined.
|
150
|
+
**/
|
151
|
+
get: function(instance, name){
|
152
|
+
var prop = propertyDetails(name);
|
153
|
+
|
154
|
+
return instance[prop.getter]();
|
155
|
+
},
|
156
|
+
/**
|
157
|
+
* Xooie.shared.set(instance, name, value)
|
158
|
+
* - instance (Widget | Addon): The instance where the property is being set.
|
159
|
+
* - name (String): The name of the property to be set.
|
160
|
+
* - value: The value of the property to be set.
|
161
|
+
*
|
162
|
+
* Sets a property, so long as that property has been defined.
|
163
|
+
**/
|
164
|
+
set: function(instance, name, value){
|
165
|
+
var prop = propertyDetails(name);
|
166
|
+
|
167
|
+
if (typeof instance[prop.setter] === 'function') {
|
168
|
+
instance[prop.setter](value);
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
};
|
173
|
+
|
174
|
+
return shared;
|
175
|
+
});
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright
|
2
|
+
* Copyright 2012 Comcast
|
3
3
|
*
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
* you may not use this file except in compliance with the License.
|
@@ -14,102 +14,101 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
define('xooie/stylesheet', ['jquery'], function
|
18
|
-
|
17
|
+
define('xooie/stylesheet', ['jquery'], function($) {
|
18
|
+
var Stylesheet = function(name){
|
19
|
+
var i, title;
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
this.element = $('style[id=' + name + ']');
|
21
|
+
//check to see if a stylesheet already exists with this name
|
22
|
+
this.element = $('style[id=' + name + ']');
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
if (this.element.length <= 0) {
|
25
|
+
//if it does, use it, else create a new one
|
26
|
+
this.element = $(['<style id="' + name + '">',
|
27
|
+
'/* This is a dynamically generated stylesheet: ' + name + ' */',
|
28
|
+
'</style>'].join(''));
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
this._name = name;
|
34
|
-
};
|
35
|
-
|
36
|
-
Stylesheet.prototype.get = function () {
|
37
|
-
return this.element[0].sheet || this.element[0].styleSheet;
|
38
|
-
};
|
39
|
-
|
40
|
-
Stylesheet.prototype.getRule = function (ruleName) {
|
41
|
-
var i, rules;
|
30
|
+
this.element.appendTo($('head'));
|
31
|
+
}
|
42
32
|
|
43
|
-
|
33
|
+
if (document.styleSheets) {
|
34
|
+
for (i = 0; i < document.styleSheets.length; i += 1){
|
35
|
+
if (document.styleSheets[i].ownerNode.getAttribute('id') === name) {
|
36
|
+
this._index = i;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
};
|
44
41
|
|
45
|
-
|
46
|
-
|
42
|
+
Stylesheet.prototype.get = function(){
|
43
|
+
return document.styleSheets[this._index];
|
44
|
+
};
|
47
45
|
|
48
|
-
|
49
|
-
|
50
|
-
return rules[i];
|
51
|
-
}
|
52
|
-
}
|
46
|
+
Stylesheet.prototype.getRule = function(ruleName){
|
47
|
+
ruleName = ruleName.toLowerCase();
|
53
48
|
|
54
|
-
|
55
|
-
};
|
49
|
+
var i, rules;
|
56
50
|
|
57
|
-
|
58
|
-
|
51
|
+
//Check if this uses the IE format (styleSheet.rules) or the Mozilla/Webkit format
|
52
|
+
rules = this.get().cssRules || this.get().rules;
|
59
53
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
54
|
+
for (i = 0; i < rules.length; i += 1){
|
55
|
+
if (rules[i].selectorText.toLowerCase() === ruleName) {
|
56
|
+
return rules[i];
|
57
|
+
}
|
64
58
|
}
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
this.
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
59
|
+
|
60
|
+
return false;
|
61
|
+
};
|
62
|
+
|
63
|
+
Stylesheet.prototype.addRule = function(ruleName, properties){
|
64
|
+
var rule = this.getRule(ruleName), index, prop, propString = '';
|
65
|
+
|
66
|
+
if (!rule){
|
67
|
+
for (prop in properties) {
|
68
|
+
propString += prop + ': ' + properties[prop] + ';';
|
69
|
+
}
|
70
|
+
|
71
|
+
if (this.get().insertRule) {
|
72
|
+
//This is the W3C-preferred method
|
73
|
+
index = this.get().cssRules.length;
|
74
|
+
this.get().insertRule(ruleName + ' {' + propString + '}', index);
|
75
|
+
rule = this.get().cssRules[index];
|
76
|
+
} else {
|
77
|
+
//support for IE < 9
|
78
|
+
index = this.get().rules.length;
|
79
|
+
this.get().addRule(ruleName, propString, index);
|
80
|
+
rule = this.get().rules[index];
|
81
|
+
}
|
79
82
|
}
|
80
83
|
|
81
|
-
rule
|
82
|
-
|
83
|
-
}
|
84
|
+
return rule;
|
85
|
+
};
|
84
86
|
|
85
|
-
|
86
|
-
|
87
|
+
Stylesheet.prototype.deleteRule = function(ruleName){
|
88
|
+
ruleName = ruleName.toLowerCase();
|
87
89
|
|
88
|
-
|
89
|
-
var i, rules;
|
90
|
+
var i, rules;
|
90
91
|
|
91
|
-
|
92
|
+
//Check if this uses the IE format (styleSheet.rules) or the Mozilla/Webkit format
|
93
|
+
rules = this.get().cssRules || this.get().rules;
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
+
for (i = 0; i < rules.length; i += 1){
|
96
|
+
if (rules[i].selectorText.toLowerCase() === ruleName) {
|
97
|
+
if (this.get().deleteRule) {
|
98
|
+
//this is the W3C-preferred method
|
99
|
+
this.get().deleteRule(i);
|
100
|
+
} else {
|
101
|
+
//support for IE < 9
|
102
|
+
this.get().removeRule(i);
|
103
|
+
}
|
95
104
|
|
96
|
-
|
97
|
-
|
98
|
-
if (this.get().deleteRule) {
|
99
|
-
//this is the W3C-preferred method
|
100
|
-
this.get().deleteRule(i);
|
101
|
-
} else {
|
102
|
-
//support for IE < 9
|
103
|
-
this.get().removeRule(i);
|
105
|
+
return true;
|
106
|
+
}
|
104
107
|
}
|
105
108
|
|
106
|
-
return
|
107
|
-
|
108
|
-
}
|
109
|
-
|
110
|
-
return false;
|
111
|
-
};
|
109
|
+
return false;
|
110
|
+
};
|
112
111
|
|
113
|
-
|
112
|
+
return Stylesheet;
|
114
113
|
|
115
114
|
});
|
File without changes
|
@@ -0,0 +1,52 @@
|
|
1
|
+
define('xooie/widgets/accordion', ['jquery', 'xooie/widgets/tab'], function($, Tab){
|
2
|
+
var Accordion = Tab.extend(function() {
|
3
|
+
var self = this;
|
4
|
+
|
5
|
+
this._tabEvents.clear('keyup');
|
6
|
+
this._tabEvents.clear('mouseup');
|
7
|
+
|
8
|
+
this._tabEvents.add({
|
9
|
+
keyup: function(event){
|
10
|
+
var activeTab = self.getActiveTabs();
|
11
|
+
|
12
|
+
if ([13,32].indexOf(event.which) !== -1){
|
13
|
+
if (activeTab.is(this)) {
|
14
|
+
self.deactivateTab($(this));
|
15
|
+
} else {
|
16
|
+
self.activateTab($(this));
|
17
|
+
}
|
18
|
+
|
19
|
+
event.preventDefault();
|
20
|
+
}
|
21
|
+
},
|
22
|
+
|
23
|
+
mouseup: function(){
|
24
|
+
var activeTab = self.getActiveTabs();
|
25
|
+
|
26
|
+
if (activeTab.is(this)) {
|
27
|
+
self.deactivateTab($(this));
|
28
|
+
} else {
|
29
|
+
self.activateTab($(this));
|
30
|
+
}
|
31
|
+
}
|
32
|
+
});
|
33
|
+
});
|
34
|
+
|
35
|
+
Accordion.define('namespace', 'accordion');
|
36
|
+
|
37
|
+
/** internal
|
38
|
+
* Xooie.Accordion#_process_role_tablist(tablist) -> Element
|
39
|
+
* - tablist (Element): A jQuery-selected collection of [[Xooie.Tab#tablists]]
|
40
|
+
*
|
41
|
+
* Same as [[Xooie.Tab#_process_role_tablist]] and also adds the [`aria-multiselectable="true"`](http://www.w3.org/TR/wai-aria/states_and_properties#aria-multiselectable) attribute.
|
42
|
+
**/
|
43
|
+
Accordion.prototype._process_role_tablist = function(tablist) {
|
44
|
+
Tab.prototype._process_role_tablist.apply(this, arguments);
|
45
|
+
|
46
|
+
tablist.attr('aria-multiselectable', true);
|
47
|
+
|
48
|
+
return tablist;
|
49
|
+
};
|
50
|
+
|
51
|
+
return Accordion;
|
52
|
+
});
|