text: var Serenity;(function(e){var t=function(t){__extends(i,t);function i(e,i){var l=t.call(this,e,i)||this;e.addClass("quick-filters-bar").addClass("clear");var a=l.options.filters;for(var n=0;n<a.length;n++){var r=a[n];l.add(r)}l.options.idPrefix=Q.coalesce(l.options.idPrefix,l.uniqueName+"_");return l}l=i;i.prototype.addSeparator=function(){this.element.append($("<hr/>"))};i.prototype.add=function(t){var i=this;if(t==null){throw new Q.ArgumentNullException("opt")}if(t.separator){this.addSeparator()}var l=$("<div class='quick-filter-item'><span class='quick-filter-label'></span></div>").appendTo(this.element).data("qffield",t.field).children();var a=t.title;if(a==null){a=this.options.getTitle?this.options.getTitle(t):null;if(a==null){a=t.field}}var n=l.text(a).parent();if(t.displayText!=null){n.data("qfdisplaytext",t.displayText)}if(t.saveState!=null){n.data("qfsavestate",t.saveState)}if(t.loadState!=null){n.data("qfloadstate",t.loadState)}if(!Q.isEmptyOrNull(t.cssClass)){n.addClass(t.cssClass)}var r=e.Widget.create({type:t.type,element:function(e){if(!Q.isEmptyOrNull(t.field)){e.attr("id",i.options.idPrefix+t.field)}e.attr("placeholder"," ");e.appendTo(n);if(t.element!=null){t.element(e)}},options:t.options,init:t.init});var s=function(i){if(n.hasClass("ignore")){return}i.EqualityFilter=i.EqualityFilter||{};var l=e.EditorUtils.getValue(r);var a=l!=null&&!Q.isEmptyOrNull(l.toString());if(t.handler!=null){var s={field:t.field,request:i,equalityFilter:i.EqualityFilter,value:l,active:a,widget:r,handled:true};t.handler(s);n.toggleClass("quick-filter-active",s.active);if(!s.handled){i.EqualityFilter[t.field]=l}}else{i.EqualityFilter[t.field]=l;n.toggleClass("quick-filter-active",a)}};r.changeSelect2(function(e){window.setTimeout(function(){return i.onChange&&i.onChange(e)},0)});this.add_submitHandlers(s);r.element.bind("remove."+this.uniqueName,function(e){i.remove_submitHandlers(s)});return r};i.prototype.addDateRange=function(e,t){return this.add(l.dateRange(e,t))};i.dateRange=function(t,i){var l=null;return{field:t,type:e.DateEditor,title:i,element:function(t){l=e.Widget.create({type:e.DateEditor,element:function(e){e.insertAfter(t)},options:null,init:null});l.element.change(function(e){t.triggerHandler("change")});$("<span/>").addClass("range-separator").text("-").insertAfter(t)},handler:function(t){var i=!Q.isTrimmedEmpty(t.widget.value);var a=!Q.isTrimmedEmpty(l.value);if(i&&!Q.parseDate(t.widget.element.val())){i=false;Q.notifyWarning(Q.text("Validation.DateInvalid"),"",null);t.widget.element.val("")}if(a&&!Q.parseDate(l.element.val())){a=false;Q.notifyWarning(Q.text("Validation.DateInvalid"),"",null);l.element.val("")}t.active=i||a;if(i){t.request.Criteria=e.Criteria.join(t.request.Criteria,"and",[[t.field],">=",t.widget.value])}if(a){var n=new Date(l.valueAsDate.valueOf());n.setDate(n.getDate()+1);t.request.Criteria=e.Criteria.join(t.request.Criteria,"and",[[t.field],"<",Q.formatDate(n,"yyyy-MM-dd")])}},displayText:function(t,i){var a=e.EditorUtils.getDisplayText(t);var n=e.EditorUtils.getDisplayText(l);if(Q.isEmptyOrNull(a)&&Q.isEmptyOrNull(n)){return null}var r=i+" >= "+a;var s=i+" <= "+n;if(!Q.isEmptyOrNull(a)&&!Q.isEmptyOrNull(n)){return r+" "+Q.coalesce(Q.tryGetText("Controls.FilterPanel.And"),"and")+" "+s}else if(!Q.isEmptyOrNull(a)){return r}else{return s}},saveState:function(t){return[e.EditorUtils.getValue(t),e.EditorUtils.getValue(l)]},loadState:function(t,i){if(i==null||!Q.isArray(i)||i.length!==2){i=[null,null]}e.EditorUtils.setValue(t,i[0]);e.EditorUtils.setValue(l,i[1])}}};i.prototype.addDateTimeRange=function(e,t){return this.add(l.dateTimeRange(e,t))};i.dateTimeRange=function(t,i){var l=null;return{field:t,type:e.DateTimeEditor,title:i,element:function(t){l=e.Widget.create({type:e.DateTimeEditor,element:function(e){e.insertAfter(t)},options:null,init:null});l.element.change(function(e){t.triggerHandler("change")});$("<span/>").addClass("range-separator").text("-").insertAfter(t)},init:function(e){e.element.parent().find(".time").change(function(t){e.element.triggerHandler("change")})},handler:function(t){var i=!Q.isTrimmedEmpty(t.widget.value);var a=!Q.isTrimmedEmpty(l.value);if(i&&!Q.parseDate(t.widget.element.val())){i=false;Q.notifyWarning(Q.text("Validation.DateInvalid"),"",null);t.widget.element.val("")}if(a&&!Q.parseDate(l.element.val())){a=false;Q.notifyWarning(Q.text("Validation.DateInvalid"),"",null);l.element.val("")}t.active=i||a;if(i){t.request.Criteria=e.Criteria.join(t.request.Criteria,"and",[[t.field],">=",t.widget.value])}if(a){t.request.Criteria=e.Criteria.join(t.request.Criteria,"and",[[t.field],"<=",l.value])}},displayText:function(t,i){var a=e.EditorUtils.getDisplayText(t);var n=e.EditorUtils.getDisplayText(l);if(Q.isEmptyOrNull(a)&&Q.isEmptyOrNull(n)){return null}var r=i+" >= "+a;var s=i+" <= "+n;if(!Q.isEmptyOrNull(a)&&!Q.isEmptyOrNull(n)){return r+" "+Q.coalesce(Q.tryGetText("Controls.FilterPanel.And"),"and")+" "+s}else if(!Q.isEmptyOrNull(a)){return r}else{return s}},saveState:function(t){return[e.EditorUtils.getValue(t),e.EditorUtils.getValue(l)]},loadState:function(t,i){if(i==null||!Q.isArray(i)||i.length!==2){i=[null,null]}e.EditorUtils.setValue(t,i[0]);e.EditorUtils.setValue(l,i[1])}}};i.prototype.addBoolean=function(e,t,i,a){return this.add(l.boolean(e,t,i,a))};i.boolean=function(t,i,l,a){var n={};var r=[];var s=l;if(s==null){s=Q.text("Controls.FilterPanel.OperatorNames.true")}r.push(["1",s]);var o=a;if(o==null){o=Q.text("Controls.FilterPanel.OperatorNames.false")}r.push(["0",o]);n.items=r;return{field:t,type:e.SelectEditor,title:i,options:n,handler:function(e){e.equalityFilter[e.field]=e.value==null||Q.isEmptyOrNull(e.value.toString())?null:!!Q.toId(e.value)}}};i.prototype.destroy=function(){this.submitHandlers=null;t.prototype.destroy.call(this)};i.prototype.onSubmit=function(e){this.submitHandlers&&this.submitHandlers(e)};i.prototype.add_submitHandlers=function(e){this.submitHandlers=Q.delegateCombine(this.submitHandlers,e)};i.prototype.remove_submitHandlers=function(e){this.submitHandlers=Q.delegateRemove(this.submitHandlers,e)};i.prototype.clear_submitHandlers=function(){};i.prototype.find=function(e,t){return $("#"+this.options.idPrefix+t).getWidget(e)};i.prototype.tryFind=function(e,t){var i=$("#"+this.options.idPrefix+t);if(!i.length)return null;return i.tryGetWidget(e)};var l;i=l=__decorate([e.Decorators.registerClass("Serenity.QuickFilterBar"),e.Decorators.element("<div/>")],i);return i}(e.Widget);e.QuickFilterBar=t})(Serenity||(Serenity={}));var Serenity;(function(e){var t=function(t){__extends(i,t);function i(i,l){var a=t.call(this,i,l)||this;i.attr("title",Q.text("Controls.QuickSearch.Hint")).attr("placeholder",Q.text("Controls.QuickSearch.Placeholder"));a.lastValue=Q.trim(Q.coalesce(i.val(),""));var n=a;a.element.bind("keyup."+a.uniqueName,function(){n.checkIfValueChanged()});a.element.bind("change."+a.uniqueName,function(){n.checkIfValueChanged()});$("<span><i></i></span>").addClass("quick-search-icon").insertBefore(i);if(Q.isValue(a.options.fields)&&a.options.fields.length>0){var r=$("<a/>").addClass("quick-search-field").attr("title",Q.text("Controls.QuickSearch.FieldSelection")).insertBefore(i);var s=$("<ul></ul>").css("width","120px");for(var o=0,u=a.options.fields;o<u.length;o++){var d=u[o];var f={$:d};$("<li><a/></li>").appendTo(s).children().attr("href","#").text(Q.coalesce(d.title,"")).click(function(e){e.preventDefault();this.$this.fieldChanged=n.field!==this.field.$;n.field=this.field.$;this.$this.updateInputPlaceHolder();this.$this.checkIfValueChanged()}.bind({field:f,$this:a}))}new e.PopupMenuButton(r,{positionMy:"right top",positionAt:"right bottom",menu:s});a.field=a.options.fields[0];a.updateInputPlaceHolder()}a.element.bind("execute-search."+a.uniqueName,function(e){if(!!a.timer){window.clearTimeout(a.timer)}a.searchNow(Q.trim(Q.coalesce(a.element.val(),"")))});return a}i.prototype.checkIfValueChanged=function(){if(this.element.hasClass("ignore-change")){return}var e=Q.trim(Q.coalesce(this.element.val(),""));if(e==this.lastValue&&(!this.fieldChanged||Q.isEmptyOrNull(e))){this.fieldChanged=false;return}this.fieldChanged=false;if(!!this.timer){window.clearTimeout(this.timer)}var t=this;this.timer=window.setTimeout(function(){t.searchNow(e)},Q.coalesce(this.options.typeDelay,500));this.lastValue=e};i.prototype.get_field=function(){return this.field};i.prototype.set_field=function(e){if(this.field!==e){this.fieldChanged=true;this.field=e;this.updateInputPlaceHolder();this.checkIfValueChanged()}};i.prototype.updateInputPlaceHolder=function(){var e=this.element.prevAll(".quick-search-field");if(this.field){e.text(this.field.title)}else{e.text("")}};i.prototype.searchNow=function(e){var t=this;this.element.parent().toggleClass(Q.coalesce(this.options.filteredParentClass,"s-QuickSearchFiltered"),!!(e.length>0));this.element.parent().addClass(Q.coalesce(this.options.loadingParentClass,"s-QuickSearchLoading")).addClass(Q.coalesce(this.options.loadingParentClass,"s-QuickSearchLoading"));var i=function(e){t.element.removeClass(Q.coalesce(t.options.loadingParentClass,"s-QuickSearchLoading")).parent().removeClass(Q.coalesce(t.options.loadingParentClass,"s-QuickSearchLoading"));if(!e){t.element.closest(".s-QuickSearchBar").find(".quick-search-icon i").effect("shake",{distance:2})}};if(this.options.onSearch!=null){this.options.onSearch(this.field!=null&&!Q.isEmptyOrNull(this.field.name)?this.field.name:null,e,i)}else{i(true)}};return i}(e.Widget);e.QuickSearchInput=t})(Serenity||(Serenity={}));