xooie 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c87aa1306202800647994b0d91fbfe16cd4992cd
4
+ data.tar.gz: 2a42d82815fbe8b38ba052542bdae07c1003e2a2
5
+ SHA512:
6
+ metadata.gz: d95038096ccde4ec760e5519d10e37b338ecd9010432859af1b1240cf56ec9b0183c8e510ad024a225a1736b2497cf4e3e137434837f7081bb598f36d4959e6b
7
+ data.tar.gz: d9f4abf26f3c44e47b263658e1eee195bc016a1279902b0433a9e694544a38265b898f8de93e3c129c47ca4864004ca09c09a02c169f46bccbc43ee636359663
@@ -20,7 +20,9 @@
20
20
  * The base xooie addon module. This module defines how addons function in relation to
21
21
  * widgets, but contains no specific functionality.
22
22
  **/
23
- define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
23
+ define('xooie/addons/base', ['xooie/shared', 'xooie/helpers'], function (shared, helpers) {
24
+ "use strict";
25
+ var Addon;
24
26
  /**
25
27
  * Xooie.Addon@xooie-addon-init(event)
26
28
  * - event (Event): A jQuery event object
@@ -36,48 +38,30 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
36
38
  * Instantiating a new Addon associates the addon with the widget passed into the constructor. The addon is
37
39
  * stored in the [[Xooie.Widget#addons]] collection.
38
40
  **/
39
- var Addon = function(widget) {
40
- var self = this;
41
+ Addon = shared.create(function (widget) {
42
+ // Check to see if the module is defined:
43
+ if (helpers.isUndefined(widget)) {
44
+ return false;
45
+ }
41
46
 
42
- // Check to see if the module is defined:
43
- if (typeof widget === 'undefined') {
44
- return false;
45
- }
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
+ }
46
51
 
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
- }
52
+ // Add this addon to the widget's addons collection:
53
+ widget.addons()[this.name()] = this;
51
54
 
52
- // Add this addon to the widget's addons collection:
53
- widget.addons()[this.name()] = this;
55
+ widget.root().addClass(this.addonClass());
54
56
 
55
- widget.root().addClass(this.addonClass());
57
+ // Set the default options
58
+ shared.setData(this, widget.root().data());
56
59
 
57
- // Set the default options
58
- shared.setData(this, widget.root().data());
59
-
60
- // Reference the widget:
61
- this.widget(widget);
62
-
63
- // Check to see if there are any additional constructors to call;
64
- var initCheck = function(){
65
- var i;
66
-
67
- if (!self._extendCount || self._extendCount <= 0) {
68
- self.widget().root().trigger(self.get('initEvent'));
69
- self._extendCount = null;
70
- } else {
71
- setTimeout(initCheck, 0);
72
- }
73
- };
74
-
75
- if (this._extendCount > 0) {
76
- setTimeout(initCheck, 0);
77
- } else {
78
- initCheck();
79
- }
80
- };
60
+ // Reference the widget:
61
+ this.widget(widget);
62
+ }, function () {
63
+ this.widget().root().trigger(this.get('initEvent'));
64
+ });
81
65
 
82
66
  /**
83
67
  * Xooie.Addon.defineReadOnly(name, defaultValue)
@@ -86,9 +70,9 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
86
70
  *
87
71
  * See [[Xooie.shared.defineReadOnly]].
88
72
  **/
89
- Addon.defineReadOnly = function(name, defaultValue){
90
- shared.defineReadOnly(this, name, defaultValue);
91
- };
73
+ Addon.defineReadOnly = function (name, defaultValue) {
74
+ shared.defineReadOnly(this, name, defaultValue);
75
+ };
92
76
 
93
77
  /**
94
78
  * Xooie.Addon.defineWriteOnly(name)
@@ -96,9 +80,9 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
96
80
  *
97
81
  * See [[Xooie.shared.defineWriteOnly]].
98
82
  **/
99
- Addon.defineWriteOnly = function(name){
100
- shared.defineWriteOnly(this, name);
101
- };
83
+ Addon.defineWriteOnly = function (name) {
84
+ shared.defineWriteOnly(this, name);
85
+ };
102
86
 
103
87
  /**
104
88
  * Xooie.Widget.define(name[, defaultValue])
@@ -108,36 +92,39 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
108
92
  * A method that defines a property as both readable and writable. In reality it calls both [[Xooie.Addon.defineReadOnly]]
109
93
  * and [[Xooie.Addon.defineWriteOnly]].
110
94
  **/
