Searched defs:SOL_OPTION_FORMAT (Results 1 - 2 of 2) sorted by relevance
/opengrok/web/js/ |
H A D | searchable-option-list-2.0.2.js | 35 SOL_OPTION_FORMAT: { 49 children: undefined // array of SOL_OPTION_FORMAT objects 694 return $.extend({}, this.SOL_OPTION_FORMAT, { 791 if (item.type === self.SOL_OPTION_FORMAT.type) {
|
H A D | searchable-option-list-2.0.2.min.js | 16 (function(d,c,a){var b=function(e,f){this.$originalElement=e;this.options=f;this.metadata=this.$originalElement.data("sol-options")};b.prototype={SOL_OPTION_FORMAT:{type:"option",value:undefined,selected:false,disabled:false,label:undefined,tooltip:undefined,cssClass:""},SOL_OPTIONGROUP_FORMAT:{type:"optiongroup",label:undefined,tooltip:undefined,disabled:false,children:undefined},DATA_KEY:"sol-element",WINDOW_EVENTS_KEY:"sol-window-events",defaults:{data:undefined,name:undefined,texts:{noItemsAvailable:"No entries found",selectAll:"Select all",selectNone:"Select none",quickDelete:"×",searchplaceholder:"Click here to search",loadingData:"Still loading data...",itemsSelected:"{$a} more items selected"},events:{onInitialized:undefined,onRendered:undefined,onOpen:undefined,onClose:undefined,onChange:undefined,onScroll:function(){var g=this.$input.offset().top-this.config.scrollTarget.scrollTop()+this.$input.outerHeight(false),h=this.$selectionContainer.outerHeight(false),i=g+h,j=this.config.displayContainerAboveInput||a.documentElement.clientHeight-this.config.scrollTarget.scrollTop()<i,e=this.$innerContainer.outerWidth(false)-parseInt(this.$selectionContainer.css("border-left-width"),10)-parseInt(this.$selectionContainer.css("border-right-width"),10);if(j){g=this.$input.offset().top-h-this.config.scrollTarget.scrollTop()+parseInt(this.$selectionContainer.css("border-bottom-width"),10);this.$container.removeClass("sol-selection-bottom").addClass("sol-selection-top")}else{this.$container.removeClass("sol-selection-top").addClass("sol-selection-bottom")}if(this.$innerContainer.css("display")!=="block"){e=e*1.2}else{var f=j?"border-bottom-right-radius":"border-top-right-radius";this.$selectionContainer.css(f,"initial");if(this.$actionButtons){this.$actionButtons.css(f,"initial")}}this.$selectionContainer.css("top",Math.floor(g)).css("left",Math.floor(this.$container.offset().left)).css("width",e);this.config.displayContainerAboveInput=j}},selectAllMaxItemsThreshold:30,showSelectAll:function(){return this.config.multiple&&this.config.selectAllMaxItemsThreshold&&this.items&&this.items.length<=this.config.selectAllMaxItemsThreshold},useBracketParameters:false,multiple:undefined,resultsContainer:undefined,closeOnClick:false,showSelectionBelowList:false,allowNullSelection:false,scrollTarget:undefined,maxHeight:undefined,converter:undefined,asyncBatchSize:300,searchTimeout:300,maxShow:0},init:function(){this.config=d.extend(true,{},this.defaults,this.options,this.metadata);var e=this._getNameAttribute(),f=this;if(!e){this._showErrorLabel("name attribute is required");return}if(typeof String.prototype.trim!=="function"){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}this.config.multiple=this.config.multiple||this.$originalElement.attr("multiple");if(!this.config.scrollTarget){this.config.scrollTarget=d(c)}this._registerWindowEventsIfNeccessary();this._initializeUiElements();this._initializeInputEvents();setTimeout(function(){f._initializeData();f.$originalElement.data(f.DATA_KEY,f).removeAttr("name").data("sol-name",e)},0);this.$originalElement.hide();this.$container.css("visibility","initial").show();return this},_getNameAttribute:function(){return this.config.name||this.$originalElement.data("sol-name")||this.$originalElement.attr("name")},_showErrorLabel:function(f){var e=d('<div style="color: red; font-weight: bold;" />').html(f);if(!this.$container){e.insertAfter(this.$originalElement)}else{this.$container.append(e)}},_registerWindowEventsIfNeccessary:function(){if(!c[this.WINDOW_EVENTS_KEY]){d(a).click(function(h){var i=d(h.target),g=i.closest(".sol-selection-container"),f=i.closest(".sol-inner-container"),e;if(f.length){e=f.first().parent(".sol-container")}else{if(g.length){e=g.first().parent(".sol-container")}}d(".sol-active").not(e).each(function(j,k){d(k).data(b.prototype.DATA_KEY).close()})});c[this.WINDOW_EVENTS_KEY]=true}},_initializeUiElements:function(){var m=this;this.internalScrollWrapper=function(){if(d.isFunction(m.config.events.onScroll)){m.config.events.onScroll.call(m)}};this.$input=d('<input type="text"/>').attr("placeholder",this.config.texts.searchplaceholder);this.$noResultsItem=d('<div class="sol-no-results"/>').html(this.config.texts.noItemsAvailable).hide();this.$loadingData=d('<div class="sol-loading-data"/>').html(this.config.texts.loadingData);this.$xItemsSelected=d('<div class="sol-results-count"/>');this.$caret=d('<div class="sol-caret-container"><b class="sol-caret"/></div>').click(function(i){m.toggle();i.preventDefault();return false});var k=d('<div class="sol-input-container"/>').append(this.$input);this.$innerContainer=d('<div class="sol-inner-container"/>').append(k).append(this.$caret);this.$selection=d('<div class="sol-selection"/>');this.$selectionContainer=d('<div class="sol-selection-container"/>').append(this.$noResultsItem).append(this.$loadingData).append(this.$selection);this.$container=d('<div class="sol-container"/>').hide().keydown(function(p){if(p.keyCode==13){var o="";d("#sbox #qtbl input[type='text']").each(function(){o+=d.trim(d(this).val())});if(p.keyCode==13&&o===""){if(m.$input.val()!==""){c.location=a.xrefPath+"/"+m.$input.val();return false}var i=d(".keyboard-selection").first().find(".sol-checkbox");if(i.length&&i.data("sol-item")&&i.data("sol-item").label){c.location=a.xrefPath+"/"+i.data("sol-item").label;return false}i=d(".sol-selected-display-item").first();if(i.length&&i.data("label")){c.location=a.xrefPath+"/"+i.data("label");return false}return false}return true}}).data(this.DATA_KEY,this).append(this.$selectionContainer).append(this.$innerContainer).insertBefore(this.$originalElement);this.$showSelectionContainer=d('<div class="sol-current-selection"/>');var n=this.config.resultsContainer||this.$innerContainer;if(this.config.resultsContainer){this.$showSelectionContainer.appendTo(n)}else{if(this.config.showSelectionBelowList){this.$showSelectionContainer.insertAfter(n)}else{this.$showSelectionContainer.insertBefore(n)}}if(this.config.maxHeight){this.$selection.css("max-height",this.config.maxHeight)}var l=this.$originalElement.attr("class"),h=this.$originalElement.attr("style"),e=[],f=[];if(l&&l.length>0){e=l.split(/\s+/);for(var g=0;g<e.length;g++){this.$container.addClass(e[g])}}if(h&&h.length>0){f=h.split(/\;/);for(var g=0;g<f.length;g++){var j=f[g].split(/\s*\:\s*/g);if(j.length===2){if(j[0].toLowerCase().indexOf("height")>=0){this.$innerContainer.css(j[0].trim(),j[1].trim())}else{this.$container.css(j[0].trim(),j[1].trim())}}}}if(this.$originalElement.css("display")!=="block"){this.$container.css("width",this._getActualCssPropertyValue(this.$originalElement,"width"))}if(d.isFunction(this.config.events.onRendered)){this.config.events.onRendered.call(this,this)}},_getActualCssPropertyValue:function(e,f){var h=e.get(0),g=e.css("display");e.css("display","none");if(h.currentStyle){return h.currentStyle[f]}else{if(c.getComputedStyle){return a.defaultView.getComputedStyle(h,null).getPropertyValue(f)}}e.css("display",g);return e.css(f)},_initializeInputEvents:function(){var f=this,e=this.$input.parents("form").first();if(e&&e.length===1&&!e.data(this.WINDOW_EVENTS_KEY)){var g=function(){var h=[];e.find(".sol-option input").each(function(k,l){var j=d(l),i=j.data("sol-item").selected;if(j.prop("checked")!==i){j.prop("checked",i).trigger("sol-change",true);h.push(j)}});if(h.length>0&&d.isFunction(f.config.events.onChange)){f.config.events.onChange.call(f,f,h)}};e.on("reset",function(h){g.call(f);setTimeout(function(){g.call(f)},100)});e.data(this.WINDOW_EVENTS_KEY,true)}this.$input.focus(function(){f.open()}).on("propertychange input",function(i){var h=true;if(i.type=="propertychange"){h=i.originalEvent.propertyName.toLowerCase()=="value"}if(h){if(d(this).data("timeout")){clearTimeout(d(this).data("timeout"))}d(this).data("timeout",setTimeout(function(){f._applySearchTermFilter()},f.config.searchTimeout))}});this.$container.on("keydown",function(m){var l=m.keyCode;if(!f.$noResultsItem.is(":visible")){var n,j,k,i=false,o=f.$selection.find(".sol-option:visible");if(l===40||l===38){f._setKeyBoardNavigationMode(true);n=f.$selection.find(".sol-option.keyboard-selection");n.find("input[type='checkbox']").blur();k=(l===38)?-1:1;var h=o.index(n)+k;if(h<0){h=o.length-1}else{if(h>=o.length){h=0}}n.removeClass("keyboard-selection");j=d(o[h]).addClass("keyboard-selection");j.find("input[type='checkbox']").focus();i=true}else{if(f.keyboardNavigationMode===true&&l===32){n=f.$selection.find(".sol-option.keyboard-selection input");n.trigger("change");i=true}}if(i){m.preventDefault();return false}}}).on("keyup",function(i){var h=i.keyCode;if(h===27){if(f.keyboardNavigationMode===true){f._setKeyBoardNavigationMode(false)}else{if(f.$input.val()===""){f.$caret.trigger("click");f.$input.trigger("blur")}else{f.$input.val("").trigger("input")}}}else{if(h===16||h===17||h===18||h===20){return}}})},_setKeyBoardNavigationMode:function(e){if(e){this.keyboardNavigationMode=true;this.$selection.addClass("sol-keyboard-navigation")}else{this.keyboardNavigationMode=false;this.$selection.find(".sol-option.keyboard-selection");this.$selection.removeClass("sol-keyboard-navigation");this.$selectionContainer.find(".sol-option.keyboard-selection").removeClass("keyboard-selection");this.$selection.scrollTop(0)}},_applySearchTermFilter:function(){if(!this.items||this.items.length===0){return}var e=this.$input.val(),f=(e||"").toLowerCase();this.$selectionContainer.find(".sol-filtered-search").removeClass("sol-filtered-search");this._setNoResultsItemVisible(false);if(f.trim().length>0){this._findTerms(this.items,f)}if(d.isFunction(this.config.events.onScroll)){this.config.events.onScroll.call(this)}},_findTerms:function(l,g){if(!l||!d.isArray(l)||l.length===0){return}var o=this,j=l.length;this._setKeyBoardNavigationMode(false);for(var e=0;e<l.length;e++){var n=l[e];if(n.type==="option"){var m=n.displayElement,k=(n.label+" "+n.tooltip).trim().toLowerCase();if(k.indexOf(g)===-1){m.addClass("sol-filtered-search");j--}}else{var i=n.children.length;for(var h=0;h<n.children.length;h++){var f=n.children[h];if(f.type==="option"){var m=f.displayElement,k=(f.label+" "+f.tooltip).trim().toLowerCase();if(k.indexOf(g)===-1){m.addClass("sol-filtered-search");i--}}}if(i===0){n.displayElement.addClass("sol-filtered-search");j--}}}this._setNoResultsItemVisible(j===0)},_initializeData:function(){if(!this.config.data){this.items=this._detectDataFromOriginalElement()}else{if(d.isFunction(this.config.data)){this.items=this._fetchDataFromFunction(this.config.data)}else{if(d.isArray(this.config.data)){this.items=this._fetchDataFromArray(this.config.data)}else{if(typeof this.config.data===(typeof"a string")){this._loadItemsFromUrl(this.config.data)}else{this._showErrorLabel("Unknown data type")}}}}if(this.items){this._processDataItems(this.items)}},_detectDataFromOriginalElement:function(){if(this.$originalElement.prop("tagName").toLowerCase()==="select"){var f=this,e=[];d.each(this.$originalElement.children(),function(i,k){var h=d(k),j=h.prop("tagName").toLowerCase(),l;if(j==="option"){l=f._processSelectOption(h);if(l){e.push(l)}}else{if(j==="optgroup"){l=f._processSelectOptgroup(h);if(l){e.push(l)}}else{f._showErrorLabel("Invalid element found in select: "+j+". Only option and optgroup are allowed")}}});return this._invokeConverterIfNeccessary(e)}else{if(this.$originalElement.data("sol-data")){var g=this.$originalElement.data("sol-data");return this._invokeConverterIfNeccessary(g)}else{this._showErrorLabel('Could not determine data from original element. Must be a select or data must be provided as data-sol-data="" attribute')}}},_processSelectOption:function(e){return d.extend({},this.SOL_OPTION_FORMAT,{value:e.val(),selected:e.prop("selected"),disabled:e.prop("disabled"),cssClass:e.attr("class"),label:e.html(),tooltip:e.attr("title"),element:e})},_processSelectOptgroup:function(f){var h=this,g=d.extend({},this.SOL_OPTIONGROUP_FORMAT,{label:f.attr("label"),tooltip:f.attr("title"),disabled:f.prop("disabled"),children:[]}),e=f.children("option");d.each(e,function(j,k){var l=d(k),i=h._processSelectOption(l);if(g.disabled){i.disabled=true}g.children.push(i)});return g},_fetchDataFromFunction:function(e){return this._invokeConverterIfNeccessary(e(this))},_fetchDataFromArray:function(e){return this._invokeConverterIfNeccessary(e)},_loadItemsFromUrl:function(f){var e=this;d.ajax(f,{success:function(g){e.items=e._invokeConverterIfNeccessary(g);if(e.items){e._processDataItems(e.items)}},error:function(i,g,h){e._showErrorLabel("Error loading from url "+f+": "+h)},dataType:"json"})},_invokeConverterIfNeccessary:function(e){if(d.isFunction(this.config.converter)){return this.config.converter.call(this,this,e)}return e},_processDataItems:function(i){if(!i){this._showErrorLabel("Data items not present. Maybe the converter did not return any values");return}if(i.length===0){this._setNoResultsItemVisible(true);this.$loadingData.remove();return}var g=this,f=0,e=function(){this.$loadingData.remove();this._initializeSelectAll();if(d.isFunction(this.config.events.onInitialized)){this.config.events.onInitialized.call(this,this,i)}},h=function(){var j=0,k;while(j++<g.config.asyncBatchSize&&f<i.length){k=i[f++];if(k.type===g.SOL_OPTION_FORMAT.type){g._renderOption(k)}else{if(k.type===g.SOL_OPTIONGROUP_FORMAT.type){g._renderOptiongroup(k)}e (…)
|
Completed in 17 milliseconds