bootstrap-switch-rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e706b7076307718425514c0685bde92b25c4fcca
4
- data.tar.gz: a756f9d5cdaf7ac9100e9219b104771e83e32405
3
+ metadata.gz: 50d7f4cc082bc72ecd6ceec23fd7f7e8361c1c11
4
+ data.tar.gz: 7a0ca84d44cd6c9e5294c582043a268e5bcfe0e7
5
5
  SHA512:
6
- metadata.gz: 13d09c70dc6e4aed31539f12aedc68ed169b0909562e4711d87400fe4c45af5ebfcbc59399616393b768953e21898641d57126eea43b3327d55460223c88c917
7
- data.tar.gz: 199be4799c241ea6e11c2344897228bed42b259474b328b34008386780f1d5f022e13e6d14411e043161dd096c96e4e5fc54f0873b74251a0167fd190d243a97
6
+ metadata.gz: 822b34195b02110c91b9c3e5802dc99fe9475f241e92fca6407fd4b957ea5ec6a4bb90ea0f2011307f49b8cbc3ce065104e06213ff43852c7af1d8e4c3212314
7
+ data.tar.gz: 2c9c8d4a3bd1eaa0a292e27de156e77edfbd8a937dd5850925009b8dbc8d7dbbf5d5c721b780651b15b67be6955e73bfd61c7bfffcafd98f06c0cd531b5f4584
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ _source
data/README.md CHANGED
@@ -35,6 +35,7 @@ See the [demo page of Mattia Larentis](http://www.larentis.eu/switch/) for examp
35
35
 
36
36
  | Version | Notes |
37
37
  |---------+---------------------------------------------------------------------------|
38
+ | 0.1.1 | Update to v1.3 of the bootstrap-switch plugin |
38
39
  | 0.1.0 | Initial release |
39
40
 
40
41
  ## License
@@ -1,7 +1,7 @@
1
1
  module Bootstrap
2
2
  module Switch
3
3
  module Rails
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  /* ============================================================
2
- * bootstrapSwitch v1.2 by Larentis Mattia @spiritualGuru
2
+ * bootstrapSwitch v1.3 by Larentis Mattia @spiritualGuru
3
3
  * http://www.larentis.eu/switch/
4
4
  * ============================================================
5
5
  * Licensed under the Apache License, Version 2.0
@@ -23,7 +23,8 @@
23
23
  , color
24
24
  , moving
25
25
  , onLabel = "ON"
26
- , offLabel = "OFF";
26
+ , offLabel = "OFF"
27
+ , icon = false;
27
28
 
28
29
  $.each(['switch-mini', 'switch-small', 'switch-large'], function (i, el) {
29
30
  if (classes.indexOf(el) >= 0)
@@ -41,6 +42,9 @@
41
42
  if ($element.data('off-label') !== undefined)
42
43
  offLabel = $element.data('off-label');
43
44
 
45
+ if ($element.data('icon') !== undefined)
46
+ icon = $element.data('icon');
47
+
44
48
  $switchLeft = $('<span>')
45
49
  .addClass("switch-left")
46
50
  .addClass(myClasses)
@@ -62,6 +66,10 @@
62
66
  .addClass(myClasses)
63
67
  .attr('for', $element.find('input').attr('id'));
64
68
 
69
+ if (icon) {
70
+ $label.html('<i class="icon icon-' + icon + '"></i>');
71
+ }
72
+
65
73
  $div = $element.find(':checkbox').wrap($('<div>')).parent().data('animated', false);
66
74
 
67
75
  if ($element.data('animated') !== false)
@@ -99,22 +107,30 @@
99
107
  changeStatus($(this));
100
108
  });
101
109
 
102
- $element.find('input').on('change', function (e) {
103
- var $element = $(this).parent();
110
+ $element.find('input').on('change', function (e, skipOnChange) {
111
+ var $this = $(this)
112
+ , $element = $this.parent()
113
+ , thisState = $this.is(':checked')
114
+ , state = $element.is('.switch-off');
104
115
 
105
116
  e.preventDefault();
106
- e.stopImmediatePropagation();
107
117
 
108
118
  $element.css('left', '');
109
119
 
110
- if ($(this).is(':checked'))
111
- $element.removeClass('switch-off').addClass('switch-on');
112
- else $element.removeClass('switch-on').addClass('switch-off');
120
+ if (state === thisState) {
113
121
 
114
- if ($element.data('animated') !== false)
115
- $element.addClass("switch-animate");
122
+ if (thisState)
123
+ $element.removeClass('switch-off').addClass('switch-on');
124
+ else $element.removeClass('switch-on').addClass('switch-off');
116
125
 
117
- $element.parent().trigger('switch-change', {'el': $(this), 'value': $(this).is(':checked')})
126
+ if ($element.data('animated') !== false)
127
+ $element.addClass("switch-animate");
128
+
129
+ if (typeof skipOnChange === 'boolean' && skipOnChange)
130
+ return;
131
+
132
+ $element.parent().trigger('switch-change', {'el': $this, 'value': thisState})
133
+ }
118
134
  });
119
135
 
120
136
  $element.find('label').on('mousedown touchstart', function (e) {
@@ -126,7 +142,7 @@
126
142
 
127
143
  $this.closest('div').removeClass('switch-animate');
128
144
 
129
- if ($this.closest('.switch').is('.deactivate'))
145
+ if ($this.closest('.has-switch').is('.deactivate'))
130
146
  $this.unbind('click');
131
147
  else {
132
148
  $this.on('mousemove touchmove', function (e) {
@@ -55,7 +55,7 @@
55
55
  transition: left 0.5s;
56
56
  }
57
57
  .has-switch > div.switch-off {
58
- left: -49%;
58
+ left: -50%;
59
59
  }
60
60
  .has-switch > div.switch-on {
61
61
  left: 0%;
@@ -99,6 +99,7 @@
99
99
  line-height: normal;
100
100
  }
101
101
  .has-switch label {
102
+ text-align: center;
102
103
  margin-top: -1px;
103
104
  margin-bottom: -1px;
104
105
  z-index: 100;
@@ -136,6 +137,12 @@
136
137
  .has-switch label.active {
137
138
  background-color: #cccccc \9;
138
139
  }
140
+ .has-switch label i {
141
+ color: #000;
142
+ text-shadow: 0 1px 0 #fff;
143
+ line-height: 18px;
144
+ pointer-events: none;
145
+ }
139
146
  .has-switch span {
140
147
  text-align: center;
141
148
  z-index: 1;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-switch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel van Rijn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-20 00:00:00.000000000 Z
11
+ date: 2013-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler