xooie 0.1.0 → 0.1.1

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.
@@ -1,193 +0,0 @@
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
- * Xooie.shared.setData(instance, data)
174
- * - instance (Widget | Addon): The instance to set data on
175
- * - data (Object): A collection of key/value pairs
176
- *
177
- * Sets the properties to the values specified, as long as the property has been defined
178
- **/
179
- setData: function(instance, data) {
180
- var i, prop;
181
-
182
- for (i = 0; i < instance._definedProps.length; i++) {
183
- prop = instance._definedProps[i];
184
- if (typeof data[prop] !== 'undefined') {
185
- instance.set(prop, data[prop]);
186
- }
187
- }
188
- }
189
-
190
- };
191
-
192
- return shared;
193
- });
@@ -1,32 +0,0 @@
1
- define('xooie/widgets/accordion', ['jquery', 'xooie/widgets/tab'], function($, Tab){
2
- var Accordion = Tab.extend(function() {
3
- });
4
-
5
- Accordion.define('namespace', 'accordion');
6
-
7
- /** internal
8
- * Xooie.Accordion#_process_role_tablist(tablist) -> Element
9
- * - tablist (Element): A jQuery-selected collection of [[Xooie.Tab#tablists]]
10
- *
11
- * 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.
12
- **/
13
- Accordion.prototype._process_role_tablist = function(tablist) {
14
- Tab.prototype._process_role_tablist.apply(this, arguments);
15
-
16
- tablist.attr('aria-multiselectable', true);
17
-
18
- return tablist;
19
- };
20
-
21
- Accordion.prototype.selectTabs = function(event, selectedTab) {
22
- var activeTabs = this.getActiveTabs();
23
-
24
- if (activeTabs.is(selectedTab)) {
25
- return activeTabs.not(selectedTab);
26
- } else {
27
- return activeTabs.add(selectedTab);
28
- }
29
- };
30
-
31
- return Accordion;
32
- });