diff --git a/js/jtable/VERSION b/js/jtable/VERSION index c787b213..154b9fce 100644 --- a/js/jtable/VERSION +++ b/js/jtable/VERSION @@ -1 +1 @@ -1.0.22 +1.0.23 diff --git a/js/jtable/jquery.jtable.js b/js/jtable/jquery.jtable.js index 276d08d2..462d35ee 100644 --- a/js/jtable/jquery.jtable.js +++ b/js/jtable/jquery.jtable.js @@ -1113,12 +1113,12 @@ THE SOFTWARE. .addClass('jtable-toolbar-item-text').appendTo($toolBarItem); } - // click event + // click event ("click" is a function defined for the item in the options list, not a triggered jquery event) if (item.click) { $toolBarItem.on("click", function (e) { e.preventDefault(); e.stopPropagation(); - item.trigger("click"); + item.click(); // call the defined function }); } diff --git a/js/jtable/jquery.jtable.min.js b/js/jtable/jquery.jtable.min.js index a549601b..720dd3a6 100644 --- a/js/jtable/jquery.jtable.min.js +++ b/js/jtable/jquery.jtable.min.js @@ -1 +1 @@ -(function($){let unloadingPage;$(window).on("beforeunload",function(){unloadingPage=true});$(window).on("unload",function(){unloadingPage=false});jTable=function(element,options){this.element=$(element);this.options=$.extend(true,{},this.options,options);this._create()};jTable.prototype={options:{tableId:undefined,actions:{},fields:{},animationsEnabled:true,defaultDateFormat:"yy-mm-dd",showCloseButton:false,loadingAnimationDelay:500,saveUserPreferences:true,jqueryuiTheme:false,unAuthorizedRequestRedirectUrl:null,listQueryParams:{},ajaxSettings:{type:"POST",dataType:"json"},toolbar:{hoverAnimation:true,hoverAnimationDuration:60,hoverAnimationEasing:undefined,items:[]},closeRequested:function(event,data){},formCreated:function(event,data){},formSubmitting:function(event,data){},formClosed:function(event,data){},loadingRecords:function(event,data){},recordsLoaded:function(event,data){},rowInserted:function(event,data){},rowsRemoved:function(event,data){},messages:{serverCommunicationError:"An error occured while communicating to the server.",loadingMessage:"Loading records...",noDataAvailable:"No data available!",areYouSure:"Are you sure?",save:"Save",saving:"Saving",cancel:"Cancel",error:"Error",close:"Close",cannotLoadOptionsFor:"Can not load options for field {0}"}},_$mainContainer:null,_$titleDiv:null,_$toolbarDiv:null,_$tableDiv:null,_$table:null,_$tableBody:null,_$tableRows:null,_$busyDialog:null,_$errorDialog:null,_columnList:null,_fieldList:null,_keyField:null,_firstDataColumnOffset:0,_lastPostData:null,_cache:null,_extraFieldTypes:[],_create:function(){this._initializeSettings();this._createFieldAndColumnList();this._cookieKeyPrefix=this._generateCookieKeyPrefix();this._loadExtraSettings();this._normalizeFieldsOptions();this._doExtraActions();this._createMainContainer();this._createTableTitle();this._createToolBar();this._createTableDiv();this._createTable();this._createBusyDialog();this._createErrorDialog();this._addNoDataRow()},_normalizeFieldsOptions:function(){let self=this;$.each(self.options.fields,function(fieldName,props){self._normalizeFieldOptions(fieldName,props)})},_normalizeFieldOptions:function(fieldName,props){if(props.listClass==undefined){props.listClass=""}if(props.inputClass==undefined){props.inputClass=""}if(props.placeholder==undefined){props.placeholder=""}if(props.type==undefined){props.type="text"}if(props.dependsOn&&$.type(props.dependsOn)==="string"){let dependsOnArray=props.dependsOn.split(",");props.dependsOn=[];for(let i=0;i").addClass("jtable-main-container").appendTo(this.element);this._jqueryuiThemeAddClass(this._$mainContainer,"ui-widget")},_createTableTitle:function(){let self=this;if(!self.options.title){return}let $titleDiv=$("
").addClass("jtable-title").appendTo(self._$mainContainer);self._jqueryuiThemeAddClass($titleDiv,"ui-widget-header");$("
").addClass("jtable-title-text").appendTo($titleDiv).append(self.options.title);if(self.options.showCloseButton){let $textSpan=$("").html(self.options.messages.close);$("").addClass("jtable-command-button jtable-close-button").attr("title",self.options.messages.close).append($textSpan).appendTo($titleDiv).on("click",function(e){e.preventDefault();e.stopPropagation();self._onCloseRequested()})}self._$titleDiv=$titleDiv},_createTableDiv:function(){this._$tableDiv=$("
").addClass("jtable-table-div").appendTo(this._$mainContainer)},_createTable:function(){this._$table=$("
").addClass("jtable").appendTo(this._$tableDiv);if(this.options.tableId){this._$table.attr("id",this.options.tableId)}else if(this._$tableDiv.attr("id")){this._$table.attr("id","jtable-"+this._$mainContainer.attr("id"))}this._jqueryuiThemeAddClass(this._$table,"ui-widget-content");this._createTableHead();this._createTableBody()},_createTableHead:function(){let $thead=$("").appendTo(this._$table);this._addRowToTableHead($thead)},_addRowToTableHead:function($thead){let $tr=$("").appendTo($thead);this._addColumnsToHeaderRow($tr)},_addColumnsToHeaderRow:function($tr){for(let i=0;i").addClass("jtable-column-header-text").html(field.title);let $headerContainerDiv=$("
").addClass("jtable-column-header-container").append($headerTextSpan);let $th=$("").addClass("jtable-column-header").addClass(field.listClass).css("width",field.width).data("fieldName",fieldName).append($headerContainerDiv);this._jqueryuiThemeAddClass($th,"ui-state-default");return $th},_createEmptyCommandHeader:function(extraclass){let $th=$("").addClass("jtable-command-column-header"+" "+extraclass).css("width","1%");this._jqueryuiThemeAddClass($th,"ui-state-default");return $th},_createTableBody:function(){this._$tableBody=$("").appendTo(this._$table)},_createBusyDialog:function(){this._$busyDialog=$("").addClass("jtable-busy-modal-dialog").prependTo(this._$mainContainer);this._$busyMessageDiv=$("
").addClass("jtable-busy-message").appendTo(this._$busyDialog);this._jqueryuiThemeAddClass(this._$busyMessageDiv,"ui-widget-header")},_createErrorDialog:function(){let self=this;self._$errorDialog=$("").addClass("jtable-modal-dialog").appendTo(self._$mainContainer);$('

').css({padding:"0px"}).html(self.options.messages.error).appendTo(self._$errorDialog);$('

').appendTo(self._$errorDialog);$('').html(""+self.options.messages.close+"").on("click",function(){self._closeErrorDialog()}).appendTo(self._$errorDialog)},_closeErrorDialog(){this._$errorDialog[0].close()},load:function(extraPostData,completeCallback){let listQueryParams={};if(typeof this.options.listQueryParams==="function"){listQueryParams=this.options.listQueryParams()}else{listQueryParams=this.options.listQueryParams}if(extraPostData){this._lastPostData={...listQueryParams,...extraPostData}}else{this._lastPostData=listQueryParams}this._reloadTable(completeCallback)},reload:function(completeCallback){this._reloadTable(completeCallback)},getRowByKey:function(key){for(let i=0;i").addClass("jtable-data-row").attr("data-record-key",this._getKeyValueOfRecord(record)).data("record",record);this._addCellsToRowUsingRecord($tr);return $tr},_addCellsToRowUsingRecord:function($row){let record=$row.data("record");for(let i=0;i").addClass(this.options.fields[fieldName].listClass).append(this._getDisplayTextForRecordField(record,fieldName))},_addRecordsToTable:function(records){let self=this;$.each(records,function(index,record){self._addRow(self._createRowFromRecord(record))});self._refreshRowStyles()},_addRowToTable:function($tableRow,index,isNewRow,animationsEnabled){let options={index:this._normalizeNumber(index,0,this._$tableRows.length,this._$tableRows.length)};if(isNewRow==true){options.isNewRow=true}if(animationsEnabled==false){options.animationsEnabled=false}this._addRow($tableRow,options)},_addRow:function($row,options){options=$.extend({index:this._$tableRows.length,isNewRow:false,animationsEnabled:true},options);if(this._$tableRows.length<=0){this._removeNoDataRow()}options.index=this._normalizeNumber(options.index,0,this._$tableRows.length,this._$tableRows.length);if(options.index==this._$tableRows.length){this._$tableBody.append($row);this._$tableRows.push($row)}else if(options.index==0){this._$tableBody.prepend($row);this._$tableRows.unshift($row)}else{this._$tableRows[options.index-1].after($row);this._$tableRows.splice(options.index,0,$row)}this._onRowInserted($row,options.isNewRow);if(options.isNewRow){this._refreshRowStyles();if(this.options.animationsEnabled&&options.animationsEnabled){this._showNewRowAnimation($row)}}},_showNewRowAnimation:function($tableRow){let className="jtable-row-created";if(this.options.jqueryuiTheme){className=className+" ui-state-highlight"}$tableRow.addClass(className,"slow","",function(){$tableRow.removeClass(className,5e3)})},_removeRowsFromTable:function($rows,reason){let self=this;if($rows.length<=0){return}$rows.addClass("jtable-row-removed").remove();$rows.each(function(){let index=self._findRowIndex($(this));if(index>=0){self._$tableRows.splice(index,1)}});self._onRowsRemoved($rows,reason);if(self._$tableRows.length==0){self._addNoDataRow()}self._refreshRowStyles()},_findRowIndex:function($row){return this._findIndexInArray($row,this._$tableRows,function($row1,$row2){return $row1.data("record")==$row2.data("record")})},_removeAllRows:function(reason){if(this._$tableRows.length<=0){return}let $rows=this._$tableBody.find("tr.jtable-data-row");this._$tableBody.empty();this._$tableRows=[];this._onRowsRemoved($rows,reason);this._addNoDataRow()},_addNoDataRow:function(){if(this._$tableBody.find(">tr.jtable-no-data-row").length>0){return}let $tr=$("").addClass("jtable-no-data-row").appendTo(this._$tableBody);let totalColumnCount=this._$table.find("thead th").length;$("").attr("colspan",totalColumnCount).html(this.options.messages.noDataAvailable).appendTo($tr)},_removeNoDataRow:function(){this._$tableBody.find(".jtable-no-data-row").remove()},_refreshRowStyles:function(){for(let i=0;i").addClass("jtable-toolbar").appendTo(this._$titleDiv);for(let i=0;i").addClass("jtable-toolbar-item").appendTo(this._$toolbarDiv);this._jqueryuiThemeAddClass($toolBarItem,"ui-widget ui-state-default ui-corner-all","ui-state-hover");if(item.cssClass){$toolBarItem.addClass(item.cssClass)}if(item.tooltip){$toolBarItem.attr("title",item.tooltip)}if(item.icon){let $icon=$('').appendTo($toolBarItem);if(item.icon===true){}else if($.type(item.icon==="string")){$icon.css("background",'url("'+item.icon+'")')}}if(item.text){$('').html(item.text).addClass("jtable-toolbar-item-text").appendTo($toolBarItem)}if(item.click){$toolBarItem.on("click",function(e){e.preventDefault();e.stopPropagation();item.trigger("click")})}let hoverAnimationDuration=undefined;let hoverAnimationEasing=undefined;if(this.options.toolbar.hoverAnimation){hoverAnimationDuration=this.options.toolbar.hoverAnimationDuration;hoverAnimationEasing=this.options.toolbar.hoverAnimationEasing}$toolBarItem.hover(function(){$toolBarItem.addClass("jtable-toolbar-item-hover",hoverAnimationDuration,hoverAnimationEasing)},function(){$toolBarItem.removeClass("jtable-toolbar-item-hover",hoverAnimationDuration,hoverAnimationEasing)});return $toolBarItem},_showError:function(message){this._$errorDialog.find(".jtable-error-message").html(message);this._$errorDialog[0].showModal()},_setBusyTimer:null,_showBusy:function(message,delay){let self=this;let makeVisible=function(){self._$busyDialog.find(".jtable-busy-message").html(message);self._$busyDialog[0].showModal()};if(delay){if(self._setBusyTimer){return}self._setBusyTimer=setTimeout(makeVisible,delay)}else{makeVisible()}},_hideBusy:function(){clearTimeout(this._setBusyTimer);this._setBusyTimer=null;this._$busyDialog[0].close()},_isBusy:function(){return this._$busyDialog.is(":visible")},_jqueryuiThemeAddClass:function($elm,className,hoverClassName){if(!this.options.jqueryuiTheme){return}$elm.addClass(className);if(hoverClassName){$elm.hover(function(){$elm.addClass(hoverClassName)},function(){$elm.removeClass(hoverClassName)})}},_performAjaxCall:function(url,postData,async,success,error){this._ajax({url:url,data:postData,async:async,success:success,error:error})},_unAuthorizedRequestHandler:function(){if(this.options.unAuthorizedRequestRedirectUrl){location.href=this.options.unAuthorizedRequestRedirectUrl}else{location.reload(true)}},_ajax:function(options){let self=this;let opts={statusCode:{401:function(){self._unAuthorizedRequestHandler()}}};opts=$.extend(opts,this.options.ajaxSettings,options);opts.success=function(data){if(data&&data.UnAuthorizedRequest==true){self._unAuthorizedRequestHandler()}if(options.success){options.success(data)}};opts.error=function(jqXHR,textStatus,errorThrown){if(unloadingPage){jqXHR.abort();return}if(options.error){options.error(arguments)}};opts.complete=function(){if(options.complete){options.complete()}};$.ajax(opts)},_getKeyValueOfRecord:function(record){return record[this._keyField]},_setCookie:function(key,value){key=this._cookieKeyPrefix+key;let expireDate=new Date;expireDate.setDate(expireDate.getDate()+30);$.cookie(key,value,{expires:expireDate})},_getCookie:function(key){key=this._cookieKeyPrefix+key;return $.cookie(key)},_removeCookie:function(key){key=this._cookieKeyPrefix+key;$.removeCookie(key,{path:"/"});return null},_generateCookieKeyPrefix:function(){let simpleHash=function(value){let hash=0;if(value.length==0){return hash}for(let i=0;imax){return max}return number},_formatString:function(){if(arguments.length==0){return null}let str=arguments[0];for(let i=1;i").addClass("jtable-input-label").html(this.options.fields[fieldName].inputTitle||this.options.fields[fieldName].title)},_createInputForRecordField:function(funcParams){let fieldName=funcParams.fieldName,value=funcParams.value,record=funcParams.record,formType=funcParams.formType,form=funcParams.form;let field=this.options.fields[fieldName];if(value==undefined||value==null){value=field.defaultValue}if(field.input){let $input=$(field.input({value:value,record:record,formType:formType,form:form}));if(!$input.attr("id")){$input.attr("id","Edit-"+fieldName)}return $("
").addClass("jtable-input jtable-custom-input").append($input)}if(field.type=="date"){return this._createDateInputForField(field,fieldName,value)}else if(field.type=="textarea"){return this._createTextAreaForField(field,fieldName,value)}else if(field.type=="checkbox"){return this._createCheckboxForField(field,fieldName,value)}else if(field.options){if(field.type=="radiobutton"){return this._createRadioButtonListForField(field,fieldName,value,record,formType)}else{return this._createDropDownListForField(field,fieldName,value,record,formType,form)}}else{return this._createInputForField(field,fieldName,value)}},_createInputForHidden:function(fieldName,value){if(value==undefined){value=""}return $('').val(value)},_createDateInputForField:function(field,fieldName,value){let $input="";if(typeof $.fn.datepicker=="function"){let displayFormat=field.displayFormat||this.options.defaultDateFormat;$input=$('');$input.datepicker({dateFormat:displayFormat})}else{$input=$('')}if(value!=undefined){$input.val(value)}return $("
").addClass("jtable-input jtable-date-input").append($input)},_createTextAreaForField:function(field,fieldName,value){let $textArea=$('');if(value!=undefined){$textArea.val(value)}return $("
").addClass("jtable-input jtable-textarea-input").append($textArea)},_createInputForField:function(field,fieldName,value){let $input=$('');if(value!=undefined){$input.val(value)}return $("
").addClass("jtable-input jtable-"+field.inputClass+"-input").append($input)},_createCheckboxForField:function(field,fieldName,value){let self=this;if(value==undefined){value=self._getCheckBoxPropertiesForFieldByState(fieldName,false).Value}let $containerDiv=$("
").addClass("jtable-input jtable-checkbox-input");let $checkBox=$('').appendTo($containerDiv);if(value!=undefined){$checkBox.val(value)}let $textSpan=$(""+(field.formText||self._getCheckBoxTextForFieldByValue(fieldName,value))+"").appendTo($containerDiv);if(self._getIsCheckBoxSelectedForFieldByValue(fieldName,value)){$checkBox.attr("checked","checked")}let refreshCheckBoxValueAndText=function(){let checkboxProps=self._getCheckBoxPropertiesForFieldByState(fieldName,$checkBox.is(":checked"));$checkBox.attr("value",checkboxProps.Value);$textSpan.html(field.formText||checkboxProps.DisplayText)};$checkBox.on("click",function(){refreshCheckBoxValueAndText()});if(field.setOnTextClick!=false){$textSpan.addClass("jtable-option-text-clickable").on("click",function(){if($checkBox.is(":checked")){$checkBox.attr("checked",false)}else{$checkBox.attr("checked",true)}refreshCheckBoxValueAndText()})}return $containerDiv},_createDropDownListForField:function(field,fieldName,value,record,source,form){let $containerDiv=$("
").addClass("jtable-input jtable-dropdown-input");let $select=$('').appendTo($containerDiv);let options=this._getOptionsForField(fieldName,{record:record,source:source,form:form,dependedValues:this._createDependedValuesUsingForm(form,field.dependsOn)});this._fillDropDownListWithOptions($select,options,value);return $containerDiv},_fillDropDownListWithOptions:function($select,options,value){$select.empty();for(let i=0;i"+options[i].DisplayText+"").val(options[i].Value).appendTo($select)}},_createDependedValuesUsingForm:function($form,dependsOn){if(!dependsOn){return{}}let dependedValues={};for(let i=0;i").addClass("jtable-input jtable-radiobuttonlist-input");let options=this._getOptionsForField(fieldName,{record:record,source:source});$.each(options,function(i,option){let $radioButtonDiv=$('
').addClass("jtable-radio-input").appendTo($containerDiv);let $radioButton=$('").val(option.Value).appendTo($radioButtonDiv);let $textSpan=$("").html(option.DisplayText).appendTo($radioButtonDiv);if(field.setOnTextClick!=false){$textSpan.addClass("jtable-option-text-clickable").on("click",function(){if(!$radioButton.is(":checked")){$radioButton.attr("checked",true)}})}});return $containerDiv},_getCheckBoxTextForFieldByValue:function(fieldName,value){return this.options.fields[fieldName].values[value]},_getIsCheckBoxSelectedForFieldByValue:function(fieldName,value){return this._createCheckBoxStateArrayForFieldWithCaching(fieldName)[1].Value.toString()==value.toString()},_getCheckBoxPropertiesForFieldByState:function(fieldName,checked){return this._createCheckBoxStateArrayForFieldWithCaching(fieldName)[checked?1:0]},_createCheckBoxStateArrayForFieldWithCaching:function(fieldName){let cacheKey="checkbox_"+fieldName;if(!this._cache[cacheKey]){this._cache[cacheKey]=this._createCheckBoxStateArrayForField(fieldName)}return this._cache[cacheKey]},_createCheckBoxStateArrayForField:function(fieldName){let stateArray=[];let currentIndex=0;$.each(this.options.fields[fieldName].values,function(propName,propValue){if(currentIndex++<2){stateArray.push({Value:propName,DisplayText:propValue})}});return stateArray},_makeCascadeDropDowns:function($form,record,source){let self=this;$form.find("select").each(function(){let $thisDropdown=$(this);let fieldName=$thisDropdown.attr("name");if(!fieldName){return}let field=self.options.fields[fieldName];if(!field.dependsOn){return}$.each(field.dependsOn,function(index,dependsOnField){let $dependsOnDropdown=$form.find("select[name="+dependsOnField+"]");$dependsOnDropdown.change(function(){let funcParams={record:record,source:source,form:$form,dependedValues:{}};funcParams.dependedValues=self._createDependedValuesUsingForm($form,field.dependsOn);let options=self._getOptionsForField(fieldName,funcParams);self._fillDropDownListWithOptions($thisDropdown,options,undefined);$thisDropdown.change()})})})},_updateRecordValuesFromForm:function(record,$form){for(let i=0;i").addClass("jtable-modal-dialog").appendTo(self._$mainContainer);self._$addRecordDialog.on("close",function(){let $addRecordForm=self._$addRecordDialog.find("form").first();self._$mainContainer.trigger("formClosed",{form:$addRecordForm,formType:"create"});$addRecordForm.remove()});$('

').css({padding:"0px"}).text(self.options.messages.addNewRecord).appendTo(self._$addRecordDialog);const $cancelButton=$(' ').attr("id","AddRecordDialogCancelButton").html(""+self.options.messages.cancel+"").on("click",function(){self._closeCreateForm()});let $saveButton=$('').attr("id","AddRecordDialogSaveButton").html(""+self.options.messages.save+"").on("click",function(){self._onSaveClickedOnCreateForm();self._closeCreateForm()});self._$addRecordDialog.append($cancelButton,$saveButton);if(self.options.addRecordButton){self.options.addRecordButton.on("click",function(e){e.preventDefault();self._showAddRecordForm()})}else{self._addToolBarItem({icon:true,cssClass:"jtable-toolbar-item-add-record",text:self.options.messages.addNewRecord,click:function(){self._showAddRecordForm()}})}},_onSaveClickedOnCreateForm:function(){let self=this;let $saveButton=self._$addRecordDialog.find("#AddRecordDialogSaveButton");let $addRecordForm=self._$addRecordDialog.find("form");if(self._$mainContainer.trigger("formSubmitting",{form:$addRecordForm,formType:"create"})!=false){self._setEnabledOfDialogButton($saveButton,false,self.options.messages.saving);self._saveAddRecordForm($addRecordForm,$saveButton)}},_closeCreateForm:function(){this._$addRecordDialog[0].close()},showCreateForm:function(){this._showAddRecordForm()},addRecord:function(options){let self=this;options=$.extend({clientOnly:false,animationsEnabled:self.options.animationsEnabled,success:function(){},error:function(){}},options);if(!options.record){self._logWarn("options parameter in addRecord method must contain a record property.");return}if(options.clientOnly){self._addRow(self._createRowFromRecord(options.record),{isNewRow:true,animationsEnabled:options.animationsEnabled});options.success();return}let completeAddRecord=function(data){if(data.Result!="OK"){self._showError(data.Message);options.error(data);return}if(!data.Record){self._logError("Server must return the created Record object.");options.error(data);return}self._onRecordAdded(data);self._addRow(self._createRowFromRecord(data.Record),{isNewRow:true,animationsEnabled:options.animationsEnabled});options.success(data)};if(!options.url&&$.isFunction(self.options.actions.createAction)){let funcResult=self.options.actions.createAction($.param(options.record));if(self._isDeferredObject(funcResult)){funcResult.done(function(data){completeAddRecord(data)}).fail(function(){self._showError(self.options.messages.serverCommunicationError);options.error()})}else{completeAddRecord(funcResult)}}else{self._submitFormUsingAjax(options.url||self.options.actions.createAction,$.param(options.record),function(data){completeAddRecord(data)},function(){self._showError(self.options.messages.serverCommunicationError);options.error()})}},_showAddRecordForm:function(){let self=this;let $addRecordForm=$('
');for(let i=0;i").addClass("jtable-input-field-container").appendTo($addRecordForm);$fieldContainer.append(self._createInputLabelForRecordField(fieldName));$fieldContainer.append(self._createInputForRecordField({fieldName:fieldName,formType:"create",form:$addRecordForm}))}self._makeCascadeDropDowns($addRecordForm,undefined,"create");$addRecordForm.submit(function(){self._onSaveClickedOnCreateForm();return false});self._$addRecordDialog.find("form:first").remove();let $saveButton=self._$editRecordDialog.find("#EditDialogSaveButton");self._setEnabledOfDialogButton($saveButton,true,self.options.messages.save);self._$addRecordDialog.find("#addRecordDialogTitle:first").after($addRecordForm);self._$addRecordDialog[0].showModal();self._$mainContainer.trigger("formCreated",{form:$addRecordForm,formType:"create"})},_saveAddRecordForm:function($addRecordForm,$saveButton){let self=this;let completeAddRecord=function(data){if(data.Result!="OK"){self._showError(data.Message);return}if(!data.Record){self._logError("Server must return the created Record object.");return}self._onRecordAdded(data);self._addRow(self._createRowFromRecord(data.Record),{isNewRow:true});self._closeCreateForm()};if($.isFunction(self.options.actions.createAction)){let funcResult=self.options.actions.createAction($addRecordForm.serialize());if(self._isDeferredObject(funcResult)){funcResult.done(function(data){completeAddRecord(data)}).fail(function(){self._showError(self.options.messages.serverCommunicationError)})}else{completeAddRecord(funcResult)}}else{self._submitFormUsingAjax(self.options.actions.createAction,$addRecordForm.serialize(),function(data){completeAddRecord(data)},function(){self._showError(self.options.messages.serverCommunicationError)})}},_onRecordAdded:function(data){this._$mainContainer.trigger("recordAdded",{record:data.Record,serverResponse:data})}})})(jQuery);(function($){let base={_create:jTable.prototype._create,_addColumnsToHeaderRow:jTable.prototype._addColumnsToHeaderRow,_addCellsToRowUsingRecord:jTable.prototype._addCellsToRowUsingRecord};$.extend(true,jTable.prototype,{options:{recordUpdated:function(event,data){},rowUpdated:function(event,data){},messages:{editRecord:"Edit Record"}},_$editRecordDialog:null,_$editingRow:null,_create:function(){base._create.apply(this,arguments);if(!this.options.actions.updateAction){return}this._createEditDialog()},_createEditDialog:function(){let self=this;self._$editRecordDialog=$("").addClass("jtable-modal-dialog").appendTo(self._$mainContainer);self._$editRecordDialog.on("close",function(){let $editForm=self._$editRecordDialog.find("form:first");self._$mainContainer.trigger("formClosed",{form:$editForm,formType:"edit",row:self._$editingRow});$editForm.remove()});$('

').css({padding:"0px"}).text(self.options.messages.editRecord).appendTo(self._$editRecordDialog);const $cancelButton=$(' ').attr("id","EditRecordDialogCancelButton").html(""+self.options.messages.cancel+"").on("click",function(){self._closeEditForm()});let $saveButton=$('').attr("id","EditDialogSaveButton").html(""+self.options.messages.save+"").on("click",function(){self._onSaveClickedOnEditForm();self._closeEditForm()});self._$editRecordDialog.append($cancelButton,$saveButton)},_onSaveClickedOnEditForm:function(){let self=this;if(self._$editingRow.hasClass("jtable-row-removed")){self._closeEditForm();return}let $saveButton=self._$editRecordDialog.find("#EditDialogSaveButton");let $editForm=self._$editRecordDialog.find("form");if(self._$mainContainer.trigger("formSubmitting",{form:$editForm,formType:"edit",row:self._$editingRow})!=false){self._setEnabledOfDialogButton($saveButton,false,self.options.messages.saving);self._saveEditForm($editForm,$saveButton)}},_closeEditForm:function(){this._$editRecordDialog[0].close()},updateRecord:function(options){let self=this;options=$.extend({clientOnly:false,animationsEnabled:self.options.animationsEnabled,success:function(){},error:function(){}},options);if(!options.record){self._logWarn("options parameter in updateRecord method must contain a record property.");return}let key=self._getKeyValueOfRecord(options.record);if(key==undefined||key==null){self._logWarn("options parameter in updateRecord method must contain a record that contains the key field property.");return}let $updatingRow=self.getRowByKey(key);if($updatingRow==null){self._logWarn('Can not found any row by key "'+key+'" on the table. Updating row must be visible on the table.');return}if(options.clientOnly){$.extend($updatingRow.data("record"),options.record);self._updateRowTexts($updatingRow);self._onRecordUpdated($updatingRow,null);if(options.animationsEnabled){self._showUpdateAnimationForRow($updatingRow)}options.success();return}let completeEdit=function(data){if(data.Result!="OK"){self._showError(data.Message);options.error(data);return}$.extend($updatingRow.data("record"),options.record);self._updateRecordValuesFromServerResponse($updatingRow.data("record"),data);self._updateRowTexts($updatingRow);self._onRecordUpdated($updatingRow,data);if(options.animationsEnabled){self._showUpdateAnimationForRow($updatingRow)}options.success(data)};if(!options.url&&$.isFunction(self.options.actions.updateAction)){let funcResult=self.options.actions.updateAction($.param(options.record));if(self._isDeferredObject(funcResult)){funcResult.done(function(data){completeEdit(data)}).fail(function(){self._showError(self.options.messages.serverCommunicationError);options.error()})}else{completeEdit(funcResult)}}else{self._submitFormUsingAjax(options.url||self.options.actions.updateAction,$.param(options.record),function(data){completeEdit(data)},function(){self._showError(self.options.messages.serverCommunicationError);options.error()})}},_addColumnsToHeaderRow:function($tr){base._addColumnsToHeaderRow.apply(this,arguments);if(this.options.actions.updateAction!=undefined){$tr.append(this._createEmptyCommandHeader("jtable-column-header-edit"))}},_addCellsToRowUsingRecord:function($row){let self=this;base._addCellsToRowUsingRecord.apply(this,arguments);if(self.options.actions.updateAction!=undefined){let $span=$("").html(self.options.messages.editRecord);let $button=$('').addClass("jtable-command-button jtable-edit-command-button").append($span).on("click",function(e){e.preventDefault();e.stopPropagation();self._showEditForm($row)});$("").addClass("jtable-command-column").append($button).appendTo($row)}},_showEditForm:function($tableRow){let self=this;let record=$tableRow.data("record");let $editForm=$('
');for(let i=0;i
').appendTo($editForm);$fieldContainer.append(self._createInputLabelForRecordField(fieldName));let currentValue=self._getValueForRecordField(record,fieldName);$fieldContainer.append(self._createInputForRecordField({fieldName:fieldName,value:currentValue,record:record,formType:"edit",form:$editForm}))}self._makeCascadeDropDowns($editForm,record,"edit");$editForm.submit(function(){self._onSaveClickedOnEditForm();return false});self._$editingRow=$tableRow;self._$editRecordDialog.find("form:first").remove();let $saveButton=self._$editRecordDialog.find("#EditDialogSaveButton");self._setEnabledOfDialogButton($saveButton,true,self.options.messages.save);self._$editRecordDialog.find("#editDialogTitle:first").after($editForm);self._$editRecordDialog[0].showModal();self._$mainContainer.trigger("formCreated",{form:$editForm,formType:"edit",record:record,row:$tableRow})},_saveEditForm:function($editForm,$saveButton){let self=this;let completeEdit=function(data){if(data.Result!="OK"){self._showError(data.Message);return}let record=self._$editingRow.data("record");self._updateRecordValuesFromForm(record,$editForm);self._updateRecordValuesFromServerResponse(record,data);self._updateRowTexts(self._$editingRow);self._$editingRow.attr("data-record-key",self._getKeyValueOfRecord(record));self._onRecordUpdated(self._$editingRow,data);if(self.options.animationsEnabled){self._showUpdateAnimationForRow(self._$editingRow)}self._closeEditForm()};if($.isFunction(self.options.actions.updateAction)){let funcResult=self.options.actions.updateAction($editForm.serialize());if(self._isDeferredObject(funcResult)){funcResult.done(function(data){completeEdit(data)}).fail(function(){self._showError(self.options.messages.serverCommunicationError)})}else{completeEdit(funcResult)}}else{self._submitFormUsingAjax(self.options.actions.updateAction,$editForm.serialize(),function(data){completeEdit(data)},function(){self._showError(self.options.messages.serverCommunicationError)})}},_updateRecordValuesFromServerResponse:function(record,serverResponse){if(!serverResponse||!serverResponse.Record){return}$.extend(true,record,serverResponse.Record)},_getValueForRecordField:function(record,fieldName){let field=this.options.fields[fieldName];let fieldValue=record[fieldName];if(field.type=="date"){return this._getDisplayTextForDateRecordField(field,fieldValue)}else{return fieldValue}},_updateRowTexts:function($tableRow){let record=$tableRow.data("record");let $columns=$tableRow.find("td");for(let i=0;i").addClass("jtable-modal-dialog").appendTo(self._$mainContainer);$('

').css({padding:"0px"}).text(self.options.messages.areYouSure).appendTo(self._$deleteDialog);$('

').appendTo(self._$deleteDialog);const $cancelButton=$(' ').attr("id","DeleteDialogCancelButton").html(""+self.options.messages.cancel+"").on("click",function(){self._closeDeleteDialog()});let $deleteButton=$('').attr("id","DeleteDialogDeleteButton").html(""+self.options.messages.deleteText+"").on("click",function(){if(self._$deletingRow.hasClass("jtable-row-removed")){self._closeDeleteDialog();return}self._setEnabledOfDialogButton($deleteButton,false,self.options.messages.deleting);self._deleteRecordFromServer(self._$deletingRow,function(){self._removeRowsFromTableWithAnimation(self._$deletingRow);self._closeDeleteDialog()},function(message){self._showError(message)})});self._$deleteDialog.append($cancelButton,$deleteButton)},_closeDeleteDialog:function(){this._$deleteDialog[0].close()},deleteRows:function($rows){let self=this;if($rows.length<=0){self._logWarn("No rows specified to jTable deleteRows method.");return}if(self._isBusy()){self._logWarn("Can not delete rows since jTable is busy!");return}if($rows.length==1){self._deleteRecordFromServer($rows,function(){self._removeRowsFromTableWithAnimation($rows)},function(message){self._showError(message)});return}self._showBusy(self._formatString(self.options.messages.deleteProggress,0,$rows.length));let completedCount=0;let isCompleted=function(){return completedCount>=$rows.length};let completed=function(){let $deletedRows=$rows.filter(".jtable-row-ready-to-remove");if($deletedRows.length<$rows.length){self._showError(self._formatString(self.options.messages.canNotDeletedRecords,$rows.length-$deletedRows.length,$rows.length))}if($deletedRows.length>0){self._removeRowsFromTableWithAnimation($deletedRows)}self._hideBusy()};let deletedCount=0;$rows.each(function(){let $row=$(this);self._deleteRecordFromServer($row,function(){++deletedCount;++completedCount;$row.addClass("jtable-row-ready-to-remove");self._showBusy(self._formatString(self.options.messages.deleteProggress,deletedCount,$rows.length));if(isCompleted()){completed()}},function(){++completedCount;if(isCompleted()){completed()}})})},deleteRecord:function(options){let self=this;options=$.extend({clientOnly:false,animationsEnabled:self.options.animationsEnabled,url:self.options.actions.deleteAction,success:function(){},error:function(){}},options);if(options.key==undefined){self._logWarn("options parameter in deleteRecord method must contain a key property.");return}let $deletingRow=self.getRowByKey(options.key);if($deletingRow==null){self._logWarn("Can not found any row by key: "+options.key);return}if(options.clientOnly){self._removeRowsFromTableWithAnimation($deletingRow,options.animationsEnabled);options.success();return}self._deleteRecordFromServer($deletingRow,function(data){self._removeRowsFromTableWithAnimation($deletingRow,options.animationsEnabled);options.success(data)},function(message){self._showError(message);options.error(message)},options.url)},_addColumnsToHeaderRow:function($tr){base._addColumnsToHeaderRow.apply(this,arguments);if(this.options.actions.deleteAction!=undefined){$tr.append(this._createEmptyCommandHeader("jtable-column-header-delete"))}},_addCellsToRowUsingRecord:function($row){base._addCellsToRowUsingRecord.apply(this,arguments);let self=this;if(self.options.actions.deleteAction!=undefined){let $span=$("").html(self.options.messages.deleteText);let $button=$('').addClass("jtable-command-button jtable-delete-command-button").append($span).on("click",function(e){e.preventDefault();e.stopPropagation();self._deleteButtonClickedForRow($row)});$("").addClass("jtable-command-column").append($button).appendTo($row)}},_deleteButtonClickedForRow:function($row){let self=this;let deleteConfirm;let deleteConfirmMessage=self.options.messages.deleteConfirmation;if($.isFunction(self.options.deleteConfirmation)){let data={row:$row,record:$row.data("record"),deleteConfirm:true,deleteConfirmMessage:deleteConfirmMessage,cancel:false,cancelMessage:null};self.options.deleteConfirmation(data);if(data.cancel){if(data.cancelMessage){self._showError(data.cancelMessage)}return}deleteConfirmMessage=data.deleteConfirmMessage;deleteConfirm=data.deleteConfirm}else{deleteConfirm=self.options.deleteConfirmation}if(deleteConfirm!=false){self._showDeleteDialog($row,deleteConfirmMessage)}else{self._deleteRecordFromServer($row,function(){self._removeRowsFromTableWithAnimation($row)},function(message){self._showError(message)})}},_showDeleteDialog:function($row,deleteConfirmMessage){this._$deletingRow=$row;this._$deleteDialog.find(".jtable-delete-confirm-message").html(deleteConfirmMessage);let $deleteButton=this._$deleteDialog.find("#DeleteDialogDeleteButton");this._setEnabledOfDialogButton($deleteButton,true,this.options.messages.deleteText);this._$deleteDialog[0].showModal()},_deleteRecordFromServer:function($row,success,error,url){let self=this;let completeDelete=function(data){if(data.Result!="OK"){$row.data("deleting",false);if(error){error(data.Message)}return}self._$mainContainer.trigger("recordDeleted",{record:$row.data("record"),row:$row,serverResponse:data});if(success){success(data)}};if($row.data("deleting")==true){return}$row.data("deleting",true);let postData={};postData[self._keyField]=self._getKeyValueOfRecord($row.data("record"));if(!url&&$.isFunction(self.options.actions.deleteAction)){let funcResult=self.options.actions.deleteAction(postData);if(self._isDeferredObject(funcResult)){funcResult.done(function(data){completeDelete(data)}).fail(function(){$row.data("deleting",false);if(error){error(self.options.messages.serverCommunicationError)}})}else{completeDelete(funcResult)}}else{this._ajax({url:url||self.options.actions.deleteAction,data:postData,success:function(data){completeDelete(data)},error:function(){$row.data("deleting",false);if(error){error(self.options.messages.serverCommunicationError)}}})}},_removeRowsFromTableWithAnimation:function($rows,animationsEnabled){let self=this;if(animationsEnabled==undefined){animationsEnabled=self.options.animationsEnabled}if(animationsEnabled){let className="jtable-row-deleting";if(this.options.jqueryuiTheme){className=className+" ui-state-disabled"}$rows.stop(true,true).addClass(className,"slow","").promise().done(function(){self._removeRowsFromTable($rows,"deleted")})}else{self._removeRowsFromTable($rows,"deleted")}}})})(jQuery);(function($){let base={_create:jTable.prototype._create,_loadExtraSettings:jTable.prototype._loadExtraSettings,_addColumnsToHeaderRow:jTable.prototype._addColumnsToHeaderRow,_addCellsToRowUsingRecord:jTable.prototype._addCellsToRowUsingRecord,_onLoadingRecords:jTable.prototype._onLoadingRecords,_onRecordsLoaded:jTable.prototype._onRecordsLoaded,_onRowsRemoved:jTable.prototype._onRowsRemoved};$.extend(true,jTable.prototype,{options:{selecting:false,multiselect:false,selectingCheckboxes:false,selectOnRowClick:true,selectionChanged:function(event,data){}},_selectedRecordIdsBeforeLoad:null,_$selectAllCheckbox:null,_shiftKeyDown:false,_create:function(){if(this.options.selecting&&this.options.selectingCheckboxes){++this._firstDataColumnOffset;this._bindKeyboardEvents()}base._create.apply(this,arguments)},_loadExtraSettings:function(){base._loadExtraSettings.apply(this,arguments);if(!this._keyField){this.options.selecting=false;this._logWarn("No key field defined, selecting is not possible.")}},_bindKeyboardEvents:function(){let self=this;$(document).on("keydown",function(event){switch(event.which){case 16:self._shiftKeyDown=true;break}}).on("keyup",function(event){switch(event.which){case 16:self._shiftKeyDown=false;break}})},selectedRows:function(){return this._getSelectedRows()},selectRows:function($rows){this._selectRows($rows);this._onSelectionChanged()},_addColumnsToHeaderRow:function($tr){if(this.options.selecting&&this.options.selectingCheckboxes){if(this.options.multiselect){$tr.append(this._createSelectAllHeader())}else{$tr.append(this._createEmptyCommandHeader())}}base._addColumnsToHeaderRow.apply(this,arguments)},_addCellsToRowUsingRecord:function($row){if(this.options.selecting){this._makeRowSelectable($row)}base._addCellsToRowUsingRecord.apply(this,arguments)},_onLoadingRecords:function(){if(this.options.selecting){this._storeSelectionList()}base._onLoadingRecords.apply(this,arguments)},_onRecordsLoaded:function(){if(this.options.selecting){this._restoreSelectionList()}base._onRecordsLoaded.apply(this,arguments)},_onRowsRemoved:function($rows,reason){if(this.options.selecting&&reason!="reloading"&&$rows.filter(".jtable-row-selected").length>0){this._onSelectionChanged()}base._onRowsRemoved.apply(this,arguments)},_createSelectAllHeader:function(){let self=this;let $columnHeader=$('').addClass("jtable-command-column jtable-command-column-header jtable-column-header-select");this._jqueryuiThemeAddClass($columnHeader,"ui-state-default");let $headerContainer=$("
").addClass("jtable-column-header-container").appendTo($columnHeader);self._$selectAllCheckbox=$('').appendTo($headerContainer).on("click",function(){if(self._$tableRows.length<=0){self._$selectAllCheckbox.attr("checked",false);return}let allRows=self._$tableBody.find(">tr.jtable-data-row");if(self._$selectAllCheckbox.is(":checked")){self._selectRows(allRows)}else{self._deselectRows(allRows)}self._onSelectionChanged()});return $columnHeader},_storeSelectionList:function(){let self=this;if(!self.options.selecting){return}self._selectedRecordIdsBeforeLoad=[];self._getSelectedRows().each(function(){self._selectedRecordIdsBeforeLoad.push(self._getKeyValueOfRecord($(this).data("record")))})},_restoreSelectionList:function(){let self=this;if(!self.options.selecting){return}let selectedRowCount=0;for(let i=0;i-1){self._selectRows(self._$tableRows[i]);++selectedRowCount}}if(self._selectedRecordIdsBeforeLoad.length>0&&self._selectedRecordIdsBeforeLoad.length!=selectedRowCount){self._onSelectionChanged()}self._selectedRecordIdsBeforeLoad=[];self._refreshSelectAllCheckboxState()},_getSelectedRows:function(){return this._$tableBody.find(">tr.jtable-row-selected")},_makeRowSelectable:function($row){let self=this;if(self.options.selectOnRowClick){$row.on("click",function(){self._invertRowSelection($row)})}if(self.options.selectingCheckboxes){let $cell=$("").addClass("jtable-command-column jtable-selecting-column");let $selectCheckbox=$('').appendTo($cell);if(typeof $row.data("recordKey")!=="undefined"){$selectCheckbox.attr("id","jtable-column-checkbox-"+$row.data("recordKey"))}if(!self.options.selectOnRowClick){$selectCheckbox.on("click",function(){self._invertRowSelection($row)})}$row.append($cell)}},_invertRowSelection:function($row){if($row.hasClass("jtable-row-selected")){this._deselectRows($row)}else{if(this._shiftKeyDown){let rowIndex=this._findRowIndex($row);let beforeIndex=this._findFirstSelectedRowIndexBeforeIndex(rowIndex)+1;if(beforeIndex>0&&beforeIndexrowIndex){this._selectRows(this._$tableBody.find("tr").slice(rowIndex,afterIndex+1))}else{this._selectRows($row)}}}else{this._selectRows($row)}}this._onSelectionChanged()},_findFirstSelectedRowIndexBeforeIndex:function(rowIndex){for(let i=rowIndex-1;i>=0;--i){if(this._$tableRows[i].hasClass("jtable-row-selected")){return i}}return-1},_findFirstSelectedRowIndexAfterIndex:function(rowIndex){for(let i=rowIndex+1;itd.jtable-selecting-column >input").prop("checked",true)}this._refreshSelectAllCheckboxState()},_deselectRows:function($rows){$rows.removeClass("jtable-row-selected ui-state-highlight");if(this.options.selectingCheckboxes){$rows.find(">td.jtable-selecting-column >input").prop("checked",false)}this._refreshSelectAllCheckboxState()},_refreshSelectAllCheckboxState:function(){if(!this.options.selectingCheckboxes||!this.options.multiselect){return}let totalRowCount=this._$tableRows.length;let selectedRowCount=this._getSelectedRows().length;if(selectedRowCount==0){this._$selectAllCheckbox.prop("indeterminate",false);this._$selectAllCheckbox.attr("checked",false)}else if(selectedRowCount==totalRowCount){this._$selectAllCheckbox.prop("indeterminate",false);this._$selectAllCheckbox.attr("checked",true)}else{this._$selectAllCheckbox.attr("checked",false);this._$selectAllCheckbox.prop("indeterminate",true)}},_onSelectionChanged:function(){this._$mainContainer.trigger("selectionChanged",{})}})})(jQuery);(function($){let base={load:jTable.prototype.load,_create:jTable.prototype._create,_setOption:jTable.prototype._setOption,_createJtParamsForLoading:jTable.prototype._createJtParamsForLoading,_addRowToTable:jTable.prototype._addRowToTable,_addRow:jTable.prototype._addRow,_removeRowsFromTable:jTable.prototype._removeRowsFromTable,_onRecordsLoaded:jTable.prototype._onRecordsLoaded};$.extend(true,jTable.prototype,{options:{paging:false,pageList:"normal",pageSize:10,pageSizes:[10,25,50,100,250,500],pageSizeChangeArea:true,gotoPageArea:"combobox",messages:{pagingInfo:"Showing {0}-{1} of {2}",pageSizeChangeLabel:"Row count",gotoPageLabel:"Go to page"}},_$bottomPanel:null,_$pagingListArea:null,_$pageSizeChangeArea:null,_$pageInfoSpan:null,_$gotoPageArea:null,_$gotoPageInput:null,_totalRecordCount:0,_currentPageNo:1,_create:function(){base._create.apply(this,arguments);if(this.options.paging){this._loadPagingSettings();this._createBottomPanel();this._createPageListArea();this._createGotoPageInput();this._createPageSizeSelection()}},_loadPagingSettings:function(){if(!this.options.saveUserPreferences){return}let pageSize=this._getCookie("page-size");if(pageSize==null){return}if(!pageSize){self._removeCookie("page-size");return}if(pageSize){this.options.pageSize=this._normalizeNumber(pageSize,1,1e6,this.options.pageSize)}},_createBottomPanel:function(){this._$bottomPanel=$("
").addClass("jtable-bottom-panel").insertAfter(this._$tableDiv);this._jqueryuiThemeAddClass(this._$bottomPanel,"ui-state-default");$("
").addClass("jtable-left-area").appendTo(this._$bottomPanel);$("
").addClass("jtable-right-area").appendTo(this._$bottomPanel)},_createPageListArea:function(){this._$pagingListArea=$("").addClass("jtable-page-list").appendTo(this._$bottomPanel.find(".jtable-left-area"));this._$pageInfoSpan=$("").addClass("jtable-page-info").appendTo(this._$bottomPanel.find(".jtable-right-area"))},_createPageSizeSelection:function(){let self=this;if(!self.options.pageSizeChangeArea){return}if(self._findIndexInArray(self.options.pageSize,self.options.pageSizes)<0){self.options.pageSizes.push(parseInt(self.options.pageSize));self.options.pageSizes.sort(function(a,b){return a-b})}self._$pageSizeChangeArea=$("").addClass("jtable-page-size-change").appendTo(self._$bottomPanel.find(".jtable-left-area"));self._$pageSizeChangeArea.append(""+self.options.messages.pageSizeChangeLabel+": ");let $pageSizeChangeCombobox=$('').appendTo(self._$pageSizeChangeArea);for(let i=0;i'+self.options.pageSizes[i]+"")}$pageSizeChangeCombobox.val(self.options.pageSize);$pageSizeChangeCombobox.change(function(){self._changePageSize(parseInt($(this).val()))})},_createGotoPageInput:function(){let self=this;if(!self.options.gotoPageArea||self.options.gotoPageArea=="none"){return}this._$gotoPageArea=$("").addClass("jtable-goto-page").appendTo(self._$bottomPanel.find(".jtable-left-area"));this._$gotoPageArea.append(""+self.options.messages.gotoPageLabel+": ");if(self.options.gotoPageArea=="combobox"){self._$gotoPageInput=$('').appendTo(this._$gotoPageArea).data("pageCount",1).change(function(){self._changePage(parseInt($(this).val()))});self._$gotoPageInput.append('')}else{self._$gotoPageInput=$('').appendTo(this._$gotoPageArea).keypress(function(event){if(event.which==13){event.preventDefault();self._changePage(parseInt(self._$gotoPageInput.val()))}else if(event.which==43){event.preventDefault();self._changePage(parseInt(self._$gotoPageInput.val())+1)}else if(event.which==45){event.preventDefault();self._changePage(parseInt(self._$gotoPageInput.val())-1)}else{let isValid=471e4){pageStep=100}else if(currentPageCount>5e3){pageStep=10}else if(currentPageCount>2e3){pageStep=5}else if(currentPageCount>1e3){pageStep=2}for(let i=pageStep;i<=currentPageCount;i+=pageStep){this._$gotoPageInput.append('")}this._$gotoPageInput.data("pageCount",currentPageCount)}}this._$gotoPageInput.val(this._currentPageNo)},load:function(){this._currentPageNo=1;base.load.apply(this,arguments)},_setOption:function(key,value){base._setOption.apply(this,arguments);if(key=="pageSize"){this._changePageSize(parseInt(value))}},_changePageSize:function(pageSize){if(pageSize==this.options.pageSize){return}this.options.pageSize=pageSize;let pageCount=this._calculatePageCount();if(this._currentPageNo>pageCount){this._currentPageNo=pageCount}if(this._currentPageNo<=0){this._currentPageNo=1}let $pageSizeChangeCombobox=this._$bottomPanel.find(".jtable-page-size-change select");if($pageSizeChangeCombobox.length>0){if(parseInt($pageSizeChangeCombobox.val())!=pageSize){let selectedOption=$pageSizeChangeCombobox.find("option[value="+pageSize+"]");if(selectedOption.length>0){$pageSizeChangeCombobox.val(pageSize)}}}this._savePagingSettings();this._reloadTable()},_savePagingSettings:function(){if(!this.options.saveUserPreferences){return}this._setCookie("page-size",this.options.pageSize)},_createJtParamsForLoading:function(){let jtParams=base._createJtParamsForLoading.apply(this,arguments);if(this.options.paging){jtParams.jtStartIndex=(this._currentPageNo-1)*this.options.pageSize;jtParams.jtPageSize=this.options.pageSize}return jtParams},_addRowToTable:function($tableRow,index,isNewRow){if(isNewRow&&this.options.paging){this._reloadTable();return}base._addRowToTable.apply(this,arguments)},_addRow:function($row,options){if(options&&options.isNewRow&&this.options.paging){this._reloadTable();return}base._addRow.apply(this,arguments)},_removeRowsFromTable:function($rows,reason){base._removeRowsFromTable.apply(this,arguments);if(this.options.paging){if(this._$tableRows.length<=0&&this._currentPageNo>1){--this._currentPageNo}this._reloadTable()}},_onRecordsLoaded:function(data){if(this.options.paging){this._totalRecordCount=data.TotalRecordCount;this._createPagingList();this._createPagingInfo();this._refreshGotoPageInput()}base._onRecordsLoaded.apply(this,arguments)},_addPagingInfoToUrl:function(url,pageNumber){if(!this.options.paging){return url}let jtStartIndex=(pageNumber-1)*this.options.pageSize;let jtPageSize=this.options.pageSize;return url+(url.includes("?")?"?":"&")+"jtStartIndex="+jtStartIndex+"&jtPageSize="+jtPageSize},_createPagingList:function(){if(this.options.pageSize<=0){return}this._$pagingListArea.empty();if(this._totalRecordCount<=0){return}let pageCount=this._calculatePageCount();this._createFirstAndPreviousPageButtons();if(this.options.pageList=="normal"){this._createPageNumberButtons(this._calculatePageNumbers(pageCount))}this._createLastAndNextPageButtons(pageCount);this._bindClickEventsToPageNumberButtons()},_createFirstAndPreviousPageButtons:function(){let $first=$("").addClass("jtable-page-number-first").html("<<").data("pageNumber",1).appendTo(this._$pagingListArea);let $previous=$("").addClass("jtable-page-number-previous").html("<").data("pageNumber",this._currentPageNo-1).appendTo(this._$pagingListArea);this._jqueryuiThemeAddClass($first,"ui-button ui-state-default","ui-state-hover");this._jqueryuiThemeAddClass($previous,"ui-button ui-state-default","ui-state-hover");if(this._currentPageNo<=1){$first.addClass("jtable-page-number-disabled");$previous.addClass("jtable-page-number-disabled");this._jqueryuiThemeAddClass($first,"ui-state-disabled");this._jqueryuiThemeAddClass($previous,"ui-state-disabled")}},_createLastAndNextPageButtons:function(pageCount){let $next=$("").addClass("jtable-page-number-next").html(">").data("pageNumber",this._currentPageNo+1).appendTo(this._$pagingListArea);let $last=$("").addClass("jtable-page-number-last").html(">>").data("pageNumber",pageCount).appendTo(this._$pagingListArea);this._jqueryuiThemeAddClass($next,"ui-button ui-state-default","ui-state-hover");this._jqueryuiThemeAddClass($last,"ui-button ui-state-default","ui-state-hover");if(this._currentPageNo>=pageCount){$next.addClass("jtable-page-number-disabled");$last.addClass("jtable-page-number-disabled");this._jqueryuiThemeAddClass($next,"ui-state-disabled");this._jqueryuiThemeAddClass($last,"ui-state-disabled")}},_createPageNumberButtons:function(pageNumbers){let previousNumber=0;for(let i=0;i1){$("").addClass("jtable-page-number-space").html("...").appendTo(this._$pagingListArea)}this._createPageNumberButton(pageNumbers[i]);previousNumber=pageNumbers[i]}},_createPageNumberButton:function(pageNumber){let $pageNumber=$("").addClass("jtable-page-number").html(pageNumber).data("pageNumber",pageNumber).appendTo(this._$pagingListArea);this._jqueryuiThemeAddClass($pageNumber,"ui-button ui-state-default","ui-state-hover");if(this._currentPageNo==pageNumber){$pageNumber.addClass("jtable-page-number-active jtable-page-number-disabled");this._jqueryuiThemeAddClass($pageNumber,"ui-state-active")}},_calculatePageCount:function(){let pageCount=Math.floor(this._totalRecordCount/this.options.pageSize);if(this._totalRecordCount%this.options.pageSize!=0){++pageCount}return pageCount},_calculatePageNumbers:function(pageCount){if(pageCount<=4){let pageNumbers=[];for(let i=1;i<=pageCount;++i){pageNumbers.push(i)}return pageNumbers}else{let shownPageNumbers=[1,2,pageCount-1,pageCount];let previousPageNo=this._normalizeNumber(this._currentPageNo-1,1,pageCount,1);let nextPageNo=this._normalizeNumber(this._currentPageNo+1,1,pageCount,1);this._insertToArrayIfDoesNotExists(shownPageNumbers,previousPageNo);this._insertToArrayIfDoesNotExists(shownPageNumbers,this._currentPageNo);this._insertToArrayIfDoesNotExists(shownPageNumbers,nextPageNo);shownPageNumbers.sort(function(a,b){return a-b});return shownPageNumbers}},_createPagingInfo:function(){if(this._totalRecordCount<=0){this._$pageInfoSpan.empty();return}let startNo=(this._currentPageNo-1)*this.options.pageSize+1;let endNo=this._currentPageNo*this.options.pageSize;endNo=this._normalizeNumber(endNo,startNo,this._totalRecordCount,0);if(endNo>=startNo){let pagingInfoMessage=this._formatString(this.options.messages.pagingInfo,startNo,endNo,this._totalRecordCount);this._$pageInfoSpan.html(pagingInfoMessage)}},_bindClickEventsToPageNumberButtons:function(){let self=this;self._$pagingListArea.find(".jtable-page-number,.jtable-page-number-previous,.jtable-page-number-next,.jtable-page-number-first,.jtable-page-number-last").not(".jtable-page-number-disabled").on("click",function(e){e.preventDefault();self._changePage($(this).data("pageNumber"))})},_changePage:function(pageNo){pageNo=this._normalizeNumber(pageNo,1,this._calculatePageCount(),1);if(pageNo==this._currentPageNo){this._refreshGotoPageInput();return}this._currentPageNo=pageNo;this._reloadTable()}})})(jQuery);(function($){let base={_initializeSettings:jTable.prototype._initializeSettings,_normalizeFieldOptions:jTable.prototype._normalizeFieldOptions,_doExtraActions:jTable.prototype._doExtraActions,_createHeaderCellForField:jTable.prototype._createHeaderCellForField,_createJtParamsForLoading:jTable.prototype._createJtParamsForLoading};$.extend(true,jTable.prototype,{options:{sorting:false,multiSorting:false,roomForSortableIcon:true,defaultSorting:""},_lastSorting:null,_initializeSettings:function(){base._initializeSettings.apply(this,arguments);this._lastSorting=[]},_normalizeFieldOptions:function(fieldName,props){base._normalizeFieldOptions.apply(this,arguments);props.sorting=props.sorting!=false},_doExtraActions:function(){base._doExtraActions.apply(this,arguments);if(this.options.sorting){this._buildDefaultSortingArray()}if(this.options.saveUserPreferences&&this.options.sorting){this._loadColumnSortSettings()}},_createHeaderCellForField:function(fieldName,field){let $headerCell=base._createHeaderCellForField.apply(this,arguments);if(this.options.sorting&&field.sorting){this._makeColumnSortable($headerCell,fieldName,field.initialSortingDirection)}return $headerCell},_buildDefaultSortingArray:function(){let self=this;$.each(self.options.defaultSorting.split(","),function(orderIndex,orderValue){$.each(self.options.fields,function(fieldName,fieldProps){if(fieldProps.sorting){let colOffset=orderValue.indexOf(fieldName);if(colOffset>-1){if(orderValue.toUpperCase().includes(" DESC",colOffset)){self._lastSorting.push({fieldName:fieldName,sortOrder:"DESC"})}else{self._lastSorting.push({fieldName:fieldName,sortOrder:"ASC"})}}}})})},_makeColumnSortable:function($columnHeader,fieldName,initialSortingDirection){let self=this;if(self.options.roomForSortableIcon){$columnHeader.find(".jtable-column-header-text").append("     ")}$columnHeader.addClass("jtable-column-header-sortable").on("click",function(e){e.preventDefault();if(!self.options.multiSorting||!e.ctrlKey){self._lastSorting=[]}self._sortTableByColumn($columnHeader)});if(initialSortingDirection){$columnHeader.addClass("jtable-column-header-sorted-"+initialSortingDirection.toLowerCase())}$.each(this._lastSorting,function(sortIndex,sortField){if(sortField.fieldName==fieldName){if(sortField.sortOrder=="DESC"){$columnHeader.addClass("jtable-column-header-sorted-desc")}else{$columnHeader.addClass("jtable-column-header-sorted-asc")}}})},_sortTableByColumn:function($columnHeader){if(this._lastSorting.length==0){$columnHeader.siblings().removeClass("jtable-column-header-sorted-asc jtable-column-header-sorted-desc")}for(let i=0;ithead >tr >th:nth-child("+columnIndexInTable+"),>tbody >tr >td:nth-child("+columnIndexInTable+")").hide()}else if(field.visibility=="hidden"&&visibility!="hidden"&&visibility!="separator"){this._$table.find(">thead >tr >th:nth-child("+columnIndexInTable+"),>tbody >tr >td:nth-child("+columnIndexInTable+")").show().css("display","table-cell")}field.visibility=visibility},_createColumnSelection:function(){let self=this;this._$columnSelectionDiv=$("
").addClass("jtable-column-selection-container").appendTo(self._$mainContainer);this._$table.children("thead").on("contextmenu",function(e){if(!self.options.columnSelectable){return}e.preventDefault();$("
").addClass("jtable-contextmenu-overlay").on("click",function(){$(this).remove();self._$columnSelectionDiv.hide()}).on("contextmenu",function(){return false}).appendTo(document.body);self._fillColumnSelection();let containerOffset=self._$mainContainer.offset();let selectionDivTop=e.pageY-containerOffset.top;let selectionDivLeft=e.pageX-containerOffset.left;let selectionDivMinWidth=100;let containerWidth=self._$mainContainer.width();if(containerWidth>selectionDivMinWidth&&selectionDivLeft>containerWidth-selectionDivMinWidth){selectionDivLeft=containerWidth-selectionDivMinWidth}self._$columnSelectionDiv.css({left:selectionDivLeft,top:selectionDivTop,"min-width":selectionDivMinWidth+"px"}).show()})},_fillColumnSelection:function(){let self=this;let $columnsUl=$("
    ").addClass("jtable-column-select-list");for(let i=0;i").appendTo($columnsUl);let $label=$("").append($(""+(field.title||columnName)+"")).appendTo($columnLi);if(field.visibility!="separator"){let $checkbox=$('').prependTo($label).on("click",function(){let clickedColumnName=$(this).attr("id");let clickedField=self.options.fields[clickedColumnName];if(clickedField.visibility=="fixed"){return}self.changeColumnVisibility(clickedColumnName,$(this).is(":checked")?"visible":"hidden")});if(field.visibility!="hidden"){$checkbox.attr("checked","checked")}if(field.visibility=="fixed"){$checkbox.attr("disabled","disabled")}}}this._$columnSelectionDiv.html($columnsUl)},_createColumnResizeBar:function(){this._$columnResizeBar=$("
    ").addClass("jtable-column-resize-bar").appendTo(this._$mainContainer).hide()},_makeColumnResizable:function($columnHeader){let self=this;$("
    ").addClass("jtable-column-resize-handler").appendTo($columnHeader.find(".jtable-column-header-container")).on("click",function(e){e.preventDefault();e.stopPropagation()}).mousedown(function(downevent){downevent.preventDefault();downevent.stopPropagation();let mainContainerOffset=self._$mainContainer.offset();let $nextColumnHeader=$columnHeader.nextAll("th.jtable-column-header:visible:first");if($nextColumnHeader.length){let nextfieldname=$nextColumnHeader.data("fieldName");if(!self.options.fields[nextfieldname].columnResizable){$nextColumnHeader=undefined}}if($nextColumnHeader){nextColumnOuterWidth=$nextColumnHeader.outerWidth()}else{nextColumnOuterWidth=0}let minimumColumnWidth=10;self._currentResizeArgs={currentColumnStartWidth:$columnHeader.outerWidth(),minWidth:minimumColumnWidth,maxWidth:$columnHeader.outerWidth()+nextColumnOuterWidth,mouseStartX:downevent.pageX,minResizeX:function(){return this.mouseStartX-(this.currentColumnStartWidth-this.minWidth)},maxResizeX:function(){return this.mouseStartX+(this.maxWidth-this.currentColumnStartWidth)}};let resizeonmousemove=function(moveevent){if(!self._currentResizeArgs){return}let resizeBarX=self._normalizeNumber(moveevent.pageX,self._currentResizeArgs.minResizeX(),self._currentResizeArgs.maxResizeX());self._$columnResizeBar.css("left",resizeBarX-mainContainerOffset.left+"px")};let resizeonmouseup=function(upevent){if(!self._currentResizeArgs){return}$(document).off("mousemove",resizeonmousemove);$(document).off("mouseup",resizeonmouseup);self._$columnResizeBar.hide();let mouseChangeX=upevent.pageX-self._currentResizeArgs.mouseStartX;if(mouseChangeX!=0){let currentColumnFinalWidth=self._normalizeNumber(self._currentResizeArgs.currentColumnStartWidth+mouseChangeX,self._currentResizeArgs.minWidth,self._currentResizeArgs.maxWidth);let pixelToPercentRatio=$columnHeader.data("width-in-percent")/self._currentResizeArgs.currentColumnStartWidth;$columnHeader.data("width-in-percent",currentColumnFinalWidth*pixelToPercentRatio);$columnHeader.css("width",$columnHeader.data("width-in-percent")+"%");if($nextColumnHeader){let nextColumnFinalWidth=nextColumnOuterWidth+(self._currentResizeArgs.currentColumnStartWidth-currentColumnFinalWidth);$nextColumnHeader.data("width-in-percent",nextColumnFinalWidth*pixelToPercentRatio);$nextColumnHeader.css("width",$nextColumnHeader.data("width-in-percent")+"%")}self._normalizeColumnWidths();if(self.options.saveUserPreferences){self._saveColumnSettings()}}self._currentResizeArgs=null};self._$columnResizeBar.show().css({top:$columnHeader.offset().top-mainContainerOffset.top+"px",left:downevent.pageX-mainContainerOffset.left+"px",height:self._$table.outerHeight()+"px"});$(document).on("mousemove",resizeonmousemove);$(document).on("mouseup",resizeonmouseup)})},_normalizeColumnWidths:function(){let self=this;let commandColumnHeaders=self._$table.find(">thead th.jtable-command-column-header").data("width-in-percent",1).css("width","1%");let headerCells=self._$table.find(">thead th");let totalWidthInPixel=self._$table.outerWidth();let columnWidths={};headerCells.each(function(){let $cell=$(this);if($cell.is(":visible")){let fieldName=$cell.data("fieldName");let widthInPercent=$cell.outerWidth()*100/totalWidthInPixel;columnWidths[fieldName]=widthInPercent}});headerCells.each(function(){let $cell=$(this);if($cell.is(":visible")){let fieldName=$cell.data("fieldName");$cell.data("width-in-percent",columnWidths[fieldName]).css("width",columnWidths[fieldName]+"%")}else{$cell.data("width-in-percent",1).css("width","1%")}})},_saveColumnSettings:function(){let self=this;let fieldSettings="";self._$table.find(">thead >tr >th.jtable-column-header").each(function(){let $cell=$(this);let fieldName=$cell.data("fieldName");let columnWidth=$cell.data("width-in-percent");let fieldVisibility=self.options.fields[fieldName].visibility;let fieldSetting=fieldName+"="+fieldVisibility+";"+columnWidth;fieldSettings=fieldSettings+fieldSetting+"|"});this._setCookie("column-settings",fieldSettings.substr(0,fieldSettings.length-1))},_loadColumnSettings:function(){let self=this;let columnSettingsCookie=self._getCookie("column-settings");if(columnSettingsCookie==null){return}if(!columnSettingsCookie){self._removeCookie("column-settings");return}let columnSettings={};$.each(columnSettingsCookie.split("|"),function(inx,fieldSetting){let splitted=fieldSetting.split("=");let fieldName=splitted[0];let settings=splitted[1].split(";");let columnVisibility=settings[0];let columnWidth=settings[1];if($.inArray(fieldName,self._fieldList)>-1){if(self.options.fields[fieldName].visibility!="fixed"){self.options.fields[fieldName].visibility=columnVisibility}if(self.options.columnResizable){let allow_resize=self.options.fields[fieldName].columnResizable!=false;if(allow_resize){self.options.fields[fieldName].width=columnWidth+"%"}}}})}})})(jQuery);(function($){let base={_removeRowsFromTable:jTable.prototype._removeRowsFromTable};$.extend(true,jTable.prototype,{options:{openChildAsAccordion:false},openChildTable:function($row,tableOptions,opened){let self=this;if(tableOptions.jqueryuiTheme==undefined){tableOptions.jqueryuiTheme=self.options.jqueryuiTheme}tableOptions.showCloseButton=tableOptions.showCloseButton!=false;if(tableOptions.showCloseButton&&!tableOptions.closeRequested){tableOptions.closeRequested=function(){self.closeChildTable($row)}}if(self.options.openChildAsAccordion){$row.siblings(".jtable-data-row").each(function(){self.closeChildTable($(this))})}self.closeChildTable($row,function(){let $childRowColumn=self.getChildRow($row).children("td").empty();let $childTableContainer=$("
    ").addClass("jtable-child-table-container").appendTo($childRowColumn);$childRowColumn.data("childTable",$childTableContainer);$childTableContainer.jtable(tableOptions);self.openChildRow($row);$childTableContainer.hide().slideDown("fast",function(){if(opened){opened({childTable:$childTableContainer})}})})},closeChildTable:function($row,closed){let self=this;let $childRowColumn=self.getChildRow($row).children("td");let $childTable=$childRowColumn.data("childTable");if(!$childTable){if(closed){closed()}return}$childRowColumn.data("childTable",null);$childTable.slideUp("fast",function(){$childTable.jtable("destroy");$childTable.remove();self.closeChildRow($row);if(closed){closed()}})},isChildRowOpen:function($row){return this.getChildRow($row).is(":visible")},getChildRow:function($row){return $row.data("childRow")||this._createChildRow($row)},openChildRow:function($row){let $childRow=this.getChildRow($row);if(!$childRow.is(":visible")){$childRow.show()}return $childRow},closeChildRow:function($row){let $childRow=this.getChildRow($row);if($childRow.is(":visible")){$childRow.hide()}},_removeRowsFromTable:function($rows,reason){if(reason=="deleted"){$rows.each(function(){let $row=$(this);let $childRow=$row.data("childRow");if($childRow){$childRow.remove()}})}base._removeRowsFromTable.apply(this,arguments)},_createChildRow:function($row){let totalColumnCount=this._$table.find("thead th").length;let $childRow=$("").addClass("jtable-child-row").append('');$row.after($childRow);$row.data("childRow",$childRow);$childRow.hide();return $childRow}})})(jQuery); \ No newline at end of file +(function($){let unloadingPage;$(window).on("beforeunload",function(){unloadingPage=true});$(window).on("unload",function(){unloadingPage=false});jTable=function(element,options){this.element=$(element);this.options=$.extend(true,{},this.options,options);this._create()};jTable.prototype={options:{tableId:undefined,actions:{},fields:{},animationsEnabled:true,defaultDateFormat:"yy-mm-dd",showCloseButton:false,loadingAnimationDelay:500,saveUserPreferences:true,jqueryuiTheme:false,unAuthorizedRequestRedirectUrl:null,listQueryParams:{},ajaxSettings:{type:"POST",dataType:"json"},toolbar:{hoverAnimation:true,hoverAnimationDuration:60,hoverAnimationEasing:undefined,items:[]},closeRequested:function(event,data){},formCreated:function(event,data){},formSubmitting:function(event,data){},formClosed:function(event,data){},loadingRecords:function(event,data){},recordsLoaded:function(event,data){},rowInserted:function(event,data){},rowsRemoved:function(event,data){},messages:{serverCommunicationError:"An error occured while communicating to the server.",loadingMessage:"Loading records...",noDataAvailable:"No data available!",areYouSure:"Are you sure?",save:"Save",saving:"Saving",cancel:"Cancel",error:"Error",close:"Close",cannotLoadOptionsFor:"Can not load options for field {0}"}},_$mainContainer:null,_$titleDiv:null,_$toolbarDiv:null,_$tableDiv:null,_$table:null,_$tableBody:null,_$tableRows:null,_$busyDialog:null,_$errorDialog:null,_columnList:null,_fieldList:null,_keyField:null,_firstDataColumnOffset:0,_lastPostData:null,_cache:null,_extraFieldTypes:[],_create:function(){this._initializeSettings();this._createFieldAndColumnList();this._cookieKeyPrefix=this._generateCookieKeyPrefix();this._loadExtraSettings();this._normalizeFieldsOptions();this._doExtraActions();this._createMainContainer();this._createTableTitle();this._createToolBar();this._createTableDiv();this._createTable();this._createBusyDialog();this._createErrorDialog();this._addNoDataRow()},_normalizeFieldsOptions:function(){let self=this;$.each(self.options.fields,function(fieldName,props){self._normalizeFieldOptions(fieldName,props)})},_normalizeFieldOptions:function(fieldName,props){if(props.listClass==undefined){props.listClass=""}if(props.inputClass==undefined){props.inputClass=""}if(props.placeholder==undefined){props.placeholder=""}if(props.type==undefined){props.type="text"}if(props.dependsOn&&$.type(props.dependsOn)==="string"){let dependsOnArray=props.dependsOn.split(",");props.dependsOn=[];for(let i=0;i").addClass("jtable-main-container").appendTo(this.element);this._jqueryuiThemeAddClass(this._$mainContainer,"ui-widget")},_createTableTitle:function(){let self=this;if(!self.options.title){return}let $titleDiv=$("
    ").addClass("jtable-title").appendTo(self._$mainContainer);self._jqueryuiThemeAddClass($titleDiv,"ui-widget-header");$("
    ").addClass("jtable-title-text").appendTo($titleDiv).append(self.options.title);if(self.options.showCloseButton){let $textSpan=$("").html(self.options.messages.close);$("").addClass("jtable-command-button jtable-close-button").attr("title",self.options.messages.close).append($textSpan).appendTo($titleDiv).on("click",function(e){e.preventDefault();e.stopPropagation();self._onCloseRequested()})}self._$titleDiv=$titleDiv},_createTableDiv:function(){this._$tableDiv=$("
    ").addClass("jtable-table-div").appendTo(this._$mainContainer)},_createTable:function(){this._$table=$("
    ").addClass("jtable").appendTo(this._$tableDiv);if(this.options.tableId){this._$table.attr("id",this.options.tableId)}else if(this._$tableDiv.attr("id")){this._$table.attr("id","jtable-"+this._$mainContainer.attr("id"))}this._jqueryuiThemeAddClass(this._$table,"ui-widget-content");this._createTableHead();this._createTableBody()},_createTableHead:function(){let $thead=$("").appendTo(this._$table);this._addRowToTableHead($thead)},_addRowToTableHead:function($thead){let $tr=$("").appendTo($thead);this._addColumnsToHeaderRow($tr)},_addColumnsToHeaderRow:function($tr){for(let i=0;i").addClass("jtable-column-header-text").html(field.title);let $headerContainerDiv=$("
    ").addClass("jtable-column-header-container").append($headerTextSpan);let $th=$("").addClass("jtable-column-header").addClass(field.listClass).css("width",field.width).data("fieldName",fieldName).append($headerContainerDiv);this._jqueryuiThemeAddClass($th,"ui-state-default");return $th},_createEmptyCommandHeader:function(extraclass){let $th=$("").addClass("jtable-command-column-header"+" "+extraclass).css("width","1%");this._jqueryuiThemeAddClass($th,"ui-state-default");return $th},_createTableBody:function(){this._$tableBody=$("").appendTo(this._$table)},_createBusyDialog:function(){this._$busyDialog=$("").addClass("jtable-busy-modal-dialog").prependTo(this._$mainContainer);this._$busyMessageDiv=$("
    ").addClass("jtable-busy-message").appendTo(this._$busyDialog);this._jqueryuiThemeAddClass(this._$busyMessageDiv,"ui-widget-header")},_createErrorDialog:function(){let self=this;self._$errorDialog=$("").addClass("jtable-modal-dialog").appendTo(self._$mainContainer);$('

    ').css({padding:"0px"}).html(self.options.messages.error).appendTo(self._$errorDialog);$('

    ').appendTo(self._$errorDialog);$('').html(""+self.options.messages.close+"").on("click",function(){self._closeErrorDialog()}).appendTo(self._$errorDialog)},_closeErrorDialog(){this._$errorDialog[0].close()},load:function(extraPostData,completeCallback){let listQueryParams={};if(typeof this.options.listQueryParams==="function"){listQueryParams=this.options.listQueryParams()}else{listQueryParams=this.options.listQueryParams}if(extraPostData){this._lastPostData={...listQueryParams,...extraPostData}}else{this._lastPostData=listQueryParams}this._reloadTable(completeCallback)},reload:function(completeCallback){this._reloadTable(completeCallback)},getRowByKey:function(key){for(let i=0;i").addClass("jtable-data-row").attr("data-record-key",this._getKeyValueOfRecord(record)).data("record",record);this._addCellsToRowUsingRecord($tr);return $tr},_addCellsToRowUsingRecord:function($row){let record=$row.data("record");for(let i=0;i").addClass(this.options.fields[fieldName].listClass).append(this._getDisplayTextForRecordField(record,fieldName))},_addRecordsToTable:function(records){let self=this;$.each(records,function(index,record){self._addRow(self._createRowFromRecord(record))});self._refreshRowStyles()},_addRowToTable:function($tableRow,index,isNewRow,animationsEnabled){let options={index:this._normalizeNumber(index,0,this._$tableRows.length,this._$tableRows.length)};if(isNewRow==true){options.isNewRow=true}if(animationsEnabled==false){options.animationsEnabled=false}this._addRow($tableRow,options)},_addRow:function($row,options){options=$.extend({index:this._$tableRows.length,isNewRow:false,animationsEnabled:true},options);if(this._$tableRows.length<=0){this._removeNoDataRow()}options.index=this._normalizeNumber(options.index,0,this._$tableRows.length,this._$tableRows.length);if(options.index==this._$tableRows.length){this._$tableBody.append($row);this._$tableRows.push($row)}else if(options.index==0){this._$tableBody.prepend($row);this._$tableRows.unshift($row)}else{this._$tableRows[options.index-1].after($row);this._$tableRows.splice(options.index,0,$row)}this._onRowInserted($row,options.isNewRow);if(options.isNewRow){this._refreshRowStyles();if(this.options.animationsEnabled&&options.animationsEnabled){this._showNewRowAnimation($row)}}},_showNewRowAnimation:function($tableRow){let className="jtable-row-created";if(this.options.jqueryuiTheme){className=className+" ui-state-highlight"}$tableRow.addClass(className,"slow","",function(){$tableRow.removeClass(className,5e3)})},_removeRowsFromTable:function($rows,reason){let self=this;if($rows.length<=0){return}$rows.addClass("jtable-row-removed").remove();$rows.each(function(){let index=self._findRowIndex($(this));if(index>=0){self._$tableRows.splice(index,1)}});self._onRowsRemoved($rows,reason);if(self._$tableRows.length==0){self._addNoDataRow()}self._refreshRowStyles()},_findRowIndex:function($row){return this._findIndexInArray($row,this._$tableRows,function($row1,$row2){return $row1.data("record")==$row2.data("record")})},_removeAllRows:function(reason){if(this._$tableRows.length<=0){return}let $rows=this._$tableBody.find("tr.jtable-data-row");this._$tableBody.empty();this._$tableRows=[];this._onRowsRemoved($rows,reason);this._addNoDataRow()},_addNoDataRow:function(){if(this._$tableBody.find(">tr.jtable-no-data-row").length>0){return}let $tr=$("").addClass("jtable-no-data-row").appendTo(this._$tableBody);let totalColumnCount=this._$table.find("thead th").length;$("").attr("colspan",totalColumnCount).html(this.options.messages.noDataAvailable).appendTo($tr)},_removeNoDataRow:function(){this._$tableBody.find(".jtable-no-data-row").remove()},_refreshRowStyles:function(){for(let i=0;i").addClass("jtable-toolbar").appendTo(this._$titleDiv);for(let i=0;i").addClass("jtable-toolbar-item").appendTo(this._$toolbarDiv);this._jqueryuiThemeAddClass($toolBarItem,"ui-widget ui-state-default ui-corner-all","ui-state-hover");if(item.cssClass){$toolBarItem.addClass(item.cssClass)}if(item.tooltip){$toolBarItem.attr("title",item.tooltip)}if(item.icon){let $icon=$('').appendTo($toolBarItem);if(item.icon===true){}else if($.type(item.icon==="string")){$icon.css("background",'url("'+item.icon+'")')}}if(item.text){$('').html(item.text).addClass("jtable-toolbar-item-text").appendTo($toolBarItem)}if(item.click){$toolBarItem.on("click",function(e){e.preventDefault();e.stopPropagation();item.click()})}let hoverAnimationDuration=undefined;let hoverAnimationEasing=undefined;if(this.options.toolbar.hoverAnimation){hoverAnimationDuration=this.options.toolbar.hoverAnimationDuration;hoverAnimationEasing=this.options.toolbar.hoverAnimationEasing}$toolBarItem.hover(function(){$toolBarItem.addClass("jtable-toolbar-item-hover",hoverAnimationDuration,hoverAnimationEasing)},function(){$toolBarItem.removeClass("jtable-toolbar-item-hover",hoverAnimationDuration,hoverAnimationEasing)});return $toolBarItem},_showError:function(message){this._$errorDialog.find(".jtable-error-message").html(message);this._$errorDialog[0].showModal()},_setBusyTimer:null,_showBusy:function(message,delay){let self=this;let makeVisible=function(){self._$busyDialog.find(".jtable-busy-message").html(message);self._$busyDialog[0].showModal()};if(delay){if(self._setBusyTimer){return}self._setBusyTimer=setTimeout(makeVisible,delay)}else{makeVisible()}},_hideBusy:function(){clearTimeout(this._setBusyTimer);this._setBusyTimer=null;this._$busyDialog[0].close()},_isBusy:function(){return this._$busyDialog.is(":visible")},_jqueryuiThemeAddClass:function($elm,className,hoverClassName){if(!this.options.jqueryuiTheme){return}$elm.addClass(className);if(hoverClassName){$elm.hover(function(){$elm.addClass(hoverClassName)},function(){$elm.removeClass(hoverClassName)})}},_performAjaxCall:function(url,postData,async,success,error){this._ajax({url:url,data:postData,async:async,success:success,error:error})},_unAuthorizedRequestHandler:function(){if(this.options.unAuthorizedRequestRedirectUrl){location.href=this.options.unAuthorizedRequestRedirectUrl}else{location.reload(true)}},_ajax:function(options){let self=this;let opts={statusCode:{401:function(){self._unAuthorizedRequestHandler()}}};opts=$.extend(opts,this.options.ajaxSettings,options);opts.success=function(data){if(data&&data.UnAuthorizedRequest==true){self._unAuthorizedRequestHandler()}if(options.success){options.success(data)}};opts.error=function(jqXHR,textStatus,errorThrown){if(unloadingPage){jqXHR.abort();return}if(options.error){options.error(arguments)}};opts.complete=function(){if(options.complete){options.complete()}};$.ajax(opts)},_getKeyValueOfRecord:function(record){return record[this._keyField]},_setCookie:function(key,value){key=this._cookieKeyPrefix+key;let expireDate=new Date;expireDate.setDate(expireDate.getDate()+30);$.cookie(key,value,{expires:expireDate})},_getCookie:function(key){key=this._cookieKeyPrefix+key;return $.cookie(key)},_removeCookie:function(key){key=this._cookieKeyPrefix+key;$.removeCookie(key,{path:"/"});return null},_generateCookieKeyPrefix:function(){let simpleHash=function(value){let hash=0;if(value.length==0){return hash}for(let i=0;imax){return max}return number},_formatString:function(){if(arguments.length==0){return null}let str=arguments[0];for(let i=1;i").addClass("jtable-input-label").html(this.options.fields[fieldName].inputTitle||this.options.fields[fieldName].title)},_createInputForRecordField:function(funcParams){let fieldName=funcParams.fieldName,value=funcParams.value,record=funcParams.record,formType=funcParams.formType,form=funcParams.form;let field=this.options.fields[fieldName];if(value==undefined||value==null){value=field.defaultValue}if(field.input){let $input=$(field.input({value:value,record:record,formType:formType,form:form}));if(!$input.attr("id")){$input.attr("id","Edit-"+fieldName)}return $("
    ").addClass("jtable-input jtable-custom-input").append($input)}if(field.type=="date"){return this._createDateInputForField(field,fieldName,value)}else if(field.type=="textarea"){return this._createTextAreaForField(field,fieldName,value)}else if(field.type=="checkbox"){return this._createCheckboxForField(field,fieldName,value)}else if(field.options){if(field.type=="radiobutton"){return this._createRadioButtonListForField(field,fieldName,value,record,formType)}else{return this._createDropDownListForField(field,fieldName,value,record,formType,form)}}else{return this._createInputForField(field,fieldName,value)}},_createInputForHidden:function(fieldName,value){if(value==undefined){value=""}return $('').val(value)},_createDateInputForField:function(field,fieldName,value){let $input="";if(typeof $.fn.datepicker=="function"){let displayFormat=field.displayFormat||this.options.defaultDateFormat;$input=$('');$input.datepicker({dateFormat:displayFormat})}else{$input=$('')}if(value!=undefined){$input.val(value)}return $("
    ").addClass("jtable-input jtable-date-input").append($input)},_createTextAreaForField:function(field,fieldName,value){let $textArea=$('');if(value!=undefined){$textArea.val(value)}return $("
    ").addClass("jtable-input jtable-textarea-input").append($textArea)},_createInputForField:function(field,fieldName,value){let $input=$('');if(value!=undefined){$input.val(value)}return $("
    ").addClass("jtable-input jtable-"+field.inputClass+"-input").append($input)},_createCheckboxForField:function(field,fieldName,value){let self=this;if(value==undefined){value=self._getCheckBoxPropertiesForFieldByState(fieldName,false).Value}let $containerDiv=$("
    ").addClass("jtable-input jtable-checkbox-input");let $checkBox=$('').appendTo($containerDiv);if(value!=undefined){$checkBox.val(value)}let $textSpan=$(""+(field.formText||self._getCheckBoxTextForFieldByValue(fieldName,value))+"").appendTo($containerDiv);if(self._getIsCheckBoxSelectedForFieldByValue(fieldName,value)){$checkBox.attr("checked","checked")}let refreshCheckBoxValueAndText=function(){let checkboxProps=self._getCheckBoxPropertiesForFieldByState(fieldName,$checkBox.is(":checked"));$checkBox.attr("value",checkboxProps.Value);$textSpan.html(field.formText||checkboxProps.DisplayText)};$checkBox.on("click",function(){refreshCheckBoxValueAndText()});if(field.setOnTextClick!=false){$textSpan.addClass("jtable-option-text-clickable").on("click",function(){if($checkBox.is(":checked")){$checkBox.attr("checked",false)}else{$checkBox.attr("checked",true)}refreshCheckBoxValueAndText()})}return $containerDiv},_createDropDownListForField:function(field,fieldName,value,record,source,form){let $containerDiv=$("
    ").addClass("jtable-input jtable-dropdown-input");let $select=$('').appendTo($containerDiv);let options=this._getOptionsForField(fieldName,{record:record,source:source,form:form,dependedValues:this._createDependedValuesUsingForm(form,field.dependsOn)});this._fillDropDownListWithOptions($select,options,value);return $containerDiv},_fillDropDownListWithOptions:function($select,options,value){$select.empty();for(let i=0;i"+options[i].DisplayText+"").val(options[i].Value).appendTo($select)}},_createDependedValuesUsingForm:function($form,dependsOn){if(!dependsOn){return{}}let dependedValues={};for(let i=0;i").addClass("jtable-input jtable-radiobuttonlist-input");let options=this._getOptionsForField(fieldName,{record:record,source:source});$.each(options,function(i,option){let $radioButtonDiv=$('
    ').addClass("jtable-radio-input").appendTo($containerDiv);let $radioButton=$('").val(option.Value).appendTo($radioButtonDiv);let $textSpan=$("").html(option.DisplayText).appendTo($radioButtonDiv);if(field.setOnTextClick!=false){$textSpan.addClass("jtable-option-text-clickable").on("click",function(){if(!$radioButton.is(":checked")){$radioButton.attr("checked",true)}})}});return $containerDiv},_getCheckBoxTextForFieldByValue:function(fieldName,value){return this.options.fields[fieldName].values[value]},_getIsCheckBoxSelectedForFieldByValue:function(fieldName,value){return this._createCheckBoxStateArrayForFieldWithCaching(fieldName)[1].Value.toString()==value.toString()},_getCheckBoxPropertiesForFieldByState:function(fieldName,checked){return this._createCheckBoxStateArrayForFieldWithCaching(fieldName)[checked?1:0]},_createCheckBoxStateArrayForFieldWithCaching:function(fieldName){let cacheKey="checkbox_"+fieldName;if(!this._cache[cacheKey]){this._cache[cacheKey]=this._createCheckBoxStateArrayForField(fieldName)}return this._cache[cacheKey]},_createCheckBoxStateArrayForField:function(fieldName){let stateArray=[];let currentIndex=0;$.each(this.options.fields[fieldName].values,function(propName,propValue){if(currentIndex++<2){stateArray.push({Value:propName,DisplayText:propValue})}});return stateArray},_makeCascadeDropDowns:function($form,record,source){let self=this;$form.find("select").each(function(){let $thisDropdown=$(this);let fieldName=$thisDropdown.attr("name");if(!fieldName){return}let field=self.options.fields[fieldName];if(!field.dependsOn){return}$.each(field.dependsOn,function(index,dependsOnField){let $dependsOnDropdown=$form.find("select[name="+dependsOnField+"]");$dependsOnDropdown.change(function(){let funcParams={record:record,source:source,form:$form,dependedValues:{}};funcParams.dependedValues=self._createDependedValuesUsingForm($form,field.dependsOn);let options=self._getOptionsForField(fieldName,funcParams);self._fillDropDownListWithOptions($thisDropdown,options,undefined);$thisDropdown.change()})})})},_updateRecordValuesFromForm:function(record,$form){for(let i=0;i").addClass("jtable-modal-dialog").appendTo(self._$mainContainer);self._$addRecordDialog.on("close",function(){let $addRecordForm=self._$addRecordDialog.find("form").first();self._$mainContainer.trigger("formClosed",{form:$addRecordForm,formType:"create"});$addRecordForm.remove()});$('

    ').css({padding:"0px"}).text(self.options.messages.addNewRecord).appendTo(self._$addRecordDialog);const $cancelButton=$(' ').attr("id","AddRecordDialogCancelButton").html(""+self.options.messages.cancel+"").on("click",function(){self._closeCreateForm()});let $saveButton=$('').attr("id","AddRecordDialogSaveButton").html(""+self.options.messages.save+"").on("click",function(){self._onSaveClickedOnCreateForm();self._closeCreateForm()});self._$addRecordDialog.append($cancelButton,$saveButton);if(self.options.addRecordButton){self.options.addRecordButton.on("click",function(e){e.preventDefault();self._showAddRecordForm()})}else{self._addToolBarItem({icon:true,cssClass:"jtable-toolbar-item-add-record",text:self.options.messages.addNewRecord,click:function(){self._showAddRecordForm()}})}},_onSaveClickedOnCreateForm:function(){let self=this;let $saveButton=self._$addRecordDialog.find("#AddRecordDialogSaveButton");let $addRecordForm=self._$addRecordDialog.find("form");if(self._$mainContainer.trigger("formSubmitting",{form:$addRecordForm,formType:"create"})!=false){self._setEnabledOfDialogButton($saveButton,false,self.options.messages.saving);self._saveAddRecordForm($addRecordForm,$saveButton)}},_closeCreateForm:function(){this._$addRecordDialog[0].close()},showCreateForm:function(){this._showAddRecordForm()},addRecord:function(options){let self=this;options=$.extend({clientOnly:false,animationsEnabled:self.options.animationsEnabled,success:function(){},error:function(){}},options);if(!options.record){self._logWarn("options parameter in addRecord method must contain a record property.");return}if(options.clientOnly){self._addRow(self._createRowFromRecord(options.record),{isNewRow:true,animationsEnabled:options.animationsEnabled});options.success();return}let completeAddRecord=function(data){if(data.Result!="OK"){self._showError(data.Message);options.error(data);return}if(!data.Record){self._logError("Server must return the created Record object.");options.error(data);return}self._onRecordAdded(data);self._addRow(self._createRowFromRecord(data.Record),{isNewRow:true,animationsEnabled:options.animationsEnabled});options.success(data)};if(!options.url&&$.isFunction(self.options.actions.createAction)){let funcResult=self.options.actions.createAction($.param(options.record));if(self._isDeferredObject(funcResult)){funcResult.done(function(data){completeAddRecord(data)}).fail(function(){self._showError(self.options.messages.serverCommunicationError);options.error()})}else{completeAddRecord(funcResult)}}else{self._submitFormUsingAjax(options.url||self.options.actions.createAction,$.param(options.record),function(data){completeAddRecord(data)},function(){self._showError(self.options.messages.serverCommunicationError);options.error()})}},_showAddRecordForm:function(){let self=this;let $addRecordForm=$('
    ');for(let i=0;i").addClass("jtable-input-field-container").appendTo($addRecordForm);$fieldContainer.append(self._createInputLabelForRecordField(fieldName));$fieldContainer.append(self._createInputForRecordField({fieldName:fieldName,formType:"create",form:$addRecordForm}))}self._makeCascadeDropDowns($addRecordForm,undefined,"create");$addRecordForm.submit(function(){self._onSaveClickedOnCreateForm();return false});self._$addRecordDialog.find("form:first").remove();let $saveButton=self._$editRecordDialog.find("#EditDialogSaveButton");self._setEnabledOfDialogButton($saveButton,true,self.options.messages.save);self._$addRecordDialog.find("#addRecordDialogTitle:first").after($addRecordForm);self._$addRecordDialog[0].showModal();self._$mainContainer.trigger("formCreated",{form:$addRecordForm,formType:"create"})},_saveAddRecordForm:function($addRecordForm,$saveButton){let self=this;let completeAddRecord=function(data){if(data.Result!="OK"){self._showError(data.Message);return}if(!data.Record){self._logError("Server must return the created Record object.");return}self._onRecordAdded(data);self._addRow(self._createRowFromRecord(data.Record),{isNewRow:true});self._closeCreateForm()};if($.isFunction(self.options.actions.createAction)){let funcResult=self.options.actions.createAction($addRecordForm.serialize());if(self._isDeferredObject(funcResult)){funcResult.done(function(data){completeAddRecord(data)}).fail(function(){self._showError(self.options.messages.serverCommunicationError)})}else{completeAddRecord(funcResult)}}else{self._submitFormUsingAjax(self.options.actions.createAction,$addRecordForm.serialize(),function(data){completeAddRecord(data)},function(){self._showError(self.options.messages.serverCommunicationError)})}},_onRecordAdded:function(data){this._$mainContainer.trigger("recordAdded",{record:data.Record,serverResponse:data})}})})(jQuery);(function($){let base={_create:jTable.prototype._create,_addColumnsToHeaderRow:jTable.prototype._addColumnsToHeaderRow,_addCellsToRowUsingRecord:jTable.prototype._addCellsToRowUsingRecord};$.extend(true,jTable.prototype,{options:{recordUpdated:function(event,data){},rowUpdated:function(event,data){},messages:{editRecord:"Edit Record"}},_$editRecordDialog:null,_$editingRow:null,_create:function(){base._create.apply(this,arguments);if(!this.options.actions.updateAction){return}this._createEditDialog()},_createEditDialog:function(){let self=this;self._$editRecordDialog=$("").addClass("jtable-modal-dialog").appendTo(self._$mainContainer);self._$editRecordDialog.on("close",function(){let $editForm=self._$editRecordDialog.find("form:first");self._$mainContainer.trigger("formClosed",{form:$editForm,formType:"edit",row:self._$editingRow});$editForm.remove()});$('

    ').css({padding:"0px"}).text(self.options.messages.editRecord).appendTo(self._$editRecordDialog);const $cancelButton=$(' ').attr("id","EditRecordDialogCancelButton").html(""+self.options.messages.cancel+"").on("click",function(){self._closeEditForm()});let $saveButton=$('').attr("id","EditDialogSaveButton").html(""+self.options.messages.save+"").on("click",function(){self._onSaveClickedOnEditForm();self._closeEditForm()});self._$editRecordDialog.append($cancelButton,$saveButton)},_onSaveClickedOnEditForm:function(){let self=this;if(self._$editingRow.hasClass("jtable-row-removed")){self._closeEditForm();return}let $saveButton=self._$editRecordDialog.find("#EditDialogSaveButton");let $editForm=self._$editRecordDialog.find("form");if(self._$mainContainer.trigger("formSubmitting",{form:$editForm,formType:"edit",row:self._$editingRow})!=false){self._setEnabledOfDialogButton($saveButton,false,self.options.messages.saving);self._saveEditForm($editForm,$saveButton)}},_closeEditForm:function(){this._$editRecordDialog[0].close()},updateRecord:function(options){let self=this;options=$.extend({clientOnly:false,animationsEnabled:self.options.animationsEnabled,success:function(){},error:function(){}},options);if(!options.record){self._logWarn("options parameter in updateRecord method must contain a record property.");return}let key=self._getKeyValueOfRecord(options.record);if(key==undefined||key==null){self._logWarn("options parameter in updateRecord method must contain a record that contains the key field property.");return}let $updatingRow=self.getRowByKey(key);if($updatingRow==null){self._logWarn('Can not found any row by key "'+key+'" on the table. Updating row must be visible on the table.');return}if(options.clientOnly){$.extend($updatingRow.data("record"),options.record);self._updateRowTexts($updatingRow);self._onRecordUpdated($updatingRow,null);if(options.animationsEnabled){self._showUpdateAnimationForRow($updatingRow)}options.success();return}let completeEdit=function(data){if(data.Result!="OK"){self._showError(data.Message);options.error(data);return}$.extend($updatingRow.data("record"),options.record);self._updateRecordValuesFromServerResponse($updatingRow.data("record"),data);self._updateRowTexts($updatingRow);self._onRecordUpdated($updatingRow,data);if(options.animationsEnabled){self._showUpdateAnimationForRow($updatingRow)}options.success(data)};if(!options.url&&$.isFunction(self.options.actions.updateAction)){let funcResult=self.options.actions.updateAction($.param(options.record));if(self._isDeferredObject(funcResult)){funcResult.done(function(data){completeEdit(data)}).fail(function(){self._showError(self.options.messages.serverCommunicationError);options.error()})}else{completeEdit(funcResult)}}else{self._submitFormUsingAjax(options.url||self.options.actions.updateAction,$.param(options.record),function(data){completeEdit(data)},function(){self._showError(self.options.messages.serverCommunicationError);options.error()})}},_addColumnsToHeaderRow:function($tr){base._addColumnsToHeaderRow.apply(this,arguments);if(this.options.actions.updateAction!=undefined){$tr.append(this._createEmptyCommandHeader("jtable-column-header-edit"))}},_addCellsToRowUsingRecord:function($row){let self=this;base._addCellsToRowUsingRecord.apply(this,arguments);if(self.options.actions.updateAction!=undefined){let $span=$("").html(self.options.messages.editRecord);let $button=$('').addClass("jtable-command-button jtable-edit-command-button").append($span).on("click",function(e){e.preventDefault();e.stopPropagation();self._showEditForm($row)});$("").addClass("jtable-command-column").append($button).appendTo($row)}},_showEditForm:function($tableRow){let self=this;let record=$tableRow.data("record");let $editForm=$('
    ');for(let i=0;i
    ').appendTo($editForm);$fieldContainer.append(self._createInputLabelForRecordField(fieldName));let currentValue=self._getValueForRecordField(record,fieldName);$fieldContainer.append(self._createInputForRecordField({fieldName:fieldName,value:currentValue,record:record,formType:"edit",form:$editForm}))}self._makeCascadeDropDowns($editForm,record,"edit");$editForm.submit(function(){self._onSaveClickedOnEditForm();return false});self._$editingRow=$tableRow;self._$editRecordDialog.find("form:first").remove();let $saveButton=self._$editRecordDialog.find("#EditDialogSaveButton");self._setEnabledOfDialogButton($saveButton,true,self.options.messages.save);self._$editRecordDialog.find("#editDialogTitle:first").after($editForm);self._$editRecordDialog[0].showModal();self._$mainContainer.trigger("formCreated",{form:$editForm,formType:"edit",record:record,row:$tableRow})},_saveEditForm:function($editForm,$saveButton){let self=this;let completeEdit=function(data){if(data.Result!="OK"){self._showError(data.Message);return}let record=self._$editingRow.data("record");self._updateRecordValuesFromForm(record,$editForm);self._updateRecordValuesFromServerResponse(record,data);self._updateRowTexts(self._$editingRow);self._$editingRow.attr("data-record-key",self._getKeyValueOfRecord(record));self._onRecordUpdated(self._$editingRow,data);if(self.options.animationsEnabled){self._showUpdateAnimationForRow(self._$editingRow)}self._closeEditForm()};if($.isFunction(self.options.actions.updateAction)){let funcResult=self.options.actions.updateAction($editForm.serialize());if(self._isDeferredObject(funcResult)){funcResult.done(function(data){completeEdit(data)}).fail(function(){self._showError(self.options.messages.serverCommunicationError)})}else{completeEdit(funcResult)}}else{self._submitFormUsingAjax(self.options.actions.updateAction,$editForm.serialize(),function(data){completeEdit(data)},function(){self._showError(self.options.messages.serverCommunicationError)})}},_updateRecordValuesFromServerResponse:function(record,serverResponse){if(!serverResponse||!serverResponse.Record){return}$.extend(true,record,serverResponse.Record)},_getValueForRecordField:function(record,fieldName){let field=this.options.fields[fieldName];let fieldValue=record[fieldName];if(field.type=="date"){return this._getDisplayTextForDateRecordField(field,fieldValue)}else{return fieldValue}},_updateRowTexts:function($tableRow){let record=$tableRow.data("record");let $columns=$tableRow.find("td");for(let i=0;i").addClass("jtable-modal-dialog").appendTo(self._$mainContainer);$('

    ').css({padding:"0px"}).text(self.options.messages.areYouSure).appendTo(self._$deleteDialog);$('

    ').appendTo(self._$deleteDialog);const $cancelButton=$(' ').attr("id","DeleteDialogCancelButton").html(""+self.options.messages.cancel+"").on("click",function(){self._closeDeleteDialog()});let $deleteButton=$('').attr("id","DeleteDialogDeleteButton").html(""+self.options.messages.deleteText+"").on("click",function(){if(self._$deletingRow.hasClass("jtable-row-removed")){self._closeDeleteDialog();return}self._setEnabledOfDialogButton($deleteButton,false,self.options.messages.deleting);self._deleteRecordFromServer(self._$deletingRow,function(){self._removeRowsFromTableWithAnimation(self._$deletingRow);self._closeDeleteDialog()},function(message){self._showError(message)})});self._$deleteDialog.append($cancelButton,$deleteButton)},_closeDeleteDialog:function(){this._$deleteDialog[0].close()},deleteRows:function($rows){let self=this;if($rows.length<=0){self._logWarn("No rows specified to jTable deleteRows method.");return}if(self._isBusy()){self._logWarn("Can not delete rows since jTable is busy!");return}if($rows.length==1){self._deleteRecordFromServer($rows,function(){self._removeRowsFromTableWithAnimation($rows)},function(message){self._showError(message)});return}self._showBusy(self._formatString(self.options.messages.deleteProggress,0,$rows.length));let completedCount=0;let isCompleted=function(){return completedCount>=$rows.length};let completed=function(){let $deletedRows=$rows.filter(".jtable-row-ready-to-remove");if($deletedRows.length<$rows.length){self._showError(self._formatString(self.options.messages.canNotDeletedRecords,$rows.length-$deletedRows.length,$rows.length))}if($deletedRows.length>0){self._removeRowsFromTableWithAnimation($deletedRows)}self._hideBusy()};let deletedCount=0;$rows.each(function(){let $row=$(this);self._deleteRecordFromServer($row,function(){++deletedCount;++completedCount;$row.addClass("jtable-row-ready-to-remove");self._showBusy(self._formatString(self.options.messages.deleteProggress,deletedCount,$rows.length));if(isCompleted()){completed()}},function(){++completedCount;if(isCompleted()){completed()}})})},deleteRecord:function(options){let self=this;options=$.extend({clientOnly:false,animationsEnabled:self.options.animationsEnabled,url:self.options.actions.deleteAction,success:function(){},error:function(){}},options);if(options.key==undefined){self._logWarn("options parameter in deleteRecord method must contain a key property.");return}let $deletingRow=self.getRowByKey(options.key);if($deletingRow==null){self._logWarn("Can not found any row by key: "+options.key);return}if(options.clientOnly){self._removeRowsFromTableWithAnimation($deletingRow,options.animationsEnabled);options.success();return}self._deleteRecordFromServer($deletingRow,function(data){self._removeRowsFromTableWithAnimation($deletingRow,options.animationsEnabled);options.success(data)},function(message){self._showError(message);options.error(message)},options.url)},_addColumnsToHeaderRow:function($tr){base._addColumnsToHeaderRow.apply(this,arguments);if(this.options.actions.deleteAction!=undefined){$tr.append(this._createEmptyCommandHeader("jtable-column-header-delete"))}},_addCellsToRowUsingRecord:function($row){base._addCellsToRowUsingRecord.apply(this,arguments);let self=this;if(self.options.actions.deleteAction!=undefined){let $span=$("").html(self.options.messages.deleteText);let $button=$('').addClass("jtable-command-button jtable-delete-command-button").append($span).on("click",function(e){e.preventDefault();e.stopPropagation();self._deleteButtonClickedForRow($row)});$("").addClass("jtable-command-column").append($button).appendTo($row)}},_deleteButtonClickedForRow:function($row){let self=this;let deleteConfirm;let deleteConfirmMessage=self.options.messages.deleteConfirmation;if($.isFunction(self.options.deleteConfirmation)){let data={row:$row,record:$row.data("record"),deleteConfirm:true,deleteConfirmMessage:deleteConfirmMessage,cancel:false,cancelMessage:null};self.options.deleteConfirmation(data);if(data.cancel){if(data.cancelMessage){self._showError(data.cancelMessage)}return}deleteConfirmMessage=data.deleteConfirmMessage;deleteConfirm=data.deleteConfirm}else{deleteConfirm=self.options.deleteConfirmation}if(deleteConfirm!=false){self._showDeleteDialog($row,deleteConfirmMessage)}else{self._deleteRecordFromServer($row,function(){self._removeRowsFromTableWithAnimation($row)},function(message){self._showError(message)})}},_showDeleteDialog:function($row,deleteConfirmMessage){this._$deletingRow=$row;this._$deleteDialog.find(".jtable-delete-confirm-message").html(deleteConfirmMessage);let $deleteButton=this._$deleteDialog.find("#DeleteDialogDeleteButton");this._setEnabledOfDialogButton($deleteButton,true,this.options.messages.deleteText);this._$deleteDialog[0].showModal()},_deleteRecordFromServer:function($row,success,error,url){let self=this;let completeDelete=function(data){if(data.Result!="OK"){$row.data("deleting",false);if(error){error(data.Message)}return}self._$mainContainer.trigger("recordDeleted",{record:$row.data("record"),row:$row,serverResponse:data});if(success){success(data)}};if($row.data("deleting")==true){return}$row.data("deleting",true);let postData={};postData[self._keyField]=self._getKeyValueOfRecord($row.data("record"));if(!url&&$.isFunction(self.options.actions.deleteAction)){let funcResult=self.options.actions.deleteAction(postData);if(self._isDeferredObject(funcResult)){funcResult.done(function(data){completeDelete(data)}).fail(function(){$row.data("deleting",false);if(error){error(self.options.messages.serverCommunicationError)}})}else{completeDelete(funcResult)}}else{this._ajax({url:url||self.options.actions.deleteAction,data:postData,success:function(data){completeDelete(data)},error:function(){$row.data("deleting",false);if(error){error(self.options.messages.serverCommunicationError)}}})}},_removeRowsFromTableWithAnimation:function($rows,animationsEnabled){let self=this;if(animationsEnabled==undefined){animationsEnabled=self.options.animationsEnabled}if(animationsEnabled){let className="jtable-row-deleting";if(this.options.jqueryuiTheme){className=className+" ui-state-disabled"}$rows.stop(true,true).addClass(className,"slow","").promise().done(function(){self._removeRowsFromTable($rows,"deleted")})}else{self._removeRowsFromTable($rows,"deleted")}}})})(jQuery);(function($){let base={_create:jTable.prototype._create,_loadExtraSettings:jTable.prototype._loadExtraSettings,_addColumnsToHeaderRow:jTable.prototype._addColumnsToHeaderRow,_addCellsToRowUsingRecord:jTable.prototype._addCellsToRowUsingRecord,_onLoadingRecords:jTable.prototype._onLoadingRecords,_onRecordsLoaded:jTable.prototype._onRecordsLoaded,_onRowsRemoved:jTable.prototype._onRowsRemoved};$.extend(true,jTable.prototype,{options:{selecting:false,multiselect:false,selectingCheckboxes:false,selectOnRowClick:true,selectionChanged:function(event,data){}},_selectedRecordIdsBeforeLoad:null,_$selectAllCheckbox:null,_shiftKeyDown:false,_create:function(){if(this.options.selecting&&this.options.selectingCheckboxes){++this._firstDataColumnOffset;this._bindKeyboardEvents()}base._create.apply(this,arguments)},_loadExtraSettings:function(){base._loadExtraSettings.apply(this,arguments);if(!this._keyField){this.options.selecting=false;this._logWarn("No key field defined, selecting is not possible.")}},_bindKeyboardEvents:function(){let self=this;$(document).on("keydown",function(event){switch(event.which){case 16:self._shiftKeyDown=true;break}}).on("keyup",function(event){switch(event.which){case 16:self._shiftKeyDown=false;break}})},selectedRows:function(){return this._getSelectedRows()},selectRows:function($rows){this._selectRows($rows);this._onSelectionChanged()},_addColumnsToHeaderRow:function($tr){if(this.options.selecting&&this.options.selectingCheckboxes){if(this.options.multiselect){$tr.append(this._createSelectAllHeader())}else{$tr.append(this._createEmptyCommandHeader())}}base._addColumnsToHeaderRow.apply(this,arguments)},_addCellsToRowUsingRecord:function($row){if(this.options.selecting){this._makeRowSelectable($row)}base._addCellsToRowUsingRecord.apply(this,arguments)},_onLoadingRecords:function(){if(this.options.selecting){this._storeSelectionList()}base._onLoadingRecords.apply(this,arguments)},_onRecordsLoaded:function(){if(this.options.selecting){this._restoreSelectionList()}base._onRecordsLoaded.apply(this,arguments)},_onRowsRemoved:function($rows,reason){if(this.options.selecting&&reason!="reloading"&&$rows.filter(".jtable-row-selected").length>0){this._onSelectionChanged()}base._onRowsRemoved.apply(this,arguments)},_createSelectAllHeader:function(){let self=this;let $columnHeader=$('').addClass("jtable-command-column jtable-command-column-header jtable-column-header-select");this._jqueryuiThemeAddClass($columnHeader,"ui-state-default");let $headerContainer=$("
    ").addClass("jtable-column-header-container").appendTo($columnHeader);self._$selectAllCheckbox=$('').appendTo($headerContainer).on("click",function(){if(self._$tableRows.length<=0){self._$selectAllCheckbox.attr("checked",false);return}let allRows=self._$tableBody.find(">tr.jtable-data-row");if(self._$selectAllCheckbox.is(":checked")){self._selectRows(allRows)}else{self._deselectRows(allRows)}self._onSelectionChanged()});return $columnHeader},_storeSelectionList:function(){let self=this;if(!self.options.selecting){return}self._selectedRecordIdsBeforeLoad=[];self._getSelectedRows().each(function(){self._selectedRecordIdsBeforeLoad.push(self._getKeyValueOfRecord($(this).data("record")))})},_restoreSelectionList:function(){let self=this;if(!self.options.selecting){return}let selectedRowCount=0;for(let i=0;i-1){self._selectRows(self._$tableRows[i]);++selectedRowCount}}if(self._selectedRecordIdsBeforeLoad.length>0&&self._selectedRecordIdsBeforeLoad.length!=selectedRowCount){self._onSelectionChanged()}self._selectedRecordIdsBeforeLoad=[];self._refreshSelectAllCheckboxState()},_getSelectedRows:function(){return this._$tableBody.find(">tr.jtable-row-selected")},_makeRowSelectable:function($row){let self=this;if(self.options.selectOnRowClick){$row.on("click",function(){self._invertRowSelection($row)})}if(self.options.selectingCheckboxes){let $cell=$("").addClass("jtable-command-column jtable-selecting-column");let $selectCheckbox=$('').appendTo($cell);if(typeof $row.data("recordKey")!=="undefined"){$selectCheckbox.attr("id","jtable-column-checkbox-"+$row.data("recordKey"))}if(!self.options.selectOnRowClick){$selectCheckbox.on("click",function(){self._invertRowSelection($row)})}$row.append($cell)}},_invertRowSelection:function($row){if($row.hasClass("jtable-row-selected")){this._deselectRows($row)}else{if(this._shiftKeyDown){let rowIndex=this._findRowIndex($row);let beforeIndex=this._findFirstSelectedRowIndexBeforeIndex(rowIndex)+1;if(beforeIndex>0&&beforeIndexrowIndex){this._selectRows(this._$tableBody.find("tr").slice(rowIndex,afterIndex+1))}else{this._selectRows($row)}}}else{this._selectRows($row)}}this._onSelectionChanged()},_findFirstSelectedRowIndexBeforeIndex:function(rowIndex){for(let i=rowIndex-1;i>=0;--i){if(this._$tableRows[i].hasClass("jtable-row-selected")){return i}}return-1},_findFirstSelectedRowIndexAfterIndex:function(rowIndex){for(let i=rowIndex+1;itd.jtable-selecting-column >input").prop("checked",true)}this._refreshSelectAllCheckboxState()},_deselectRows:function($rows){$rows.removeClass("jtable-row-selected ui-state-highlight");if(this.options.selectingCheckboxes){$rows.find(">td.jtable-selecting-column >input").prop("checked",false)}this._refreshSelectAllCheckboxState()},_refreshSelectAllCheckboxState:function(){if(!this.options.selectingCheckboxes||!this.options.multiselect){return}let totalRowCount=this._$tableRows.length;let selectedRowCount=this._getSelectedRows().length;if(selectedRowCount==0){this._$selectAllCheckbox.prop("indeterminate",false);this._$selectAllCheckbox.attr("checked",false)}else if(selectedRowCount==totalRowCount){this._$selectAllCheckbox.prop("indeterminate",false);this._$selectAllCheckbox.attr("checked",true)}else{this._$selectAllCheckbox.attr("checked",false);this._$selectAllCheckbox.prop("indeterminate",true)}},_onSelectionChanged:function(){this._$mainContainer.trigger("selectionChanged",{})}})})(jQuery);(function($){let base={load:jTable.prototype.load,_create:jTable.prototype._create,_setOption:jTable.prototype._setOption,_createJtParamsForLoading:jTable.prototype._createJtParamsForLoading,_addRowToTable:jTable.prototype._addRowToTable,_addRow:jTable.prototype._addRow,_removeRowsFromTable:jTable.prototype._removeRowsFromTable,_onRecordsLoaded:jTable.prototype._onRecordsLoaded};$.extend(true,jTable.prototype,{options:{paging:false,pageList:"normal",pageSize:10,pageSizes:[10,25,50,100,250,500],pageSizeChangeArea:true,gotoPageArea:"combobox",messages:{pagingInfo:"Showing {0}-{1} of {2}",pageSizeChangeLabel:"Row count",gotoPageLabel:"Go to page"}},_$bottomPanel:null,_$pagingListArea:null,_$pageSizeChangeArea:null,_$pageInfoSpan:null,_$gotoPageArea:null,_$gotoPageInput:null,_totalRecordCount:0,_currentPageNo:1,_create:function(){base._create.apply(this,arguments);if(this.options.paging){this._loadPagingSettings();this._createBottomPanel();this._createPageListArea();this._createGotoPageInput();this._createPageSizeSelection()}},_loadPagingSettings:function(){if(!this.options.saveUserPreferences){return}let pageSize=this._getCookie("page-size");if(pageSize==null){return}if(!pageSize){self._removeCookie("page-size");return}if(pageSize){this.options.pageSize=this._normalizeNumber(pageSize,1,1e6,this.options.pageSize)}},_createBottomPanel:function(){this._$bottomPanel=$("
    ").addClass("jtable-bottom-panel").insertAfter(this._$tableDiv);this._jqueryuiThemeAddClass(this._$bottomPanel,"ui-state-default");$("
    ").addClass("jtable-left-area").appendTo(this._$bottomPanel);$("
    ").addClass("jtable-right-area").appendTo(this._$bottomPanel)},_createPageListArea:function(){this._$pagingListArea=$("").addClass("jtable-page-list").appendTo(this._$bottomPanel.find(".jtable-left-area"));this._$pageInfoSpan=$("").addClass("jtable-page-info").appendTo(this._$bottomPanel.find(".jtable-right-area"))},_createPageSizeSelection:function(){let self=this;if(!self.options.pageSizeChangeArea){return}if(self._findIndexInArray(self.options.pageSize,self.options.pageSizes)<0){self.options.pageSizes.push(parseInt(self.options.pageSize));self.options.pageSizes.sort(function(a,b){return a-b})}self._$pageSizeChangeArea=$("").addClass("jtable-page-size-change").appendTo(self._$bottomPanel.find(".jtable-left-area"));self._$pageSizeChangeArea.append(""+self.options.messages.pageSizeChangeLabel+": ");let $pageSizeChangeCombobox=$('').appendTo(self._$pageSizeChangeArea);for(let i=0;i'+self.options.pageSizes[i]+"")}$pageSizeChangeCombobox.val(self.options.pageSize);$pageSizeChangeCombobox.change(function(){self._changePageSize(parseInt($(this).val()))})},_createGotoPageInput:function(){let self=this;if(!self.options.gotoPageArea||self.options.gotoPageArea=="none"){return}this._$gotoPageArea=$("").addClass("jtable-goto-page").appendTo(self._$bottomPanel.find(".jtable-left-area"));this._$gotoPageArea.append(""+self.options.messages.gotoPageLabel+": ");if(self.options.gotoPageArea=="combobox"){self._$gotoPageInput=$('').appendTo(this._$gotoPageArea).data("pageCount",1).change(function(){self._changePage(parseInt($(this).val()))});self._$gotoPageInput.append('')}else{self._$gotoPageInput=$('').appendTo(this._$gotoPageArea).keypress(function(event){if(event.which==13){event.preventDefault();self._changePage(parseInt(self._$gotoPageInput.val()))}else if(event.which==43){event.preventDefault();self._changePage(parseInt(self._$gotoPageInput.val())+1)}else if(event.which==45){event.preventDefault();self._changePage(parseInt(self._$gotoPageInput.val())-1)}else{let isValid=471e4){pageStep=100}else if(currentPageCount>5e3){pageStep=10}else if(currentPageCount>2e3){pageStep=5}else if(currentPageCount>1e3){pageStep=2}for(let i=pageStep;i<=currentPageCount;i+=pageStep){this._$gotoPageInput.append('")}this._$gotoPageInput.data("pageCount",currentPageCount)}}this._$gotoPageInput.val(this._currentPageNo)},load:function(){this._currentPageNo=1;base.load.apply(this,arguments)},_setOption:function(key,value){base._setOption.apply(this,arguments);if(key=="pageSize"){this._changePageSize(parseInt(value))}},_changePageSize:function(pageSize){if(pageSize==this.options.pageSize){return}this.options.pageSize=pageSize;let pageCount=this._calculatePageCount();if(this._currentPageNo>pageCount){this._currentPageNo=pageCount}if(this._currentPageNo<=0){this._currentPageNo=1}let $pageSizeChangeCombobox=this._$bottomPanel.find(".jtable-page-size-change select");if($pageSizeChangeCombobox.length>0){if(parseInt($pageSizeChangeCombobox.val())!=pageSize){let selectedOption=$pageSizeChangeCombobox.find("option[value="+pageSize+"]");if(selectedOption.length>0){$pageSizeChangeCombobox.val(pageSize)}}}this._savePagingSettings();this._reloadTable()},_savePagingSettings:function(){if(!this.options.saveUserPreferences){return}this._setCookie("page-size",this.options.pageSize)},_createJtParamsForLoading:function(){let jtParams=base._createJtParamsForLoading.apply(this,arguments);if(this.options.paging){jtParams.jtStartIndex=(this._currentPageNo-1)*this.options.pageSize;jtParams.jtPageSize=this.options.pageSize}return jtParams},_addRowToTable:function($tableRow,index,isNewRow){if(isNewRow&&this.options.paging){this._reloadTable();return}base._addRowToTable.apply(this,arguments)},_addRow:function($row,options){if(options&&options.isNewRow&&this.options.paging){this._reloadTable();return}base._addRow.apply(this,arguments)},_removeRowsFromTable:function($rows,reason){base._removeRowsFromTable.apply(this,arguments);if(this.options.paging){if(this._$tableRows.length<=0&&this._currentPageNo>1){--this._currentPageNo}this._reloadTable()}},_onRecordsLoaded:function(data){if(this.options.paging){this._totalRecordCount=data.TotalRecordCount;this._createPagingList();this._createPagingInfo();this._refreshGotoPageInput()}base._onRecordsLoaded.apply(this,arguments)},_addPagingInfoToUrl:function(url,pageNumber){if(!this.options.paging){return url}let jtStartIndex=(pageNumber-1)*this.options.pageSize;let jtPageSize=this.options.pageSize;return url+(url.includes("?")?"?":"&")+"jtStartIndex="+jtStartIndex+"&jtPageSize="+jtPageSize},_createPagingList:function(){if(this.options.pageSize<=0){return}this._$pagingListArea.empty();if(this._totalRecordCount<=0){return}let pageCount=this._calculatePageCount();this._createFirstAndPreviousPageButtons();if(this.options.pageList=="normal"){this._createPageNumberButtons(this._calculatePageNumbers(pageCount))}this._createLastAndNextPageButtons(pageCount);this._bindClickEventsToPageNumberButtons()},_createFirstAndPreviousPageButtons:function(){let $first=$("").addClass("jtable-page-number-first").html("<<").data("pageNumber",1).appendTo(this._$pagingListArea);let $previous=$("").addClass("jtable-page-number-previous").html("<").data("pageNumber",this._currentPageNo-1).appendTo(this._$pagingListArea);this._jqueryuiThemeAddClass($first,"ui-button ui-state-default","ui-state-hover");this._jqueryuiThemeAddClass($previous,"ui-button ui-state-default","ui-state-hover");if(this._currentPageNo<=1){$first.addClass("jtable-page-number-disabled");$previous.addClass("jtable-page-number-disabled");this._jqueryuiThemeAddClass($first,"ui-state-disabled");this._jqueryuiThemeAddClass($previous,"ui-state-disabled")}},_createLastAndNextPageButtons:function(pageCount){let $next=$("").addClass("jtable-page-number-next").html(">").data("pageNumber",this._currentPageNo+1).appendTo(this._$pagingListArea);let $last=$("").addClass("jtable-page-number-last").html(">>").data("pageNumber",pageCount).appendTo(this._$pagingListArea);this._jqueryuiThemeAddClass($next,"ui-button ui-state-default","ui-state-hover");this._jqueryuiThemeAddClass($last,"ui-button ui-state-default","ui-state-hover");if(this._currentPageNo>=pageCount){$next.addClass("jtable-page-number-disabled");$last.addClass("jtable-page-number-disabled");this._jqueryuiThemeAddClass($next,"ui-state-disabled");this._jqueryuiThemeAddClass($last,"ui-state-disabled")}},_createPageNumberButtons:function(pageNumbers){let previousNumber=0;for(let i=0;i1){$("").addClass("jtable-page-number-space").html("...").appendTo(this._$pagingListArea)}this._createPageNumberButton(pageNumbers[i]);previousNumber=pageNumbers[i]}},_createPageNumberButton:function(pageNumber){let $pageNumber=$("").addClass("jtable-page-number").html(pageNumber).data("pageNumber",pageNumber).appendTo(this._$pagingListArea);this._jqueryuiThemeAddClass($pageNumber,"ui-button ui-state-default","ui-state-hover");if(this._currentPageNo==pageNumber){$pageNumber.addClass("jtable-page-number-active jtable-page-number-disabled");this._jqueryuiThemeAddClass($pageNumber,"ui-state-active")}},_calculatePageCount:function(){let pageCount=Math.floor(this._totalRecordCount/this.options.pageSize);if(this._totalRecordCount%this.options.pageSize!=0){++pageCount}return pageCount},_calculatePageNumbers:function(pageCount){if(pageCount<=4){let pageNumbers=[];for(let i=1;i<=pageCount;++i){pageNumbers.push(i)}return pageNumbers}else{let shownPageNumbers=[1,2,pageCount-1,pageCount];let previousPageNo=this._normalizeNumber(this._currentPageNo-1,1,pageCount,1);let nextPageNo=this._normalizeNumber(this._currentPageNo+1,1,pageCount,1);this._insertToArrayIfDoesNotExists(shownPageNumbers,previousPageNo);this._insertToArrayIfDoesNotExists(shownPageNumbers,this._currentPageNo);this._insertToArrayIfDoesNotExists(shownPageNumbers,nextPageNo);shownPageNumbers.sort(function(a,b){return a-b});return shownPageNumbers}},_createPagingInfo:function(){if(this._totalRecordCount<=0){this._$pageInfoSpan.empty();return}let startNo=(this._currentPageNo-1)*this.options.pageSize+1;let endNo=this._currentPageNo*this.options.pageSize;endNo=this._normalizeNumber(endNo,startNo,this._totalRecordCount,0);if(endNo>=startNo){let pagingInfoMessage=this._formatString(this.options.messages.pagingInfo,startNo,endNo,this._totalRecordCount);this._$pageInfoSpan.html(pagingInfoMessage)}},_bindClickEventsToPageNumberButtons:function(){let self=this;self._$pagingListArea.find(".jtable-page-number,.jtable-page-number-previous,.jtable-page-number-next,.jtable-page-number-first,.jtable-page-number-last").not(".jtable-page-number-disabled").on("click",function(e){e.preventDefault();self._changePage($(this).data("pageNumber"))})},_changePage:function(pageNo){pageNo=this._normalizeNumber(pageNo,1,this._calculatePageCount(),1);if(pageNo==this._currentPageNo){this._refreshGotoPageInput();return}this._currentPageNo=pageNo;this._reloadTable()}})})(jQuery);(function($){let base={_initializeSettings:jTable.prototype._initializeSettings,_normalizeFieldOptions:jTable.prototype._normalizeFieldOptions,_doExtraActions:jTable.prototype._doExtraActions,_createHeaderCellForField:jTable.prototype._createHeaderCellForField,_createJtParamsForLoading:jTable.prototype._createJtParamsForLoading};$.extend(true,jTable.prototype,{options:{sorting:false,multiSorting:false,roomForSortableIcon:true,defaultSorting:""},_lastSorting:null,_initializeSettings:function(){base._initializeSettings.apply(this,arguments);this._lastSorting=[]},_normalizeFieldOptions:function(fieldName,props){base._normalizeFieldOptions.apply(this,arguments);props.sorting=props.sorting!=false},_doExtraActions:function(){base._doExtraActions.apply(this,arguments);if(this.options.sorting){this._buildDefaultSortingArray()}if(this.options.saveUserPreferences&&this.options.sorting){this._loadColumnSortSettings()}},_createHeaderCellForField:function(fieldName,field){let $headerCell=base._createHeaderCellForField.apply(this,arguments);if(this.options.sorting&&field.sorting){this._makeColumnSortable($headerCell,fieldName,field.initialSortingDirection)}return $headerCell},_buildDefaultSortingArray:function(){let self=this;$.each(self.options.defaultSorting.split(","),function(orderIndex,orderValue){$.each(self.options.fields,function(fieldName,fieldProps){if(fieldProps.sorting){let colOffset=orderValue.indexOf(fieldName);if(colOffset>-1){if(orderValue.toUpperCase().includes(" DESC",colOffset)){self._lastSorting.push({fieldName:fieldName,sortOrder:"DESC"})}else{self._lastSorting.push({fieldName:fieldName,sortOrder:"ASC"})}}}})})},_makeColumnSortable:function($columnHeader,fieldName,initialSortingDirection){let self=this;if(self.options.roomForSortableIcon){$columnHeader.find(".jtable-column-header-text").append("     ")}$columnHeader.addClass("jtable-column-header-sortable").on("click",function(e){e.preventDefault();if(!self.options.multiSorting||!e.ctrlKey){self._lastSorting=[]}self._sortTableByColumn($columnHeader)});if(initialSortingDirection){$columnHeader.addClass("jtable-column-header-sorted-"+initialSortingDirection.toLowerCase())}$.each(this._lastSorting,function(sortIndex,sortField){if(sortField.fieldName==fieldName){if(sortField.sortOrder=="DESC"){$columnHeader.addClass("jtable-column-header-sorted-desc")}else{$columnHeader.addClass("jtable-column-header-sorted-asc")}}})},_sortTableByColumn:function($columnHeader){if(this._lastSorting.length==0){$columnHeader.siblings().removeClass("jtable-column-header-sorted-asc jtable-column-header-sorted-desc")}for(let i=0;ithead >tr >th:nth-child("+columnIndexInTable+"),>tbody >tr >td:nth-child("+columnIndexInTable+")").hide()}else if(field.visibility=="hidden"&&visibility!="hidden"&&visibility!="separator"){this._$table.find(">thead >tr >th:nth-child("+columnIndexInTable+"),>tbody >tr >td:nth-child("+columnIndexInTable+")").show().css("display","table-cell")}field.visibility=visibility},_createColumnSelection:function(){let self=this;this._$columnSelectionDiv=$("
    ").addClass("jtable-column-selection-container").appendTo(self._$mainContainer);this._$table.children("thead").on("contextmenu",function(e){if(!self.options.columnSelectable){return}e.preventDefault();$("
    ").addClass("jtable-contextmenu-overlay").on("click",function(){$(this).remove();self._$columnSelectionDiv.hide()}).on("contextmenu",function(){return false}).appendTo(document.body);self._fillColumnSelection();let containerOffset=self._$mainContainer.offset();let selectionDivTop=e.pageY-containerOffset.top;let selectionDivLeft=e.pageX-containerOffset.left;let selectionDivMinWidth=100;let containerWidth=self._$mainContainer.width();if(containerWidth>selectionDivMinWidth&&selectionDivLeft>containerWidth-selectionDivMinWidth){selectionDivLeft=containerWidth-selectionDivMinWidth}self._$columnSelectionDiv.css({left:selectionDivLeft,top:selectionDivTop,"min-width":selectionDivMinWidth+"px"}).show()})},_fillColumnSelection:function(){let self=this;let $columnsUl=$("
      ").addClass("jtable-column-select-list");for(let i=0;i").appendTo($columnsUl);let $label=$("").append($(""+(field.title||columnName)+"")).appendTo($columnLi);if(field.visibility!="separator"){let $checkbox=$('').prependTo($label).on("click",function(){let clickedColumnName=$(this).attr("id");let clickedField=self.options.fields[clickedColumnName];if(clickedField.visibility=="fixed"){return}self.changeColumnVisibility(clickedColumnName,$(this).is(":checked")?"visible":"hidden")});if(field.visibility!="hidden"){$checkbox.attr("checked","checked")}if(field.visibility=="fixed"){$checkbox.attr("disabled","disabled")}}}this._$columnSelectionDiv.html($columnsUl)},_createColumnResizeBar:function(){this._$columnResizeBar=$("
      ").addClass("jtable-column-resize-bar").appendTo(this._$mainContainer).hide()},_makeColumnResizable:function($columnHeader){let self=this;$("
      ").addClass("jtable-column-resize-handler").appendTo($columnHeader.find(".jtable-column-header-container")).on("click",function(e){e.preventDefault();e.stopPropagation()}).mousedown(function(downevent){downevent.preventDefault();downevent.stopPropagation();let mainContainerOffset=self._$mainContainer.offset();let $nextColumnHeader=$columnHeader.nextAll("th.jtable-column-header:visible:first");if($nextColumnHeader.length){let nextfieldname=$nextColumnHeader.data("fieldName");if(!self.options.fields[nextfieldname].columnResizable){$nextColumnHeader=undefined}}if($nextColumnHeader){nextColumnOuterWidth=$nextColumnHeader.outerWidth()}else{nextColumnOuterWidth=0}let minimumColumnWidth=10;self._currentResizeArgs={currentColumnStartWidth:$columnHeader.outerWidth(),minWidth:minimumColumnWidth,maxWidth:$columnHeader.outerWidth()+nextColumnOuterWidth,mouseStartX:downevent.pageX,minResizeX:function(){return this.mouseStartX-(this.currentColumnStartWidth-this.minWidth)},maxResizeX:function(){return this.mouseStartX+(this.maxWidth-this.currentColumnStartWidth)}};let resizeonmousemove=function(moveevent){if(!self._currentResizeArgs){return}let resizeBarX=self._normalizeNumber(moveevent.pageX,self._currentResizeArgs.minResizeX(),self._currentResizeArgs.maxResizeX());self._$columnResizeBar.css("left",resizeBarX-mainContainerOffset.left+"px")};let resizeonmouseup=function(upevent){if(!self._currentResizeArgs){return}$(document).off("mousemove",resizeonmousemove);$(document).off("mouseup",resizeonmouseup);self._$columnResizeBar.hide();let mouseChangeX=upevent.pageX-self._currentResizeArgs.mouseStartX;if(mouseChangeX!=0){let currentColumnFinalWidth=self._normalizeNumber(self._currentResizeArgs.currentColumnStartWidth+mouseChangeX,self._currentResizeArgs.minWidth,self._currentResizeArgs.maxWidth);let pixelToPercentRatio=$columnHeader.data("width-in-percent")/self._currentResizeArgs.currentColumnStartWidth;$columnHeader.data("width-in-percent",currentColumnFinalWidth*pixelToPercentRatio);$columnHeader.css("width",$columnHeader.data("width-in-percent")+"%");if($nextColumnHeader){let nextColumnFinalWidth=nextColumnOuterWidth+(self._currentResizeArgs.currentColumnStartWidth-currentColumnFinalWidth);$nextColumnHeader.data("width-in-percent",nextColumnFinalWidth*pixelToPercentRatio);$nextColumnHeader.css("width",$nextColumnHeader.data("width-in-percent")+"%")}self._normalizeColumnWidths();if(self.options.saveUserPreferences){self._saveColumnSettings()}}self._currentResizeArgs=null};self._$columnResizeBar.show().css({top:$columnHeader.offset().top-mainContainerOffset.top+"px",left:downevent.pageX-mainContainerOffset.left+"px",height:self._$table.outerHeight()+"px"});$(document).on("mousemove",resizeonmousemove);$(document).on("mouseup",resizeonmouseup)})},_normalizeColumnWidths:function(){let self=this;let commandColumnHeaders=self._$table.find(">thead th.jtable-command-column-header").data("width-in-percent",1).css("width","1%");let headerCells=self._$table.find(">thead th");let totalWidthInPixel=self._$table.outerWidth();let columnWidths={};headerCells.each(function(){let $cell=$(this);if($cell.is(":visible")){let fieldName=$cell.data("fieldName");let widthInPercent=$cell.outerWidth()*100/totalWidthInPixel;columnWidths[fieldName]=widthInPercent}});headerCells.each(function(){let $cell=$(this);if($cell.is(":visible")){let fieldName=$cell.data("fieldName");$cell.data("width-in-percent",columnWidths[fieldName]).css("width",columnWidths[fieldName]+"%")}else{$cell.data("width-in-percent",1).css("width","1%")}})},_saveColumnSettings:function(){let self=this;let fieldSettings="";self._$table.find(">thead >tr >th.jtable-column-header").each(function(){let $cell=$(this);let fieldName=$cell.data("fieldName");let columnWidth=$cell.data("width-in-percent");let fieldVisibility=self.options.fields[fieldName].visibility;let fieldSetting=fieldName+"="+fieldVisibility+";"+columnWidth;fieldSettings=fieldSettings+fieldSetting+"|"});this._setCookie("column-settings",fieldSettings.substr(0,fieldSettings.length-1))},_loadColumnSettings:function(){let self=this;let columnSettingsCookie=self._getCookie("column-settings");if(columnSettingsCookie==null){return}if(!columnSettingsCookie){self._removeCookie("column-settings");return}let columnSettings={};$.each(columnSettingsCookie.split("|"),function(inx,fieldSetting){let splitted=fieldSetting.split("=");let fieldName=splitted[0];let settings=splitted[1].split(";");let columnVisibility=settings[0];let columnWidth=settings[1];if($.inArray(fieldName,self._fieldList)>-1){if(self.options.fields[fieldName].visibility!="fixed"){self.options.fields[fieldName].visibility=columnVisibility}if(self.options.columnResizable){let allow_resize=self.options.fields[fieldName].columnResizable!=false;if(allow_resize){self.options.fields[fieldName].width=columnWidth+"%"}}}})}})})(jQuery);(function($){let base={_removeRowsFromTable:jTable.prototype._removeRowsFromTable};$.extend(true,jTable.prototype,{options:{openChildAsAccordion:false},openChildTable:function($row,tableOptions,opened){let self=this;if(tableOptions.jqueryuiTheme==undefined){tableOptions.jqueryuiTheme=self.options.jqueryuiTheme}tableOptions.showCloseButton=tableOptions.showCloseButton!=false;if(tableOptions.showCloseButton&&!tableOptions.closeRequested){tableOptions.closeRequested=function(){self.closeChildTable($row)}}if(self.options.openChildAsAccordion){$row.siblings(".jtable-data-row").each(function(){self.closeChildTable($(this))})}self.closeChildTable($row,function(){let $childRowColumn=self.getChildRow($row).children("td").empty();let $childTableContainer=$("
      ").addClass("jtable-child-table-container").appendTo($childRowColumn);$childRowColumn.data("childTable",$childTableContainer);$childTableContainer.jtable(tableOptions);self.openChildRow($row);$childTableContainer.hide().slideDown("fast",function(){if(opened){opened({childTable:$childTableContainer})}})})},closeChildTable:function($row,closed){let self=this;let $childRowColumn=self.getChildRow($row).children("td");let $childTable=$childRowColumn.data("childTable");if(!$childTable){if(closed){closed()}return}$childRowColumn.data("childTable",null);$childTable.slideUp("fast",function(){$childTable.jtable("destroy");$childTable.remove();self.closeChildRow($row);if(closed){closed()}})},isChildRowOpen:function($row){return this.getChildRow($row).is(":visible")},getChildRow:function($row){return $row.data("childRow")||this._createChildRow($row)},openChildRow:function($row){let $childRow=this.getChildRow($row);if(!$childRow.is(":visible")){$childRow.show()}return $childRow},closeChildRow:function($row){let $childRow=this.getChildRow($row);if($childRow.is(":visible")){$childRow.hide()}},_removeRowsFromTable:function($rows,reason){if(reason=="deleted"){$rows.each(function(){let $row=$(this);let $childRow=$row.data("childRow");if($childRow){$childRow.remove()}})}base._removeRowsFromTable.apply(this,arguments)},_createChildRow:function($row){let totalColumnCount=this._$table.find("thead th").length;let $childRow=$("").addClass("jtable-child-row").append('');$row.after($childRow);$row.data("childRow",$childRow);$childRow.hide();return $childRow}})})(jQuery); \ No newline at end of file