upgrade app

This commit is contained in:
Xes
2025-08-14 22:33:03 +02:00
parent d862a535e5
commit 2fe1c43b3e
39284 changed files with 991979 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
{
"name": "multiselect",
"version": "2.5.7",
"homepage": "https://github.com/crlcu/multiselect",
"authors": [
"Adrian Crisan <adrian.crisan88@gmail.com>"
],
"description": "jQuery multiselect plugin with two sides",
"main": "dist/js/multiselect.min.js",
"keywords": [
"multiselect"
],
"license": "MIT",
"dependencies": {
"jquery": ">= 1.7"
},
"_release": "2.5.7",
"_resolution": {
"type": "version",
"tag": "v2.5.7",
"commit": "5518a4229ff96eec6678be954db3b3c48e1420ee"
},
"_source": "https://github.com/crlcu/multiselect.git",
"_target": "2.5.*",
"_originalSource": "multiselect-two-sides"
}

View File

@@ -0,0 +1 @@
github: crlcu

View File

@@ -0,0 +1,3 @@
/node_modules
.htaccess
.idea

View File

@@ -0,0 +1,72 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [2.5.7](https://github.com/crlcu/multiselect/compare/v2.5.6...v2.5.7) (2020-05-06)
### [2.5.6](https://github.com/crlcu/multiselect/compare/v2.5.5...v2.5.6) (2020-05-06)
* Upgrade dev dependencies
<a name="2.5.5"></a>
## [2.5.5](https://github.com/crlcu/multiselect/compare/v2.5.4...v2.5.5) (2018-07-25)
### Bug Fixes
* :visible selector is not working on safari, use :not(.hidden) ([beebfe0](https://github.com/crlcu/multiselect/commit/beebfe0))
* [#152](https://github.com/crlcu/multiselect/issues/152) - ignoreDisabled: true does not work with optgroups ([afc5d8c](https://github.com/crlcu/multiselect/commit/afc5d8c))
<a name="2.5.4"></a>
## [2.5.4](https://github.com/crlcu/multiselect/compare/v2.5.3...v2.5.4) (2018-07-17)
### Bug Fixes
* [#166](https://github.com/crlcu/multiselect/issues/166) - Searching and Adding elements cause the already selected elements to get added as a hidden element ([ddefce3](https://github.com/crlcu/multiselect/commit/ddefce3))
<a name="2.5.3"></a>
## [2.5.3](https://github.com/crlcu/multiselect/compare/v2.5.2...v2.5.3) (2018-07-16)
### Bug Fixes
* [#152](https://github.com/crlcu/multiselect/issues/152) - ignoreDisabled: true does not work with optgroups ([afc5d8c](https://github.com/crlcu/multiselect/commit/afc5d8c))
<a name="2.5.2"></a>
## [2.5.2](https://github.com/crlcu/multiselect/compare/v2.5.1...v2.5.2) (2018-07-10)
### Bug Fixes
* [#164](https://github.com/crlcu/multiselect/issues/164) - Invalid regular expression ([541bb68](https://github.com/crlcu/multiselect/commit/541bb68))
<a name="2.5.1"></a>
## [2.5.1](https://github.com/crlcu/multiselect/compare/v2.5.0...v2.5.1) (2018-04-27)
### Patches
* change the value for the main path ([22414f8](https://github.com/crlcu/multiselect/commit/22414f8))
### Features
* add afterInit event ([22e1523](https://github.com/crlcu/multiselect/commit/22e1523))
<a name="2.5.0"></a>
# [2.5.0](https://github.com/crlcu/multiselect/compare/v2.4.1...v2.5.0) (2018-02-06)
### Features
* now we can have different sort functions for left and right ([887ab4a](https://github.com/crlcu/multiselect/commit/887ab4a))

View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2014 Adrian Crisan (adrian.crisan88@gmail.com)
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.

View File

@@ -0,0 +1,17 @@
{
"name": "multiselect",
"version": "2.5.7",
"homepage": "https://github.com/crlcu/multiselect",
"authors": [
"Adrian Crisan <adrian.crisan88@gmail.com>"
],
"description": "jQuery multiselect plugin with two sides",
"main": "dist/js/multiselect.min.js",
"keywords": [
"multiselect"
],
"license": "MIT",
"dependencies": {
"jquery": ">= 1.7"
}
}

View File

@@ -0,0 +1,26 @@
.github.ribbon {
position: fixed;
display: block;
top: 40px;
right: 0;
border: 0;
z-index: 1001;
}
.prettyprint {
padding: 10px!important;
}
#wrap {
padding-top: 70px;
}
#home h1 {
margin-bottom: 30px;
}
#demo,
#examples,
#support,
#download {
padding-top: 40px;
}

View File

@@ -0,0 +1,818 @@
/*
* @license
*
* Multiselect v2.5.6
* http://crlcu.github.io/multiselect/
*
* Copyright (c) 2016-2020 Adrian Crisan
* Licensed under the MIT license (https://github.com/crlcu/multiselect/blob/master/LICENSE)
*/
if (typeof jQuery === 'undefined') {
throw new Error('multiselect requires jQuery');
}
;(function ($) {
'use strict';
var version = $.fn.jquery.split(' ')[0].split('.');
if (version[0] < 2 && version[1] < 7) {
throw new Error('multiselect requires jQuery version 1.7 or higher');
}
})(jQuery);
;(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module depending on jQuery.
define(['jquery'], factory);
} else {
// No AMD. Register plugin with global jQuery object.
factory(jQuery);
}
}(function ($) {
'use strict';
var Multiselect = (function($) {
/** Multiselect object constructor
*
* @class Multiselect
* @constructor
**/
function Multiselect( $select, settings ) {
var id = $select.prop('id');
this.$left = $select;
this.$right = $( settings.right ).length ? $( settings.right ) : $('#' + id + '_to');
this.actions = {
$leftAll: $( settings.leftAll ).length ? $( settings.leftAll ) : $('#' + id + '_leftAll'),
$rightAll: $( settings.rightAll ).length ? $( settings.rightAll ) : $('#' + id + '_rightAll'),
$leftSelected: $( settings.leftSelected ).length ? $( settings.leftSelected ) : $('#' + id + '_leftSelected'),
$rightSelected: $( settings.rightSelected ).length ? $( settings.rightSelected ) : $('#' + id + '_rightSelected'),
$undo: $( settings.undo ).length ? $( settings.undo ) : $('#' + id + '_undo'),
$redo: $( settings.redo ).length ? $( settings.redo ) : $('#' + id + '_redo'),
$moveUp: $( settings.moveUp ).length ? $( settings.moveUp ) : $('#' + id + '_move_up'),
$moveDown: $( settings.moveDown ).length ? $( settings.moveDown ) : $('#' + id + '_move_down')
};
delete settings.leftAll;
delete settings.leftSelected;
delete settings.right;
delete settings.rightAll;
delete settings.rightSelected;
delete settings.undo;
delete settings.redo;
delete settings.moveUp;
delete settings.moveDown;
this.options = {
keepRenderingSort: settings.keepRenderingSort,
submitAllLeft: settings.submitAllLeft !== undefined ? settings.submitAllLeft : true,
submitAllRight: settings.submitAllRight !== undefined ? settings.submitAllRight : true,
search: settings.search,
ignoreDisabled: settings.ignoreDisabled !== undefined ? settings.ignoreDisabled : false,
matchOptgroupBy: settings.matchOptgroupBy !== undefined ? settings.matchOptgroupBy : 'label'
};
delete settings.keepRenderingSort, settings.submitAllLeft, settings.submitAllRight, settings.search, settings.ignoreDisabled, settings.matchOptgroupBy;
this.callbacks = settings;
if ( typeof this.callbacks.sort == 'function' ) {
var sort = this.callbacks.sort;
this.callbacks.sort = {
left: sort,
right: sort,
};
}
this.init();
}
Multiselect.prototype = {
init: function() {
var self = this;
self.undoStack = [];
self.redoStack = [];
if (self.options.keepRenderingSort) {
self.skipInitSort = true;
if (self.callbacks.sort !== false) {
self.callbacks.sort = {
left: function(a, b) {
return $(a).data('position') > $(b).data('position') ? 1 : -1;
},
right: function(a, b) {
return $(a).data('position') > $(b).data('position') ? 1 : -1;
},
};
}
self.$left.attachIndex();
self.$right.each(function(i, select) {
$(select).attachIndex();
});
}
if ( typeof self.callbacks.startUp == 'function' ) {
self.callbacks.startUp( self.$left, self.$right );
}
if ( !self.skipInitSort ) {
if ( typeof self.callbacks.sort.left == 'function' ) {
self.$left.mSort(self.callbacks.sort.left);
}
if ( typeof self.callbacks.sort.right == 'function' ) {
self.$right.each(function(i, select) {
$(select).mSort(self.callbacks.sort.right);
});
}
}
// Append left filter
if (self.options.search && self.options.search.left) {
self.options.search.$left = $(self.options.search.left);
self.$left.before(self.options.search.$left);
}
// Append right filter
if (self.options.search && self.options.search.right) {
self.options.search.$right = $(self.options.search.right);
self.$right.before($(self.options.search.$right));
}
// Initialize events
self.events();
if ( typeof self.callbacks.afterInit == 'function' ) {
self.callbacks.afterInit();
}
},
events: function() {
var self = this;
// Attach event to left filter
if (self.options.search && self.options.search.$left) {
self.options.search.$left.on('keyup', function(e) {
if (self.callbacks.fireSearch(this.value)) {
var $toShow = self.$left.find('option:search("' + this.value + '")').mShow();
var $toHide = self.$left.find('option:not(:search("' + this.value + '"))').mHide();
var $grpHide = self.$left.find('option').closest('optgroup').mHide();
var $grpShow = self.$left.find('option:not(.hidden)').parent('optgroup').mShow();
} else {
self.$left.find('option, optgroup').mShow();
}
});
}
// Attach event to right filter
if (self.options.search && self.options.search.$right) {
self.options.search.$right.on('keyup', function(e) {
if (self.callbacks.fireSearch(this.value)) {
var $toShow = self.$right.find('option:search("' + this.value + '")').mShow();
var $toHide = self.$right.find('option:not(:search("' + this.value + '"))').mHide();
var $grpHide = self.$right.find('option').closest('optgroup').mHide();
var $grpShow = self.$right.find('option:not(.hidden)').parent('optgroup').mShow();
} else {
self.$right.find('option, optgroup').mShow();
}
});
}
// Select all the options from left and right side when submiting the parent form
self.$right.closest('form').on('submit', function(e) {
if (self.options.search) {
// Clear left search input
if (self.options.search.$left) {
self.options.search.$left.val('').trigger('keyup');
}
// Clear right search input
if (self.options.search.$right) {
self.options.search.$right.val('').trigger('keyup');
}
}
self.$left.find('option').prop('selected', self.options.submitAllLeft);
self.$right.find('option').prop('selected', self.options.submitAllRight);
});
// Attach event for double clicking on options from left side
self.$left.on('dblclick', 'option', function(e) {
e.preventDefault();
var $options = self.$left.find('option:selected:not(.hidden)');
if ( $options.length ) {
self.moveToRight($options, e);
}
});
// Attach event for clicking on optgroup's from left side
self.$left.on('click', 'optgroup', function(e) {
if ($(e.target).prop('tagName') == 'OPTGROUP') {
$(this)
.children()
.prop('selected', true);
}
});
// Attach event for pushing ENTER on options from left side
self.$left.on('keypress', function(e) {
if (e.keyCode === 13) {
e.preventDefault();
var $options = self.$left.find('option:selected:not(.hidden)');
if ( $options.length ) {
self.moveToRight($options, e);
}
}
});
// Attach event for double clicking on options from right side
self.$right.on('dblclick', 'option', function(e) {
e.preventDefault();
var $options = self.$right.find('option:selected:not(.hidden)');
if ( $options.length ) {
self.moveToLeft($options, e);
}
});
// Attach event for clicking on optgroup's from right side
self.$right.on('click', 'optgroup', function(e) {
if ($(e.target).prop('tagName') == 'OPTGROUP') {
$(this)
.children()
.prop('selected', true);
}
});
// Attach event for pushing BACKSPACE or DEL on options from right side
self.$right.on('keydown', function(e) {
if (e.keyCode === 8 || e.keyCode === 46) {
e.preventDefault();
var $options = self.$right.find('option:selected:not(.hidden)');
if ( $options.length ) {
self.moveToLeft($options, e);
}
}
});
// dblclick support for IE
if ( navigator.userAgent.match(/MSIE/i) || navigator.userAgent.indexOf('Trident/') > 0 || navigator.userAgent.indexOf('Edge/') > 0) {
self.$left.dblclick(function(e) {
self.actions.$rightSelected.trigger('click');
});
self.$right.dblclick(function(e) {
self.actions.$leftSelected.trigger('click');
});
}
self.actions.$rightSelected.on('click', function(e) {
e.preventDefault();
var $options = self.$left.find('option:selected:not(.hidden)');
if ( $options.length ) {
self.moveToRight($options, e);
}
$(this).blur();
});
self.actions.$leftSelected.on('click', function(e) {
e.preventDefault();
var $options = self.$right.find('option:selected:not(.hidden)');
if ( $options.length ) {
self.moveToLeft($options, e);
}
$(this).blur();
});
self.actions.$rightAll.on('click', function(e) {
e.preventDefault();
var $options = self.$left.children(':not(span):not(.hidden)');
if ( $options.length ) {
self.moveToRight($options, e);
}
$(this).blur();
});
self.actions.$leftAll.on('click', function(e) {
e.preventDefault();
var $options = self.$right.children(':not(span):not(.hidden)');
if ( $options.length ) {
self.moveToLeft($options, e);
}
$(this).blur();
});
self.actions.$undo.on('click', function(e) {
e.preventDefault();
self.undo(e);
});
self.actions.$redo.on('click', function(e) {
e.preventDefault();
self.redo(e);
});
self.actions.$moveUp.on('click', function(e) {
e.preventDefault();
var $options = self.$right.find(':selected:not(span):not(.hidden)');
if ( $options.length ) {
self.moveUp($options, e);
}
$(this).blur();
});
self.actions.$moveDown.on('click', function(e) {
e.preventDefault();
var $options = self.$right.find(':selected:not(span):not(.hidden)');
if ( $options.length ) {
self.moveDown($options, e);
}
$(this).blur();
});
},
moveToRight: function( $options, event, silent, skipStack ) {
var self = this;
if ( typeof self.callbacks.moveToRight == 'function' ) {
return self.callbacks.moveToRight( self, $options, event, silent, skipStack );
}
if ( typeof self.callbacks.beforeMoveToRight == 'function' && !silent ) {
if ( !self.callbacks.beforeMoveToRight( self.$left, self.$right, $options ) ) {
return false;
}
}
self.moveFromAtoB(self.$left, self.$right, $options, event, silent, skipStack);
if ( !skipStack ) {
self.undoStack.push(['right', $options ]);
self.redoStack = [];
}
if ( typeof self.callbacks.sort.right == 'function' && !silent && !self.doNotSortRight ) {
self.$right.mSort(self.callbacks.sort.right);
}
if ( typeof self.callbacks.afterMoveToRight == 'function' && !silent ) {
self.callbacks.afterMoveToRight( self.$left, self.$right, $options );
}
return self;
},
moveToLeft: function( $options, event, silent, skipStack ) {
var self = this;
if ( typeof self.callbacks.moveToLeft == 'function' ) {
return self.callbacks.moveToLeft( self, $options, event, silent, skipStack );
}
if ( typeof self.callbacks.beforeMoveToLeft == 'function' && !silent ) {
if ( !self.callbacks.beforeMoveToLeft( self.$left, self.$right, $options ) ) {
return false;
}
}
self.moveFromAtoB(self.$right, self.$left, $options, event, silent, skipStack);
if ( !skipStack ) {
self.undoStack.push(['left', $options ]);
self.redoStack = [];
}
if ( typeof self.callbacks.sort.left == 'function' && !silent ) {
self.$left.mSort(self.callbacks.sort.left);
}
if ( typeof self.callbacks.afterMoveToLeft == 'function' && !silent ) {
self.callbacks.afterMoveToLeft( self.$left, self.$right, $options );
}
return self;
},
moveFromAtoB: function( $source, $destination, $options, event, silent, skipStack ) {
var self = this;
if ( typeof self.callbacks.moveFromAtoB == 'function' ) {
return self.callbacks.moveFromAtoB(self, $source, $destination, $options, event, silent, skipStack);
}
$options.each(function(index, option) {
var $option = $(option);
if (self.options.ignoreDisabled && $option.is(':disabled')) {
return true;
}
if ($option.is('optgroup') || $option.parent().is('optgroup')) {
var $sourceGroup = $option.is('optgroup') ? $option : $option.parent();
var optgroupSelector = 'optgroup[' + self.options.matchOptgroupBy + '="' + $sourceGroup.prop(self.options.matchOptgroupBy) + '"]';
var $destinationGroup = $destination.find(optgroupSelector);
if (!$destinationGroup.length) {
$destinationGroup = $sourceGroup.clone(true);
$destinationGroup.empty();
$destination.move($destinationGroup);
}
if ($option.is('optgroup')) {
var disabledSelector = '';
if (self.options.ignoreDisabled) {
disabledSelector = ':not(:disabled)';
}
$destinationGroup.move($option.find('option' + disabledSelector));
} else {
$destinationGroup.move($option);
}
$sourceGroup.removeIfEmpty();
} else {
$destination.move($option);
}
});
return self;
},
moveUp: function($options) {
var self = this;
if ( typeof self.callbacks.beforeMoveUp == 'function' ) {
if ( !self.callbacks.beforeMoveUp( $options ) ) {
return false;
}
}
$options.first().prev().before($options);
if ( typeof self.callbacks.afterMoveUp == 'function' ) {
self.callbacks.afterMoveUp( $options );
}
},
moveDown: function($options) {
var self = this;
if ( typeof self.callbacks.beforeMoveDown == 'function' ) {
if ( !self.callbacks.beforeMoveDown( $options ) ) {
return false;
}
}
$options.last().next().after($options);
if ( typeof self.callbacks.afterMoveDown == 'function' ) {
self.callbacks.afterMoveDown( $options );
}
},
undo: function(event) {
var self = this;
var last = self.undoStack.pop();
if ( last ) {
self.redoStack.push(last);
switch(last[0]) {
case 'left':
self.moveToRight(last[1], event, false, true);
break;
case 'right':
self.moveToLeft(last[1], event, false, true);
break;
}
}
},
redo: function(event) {
var self = this;
var last = self.redoStack.pop();
if ( last ) {
self.undoStack.push(last);
switch(last[0]) {
case 'left':
self.moveToLeft(last[1], event, false, true);
break;
case 'right':
self.moveToRight(last[1], event, false, true);
break;
}
}
}
}
return Multiselect;
})($);
$.multiselect = {
defaults: {
/** will be executed once - remove from $left all options that are already in $right
*
* @method startUp
* @attribute $left jQuery object
* @attribute $right jQuery object
**/
startUp: function( $left, $right ) {
$right.find('option').each(function(index, rightOption) {
if ($(rightOption).parent().prop('tagName') == 'OPTGROUP') {
var optgroupSelector = 'optgroup[label="' + $(rightOption).parent().attr('label') + '"]';
$left.find(optgroupSelector + ' option[value="' + rightOption.value + '"]').each(function(index, leftOption) {
leftOption.remove();
});
$left.find(optgroupSelector).removeIfEmpty();
} else {
var $option = $left.find('option[value="' + rightOption.value + '"]');
$option.remove();
}
});
},
/** will be executed after initialize plugin
*
* @method afterInit
*
* @default true
* @return {boolean}
**/
afterInit: function(){ return true; },
/** will be executed each time before moving option[s] to right
*
* IMPORTANT : this method must return boolean value
* true : continue to moveToRight method
* false : stop
*
* @method beforeMoveToRight
* @attribute $left jQuery object
* @attribute $right jQuery object
* @attribute $options HTML object (the option[s] which was selected to be moved)
*
* @default true
* @return {boolean}
**/
beforeMoveToRight: function($left, $right, $options) { return true; },
/* will be executed each time after moving option[s] to right
*
* @method afterMoveToRight
* @attribute $left jQuery object
* @attribute $right jQuery object
* @attribute $options HTML object (the option[s] which was selected to be moved)
**/
afterMoveToRight: function($left, $right, $options) {},
/** will be executed each time before moving option[s] to left
*
* IMPORTANT : this method must return boolean value
* true : continue to moveToRight method
* false : stop
*
* @method beforeMoveToLeft
* @attribute $left jQuery object
* @attribute $right jQuery object
* @attribute $options HTML object (the option[s] which was selected to be moved)
*
* @default true
* @return {boolean}
**/
beforeMoveToLeft: function($left, $right, $options) { return true; },
/* will be executed each time after moving option[s] to left
*
* @method afterMoveToLeft
* @attribute $left jQuery object
* @attribute $right jQuery object
* @attribute $options HTML object (the option[s] which was selected to be moved)
**/
afterMoveToLeft: function($left, $right, $options) {},
/** will be executed each time before moving option[s] up
*
* IMPORTANT : this method must return boolean value
* true : continue to moveUp method
* false : stop
*
* @method beforeMoveUp
* @attribute $options HTML object (the option[s] which was selected to be moved)
*
* @default true
* @return {boolean}
**/
beforeMoveUp: function($options) { return true; },
/* will be executed each time after moving option[s] up
*
* @method afterMoveUp
* @attribute $left jQuery object
* @attribute $right jQuery object
* @attribute $options HTML object (the option[s] which was selected to be moved)
**/
afterMoveUp: function($options) {},
/** will be executed each time before moving option[s] down
*
* IMPORTANT : this method must return boolean value
* true : continue to moveUp method
* false : stop
*
* @method beforeMoveDown
* @attribute $options HTML object (the option[s] which was selected to be moved)
*
* @default true
* @return {boolean}
**/
beforeMoveDown: function($options) { return true; },
/* will be executed each time after moving option[s] down
*
* @method afterMoveUp
* @attribute $left jQuery object
* @attribute $right jQuery object
* @attribute $options HTML object (the option[s] which was selected to be moved)
**/
afterMoveDown: function($options) {},
/** sort options by option text
*
* @method sort
* @attribute a HTML option
* @attribute b HTML option
*
* @return 1/-1
**/
sort: function(a, b) {
if (a.innerHTML == 'NA') {
return 1;
} else if (b.innerHTML == 'NA') {
return -1;
}
return (a.innerHTML > b.innerHTML) ? 1 : -1;
},
/* will tell if the search can start
*
* @method fireSearch
* @attribute value String
*
* @return {boolean}
**/
fireSearch: function(value) {
return value.length > 1;
}
}
};
var ua = window.navigator.userAgent;
var isIE = (ua.indexOf("MSIE ") + ua.indexOf("Trident/") + ua.indexOf("Edge/")) > -3;
var isSafari = ua.toLowerCase().indexOf("safari") > -1;
var isFirefox = ua.toLowerCase().indexOf("firefox") > -1;
$.fn.multiselect = function( options ) {
return this.each(function() {
var $this = $(this),
data = $this.data('crlcu.multiselect'),
settings = $.extend({}, $.multiselect.defaults, $this.data(), (typeof options === 'object' && options));
if (!data) {
$this.data('crlcu.multiselect', (data = new Multiselect($this, settings)));
}
});
};
// append options
// then set the selected attribute to false
$.fn.move = function( $options ) {
this
.append($options)
.find('option')
.prop('selected', false);
return this;
};
$.fn.removeIfEmpty = function() {
if (!this.children().length) {
this.remove();
}
return this;
};
$.fn.mShow = function() {
this.removeClass('hidden').show();
if (isIE || isSafari) {
this.each(function(index, option) {
// Remove <span> to make it compatible with IE
if($(option).parent().is('span')) {
$(option).parent().replaceWith(option);
}
$(option).show();
});
}
if(isFirefox){
this.prop('disabled', false)
}
return this;
};
$.fn.mHide = function() {
this.addClass('hidden').hide();
if (isIE || isSafari) {
this.each(function(index, option) {
// Wrap with <span> to make it compatible with IE
if(!$(option).parent().is('span')) {
$(option).wrap('<span>').hide();
}
});
}
if(isFirefox){
this.prop('disabled', true)
}
return this;
};
// sort options then reappend them to the select
$.fn.mSort = function(callback) {
this
.children()
.sort(callback)
.appendTo(this);
this
.find('optgroup')
.each(function(i, group) {
$(group).children()
.sort(callback)
.appendTo(group);
})
return this;
};
// attach index to children
$.fn.attachIndex = function() {
this.children().each(function(index, option) {
var $option = $(option);
if ($option.is('optgroup')) {
$option.children().each(function(i, children) {
$(children).data('position', i);
});
}
$option.data('position', index);
});
};
$.expr[":"].search = function(elem, index, meta) {
var regex = new RegExp(meta[3].replace(/([^a-zA-Z0-9])/g, "\\$1"), "i");
return $(elem).text().match(regex);
}
}));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,19 @@
var gulp = require('gulp');
// include plug-ins
var rename = require('gulp-rename');
var stripDebug = require('gulp-strip-debug');
var uglify = require('gulp-uglify');
// JS concat, strip debugging and minify
gulp.task('scripts', function() {
return gulp.src(['dist/js/multiselect.js'])
.pipe(rename('multiselect.min.js'))
.pipe(stripDebug())
.pipe(uglify({
sourceMap: true
}))
.pipe(gulp.dest('dist/js/'));
});
gulp.task('default', gulp.parallel('scripts'));

View File

@@ -0,0 +1,30 @@
.com { color: #93a1a1; }
.lit { color: #195f91; }
.pun, .opn, .clo { color: #93a1a1; }
.fun { color: #dc322f; }
.str, .atv { color: #D14; }
.kwd, .linenums .tag { color: #1e347b; }
.typ, .atn, .dec, .var { color: teal; }
.pln { color: #48484c; }
.prettyprint {
padding: 8px;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
}
.prettyprint.linenums {
-webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
-moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin: 0 0 0 33px; /* IE indents via margin-left */
}
ol.linenums li {
padding-left: 12px;
color: #bebec5;
line-height: 18px;
text-shadow: 0 1px 0 #fff;
}

View File

@@ -0,0 +1,188 @@
jasmine.TrivialReporter = function(doc) {
this.document = doc || document;
this.suiteDivs = {};
this.logRunningSpecs = false;
};
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
var el = document.createElement(type);
for (var i = 2; i < arguments.length; i++) {
var child = arguments[i];
if (typeof child === 'string') {
el.appendChild(document.createTextNode(child));
} else {
if (child) { el.appendChild(child); }
}
}
for (var attr in attrs) {
if (attr == "className") {
el[attr] = attrs[attr];
} else {
el.setAttribute(attr, attrs[attr]);
}
}
return el;
};
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
var showPassed, showSkipped;
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
this.createDom('div', { className: 'banner' },
this.createDom('div', { className: 'logo' },
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
this.createDom('span', { className: 'version' }, runner.env.versionString())),
this.createDom('div', { className: 'options' },
"Show ",
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
)
),
this.runnerDiv = this.createDom('div', { className: 'runner running' },
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
);
this.document.body.appendChild(this.outerDiv);
var suites = runner.suites();
for (var i = 0; i < suites.length; i++) {
var suite = suites[i];
var suiteDiv = this.createDom('div', { className: 'suite' },
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
this.suiteDivs[suite.id] = suiteDiv;
var parentDiv = this.outerDiv;
if (suite.parentSuite) {
parentDiv = this.suiteDivs[suite.parentSuite.id];
}
parentDiv.appendChild(suiteDiv);
}
this.startedAt = new Date();
var self = this;
showPassed.onclick = function(evt) {
if (showPassed.checked) {
self.outerDiv.className += ' show-passed';
} else {
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
}
};
showSkipped.onclick = function(evt) {
if (showSkipped.checked) {
self.outerDiv.className += ' show-skipped';
} else {
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
}
};
};
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
var results = runner.results();
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
this.runnerDiv.setAttribute("class", className);
//do it twice for IE
this.runnerDiv.setAttribute("className", className);
var specs = runner.specs();
var specCount = 0;
for (var i = 0; i < specs.length; i++) {
if (this.specFilter(specs[i])) {
specCount++;
}
}
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
};
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
var results = suite.results();
var status = results.passed() ? 'passed' : 'failed';
if (results.totalCount == 0) { // todo: change this to check results.skipped
status = 'skipped';
}
this.suiteDivs[suite.id].className += " " + status;
};
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
if (this.logRunningSpecs) {
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
}
};
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
var results = spec.results();
var status = results.passed() ? 'passed' : 'failed';
if (results.skipped) {
status = 'skipped';
}
var specDiv = this.createDom('div', { className: 'spec ' + status },
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
this.createDom('a', {
className: 'description',
href: '?spec=' + encodeURIComponent(spec.getFullName()),
title: spec.getFullName()
}, spec.description));
var resultItems = results.getItems();
var messagesDiv = this.createDom('div', { className: 'messages' });
for (var i = 0; i < resultItems.length; i++) {
var result = resultItems[i];
if (result.type == 'log') {
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
} else if (result.type == 'expect' && result.passed && !result.passed()) {
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
if (result.trace.stack) {
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
}
}
}
if (messagesDiv.childNodes.length > 0) {
specDiv.appendChild(messagesDiv);
}
this.suiteDivs[spec.suite.id].appendChild(specDiv);
};
jasmine.TrivialReporter.prototype.log = function() {
var console = jasmine.getGlobal().console;
if (console && console.log) {
if (console.log.apply) {
console.log.apply(console, arguments);
} else {
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
}
}
};
jasmine.TrivialReporter.prototype.getLocation = function() {
return this.document.location;
};
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
var paramMap = {};
var params = this.getLocation().search.substring(1).split('&');
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
}
if (!paramMap["spec"]) return true;
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
};

View File

@@ -0,0 +1,203 @@
var readFixtures = function() {
return jasmine.getFixtures().proxyCallTo_('read', arguments);
};
var loadFixtures = function() {
jasmine.getFixtures().proxyCallTo_('load', arguments);
};
var setFixtures = function(html) {
jasmine.getFixtures().set(html);
}
var sandbox = function(attributes) {
return jasmine.getFixtures().sandbox(attributes);
};
jasmine.getFixtures = function() {
return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures();
};
jasmine.Fixtures = function() {
this.containerId = 'jasmine-fixtures';
this.fixturesCache_ = {};
};
jasmine.Fixtures.prototype.set = function(html) {
this.cleanUp();
this.createContainer_(html);
};
jasmine.Fixtures.prototype.load = function() {
this.cleanUp();
this.createContainer_(this.read.apply(this, arguments));
};
jasmine.Fixtures.prototype.read = function() {
var htmlChunks = [];
var fixtureUrls = arguments;
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]));
}
return htmlChunks.join('');
};
jasmine.Fixtures.prototype.clearCache = function() {
this.fixturesCache_ = {};
};
jasmine.Fixtures.prototype.cleanUp = function() {
$('#' + this.containerId).remove();
};
jasmine.Fixtures.prototype.sandbox = function(attributes) {
var attributesToSet = attributes || {};
return $('<div id="sandbox" />').attr(attributesToSet);
};
jasmine.Fixtures.prototype.createContainer_ = function(html) {
var container = $('<div id="' + this.containerId + '" />');
container.html(html);
$('body').append(container);
};
jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
if (typeof this.fixturesCache_[url] == 'undefined') {
this.loadFixtureIntoCache_(url);
}
return this.fixturesCache_[url];
};
jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(url) {
var self = this;
$.ajax({
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
cache: false,
dataType: 'html',
url: url,
success: function(data) {
self.fixturesCache_[url] = data;
}
});
};
jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
return this[methodName].apply(this, passedArguments);
};
jasmine.JQuery = function() {};
jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
return $('<div/>').append(html).html();
};
jasmine.JQuery.elementToString = function(element) {
return $('<div />').append(element.clone()).html();
};
jasmine.JQuery.matchersClass = {};
(function(){
var jQueryMatchers = {
toHaveClass: function(className) {
return this.actual.hasClass(className);
},
toBeVisible: function() {
return this.actual.is(':visible');
},
toBeHidden: function() {
return this.actual.is(':hidden');
},
toBeSelected: function() {
return this.actual.is(':selected');
},
toBeChecked: function() {
return this.actual.is(':checked');
},
toBeEmpty: function() {
return this.actual.is(':empty');
},
toExist: function() {
return this.actual.size() > 0;
},
toHaveAttr: function(attributeName, expectedAttributeValue) {
return hasProperty(this.actual.attr(attributeName), expectedAttributeValue);
},
toHaveId: function(id) {
return this.actual.attr('id') == id;
},
toHaveHtml: function(html) {
return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html);
},
toHaveText: function(text) {
return this.actual.text() == text;
},
toHaveValue: function(value) {
return this.actual.val() == value;
},
toHaveData: function(key, expectedValue) {
return hasProperty(this.actual.data(key), expectedValue);
},
toBe: function(selector) {
return this.actual.is(selector);
},
toContain: function(selector) {
return this.actual.find(selector).size() > 0;
}
};
var hasProperty = function(actualValue, expectedValue) {
if (expectedValue === undefined) {
return actualValue !== undefined;
}
return actualValue == expectedValue;
};
var bindMatcher = function(methodName) {
var builtInMatcher = jasmine.Matchers.prototype[methodName];
jasmine.JQuery.matchersClass[methodName] = function() {
if (this.actual instanceof jQuery) {
var result = jQueryMatchers[methodName].apply(this, arguments);
this.actual = jasmine.JQuery.elementToString(this.actual);
return result;
}
if (builtInMatcher) {
return builtInMatcher.apply(this, arguments);
}
return false;
};
};
for(var methodName in jQueryMatchers) {
bindMatcher(methodName);
}
})();
beforeEach(function() {
this.addMatchers(jasmine.JQuery.matchersClass);
});
afterEach(function() {
jasmine.getFixtures().cleanUp();
});

