switchery-rails 0.1.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +53 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/switchery/rails/version.rb +1 -2
- data/vendor/assets/javascripts/switchery.js +459 -57
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67fef65691b2777c85b1264bbbe619f21a943311
|
4
|
+
data.tar.gz: b7fd5512ba99d5d581fac9b1762685082ce1a043
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddf413a66709204db4aac7fc5a68b49a0fb8cef7de69cb2bf42afc59e736585949e41a975d3be13da8011437649652ad28d61d0a58026b1805abf15e10a7b6b0
|
7
|
+
data.tar.gz: b04a4bb9838674e3e22a9f79d351372423d4eaea1f48b50c7e0613112121fcc27b44572a0229a9bbdaffb23dcb331329275213d310f7fb58a41421ae0d7495b7
|
data/Dockerfile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Switchery-rails gem Dockerfile
|
2
|
+
#
|
3
|
+
# How to use it
|
4
|
+
# =============
|
5
|
+
#
|
6
|
+
# $ sudo docker build -t zedtux/switchery-rails .
|
7
|
+
# $ sudo docker run -it zedtux/switchery-rails
|
8
|
+
# rake build # Build switchery-rails-0.1.0.gem into the pkg directory
|
9
|
+
# rake install # Build and install switchery-rails-0.1.0.gem into system gems
|
10
|
+
# rake install:local # Build and install switchery-rails-0.1.0.gem into system gems without network access
|
11
|
+
# rake release # Create tag v0.1.0 and build and push switchery-rails-0.1.0.gem to Rubygems
|
12
|
+
# rake update_switchery # Update the Switchery Javascript and CSS files
|
13
|
+
#
|
14
|
+
# Update the Switchery library
|
15
|
+
# ----------------------------
|
16
|
+
#
|
17
|
+
# Update the file `lib/switchery/rails/version.rb` in order to set the Switchery version to download then:
|
18
|
+
#
|
19
|
+
# $ sudo docker run --rm -v `pwd`:/gem/ -it zedtux/switchery-rails rake update_switchery
|
20
|
+
# Downlading Switchery 0.8.0 ...
|
21
|
+
# Done!
|
22
|
+
#
|
23
|
+
|
24
|
+
# ~~~~ Image base ~~~~
|
25
|
+
# Base image with the latest Ruby only
|
26
|
+
FROM litaio/ruby:2.2.2
|
27
|
+
MAINTAINER Guillaume Hain zedtux@zedroot.org
|
28
|
+
|
29
|
+
|
30
|
+
# ~~~~ Set up the environment ~~~~
|
31
|
+
ENV DEBIAN_FRONTEND noninteractive
|
32
|
+
|
33
|
+
# ~~~~ OS Maintenance ~~~~
|
34
|
+
RUN apt-get update && apt-get install -y git
|
35
|
+
|
36
|
+
# ~~~~ Rails Preparation ~~~~
|
37
|
+
# Rubygems and Bundler
|
38
|
+
RUN touch ~/.gemrc && \
|
39
|
+
echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
|
40
|
+
gem install rubygems-update && \
|
41
|
+
update_rubygems && \
|
42
|
+
gem install bundler && \
|
43
|
+
mkdir -p /gem/
|
44
|
+
|
45
|
+
WORKDIR /gem/
|
46
|
+
ADD . /gem/
|
47
|
+
RUN bundle install
|
48
|
+
|
49
|
+
# Import the gem source code
|
50
|
+
VOLUME .:/gem/
|
51
|
+
|
52
|
+
ENTRYPOINT ["bundle", "exec"]
|
53
|
+
CMD ["rake", "-T"]
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -14,6 +14,6 @@ task :update_switchery do
|
|
14
14
|
|
15
15
|
FileUtils.mkdir_p('vendor/assets/javascripts')
|
16
16
|
FileUtils.mkdir_p('vendor/assets/stylesheets')
|
17
|
-
download_switchery(Switchery::Rails::
|
17
|
+
download_switchery(Switchery::Rails::VERSION)
|
18
18
|
puts "\e[32mDone!\e[0m"
|
19
19
|
end
|
@@ -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
|
}
|
@@ -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.0
|
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,66 @@ 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) this.options.disabled = false;
|
1926
|
+
if (this.element.disabled) this.element.disabled = false;
|
1927
|
+
if (this.element.readOnly) this.element.readOnly = false;
|
1928
|
+
this.switcher.style.opacity = 1;
|
1929
|
+
this.events.bind('click', 'bindClick');
|
1930
|
+
};
|
1931
|
+
|
1932
|
+
/**
|
1933
|
+
* Disable switch element.
|
1934
|
+
*
|
1935
|
+
* @api public
|
1936
|
+
*/
|
1937
|
+
|
1938
|
+
Switchery.prototype.disable = function() {
|
1939
|
+
if (this.options.disabled) this.options.disabled = true;
|
1940
|
+
if (this.element.disabled) this.element.disabled = true;
|
1941
|
+
if (this.element.readOnly) this.element.readOnly = true;
|
1942
|
+
this.switcher.style.opacity = this.options.disabledOpacity;
|
1943
|
+
this.destroy();
|
1944
|
+
};
|
1945
|
+
|
1544
1946
|
});
|
1545
1947
|
|
1546
1948
|
if (typeof exports == "object") {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.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: 2015-
|
11
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- ".ruby-gemset"
|
64
64
|
- ".ruby-version"
|
65
65
|
- CHANGELOG.md
|
66
|
+
- Dockerfile
|
66
67
|
- Gemfile
|
67
68
|
- LICENSE
|
68
69
|
- README.md
|
@@ -94,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
95
|
version: '0'
|
95
96
|
requirements: []
|
96
97
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.4.
|
98
|
+
rubygems_version: 2.4.6
|
98
99
|
signing_key:
|
99
100
|
specification_version: 4
|
100
101
|
summary: Use Switchery for Rails
|