xooie 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,7 +32,15 @@ define('xooie/stylesheet', ['jquery'], function($) {
32
32
 
33
33
  if (document.styleSheets) {
34
34
  for (i = 0; i < document.styleSheets.length; i += 1){
35
- if (document.styleSheets[i].ownerNode.getAttribute('id') === name) {
35
+ if (document.styleSheets[i].ownerNode && document.styleSheets[i].ownerNode.getAttribute('id') === name) {
36
+ this._index = i;
37
+ }
38
+ }
39
+ }
40
+
41
+ if (typeof this._index === 'undefined') {
42
+ for (i = 0; i < document.styleSheets.length; i += 1){
43
+ if (document.styleSheets[i].id === name) {
36
44
  this._index = i;
37
45
  }
38
46
  }
@@ -111,4 +119,4 @@ define('xooie/stylesheet', ['jquery'], function($) {
111
119
 
112
120
  return Stylesheet;
113
121
 
114
- });
122
+ });
metadata CHANGED
@@ -1,35 +1,46 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: xooie
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
5
11
  platform: ruby
6
- authors:
12
+ authors:
7
13
  - Andrew Larkin
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
- date: 2013-11-01 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-11-21 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
14
21
  name: railties
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '3.1'
20
- type: :runtime
21
22
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
24
26
  - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '3.1'
27
+ - !ruby/object:Gem::Version
28
+ hash: 5
29
+ segments:
30
+ - 3
31
+ - 1
32
+ version: "3.1"
33
+ type: :runtime
34
+ version_requirements: *id001
27
35
  description: A highly modular, extensible JavaScript UI framework.
28
36
  email: andrewlarkin2@gmail.com
29
37
  executables: []
38
+
30
39
  extensions: []
40
+
31
41
  extra_rdoc_files: []
32
- files:
42
+
43
+ files:
33
44
  - vendor/assets/javascripts/xooie.js
34
45
  - vendor/assets/javascripts/xooie/addons/base.js
35
46
  - vendor/assets/javascripts/xooie/addons/carousel_lentils.js
@@ -41,44 +52,43 @@ files:
41
52
  - vendor/assets/javascripts/xooie/carousel.js
42
53
  - vendor/assets/javascripts/xooie/dialog.js
43
54
  - vendor/assets/javascripts/xooie/dropdown.js
44
- - vendor/assets/javascripts/xooie/event_handler.js
45
- - vendor/assets/javascripts/xooie/helpers.js
46
- - vendor/assets/javascripts/xooie/keyboard_navigation.js
47
- - vendor/assets/javascripts/xooie/shared.js
48
55
  - vendor/assets/javascripts/xooie/stylesheet.js
49
56
  - vendor/assets/javascripts/xooie/tab.js
50
- - vendor/assets/javascripts/xooie/widgets/accordion.js
51
- - vendor/assets/javascripts/xooie/widgets/base.js
52
- - vendor/assets/javascripts/xooie/widgets/carousel.js
53
- - vendor/assets/javascripts/xooie/widgets/dialog.js
54
- - vendor/assets/javascripts/xooie/widgets/dropdown.js
55
- - vendor/assets/javascripts/xooie/widgets/tab.js
56
- - vendor/assets/javascripts/xooie/xooie.js
57
57
  - lib/xooie.rb
58
58
  - README.md
59
59
  - License.txt
60
60
  homepage: http://github.com/Comcast/Xooie
61
- licenses:
61
+ licenses:
62
62
  - Apache
63
- metadata: {}
64
63
  post_install_message:
65
64
  rdoc_options: []
66
- require_paths:
65
+
66
+ require_paths:
67
67
  - lib
68
- required_ruby_version: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - ! '>='
71
- - !ruby/object:Gem::Version
72
- version: '0'
73
- required_rubygems_version: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
78
86
  requirements: []
87
+
79
88
  rubyforge_project:
80
- rubygems_version: 2.0.3
89
+ rubygems_version: 1.8.24
81
90
  signing_key:
82
- specification_version: 4
91
+ specification_version: 3
83
92
  summary: A highly modular, extensible JavaScript UI framework.
84
93
  test_files: []
94
+
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjU5YmQyYzFiMWZjYjExMmE1MTU2YmE2MzJiYTYxMzRmZDBkNjdjYQ==
5
- data.tar.gz: !binary |-
6
- MTc0ZGNiYTFlMThmMjkzMTQ0YzZiNjBjYjk4YjQwMzJmNGJkZmZkMA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- M2M2Yjg2OWVlYjYxOTRiZDhjMzdmMGFlMmRhYjAzNzY3ZDYzNzA0MzYxMDA0
10
- YmNjYWMyOWQ1MDUyZDc4M2RiOGFhNzYyZWZiMzY2Njg5YTMxNzg3OTMxYjVl
11
- YWQ5MjcwMTNhYTI5MGE4MmViNDUxOWFiZDk0NWM5Y2ZjNzFiM2Y=
12
- data.tar.gz: !binary |-
13
- NmJkYTZiMWIxMWQzNDYwZDUwNTBlOGYzNWNkY2VjMjgzYjNkMzQwNjY0NmM2
14
- YjYxN2U3NjljNDE0NTlhOTRiNjdmMWEyNGUwYjhjMGYzOTcwNzFiNzMzYzMy
15
- Mjg1OTY4NzVkM2YyNWEzNjcyNmM1MWNlODQwNjlmN2FhOTI4ZmQ=
@@ -1,83 +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/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 (!namespace) {
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
- });
@@ -1,61 +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
- /**
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
- });
@@ -1,216 +0,0 @@
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
- });