weeler 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/README.md +4 -0
- data/app/.DS_Store +0 -0
- data/app/assets/.DS_Store +0 -0
- data/app/assets/javascripts/.DS_Store +0 -0
- data/app/assets/javascripts/weeler.js.coffee +8 -0
- data/app/assets/javascripts/weeler/.DS_Store +0 -0
- data/app/assets/javascripts/weeler/bootstrap-fileupload.js +169 -0
- data/app/assets/javascripts/weeler/bootstrap.js +1992 -0
- data/app/assets/javascripts/weeler/bootstrap.rowlink.js +71 -0
- data/app/assets/javascripts/weeler/bootstrap.switch.js +382 -0
- data/app/assets/javascripts/weeler/jquery.pnotify.js +912 -0
- data/app/assets/stylesheets/.DS_Store +0 -0
- data/app/assets/stylesheets/weeler.css +9 -0
- data/app/assets/stylesheets/weeler/.DS_Store +0 -0
- data/app/assets/stylesheets/weeler/bootstrap-fileupload.css +132 -0
- data/app/assets/stylesheets/weeler/bootstrap.css +6086 -0
- data/app/assets/stylesheets/weeler/bootstrap.min.css +9 -0
- data/app/assets/stylesheets/weeler/bootstrap.rowlink.css +50 -0
- data/app/assets/stylesheets/weeler/bootstrap.spinner.css +43 -0
- data/app/assets/stylesheets/weeler/bootstrap.switch.css +408 -0
- data/app/assets/stylesheets/weeler/jquery.pnotify.css +84 -0
- data/app/assets/stylesheets/weeler/style.css.scss.erb +48 -0
- data/app/controllers/weeler/base_controller.rb +16 -0
- data/app/controllers/weeler/home_controller.rb +8 -0
- data/app/controllers/weeler/translations_controller.rb +151 -0
- data/app/views/kaminari/_first_page.html.erb +13 -0
- data/app/views/kaminari/_gap.html.erb +8 -0
- data/app/views/kaminari/_last_page.html.erb +13 -0
- data/app/views/kaminari/_next_page.html.erb +14 -0
- data/app/views/kaminari/_page.html.erb +12 -0
- data/app/views/kaminari/_paginator.html.erb +23 -0
- data/app/views/kaminari/_prev_page.html.erb +13 -0
- data/app/views/layouts/weeler/base.html.erb +86 -0
- data/app/views/weeler/home/about.html.erb +16 -0
- data/app/views/weeler/home/index.html.erb +4 -0
- data/app/views/weeler/translations/_form.html.erb +43 -0
- data/app/views/weeler/translations/_translation.html.erb +11 -0
- data/app/views/weeler/translations/edit.html.erb +19 -0
- data/app/views/weeler/translations/index.html.erb +106 -0
- data/app/views/weeler/translations/new.html.erb +19 -0
- data/config/initializers/weeler_mime_types.rb +1 -0
- data/lib/.DS_Store +0 -0
- data/lib/generators/weeler/.DS_Store +0 -0
- data/lib/generators/weeler/install_generator.rb +73 -0
- data/lib/generators/weeler/templates/initializers/weeler.rb +7 -0
- data/lib/generators/weeler/templates/migrations/create_weeler_translations.rb +16 -0
- data/lib/i18n/.DS_Store +0 -0
- data/lib/i18n/backend/.DS_Store +0 -0
- data/lib/i18n/backend/weeler.rb +76 -0
- data/lib/i18n/backend/weeler/store_procs.rb +39 -0
- data/lib/i18n/backend/weeler/translation.rb +118 -0
- data/lib/i18n/humanize_missing_translations.rb +11 -0
- data/lib/i18n/weeler.rb +6 -0
- data/lib/weeler.rb +25 -1
- data/lib/weeler/.DS_Store +0 -0
- data/lib/weeler/engine.rb +11 -0
- data/lib/weeler/route_mapper.rb +41 -0
- data/lib/weeler/version.rb +1 -1
- data/rspec.html +454 -0
- data/spec/.DS_Store +0 -0
- data/spec/controllers/translations_controller_spec.rb +41 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/weeler/posts_controller.rb +7 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/weeler.rb +2 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20131015144900_create_weeler_translations.rb +16 -0
- data/spec/dummy/db/production.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +29 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/log/development.log +19 -0
- data/spec/dummy/log/production.log +4 -0
- data/spec/dummy/log/test.log +38396 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/translations.rb +7 -0
- data/spec/routing/routes_spec.rb +140 -0
- data/spec/spec_helper.rb +54 -0
- data/spec/weeler/.DS_Store +0 -0
- data/spec/weeler/i18n_backend_weeler_spec.rb +169 -0
- data/spec/weeler/i18n_humanize_missing_translations_spec.rb +18 -0
- data/weeler.gemspec +14 -0
- metadata +354 -3
@@ -0,0 +1,71 @@
|
|
1
|
+
/* ============================================================
|
2
|
+
* bootstrap-rowlink.js j1
|
3
|
+
* http://jasny.github.com/bootstrap/javascript.html#rowlink
|
4
|
+
* ============================================================
|
5
|
+
* Copyright 2012 Jasny BV, Netherlands.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ============================================================ */
|
19
|
+
|
20
|
+
!function ($) {
|
21
|
+
|
22
|
+
"use strict"; // jshint ;_;
|
23
|
+
|
24
|
+
var Rowlink = function (element, options) {
|
25
|
+
options = $.extend({}, $.fn.rowlink.defaults, options)
|
26
|
+
var tr = element.nodeName.toLowerCase() == 'tr' ? $(element) : $(element).find('tr:has(td)')
|
27
|
+
|
28
|
+
tr.each(function() {
|
29
|
+
var link = $(this).find(options.target).first()
|
30
|
+
if (!link.length) return
|
31
|
+
|
32
|
+
var href = link.attr('href')
|
33
|
+
|
34
|
+
$(this).find('td').not('.nolink').click(function() {
|
35
|
+
window.location = href;
|
36
|
+
})
|
37
|
+
|
38
|
+
$(this).addClass('rowlink')
|
39
|
+
link.replaceWith(link.html())
|
40
|
+
})
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
/* ROWLINK PLUGIN DEFINITION
|
45
|
+
* =========================== */
|
46
|
+
|
47
|
+
$.fn.rowlink = function (options) {
|
48
|
+
return this.each(function () {
|
49
|
+
var $this = $(this)
|
50
|
+
, data = $this.data('rowlink')
|
51
|
+
if (!data) $this.data('rowlink', (data = new Rowlink(this, options)))
|
52
|
+
})
|
53
|
+
}
|
54
|
+
|
55
|
+
$.fn.rowlink.defaults = {
|
56
|
+
target: "a"
|
57
|
+
}
|
58
|
+
|
59
|
+
$.fn.rowlink.Constructor = Rowlink
|
60
|
+
|
61
|
+
|
62
|
+
/* ROWLINK DATA-API
|
63
|
+
* ================== */
|
64
|
+
|
65
|
+
$(function () {
|
66
|
+
$('[data-provide="rowlink"],[data-provides="rowlink"]').each(function () {
|
67
|
+
$(this).rowlink($(this).data())
|
68
|
+
})
|
69
|
+
})
|
70
|
+
|
71
|
+
}(window.jQuery);
|
@@ -0,0 +1,382 @@
|
|
1
|
+
/*! ============================================================
|
2
|
+
* bootstrapSwitch v1.8 by Larentis Mattia @SpiritualGuru
|
3
|
+
* http://www.larentis.eu/
|
4
|
+
*
|
5
|
+
* Enhanced for radiobuttons by Stein, Peter @BdMdesigN
|
6
|
+
* http://www.bdmdesign.org/
|
7
|
+
*
|
8
|
+
* Project site:
|
9
|
+
* http://www.larentis.eu/switch/
|
10
|
+
* ============================================================
|
11
|
+
* Licensed under the Apache License, Version 2.0
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
* ============================================================ */
|
14
|
+
|
15
|
+
!function ($) {
|
16
|
+
"use strict";
|
17
|
+
|
18
|
+
$.fn['bootstrapSwitch'] = function (method) {
|
19
|
+
var inputSelector = 'input[type!="hidden"]';
|
20
|
+
var methods = {
|
21
|
+
init: function () {
|
22
|
+
return this.each(function () {
|
23
|
+
var $element = $(this)
|
24
|
+
, $div
|
25
|
+
, $switchLeft
|
26
|
+
, $switchRight
|
27
|
+
, $label
|
28
|
+
, $form = $element.closest('form')
|
29
|
+
, myClasses = ""
|
30
|
+
, classes = $element.attr('class')
|
31
|
+
, color
|
32
|
+
, moving
|
33
|
+
, onLabel = "ON"
|
34
|
+
, offLabel = "OFF"
|
35
|
+
, icon = false
|
36
|
+
, textLabel = false;
|
37
|
+
|
38
|
+
$.each(['switch-mini', 'switch-small', 'switch-large'], function (i, el) {
|
39
|
+
if (classes.indexOf(el) >= 0)
|
40
|
+
myClasses = el;
|
41
|
+
});
|
42
|
+
|
43
|
+
$element.addClass('has-switch');
|
44
|
+
|
45
|
+
if ($element.data('on') !== undefined)
|
46
|
+
color = "switch-" + $element.data('on');
|
47
|
+
|
48
|
+
if ($element.data('on-label') !== undefined)
|
49
|
+
onLabel = $element.data('on-label');
|
50
|
+
|
51
|
+
if ($element.data('off-label') !== undefined)
|
52
|
+
offLabel = $element.data('off-label');
|
53
|
+
|
54
|
+
if ($element.data('label-icon') !== undefined)
|
55
|
+
icon = $element.data('label-icon');
|
56
|
+
|
57
|
+
if ($element.data('text-label') !== undefined)
|
58
|
+
textLabel = $element.data('text-label');
|
59
|
+
|
60
|
+
$switchLeft = $('<span>')
|
61
|
+
.addClass("switch-left")
|
62
|
+
.addClass(myClasses)
|
63
|
+
.addClass(color)
|
64
|
+
.html(onLabel);
|
65
|
+
|
66
|
+
color = '';
|
67
|
+
if ($element.data('off') !== undefined)
|
68
|
+
color = "switch-" + $element.data('off');
|
69
|
+
|
70
|
+
$switchRight = $('<span>')
|
71
|
+
.addClass("switch-right")
|
72
|
+
.addClass(myClasses)
|
73
|
+
.addClass(color)
|
74
|
+
.html(offLabel);
|
75
|
+
|
76
|
+
$label = $('<label>')
|
77
|
+
.html(" ")
|
78
|
+
.addClass(myClasses)
|
79
|
+
.attr('for', $element.find(inputSelector).attr('id'));
|
80
|
+
|
81
|
+
if (icon) {
|
82
|
+
$label.html('<i class="icon ' + icon + '"></i>');
|
83
|
+
}
|
84
|
+
|
85
|
+
if (textLabel) {
|
86
|
+
$label.html('' + textLabel + '');
|
87
|
+
}
|
88
|
+
|
89
|
+
$div = $element.find(inputSelector).wrap($('<div>')).parent().data('animated', false);
|
90
|
+
|
91
|
+
if ($element.data('animated') !== false)
|
92
|
+
$div.addClass('switch-animate').data('animated', true);
|
93
|
+
|
94
|
+
$div
|
95
|
+
.append($switchLeft)
|
96
|
+
.append($label)
|
97
|
+
.append($switchRight);
|
98
|
+
|
99
|
+
$element.find('>div').addClass(
|
100
|
+
$element.find(inputSelector).is(':checked') ? 'switch-on' : 'switch-off'
|
101
|
+
);
|
102
|
+
|
103
|
+
if ($element.find(inputSelector).is(':disabled'))
|
104
|
+
$(this).addClass('deactivate');
|
105
|
+
|
106
|
+
var changeStatus = function ($this) {
|
107
|
+
if ($element.parent('label').is('.label-change-switch')) {
|
108
|
+
|
109
|
+
} else {
|
110
|
+
$this.siblings('label').trigger('mousedown').trigger('mouseup').trigger('click');
|
111
|
+
}
|
112
|
+
};
|
113
|
+
|
114
|
+
$element.on('keydown', function (e) {
|
115
|
+
if (e.keyCode === 32) {
|
116
|
+
e.stopImmediatePropagation();
|
117
|
+
e.preventDefault();
|
118
|
+
changeStatus($(e.target).find('span:first'));
|
119
|
+
}
|
120
|
+
});
|
121
|
+
|
122
|
+
$switchLeft.on('click', function (e) {
|
123
|
+
changeStatus($(this));
|
124
|
+
});
|
125
|
+
|
126
|
+
$switchRight.on('click', function (e) {
|
127
|
+
changeStatus($(this));
|
128
|
+
});
|
129
|
+
|
130
|
+
$element.find(inputSelector).on('change', function (e, skipOnChange) {
|
131
|
+
var $this = $(this)
|
132
|
+
, $element = $this.parent()
|
133
|
+
, thisState = $this.is(':checked')
|
134
|
+
, state = $element.is('.switch-off');
|
135
|
+
|
136
|
+
e.preventDefault();
|
137
|
+
|
138
|
+
$element.css('left', '');
|
139
|
+
|
140
|
+
if (state === thisState) {
|
141
|
+
|
142
|
+
if (thisState)
|
143
|
+
$element.removeClass('switch-off').addClass('switch-on');
|
144
|
+
else $element.removeClass('switch-on').addClass('switch-off');
|
145
|
+
|
146
|
+
if ($element.data('animated') !== false)
|
147
|
+
$element.addClass("switch-animate");
|
148
|
+
|
149
|
+
if (typeof skipOnChange === 'boolean' && skipOnChange)
|
150
|
+
return;
|
151
|
+
|
152
|
+
$element.parent().trigger('switch-change', {'el': $this, 'value': thisState})
|
153
|
+
}
|
154
|
+
});
|
155
|
+
|
156
|
+
$element.find('label').on('mousedown touchstart', function (e) {
|
157
|
+
var $this = $(this);
|
158
|
+
moving = false;
|
159
|
+
|
160
|
+
e.preventDefault();
|
161
|
+
e.stopImmediatePropagation();
|
162
|
+
|
163
|
+
$this.closest('div').removeClass('switch-animate');
|
164
|
+
|
165
|
+
if ($this.closest('.has-switch').is('.deactivate')) {
|
166
|
+
$this.unbind('click');
|
167
|
+
} else if ($this.closest('.switch-on').parent().is('.radio-no-uncheck')) {
|
168
|
+
$this.unbind('click');
|
169
|
+
} else {
|
170
|
+
$this.on('mousemove touchmove', function (e) {
|
171
|
+
var $element = $(this).closest('.make-switch')
|
172
|
+
, relativeX = (e.pageX || e.originalEvent.targetTouches[0].pageX) - $element.offset().left
|
173
|
+
, percent = (relativeX / $element.width()) * 100
|
174
|
+
, left = 25
|
175
|
+
, right = 75;
|
176
|
+
|
177
|
+
moving = true;
|
178
|
+
|
179
|
+
if (percent < left)
|
180
|
+
percent = left;
|
181
|
+
else if (percent > right)
|
182
|
+
percent = right;
|
183
|
+
|
184
|
+
$element.find('>div').css('left', (percent - right) + "%")
|
185
|
+
});
|
186
|
+
|
187
|
+
$this.on('click touchend', function (e) {
|
188
|
+
var $this = $(this)
|
189
|
+
, $myInputBox = $this.siblings('input');
|
190
|
+
|
191
|
+
e.stopImmediatePropagation();
|
192
|
+
e.preventDefault();
|
193
|
+
|
194
|
+
$this.unbind('mouseleave');
|
195
|
+
|
196
|
+
if (moving)
|
197
|
+
$myInputBox.prop('checked', !(parseInt($this.parent().css('left')) < -25));
|
198
|
+
else
|
199
|
+
$myInputBox.prop("checked", !$myInputBox.is(":checked"));
|
200
|
+
|
201
|
+
moving = false;
|
202
|
+
$myInputBox.trigger('change');
|
203
|
+
});
|
204
|
+
|
205
|
+
$this.on('mouseleave', function (e) {
|
206
|
+
var $this = $(this)
|
207
|
+
, $myInputBox = $this.siblings('input');
|
208
|
+
|
209
|
+
e.preventDefault();
|
210
|
+
e.stopImmediatePropagation();
|
211
|
+
|
212
|
+
$this.unbind('mouseleave mousemove');
|
213
|
+
$this.trigger('mouseup');
|
214
|
+
|
215
|
+
$myInputBox.prop('checked', !(parseInt($this.parent().css('left')) < -25)).trigger('change');
|
216
|
+
});
|
217
|
+
|
218
|
+
$this.on('mouseup', function (e) {
|
219
|
+
e.stopImmediatePropagation();
|
220
|
+
e.preventDefault();
|
221
|
+
|
222
|
+
$(this).trigger('mouseleave');
|
223
|
+
});
|
224
|
+
}
|
225
|
+
});
|
226
|
+
|
227
|
+
if ($form.data('bootstrapSwitch') !== 'injected') {
|
228
|
+
$form.bind('reset', function () {
|
229
|
+
setTimeout(function () {
|
230
|
+
$form.find('.make-switch').each(function () {
|
231
|
+
var $input = $(this).find(inputSelector);
|
232
|
+
|
233
|
+
$input.prop('checked', $input.is(':checked')).trigger('change');
|
234
|
+
});
|
235
|
+
}, 1);
|
236
|
+
});
|
237
|
+
$form.data('bootstrapSwitch', 'injected');
|
238
|
+
}
|
239
|
+
}
|
240
|
+
);
|
241
|
+
},
|
242
|
+
toggleActivation: function () {
|
243
|
+
var $this = $(this);
|
244
|
+
|
245
|
+
$this.toggleClass('deactivate');
|
246
|
+
$this.find(inputSelector).prop('disabled', $this.is('.deactivate'));
|
247
|
+
},
|
248
|
+
isActive: function () {
|
249
|
+
return !$(this).hasClass('deactivate');
|
250
|
+
},
|
251
|
+
setActive: function (active) {
|
252
|
+
var $this = $(this);
|
253
|
+
|
254
|
+
if (active) {
|
255
|
+
$this.removeClass('deactivate');
|
256
|
+
$this.find(inputSelector).removeAttr('disabled');
|
257
|
+
}
|
258
|
+
else {
|
259
|
+
$this.addClass('deactivate');
|
260
|
+
$this.find(inputSelector).attr('disabled', 'disabled');
|
261
|
+
}
|
262
|
+
},
|
263
|
+
toggleState: function (skipOnChange) {
|
264
|
+
var $input = $(this).find(':checkbox');
|
265
|
+
$input.prop('checked', !$input.is(':checked')).trigger('change', skipOnChange);
|
266
|
+
},
|
267
|
+
toggleRadioState: function (skipOnChange) {
|
268
|
+
var $radioinput = $(this).find(':radio');
|
269
|
+
$radioinput.not(':checked').prop('checked', !$radioinput.is(':checked')).trigger('change', skipOnChange);
|
270
|
+
},
|
271
|
+
toggleRadioStateAllowUncheck: function (uncheck, skipOnChange) {
|
272
|
+
var $radioinput = $(this).find(':radio');
|
273
|
+
if (uncheck) {
|
274
|
+
$radioinput.not(':checked').trigger('change', skipOnChange);
|
275
|
+
}
|
276
|
+
else {
|
277
|
+
$radioinput.not(':checked').prop('checked', !$radioinput.is(':checked')).trigger('change', skipOnChange);
|
278
|
+
}
|
279
|
+
},
|
280
|
+
setState: function (value, skipOnChange) {
|
281
|
+
$(this).find(inputSelector).prop('checked', value).trigger('change', skipOnChange);
|
282
|
+
},
|
283
|
+
setOnLabel: function (value) {
|
284
|
+
var $switchLeft = $(this).find(".switch-left");
|
285
|
+
$switchLeft.html(value);
|
286
|
+
},
|
287
|
+
setOffLabel: function (value) {
|
288
|
+
var $switchRight = $(this).find(".switch-right");
|
289
|
+
$switchRight.html(value);
|
290
|
+
},
|
291
|
+
setOnClass: function (value) {
|
292
|
+
var $switchLeft = $(this).find(".switch-left");
|
293
|
+
var color = '';
|
294
|
+
if (value !== undefined) {
|
295
|
+
if ($(this).attr('data-on') !== undefined) {
|
296
|
+
color = "switch-" + $(this).attr('data-on')
|
297
|
+
}
|
298
|
+
$switchLeft.removeClass(color);
|
299
|
+
color = "switch-" + value;
|
300
|
+
$switchLeft.addClass(color);
|
301
|
+
}
|
302
|
+
},
|
303
|
+
setOffClass: function (value) {
|
304
|
+
var $switchRight = $(this).find(".switch-right");
|
305
|
+
var color = '';
|
306
|
+
if (value !== undefined) {
|
307
|
+
if ($(this).attr('data-off') !== undefined) {
|
308
|
+
color = "switch-" + $(this).attr('data-off')
|
309
|
+
}
|
310
|
+
$switchRight.removeClass(color);
|
311
|
+
color = "switch-" + value;
|
312
|
+
$switchRight.addClass(color);
|
313
|
+
}
|
314
|
+
},
|
315
|
+
setAnimated: function (value) {
|
316
|
+
var $element = $(this).find(inputSelector).parent();
|
317
|
+
if (value === undefined) value = false;
|
318
|
+
$element.data('animated', value);
|
319
|
+
$element.attr('data-animated', value);
|
320
|
+
|
321
|
+
if ($element.data('animated') !== false) {
|
322
|
+
$element.addClass("switch-animate");
|
323
|
+
} else {
|
324
|
+
$element.removeClass("switch-animate");
|
325
|
+
}
|
326
|
+
},
|
327
|
+
setSizeClass: function (value) {
|
328
|
+
var $element = $(this);
|
329
|
+
var $switchLeft = $element.find(".switch-left");
|
330
|
+
var $switchRight = $element.find(".switch-right");
|
331
|
+
var $label = $element.find("label");
|
332
|
+
$.each(['switch-mini', 'switch-small', 'switch-large'], function (i, el) {
|
333
|
+
if (el !== value) {
|
334
|
+
$switchLeft.removeClass(el);
|
335
|
+
$switchRight.removeClass(el);
|
336
|
+
$label.removeClass(el);
|
337
|
+
} else {
|
338
|
+
$switchLeft.addClass(el);
|
339
|
+
$switchRight.addClass(el);
|
340
|
+
$label.addClass(el);
|
341
|
+
}
|
342
|
+
});
|
343
|
+
},
|
344
|
+
status: function () {
|
345
|
+
return $(this).find(inputSelector).is(':checked');
|
346
|
+
},
|
347
|
+
destroy: function () {
|
348
|
+
var $element = $(this)
|
349
|
+
, $div = $element.find('div')
|
350
|
+
, $form = $element.closest('form')
|
351
|
+
, $inputbox;
|
352
|
+
|
353
|
+
$div.find(':not(input)').remove();
|
354
|
+
|
355
|
+
$inputbox = $div.children();
|
356
|
+
$inputbox.unwrap().unwrap();
|
357
|
+
|
358
|
+
$inputbox.unbind('change');
|
359
|
+
|
360
|
+
if ($form) {
|
361
|
+
$form.unbind('reset');
|
362
|
+
$form.removeData('bootstrapSwitch');
|
363
|
+
}
|
364
|
+
|
365
|
+
return $inputbox;
|
366
|
+
}
|
367
|
+
};
|
368
|
+
|
369
|
+
if (methods[method])
|
370
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
371
|
+
else if (typeof method === 'object' || !method)
|
372
|
+
return methods.init.apply(this, arguments);
|
373
|
+
else
|
374
|
+
$.error('Method ' + method + ' does not exist!');
|
375
|
+
};
|
376
|
+
}(jQuery);
|
377
|
+
|
378
|
+
(function ($) {
|
379
|
+
$(function () {
|
380
|
+
$('.make-switch')['bootstrapSwitch']();
|
381
|
+
});
|
382
|
+
})(jQuery);
|