ios-checkboxes 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/Rakefile +22 -0
- data/ios-checkboxes.gemspec +19 -0
- data/lib/ios-checkboxes/version.rb +2 -2
- data/vendor/assets/images/ios-style-checkboxes/off.png +0 -0
- data/vendor/assets/images/ios-style-checkboxes/on.png +0 -0
- data/vendor/assets/images/ios-style-checkboxes/slider.png +0 -0
- data/vendor/assets/images/ios-style-checkboxes/slider_center.png +0 -0
- data/vendor/assets/images/ios-style-checkboxes/slider_left.png +0 -0
- data/vendor/assets/images/ios-style-checkboxes/slider_right.png +0 -0
- data/vendor/assets/images/iphone-style-checkboxes/off.png +0 -0
- data/vendor/assets/images/iphone-style-checkboxes/on.png +0 -0
- data/vendor/assets/images/iphone-style-checkboxes/slider.png +0 -0
- data/vendor/assets/images/iphone-style-checkboxes/slider_center.png +0 -0
- data/vendor/assets/images/iphone-style-checkboxes/slider_left.png +0 -0
- data/vendor/assets/images/iphone-style-checkboxes/slider_right.png +0 -0
- data/vendor/assets/javascripts/ios-checkboxes.js +31 -23
- data/vendor/assets/stylesheets/{ios-checkboxes.css → ios-checkboxes.css.erb} +10 -10
- metadata +48 -50
data/.gitignore
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
desc "Update the gem with the latest files"
|
5
|
+
task :update do
|
6
|
+
# Copy the js file and require jQuery
|
7
|
+
js_content = File.read "../jquery/iphone-style-checkboxes.js"
|
8
|
+
f = File.new("vendor/assets/javascripts/ios-checkboxes.js", "w")
|
9
|
+
f.write("//= require jquery\n\n#{js_content}")
|
10
|
+
f.close
|
11
|
+
|
12
|
+
# Copy the images
|
13
|
+
cp_r "../images/", "vendor/assets/"
|
14
|
+
|
15
|
+
# Copy CSS and make sure it references the images via assets pipeline
|
16
|
+
css_content = File.read "../style.css"
|
17
|
+
pattern = /url\('images\/([^']+)'\)/
|
18
|
+
css_processed = css_content.gsub(pattern) {|m| "url('<%= image_path \"#{$1.sub(/\?.*/, '')}\" %>')" }
|
19
|
+
f2 = File.new("vendor/assets/stylesheets/ios-checkboxes.css.erb", "w")
|
20
|
+
f2.write(css_processed)
|
21
|
+
f2.close
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/ios-checkboxes/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "ios-checkboxes"
|
6
|
+
s.version = IOSCheckboxes::VERSION
|
7
|
+
s.authors = ["Thomas Reynolds"]
|
8
|
+
s.email = ["me@tdreyno.com"]
|
9
|
+
s.homepage = "https://github.com/tdreyno/iphone-style-checkboxes"
|
10
|
+
s.summary = %q{iOS-style Checkboxes}
|
11
|
+
s.description = %q{iOS-style Checkboxes for Rails asset pipeline.}
|
12
|
+
|
13
|
+
s.rubyforge_project = "ios-checkboxes"
|
14
|
+
s.add_dependency "railties", "~> 3.1"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module IOSCheckboxes
|
2
|
-
VERSION = "0.0
|
3
|
-
end
|
2
|
+
VERSION = "0.1.0"
|
3
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,3 +1,5 @@
|
|
1
|
+
//= require jquery
|
2
|
+
|
1
3
|
(function() {
|
2
4
|
var iOSCheckbox;
|
3
5
|
var __slice = Array.prototype.slice;
|
@@ -10,6 +12,7 @@
|
|
10
12
|
value = opts[key];
|
11
13
|
this[key] = value;
|
12
14
|
}
|
15
|
+
this.elem.data(this.dataName, this);
|
13
16
|
this.wrapCheckboxWithDivs();
|
14
17
|
this.attachEvents();
|
15
18
|
this.disableTextSelection();
|
@@ -38,13 +41,20 @@
|
|
38
41
|
return $([this.handle, this.offLabel, this.onLabel, this.container]).attr("unselectable", "on");
|
39
42
|
}
|
40
43
|
};
|
44
|
+
iOSCheckbox.prototype._getDimension = function(elem, dimension) {
|
45
|
+
if ($.fn.actual != null) {
|
46
|
+
return elem.actual(dimension);
|
47
|
+
} else {
|
48
|
+
return elem[dimension]();
|
49
|
+
}
|
50
|
+
};
|
41
51
|
iOSCheckbox.prototype.optionallyResize = function(mode) {
|
42
52
|
var newWidth, offLabelWidth, onLabelWidth;
|
43
|
-
onLabelWidth = this.onLabel
|
44
|
-
offLabelWidth = this.offLabel
|
53
|
+
onLabelWidth = this._getDimension(this.onLabel, "width");
|
54
|
+
offLabelWidth = this._getDimension(this.offLabel, "width");
|
45
55
|
if (mode === "container") {
|
46
56
|
newWidth = onLabelWidth > offLabelWidth ? onLabelWidth : offLabelWidth;
|
47
|
-
newWidth += this.handle
|
57
|
+
newWidth += this._getDimension(this.handle, "width") + this.handleMargin;
|
48
58
|
return this.container.css({
|
49
59
|
width: newWidth
|
50
60
|
});
|
@@ -156,15 +166,16 @@
|
|
156
166
|
});
|
157
167
|
};
|
158
168
|
iOSCheckbox.prototype.initialPosition = function() {
|
159
|
-
var offset;
|
169
|
+
var containerWidth, offset;
|
170
|
+
containerWidth = this._getDimension(this.container, "width");
|
160
171
|
this.offLabel.css({
|
161
|
-
width:
|
172
|
+
width: containerWidth - this.containerRadius
|
162
173
|
});
|
163
174
|
offset = this.containerRadius + 1;
|
164
175
|
if ($.browser.msie && $.browser.version < 7) {
|
165
176
|
offset -= 3;
|
166
177
|
}
|
167
|
-
this.rightSide =
|
178
|
+
this.rightSide = containerWidth - this._getDimension(this.handle, "width") - offset;
|
168
179
|
if (this.elem.is(':checked')) {
|
169
180
|
this.handle.css({
|
170
181
|
left: this.rightSide
|
@@ -226,32 +237,33 @@
|
|
226
237
|
handleMargin: 15,
|
227
238
|
handleRadius: 4,
|
228
239
|
containerRadius: 5,
|
240
|
+
dataName: "iphoneStyle",
|
229
241
|
onChange: function() {}
|
230
242
|
};
|
231
243
|
return iOSCheckbox;
|
232
244
|
})();
|
233
245
|
$.iphoneStyle = this.iOSCheckbox = iOSCheckbox;
|
234
246
|
$.fn.iphoneStyle = function() {
|
235
|
-
var args, checkbox, existingControl, method,
|
247
|
+
var args, checkbox, dataName, existingControl, method, params, _i, _len, _ref, _ref2, _ref3, _ref4;
|
236
248
|
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
237
|
-
_ref =
|
238
|
-
|
239
|
-
|
240
|
-
|
249
|
+
dataName = (_ref = (_ref2 = args[0]) != null ? _ref2.dataName : void 0) != null ? _ref : iOSCheckbox.defaults.dataName;
|
250
|
+
_ref3 = this.filter(':checkbox');
|
251
|
+
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
|
252
|
+
checkbox = _ref3[_i];
|
253
|
+
existingControl = $(checkbox).data(dataName);
|
241
254
|
if (existingControl != null) {
|
242
255
|
method = args[0], params = 2 <= args.length ? __slice.call(args, 1) : [];
|
243
|
-
if ((
|
244
|
-
|
256
|
+
if ((_ref4 = existingControl[method]) != null) {
|
257
|
+
_ref4.apply(existingControl, params);
|
245
258
|
}
|
246
259
|
} else {
|
247
|
-
|
248
|
-
$(checkbox).data("iphoneStyle", new iOSCheckbox(checkbox, options));
|
260
|
+
new iOSCheckbox(checkbox, args[0]);
|
249
261
|
}
|
250
262
|
}
|
251
263
|
return this;
|
252
264
|
};
|
253
265
|
$.fn.iOSCheckbox = function(options) {
|
254
|
-
var
|
266
|
+
var opts;
|
255
267
|
if (options == null) {
|
256
268
|
options = {};
|
257
269
|
}
|
@@ -263,13 +275,9 @@
|
|
263
275
|
labelOffClass: 'iOSCheckLabelOff',
|
264
276
|
handleClass: 'iOSCheckHandle',
|
265
277
|
handleCenterClass: 'iOSCheckHandleCenter',
|
266
|
-
handleRightClass: 'iOSCheckHandleRight'
|
278
|
+
handleRightClass: 'iOSCheckHandleRight',
|
279
|
+
dataName: 'iOSCheckbox'
|
267
280
|
});
|
268
|
-
|
269
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
270
|
-
checkbox = _ref[_i];
|
271
|
-
$(checkbox).data("iOSCheckbox", new iOSCheckbox(checkbox, opts));
|
272
|
-
}
|
273
|
-
return this;
|
281
|
+
return this.iphoneStyle(opts);
|
274
282
|
};
|
275
283
|
}).call(this);
|
@@ -35,7 +35,7 @@
|
|
35
35
|
|
36
36
|
label.iPhoneCheckLabelOn {
|
37
37
|
color: white;
|
38
|
-
background: url('
|
38
|
+
background: url('<%= image_path "iphone-style-checkboxes/on.png" %>') no-repeat;
|
39
39
|
text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.6);
|
40
40
|
left: 0;
|
41
41
|
padding-top: 5px; }
|
@@ -43,7 +43,7 @@ label.iPhoneCheckLabelOn {
|
|
43
43
|
padding-left: 8px; }
|
44
44
|
label.iPhoneCheckLabelOff {
|
45
45
|
color: #8b8b8b;
|
46
|
-
background: url('
|
46
|
+
background: url('<%= image_path "iphone-style-checkboxes/off.png" %>') no-repeat right 0;
|
47
47
|
text-shadow: 0px 0px 2px rgba(255, 255, 255, 0.6);
|
48
48
|
text-align: right;
|
49
49
|
right: 0; }
|
@@ -58,19 +58,19 @@ label.iPhoneCheckLabelOff {
|
|
58
58
|
top: 0;
|
59
59
|
left: 0;
|
60
60
|
width: 0;
|
61
|
-
background: url('
|
61
|
+
background: url('<%= image_path "iphone-style-checkboxes/slider_left.png" %>') no-repeat;
|
62
62
|
padding-left: 3px; }
|
63
63
|
|
64
64
|
.iPhoneCheckHandleRight {
|
65
65
|
height: 100%;
|
66
66
|
width: 100%;
|
67
67
|
padding-right: 3px;
|
68
|
-
background: url('
|
68
|
+
background: url('<%= image_path "iphone-style-checkboxes/slider_right.png" %>') no-repeat right 0; }
|
69
69
|
|
70
70
|
.iPhoneCheckHandleCenter {
|
71
71
|
height: 100%;
|
72
72
|
width: 100%;
|
73
|
-
background: url('
|
73
|
+
background: url('<%= image_path "iphone-style-checkboxes/slider_center.png" %>'); }
|
74
74
|
|
75
75
|
.iOSCheckContainer {
|
76
76
|
position: relative;
|
@@ -109,7 +109,7 @@ label.iPhoneCheckLabelOff {
|
|
109
109
|
|
110
110
|
label.iOSCheckLabelOn {
|
111
111
|
color: white;
|
112
|
-
background: url('
|
112
|
+
background: url('<%= image_path "ios-style-checkboxes/on.png" %>') no-repeat;
|
113
113
|
text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.6);
|
114
114
|
left: 0;
|
115
115
|
padding-top: 5px; }
|
@@ -117,7 +117,7 @@ label.iOSCheckLabelOn {
|
|
117
117
|
padding-left: 8px; }
|
118
118
|
label.iOSCheckLabelOff {
|
119
119
|
color: #8b8b8b;
|
120
|
-
background: url('
|
120
|
+
background: url('<%= image_path "ios-style-checkboxes/off.png" %>') no-repeat right 0;
|
121
121
|
text-shadow: 0px 0px 2px rgba(255, 255, 255, 0.6);
|
122
122
|
text-align: right;
|
123
123
|
right: 0; }
|
@@ -132,16 +132,16 @@ label.iOSCheckLabelOff {
|
|
132
132
|
top: 0;
|
133
133
|
left: 0;
|
134
134
|
width: 0;
|
135
|
-
background: url('
|
135
|
+
background: url('<%= image_path "ios-style-checkboxes/slider_left.png" %>') no-repeat;
|
136
136
|
padding-left: 3px; }
|
137
137
|
|
138
138
|
.iOSCheckHandleRight {
|
139
139
|
height: 100%;
|
140
140
|
width: 100%;
|
141
141
|
padding-right: 3px;
|
142
|
-
background: url('
|
142
|
+
background: url('<%= image_path "ios-style-checkboxes/slider_right.png" %>') no-repeat right 0; }
|
143
143
|
|
144
144
|
.iOSCheckHandleCenter {
|
145
145
|
height: 100%;
|
146
146
|
width: 100%;
|
147
|
-
background: url('
|
147
|
+
background: url('<%= image_path "ios-style-checkboxes/slider_center.png" %>'); }
|
metadata
CHANGED
@@ -1,78 +1,76 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ios-checkboxes
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Thomas Reynolds
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-11-13 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: railties
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
16
|
+
requirement: &70318773319200 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
25
19
|
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 3
|
29
|
-
- 1
|
30
|
-
version: "3.1"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
31
22
|
type: :runtime
|
32
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70318773319200
|
33
25
|
description: iOS-style Checkboxes for Rails asset pipeline.
|
34
|
-
email:
|
26
|
+
email:
|
35
27
|
- me@tdreyno.com
|
36
28
|
executables: []
|
37
|
-
|
38
29
|
extensions: []
|
39
|
-
|
40
30
|
extra_rdoc_files: []
|
41
|
-
|
42
|
-
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Rakefile
|
34
|
+
- ios-checkboxes.gemspec
|
43
35
|
- lib/ios-checkboxes.rb
|
44
36
|
- lib/ios-checkboxes/version.rb
|
37
|
+
- vendor/assets/images/ios-style-checkboxes/off.png
|
38
|
+
- vendor/assets/images/ios-style-checkboxes/on.png
|
39
|
+
- vendor/assets/images/ios-style-checkboxes/slider.png
|
40
|
+
- vendor/assets/images/ios-style-checkboxes/slider_center.png
|
41
|
+
- vendor/assets/images/ios-style-checkboxes/slider_left.png
|
42
|
+
- vendor/assets/images/ios-style-checkboxes/slider_right.png
|
43
|
+
- vendor/assets/images/iphone-style-checkboxes/off.png
|
44
|
+
- vendor/assets/images/iphone-style-checkboxes/on.png
|
45
|
+
- vendor/assets/images/iphone-style-checkboxes/slider.png
|
46
|
+
- vendor/assets/images/iphone-style-checkboxes/slider_center.png
|
47
|
+
- vendor/assets/images/iphone-style-checkboxes/slider_left.png
|
48
|
+
- vendor/assets/images/iphone-style-checkboxes/slider_right.png
|
45
49
|
- vendor/assets/javascripts/ios-checkboxes.js
|
46
|
-
- vendor/assets/stylesheets/ios-checkboxes.css
|
47
|
-
has_rdoc: true
|
50
|
+
- vendor/assets/stylesheets/ios-checkboxes.css.erb
|
48
51
|
homepage: https://github.com/tdreyno/iphone-style-checkboxes
|
49
52
|
licenses: []
|
50
|
-
|
51
53
|
post_install_message:
|
52
54
|
rdoc_options: []
|
53
|
-
|
54
|
-
require_paths:
|
55
|
+
require_paths:
|
55
56
|
- lib
|
56
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
|
68
|
-
- 0
|
69
|
-
version: "0"
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
70
69
|
requirements: []
|
71
|
-
|
72
70
|
rubyforge_project: ios-checkboxes
|
73
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 1.8.10
|
74
72
|
signing_key:
|
75
73
|
specification_version: 3
|
76
74
|
summary: iOS-style Checkboxes
|
77
75
|
test_files: []
|
78
|
-
|
76
|
+
has_rdoc:
|