111
- Addon.define = function(name, defaultValue){
112
- this.defineReadOnly(name, defaultValue);
113
- this.defineWriteOnly(name);
114
- };
95
+ Addon.define = function (name, defaultValue) {
96
+ this.defineReadOnly(name, defaultValue);
97
+ this.defineWriteOnly(name);
98
+ };
115
99
 
116
100
  /**
117
101
  * Xooie.Addon.extend(constr) -> Addon
118
102
  * - constr (Function): The constructor for the new [[Xooie.Addon]] class.
119
103
  *
120
- * See [[Xooie.shared.extend]].
104
+ * See [[Xooie.shared.create]].
121
105
  **/
122
- Addon.extend = function(constr){
123
- return shared.extend(constr, this);
124
- };
106
+ Addon.extend = function (constr, post_constr) {
107
+ return shared.create(constr, post_constr, this);
108
+ };
125
109
 
126
110
  /** internal
127
111
  * Xooie.Addon#_definedProps -> Array
128
112
  *
129
113
  * Same as [[Xooie.Widget#_definedProps]].
130
114
  **/
131
- Addon.prototype._definedProps = [];
115
+ Addon.prototype._definedProps = [];
132
116
 
133
117
  /** internal
118
+ <<<<<<< HEAD
134
119
  * Xooie.Addon#_extendCount -> Integer | null
135
120
  *
136
121
  * Same as [[Xooie.Widget#_extendCount]].
137
122
  **/
138
- Addon.prototype._extendCount = null;
123
+ Addon.prototype._extendCount = null;
139
124
 
140
125
  /** internal
126
+ =======
127
+ >>>>>>> bcde81f4a5817b1ab23f9f90ab6dd67cd86867b8
141
128
  * Xooie.Addon#_widget -> Widget
142
129
  *
143
130
  * The widget for which this addon was instantiated.
@@ -149,7 +136,7 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
149
136
  * The method for setting or getting [[Xooie.Addon#_widget]]. Returns the current value of
150
137
  * [[Xooie.Addon#_widget]] if no value is passed or sets the value.
151
138
  **/
152
- Addon.define('widget');
139
+ Addon.define('widget');
153
140
 
154
141
  /** internal
155
142
  * Xooie.Addon#_name -> String
@@ -163,7 +150,7 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
163
150
  * The method for setting or getting [[Xooie.Addon#_name]]. Returns the current value of
164
151
  * [[Xooie.Addon#_name]] if no value is passed or sets the value.
165
152
  **/
166
- Addon.define('name', 'addon');
153
+ Addon.define('name', 'addon');
167
154
 
168
155
  /** internal, read-only
169
156
  * Xooie.Addon#_initEvent -> String
@@ -175,7 +162,7 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
175
162
  *
176
163
  * The method for getting [[Xooie.Addon#_initEvent]].
177
164
  **/
178
- Addon.defineReadOnly('initEvent', 'xooie-addon-init');
165
+ Addon.defineReadOnly('initEvent', 'xooie-addon-init');
179
166
 
180
167
  /** internal, read-only
181
168
  * Xooie.Addon#_addonClass -> String
@@ -187,7 +174,7 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
187
174
  *
188
175
  * The method for getting [[Xooie.Addon#_addonClass]].
189
176
  **/
190
- Addon.defineReadOnly('addonClass', 'has-addon');
177
+ Addon.defineReadOnly('addonClass', 'has-addon');
191
178
 
192
179
  /**
193
180
  * Xooie.Addon#get(name) -> object
@@ -195,9 +182,9 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
195
182
  *
196
183
  * See [[Xooie.shared.get]].
197
184
  **/
198
- Addon.prototype.get = function(name) {
199
- return shared.get(this, name);
200
- };
185
+ Addon.prototype.get = function (name) {
186
+ return shared.get(this, name);
187
+ };
201
188
 
202
189
  /**
203
190
  * Xooie.Addon#set(name, value)
@@ -206,9 +193,9 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
206
193
  *
207
194
  * See [[Xooie.shared.set]].
208
195
  **/
209
- Addon.prototype.set = function(name, value) {
210
- return shared.set(this, name, value);
211
- };
196
+ Addon.prototype.set = function (name, value) {
197
+ return shared.set(this, name, value);
198
+ };
212
199
 
