eventman/static/js/nya-bs-select.min.js

6 lines
13 KiB
JavaScript
Raw Normal View History

2016-06-18 20:01:17 +02:00
/**
* nya-bootstrap-select v2.0.10
* Copyright 2014 Nyasoft
* Licensed under MIT license
*/
!function(){"use strict";function a(){return++j}function b(a){return a&&a.window===a}function c(a){return"string"==typeof a}function d(a){if(null==a||b(a))return!1;var d=a.length;return 1===a.nodeType&&d?!0:c(a)||Array.isArray(a)||0===d||"number"==typeof d&&d>0&&d-1 in a}function e(){return Object.create(null)}function f(b,c){var d,e=typeof b;return"function"==e||"object"==e&&null!==b?"function"==typeof(d=b.$$hashKey)?d=b.$$hashKey():void 0===d&&(d=b.$$hashKey=(c||a)()):d=b,e+":"+d}function g(a,b,c){var d,e,f=[],g=[];for(d=0;d<b.length;d++)for(e=0;e<a.length;e++)a[e][c]?a[e][c]===b[d]&&g.push(a[e]):f.push(a[e]);return g=g.concat(f)}function h(a){var b=a[0],c=a[a.length-1],d=[b];do{if(b=b.nextSibling,!b)break;d.push(b)}while(b!==c);return angular.element(d)}function i(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}var j=0,k=function(a){return a.clone[0]},l=function(a){return a.clone[a.clone.length-1]},m=function(a,b,c,d,e,f,g,h){a[c]=d,e&&(a[e]=f),a.$index=b,a.$first=0===b,a.$last=b===g-1,a.$middle=!(a.$first||a.$last),a.$odd=!(a.$even=0===(1&b)),h&&(a.$group=h)},n=function(a,b){var c,d=a.length;if(0===d)return!1;for(c=0;d>c;c++)if(v(b,a[c]))return!0;return!1},o=function(a,b){var c,d=a.length;if(0===d)return-1;for(c=0;d>c;c++)if(v(b,a[c]))return c;return-1},p=function(a,b,c){var d,e=a,f=typeof c;if(a==b)return null;do if("string"===f){if(d=" "+e.className+" ",1===e.nodeType&&d.replace(/[\t\r\n\f]/g," ").indexOf(c)>=0)return e}else if(e==c)return e;while((e=e.parentNode)&&e!=b&&9!==e.nodeType);return null},q=function(a){var b,c=a.className.replace(/[\t\r\n\f]/g," ").trim();b=c.split(" ");for(var d=0;d<b.length;d++)/\s+/.test(b[d])&&(b.splice(d,1),d--);return b},r=function(a,b){var c=q(a);return-1!==c.indexOf(b)},s=function(a,b){var c,d,e,f=a.children(),g=f.length;if(g>0)for(var h=0;g>h;h++){if(c=f.eq(h),d=!0,e=q(c[0]),e.length>0)for(var i=0;i<b.length;i++)if(-1===e.indexOf(b[i])){d=!1;break}if(d)return c}return[]},t=function(a,b){var c,d,e;if(-1!==a.text().toLowerCase().indexOf(b.toLowerCase()))return!0;for(c=a.children(),e=c.length,d=0;e>d;d++)if(-1!==c.eq(d).text().toLowerCase().indexOf(b.toLowerCase()))return!0;return!1},u=angular.element,v=angular.equals,w=angular.copy,x=angular.extend,y=angular.module("nya.bootstrap.select",[]);y.provider("nyaBsConfig",function(){var a=null,b={"en-us":{defaultNoneSelection:"Nothing selected",noSearchResult:"NO SEARCH RESULT",numberItemSelected:"%d item selected"}},c=w(b);this.setLocalizedText=function(a,b){if(!a)throw new Error("localeId must be a string formatted as languageId-countryId");c[a]||(c[a]={}),c[a]=x(c[a],b)},this.useLocale=function(b){a=b},this.$get=["$locale",function(d){var e;return e=a?c[a]:c[d.id],e||(e=b["en-us"]),e}]}),y.controller("nyaBsSelectCtrl",function(){var a=this;a.keyIdentifier=null,a.valueIdentifier=null,a.isMultiple=!1,a.onCollectionChange=function(){},a.setId=function(b){a.id=b||"id#"+Math.floor(1e4*Math.random())}}),y.directive("nyaBsSelect",["$parse","$document","$timeout","nyaBsConfig",function(a,b,c,d){var e="Nothing selected",f='<button class="btn btn-default dropdown-toggle" type="button"><span class="pull-left filter-option"></span>&nbsp;<span class="caret"></span></button>',g='<div class="dropdown-menu open"></div>',h='<div class="bs-searchbox"><input type="text" class="form-control"></div>',j='<ul class="dropdown-menu inner"></ul>',k='<li class="no-search-result"><span>NO SEARCH RESULT</span></li>';return{restrict:"ECA",require:["ngModel","nyaBsSelect"],controller:"nyaBsSelectCtrl",compile:function(l,m){l.addClass("btn-group");var x,y,z,A,B,C,D=function(){var a;return a=m.titleTpl?u(m.titleTpl):m.title?document.createTextNode(m.title):I.defaultNoneSelectionTpl?u(I.defaultNoneSelectionTpl):document.createTextNode(I.defaultNoneSelection?I.defaultNoneSelection:e)},E=l.children(),F=u(f),G=u(g),H=u(j),I=d;for(z=q(l[0]),z.forEach(function(a){/btn-(?:primary|info|success|warning|danger|inverse)/.test(a)&&(l.removeClass(a),F.removeClass("btn-default"),F.addClass(a)),"form-control"===a&&F.addClass(a)}),H.append(E),A=E.length,B=0;A>B;B++)C=E.eq(B),(C.hasC