From e07af2718124ef00d39666c1a12583eeb35fff4d Mon Sep 17 00:00:00 2001 From: Roman Pawel Date: Wed, 11 Oct 2017 13:28:12 +0200 Subject: [PATCH] Fix error in function deselectOption Add missing ' in the function "deselectOption" to the command e("option[value='"+e(t).data("val")+"']",this.source).prop("selected",!1). Now deselection is working without error. --- dist/selectr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/selectr.js b/dist/selectr.js index d1f1111..34408ff 100644 --- a/dist/selectr.js +++ b/dist/selectr.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports?exports.selectr=t(require("jquery")):e.selectr=t(e.$)}(this,function(e){return function(e){function t(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){var o,i=function(e,t){return function(){return e.apply(t,arguments)}};o=r(1),window.NO_STYLES||(r(2),window.POLYFILL_BOOTSTRAP_STYLES&&r(6)),function(e,t){var r;return r=function(){function t(t,r){this.source=t,this.args=r,this.updateFooter=i(this.updateFooter,this),this.deselectOption=i(this.deselectOption,this),this.selectOption=i(this.selectOption,this),this.triggerChange=i(this.triggerChange,this),this.args=e.extend({},this.defaults,this.args,this.source.data("selectr-opts")),this.multi=this.source.prop("multiple"),this.createSelectr(),this.monitorSource(),this.selectrContainer.insertAfter(this.source),this.selectrContainer=e(this.source.next()),this.bindEventListeners(),this.source.hide()}return t.prototype.defaults={title:"Select Options",noMatchingOptionsText:"No options found",placeholder:"Search",resetText:"Clear All",width:"300px",maxListHeight:"250px",tooltipBreakpoint:25,maxSelection:1/0,panelStyle:"default",alwaysShowFooter:!1},t.prototype.createSelectr=function(){return this.selectrContainer=this.createContainer(),e(".list-group",this.selectrContainer).append(this.createOpts()),this.updateFooter()},t.prototype.createContainer=function(){return e(document.createElement("div")).addClass("selectr panel panel-"+this.args.panelStyle+" "+(this.multi?"multi":void 0)).css("width",this.args.width).html("

"+this.args.title+"