View File

@@ -0,0 +1,166 @@
body {
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
}
.jasmine_reporter a:visited, .jasmine_reporter a {
color: #303;
}
.jasmine_reporter a:hover, .jasmine_reporter a:active {
color: blue;
}
.run_spec {
float:right;
padding-right: 5px;
font-size: .8em;
text-decoration: none;
}
.jasmine_reporter {
margin: 0 5px;
}
.banner {
color: #303;
background-color: #fef;
padding: 5px;
}
.logo {
float: left;
font-size: 1.1em;
padding-left: 5px;
}
.logo .version {
font-size: .6em;
padding-left: 1em;
}
.runner.running {
background-color: yellow;
}
.options {
text-align: right;
font-size: .8em;
}
.suite {
border: 1px outset gray;
margin: 5px 0;
padding-left: 1em;
}
.suite .suite {
margin: 5px;
}
.suite.passed {
background-color: #dfd;
}
.suite.failed {
background-color: #fdd;
}
.spec {
margin: 5px;
padding-left: 1em;
clear: both;
}
.spec.failed, .spec.passed, .spec.skipped {
padding-bottom: 5px;
border: 1px solid gray;
}
.spec.failed {
background-color: #fbb;
border-color: red;
}
.spec.passed {
background-color: #bfb;
border-color: green;
}
.spec.skipped {
background-color: #bbb;
}
.messages {
border-left: 1px dashed gray;
padding-left: 1em;
padding-right: 1em;
}
.passed {
background-color: #cfc;
display: none;
}
.failed {
background-color: #fbb;
}
.skipped {
color: #777;
background-color: #eee;
display: none;
}
/*.resultMessage {*/
/*white-space: pre;*/
/*}*/
.resultMessage span.result {
display: block;
line-height: 2em;
color: black;
}
.resultMessage .mismatch {
color: black;
}
.stackTrace {
white-space: pre;
font-size: .8em;
margin-left: 10px;
max-height: 5em;
overflow: auto;
border: 1px inset red;
padding: 1em;
background: #eef;
}
.finished-at {
padding-left: 1em;
font-size: .6em;
}
.show-passed .passed,
.show-skipped .skipped {
display: block;
}
#jasmine_content {
position:fixed;
right: 100%;
}
.runner {
border: 1px solid gray;
display: block;
margin: 5px 0;
padding: 2px 0 2px 10px;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,331 @@
/*!
* jQuery Simulate v@VERSION - simulate browser mouse and keyboard events
* https://github.com/jquery/jquery-simulate
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* Date: @DATE
*/
;(function( $, undefined ) {
var rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|contextmenu)|click/;
$.fn.simulate = function( type, options ) {
return this.each(function() {
new $.simulate( this, type, options );
});
};
$.simulate = function( elem, type, options ) {
var method = $.camelCase( "simulate-" + type );
this.target = elem;
this.options = options;
if ( this[ method ] ) {
this[ method ]();
} else {
this.simulateEvent( elem, type, options );
}
};
$.extend( $.simulate, {
keyCode: {
BACKSPACE: 8,
COMMA: 188,
DELETE: 46,
DOWN: 40,
END: 35,
ENTER: 13,
ESCAPE: 27,
HOME: 36,
LEFT: 37,
NUMPAD_ADD: 107,
NUMPAD_DECIMAL: 110,
NUMPAD_DIVIDE: 111,
NUMPAD_ENTER: 108,
NUMPAD_MULTIPLY: 106,
NUMPAD_SUBTRACT: 109,
PAGE_DOWN: 34,
PAGE_UP: 33,
PERIOD: 190,
RIGHT: 39,
SPACE: 32,
TAB: 9,
UP: 38
},
buttonCode: {
LEFT: 0,
MIDDLE: 1,
RIGHT: 2
}
});
$.extend( $.simulate.prototype, {
simulateEvent: function( elem, type, options ) {
var event = this.createEvent( type, options );
this.dispatchEvent( elem, type, event, options );
},
createEvent: function( type, options ) {
if ( rkeyEvent.test( type ) ) {
return this.keyEvent( type, options );
}
if ( rmouseEvent.test( type ) ) {
return this.mouseEvent( type, options );
}
},
mouseEvent: function( type, options ) {
var event, eventDoc, doc, body;
options = $.extend({
bubbles: true,
cancelable: (type !== "mousemove"),
view: window,
detail: 0,
screenX: 0,
screenY: 0,
clientX: 1,
clientY: 1,
ctrlKey: false,
altKey: false,
shiftKey: false,
metaKey: false,
button: 0,
relatedTarget: undefined
}, options );
if ( document.createEvent ) {
event = document.createEvent( "MouseEvents" );
event.initMouseEvent( type, options.bubbles, options.cancelable,
options.view, options.detail,
options.screenX, options.screenY, options.clientX, options.clientY,
options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
options.button, options.relatedTarget || document.body.parentNode );
// IE 9+ creates events with pageX and pageY set to 0.
// Trying to modify the properties throws an error,
// so we define getters to return the correct values.
if ( event.pageX === 0 && event.pageY === 0 && Object.defineProperty ) {
eventDoc = event.relatedTarget.ownerDocument || document;
doc = eventDoc.documentElement;
body = eventDoc.body;
Object.defineProperty( event, "pageX", {
get: function() {
return options.clientX +
( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -
( doc && doc.clientLeft || body && body.clientLeft || 0 );
}
});
Object.defineProperty( event, "pageY", {
get: function() {
return options.clientY +
( doc && doc.scrollTop || body && body.scrollTop || 0 ) -
( doc && doc.clientTop || body && body.clientTop || 0 );
}
});
}
} else if ( document.createEventObject ) {
event = document.createEventObject();
$.extend( event, options );
// standards event.button uses constants defined here: http://msdn.microsoft.com/en-us/library/ie/ff974877(v=vs.85).aspx
// old IE event.button uses constants defined here: http://msdn.microsoft.com/en-us/library/ie/ms533544(v=vs.85).aspx
// so we actually need to map the standard back to oldIE
event.button = {
0: 1,
1: 4,
2: 2
}[ event.button ] || ( event.button === -1 ? 0 : event.button );
}
return event;
},
keyEvent: function( type, options ) {
var event;
options = $.extend({
bubbles: true,
cancelable: true,
view: window,
ctrlKey: false,
altKey: false,
shiftKey: false,
metaKey: false,
keyCode: 0,
charCode: undefined
}, options );
if ( document.createEvent ) {
try {
event = document.createEvent( "KeyEvents" );
event.initKeyEvent( type, options.bubbles, options.cancelable, options.view,
options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
options.keyCode, options.charCode );
// initKeyEvent throws an exception in WebKit
// see: http://stackoverflow.com/questions/6406784/initkeyevent-keypress-only-works-in-firefox-need-a-cross-browser-solution
// and also https://bugs.webkit.org/show_bug.cgi?id=13368
// fall back to a generic event until we decide to implement initKeyboardEvent
} catch( err ) {
event = document.createEvent( "Events" );
event.initEvent( type, options.bubbles, options.cancelable );
$.extend( event, {
view: options.view,
ctrlKey: options.ctrlKey,
altKey: options.altKey,
shiftKey: options.shiftKey,
metaKey: options.metaKey,
keyCode: options.keyCode,
charCode: options.charCode
});
}
} else if ( document.createEventObject ) {
event = document.createEventObject();
$.extend( event, options );
}
if ( !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ) || (({}).toString.call( window.opera ) === "[object Opera]") ) {
event.keyCode = (options.charCode > 0) ? options.charCode : options.keyCode;
event.charCode = undefined;
}
return event;
},
dispatchEvent: function( elem, type, event ) {
if ( elem.dispatchEvent ) {
elem.dispatchEvent( event );
} else if ( type === "click" && elem.click && elem.nodeName.toLowerCase() === "input" ) {
elem.click();
} else if ( elem.fireEvent ) {
elem.fireEvent( "on" + type, event );
}
},
simulateFocus: function() {
var focusinEvent,
triggered = false,
element = $( this.target );
function trigger() {
triggered = true;
}
element.bind( "focus", trigger );
element[ 0 ].focus();
if ( !triggered ) {
focusinEvent = $.Event( "focusin" );
focusinEvent.preventDefault();
element.trigger( focusinEvent );
element.triggerHandler( "focus" );
}
element.unbind( "focus", trigger );
},
simulateBlur: function() {
var focusoutEvent,
triggered = false,
element = $( this.target );
function trigger() {
triggered = true;
}
element.bind( "blur", trigger );
element[ 0 ].blur();
// blur events are async in IE
setTimeout(function() {
// IE won't let the blur occur if the window is inactive
if ( element[ 0 ].ownerDocument.activeElement === element[ 0 ] ) {
element[ 0 ].ownerDocument.body.focus();
}
// Firefox won't trigger events if the window is inactive
// IE doesn't trigger events if we had to manually focus the body
if ( !triggered ) {
focusoutEvent = $.Event( "focusout" );
focusoutEvent.preventDefault();
element.trigger( focusoutEvent );
element.triggerHandler( "blur" );
}
element.unbind( "blur", trigger );
}, 1 );
}
});
/** complex events **/
function findCenter( elem ) {
var offset,
document = $( elem.ownerDocument );
elem = $( elem );
offset = elem.offset();
return {
x: offset.left + elem.outerWidth() / 2 - document.scrollLeft(),
y: offset.top + elem.outerHeight() / 2 - document.scrollTop()
};
}
function findCorner( elem ) {
var offset,
document = $( elem.ownerDocument );
elem = $( elem );
offset = elem.offset();
return {
x: offset.left - document.scrollLeft(),
y: offset.top - document.scrollTop()
};
}
$.extend( $.simulate.prototype, {
simulateDrag: function() {
var i = 0,
target = this.target,
eventDoc = target.ownerDocument,
options = this.options,
center = options.handle === "corner" ? findCorner( target ) : findCenter( target ),
x = Math.floor( center.x ),
y = Math.floor( center.y ),
coord = { clientX: x, clientY: y },
dx = options.dx || ( options.x !== undefined ? options.x - x : 0 ),
dy = options.dy || ( options.y !== undefined ? options.y - y : 0 ),
moves = options.moves || 3;
this.simulateEvent( target, "mousedown", coord );
for ( ; i < moves ; i++ ) {
x += dx / moves;
y += dy / moves;
coord = {
clientX: Math.round( x ),
clientY: Math.round( y )
};
this.simulateEvent( eventDoc, "mousemove", coord );
}
if ( $.contains( eventDoc, target ) ) {
this.simulateEvent( target, "mouseup", coord );
this.simulateEvent( target, "click", coord );
} else {
this.simulateEvent( eventDoc, "mouseup", coord );
}
}
});
})( jQuery );

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
{
"name": "multiselect-two-sides",
"version": "2.5.7",
"description": "jQuery multiselect plugin with two sides",
"main": "dist/js/multiselect.min.js",
"unpkg": "dist/js/multiselect.min.js",
"files": [
"dist"
],
"scripts": {
"test": "jasmine",
"release": "standard-version"
},
"repository": {
"type": "git",
"url": "git+https://github.com/crlcu/multiselect.git"
},
"keywords": [
"multiselect"
],
"author": "Adrian Crisan <adrian.crisan88@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/crlcu/multiselect/issues"
},
"homepage": "https://github.com/crlcu/multiselect#readme",
"devDependencies": {
"gulp": "^4.0.2",
"gulp-rename": "^2.0.0",
"gulp-strip-debug": "^3.0.0",
"gulp-uglify": "^3.0.2",
"standard-version": "^7.1.0"
},
"dependencies": {
"jquery": ">=1.7"
}
}

