First Initial
This commit is contained in:
13
wwwroot/BackendScript/assets/jquery-multi-select/LICENSE.txt
Normal file
13
wwwroot/BackendScript/assets/jquery-multi-select/LICENSE.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
@@ -0,0 +1,3 @@
|
||||
# jquery.multi-select.js
|
||||
|
||||
Usage and Demos [http://loudev.com](http://loudev.com "jquery.multi-select.js")
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "multiselect",
|
||||
"version": "0.9.8",
|
||||
"main": ["css/multi-select.css", "img/switch.png", "js/jquery.multi-select.js"],
|
||||
"dependencies" : {
|
||||
"jquery" ">= 1.7.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
.ms-container{
|
||||
background: transparent url('../img/switch.png') no-repeat 50% 50%;
|
||||
width: 370px;
|
||||
}
|
||||
|
||||
.ms-container:after{
|
||||
content: ".";
|
||||
display: block;
|
||||
height: 0;
|
||||
line-height: 0;
|
||||
font-size: 0;
|
||||
clear: both;
|
||||
min-height: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.ms-container .ms-selectable, .ms-container .ms-selection{
|
||||
background: #fff;
|
||||
color: #555555;
|
||||
float: left;
|
||||
width: 45%;
|
||||
}
|
||||
.ms-container .ms-selection{
|
||||
float: right;
|
||||
}
|
||||
|
||||
.ms-container .ms-list{
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
-webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
|
||||
-moz-transition: border linear 0.2s, box-shadow linear 0.2s;
|
||||
-ms-transition: border linear 0.2s, box-shadow linear 0.2s;
|
||||
-o-transition: border linear 0.2s, box-shadow linear 0.2s;
|
||||
transition: border linear 0.2s, box-shadow linear 0.2s;
|
||||
border: 1px solid #ccc;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
position: relative;
|
||||
height: 200px;
|
||||
padding: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.ms-container .ms-list.ms-focus{
|
||||
border-color: rgba(82, 168, 236, 0.8);
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
||||
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
||||
outline: 0;
|
||||
outline: thin dotted \9;
|
||||
}
|
||||
|
||||
.ms-container ul{
|
||||
margin: 0;
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.ms-container .ms-optgroup-container{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ms-container .ms-optgroup-label{
|
||||
margin: 0;
|
||||
padding: 5px 0px 0px 5px;
|
||||
cursor: pointer;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.ms-container .ms-selectable li.ms-elem-selectable,
|
||||
.ms-container .ms-selection li.ms-elem-selection{
|
||||
border-bottom: 1px #eee solid;
|
||||
padding: 2px 10px;
|
||||
color: #555;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.ms-container .ms-selectable li.ms-hover,
|
||||
.ms-container .ms-selection li.ms-hover{
|
||||
cursor: pointer;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
background-color: #08c;
|
||||
}
|
||||
|
||||
.ms-container .ms-selectable li.disabled,
|
||||
.ms-container .ms-selection li.disabled{
|
||||
background-color: #eee;
|
||||
color: #aaa;
|
||||
cursor: text;
|
||||
}
|
||||
BIN
wwwroot/BackendScript/assets/jquery-multi-select/img/switch.png
Normal file
BIN
wwwroot/BackendScript/assets/jquery-multi-select/img/switch.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 236 B |
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,470 @@
|
||||
/*
|
||||
* MultiSelect v0.9.8
|
||||
* Copyright (c) 2012 Louis Cuny
|
||||
*
|
||||
* This program is free software. It comes without any warranty, to
|
||||
* the extent permitted by applicable law. You can redistribute it
|
||||
* and/or modify it under the terms of the Do What The Fuck You Want
|
||||
* To Public License, Version 2, as published by Sam Hocevar. See
|
||||
* http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
*/
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
/* MULTISELECT CLASS DEFINITION
|
||||
* ====================== */
|
||||
|
||||
var MultiSelect = function (element, options) {
|
||||
this.options = options;
|
||||
this.$element = $(element);
|
||||
|
||||
this.$container = $('<div/>', { 'class': "ms-container" });
|
||||
this.$selectableContainer = $('<div/>', { 'class': 'ms-selectable' });
|
||||
this.$selectionContainer = $('<div/>', { 'class': 'ms-selection' });
|
||||
this.$selectableUl = $('<ul/>', { 'class': "ms-list", 'tabindex' : '-1' });
|
||||
this.$selectionUl = $('<ul/>', { 'class': "ms-list", 'tabindex' : '-1' });
|
||||
this.scrollTo = 0;
|
||||
this.sanitizeRegexp = new RegExp("\\W+", 'gi');
|
||||
this.elemsSelector = 'li:visible:not(.ms-optgroup-label,.ms-optgroup-container,.'+options.disabledClass+')';
|
||||
};
|
||||
|
||||
MultiSelect.prototype = {
|
||||
constructor: MultiSelect,
|
||||
|
||||
init: function(){
|
||||
var that = this,
|
||||
ms = this.$element;
|
||||
|
||||
if (ms.next('.ms-container').length === 0){
|
||||
ms.css({ position: 'absolute', left: '-9999px' });
|
||||
ms.attr('id', ms.attr('id') ? ms.attr('id') : Math.ceil(Math.random()*1000)+'multiselect');
|
||||
this.$container.attr('id', 'ms-'+ms.attr('id'));
|
||||
|
||||
ms.find('option').each(function(){
|
||||
that.generateLisFromOption(this);
|
||||
});
|
||||
|
||||
this.$selectionUl.find('.ms-optgroup-label').hide();
|
||||
|
||||
if (that.options.selectableHeader){
|
||||
that.$selectableContainer.append(that.options.selectableHeader);
|
||||
}
|
||||
that.$selectableContainer.append(that.$selectableUl);
|
||||
if (that.options.selectableFooter){
|
||||
that.$selectableContainer.append(that.options.selectableFooter);
|
||||
}
|
||||
|
||||
if (that.options.selectionHeader){
|
||||
that.$selectionContainer.append(that.options.selectionHeader);
|
||||
}
|
||||
that.$selectionContainer.append(that.$selectionUl);
|
||||
if (that.options.selectionFooter){
|
||||
that.$selectionContainer.append(that.options.selectionFooter);
|
||||
}
|
||||
|
||||
that.$container.append(that.$selectableContainer);
|
||||
that.$container.append(that.$selectionContainer);
|
||||
ms.after(that.$container);
|
||||
|
||||
that.activeMouse(that.$selectableUl);
|
||||
that.activeKeyboard(that.$selectableUl);
|
||||
|
||||
var action = that.options.dblClick ? 'dblclick' : 'click';
|
||||
|
||||
that.$selectableUl.on(action, '.ms-elem-selectable', function(){
|
||||
that.select($(this).data('ms-value'));
|
||||
});
|
||||
that.$selectionUl.on(action, '.ms-elem-selection', function(){
|
||||
that.deselect($(this).data('ms-value'));
|
||||
});
|
||||
|
||||
that.activeMouse(that.$selectionUl);
|
||||
that.activeKeyboard(that.$selectionUl);
|
||||
|
||||
ms.on('focus', function(){
|
||||
that.$selectableUl.focus();
|
||||
})
|
||||
}
|
||||
|
||||
var selectedValues = ms.find('option:selected').map(function(){ return $(this).val(); }).get();
|
||||
that.select(selectedValues, 'init');
|
||||
|
||||
if (typeof that.options.afterInit === 'function') {
|
||||
that.options.afterInit.call(this, this.$container);
|
||||
}
|
||||
},
|
||||
|
||||
'generateLisFromOption' : function(option){
|
||||
var that = this,
|
||||
ms = that.$element,
|
||||
attributes = "",
|
||||
$option = $(option);
|
||||
|
||||
for (var cpt = 0; cpt < option.attributes.length; cpt++){
|
||||
var attr = option.attributes[cpt];
|
||||
|
||||
if(attr.name !== 'value' && attr.name !== 'disabled'){
|
||||
attributes += attr.name+'="'+attr.value+'" ';
|
||||
}
|
||||
}
|
||||
var selectableLi = $('<li '+attributes+'><span>'+$option.text()+'</span></li>'),
|
||||
selectedLi = selectableLi.clone(),
|
||||
value = $option.val(),
|
||||
elementId = that.sanitize(value, that.sanitizeRegexp);
|
||||
|
||||
selectableLi
|
||||
.data('ms-value', value)
|
||||
.addClass('ms-elem-selectable')
|
||||
.attr('id', elementId+'-selectable');
|
||||
|
||||
selectedLi
|
||||
.data('ms-value', value)
|
||||
.addClass('ms-elem-selection')
|
||||
.attr('id', elementId+'-selection')
|
||||
.hide();
|
||||
|
||||
if ($option.prop('disabled') || ms.prop('disabled')){
|
||||
selectedLi.addClass(that.options.disabledClass);
|
||||
selectableLi.addClass(that.options.disabledClass);
|
||||
}
|
||||
|
||||
var $optgroup = $option.parent('optgroup');
|
||||
|
||||
if ($optgroup.length > 0){
|
||||
var optgroupLabel = $optgroup.attr('label'),
|
||||
optgroupId = that.sanitize(optgroupLabel, that.sanitizeRegexp),
|
||||
$selectableOptgroup = that.$selectableUl.find('#optgroup-selectable-'+optgroupId),
|
||||
$selectionOptgroup = that.$selectionUl.find('#optgroup-selection-'+optgroupId);
|
||||
|
||||
if ($selectableOptgroup.length === 0){
|
||||
var optgroupContainerTpl = '<li class="ms-optgroup-container"></li>',
|
||||
optgroupTpl = '<ul class="ms-optgroup"><li class="ms-optgroup-label"><span>'+optgroupLabel+'</span></li></ul>';
|
||||
|
||||
$selectableOptgroup = $(optgroupContainerTpl);
|
||||
$selectionOptgroup = $(optgroupContainerTpl);
|
||||
$selectableOptgroup.attr('id', 'optgroup-selectable-'+optgroupId);
|
||||
$selectionOptgroup.attr('id', 'optgroup-selection-'+optgroupId);
|
||||
$selectableOptgroup.append($(optgroupTpl));
|
||||
$selectionOptgroup.append($(optgroupTpl));
|
||||
if (that.options.selectableOptgroup){
|
||||
$selectableOptgroup.find('.ms-optgroup-label').on('click', function(){
|
||||
var values = $optgroup.children(':not(:selected)').map(function(){ return $(this).val() }).get();
|
||||
that.select(values);
|
||||
});
|
||||
$selectionOptgroup.find('.ms-optgroup-label').on('click', function(){
|
||||
var values = $optgroup.children(':selected').map(function(){ return $(this).val() }).get();
|
||||
that.deselect(values);
|
||||
});
|
||||
}
|
||||
that.$selectableUl.append($selectableOptgroup);
|
||||
that.$selectionUl.append($selectionOptgroup);
|
||||
}
|
||||
$selectableOptgroup.children().append(selectableLi);
|
||||
$selectionOptgroup.children().append(selectedLi);
|
||||
} else {
|
||||
that.$selectableUl.append(selectableLi);
|
||||
that.$selectionUl.append(selectedLi);
|
||||
}
|
||||
},
|
||||
|
||||
'activeKeyboard' : function($list){
|
||||
var that = this;
|
||||
|
||||
$list.on('focus', function(){
|
||||
$(this).addClass('ms-focus');
|
||||
})
|
||||
.on('blur', function(){
|
||||
$(this).removeClass('ms-focus');
|
||||
})
|
||||
.on('keydown', function(e){
|
||||
switch (e.which) {
|
||||
case 40:
|
||||
case 38:
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
that.moveHighlight($(this), (e.which === 38) ? -1 : 1);
|
||||
return;
|
||||
case 32:
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
that.selectHighlighted($list);
|
||||
return;
|
||||
case 37:
|
||||
case 39:
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
that.switchList($list);
|
||||
return;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
'moveHighlight': function($list, direction){
|
||||
var $elems = $list.find(this.elemsSelector),
|
||||
$currElem = $elems.filter('.ms-hover'),
|
||||
$nextElem = null,
|
||||
elemHeight = $elems.first().outerHeight(),
|
||||
containerHeight = $list.height(),
|
||||
containerSelector = '#'+this.$container.prop('id');
|
||||
|
||||
// Deactive mouseenter event when move is active
|
||||
// It fixes a bug when mouse is over the list
|
||||
$elems.off('mouseenter');
|
||||
|
||||
$elems.removeClass('ms-hover');
|
||||
if (direction === 1){ // DOWN
|
||||
|
||||
$nextElem = $currElem.nextAll(this.elemsSelector).first();
|
||||
if ($nextElem.length === 0){
|
||||
var $optgroupUl = $currElem.parent();
|
||||
|
||||
if ($optgroupUl.hasClass('ms-optgroup')){
|
||||
var $optgroupLi = $optgroupUl.parent(),
|
||||
$nextOptgroupLi = $optgroupLi.next(':visible');
|
||||
|
||||
if ($nextOptgroupLi.length > 0){
|
||||
$nextElem = $nextOptgroupLi.find(this.elemsSelector).first();
|
||||
} else {
|
||||
$nextElem = $elems.first();
|
||||
}
|
||||
} else {
|
||||
$nextElem = $elems.first();
|
||||
}
|
||||
}
|
||||
} else if (direction === -1){ // UP
|
||||
|
||||
$nextElem = $currElem.prevAll(this.elemsSelector).first();
|
||||
if ($nextElem.length === 0){
|
||||
var $optgroupUl = $currElem.parent();
|
||||
|
||||
if ($optgroupUl.hasClass('ms-optgroup')){
|
||||
var $optgroupLi = $optgroupUl.parent(),
|
||||
$prevOptgroupLi = $optgroupLi.prev(':visible');
|
||||
|
||||
if ($prevOptgroupLi.length > 0){
|
||||
$nextElem = $prevOptgroupLi.find(this.elemsSelector).last();
|
||||
} else {
|
||||
$nextElem = $elems.last();
|
||||
}
|
||||
} else {
|
||||
$nextElem = $elems.last();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($nextElem.length > 0){
|
||||
$nextElem.addClass('ms-hover');
|
||||
var scrollTo = $list.scrollTop() + $nextElem.position().top -
|
||||
containerHeight / 2 + elemHeight / 2;
|
||||
|
||||
$list.scrollTop(scrollTo);
|
||||
}
|
||||
},
|
||||
|
||||
'selectHighlighted' : function($list){
|
||||
var $elems = $list.find(this.elemsSelector),
|
||||
$highlightedElem = $elems.filter('.ms-hover').first();
|
||||
|
||||
if ($highlightedElem.length > 0){
|
||||
if ($list.parent().hasClass('ms-selectable')){
|
||||
this.select($highlightedElem.data('ms-value'));
|
||||
} else {
|
||||
this.deselect($highlightedElem.data('ms-value'));
|
||||
}
|
||||
$elems.removeClass('ms-hover');
|
||||
}
|
||||
},
|
||||
|
||||
'switchList' : function($list){
|
||||
$list.blur();
|
||||
if ($list.parent().hasClass('ms-selectable')){
|
||||
this.$selectionUl.focus();
|
||||
} else {
|
||||
this.$selectableUl.focus();
|
||||
}
|
||||
},
|
||||
|
||||
'activeMouse' : function($list){
|
||||
var that = this;
|
||||
|
||||
$list.on('mousemove', function(){
|
||||
var elems = $list.find(that.elemsSelector);
|
||||
|
||||
elems.on('mouseenter', function(){
|
||||
elems.removeClass('ms-hover');
|
||||
$(this).addClass('ms-hover');
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'refresh' : function() {
|
||||
this.destroy();
|
||||
this.$element.multiSelect(this.options);
|
||||
},
|
||||
|
||||
'destroy' : function(){
|
||||
$("#ms-"+this.$element.attr("id")).remove();
|
||||
this.$element.removeData('multiselect');
|
||||
},
|
||||
|
||||
'select' : function(value, method){
|
||||
if (typeof value === 'string'){ value = [value]; }
|
||||
|
||||
var that = this,
|
||||
ms = this.$element,
|
||||
msIds = $.map(value, function(val){ return(that.sanitize(val, that.sanitizeRegexp)); }),
|
||||
selectables = this.$selectableUl.find('#' + msIds.join('-selectable, #')+'-selectable').filter(':not(.'+that.options.disabledClass+')'),
|
||||
selections = this.$selectionUl.find('#' + msIds.join('-selection, #') + '-selection').filter(':not(.'+that.options.disabledClass+')'),
|
||||
options = ms.find('option:not(:disabled)').filter(function(){ return($.inArray(this.value, value) > -1); });
|
||||
|
||||
if (selectables.length > 0){
|
||||
selectables.addClass('ms-selected').hide();
|
||||
selections.addClass('ms-selected').show();
|
||||
options.prop('selected', true);
|
||||
|
||||
var selectableOptgroups = that.$selectableUl.children('.ms-optgroup-container');
|
||||
if (selectableOptgroups.length > 0){
|
||||
selectableOptgroups.each(function(){
|
||||
var selectablesLi = $(this).find('.ms-elem-selectable');
|
||||
if (selectablesLi.length === selectablesLi.filter('.ms-selected').length){
|
||||
$(this).find('.ms-optgroup-label').hide();
|
||||
}
|
||||
});
|
||||
|
||||
var selectionOptgroups = that.$selectionUl.children('.ms-optgroup-container');
|
||||
selectionOptgroups.each(function(){
|
||||
var selectionsLi = $(this).find('.ms-elem-selection');
|
||||
if (selectionsLi.filter('.ms-selected').length > 0){
|
||||
$(this).find('.ms-optgroup-label').show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (that.options.keepOrder){
|
||||
var selectionLiLast = that.$selectionUl.find('.ms-selected');
|
||||
if((selectionLiLast.length > 1) && (selectionLiLast.last().get(0) != selections.get(0))) {
|
||||
selections.insertAfter(selectionLiLast.last());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (method !== 'init'){
|
||||
ms.trigger('change');
|
||||
if (typeof that.options.afterSelect === 'function') {
|
||||
that.options.afterSelect.call(this, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'deselect' : function(value){
|
||||
if (typeof value === 'string'){ value = [value]; }
|
||||
|
||||
var that = this,
|
||||
ms = this.$element,
|
||||
msIds = $.map(value, function(val){ return(that.sanitize(val, that.sanitizeRegexp)); }),
|
||||
selectables = this.$selectableUl.find('#' + msIds.join('-selectable, #')+'-selectable'),
|
||||
selections = this.$selectionUl.find('#' + msIds.join('-selection, #')+'-selection').filter('.ms-selected'),
|
||||
options = ms.find('option').filter(function(){ return($.inArray(this.value, value) > -1); });
|
||||
|
||||
if (selections.length > 0){
|
||||
selectables.removeClass('ms-selected').show();
|
||||
selections.removeClass('ms-selected').hide();
|
||||
options.prop('selected', false);
|
||||
|
||||
var selectableOptgroups = that.$selectableUl.children('.ms-optgroup-container');
|
||||
if (selectableOptgroups.length > 0){
|
||||
selectableOptgroups.each(function(){
|
||||
var selectablesLi = $(this).find('.ms-elem-selectable');
|
||||
if (selectablesLi.filter(':not(.ms-selected)').length > 0){
|
||||
$(this).find('.ms-optgroup-label').show();
|
||||
}
|
||||
});
|
||||
|
||||
var selectionOptgroups = that.$selectionUl.children('.ms-optgroup-container');
|
||||
selectionOptgroups.each(function(){
|
||||
var selectionsLi = $(this).find('.ms-elem-selection');
|
||||
if (selectionsLi.filter('.ms-selected').length === 0){
|
||||
$(this).find('.ms-optgroup-label').hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
ms.trigger('change');
|
||||
if (typeof that.options.afterDeselect === 'function') {
|
||||
that.options.afterDeselect.call(this, value);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'select_all' : function(){
|
||||
var ms = this.$element,
|
||||
values = ms.val();
|
||||
|
||||
ms.find('option:not(":disabled")').prop('selected', true);
|
||||
this.$selectableUl.find('.ms-elem-selectable').filter(':not(.'+this.options.disabledClass+')').addClass('ms-selected').hide();
|
||||
this.$selectionUl.find('.ms-optgroup-label').show();
|
||||
this.$selectableUl.find('.ms-optgroup-label').hide();
|
||||
this.$selectionUl.find('.ms-elem-selection').filter(':not(.'+this.options.disabledClass+')').addClass('ms-selected').show();
|
||||
this.$selectionUl.focus();
|
||||
ms.trigger('change');
|
||||
if (typeof this.options.afterSelect === 'function') {
|
||||
var selectedValues = $.grep(ms.val(), function(item){
|
||||
return $.inArray(item, values) < 0;
|
||||
});
|
||||
this.options.afterSelect.call(this, selectedValues);
|
||||
}
|
||||
},
|
||||
|
||||
'deselect_all' : function(){
|
||||
var ms = this.$element,
|
||||
values = ms.val();
|
||||
|
||||
ms.find('option').prop('selected', false);
|
||||
this.$selectableUl.find('.ms-elem-selectable').removeClass('ms-selected').show();
|
||||
this.$selectionUl.find('.ms-optgroup-label').hide();
|
||||
this.$selectableUl.find('.ms-optgroup-label').show();
|
||||
this.$selectionUl.find('.ms-elem-selection').removeClass('ms-selected').hide();
|
||||
this.$selectableUl.focus();
|
||||
ms.trigger('change');
|
||||
if (typeof this.options.afterDeselect === 'function') {
|
||||
this.options.afterDeselect.call(this, values);
|
||||
}
|
||||
},
|
||||
|
||||
sanitize: function(value, reg){
|
||||
return(value.replace(reg, '_'));
|
||||
}
|
||||
};
|
||||
|
||||
/* MULTISELECT PLUGIN DEFINITION
|
||||
* ======================= */
|
||||
|
||||
$.fn.multiSelect = function () {
|
||||
var option = arguments[0],
|
||||
args = arguments;
|
||||
|
||||
return this.each(function () {
|
||||
var $this = $(this),
|
||||
data = $this.data('multiselect'),
|
||||
options = $.extend({}, $.fn.multiSelect.defaults, $this.data(), typeof option === 'object' && option);
|
||||
|
||||
if (!data){ $this.data('multiselect', (data = new MultiSelect(this, options))); }
|
||||
|
||||
if (typeof option === 'string'){
|
||||
data[option](args[1]);
|
||||
} else {
|
||||
data.init();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.multiSelect.defaults = {
|
||||
selectableOptgroup: false,
|
||||
disabledClass : 'disabled',
|
||||
dblClick : false,
|
||||
keepOrder: false
|
||||
};
|
||||
|
||||
$.fn.multiSelect.Constructor = MultiSelect;
|
||||
|
||||
}(window.jQuery);
|
||||
@@ -0,0 +1,181 @@
|
||||
(function($, window, document, undefined) {
|
||||
$.fn.quicksearch = function (target, opt) {
|
||||
|
||||
var timeout, cache, rowcache, jq_results, val = '', e = this, options = $.extend({
|
||||
delay: 100,
|
||||
selector: null,
|
||||
stripeRows: null,
|
||||
loader: null,
|
||||
noResults: '',
|
||||
matchedResultsCount: 0,
|
||||
bind: 'keyup',
|
||||
onBefore: function () {
|
||||
return;
|
||||
},
|
||||
onAfter: function () {
|
||||
return;
|
||||
},
|
||||
show: function () {
|
||||
this.style.display = "";
|
||||
},
|
||||
hide: function () {
|
||||
this.style.display = "none";
|
||||
},
|
||||
prepareQuery: function (val) {
|
||||
return val.toLowerCase().split(' ');
|
||||
},
|
||||
testQuery: function (query, txt, _row) {
|
||||
for (var i = 0; i < query.length; i += 1) {
|
||||
if (txt.indexOf(query[i]) === -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, opt);
|
||||
|
||||
this.go = function () {
|
||||
|
||||
var i = 0,
|
||||
numMatchedRows = 0,
|
||||
noresults = true,
|
||||
query = options.prepareQuery(val),
|
||||
val_empty = (val.replace(' ', '').length === 0);
|
||||
|
||||
for (var i = 0, len = rowcache.length; i < len; i++) {
|
||||
if (val_empty || options.testQuery(query, cache[i], rowcache[i])) {
|
||||
options.show.apply(rowcache[i]);
|
||||
noresults = false;
|
||||
numMatchedRows++;
|
||||
} else {
|
||||
options.hide.apply(rowcache[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (noresults) {
|
||||
this.results(false);
|
||||
} else {
|
||||
this.results(true);
|
||||
this.stripe();
|
||||
}
|
||||
|
||||
this.matchedResultsCount = numMatchedRows;
|
||||
this.loader(false);
|
||||
options.onAfter();
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/*
|
||||
* External API so that users can perform search programatically.
|
||||
* */
|
||||
this.search = function (submittedVal) {
|
||||
val = submittedVal;
|
||||
e.trigger();
|
||||
};
|
||||
|
||||
/*
|
||||
* External API to get the number of matched results as seen in
|
||||
* https://github.com/ruiz107/quicksearch/commit/f78dc440b42d95ce9caed1d087174dd4359982d6
|
||||
* */
|
||||
this.currentMatchedResults = function() {
|
||||
return this.matchedResultsCount;
|
||||
};
|
||||
|
||||
this.stripe = function () {
|
||||
|
||||
if (typeof options.stripeRows === "object" && options.stripeRows !== null)
|
||||
{
|
||||
var joined = options.stripeRows.join(' ');
|
||||
var stripeRows_length = options.stripeRows.length;
|
||||
|
||||
jq_results.not(':hidden').each(function (i) {
|
||||
$(this).removeClass(joined).addClass(options.stripeRows[i % stripeRows_length]);
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
this.strip_html = function (input) {
|
||||
var output = input.replace(new RegExp('<[^<]+\>', 'g'), "");
|
||||
output = $.trim(output.toLowerCase());
|
||||
return output;
|
||||
};
|
||||
|
||||
this.results = function (bool) {
|
||||
if (typeof options.noResults === "string" && options.noResults !== "") {
|
||||
if (bool) {
|
||||
$(options.noResults).hide();
|
||||
} else {
|
||||
$(options.noResults).show();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
this.loader = function (bool) {
|
||||
if (typeof options.loader === "string" && options.loader !== "") {
|
||||
(bool) ? $(options.loader).show() : $(options.loader).hide();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
this.cache = function () {
|
||||
|
||||
jq_results = $(target);
|
||||
|
||||
if (typeof options.noResults === "string" && options.noResults !== "") {
|
||||
jq_results = jq_results.not(options.noResults);
|
||||
}
|
||||
|
||||
var t = (typeof options.selector === "string") ? jq_results.find(options.selector) : $(target).not(options.noResults);
|
||||
cache = t.map(function () {
|
||||
return e.strip_html(this.innerHTML);
|
||||
});
|
||||
|
||||
rowcache = jq_results.map(function () {
|
||||
return this;
|
||||
});
|
||||
|
||||
/*
|
||||
* Modified fix for sync-ing "val".
|
||||
* Original fix https://github.com/michaellwest/quicksearch/commit/4ace4008d079298a01f97f885ba8fa956a9703d1
|
||||
* */
|
||||
val = val || this.val() || "";
|
||||
|
||||
return this.go();
|
||||
};
|
||||
|
||||
this.trigger = function () {
|
||||
this.loader(true);
|
||||
options.onBefore();
|
||||
|
||||
window.clearTimeout(timeout);
|
||||
timeout = window.setTimeout(function () {
|
||||
e.go();
|
||||
}, options.delay);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
this.cache();
|
||||
this.results(true);
|
||||
this.stripe();
|
||||
this.loader(false);
|
||||
|
||||
return this.each(function () {
|
||||
|
||||
/*
|
||||
* Changed from .bind to .on.
|
||||
* */
|
||||
$(this).on(options.bind, function () {
|
||||
|
||||
val = $(this).val();
|
||||
e.trigger();
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
}(jQuery, this, document));
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "multi-select",
|
||||
"title": "multiselect",
|
||||
"description": "This is a user-friendlier drop-in replacement for the standard <select> with multiple attribute activated.",
|
||||
"keywords": [
|
||||
"multiselect",
|
||||
"select",
|
||||
"multiple",
|
||||
"form"
|
||||
],
|
||||
"version": "0.9.8",
|
||||
"author": {
|
||||
"name": "lou",
|
||||
"email" : "louiscuny@gmail.com",
|
||||
"url": "https://github.com/lou"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Louis CUNY",
|
||||
"email": "louiscuny@gmail.com",
|
||||
"url": "https://github.com/lou"
|
||||
}
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "wtfpl",
|
||||
"url": "http://sam.zoy.org/wtfpl/COPYING"
|
||||
}
|
||||
],
|
||||
"bugs": "https://github.com/lou/multi-select/issues",
|
||||
"homepage": "http://loudev.com/",
|
||||
"docs": "http://loudev.com/",
|
||||
"download": "https://github.com/lou/multi-select/archive/master.zip",
|
||||
"dependencies": {
|
||||
"jquery": ">= 1.8"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Spec Runner</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.2.0/jasmine_favicon.png">
|
||||
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.2.0/jasmine.css">
|
||||
|
||||
<script type="text/javascript" src="src/jquery.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-jquery.js"></script>
|
||||
<!-- include source files here... -->
|
||||
<script type="text/javascript" src="spec/SpecHelper.js"></script>
|
||||
<script type="text/javascript" src="spec/multiSelectSpec.js"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="../js/jquery.multi-select.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
|
||||
var htmlReporter = new jasmine.HtmlReporter();
|
||||
|
||||
jasmineEnv.addReporter(htmlReporter);
|
||||
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return htmlReporter.specFilter(spec);
|
||||
};
|
||||
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
execJasmine();
|
||||
};
|
||||
|
||||
function execJasmine() {
|
||||
jasmineEnv.execute();
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2008-2011 Pivotal Labs
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,616 @@
|
||||
jasmine.HtmlReporterHelpers = {};
|
||||
|
||||
jasmine.HtmlReporterHelpers.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.HtmlReporterHelpers.getSpecStatus = function(child) {
|
||||
var results = child.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
|
||||
return status;
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
|
||||
var parentDiv = this.dom.summary;
|
||||
var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
|
||||
var parent = child[parentSuite];
|
||||
|
||||
if (parent) {
|
||||
if (typeof this.views.suites[parent.id] == 'undefined') {
|
||||
this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
|
||||
}
|
||||
parentDiv = this.views.suites[parent.id].element;
|
||||
}
|
||||
|
||||
parentDiv.appendChild(childElement);
|
||||
};
|
||||
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
|
||||
for(var fn in jasmine.HtmlReporterHelpers) {
|
||||
ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter = function(_doc) {
|
||||
var self = this;
|
||||
var doc = _doc || window.document;
|
||||
|
||||
var reporterView;
|
||||
|
||||
var dom = {};
|
||||
|
||||
// Jasmine Reporter Public Interface
|
||||
self.logRunningSpecs = false;
|
||||
|
||||
self.reportRunnerStarting = function(runner) {
|
||||
var specs = runner.specs() || [];
|
||||
|
||||
if (specs.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
createReporterDom(runner.env.versionString());
|
||||
doc.body.appendChild(dom.reporter);
|
||||
|
||||
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
|
||||
reporterView.addSpecs(specs, self.specFilter);
|
||||
};
|
||||
|
||||
self.reportRunnerResults = function(runner) {
|
||||
reporterView && reporterView.complete();
|
||||
};
|
||||
|
||||
self.reportSuiteResults = function(suite) {
|
||||
reporterView.suiteComplete(suite);
|
||||
};
|
||||
|
||||
self.reportSpecStarting = function(spec) {
|
||||
if (self.logRunningSpecs) {
|
||||
self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
self.reportSpecResults = function(spec) {
|
||||
reporterView.specComplete(spec);
|
||||
};
|
||||
|
||||
self.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
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.specFilter = function(spec) {
|
||||
if (!focusedSpecName()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return spec.getFullName().indexOf(focusedSpecName()) === 0;
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
function focusedSpecName() {
|
||||
var specName;
|
||||
|
||||
(function memoizeFocusedSpec() {
|
||||
if (specName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var paramMap = [];
|
||||
var params = doc.location.search.substring(1).split('&');
|
||||
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
specName = paramMap.spec;
|
||||
})();
|
||||
|
||||
return specName;
|
||||
}
|
||||
|
||||
function createReporterDom(version) {
|
||||
dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
|
||||
dom.banner = self.createDom('div', { className: 'banner' },
|
||||
self.createDom('span', { className: 'title' }, "Jasmine "),
|
||||
self.createDom('span', { className: 'version' }, version)),
|
||||
|
||||
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
|
||||
dom.alert = self.createDom('div', {className: 'alert'}),
|
||||
dom.results = self.createDom('div', {className: 'results'},
|
||||
dom.summary = self.createDom('div', { className: 'summary' }),
|
||||
dom.details = self.createDom('div', { id: 'details' }))
|
||||
);
|
||||
}
|
||||
};
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporter.ReporterView = function(dom) {
|
||||
this.startedAt = new Date();
|
||||
this.runningSpecCount = 0;
|
||||
this.completeSpecCount = 0;
|
||||
this.passedCount = 0;
|
||||
this.failedCount = 0;
|
||||
this.skippedCount = 0;
|
||||
|
||||
this.createResultsMenu = function() {
|
||||
this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
|
||||
this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
|
||||
' | ',
|
||||
this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
|
||||
|
||||
this.summaryMenuItem.onclick = function() {
|
||||
dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
|
||||
};
|
||||
|
||||
this.detailsMenuItem.onclick = function() {
|
||||
showDetails();
|
||||
};
|
||||
};
|
||||
|
||||
this.addSpecs = function(specs, specFilter) {
|
||||
this.totalSpecCount = specs.length;
|
||||
|
||||
this.views = {
|
||||
specs: {},
|
||||
suites: {}
|
||||
};
|
||||
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
var spec = specs[i];
|
||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
|
||||
if (specFilter(spec)) {
|
||||
this.runningSpecCount++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.specComplete = function(spec) {
|
||||
this.completeSpecCount++;
|
||||
|
||||
if (isUndefined(this.views.specs[spec.id])) {
|
||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
|
||||
}
|
||||
|
||||
var specView = this.views.specs[spec.id];
|
||||
|
||||
switch (specView.status()) {
|
||||
case 'passed':
|
||||
this.passedCount++;
|
||||
break;
|
||||
|
||||
case 'failed':
|
||||
this.failedCount++;
|
||||
break;
|
||||
|
||||
case 'skipped':
|
||||
this.skippedCount++;
|
||||
break;
|
||||
}
|
||||
|
||||
specView.refresh();
|
||||
this.refresh();
|
||||
};
|
||||
|
||||
this.suiteComplete = function(suite) {
|
||||
var suiteView = this.views.suites[suite.id];
|
||||
if (isUndefined(suiteView)) {
|
||||
return;
|
||||
}
|
||||
suiteView.refresh();
|
||||
};
|
||||
|
||||
this.refresh = function() {
|
||||
|
||||
if (isUndefined(this.resultsMenu)) {
|
||||
this.createResultsMenu();
|
||||
}
|
||||
|
||||
// currently running UI
|
||||
if (isUndefined(this.runningAlert)) {
|
||||
this.runningAlert = this.createDom('a', {href: "?", className: "runningAlert bar"});
|
||||
dom.alert.appendChild(this.runningAlert);
|
||||
}
|
||||
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
|
||||
|
||||
// skipped specs UI
|
||||
if (isUndefined(this.skippedAlert)) {
|
||||
this.skippedAlert = this.createDom('a', {href: "?", className: "skippedAlert bar"});
|
||||
}
|
||||
|
||||
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
||||
|
||||
if (this.skippedCount === 1 && isDefined(dom.alert)) {
|
||||
dom.alert.appendChild(this.skippedAlert);
|
||||
}
|
||||
|
||||
// passing specs UI
|
||||
if (isUndefined(this.passedAlert)) {
|
||||
this.passedAlert = this.createDom('span', {href: "?", className: "passingAlert bar"});
|
||||
}
|
||||
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
|
||||
|
||||
// failing specs UI
|
||||
if (isUndefined(this.failedAlert)) {
|
||||
this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
|
||||
}
|
||||
this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
|
||||
|
||||
if (this.failedCount === 1 && isDefined(dom.alert)) {
|
||||
dom.alert.appendChild(this.failedAlert);
|
||||
dom.alert.appendChild(this.resultsMenu);
|
||||
}
|
||||
|
||||
// summary info
|
||||
this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
|
||||
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
|
||||
};
|
||||
|
||||
this.complete = function() {
|
||||
dom.alert.removeChild(this.runningAlert);
|
||||
|
||||
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
||||
|
||||
if (this.failedCount === 0) {
|
||||
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
|
||||
} else {
|
||||
showDetails();
|
||||
}
|
||||
|
||||
dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function showDetails() {
|
||||
if (dom.reporter.className.search(/showDetails/) === -1) {
|
||||
dom.reporter.className += " showDetails";
|
||||
}
|
||||
}
|
||||
|
||||
function isUndefined(obj) {
|
||||
return typeof obj === 'undefined';
|
||||
}
|
||||
|
||||
function isDefined(obj) {
|
||||
return !isUndefined(obj);
|
||||
}
|
||||
|
||||
function specPluralizedFor(count) {
|
||||
var str = count + " spec";
|
||||
if (count > 1) {
|
||||
str += "s"
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
|
||||
|
||||
|
||||
jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
|
||||
this.spec = spec;
|
||||
this.dom = dom;
|
||||
this.views = views;
|
||||
|
||||
this.symbol = this.createDom('li', { className: 'pending' });
|
||||
this.dom.symbolSummary.appendChild(this.symbol);
|
||||
|
||||
this.summary = this.createDom('div', { className: 'specSummary' },
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
|
||||
title: this.spec.getFullName()
|
||||
}, this.spec.description)
|
||||
);
|
||||
|
||||
this.detail = this.createDom('div', { className: 'specDetail' },
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
|
||||
title: this.spec.getFullName()
|
||||
}, this.spec.getFullName())
|
||||
);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.status = function() {
|
||||
return this.getSpecStatus(this.spec);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
|
||||
this.symbol.className = this.status();
|
||||
|
||||
switch (this.status()) {
|
||||
case 'skipped':
|
||||
break;
|
||||
|
||||
case 'passed':
|
||||
this.appendSummaryToSuiteDiv();
|
||||
break;
|
||||
|
||||
case 'failed':
|
||||
this.appendSummaryToSuiteDiv();
|
||||
this.appendFailureDetail();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
|
||||
this.summary.className += ' ' + this.status();
|
||||
this.appendToSummary(this.spec, this.summary);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
|
||||
this.detail.className += ' ' + this.status();
|
||||
|
||||
var resultItems = this.spec.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) {
|
||||
this.detail.appendChild(messagesDiv);
|
||||
this.dom.details.appendChild(this.detail);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
|
||||
this.suite = suite;
|
||||
this.dom = dom;
|
||||
this.views = views;
|
||||
|
||||
this.element = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(this.suite.getFullName()) }, this.suite.description)
|
||||
);
|
||||
|
||||
this.appendToSummary(this.suite, this.element);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SuiteView.prototype.status = function() {
|
||||
return this.getSpecStatus(this.suite);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
|
||||
this.element.className += " " + this.status();
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
|
||||
|
||||
/* @deprecated Use jasmine.HtmlReporter instead
|
||||
*/
|
||||
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', { id: 'TrivialReporter', className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
this.createDom('span', { className: 'title' }, "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;
|
||||
};
|
||||
@@ -0,0 +1,81 @@
|
||||
body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
|
||||
|
||||
#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
|
||||
#HTMLReporter a { text-decoration: none; }
|
||||
#HTMLReporter a:hover { text-decoration: underline; }
|
||||
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
|
||||
#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
|
||||
#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
|
||||
#HTMLReporter .version { color: #aaaaaa; }
|
||||
#HTMLReporter .banner { margin-top: 14px; }
|
||||
#HTMLReporter .duration { color: #aaaaaa; float: right; }
|
||||
#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
|
||||
#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
|
||||
#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
|
||||
#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
|
||||
#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
|
||||
#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
|
||||
#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
|
||||
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
|
||||
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
|
||||
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
|
||||
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
|
||||
#HTMLReporter .runningAlert { background-color: #666666; }
|
||||
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
|
||||
#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
|
||||
#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
|
||||
#HTMLReporter .passingAlert { background-color: #a6b779; }
|
||||
#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
|
||||
#HTMLReporter .failingAlert { background-color: #cf867e; }
|
||||
#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
|
||||
#HTMLReporter .results { margin-top: 14px; }
|
||||
#HTMLReporter #details { display: none; }
|
||||
#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
|
||||
#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
|
||||
#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
|
||||
#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
#HTMLReporter.showDetails .summary { display: none; }
|
||||
#HTMLReporter.showDetails #details { display: block; }
|
||||
#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
#HTMLReporter .summary { margin-top: 14px; }
|
||||
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
|
||||
#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
|
||||
#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
|
||||
#HTMLReporter .description + .suite { margin-top: 0; }
|
||||
#HTMLReporter .suite { margin-top: 14px; }
|
||||
#HTMLReporter .suite a { color: #333333; }
|
||||
#HTMLReporter #details .specDetail { margin-bottom: 28px; }
|
||||
#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
|
||||
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
|
||||
#HTMLReporter .resultMessage span.result { display: block; }
|
||||
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
|
||||
|
||||
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
|
||||
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
|
||||
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
|
||||
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
|
||||
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
|
||||
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
|
||||
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
|
||||
#TrivialReporter .runner.running { background-color: yellow; }
|
||||
#TrivialReporter .options { text-align: right; font-size: .8em; }
|
||||
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
|
||||
#TrivialReporter .suite .suite { margin: 5px; }
|
||||
#TrivialReporter .suite.passed { background-color: #dfd; }
|
||||
#TrivialReporter .suite.failed { background-color: #fdd; }
|
||||
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
|
||||
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
|
||||
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
|
||||
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
|
||||
#TrivialReporter .spec.skipped { background-color: #bbb; }
|
||||
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
|
||||
#TrivialReporter .passed { background-color: #cfc; display: none; }
|
||||
#TrivialReporter .failed { background-color: #fbb; }
|
||||
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
|
||||
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
|
||||
#TrivialReporter .resultMessage .mismatch { color: black; }
|
||||
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
|
||||
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
|
||||
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
|
||||
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
|
||||
#TrivialReporter .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
400
wwwroot/BackendScript/assets/jquery-multi-select/test/lib/jasmine-jquery.js
vendored
Normal file
400
wwwroot/BackendScript/assets/jquery-multi-select/test/lib/jasmine-jquery.js
vendored
Normal file
@@ -0,0 +1,400 @@
|
||||
var readFixtures = function() {
|
||||
return jasmine.getFixtures().proxyCallTo_('read', arguments)
|
||||
}
|
||||
|
||||
var preloadFixtures = function() {
|
||||
jasmine.getFixtures().proxyCallTo_('preload', arguments)
|
||||
}
|
||||
|
||||
var loadFixtures = function() {
|
||||
jasmine.getFixtures().proxyCallTo_('load', arguments)
|
||||
}
|
||||
|
||||
var appendLoadFixtures = function() {
|
||||
jasmine.getFixtures().proxyCallTo_('appendLoad', arguments)
|
||||
}
|
||||
|
||||
var setFixtures = function(html) {
|
||||
jasmine.getFixtures().proxyCallTo_('set', arguments)
|
||||
}
|
||||
|
||||
var appendSetFixtures = function() {
|
||||
jasmine.getFixtures().proxyCallTo_('appendSet', arguments)
|
||||
}
|
||||
|
||||
var sandbox = function(attributes) {
|
||||
return jasmine.getFixtures().sandbox(attributes)
|
||||
}
|
||||
|
||||
var spyOnEvent = function(selector, eventName) {
|
||||
return jasmine.JQuery.events.spyOn($(selector).selector, eventName)
|
||||
}
|
||||
|
||||
jasmine.getFixtures = function() {
|
||||
return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures()
|
||||
}
|
||||
|
||||
jasmine.Fixtures = function() {
|
||||
this.containerId = 'jasmine-fixtures'
|
||||
this.fixturesCache_ = {}
|
||||
this.fixturesPath = 'spec/javascripts/fixtures'
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.set = function(html) {
|
||||
this.cleanUp()
|
||||
this.createContainer_(html)
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.appendSet= function(html) {
|
||||
this.addToContainer_(html)
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.preload = function() {
|
||||
this.read.apply(this, arguments)
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.load = function() {
|
||||
this.cleanUp()
|
||||
this.createContainer_(this.read.apply(this, arguments))
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.appendLoad = function() {
|
||||
this.addToContainer_(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() {
|
||||
jQuery('#' + this.containerId).remove()
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.sandbox = function(attributes) {
|
||||
var attributesToSet = attributes || {}
|
||||
return jQuery('<div id="sandbox" />').attr(attributesToSet)
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.createContainer_ = function(html) {
|
||||
var container
|
||||
if(html instanceof jQuery) {
|
||||
container = jQuery('<div id="' + this.containerId + '" />')
|
||||
container.html(html)
|
||||
} else {
|
||||
container = '<div id="' + this.containerId + '">' + html + '</div>'
|
||||
}
|
||||
jQuery('body').append(container)
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.addToContainer_ = function(html){
|
||||
var container = jQuery('body').find('#'+this.containerId).append(html)
|
||||
if(!container.length){
|
||||
this.createContainer_(html)
|
||||
}
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
|
||||
if (typeof this.fixturesCache_[url] === 'undefined') {
|
||||
this.loadFixtureIntoCache_(url)
|
||||
}
|
||||
return this.fixturesCache_[url]
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
|
||||
var url = this.makeFixtureUrl_(relativeUrl)
|
||||
var request = new XMLHttpRequest()
|
||||
request.open("GET", url + "?" + new Date().getTime(), false)
|
||||
request.send(null)
|
||||
this.fixturesCache_[relativeUrl] = request.responseText
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.makeFixtureUrl_ = function(relativeUrl){
|
||||
return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
|
||||
}
|
||||
|
||||
jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
|
||||
return this[methodName].apply(this, passedArguments)
|
||||
}
|
||||
|
||||
|
||||
jasmine.JQuery = function() {}
|
||||
|
||||
jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
|
||||
return jQuery('<div/>').append(html).html()
|
||||
}
|
||||
|
||||
jasmine.JQuery.elementToString = function(element) {
|
||||
var domEl = $(element).get(0)
|
||||
if (domEl == undefined || domEl.cloneNode)
|
||||
return jQuery('<div />').append($(element).clone()).html()
|
||||
else
|
||||
return element.toString()
|
||||
}
|
||||
|
||||
jasmine.JQuery.matchersClass = {};
|
||||
|
||||
!function(namespace) {
|
||||
var data = {
|
||||
spiedEvents: {},
|
||||
handlers: []
|
||||
}
|
||||
|
||||
namespace.events = {
|
||||
spyOn: function(selector, eventName) {
|
||||
var handler = function(e) {
|
||||
data.spiedEvents[[selector, eventName]] = e
|
||||
}
|
||||
jQuery(selector).bind(eventName, handler)
|
||||
data.handlers.push(handler)
|
||||
return {
|
||||
selector: selector,
|
||||
eventName: eventName,
|
||||
handler: handler,
|
||||
reset: function(){
|
||||
delete data.spiedEvents[[this.selector, this.eventName]];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
wasTriggered: function(selector, eventName) {
|
||||
return !!(data.spiedEvents[[selector, eventName]])
|
||||
},
|
||||
|
||||
wasPrevented: function(selector, eventName) {
|
||||
return data.spiedEvents[[selector, eventName]].isDefaultPrevented()
|
||||
},
|
||||
|
||||
cleanUp: function() {
|
||||
data.spiedEvents = {}
|
||||
data.handlers = []
|
||||
}
|
||||
}
|
||||
}(jasmine.JQuery)
|
||||
|
||||
!function(){
|
||||
var jQueryMatchers = {
|
||||
toHaveClass: function(className) {
|
||||
return this.actual.hasClass(className)
|
||||
},
|
||||
|
||||
toHaveCss: function(css){
|
||||
for (var prop in css){
|
||||
if (this.actual.css(prop) !== css[prop]) return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
|
||||
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 $(document).find(this.actual).length
|
||||
},
|
||||
|
||||
toHaveAttr: function(attributeName, expectedAttributeValue) {
|
||||
return hasProperty(this.actual.attr(attributeName), expectedAttributeValue)
|
||||
},
|
||||
|
||||
toHaveProp: function(propertyName, expectedPropertyValue) {
|
||||
return hasProperty(this.actual.prop(propertyName), expectedPropertyValue)
|
||||
},
|
||||
|
||||
toHaveId: function(id) {
|
||||
return this.actual.attr('id') == id
|
||||
},
|
||||
|
||||
toHaveHtml: function(html) {
|
||||
return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html)
|
||||
},
|
||||
|
||||
toContainHtml: function(html){
|
||||
var actualHtml = this.actual.html()
|
||||
var expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html)
|
||||
return (actualHtml.indexOf(expectedHtml) >= 0)
|
||||
},
|
||||
|
||||
toHaveText: function(text) {
|
||||
var trimmedText = $.trim(this.actual.text())
|
||||
if (text && jQuery.isFunction(text.test)) {
|
||||
return text.test(trimmedText)
|
||||
} else {
|
||||
return trimmedText == 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).length
|
||||
},
|
||||
|
||||
toBeDisabled: function(selector){
|
||||
return this.actual.is(':disabled')
|
||||
},
|
||||
|
||||
toBeFocused: function(selector) {
|
||||
return this.actual.is(':focus')
|
||||
},
|
||||
|
||||
toHandle: function(event) {
|
||||
|
||||
var events = this.actual.data('events')
|
||||
|
||||
if(!events || !event || typeof event !== "string") {
|
||||
return false
|
||||
}
|
||||
|
||||
var namespaces = event.split(".")
|
||||
var eventType = namespaces.shift()
|
||||
var sortedNamespaces = namespaces.slice(0).sort()
|
||||
var namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)")
|
||||
|
||||
if(events[eventType] && namespaces.length) {
|
||||
for(var i = 0; i < events[eventType].length; i++) {
|
||||
var namespace = events[eventType][i].namespace
|
||||
if(namespaceRegExp.test(namespace)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return events[eventType] && events[eventType].length > 0
|
||||
}
|
||||
},
|
||||
|
||||
// tests the existence of a specific event binding + handler
|
||||
toHandleWith: function(eventName, eventHandler) {
|
||||
var stack = this.actual.data("events")[eventName]
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
if (stack[i].handler == eventHandler) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
&& (this.actual instanceof jQuery
|
||||
|| jasmine.isDomNode(this.actual))) {
|
||||
this.actual = $(this.actual)
|
||||
var result = jQueryMatchers[methodName].apply(this, arguments)
|
||||
var element;
|
||||
if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML")
|
||||
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)
|
||||
this.addMatchers({
|
||||
toHaveBeenTriggeredOn: function(selector) {
|
||||
this.message = function() {
|
||||
return [
|
||||
"Expected event " + this.actual + " to have been triggered on " + selector,
|
||||
"Expected event " + this.actual + " not to have been triggered on " + selector
|
||||
]
|
||||
}
|
||||
return jasmine.JQuery.events.wasTriggered($(selector).selector, this.actual)
|
||||
}
|
||||
})
|
||||
this.addMatchers({
|
||||
toHaveBeenTriggered: function(){
|
||||
var eventName = this.actual.eventName,
|
||||
selector = this.actual.selector;
|
||||
this.message = function() {
|
||||
return [
|
||||
"Expected event " + eventName + " to have been triggered on " + selector,
|
||||
"Expected event " + eventName + " not to have been triggered on " + selector
|
||||
]
|
||||
}
|
||||
return jasmine.JQuery.events.wasTriggered(selector, eventName)
|
||||
}
|
||||
})
|
||||
this.addMatchers({
|
||||
toHaveBeenPreventedOn: function(selector) {
|
||||
this.message = function() {
|
||||
return [
|
||||
"Expected event " + this.actual + " to have been prevented on " + selector,
|
||||
"Expected event " + this.actual + " not to have been prevented on " + selector
|
||||
]
|
||||
}
|
||||
return jasmine.JQuery.events.wasPrevented($(selector).selector, this.actual)
|
||||
}
|
||||
})
|
||||
this.addMatchers({
|
||||
toHaveBeenPrevented: function() {
|
||||
var eventName = this.actual.eventName,
|
||||
selector = this.actual.selector;
|
||||
this.message = function() {
|
||||
return [
|
||||
"Expected event " + eventName + " to have been prevented on " + selector,
|
||||
"Expected event " + eventName + " not to have been prevented on " + selector
|
||||
]
|
||||
}
|
||||
return jasmine.JQuery.events.wasPrevented(selector, eventName)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
jasmine.getFixtures().cleanUp()
|
||||
jasmine.JQuery.events.cleanUp()
|
||||
})
|
||||
19
wwwroot/BackendScript/assets/jquery-multi-select/test/spec/SpecHelper.js
vendored
Normal file
19
wwwroot/BackendScript/assets/jquery-multi-select/test/spec/SpecHelper.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var select;
|
||||
var msContainer;
|
||||
|
||||
beforeEach(function() {
|
||||
$('<select id="multi-select" multiple="multiple" name="test[]"></select>').appendTo('body');
|
||||
for (var i=1; i <= 10; i++) {
|
||||
$('<option value="value'+i+'">text'+i+'</option>').appendTo($("#multi-select"));
|
||||
};
|
||||
select = $("#multi-select");
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
$("#multi-select, #multi-select-optgroup, .ms-container").remove();
|
||||
});
|
||||
|
||||
sanitize = function(value){
|
||||
reg = new RegExp("\\W+", 'gi');
|
||||
return value.replace(reg, '_');
|
||||
}
|
||||
253
wwwroot/BackendScript/assets/jquery-multi-select/test/spec/multiSelectSpec.js
vendored
Normal file
253
wwwroot/BackendScript/assets/jquery-multi-select/test/spec/multiSelectSpec.js
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
describe("multiSelect", function() {
|
||||
|
||||
describe('init', function(){
|
||||
it ('should be chainable', function(){
|
||||
select.multiSelect().addClass('chainable');
|
||||
expect(select.hasClass('chainable')).toBeTruthy();
|
||||
});
|
||||
describe('without options', function(){
|
||||
|
||||
beforeEach(function() {
|
||||
select.multiSelect();
|
||||
msContainer = select.next();
|
||||
});
|
||||
|
||||
it('should hide the original select', function(){
|
||||
expect(select.css('position')).toBe('absolute');
|
||||
expect(select.css('left')).toBe('-9999px');
|
||||
});
|
||||
|
||||
it('should create a container', function(){
|
||||
expect(msContainer).toBe('div.ms-container');
|
||||
});
|
||||
|
||||
it ('should create a selectable and a selection container', function(){
|
||||
expect(msContainer).toContain('div.ms-selectable, div.ms-selection');
|
||||
});
|
||||
|
||||
it ('should create a list for both selectable and selection container', function(){
|
||||
expect(msContainer).toContain('div.ms-selectable ul.ms-list, div.ms-selection ul.ms-list');
|
||||
});
|
||||
|
||||
it ('should populate the selectable list', function(){
|
||||
expect($('.ms-selectable ul.ms-list li').length).toEqual(10);
|
||||
});
|
||||
|
||||
it ('should populate the selection list', function(){
|
||||
expect($('.ms-selectable ul.ms-list li').length).toEqual(10);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('with pre-selected options', function(){
|
||||
|
||||
var selectedValues = [];
|
||||
|
||||
beforeEach(function() {
|
||||
var firstOption = select.children('option').first();
|
||||
var lastOption = select.children('option').last();
|
||||
firstOption.prop('selected', true);
|
||||
lastOption.prop('selected', true);
|
||||
selectedValues.push(firstOption.val(), lastOption.val());
|
||||
select.multiSelect();
|
||||
msContainer = select.next();
|
||||
});
|
||||
|
||||
it ('should select the pre-selected options', function(){
|
||||
$.each(selectedValues, function(index, value){
|
||||
expect($('.ms-selectable ul.ms-list li#'+sanitize(value)+'-selectable')).toBe('.ms-selected');
|
||||
});
|
||||
expect($('.ms-selectable ul.ms-list li.ms-selected').length).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('optgroup', function(){
|
||||
var optgroupMsContainer, optgroupSelect, optgroupLabels;
|
||||
|
||||
beforeEach(function() {
|
||||
$('<select id="multi-select-optgroup" multiple="multiple" name="testy[]"></select>').appendTo('body');
|
||||
for (var o=1; o <= 10; o++) {
|
||||
var optgroup = $('<optgroup label="opgroup'+o+'"></optgroup>')
|
||||
for (var i=1; i <= 10; i++) {
|
||||
var value = i + (o * 10);
|
||||
$('<option value="value'+value+'">text'+value+'</option>').appendTo(optgroup);
|
||||
};
|
||||
optgroup.appendTo($("#multi-select-optgroup"));
|
||||
}
|
||||
optgroupSelect = $("#multi-select-optgroup");
|
||||
});
|
||||
|
||||
describe('init', function(){
|
||||
describe('with selectableOptgroup option set to false', function(){
|
||||
beforeEach(function(){
|
||||
optgroupSelect.multiSelect({ selectableOptgroup: false });
|
||||
optgroupMsContainer = optgroupSelect.next();
|
||||
optgroupLabels = optgroupMsContainer.find('.ms-selectable .ms-optgroup-label');
|
||||
});
|
||||
|
||||
it ('sould display all optgroups', function(){
|
||||
expect(optgroupLabels.length).toEqual(10);
|
||||
});
|
||||
|
||||
it ('should do nothing when clicking on optgroup', function(){
|
||||
var clickedOptGroupLabel = optgroupLabels.first();
|
||||
clickedOptGroupLabel.trigger('click');
|
||||
expect(optgroupSelect.val()).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('with selectableOptgroup option set to true', function(){
|
||||
beforeEach(function(){
|
||||
optgroupSelect.multiSelect({ selectableOptgroup: true });
|
||||
optgroupMsContainer = optgroupSelect.next();
|
||||
optgroupLabels = optgroupMsContainer.find('.ms-selectable .ms-optgroup-label');
|
||||
});
|
||||
|
||||
it ('should select all nested options when clicking on optgroup', function(){
|
||||
var clickedOptGroupLabel = optgroupLabels.first();
|
||||
clickedOptGroupLabel.trigger('click');
|
||||
expect(optgroupSelect.val().length).toBe(10);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('select', function(){
|
||||
|
||||
describe('multiple values (Array)', function(){
|
||||
var values = ['value1', 'value2', 'value7'];
|
||||
beforeEach(function(){
|
||||
$('#multi-select').multiSelect();
|
||||
$('#multi-select').multiSelect('select', values);
|
||||
});
|
||||
|
||||
it('should select corresponding option', function(){
|
||||
expect(select.val()).toEqual(values);
|
||||
});
|
||||
});
|
||||
|
||||
describe('single value (String)', function(){
|
||||
var value = 'value1';
|
||||
|
||||
beforeEach(function(){
|
||||
$('#multi-select').multiSelect();
|
||||
$('#multi-select').multiSelect('select', value);
|
||||
});
|
||||
|
||||
it('should select corresponding option', function(){
|
||||
expect($.inArray(value, select.val()) > -1).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("on click", function(){
|
||||
var clickedItem, value;
|
||||
|
||||
beforeEach(function() {
|
||||
$('#multi-select').multiSelect();
|
||||
clickedItem = $('.ms-selectable ul.ms-list li').first();
|
||||
value = clickedItem.data('ms-value');
|
||||
spyOnEvent(select, 'change');
|
||||
spyOnEvent(select, 'focus');
|
||||
clickedItem.trigger('click');
|
||||
});
|
||||
|
||||
it('should hide selected item', function(){
|
||||
expect(clickedItem).toBeHidden();
|
||||
});
|
||||
|
||||
it('should add the .ms-selected class to the selected item', function(){
|
||||
expect(clickedItem.hasClass('ms-selected')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should select corresponding option', function(){
|
||||
expect(select.find('option[value="'+value+'"]')).toBeSelected();
|
||||
});
|
||||
|
||||
it('should show the associated selected item', function(){
|
||||
expect($('#'+sanitize(value)+'-selection')).toBe(':visible');
|
||||
});
|
||||
|
||||
it('should trigger the original select change event', function(){
|
||||
expect('change').toHaveBeenTriggeredOn("#multi-select");
|
||||
});
|
||||
|
||||
afterEach(function(){
|
||||
select.multiSelect('deselect_all');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('deselect', function(){
|
||||
describe('multiple values (Array)', function(){
|
||||
var selectedValues = ['value1', 'value2', 'value7'],
|
||||
deselectValues = ['value1', 'value2'];
|
||||
beforeEach(function(){
|
||||
$('#multi-select').multiSelect();
|
||||
$('#multi-select').multiSelect('select', selectedValues);
|
||||
$('#multi-select').multiSelect('deselect', deselectValues);
|
||||
});
|
||||
|
||||
it('should select corresponding option', function(){
|
||||
expect(select.val()).toEqual(['value7']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('single value (String)', function(){
|
||||
var selectedValues = ['value1', 'value2', 'value7'],
|
||||
deselectValue = 'value2';
|
||||
|
||||
beforeEach(function(){
|
||||
$('#multi-select').multiSelect();
|
||||
$('#multi-select').multiSelect('select', selectedValues);
|
||||
$('#multi-select').multiSelect('deselect', deselectValue);
|
||||
});
|
||||
|
||||
it('should select corresponding option', function(){
|
||||
expect($.inArray(deselectValue, select.val()) > -1).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("on click", function(){
|
||||
var clickedItem, value;
|
||||
var correspondingSelectableItem;
|
||||
|
||||
beforeEach(function() {
|
||||
$('#multi-select').find('option').first().prop('selected', true);
|
||||
$('#multi-select').multiSelect();
|
||||
|
||||
clickedItem = $('.ms-selection ul.ms-list li').first();
|
||||
value = clickedItem.attr('id').replace('-selection', '');
|
||||
correspondingSelectableItem = $('.ms-selection ul.ms-list li').first();
|
||||
spyOnEvent(select, 'change');
|
||||
spyOnEvent(select, 'focus');
|
||||
clickedItem.trigger('click');
|
||||
});
|
||||
|
||||
it ('should hide clicked item', function(){
|
||||
expect(clickedItem).toBe(':hidden');
|
||||
});
|
||||
|
||||
it('should show associated selectable item', function(){
|
||||
expect($('#'+value+'-selectable')).toBe(':visible');
|
||||
});
|
||||
|
||||
it('should remove the .ms-selected class to the corresponding selectable item', function(){
|
||||
expect(correspondingSelectableItem.hasClass('ms-selected')).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should deselect corresponding option', function(){
|
||||
expect(select.find('option[value="'+value+'"]')).not.toBeSelected();
|
||||
});
|
||||
|
||||
it('should trigger the original select change event', function(){
|
||||
expect('change').toHaveBeenTriggeredOn("#multi-select");
|
||||
});
|
||||
|
||||
afterEach(function(){
|
||||
select.multiSelect('deselect_all');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
2
wwwroot/BackendScript/assets/jquery-multi-select/test/src/jquery.js
vendored
Normal file
2
wwwroot/BackendScript/assets/jquery-multi-select/test/src/jquery.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user