213
200
  /**
214
201
  * Xooie.Addon#cleanup()
@@ -216,9 +203,9 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
216
203
  * Removes the `addonClass` from the `root` of the associated `widget` and prepares this widget to be
217
204
  * garbage collected.
218
205
  **/
219
- Addon.prototype.cleanup = function() {
220
- this.widget().root().removeClass(this.addonClass());
221
- };
206
+ Addon.prototype.cleanup = function () {
207
+ this.widget().root().removeClass(this.addonClass());
208
+ };
222
209
 
223
210
  /** internal
224
211
  * Xooie.Addon#_process_initEvent(initEvent) -> String
@@ -226,9 +213,9 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
226
213
  *
227
214
  * Adds the [[Xooie.Addon#name]] to the `initEvent`
228
215
  **/
229
- Addon.prototype._process_initEvent = function(initEvent) {
230
- return this.name() === 'addon' ? initEvent : initEvent + '.' + this.name();
231
- };
216
+ Addon.prototype._process_initEvent = function (initEvent) {
217
+ return this.name() === 'addon' ? initEvent : initEvent + '.' + this.name();
218
+ };
232
219
 
233
220
  /** internal
234
221
  * Xooie.Addon#_process_addonClass(className) -> String
@@ -236,9 +223,9 @@ define('xooie/addons/base', ['jquery', 'xooie/shared'], function($, shared) {
236
223
  *
237
224
  * Adds the [[Xooie.Addon#name]] to the `addonClass`
238
225
  **/
239
- Addon.prototype._process_addonClass = function(addonClass) {
240
- return this.name() === 'addon' ? addonClass : 'has-' + this.name() + '-addon';
241
- };
226
+ Addon.prototype._process_addonClass = function (addonClass) {
227
+ return this.name() === 'addon' ? addonClass : 'has-' + this.name() + '-addon';
228
+ };
242
229
 
243
- return Addon;
230
+ return Addon;
244
231
  });
