text: !function(o){"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(t){return o(t,window,document)}):"object"==typeof exports?module.exports=function(t,e){return t||(t=window),e&&e.fn.dataTable||(e=require("datatables.net")(t,e).$),o(e,t,t.document)}:o(jQuery,window,document)}(function(u,t,o,c){"use strict";var l=u.fn.dataTable,a=0,r=function(t,e){if(!l.versionCheck||!l.versionCheck("1.10.8"))throw"Warning: altEditor requires DataTables 1.10.8 or greater";this.c=u.extend(!0,{},l.defaults.altEditor,r.defaults,e),this.s={dt:new l.Api(t),namespace:".altEditor"+a++},this.dom={modal:u('<div class="dt-altEditor-handle"/>')},this._constructor()};return u.extend(r.prototype,{_constructor:function(){var t=this,e=this.s.dt;e.settings()[0].oInit.onAddRow&&(t.onAddRow=e.settings()[0].oInit.onAddRow),e.settings()[0].oInit.onDeleteRow&&(t.onDeleteRow=e.settings()[0].oInit.onDeleteRow),e.settings()[0].oInit.onEditRow&&(t.onEditRow=e.settings()[0].oInit.onEditRow),this._setup(),e.on("destroy.altEditor",function(){e.off(".altEditor"),u(e.table().body()).off(t.s.namespace),u(o.body).off(t.s.namespace)})},_setup:function(){var n=this,t=this.s.dt,e="altEditor-modal-"+(""+Math.random()).replace(".","");this.modal_selector="#"+e;var o='<div class="modal fade" id="'+e+'" tabindex="-1" role="dialog"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h4 style="padding-top: 1rem;padding-left: 1rem;" class="modal-title"></h4><button style="margin: initial;" type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></div><div class="modal-body"><p></p></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button><input type="submit" form="altEditor-form" class="btn btn-primary"></input></div></div></div></div>';u("body").append(o),t.button("edit:name")&&(t.button("edit:name").action(function(t,e,o,a){n._openEditModal()}),u(this.modal_selector).on("click","#editRowBtn",function(t){n._inputValidation()&&(t.preventDefault(),t.stopPropagation(),n._editRowData())})),t.button("delete:name")&&(t.button("delete:name").action(function(t,e,o,a){n._openDeleteModal()}),u(this.modal_selector).on("click","#deleteRowBtn",function(t){t.preventDefault(),t.stopPropagation(),n._deleteRow(),u(this).prop("disabled",!0)})),t.button("add:name")&&(t.button("add:name").action(function(t,e,o,a){n._openAddModal()}),u(this.modal_selector).on("click","#addRowBtn",function(t){n._inputValidation()&&(t.preventDefault(),t.stopPropagation(),n._addRowData())})),this.s.dt.button("refresh:name")&&this.s.dt.button("refresh:name").action(function(t,e,o,a){e.ajax&&e.ajax.url()&&e.ajax.reload()})},_emitEvent:function(o,a){this.s.dt.iterator("table",function(t,e){u(t.nTable).triggerHandler(o+".dt",a)})},_openEditModal:function(){var t=this,e=this.s.dt,o=[];for(var a in e.context[0].aoColumns){var n=e.context[0].aoColumns[a];o[a]={title:n.sTitle,name:n.data?n.data:n.mData,type:n.type?n.type:"text",options:n.options?n.options:[],msg:n.errorMsg?n.errorMsg:"",hoverMsg:n.hoverMsg?n.hoverMsg:"",pattern:n.pattern?n.pattern:".*",special:n.special?n.special:"",unique:!!n.unique&&n.unique,uniqueMsg:n.uniqueMsg?n.uniqueMsg:"",maxLength:!!n.maxLength&&n.maxLength,multiple:!!n.multiple&&n.multiple,select2:!!n.select2&&n.select2,datepicker:!!n.datepicker&&n.datepicker,required:!!n.required&&n.required,customValidation:!!n.customValidation,max:isNaN(n.max)?c:n.max,min:isNaN(n.min)?c:n.min,formatData:!!n.formatData}}var i=e.rows({selected:!0}),l="";for(var r in l+="<form name='altEditor-form' role='form'>",o)if(0<=o[r].type.indexOf("hidden"))l+="<input type='hidden' id='"+o[r].name+"' value='"+i.data()[0][o[r].name]+"'></input>";else{if(l+="<div style='margin-left: initial;margin-right: initial;' class='form-group row'>",l+="<div class='col-sm-3 col-md-3 col-lg-3 text-right' style='padding-top:4px;'>",l+="<label for='"+o[r].name+"'>"+o[r].title+":</label>"+(o[r].required?"<span class='ms-formvalidation'>*</span>":"")+"</div>",l+="<div class='col-sm-8 col-md-8 col-lg-8'>",(0<=o[r].type.indexOf("text")||0<=o[r].type.indexOf("number"))&&(l+="<input type='"+t._quoteattr(o[r].type)+"' id='"+t._quoteattr(o[r].name)+"'  pattern='"+t._quoteattr(o[r].pattern)+"'  title='"+t._quoteattr(o[r].hoverMsg)+"' name='"+t._quoteattr(o[r].title)+"' placeholder='"+t._quoteattr(o[r].title)+"' data-special='"+t._quoteattr(o[r].special)+"' data-errorMsg='"+t._quoteattr(o[r].msg)+"' data-uniqueMsg='"+t._quoteattr(o[r].uniqueMsg)+"' data-unique='"+o[r].unique+"'"+(o[r].maxLength?" maxlength='"+o[r].maxLength+"'":"")+(!isNaN(o[r].max)&&0<=o[r].type.indexOf("number")?" max='"+o[r].max+"'":"")+(!isNaN(o[r].min)&&0<=o[r].type.indexOf("number")?" min='"+o[r].min+"'":"")+" coll-number='"+r+"' custom-validation='"+o[r].customValidation+"' format-data='"+o[r].formatData+"' style='overflow:hidden'  class='form-control  form-control-sm' value='"+t._quoteattr(i.data()[0][o[r].name])+"' "+ +(o[r].required?"required":"")+">",l+="<label id='"+o[r].name+"label' class='errorLabel'></label>"),0<=o[r].type.indexOf("readonly")&&(l+="<input type='text' readonly  id='"+o[r].name+"' name='"+o[r].title+"' placeholder='"+o[r].title+"' style='overflow:hidden'  class='form-control  form-control-sm' value='"+i.data()[0][o[r].name]+"'>"),0<=o[r].type.indexOf("select")){var s="";for(a=0;a<o[r].options.length;a++)0<=i.data()[0][o[r].name].indexOf(o[r].options[a])?s+="<option value='"+o[r].options[a]+"'selected>"+o[r].options[a]+"</option>":s+="<option value='"+o[r].options[a]+"'>"+o[r].options[a]+"</option>";l+="<select class='form-control"+(o[r].select2?" select2":"")+"' id='"+o[r].name+"' name='"+o[r].title+"' "+(o[r].multiple?"multiple":"")+" coll-number='"+r+"' custom-validation='"+o[r].customValidation+"'>"+s+"</select>"}l+="</div><div style='clear:both;'></div></div>"}l+="</form>";var d=this.modal_selector;for(var r in u(d).on("show.bs.modal",function(){u(d).find(".modal-title").html("Edit Record"),u(d).find(".modal-body").html(l),u(d).find(".modal-footer").html('<button type="button" data-content="remove" class="btn btn-default" data-dismiss="modal" id="editRowBtnClose">Close</button><button type="button" data-content="remove" class="btn btn-primary" id="editRowBtn">Save</button>')}),u(d).modal("show"),u(d+" input[0]").focus(),o)o[r].select2&&u(d).find("select#"+o[r].name).select2(o[r].select2);for(var r in o)o[r].datepicker&&u(d).find("#"+o[r].name).datepicker(o[r].datepicker)},_editRowData:function(){var i=this,o=this.s.dt,a={};o.rows({selected:!0});u('form[name="altEditor-form"] *').filter(":input").each(function(t){var e=u(this).val();"true"==u(this).attr("format-data")&&(e=o.context[0].aoColumns[parseInt(u(this).attr("coll-number"))].formatData(e)),a[u(this).attr("id")]=e}),console!=c&&console.log(a),i.onEditRow(i,a,function(t,e,o,a,n){i._editRowCallback(t,e,o,a,n)},function(t){i._errorCallback(t)})},_openDeleteModal:function(){var t=this,e=this.s.dt,o=[];for(var a in e.context[0].aoColumns)o.push({title:e.context[0].aoColumns[a].sTitle,type:e.context[0].aoColumns[a].type?e.context[0].aoColumns[a].type:"text",name:e.context[0].aoColumns[a].data?e.context[0].aoColumns[a].data:e.context[0].aoColumns[a].mData});var n=e.rows({selected:!0}),i="";for(var l in i+="<form name='altEditor-form' role='form'>",o)0<=o[l].type.indexOf("hidden")?i+="<input type='hidden' id='"+o[l].title+"' value='"+n.data()[0][o[l].name]+"'></input>":i+="<div style='margin-left: initial;margin-right: initial;' class='form-group row'><label for='"+t._quoteattr(o[l].name)+"'>"+o[l].title+":&nbsp</label> <input  type='hidden'  id='"+t._quoteattr(o[l].title)+"' name='"+t._quoteattr(o[l].title)+"' placeholder='"+t._quoteattr(o[l].title)+"' style='overflow:hidden'  class='form-control' value='"+t._quoteattr(n.data()[0][o[l].name])+"' >"+n.data()[0][o[l].name]+"</input></div>";i+="</form>";var r=this.modal_selector;u(r).on("show.bs.modal",function(){u(r).find(".modal-title").html("Delete Record"),u(r).find(".modal-body").html(i),u(r).find(".modal-footer").html('<button type="button" data-content="remove" class="btn btn-default" data-dismiss="modal" id="deleteRowBtnClose">Close</button><button type="button"  data-content="remove" class="btn btn-danger" id="deleteRowBtn">Delete</button>')}),u(r).modal("show"),u(r+" input[0]").focus()},_deleteRow:function(){for(var e=this,t=this.s.dt,o={},a=t.rows({selected:!0}),n=0;n<t.context[0].aoColumns.length;n++){var i=t.context[0].aoColumns[n].data?t.context[0].aoColumns[n].data:t.context[0].aoColumns[n].mData?t.context[0].aoColumns[n].mData:t.context[0].aoColumns[n].idx;o[i]=a.data()[0][i]}e.onDeleteRow(e,o,function(t){e._deleteRowCallback(t)},function(t){e._errorCallback(t)})},_openAddModal:function(){var t=this,e=this.s.dt,o=[];for(var a in e.context[0].aoColumns){var n=e.context[0].aoColumns[a];o[a]={title:n.sTitle,name:n.data?n.data:n.mData,type:n.type?n.type:"text",options:n.options?n.options:[],msg:n.errorMsg?n.errorMsg:"",hoverMsg:n.hoverMsg?n.hoverMsg:"",pattern:n.pattern?n.pattern:".*",special:n.special?n.special:"",unique:!!n.unique&&n.unique,uniqueMsg:n.uniqueMsg?n.uniqueMsg:"",maxLength:!!n.maxLength&&n.maxLength,multiple:!!n.multiple&&n.multiple,select2:!!n.select2&&n.select2,datepicker:!!n.datepicker&&n.datepicker,required:!!n.required&&n.required,customValidation:!!n.customValidation,defaultValue:"function"==typeof n.defaultValue?n.defaultValue():n.defaultValue,max:isNaN(n.max)?c:n.max,min:isNaN(n.min)?c:n.min,formatData:!!n.formatData}}console!=c&&console.log(o);var i="";for(var l in i+="<form name='altEditor-form' role='form'>",o)if(0<=o[l].type.indexOf("hidden"));else{if(i+="<div style='margin-left: initial;margin-right: initial;' class='form-group row'><div class='col-sm-3 col-md-3 col-lg-3 text-right' style='padding-top:4px;'><label for='"+o[l].name+"'>"+o[l].title+":</label>"+(o[l].required?"<span class='ms-formvalidation'>*</span>":"")+"</div><div class='col-sm-8 col-md-8 col-lg-8'>",(0<=o[l].type.indexOf("text")||0<=o[l].type.indexOf("number"))&&(i+="<input type='"+t._quoteattr(o[l].type)+"' id='"+t._quoteattr(o[l].name)+"'  pattern='"+t._quoteattr(o[l].pattern)+"'  title='"+t._quoteattr(o[l].hoverMsg)+"' name='"+t._quoteattr(o[l].title)+"' placeholder='"+t._quoteattr(o[l].title)+"' data-special='"+o[l].special+"' data-errorMsg='"+t._quoteattr(o[l].msg)+"' data-uniqueMsg='"+t._quoteattr(o[l].uniqueMsg)+"' data-unique='"+o[l].unique+"'"+(o[l].maxLength?" maxlength='"+o[l].maxLength+"'":"")+(!isNaN(o[l].max)&&0<=o[l].type.indexOf("number")?" max='"+o[l].max+"'":"")+(!isNaN(o[l].min)&&0<=o[l].type.indexOf("number")?" min='"+o[l].min+"'":"")+" coll-number='"+l+"' custom-validation='"+o[l].customValidation+"' format-data='"+o[l].formatData+"' style='overflow:hidden'  class='form-control  form-control-sm' value='"+(o[l].defaultValue?o[l].defaultValue:"")+"' "+(o[l].required?"required":"")+">",i+="<label id='"+t._quoteattr(o[l].name)+"label' class='errorLabel'></label>"),0<=o[l].type.indexOf("readonly")&&(i+="<input type='text' readonly  id='"+t._quoteattr(o[l].name)+"' name='"+t._quoteattr(o[l].title)+"' placeholder='"+t._quoteattr(o[l].title)+"' style='overflow:hidden'  class='form-control  form-control-sm' value=''>"),0<=o[l].type.indexOf("select")){var r="";for(a=0;a<o[l].options.length;a++)o[l].defaultValue==o[l].options[a]?r+="<option value='"+t._quoteattr(o[l].options[a])+"' selected>"+o[l].options[a]+"</option>":r+="<option value='"+t._quoteattr(o[l].options[a])+"'>"+o[l].options[a]+"</option>";i+="<select class='form-control"+(o[l].select2?" select2":"")+"' id='"+t._quoteattr(o[l].name)+"' name='"+t._quoteattr(o[l].title)+"' "+(o[l].multiple?"multiple":"")+" coll-number='"+l+"' custom-validation='"+o[l].customValidation+"'>"+r+"</select>",i+="<label id='"+t._quoteattr(o[l].name)+"label' class='errorLabel'></label>"}i+="</div><div style='clear:both;'></div></div>"}i+="</form>";var s=this.modal_selector;for(var l in u(s).on("show.bs.modal",function(){u(s).find(".modal-title").html("Add Record"),u(s).find(".modal-body").html(i),u(s).find(".modal-footer").html('<button type="button" data-content="remove" class="btn btn-default" data-dismiss="modal" id="addRowBtnClose">Close</button><button type="button"  data-content="remove" class="btn btn-primary" id="addRowBtn">Add</button>')}),u(s).modal("show"),u(s+" input[0]").focus(),o)o[l].select2&&u(s).find("select#"+o[l].name).select2(o[l].select2)},_addRowData:function(){var e=this,o=this.s.dt,a={};u('form[name="altEditor-form"] *').filter(":input").each(function(t){var e=u(this).val();"true"==u(this).attr("format-data")&&(e=o.context[0].aoColumns[parseInt(u(this).attr("coll-number"))].formatData(e)),a[u(this).attr("id")]=e}),console,e.onAddRow(e,a,function(t){e._addRowCallback(t)},function(t){e._errorCallback(t)})},_deleteRowCallback:function(t,e,o){var a=this.modal_selector;u(a+" .modal-body .alert").remove();u(a+" .modal-body").append('<div class="alert alert-success" role="alert"><strong>Success!</strong></div>'),this.s.dt.row({selected:!0}).remove(),this.s.dt.draw(),u("div"+a).find("button#addRowBtnClose").trigger("click"),u("div"+a).find("button#editRowBtnClose").trigger("click"),u("div"+a).find("button#deleteRowBtnClose").trigger("click")},_addRowCallback:function(t,e,o){var a="string"==typeof t?JSON.parse(t):t,n=this.modal_selector;u(n+" .modal-body .alert").remove();u(n+" .modal-body").append('<div class="alert alert-success" role="alert"><strong>Success!</strong></div>'),this.s.dt.row.add(a).draw(!1),u("div"+n).find("button#addRowBtnClose").trigger("click"),u("div"+n).find("button#editRowBtnClose").trigger("click"),u("div"+n).find("button#deleteRowBtnClose").trigger("click")},_editRowCallback:function(t,e,o){var a="string"==typeof t?JSON.parse(t):t,n=this.modal_selector;u(n+" .modal-body .alert").remove();u(n+" .modal-body").append('<div class="alert alert-success" role="alert"><strong>Success!</strong></div>'),this.s.dt.row({selected:!0}).data(a),this.s.dt.draw(),u("div"+n).find("button#addRowBtnClose").trigger("click"),u("div"+n).find("button#editRowBtnClose").trigger("click"),u("div"+n).find("button#deleteRowBtnClose").trigger("click")},_errorCallback:function(t,e,o){var a=t,n=this.modal_selector;u(n+" .modal-body .alert").remove();var i="There was an unknown error!";if(a.responseJSON&&a.responseJSON.errors)for(var l in i="",a.responseJSON.errors)i+=a.responseJSON.errors[l][0];var r='<div class="alert alert-danger" role="alert"><strong>Error!</strong> '+(null==a.status?"":"Response code: "+a.status)+" "+i+"</div>";u(n+" .modal-body").append(r)},onAddRow:function(t,e,o,a){console!=c&&console.log("Missing AJAX configuration for INSERT"),o(e)},onEditRow:function(t,e,o,a){console!=c&&console.log("Missing AJAX configuration for UPDATE"),o(e)},onDeleteRow:function(t,e,o,a){console!=c&&console.log("Missing AJAX configuration for DELETE"),o(e)},_inputValidation:function(){var l=this.s.dt,t=!1,r=0;return u(".modal.show").find('form[name="altEditor-form"] *').filter(":text, input[type=number], select").each(function(t){var e="#"+u(this).attr("id")+"label";if(u(e).hide(),u(e).empty(),u(this).prop("required")&&!u(this).val())u(e).html("This field is required !"),u(e).show(),r++;else if(u(this).val().match(u(this).attr("pattern"))){if(u(this).prop("maxlength"))if(u(this).val().length>parseInt(u(this).attr("maxlength")))u(e).html("Max length cannot be more then "+u(this).attr("maxlength")),u(e).show(),r++;else if(u(this).prop("max")&&"number"==u(this).attr("type")&&u(this).val())if(parseFloat(u(this).val())>parseFloat(u(this).attr("max")))u(e).html("Max value cannot be more then "+u(this).attr("max")),u(e).show(),r++;else if(u(this).prop("min")&&"number"==u(this).attr("type")&&u(this).val())if(parseFloat(u(this).val())<parseFloat(u(this).attr("min")))u(e).html("Min value cannot be less then "+u(this).attr("min")),u(e).show(),r++;else if("true"==u(this).attr("data-unique")){var o=l.column("th:contains('"+u(this).attr("name")+"')").data(),a=null;for(var n in null!=l.row({selected:!0}).index()&&(a=l.cell(l.row({selected:!0}).index(),l.column("th:contains('"+u(this).attr("name")+"')").index()).data()),o)u(this).val()==o[n]&&o[n]!=a&&(u(e).html(u(this).attr("data-uniqueMsg")),u(e).show(),r++)}else if("true"==u(this).attr("custom-validation")){var i=l.context[0].aoColumns[parseInt(u(this).attr("coll-number"))].customValidation(u(this).val());"string"==typeof i&&(u(e).html(i),u(e).show(),r++)}}else u(e).html(u(this).attr("data-errorMsg")),u(e).show(),r++}),0==r&&(t=!0),t},_quoteattr:function(t,e){return null==t?"":(e=e?"&#13;":"\n",(""+t).replace(/&/g,"&amp;").replace(/'/g,"&apos;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r\n/g,e).replace(/[\r\n]/g,e))}}),r.version="2.0",r.defaults={alwaysAsk:!1,focus:null,columns:"",update:null,editor:null},r.classes={btn:"btn"},u(o).on("preInit.dt.altEditor",function(t,e,o){if("dt"===t.namespace){var a=e.oInit.altEditor,n=l.defaults.altEditor;if(a||n){var i=u.extend({},a,n);!1!==a&&new r(e,i)}}}),l.altEditor=r});