dual-listbox
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -1,1 +0,1 @@ | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,function(){return function(t){function e(s){if(i[s])return i[s].exports;var l=i[s]={exports:{},id:s,loaded:!1};return t[s].call(l.exports,l,l.exports,e),l.loaded=!0,l.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}return function(e,i,s){return i&&t(e.prototype,i),s&&t(e,s),e}}(),l="dual-listbox",a="dual-lsitbox__container",n="dual-listbox__available",d="dual-listbox__selected",o="dual-listbox__title",c="dual-listbox__item",u="dual-listbox__buttons",r="dual-listbox__button",h="dual-listbox__search",v="dual-listbox__item--selected",b=function(){function t(e){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,t),this.setDefaults(),this.select=document.querySelector(e),this.selected=[],this.available=[],this._initOptions(s),this._initReusableElements(),this._splitSelectOptions(this.select),this._buildDualListbox(this.select.parentNode),this._addActions(),this.redraw()}return s(t,[{key:"setDefaults",value:function(){this.addEvent=null,this.removeEvent=null,this.availableTitle="Available options",this.selectedTitle="Selected options",this.addButtonText="add",this.removeButtonText="remove",this.addAllButtonText="add all",this.removeAllButtonText="remove all",this.searchPlaceholder="Search"}},{key:"addSelected",value:function(t){var e=this.available.indexOf(t);e>-1&&(this.available.splice(e,1),this.selected.push(t),this._selectOption(t.dataset.id),this.redraw())}},{key:"redraw",value:function(){this.updateAvailableListbox(),this.updateSelectedListbox()}},{key:"removeSelected",value:function(t){var e=this.selected.indexOf(t);e>-1&&(this.selected.splice(e,1),this.available.push(t),this._deselectOption(t.dataset.id),this.redraw())}},{key:"searchLists",value:function(t,e){for(var i=e.querySelectorAll("."+c),s=0;s<i.length;s++){var l=i[s];t&&l.textContent.indexOf(t)===-1?l.style.display="none":l.style.display="list-item"}}},{key:"updateAvailableListbox",value:function(){this.availebleList.innerHTML="",this.availebleList.appendChild(this.availableListTitle);for(var t=0;t<this.available.length;t++){var e=this.available[t];this.availebleList.appendChild(e)}}},{key:"updateSelectedListbox",value:function(){this.selectedList.innerHTML="",this.selectedList.appendChild(this.selectedListTitle);for(var t=0;t<this.selected.length;t++){var e=this.selected[t];this.selectedList.appendChild(e)}}},{key:"_actionAllSelected",value:function(t){for(t.preventDefault();this.available.length>0;)this.addSelected(this.available[0])}},{key:"_actionItemSelected",value:function(t){t.preventDefault();var e=this.dualListbox.querySelector("."+v);e&&this.addSelected(e)}},{key:"_actionAllDeselected",value:function(t){for(t.preventDefault();this.selected.length>0;)this.removeSelected(this.selected[0])}},{key:"_actionItemDeselected",value:function(t){t.preventDefault();var e=this.dualListbox.querySelector("."+v);e&&this.removeSelected(e)}},{key:"_actionItemDoubleClick",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e&&(e.preventDefault(),e.stopPropagation()),this.selected.indexOf(t)>-1?this.removeSelected(t):this.addSelected(t)}},{key:"_actionItemClick",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;i&&i.preventDefault();for(var s=e.querySelectorAll("."+c),l=0;l<s.length;l++){var a=s[l];a!==t&&a.classList.remove(v)}t.classList.contains(v)?t.classList.remove(v):t.classList.add(v)}},{key:"_addActions",value:function(){this._addButtonActions(),this._addSearchActions()}},{key:"_addButtonActions",value:function(){var t=this;this.add_all_button.addEventListener("click",function(e){return t._actionAllSelected(e)}),this.add_button.addEventListener("click",function(e){return t._actionItemSelected(e)}),this.remove_button.addEventListener("click",function(e){return t._actionItemDeselected(e)}),this.remove_all_button.addEventListener("click",function(e){return t._actionAllDeselected(e)})}},{key:"_addClickActions",value:function(t){var e=this;return t.addEventListener("dblclick",function(i){return e._actionItemDoubleClick(t,i)}),t.addEventListener("click",function(i){return e._actionItemClick(t,e.dualListbox,i)}),t}},{key:"_addSearchActions",value:function(){var t=this;this.search.addEventListener("change",function(e){return t.searchLists(e.target.value,t.dualListbox)}),this.search.addEventListener("keyup",function(e){return t.searchLists(e.target.value,t.dualListbox)})}},{key:"_buildDualListbox",value:function(t){this.select.style.display="none",this.dualListBoxContainer.appendChild(this.availebleList),this.dualListBoxContainer.appendChild(this.buttons),this.dualListBoxContainer.appendChild(this.selectedList),this.dualListbox.appendChild(this.search),this.dualListbox.appendChild(this.dualListBoxContainer),t.insertBefore(this.dualListbox,this.select)}},{key:"_createButtons",value:function(){this.buttons=document.createElement("div"),this.buttons.classList.add(u),this.add_all_button=document.createElement("button"),this.add_all_button.classList.add(r),this.add_all_button.innerHTML=this.addAllButtonText,this.add_button=document.createElement("button"),this.add_button.classList.add(r),this.add_button.innerHTML=this.addButtonText,this.remove_button=document.createElement("button"),this.remove_button.classList.add(r),this.remove_button.innerHTML=this.removeButtonText,this.remove_all_button=document.createElement("button"),this.remove_all_button.classList.add(r),this.remove_all_button.innerHTML=this.removeAllButtonText,this.buttons.appendChild(this.add_all_button),this.buttons.appendChild(this.add_button),this.buttons.appendChild(this.remove_button),this.buttons.appendChild(this.remove_all_button)}},{key:"_createListItem",value:function(t){var e=document.createElement("li");return e.classList.add(c),e.innerHTML=t.innerHTML,e.dataset.id=t.value,this._addClickActions(e),e}},{key:"_createSearch",value:function(){this.search=document.createElement("input"),this.search.classList.add(h),this.search.placeholder=this.searchPlaceholder}},{key:"_deselectOption",value:function(t){for(var e=this.select.options,i=0;i<e.length;i++){var s=e[i];s.value===t&&(s.selected=!1)}this.removeEvent&&this.removeEvent(t)}},{key:"_initOptions",value:function(t){for(var e in t)this[e]=t[e]}},{key:"_initReusableElements",value:function(){this.dualListbox=document.createElement("div"),this.dualListbox.classList.add(l),this.select.id&&this.dualListbox.classList.add(this.select.id),this.dualListBoxContainer=document.createElement("div"),this.dualListBoxContainer.classList.add(a),this.availebleList=document.createElement("ul"),this.availebleList.classList.add(n),this.selectedList=document.createElement("ul"),this.selectedList.classList.add(d),this.availableListTitle=document.createElement("li"),this.availableListTitle.classList.add(o),this.availableListTitle.innerText=this.availableTitle,this.selectedListTitle=document.createElement("li"),this.selectedListTitle.classList.add(o),this.selectedListTitle.innerText=this.selectedTitle,this._createButtons(),this._createSearch()}},{key:"_selectOption",value:function(t){for(var e=this.select.options,i=0;i<e.length;i++){var s=e[i];s.value===t&&(s.selected=!0)}this.addEvent&&this.addEvent(t)}},{key:"_splitSelectOptions",value:function(t){for(var e=t.options,i=0;i<e.length;i++){var s=e[i],l=this._createListItem(s);s.attributes.selected?this.selected.push(l):this.available.push(l)}}}]),t}();e.default=b,e.DualListbox=b}])}); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i=t();for(var s in i)("object"==typeof exports?exports:e)[s]=i[s]}}(this,function(){return function(e){function t(s){if(i[s])return i[s].exports;var l=i[s]={exports:{},id:s,loaded:!1};return e[s].call(l.exports,l,l.exports,t),l.loaded=!0,l.exports}var i={};return t.m=e,t.c=i,t.p="",t(0)}([function(e,t){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l=function(){function e(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}return function(t,i,s){return i&&e(t.prototype,i),s&&e(t,s),t}}(),n="dual-listbox",a="dual-lsitbox__container",o="dual-listbox__available",d="dual-listbox__selected",c="dual-listbox__title",u="dual-listbox__item",r="dual-listbox__buttons",h="dual-listbox__button",v="dual-listbox__search",b="dual-listbox__item--selected",f=function(){function e(t){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,e),this.setDefaults(),this.selected=[],this.available=[],this.isDomElement(t)?this.select=t:this.select=document.querySelector(t),this._initOptions(s),this._initReusableElements(),this._splitSelectOptions(this.select),this._buildDualListbox(this.select.parentNode),this._addActions(),this.redraw()}return l(e,[{key:"setDefaults",value:function(){this.addEvent=null,this.removeEvent=null,this.availableTitle="Available options",this.selectedTitle="Selected options",this.addButtonText="add",this.removeButtonText="remove",this.addAllButtonText="add all",this.removeAllButtonText="remove all",this.searchPlaceholder="Search"}},{key:"addSelected",value:function(e){var t=this.available.indexOf(e);t>-1&&(this.available.splice(t,1),this.selected.push(e),this._selectOption(e.dataset.id),this.redraw())}},{key:"redraw",value:function(){this.updateAvailableListbox(),this.updateSelectedListbox()}},{key:"removeSelected",value:function(e){var t=this.selected.indexOf(e);t>-1&&(this.selected.splice(t,1),this.available.push(e),this._deselectOption(e.dataset.id),this.redraw())}},{key:"searchLists",value:function(e,t){for(var i=t.querySelectorAll("."+u),s=e.toLowerCase(),l=0;l<i.length;l++){var n=i[l];e&&n.textContent.toLowerCase().indexOf(s)===-1?n.style.display="none":n.style.display="list-item"}}},{key:"updateAvailableListbox",value:function(){this.availebleList.innerHTML="",this.availebleList.appendChild(this.availableListTitle);for(var e=0;e<this.available.length;e++){var t=this.available[e];this.availebleList.appendChild(t)}}},{key:"updateSelectedListbox",value:function(){this.selectedList.innerHTML="",this.selectedList.appendChild(this.selectedListTitle);for(var e=0;e<this.selected.length;e++){var t=this.selected[e];this.selectedList.appendChild(t)}}},{key:"_actionAllSelected",value:function(e){for(e.preventDefault();this.available.length>0;)this.addSelected(this.available[0])}},{key:"_actionItemSelected",value:function(e){e.preventDefault();var t=this.dualListbox.querySelector("."+b);t&&this.addSelected(t)}},{key:"_actionAllDeselected",value:function(e){for(e.preventDefault();this.selected.length>0;)this.removeSelected(this.selected[0])}},{key:"_actionItemDeselected",value:function(e){e.preventDefault();var t=this.dualListbox.querySelector("."+b);t&&this.removeSelected(t)}},{key:"_actionItemDoubleClick",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t&&(t.preventDefault(),t.stopPropagation()),this.selected.indexOf(e)>-1?this.removeSelected(e):this.addSelected(e)}},{key:"_actionItemClick",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;i&&i.preventDefault();for(var s=t.querySelectorAll("."+u),l=0;l<s.length;l++){var n=s[l];n!==e&&n.classList.remove(b)}e.classList.contains(b)?e.classList.remove(b):e.classList.add(b)}},{key:"_addActions",value:function(){this._addButtonActions(),this._addSearchActions()}},{key:"_addButtonActions",value:function(){var e=this;this.add_all_button.addEventListener("click",function(t){return e._actionAllSelected(t)}),this.add_button.addEventListener("click",function(t){return e._actionItemSelected(t)}),this.remove_button.addEventListener("click",function(t){return e._actionItemDeselected(t)}),this.remove_all_button.addEventListener("click",function(t){return e._actionAllDeselected(t)})}},{key:"_addClickActions",value:function(e){var t=this;return e.addEventListener("dblclick",function(i){return t._actionItemDoubleClick(e,i)}),e.addEventListener("click",function(i){return t._actionItemClick(e,t.dualListbox,i)}),e}},{key:"_addSearchActions",value:function(){var e=this;this.search.addEventListener("change",function(t){return e.searchLists(t.target.value,e.dualListbox)}),this.search.addEventListener("keyup",function(t){return e.searchLists(t.target.value,e.dualListbox)})}},{key:"_buildDualListbox",value:function(e){this.select.style.display="none",this.dualListBoxContainer.appendChild(this.availebleList),this.dualListBoxContainer.appendChild(this.buttons),this.dualListBoxContainer.appendChild(this.selectedList),this.dualListbox.appendChild(this.search),this.dualListbox.appendChild(this.dualListBoxContainer),e.insertBefore(this.dualListbox,this.select)}},{key:"_createButtons",value:function(){this.buttons=document.createElement("div"),this.buttons.classList.add(r),this.add_all_button=document.createElement("button"),this.add_all_button.classList.add(h),this.add_all_button.innerHTML=this.addAllButtonText,this.add_button=document.createElement("button"),this.add_button.classList.add(h),this.add_button.innerHTML=this.addButtonText,this.remove_button=document.createElement("button"),this.remove_button.classList.add(h),this.remove_button.innerHTML=this.removeButtonText,this.remove_all_button=document.createElement("button"),this.remove_all_button.classList.add(h),this.remove_all_button.innerHTML=this.removeAllButtonText,this.buttons.appendChild(this.add_all_button),this.buttons.appendChild(this.add_button),this.buttons.appendChild(this.remove_button),this.buttons.appendChild(this.remove_all_button)}},{key:"_createListItem",value:function(e){var t=document.createElement("li");return t.classList.add(u),t.innerHTML=e.innerHTML,t.dataset.id=e.value,this._addClickActions(t),t}},{key:"_createSearch",value:function(){this.search=document.createElement("input"),this.search.classList.add(v),this.search.placeholder=this.searchPlaceholder}},{key:"_deselectOption",value:function(e){for(var t=this.select.options,i=0;i<t.length;i++){var s=t[i];s.value===e&&(s.selected=!1)}this.removeEvent&&this.removeEvent(e)}},{key:"_initOptions",value:function(e){for(var t in e)this[t]=e[t]}},{key:"_initReusableElements",value:function(){this.dualListbox=document.createElement("div"),this.dualListbox.classList.add(n),this.select.id&&this.dualListbox.classList.add(this.select.id),this.dualListBoxContainer=document.createElement("div"),this.dualListBoxContainer.classList.add(a),this.availebleList=document.createElement("ul"),this.availebleList.classList.add(o),this.selectedList=document.createElement("ul"),this.selectedList.classList.add(d),this.availableListTitle=document.createElement("li"),this.availableListTitle.classList.add(c),this.availableListTitle.innerText=this.availableTitle,this.selectedListTitle=document.createElement("li"),this.selectedListTitle.classList.add(c),this.selectedListTitle.innerText=this.selectedTitle,this._createButtons(),this._createSearch()}},{key:"_selectOption",value:function(e){for(var t=this.select.options,i=0;i<t.length;i++){var s=t[i];s.value===e&&(s.selected=!0)}this.addEvent&&this.addEvent(e)}},{key:"_splitSelectOptions",value:function(e){for(var t=e.options,i=0;i<t.length;i++){var s=t[i],l=this._createListItem(s);s.attributes.selected?this.selected.push(l):this.available.push(l)}}},{key:"isDomElement",value:function(e){return"object"===("undefined"==typeof HTMLElement?"undefined":s(HTMLElement))?e instanceof HTMLElement:e&&"object"===(void 0===e?"undefined":s(e))&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName}}]),e}();t.default=f,t.DualListbox=f}])}); |
@@ -20,10 +20,73 @@ var clone= require('clone'); | ||
function ConfigException(message) { | ||
this.message = message; | ||
this.name = 'ConfigException'; | ||
} | ||
// The main configuration | ||
module.exports = function(config) { | ||
config.set({ | ||
browserStack: { | ||
username: '', | ||
accessKey: '' | ||
if (process.env.CI && (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY)) { | ||
throw ConfigException('Make sure the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set.') | ||
} | ||
// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/ | ||
var customLaunchers = { | ||
sl_chrome: { | ||
base: 'SauceLabs', | ||
browserName: 'chrome', | ||
platform: 'Windows 10', | ||
version: 'latest' | ||
}, | ||
sl_chrome_2: { | ||
base: 'SauceLabs', | ||
browserName: 'chrome', | ||
platform: 'Windows 10', | ||
version: 'latest-1' | ||
}, | ||
sl_edge: { | ||
base: 'SauceLabs', | ||
browserName: 'MicrosoftEdge', | ||
platform: 'Windows 10', | ||
version: 'latest' | ||
}, | ||
sl_edge_2: { | ||
base: 'SauceLabs', | ||
browserName: 'MicrosoftEdge', | ||
platform: 'Windows 10', | ||
version: '14.14393' | ||
}, | ||
sl_safari: { | ||
base: 'SauceLabs', | ||
browserName: 'safari', | ||
platform: 'macOS 10.12', | ||
version: 'latest' | ||
}, | ||
sl_safari_2: { | ||
base: 'SauceLabs', | ||
browserName: 'safari', | ||
platform: 'OS X 10.11', | ||
version: '9.0' | ||
}, | ||
sl_firefox: { | ||
base: 'SauceLabs', | ||
browserName: 'firefox', | ||
platform: 'Windows 10', | ||
version: 'latest' | ||
}, | ||
sl_firefox_2: { | ||
base: 'SauceLabs', | ||
browserName: 'firefox', | ||
platform: 'Windows 10', | ||
version: 'latest-1' | ||
}, | ||
sl_ie_11: { | ||
base: 'SauceLabs', | ||
browserName: 'internet explorer', | ||
platform: 'Windows 8.1', | ||
version: '11' | ||
} | ||
} | ||
config.set({ | ||
frameworks: [ | ||
@@ -57,34 +120,15 @@ 'jasmine-jquery', | ||
}, | ||
colors: true, | ||
recordScreenshots: false, | ||
reporters: (process.env.TRAVIS) ? ['spec', 'coverage', 'coveralls', 'saucelabs'] : ['spec', 'coverage', 'saucelabs'], | ||
reporters: (process.env.TRAVIS) ? ['spec', 'coverage', 'coveralls'] : ['spec', 'coverage'], | ||
// customLaunchers: { | ||
// edge14: { | ||
// base: 'BrowserStack', | ||
// browser: 'edge', | ||
// browser_version: '14', | ||
// os: 'Windows', | ||
// os_version: '10' | ||
// }, | ||
// edge15: { | ||
// base: 'BrowserStack', | ||
// browser: 'edge', | ||
// browser_version: '15', | ||
// os: 'Windows', | ||
// os_version: '10' | ||
// }, | ||
// ie11: { | ||
// base: 'BrowserStack', | ||
// browser: 'ie', | ||
// browser_version: '11', | ||
// os: 'Windows', | ||
// os_version: '7' | ||
// } | ||
// }, | ||
// browsers: ['Chrome', 'Firefox', 'edge14', 'edge15', 'ie11'] | ||
browsers: ['Chrome', 'Firefox'] | ||
sauceLabs: { | ||
testName: 'Dual listbox browser testing', | ||
public: 'public' | ||
}, | ||
customLaunchers: customLaunchers, | ||
captureTimeout: 120000, | ||
browsers: Object.keys(customLaunchers), | ||
singleRun: true | ||
}); | ||
} |
{ | ||
"name": "dual-listbox", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Dual listbox for multi-select elements", | ||
@@ -27,3 +27,2 @@ "main": "dist/dual-listbox.js", | ||
"karma": "^1.1.0", | ||
"karma-browserstack-launcher": "^1.2.0", | ||
"karma-chrome-launcher": "^1.0.1", | ||
@@ -37,2 +36,3 @@ "karma-coverage": "^1.0.0", | ||
"karma-jasmine-jquery": "^0.1.1", | ||
"karma-sauce-launcher": "^1.1.0", | ||
"karma-spec-reporter": "^0.0.26", | ||
@@ -39,0 +39,0 @@ "karma-webpack": "^1.7.0", |
@@ -5,5 +5,8 @@ [![Build Status](https://travis-ci.org/maykinmedia/dual-listbox.svg?branch=master)](https://travis-ci.org/maykinmedia/dual-listbox) | ||
[![Lintly](https://lintly.com/gh/maykinmedia/dual-listbox/badge.svg)](https://lintly.com/gh/maykinmedia/dual-listbox/) | ||
[![npm](https://img.shields.io/npm/dw/localeval.svg)](https://github.com/maykinmedia/dual-listbox) | ||
[![NPM](https://nodei.co/npm/dual-listbox.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/dual-listbox/) | ||
[![Sauce Test Status](https://saucelabs.com/browser-matrix/jostcrow.svg)](https://saucelabs.com/u/jostcrow) | ||
# Dual Listbox | ||
@@ -10,0 +13,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73539
27
915
74
5