mirror of
https://gitlab.com/JKANetwork/CheckServer.git
synced 2026-02-20 12:11:34 +01:00
Start again
This commit is contained in:
44
vendors/switchery/.bower.json
vendored
Normal file
44
vendors/switchery/.bower.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "switchery",
|
||||
"main": [
|
||||
"dist/switchery.js",
|
||||
"dist/switchery.css"
|
||||
],
|
||||
"version": "0.8.1",
|
||||
"homepage": "http://abpetkov.github.io/switchery/",
|
||||
"author": [
|
||||
"Alexander Petkov <abpetkov@gmail.com> (https://github.com/abpetkov)"
|
||||
],
|
||||
"description": "Component to create iOS 7 styled switches from default input checkboxes",
|
||||
"keywords": [
|
||||
"checkbox",
|
||||
"input",
|
||||
"switch",
|
||||
"iOS7"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"build",
|
||||
"components",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"component.json",
|
||||
"Makefile",
|
||||
"README.md",
|
||||
".*"
|
||||
],
|
||||
"dependencies": {
|
||||
"transitionize": "*",
|
||||
"fastclick": "v0.6.11"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"_release": "0.8.1",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "0.8.1",
|
||||
"commit": "64d237840e26808e7232516941bb429e30ffc6d6"
|
||||
},
|
||||
"_source": "https://github.com/abpetkov/switchery.git",
|
||||
"_target": "^0.8.1",
|
||||
"_originalSource": "switchery"
|
||||
}
|
||||
139
vendors/switchery/CHANGELOG.md
vendored
Normal file
139
vendors/switchery/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
|
||||
0.8.1 / 2015-06-26
|
||||
==================
|
||||
|
||||
* Check disabled values properly, because of `.isDisabled()` method returning improper value
|
||||
|
||||
0.8.0 / 2015-04-03
|
||||
==================
|
||||
|
||||
* Secondary jack color functionality
|
||||
* Enable/disable switch dynamically
|
||||
* Destroy event handlers attached to a Switchery instance
|
||||
* Meteor.js integration
|
||||
|
||||
0.7.0 / 2014-12-09
|
||||
==================
|
||||
|
||||
* Respect `readonly` attribute on checkbox input
|
||||
* Large and small size switches
|
||||
|
||||
0.6.3 / 2014-11-02
|
||||
==================
|
||||
|
||||
* Update component version
|
||||
* Added separate Jack color option
|
||||
* Add the CSS file to bower.json
|
||||
* Fix bug in Hongmi phone
|
||||
* Fixing issue found in IE9+ with change event dispatch
|
||||
|
||||
0.6.2 / 2014-08-22
|
||||
==================
|
||||
|
||||
* Prevent text selection on double click
|
||||
|
||||
0.6.1 / 2014-07-11
|
||||
==================
|
||||
|
||||
* Fix switch click state when inside label
|
||||
|
||||
0.6.0 / 2014-05-22
|
||||
==================
|
||||
|
||||
* Corresponding label with `for` attribute of the native input, to change switch state as well
|
||||
* Do not copy input's `id` and `name` attributes to switch
|
||||
|
||||
0.5.5 / 2014-05-14
|
||||
==================
|
||||
|
||||
* Set secondary color to be background color on switch off state
|
||||
|
||||
0.5.4 / 2014-04-29
|
||||
==================
|
||||
|
||||
* Fix box-sizing when using Bootstrap 3
|
||||
|
||||
0.5.3 / 2014-04-12
|
||||
==================
|
||||
|
||||
* Detect native checkbox state change
|
||||
|
||||
0.5.2 / 2014-04-03
|
||||
==================
|
||||
|
||||
* Enable event bubbles
|
||||
|
||||
0.5.1 / 2014-03-22
|
||||
==================
|
||||
|
||||
* Fix jack position when switch is hidden
|
||||
|
||||
0.5.0 / 2014-02-07
|
||||
==================
|
||||
|
||||
* Removes the internal validation for loaded switches and lets people do it on their own
|
||||
* Sets a data attribute to handle multiple calls for a checkbox
|
||||
|
||||
0.4.2 / 2014-01-24
|
||||
==================
|
||||
|
||||
* Resolve property method issues in IE
|
||||
* Disable label checkbox change event
|
||||
* Check if element is null
|
||||
|
||||
0.4.1 / 2014-01-18
|
||||
==================
|
||||
|
||||
* Fix Event errors in IE8
|
||||
|
||||
0.4.0 / 2014-01-15
|
||||
==================
|
||||
|
||||
* Use ftlabs/fastclick for mobile browser optimization
|
||||
|
||||
0.3.6 / 2014-01-04
|
||||
==================
|
||||
|
||||
* Generate new standalone file
|
||||
* Refactor code
|
||||
* Use event constructors to create onchange and click events
|
||||
* Updated standalone to dist in bower.json
|
||||
* Required files
|
||||
* Add development info
|
||||
|
||||
0.3.5 / 2013-12-31
|
||||
==================
|
||||
|
||||
* Proper checkbox value with onchange event
|
||||
|
||||
0.3.4 / 2013-12-31
|
||||
==================
|
||||
|
||||
* Merge ni-c:master
|
||||
* Refactor onchange
|
||||
|
||||
0.3.3 / 2013-12-28
|
||||
==================
|
||||
|
||||
* Merge pull request from tenbits:patch-1
|
||||
* Leave first line empty
|
||||
* Undefined option's property
|
||||
* Update Readme
|
||||
* Update standalone
|
||||
* Changelog
|
||||
* Standalone -> dist, update Readme, add changelog
|
||||
|
||||
0.3.2 / 2013-12-27
|
||||
==================
|
||||
|
||||
* Standalone -> dist, update Readme, add changelog
|
||||
* Merge pull request from vesln:min
|
||||
* Add minified versions
|
||||
* Minify CSS & JS
|
||||
* Fix the standalone build & improve Makefile
|
||||
* Ignore node_modules
|
||||
* Add package.json
|
||||
* Disabled opacity option
|
||||
* Disabled opacity option
|
||||
* Insert switch after target element
|
||||
* Require Transitionize
|
||||
35
vendors/switchery/bower.json
vendored
Normal file
35
vendors/switchery/bower.json
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "switchery",
|
||||
"main": [
|
||||
"dist/switchery.js",
|
||||
"dist/switchery.css"
|
||||
],
|
||||
"version": "0.8.1",
|
||||
"homepage": "http://abpetkov.github.io/switchery/",
|
||||
"author": [
|
||||
"Alexander Petkov <abpetkov@gmail.com> (https://github.com/abpetkov)"
|
||||
],
|
||||
"description": "Component to create iOS 7 styled switches from default input checkboxes",
|
||||
"keywords": [
|
||||
"checkbox",
|
||||
"input",
|
||||
"switch",
|
||||
"iOS7"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"build",
|
||||
"components",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"component.json",
|
||||
"Makefile",
|
||||
"README.md",
|
||||
".*"
|
||||
],
|
||||
"dependencies": {
|
||||
"transitionize": "*",
|
||||
"fastclick": "v0.6.11"
|
||||
},
|
||||
"devDependencies": {}
|
||||
}
|
||||
64
vendors/switchery/dist/switchery.css
vendored
Normal file
64
vendors/switchery/dist/switchery.css
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
*
|
||||
* Main stylesheet for Switchery.
|
||||
* http://abpetkov.github.io/switchery/
|
||||
*
|
||||
*/
|
||||
|
||||
/* Switchery defaults. */
|
||||
|
||||
.switchery {
|
||||
background-color: #fff;
|
||||
border: 1px solid #dfdfdf;
|
||||
border-radius: 20px;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
height: 30px;
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
width: 50px;
|
||||
|
||||
-moz-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
box-sizing: content-box;
|
||||
background-clip: content-box;
|
||||
}
|
||||
|
||||
.switchery > small {
|
||||
background: #fff;
|
||||
border-radius: 100%;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
|
||||
height: 30px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
/* Switchery sizes. */
|
||||
|
||||
.switchery-small {
|
||||
border-radius: 20px;
|
||||
height: 20px;
|
||||
width: 33px;
|
||||
}
|
||||
|
||||
.switchery-small > small {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.switchery-large {
|
||||
border-radius: 40px;
|
||||
height: 40px;
|
||||
width: 66px;
|
||||
}
|
||||
|
||||
.switchery-large > small {
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
|
||||
1955
vendors/switchery/dist/switchery.js
vendored
Normal file
1955
vendors/switchery/dist/switchery.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
vendors/switchery/dist/switchery.min.css
vendored
Normal file
1
vendors/switchery/dist/switchery.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.switchery{background-color:#fff;border:1px solid #dfdfdf;border-radius:20px;cursor:pointer;display:inline-block;height:30px;position:relative;vertical-align:middle;width:50px;-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none;box-sizing:content-box;background-clip:content-box}.switchery>small{background:#fff;border-radius:100%;box-shadow:0 1px 3px rgba(0,0,0,0.4);height:30px;position:absolute;top:0;width:30px}.switchery-small{border-radius:20px;height:20px;width:33px}.switchery-small>small{height:20px;width:20px}.switchery-large{border-radius:40px;height:40px;width:66px}.switchery-large>small{height:40px;width:40px}
|
||||
1
vendors/switchery/dist/switchery.min.js
vendored
Normal file
1
vendors/switchery/dist/switchery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3
vendors/switchery/meteor/export.js
vendored
Normal file
3
vendors/switchery/meteor/export.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/*global Switchery:true*/ // Meteor creates a file-scope global for exporting. This comment prevents a potential JSHint warning.
|
||||
Switchery = window.Switchery;
|
||||
delete window.Switchery;
|
||||
10
vendors/switchery/meteor/tests.js
vendored
Normal file
10
vendors/switchery/meteor/tests.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
Tinytest.add('Switchery integration', function (test) {
|
||||
|
||||
var checkbox = document.createElement('input');
|
||||
checkbox.className = 'js-switch';
|
||||
var switchy = new Switchery(checkbox);
|
||||
|
||||
test.instanceOf(switchy, Switchery, 'instantiation OK');
|
||||
});
|
||||
24
vendors/switchery/package.js
vendored
Normal file
24
vendors/switchery/package.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// package metadata file for Meteor.js
|
||||
'use strict';
|
||||
|
||||
var packageName = 'abpetkov:switchery'; // https://atmospherejs.com/mediatainment/switchery
|
||||
var where = 'client'; // where to install: 'client' or 'server'. For both, pass nothing.
|
||||
|
||||
Package.describe({
|
||||
name: packageName,
|
||||
summary: 'Switchery (official) - turns your default HTML checkbox inputs into beautiful iOS 7 style switches.',
|
||||
version: "0.1.0", //packageJson.version,
|
||||
git: 'https://github.com/abpetkov/switchery'
|
||||
});
|
||||
|
||||
Package.onUse(function(api) {
|
||||
api.versionsFrom(['METEOR@0.9.0', 'METEOR@1.0']);
|
||||
api.export('Switchery');
|
||||
api.addFiles(['dist/switchery.js', 'dist/switchery.css', 'meteor/export.js'], where);
|
||||
});
|
||||
|
||||
Package.onTest(function(api) {
|
||||
api.use(packageName, where);
|
||||
api.use('tinytest', where);
|
||||
api.addFiles('meteor/tests.js', where); // testing specific files
|
||||
});
|
||||
22
vendors/switchery/package.json
vendored
Normal file
22
vendors/switchery/package.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "switchery",
|
||||
"version": "0.8.1",
|
||||
"description": "Create iOS 7 styled switches from default input checkboxes",
|
||||
"main": "switchery.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/abpetkov/switchery.git"
|
||||
},
|
||||
"author": "Alexander Petkov",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/abpetkov/switchery/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"uglify-js": "~2.4.8",
|
||||
"component": "^1.0.0",
|
||||
"uglifycss": "0.0.7",
|
||||
"grunt-exec": "latest",
|
||||
"spacejam": "latest"
|
||||
}
|
||||
}
|
||||
67
vendors/switchery/switchery.css
vendored
Normal file
67
vendors/switchery/switchery.css
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
*
|
||||
* Main stylesheet for Switchery.
|
||||
* http://abpetkov.github.io/switchery/
|
||||
*
|
||||
*/
|
||||
|
||||
/* Switchery defaults. */
|
||||
|
||||
.switchery {
|
||||
background-color: #fff;
|
||||
border: 1px solid #dfdfdf;
|
||||
border-radius: 20px;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
height: 30px;
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
width: 50px;
|
||||
|
||||
-moz-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
|
||||
-webkit-box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
|
||||
-webkit-background-clip: content-box;
|
||||
background-clip: content-box;
|
||||
}
|
||||
|
||||
.switchery > small {
|
||||
background: #fff;
|
||||
border-radius: 100%;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
|
||||
height: 30px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
/* Switchery sizes. */
|
||||
|
||||
.switchery-small {
|
||||
border-radius: 20px;
|
||||
height: 20px;
|
||||
width: 33px;
|
||||
}
|
||||
|
||||
.switchery-small > small {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.switchery-large {
|
||||
border-radius: 40px;
|
||||
height: 40px;
|
||||
width: 66px;
|
||||
}
|
||||
|
||||
.switchery-large > small {
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
}
|
||||
384
vendors/switchery/switchery.js
vendored
Normal file
384
vendors/switchery/switchery.js
vendored
Normal file
@@ -0,0 +1,384 @@
|
||||
/**
|
||||
* Switchery 0.8.1
|
||||
* http://abpetkov.github.io/switchery/
|
||||
*
|
||||
* Authored by Alexander Petkov
|
||||
* https://github.com/abpetkov
|
||||
*
|
||||
* Copyright 2013-2015, Alexander Petkov
|
||||
* License: The MIT License (MIT)
|
||||
* http://opensource.org/licenses/MIT
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* External dependencies.
|
||||
*/
|
||||
|
||||
var transitionize = require('transitionize')
|
||||
, fastclick = require('fastclick')
|
||||
, classes = require('classes')
|
||||
, events = require('events');
|
||||
|
||||
/**
|
||||
* Expose `Switchery`.
|
||||
*/
|
||||
|
||||
module.exports = Switchery;
|
||||
|
||||
/**
|
||||
* Set Switchery default values.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var defaults = {
|
||||
color : '#64bd63'
|
||||
, secondaryColor : '#dfdfdf'
|
||||
, jackColor : '#fff'
|
||||
, jackSecondaryColor: null
|
||||
, className : 'switchery'
|
||||
, disabled : false
|
||||
, disabledOpacity : 0.5
|
||||
, speed : '0.4s'
|
||||
, size : 'default'
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Switchery object.
|
||||
*
|
||||
* @param {Object} element
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Switchery(element, options) {
|
||||
if (!(this instanceof Switchery)) return new Switchery(element, options);
|
||||
|
||||
this.element = element;
|
||||
this.options = options || {};
|
||||
|
||||
for (var i in defaults) {
|
||||
if (this.options[i] == null) {
|
||||
this.options[i] = defaults[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (this.element != null && this.element.type == 'checkbox') this.init();
|
||||
if (this.isDisabled() === true) this.disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the target element.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.hide = function() {
|
||||
this.element.style.display = 'none';
|
||||
};
|
||||
|
||||
/**
|
||||
* Show custom switch after the target element.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.show = function() {
|
||||
var switcher = this.create();
|
||||
this.insertAfter(this.element, switcher);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create custom switch.
|
||||
*
|
||||
* @returns {Object} this.switcher
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.create = function() {
|
||||
this.switcher = document.createElement('span');
|
||||
this.jack = document.createElement('small');
|
||||
this.switcher.appendChild(this.jack);
|
||||
this.switcher.className = this.options.className;
|
||||
this.events = events(this.switcher, this);
|
||||
|
||||
return this.switcher;
|
||||
};
|
||||
|
||||
/**
|
||||
* Insert after element after another element.
|
||||
*
|
||||
* @param {Object} reference
|
||||
* @param {Object} target
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.insertAfter = function(reference, target) {
|
||||
reference.parentNode.insertBefore(target, reference.nextSibling);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set switch jack proper position.
|
||||
*
|
||||
* @param {Boolean} clicked - we need this in order to uncheck the input when the switch is clicked
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.setPosition = function (clicked) {
|
||||
var checked = this.isChecked()
|
||||
, switcher = this.switcher
|
||||
, jack = this.jack;
|
||||
|
||||
if (clicked && checked) checked = false;
|
||||
else if (clicked && !checked) checked = true;
|
||||
|
||||
if (checked === true) {
|
||||
this.element.checked = true;
|
||||
|
||||
if (window.getComputedStyle) jack.style.left = parseInt(window.getComputedStyle(switcher).width) - parseInt(window.getComputedStyle(jack).width) + 'px';
|
||||
else jack.style.left = parseInt(switcher.currentStyle['width']) - parseInt(jack.currentStyle['width']) + 'px';
|
||||
|
||||
if (this.options.color) this.colorize();
|
||||
this.setSpeed();
|
||||
} else {
|
||||
jack.style.left = 0;
|
||||
this.element.checked = false;
|
||||
this.switcher.style.boxShadow = 'inset 0 0 0 0 ' + this.options.secondaryColor;
|
||||
this.switcher.style.borderColor = this.options.secondaryColor;
|
||||
this.switcher.style.backgroundColor = (this.options.secondaryColor !== defaults.secondaryColor) ? this.options.secondaryColor : '#fff';
|
||||
this.jack.style.backgroundColor = (this.options.jackSecondaryColor !== this.options.jackColor) ? this.options.jackSecondaryColor : this.options.jackColor;
|
||||
this.setSpeed();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set speed.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.setSpeed = function() {
|
||||
var switcherProp = {}
|
||||
, jackProp = {
|
||||
'background-color': this.options.speed
|
||||
, 'left': this.options.speed.replace(/[a-z]/, '') / 2 + 's'
|
||||
};
|
||||
|
||||
if (this.isChecked()) {
|
||||
switcherProp = {
|
||||
'border': this.options.speed
|
||||
, 'box-shadow': this.options.speed
|
||||
, 'background-color': this.options.speed.replace(/[a-z]/, '') * 3 + 's'
|
||||
};
|
||||
} else {
|
||||
switcherProp = {
|
||||
'border': this.options.speed
|
||||
, 'box-shadow': this.options.speed
|
||||
};
|
||||
}
|
||||
|
||||
transitionize(this.switcher, switcherProp);
|
||||
transitionize(this.jack, jackProp);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set switch size.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.setSize = function() {
|
||||
var small = 'switchery-small'
|
||||
, normal = 'switchery-default'
|
||||
, large = 'switchery-large';
|
||||
|
||||
switch (this.options.size) {
|
||||
case 'small':
|
||||
classes(this.switcher).add(small)
|
||||
break;
|
||||
case 'large':
|
||||
classes(this.switcher).add(large)
|
||||
break;
|
||||
default:
|
||||
classes(this.switcher).add(normal)
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set switch color.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.colorize = function() {
|
||||
var switcherHeight = this.switcher.offsetHeight / 2;
|
||||
|
||||
this.switcher.style.backgroundColor = this.options.color;
|
||||
this.switcher.style.borderColor = this.options.color;
|
||||
this.switcher.style.boxShadow = 'inset 0 0 0 ' + switcherHeight + 'px ' + this.options.color;
|
||||
this.jack.style.backgroundColor = this.options.jackColor;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle the onchange event.
|
||||
*
|
||||
* @param {Boolean} state
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.handleOnchange = function(state) {
|
||||
if (document.dispatchEvent) {
|
||||
var event = document.createEvent('HTMLEvents');
|
||||
event.initEvent('change', true, true);
|
||||
this.element.dispatchEvent(event);
|
||||
} else {
|
||||
this.element.fireEvent('onchange');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle the native input element state change.
|
||||
* A `change` event must be fired in order to detect the change.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.handleChange = function() {
|
||||
var self = this
|
||||
, el = this.element;
|
||||
|
||||
if (el.addEventListener) {
|
||||
el.addEventListener('change', function() {
|
||||
self.setPosition();
|
||||
});
|
||||
} else {
|
||||
el.attachEvent('onchange', function() {
|
||||
self.setPosition();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle the switch click event.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.handleClick = function() {
|
||||
var switcher = this.switcher;
|
||||
|
||||
fastclick(switcher);
|
||||
this.events.bind('click', 'bindClick');
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach all methods that need to happen on switcher click.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.bindClick = function() {
|
||||
var parent = this.element.parentNode.tagName.toLowerCase()
|
||||
, labelParent = (parent === 'label') ? false : true;
|
||||
|
||||
this.setPosition(labelParent);
|
||||
this.handleOnchange(this.element.checked);
|
||||
};
|
||||
|
||||
/**
|
||||
* Mark an individual switch as already handled.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.markAsSwitched = function() {
|
||||
this.element.setAttribute('data-switchery', true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if an individual switch is already handled.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.markedAsSwitched = function() {
|
||||
return this.element.getAttribute('data-switchery');
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize Switchery.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Switchery.prototype.init = function() {
|
||||
this.hide();
|
||||
this.show();
|
||||
this.setSize();
|
||||
this.setPosition();
|
||||
this.markAsSwitched();
|
||||
this.handleChange();
|
||||
this.handleClick();
|
||||
};
|
||||
|
||||
/**
|
||||
* See if input is checked.
|
||||
*
|
||||
* @returns {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Switchery.prototype.isChecked = function() {
|
||||
return this.element.checked;
|
||||
};
|
||||
|
||||
/**
|
||||
* See if switcher should be disabled.
|
||||
*
|
||||
* @returns {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Switchery.prototype.isDisabled = function() {
|
||||
return this.options.disabled || this.element.disabled || this.element.readOnly;
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy all event handlers attached to the switch.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Switchery.prototype.destroy = function() {
|
||||
this.events.unbind();
|
||||
};
|
||||
|
||||
/**
|
||||
* Enable disabled switch element.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Switchery.prototype.enable = function() {
|
||||
if (this.options.disabled) this.options.disabled = false;
|
||||
if (this.element.disabled) this.element.disabled = false;
|
||||
if (this.element.readOnly) this.element.readOnly = false;
|
||||
this.switcher.style.opacity = 1;
|
||||
this.events.bind('click', 'bindClick');
|
||||
};
|
||||
|
||||
/**
|
||||
* Disable switch element.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Switchery.prototype.disable = function() {
|
||||
if (!this.options.disabled) this.options.disabled = true;
|
||||
if (!this.element.disabled) this.element.disabled = true;
|
||||
if (!this.element.readOnly) this.element.readOnly = true;
|
||||
this.switcher.style.opacity = this.options.disabledOpacity;
|
||||
this.destroy();
|
||||
};
|
||||
Reference in New Issue
Block a user