@@ -14,109 +14,110 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- define('xooie/addons/carousel_lentils', ['jquery', 'xooie/addons/base'], function($, Base) {
17
+ define('xooie/addons/carousel_lentils', ['jquery', 'xooie/addons/base', 'xooie/helpers'], function ($, Base, helpers) {
18
+ 'use strict';
18
19
 
19
- var Lentils = Base('lentils', function(){
20
- var self = this;
20
+ var Lentils = new Base('lentils', function () {
21
+ var self = this;
21
22
 
22
- this.lentilBuilders = {
23
- "item": function(container, template){
24
- var items = self.module.content.children(),
25
- element, i;
23
+ this.lentilBuilders = {
24
+ "item": function (container, template) {
25
+ var items, element, i;
26
26
 
27
- for (i = 0; i < items.length; i += 1) {
27
+ items = self.module.content.children();
28
28
 
29
- element = self.module.render(template, {
30
- number: i + 1,
31
- scroll_mode: "item",
32
- lentil_is_last: (i === items.length - 1)
33
- });
34
- container.append(element);
35
- }
36
- },
37
-
38
- "page": function(container, template){
39
- if (typeof self.module.addons.pagination === 'undefined') {
40
- return;
41
- }
29
+ for (i = 0; i < items.length; i += 1) {
30
+ element = self.module.render(template, {
31
+ number: i + 1,
32
+ scroll_mode: "item",
33
+ lentil_is_last: (i === items.length - 1)
34
+ });
35
+ container.append(element);
36
+ }
37
+ },
42
38
 
43
- var element, i;
39
+ "page": function (container, template) {
40
+ if (helpers.isUndefined(self.module.addons.pagination)) {
41
+ return;
42
+ }
44
43
 
45
- for (i = 0; i < self.module.addons.pagination._breaks.length; i += 1) {
46
- element = self.module.render(template, {
47
- number: i + 1,
48
- scroll_mode: "page",
49
- lentil_is_last: (i === self.module.addons.pagination._breaks.length - 1)
50
- });
44
+ var element, i;
51
45
 
52
- container.append(element);
53
- }
46
+ for (i = 0; i < self.module.addons.pagination._breaks.length; i += 1) {
47
+ element = self.module.render(template, {
48
+ number: i + 1,
49
+ scroll_mode: "page",
50
+ lentil_is_last: (i === self.module.addons.pagination._breaks.length - 1)
51
+ });
54
52
 
55
- }
53
+ container.append(element);
54
+ }
55
+ }
56
+ };
56
57
 
57
- };
58
+ this.module.root.addClass('is-carousel-lentiled');
58
59
 
59
- this.module.root.addClass('is-carousel-lentiled');
60
+ this.module.root.on('carouselUpdated', function () {
61
+ self.updateLentils();
62
+ });
60
63
 
61
- this.module.root.on('carouselUpdated', function(){
62
- self.updateLentils();
63
- });
64
+ this.module.root.on('carouselScrollComplete', function () {
65
+ self.currentLentil();
66
+ });
64
67
 
65
- this.module.root.on('carouselScrollComplete', function(){
66
- self.currentLentil();
67
- });
68
+ this.updateLentils();
68
69
 
69
- this.updateLentils();
70
+ this.currentLentil();
70
71
 
71
- this.currentLentil();
72
+ });
72
73
 
73
- });
74
+ Lentils.setDefaultOptions({
75
+ lentilMode: 'item',
76
+ lentilSelector: '[data-role="carousel-lentils"]',
77
+ lentilTemplateSelector: '[data-role="carousel-lentils-template"]',
74
78
 
75
- Lentils.setDefaultOptions({
76
- lentilMode: 'item',
77
- lentilSelector: '[data-role="carousel-lentils"]',
78
- lentilTemplateSelector: '[data-role="carousel-lentils-template"]',
79
+ activeLentilClass: 'is-active-lentil'
80
+ });
79
81
 
80
- activeLentilClass: 'is-active-lentil'
81
- });
82
+ Lentils.prototype.currentLentil = function () {
83
+ var container, lentils, index;
82
84
 
83
- Lentils.prototype.currentLentil = function(){
84
- var container = this.module.root.find(this.options.lentilSelector),
85
- lentils = container.children(),
86
- index;
85
+ container = this.module.root.find(this.options.lentilSelector);
86
+ lentils = container.children();
87
87
 
88
- if (this.options.lentilMode === 'page' && typeof this.module.addons.pagination !== 'undefined') {
89
- index = this.module.addons.pagination.currentPage();
90
- } else {
91
- index = this.module.currentItem();
92
- }
88
+ if (this.options.lentilMode === 'page' && !helpers.isUndefned(this.module.addons.pagination)) {
89
+ index = this.module.addons.pagination.currentPage();
90
+ } else {
91
+ index = this.module.currentItem();
92
+ }
93
93
 
94
- lentils.filter('.' + this.options.activeLentilClass).removeClass(this.options.activeLentilClass);
94
+ lentils.filter('.' + this.options.activeLentilClass).removeClass(this.options.activeLentilClass);
95
95
 
96
- lentils.eq(index).addClass(this.options.activeLentilClass);
97
- };
96
+ lentils.eq(index).addClass(this.options.activeLentilClass);
97
+ };
98
98
 
99
- Lentils.prototype.updateLentils = function() {
100
- var container = this.module.root.find(this.options.lentilSelector),
101
- template = this.module.root.find(this.options.lentilTemplateSelector),
102
- self = this;
99
+ Lentils.prototype.updateLentils = function () {
100
+ var container, template, self;
103
101
 
104
- if (container.length > 0 && template.length > 0) {
105
- container.html('');
102
+ container = this.module.root.find(this.options.lentilSelector);
103
+ template = this.module.root.find(this.options.lentilTemplateSelector);
104
+ self = this;
106
105
 
107
- if (typeof this.lentilBuilders[this.options.lentilMode] === 'function') {
108
- this.lentilBuilders[this.options.lentilMode](container, template);
106
+ if (container.length > 0 && template.length > 0) {
107
+ container.html('');
109
108
 
110
- container.children().on('click', function(event) {
111
- event.preventDefault();
112
- self.module.updatePosition($(this).data('scroll'));
113
- });
109
+ if (helpers.isFunction(this.lentilBuilders[this.options.lentilMode])) {
110
+ this.lentilBuilders[this.options.lentilMode](container, template);
114
111
 
115
- this.currentLentil();
112
+ container.children().on('click', function (event) {
113
+ event.preventDefault();
114
+ self.module.updatePosition($(this).data('scroll'));
115
+ });
116
116
 
117
- }
118
- }
119
- };
117
+ this.currentLentil();
118
+ }
119
+ }
120
+ };
120
121
 
121
- return Lentils;
122
- });
122
+ return Lentils;
123
+ });