10 lines
3.3 KiB
JavaScript
10 lines
3.3 KiB
JavaScript
/**
|
|
* angular-bootstrap-duallistbox
|
|
* @version v0.1.0 - 2015-06-13
|
|
* @author Francesco Pontillo (francescopontillo@gmail.com)
|
|
* @link https://github.com/frapontillo/angular-bootstrap-duallistbox
|
|
* @license Apache License 2.0
|
|
**/
|
|
|
|
"use strict";angular.module("frapontillo.bootstrap-duallistbox",[]),angular.module("frapontillo.bootstrap-duallistbox").directive("bsDuallistbox",["$compile","$timeout",function(a,b){return{restrict:"A",require:"ngModel",link:function(c,d,e){var f,g=/^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/,h=e.ngOptions.match(g)[7],i=function(a){return a===!0||"true"===a},j={bootstrap2:{changeFn:"setBootstrap2Compatible",transformFn:i},postfix:"setHelperSelectNamePostfix",selectMinHeight:{changeFn:"setSelectOrMinimalHeight",defaultValue:100},filter:{changeFn:"setShowFilterInputs",defaultValue:!0,transformFn:i},filterClear:{changeFn:"setFilterTextClear",defaultValue:"show all"},filterPlaceholder:"setFilterPlaceHolder",filterValues:{changeFn:"setFilterOnValues",transformFn:i},moveOnSelect:{changeFn:"setMoveOnSelect",defaultValue:!0,transformFn:i},preserveSelection:"setPreserveSelectionOnMove",moveSelectedLabel:"setMoveSelectedLabel",moveAllLabel:"setMoveAllLabel",removeSelectedLabel:"setRemoveSelectedLabel",removeAllLabel:"setRemoveAllLabel",selectedListLabel:"setSelectedListLabel",nonSelectedListLabel:"setNonSelectedListLabel",infoAll:{changeFn:"setInfoText",defaultValue:"Showing all {0}"},infoFiltered:{changeFn:"setInfoTextFiltered",defaultValue:'<span class="label label-warning">Filtered</span> {0} from {1}'},infoEmpty:{changeFn:"setInfoTextEmpty",defaultValue:"Empty list"}},k=function(a){var b,c,d=j[a],f=e[a];return angular.isObject(d)&&(b=d.defaultValue,c=d.transformFn),f||(f=b),angular.isFunction(c)&&(f=c(f)),f},l=function(a){var b=j[a],c=b;return angular.isObject(b)&&(c=b.changeFn),c},m=function(){c.$watch(e.ngModel,function(){o(),n()}),c.$watch(h,n,!0),c.$watch(e.filterNonSelected,function(){n()}),c.$watch(e.filterSelected,function(){n()}),angular.forEach(j,function(a,b){e.$observe(b,function(){var a=l(b),c=k(b);d.bootstrapDualListbox(a,c,!0)})})},n=function(){b(function(){d.bootstrapDualListbox("refresh")})},o=function(){f||p()},p=function(){var b={};angular.forEach(j,function(a,c){var d=k(c);b[c]=d}),f=d.bootstrapDualListbox({bootstrap2Compatible:b.bootstrap2,filterTextClear:b.filterClear,filterPlaceHolder:b.filterPlaceholder,moveSelectedLabel:b.moveSelectedLabel,moveAllLabel:b.moveAllLabel,removeSelectedLabel:b.removeSelectedLabel,removeAllLabel:b.removeAllLabel,moveOnSelect:b.moveOnSelect,preserveSelectionOnMove:b.preserveSelection,selectedListLabel:b.selectedListLabel,nonSelectedListLabel:b.nonSelectedListLabel,helperSelectNamePostfix:b.postfix,selectorMinimalHeight:b.selectMinHeight,showFilterInputs:b.filter,nonSelectedFilter:"",selectedFilter:"",infoText:b.infoAll,infoTextFiltered:b.infoFiltered,infoTextEmpty:b.infoEmpty,filterOnValues:b.filterValues});var g=d.bootstrapDualListbox("getContainer"),h=g.find(".box1 .filter");h.attr("ng-model",e.filterNonSelected),a(h)(c);var i=g.find(".box2 .filter");i.attr("ng-model",e.filterSelected),a(i)(c)};m(),c.$on("$destroy",function(){d.bootstrapDualListbox("destroy")})}}}]);
|