View File

@@ -0,0 +1,107 @@
describe("data options", function() {
var $multiselect,
$multiselect_to;
beforeEach(function() {
var html = '<div class="row">'+
' <div class="col-xs-5">'+
' <select name="from[]" class="multiselect form-control" size="8" multiple="multiple" data-right="#multiselect_to_1" data-right-all="#right_All_1" data-right-selected="#right_Selected_1" data-left-all="#left_All_1" data-left-selected="#left_Selected_1">'+
' <option value="1">Item 1</option>'+
' <option value="2">Item 5</option>'+
' <option value="2">Item 2</option>'+
' <option value="2">Item 4</option>'+
' <option value="3">Item 3</option>'+
' </select>'+
' </div>'+
' '+
' <div class="col-xs-2">'+
' <button type="button" id="right_All_1" class="btn btn-block"><i class="glyphicon glyphicon-forward"></i></button>'+
' <button type="button" id="right_Selected_1" class="btn btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>'+
' <button type="button" id="left_Selected_1" class="btn btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>'+
' <button type="button" id="left_All_1" class="btn btn-block"><i class="glyphicon glyphicon-backward"></i></button>'+
' </div>'+
' '+
' <div class="col-xs-5">'+
' <select name="to[]" id="multiselect_to_1" class="form-control" size="8" multiple="multiple"></select>'+
' </div>'+
'</div>';
jasmine.getFixtures().set(html);
$multiselect = $('.multiselect').multiselect();
$multiselect_to = $('#multiselect_to_1');
});
it("multiselect is instantiated and contains options", function() {
expect($multiselect.hasClass('multiselect')).toBe(true);
expect($multiselect.find('option').length).toBe(5);
expect($multiselect_to.attr('id')).toBe('multiselect_to_1');
expect($multiselect_to.find('option').length).toBe(0);
});
it("move all to right", function() {
// Click move all to right
$('#right_All_1').trigger('click');
expect($multiselect.find('option').length).toBe(0);
expect($multiselect_to.find('option').length).toBe(5);
});
it("move one to right", function() {
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#right_Selected_1').trigger('click');
expect($multiselect.find('option').length).toBe(4);
expect($multiselect_to.find('option').length).toBe(1);
});
it("move all selected to right", function() {
$multiselect.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#right_Selected_1').trigger('click');
expect($multiselect.find('option').length).toBe(3);
expect($multiselect_to.find('option').length).toBe(2);
});
it("move all to left", function() {
// Click move all to right
$('#right_All_1').trigger('click');
// Click move all to left
$('#left_All_1').trigger('click');
expect($multiselect.find('option').length).toBe(5);
expect($multiselect_to.find('option').length).toBe(0);
});
it("move one to left", function() {
// Click move all to right
$('#right_All_1').trigger('click');
$multiselect_to.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#left_Selected_1').trigger('click');
expect($multiselect.find('option').length).toBe(1);
expect($multiselect_to.find('option').length).toBe(4);
});
it("move all selected to left", function() {
// Click move all to right
$('#right_All_1').trigger('click');
$multiselect_to.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#left_Selected_1').trigger('click');
expect($multiselect.find('option').length).toBe(2);
expect($multiselect_to.find('option').length).toBe(3);
});
});

