flashgrid 1.0.13 → 1.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
- +function ($) { "use strict";
1
+ +function ($) {
2
+ 'use strict';
2
3
 
3
4
  // POPOVER PUBLIC CLASS DEFINITION
4
5
  // ===============================
@@ -9,11 +10,11 @@
9
10
 
10
11
  if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
11
12
 
12
- Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
13
- placement: 'right'
14
- , trigger: 'click'
15
- , content: ''
16
- , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
13
+ Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
14
+ placement: 'right',
15
+ trigger: 'click',
16
+ content: '',
17
+ template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
17
18
  })
18
19
 
19
20
 
@@ -34,7 +35,9 @@
34
35
  var content = this.getContent()
35
36
 
36
37
  $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
37
- $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
38
+ $tip.find('.popover-content')[ // we use append for html objects to maintain js events
39
+ this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
40
+ ](content)
38
41
 
39
42
  $tip.removeClass('fade top bottom left right in')
40
43
 
@@ -78,6 +81,7 @@
78
81
  var data = $this.data('bs.popover')
79
82
  var options = typeof option == 'object' && option
80
83
 
84
+ if (!data && option == 'destroy') return
81
85
  if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
82
86
  if (typeof option == 'string') data[option]()
83
87
  })
@@ -1,346 +1,415 @@
1
- !function ($) {
2
- "use strict";
3
-
4
- $.fn['switch'] = function (method) {
5
- var inputSelector = 'input[type!="hidden"]';
6
- var methods = {
7
- init: function () {
8
- return this.each(function () {
9
- var $element = $(this)
10
- , $div
11
- , $switchLeft
12
- , $switchRight
13
- , $label
14
- , $form = $element.closest('form')
15
- , myClasses = ""
16
- , classes = $element.attr('class')
17
- , color
18
- , moving
19
- , onLabel = "On"
20
- , offLabel = "Off"
21
- , icon = false
22
- , textLabel = false;
23
-
24
- $element.addClass('switch');
25
-
26
- if ($element.data('on') !== undefined)
27
- color = "switch-" + $element.data('on');
28
-
29
- if ($element.data('on-label') !== undefined)
30
- onLabel = $element.data('on-label');
31
-
32
- if ($element.data('off-label') !== undefined)
33
- offLabel = $element.data('off-label');
34
-
35
- if ($element.data('label-icon') !== undefined)
36
- icon = $element.data('label-icon');
37
-
38
- if ($element.data('text-label') !== undefined)
39
- textLabel = $element.data('text-label');
40
-
41
- $switchLeft = $('<span>')
42
- .addClass("switch-left")
43
- .addClass(myClasses)
44
- .addClass(color)
45
- .html('' + onLabel + '');
46
-
47
- color = '';
48
- if ($element.data('off') !== undefined)
49
- color = "switch-" + $element.data('off');
50
-
51
- $switchRight = $('<span>')
52
- .addClass("switch-right")
53
- .addClass(myClasses)
54
- .addClass(color)
55
- .html('' + offLabel + '');
56
-
57
- $label = $('<label>')
58
- .html("&nbsp;")
59
- .addClass(myClasses)
60
- .attr('for', $element.find(inputSelector).attr('id'));
61
-
62
- if (icon) {
63
- $label.html('<i class="icon ' + icon + '"></i>');
64
- }
65
-
66
- if (textLabel) {
67
- $label.html('' + textLabel + '');
68
- }
69
-
70
- $div = $element.find(inputSelector).wrap($('<div>')).parent().data('animated', false);
71
-
72
- if ($element.data('animated') !== false)
73
- $div.addClass('switch-animate').data('animated', true);
74
-
75
- $div
76
- .append($switchLeft)
77
- .append($label)
78
- .append($switchRight);
79
-
80
- $element.find('>div').addClass(
81
- $element.find(inputSelector).is(':checked') ? 'switch-on' : 'switch-off'
82
- );
83
-
84
- if ($element.find(inputSelector).is(':disabled'))
85
- $(this).addClass('deactivate');
86
-
87
- var changeStatus = function ($this) {
88
- if ($element.parent('label').is('.label-change-switch')) {
89
-
90
- } else {
91
- $this.siblings('label').trigger('mousedown').trigger('mouseup').trigger('click');
1
+ (function() {
2
+ var __slice = [].slice;
3
+
4
+ (function($, window) {
5
+ "use strict";
6
+ var Switch;
7
+ Switch = (function() {
8
+ Switch.prototype.defaults = {
9
+ state: true,
10
+ size: null,
11
+ animate: true,
12
+ disabled: false,
13
+ readonly: false,
14
+ onColor: null,
15
+ offColor: null,
16
+ onText: "On",
17
+ offText: "Off",
18
+ labelText: "&nbsp;"
19
+ };
20
+
21
+ Switch.prototype.name = "switch";
22
+
23
+ function Switch(element, options) {
24
+ if (options == null) {
25
+ options = {};
26
+ }
27
+ this.$element = $(element);
28
+ this.options = $.extend({}, this.defaults, options, {
29
+ state: this.$element.is(":checked"),
30
+ size: this.$element.data("size"),
31
+ animate: this.$element.data("animate"),
32
+ disabled: this.$element.is(":disabled"),
33
+ readonly: this.$element.is("[readonly]"),
34
+ onColor: this.$element.data("on-color"),
35
+ offColor: this.$element.data("off-color"),
36
+ onText: this.$element.data("on-text"),
37
+ offText: this.$element.data("off-text"),
38
+ labelText: this.$element.data("label-text")
39
+ });
40
+ this.$on = $("<span>", {
41
+ "class": "" + this.name + "-handle-on " + this.name + "-" + this.options.onColor,
42
+ html: this.options.onText
43
+ });
44
+ this.$off = $("<span>", {
45
+ "class": "" + this.name + "-handle-off " + this.name + "-" + this.options.offColor,
46
+ html: this.options.offText
47
+ });
48
+ this.$label = $("<label>", {
49
+ "for": this.$element.attr("id"),
50
+ html: this.options.labelText
51
+ });
52
+ this.$wrapper = $("<div>", {
53
+ "class": (function(_this) {
54
+ return function() {
55
+ var classes;
56
+ classes = ["" + _this.name];
57
+ classes.push(_this.options.state ? "" + _this.name + "-on" : "" + _this.name + "-off");
58
+ if (_this.options.size != null) {
59
+ classes.push("" + _this.name + "-" + _this.options.size);
92
60
  }
93
- };
94
-
95
- $element.on('keydown', function (e) {
96
- if (e.keyCode === 32) {
97
- e.stopImmediatePropagation();
98
- e.preventDefault();
99
- changeStatus($(e.target).find('span:first'));
61
+ if (_this.options.onColor != null) {
62
+ classes.push("" + _this.name + "-" + _this.options.onColor);
100
63
  }
101
- });
64
+ if (_this.options.animate) {
65
+ classes.push("" + _this.name + "-animate");
66
+ }
67
+ if (_this.options.disabled) {
68
+ classes.push("" + _this.name + "-disabled");
69
+ }
70
+ if (_this.options.readonly) {
71
+ classes.push("" + _this.name + "-readonly");
72
+ }
73
+ if (_this.$element.attr("id")) {
74
+ classes.push("" + _this.name + "-id-" + (_this.$element.attr("id")));
75
+ }
76
+ return classes.join(" ");
77
+ };
78
+ })(this)
79
+ });
80
+ this.$div = this.$element.wrap($("<div>")).parent();
81
+ this.$wrapper = this.$div.wrap(this.$wrapper).parent();
82
+ this.$element.before(this.$on).before(this.$label).before(this.$off);
83
+ this._elementHandlers();
84
+ this._handleHandlers();
85
+ this._labelHandlers();
86
+ this._formHandler();
87
+ }
102
88
 
103
- $switchLeft.on('click', function (e) {
104
- changeStatus($(this));
105
- });
89
+ Switch.prototype._constructor = Switch;
106
90
 
107
- $switchRight.on('click', function (e) {
108
- changeStatus($(this));
109
- });
110
-
111
- $element.find(inputSelector).on('change', function (e, skipOnChange) {
112
- var $this = $(this)
113
- , $element = $this.parent()
114
- , thisState = $this.is(':checked')
115
- , state = $element.is('.switch-off');
91
+ Switch.prototype.state = function(value, skip) {
92
+ if (typeof value === "undefined") {
93
+ return this.options.state;
94
+ }
95
+ if (this.options.disabled || this.options.readonly) {
96
+ return this.$element;
97
+ }
98
+ value = !!value;
99
+ this.$element.prop("checked", value).trigger("change.Switch", skip);
100
+ return this.$element;
101
+ };
102
+
103
+ Switch.prototype.toggleState = function(skip) {
104
+ if (this.options.disabled || this.options.readonly) {
105
+ return this.$element;
106
+ }
107
+ return this.$element.prop("checked", !this.options.state).trigger("change.Switch", skip);
108
+ };
116
109
 
110
+ Switch.prototype.size = function(value) {
111
+ if (typeof value === "undefined") {
112
+ return this.options.size;
113
+ }
114
+ if (this.options.size != null) {
115
+ this.$wrapper.removeClass("" + this.name + "-" + this.options.size);
116
+ }
117
+ this.$wrapper.addClass("" + this.name + "-" + value);
118
+ this.options.size = value;
119
+ return this.$element;
120
+ };
121
+
122
+ Switch.prototype.animate = function(value) {
123
+ if (typeof value === "undefined") {
124
+ return this.options.animate;
125
+ }
126
+ value = !!value;
127
+ this.$wrapper[value ? "addClass" : "removeClass"]("" + this.name + "-animate");
128
+ this.options.animate = value;
129
+ return this.$element;
130
+ };
131
+
132
+ Switch.prototype.disabled = function(value) {
133
+ if (typeof value === "undefined") {
134
+ return this.options.disabled;
135
+ }
136
+ value = !!value;
137
+ this.$wrapper[value ? "addClass" : "removeClass"]("" + this.name + "-disabled");
138
+ this.$element.prop("disabled", value);
139
+ this.options.disabled = value;
140
+ return this.$element;
141
+ };
142
+
143
+ Switch.prototype.toggleDisabled = function() {
144
+ this.$element.prop("disabled", !this.options.disabled);
145
+ this.$wrapper.toggleClass("" + this.name + "-disabled");
146
+ this.options.disabled = !this.options.disabled;
147
+ return this.$element;
148
+ };
149
+
150
+ Switch.prototype.readonly = function(value) {
151
+ if (typeof value === "undefined") {
152
+ return this.options.readonly;
153
+ }
154
+ value = !!value;
155
+ this.$wrapper[value ? "addClass" : "removeClass"]("" + this.name + "-readonly");
156
+ this.$element.prop("readonly", value);
157
+ this.options.readonly = value;
158
+ return this.$element;
159
+ };
160
+
161
+ Switch.prototype.toggleReadonly = function() {
162
+ this.$element.prop("readonly", !this.options.readonly);
163
+ this.$wrapper.toggleClass("" + this.name + "-readonly");
164
+ this.options.readonly = !this.options.readonly;
165
+ return this.$element;
166
+ };
167
+
168
+ Switch.prototype.onColor = function(value) {
169
+ var color;
170
+ color = this.options.onColor;
171
+ if (typeof value === "undefined") {
172
+ return color;
173
+ }
174
+ if (color != null) {
175
+ this.$on.removeClass("" + this.name + "-" + color);
176
+ }
177
+ this.$on.addClass("" + this.name + "-" + value);
178
+ this.options.onColor = value;
179
+ return this.$element;
180
+ };
181
+
182
+ Switch.prototype.offColor = function(value) {
183
+ var color;
184
+ color = this.options.offColor;
185
+ if (typeof value === "undefined") {
186
+ return color;
187
+ }
188
+ if (color != null) {
189
+ this.$off.removeClass("" + this.name + "-" + color);
190
+ }
191
+ this.$off.addClass("" + this.name + "-" + value);
192
+ this.options.offColor = value;
193
+ return this.$element;
194
+ };
195
+
196
+ Switch.prototype.onText = function(value) {
197
+ if (typeof value === "undefined") {
198
+ return this.options.onText;
199
+ }
200
+ this.$on.html(value);
201
+ this.options.onText = value;
202
+ return this.$element;
203
+ };
204
+
205
+ Switch.prototype.offText = function(value) {
206
+ if (typeof value === "undefined") {
207
+ return this.options.offText;
208
+ }
209
+ this.$off.html(value);
210
+ this.options.offText = value;
211
+ return this.$element;
212
+ };
213
+
214
+ Switch.prototype.labelText = function(value) {
215
+ if (typeof value === "undefined") {
216
+ return this.options.labelText;
217
+ }
218
+ this.$label.html(value);
219
+ this.options.labelText = value;
220
+ return this.$element;
221
+ };
222
+
223
+ Switch.prototype.destroy = function() {
224
+ var $form;
225
+ $form = this.$element.closest("form");
226
+ if ($form.length) {
227
+ $form.off("reset.Switch").removeData("switch");
228
+ }
229
+ this.$div.children().not(this.$element).remove();
230
+ this.$element.unwrap().unwrap().off(".Switch").removeData("switch");
231
+ return this.$element;
232
+ };
233
+
234
+ Switch.prototype._elementHandlers = function() {
235
+ return this.$element.on({
236
+ "change.Switch": (function(_this) {
237
+ return function(e, skip) {
238
+ var checked;
117
239
  e.preventDefault();
118
-
119
- $element.css('left', '');
120
-
121
- if (state === thisState) {
122
-
123
- if (thisState)
124
- $element.removeClass('switch-off').addClass('switch-on');
125
- else $element.removeClass('switch-on').addClass('switch-off');
126
-
127
- if ($element.data('animated') !== false)
128
- $element.addClass("switch-animate");
129
-
130
- if (typeof skipOnChange === 'boolean' && skipOnChange)
131
- return;
132
-
133
- $element.parent().trigger('switch-change', {'el': $this, 'value': thisState})
240
+ e.stopPropagation();
241
+ e.stopImmediatePropagation();
242
+ checked = _this.$element.is(":checked");
243
+ if (checked === _this.options.state) {
244
+ return;
134
245
  }
135
- });
136
-
137
- $element.find('label').on('mousedown touchstart', function (e) {
138
- var $this = $(this);
139
- moving = false;
140
-
246
+ _this.options.state = checked;
247
+ _this.$wrapper.removeClass(checked ? "" + _this.name + "-off" : "" + _this.name + "-on").addClass(checked ? "" + _this.name + "-on" : "" + _this.name + "-off");
248
+ if (!skip) {
249
+ if (_this.$element.is(":radio")) {
250
+ $("[name='" + (_this.$element.attr('name')) + "']").not(_this.$element).prop("checked", false).trigger("change.Switch", true);
251
+ }
252
+ return _this.$element.trigger("switchChange", {
253
+ el: _this.$element,
254
+ value: checked
255
+ });
256
+ }
257
+ };
258
+ })(this),
259
+ "focus.Switch": (function(_this) {
260
+ return function(e) {
141
261
  e.preventDefault();
262
+ e.stopPropagation();
142
263
  e.stopImmediatePropagation();
143
-
144
- $this.closest('div').removeClass('switch-animate');
145
-
146
- if ($this.closest('.switch').is('.deactivate')) {
147
- $this.unbind('click');
148
- } else if ($this.closest('.switch-on').parent().is('.radio-no-uncheck')) {
149
- $this.unbind('click');
150
- } else {
151
- $this.on('mousemove touchmove', function (e) {
152
- var $element = $(this).closest('.form-switch')
153
- , relativeX = (e.pageX || e.originalEvent.targetTouches[0].pageX) - $element.offset().left
154
- , percent = (relativeX / $element.width()) * 100
155
- , left = 25
156
- , right = 75;
157
-
158
- moving = true;
159
-
160
- if (percent < left)
161
- percent = left;
162
- else if (percent > right)
163
- percent = right;
164
-
165
- $element.find('>div').css('left', (percent - right) + "%")
166
- });
167
-
168
- $this.on('click touchend', function (e) {
169
- var $this = $(this)
170
- , $myInputBox = $this.siblings('input');
171
-
172
- e.stopImmediatePropagation();
173
- e.preventDefault();
174
-
175
- $this.unbind('mouseleave');
176
-
177
- if (moving)
178
- $myInputBox.prop('checked', !(parseInt($this.parent().css('left')) < -25));
179
- else
180
- $myInputBox.prop("checked", !$myInputBox.is(":checked"));
181
-
182
- moving = false;
183
- $myInputBox.trigger('change');
184
- });
185
-
186
- $this.on('mouseleave', function (e) {
187
- var $this = $(this)
188
- , $myInputBox = $this.siblings('input');
189
-
264
+ return _this.$wrapper.addClass("" + _this.name + "-focused");
265
+ };
266
+ })(this),
267
+ "blur.Switch": (function(_this) {
268
+ return function(e) {
269
+ e.preventDefault();
270
+ e.stopPropagation();
271
+ e.stopImmediatePropagation();
272
+ return _this.$wrapper.removeClass("" + _this.name + "-focused");
273
+ };
274
+ })(this),
275
+ "keydown.Switch": (function(_this) {
276
+ return function(e) {
277
+ if (!e.which || _this.options.disabled || _this.options.readonly) {
278
+ return;
279
+ }
280
+ switch (e.which) {
281
+ case 32:
190
282
  e.preventDefault();
283
+ e.stopPropagation();
191
284
  e.stopImmediatePropagation();
192
-
193
- $this.unbind('mouseleave mousemove');
194
- $this.trigger('mouseup');
195
-
196
- $myInputBox.prop('checked', !(parseInt($this.parent().css('left')) < -25)).trigger('change');
197
- });
198
-
199
- $this.on('mouseup', function (e) {
285
+ return _this.toggleState();
286
+ case 37:
287
+ e.preventDefault();
288
+ e.stopPropagation();
200
289
  e.stopImmediatePropagation();
290
+ return _this.state(false);
291
+ case 39:
201
292
  e.preventDefault();
202
-
203
- $(this).trigger('mouseleave');
204
- });
293
+ e.stopPropagation();
294
+ e.stopImmediatePropagation();
295
+ return _this.state(true);
205
296
  }
206
- });
207
-
208
- if ($form.data('switch') !== 'injected') {
209
- $form.bind('reset', function () {
210
- setTimeout(function () {
211
- $form.find('.form-switch').each(function () {
212
- var $input = $(this).find(inputSelector);
213
-
214
- $input.prop('checked', $input.is(':checked')).trigger('change');
215
- });
216
- }, 1);
217
- });
218
- $form.data('switch', 'injected');
219
- }
220
- }
221
- );
222
- },
223
- toggleActivation: function () {
224
- var $this = $(this);
225
-
226
- $this.toggleClass('deactivate');
227
- $this.find(inputSelector).prop('disabled', $this.is('.deactivate'));
228
- },
229
- isActive: function () {
230
- return !$(this).hasClass('deactivate');
231
- },
232
- setActive: function (active) {
233
- var $this = $(this);
234
-
235
- if (active) {
236
- $this.removeClass('deactivate');
237
- $this.find(inputSelector).removeAttr('disabled');
238
- }
239
- else {
240
- $this.addClass('deactivate');
241
- $this.find(inputSelector).attr('disabled', 'disabled');
242
- }
243
- },
244
- toggleState: function (skipOnChange) {
245
- var $input = $(this).find(':checkbox');
246
- $input.prop('checked', !$input.is(':checked')).trigger('change', skipOnChange);
247
- },
248
- toggleRadioState: function (skipOnChange) {
249
- var $radioinput = $(this).find(':radio');
250
- $radioinput.not(':checked').prop('checked', !$radioinput.is(':checked')).trigger('change', skipOnChange);
251
- },
252
- toggleRadioStateAllowUncheck: function (uncheck, skipOnChange) {
253
- var $radioinput = $(this).find(':radio');
254
- if (uncheck) {
255
- $radioinput.not(':checked').trigger('change', skipOnChange);
256
- }
257
- else {
258
- $radioinput.not(':checked').prop('checked', !$radioinput.is(':checked')).trigger('change', skipOnChange);
297
+ };
298
+ })(this)
299
+ });
300
+ };
301
+
302
+ Switch.prototype._handleHandlers = function() {
303
+ this.$on.on("click.Switch", (function(_this) {
304
+ return function(e) {
305
+ _this.state(false);
306
+ return _this.$element.trigger("focus.Switch");
307
+ };
308
+ })(this));
309
+ return this.$off.on("click.Switch", (function(_this) {
310
+ return function(e) {
311
+ _this.state(true);
312
+ return _this.$element.trigger("focus.Switch");
313
+ };
314
+ })(this));
315
+ };
316
+
317
+ Switch.prototype._labelHandlers = function() {
318
+ return this.$label.on({
319
+ "mousemove.Switch": (function(_this) {
320
+ return function(e) {
321
+ var left, percent, right;
322
+ if (!_this.drag) {
323
+ return;
324
+ }
325
+ percent = ((e.pageX - _this.$wrapper.offset().left) / _this.$wrapper.width()) * 100;
326
+ left = 25;
327
+ right = 75;
328
+ if (percent < left) {
329
+ percent = left;
330
+ } else if (percent > right) {
331
+ percent = right;
332
+ }
333
+ _this.$div.css("margin-left", "" + (percent - right) + "%");
334
+ return _this.$element.trigger("focus.Switch");
335
+ };
336
+ })(this),
337
+ "mousedown.Switch": (function(_this) {
338
+ return function(e) {
339
+ if (_this.drag || _this.options.disabled || _this.options.readonly) {
340
+ return;
341
+ }
342
+ _this.drag = true;
343
+ if (_this.options.animate) {
344
+ _this.$wrapper.removeClass("" + _this.name + "-animate");
345
+ }
346
+ return _this.$element.trigger("focus.Switch");
347
+ };
348
+ })(this),
349
+ "mouseup.Switch": (function(_this) {
350
+ return function(e) {
351
+ if (!_this.drag) {
352
+ return;
353
+ }
354
+ _this.drag = false;
355
+ _this.$element.prop("checked", parseInt(_this.$div.css("margin-left"), 10) > -25).trigger("change.Switch");
356
+ _this.$div.css("margin-left", "");
357
+ if (_this.options.animate) {
358
+ return _this.$wrapper.addClass("" + _this.name + "-animate");
359
+ }
360
+ };
361
+ })(this),
362
+ "click.Switch": (function(_this) {
363
+ return function(e) {
364
+ e.preventDefault();
365
+ e.stopImmediatePropagation();
366
+ _this.toggleState();
367
+ return _this.$element.trigger("focus.Switch");
368
+ };
369
+ })(this)
370
+ });
371
+ };
372
+
373
+ Switch.prototype._formHandler = function() {
374
+ var $form;
375
+ $form = this.$element.closest("form");
376
+ if ($form.data("switch")) {
377
+ return;
259
378
  }
260
- },
261
- setState: function (value, skipOnChange) {
262
- $(this).find(inputSelector).prop('checked', value).trigger('change', skipOnChange);
263
- },
264
- setOnLabel: function (value) {
265
- var $switchLeft = $(this).find(".switch-left");
266
- $switchLeft.html(value);
267
- },
268
- setOffLabel: function (value) {
269
- var $switchRight = $(this).find(".switch-right");
270
- $switchRight.html(value);
271
- },
272
- setOnClass: function (value) {
273
- var $switchLeft = $(this).find(".switch-left");
274
- var color = '';
275
- if (value !== undefined) {
276
- if ($(this).attr('data-on') !== undefined) {
277
- color = "switch-" + $(this).attr('data-on')
379
+ return $form.on("reset.Switch", function() {
380
+ return window.setTimeout(function() {
381
+ return $form.find("input").filter(function() {
382
+ return $(this).data("switch");
383
+ }).each(function() {
384
+ return $(this).Switch("state", false);
385
+ });
386
+ }, 1);
387
+ }).data("switch", true);
388
+ };
389
+
390
+ return Switch;
391
+
392
+ })();
393
+ $.fn.extend({
394
+ Switch: function() {
395
+ var args, option, ret;
396
+ option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
397
+ ret = this;
398
+ this.each(function() {
399
+ var $this, data;
400
+ $this = $(this);
401
+ data = $this.data("switch");
402
+ if (!data) {
403
+ $this.data("switch", data = new Switch(this, option));
278
404
  }
279
- $switchLeft.removeClass(color);
280
- color = "switch-" + value;
281
- $switchLeft.addClass(color);
282
- }
283
- },
284
- setOffClass: function (value) {
285
- var $switchRight = $(this).find(".switch-right");
286
- var color = '';
287
- if (value !== undefined) {
288
- if ($(this).attr('data-off') !== undefined) {
289
- color = "switch-" + $(this).attr('data-off')
405
+ if (typeof option === "string") {
406
+ return ret = data[option].apply(data, args);
290
407
  }
291
- $switchRight.removeClass(color);
292
- color = "switch-" + value;
293
- $switchRight.addClass(color);
294
- }
295
- },
296
- setAnimated: function (value) {
297
- var $element = $(this).find(inputSelector).parent();
298
- if (value === undefined) value = false;
299
- $element.data('animated', value);
300
- $element.attr('data-animated', value);
301
-
302
- if ($element.data('animated') !== false) {
303
- $element.addClass("switch-animate");
304
- } else {
305
- $element.removeClass("switch-animate");
306
- }
307
- },
308
- status: function () {
309
- return $(this).find(inputSelector).is(':checked');
310
- },
311
- destroy: function () {
312
- var $element = $(this)
313
- , $div = $element.find('div')
314
- , $form = $element.closest('form')
315
- , $inputbox;
316
-
317
- $div.find(':not(input)').remove();
318
-
319
- $inputbox = $div.children();
320
- $inputbox.unwrap().unwrap();
321
-
322
- $inputbox.unbind('change');
323
-
324
- if ($form) {
325
- $form.unbind('reset');
326
- $form.removeData('switch');
327
- }
328
-
329
- return $inputbox;
408
+ });
409
+ return ret;
330
410
  }
331
- };
332
-
333
- if (methods[method])
334
- return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
335
- else if (typeof method === 'object' || !method)
336
- return methods.init.apply(this, arguments);
337
- else
338
- $.error('Method ' + method + ' does not exist!');
339
- };
340
- }(jQuery);
411
+ });
412
+ return $.fn.Switch.Constructor = Switch;
413
+ })(window.jQuery, window);
341
414
 
342
- (function ($) {
343
- $(function () {
344
- $('.form-switch')['switch']();
345
- });
346
- })(jQuery);
415
+ }).call(this);