function JDialog(options) { var element=options.element; if (($(element).hasClass("ui-dialog-content"))&&($(element.dialog("isOpen")))) return; var parentElement=options.element.parent(); $(element).css('zIndex',9999); element.data("parentElement",parentElement); if (options.closebutton) { if (options.buttons==null) options.buttons={}; options.buttons["closeBtn"]={ class:"btn btn-danger btn-37", html:"
", click:function(){ var dlg=$(this).parents("div.ui-dialog").attr("aria-describedby"); $("#"+dlg).dialog("close"); }, mouseover:function(){ $(this).parent().find("button").not(this).find(".btntext").hide(200); $(this).find(".btntext").show(200); } } } if (options.acceptbutton!=null) { if (options.buttons==null) options.buttons={}; options.buttons["acceptBtn"]={ class:"btn btn-success btn-37", html:" ", click:options.acceptbutton, mouseover:function(){ $(this).parent().find("button").not(this).find(".btntext").hide(200); $(this).find(".btntext").show(200); } }; element.off("keypress"); element.keypress(function(e) { if (e.keyCode == $.ui.keyCode.ENTER) { if (!$(e.target).hasClass("filterelement")) options.acceptbutton(); } }); } var appendto=null; if (document.fullscreenElement) appendto="#tdmain"; if (options.appendto!=null) appendto=options.appendto; if ((options.class!=null)&&(options.classes==null)) options.classes={ "ui-dialog":"ui-corner-all","ui-dialog-titlebar":'ui-corner-all bg-'+options.class }; element.dialog({ height:(options.height==null)?"auto":options.height, width:(options.width==null)?"auto":options.width, modal:(options.modal==null)?true:options.modal, autoOpen:(options.autoOpen==null)?true:options.autoOpen, classes:options.classes, resizable:(options.resizable==true), draggable:(options.draggable!==null)?options.draggable:true, autoResize:true, responsive:true, appendTo:appendto, position:(options.position!=null)?options.position:{my:'top',at:'top+150'}, title:options.title, buttons:options.buttons, close:function(){ element.dialog("destroy"); element.appendTo(parentElement); if (options.close!=null) options.close.apply(this); // options.close(); }, open: function () { var ui_dialog_interaction = $.ui.dialog.prototype._allowInteraction; $.ui.dialog.prototype._allowInteraction = function (e) { if ($(e.target).is(".allowinteraction")) return true; if ($(e.target).closest('.select2-search__field,.select2-dropdown').length) return true; return ui_dialog_interaction.apply(this, arguments); }; $.ui.dialog.prototype._allowInteractionRemapped = true; if (options.open!=null) options.open(); setTimeout(function(){ $(".ui-dialog").draggable({ cancel:".ui-dialog-content" }); },1000); }, _allowInteraction: function (event) { return !!($(event.target).is(".select2-input")||($(event.target).is(".allowinteraction"))) || this._super(event); } }); } function JDButton(opts) { return { class:"btn btn-37 "+(opts.class!=null)?opts.class:"", html:" ", click:opts.action, mouseover:function(){ $(this).parent().find("button").not(this).find(".btntext").hide(200); $(this).find(".btntext").show(200); } }; } function JDialogPost(dlg,data,callback) { obj={ dialog:dlg, callback:callback, data:data }; dlg.JDialog("waitbuttons"); $.ajax({ url: "/headless.php", type: "post", data: data, context:obj }).done(processReturn(function(d){ if (this.callback!=null) this.callback.apply(this,[d]); this.dialog.dialog("close"); },{ funcrevert:function(){ this.dialog.JDialog("returnbuttons"); } })); } $.fn.JDialog=function(options) { if ( typeof options === 'object') { options["element"]=$(this); JDialog(options); return; } else { params=arguments[1]; switch(options) { case "isopen": return ($(this).hasClass("ui-dialog-content")); case "recenter": recenter($(this)); break; case "checkTablers": return checkTablers($(this)); case "waitbuttons": $(this).data("tabler_buttons",$(this).dialog("option","buttons")); $(this).dialog("option","buttons",{ "Ожидайте...":function(){} });break; case "returnbuttons": $(this).dialog("option","buttons",$(this).data("tabler_buttons")); break; case "post": return JDialogPost($(this),params,arguments[2]); } } } function isFormValid(el,zerosnotallowed,addfunction) { var str; checkRequiredForm(el,zerosnotallowed,addfunction); str=""; $(el).find(".has-error").each(function(){ var title=$(this).find(".inputrequired,.erroreditem").attr("title"); if (title==null) { title=$(this).prev().text().replace(":",""); } str+=title+" "; }); if (str!="") { $.snackbar({ content:"