View File

@@ -0,0 +1,113 @@
describe("javascript options", function() {
var $multiselect,
$multiselect_to;
beforeEach(function() {
var html = '<div class="row">'+
' <div class="col-xs-5">'+
' <select name="from[]" class="js-multiselect form-control" size="8" multiple="multiple">'+
' <option value="1">Item 1</option>'+
' <option value="2">Item 5</option>'+
' <option value="2">Item 2</option>'+
' <option value="2">Item 4</option>'+
' <option value="3">Item 3</option>'+
' </select>'+
' </div>'+
' '+
' <div class="col-xs-2">'+
' <button type="button" id="js_right_All_1" class="btn btn-block"><i class="glyphicon glyphicon-forward"></i></button>'+
' <button type="button" id="js_right_Selected_1" class="btn btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>'+
' <button type="button" id="js_left_Selected_1" class="btn btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>'+
' <button type="button" id="js_left_All_1" class="btn btn-block"><i class="glyphicon glyphicon-backward"></i></button>'+
' </div>'+
' '+
' <div class="col-xs-5">'+
' <select name="to[]" id="js_multiselect_to_1" class="form-control" size="8" multiple="multiple"></select>'+
' </div>'+
'</div>';
jasmine.getFixtures().set(html);
$multiselect = $('.js-multiselect').multiselect({
right: '#js_multiselect_to_1',
rightAll: '#js_right_All_1',
rightSelected: '#js_right_Selected_1',
leftSelected: '#js_left_Selected_1',
leftAll: '#js_left_All_1'
});
$multiselect_to = $('#js_multiselect_to_1');
});
it("multiselect is instantiated and contains options", function() {
expect($multiselect.hasClass('js-multiselect')).toBe(true);
expect($multiselect.find('option').length).toBe(5);
expect($multiselect_to.attr('id')).toBe('js_multiselect_to_1');
expect($multiselect_to.find('option').length).toBe(0);
});
it("move all to right", function() {
// Click move all to right
$('#js_right_All_1').trigger('click');
expect($multiselect.find('option').length).toBe(0);
expect($multiselect_to.find('option').length).toBe(5);
});
it("move one to right", function() {
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#js_right_Selected_1').trigger('click');
expect($multiselect.find('option').length).toBe(4);
expect($multiselect_to.find('option').length).toBe(1);
});
it("move all selected to right", function() {
$multiselect.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#js_right_Selected_1').trigger('click');
expect($multiselect.find('option').length).toBe(3);
expect($multiselect_to.find('option').length).toBe(2);
});
it("move all to left", function() {
// Click move all to right
$('#js_right_All_1').trigger('click');
// Click move all to left
$('#js_left_All_1').trigger('click');
expect($multiselect.find('option').length).toBe(5);
expect($multiselect_to.find('option').length).toBe(0);
});
it("move one to left", function() {
// Click move all to right
$('#js_right_All_1').trigger('click');
$multiselect_to.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#js_left_Selected_1').trigger('click');
expect($multiselect.find('option').length).toBe(1);
expect($multiselect_to.find('option').length).toBe(4);
});
it("move all selected to left", function() {
// Click move all to right
$('#js_right_All_1').trigger('click');
$multiselect_to.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#js_left_Selected_1').trigger('click');
expect($multiselect.find('option').length).toBe(2);
expect($multiselect_to.find('option').length).toBe(3);
});
});

