diff --git a/bower.json b/bower.json index 86959b2..63aadef 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "uxrocket.select", - "version": "3.5.7", + "version": "3.5.8", "homepage": "https://github.com/uxrocket/uxrocket.select", "authors": [ "Bilal Çınarlı " diff --git a/dist/uxrocket.select.js b/dist/uxrocket.select.js index b84664b..6f77d09 100644 --- a/dist/uxrocket.select.js +++ b/dist/uxrocket.select.js @@ -465,6 +465,7 @@ Select.prototype.unbindUI = function() { this.emitEvent('destroy'); this.$selection.off('.' + rocketName); + this.$selection.parent().off('.' + rocketName); this.$el.off('.' + rocketName); }; @@ -584,23 +585,29 @@ if(!this.$drop) { this.prepareDrop(); } else { - this.$drop.find('[data-value="' + value + '"]').parent().removeClass(selected) + this.$drop.find('[data-value="' + value + '"]').parent().removeClass(selected); } this.$el.find('[value="' + value + '"]').removeAttr('selected'); option.removeClass(selected); this.$selection.find('[data-value="' + value + '"]').remove(); - this.$el.val($.grep(this.$el.val(), function(val) { - return val !== value; - })); - - if(this.multiple && this.options.displayType !== 'tags' && this.$el.val() !== null) { - this.$selection - .find('.' + selectionText) - .html(this.options.multipleInfoMessage + ' ' + this.$el.val().length + '/' + this.optionData.length); + if(this.$el.val()) { + this.$el.val($.grep(this.$el.val(), function(val) { + return val !== value; + })); } - if(this.multiple && this.options.displayType === 'tags' && this.$el.val().length < 1) { + if(this.multiple && this.options.displayType !== 'tags') { + var $selection = this.$selection.find('.' + selectionText); + if(this.$el.val()) { + $selection.html(this.options.multipleInfoMessage + ' ' + this.$el.val().length + '/' + this.optionData.length); + } + else { + $selection.html(this.options.multipleInfoMessage + ' ' + 0 + '/' + this.optionData.length); + } + } + + if(this.multiple && this.options.displayType === 'tags' && (this.$el.val() === null || this.$el.val().length < 1)) { this.$selection.find('.' + selectionText).text(this.multiplePlaceholder); } @@ -826,16 +833,16 @@ minWidth: this.$selection.outerWidth() }; var optionList = $('.uxr-select-list'); - var dropHeight = this.$drop.height(); + var dropHeight = this.$drop.height() > 280 ? 280 : this.$drop.height(); // Max-height with search field var totalVisibleHeight = document.documentElement.clientHeight; - var topSpace = (this.$el.offset().top - $(window).scrollTop()) > 250 ? 250 : this.$el.offset().top - $(window).scrollTop(); - var bottomSpace = ((totalVisibleHeight - topSpace) - this.$selection.height()) > 250 ? 250 :(totalVisibleHeight - topSpace) - this.$selection.height(); + var topSpace = this.$el.offset().top - $(window).scrollTop(); + var bottomSpace = (totalVisibleHeight - topSpace) - this.$selection.height(); var setPosition = { top: function(){ - optionList.css( { maxHeight: topSpace } ); + optionList.css( { maxHeight: topSpace > 250 ? 250 : topSpace} ); // Max-height for options }, bottom: function(){ - optionList.css( { maxHeight: bottomSpace } ); + optionList.css( { maxHeight: bottomSpace > 250 ? 250 : bottomSpace } ); } }; if( bottomSpace >= dropHeight ){ @@ -1001,6 +1008,10 @@ focusedInstances.current = null; } + if(focusedInstances.current && focusedInstances.current.el === this.$el[0]) { + focusedInstances.current = null; + } + this.unbindUI(); this.undecorateUI(); @@ -1159,7 +1170,7 @@ }); // version - ux.version = '3.5.7'; + ux.version = '3.5.8'; // default settings ux.settings = defaults; diff --git a/dist/uxrocket.select.min.css b/dist/uxrocket.select.min.css index ec34ad7..8c71e3a 100644 --- a/dist/uxrocket.select.min.css +++ b/dist/uxrocket.select.min.css @@ -1,8 +1,8 @@ /*! UX Rocket Select * jQuery based Select box replacement function * @author Bilal Cinarli (http://bcinarli.com/) - * @version 3.5.7 - * @build Fri Oct 21 2016 11:16:17 GMT+0300 (Turkey Daylight Time) + * @version 3.5.8 + * @build Tue Nov 01 2016 15:47:56 GMT+0300 (Russia TZ 2 Standard Time) */ [class^="uxr-select-"]{box-sizing:border-box}.uxr-select-wrap .uxr-select-aria-hidden{position:absolute;overflow:hidden;width:1px;height:1px;margin:-1px;padding:0;border:0;clip:rect(0, 0, 0, 0);-webkit-clip-path:inset(0 0 0 0);clip-path:inset(0 0 0 0)}.uxr-select-ready{visibility:hidden}.uxr-select-selection{position:relative;overflow:hidden;display:inline-block;min-height:32px;border-radius:4px;border:1px solid #ccc;color:#222;text-decoration:none;vertical-align:middle}.uxr-select-selection.uxr-select-opened{border-radius:4px 4px 0 0}.uxr-select-selection.uxr-select-loading:after{position:absolute;top:4px;right:4px;width:20px;height:20px;border-radius:50%;border:dashed 2px #ccc;background-color:#fff;animation:uxr-select-loading 2s infinite linear;content:""}.uxr-select-selection-text{display:block;overflow:hidden;width:100%;padding:5px 30px 5px 5px;text-overflow:ellipsis;white-space:nowrap}.uxr-select-multiple .uxr-select-selection-text{padding:5px;overflow:auto;background-color:#fff;white-space:normal}.uxr-select-multiple.uxr-select-opened .uxr-select-selection-text:after{content:"|";animation:uxr-select-blink linear infinite 1s}.uxr-select-disabled,.uxr-select-disabled:hover{color:#999;cursor:default}.uxr-select-readonly,.uxr-select-readonly:hover{color:#777;cursor:default}.uxr-select-arrow{position:absolute;top:50%;right:5px;width:0;height:0;margin-top:-2px;border:5px solid;border-color:#555 transparent transparent}.uxr-select-multiple .uxr-select-arrow{display:none}.uxr-select-opened .uxr-select-arrow{margin-top:-7px;border-color:transparent transparent #555}.uxr-select-disabled .uxr-select-arrow{border-color:#999 transparent transparent}.uxr-select-disabled.uxr-select-opened .uxr-select-arrow{border-color:transparent transparent #999}.uxr-select-readonly .uxr-select-arrow{border-color:#777 transparent transparent}.uxr-select-readonly.uxr-select-opened .uxr-select-arrow{border-color:transparent transparent #777}.uxr-select-selected-tag{position:relative;display:inline-block;margin-bottom:3px;padding:3px 25px 3px 3px;border-radius:4px;background-color:#ddd;font-size:.8em;line-height:1}.uxr-select-remove-selected-tag{position:absolute;top:0;right:0;width:20px;height:100%;padding:3px;text-align:center;cursor:pointer}.uxr-select-drop{position:absolute;z-index:11000;border:1px solid #ccc;border-radius:0 0 4px;background-color:#fff}.uxr-select-drop ul{list-style:none;margin:0;padding:0}.uxr-select-drop li{list-style:none}.uxr-select-list{max-height:250px;overflow-y:auto}.uxr-select-list,.uxr-select-list ul{margin:0;padding:0;list-style:none}.uxr-select-search{display:block;padding:4px}.uxr-select-search input{width:calc(100% - 8px);padding:4px;border:1px solid #ccc;border-radius:4px}.uxr-select-search div[searchField="true"]{width:calc(100% - 8px);padding:4px;border:1px solid #ccc;border-radius:4px;height:25px}.uxr-select-group-name{display:block;padding:4px;font-weight:bold}.uxr-select-option{display:block;max-width:400px;padding:4px;cursor:pointer}.uxr-select-option:hover,.uxr-select-selected .uxr-select-option,.uxr-select-highlight .uxr-select-option{background-color:#f0f0f0}.uxr-select-disabled .uxr-select-option{background-color:#fff;color:#ccc;cursor:default}.uxr-select-hide{display:none}@keyframes uxr-select-blink{0%{opacity:0}50%{opacity:0}100%{opacity:1}}@keyframes uxr-select-loading{from{transform:rotate(0deg)}to{transform:rotate(360deg)}} diff --git a/dist/uxrocket.select.min.js b/dist/uxrocket.select.min.js index d3266dc..15c8088 100644 --- a/dist/uxrocket.select.min.js +++ b/dist/uxrocket.select.min.js @@ -1,7 +1,7 @@ /*! UX Rocket Select * jQuery based Select box replacement function * @author Bilal Cinarli (http://bcinarli.com/) - * @version 3.5.7 - * @build Fri Oct 21 2016 11:16:25 GMT+0300 (Turkey Daylight Time) + * @version 3.5.8 + * @build Tue Nov 01 2016 15:48:01 GMT+0300 (Russia TZ 2 Standard Time) */ -!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports&&"function"==typeof require?require("jquery"):jQuery)}(function(e){"use strict";"undefined"==typeof window.UXRocket&&console.warn("UXRocket Select is required UXRocket Factory to run properly. You can clone/download factory at https://github.com/uxrocket/uxrocket.factory");var t,s=1,i="uxrSelect",o={lastFocused:null,current:null},n=!1,a={selection:' {{selectionText}} ',tags:'{{#each selected}} {{selected.text}} X{{/each}}',multi:' {{selectionText}} X',search:' ',list:'
    {{#each options}} {{#if options.groupStart}}
  • {{options.groupName}} {{/if}} {{/each}}
',drop:'
{{search}} {{list}}
'},l={wrapper:"",opened:"",current:"",arrow:"",drop:"",list:"",option:"",selected:"",disabled:"",search:!0,searchItemLimit:10,searchType:"starts",displayType:"tags",multipleInfoMessage:"Seçilen Kayıt:",minLetters:2,maxSelection:0,maxSelectionWarn:"You have reached allowed maximum selection",numeric:!1,onReady:!1,onOpen:!1,onClose:!1,onSelect:!1,onChange:!1,onUpdate:!1,onDestroy:!1},r={focus:"focus."+i,blur:"blur."+i,change:"change."+i,click:"click."+i+" touchend."+i+" pointerup."+i+" MSPointerUp."+i,mousedown:"mousedown."+i+" touchend."+i+" pointerdown."+i+" MSPointerDown."+i,keyup:"keyup."+i,keydown:"keydown."+i,keypress:"keypress."+i,input:"input."+i,resize:"resize."+i,touchend:"touchend."+i+" pointerup."+i+" MSPointerUp."+i,touchmove:"touchmove."+i,ready:"uxrready."+i,open:"uxropen."+i,close:"uxrclose."+i,select:"uxrselect."+i,update:"uxrupdate."+i,destroy:"uxrdestroy."+i,scroll:"scroll"},p={codes:{8:"backspace",9:"tab",13:"return",27:"esc",37:"left",38:"up",39:"right",40:"down"},backspace:8,tab:9,"return":13,esc:27,left:37,up:38,right:39,down:40},h={prefix:"uxr-",rocket:"uxRocket",data:i,name:"select",classes:{wrap:"wrap",ready:"ready",disabled:"disabled",readonly:"readonly",selection:"selection",selectionText:"selection-text",selectionTag:"selected-tag",removeSelection:"remove-selected-tag",arrow:"arrow",multiple:"multiple",numeric:"numeric",opened:"opened",drop:"drop",reverseDrop:"reverse-drop",list:"list",option:"option",optionName:"option-name",group:"group",groupName:"group-name",highlight:"highlight",selected:"selected",search:"search",hidden:"aria-hidden",hide:"hide"}},c=new window.uxrPluginUtils({ns:h}),d=function(t,o,n){this._instance=s,this._name=i,this._defaults=l,this.wrapped=!1,this.el=t,this.$el=e(t),this.id="uxr-select-options-"+s,this.multiple=this.el.hasAttribute("multiple"),this.disabled=this.el.hasAttribute("disabled"),this.readonly=this.el.hasAttribute("readonly"),this.width=this.getWidth(),this.selector=n,this.opened=!1,this.hasGroup=!1,this.tabbed=!1,this.clicked=!1,this.searchQueryHolder=[],this.nonLetters=[8,9,13,27,38,40,46],this.options=e.extend(!0,{},l,o,this.$el.data()),s++,this.init()};d.prototype.init=function(){""===this.el.id&&(this.el.id=h.data+"-"+this._instance),this.registry(),this.getOptionData(),this.decorateUI(),this.bindUI(),this.bindSelectionUI(),this.$el.addClass(c.getClassname("ready")),this.emitEvent("ready")},d.prototype.getSelected=function(){var t=[];return this.multiple?this.$el.find("option:selected").each(function(){t.push({index:e(this).index(),value:e(this).attr("value"),text:e(this).text()})}):(t.value=this.$el.val(),t.text=this.$el.find("option:selected").text()),t},d.prototype.getOptionData=function(){var t=this,s=0;t.optionData=[],this.$el.find("option").each(function(){var i=!1,o=!1,n=!1;"OPTGROUP"===this.parentElement.tagName&&(this===this.parentElement.firstElementChild&&(o=this.parentElement.label,i=!0),this===this.parentElement.lastElementChild&&(n=!0)),t.optionData.push({groupName:o,groupStart:i,groupEnd:n,index:s,text:e(this).text(),value:e(this).val(),selected:e(this).is(":selected"),disabled:e(this).is(":disabled"),"class":e(this).attr("class")||""}),s++})},d.prototype.decorateUI=function(){this.addAttributes(),this.wrap(),this.addSelection()},d.prototype.undecorateUI=function(){this.unwrap(),this.removeSelection(),this.removeAttributes()},d.prototype.wrap=function(){this.$el.parent().is("label")?this.$el.parent().addClass(c.getClassname("wrap")):(this.wrapped=!0,this.$el.wrap('')),this.$el.parent().addClass(this.options.wrapper)},d.prototype.unwrap=function(){this.wrapped?this.$el.unwrap():this.$el.parent().removeClass(c.getClassname("wrap")+" "+this.options.wrapper)},d.prototype.addSelection=function(){var t=this.renderSelection();this.$selection=e(t),this.$el.after(this.$selection)},d.prototype.removeSelection=function(){this.$el.next("."+c.getClassname("selection")).remove(),delete this.$selection},d.prototype.addAttributes=function(){this.$el.addClass(c.getClassname("hidden")).attr("aria-hidden",!0)},d.prototype.removeAttributes=function(){this.$el.removeAttr("aria-hidden").removeClass(c.getClassname("hidden")+" "+c.getClassname("ready"))},d.prototype.bindUI=function(){var e=this;e.$el.on(r.focus,function(t){t.preventDefault(),e.onFocus()}).on(r.open,function(t){e.onOpen(t)}).on(r.close,function(t){e.onClose(t)}).on(r.change,function(t){e.onChange(t)}).on(r.ready,function(t){e.onReady(t)}).on(r.select,function(t){e.onSelect(t)}).on(r.update,function(){e.onUpdate()}).on(r.destroy,function(){e.onDestroy()})},d.prototype.bindSelectionUI=function(){var t=this;t.$selection.on(r.keyup,function(e){e.preventDefault(),t.onKeyup(e)}).on(r.focus,function(e){e.preventDefault(),t.onFocus()}).on(r.blur,function(){t.onBlur()}).on(r.mousedown,function(e){e.stopPropagation(),e.preventDefault(),t.onClick(e)}).on(r.click,function(e){e.stopPropagation(),e.preventDefault()}).on(r.mousedown,"."+c.getClassname("removeSelection"),function(s){return s.stopPropagation(),s.preventDefault(),!t.disabled&&(e(t.optionData).each(function(){this.text===e(s.target).parent().data("value")&&(this.selected=!1)}),void t.removeTag(e(this).parent()))}).parent().on(r.mousedown,function(e){e.stopPropagation(),e.preventDefault(),setTimeout(function(){t.onFocus()},100)})},d.prototype.bindDropUI=function(){var t=this;t.$drop.on(r.click,function(e){e.stopPropagation()}).on(r.touchmove,"."+c.getClassname("option"),function(e){e.stopPropagation(),n=!0}).on(r.mousedown,"."+c.getClassname("option"),function(s){s.stopPropagation(),s.preventDefault(),n||(t.emitEvent("select"),t.select(e(s.currentTarget))),n=!1}).on(r.focus,"."+c.getClassname("search")+" input",function(){t.setDropPosition(!0)}),t.bindKeyupListener()},d.prototype.unbindUI=function(){this.emitEvent("destroy"),this.$selection.off("."+i),this.$el.off("."+i)},d.prototype.unbindKeyupListener=function(){e(document).off(r.keyup)},d.prototype.bindKeyupListener=function(){var t=this;e(document).on(r.keyup,function(e){return e.preventDefault(),e.keyCode===p.up||e.keyCode===p.down?t.navigateWithArrow(p.codes[e.keyCode]):e.keyCode===p["return"]?t.navigateWithEnter():e.keyCode===p.esc?t.close():t.$search.val().length>=t.options.minLetters?t.search(t.$search.val()):t.setOriginalList(),!0})},d.prototype.select=function(e){var t=c.getClassname("selected"),s=c.getClassname("highlight"),i=c.getClassname("selectionText"),o=c.getClassname("selectionTag"),n=c.getClassname("removeSelection"),l=e.parent(),r=l.attr("id"),p=e.data("index"),h=e.data("value"),d=e.text(),u=this.$el.val();if(!l.hasClass(c.getClassname("disabled"))){if(this.multiple){if(l.hasClass(t))this.deSelect(h);else{if(this.options.maxSelection>0&&null!==u&&u.length>=this.options.maxSelection)return void alert(this.options.maxSelectionWarn);if(this.$el.find('[value="'+h+'"]').prop("selected",!0),l.addClass(t),"tags"===this.options.displayType){var f=c.render(a.multi,{selectionText:d,selectionTagClass:o,removeSelectionClass:n,index:p,value:h});null===this.$el.val()?this.$selection.find("."+i).html(f):this.$selection.find("."+i).append(f)}else this.$selection.find("."+i).html(this.options.multipleInfoMessage+" "+this.$el.val().length+"/"+this.optionData.length)}this.setDropPosition()}else this.$list.find("."+s).removeClass(s),this.$list.find("."+t).removeClass(t),this.$selection.find("."+i).text(d),this.$el.find('[value="'+h+'"]').prop("selected",!0),this.onBlur(),this.$list.find("#"+r).addClass(t),""!==this.$el.val()?this.$selection.parent().addClass(t+" "+this.options.selected):this.$selection.parent().removeClass(t+" "+this.options.selected);this.emitEvent("change")}},d.prototype.deSelect=function(t){var s=c.getClassname("selected"),i=c.getClassname("selectionText"),o=(c.getClassname("selectionTag"),e('[data-value="'+t+'"]').parent());this.$drop?this.$drop.find('[data-value="'+t+'"]').parent().removeClass(s):this.prepareDrop(),this.$el.find('[value="'+t+'"]').removeAttr("selected"),o.removeClass(s),this.$selection.find('[data-value="'+t+'"]').remove(),this.$el.val(e.grep(this.$el.val(),function(e){return e!==t})),this.multiple&&"tags"!==this.options.displayType&&null!==this.$el.val()&&this.$selection.find("."+i).html(this.options.multipleInfoMessage+" "+this.$el.val().length+"/"+this.optionData.length),this.multiple&&"tags"===this.options.displayType&&this.$el.val().length<1&&this.$selection.find("."+i).text(this.multiplePlaceholder),this.emitEvent("change"),this.$el.trigger("change")},d.prototype.removeTag=function(e){this.deSelect(e.data("value")),this.setDropPosition()},d.prototype.search=function(t){var s,i,o=this,n=this.$drop.find("."+c.getClassname("list"));s=e.map(this.optionData,function(e){if(o._search(e,t.trim()))return e}),i=this.renderList(s),n.replaceWith(i),this.setDropPosition()},d.prototype._search=function(e,t){var s=e.text.replace("İ","i").toLowerCase(),i=e.value.replace("İ","i").toLowerCase(),o=t.replace("İ","i").toLowerCase();switch(this.options.searchType){default:case"starts":return 0===s.indexOf(o)||0===i.toLowerCase().indexOf(o);case"contains":return s.indexOf(o)>-1||i.toLowerCase().indexOf(o)>-1}},d.prototype.navigateWithEnter=function(){if(!this.multiple){var e=this.$drop.find("."+c.getClassname("list")),t=c.getClassname("highlight"),s=e.find("."+t);s.length>0&&(s.removeClass(t),this.select(s.find("a")),this.emitEvent("select"))}},d.prototype.navigateWithArrow=function(t){var s,i=c.getClassname("highlight"),o=this.$drop.find("."+c.getClassname("list")),n=o.find("li:not(."+c.getClassname("group")+")"),a=o.find("."+i).length>0?o.find("."+i):o.find("."+c.getClassname("selected")),l=n.index(a),r=o.offset().top,p=o.scrollTop(),h=o.height();if(a.length)a.removeClass(i),"up"===t?--l<0&&(l=n.length-1):n.length===++l&&(l=0),s=e(n[l]).addClass(i),s.length&&("down"===t?s.offset().top>r+h-s.height()?o.scrollTop(p+s.height()):s.offset().topr+h&&o.scrollTop(p+s.offset().top));else{var d="up"===t?"last":"first";n[d]().addClass(i)}},d.prototype.renderSelection=function(){var e={id:this.el.id,selectionClass:c.getClassname("selection"),multiple:this.multiple,multipleClass:c.getClassname("multiple"),disabled:this.disabled,disabledClass:c.getClassname("disabled"),readonly:this.readonly,readonlyClass:c.getClassname("readonly"),width:"width:"+this.width,selectionTextClass:c.getClassname("selectionText"),selectionText:this.getSelected().text,arrowClass:c.getClassname("arrow"),themeCurrent:this.options.current,themeArrow:this.options.arrow};return this.multiple&&(this.multiplePlaceholder=this.$el.attr("placeholder")||this.options.placeholder||"",this.getSelected().length>0?"text"===this.options.displayType?e.selectionText=this.options.multipleInfoMessage+" "+this.getSelected().length+"/"+this.optionData.length:e.selectionText=this.renderSelectionTags():e.selectionText=this.multiplePlaceholder),c.render(a.selection,e)},d.prototype.renderSelectionTags=function(){var e={selectionTagClass:c.getClassname("selectionTag"),removeSelectionClass:c.getClassname("removeSelection"),selected:this.getSelected()};return c.render(a.tags,e)},d.prototype.renderSearchField=function(){var e={searchClass:c.getClassname("search"),searchInput:c.getClassname("search")+"-"+this._instance,inputType:this.options.numeric?"tel":"text",list:this.id};return c.render(a.search,e)},d.prototype.renderList=function(e){var t={listClass:c.getClassname("list"),groupClass:c.getClassname("group"),groupNameClass:c.getClassname("groupName"),selectedClass:c.getClassname("selected"),disabledClass:c.getClassname("disabled"),optionClass:c.getClassname("option"),options:e||this.optionData,themeList:this.options.list,themeSelected:this.options.selected,themeDisabled:this.options.disabled,themeOption:this.options.option};return c.render(a.list,t)},d.prototype.renderDrop=function(){var e={dropID:this.id,id:this.el.id,dropClass:c.getClassname("drop"),themeDrop:this.options.drop,multiple:this.multiple,multipleClass:c.getClassname("drop")+"-multiple",search:this.renderSearchField(),list:this.renderList()};return c.render(a.drop,e)},d.prototype.prepareDrop=function(){this.$drop=e(this.renderDrop()),this.$list=this.$drop.find("."+c.getClassname("list")),this.$search=this.$drop.find("."+c.getClassname("search")+" input"),this.setDropPosition(),this.setListPosition(),!this.options.search||this.options.searchItemLimit>=this.optionData.length?this.$search.parent().addClass(c.getClassname("hide")):this.$search.parent().removeClass(c.getClassname("hide"))},d.prototype.setDropPosition=function(t){var s={top:this.getPosition().top+this.$selection.height(),left:this.getPosition().left,minWidth:this.$selection.outerWidth()},i=e(".uxr-select-list"),o=this.$drop.height(),n=document.documentElement.clientHeight,a=this.$el.offset().top-e(window).scrollTop()>250?250:this.$el.offset().top-e(window).scrollTop(),l=n-a-this.$selection.height()>250?250:n-a-this.$selection.height(),r={top:function(){i.css({maxHeight:a})},bottom:function(){i.css({maxHeight:l})}};if(l>=o)r.bottom();else{var p=o-l0&&(e("#"+this.id).remove(),this.$search.val(""),this.setOriginalList())},d.prototype.open=function(){this.disabled||this.readonly||(t.close(),this.$drop||this.prepareDrop(),this.showDrop(),this.$selection.parent().addClass(c.getClassname("opened")+" "+this.options.opened),this.opened=!0,this.$search.focus(),this.emitEvent("open"))},d.prototype.close=function(){n=!1,this.clicked=!1,this.tabbed=!1,this.opened=!1,this.unbindKeyupListener(),this.hideDrop(),this.$selection.parent().removeClass(c.getClassname("opened")+" "+this.options.opened),this.emitEvent("close")},d.prototype.onKeyup=function(e){e.keyCode===p.tab&&(this.tabbed=!0)},d.prototype.onClick=function(e){this.clicked=!0,this.opened?this.onBlur():this.onFocus()},d.prototype.onFocus=function(){o.lastFocused=o.current,o.current=this,this.open()},d.prototype.onBlur=function(){this.close()},d.prototype.onChange=function(e){c.callback(this.options.onChange)},d.prototype.onReady=function(){c.callback(this.options.onReady)},d.prototype.onOpen=function(){c.callback(this.options.onOpen)},d.prototype.onClose=function(){c.callback(this.options.onClose)},d.prototype.onSelect=function(){c.callback(this.options.onSelect)},d.prototype.onUpdate=function(){c.callback(this.options.onUpdate)},d.prototype.onDestroy=function(){c.callback(this.options.onDestroy)},d.prototype.resetSelection=function(){this.removeSelection(),this.addSelection(),this.bindSelectionUI()},d.prototype.update=function(t){var s=this.options;this.multiple=this.el.hasAttribute("multiple"),this.disabled=this.el.hasAttribute("disabled"),this.readonly=this.el.hasAttribute("readonly"),this.options=e.extend(!0,{},s,t),this.getOptionData(),this.resetSelection(),this.prepareDrop(),this.emitEvent("update")},d.prototype.destroy=function(){this.emitEvent("destroy"),this.opened&&(this.close(),o.current=null),this.unbindUI(),this.undecorateUI(),this.$el.removeData(i)},d.prototype.registry=function(){var e=this.$el.data(h.rocket)||{};e[h.data]={hasWrapper:!0,wrapper:h.wrap,ready:c.getClassname("ready"),selector:this.selector,options:this.options},this.$el.data(h.rocket,e)},d.prototype.getPosition=function(){return{top:this.$selection.offset().top,left:this.$selection.offset().left}},d.prototype.getWidth=function(){var t,s=this.$el.attr("class"),i=this.$el.attr("style"),o=e(document.createElement("div")).css("display","none"),n="";return s&&(n+=' class="'+s.replace(c.getClassname("ready"),"").replace(c.getClassname("hidden"),"")+'"'),i&&(n+=' style="'+i+'"'),o.html("
").appendTo("body"),t=o.find("div").css("width"),"0px"===t&&(t=this.$el.width()+"px"),o.remove(),t},d.prototype.emitEvent=function(e){this.$el.trigger(r[e])},d.prototype.isTouchDevice=function(){return"ontouchstart"in window||navigator.msMaxTouchPoints};var u=e.fn.select;t=e.fn.uxitdselect=e.fn.select=e.fn.Select=e.fn.uxrselect=e.uxrselect=function(t){var s=this.selector;return this.each(function(){e.data(this,h.data)||e.data(this,h.data,new d(this,t,s))})},e.uxrselect.noConflict=!0,t.update=function(t,s){var i,o=s||t;if(t)if("string"==typeof t)i=e(t);else{if("object"!=typeof t)return;i=t}else i=e("."+c.getClassname("ready"));i.filter("select").each(function(){e(this).hasClass(c.getClassname("ready"))?e(this).data(h.data).update(o):console.warn("Component not initialized yet, update after initialization")})},t.close=function(){var t=e("."+c.getClassname("drop"));t.length>0&&t.each(function(){var t=e(c.escapeSelector("#"+e(this).data("select"))).data(h.data);t.close()})},t.destroy=t.remove=function(t){var s=e("undefined"==typeof t?"."+c.getClassname("ready"):t);s.each(function(){e(this).data(h.data).destroy()})},t.getFocusedInstances=function(){return o},e(document).on("ready",function(){e.uxrselect.noConflict&&(e.fn.select=u)}).on(r.click,function(e){null!==o.current&&o.current.close()}),e(window).on(r.resize+" "+r.touchend+" "+r.scroll,function(){var t=e("."+c.getClassname("drop"));1===t.length&&e(c.escapeSelector("#"+t.data("select"))).data(h.data).setDropPosition()}),t.version="3.5.7",t.settings=l,t.namespace=h}); \ No newline at end of file +!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports&&"function"==typeof require?require("jquery"):jQuery)}(function(e){"use strict";"undefined"==typeof window.UXRocket&&console.warn("UXRocket Select is required UXRocket Factory to run properly. You can clone/download factory at https://github.com/uxrocket/uxrocket.factory");var t,s=1,i="uxrSelect",o={lastFocused:null,current:null},n=!1,a={selection:' {{selectionText}} ',tags:'{{#each selected}} {{selected.text}} X{{/each}}',multi:' {{selectionText}} X',search:' ',list:'
    {{#each options}} {{#if options.groupStart}}
  • {{options.groupName}} {{/if}} {{/each}}
',drop:'
{{search}} {{list}}
'},l={wrapper:"",opened:"",current:"",arrow:"",drop:"",list:"",option:"",selected:"",disabled:"",search:!0,searchItemLimit:10,searchType:"starts",displayType:"tags",multipleInfoMessage:"Seçilen Kayıt:",minLetters:2,maxSelection:0,maxSelectionWarn:"You have reached allowed maximum selection",numeric:!1,onReady:!1,onOpen:!1,onClose:!1,onSelect:!1,onChange:!1,onUpdate:!1,onDestroy:!1},r={focus:"focus."+i,blur:"blur."+i,change:"change."+i,click:"click."+i+" touchend."+i+" pointerup."+i+" MSPointerUp."+i,mousedown:"mousedown."+i+" touchend."+i+" pointerdown."+i+" MSPointerDown."+i,keyup:"keyup."+i,keydown:"keydown."+i,keypress:"keypress."+i,input:"input."+i,resize:"resize."+i,touchend:"touchend."+i+" pointerup."+i+" MSPointerUp."+i,touchmove:"touchmove."+i,ready:"uxrready."+i,open:"uxropen."+i,close:"uxrclose."+i,select:"uxrselect."+i,update:"uxrupdate."+i,destroy:"uxrdestroy."+i,scroll:"scroll"},p={codes:{8:"backspace",9:"tab",13:"return",27:"esc",37:"left",38:"up",39:"right",40:"down"},backspace:8,tab:9,"return":13,esc:27,left:37,up:38,right:39,down:40},h={prefix:"uxr-",rocket:"uxRocket",data:i,name:"select",classes:{wrap:"wrap",ready:"ready",disabled:"disabled",readonly:"readonly",selection:"selection",selectionText:"selection-text",selectionTag:"selected-tag",removeSelection:"remove-selected-tag",arrow:"arrow",multiple:"multiple",numeric:"numeric",opened:"opened",drop:"drop",reverseDrop:"reverse-drop",list:"list",option:"option",optionName:"option-name",group:"group",groupName:"group-name",highlight:"highlight",selected:"selected",search:"search",hidden:"aria-hidden",hide:"hide"}},c=new window.uxrPluginUtils({ns:h}),d=function(t,o,n){this._instance=s,this._name=i,this._defaults=l,this.wrapped=!1,this.el=t,this.$el=e(t),this.id="uxr-select-options-"+s,this.multiple=this.el.hasAttribute("multiple"),this.disabled=this.el.hasAttribute("disabled"),this.readonly=this.el.hasAttribute("readonly"),this.width=this.getWidth(),this.selector=n,this.opened=!1,this.hasGroup=!1,this.tabbed=!1,this.clicked=!1,this.searchQueryHolder=[],this.nonLetters=[8,9,13,27,38,40,46],this.options=e.extend(!0,{},l,o,this.$el.data()),s++,this.init()};d.prototype.init=function(){""===this.el.id&&(this.el.id=h.data+"-"+this._instance),this.registry(),this.getOptionData(),this.decorateUI(),this.bindUI(),this.bindSelectionUI(),this.$el.addClass(c.getClassname("ready")),this.emitEvent("ready")},d.prototype.getSelected=function(){var t=[];return this.multiple?this.$el.find("option:selected").each(function(){t.push({index:e(this).index(),value:e(this).attr("value"),text:e(this).text()})}):(t.value=this.$el.val(),t.text=this.$el.find("option:selected").text()),t},d.prototype.getOptionData=function(){var t=this,s=0;t.optionData=[],this.$el.find("option").each(function(){var i=!1,o=!1,n=!1;"OPTGROUP"===this.parentElement.tagName&&(this===this.parentElement.firstElementChild&&(o=this.parentElement.label,i=!0),this===this.parentElement.lastElementChild&&(n=!0)),t.optionData.push({groupName:o,groupStart:i,groupEnd:n,index:s,text:e(this).text(),value:e(this).val(),selected:e(this).is(":selected"),disabled:e(this).is(":disabled"),"class":e(this).attr("class")||""}),s++})},d.prototype.decorateUI=function(){this.addAttributes(),this.wrap(),this.addSelection()},d.prototype.undecorateUI=function(){this.unwrap(),this.removeSelection(),this.removeAttributes()},d.prototype.wrap=function(){this.$el.parent().is("label")?this.$el.parent().addClass(c.getClassname("wrap")):(this.wrapped=!0,this.$el.wrap('')),this.$el.parent().addClass(this.options.wrapper)},d.prototype.unwrap=function(){this.wrapped?this.$el.unwrap():this.$el.parent().removeClass(c.getClassname("wrap")+" "+this.options.wrapper)},d.prototype.addSelection=function(){var t=this.renderSelection();this.$selection=e(t),this.$el.after(this.$selection)},d.prototype.removeSelection=function(){this.$el.next("."+c.getClassname("selection")).remove(),delete this.$selection},d.prototype.addAttributes=function(){this.$el.addClass(c.getClassname("hidden")).attr("aria-hidden",!0)},d.prototype.removeAttributes=function(){this.$el.removeAttr("aria-hidden").removeClass(c.getClassname("hidden")+" "+c.getClassname("ready"))},d.prototype.bindUI=function(){var e=this;e.$el.on(r.focus,function(t){t.preventDefault(),e.onFocus()}).on(r.open,function(t){e.onOpen(t)}).on(r.close,function(t){e.onClose(t)}).on(r.change,function(t){e.onChange(t)}).on(r.ready,function(t){e.onReady(t)}).on(r.select,function(t){e.onSelect(t)}).on(r.update,function(){e.onUpdate()}).on(r.destroy,function(){e.onDestroy()})},d.prototype.bindSelectionUI=function(){var t=this;t.$selection.on(r.keyup,function(e){e.preventDefault(),t.onKeyup(e)}).on(r.focus,function(e){e.preventDefault(),t.onFocus()}).on(r.blur,function(){t.onBlur()}).on(r.mousedown,function(e){e.stopPropagation(),e.preventDefault(),t.onClick(e)}).on(r.click,function(e){e.stopPropagation(),e.preventDefault()}).on(r.mousedown,"."+c.getClassname("removeSelection"),function(s){return s.stopPropagation(),s.preventDefault(),!t.disabled&&(e(t.optionData).each(function(){this.text===e(s.target).parent().data("value")&&(this.selected=!1)}),void t.removeTag(e(this).parent()))}).parent().on(r.mousedown,function(e){e.stopPropagation(),e.preventDefault(),setTimeout(function(){t.onFocus()},100)})},d.prototype.bindDropUI=function(){var t=this;t.$drop.on(r.click,function(e){e.stopPropagation()}).on(r.touchmove,"."+c.getClassname("option"),function(e){e.stopPropagation(),n=!0}).on(r.mousedown,"."+c.getClassname("option"),function(s){s.stopPropagation(),s.preventDefault(),n||(t.emitEvent("select"),t.select(e(s.currentTarget))),n=!1}).on(r.focus,"."+c.getClassname("search")+" input",function(){t.setDropPosition(!0)}),t.bindKeyupListener()},d.prototype.unbindUI=function(){this.emitEvent("destroy"),this.$selection.off("."+i),this.$selection.parent().off("."+i),this.$el.off("."+i)},d.prototype.unbindKeyupListener=function(){e(document).off(r.keyup)},d.prototype.bindKeyupListener=function(){var t=this;e(document).on(r.keyup,function(e){return e.preventDefault(),e.keyCode===p.up||e.keyCode===p.down?t.navigateWithArrow(p.codes[e.keyCode]):e.keyCode===p["return"]?t.navigateWithEnter():e.keyCode===p.esc?t.close():t.$search.val().length>=t.options.minLetters?t.search(t.$search.val()):t.setOriginalList(),!0})},d.prototype.select=function(e){var t=c.getClassname("selected"),s=c.getClassname("highlight"),i=c.getClassname("selectionText"),o=c.getClassname("selectionTag"),n=c.getClassname("removeSelection"),l=e.parent(),r=l.attr("id"),p=e.data("index"),h=e.data("value"),d=e.text(),u=this.$el.val();if(!l.hasClass(c.getClassname("disabled"))){if(this.multiple){if(l.hasClass(t))this.deSelect(h);else{if(this.options.maxSelection>0&&null!==u&&u.length>=this.options.maxSelection)return void alert(this.options.maxSelectionWarn);if(this.$el.find('[value="'+h+'"]').prop("selected",!0),l.addClass(t),"tags"===this.options.displayType){var f=c.render(a.multi,{selectionText:d,selectionTagClass:o,removeSelectionClass:n,index:p,value:h});null===this.$el.val()?this.$selection.find("."+i).html(f):this.$selection.find("."+i).append(f)}else this.$selection.find("."+i).html(this.options.multipleInfoMessage+" "+this.$el.val().length+"/"+this.optionData.length)}this.setDropPosition()}else this.$list.find("."+s).removeClass(s),this.$list.find("."+t).removeClass(t),this.$selection.find("."+i).text(d),this.$el.find('[value="'+h+'"]').prop("selected",!0),this.onBlur(),this.$list.find("#"+r).addClass(t),""!==this.$el.val()?this.$selection.parent().addClass(t+" "+this.options.selected):this.$selection.parent().removeClass(t+" "+this.options.selected);this.emitEvent("change")}},d.prototype.deSelect=function(t){var s=c.getClassname("selected"),i=c.getClassname("selectionText"),o=(c.getClassname("selectionTag"),e('[data-value="'+t+'"]').parent());if(this.$drop?this.$drop.find('[data-value="'+t+'"]').parent().removeClass(s):this.prepareDrop(),this.$el.find('[value="'+t+'"]').removeAttr("selected"),o.removeClass(s),this.$selection.find('[data-value="'+t+'"]').remove(),this.$el.val()&&this.$el.val(e.grep(this.$el.val(),function(e){return e!==t})),this.multiple&&"tags"!==this.options.displayType){var n=this.$selection.find("."+i);this.$el.val()?n.html(this.options.multipleInfoMessage+" "+this.$el.val().length+"/"+this.optionData.length):n.html(this.options.multipleInfoMessage+" 0/"+this.optionData.length)}this.multiple&&"tags"===this.options.displayType&&(null===this.$el.val()||this.$el.val().length<1)&&this.$selection.find("."+i).text(this.multiplePlaceholder),this.emitEvent("change"),this.$el.trigger("change")},d.prototype.removeTag=function(e){this.deSelect(e.data("value")),this.setDropPosition()},d.prototype.search=function(t){var s,i,o=this,n=this.$drop.find("."+c.getClassname("list"));s=e.map(this.optionData,function(e){if(o._search(e,t.trim()))return e}),i=this.renderList(s),n.replaceWith(i),this.setDropPosition()},d.prototype._search=function(e,t){var s=e.text.replace("İ","i").toLowerCase(),i=e.value.replace("İ","i").toLowerCase(),o=t.replace("İ","i").toLowerCase();switch(this.options.searchType){default:case"starts":return 0===s.indexOf(o)||0===i.toLowerCase().indexOf(o);case"contains":return s.indexOf(o)>-1||i.toLowerCase().indexOf(o)>-1}},d.prototype.navigateWithEnter=function(){if(!this.multiple){var e=this.$drop.find("."+c.getClassname("list")),t=c.getClassname("highlight"),s=e.find("."+t);s.length>0&&(s.removeClass(t),this.select(s.find("a")),this.emitEvent("select"))}},d.prototype.navigateWithArrow=function(t){var s,i=c.getClassname("highlight"),o=this.$drop.find("."+c.getClassname("list")),n=o.find("li:not(."+c.getClassname("group")+")"),a=o.find("."+i).length>0?o.find("."+i):o.find("."+c.getClassname("selected")),l=n.index(a),r=o.offset().top,p=o.scrollTop(),h=o.height();if(a.length)a.removeClass(i),"up"===t?--l<0&&(l=n.length-1):n.length===++l&&(l=0),s=e(n[l]).addClass(i),s.length&&("down"===t?s.offset().top>r+h-s.height()?o.scrollTop(p+s.height()):s.offset().topr+h&&o.scrollTop(p+s.offset().top));else{var d="up"===t?"last":"first";n[d]().addClass(i)}},d.prototype.renderSelection=function(){var e={id:this.el.id,selectionClass:c.getClassname("selection"),multiple:this.multiple,multipleClass:c.getClassname("multiple"),disabled:this.disabled,disabledClass:c.getClassname("disabled"),readonly:this.readonly,readonlyClass:c.getClassname("readonly"),width:"width:"+this.width,selectionTextClass:c.getClassname("selectionText"),selectionText:this.getSelected().text,arrowClass:c.getClassname("arrow"),themeCurrent:this.options.current,themeArrow:this.options.arrow};return this.multiple&&(this.multiplePlaceholder=this.$el.attr("placeholder")||this.options.placeholder||"",this.getSelected().length>0?"text"===this.options.displayType?e.selectionText=this.options.multipleInfoMessage+" "+this.getSelected().length+"/"+this.optionData.length:e.selectionText=this.renderSelectionTags():e.selectionText=this.multiplePlaceholder),c.render(a.selection,e)},d.prototype.renderSelectionTags=function(){var e={selectionTagClass:c.getClassname("selectionTag"),removeSelectionClass:c.getClassname("removeSelection"),selected:this.getSelected()};return c.render(a.tags,e)},d.prototype.renderSearchField=function(){var e={searchClass:c.getClassname("search"),searchInput:c.getClassname("search")+"-"+this._instance,inputType:this.options.numeric?"tel":"text",list:this.id};return c.render(a.search,e)},d.prototype.renderList=function(e){var t={listClass:c.getClassname("list"),groupClass:c.getClassname("group"),groupNameClass:c.getClassname("groupName"),selectedClass:c.getClassname("selected"),disabledClass:c.getClassname("disabled"),optionClass:c.getClassname("option"),options:e||this.optionData,themeList:this.options.list,themeSelected:this.options.selected,themeDisabled:this.options.disabled,themeOption:this.options.option};return c.render(a.list,t)},d.prototype.renderDrop=function(){var e={dropID:this.id,id:this.el.id,dropClass:c.getClassname("drop"),themeDrop:this.options.drop,multiple:this.multiple,multipleClass:c.getClassname("drop")+"-multiple",search:this.renderSearchField(),list:this.renderList()};return c.render(a.drop,e)},d.prototype.prepareDrop=function(){this.$drop=e(this.renderDrop()),this.$list=this.$drop.find("."+c.getClassname("list")),this.$search=this.$drop.find("."+c.getClassname("search")+" input"),this.setDropPosition(),this.setListPosition(),!this.options.search||this.options.searchItemLimit>=this.optionData.length?this.$search.parent().addClass(c.getClassname("hide")):this.$search.parent().removeClass(c.getClassname("hide"))},d.prototype.setDropPosition=function(t){var s={top:this.getPosition().top+this.$selection.height(),left:this.getPosition().left,minWidth:this.$selection.outerWidth()},i=e(".uxr-select-list"),o=this.$drop.height()>280?280:this.$drop.height(),n=document.documentElement.clientHeight,a=this.$el.offset().top-e(window).scrollTop(),l=n-a-this.$selection.height(),r={top:function(){i.css({maxHeight:a>250?250:a})},bottom:function(){i.css({maxHeight:l>250?250:l})}};if(l>=o)r.bottom();else{var p=o-l0&&(e("#"+this.id).remove(),this.$search.val(""),this.setOriginalList())},d.prototype.open=function(){this.disabled||this.readonly||(t.close(),this.$drop||this.prepareDrop(),this.showDrop(),this.$selection.parent().addClass(c.getClassname("opened")+" "+this.options.opened),this.opened=!0,this.$search.focus(),this.emitEvent("open"))},d.prototype.close=function(){n=!1,this.clicked=!1,this.tabbed=!1,this.opened=!1,this.unbindKeyupListener(),this.hideDrop(),this.$selection.parent().removeClass(c.getClassname("opened")+" "+this.options.opened),this.emitEvent("close")},d.prototype.onKeyup=function(e){e.keyCode===p.tab&&(this.tabbed=!0)},d.prototype.onClick=function(e){this.clicked=!0,this.opened?this.onBlur():this.onFocus()},d.prototype.onFocus=function(){o.lastFocused=o.current,o.current=this,this.open()},d.prototype.onBlur=function(){this.close()},d.prototype.onChange=function(e){c.callback(this.options.onChange)},d.prototype.onReady=function(){c.callback(this.options.onReady)},d.prototype.onOpen=function(){c.callback(this.options.onOpen)},d.prototype.onClose=function(){c.callback(this.options.onClose)},d.prototype.onSelect=function(){c.callback(this.options.onSelect)},d.prototype.onUpdate=function(){c.callback(this.options.onUpdate)},d.prototype.onDestroy=function(){c.callback(this.options.onDestroy)},d.prototype.resetSelection=function(){this.removeSelection(),this.addSelection(),this.bindSelectionUI()},d.prototype.update=function(t){var s=this.options;this.multiple=this.el.hasAttribute("multiple"),this.disabled=this.el.hasAttribute("disabled"),this.readonly=this.el.hasAttribute("readonly"),this.options=e.extend(!0,{},s,t),this.getOptionData(),this.resetSelection(),this.prepareDrop(),this.emitEvent("update")},d.prototype.destroy=function(){this.emitEvent("destroy"),this.opened&&(this.close(),o.current=null),o.current&&o.current.el===this.$el[0]&&(o.current=null),this.unbindUI(),this.undecorateUI(),this.$el.removeData(i)},d.prototype.registry=function(){var e=this.$el.data(h.rocket)||{};e[h.data]={hasWrapper:!0,wrapper:h.wrap,ready:c.getClassname("ready"),selector:this.selector,options:this.options},this.$el.data(h.rocket,e)},d.prototype.getPosition=function(){return{top:this.$selection.offset().top,left:this.$selection.offset().left}},d.prototype.getWidth=function(){var t,s=this.$el.attr("class"),i=this.$el.attr("style"),o=e(document.createElement("div")).css("display","none"),n="";return s&&(n+=' class="'+s.replace(c.getClassname("ready"),"").replace(c.getClassname("hidden"),"")+'"'),i&&(n+=' style="'+i+'"'),o.html("
").appendTo("body"),t=o.find("div").css("width"),"0px"===t&&(t=this.$el.width()+"px"),o.remove(),t},d.prototype.emitEvent=function(e){this.$el.trigger(r[e])},d.prototype.isTouchDevice=function(){return"ontouchstart"in window||navigator.msMaxTouchPoints};var u=e.fn.select;t=e.fn.uxitdselect=e.fn.select=e.fn.Select=e.fn.uxrselect=e.uxrselect=function(t){var s=this.selector;return this.each(function(){e.data(this,h.data)||e.data(this,h.data,new d(this,t,s))})},e.uxrselect.noConflict=!0,t.update=function(t,s){var i,o=s||t;if(t)if("string"==typeof t)i=e(t);else{if("object"!=typeof t)return;i=t}else i=e("."+c.getClassname("ready"));i.filter("select").each(function(){e(this).hasClass(c.getClassname("ready"))?e(this).data(h.data).update(o):console.warn("Component not initialized yet, update after initialization")})},t.close=function(){var t=e("."+c.getClassname("drop"));t.length>0&&t.each(function(){var t=e(c.escapeSelector("#"+e(this).data("select"))).data(h.data);t.close()})},t.destroy=t.remove=function(t){var s=e("undefined"==typeof t?"."+c.getClassname("ready"):t);s.each(function(){e(this).data(h.data).destroy()})},t.getFocusedInstances=function(){return o},e(document).on("ready",function(){e.uxrselect.noConflict&&(e.fn.select=u)}).on(r.click,function(e){null!==o.current&&o.current.close()}),e(window).on(r.resize+" "+r.touchend+" "+r.scroll,function(){var t=e("."+c.getClassname("drop"));1===t.length&&e(c.escapeSelector("#"+t.data("select"))).data(h.data).setDropPosition()}),t.version="3.5.8",t.settings=l,t.namespace=h}); \ No newline at end of file diff --git a/examples/index.html b/examples/index.html index e2d127f..753d120 100644 --- a/examples/index.html +++ b/examples/index.html @@ -3480,7 +3480,6 @@ console.log('Selected Text: ' + $el.text()); } } - var $s = $('#sample-01').data('uxrSelect'); diff --git a/lib/uxrocket.select.js b/lib/uxrocket.select.js index b84664b..6f77d09 100644 --- a/lib/uxrocket.select.js +++ b/lib/uxrocket.select.js @@ -465,6 +465,7 @@ Select.prototype.unbindUI = function() { this.emitEvent('destroy'); this.$selection.off('.' + rocketName); + this.$selection.parent().off('.' + rocketName); this.$el.off('.' + rocketName); }; @@ -584,23 +585,29 @@ if(!this.$drop) { this.prepareDrop(); } else { - this.$drop.find('[data-value="' + value + '"]').parent().removeClass(selected) + this.$drop.find('[data-value="' + value + '"]').parent().removeClass(selected); } this.$el.find('[value="' + value + '"]').removeAttr('selected'); option.removeClass(selected); this.$selection.find('[data-value="' + value + '"]').remove(); - this.$el.val($.grep(this.$el.val(), function(val) { - return val !== value; - })); - - if(this.multiple && this.options.displayType !== 'tags' && this.$el.val() !== null) { - this.$selection - .find('.' + selectionText) - .html(this.options.multipleInfoMessage + ' ' + this.$el.val().length + '/' + this.optionData.length); + if(this.$el.val()) { + this.$el.val($.grep(this.$el.val(), function(val) { + return val !== value; + })); } - if(this.multiple && this.options.displayType === 'tags' && this.$el.val().length < 1) { + if(this.multiple && this.options.displayType !== 'tags') { + var $selection = this.$selection.find('.' + selectionText); + if(this.$el.val()) { + $selection.html(this.options.multipleInfoMessage + ' ' + this.$el.val().length + '/' + this.optionData.length); + } + else { + $selection.html(this.options.multipleInfoMessage + ' ' + 0 + '/' + this.optionData.length); + } + } + + if(this.multiple && this.options.displayType === 'tags' && (this.$el.val() === null || this.$el.val().length < 1)) { this.$selection.find('.' + selectionText).text(this.multiplePlaceholder); } @@ -826,16 +833,16 @@ minWidth: this.$selection.outerWidth() }; var optionList = $('.uxr-select-list'); - var dropHeight = this.$drop.height(); + var dropHeight = this.$drop.height() > 280 ? 280 : this.$drop.height(); // Max-height with search field var totalVisibleHeight = document.documentElement.clientHeight; - var topSpace = (this.$el.offset().top - $(window).scrollTop()) > 250 ? 250 : this.$el.offset().top - $(window).scrollTop(); - var bottomSpace = ((totalVisibleHeight - topSpace) - this.$selection.height()) > 250 ? 250 :(totalVisibleHeight - topSpace) - this.$selection.height(); + var topSpace = this.$el.offset().top - $(window).scrollTop(); + var bottomSpace = (totalVisibleHeight - topSpace) - this.$selection.height(); var setPosition = { top: function(){ - optionList.css( { maxHeight: topSpace } ); + optionList.css( { maxHeight: topSpace > 250 ? 250 : topSpace} ); // Max-height for options }, bottom: function(){ - optionList.css( { maxHeight: bottomSpace } ); + optionList.css( { maxHeight: bottomSpace > 250 ? 250 : bottomSpace } ); } }; if( bottomSpace >= dropHeight ){ @@ -1001,6 +1008,10 @@ focusedInstances.current = null; } + if(focusedInstances.current && focusedInstances.current.el === this.$el[0]) { + focusedInstances.current = null; + } + this.unbindUI(); this.undecorateUI(); @@ -1159,7 +1170,7 @@ }); // version - ux.version = '3.5.7'; + ux.version = '3.5.8'; // default settings ux.settings = defaults; diff --git a/package.json b/package.json index e8ea0f1..a801afc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uxrocket.select", - "version": "3.5.7", + "version": "3.5.8", "description": "jQuery based Select box replacement function", "repository": { "type": "git", diff --git a/uxrocket.json b/uxrocket.json index 79d2e92..5593536 100644 --- a/uxrocket.json +++ b/uxrocket.json @@ -1,7 +1,7 @@ { "name": "Select", "registry": "uxrocket.select", - "version": "3.5.7", + "version": "3.5.8", "paths": { "lib": "lib/", "dist": "dist/", diff --git a/version.md b/version.md index b7ab390..14aba67 100644 --- a/version.md +++ b/version.md @@ -1,3 +1,8 @@ +## Versiyon 3.5.8 +- FIX: Display-type text durumunda seçim sayısının sıfır olmaması problemi giderildi. +- FIX: Drop pozisyonunun hesaplanmasındaki bir yanlışlık düzeltildi. +- FIX: Component remove edildikten sonra da çalışan bir event düzeltildi. + ## Versiyon 3.5.7 - FIX: Display-type text olması durumunda pre-selected verilerin tag şeklinde gözükmesi problemi giderildi. - FIX: Display-type tag olması durumunda pre-selected verilerin çalışması düzenlendi.