var BuilderPages=function(){};BuilderPages.prototype={changed:false,pageDeleted:false,showForm:function(){var a=$('
').appendTo(document.body).modal("show").load("/_builder/pages/modalform.html?id="+$.builder.page_id,$.proxy(function(){this.changed=false;this.pageDeleted=false;this.bindChange()},this)).on("hidden",function(){$(this).remove();if($.builder.pages.pageDeleted){document.location="/"}else{if($.builder.pages.changed){$.builder.reloadPage()}}})},bindChange:function(){$("#builderPagesFormPlace input").on("change keyup",function(){$("#builderPagesForm input[data-action=save]").removeAttr("disabled")})},showEditForm:function(a){$("#builderPagesFormPlace").load("/_builder/pages/editform.html"+((a!=undefined)?("?id="+a):""),function(){this.bindChange()});$("#builderPagesListPlace li").removeClass("active");if(typeof(load)!=undefined){$('#builderPagesListPlace li[data-id="'+a+'"]').addClass("active")}},deletePage:function(a){if(confirm("Вы уверенны что хотите удалить эту страницу?")){$.ajax({url:"/_builder/pages/delete.html?id="+a,success:$.proxy(function(){var b=($.builder.page_id!=a)?$.builder.page_id:$("#builderPagesListPlace li:first-child").data("id");if(a==$.builder.page_id){this.pageDeleted=true}this.changed=true;this.showEditForm(b);$("#builderPagesListPlace").load("/_builder/pages/pageslist.html?id="+b)},this)})}},save:function(){this.changed=true;$("#builderPageForm").ajaxSubmit({success:$.proxy(function(b){if(b.substr(0,2)=="ok"){var a=b.split(":");var c=a[1];$("#builderPagesListPlace").load("/_builder/pages/pageslist.html?id="+c);$("#builderPagesForm input[data-action=save]").attr("disabled","on");$("#builderPagesFormPlace .error").removeClass("error")}else{$("#builderPagesFormPlace").html(b);this.bindChange()}},this)})}};