View File

@@ -0,0 +1,128 @@
describe("keep rendering sort", function() {
var $multiselect,
$multiselect_to;
beforeEach(function() {
var html = '<div class="row">'+
' <div class="col-xs-5">'+
' <select name="from[]" id="keepRenderingSort" class="form-control" size="8" multiple="multiple">'+
' <option value="1">Item 1</option>'+
' <option value="2">Item 5</option>'+
' <option value="2">Item 2</option>'+
' <option value="2">Item 4</option>'+
' <option value="3">Item 3</option>'+
' </select>'+
' </div>'+
' '+
' <div class="col-xs-2">'+
' <button type="button" id="keepRenderingSort_rightAll" class="btn btn-block"><i class="glyphicon glyphicon-forward"></i></button>'+
' <button type="button" id="keepRenderingSort_rightSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>'+
' <button type="button" id="keepRenderingSort_leftSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>'+
' <button type="button" id="keepRenderingSort_leftAll" class="btn btn-block"><i class="glyphicon glyphicon-backward"></i></button>'+
' </div>'+
' '+
' <div class="col-xs-5">'+
' <select name="to[]" id="keepRenderingSort_to" class="form-control" size="8" multiple="multiple"></select>'+
' </div>'+
'</div>';
jasmine.getFixtures().set(html);
$multiselect = $('#keepRenderingSort').multiselect({
keepRenderingSort: true
});
$multiselect_to = $('#keepRenderingSort_to');
});
it("multiselect is instantiated and contains options", function() {
expect($multiselect.attr('id')).toBe('keepRenderingSort');
expect($multiselect.find('option').length).toBe(5);
expect($multiselect_to.attr('id')).toBe('keepRenderingSort_to');
expect($multiselect_to.find('option').length).toBe(0);
});
it("move all to right", function() {
// Click move all to right
$('#keepRenderingSort_rightAll').trigger('click');
expect($multiselect.find('option').length).toBe(0);
expect($multiselect_to.find('option').length).toBe(5);
});
it("move one to right", function() {
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#keepRenderingSort_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(4);
expect($multiselect_to.find('option').length).toBe(1);
});
it("move all selected to right", function() {
$multiselect.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#keepRenderingSort_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(3);
expect($multiselect_to.find('option').length).toBe(2);
});
it("move all to left", function() {
// Click move all to right
$('#keepRenderingSort_rightAll').trigger('click');
// Click move all to left
$('#keepRenderingSort_leftAll').trigger('click');
expect($multiselect.find('option').length).toBe(5);
expect($multiselect_to.find('option').length).toBe(0);
});
it("move one to left", function() {
// Click move all to right
$('#keepRenderingSort_rightAll').trigger('click');
$multiselect_to.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#keepRenderingSort_leftSelected').trigger('click');
expect($multiselect.find('option').length).toBe(1);
expect($multiselect_to.find('option').length).toBe(4);
});
it("move all selected to left", function() {
// Click move all to right
$('#keepRenderingSort_rightAll').trigger('click');
$multiselect_to.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#keepRenderingSort_leftSelected').trigger('click');
expect($multiselect.find('option').length).toBe(2);
expect($multiselect_to.find('option').length).toBe(3);
});
it("options in the left are displayed in the way they were rendered", function() {
expect($multiselect.find('option:eq(0)').text()).toBe('Item 1');
expect($multiselect.find('option:eq(1)').text()).toBe('Item 5');
expect($multiselect.find('option:eq(2)').text()).toBe('Item 2');
expect($multiselect.find('option:eq(3)').text()).toBe('Item 4');
expect($multiselect.find('option:eq(4)').text()).toBe('Item 3');
});
it("options in the right are displayed in the way they were rendered", function() {
// Click move all to right
$('#keepRenderingSort_rightAll').trigger('click');
expect($multiselect_to.find('option:eq(0)').text()).toBe('Item 1');
expect($multiselect_to.find('option:eq(1)').text()).toBe('Item 5');
expect($multiselect_to.find('option:eq(2)').text()).toBe('Item 2');
expect($multiselect_to.find('option:eq(3)').text()).toBe('Item 4');
expect($multiselect_to.find('option:eq(4)').text()).toBe('Item 3');
});
});

