switchery-rails 0.1.0 → 0.8.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Dockerfile +40 -0
- data/README.md +2 -2
- data/Rakefile +6 -2
- data/lib/switchery/rails/version.rb +1 -2
- data/make_new_release.sh +35 -0
- data/switchery-rails.gemspec +2 -2
- data/vendor/assets/javascripts/switchery.js +466 -62
- metadata +13 -15
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/CHANGELOG.md +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 59fb74ac8ba5c0b5a7ac0f744c7f7072b9fd37db4f76c75f75917f4810e5320e
|
4
|
+
data.tar.gz: 670e4f260eea535c9e77dcdad3a49b5241388e83f77391ee12c10ec01827f93e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c271caf8c995a0dcc3cc94405ea653c0e79dfb8b1f13ef8ee8812883e0fea9ed86853bea05f0d8075d04055b4a5e91771c088ee3537125eed19d2d5aee167f42
|
7
|
+
data.tar.gz: 84546e4b7674b952f6f824ea4954be410fa01120869d5d394009fc70ec17b6a04a08ebd42931f7b76b7ee33d947d82f32af5ce38ebf373456ce5061c8419da13
|
data/Dockerfile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Switchery-rails gem Dockerfile
|
2
|
+
#
|
3
|
+
# How to use it
|
4
|
+
# =============
|
5
|
+
#
|
6
|
+
# Visit https://blog.zedroot.org/2015/04/30/using-docker-to-maintain-a-ruby-gem/
|
7
|
+
|
8
|
+
# ~~~~ Image base ~~~~
|
9
|
+
# Base image with the latest Ruby only
|
10
|
+
FROM ruby:3.0.3-slim
|
11
|
+
MAINTAINER Guillaume Hain zedtux@zedroot.org
|
12
|
+
|
13
|
+
|
14
|
+
# ~~~~ Set up the environment ~~~~
|
15
|
+
ENV DEBIAN_FRONTEND noninteractive
|
16
|
+
|
17
|
+
RUN mkdir -p /gem/
|
18
|
+
WORKDIR /gem/
|
19
|
+
ADD . /gem/
|
20
|
+
|
21
|
+
# ~~~~ OS Maintenance & Rails Preparation ~~~~
|
22
|
+
# Rubygems and Bundler
|
23
|
+
RUN apt-get update && \
|
24
|
+
apt-get install -y git build-essential curl && \
|
25
|
+
touch ~/.gemrc && \
|
26
|
+
echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
|
27
|
+
gem install rubygems-update && \
|
28
|
+
update_rubygems && \
|
29
|
+
gem install bundler && \
|
30
|
+
bundle install && \
|
31
|
+
apt-get remove --purge -y build-essential && \
|
32
|
+
apt-get autoclean -y && \
|
33
|
+
apt-get clean
|
34
|
+
|
35
|
+
# Import the gem source code
|
36
|
+
VOLUME .:/gem/
|
37
|
+
|
38
|
+
|
39
|
+
ENTRYPOINT ["bundle", "exec"]
|
40
|
+
CMD ["rake", "-T"]
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# switchery-rails
|
2
2
|
|
3
|
-
Switchery for Rails.
|
3
|
+
[Switchery](https://github.com/abpetkov/switchery) for Rails.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -32,7 +32,7 @@ Then follow the instructions as described on the Switchery documentation.
|
|
32
32
|
|
33
33
|
## Contributing
|
34
34
|
|
35
|
-
1. Fork it ( https://github.com/
|
35
|
+
1. Fork it ( https://github.com/YourCursus/switchery-rails/fork )
|
36
36
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
37
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
38
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -2,7 +2,11 @@ require 'bundler/gem_tasks'
|
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
4
|
desc 'Update the Switchery Javascript and CSS files'
|
5
|
-
task :
|
5
|
+
task :update do
|
6
|
+
def remove_extra_version(version)
|
7
|
+
version.scan(/(\d\.\d\.\d)/).flatten.first
|
8
|
+
end
|
9
|
+
|
6
10
|
def download_switchery(version)
|
7
11
|
base_url = 'https://raw.githubusercontent.com/abpetkov/switchery'
|
8
12
|
puts "Downlading Switchery #{version} ..."
|
@@ -14,6 +18,6 @@ task :update_switchery do
|
|
14
18
|
|
15
19
|
FileUtils.mkdir_p('vendor/assets/javascripts')
|
16
20
|
FileUtils.mkdir_p('vendor/assets/stylesheets')
|
17
|
-
download_switchery(Switchery::Rails::
|
21
|
+
download_switchery(remove_extra_version(Switchery::Rails::VERSION))
|
18
22
|
puts "\e[32mDone!\e[0m"
|
19
23
|
end
|
data/make_new_release.sh
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
DOCKER_IMAGE_NAME="$USER/switchery-rails"
|
4
|
+
LIBRARY_NEW_VERSION=`cat lib/switchery/rails/version.rb | grep VERSION | awk '{ print $3 }' | tr -d "'"`
|
5
|
+
|
6
|
+
LIBRARY_UPDATED=`git status --porcelain | grep -v "lib/switchery/rails/version.rb"`
|
7
|
+
if [[ -n "$LIBRARY_UPDATED" ]]; then
|
8
|
+
echo "Your repository is not clean !"
|
9
|
+
exit 1
|
10
|
+
fi
|
11
|
+
|
12
|
+
echo "Building the Docker image ..."
|
13
|
+
docker build -t "$DOCKER_IMAGE_NAME" .
|
14
|
+
|
15
|
+
echo "Updating library code to version $LIBRARY_NEW_VERSION ..."
|
16
|
+
docker run --rm -v `pwd`:/gem/ "$DOCKER_IMAGE_NAME" rake update
|
17
|
+
|
18
|
+
LIBRARY_UPDATED=`git status --porcelain | grep -v make_new_release.sh`
|
19
|
+
if [[ -z "$LIBRARY_UPDATED" ]]; then
|
20
|
+
echo "No update found, stopping release creation."
|
21
|
+
exit 1
|
22
|
+
elif [[ "$LIBRARY_UPDATED" == " M lib/switchery/rails/version.rb" ]]; then
|
23
|
+
echo "None of the JS or CSS files have been updated."
|
24
|
+
exit 1
|
25
|
+
fi
|
26
|
+
|
27
|
+
echo "Committing new version ..."
|
28
|
+
git commit -am "Bumped version $LIBRARY_NEW_VERSION"
|
29
|
+
git tag -a "v$LIBRARY_NEW_VERSION" -m "v$LIBRARY_NEW_VERSION"
|
30
|
+
|
31
|
+
echo "Releasing gem ..."
|
32
|
+
docker run --rm -v ~/.gitconfig:/root/.gitconfig \
|
33
|
+
-v ~/.ssh/:/root/.ssh/ \
|
34
|
+
-v ~/.gem/:/root/.gem/ \
|
35
|
+
-v `pwd`:/gem/ "$DOCKER_IMAGE_NAME" rake release
|
data/switchery-rails.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.add_dependency 'railties', '
|
22
|
+
spec.add_dependency 'railties', '>= 3.2'
|
23
23
|
|
24
|
-
spec.add_development_dependency 'bundler'
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
26
|
end
|
@@ -56,11 +56,11 @@ require.helper.semVerSort = function(a, b) {
|
|
56
56
|
|
57
57
|
/**
|
58
58
|
* Find and require a module which name starts with the provided name.
|
59
|
-
* If multiple modules exists, the highest semver is used.
|
59
|
+
* If multiple modules exists, the highest semver is used.
|
60
60
|
* This function can only be used for remote dependencies.
|
61
61
|
|
62
62
|
* @param {String} name - module name: `user~repo`
|
63
|
-
* @param {Boolean} returnPath - returns the canonical require path if true,
|
63
|
+
* @param {Boolean} returnPath - returns the canonical require path if true,
|
64
64
|
* otherwise it returns the epxorted module
|
65
65
|
*/
|
66
66
|
require.latest = function (name, returnPath) {
|
@@ -83,7 +83,7 @@ require.latest = function (name, returnPath) {
|
|
83
83
|
semVerCandidates.push({version: version, name: moduleName});
|
84
84
|
} else {
|
85
85
|
otherCandidates.push({version: version, name: moduleName});
|
86
|
-
}
|
86
|
+
}
|
87
87
|
}
|
88
88
|
}
|
89
89
|
if (semVerCandidates.concat(otherCandidates).length === 0) {
|
@@ -98,7 +98,7 @@ require.latest = function (name, returnPath) {
|
|
98
98
|
}
|
99
99
|
// if the build contains more than one branch of the same module
|
100
100
|
// you should not use this funciton
|
101
|
-
var module = otherCandidates.
|
101
|
+
var module = otherCandidates.sort(function(a, b) {return a.name > b.name})[0].name;
|
102
102
|
if (returnPath === true) {
|
103
103
|
return module;
|
104
104
|
}
|
@@ -943,7 +943,7 @@ FastClick.notNeeded = function(layer) {
|
|
943
943
|
|
944
944
|
if (FastClick.prototype.deviceIsAndroid) {
|
945
945
|
metaViewport = document.querySelector('meta[name=viewport]');
|
946
|
-
|
946
|
+
|
947
947
|
if (metaViewport) {
|
948
948
|
// Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)
|
949
949
|
if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
|
@@ -1195,15 +1195,377 @@ ClassList.prototype.contains = function(name){
|
|
1195
1195
|
|
1196
1196
|
});
|
1197
1197
|
|
1198
|
+
require.register("component~event@0.1.4", function (exports, module) {
|
1199
|
+
var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',
|
1200
|
+
unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
|
1201
|
+
prefix = bind !== 'addEventListener' ? 'on' : '';
|
1202
|
+
|
1203
|
+
/**
|
1204
|
+
* Bind `el` event `type` to `fn`.
|
1205
|
+
*
|
1206
|
+
* @param {Element} el
|
1207
|
+
* @param {String} type
|
1208
|
+
* @param {Function} fn
|
1209
|
+
* @param {Boolean} capture
|
1210
|
+
* @return {Function}
|
1211
|
+
* @api public
|
1212
|
+
*/
|
1213
|
+
|
1214
|
+
exports.bind = function(el, type, fn, capture){
|
1215
|
+
el[bind](prefix + type, fn, capture || false);
|
1216
|
+
return fn;
|
1217
|
+
};
|
1218
|
+
|
1219
|
+
/**
|
1220
|
+
* Unbind `el` event `type`'s callback `fn`.
|
1221
|
+
*
|
1222
|
+
* @param {Element} el
|
1223
|
+
* @param {String} type
|
1224
|
+
* @param {Function} fn
|
1225
|
+
* @param {Boolean} capture
|
1226
|
+
* @return {Function}
|
1227
|
+
* @api public
|
1228
|
+
*/
|
1229
|
+
|
1230
|
+
exports.unbind = function(el, type, fn, capture){
|
1231
|
+
el[unbind](prefix + type, fn, capture || false);
|
1232
|
+
return fn;
|
1233
|
+
};
|
1234
|
+
});
|
1235
|
+
|
1236
|
+
require.register("component~query@0.0.3", function (exports, module) {
|
1237
|
+
function one(selector, el) {
|
1238
|
+
return el.querySelector(selector);
|
1239
|
+
}
|
1240
|
+
|
1241
|
+
exports = module.exports = function(selector, el){
|
1242
|
+
el = el || document;
|
1243
|
+
return one(selector, el);
|
1244
|
+
};
|
1245
|
+
|
1246
|
+
exports.all = function(selector, el){
|
1247
|
+
el = el || document;
|
1248
|
+
return el.querySelectorAll(selector);
|
1249
|
+
};
|
1250
|
+
|
1251
|
+
exports.engine = function(obj){
|
1252
|
+
if (!obj.one) throw new Error('.one callback required');
|
1253
|
+
if (!obj.all) throw new Error('.all callback required');
|
1254
|
+
one = obj.one;
|
1255
|
+
exports.all = obj.all;
|
1256
|
+
return exports;
|
1257
|
+
};
|
1258
|
+
|
1259
|
+
});
|
1260
|
+
|
1261
|
+
require.register("component~matches-selector@0.1.5", function (exports, module) {
|
1262
|
+
/**
|
1263
|
+
* Module dependencies.
|
1264
|
+
*/
|
1265
|
+
|
1266
|
+
var query = require('component~query@0.0.3');
|
1267
|
+
|
1268
|
+
/**
|
1269
|
+
* Element prototype.
|
1270
|
+
*/
|
1271
|
+
|
1272
|
+
var proto = Element.prototype;
|
1273
|
+
|
1274
|
+
/**
|
1275
|
+
* Vendor function.
|
1276
|
+
*/
|
1277
|
+
|
1278
|
+
var vendor = proto.matches
|
1279
|
+
|| proto.webkitMatchesSelector
|
1280
|
+
|| proto.mozMatchesSelector
|
1281
|
+
|| proto.msMatchesSelector
|
1282
|
+
|| proto.oMatchesSelector;
|
1283
|
+
|
1284
|
+
/**
|
1285
|
+
* Expose `match()`.
|
1286
|
+
*/
|
1287
|
+
|
1288
|
+
module.exports = match;
|
1289
|
+
|
1290
|
+
/**
|
1291
|
+
* Match `el` to `selector`.
|
1292
|
+
*
|
1293
|
+
* @param {Element} el
|
1294
|
+
* @param {String} selector
|
1295
|
+
* @return {Boolean}
|
1296
|
+
* @api public
|
1297
|
+
*/
|
1298
|
+
|
1299
|
+
function match(el, selector) {
|
1300
|
+
if (!el || el.nodeType !== 1) return false;
|
1301
|
+
if (vendor) return vendor.call(el, selector);
|
1302
|
+
var nodes = query.all(selector, el.parentNode);
|
1303
|
+
for (var i = 0; i < nodes.length; ++i) {
|
1304
|
+
if (nodes[i] == el) return true;
|
1305
|
+
}
|
1306
|
+
return false;
|
1307
|
+
}
|
1308
|
+
|
1309
|
+
});
|
1310
|
+
|
1311
|
+
require.register("component~closest@0.1.4", function (exports, module) {
|
1312
|
+
var matches = require('component~matches-selector@0.1.5')
|
1313
|
+
|
1314
|
+
module.exports = function (element, selector, checkYoSelf, root) {
|
1315
|
+
element = checkYoSelf ? {parentNode: element} : element
|
1316
|
+
|
1317
|
+
root = root || document
|
1318
|
+
|
1319
|
+
// Make sure `element !== document` and `element != null`
|
1320
|
+
// otherwise we get an illegal invocation
|
1321
|
+
while ((element = element.parentNode) && element !== document) {
|
1322
|
+
if (matches(element, selector))
|
1323
|
+
return element
|
1324
|
+
// After `matches` on the edge case that
|
1325
|
+
// the selector matches the root
|
1326
|
+
// (when the root is not the document)
|
1327
|
+
if (element === root)
|
1328
|
+
return
|
1329
|
+
}
|
1330
|
+
}
|
1331
|
+
|
1332
|
+
});
|
1333
|
+
|
1334
|
+
require.register("component~delegate@0.2.3", function (exports, module) {
|
1335
|
+
/**
|
1336
|
+
* Module dependencies.
|
1337
|
+
*/
|
1338
|
+
|
1339
|
+
var closest = require('component~closest@0.1.4')
|
1340
|
+
, event = require('component~event@0.1.4');
|
1341
|
+
|
1342
|
+
/**
|
1343
|
+
* Delegate event `type` to `selector`
|
1344
|
+
* and invoke `fn(e)`. A callback function
|
1345
|
+
* is returned which may be passed to `.unbind()`.
|
1346
|
+
*
|
1347
|
+
* @param {Element} el
|
1348
|
+
* @param {String} selector
|
1349
|
+
* @param {String} type
|
1350
|
+
* @param {Function} fn
|
1351
|
+
* @param {Boolean} capture
|
1352
|
+
* @return {Function}
|
1353
|
+
* @api public
|
1354
|
+
*/
|
1355
|
+
|
1356
|
+
exports.bind = function(el, selector, type, fn, capture){
|
1357
|
+
return event.bind(el, type, function(e){
|
1358
|
+
var target = e.target || e.srcElement;
|
1359
|
+
e.delegateTarget = closest(target, selector, true, el);
|
1360
|
+
if (e.delegateTarget) fn.call(el, e);
|
1361
|
+
}, capture);
|
1362
|
+
};
|
1363
|
+
|
1364
|
+
/**
|
1365
|
+
* Unbind event `type`'s callback `fn`.
|
1366
|
+
*
|
1367
|
+
* @param {Element} el
|
1368
|
+
* @param {String} type
|
1369
|
+
* @param {Function} fn
|
1370
|
+
* @param {Boolean} capture
|
1371
|
+
* @api public
|
1372
|
+
*/
|
1373
|
+
|
1374
|
+
exports.unbind = function(el, type, fn, capture){
|
1375
|
+
event.unbind(el, type, fn, capture);
|
1376
|
+
};
|
1377
|
+
|
1378
|
+
});
|
1379
|
+
|
1380
|
+
require.register("component~events@1.0.9", function (exports, module) {
|
1381
|
+
|
1382
|
+
/**
|
1383
|
+
* Module dependencies.
|
1384
|
+
*/
|
1385
|
+
|
1386
|
+
var events = require('component~event@0.1.4');
|
1387
|
+
var delegate = require('component~delegate@0.2.3');
|
1388
|
+
|
1389
|
+
/**
|
1390
|
+
* Expose `Events`.
|
1391
|
+
*/
|
1392
|
+
|
1393
|
+
module.exports = Events;
|
1394
|
+
|
1395
|
+
/**
|
1396
|
+
* Initialize an `Events` with the given
|
1397
|
+
* `el` object which events will be bound to,
|
1398
|
+
* and the `obj` which will receive method calls.
|
1399
|
+
*
|
1400
|
+
* @param {Object} el
|
1401
|
+
* @param {Object} obj
|
1402
|
+
* @api public
|
1403
|
+
*/
|
1404
|
+
|
1405
|
+
function Events(el, obj) {
|
1406
|
+
if (!(this instanceof Events)) return new Events(el, obj);
|
1407
|
+
if (!el) throw new Error('element required');
|
1408
|
+
if (!obj) throw new Error('object required');
|
1409
|
+
this.el = el;
|
1410
|
+
this.obj = obj;
|
1411
|
+
this._events = {};
|
1412
|
+
}
|
1413
|
+
|
1414
|
+
/**
|
1415
|
+
* Subscription helper.
|
1416
|
+
*/
|
1417
|
+
|
1418
|
+
Events.prototype.sub = function(event, method, cb){
|
1419
|
+
this._events[event] = this._events[event] || {};
|
1420
|
+
this._events[event][method] = cb;
|
1421
|
+
};
|
1422
|
+
|
1423
|
+
/**
|
1424
|
+
* Bind to `event` with optional `method` name.
|
1425
|
+
* When `method` is undefined it becomes `event`
|
1426
|
+
* with the "on" prefix.
|
1427
|
+
*
|
1428
|
+
* Examples:
|
1429
|
+
*
|
1430
|
+
* Direct event handling:
|
1431
|
+
*
|
1432
|
+
* events.bind('click') // implies "onclick"
|
1433
|
+
* events.bind('click', 'remove')
|
1434
|
+
* events.bind('click', 'sort', 'asc')
|
1435
|
+
*
|
1436
|
+
* Delegated event handling:
|
1437
|
+
*
|
1438
|
+
* events.bind('click li > a')
|
1439
|
+
* events.bind('click li > a', 'remove')
|
1440
|
+
* events.bind('click a.sort-ascending', 'sort', 'asc')
|
1441
|
+
* events.bind('click a.sort-descending', 'sort', 'desc')
|
1442
|
+
*
|
1443
|
+
* @param {String} event
|
1444
|
+
* @param {String|function} [method]
|
1445
|
+
* @return {Function} callback
|
1446
|
+
* @api public
|
1447
|
+
*/
|
1448
|
+
|
1449
|
+
Events.prototype.bind = function(event, method){
|
1450
|
+
var e = parse(event);
|
1451
|
+
var el = this.el;
|
1452
|
+
var obj = this.obj;
|
1453
|
+
var name = e.name;
|
1454
|
+
var method = method || 'on' + name;
|
1455
|
+
var args = [].slice.call(arguments, 2);
|
1456
|
+
|
1457
|
+
// callback
|
1458
|
+
function cb(){
|
1459
|
+
var a = [].slice.call(arguments).concat(args);
|
1460
|
+
obj[method].apply(obj, a);
|
1461
|
+
}
|
1462
|
+
|
1463
|
+
// bind
|
1464
|
+
if (e.selector) {
|
1465
|
+
cb = delegate.bind(el, e.selector, name, cb);
|
1466
|
+
} else {
|
1467
|
+
events.bind(el, name, cb);
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
// subscription for unbinding
|
1471
|
+
this.sub(name, method, cb);
|
1472
|
+
|
1473
|
+
return cb;
|
1474
|
+
};
|
1475
|
+
|
1476
|
+
/**
|
1477
|
+
* Unbind a single binding, all bindings for `event`,
|
1478
|
+
* or all bindings within the manager.
|
1479
|
+
*
|
1480
|
+
* Examples:
|
1481
|
+
*
|
1482
|
+
* Unbind direct handlers:
|
1483
|
+
*
|
1484
|
+
* events.unbind('click', 'remove')
|
1485
|
+
* events.unbind('click')
|
1486
|
+
* events.unbind()
|
1487
|
+
*
|
1488
|
+
* Unbind delegate handlers:
|
1489
|
+
*
|
1490
|
+
* events.unbind('click', 'remove')
|
1491
|
+
* events.unbind('click')
|
1492
|
+
* events.unbind()
|
1493
|
+
*
|
1494
|
+
* @param {String|Function} [event]
|
1495
|
+
* @param {String|Function} [method]
|
1496
|
+
* @api public
|
1497
|
+
*/
|
1498
|
+
|
1499
|
+
Events.prototype.unbind = function(event, method){
|
1500
|
+
if (0 == arguments.length) return this.unbindAll();
|
1501
|
+
if (1 == arguments.length) return this.unbindAllOf(event);
|
1502
|
+
|
1503
|
+
// no bindings for this event
|
1504
|
+
var bindings = this._events[event];
|
1505
|
+
if (!bindings) return;
|
1506
|
+
|
1507
|
+
// no bindings for this method
|
1508
|
+
var cb = bindings[method];
|
1509
|
+
if (!cb) return;
|
1510
|
+
|
1511
|
+
events.unbind(this.el, event, cb);
|
1512
|
+
};
|
1513
|
+
|
1514
|
+
/**
|
1515
|
+
* Unbind all events.
|
1516
|
+
*
|
1517
|
+
* @api private
|
1518
|
+
*/
|
1519
|
+
|
1520
|
+
Events.prototype.unbindAll = function(){
|
1521
|
+
for (var event in this._events) {
|
1522
|
+
this.unbindAllOf(event);
|
1523
|
+
}
|
1524
|
+
};
|
1525
|
+
|
1526
|
+
/**
|
1527
|
+
* Unbind all events for `event`.
|
1528
|
+
*
|
1529
|
+
* @param {String} event
|
1530
|
+
* @api private
|
1531
|
+
*/
|
1532
|
+
|
1533
|
+
Events.prototype.unbindAllOf = function(event){
|
1534
|
+
var bindings = this._events[event];
|
1535
|
+
if (!bindings) return;
|
1536
|
+
|
1537
|
+
for (var method in bindings) {
|
1538
|
+
this.unbind(event, method);
|
1539
|
+
}
|
1540
|
+
};
|
1541
|
+
|
1542
|
+
/**
|
1543
|
+
* Parse `event`.
|
1544
|
+
*
|
1545
|
+
* @param {String} event
|
1546
|
+
* @return {Object}
|
1547
|
+
* @api private
|
1548
|
+
*/
|
1549
|
+
|
1550
|
+
function parse(event) {
|
1551
|
+
var parts = event.split(/ +/);
|
1552
|
+
return {
|
1553
|
+
name: parts.shift(),
|
1554
|
+
selector: parts.join(' ')
|
1555
|
+
}
|
1556
|
+
}
|
1557
|
+
|
1558
|
+
});
|
1559
|
+
|
1198
1560
|
require.register("switchery", function (exports, module) {
|
1199
1561
|
/**
|
1200
|
-
* Switchery 0.
|
1562
|
+
* Switchery 0.8.1
|
1201
1563
|
* http://abpetkov.github.io/switchery/
|
1202
1564
|
*
|
1203
1565
|
* Authored by Alexander Petkov
|
1204
1566
|
* https://github.com/abpetkov
|
1205
1567
|
*
|
1206
|
-
* Copyright 2013-
|
1568
|
+
* Copyright 2013-2015, Alexander Petkov
|
1207
1569
|
* License: The MIT License (MIT)
|
1208
1570
|
* http://opensource.org/licenses/MIT
|
1209
1571
|
*
|
@@ -1215,7 +1577,8 @@ require.register("switchery", function (exports, module) {
|
|
1215
1577
|
|
1216
1578
|
var transitionize = require('abpetkov~transitionize@0.0.3')
|
1217
1579
|
, fastclick = require('ftlabs~fastclick@v0.6.11')
|
1218
|
-
, classes = require('component~classes@1.2.1')
|
1580
|
+
, classes = require('component~classes@1.2.1')
|
1581
|
+
, events = require('component~events@1.0.9');
|
1219
1582
|
|
1220
1583
|
/**
|
1221
1584
|
* Expose `Switchery`.
|
@@ -1230,14 +1593,15 @@ module.exports = Switchery;
|
|
1230
1593
|
*/
|
1231
1594
|
|
1232
1595
|
var defaults = {
|
1233
|
-
color
|
1234
|
-
, secondaryColor
|
1235
|
-
, jackColor
|
1236
|
-
,
|
1237
|
-
,
|
1238
|
-
,
|
1239
|
-
,
|
1240
|
-
,
|
1596
|
+
color : '#64bd63'
|
1597
|
+
, secondaryColor : '#dfdfdf'
|
1598
|
+
, jackColor : '#fff'
|
1599
|
+
, jackSecondaryColor: null
|
1600
|
+
, className : 'switchery'
|
1601
|
+
, disabled : false
|
1602
|
+
, disabledOpacity : 0.5
|
1603
|
+
, speed : '0.4s'
|
1604
|
+
, size : 'default'
|
1241
1605
|
};
|
1242
1606
|
|
1243
1607
|
/**
|
@@ -1261,6 +1625,7 @@ function Switchery(element, options) {
|
|
1261
1625
|
}
|
1262
1626
|
|
1263
1627
|
if (this.element != null && this.element.type == 'checkbox') this.init();
|
1628
|
+
if (this.isDisabled() === true) this.disable();
|
1264
1629
|
}
|
1265
1630
|
|
1266
1631
|
/**
|
@@ -1296,6 +1661,7 @@ Switchery.prototype.create = function() {
|
|
1296
1661
|
this.jack = document.createElement('small');
|
1297
1662
|
this.switcher.appendChild(this.jack);
|
1298
1663
|
this.switcher.className = this.options.className;
|
1664
|
+
this.events = events(this.switcher, this);
|
1299
1665
|
|
1300
1666
|
return this.switcher;
|
1301
1667
|
};
|
@@ -1312,28 +1678,6 @@ Switchery.prototype.insertAfter = function(reference, target) {
|
|
1312
1678
|
reference.parentNode.insertBefore(target, reference.nextSibling);
|
1313
1679
|
};
|
1314
1680
|
|
1315
|
-
/**
|
1316
|
-
* See if input is checked.
|
1317
|
-
*
|
1318
|
-
* @returns {Boolean}
|
1319
|
-
* @api private
|
1320
|
-
*/
|
1321
|
-
|
1322
|
-
Switchery.prototype.isChecked = function() {
|
1323
|
-
return this.element.checked;
|
1324
|
-
};
|
1325
|
-
|
1326
|
-
/**
|
1327
|
-
* See if switcher should be disabled.
|
1328
|
-
*
|
1329
|
-
* @returns {Boolean}
|
1330
|
-
* @api private
|
1331
|
-
*/
|
1332
|
-
|
1333
|
-
Switchery.prototype.isDisabled = function() {
|
1334
|
-
return this.options.disabled || this.element.disabled || this.element.readOnly;
|
1335
|
-
};
|
1336
|
-
|
1337
1681
|
/**
|
1338
1682
|
* Set switch jack proper position.
|
1339
1683
|
*
|
@@ -1363,7 +1707,7 @@ Switchery.prototype.setPosition = function (clicked) {
|
|
1363
1707
|
this.switcher.style.boxShadow = 'inset 0 0 0 0 ' + this.options.secondaryColor;
|
1364
1708
|
this.switcher.style.borderColor = this.options.secondaryColor;
|
1365
1709
|
this.switcher.style.backgroundColor = (this.options.secondaryColor !== defaults.secondaryColor) ? this.options.secondaryColor : '#fff';
|
1366
|
-
this.jack.style.backgroundColor = this.options.jackColor;
|
1710
|
+
this.jack.style.backgroundColor = (this.options.jackSecondaryColor !== this.options.jackColor) ? this.options.jackSecondaryColor : this.options.jackColor;
|
1367
1711
|
this.setSpeed();
|
1368
1712
|
}
|
1369
1713
|
};
|
@@ -1376,7 +1720,10 @@ Switchery.prototype.setPosition = function (clicked) {
|
|
1376
1720
|
|
1377
1721
|
Switchery.prototype.setSpeed = function() {
|
1378
1722
|
var switcherProp = {}
|
1379
|
-
, jackProp = {
|
1723
|
+
, jackProp = {
|
1724
|
+
'background-color': this.options.speed
|
1725
|
+
, 'left': this.options.speed.replace(/[a-z]/, '') / 2 + 's'
|
1726
|
+
};
|
1380
1727
|
|
1381
1728
|
if (this.isChecked()) {
|
1382
1729
|
switcherProp = {
|
@@ -1480,29 +1827,24 @@ Switchery.prototype.handleChange = function() {
|
|
1480
1827
|
*/
|
1481
1828
|
|
1482
1829
|
Switchery.prototype.handleClick = function() {
|
1483
|
-
var
|
1484
|
-
, switcher = this.switcher
|
1485
|
-
, parent = self.element.parentNode.tagName.toLowerCase()
|
1486
|
-
, labelParent = (parent === 'label') ? false : true;
|
1830
|
+
var switcher = this.switcher;
|
1487
1831
|
|
1488
|
-
|
1489
|
-
|
1832
|
+
fastclick(switcher);
|
1833
|
+
this.events.bind('click', 'bindClick');
|
1834
|
+
};
|
1490
1835
|
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
this.element.disabled = true;
|
1504
|
-
this.switcher.style.opacity = this.options.disabledOpacity;
|
1505
|
-
}
|
1836
|
+
/**
|
1837
|
+
* Attach all methods that need to happen on switcher click.
|
1838
|
+
*
|
1839
|
+
* @api private
|
1840
|
+
*/
|
1841
|
+
|
1842
|
+
Switchery.prototype.bindClick = function() {
|
1843
|
+
var parent = this.element.parentNode.tagName.toLowerCase()
|
1844
|
+
, labelParent = (parent === 'label') ? false : true;
|
1845
|
+
|
1846
|
+
this.setPosition(labelParent);
|
1847
|
+
this.handleOnchange(this.element.checked);
|
1506
1848
|
};
|
1507
1849
|
|
1508
1850
|
/**
|
@@ -1541,6 +1883,68 @@ Switchery.prototype.init = function() {
|
|
1541
1883
|
this.handleClick();
|
1542
1884
|
};
|
1543
1885
|
|
1886
|
+
/**
|
1887
|
+
* See if input is checked.
|
1888
|
+
*
|
1889
|
+
* @returns {Boolean}
|
1890
|
+
* @api public
|
1891
|
+
*/
|
1892
|
+
|
1893
|
+
Switchery.prototype.isChecked = function() {
|
1894
|
+
return this.element.checked;
|
1895
|
+
};
|
1896
|
+
|
1897
|
+
/**
|
1898
|
+
* See if switcher should be disabled.
|
1899
|
+
*
|
1900
|
+
* @returns {Boolean}
|
1901
|
+
* @api public
|
1902
|
+
*/
|
1903
|
+
|
1904
|
+
Switchery.prototype.isDisabled = function() {
|
1905
|
+
return this.options.disabled || this.element.disabled || this.element.readOnly;
|
1906
|
+
};
|
1907
|
+
|
1908
|
+
/**
|
1909
|
+
* Destroy all event handlers attached to the switch.
|
1910
|
+
*
|
1911
|
+
* @api public
|
1912
|
+
*/
|
1913
|
+
|
1914
|
+
Switchery.prototype.destroy = function() {
|
1915
|
+
this.events.unbind();
|
1916
|
+
};
|
1917
|
+
|
1918
|
+
/**
|
1919
|
+
* Enable disabled switch element.
|
1920
|
+
*
|
1921
|
+
* @api public
|
1922
|
+
*/
|
1923
|
+
|
1924
|
+
Switchery.prototype.enable = function() {
|
1925
|
+
if (!this.options.disabled) return;
|
1926
|
+
if (this.options.disabled) this.options.disabled = false;
|
1927
|
+
if (this.element.disabled) this.element.disabled = false;
|
1928
|
+
if (this.element.readOnly) this.element.readOnly = false;
|
1929
|
+
this.switcher.style.opacity = 1;
|
1930
|
+
this.events.bind('click', 'bindClick');
|
1931
|
+
};
|
1932
|
+
|
1933
|
+
/**
|
1934
|
+
* Disable switch element.
|
1935
|
+
*
|
1936
|
+
* @api public
|
1937
|
+
*/
|
1938
|
+
|
1939
|
+
Switchery.prototype.disable = function() {
|
1940
|
+
if (this.options.disabled) return;
|
1941
|
+
if (!this.options.disabled) this.options.disabled = true;
|
1942
|
+
if (!this.element.disabled) this.element.disabled = true;
|
1943
|
+
if (!this.element.readOnly) this.element.readOnly = true;
|
1944
|
+
this.switcher.style.opacity = this.options.disabledOpacity;
|
1945
|
+
this.destroy();
|
1946
|
+
};
|
1947
|
+
|
1544
1948
|
});
|
1545
1949
|
|
1546
1950
|
if (typeof exports == "object") {
|
@@ -1550,4 +1954,4 @@ if (typeof exports == "object") {
|
|
1550
1954
|
} else {
|
1551
1955
|
(this || window)["Switchery"] = require("switchery");
|
1552
1956
|
}
|
1553
|
-
})()
|
1957
|
+
})();
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switchery-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Hain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,9 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
|
-
-
|
64
|
-
- ".ruby-version"
|
65
|
-
- CHANGELOG.md
|
63
|
+
- Dockerfile
|
66
64
|
- Gemfile
|
67
65
|
- LICENSE
|
68
66
|
- README.md
|
@@ -71,6 +69,7 @@ files:
|
|
71
69
|
- lib/switchery/rails.rb
|
72
70
|
- lib/switchery/rails/engine.rb
|
73
71
|
- lib/switchery/rails/version.rb
|
72
|
+
- make_new_release.sh
|
74
73
|
- switchery-rails.gemspec
|
75
74
|
- vendor/assets/javascripts/switchery.js
|
76
75
|
- vendor/assets/stylesheets/switchery.css
|
@@ -93,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
92
|
- !ruby/object:Gem::Version
|
94
93
|
version: '0'
|
95
94
|
requirements: []
|
96
|
-
|
97
|
-
rubygems_version: 2.4.5
|
95
|
+
rubygems_version: 3.2.33
|
98
96
|
signing_key:
|
99
97
|
specification_version: 4
|
100
98
|
summary: Use Switchery for Rails
|
data/.ruby-gemset
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
switchery-rails
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.2.0
|
data/CHANGELOG.md
DELETED