icheck-rails 0.9.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +4 -0
- data/README.md +96 -0
- data/Rakefile +38 -0
- data/lib/icheck-rails.rb +2 -0
- data/lib/icheck/rails/engine.rb +8 -0
- data/lib/icheck/rails/version.rb +5 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +16 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/tmp/cache/assets/C49/860/sprockets%2Ff95ca6fa195a121539576516050f0442 +0 -0
- data/test/dummy/tmp/cache/assets/C9D/6A0/sprockets%2F4e5f511955e048e988945f98fa362d50 +0 -0
- data/test/dummy/tmp/cache/assets/CA6/AD0/sprockets%2F54996ad04dbd12db290577520c5700a8 +0 -0
- data/test/dummy/tmp/cache/assets/D38/750/sprockets%2Fc329f8e2db11af756248e0ad6641af14 +0 -0
- data/test/dummy/tmp/cache/assets/D47/4E0/sprockets%2Fe628b0a79f40ee32cde4ee70e1671786 +0 -0
- data/test/dummy/tmp/cache/assets/D64/5D0/sprockets%2F3239d9cc3226b6f515f4b30fbfc46ac0 +0 -0
- data/test/dummy/tmp/cache/assets/DCB/2C0/sprockets%2F88aac4e21c3d3e6cfa7b82d245362def +0 -0
- data/test/dummy/tmp/cache/assets/E3A/2E0/sprockets%2Fd64d85294b8d3da8cfb8cdb4ce7e1fa6 +0 -0
- data/test/integration/icheck_deployment_test.rb +15 -0
- data/test/test_helper.rb +12 -0
- data/vendor/assets/images/icheck/flat/aero.png +0 -0
- data/vendor/assets/images/icheck/flat/aero@2x.png +0 -0
- data/vendor/assets/images/icheck/flat/blue.png +0 -0
- data/vendor/assets/images/icheck/flat/blue@2x.png +0 -0
- data/vendor/assets/images/icheck/flat/flat.png +0 -0
- data/vendor/assets/images/icheck/flat/flat@2x.png +0 -0
- data/vendor/assets/images/icheck/flat/green.png +0 -0
- data/vendor/assets/images/icheck/flat/green@2x.png +0 -0
- data/vendor/assets/images/icheck/flat/grey.png +0 -0
- data/vendor/assets/images/icheck/flat/grey@2x.png +0 -0
- data/vendor/assets/images/icheck/flat/orange.png +0 -0
- data/vendor/assets/images/icheck/flat/orange@2x.png +0 -0
- data/vendor/assets/images/icheck/flat/pink.png +0 -0
- data/vendor/assets/images/icheck/flat/pink@2x.png +0 -0
- data/vendor/assets/images/icheck/flat/purple.png +0 -0
- data/vendor/assets/images/icheck/flat/purple@2x.png +0 -0
- data/vendor/assets/images/icheck/flat/red.png +0 -0
- data/vendor/assets/images/icheck/flat/red@2x.png +0 -0
- data/vendor/assets/images/icheck/flat/yellow.png +0 -0
- data/vendor/assets/images/icheck/flat/yellow@2x.png +0 -0
- data/vendor/assets/images/icheck/futurico/futurico.png +0 -0
- data/vendor/assets/images/icheck/futurico/futurico@2x.png +0 -0
- data/vendor/assets/images/icheck/line/line.png +0 -0
- data/vendor/assets/images/icheck/line/line@2x.png +0 -0
- data/vendor/assets/images/icheck/minimal/aero.png +0 -0
- data/vendor/assets/images/icheck/minimal/aero@2x.png +0 -0
- data/vendor/assets/images/icheck/minimal/blue.png +0 -0
- data/vendor/assets/images/icheck/minimal/blue@2x.png +0 -0
- data/vendor/assets/images/icheck/minimal/green.png +0 -0
- data/vendor/assets/images/icheck/minimal/green@2x.png +0 -0
- data/vendor/assets/images/icheck/minimal/grey.png +0 -0
- data/vendor/assets/images/icheck/minimal/grey@2x.png +0 -0
- data/vendor/assets/images/icheck/minimal/minimal.png +0 -0
- data/vendor/assets/images/icheck/minimal/minimal@2x.png +0 -0
- data/vendor/assets/images/icheck/minimal/orange.png +0 -0
- data/vendor/assets/images/icheck/minimal/orange@2x.png +0 -0
- data/vendor/assets/images/icheck/minimal/pink.png +0 -0
- data/vendor/assets/images/icheck/minimal/pink@2x.png +0 -0
- data/vendor/assets/images/icheck/minimal/purple.png +0 -0
- data/vendor/assets/images/icheck/minimal/purple@2x.png +0 -0
- data/vendor/assets/images/icheck/minimal/red.png +0 -0
- data/vendor/assets/images/icheck/minimal/red@2x.png +0 -0
- data/vendor/assets/images/icheck/minimal/yellow.png +0 -0
- data/vendor/assets/images/icheck/minimal/yellow@2x.png +0 -0
- data/vendor/assets/images/icheck/polaris/polaris.png +0 -0
- data/vendor/assets/images/icheck/polaris/polaris@2x.png +0 -0
- data/vendor/assets/images/icheck/square/aero.png +0 -0
- data/vendor/assets/images/icheck/square/aero@2x.png +0 -0
- data/vendor/assets/images/icheck/square/blue.png +0 -0
- data/vendor/assets/images/icheck/square/blue@2x.png +0 -0
- data/vendor/assets/images/icheck/square/green.png +0 -0
- data/vendor/assets/images/icheck/square/green@2x.png +0 -0
- data/vendor/assets/images/icheck/square/grey.png +0 -0
- data/vendor/assets/images/icheck/square/grey@2x.png +0 -0
- data/vendor/assets/images/icheck/square/orange.png +0 -0
- data/vendor/assets/images/icheck/square/orange@2x.png +0 -0
- data/vendor/assets/images/icheck/square/pink.png +0 -0
- data/vendor/assets/images/icheck/square/pink@2x.png +0 -0
- data/vendor/assets/images/icheck/square/purple.png +0 -0
- data/vendor/assets/images/icheck/square/purple@2x.png +0 -0
- data/vendor/assets/images/icheck/square/red.png +0 -0
- data/vendor/assets/images/icheck/square/red@2x.png +0 -0
- data/vendor/assets/images/icheck/square/square.png +0 -0
- data/vendor/assets/images/icheck/square/square@2x.png +0 -0
- data/vendor/assets/images/icheck/square/yellow.png +0 -0
- data/vendor/assets/images/icheck/square/yellow@2x.png +0 -0
- data/vendor/assets/javascripts/jquery.icheck.js +397 -0
- data/vendor/assets/javascripts/zepto.icheck.js +402 -0
- data/vendor/assets/stylesheets/icheck/flat/_all.css +540 -0
- data/vendor/assets/stylesheets/icheck/flat/aero.css +54 -0
- data/vendor/assets/stylesheets/icheck/flat/blue.css +54 -0
- data/vendor/assets/stylesheets/icheck/flat/flat.css +54 -0
- data/vendor/assets/stylesheets/icheck/flat/green.css +54 -0
- data/vendor/assets/stylesheets/icheck/flat/grey.css +54 -0
- data/vendor/assets/stylesheets/icheck/flat/orange.css +54 -0
- data/vendor/assets/stylesheets/icheck/flat/pink.css +54 -0
- data/vendor/assets/stylesheets/icheck/flat/purple.css +54 -0
- data/vendor/assets/stylesheets/icheck/flat/red.css +54 -0
- data/vendor/assets/stylesheets/icheck/flat/yellow.css +54 -0
- data/vendor/assets/stylesheets/icheck/futurico/futurico.css +54 -0
- data/vendor/assets/stylesheets/icheck/line/_all.css +740 -0
- data/vendor/assets/stylesheets/icheck/line/aero.css +74 -0
- data/vendor/assets/stylesheets/icheck/line/blue.css +74 -0
- data/vendor/assets/stylesheets/icheck/line/green.css +74 -0
- data/vendor/assets/stylesheets/icheck/line/grey.css +74 -0
- data/vendor/assets/stylesheets/icheck/line/line.css +74 -0
- data/vendor/assets/stylesheets/icheck/line/orange.css +74 -0
- data/vendor/assets/stylesheets/icheck/line/pink.css +74 -0
- data/vendor/assets/stylesheets/icheck/line/purple.css +74 -0
- data/vendor/assets/stylesheets/icheck/line/red.css +74 -0
- data/vendor/assets/stylesheets/icheck/line/yellow.css +74 -0
- data/vendor/assets/stylesheets/icheck/minimal/_all.css +600 -0
- data/vendor/assets/stylesheets/icheck/minimal/aero.css +60 -0
- data/vendor/assets/stylesheets/icheck/minimal/blue.css +60 -0
- data/vendor/assets/stylesheets/icheck/minimal/green.css +60 -0
- data/vendor/assets/stylesheets/icheck/minimal/grey.css +60 -0
- data/vendor/assets/stylesheets/icheck/minimal/minimal.css +60 -0
- data/vendor/assets/stylesheets/icheck/minimal/orange.css +60 -0
- data/vendor/assets/stylesheets/icheck/minimal/pink.css +60 -0
- data/vendor/assets/stylesheets/icheck/minimal/purple.css +60 -0
- data/vendor/assets/stylesheets/icheck/minimal/red.css +60 -0
- data/vendor/assets/stylesheets/icheck/minimal/yellow.css +60 -0
- data/vendor/assets/stylesheets/icheck/polaris/polaris.css +60 -0
- data/vendor/assets/stylesheets/icheck/square/_all.css +600 -0
- data/vendor/assets/stylesheets/icheck/square/aero.css +60 -0
- data/vendor/assets/stylesheets/icheck/square/blue.css +60 -0
- data/vendor/assets/stylesheets/icheck/square/green.css +60 -0
- data/vendor/assets/stylesheets/icheck/square/grey.css +60 -0
- data/vendor/assets/stylesheets/icheck/square/orange.css +60 -0
- data/vendor/assets/stylesheets/icheck/square/pink.css +60 -0
- data/vendor/assets/stylesheets/icheck/square/purple.css +60 -0
- data/vendor/assets/stylesheets/icheck/square/red.css +60 -0
- data/vendor/assets/stylesheets/icheck/square/square.css +60 -0
- data/vendor/assets/stylesheets/icheck/square/yellow.css +60 -0
- metadata +319 -0
Binary file
|
File without changes
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe "icheck asset pipeline integration" do
|
4
|
+
|
5
|
+
it "should include jquery.icheck.js via the asset pipeline" do
|
6
|
+
visit '/assets/jquery.icheck.js'
|
7
|
+
page.text.must_include '(c) 2013 Damir Foy, http://damirfoy.com'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should include jquery.icheck.js via the asset pipeline" do
|
11
|
+
visit '/assets/square/_all.css'
|
12
|
+
page.text.must_include 'iCheck plugin Square skin'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV['RAILS_ENV'] = 'test'
|
3
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'capybara/rails'
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
class IntegrationTest < MiniTest::Spec
|
10
|
+
include Capybara::DSL
|
11
|
+
register_spec_type(/integration$/, self)
|
12
|
+
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
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,397 @@
|
|
1
|
+
/*!
|
2
|
+
* iCheck v0.9, http://git.io/uhUPMA
|
3
|
+
* =================================
|
4
|
+
* Powerful jQuery plugin for checkboxes and radio buttons customization
|
5
|
+
*
|
6
|
+
* (c) 2013 Damir Foy, http://damirfoy.com
|
7
|
+
* MIT Licensed
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function($, _iCheck, _checkbox, _radio, _checked, _disabled, _type, _click, _touch, _add, _remove, _cursor) {
|
11
|
+
|
12
|
+
// Create a plugin
|
13
|
+
$.fn[_iCheck] = function(options, fire) {
|
14
|
+
|
15
|
+
// Cached vars
|
16
|
+
var user = navigator.userAgent,
|
17
|
+
mobile = /ipad|iphone|ipod|android|blackberry|windows phone|opera mini/i.test(user),
|
18
|
+
handle = ':' + _checkbox + ', :' + _radio,
|
19
|
+
stack = $(),
|
20
|
+
walker = function(object) {
|
21
|
+
object.each(function() {
|
22
|
+
var self = $(this);
|
23
|
+
|
24
|
+
if (self.is(handle)) {
|
25
|
+
stack = stack.add(self);
|
26
|
+
} else {
|
27
|
+
stack = stack.add(self.find(handle));
|
28
|
+
};
|
29
|
+
});
|
30
|
+
};
|
31
|
+
|
32
|
+
// Check if we should operate with some method
|
33
|
+
if (/^(check|uncheck|toggle|disable|enable|update|destroy)$/.test(options)) {
|
34
|
+
|
35
|
+
// Find checkboxes and radio buttons
|
36
|
+
walker(this);
|
37
|
+
|
38
|
+
return stack.each(function() {
|
39
|
+
var self = $(this);
|
40
|
+
|
41
|
+
if (options == 'destroy') {
|
42
|
+
tidy(self, 'ifDestroyed');
|
43
|
+
} else {
|
44
|
+
operate(self, true, options);
|
45
|
+
};
|
46
|
+
|
47
|
+
// Fire method's callback
|
48
|
+
if ($.isFunction(fire)) {
|
49
|
+
fire();
|
50
|
+
};
|
51
|
+
});
|
52
|
+
|
53
|
+
// Customization
|
54
|
+
} else if (typeof options == 'object' || !options) {
|
55
|
+
|
56
|
+
// Check if any options were passed
|
57
|
+
var settings = $.extend({
|
58
|
+
checkedClass: _checked,
|
59
|
+
disabledClass: _disabled,
|
60
|
+
labelHover: true
|
61
|
+
}, options),
|
62
|
+
|
63
|
+
selector = settings.handle,
|
64
|
+
hoverClass = settings.hoverClass || 'hover',
|
65
|
+
focusClass = settings.focusClass || 'focus',
|
66
|
+
activeClass = settings.activeClass || 'active',
|
67
|
+
labelHover = !!settings.labelHover,
|
68
|
+
labelHoverClass = settings.labelHoverClass || 'hover',
|
69
|
+
|
70
|
+
// Setup clickable area
|
71
|
+
area = ('' + settings.increaseArea).replace('%', '') | 0;
|
72
|
+
|
73
|
+
// Selector limit
|
74
|
+
if (selector == _checkbox || selector == _radio) {
|
75
|
+
handle = ':' + selector;
|
76
|
+
};
|
77
|
+
|
78
|
+
// Clickable area limit
|
79
|
+
if (area < -50) {
|
80
|
+
area = -50;
|
81
|
+
};
|
82
|
+
|
83
|
+
// Walk around the selector
|
84
|
+
walker(this);
|
85
|
+
|
86
|
+
return stack.each(function() {
|
87
|
+
var self = $(this);
|
88
|
+
|
89
|
+
// If already customized
|
90
|
+
tidy(self);
|
91
|
+
|
92
|
+
var node = this,
|
93
|
+
id = node.id,
|
94
|
+
|
95
|
+
// Layer styles
|
96
|
+
offset = -area + '%',
|
97
|
+
size = 100 + (area * 2) + '%',
|
98
|
+
layer = {
|
99
|
+
position: 'absolute',
|
100
|
+
top: offset,
|
101
|
+
left: offset,
|
102
|
+
display: 'block',
|
103
|
+
width: size,
|
104
|
+
height: size,
|
105
|
+
margin: 0,
|
106
|
+
padding: 0,
|
107
|
+
background: '#fff',
|
108
|
+
border: 0,
|
109
|
+
opacity: 0
|
110
|
+
},
|
111
|
+
|
112
|
+
// Choose how to hide input
|
113
|
+
hide = mobile ? {
|
114
|
+
position: 'absolute',
|
115
|
+
visibility: 'hidden'
|
116
|
+
} : area ? layer : {
|
117
|
+
position: 'absolute',
|
118
|
+
opacity: 0
|
119
|
+
},
|
120
|
+
|
121
|
+
// Get proper class
|
122
|
+
className = node[_type] == _checkbox ? settings.checkboxClass || 'i' + _checkbox : settings.radioClass || 'i' + _radio,
|
123
|
+
|
124
|
+
// Find assigned labels
|
125
|
+
label = $('label[for="' + id + '"]').add(self.closest('label')),
|
126
|
+
|
127
|
+
// Wrap input
|
128
|
+
parent = self.wrap('<div class="' + className + '"/>').trigger('ifCreated').parent().append(settings.insert),
|
129
|
+
|
130
|
+
// Layer addition
|
131
|
+
helper = $('<ins class="' + _iCheck + '-helper"/>').css(layer).appendTo(parent);
|
132
|
+
|
133
|
+
// Finalize customization
|
134
|
+
self.data(_iCheck, {o: settings, s: self.attr('style')}).css(hide);
|
135
|
+
!!settings.inheritClass && parent[_add](node.className);
|
136
|
+
!!settings.inheritID && id && parent.attr('id', _iCheck + '-' + id);
|
137
|
+
parent.css('position') == 'static' && parent.css('position', 'relative');
|
138
|
+
operate(self, true, 'update');
|
139
|
+
|
140
|
+
// Label events
|
141
|
+
if (label.length) {
|
142
|
+
label.on(_click + '.i mouseenter.i mouseleave.i ' + _touch, function(event) {
|
143
|
+
var type = event[_type],
|
144
|
+
item = $(this);
|
145
|
+
|
146
|
+
// Do nothing if input is disabled
|
147
|
+
if (!node[_disabled]) {
|
148
|
+
|
149
|
+
// Click
|
150
|
+
if (type == _click) {
|
151
|
+
operate(self, false, true);
|
152
|
+
|
153
|
+
// Hover state
|
154
|
+
} else if (labelHover) {
|
155
|
+
if (/ve|nd/.test(type)) {
|
156
|
+
// mouseleave|touchend
|
157
|
+
parent[_remove](hoverClass);
|
158
|
+
item[_remove](labelHoverClass);
|
159
|
+
} else {
|
160
|
+
parent[_add](hoverClass);
|
161
|
+
item[_add](labelHoverClass);
|
162
|
+
};
|
163
|
+
};
|
164
|
+
|
165
|
+
if (mobile) {
|
166
|
+
event.stopPropagation();
|
167
|
+
} else {
|
168
|
+
return false;
|
169
|
+
};
|
170
|
+
};
|
171
|
+
});
|
172
|
+
};
|
173
|
+
|
174
|
+
// Input events
|
175
|
+
self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i', function(event) {
|
176
|
+
var type = event[_type],
|
177
|
+
key = event.keyCode;
|
178
|
+
|
179
|
+
// Click
|
180
|
+
if (type == _click) {
|
181
|
+
return false;
|
182
|
+
|
183
|
+
// Keydown
|
184
|
+
} else if (type == 'keydown' && key == 32) {
|
185
|
+
if (!(node[_type] == _radio && node[_checked])) {
|
186
|
+
if (node[_checked]) {
|
187
|
+
off(self, _checked);
|
188
|
+
} else {
|
189
|
+
on(self, _checked);
|
190
|
+
};
|
191
|
+
};
|
192
|
+
|
193
|
+
return false;
|
194
|
+
|
195
|
+
// Keyup
|
196
|
+
} else if (type == 'keyup' && node[_type] == _radio) {
|
197
|
+
!node[_checked] && on(self, _checked);
|
198
|
+
|
199
|
+
// Focus/blur
|
200
|
+
} else if (/us|ur/.test(type)) {
|
201
|
+
parent[type == 'blur' ? _remove : _add](focusClass);
|
202
|
+
};
|
203
|
+
});
|
204
|
+
|
205
|
+
// Helper events
|
206
|
+
helper.on(_click + ' mousedown mouseup mouseover mouseout ' + _touch, function(event) {
|
207
|
+
var type = event[_type],
|
208
|
+
|
209
|
+
// mousedown|mouseup
|
210
|
+
toggle = /wn|up/.test(type) ? activeClass : hoverClass;
|
211
|
+
|
212
|
+
// Do nothing if input is disabled
|
213
|
+
if (!node[_disabled]) {
|
214
|
+
|
215
|
+
// Click
|
216
|
+
if (type == _click) {
|
217
|
+
operate(self, false, true);
|
218
|
+
|
219
|
+
// Active and hover states
|
220
|
+
} else {
|
221
|
+
|
222
|
+
// State is on
|
223
|
+
if (/wn|er|in/.test(type)) {
|
224
|
+
// mousedown|mouseover|touchbegin
|
225
|
+
parent[_add](toggle);
|
226
|
+
|
227
|
+
// State is off
|
228
|
+
} else {
|
229
|
+
parent[_remove](toggle + ' ' + activeClass);
|
230
|
+
};
|
231
|
+
|
232
|
+
// Label hover
|
233
|
+
if (label.length && labelHover && toggle == hoverClass) {
|
234
|
+
|
235
|
+
// mouseout|touchend
|
236
|
+
label[/ut|nd/.test(type) ? _remove : _add](labelHoverClass);
|
237
|
+
};
|
238
|
+
};
|
239
|
+
|
240
|
+
if (mobile) {
|
241
|
+
event.stopPropagation();
|
242
|
+
} else {
|
243
|
+
return false;
|
244
|
+
};
|
245
|
+
};
|
246
|
+
});
|
247
|
+
});
|
248
|
+
} else {
|
249
|
+
return this;
|
250
|
+
};
|
251
|
+
};
|
252
|
+
|
253
|
+
// Do something with inputs
|
254
|
+
function operate(input, direct, method) {
|
255
|
+
var node = input[0];
|
256
|
+
|
257
|
+
// disable|enable
|
258
|
+
state = /ble/.test(method) ? _disabled : _checked,
|
259
|
+
active = method == 'update' ? {checked: node[_checked], disabled: node[_disabled]} : node[state];
|
260
|
+
|
261
|
+
// Check and disable
|
262
|
+
if (/^ch|di/.test(method) && !active) {
|
263
|
+
on(input, state);
|
264
|
+
|
265
|
+
// Uncheck and enable
|
266
|
+
} else if (/^un|en/.test(method) && active) {
|
267
|
+
off(input, state);
|
268
|
+
|
269
|
+
// Update
|
270
|
+
} else if (method == 'update') {
|
271
|
+
|
272
|
+
// Both checked and disabled states
|
273
|
+
for (var state in active) {
|
274
|
+
if (active[state]) {
|
275
|
+
on(input, state, true);
|
276
|
+
} else {
|
277
|
+
off(input, state, true);
|
278
|
+
};
|
279
|
+
};
|
280
|
+
|
281
|
+
} else if (!direct || method == 'toggle') {
|
282
|
+
|
283
|
+
// Helper or label was clicked
|
284
|
+
if (!direct) {
|
285
|
+
input.trigger('ifClicked');
|
286
|
+
};
|
287
|
+
|
288
|
+
// Toggle checked state
|
289
|
+
if (active) {
|
290
|
+
if (node[_type] !== _radio) {
|
291
|
+
off(input, state);
|
292
|
+
};
|
293
|
+
} else {
|
294
|
+
on(input, state);
|
295
|
+
};
|
296
|
+
};
|
297
|
+
};
|
298
|
+
|
299
|
+
// Set checked or disabled state
|
300
|
+
function on(input, state, keep) {
|
301
|
+
var node = input[0],
|
302
|
+
parent = input.parent(),
|
303
|
+
remove = state == _disabled ? 'enabled' : 'un' + _checked,
|
304
|
+
regular = option(input, remove + capitalize(node[_type])),
|
305
|
+
specific = option(input, state + capitalize(node[_type]));
|
306
|
+
|
307
|
+
// Prevent unnecessary actions
|
308
|
+
if (node[state] !== true && !keep) {
|
309
|
+
|
310
|
+
// Toggle state
|
311
|
+
node[state] = true;
|
312
|
+
|
313
|
+
// Trigger callbacks
|
314
|
+
input.trigger('ifChanged').trigger('if' + capitalize(state));
|
315
|
+
|
316
|
+
// Toggle assigned radio buttons
|
317
|
+
if (state == _checked && node[_type] == _radio && node.name) {
|
318
|
+
var form = input.closest('form'),
|
319
|
+
stack = 'input[name="' + node.name + '"]';
|
320
|
+
|
321
|
+
stack = form.length ? form.find(stack) : $(stack);
|
322
|
+
|
323
|
+
stack.each(function() {
|
324
|
+
if (this !== node && $(this).data(_iCheck)) {
|
325
|
+
off($(this), state);
|
326
|
+
};
|
327
|
+
});
|
328
|
+
};
|
329
|
+
};
|
330
|
+
|
331
|
+
// Add proper cursor
|
332
|
+
if (node[_disabled] && !!option(input, _cursor, true)) {
|
333
|
+
parent.find('.' + _iCheck + '-helper').css(_cursor, 'default');
|
334
|
+
};
|
335
|
+
|
336
|
+
// Add state class
|
337
|
+
parent[_add](specific || option(input, state));
|
338
|
+
|
339
|
+
// Remove regular state class
|
340
|
+
parent[_remove](regular || option(input, remove) || '');
|
341
|
+
};
|
342
|
+
|
343
|
+
// Remove checked or disabled state
|
344
|
+
function off(input, state, keep) {
|
345
|
+
var node = input[0],
|
346
|
+
parent = input.parent(),
|
347
|
+
callback = state == _disabled ? 'enabled' : 'un' + _checked,
|
348
|
+
regular = option(input, callback + capitalize(node[_type])),
|
349
|
+
specific = option(input, state + capitalize(node[_type]));
|
350
|
+
|
351
|
+
// Prevent unnecessary actions
|
352
|
+
if (node[state] !== false && !keep) {
|
353
|
+
|
354
|
+
// Toggle state
|
355
|
+
node[state] = false;
|
356
|
+
|
357
|
+
// Trigger callbacks
|
358
|
+
input.trigger('ifChanged').trigger('if' + capitalize(callback));
|
359
|
+
};
|
360
|
+
|
361
|
+
// Add proper cursor
|
362
|
+
if (!node[_disabled] && !!option(input, _cursor, true)) {
|
363
|
+
parent.find('.' + _iCheck + '-helper').css(_cursor, 'pointer');
|
364
|
+
};
|
365
|
+
|
366
|
+
// Remove state class
|
367
|
+
parent[_remove](specific || option(input, state) || '');
|
368
|
+
|
369
|
+
// Add regular state class
|
370
|
+
parent[_add](regular || option(input, callback));
|
371
|
+
};
|
372
|
+
|
373
|
+
// Remove all traces of iCheck
|
374
|
+
function tidy(input, callback) {
|
375
|
+
if (input.data(_iCheck)) {
|
376
|
+
|
377
|
+
// Remove everything except input
|
378
|
+
input.parent().html(input.attr('style', input.data(_iCheck).s || '').trigger(callback || ''));
|
379
|
+
|
380
|
+
// Unbind events
|
381
|
+
input.off('.i').unwrap();
|
382
|
+
$('label[for="' + input[0].id + '"]').add(input.closest('label')).off('.i');
|
383
|
+
};
|
384
|
+
};
|
385
|
+
|
386
|
+
// Get some option
|
387
|
+
function option(input, state, regular) {
|
388
|
+
if (input.data(_iCheck)) {
|
389
|
+
return input.data(_iCheck).o[state + (regular ? '' : 'Class')];
|
390
|
+
};
|
391
|
+
};
|
392
|
+
|
393
|
+
// Capitalize some string
|
394
|
+
function capitalize(string) {
|
395
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
396
|
+
};
|
397
|
+
})(jQuery, 'iCheck', 'checkbox', 'radio', 'checked', 'disabled', 'type', 'click', 'touchbegin.i touchend.i', 'addClass', 'removeClass', 'cursor');
|