View File

@@ -0,0 +1,300 @@
describe("multiple destinations", function() {
var $multiselect,
$multiselect_to,
$multiselect_to_2;
beforeEach(function() {
var html = '<div class="row">'+
' <div class="col-xs-5">'+
' <select name="from[]" id="multi_d" class="form-control" size="26" multiple="multiple">'+
' <option value="1">C++</option>'+
' <option value="2">C#</option>'+
' <option value="3">Haskell</option>'+
' <option value="4">Java</option>'+
' <option value="5">JavaScript</option>'+
' <option value="6">Lisp</option>'+
' <option value="7">Lua</option>'+
' <option value="8">MATLAB</option>'+
' <option value="9">NewLISP</option>'+
' <option value="10">PHP</option>'+
' <option value="11">Perl</option>'+
' <option value="12">SQL</option>'+
' <option value="13">Unix shell</option>'+
' </select>'+
' </div>'+
' '+
' <div class="col-xs-2">'+
' <button type="button" id="multi_d_rightAll" class="btn btn-default btn-block" style="margin-top: 20px;"><i class="glyphicon glyphicon-forward"></i></button>'+
' <button type="button" id="multi_d_rightSelected" class="btn btn-default btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>'+
' <button type="button" id="multi_d_leftSelected" class="btn btn-default btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>'+
' <button type="button" id="multi_d_leftAll" class="btn btn-default btn-block"><i class="glyphicon glyphicon-backward"></i></button>'+
' '+
' <hr style="margin: 40px 0 60px;" />'+
' '+
' <button type="button" id="multi_d_rightAll_2" class="btn btn-default btn-block"><i class="glyphicon glyphicon-forward"></i></button>'+
' <button type="button" id="multi_d_rightSelected_2" class="btn btn-default btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>'+
' <button type="button" id="multi_d_leftSelected_2" class="btn btn-default btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>'+
' <button type="button" id="multi_d_leftAll_2" class="btn btn-default btn-block"><i class="glyphicon glyphicon-backward"></i></button>'+
' </div>'+
' '+
' <div class="col-xs-5">'+
' <b>Known languages</b>'+
' <select name="to[]" id="multi_d_to" class="form-control" size="8" multiple="multiple"></select>'+
' '+
' <br/><hr/><br/>'+
' '+
' <b>I want to learn</b>'+
' <select name="to_2[]" id="multi_d_to_2" class="form-control" size="8" multiple="multiple"></select>'+
' </div>'+
'</div>';
jasmine.getFixtures().set(html);
$multiselect = $('#multi_d').multiselect({
right: '#multi_d_to, #multi_d_to_2',
rightSelected: '#multi_d_rightSelected, #multi_d_rightSelected_2',
leftSelected: '#multi_d_leftSelected, #multi_d_leftSelected_2',
rightAll: '#multi_d_rightAll, #multi_d_rightAll_2',
leftAll: '#multi_d_leftAll, #multi_d_leftAll_2',
search: {
left: '<input type="text" name="q" class="form-control" placeholder="Search..." />'
},
moveToRight: function(Multiselect, $options, event, silent, skipStack) {
var button = $(event.currentTarget).attr('id');
if (button == 'multi_d_rightSelected') {
var $left_options = Multiselect.$left.find('> option:selected');
Multiselect.$right.eq(0).append($left_options);
if ( typeof Multiselect.callbacks.sort == 'function' && !silent ) {
Multiselect.$right.eq(0).find('> option').sort(Multiselect.callbacks.sort).appendTo(Multiselect.$right.eq(0));
}
} else if (button == 'multi_d_rightAll') {
var $left_options = Multiselect.$left.children(':visible');
Multiselect.$right.eq(0).append($left_options);
if ( typeof Multiselect.callbacks.sort == 'function' && !silent ) {
Multiselect.$right.eq(0).find('> option').sort(Multiselect.callbacks.sort).appendTo(Multiselect.$right.eq(0));
}
} else if (button == 'multi_d_rightSelected_2') {
var $left_options = Multiselect.$left.find('> option:selected');
Multiselect.$right.eq(1).append($left_options);
if ( typeof Multiselect.callbacks.sort == 'function' && !silent ) {
Multiselect.$right.eq(1).find('> option').sort(Multiselect.callbacks.sort).appendTo(Multiselect.$right.eq(1));
}
} else if (button == 'multi_d_rightAll_2') {
var $left_options = Multiselect.$left.children(':visible');
Multiselect.$right.eq(1).append($left_options);
if ( typeof Multiselect.callbacks.sort == 'function' && !silent ) {
Multiselect.$right.eq(1).eq(1).find('> option').sort(Multiselect.callbacks.sort).appendTo(Multiselect.$right.eq(1));
}
}
},
moveToLeft: function(Multiselect, $options, event, silent, skipStack) {
var button = $(event.currentTarget).attr('id');
if (button == 'multi_d_leftSelected') {
var $right_options = Multiselect.$right.eq(0).find('> option:selected');
Multiselect.$left.append($right_options);
if ( typeof Multiselect.callbacks.sort == 'function' && !silent ) {
Multiselect.$left.find('> option').sort(Multiselect.callbacks.sort).appendTo(Multiselect.$left);
}
} else if (button == 'multi_d_leftAll') {
var $right_options = Multiselect.$right.eq(0).children(':visible');
Multiselect.$left.append($right_options);
if ( typeof Multiselect.callbacks.sort == 'function' && !silent ) {
Multiselect.$left.find('> option').sort(Multiselect.callbacks.sort).appendTo(Multiselect.$left);
}
} else if (button == 'multi_d_leftSelected_2') {
var $right_options = Multiselect.$right.eq(1).find('> option:selected');
Multiselect.$left.append($right_options);
if ( typeof Multiselect.callbacks.sort == 'function' && !silent ) {
Multiselect.$left.find('> option').sort(Multiselect.callbacks.sort).appendTo(Multiselect.$left);
}
} else if (button == 'multi_d_leftAll_2') {
var $right_options = Multiselect.$right.eq(1).children(':visible');
Multiselect.$left.append($right_options);
if ( typeof Multiselect.callbacks.sort == 'function' && !silent ) {
Multiselect.$left.find('> option').sort(Multiselect.callbacks.sort).appendTo(Multiselect.$left);
}
}
}
});
$multiselect_to = $('#multi_d_to');
$multiselect_to_2 = $('#multi_d_to_2');
});
it("multiselect is instantiated and contains options", function() {
expect($multiselect.attr('id')).toBe('multi_d');
expect($multiselect.find('option').length).toBe(13);
expect($multiselect_to.attr('id')).toBe('multi_d_to');
expect($multiselect_to.find('option').length).toBe(0);
expect($multiselect_to_2.attr('id')).toBe('multi_d_to_2');
expect($multiselect_to_2.find('option').length).toBe(0);
});
it("move all to right 1", function() {
// Click move all to right
$('#multi_d_rightAll').trigger('click');
expect($multiselect.find('option').length).toBe(0);
expect($multiselect_to.find('option').length).toBe(13);
});
it("move one to right 1", function() {
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#multi_d_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(12);
expect($multiselect_to.find('option').length).toBe(1);
});
it("move all selected to right 1", function() {
$multiselect.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#multi_d_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(7);
expect($multiselect_to.find('option').length).toBe(6);
});
it("move all to left 1", function() {
// Click move all to right
$('#multi_d_rightAll').trigger('click');
// Click move all to left
$('#multi_d_leftAll').trigger('click');
expect($multiselect.find('option').length).toBe(13);
expect($multiselect_to.find('option').length).toBe(0);
});
it("move one to left 1", function() {
// Click move all to right
$('#multi_d_rightAll').trigger('click');
$multiselect_to.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#multi_d_leftSelected').trigger('click');
expect($multiselect.find('option').length).toBe(1);
expect($multiselect_to.find('option').length).toBe(12);
});
it("move all selected to left 1", function() {
// Click move all to right
$('#multi_d_rightAll').trigger('click');
$multiselect_to.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#multi_d_leftSelected').trigger('click');
expect($multiselect.find('option').length).toBe(6);
expect($multiselect_to.find('option').length).toBe(7);
});
it("move all to right 2", function() {
// Click move all to right
$('#multi_d_rightAll_2').trigger('click');
expect($multiselect.find('option').length).toBe(0);
expect($multiselect_to_2.find('option').length).toBe(13);
});
it("move one to right 2", function() {
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#multi_d_rightSelected_2').trigger('click');
expect($multiselect.find('option').length).toBe(12);
expect($multiselect_to_2.find('option').length).toBe(1);
});
it("move all selected to right 2", function() {
$multiselect.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#multi_d_rightSelected_2').trigger('click');
expect($multiselect.find('option').length).toBe(7);
expect($multiselect_to_2.find('option').length).toBe(6);
});
it("move all to left 2", function() {
// Click move all to right
$('#multi_d_rightAll_2').trigger('click');
// Click move all to left
$('#multi_d_leftAll_2').trigger('click');
expect($multiselect.find('option').length).toBe(13);
expect($multiselect_to_2.find('option').length).toBe(0);
});
it("move one to left 2", function() {
// Click move all to right
$('#multi_d_rightAll_2').trigger('click');
$multiselect_to_2.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#multi_d_leftSelected_2').trigger('click');
expect($multiselect.find('option').length).toBe(1);
expect($multiselect_to_2.find('option').length).toBe(12);
});
it("move all selected to left 2", function() {
// Click move all to right
$('#multi_d_rightAll_2').trigger('click');
$multiselect_to_2.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#multi_d_leftSelected_2').trigger('click');
expect($multiselect.find('option').length).toBe(6);
expect($multiselect_to_2.find('option').length).toBe(7);
});
it("move one to right 1 and one to right 2", function() {
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#multi_d_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(12);
expect($multiselect_to.find('option').length).toBe(1);
expect($multiselect_to_2.find('option').length).toBe(0);
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#multi_d_rightSelected_2').trigger('click');
expect($multiselect.find('option').length).toBe(11);
expect($multiselect_to.find('option').length).toBe(1);
expect($multiselect_to_2.find('option').length).toBe(1);
});
});