")},t.prototype.createOpts=function(){var t,r,o,i,n;for(i=e("option",this.source),n=[],t=0,r=i.length;tthis.args.tooltipBreakpoint?e(o).text():""})).append(e(document.createElement("div")).html("×").addClass("add-remove "+(this.multi?void 0:"hidden"))));return n},t.prototype.monitorSource=function(){var t;return t=function(t){return function(){var r;return r=e(document.createElement("ul")).addClass("list-group").css("max-height",t.args.maxListHeight).append(t.createOpts()),e(".list-group",t.selectrContainer).replaceWith(r),t.updateFooter()}}(this),this.source.on("change",function(e,r){if("selectrInitiated"!==r)return t()})},t.prototype.bindEventListeners=function(){var t,r,o,i,n,s,a,l,c,d,p,u,h,f;return a=this.multi,p=this.selectrContainer,u=this.source,d=this.selectOption,n=this.deselectOption,h=this.triggerChange,f=this.updateFooter,s=function(t){var r,o;if(t.stopPropagation(),2!==(null!=(o=t.originalEvent)?o.detail:void 0))return r=(t.ctrlKey||t.metaKey)&&a,e(this).hasClass("selected")&&(r||0===e(this).siblings(".selected").length)&&a?n(this):d(r,this)},t=function(t){var r;if(t.stopPropagation(),!t.originalEvent.detail||2!==t.originalEvent.detail)return r=e(t.target).parents(".list-group-item"),r.hasClass("selected")?n(r):d(!0,r)},c=function(t){var r,o,i,n;return t.stopPropagation(),i=new RegExp(e(this).val().replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),"i"),n=!0,e(".list-group-item",p).each(function(t,r){e(r).text().match(i)?(e(r).removeClass("hidden"),n=!1):e(r).addClass("hidden")}),r=e(".clear-search",p),e(this).val().length>0?r.removeClass("hidden"):r.addClass("hidden"),o=e(".no-matching-options",p),n?o.removeClass("hidden"):o.addClass("hidden")},r=function(t){return e(this).siblings("input").val("").trigger("change")},l=function(t){return p.find("ul > li").removeClass("selected"),e("option",u).prop("selected",!1),h(u),f()},o=function(t){if(t.ctrlKey)return e(".list-group",p).addClass("ctrl-key")},i=function(t){if(!t.ctrlKey)return e(".list-group",p).removeClass("ctrl-key")},e(p).on("click",".list-group-item",s),e(p).on("click",".add-remove",t),e(p).on("click change keyup",".form-control",c),e(p).on("click",".clear-search",r),e(p).on("click",".reset",l),e(document).on("keydown",o),e(document).on("keyup",i)},t.prototype.triggerChange=function(){return this.source.trigger("change",["selectrInitiated"])},t.prototype.selectOption=function(t,r){var o,i,n,s;if(!(this.args.maxSelection<=e(r).siblings(".selected").length&&t)){if(!t)for(e("option",this.source).prop("selected",!1),n=e(r).siblings(),o=0,i=n.length;o0?r:""),r===this.args.maxSelection?this.selectrContainer.addClass("max-selection-reached"):this.selectrContainer.removeClass("max-selection-reached"),!this.args.alwaysShowFooter))return t=e(".panel-footer",this.selectrContainer),0===r?t.addClass("hidden"):t.removeClass("hidden")},t}(),e.fn.extend({selectr:function(t){return this.each(function(){var o;if(o=e(this),!o.data("selectr-initialized"))return new r(o,t),o.data("selectr-initialized",!0)})}})}(o,this)},function(t,r){t.exports=e},function(e,t,r){var o=r(3);"string"==typeof o&&(o=[[e.id,o,""]]);r(5)(o,{});o.locals&&(e.exports=o.locals)},function(e,t,r){t=e.exports=r(4)(),t.push([e.id,".selectr{margin:0;display:inline-block;max-width:100%}.selectr,.selectr :not(input){-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.selectr .panel-heading{cursor:default}.selectr .panel-heading.no-title{padding:0;border-bottom:none}.selectr .panel-body{position:relative}.selectr input::-ms-clear{display:none;width:0;height:0}.selectr .clear-search{position:absolute;right:25px;top:12px;font-size:28px;font-weight:700;color:#333;opacity:.8;cursor:pointer}.selectr .clear-search:hover{opacity:1}.selectr .list-group{overflow-x:hidden;-ms-overflow-y:auto}.selectr .list-group-item{padding:0!important;overflow:hidden;cursor:pointer}.selectr .list-group-item.selected{background-color:#4679bd;color:#fff;font-weight:700}.selectr .list-group-item.selected .add-remove{-webkit-transform:rotate(0deg);transform:rotate(0deg)}.selectr.multi .list-group-item:hover .option-name{margin-right:50px;border-right:1px solid #ddd}.selectr.multi .list-group-item:hover .selected .option-name{border-right:1px solid #fff}.selectr.multi .list-group-item:hover .add-remove{display:block}.selectr .option-name{height:100%;padding:10px 15px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.selectr .color-code{width:20px;height:20px;margin:10px;margin-right:0;float:left;border-radius:5px}.selectr .color-code.no-color{width:0;height:0;margin:0}.selectr .add-remove{-webkit-transform:rotate(45deg);transform:rotate(45deg);-webkit-transition:-webkit-transform .2s linear;transition:-webkit-transform .2s linear;transition:transform .2s linear;transition:transform .2s linear,-webkit-transform .2s linear;opacity:.5;display:none;cursor:pointer;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:24px;font-weight:900;position:absolute;right:0;top:0;width:50px;padding:8px;line-height:24px;text-align:center;vertical-align:middle}.selectr .add-remove:hover,.selectr .ctrl-key .add-remove{opacity:.8}.selectr .current-selection{float:right;margin-top:5px;cursor:default}.selectr.max-selection-reached li:not(.selected) .option-name{margin-right:0!important;border-right:none!important}.selectr.max-selection-reached li:not(.selected) .add-remove{display:none!important}.selectr.max-selection-reached .current-selection{background-color:#d9534f}.selectr .no-matching-options{padding:10px;padding-top:0;text-align:center}",""])},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t=0&&b.splice(t,1)}function a(e){var t=document.createElement("style");return t.type="text/css",n(e,t),t}function l(e){var t=document.createElement("link");return t.rel="stylesheet",n(e,t),t}function c(e,t){var r,o,i;if(t.singleton){var n=x++;r=v||(v=a(t)),o=d.bind(null,r,n,!1),i=d.bind(null,r,n,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(r=l(t),o=u.bind(null,r),i=function(){s(r),r.href&&URL.revokeObjectURL(r.href)}):(r=a(t),o=p.bind(null,r),i=function(){s(r)});return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else i()}}function d(e,t,r,o){var i=r?"":o.css;if(e.styleSheet)e.styleSheet.cssText=y(t,i);else{var n=document.createTextNode(i),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(n,s[t]):e.appendChild(n)}}function p(e,t){var r=t.css,o=t.media;if(o&&e.setAttribute("media",o),e.styleSheet)e.styleSheet.cssText=r;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(r))}}function u(e,t){var r=t.css,o=t.sourceMap;o&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var i=new Blob([r],{type:"text/css"}),n=e.href;e.href=URL.createObjectURL(i),n&&URL.revokeObjectURL(n)}var h={},f=function(e){var t;return function(){return"undefined"==typeof t&&(t=e.apply(this,arguments)),t}},g=f(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),m=f(function(){return document.head||document.getElementsByTagName("head")[0]}),v=null,x=0,b=[];e.exports=function(e,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=g()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var r=i(e);return o(r,t),function(e){for(var n=[],s=0;s

"+this.args.title+"

")},t.prototype.createOpts=function(){var t,r,o,i,n;for(i=e("option",this.source),n=[],t=0,r=i.length;tthis.args.tooltipBreakpoint?e(o).text():""})).append(e(document.createElement("div")).html("×").addClass("add-remove "+(this.multi?void 0:"hidden"))));return n},t.prototype.monitorSource=function(){var t;return t=function(t){return function(){var r;return r=e(document.createElement("ul")).addClass("list-group").css("max-height",t.args.maxListHeight).append(t.createOpts()),e(".list-group",t.selectrContainer).replaceWith(r),t.updateFooter()}}(this),this.source.on("change",function(e,r){if("selectrInitiated"!==r)return t()})},t.prototype.bindEventListeners=function(){var t,r,o,i,n,s,a,l,c,d,p,u,h,f;return a=this.multi,p=this.selectrContainer,u=this.source,d=this.selectOption,n=this.deselectOption,h=this.triggerChange,f=this.updateFooter,s=function(t){var r,o;if(t.stopPropagation(),2!==(null!=(o=t.originalEvent)?o.detail:void 0))return r=(t.ctrlKey||t.metaKey)&&a,e(this).hasClass("selected")&&(r||0===e(this).siblings(".selected").length)&&a?n(this):d(r,this)},t=function(t){var r;if(t.stopPropagation(),!t.originalEvent.detail||2!==t.originalEvent.detail)return r=e(t.target).parents(".list-group-item"),r.hasClass("selected")?n(r):d(!0,r)},c=function(t){var r,o,i,n;return t.stopPropagation(),i=new RegExp(e(this).val().replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),"i"),n=!0,e(".list-group-item",p).each(function(t,r){e(r).text().match(i)?(e(r).removeClass("hidden"),n=!1):e(r).addClass("hidden")}),r=e(".clear-search",p),e(this).val().length>0?r.removeClass("hidden"):r.addClass("hidden"),o=e(".no-matching-options",p),n?o.removeClass("hidden"):o.addClass("hidden")},r=function(t){return e(this).siblings("input").val("").trigger("change")},l=function(t){return p.find("ul > li").removeClass("selected"),e("option",u).prop("selected",!1),h(u),f()},o=function(t){if(t.ctrlKey)return e(".list-group",p).addClass("ctrl-key")},i=function(t){if(!t.ctrlKey)return e(".list-group",p).removeClass("ctrl-key")},e(p).on("click",".list-group-item",s),e(p).on("click",".add-remove",t),e(p).on("click change keyup",".form-control",c),e(p).on("click",".clear-search",r),e(p).on("click",".reset",l),e(document).on("keydown",o),e(document).on("keyup",i)},t.prototype.triggerChange=function(){return this.source.trigger("change",["selectrInitiated"])},t.prototype.selectOption=function(t,r){var o,i,n,s;if(!(this.args.maxSelection<=e(r).siblings(".selected").length&&t)){if(!t)for(e("option",this.source).prop("selected",!1),n=e(r).siblings(),o=0,i=n.length;o0?r:""),r===this.args.maxSelection?this.selectrContainer.addClass("max-selection-reached"):this.selectrContainer.removeClass("max-selection-reached"),!this.args.alwaysShowFooter))return t=e(".panel-footer",this.selectrContainer),0===r?t.addClass("hidden"):t.removeClass("hidden")},t}(),e.fn.extend({selectr:function(t){return this.each(function(){var o;if(o=e(this),!o.data("selectr-initialized"))return new r(o,t),o.data("selectr-initialized",!0)})}})}(o,this)},function(t,r){t.exports=e},function(e,t,r){var o=r(3);"string"==typeof o&&(o=[[e.id,o,""]]);r(5)(o,{});o.locals&&(e.exports=o.locals)},function(e,t,r){t=e.exports=r(4)(),t.push([e.id,".selectr{margin:0;display:inline-block;max-width:100%}.selectr,.selectr :not(input){-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.selectr .panel-heading{cursor:default}.selectr .panel-heading.no-title{padding:0;border-bottom:none}.selectr .panel-body{position:relative}.selectr input::-ms-clear{display:none;width:0;height:0}.selectr .clear-search{position:absolute;right:25px;top:12px;font-size:28px;font-weight:700;color:#333;opacity:.8;cursor:pointer}.selectr .clear-search:hover{opacity:1}.selectr .list-group{overflow-x:hidden;-ms-overflow-y:auto}.selectr .list-group-item{padding:0!important;overflow:hidden;cursor:pointer}.selectr .list-group-item.selected{background-color:#4679bd;color:#fff;font-weight:700}.selectr .list-group-item.selected .add-remove{-webkit-transform:rotate(0deg);transform:rotate(0deg)}.selectr.multi .list-group-item:hover .option-name{margin-right:50px;border-right:1px solid #ddd}.selectr.multi .list-group-item:hover .selected .option-name{border-right:1px solid #fff}.selectr.multi .list-group-item:hover .add-remove{display:block}.selectr .option-name{height:100%;padding:10px 15px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.selectr .color-code{width:20px;height:20px;margin:10px;margin-right:0;float:left;border-radius:5px}.selectr .color-code.no-color{width:0;height:0;margin:0}.selectr .add-remove{-webkit-transform:rotate(45deg);transform:rotate(45deg);-webkit-transition:-webkit-transform .2s linear;transition:-webkit-transform .2s linear;transition:transform .2s linear;transition:transform .2s linear,-webkit-transform .2s linear;opacity:.5;display:none;cursor:pointer;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:24px;font-weight:900;position:absolute;right:0;top:0;width:50px;padding:8px;line-height:24px;text-align:center;vertical-align:middle}.selectr .add-remove:hover,.selectr .ctrl-key .add-remove{opacity:.8}.selectr .current-selection{float:right;margin-top:5px;cursor:default}.selectr.max-selection-reached li:not(.selected) .option-name{margin-right:0!important;border-right:none!important}.selectr.max-selection-reached li:not(.selected) .add-remove{display:none!important}.selectr.max-selection-reached .current-selection{background-color:#d9534f}.selectr .no-matching-options{padding:10px;padding-top:0;text-align:center}",""])},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t=0&&b.splice(t,1)}function a(e){var t=document.createElement("style");return t.type="text/css",n(e,t),t}function l(e){var t=document.createElement("link");return t.rel="stylesheet",n(e,t),t}function c(e,t){var r,o,i;if(t.singleton){var n=x++;r=v||(v=a(t)),o=d.bind(null,r,n,!1),i=d.bind(null,r,n,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(r=l(t),o=u.bind(null,r),i=function(){s(r),r.href&&URL.revokeObjectURL(r.href)}):(r=a(t),o=p.bind(null,r),i=function(){s(r)});return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else i()}}function d(e,t,r,o){var i=r?"":o.css;if(e.styleSheet)e.styleSheet.cssText=y(t,i);else{var n=document.createTextNode(i),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(n,s[t]):e.appendChild(n)}}function p(e,t){var r=t.css,o=t.media;if(o&&e.setAttribute("media",o),e.styleSheet)e.styleSheet.cssText=r;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(r))}}function u(e,t){var r=t.css,o=t.sourceMap;o&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var i=new Blob([r],{type:"text/css"}),n=e.href;e.href=URL.createObjectURL(i),n&&URL.revokeObjectURL(n)}var h={},f=function(e){var t;return function(){return"undefined"==typeof t&&(t=e.apply(this,arguments)),t}},g=f(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),m=f(function(){return document.head||document.getElementsByTagName("head")[0]}),v=null,x=0,b=[];e.exports=function(e,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=g()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var r=i(e);return o(r,t),function(e){for(var n=[],s=0;s