flashoff 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/flashoff/version.rb +1 -1
- data/vendor/assets/javascripts/switch.js +346 -0
- data/vendor/assets/stylesheets/switch.css.scss +73 -0
- data/vendor/assets/stylesheets/tab.css.scss +0 -2
- data/vendor/assets/stylesheets/table.css.scss +4 -1
- metadata +4 -4
- data/flashoff-0.0.3.gem +0 -0
- data/flashoff-0.0.4.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 631209bc1338f5dca4cdf8c18bcf36795c0b4e05
|
4
|
+
data.tar.gz: b0b8b675b0512a54f53c7082a2b904035d01cee0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca84128728107ae18e10eeaed0c0189e7e23ee1bad280b739768333e60df744857309f7cd23d115f1d965801a0de0041e75d70fc653b4f4beffbc677cabd6990
|
7
|
+
data.tar.gz: 9142bbfc5190f5e8285fa16e48b5d6d89d07c259e67474e983d2c2786d8da186f8db25e809d42cc600295ff410e7028a25a952d3613a1dfd7caa69c46f0b5805
|
data/README.md
CHANGED
@@ -47,6 +47,7 @@ Add the CSS files you want to include:
|
|
47
47
|
*= require placeholder.css
|
48
48
|
*= require popover.css
|
49
49
|
*= require progress.css
|
50
|
+
*= require switch.css
|
50
51
|
*= require tab.css
|
51
52
|
*= require table.css
|
52
53
|
*= require timepicker.css
|
@@ -66,6 +67,7 @@ Add the JS files you want to include:
|
|
66
67
|
//= require file_input.js
|
67
68
|
//= require map.js
|
68
69
|
//= require modal.js
|
70
|
+
//= require switch.js
|
69
71
|
//= require tab.js
|
70
72
|
//= require time_picker.js
|
71
73
|
//= require tooltip.js
|
data/lib/flashoff/version.rb
CHANGED
@@ -0,0 +1,346 @@
|
|
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(" ")
|
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');
|
92
|
+
}
|
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'));
|
100
|
+
}
|
101
|
+
});
|
102
|
+
|
103
|
+
$switchLeft.on('click', function (e) {
|
104
|
+
changeStatus($(this));
|
105
|
+
});
|
106
|
+
|
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');
|
116
|
+
|
117
|
+
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})
|
134
|
+
}
|
135
|
+
});
|
136
|
+
|
137
|
+
$element.find('label').on('mousedown touchstart', function (e) {
|
138
|
+
var $this = $(this);
|
139
|
+
moving = false;
|
140
|
+
|
141
|
+
e.preventDefault();
|
142
|
+
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
|
+
|
190
|
+
e.preventDefault();
|
191
|
+
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) {
|
200
|
+
e.stopImmediatePropagation();
|
201
|
+
e.preventDefault();
|
202
|
+
|
203
|
+
$(this).trigger('mouseleave');
|
204
|
+
});
|
205
|
+
}
|
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);
|
259
|
+
}
|
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')
|
278
|
+
}
|
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')
|
290
|
+
}
|
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;
|
330
|
+
}
|
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);
|
341
|
+
|
342
|
+
(function ($) {
|
343
|
+
$(function () {
|
344
|
+
$('.form-switch')['switch']();
|
345
|
+
});
|
346
|
+
})(jQuery);
|
@@ -0,0 +1,73 @@
|
|
1
|
+
/* Table of Contents
|
2
|
+
==================================================
|
3
|
+
#Switch */
|
4
|
+
|
5
|
+
/* #Switch
|
6
|
+
================================================== */
|
7
|
+
.switch input[type=radio],
|
8
|
+
.switch input[type=checkbox] { display: none; }
|
9
|
+
.switch {
|
10
|
+
background: rgba(58,144,216,1);
|
11
|
+
border-radius: 500px;
|
12
|
+
color: rgba(255,255,255,1);
|
13
|
+
cursor: pointer;
|
14
|
+
display: inline-block;
|
15
|
+
font-size: 11px;
|
16
|
+
-webkit-font-smoothing: antialiased;
|
17
|
+
font-weight: bold;
|
18
|
+
line-height: 11px;
|
19
|
+
margin-top: -2px;
|
20
|
+
min-width: 64px;
|
21
|
+
overflow: hidden;
|
22
|
+
padding: 4px 0;
|
23
|
+
position: relative;
|
24
|
+
text-align: center;
|
25
|
+
text-rendering: geometricPrecision;
|
26
|
+
text-transform: uppercase;
|
27
|
+
-webkit-user-select: none;
|
28
|
+
-moz-user-select: none;
|
29
|
+
-ms-user-select: none;
|
30
|
+
user-select: none;
|
31
|
+
vertical-align: middle;
|
32
|
+
}
|
33
|
+
.switch span,
|
34
|
+
.switch label {
|
35
|
+
-webkit-box-sizing: border-box;
|
36
|
+
box-sizing: border-box;
|
37
|
+
cursor: pointer;
|
38
|
+
display: inline-block;
|
39
|
+
height: 100%;
|
40
|
+
position: relative;
|
41
|
+
}
|
42
|
+
.switch label {
|
43
|
+
background: rgba(255,255,255,1);
|
44
|
+
border-radius: 500px;
|
45
|
+
margin-bottom: 0;
|
46
|
+
margin-top: 0;
|
47
|
+
padding-bottom: 4px;
|
48
|
+
padding-top: 4px;
|
49
|
+
text-align: center;
|
50
|
+
vertical-align: middle;
|
51
|
+
width: 20%;
|
52
|
+
z-index: 100;
|
53
|
+
}
|
54
|
+
.switch span {
|
55
|
+
padding-bottom: 5px;
|
56
|
+
padding-top: 3px;
|
57
|
+
text-align: center;
|
58
|
+
vertical-align: middle;
|
59
|
+
width: 40%;
|
60
|
+
z-index: 1;
|
61
|
+
}
|
62
|
+
.switch > div {
|
63
|
+
display: inline-block;
|
64
|
+
position: relative;
|
65
|
+
top: 0;
|
66
|
+
width: 150%;
|
67
|
+
}
|
68
|
+
.switch > div.switch-off { left: -50%; }
|
69
|
+
.switch > div.switch-on { left: 0%; }
|
70
|
+
.switch > div.switch-animate {
|
71
|
+
-webkit-transition: left 0.5s;
|
72
|
+
transition: left 0.5s;
|
73
|
+
}
|
@@ -42,7 +42,10 @@ table {
|
|
42
42
|
font-size: 14px;
|
43
43
|
padding: 5px 5px 3px 5px;
|
44
44
|
}
|
45
|
-
.table-condensed th {
|
45
|
+
.table-condensed th {
|
46
|
+
font-size: 12px;
|
47
|
+
padding: 5px;
|
48
|
+
}
|
46
49
|
.table-bordered {
|
47
50
|
border: 1px solid rgba(217,222,225,1);
|
48
51
|
border-collapse: separate;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flashoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,8 +70,6 @@ files:
|
|
70
70
|
- app/assets/fonts/ionicons/ionicons.svg
|
71
71
|
- app/assets/fonts/ionicons/ionicons.ttf
|
72
72
|
- app/assets/fonts/ionicons/ionicons.woff
|
73
|
-
- flashoff-0.0.3.gem
|
74
|
-
- flashoff-0.0.4.gem
|
75
73
|
- flashoff.gemspec
|
76
74
|
- lib/flashoff.rb
|
77
75
|
- lib/flashoff/version.rb
|
@@ -83,6 +81,7 @@ files:
|
|
83
81
|
- vendor/assets/javascripts/map.js
|
84
82
|
- vendor/assets/javascripts/modal.js
|
85
83
|
- vendor/assets/javascripts/popover.js
|
84
|
+
- vendor/assets/javascripts/switch.js
|
86
85
|
- vendor/assets/javascripts/tab.js
|
87
86
|
- vendor/assets/javascripts/time_picker.js
|
88
87
|
- vendor/assets/javascripts/tooltip.js
|
@@ -111,6 +110,7 @@ files:
|
|
111
110
|
- vendor/assets/stylesheets/popover.css.scss
|
112
111
|
- vendor/assets/stylesheets/progress.css.scss
|
113
112
|
- vendor/assets/stylesheets/reset.css.scss
|
113
|
+
- vendor/assets/stylesheets/switch.css.scss
|
114
114
|
- vendor/assets/stylesheets/tab.css.scss
|
115
115
|
- vendor/assets/stylesheets/table.css.scss
|
116
116
|
- vendor/assets/stylesheets/timepicker.css.scss
|
data/flashoff-0.0.3.gem
DELETED
Binary file
|
data/flashoff-0.0.4.gem
DELETED
Binary file
|