diff --git a/dist/lib/picker/zui.picker.css b/dist/lib/picker/zui.picker.css index 609c55269d39c42044bef264fee91daa7f6caff9..6d187a052cc397c1d80baf436c8f5f5309d116b4 100644 --- a/dist/lib/picker/zui.picker.css +++ b/dist/lib/picker/zui.picker.css @@ -1,5 +1,5 @@ /*! - * ZUI: 选择器 - v1.9.1 - 2020-05-11 + * ZUI: 选择器 - v1.9.1 - 2020-05-12 * http://openzui.com * GitHub: https://github.com/easysoft/zui.git * Copyright (c) 2020 cnezsoft.com; Licensed MIT @@ -151,6 +151,9 @@ .picker-single.picker-focus .picker-selection-remove { display: none; } +.picker-multi.picker-sortable .picker-selection-text { + cursor: move; + } .picker-search { color: transparent; background: none; diff --git a/dist/lib/picker/zui.picker.js b/dist/lib/picker/zui.picker.js index b5906bc072fb8a9c10d5c75d06a47525e45d9c16..748684a9063dbf80e58477369591d20b089848cb 100644 --- a/dist/lib/picker/zui.picker.js +++ b/dist/lib/picker/zui.picker.js @@ -1,5 +1,5 @@ /*! - * ZUI: 选择器 - v1.9.1 - 2020-05-11 + * ZUI: 选择器 - v1.9.1 - 2020-05-12 * http://openzui.com * GitHub: https://github.com/easysoft/zui.git * Copyright (c) 2020 cnezsoft.com; Licensed MIT @@ -14,7 +14,6 @@ /** * TODO: - * * Option: sortMultiValuesByDnd * * 优化展开时滚动到选中项体验 */ @@ -61,7 +60,7 @@ searchDelay: 200, fixLabelFor: true, hotkey: true, - // sortMultiValuesByDnd: false, + // sortValuesByDnd: false, // defaultValue: null, onSelect: null, // function({value, picker}), onDeselect: null, // function({value, picker}), @@ -294,10 +293,33 @@ return; } }).on('mouseup', function(e) { - if (!$(e.target).closest('.picker-selection-remove').length && !that.dropListShowed) { + if (!$selections.hasClass('sortable-sorting') && !$(e.target).closest('.picker-selection-remove').length && !that.dropListShowed) { that.focus(); } }); + + var sortValuesByDnd = options.sortValuesByDnd; + if (sortValuesByDnd && $.fn.sortable) { + $container.addClass('picker-sortable'); + var sortableOptions = { + selector: '.picker-selection', + stopPropagation: true, + start: function() { + that.hideDropList(); + }, + finish: function(e) { + var values = []; + $.each(e.list, function(_, ele) { + values.push(ele.item.data('value')); + }); + that.setValue(values, false, true); + } + }; + if (typeof sortValuesByDnd === 'object') { + $.extend(sortableOptions, sortValuesByDnd); + } + $selections.sortable(sortableOptions); + } } $selections.on('click', '.picker-selection-remove', function(e) { if (that.multi) { @@ -990,7 +1012,7 @@ } }; - Picker.prototype.setValue = function(value, silent) { + Picker.prototype.setValue = function(value, silent, skipRenderSelections) { var that = this; var options = that.options; @@ -1048,40 +1070,42 @@ } $formItem.val(value); - // Update container - var hasValue = false; - if (that.multi) { - var $selections = that.$selections; - var $selects = $selections.children('.picker-selection').addClass('picker-expired'); - $.each(value, function(_index, val) { - if (val === undefined || val === null) { - val = ''; - } else if (typeof val !== 'string') { - val = String(val); - } - var item = that.getListItem(val); - if (!item) { - return; - } - hasValue = true; - var text = item[options.textKey]; - var itemID = that.getItemID(item, 'selection'); - var $select = $selects.find('#' + itemID); - if (!$select.length) { - $select = $('
').data('value', val); - } else { - $select.removeClass('picker-expired'); - } - $select.find('.picker-selection-text').text(text); - $select.attr('title', text).insertBefore(that.$search); - }); - $selects.filter('.picker-expired').remove(); - } else { - var item = that.getListItem(value); - hasValue = !!item; - that.$singleSelection.find('.picker-selection-text').text(hasValue ? item[options.textKey] : ''); + // Update selections + if (!skipRenderSelections) { + var hasValue = false; + if (that.multi) { + var $selections = that.$selections; + var $selects = $selections.children('.picker-selection').addClass('picker-expired'); + $.each(value, function(_index, val) { + if (val === undefined || val === null) { + val = ''; + } else if (typeof val !== 'string') { + val = String(val); + } + var item = that.getListItem(val); + if (!item) { + return; + } + hasValue = true; + var text = item[options.textKey]; + var itemID = that.getItemID(item, 'selection'); + var $select = $selects.find('#' + itemID); + if (!$select.length) { + $select = $('
').data('value', val); + } else { + $select.removeClass('picker-expired'); + } + $select.find('.picker-selection-text').text(text); + $select.attr('title', text).insertBefore(that.$search); + }); + $selects.filter('.picker-expired').remove(); + } else { + var item = that.getListItem(value); + hasValue = !!item; + that.$singleSelection.find('.picker-selection-text').text(hasValue ? item[options.textKey] : ''); + } + that.$container.toggleClass('picker-no-value', !hasValue).toggleClass('picker-has-value', hasValue); } - that.$container.toggleClass('picker-no-value', !hasValue).toggleClass('picker-has-value', hasValue); if (that.dropListShowed) { that.renderOptionsList(); diff --git a/dist/lib/picker/zui.picker.min.css b/dist/lib/picker/zui.picker.min.css index 47de54c594c30edef4f321ec2ac48a49289e65da..4d9e6e6465f9a6fddf350221d005ead3f04c5648 100644 --- a/dist/lib/picker/zui.picker.min.css +++ b/dist/lib/picker/zui.picker.min.css @@ -1,6 +1,6 @@ /*! - * ZUI: 选择器 - v1.9.1 - 2020-05-11 + * ZUI: 选择器 - v1.9.1 - 2020-05-12 * http://openzui.com * GitHub: https://github.com/easysoft/zui.git * Copyright (c) 2020 cnezsoft.com; Licensed MIT - */.picker{min-height:32px;background-color:#eee}.picker:not(.picker-ready)>*{display:none}.picker-selections{position:relative;min-height:32px;color:#222;background-color:#fff;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.picker-focus .picker-selections{border-color:#145ccd;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(20,92,205,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(20,92,205,.6)}.picker-multi .picker-selections{padding:3px}.picker-multi.picker-focus .picker-selections:before{position:absolute;right:0;bottom:8px;display:block;width:24px;height:14px;font-family:ZenIcon;font-size:14px;font-style:normal;font-weight:400;font-variant:normal;line-height:1;text-align:center;text-transform:none;content:'\e603';opacity:.4;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.picker-multi.picker-focus.picker-loading .picker-selections::before{display:inline-block;content:'\e97c';-webkit-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;animation:spin 2s infinite linear}.picker-multi .picker-selection{position:relative;display:inline-block;padding:0 20px 0 5px;margin:2px;line-height:18px;background-color:#f1f1f1;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #ddd;border-radius:3px;-webkit-box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05);box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05)}.picker-selection-single{max-width:100%;padding:5px 20px 5px 8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.picker-focus .picker-selection-single .picker-selection-text{display:none}.picker-selection-single:after{position:absolute;top:7px;right:0;display:block;width:24px;height:14px;font-family:ZenIcon;font-size:14px;font-style:normal;font-weight:400;font-variant:normal;line-height:1;text-align:center;text-transform:none;content:'\e6b8';opacity:.4;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.picker-focus .picker-selection-single::after{content:'\e603'}.picker-focus.picker-loading .picker-selection-single::after{display:inline-block;content:'\e97c';-webkit-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;animation:spin 2s infinite linear}.picker-selection-remove{position:absolute;top:0;right:0;width:20px;height:20px;text-align:center;cursor:pointer;opacity:.2}.picker-selection-remove:before{font-family:ZenIcon;font-size:14px;font-style:normal;font-weight:400;font-variant:normal;line-height:1;text-shadow:0 1px 0 #fff;text-transform:none;content:'\d7';speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.picker-selection-remove:hover{opacity:.5}.picker-single .picker-selection-remove{top:5px;right:20px}.picker-no-value .picker-selection-remove,.picker-single.picker-focus .picker-selection-remove{display:none}.picker-search{color:transparent;background:0 0;border:none}.picker-search:focus{color:inherit;outline:0}.picker-single .picker-search{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;width:100%;padding:5px 8px}.picker-multi .picker-search{display:inline-block;width:10px;min-width:10px;max-width:100%;padding:0 2px;margin:2px 0}.picker-placeholder{position:absolute;top:5px;right:20px;left:8px;z-index:0;display:none;overflow:hidden;color:grey;text-overflow:ellipsis;white-space:nowrap}.picker-no-value.picker-focus .picker-placeholder{display:none}.picker-input-empty.picker-focus.picker-no-value .picker-placeholder,.picker-no-value .picker-placeholder{display:block}.picker-drop-menu{position:fixed;z-index:1200;display:none;min-width:100px;background-color:#fff;border:1px solid rgba(0,0,0,.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,.12),0 1px 3px rgba(0,0,0,.1);box-shadow:0 6px 12px rgba(0,0,0,.12),0 1px 3px rgba(0,0,0,.1);opacity:0}.picker-drop-menu.picker-drop-show{display:block}.picker-drop-menu.picker-has-message{min-height:22px;padding-bottom:22px}.picker-option-list{padding:5px 0;margin:0;overflow-y:auto}.picker-no-options .picker-option-list{display:none}.picker-option{display:block;min-height:30px;padding:5px 10px;overflow:hidden;clear:both;font-weight:400;line-height:1.53846154;color:#353535;text-overflow:ellipsis;white-space:nowrap;-webkit-transition:none;-o-transition:none;transition:none}.picker-single .picker-option.picker-option-selected{color:#3280fc;background:#ebf2f9}.picker-option:focus,.picker-option:hover{text-decoration:none}.picker-option.picker-option-active,.picker-single .picker-option.picker-option-selected.picker-option-active{color:#fff;background-color:#3280fc}.picker-multi .picker-option.picker-option-selected,.picker-multi .picker-option.picker-option-selected.picker-option-active{color:#ccc;cursor:not-allowed;background-color:#fff}.picker-option-text-matched{position:relative;color:#3280fc}.picker-option-text-matched:before{position:absolute;right:0;bottom:-4px;left:0;display:block;height:3px;content:' ';background-color:#3280fc;border-radius:2px;opacity:.5}.picker-option-active .picker-option-text-matched,.picker-option:hover .picker-option-text-matched{color:#fff}.picker-option-active .picker-option-text-matched:before,.picker-option:hover .picker-option-text-matched:before{background-color:#fff}.picker-message{position:absolute;right:0;bottom:0;left:0;display:none;height:22px;padding:2px 5px;overflow:hidden;font-size:12px;color:grey;text-overflow:ellipsis;white-space:nowrap;background-color:#f1f1f1}.picker-has-message .picker-message{display:block}.picker-message[data-type=danger]{color:#ea644a} \ No newline at end of file + */.picker{min-height:32px;background-color:#eee}.picker:not(.picker-ready)>*{display:none}.picker-selections{position:relative;min-height:32px;color:#222;background-color:#fff;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.picker-focus .picker-selections{border-color:#145ccd;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(20,92,205,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(20,92,205,.6)}.picker-multi .picker-selections{padding:3px}.picker-multi.picker-focus .picker-selections:before{position:absolute;right:0;bottom:8px;display:block;width:24px;height:14px;font-family:ZenIcon;font-size:14px;font-style:normal;font-weight:400;font-variant:normal;line-height:1;text-align:center;text-transform:none;content:'\e603';opacity:.4;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.picker-multi.picker-focus.picker-loading .picker-selections::before{display:inline-block;content:'\e97c';-webkit-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;animation:spin 2s infinite linear}.picker-multi .picker-selection{position:relative;display:inline-block;padding:0 20px 0 5px;margin:2px;line-height:18px;background-color:#f1f1f1;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #ddd;border-radius:3px;-webkit-box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05);box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05)}.picker-selection-single{max-width:100%;padding:5px 20px 5px 8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.picker-focus .picker-selection-single .picker-selection-text{display:none}.picker-selection-single:after{position:absolute;top:7px;right:0;display:block;width:24px;height:14px;font-family:ZenIcon;font-size:14px;font-style:normal;font-weight:400;font-variant:normal;line-height:1;text-align:center;text-transform:none;content:'\e6b8';opacity:.4;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.picker-focus .picker-selection-single::after{content:'\e603'}.picker-focus.picker-loading .picker-selection-single::after{display:inline-block;content:'\e97c';-webkit-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;animation:spin 2s infinite linear}.picker-selection-remove{position:absolute;top:0;right:0;width:20px;height:20px;text-align:center;cursor:pointer;opacity:.2}.picker-selection-remove:before{font-family:ZenIcon;font-size:14px;font-style:normal;font-weight:400;font-variant:normal;line-height:1;text-shadow:0 1px 0 #fff;text-transform:none;content:'\d7';speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.picker-selection-remove:hover{opacity:.5}.picker-single .picker-selection-remove{top:5px;right:20px}.picker-no-value .picker-selection-remove,.picker-single.picker-focus .picker-selection-remove{display:none}.picker-multi.picker-sortable .picker-selection-text{cursor:move}.picker-search{color:transparent;background:0 0;border:none}.picker-search:focus{color:inherit;outline:0}.picker-single .picker-search{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;width:100%;padding:5px 8px}.picker-multi .picker-search{display:inline-block;width:10px;min-width:10px;max-width:100%;padding:0 2px;margin:2px 0}.picker-placeholder{position:absolute;top:5px;right:20px;left:8px;z-index:0;display:none;overflow:hidden;color:grey;text-overflow:ellipsis;white-space:nowrap}.picker-no-value.picker-focus .picker-placeholder{display:none}.picker-input-empty.picker-focus.picker-no-value .picker-placeholder,.picker-no-value .picker-placeholder{display:block}.picker-drop-menu{position:fixed;z-index:1200;display:none;min-width:100px;background-color:#fff;border:1px solid rgba(0,0,0,.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,.12),0 1px 3px rgba(0,0,0,.1);box-shadow:0 6px 12px rgba(0,0,0,.12),0 1px 3px rgba(0,0,0,.1);opacity:0}.picker-drop-menu.picker-drop-show{display:block}.picker-drop-menu.picker-has-message{min-height:22px;padding-bottom:22px}.picker-option-list{padding:5px 0;margin:0;overflow-y:auto}.picker-no-options .picker-option-list{display:none}.picker-option{display:block;min-height:30px;padding:5px 10px;overflow:hidden;clear:both;font-weight:400;line-height:1.53846154;color:#353535;text-overflow:ellipsis;white-space:nowrap;-webkit-transition:none;-o-transition:none;transition:none}.picker-single .picker-option.picker-option-selected{color:#3280fc;background:#ebf2f9}.picker-option:focus,.picker-option:hover{text-decoration:none}.picker-option.picker-option-active,.picker-single .picker-option.picker-option-selected.picker-option-active{color:#fff;background-color:#3280fc}.picker-multi .picker-option.picker-option-selected,.picker-multi .picker-option.picker-option-selected.picker-option-active{color:#ccc;cursor:not-allowed;background-color:#fff}.picker-option-text-matched{position:relative;color:#3280fc}.picker-option-text-matched:before{position:absolute;right:0;bottom:-4px;left:0;display:block;height:3px;content:' ';background-color:#3280fc;border-radius:2px;opacity:.5}.picker-option-active .picker-option-text-matched,.picker-option:hover .picker-option-text-matched{color:#fff}.picker-option-active .picker-option-text-matched:before,.picker-option:hover .picker-option-text-matched:before{background-color:#fff}.picker-message{position:absolute;right:0;bottom:0;left:0;display:none;height:22px;padding:2px 5px;overflow:hidden;font-size:12px;color:grey;text-overflow:ellipsis;white-space:nowrap;background-color:#f1f1f1}.picker-has-message .picker-message{display:block}.picker-message[data-type=danger]{color:#ea644a} \ No newline at end of file diff --git a/dist/lib/picker/zui.picker.min.js b/dist/lib/picker/zui.picker.min.js index 5604e21bd2a2c2f0e07e1741a710891ea43ebb23..c27323e92ec155462feda8234a51b2bed151f221 100644 --- a/dist/lib/picker/zui.picker.min.js +++ b/dist/lib/picker/zui.picker.min.js @@ -1,7 +1,7 @@ /*! - * ZUI: 选择器 - v1.9.1 - 2020-05-11 + * ZUI: 选择器 - v1.9.1 - 2020-05-12 * http://openzui.com * GitHub: https://github.com/easysoft/zui.git * Copyright (c) 2020 cnezsoft.com; Licensed MIT */ -!function(e,t,i){"use strict";var o="zui.picker",n={},r={lang:null,remote:null,remoteConverter:null,remoteOnly:!1,onRemoteError:null,textKey:"text",valueKey:"value",keysKey:"keys",multi:"auto",formItem:"auto",list:null,allowSingleDeselect:null,showMultiSelectedOptions:!1,autoSelectFirst:!1,optionItemFormatter:null,maxSelectedCount:0,maxListCount:50,hideEmptyTextOption:!0,searchValueKey:!0,emptyResultHint:null,hideOnWindowScroll:!0,inheritFormItemClasses:!1,emptySearchResultHint:null,accurateSearchHint:null,remoteErrorHint:null,deleteByBackspace:!0,disableScrollOnShow:!0,maxDropHeight:250,dropDirection:"auto",dropWidth:"100%",maxAutoDropWidth:450,multiValueSplitter:",",searchDelay:200,fixLabelFor:!0,hotkey:!0,onSelect:null,onDeselect:null,beforeChange:null,onChange:null,onReady:null,onNoResults:null,onShowingDrop:null,onHidingDrop:null,onShowedDrop:null,onHiddenDrop:null},l={zh_cn:{emptyResultHint:"没有可选项",emptySearchResultHint:"没有找到 “{0}”",accurateSearchHint:"请提供更多关键词缩小匹配范围",remoteErrorHint:"无法从服务器获取结果 - {0}"},zh_tw:{emptyResultHint:"沒有可選項",emptySearchResultHint:"沒有找到 “{0}”",accurateSearchHint:"請提供更多關鍵詞縮小匹配範圍",remoteErrorHint:"無法從服務器獲取結果 - {0}"},en:{emptyResultHint:"No options",emptySearchResultHint:'Cannot found "{0}"',accurateSearchHint:"Suggest to provide more keywords",remoteErrorHint:"Unable to get result from server: {0}"}},s=function(t,i){var n=this;n.name=o,n.id="pk_"+e.zui.uuid(),n.$=e(t),i=n.options=e.extend({},s.DEFAULTS,this.$.data(),i);var r=e.zui.clientLang?e.zui.clientLang():"en",a=i.lang||r;n.lang=e.zui.getLangData?e.zui.getLangData(o,a,l):l[a]||l[r];var p,c,u=i.formItem,d='.form-item,input[type="hidden"],select,input[type="text"]';if(p="self"===u?n.$:"auto"!==u&&u?n.$.find(u):n.$.is(d)?n.$:n.$.find(d).first(),!p.length)return console.error&&console.error("Cannot found form item for picker.");if(p.is('input[type="hidden"]'))c="hidden";else if(p.is("select"))c="select";else{if(!p.is('input[type="text"]'))return console.error&&console.error("Unknown form type for picker.");c="text"}i.inheritFormItemClasses&&f.addClass(p.attr("class")),n.formType=c,n.$formItem=p.removeClass("picker").hide(),n.selfFormItem=p.is(n.$);var h=i.multi;h&&"auto"!==h||(h="select"===c&&"multiple"===p.attr("multiple")),h=!!h,n.multi=h;var v=i.list;v?n.setList("function"==typeof v?v({search:n.search,limit:i.maxListCount}):v,!0):"select"===c?n.updateFromSelect():n.setList([],!0);var f;f=!n.selfFormItem&&n.$.hasClass("picker")?n.$:e('
').insertAfter(n.$),f.addClass("picker").toggleClass("picker-multi",h).toggleClass("picker-single",!h);var g=f.children(".picker-selections");g.length?g.empty():g=e('
');var m=n.id+"-search",y=e('').appendTo(g);if(!h){var k=e('
');i.allowSingleDeselect&&k.append(''),k.appendTo(g),n.$singleSelection=k}f.toggleClass("picker-input-empty",!y.val().length).append(g),n.$container=f,n.$selections=g,n.$search=y,n.search="";var S=i.placeholder;if(void 0===S&&(S=p.attr("placeholder")),"string"==typeof S&&S.length&&g.append(e('
').text(S)),i.placeholder=S,i.fixLabelFor){var x=p.attr("id");x&&e('label[for="'+x+'"]').attr("for",m)}var w=void 0!==i.defaultValue?i.defaultValue:p.val();n.setValue(w,!0),y.on("focus",function(){f.addClass("picker-focus"),n.showDropList()}).on("blur",function(){f.removeClass("picker-focus")}).on("input change",function(){var e=y.val();h&&y.width(14*e.length),f.toggleClass("picker-input-empty",!e.length),n.tryUpdateList(e)}),i.hotkey&&y.on("keydown",function(e){var t=e.key||e.which;if(n.dropListShowed){var o=n.activeValue,r="string"==typeof o;if("Enter"===t||13===t)r&&(n.select(o),n.multi||y.blur(),e.preventDefault());else if("ArrowDown"===t||40===t){var l,s=n.$activeOption;if(s&&(l=s.next(".picker-option"),n.multi))for(;l.length&&l.hasClass("picker-option-selected");)l=l.next(".picker-option");l&&l.length||(l=n.$optionsList.children(n.multi?".picker-option:not(.picker-option-selected)":".picker-option").first()),l.length&&n.activeOption(l),e.preventDefault()}else if("ArrowUp"===t||30===t){var a,s=n.$activeOption;if(s&&(a=s.prev(".picker-option"),n.multi))for(;a.length&&a.hasClass("picker-option-selected");)a=a.prev(".picker-option");a&&a.length||(a=n.$optionsList.children(n.multi?".picker-option:not(.picker-option-selected)":".picker-option").last()),a.length&&n.activeOption(a),e.preventDefault()}else i.deleteByBackspace&&n.multi&&("Backspace"===t||8===t)&&n.value&&n.value.length&&n.deselect(n.value[n.value.length-1])}}),h&&g.on("mousedown",function(e){if(n.dropListShowed)return e.preventDefault(),void e.stopPropagation()}).on("mouseup",function(t){e(t.target).closest(".picker-selection-remove").length||n.dropListShowed||n.focus()}),g.on("click",".picker-selection-remove",function(t){if(n.multi){var i=e(this).closest(".picker-selection");n.deselect(i.data("value"))}else n.deselect();t.stopPropagation()}),p.on("chosen:updated",function(){n.updateFromSelect(),n.setValue(p.val()),n.updateList()}).on("chosen:activate",n.focus).on("chosen:open",n.showDropList).on("chosen:close",n.hideDropList),f.addClass("picker-ready"),setTimeout(function(){n.triggerEvent("ready",{picker:n},"","chosen:ready")},0)};s.prototype.focus=function(){this.$search.focus()},s.prototype.select=function(e){var t=this;if(!t.isSelectedValue(e)){if(t.triggerEvent("select",{value:e,picker:t})===!1)return;if(t.multi){var i=t.value;i||(i=[]),i.push(e),t.setValue(i)}else t.setValue(e)}t.hideDropList()},s.prototype.deselect=function(e){var t=this;if(t.multi){if(!t.isSelectedValue(e))return;if(t.triggerEvent("deselect",{value:e,picker:t})===!1)return;var i=t.value;if(i&&i.length)for(var o=0;oh&&i.top>h-i.top-i.height?"top":"bottom"),r.dropDirection=c;var m=Math.min(s,"bottom"===c?h-i.top-i.height:i.top);if(v=Math.min(v,m),g.top="bottom"===c?i.top+i.height:i.top-v,"100%"===f)g.width=i.width;else if("auto"===f){if(g.width="auto",g.maxWidth="auto"===u?i.width:u,r.multi){var y=r.$search[0].getBoundingClientRect();g.left=y.left}}else g.width=f;var k=r.hasMessage?r.$message.outerHeight():0;p.css("max-height",v-k),a.css(g),n&&n()},0)}},s.prototype.tryUpdateList=function(e){var t=this;t.search!==e&&(t.search=e,t.updateListTimer&&clearTimeout(t.updateListTimer),t.updateListTimer=setTimeout(function(){t.updateListTimer=null,t.updateList()},t.options.searchDelay))},s.prototype.renderOptionsList=function(t,i){var o=this,n=o.$optionsList;if(void 0===t?t=o.optionsList:o.optionsList=t,n){var r="",l=o.options,s=o.search,a="string"==typeof s&&s.length;if(t.length){for(var p,c,u,d=l.maxListCount,h=l.valueKey,v=l.textKey,f=l.showMultiSelectedOptions,g=Math.min(t.length,d),m=s.toLowerCase(),y=n.children(".picker-option").addClass("picker-expired"),k=o.activeValue,S=void 0!==k&&null!==k,x=0;x'),D.attr("title",$).removeClass(".picker-option-active").toggleClass("picker-option-selected",C);var _=D.find(".picker-option-text");if(a){var O=$.toLowerCase(),M=O.split(m);if(M.length>1){_.empty();var E=0,H=M[0].length;H&&(_.append(e("").text($.substr(E,H))),E+=H);for(var V=1;V').text($.substr(E,s.length))),E+=s.length,H=M[V].length,H&&(_.append(e("").text($.substr(E,H))),E+=H)}else _.text($)}else _.text($);D.appendTo(n),o.multi?C||c||(c=w):!u&&S&&L===k?u=w:C?p=w:c||(c=w)}}}y.filter(".picker-expired").remove(),!i&&g-1&&(f+=0===m?20:10)}if(!f){var y=h[s];if(null!==y&&void 0!==y&&""!==y){y=y.toLowerCase();var m=y.indexOf(e);m>-1&&(f+=0===m?8:4)}}if(!f&&c&&null!==v&&void 0!==v&&""!==v){v=v.toLowerCase();var m=v.indexOf(e);m>-1&&(f+=0===m?3:1)}if(f&&(u[v]=f+(o.list.length-d)/o.list.length,r.push(h)),l&&r.length>=l)break}}r.length&&(r=r.sort(function(e,t){return u[t[p]]-u[e[p]]}))}o.renderOptionsList(r,!1,i)}t||o.getRemoteList(function(t){n?o.renderOptionsList(o.list,!1,i):o.updateList(e,!0)},n?function(){o.renderOptionsList([],!0,i)}:null)},s.prototype.showDropList=function(){var t=this;if(t.triggerEvent("showingDrop",{picker:t})!==!1){if(t.dropListShowed=!0,t.dropDirection=null,t.listRendered=!1,t.activeValue=null,n[t.id]=t,t.options.disableScrollOnShow&&e.zui.fixBodyScrollbar(),!t.$dropMenu){var i=e('
'),r=e('
').appendTo(i);i.data(o,t).toggleClass("picker-multi",t.multi).toggleClass("picker-single",!t.multi).appendTo("body"),t.options.chosenMode&&i.addClass("chosen-up"),r.on("click",".picker-option",function(){t.select(e(this).attr("data-value"))}).on("mouseenter",".picker-option",function(){t.activeOption(e(this),!0)});var l=e('
').appendTo(i);t.$dropMenu=i,t.$message=l,t.$optionsList=r}t.updateList(t.search,!1,function(){t.triggerEvent("showedDrop",{picker:t},"","chosen:showing_dropdown")}),t.$dropMenu.addClass("picker-drop-show")}},s.prototype.hideDropList=function(){var t=this;t.triggerEvent("hidingDrop",{picker:t})!==!1&&(t.dropListShowed=!1,t.$activeOption=null,t.activeValue=null,t.$search.val(""),t.search="",delete n[t.id],t.$dropMenu&&t.$dropMenu.removeClass("picker-drop-show"),t.options.disableScrollOnShow&&e.zui.resetBodyScrollbar(),t.triggerEvent("hiddenDrop",{picker:t},"","chosen:hiding_dropdown"))},s.prototype.updateFromSelect=function(t){var i=this,o=i.options,n=[];void 0===t&&(t=!0),i.$formItem.children("option").each(function(){var t=e(this),i=t.text(),r=t.val();if(i.length||r.length){var l={};l[o.valueKey]=r,l[o.textKey]=i,l[o.keysKey]=t.data(o.keysKey),n.push(l)}null!==o.allowSingleDeselect&&void 0!==o.allowSingleDeselect||r.length||(o.allowSingleDeselect=!0)}),i.setList(n,t)},s.prototype.setList=function(t,i){var o=this,n=o.options,r=i?[]:o.list||[],l=i?{}:o.listMap||{};"string"==typeof t&&(t=t.split(","));for(var s=0;s')}):l&&r.find('option[value="'+t+'"]').length||r.append('