View File

@@ -0,0 +1,142 @@
describe("with search", function() {
var $multiselect,
$multiselect_to;
beforeEach(function() {
var html = '<div class="row">'+
' <div class="col-xs-5">'+
' <select name="from[]" id="search" class="form-control" size="8" multiple="multiple">'+
' <option value="1">Item 1</option>'+
' <option value="2">Item 5</option>'+
' <option value="2">Item 2</option>'+
' <option value="2">Item 4</option>'+
' <option value="3">Item 3</option>'+
' </select>'+
' </div>'+
' '+
' <div class="col-xs-2">'+
' <button type="button" id="search_rightAll" class="btn btn-block"><i class="glyphicon glyphicon-forward"></i></button>'+
' <button type="button" id="search_rightSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>'+
' <button type="button" id="search_leftSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>'+
' <button type="button" id="search_leftAll" class="btn btn-block"><i class="glyphicon glyphicon-backward"></i></button>'+
' </div>'+
' '+
' <div class="col-xs-5">'+
' <select name="to[]" id="search_to" class="form-control" size="8" multiple="multiple"></select>'+
' </div>'+
'</div>';
jasmine.getFixtures().set(html);
$multiselect = $('#search').multiselect({
search: {
left: '<input type="text" name="q" class="form-control" placeholder="Search..." />',
right: '<input type="text" name="q" class="form-control" placeholder="Search..." />',
},
fireSearch: function(value) {
return value.length > 3;
}
});
$multiselect_to = $('#search_to');
});
it("multiselect is instantiated and contains options", function() {
expect($multiselect.attr('id')).toBe('search');
expect($multiselect.find('option').length).toBe(5);
expect($multiselect_to.attr('id')).toBe('search_to');
expect($multiselect_to.find('option').length).toBe(0);
});
it("move all to right", function() {
// Click move all to right
$('#search_rightAll').trigger('click');
expect($multiselect.find('option').length).toBe(0);
expect($multiselect_to.find('option').length).toBe(5);
});
it("move one to right", function() {
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#search_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(4);
expect($multiselect_to.find('option').length).toBe(1);
});
it("move all selected to right", function() {
$multiselect.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#search_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(3);
expect($multiselect_to.find('option').length).toBe(2);
});
it("move all to left", function() {
// Click move all to right
$('#search_rightAll').trigger('click');
// Click move all to left
$('#search_leftAll').trigger('click');
expect($multiselect.find('option').length).toBe(5);
expect($multiselect_to.find('option').length).toBe(0);
});
it("move one to left", function() {
// Click move all to right
$('#search_rightAll').trigger('click');
$multiselect_to.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#search_leftSelected').trigger('click');
expect($multiselect.find('option').length).toBe(1);
expect($multiselect_to.find('option').length).toBe(4);
});
it("move all selected to left", function() {
// Click move all to right
$('#search_rightAll').trigger('click');
$multiselect_to.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#search_leftSelected').trigger('click');
expect($multiselect.find('option').length).toBe(2);
expect($multiselect_to.find('option').length).toBe(3);
});
it("search on the left side", function() {
// Search for "Item 1"
$('#search').prev('[name="q"]').val('Item 1').trigger('keyup');
expect($multiselect.find('option:visible').length).toBe(1);
// Search for "Item"
$('#search').prev('[name="q"]').val('Item').trigger('keyup');
expect($multiselect.find('option:visible').length).toBe(5);
});
it("search on the right side", function() {
// Click move all to right
$('#search_rightAll').trigger('click');
// Search for "Item 1"
$('#search_to').prev('[name="q"]').val('Item 1').trigger('keyup');
expect($multiselect_to.find('option:visible').length).toBe(1);
// Search for "Item"
$('#search_to').prev('[name="q"]').val('Item').trigger('keyup');
expect($multiselect_to.find('option:visible').length).toBe(5);
});
});

