mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
NEW Admin panel pages: questionnairelist.php, samplelist.php, samplesearch.php,
updated callhistory.php, custom.css aded library bootstrap-toggle, bootstrap-confirmation.js
This commit is contained in:
21
include/bootstrap-toggle/LICENSE
Normal file
21
include/bootstrap-toggle/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011-2014 Min Hur, The New York Times Company
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
169
include/bootstrap-toggle/README.md
Normal file
169
include/bootstrap-toggle/README.md
Normal file
@@ -0,0 +1,169 @@
|
||||
# Bootstrap Toggle
|
||||
Bootstrap Toggle is a highly flexible Bootstrap plugin that converts checkboxes into toggles.
|
||||
|
||||
Visit http://www.bootstraptoggle.com for demos.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Installation
|
||||
You can [download](https://github.com/minhur/bootstrap-toggle/archive/master.zip) the latest version of Bootstrap Toggle or use CDN to load the library.
|
||||
|
||||
`Warning` If you are using Bootstrap v2.3.2, use `bootstrap2-toggle.min.js` and `bootstrap2-toggle.min.css` instead.
|
||||
|
||||
```html
|
||||
<link href="https://gitcdn.github.io/bootstrap-toggle/2.1.0/css/bootstrap-toggle.min.css" rel="stylesheet">
|
||||
<script src="https://gitcdn.github.io/bootstrap-toggle/2.1.0/js/bootstrap-toggle.min.js"></script>
|
||||
```
|
||||
|
||||
### Bower Install
|
||||
```bash
|
||||
bower install bootstrap-toggle
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic example
|
||||
Simply add `data-toggle="toggle"` to convert checkboxes into toggles.
|
||||
|
||||
```html
|
||||
<input type="checkbox" checked data-toggle="toggle">
|
||||
```
|
||||
|
||||
### Stacked checkboxes
|
||||
Refer to Bootstrap Form Controls documentation to create stacked checkboxes. Simply add `data-toggle="toggle"` to convert checkboxes into toggles.
|
||||
|
||||
```html
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" data-toggle="toggle">
|
||||
Option one is enabled
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox disabled">
|
||||
<label>
|
||||
<input type="checkbox" disabled data-toggle="toggle">
|
||||
Option two is disabled
|
||||
</label>
|
||||
</div>
|
||||
```
|
||||
|
||||
### Inline Checkboxes
|
||||
Refer to Bootstrap Form Controls documentation to create inline checkboxes. Simply add `data-toggle="toggle"` to a convert checkboxes into toggles.
|
||||
|
||||
```html
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" checked data-toggle="toggle"> First
|
||||
</label>
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" data-toggle="toggle"> Second
|
||||
</label>
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" data-toggle="toggle"> Third
|
||||
</label>
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### Initialize by JavaScript
|
||||
Initialize toggles with id `toggle-one` with a single line of JavaScript.
|
||||
|
||||
```html
|
||||
<input id="toggle-one" checked type="checkbox">
|
||||
<script>
|
||||
$(function() {
|
||||
$('#toggle-one').bootstrapToggle();
|
||||
})
|
||||
</script>
|
||||
```
|
||||
|
||||
### Options
|
||||
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-on="Enabled"`.
|
||||
|
||||
```html
|
||||
<input type="checkbox" data-toggle="toggle" data-on="Enabled" data-off="Disabled">
|
||||
<input type="checkbox" id="toggle-two">
|
||||
<script>
|
||||
$(function() {
|
||||
$('#toggle-two').bootstrapToggle({
|
||||
on: 'Enabled',
|
||||
off: 'Disabled'
|
||||
});
|
||||
})
|
||||
</script>
|
||||
```
|
||||
|
||||
Name|Type|Default|Description|
|
||||
---|---|---|---
|
||||
on|string/html|"On"|Text of the on toggle
|
||||
off|string/html|"Off"|Text of the off toggle
|
||||
size|string|"normal"|Size of the toggle. Possible values are `large`, `normal`, `small`, `mini`.
|
||||
onstyle|string|"primary"|Style of the on toggle. Possible values are `default`, `primary`, `success`, `info`, `warning`, `danger`
|
||||
offstyle|string|"default"|Style of the off toggle. Possible values are `default`, `primary`, `success`, `info`, `warning`, `danger`
|
||||
style|string| |Appends the value to the class attribute of the toggle. This can be used to apply custom styles. Refer to Custom Styles for reference.
|
||||
width|integer|*null*|Sets the width of the toggle. if set to *null*, width will be calculated.
|
||||
height|integer|*null*|Sets the height of the toggle. if set to *null*, height will be calculated.
|
||||
|
||||
### Methods
|
||||
Methods can be used to control toggles directly.
|
||||
|
||||
```html
|
||||
<input id="toggle-demo" type="checkbox" data-toggle="toggle">
|
||||
```
|
||||
|
||||
Method|Example|Description
|
||||
---|---|---
|
||||
initialize|$('#toggle-demo').bootstrapToggle()|Initializes the toggle plugin with options
|
||||
destroy|$('#toggle-demo').bootstrapToggle('destroy')|Destroys the toggle
|
||||
on|$('#toggle-demo').bootstrapToggle('on')|Sets the toggle to 'On' state
|
||||
off|$('#toggle-demo').bootstrapToggle('off')|Sets the toggle to 'Off' state
|
||||
toggle|$('#toggle-demo').bootstrapToggle('toggle')|Toggles the state of the toggle
|
||||
enable|$('#toggle-demo').bootstrapToggle('enable')|Enables the toggle
|
||||
disable|$('#toggle-demo').bootstrapToggle('disable')|Disables the toggle
|
||||
|
||||
## Events
|
||||
|
||||
### Event Propagation
|
||||
Note All events are propagated to and from input element to the toggle.
|
||||
|
||||
You should listen to events from the `<input type="checkbox">` directly rather than look for custom events.
|
||||
|
||||
```html
|
||||
<input id="toggle-event" type="checkbox" data-toggle="toggle">
|
||||
<div id="console-event"></div>
|
||||
<script>
|
||||
$(function() {
|
||||
$('#toggle-event').change(function() {
|
||||
$('#console-event').html('Toggle: ' + $(this).prop('checked'))
|
||||
})
|
||||
})
|
||||
</script>
|
||||
```
|
||||
|
||||
### API vs Input
|
||||
This also means that using the API or Input to trigger events will work both ways.
|
||||
|
||||
```html
|
||||
<input id="toggle-trigger" type="checkbox" data-toggle="toggle">
|
||||
<button class="btn btn-success" onclick="toggleOn()">On by API</button>
|
||||
<button class="btn btn-danger" onclick="toggleOff()">Off by API</button>
|
||||
<button class="btn btn-success" onclick="toggleOnByInput()">On by Input</button>
|
||||
<button class="btn btn-danger" onclick="toggleOffByInput()">Off by Input</button>
|
||||
<script>
|
||||
function toggleOn() {
|
||||
$('#toggle-trigger').bootstrapToggle('on')
|
||||
}
|
||||
function toggleOff() {
|
||||
$('#toggle-trigger').bootstrapToggle('off')
|
||||
}
|
||||
function toggleOnByInput() {
|
||||
$('#toggle-trigger').prop('checked', true).change()
|
||||
}
|
||||
function toggleOffByInput() {
|
||||
$('#toggle-trigger').prop('checked', false).change()
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
## Demos
|
||||
|
||||
Visit http://www.bootstraptoggle.com for demos.
|
||||
83
include/bootstrap-toggle/css/bootstrap-toggle.css
vendored
Normal file
83
include/bootstrap-toggle/css/bootstrap-toggle.css
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/*! ========================================================================
|
||||
* Bootstrap Toggle: bootstrap-toggle.css v2.2.0
|
||||
* http://www.bootstraptoggle.com
|
||||
* ========================================================================
|
||||
* Copyright 2014 Min Hur, The New York Times Company
|
||||
* Licensed under MIT
|
||||
* ======================================================================== */
|
||||
|
||||
|
||||
.checkbox label .toggle,
|
||||
.checkbox-inline .toggle {
|
||||
margin-left: -20px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.toggle {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.toggle input[type="checkbox"] {
|
||||
display: none;
|
||||
}
|
||||
.toggle-group {
|
||||
position: absolute;
|
||||
width: 200%;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
transition: left 0.35s;
|
||||
-webkit-transition: left 0.35s;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
.toggle.off .toggle-group {
|
||||
left: -100%;
|
||||
}
|
||||
.toggle-on {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 50%;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
.toggle-off {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
.toggle-handle {
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 0px;
|
||||
height: 100%;
|
||||
width: 0px;
|
||||
border-width: 0 1px;
|
||||
}
|
||||
|
||||
.toggle.btn { min-width: 59px; min-height: 34px; }
|
||||
.toggle-on.btn { padding-right: 24px; }
|
||||
.toggle-off.btn { padding-left: 24px; }
|
||||
|
||||
.toggle.btn-lg { min-width: 79px; min-height: 45px; }
|
||||
.toggle-on.btn-lg { padding-right: 31px; }
|
||||
.toggle-off.btn-lg { padding-left: 31px; }
|
||||
.toggle-handle.btn-lg { width: 40px; }
|
||||
|
||||
.toggle.btn-sm { min-width: 50px; min-height: 30px;}
|
||||
.toggle-on.btn-sm { padding-right: 20px; }
|
||||
.toggle-off.btn-sm { padding-left: 20px; }
|
||||
|
||||
.toggle.btn-xs { min-width: 35px; min-height: 22px;}
|
||||
.toggle-on.btn-xs { padding-right: 12px; }
|
||||
.toggle-off.btn-xs { padding-left: 12px; }
|
||||
|
||||
28
include/bootstrap-toggle/css/bootstrap-toggle.min.css
vendored
Normal file
28
include/bootstrap-toggle/css/bootstrap-toggle.min.css
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/*! ========================================================================
|
||||
* Bootstrap Toggle: bootstrap-toggle.css v2.2.0
|
||||
* http://www.bootstraptoggle.com
|
||||
* ========================================================================
|
||||
* Copyright 2014 Min Hur, The New York Times Company
|
||||
* Licensed under MIT
|
||||
* ======================================================================== */
|
||||
.checkbox label .toggle,.checkbox-inline .toggle{margin-left:-20px;margin-right:5px}
|
||||
.toggle{position:relative;overflow:hidden}
|
||||
.toggle input[type=checkbox]{display:none}
|
||||
.toggle-group{position:absolute;width:200%;top:0;bottom:0;left:0;transition:left .35s;-webkit-transition:left .35s;-moz-user-select:none;-webkit-user-select:none}
|
||||
.toggle.off .toggle-group{left:-100%}
|
||||
.toggle-on{position:absolute;top:0;bottom:0;left:0;right:50%;margin:0;border:0;border-radius:0}
|
||||
.toggle-off{position:absolute;top:0;bottom:0;left:50%;right:0;margin:0;border:0;border-radius:0}
|
||||
.toggle-handle{position:relative;margin:0 auto;padding-top:0;padding-bottom:0;height:100%;width:0;border-width:0 1px}
|
||||
.toggle.btn{min-width:59px;min-height:34px}
|
||||
.toggle-on.btn{padding-right:24px}
|
||||
.toggle-off.btn{padding-left:24px}
|
||||
.toggle.btn-lg{min-width:79px;min-height:45px}
|
||||
.toggle-on.btn-lg{padding-right:31px}
|
||||
.toggle-off.btn-lg{padding-left:31px}
|
||||
.toggle-handle.btn-lg{width:40px}
|
||||
.toggle.btn-sm{min-width:50px;min-height:30px}
|
||||
.toggle-on.btn-sm{padding-right:20px}
|
||||
.toggle-off.btn-sm{padding-left:20px}
|
||||
.toggle.btn-xs{min-width:35px;min-height:22px}
|
||||
.toggle-on.btn-xs{padding-right:12px}
|
||||
.toggle-off.btn-xs{padding-left:12px}
|
||||
180
include/bootstrap-toggle/js/bootstrap-toggle.js
vendored
Normal file
180
include/bootstrap-toggle/js/bootstrap-toggle.js
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
/*! ========================================================================
|
||||
* Bootstrap Toggle: bootstrap-toggle.js v2.2.0
|
||||
* http://www.bootstraptoggle.com
|
||||
* ========================================================================
|
||||
* Copyright 2014 Min Hur, The New York Times Company
|
||||
* Licensed under MIT
|
||||
* ======================================================================== */
|
||||
|
||||
|
||||
+function ($) {
|
||||
'use strict';
|
||||
|
||||
// TOGGLE PUBLIC CLASS DEFINITION
|
||||
// ==============================
|
||||
|
||||
var Toggle = function (element, options) {
|
||||
this.$element = $(element)
|
||||
this.options = $.extend({}, this.defaults(), options)
|
||||
this.render()
|
||||
}
|
||||
|
||||
Toggle.VERSION = '2.2.0'
|
||||
|
||||
Toggle.DEFAULTS = {
|
||||
on: 'On',
|
||||
off: 'Off',
|
||||
onstyle: 'primary',
|
||||
offstyle: 'default',
|
||||
size: 'normal',
|
||||
style: '',
|
||||
width: null,
|
||||
height: null
|
||||
}
|
||||
|
||||
Toggle.prototype.defaults = function() {
|
||||
return {
|
||||
on: this.$element.attr('data-on') || Toggle.DEFAULTS.on,
|
||||
off: this.$element.attr('data-off') || Toggle.DEFAULTS.off,
|
||||
onstyle: this.$element.attr('data-onstyle') || Toggle.DEFAULTS.onstyle,
|
||||
offstyle: this.$element.attr('data-offstyle') || Toggle.DEFAULTS.offstyle,
|
||||
size: this.$element.attr('data-size') || Toggle.DEFAULTS.size,
|
||||
style: this.$element.attr('data-style') || Toggle.DEFAULTS.style,
|
||||
width: this.$element.attr('data-width') || Toggle.DEFAULTS.width,
|
||||
height: this.$element.attr('data-height') || Toggle.DEFAULTS.height
|
||||
}
|
||||
}
|
||||
|
||||
Toggle.prototype.render = function () {
|
||||
this._onstyle = 'btn-' + this.options.onstyle
|
||||
this._offstyle = 'btn-' + this.options.offstyle
|
||||
var size = this.options.size === 'large' ? 'btn-lg'
|
||||
: this.options.size === 'small' ? 'btn-sm'
|
||||
: this.options.size === 'mini' ? 'btn-xs'
|
||||
: ''
|
||||
var $toggleOn = $('<label class="btn">').html(this.options.on)
|
||||
.addClass(this._onstyle + ' ' + size)
|
||||
var $toggleOff = $('<label class="btn">').html(this.options.off)
|
||||
.addClass(this._offstyle + ' ' + size + ' active')
|
||||
var $toggleHandle = $('<span class="toggle-handle btn btn-default">')
|
||||
.addClass(size)
|
||||
var $toggleGroup = $('<div class="toggle-group">')
|
||||
.append($toggleOn, $toggleOff, $toggleHandle)
|
||||
var $toggle = $('<div class="toggle btn" data-toggle="toggle">')
|
||||
.addClass( this.$element.prop('checked') ? this._onstyle : this._offstyle+' off' )
|
||||
.addClass(size).addClass(this.options.style)
|
||||
|
||||
this.$element.wrap($toggle)
|
||||
$.extend(this, {
|
||||
$toggle: this.$element.parent(),
|
||||
$toggleOn: $toggleOn,
|
||||
$toggleOff: $toggleOff,
|
||||
$toggleGroup: $toggleGroup
|
||||
})
|
||||
this.$toggle.append($toggleGroup)
|
||||
|
||||
var width = this.options.width || Math.max($toggleOn.outerWidth(), $toggleOff.outerWidth())+($toggleHandle.outerWidth()/2)
|
||||
var height = this.options.height || Math.max($toggleOn.outerHeight(), $toggleOff.outerHeight())
|
||||
$toggleOn.addClass('toggle-on')
|
||||
$toggleOff.addClass('toggle-off')
|
||||
this.$toggle.css({ width: width, height: height })
|
||||
if (this.options.height) {
|
||||
$toggleOn.css('line-height', $toggleOn.height() + 'px')
|
||||
$toggleOff.css('line-height', $toggleOff.height() + 'px')
|
||||
}
|
||||
this.update(true)
|
||||
this.trigger(true)
|
||||
}
|
||||
|
||||
Toggle.prototype.toggle = function () {
|
||||
if (this.$element.prop('checked')) this.off()
|
||||
else this.on()
|
||||
}
|
||||
|
||||
Toggle.prototype.on = function (silent) {
|
||||
if (this.$element.prop('disabled')) return false
|
||||
this.$toggle.removeClass(this._offstyle + ' off').addClass(this._onstyle)
|
||||
this.$element.prop('checked', true)
|
||||
if (!silent) this.trigger()
|
||||
}
|
||||
|
||||
Toggle.prototype.off = function (silent) {
|
||||
if (this.$element.prop('disabled')) return false
|
||||
this.$toggle.removeClass(this._onstyle).addClass(this._offstyle + ' off')
|
||||
this.$element.prop('checked', false)
|
||||
if (!silent) this.trigger()
|
||||
}
|
||||
|
||||
Toggle.prototype.enable = function () {
|
||||
this.$toggle.removeAttr('disabled')
|
||||
this.$element.prop('disabled', false)
|
||||
}
|
||||
|
||||
Toggle.prototype.disable = function () {
|
||||
this.$toggle.attr('disabled', 'disabled')
|
||||
this.$element.prop('disabled', true)
|
||||
}
|
||||
|
||||
Toggle.prototype.update = function (silent) {
|
||||
if (this.$element.prop('disabled')) this.disable()
|
||||
else this.enable()
|
||||
if (this.$element.prop('checked')) this.on(silent)
|
||||
else this.off(silent)
|
||||
}
|
||||
|
||||
Toggle.prototype.trigger = function (silent) {
|
||||
this.$element.off('change.bs.toggle')
|
||||
if (!silent) this.$element.change()
|
||||
this.$element.on('change.bs.toggle', $.proxy(function() {
|
||||
this.update()
|
||||
}, this))
|
||||
}
|
||||
|
||||
Toggle.prototype.destroy = function() {
|
||||
this.$element.off('change.bs.toggle')
|
||||
this.$toggleGroup.remove()
|
||||
this.$element.removeData('bs.toggle')
|
||||
this.$element.unwrap()
|
||||
}
|
||||
|
||||
// TOGGLE PLUGIN DEFINITION
|
||||
// ========================
|
||||
|
||||
function Plugin(option) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
var data = $this.data('bs.toggle')
|
||||
var options = typeof option == 'object' && option
|
||||
|
||||
if (!data) $this.data('bs.toggle', (data = new Toggle(this, options)))
|
||||
if (typeof option == 'string' && data[option]) data[option]()
|
||||
})
|
||||
}
|
||||
|
||||
var old = $.fn.bootstrapToggle
|
||||
|
||||
$.fn.bootstrapToggle = Plugin
|
||||
$.fn.bootstrapToggle.Constructor = Toggle
|
||||
|
||||
// TOGGLE NO CONFLICT
|
||||
// ==================
|
||||
|
||||
$.fn.toggle.noConflict = function () {
|
||||
$.fn.bootstrapToggle = old
|
||||
return this
|
||||
}
|
||||
|
||||
// TOGGLE DATA-API
|
||||
// ===============
|
||||
|
||||
$(function() {
|
||||
$('input[type=checkbox][data-toggle^=toggle]').bootstrapToggle()
|
||||
})
|
||||
|
||||
$(document).on('click.bs.toggle', 'div[data-toggle^=toggle]', function(e) {
|
||||
var $checkbox = $(this).find('input[type=checkbox]')
|
||||
$checkbox.bootstrapToggle('toggle')
|
||||
e.preventDefault()
|
||||
})
|
||||
|
||||
}(jQuery);
|
||||
9
include/bootstrap-toggle/js/bootstrap-toggle.min.js
vendored
Normal file
9
include/bootstrap-toggle/js/bootstrap-toggle.min.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/*! ========================================================================
|
||||
* Bootstrap Toggle: bootstrap-toggle.js v2.2.0
|
||||
* http://www.bootstraptoggle.com
|
||||
* ========================================================================
|
||||
* Copyright 2014 Min Hur, The New York Times Company
|
||||
* Licensed under MIT
|
||||
* ======================================================================== */
|
||||
+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.toggle"),f="object"==typeof b&&b;e||d.data("bs.toggle",e=new c(this,f)),"string"==typeof b&&e[b]&&e[b]()})}var c=function(b,c){this.$element=a(b),this.options=a.extend({},this.defaults(),c),this.render()};c.VERSION="2.2.0",c.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"default",size:"normal",style:"",width:null,height:null},c.prototype.defaults=function(){return{on:this.$element.attr("data-on")||c.DEFAULTS.on,off:this.$element.attr("data-off")||c.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||c.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||c.DEFAULTS.offstyle,size:this.$element.attr("data-size")||c.DEFAULTS.size,style:this.$element.attr("data-style")||c.DEFAULTS.style,width:this.$element.attr("data-width")||c.DEFAULTS.width,height:this.$element.attr("data-height")||c.DEFAULTS.height}},c.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var b="large"===this.options.size?"btn-lg":"small"===this.options.size?"btn-sm":"mini"===this.options.size?"btn-xs":"",c=a('<label class="btn">').html(this.options.on).addClass(this._onstyle+" "+b),d=a('<label class="btn">').html(this.options.off).addClass(this._offstyle+" "+b+" active"),e=a('<span class="toggle-handle btn btn-default">').addClass(b),f=a('<div class="toggle-group">').append(c,d,e),g=a('<div class="toggle btn" data-toggle="toggle">').addClass(this.$element.prop("checked")?this._onstyle:this._offstyle+" off").addClass(b).addClass(this.options.style);this.$element.wrap(g),a.extend(this,{$toggle:this.$element.parent(),$toggleOn:c,$toggleOff:d,$toggleGroup:f}),this.$toggle.append(f);var h=this.options.width||Math.max(c.outerWidth(),d.outerWidth())+e.outerWidth()/2,i=this.options.height||Math.max(c.outerHeight(),d.outerHeight());c.addClass("toggle-on"),d.addClass("toggle-off"),this.$toggle.css({width:h,height:i}),this.options.height&&(c.css("line-height",c.height()+"px"),d.css("line-height",d.height()+"px")),this.update(!0),this.trigger(!0)},c.prototype.toggle=function(){this.$element.prop("checked")?this.off():this.on()},c.prototype.on=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._offstyle+" off").addClass(this._onstyle),this.$element.prop("checked",!0),void(a||this.trigger()))},c.prototype.off=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._onstyle).addClass(this._offstyle+" off"),this.$element.prop("checked",!1),void(a||this.trigger()))},c.prototype.enable=function(){this.$toggle.removeAttr("disabled"),this.$element.prop("disabled",!1)},c.prototype.disable=function(){this.$toggle.attr("disabled","disabled"),this.$element.prop("disabled",!0)},c.prototype.update=function(a){this.$element.prop("disabled")?this.disable():this.enable(),this.$element.prop("checked")?this.on(a):this.off(a)},c.prototype.trigger=function(b){this.$element.off("change.bs.toggle"),b||this.$element.change(),this.$element.on("change.bs.toggle",a.proxy(function(){this.update()},this))},c.prototype.destroy=function(){this.$element.off("change.bs.toggle"),this.$toggleGroup.remove(),this.$element.removeData("bs.toggle"),this.$element.unwrap()};var d=a.fn.bootstrapToggle;a.fn.bootstrapToggle=b,a.fn.bootstrapToggle.Constructor=c,a.fn.toggle.noConflict=function(){return a.fn.bootstrapToggle=d,this},a(function(){a("input[type=checkbox][data-toggle^=toggle]").bootstrapToggle()}),a(document).on("click.bs.toggle","div[data-toggle^=toggle]",function(b){var c=a(this).find("input[type=checkbox]");c.bootstrapToggle("toggle"),b.preventDefault()})}(jQuery);
|
||||
//# sourceMappingURL=bootstrap-toggle.min.js.map
|
||||
49
include/bootstrap-toggle/script.js
Normal file
49
include/bootstrap-toggle/script.js
Normal file
@@ -0,0 +1,49 @@
|
||||
+function ($) {
|
||||
'use strict';
|
||||
|
||||
$('.example:not(.skip)').each(function() {
|
||||
// fetch & encode html
|
||||
var html = $('<div>').text($(this).html()).html()
|
||||
// find number of space/tabs on first line (minus line break)
|
||||
var count = html.match(/^(\s+)/)[0].length - 1
|
||||
// replace tabs/spaces on each lines with
|
||||
var regex = new RegExp('\\n\\s{'+count+'}', 'g')
|
||||
var code = html.replace(regex, '\n').replace(/\t/g, ' ').trim()
|
||||
// other cleanup
|
||||
code = code.replace(/=""/g,'')
|
||||
// add code block to dom
|
||||
$(this).after( $('<code class="highlight html">').html(code) )
|
||||
});
|
||||
|
||||
$('code.highlight').each(function() {
|
||||
hljs.highlightBlock(this)
|
||||
});
|
||||
|
||||
}(jQuery);
|
||||
|
||||
var Demo = function () {}
|
||||
|
||||
Demo.prototype.init = function(selector) {
|
||||
$(selector).bootstrapToggle(selector)
|
||||
}
|
||||
Demo.prototype.destroy = function(selector) {
|
||||
$(selector).bootstrapToggle('destroy')
|
||||
}
|
||||
Demo.prototype.on = function(selector) {
|
||||
$(selector).bootstrapToggle('on')
|
||||
}
|
||||
Demo.prototype.off = function(selector) {
|
||||
$(selector).bootstrapToggle('off')
|
||||
}
|
||||
Demo.prototype.toggle = function(selector) {
|
||||
$(selector).bootstrapToggle('toggle')
|
||||
}
|
||||
Demo.prototype.enable = function(selector) {
|
||||
$(selector).bootstrapToggle('enable')
|
||||
}
|
||||
Demo.prototype.disable = function(selector) {
|
||||
$(selector).bootstrapToggle('disable')
|
||||
}
|
||||
|
||||
|
||||
demo = new Demo()
|
||||
Reference in New Issue
Block a user