View File

@@ -0,0 +1,193 @@
describe("undo redo", function() {
var $multiselect,
$multiselect_to;
beforeEach(function() {
var html = '<div class="row">'+
' <div class="col-xs-5">'+
' <select name="from[]" id="undo_redo" class="form-control" size="13" multiple="multiple">'+
' <option value="1">C++</option>'+
' <option value="2">C#</option>'+
' <option value="3">Haskell</option>'+
' <option value="4">Java</option>'+
' <option value="5">JavaScript</option>'+
' <option value="6">Lisp</option>'+
' <option value="7">Lua</option>'+
' <option value="8">MATLAB</option>'+
' <option value="9">NewLISP</option>'+
' <option value="10">PHP</option>'+
' <option value="11">Perl</option>'+
' <option value="12">SQL</option>'+
' <option value="13">Unix shell</option>'+
' </select>'+
' </div>'+
' '+
' <div class="col-xs-2">'+
' <button type="button" id="undo_redo_undo" class="btn btn-primary btn-block">undo</button>'+
' <button type="button" id="undo_redo_rightAll" class="btn btn-default btn-block"><i class="glyphicon glyphicon-forward"></i></button>'+
' <button type="button" id="undo_redo_rightSelected" class="btn btn-default btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>'+
' <button type="button" id="undo_redo_leftSelected" class="btn btn-default btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>'+
' <button type="button" id="undo_redo_leftAll" class="btn btn-default btn-block"><i class="glyphicon glyphicon-backward"></i></button>'+
' <button type="button" id="undo_redo_redo" class="btn btn-warning btn-block">redo</button>'+
' </div>'+
' '+
' <div class="col-xs-5">'+
' <select name="to[]" id="undo_redo_to" class="form-control" size="13" multiple="multiple"></select>'+
' </div>'+
'</div>';
jasmine.getFixtures().set(html);
$multiselect = $('#undo_redo').multiselect();
$multiselect_to = $('#undo_redo_to');
});
it("multiselect is instantiated and contains options", function() {
expect($multiselect.attr('id')).toBe('undo_redo');
expect($multiselect.find('option').length).toBe(13);
expect($multiselect_to.attr('id')).toBe('undo_redo_to');
expect($multiselect_to.find('option').length).toBe(0);
});
it("move all to right", function() {
// Click move all to right
$('#undo_redo_rightAll').trigger('click');
expect($multiselect.find('option').length).toBe(0);
expect($multiselect_to.find('option').length).toBe(13);
});
it("move one to right", function() {
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#undo_redo_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(12);
expect($multiselect_to.find('option').length).toBe(1);
});
it("move all selected to right", function() {
$multiselect.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#undo_redo_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(7);
expect($multiselect_to.find('option').length).toBe(6);
});
it("move all to left", function() {
// Click move all to right
$('#undo_redo_rightAll').trigger('click');
// Click move all to left
$('#undo_redo_leftAll').trigger('click');
expect($multiselect.find('option').length).toBe(13);
expect($multiselect_to.find('option').length).toBe(0);
});
it("move one to left", function() {
// Click move all to right
$('#undo_redo_rightAll').trigger('click');
$multiselect_to.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#undo_redo_leftSelected').trigger('click');
expect($multiselect.find('option').length).toBe(1);
expect($multiselect_to.find('option').length).toBe(12);
});
it("move all selected to left", function() {
// Click move all to right
$('#undo_redo_rightAll').trigger('click');
$multiselect_to.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#undo_redo_leftSelected').trigger('click');
expect($multiselect.find('option').length).toBe(6);
expect($multiselect_to.find('option').length).toBe(7);
});
it("move one to right then undo", function() {
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#undo_redo_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(12);
expect($multiselect_to.find('option').length).toBe(1);
// Click undo
$('#undo_redo_undo').trigger('click');
expect($multiselect.find('option').length).toBe(13);
expect($multiselect_to.find('option').length).toBe(0);
});
it("move one to right then undo then redo", function() {
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#undo_redo_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(12);
expect($multiselect_to.find('option').length).toBe(1);
// Click undo
$('#undo_redo_undo').trigger('click');
expect($multiselect.find('option').length).toBe(13);
expect($multiselect_to.find('option').length).toBe(0);
// Click redo
$('#undo_redo_redo').trigger('click');
expect($multiselect.find('option').length).toBe(12);
expect($multiselect_to.find('option').length).toBe(1);
});
it("move all selected to right then undo", function() {
$multiselect.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#undo_redo_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(7);
expect($multiselect_to.find('option').length).toBe(6);
// Click undo
$('#undo_redo_undo').trigger('click');
expect($multiselect.find('option').length).toBe(13);
expect($multiselect_to.find('option').length).toBe(0);
});
it("move all selected to right then undo then redo", function() {
$multiselect.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#undo_redo_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(7);
expect($multiselect_to.find('option').length).toBe(6);
// Click undo
$('#undo_redo_undo').trigger('click');
expect($multiselect.find('option').length).toBe(13);
expect($multiselect_to.find('option').length).toBe(0);
// Click redo
$('#undo_redo_redo').trigger('click');
expect($multiselect.find('option').length).toBe(7);
expect($multiselect_to.find('option').length).toBe(6);
});
});

View File

@@ -0,0 +1,115 @@
if (typeof window === 'undefined') {
var jsdom = require("jsdom");
global.document = jsdom.jsdom();
global.window = global.document.defaultView;
var navigator = {userAgent: "node-js", platform: "Linux i686"};
global.window.navigator = global.navigator = navigator;
navigator.platform = "Linux i686";
global.jQuery = global.$ = require("jquery");
}
describe("zero configuration", function() {
var $multiselect,
$multiselect_to;
beforeEach(function() {
var html = '<div class="row">'+
' <div class="col-xs-5">'+
' <select name="from[]" id="multiselect" class="form-control" size="8" multiple="multiple">'+
' <option value="1">Item 1</option>'+
' <option value="2">Item 5</option>'+
' <option value="2">Item 2</option>'+
' <option value="2">Item 4</option>'+
' <option value="3">Item 3</option>'+
' </select>'+
' </div>'+
' '+
' <div class="col-xs-2">'+
' <button type="button" id="multiselect_rightAll" class="btn btn-block"><i class="glyphicon glyphicon-forward"></i></button>'+
' <button type="button" id="multiselect_rightSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>'+
' <button type="button" id="multiselect_leftSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>'+
' <button type="button" id="multiselect_leftAll" class="btn btn-block"><i class="glyphicon glyphicon-backward"></i></button>'+
' </div>'+
' '+
' <div class="col-xs-5">'+
' <select name="to[]" id="multiselect_to" class="form-control" size="8" multiple="multiple"></select>'+
' </div>'+
'</div>';
jasmine.getFixtures().set(html);
$multiselect = $('#multiselect').multiselect();
$multiselect_to = $('#multiselect_to');
});
it("multiselect is instantiated and contains options", function() {
expect($multiselect.attr('id')).toBe('multiselect');
expect($multiselect.find('option').length).toBe(5);
expect($multiselect_to.attr('id')).toBe('multiselect_to');
expect($multiselect_to.find('option').length).toBe(0);
});
it("move all to right", function() {
// Click move all to right
$('#multiselect_rightAll').trigger('click');
expect($multiselect.find('option').length).toBe(0);
});
it("move one to right", function() {
$multiselect.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#multiselect_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(4);
expect($multiselect_to.find('option').length).toBe(1);
});
it("move all selected to right", function() {
$multiselect.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#multiselect_rightSelected').trigger('click');
expect($multiselect.find('option').length).toBe(3);
expect($multiselect_to.find('option').length).toBe(2);
});
it("move all to left", function() {
// Click move all to right
$('#multiselect_rightAll').trigger('click');
// Click move all to left
$('#multiselect_leftAll').trigger('click');
expect($multiselect.find('option').length).toBe(5);
});
it("move one to left", function() {
// Click move all to right
$('#multiselect_rightAll').trigger('click');
$multiselect_to.find('option:eq(0)').attr('selected', true);
// Click move selected to right
$('#multiselect_leftSelected').trigger('click');
expect($multiselect.find('option').length).toBe(1);
expect($multiselect_to.find('option').length).toBe(4);
});
it("move all selected to left", function() {
// Click move all to right
$('#multiselect_rightAll').trigger('click');
$multiselect_to.find('option:nth-child(2n)').attr('selected', true);
// Click move selected to right
$('#multiselect_leftSelected').trigger('click');
expect($multiselect.find('option').length).toBe(2);
expect($multiselect_to.find('option').length).toBe(3);
});
});