builder.js.map 224 KB
Newer Older
1
{"version":3,"names":[],"mappings":"","sources":["main.js"],"sourcesContent":["!function(){var e,t,n;!function(i){function r(e,t){return b.call(e,t)}function a(e,t){var n,i,r,a,l,s,o,c,d,u,h,g=t&&t.split(\"/\"),p=v.map,f=p&&p[\"*\"]||{};if(e&&\".\"===e.charAt(0))if(t){for(e=e.split(\"/\"),l=e.length-1,v.nodeIdCompat&&j.test(e[l])&&(e[l]=e[l].replace(j,\"\")),e=g.slice(0,g.length-1).concat(e),d=0;d<e.length;d+=1)if(\".\"===(h=e[d]))e.splice(d,1),d-=1;else if(\"..\"===h){if(1===d&&(\"..\"===e[2]||\"..\"===e[0]))break;d>0&&(e.splice(d-1,2),d-=2)}e=e.join(\"/\")}else 0===e.indexOf(\"./\")&&(e=e.substring(2));if((g||f)&&p){for(n=e.split(\"/\"),d=n.length;d>0;d-=1){if(i=n.slice(0,d).join(\"/\"),g)for(u=g.length;u>0;u-=1)if((r=p[g.slice(0,u).join(\"/\")])&&(r=r[i])){a=r,s=d;break}if(a)break;!o&&f&&f[i]&&(o=f[i],c=d)}!a&&o&&(a=o,s=c),a&&(n.splice(0,s,a),e=n.join(\"/\"))}return e}function l(e,t){return function(){var n=C.call(arguments,0);return\"string\"!=typeof n[0]&&1===n.length&&n.push(null),g.apply(i,n.concat([e,t]))}}function s(e){return function(t){return a(t,e)}}function o(e){return function(t){m[e]=t}}function c(e){if(r(y,e)){var t=y[e];delete y[e],w[e]=!0,h.apply(i,t)}if(!r(m,e)&&!r(w,e))throw new Error(\"No \"+e);return m[e]}function d(e){var t,n=e?e.indexOf(\"!\"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function u(e){return function(){return v&&v.config&&v.config[e]||{}}}var h,g,p,f,m={},y={},v={},w={},b=Object.prototype.hasOwnProperty,C=[].slice,j=/\\.js$/;p=function(e,t){var n,i=d(e),r=i[0];return e=i[1],r&&(r=a(r,t),n=c(r)),r?e=n&&n.normalize?n.normalize(e,s(t)):a(e,t):(e=a(e,t),i=d(e),r=i[0],e=i[1],r&&(n=c(r))),{f:r?r+\"!\"+e:e,n:e,pr:r,p:n}},f={require:function(e){return l(e)},exports:function(e){var t=m[e];return void 0!==t?t:m[e]={}},module:function(e){return{id:e,uri:\"\",exports:m[e],config:u(e)}}},h=function(e,t,n,a){var s,d,u,h,g,v,b=[],C=typeof n;if(a=a||e,\"undefined\"===C||\"function\"===C){for(t=!t.length&&n.length?[\"require\",\"exports\",\"module\"]:t,g=0;g<t.length;g+=1)if(h=p(t[g],a),\"require\"===(d=h.f))b[g]=f.require(e);else if(\"exports\"===d)b[g]=f.exports(e),v=!0;else if(\"module\"===d)s=b[g]=f.module(e);else if(r(m,d)||r(y,d)||r(w,d))b[g]=c(d);else{if(!h.p)throw new Error(e+\" missing \"+d);h.p.load(h.n,l(a,!0),o(d),{}),b[g]=m[d]}u=n?n.apply(m[e],b):void 0,e&&(s&&s.exports!==i&&s.exports!==m[e]?m[e]=s.exports:u===i&&v||(m[e]=u))}else e&&(m[e]=n)},e=t=g=function(e,t,n,r,a){if(\"string\"==typeof e)return f[e]?f[e](t):c(p(e,t).f);if(!e.splice){if(v=e,v.deps&&g(v.deps,v.callback),!t)return;t.splice?(e=t,t=n,n=null):e=i}return t=t||function(){},\"function\"==typeof n&&(n=r,r=a),r?h(i,e,t,n):setTimeout(function(){h(i,e,t,n)},4),g},g.config=function(e){return g(e)},e._defined=m,n=function(e,t,n){if(\"string\"!=typeof e)throw new Error(\"See almond README: incorrect module build, no module name\");t.splice||(n=t,t=[]),r(m,e)||r(y,e)||(y[e]=[e,t,n])},n.amd={jQuery:!0}}(),n(\"../lib/almond\",function(){}),n(\"views/app/menuItem\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-app-menu-item\",initialize:function(){this.listenTo(i.channel(\"app\"),\"change:currentDomain\",this.render),this.model.on(\"change\",this.render,this)},onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el)},events:{\"click a\":\"clickAppMenu\"},clickAppMenu:function(e){i.channel(\"app\").trigger(\"click:menu\",e,this.model)},templateHelpers:function(){return{renderDashicons:function(){if(!this.dashicons)return\"\";var e=document.createElement(\"span\");return e.classList.add(\"dashicons\"),e.classList.add(this.dashicons),e.outerHTML},renderClasses:function(){var e=this.classes;return i.channel(\"app\").request(\"get:currentDomain\").get(\"id\")==this.id&&(e+=\" active\"),e},renderUrl:function(){if(\"\"!=this.url){var e=i.channel(\"app\").request(\"get:formModel\");return this.url+e.get(\"id\")}return\"#\"},renderTarget:function(){return\"\"!=this.url?\"_blank\":\"_self\"},renderDisabled:function(){return this.disabled?\"disabled\":\"\"}}}})}),n(\"views/app/menu\",[\"views/app/menuItem\"],function(e){return Marionette.CollectionView.extend({tagName:\"div\",childView:e,onShow:function(){jQuery(this.el).find(\"li:last\").unwrap()}})}),n(\"views/app/menuButtons\",[],function(){return Marionette.ItemView.extend({tagName:\"span\",template:\"#tmpl-nf-app-header-action-button\",initialize:function(){this.listenTo(i.channel(\"app\"),\"change:clean\",this.render,this),this.listenTo(i.channel(\"app\"),\"change:loading\",this.render,this),this.listenTo(i.channel(\"app\"),\"response:updateDB\",this.bounceIcon,this)},templateHelpers:function(){var e=this;return{renderPublish:function(){if(e.publishWidth?this.publishWidth=e.publishWidth+\"px\":this.publishWidth=\"auto\",i.channel(\"app\").request(\"get:setting\",\"loading\"))var t=i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-add-header-publish-loading\");else var t=i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-app-header-publish-button\");return t(this)},maybeDisabled:function(){return i.channel(\"app\").request(\"get:setting\",\"clean\")?\"disabled\":\"\"},maybeRenderCancel:function(){return\"\"},renderPublicLink:function(){var e=Backbone.Radio.channel(\"app\").request(\"get:formModel\");if(!isNaN(e.get(\"id\"))){return i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-app-header-public-link\")(this)}}}},onShow:function(){jQuery(this.el).find(\".publish\")},events:{\"click .publish\":\"clickPublish\",\"click .viewChanges\":\"clickViewChanges\",\"click .publicLink\":\"clickPublicLink\"},clickPublish:function(e){i.channel(\"app\").trigger(\"click:publish\",e)},clickViewChanges:function(e){i.channel(\"app\").trigger(\"click:viewChanges\",e)},clickPublicLink:function(e){i.channel(\"app\").trigger(\"click:publicLink\",e)},bounceIcon:function(e){jQuery(this.el).find(\".dashicons-backup\").effect(\"bounce\",{times:3},600)}})}),n(\"views/app/mobileMenuButton\",[],function(){return Marionette.ItemView.extend({tagName:\"span\",template:\"#tmpl-nf-mobile-menu-button\",initialize:function(){this.listenTo(i.channel(\"app\"),\"change:clean\",this.render,this)},templateHelpers:function(){return{maybeDisabled:function(){return i.channel(\"app\").request(\"get:setting\",\"clean\")?\"disabled\":\"\"}}},events:{\"click .nf-mobile-menu\":\"clickMobileMenu\"},clickMobileMenu:function(e){var t=i.channel(\"app\").request(\"get:builderEl\");jQuery(t).toggleClass(\"nf-menu-expand\")}})}),n(\"views/app/header\",[\"views/app/menu\",\"views/app/menuButtons\",\"views/app/mobileMenuButton\"],function(e,t,n){return Marionette.LayoutView.extend({tagName:\"div\",template:\"#tmpl-nf-app-header\",regions:{menu:\".nf-app-menu\",buttons:\".nf-app-buttons\",mobileMenuButton:\".nf-mobile-menu-button\"},onRender:function(){var r=i.channel(\"app\").request(\"get:domainCollection\");this.menu.show(new e({collection:r})),this.buttons.show(new t),this.mobileMenuButton.show(new n)},events:{\"click #nf-logo\":\"clickLogo\"},clickLogo:function(e){}})}),n(\"views/app/subHeader\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-sub-header\"})}),n(\"views/app/builderHeader\",[\"views/app/header\",\"views/app/subHeader\"],function(e,t){return Marionette.LayoutView.extend({tagName:\"div\",template:\"#tmpl-nf-header\",regions:{app:\"#nf-app-header\",formTitle:\"#nf-app-form-title\",appSub:\"#nf-app-sub-header\"},initialize:function(){this.listenTo(i.channel(\"app\"),\"change:currentDomain\",this.changeSubHeader)},onShow:function(){this.app.show(new e);var t=i.channel(\"app\").request(\"get:formModel\"),n=t.get(\"settings\"),r=i.channel(\"views\").request(\"get:formTitle\");this.formTitle.show(new r({model:n})),this.changeSubHeader()},changeSubHeader:function(){var e=i.channel(\"app\").request(\"get:currentDomain\"),t=e.get(\"getSubHeaderView\").call(e);this.appSub.show(t)}})}),n(\"views/app/main\",[],function(){return Marionette.LayoutView.extend({tagName:\"div\",template:\"#tmpl-nf-main\",className:\"nf-main-test\",maybeDone:!1,offsetRight:!1,offsetLeft:!1,regions:{gutterLeft:\"#nf-main-gutter-left\",body:\"#nf-main-body\",gutterRight:\"#nf-main-gutter-right\"},initialize:function(){this.listenTo(i.channel(\"app\"),\"change:currentDomain\",this.render),i.channel(\"app\").reply(\"get:mainEl\",this.getMainEl,this),jQuery(window).on(\"resize\",{context:this},this.resizeBothGutters),this.listenTo(i.channel(\"drawer\"),\"before:open\",this.setBothGuttersAbsolute),this.listenTo(i.channel(\"drawer\"),\"opened\",this.setBothGuttersFixed),this.listenTo(i.channel(\"drawer\"),\"before:close\",this.setBothGuttersAbsolute),this.listenTo(i.channel(\"drawer\"),\"closed\",this.setBothGuttersFixed),this.listenTo(i.channel(\"app\"),\"change:currentDomain\",function(){setTimeout(function(){i.channel(\"app\").request(\"update:gutters\")},300,this)},this),i.channel(\"app\").reply(\"update:gutters\",this.updateGutters,this)},onShow:function(){i.channel(\"main\").trigger(\"show:main\",this)},onRender:function(){var e=i.channel(\"app\").request(\"get:currentDomain\"),t=e.get(\"getMainContentView\").call(e);this.body.show(t);var n=e.get(\"getGutterLeftView\").call(e);this.gutterLeft.show(n);var r=e.get(\"getGutterRightView\").call(e);this.gutterRight.show(r),i.channel(\"main\").trigger(\"render:main\")},getMainEl:function(){return jQuery(this.el).parent()},onAttach:function(){this.initialGutterResize()},onBeforeDestroy:function(){jQuery(window).off(\"resize\",this.resize)},initialGutterResize:function(){this.resizeGutter(this.gutterLeft.el),this.resizeGutter(this.gutterRight.el),this.setBothGuttersFixed(this)},resizeBothGutters:function(e){var t=e?e.data.context:this,n=t.gutterLeft.el,i=t.gutterRight.el;t.resizeGutter(n,t),t.resizeGutter(i,t),t.setBothGuttersAbsolute(t),clearTimeout(t.maybeDone),t.maybeDone=setTimeout(t.setBothGuttersFixed,100,t)},resizeGutter:function(e,t){var n=jQuery(e).offset().top,i=jQuery(window).height(),r=i-n;jQuery(e).height(r)},setBothGuttersFixed:function(e){e=e||this;var t=jQuery(e.gutterLeft.el).offset(),n=t.top,i=t.left;jQuery(e.gutterLeft.el).css({position:\"fixed\",left:i,top:n});var t=jQuery(e.gutterLeft.el).offset(),r=jQuery(e.gutterRight.el).offset(),a=r.top,l=r.left;jQuery(e.gutterRight.el).css({position:\"fixed\",left:l,top:a})},setBothGuttersAbsolute:function(e){e=e||this;var t=(jQuery(e.gutterLeft.el).offset(),jQuery(e.gutterRight.el).offset(),jQuery(\"#nf-main\").scrollTop());jQuery(e.gutterLeft.el).css({position:\"absolute\",left:0,top:t}),jQuery(e.gutterRight.el).css({position:\"absolute\",top:t,right:0,left:\"auto\"})},updateGutters:function(){this.resizeBothGutters()}})}),n(\"views/app/mobileMenuItem\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-mobile-menu-item\",onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el)},events:{\"click a\":\"clickAppMenu\"},clickAppMenu:function(e){i.channel(\"app\").trigger(\"click:menu\",e,this.model)},templateHelpers:function(){return{renderDashicons:function(){if(!this.mobileDashicon)return\"\";var e=document.createElement(\"span\");return e.classList.add(\"dashicons\"),e.classList.add(this.mobileDashicon),e.outerHTML},renderClasses:function(){var e=this.classes;return i.channel(\"app\").request(\"get:currentDomain\").get(\"id\")==this.id&&(e+=\" active\"),e},renderUrl:function(){if(\"\"!=this.url){var e=i.channel(\"app\").request(\"get:formModel\");return this.url+e.get(\"id\")}return\"#\"},renderTarget:function(){return\"\"!=this.url?\"_blank\":\"_self\"},renderDisabled:function(){return this.disabled?\"disabled\":\"\"}}}})}),n(\"views/app/mobileMenu\",[\"views/app/mobileMenuItem\"],function(e){return Marionette.CompositeView.extend({tagName:\"div\",template:\"#tmpl-nf-mobile-menu\",childView:e,initialize:function(){this.listenTo(i.channel(\"app\"),\"change:clean\",this.render,this)},attachHtml:function(e,t){jQuery(e.el).find(\".secondary\").append(t.el)},templateHelpers:function(){return{maybeDisabled:function(){return i.channel(\"app\").request(\"get:setting\",\"clean\")?\"disabled\":\"\"}}},events:{\"click .nf-publish\":\"clickPublish\"},clickPublish:function(e){i.channel(\"app\").trigger(\"click:publish\",e);var t=i.channel(\"app\").request(\"get:builderEl\");jQuery(t).toggleClass(\"nf-menu-expand\")}})}),n(\"views/app/drawer/contentEmpty\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-empty\"})}),n(\"views/app/drawer\",[\"views/app/drawer/contentEmpty\"],function(e){return Marionette.LayoutView.extend({template:\"#tmpl-nf-drawer\",regions:{header:\"#nf-drawer-header\",content:\"#nf-drawer-content\",footer:\"#nf-drawer-footer\"},initialize:function(){i.channel(\"app\").reply(\"get:drawerEl\",this.getEl,this),i.channel(\"drawer\").reply(\"load:drawerContent\",this.loadContent,this),i.channel(\"drawer\").reply(\"empty:drawerContent\",this.emptyContent,this)},onShow:function(){jQuery(this.el).parent().perfectScrollbar()},loadContent:function(e,t){var n=i.channel(\"app\").request(\"get:drawer\",e),r=n.get(\"getContentView\").call(n,t),a=n.get(\"getHeaderView\").call(n,t),l=n.get(\"getFooterView\").call(n,t);this.header.show(a),this.content.show(r),this.footer.show(l)},emptyContent:function(){this.header.empty(),this.content.empty(),this.footer.empty()},getEl:function(){return jQuery(this.el).parent()},events:{\"click .nf-toggle-drawer\":\"clickToggleDrawer\"},clickToggleDrawer:function(){i.channel(\"app\").trigger(\"click:toggleDrawerSize\")}})}),n(\"views/app/drawer/mergeTagItem\",[],function(){return Marionette.ItemView.extend({tagName:\"li\",template:\"#tmpl-nf-merge-tags-item\",onBeforeDestroy:function(){this.model.off(\"change:active\",this.render)},initialize:function(){this.model.on(\"change:active\",this.render,this)},events:{\"click a\":\"clickTag\"},clickTag:function(e){i.channel(\"mergeTags\").trigger(\"click:mergeTag\",e,this.model)},templateHelpers:function(){return{renderClasses:function(){if(this.active)return\"active\"}}}})}),n(\"views/app/drawer/mergeTagsSection\",[\"views/app/drawer/mergeTagItem\"],function(e){return Marionette.CompositeView.extend({tagName:\"div\",childView:e,template:\"#tmpl-nf-merge-tags-section\",initialize:function(){this.collection=this.model.get(\"tags\"),this.model.on(\"change\",this.render,this),this.model.get(\"id\")},onBeforeDestroy:function(){if(this.model.off(\"change\",this.render),\"fields\"==this.model.get(\"id\")){i.channel(\"fields\").request(\"get:collection\").off(\"all\",this.updateFields,this)}},attachHtml:function(e,t){jQuery(e.el).find(\".merge-tags\").append(t.el)},updateFields:function(){var e=i.channel(\"fields\").request(\"get:collection\");this.model.set(\"tags\",e)}})}),n(\"models/app/mergeTagModel\",[],function(){return Backbone.Model.extend({defaults:{active:!1,exclude:!1}})}),n(\"models/app/mergeTagCollection\",[\"models/app/mergeTagModel\"],function(e){return Backbone.Collection.extend({model:e})}),n(\"views/app/drawer/mergeTagsContent\",[\"views/app/drawer/mergeTagsSection\",\"models/app/mergeTagCollection\"],function(e,t){return Marionette.CollectionView.extend({tagName:\"div\",template:\"#tmpl-nf-merge-tags-content\",childView:e,initialize:function(){i.channel(\"mergeTags\").reply(\"get:view\",this.getMergeTagsView,this)},reRender:function(e){var n=i.channel(\"mergeTags\").request(\"get:collection\"),r=n.where({default_group:!0});if(\"actions\"==i.channel(\"app\").request(\"get:currentDomain\").get(\"id\")){var a=n.where({id:\"calcs\"});r=r.concat(a)}this.collection=new t(r);var l=this,s=e.get(\"use_merge_tags\");\"object\"==typeof s&&(void 0!==s.exclude&&_.each(s.exclude,function(e){l.collection.remove(e)}),void 0!==s.include&&_.each(n.models,function(e){-1!=s.include.indexOf(e.get(\"id\"))&&l.collection.add(e)})),this.render()},getMergeTagsView:function(){return this}})}),n(\"views/app/builder\",[\"views/app/builderHeader\",\"views/app/main\",\"views/app/mobileMenu\",\"views/app/drawer\",\"views/app/drawer/mergeTagsContent\"],function(e,t,n,r,a){return Marionette.LayoutView.extend({template:\"#tmpl-nf-builder\",el:\"#nf-builder\",regions:{header:\"#nf-header\",main:\"#nf-main\",menuDrawer:\"#nf-menu-drawer\",drawer:\"#nf-drawer\",mergeTagsContent:\".merge-tags-content\"},initialize:function(){i.channel(\"app\").reply(\"get:builderEl\",this.getBuilderEl,this),i.channel(\"app\").reply(\"get:builderView\",this.getBuilderView,this),this.render();var l=i.channel(\"mergeTags\").request(\"get:collection\"),s=l.clone();this.mergeTagsContent.show(new a({collection:s})),this.header.show(new e),this.main.show(new t);var o=i.channel(\"app\").request(\"get:domainCollection\");this.menuDrawer.show(new n({collection:o})),this.drawer.show(new r)},onRender:function(){},getBuilderEl:function(){return this.el},getBuilderView:function(){return this},events:{\"click .nf-open-drawer\":\"openDrawer\",\"click .nf-change-domain\":\"changeDomain\",\"click .nf-close-drawer\":\"closeDrawer\"},openDrawer:function(e){i.channel(\"app\").trigger(\"click:openDrawer\",e)},closeDrawer:function(){i.channel(\"app\").trigger(\"click:closeDrawer\")},changeDomain:function(e){i.channel(\"app\").trigger(\"click:menu\",e)}})}),n(\"controllers/app/remote\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"setting\"),\"remote\",this.addListener)},addListener:function(e,t){var n=e.get(\"remote\").listen;this.listenTo(i.channel(\"fieldSetting-\"+n),\"update:setting\",this.updateSetting),this.listenTo(i.channel(\"actionSetting-\"+n),\"update:setting\",this.updateSetting),this.listenTo(i.channel(\"setting-type-\"+e.get(\"type\")),\"click:extra\",this.clickExtra),e.listenTo(i.channel(\"setting-remote\"),\"get:remote\",this.getRemote,e),i.channel(\"setting-remote\").trigger(\"get:remote\",t)},clickExtra:function(e,t,n,r){jQuery(e.srcElement).addClass(\"spin\"),i.channel(\"setting-remote\").trigger(\"get:remote\",n)},updateSetting:function(e,t){i.channel(\"setting-remote\").trigger(\"get:remote\",e)},getRemote:function(e){var t=this.get(\"remote\"),n={parentValue:e.get(t.listen),action:t.action,security:t.security?t.security:nfAdmin.ajaxNonce},i=this;jQuery.post(ajaxurl,n,function(t){var t=JSON.parse(t);\"textbox\"==i.get(\"type\")&&e.set(i.get(\"name\"),t.value),\"select\"==i.get(\"type\")&&(i.set(\"options\",t.options),i.trigger(\"rerender\"))})}})}),n(\"controllers/app/drawer\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"click:openDrawer\",this.clickOpenDrawer),this.listenTo(i.channel(\"app\"),\"click:closeDrawer\",this.closeDrawer),this.listenTo(i.channel(\"app\"),\"click:toggleDrawerSize\",this.toggleDrawerSize),i.channel(\"app\").reply(\"open:drawer\",this.openDrawer,this),i.channel(\"app\").reply(\"close:drawer\",this.closeDrawer,this),i.channel(\"drawer\").reply(\"get:closedRightPos\",this.getClosedDrawerPos,this),i.channel(\"drawer\").reply(\"prevent:close\",this.preventClose,this),i.channel(\"drawer\").reply(\"enable:close\",this.enableClose,this),i.channel(\"drawer\").reply(\"get:preventClose\",this.maybePreventClose,this),this.objPreventClose={},this.listenTo(i.channel(\"drawer\"),\"filter:focused\",this.filterFocused)},closeDrawer:function(){var e=i.channel(\"app\").request(\"get:currentDrawer\");if(!e||this.maybePreventClose())return!1;i.channel(\"drawer-\"+e.get(\"id\")).trigger(\"before:closeDrawer\"),i.channel(\"drawer\").trigger(\"before:closeDrawer\"),i.channel(\"drawer\").trigger(\"before:close\"),i.channel(\"drawer\").request(\"empty:drawerContent\");var t=i.channel(\"app\").request(\"get:builderEl\");jQuery(t).addClass(\"nf-drawer-closed\").removeClass(\"nf-drawer-opened\"),jQuery(t).removeClass(\"disable-main\");var n=this.getClosedDrawerPos(),r=i.channel(\"app\").request(\"get:drawerEl\");jQuery(r).css({right:n});var a=this;this.checkCloseDrawerPos=setInterval(function(){n==jQuery(r).css(\"right\")&&(clearInterval(a.checkCloseDrawerPos),i.channel(\"app\").request(\"update:currentDrawer\",!1),i.channel(\"drawer\").trigger(\"closed\"),jQuery(\".nf-master-control\").css(\"z-index\",98))},150)},clickOpenDrawer:function(e){var t=jQuery(e.target).data(\"drawerid\");this.openDrawer(t)},openDrawer:function(e,t){if(this.maybePreventClose())return!1;if(t=t||{},void 0!==t.model){var n=i.channel(\"app\").request(\"get:currentDomain\"),r=n.get(\"id\");i.channel(r).request(\"clear:editActive\"),t.model.set(\"editActive\",!0),this.dataModel=t.model}i.channel(\"drawer\").request(\"load:drawerContent\",e,t),i.channel(\"drawer\").trigger(\"before:open\");var a=i.channel(\"app\").request(\"get:builderEl\");jQuery(a).addClass(\"nf-drawer-opened\").removeClass(\"nf-drawer-closed\");var l=i.channel(\"app\").request(\"get:drawerEl\");jQuery(l).css({right:\"0px\"});var s=this;this.hasFocus=!1,jQuery(\".nf-master-control\").css(\"z-index\",0),this.checkOpenDrawerPos=setInterval(function(){\"0px\"==jQuery(l).css(\"right\")&&(clearInterval(s.checkOpenDrawerPos),s.hasFocus||(s.focusFilter(),s.hasFocus=!0,i.channel(\"app\").request(\"update:currentDrawer\",e),jQuery(l).scrollTop(0),i.channel(\"drawer\").trigger(\"opened\")))},150)},toggleDrawerSize:function(){var e=i.channel(\"app\").request(\"get:drawerEl\");jQuery(e).toggleClass(\"nf-drawer-expand\")},focusFilter:function(){var e=i.channel(\"drawer\").request(\"get:filterEl\");jQuery(e).focus()},getClosedDrawerPos:function(){var e=i.channel(\"app\").request(\"get:builderEl\");return\"-\"+(jQuery(e).width()+300)+\"px\"},maybePreventClose:function(){return 0!=Object.keys(this.objPreventClose).length},preventClose:function(e){this.objPreventClose[e]=!0,this.dataModel.set(\"drawerDisabled\",!0)},enableClose:function(e){delete this.objPreventClose[e],this.maybePreventClose()||void 0===this.dataModel||this.dataModel.set(\"drawerDisabled\",!1)},filterFocused:function(){clearInterval(this.checkOpenDrawerPos)},getPreventClose:function(){return this.objPreventClose}})}),n(\"views/app/drawer/headerDefault\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-header-default\",initialize:function(){this.model&&this.model.on(\"change:drawerDisabled\",this.render,this)},onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el),i.channel(\"drawer\").reply(\"clear:filter\",this.clearFilter,this),i.channel(\"drawer\").reply(\"blur:filter\",this.blurFilter,this),i.channel(\"drawer\").reply(\"get:filterEl\",this.getEl,this)},onBeforeDestroy:function(){this.model&&this.model.off(\"change:drawerDisabled\",this.render)},events:{\"keyup .nf-filter\":\"maybeChangeFilter\",\"input .nf-filter\":\"changeFilter\",\"focus input\":\"getFocus\"},changeFilter:function(e){var t=i.channel(\"app\").request(\"get:currentDrawer\");i.channel(\"drawer-\"+t.get(\"id\")).trigger(\"change:filter\",e.target.value,e)},maybeChangeFilter:function(e){13==e.keyCode&&(e.addObject=!0,this.changeFilter(e))},clearFilter:function(){var e=jQuery(this.el).find(\".nf-filter\");\"\"!=jQuery.trim(e.val())&&(e.val(\"\"),e.trigger(\"input\"),e.focus())},blurFilter:function(){jQuery(this.el).find(\".nf-filter\").blur()},getEl:function(){return jQuery(this.el).find(\".nf-filter\")},getFocus:function(){i.channel(\"drawer\").trigger(\"filter:focused\")},templateHelpers:function(){return{renderDisabled:function(){return this.drawerDisabled?\"disabled\":\"\"}}}})}),n(\"views/app/drawer/footerDefault\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-empty\"})}),n(\"models/app/drawerModel\",[\"views/app/drawer/headerDefault\",\"views/app/drawer/footerDefault\"],function(e,t){return Backbone.Model.extend({defaults:{getHeaderView:function(t){return new e(t)},getFooterView:function(e){return new t(e)}}})}),n(\"models/app/drawerCollection\",[\"models/app/drawerModel\"],function(e){return Backbone.Collection.extend({model:e})}),n(\"views/fields/drawer/stagedField\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-staged-field\",onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el)},events:{\"click .dashicons-dismiss\":\"removeStagedField\"},removeStagedField:function(e){i.channel(\"drawer-addField\").trigger(\"click:removeStagedField\",e,this.model)}})}),n(\"views/fields/drawer/stagingEmpty\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-staged-fields-empty\",onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el)}})}),n(\"views/fields/drawer/stagingCollection\",[\"views/fields/drawer/stagedField\",\"views/fields/drawer/stagingEmpty\"],function(e,t){return Marionette.CollectionView.extend({tagName:\"div\",childView:e,emptyView:t,activeClass:\"nf-staged-fields-active\",initialize:function(){i.channel(\"app\").reply(\"get:stagedFieldsEl\",this.getStagedFieldsEl,this)},onShow:function(){this.$el=jQuery(this.el).parent(),jQuery(this.$el).find(\"span:first\").unwrap(),this.setElement(this.$el);jQuery(this.el).sortable({placeholder:\"nf-staged-fields-sortable-placeholder\",helper:\"clone\",tolerance:\"pointer\",over:function(e,t){i.channel(\"drawer-addField\").trigger(\"over:stagedFields\",e,t)},out:function(e,t){i.channel(\"drawer-addField\").trigger(\"out:stagedFields\",t)},receive:function(e,t){i.channel(\"drawer-addField\").trigger(\"receive:stagedFields\",t)},update:function(e,t){i.channel(\"fields\").request(\"sort:staging\")},start:function(e,t){i.channel(\"drawer-addField\").trigger(\"start:stagedFields\",t)},stop:function(e,t){i.channel(\"drawer-addField\").trigger(\"stop:stagedFields\",t)}}),jQuery(this.el).parent().draggable({opacity:.9,connectToSortable:\".nf-field-type-droppable\",appendTo:\"#nf-main\",refreshPositions:!0,grid:[3,3],tolerance:\"pointer\",helper:function(e){var t=jQuery(e.target).parent().width(),n=jQuery(e.target).parent().height(),i=jQuery(e.target).parent().clone(),r=t/4,a=n/2;return jQuery(this).draggable(\"option\",\"cursorAt\",{top:a,left:r}),jQuery(i).zIndex(1e3),i},start:function(e,t){i.channel(\"drawer-addField\").trigger(\"startDrag:fieldStaging\",this,t)},stop:function(e,t){i.channel(\"drawer-addField\").trigger(\"stopDrag:fieldStaging\",this,t)}})},getStagedFieldsEl:function(){return jQuery(this.el)},onAddChild:function(){jQuery(this.el).addClass(this.activeClass)},onRemoveChild:function(){this.hasStagedFields()||jQuery(this.el).removeClass(this.activeClass)},hasStagedFields:function(){return 0!=this.collection.length}})}),n(\"models/fields/stagingModel\",[],function(){return Backbone.Model.extend({})}),n(\"models/fields/stagingCollection\",[\"models/fields/stagingModel\"],function(e){return Backbone.Collection.extend({model:e,comparator:\"order\"})}),n(\"views/fields/drawer/typeSection\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-field-type-section\",initialize:function(){_.bindAll(this,\"render\"),i.channel(\"fields\").reply(\"get:typeSection\",this.getTypeSection,this)},onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el),this.dragging=!1;var e=this;i.channel(\"app\").request(\"is:mobile\")||(jQuery(this.el).find(\"div.nf-field-type-draggable\").draggable({opacity:.9,tolerance:\"pointer\",connectToSortable:\".nf-field-type-droppable\",refreshPositions:!0,grid:[5,5],appendTo:\"#nf-builder\",helper:function(e){var t=jQuery(e.target).parent().width(),n=jQuery(e.target).parent().height(),i=jQuery(e.target).parent().clone(),r=t/4,a=n/2;return jQuery(this).draggable(\"option\",\"cursorAt\",{top:a,left:r}),jQuery(i).zIndex(1e3),i},start:function(t,n){e.dragging=!0,i.channel(\"drawer-addField\").trigger(\"startDrag:type\",this,n)},stop:function(t,n){e.dragging=!1,i.channel(\"drawer-addField\").trigger(\"stopDrag:type\",this,n)},drag:function(e,t){i.channel(\"drawer-addField\").trigger(\"drag:type\",this,t,e)}}).disableSelection(),jQuery(this.el).find(\".nf-item\").focus(function(){jQuery(this).addClass(\"active\")}).blur(function(){jQuery(this).removeClass(\"active\")}))},events:{\"click .nf-item\":\"clickFieldType\",\"keydown .nf-item\":\"maybeClickFieldType\",\"mousedown .nf-item\":\"mousedownFieldType\"},clickFieldType:function(e){this.dragging||i.channel(\"drawer\").trigger(\"click:fieldType\",e)},mousedownFieldType:function(e){jQuery(e.target).addClass(\"clicked\"),setTimeout(function(){jQuery(e.target).removeClass(\"clicked\")},1500)},maybeClickFieldType:function(e){13==e.keyCode&&(this.clickFieldType(e),i.channel(\"drawer\").request(\"clear:filter\"))},templateHelpers:function(){return{renderFieldTypes:function(){var e=document.createElement(\"span\"),t=this;return _.each(this.fieldTypes,function(n){var r=i.channel(\"fields\").request(\"get:type\",n),a=r.get(\"nicename\"),l=r.get(\"icon\"),s=i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-drawer-field-type-button\"),o=s({id:n,nicename:a,icon:l,type:r,savedField:t.savedField}),c=document.createRange().createContextualFragment(o);e.appendChild(c)}),e.innerHTML},savedField:function(){return this.type.get(\"savedField\")?\"nf-saved\":\"\"}}},getTypeSection:function(){return this.el}})}),n(\"views/fields/drawer/typeSectionCollection\",[\"views/fields/drawer/typeSection\"],function(e){return Marionette.CollectionView.extend({tagName:\"div\",childView:e,onShow:function(){jQuery(this.el).find(\".nf-settings\").unwrap(),i.channel(\"fields\").request(\"clear:editActive\")}})}),n(\"views/fields/drawer/addField\",[\"views/fields/drawer/stagingCollection\",\"models/fields/stagingCollection\",\"views/fields/drawer/typeSectionCollection\"],function(e,t,n){return Marionette.LayoutView.extend({template:\"#tmpl-nf-drawer-content-add-field\",regions:{staging:\"#nf-drawer-staging .nf-reservoir\",primary:\"#nf-drawer-primary\",secondary:\"#nf-drawer-secondary\"},initialize:function(){this.listenTo(i.channel(\"drawer\"),\"filter:fieldTypes\",this.filterFieldTypes),this.listenTo(i.channel(\"drawer\"),\"clear:filter\",this.removeFieldTypeFilter),this.savedCollection=i.channel(\"fields\").request(\"get:savedFields\"),this.primaryCollection=this.savedCollection,this.fieldTypeSectionCollection=i.channel(\"fields\").request(\"get:typeSections\"),this.secondaryCollection=this.fieldTypeSectionCollection},onShow:function(){var t=i.channel(\"fields\").request(\"get:staging\");this.staging.show(new e({collection:t})),this.primary.show(new n({collection:this.primaryCollection})),this.secondary.show(new n({collection:this.secondaryCollection}))},getEl:function(){return jQuery(this.el).parent()},filterFieldTypes:function(e){this.primary.reset(),this.secondary.reset(),this.filteredSectionCollection=e,this.primary.show(new n({collection:this.filteredSectionCollection}))},removeFieldTypeFilter:function(){this.primary.show(new n({collection:this.savedCollection})),this.secondary.show(new n({collection:this.fieldTypeSectionCollection}))}})}),n(\"views/app/drawer/itemSettingCollection\",[],function(){return Marionette.CollectionView.extend({tagName:\"div\",initialize:function(e){this.childViewOptions={dataModel:e.dataModel}},getChildView:function(e){return i.channel(\"app\").request(\"get:settingChildView\",e)}})}),n(\"views/app/drawer/itemSettingGroup\",[\"views/app/drawer/itemSettingCollection\"],function(e){return Marionette.LayoutView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-content-edit-field-setting-group\",regions:{settings:\".nf-field-settings\"},initialize:function(e){this.model.on(\"change\",this.render,this),this.dataModel=e.dataModel},onBeforeDestroy:function(){this.model.off(\"change\",this.render)},onRender:function(){if(this.settings.show(new e({collection:this.model.get(\"settings\"),dataModel:this.dataModel})),!nfAdmin.devMode&&0==this.$el.find(\".calculations\").length){var t=!1;this.$el.find(\".nf-setting\").each(function(e,n){if(\"none\"!==n.style.display)return t=!0,!1}),t||this.$el.hide()}this.model.get(\"display\")||this.settings.empty(),i.channel(\"drawer\").trigger(\"render:settingGroup\",this)},events:{\"click .toggle\":\"clickToggleGroup\"},clickToggleGroup:function(e){i.channel(\"drawer\").trigger(\"click:toggleSettingGroup\",e,this.model)},templateHelpers:function(){return{renderLabel:function(){if(\"\"!=this.label){return i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-drawer-content-edit-setting-group-label\")(this)}return\"\"},renderArrowDir:function(){return this.display?\"down\":\"right\"}}}})}),n(\"views/app/drawer/itemSettingGroupCollection\",[\"views/app/drawer/itemSettingGroup\"],function(e){return Marionette.CollectionView.extend({tagName:\"div\",childView:e,initialize:function(e){this.childViewOptions={dataModel:e.dataModel}}})}),n(\"views/app/drawer/editSettings\",[\"views/app/drawer/itemSettingGroupCollection\"],function(e){return Marionette.LayoutView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-content-edit-settings\",regions:{settingTitle:\".nf-setting-title\",settingGroups:\".nf-setting-groups\"},initialize:function(e){this.dataModel=e.model,this.groupCollection=e.groupCollection},onRender:function(){var t=i.channel(\"app\").request(\"get:currentDomain\"),n=t.get(\"getSettingsTitleView\").call(t,{model:this.model});this.settingTitle.show(n),\nthis.settingGroups.show(new e({collection:this.groupCollection,dataModel:this.dataModel}))},templateHelpers:function(){return{maybeRenderTitle:function(){if(void 0!==this.type){return i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-drawer-content-edit-settings-title\")(this)}return\"\"},renderTypeNicename:function(){var e=i.channel(\"app\").request(\"get:currentDomain\"),t=e.get(\"id\");return i.channel(t).request(\"get:type\",this.type).get(\"nicename\")}}}})}),n(\"views/app/drawer/headerEditSettings\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-header-edit-settings\",initialize:function(){this.model&&this.model.on(\"change:drawerDisabled\",this.render,this)},onBeforeDestroy:function(){this.model&&this.model.off(\"change:drawerDisabled\",this.render)},templateHelpers:function(){return{renderDisabled:function(){return this.drawerDisabled?\"disabled\":\"\"}}}})}),n(\"views/actions/drawer/typeButton\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-action-type-button\",onRender:function(){if(jQuery(this.el).disableSelection(),\"installed\"==this.model.get(\"section\")){var e=this;jQuery(this.el).draggable({opacity:.9,tolerance:\"intersect\",scroll:!1,helper:\"clone\",start:function(t,n){e.dragging=!0,i.channel(\"drawer-addAction\").trigger(\"startDrag:type\",this,n)},stop:function(t,n){e.dragging=!1,i.channel(\"drawer-addAction\").trigger(\"stopDrag:type\",this,n)}})}},events:{\"click .nf-item\":\"clickAddAction\"},clickAddAction:function(e){if(!this.dragging)if(\"installed\"==this.model.get(\"section\"))i.channel(\"actions\").trigger(\"click:addAction\",this.model);else{var t=this.model.get(\"modal_content\"),n=new jBox(\"Modal\",{content:t,zIndex:99999999,closeButton:\"box\",overlay:!0,width:600,repositionOnOpen:!0,reposition:!0});n.open()}},templateHelpers:function(){return{renderClasses:function(){var e=\"nf-item\";return\"\"!=jQuery.trim(this.image)&&(e+=\" nf-has-img\"),\"installed\"==this.section&&(e+=\" nf-action-type\"),e},renderStyle:function(){return\"\"!=jQuery.trim(this.image)?\"background-image: url('\"+jQuery.trim(this.image)+\"')\":\"\"}}}})}),n(\"views/actions/drawer/typeCollection\",[\"views/actions/drawer/typeButton\"],function(e){return Marionette.CompositeView.extend({template:\"#tmpl-nf-drawer-action-type-section\",childView:e,templateHelpers:function(){var e=this;return{renderNicename:function(){return e.collection.nicename},renderClasses:function(){return e.collection.slug}}},attachHtml:function(e,t){jQuery(e.el).find(\".action-types\").append(t.el)}})}),n(\"views/actions/drawer/addAction\",[\"views/actions/drawer/typeCollection\"],function(e){return Marionette.LayoutView.extend({template:\"#tmpl-nf-drawer-content-add-action\",regions:{primary:\"#nf-drawer-primary\",secondary:\"#nf-drawer-secondary\"},initialize:function(){this.listenTo(i.channel(\"drawer\"),\"filter:actionTypes\",this.filteractionTypes),this.listenTo(i.channel(\"drawer\"),\"clear:filter\",this.removeactionTypeFilter),this.installedActions=i.channel(\"actions\").request(\"get:installedActions\"),this.primaryCollection=this.installedActions,this.availableActions=i.channel(\"actions\").request(\"get:availableActions\"),this.secondaryCollection=this.availableActions},onShow:function(){this.primary.show(new e({collection:this.primaryCollection})),this.secondary.show(new e({collection:this.secondaryCollection}))},getEl:function(){return jQuery(this.el).parent()},filteractionTypes:function(t,n){this.primary.reset(),this.secondary.reset(),this.primary.show(new e({collection:t})),this.secondary.show(new e({collection:n}))},removeactionTypeFilter:function(){this.primary.show(new e({collection:this.installedActions})),this.secondary.show(new e({collection:this.availableActions}))}})}),n(\"views/app/drawer/contentViewChangesItem\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-content-view-changes-item\",initialize:function(){this.model.on(\"change:disabled\",this.render,this)},onBeforeDestroy:function(){this.model.off(\"change:disabled\",this.render)},onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el)},events:{\"click .undoSingle\":\"undoSingle\"},undoSingle:function(e){i.channel(\"drawer\").trigger(\"click:undoSingle\",this.model)}})}),n(\"views/app/drawer/contentViewChanges\",[\"views/app/drawer/contentViewChangesItem\"],function(e){return Marionette.CollectionView.extend({tagName:\"table\",className:\"nf-changes\",childView:e})}),n(\"views/app/drawer/headerViewChanges\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-header-view-changes\",events:{\"click .undoChanges\":\"clickUndoChanges\"},clickUndoChanges:function(e){i.channel(\"drawer\").trigger(\"click:undoChanges\")}})}),n(\"views/app/drawer/settingError\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-edit-setting-error\"})}),n(\"views/app/drawer/itemSetting\",[\"views/app/drawer/mergeTagsContent\",\"views/app/drawer/settingError\"],function(e,t){return Marionette.LayoutView.extend({tagName:\"div\",template:\"#tmpl-nf-edit-setting-wrap\",regions:{error:\".nf-setting-error\"},initialize:function(e){this.dataModel=e.dataModel,void 0!==i.channel(\"setting-type-\"+this.model.get(\"type\")).request(\"renderOnChange\")&&i.channel(\"setting-type-\"+this.model.get(\"type\")).request(\"renderOnChange\")&&this.dataModel.on(\"change:\"+this.model.get(\"name\"),this.render,this),this.model.on(\"change:error\",this.renderError,this),this.model.on(\"change:warning\",this.renderWarning,this);var t=this.model.get(\"deps\");if(t)for(var n in t)t.hasOwnProperty(n)&&this.dataModel.on(\"change:\"+n,this.render,this);var r=this.model.get(\"remote\");if(r){if(void 0!==r.refresh||r.refresh){var a,l,s,o;a=document.createTextNode(this.model.get(\"label\")),l=document.createElement(\"span\"),l.classList.add(\"dashicons\",\"dashicons-update\"),s=document.createElement(\"a\"),s.classList.add(\"extra\"),s.appendChild(l),o=document.createElement(\"span\"),o.appendChild(a),o.appendChild(s),this.model.set(\"label\",o.innerHTML)}i.channel(\"setting\").trigger(\"remote\",this.model,this.dataModel,this),this.model.on(\"rerender\",this.render,this)}this.listenTo(i.channel(\"drawer\"),\"opened\",this.drawerOpened),this.listenTo(i.channel(\"drawer\"),\"closed\",this.drawerClosed)},onBeforeDestroy:function(){this.dataModel.off(\"change:\"+this.model.get(\"name\"),this.render),this.model.off(\"change:error\",this.renderError);var e=this.model.get(\"deps\");if(e)for(var t in e)e.hasOwnProperty(t)&&this.dataModel.off(\"change:\"+t,this.render);if(this.model.get(\"remote\")&&this.model.off(\"rerender\",this.render,this),i.channel(\"setting-\"+this.model.get(\"name\")).trigger(\"destroy:setting\",this.model,this.dataModel,this),i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"destroy:setting\",this.model,this.dataModel,this),\"textbox\"==this.model.get(\"type\")){var n=this.model.get(\"name\"),r=this.dataModel.get(n);this.dataModel.set(n,_.unescape(r),{silent:!0})}},onBeforeRender:function(){if(\"textbox\"==this.model.get(\"type\")){var e=this.model.get(\"name\"),t=this.dataModel.get(e);this.dataModel.set(e,_.escape(t),{silent:!0})}i.channel(\"app\").trigger(\"before:renderSetting\",this.model,this.dataModel),i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"before:renderSetting\",this.model,this.dataModel,this),i.channel(\"setting-\"+this.model.get(\"name\")).trigger(\"before:renderSetting\",this.model,this.dataModel,this)},onRender:function(){this.mergeTagsContentView=!1;i.channel(\"setting-\"+this.model.get(\"name\")).trigger(\"render:setting\",this.model,this.dataModel,this),i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"render:setting\",this.model,this.dataModel,this),jQuery(this.el).find(\".nf-help\").each(function(){var e=jQuery(this).next(\".nf-help-text\");jQuery(this).jBox(\"Tooltip\",{content:e,maxWidth:200,theme:\"TooltipBorder\",trigger:\"click\",closeOnClick:!0})}),this.model.get(\"use_merge_tags\")&&i.channel(\"mergeTags\").request(\"init\",this);var e=this.model.get(\"mask\");if(void 0!==e){var t=jQuery(this.$el).find(\"input\");switch(e.type){case\"numeric\":t.autoNumeric({aSep:thousandsSeparator,aDec:decimalPoint});break;case\"currency\":var n=i.channel(\"settings\").request(\"get:setting\",\"currency\"),r=nfAdmin.currencySymbols[n]||\"\";t.autoNumeric({aSign:jQuery(\"<div />\").html(r).text(),aSep:thousandsSeparator,aDec:decimalPoint});break;case\"custom\":e.format&&t.mask(e.format);break;default:console.log('Notice: Mask type of \"'+e.type+'\" is not supported.')}}this.renderError()},onShow:function(){i.channel(\"setting-\"+this.model.get(\"name\")).trigger(\"show:setting\",this.model,this.dataModel,this),i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"show:setting\",this.model,this.dataModel,this)},onAttach:function(){i.channel(\"setting-\"+this.model.get(\"name\")).trigger(\"attach:setting\",this.model,this.dataModel,this),i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"attach:setting\",this.model,this.dataModel,this)},renderError:function(){this.model.get(\"error\")?(jQuery(this.el).find(\".nf-setting\").addClass(\"nf-error\"),this.error.show(new t({model:this.model}))):(jQuery(this.el).find(\".nf-setting\").removeClass(\"nf-error\"),this.error.empty())},renderWarning:function(){this.model.get(\"warning\")?(jQuery(this.el).find(\".nf-setting\").addClass(\"nf-warning\"),this.error.show(new t({model:this.model}))):(jQuery(this.el).find(\".nf-setting\").removeClass(\"nf-warning\"),this.error.empty())},templateHelpers:function(){var e=this;return{renderVisible:function(){if(!nfAdmin.devMode){if(\"Action\"==e.dataModel.get(\"objectType\")&&\"email\"==e.dataModel.get(\"type\")){if(\"cc\"==this.name)return'style=\"display:none;\"';if(\"bcc\"==this.name)return'style=\"display:none;\"';if(\"from_name\"==this.name)return'style=\"display:none;\"';if(\"from_address\"==this.name)return'style=\"display:none;\"';if(\"email_format\"==this.name)return'style=\"display:none;\"'}if(\"Action\"==e.dataModel.get(\"objectType\")&&\"save\"==e.dataModel.get(\"type\")&&\"submitter_email\"==this.name)return'style=\"display:none;\"';if(\"label_pos\"==this.name)return'style=\"display:none;\"';if(\"input_limit\"==this.name)return'style=\"display:none;\"';if(\"input_limit_type\"==this.name)return'style=\"display:none;\"';if(\"input_limit_msg\"==this.name)return'style=\"display:none;\"';if(\"help_text\"==this.name)return'style=\"display:none;\"';if(\"disable_input\"==this.name)return'style=\"display:none;\"';if(\"disable_browser_autocomplete\"==this.name)return'style=\"display:none;\"';if(\"mask\"==this.name)return'style=\"display:none;\"';if(\"custom_mask\"==this.name)return'style=\"display:none;\"';if(\"custom_name_attribute\"==this.name)return'style=\"display:none;\"';if(\"personally_identifiable\"==this.name)return'style=\"display:none;\"';if(\"key\"==this.name)return'style=\"display:none;\"';if(\"admin_label\"==this.name)return'style=\"display:none;\"';if(\"num_sort\"==this.name)return'style=\"display:none;\"';if(\"user_state\"==this.name)return'style=\"display:none;\"';if(\"checkbox\"==e.dataModel.get(\"type\")){if(\"checked_value\"==this.name)return'style=\"display:none;\"';if(\"unchecked_value\"==this.name)return'style=\"display:none;\"';if(\"checked_calc_value\"==this.name)return'style=\"display:none;\"';if(\"unchecked_calc_value\"==this.name)return'style=\"display:none;\"'}if(\"starrating\"==e.dataModel.get(\"type\")&&\"default\"==this.name)return'style=\"display:none;\"';if(\"listmultiselect\"==e.dataModel.get(\"type\")&&\"box_size\"==this.name)return'style=\"display:none;\"';if(\"date\"==e.dataModel.get(\"type\")){if(\"year_range_start\"==this.name)return'style=\"display:none;\"';if(\"year_range_end\"==this.name)return'style=\"display:none;\"'}}if(this.deps)for(var t in this.deps)if(this.deps.hasOwnProperty(t)&&e.dataModel.get(t)!=this.deps[t])return'style=\"display:none;\"';return\"\"},renderSetting:function(){return void 0!==e.dataModel.get(this.name)?this.value=e.dataModel.get(this.name):void 0===this.value&&(this.value=\"\"),i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-edit-setting-\"+this.type)(this)},renderLabelClasses:function(){var e=\"\";return this.use_merge_tags&&(e+=\" has-merge-tags\"),\"rte\"==this.type&&(e+=\" rte\"),e},renderClasses:function(){var e=\"nf-setting \";return void 0!==this.width?e+=\"nf-\"+this.width:e+=\" nf-one-half\",this.error&&(e+=\" nf-error\"),e},renderTooltip:function(){if(!this.help)return\"\";var e,t,n,i,r;return e=document.createElement(\"div\"),e.innerHTML=this.help,t=document.createElement(\"div\"),t.classList.add(\"nf-help-text\"),t.appendChild(e),n=document.createElement(\"span\"),n.classList.add(\"dashicons\",\"dashicons-admin-comments\"),i=document.createElement(\"a\"),i.classList.add(\"nf-help\"),i.setAttribute(\"href\",\"#\"),i.setAttribute(\"tabindex\",\"-1\"),i.appendChild(n),r=document.createElement(\"span\"),r.appendChild(i),r.appendChild(t),r.innerHTML},renderEmailFieldOptions:function(){var e=i.channel(\"fields\").request(\"get:collection\");initialOption=document.createElement(\"option\"),initialOption.value=\"\",initialOption.label=\"--\",initialOption.innerHTML=\"--\";var t=document.createElement(\"select\");t.classList.add(\"setting\"),t.setAttribute(\"data-id\",\"my_seledt\"),t.appendChild(initialOption);var n=0,r=this;return e.each(function(e){if(\"email\"!=e.get(\"type\"))return\"\";var i=document.createElement(\"option\");i.value=e.get(\"key\"),i.innerHTML=e.get(\"label\"),i.label=e.get(\"label\"),r.value===e.get(\"key\")&&i.setAttribute(\"selected\",\"selected\"),t.appendChild(i),n+=1}),label=document.createElement(\"label\"),label.classList.add(\"nf-select\"),label.appendChild(t),emptyContainer=document.createElement(\"div\"),label.appendChild(emptyContainer),label.innerHTML},renderMergeTags:function(){return this.use_merge_tags&&!this.hide_merge_tags?'<span class=\"dashicons dashicons-list-view merge-tags\"></span>':\"\"},renderMinMax:function(){var e=\"\";return void 0!==this.min_val&&null!=this.min_val&&jQuery.isNumeric(this.min_val)&&(e=e+\"min='\"+this.min_val+\"'\"),void 0!==this.max_val&&\"\"!=this.max_val&&jQuery.isNumeric(this.max_val)&&(e=e+\" max='\"+this.max_val+\"'\"),e},renderMinMaxHelper:function(){var e=\"\";return void 0!==this.min_val&&null!=this.min_val&&jQuery.isNumeric(this.min_val)&&(0==e.length&&(e=\"(\"),e=e+nfi18n.minVal+\": \"+this.min_val),void 0!==this.max_val&&\"\"!=this.max_val&&jQuery.isNumeric(this.max_val)&&(0==e.length?e=\"(\":e+=\", \",e=e+nfi18n.maxVal+\": \"+this.max_val),0<e.length&&(e+=\")\"),e}}},events:{\"change .setting\":\"changeSetting\",\"keyup .setting\":\"keyUpSetting\",\"click .setting\":\"clickSetting\",\"click .extra\":\"clickExtra\"},changeSetting:function(e){i.channel(\"app\").trigger(\"change:setting\",e,this.model,this.dataModel)},keyUpSetting:function(e){i.channel(\"app\").trigger(\"keyup:setting\",e,this.model,this.dataModel),i.channel(\"setting-\"+this.model.get(\"name\")).trigger(\"keyup:setting\",e,this.model,this.dataModel)},clickSetting:function(e){i.channel(\"app\").trigger(\"click:setting\",e,this.model,this.dataModel),i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"click:setting\",e,this.model,this.dataModel,this)},clickExtra:function(e){i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"click:extra\",e,this.model,this.dataModel,this),i.channel(\"setting-type-\"+this.model.get(\"name\")).trigger(\"click:extra\",e,this.model,this.dataModel,this),i.channel(\"setting-name-\"+this.model.get(\"name\")).trigger(\"click:extra\",e,this.model,this.dataModel,this)},drawerOpened:function(){i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"drawer:opened\",this.model,this.dataModel,this)},drawerClosed:function(){i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"drawer:closed\",this.model,this.dataModel,this)}})}),n(\"views/app/drawer/contentPublicLink\",[\"views/app/drawer/itemSetting\"],function(e){return Marionette.LayoutView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-content-public-link\",regions:{embedForm:\".embed-form\",enablePublicLink:\".enable-public-link\",copyPublicLink:\".copy-public-link\"},onRender:function(){var t=Backbone.Radio.channel(\"app\").request(\"get:formModel\"),n=i.channel(\"settings\").request(\"get:settings\"),r=i.channel(\"settings\").request(\"get:settingModel\",\"allow_public_link\");this.enablePublicLink.show(new e({model:r,dataModel:n}));var a=\"[ninja_form id='{FORM_ID}']\".replace(\"{FORM_ID}\",t.get(\"id\"));n.set(\"embed_form\",a);var l=i.channel(\"settings\").request(\"get:settingModel\",\"embed_form\");this.embedForm.show(new e({model:l,dataModel:n}));var s=n.get(\"public_link_key\");s||(s=i.channel(\"app\").request(\"generate:publicLinkKey\"));var o=nfAdmin.publicLinkStructure.replace(\"[FORM_ID]\",s);n.set(\"public_link\",o);var c=i.channel(\"settings\").request(\"get:settingModel\",\"public_link\");this.copyPublicLink.show(new e({model:c,dataModel:n}))},events:{\"click #embed_form + .js-click-copytext\":\"copyFormEmbedHandler\",\"click #public_link + .js-click-copytext\":\"copyPublicLinkHandler\"},copyFormEmbedHandler:function(e){document.getElementById(\"embed_form\").select(),document.execCommand(\"copy\"),e.target.innerHTML=\"Copied!\"},copyPublicLinkHandler:function(e){document.getElementById(\"public_link\").select(),document.execCommand(\"copy\"),e.target.innerHTML=\"Copied!\"}})}),n(\"views/app/drawer/headerPublicLink\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-header-public-link\"})}),n(\"views/app/drawer/contentNewForm\",[\"views/app/drawer/itemSetting\"],function(e){return Marionette.LayoutView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-content-new-form\",regions:{formName:\".new-form-name\",formSubmit:\".new-form-submit\"},onRender:function(){var t=i.channel(\"settings\").request(\"get:settingModel\",\"title\"),n=i.channel(\"settings\").request(\"get:settingModel\",\"add_submit\"),r=i.channel(\"settings\").request(\"get:settings\");this.formName.show(new e({model:t,dataModel:r})),void 0===i.channel(\"fields\").request(\"get:collection\").findWhere({type:\"submit\"})?this.formSubmit.show(new e({model:n,dataModel:r})):r.set(\"add_submit\",0)},events:{\"click .publish\":\"clickPublish\"},clickPublish:function(e){i.channel(\"app\").trigger(\"click:confirmPublish\",e)}})}),n(\"views/app/drawer/headerNewForm\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-header-new-form\"})}),n(\"controllers/app/drawerConfig\",[\"models/app/drawerCollection\",\"views/fields/drawer/addField\",\"views/app/drawer/editSettings\",\"views/app/drawer/headerEditSettings\",\"views/actions/drawer/addAction\",\"views/app/drawer/contentViewChanges\",\"views/app/drawer/headerViewChanges\",\"views/app/drawer/contentPublicLink\",\"views/app/drawer/headerPublicLink\",\"views/app/drawer/contentNewForm\",\"views/app/drawer/headerNewForm\"],function(e,t,n,r,a,l,s,o,c,d,u,h){return Marionette.Object.extend({initialize:function(){this.collection=new e([{id:\"addField\",getContentView:function(e){return new t(e)}},{id:\"addAction\",getContentView:function(e){return new a(e)}},{id:\"editSettings\",getHeaderView:function(e){if(void 0!==e.typeModel)var t=i.channel(e.typeModel.get(\"id\")).request(\"get:drawerHeaderView\")||r;else var t=r;return new t(e)},getContentView:function(e){return new n(e)}},{id:\"viewChanges\",getHeaderView:function(e){return new s(e)},getContentView:function(e){return new l(e)}},{id:\"publicLink\",getHeaderView:function(e){return new c(e)},getContentView:function(e){return new o(e)}},{id:\"newForm\",getHeaderView:function(e){return new u(e)},getContentView:function(e){return new d(e)}}]),i.channel(\"app\").reply(\"get:drawerCollection\",this.getDrawerCollection,this),i.channel(\"app\").reply(\"get:drawer\",this.getDrawer,this)},getDrawerCollection:function(){return this.collection},getDrawer:function(e){return this.collection.get(e)}})}),n(\"views/app/drawer/defaultSettingsTitle\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-content-edit-settings-title-default\",templateHelpers:function(){return{renderTypeNicename:function(){var e=i.channel(\"app\").request(\"get:currentDomain\"),t=e.get(\"id\"),n=i.channel(t).request(\"get:type\",this.type);return void 0!==n?n.get(\"nicename\"):\"\"}}}})}),n(\"views/app/empty\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-empty\"})}),n(\"models/app/domainModel\",[\"views/app/drawer/defaultSettingsTitle\",\"views/app/empty\"],function(e,t){return Backbone.Model.extend({defaults:{dashicons:\"\",classes:\"\",active:!1,url:\"\",hotkeys:!1,disabled:!1,getSettingsTitleView:function(t){return new e(t)},getDefaultSettingsTitleView:function(t){return new e(t)},getGutterLeftView:function(e){return new t},getGutterRightView:function(e){return new t}}})}),n(\"models/app/domainCollection\",[\"models/app/domainModel\"],function(e){return Backbone.Collection.extend({model:e})}),n(\"views/fields/subHeader\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-sub-header-fields\"})}),n(\"views/fields/mainContentFieldCollection\",[],function(){return Marionette.CollectionView.extend({tagName:\"div\",reorderOnSort:!0,getChildView:function(){return i.channel(\"views\").request(\"get:fieldItem\")},getEmptyView:function(){return i.channel(\"views\").request(\"get:mainContentEmpty\")},initialize:function(){i.channel(\"fields\").reply(\"get:sortableEl\",this.getSortableEl,this),i.channel(\"fields\").reply(\"init:sortable\",this.initSortable,this),i.channel(\"fields\").reply(\"destroy:sortable\",this.destroySortable,this)},onRender:function(){if(this.collection.models.length>0){jQuery(this.el).addClass(\"nf-field-type-droppable\").addClass(\"nf-fields-sortable\");this.initSortable()}i.channel(\"app\").trigger(\"render:fieldsSortable\",this)},getSortableEl:function(){return this.el},initSortable:function(){if(i.channel(\"app\").request(\"is:mobile\"));else;jQuery(this.el).sortable({helper:\"clone\",cancel:\".nf-item-controls\",placeholder:\"nf-fields-sortable-placeholder\",opacity:.95,grid:[5,5],appendTo:\"#nf-main\",scrollSensitivity:10,receive:function(e,t){t.item.dropping||i.channel(\"app\").request(\"receive:fieldsSortable\",t)},over:function(e,t){t.item.dropping||i.channel(\"app\").request(\"over:fieldsSortable\",t)},out:function(e,t){t.item.dropping||i.channel(\"app\").request(\"out:fieldsSortable\",t)},start:function(e,t){t.item.dropping||i.channel(\"app\").request(\"start:fieldsSortable\",t)},update:function(e,t){t.item.dropping||i.channel(\"app\").request(\"update:fieldsSortable\",t,this)},stop:function(e,t){t.item.dropping||i.channel(\"app\").request(\"stop:fieldsSortable\",t)}})},destroySortable:function(){jQuery(this.el).sortable(\"destroy\")},onAddChild:function(e){i.channel(\"fields\").request(\"get:adding\")&&(e.$el.hide().show(\"clip\"),i.channel(\"fields\").request(\"set:adding\",!1))}})}),n(\"views/fields/drawer/addSavedField\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-add-saved-field\",initialize:function(){this.model.on(\"change:addSavedLoading\",this.renderAddButton,this)},onRender:function(){this.renderAddButton()},renderAddButton:function(){if(this.model.get(\"addSavedLoading\"))var e=i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-add-saved-field-loading\");else var e=i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-add-saved-field-button\");jQuery(this.el).find(\".add-button\").html(e(this))},onBeforeDestroy:function(){this.model.off(\"change:addSavedLoading\",this.render)},events:{\"click .nf-button\":\"clickAddSavedField\"},clickAddSavedField:function(e){i.channel(\"drawer\").trigger(\"click:addSavedField\",e,this.model)}})}),n(\"views/fields/drawer/settingsTitle\",[\"views/fields/drawer/addSavedField\"],function(e){return Marionette.LayoutView.extend({tagName:\"div\",template:\"#tmpl-nf-drawer-content-edit-settings-title-fields\",initialize:function(){this.model.on(\"change:saved\",this.render,this),this.model.on(\"change:label\",this.renderjBoxContent,this)},regions:{addSaved:\".nf-add-saved-field\"},onBeforeDestroy:function(){this.model.off(\"change:saved\",this.render),this.addSavedjBox.destroy(),this.model.unset(\"jBox\",{silent:!0})},onRender:function(){this.renderjBoxContent();var e=this;this.addSavedjBox=new jBox(\"Tooltip\",{trigger:\"click\",title:\"Add to Saved Fields\",position:{x:\"left\",y:\"center\"},outside:\"x\",closeOnClick:\"body\",onCreated:function(){this.setContent(jQuery(e.el).find(\".nf-add-saved-field\"))}}),this.addSavedjBox.attach(jQuery(this.el).find(\".dashicons\")),this.model.set(\"jBox\",this.addSavedjBox,{silent:!0})},renderjBoxContent:function(){this.addSaved&&this.addSaved.show(new e({model:this.model}))},templateHelpers:function(){return{renderTypeNicename:function(){var e=i.channel(\"app\").request(\"get:currentDomain\"),t=e.get(\"id\"),n=i.channel(t).request(\"get:type\",this.type),r=n.get(\"nicename\");if(this.saved){r+=\" - \"+i.channel(t).request(\"get:type\",n.get(\"type\")).get(\"nicename\")}return r},renderSavedStar:function(){if(this.saved)var e=\"filled\";else var e=\"empty\";return'<span class=\"dashicons dashicons-star-'+e+'\"></span>'}}}})}),n(\"views/actions/mainHeader\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-main-header-actions\",initialize:function(){var e=i.channel(\"actions\").request(\"get:collection\");this.listenTo(e,\"add\",this.render),this.listenTo(e,\"remove\",this.render)},onRender:function(){0==i.channel(\"actions\").request(\"get:collection\").models.length?jQuery(this.el).hide():jQuery(this.el).show()}})}),n(\"views/actions/subHeader\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-sub-header-actions\"})}),n(\"views/app/itemControls\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-item-controls\",initialize:function(){},onRender:function(){this.currentDomain=i.channel(\"app\").request(\"get:currentDomain\")},events:{\"mouseover .nf-item-control\":\"mouseoverItemControl\",\"click .nf-edit-settings\":\"clickEdit\",\"singletap .nf-item-control\":\"singleTapEdit\",\"click .nf-item-delete\":\"clickDelete\",\"click .nf-item-duplicate\":\"clickDuplicateField\"},clickEdit:function(e){i.channel(\"app\").request(\"is:mobile\")||i.channel(\"app\").trigger(\"click:edit\",e,this.model)},singleTapEdit:function(e){i.channel(\"app\").trigger(\"click:edit\",e,this.model)},clickDelete:function(e){i.channel(\"app\").trigger(\"click:delete\",e,this.model)},clickDuplicateField:function(e){i.channel(\"app\").trigger(\"click:duplicate\",e,this.model)},mouseoverItemControl:function(e){i.channel(\"app\").trigger(\"mouseover:itemControl\",e,this.model)}})}),n(\"views/actions/actionItem\",[\"views/app/itemControls\"],function(e){return Marionette.LayoutView.extend({tagName:\"tr\",template:\"#tmpl-nf-action-item\",regions:{itemControls:\".nf-item-controls\"},initialize:function(){this.template=i.channel(\"actions\").request(\"get:actionItemTemplate\")||this.template,this.model.on(\"change:label\",this.render,this),this.model.on(\"change:editActive\",this.render,this),this.model.on(\"change:active\",this.maybeDeactivate,this)},onBeforeDestroy:function(){this.model.off(\"change:label\",this.render),this.model.off(\"change:editActive\",this.render),this.model.off(\"change:active\",this.maybeDeactivate)},onRender:function(){this.model.get(\"editActive\")?jQuery(this.el).addClass(\"active\"):jQuery(this.el).removeClass(\"active\"),this.maybeDeactivate(),this.itemControls.show(new e({model:this.model}))},maybeDeactivate:function(){0==this.model.get(\"active\")?jQuery(this.el).addClass(\"deactivated\"):jQuery(this.el).removeClass(\"deactivated\")},events:{\"change input\":\"changeToggle\",click:\"maybeClickEdit\"},maybeClickEdit:function(e){\"TR\"==jQuery(e.target).parent().prop(\"tagName\")&&i.channel(\"app\").trigger(\"click:edit\",e,this.model)},changeToggle:function(e){var t=jQuery(e.target).data(\"setting\"),n=i.channel(\"actions\").request(\"get:settingModel\",t);console.log(n),console.log(this.model),i.channel(\"app\").request(\"change:setting\",e,n,this.model),i.channel(\"app\").request(\"update:db\")},templateHelpers:function(){return{renderToggle:function(e){this.settingName=e||\"active\";var t=this.label;this.label=\"\",this.value=this[this.settingName],this.name=this.id+\"-\"+this.settingName;var n=i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-edit-setting-toggle\");return n=n(this),this.label=t,n},renderTypeNicename:function(){var e=i.channel(\"actions\").request(\"get:type\",this.type);if(void 0!==e)return e.get(\"nicename\")},renderTooltip:function(){return\"\"},renderMergeTags:function(){return this.use_merge_tags?'<span class=\"dashicons dashicons-list-view merge-tags\"></span>':\"\"}}}})}),n(\"views/actions/mainContentEmpty\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-main-content-actions-empty\",onBeforeDestroy:function(){jQuery(this.el).parent().parent().removeClass(\"nf-actions-empty\")},onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el)},onShow:function(){jQuery(this.el).parent().parent().addClass(\"nf-actions-empty\")}})}),n(\"views/actions/mainContent\",[\"views/actions/actionItem\",\"views/actions/mainContentEmpty\"],function(e,t){return Marionette.CompositeView.extend({template:\"#tmpl-nf-action-table\",childView:e,emptyView:t,initialize:function(){this.template=i.channel(\"actions\").request(\"get:mainContentTemplate\")||this.template},onRender:function(){jQuery(this.el).droppable({accept:\".nf-action-type-draggable\",activeClass:\"nf-droppable-active\",hoverClass:\"nf-droppable-hover\",drop:function(e,t){i.channel(\"app\").request(\"drop:actionType\",e,t)}})},attachHtml:function(e,t){void 0!==i.channel(\"actions\").request(\"get:type\",t.model.get(\"type\"))&&jQuery(e.el).find(\"tbody\").append(t.el)}})}),n(\"views/advanced/mainHeader\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-main-header-settings\"})}),n(\"views/advanced/subHeader\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-sub-header-settings\"})}),n(\"views/advanced/settingItem\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-form-setting-type\",onBeforeDestroy:function(){this.model.off(\"change:editActive\",this.updateActiveClass)},initialize:function(){this.model.on(\"change:editActive\",this.updateActiveClass,this)},events:{click:\"clickEdit\"},clickEdit:function(e){i.channel(\"settings\").trigger(\"click:edit\",e,this.model)},templateHelpers:function(){return{renderClasses:function(){var e=\"nf-setting-wrap \"+this.id;return this.editActive&&(e+=\" active\"),e}}},updateActiveClass:function(){this.model.get(\"editActive\")?jQuery(this.el).find(\".nf-setting-wrap\").addClass(\"active\"):jQuery(this.el).find(\".nf-setting-wrap\").removeClass(\"active\")}})}),n(\"views/advanced/mainContent\",[\"views/advanced/settingItem\"],function(e){return Marionette.CompositeView.extend({childView:e,template:\"#tmpl-nf-advanced-main-content\",attachHtml:function(e,t){jQuery(e.el).find(\".child-view-container\").append(t.el)}})}),n(\"models/fields/fieldModel\",[],function(){return Backbone.Model.extend({defaults:{objectType:\"Field\",objectDomain:\"fields\",editActive:!1,order:999},initialize:function(){if(void 0!==this.get(\"type\")){this.on(\"change\",this.changeSetting,this);var e=i.channel(\"fields\").request(\"get:type\",this.get(\"type\")),t=e.get(\"parentType\");_.each(e.get(\"settingDefaults\"),function(e,t){void 0===this.get(t)&&this.set(t,e,{silent:!0})},this),\"saved\"==e.get(\"section\")&&this.set(\"type\",e.get(\"type\")),i.channel(\"fields\").trigger(\"init:fieldModel\",this),i.channel(\"fields-\"+t).trigger(\"init:fieldModel\",this),i.channel(\"fields-\"+this.get(\"type\")).trigger(\"init:fieldModel\",this),this.listenTo(i.channel(\"app\"),\"fire:updateFieldKey\",this.updateFieldKey)}},changeSetting:function(e,t){i.channel(\"fieldSetting-\"+_.keys(e.changedAttributes())[0]).trigger(\"update:setting\",this,t.settingModel),i.channel(\"fields\").trigger(\"update:setting\",this,t.settingModel),i.channel(\"app\").trigger(\"update:setting\",this,t.settingModel)},updateFieldKey:function(e,t){i.channel(\"app\").trigger(\"replace:fieldKey\",this,e,t)},formatLabel:function(){var e=this.get(\"admin_label\");return\"\"==e&&(e=this.get(\"label\")),e}})}),n(\"models/fields/fieldCollection\",[\"models/fields/fieldModel\"],function(e){return Backbone.Collection.extend({model:e,comparator:function(e){return parseInt(e.get(\"order\"))},tmpNum:1,initialize:function(){this.on(\"add\",this.addField,this),this.on(\"remove\",this.removeField,this),this.listenTo(this,\"add:field\",this.addNewField),this.listenTo(this,\"append:field\",this.appendNewField),this.listenTo(this,\"remove:field\",this.removeFieldResponse),this.newIDs=[]},\naddField:function(e){this.newIDs.push(e.get(\"id\"))},removeField:function(e){this.removedIDs=this.removedIDs||{},this.removedIDs[e.get(\"id\")]=e.get(\"id\")},addNewField:function(e){this.add(e)},appendNewField:function(e){if(0==this.length)var t=0;else var t=this.at(this.length-1).get(\"order\")+1;e.set(\"order\",t,{silent:!0}),this.add(e)},removeFieldResponse:function(e){this.remove(e)},fieldExists:function(e){return-1!=this.indexOf(e)}})}),n(\"controllers/app/domainConfig\",[\"models/app/domainCollection\",\"views/fields/subHeader\",\"views/fields/mainContentFieldCollection\",\"views/fields/drawer/settingsTitle\",\"views/actions/mainHeader\",\"views/actions/subHeader\",\"views/actions/mainContent\",\"views/advanced/mainHeader\",\"views/advanced/subHeader\",\"views/advanced/mainContent\",\"views/app/empty\",\"models/fields/fieldCollection\"],function(e,t,n,r,a,l,s,o,c,d,u,h){return Marionette.Object.extend({initialize:function(){i.channel(\"formContent\").request(\"add:viewFilter\",this.defaultFormContentView,10,this),i.channel(\"formContent\").request(\"add:loadFilter\",this.defaultFormContentLoad,10,this),i.channel(\"formContentGutters\").request(\"add:leftFilter\",this.defaultFormContentGutterView,10,this),i.channel(\"formContentGutters\").request(\"add:rightFilter\",this.defaultFormContentGutterView,10,this),this.collection=new e([{id:\"fields\",nicename:nfi18n.domainFormFields,hotkeys:{Esc:\"close:drawer\",\"Ctrl+Shift+n\":\"add:newField\",\"Ctrl+Shift+a\":\"changeDomain:actions\",\"Ctrl+Shift+s\":\"changeDomain:settings\",\"Alt+Ctrl+t\":\"open:mergeTags\",up:\"up:mergeTags\",down:\"down:mergeTags\",\"Shift+return\":\"return:mergeTags\"},mobileDashicon:\"dashicons-menu\",getSubHeaderView:function(){return new t},getMainContentView:function(e){var t=i.channel(\"settings\").request(\"get:setting\",\"formContentData\");t||(t=i.channel(\"settings\").request(\"get:setting\",\"fieldContentsData\"));var n=i.channel(\"formContent\").request(\"get:loadFilters\"),r=_.without(n,void 0),a=_.first(r);t=a(t,i.channel(\"app\").request(\"get:formModel\"),!0);var l=i.channel(\"formContent\").request(\"get:viewFilters\"),r=_.without(l,void 0),a=_.first(r);return formContentView=a(),i.channel(\"settings\").request(\"update:setting\",\"formContentData\",t,!0),new formContentView({collection:t})},getSettingsTitleView:function(e){return\"fields\"==e.model.get(\"objectDomain\")?new r(e):this.get(\"getDefaultSettingsTitleView\").call(this,e)},getGutterLeftView:function(e){var t=i.channel(\"formContentGutters\").request(\"get:leftFilters\"),n=_.without(t,void 0),r=_.first(n);return gutterView=r(),new gutterView},getGutterRightView:function(){var e=i.channel(\"formContentGutters\").request(\"get:rightFilters\"),t=_.without(e,void 0),n=_.first(t);return gutterView=n(),new gutterView}},{id:\"actions\",nicename:nfi18n.domainActions,hotkeys:{Esc:\"close:drawer\",\"Ctrl+Shift+n\":\"add:newAction\",\"Ctrl+Shift+f\":\"changeDomain:fields\",\"Ctrl+Shift+s\":\"changeDomain:settings\",\"Alt+Ctrl+t\":\"open:mergeTags\",up:\"up:mergeTags\",down:\"down:mergeTags\",\"Shift+return\":\"return:mergeTags\"},mobileDashicon:\"dashicons-external\",getSubHeaderView:function(){return new l},getMainContentView:function(){var e=i.channel(\"actions\").request(\"get:collection\");return new s({collection:e})}},{id:\"settings\",nicename:nfi18n.domainAdvanced,hotkeys:{Esc:\"close:drawer\",\"Ctrl+Shift+f\":\"changeDomain:fields\",\"Ctrl+Shift+a\":\"changeDomain:actions\",\"Alt+Ctrl+t\":\"open:mergeTags\",up:\"up:mergeTags\",down:\"down:mergeTags\",\"Shift+return\":\"return:mergeTags\"},mobileDashicon:\"dashicons-admin-generic\",getSubHeaderView:function(){return new c},getMainContentView:function(){var e=i.channel(\"settings\").request(\"get:typeCollection\");return new d({collection:e})}},{id:\"preview\",nicename:\"Preview Form\",classes:\"preview\",dashicons:\"dashicons-visibility\",mobileDashicon:\"dashicons-visibility\",url:nfAdmin.previewurl}]),i.channel(\"app\").trigger(\"init:domainCollection\",this.collection),i.channel(\"app\").reply(\"get:domainCollection\",this.getDomainCollection,this),i.channel(\"app\").reply(\"get:domainModel\",this.getDomainModel,this)},getDomainCollection:function(){return this.collection},getDomainModel:function(e){return this.collection.get(e)},defaultFormContentView:function(e){return n},defaultFormContentLoad:function(e){var t=i.channel(\"fields\").request(\"get:collection\"),n=i.channel(\"formContent\").request(\"get:loadFilters\");if(1==_.without(n,void 0).length||void 0===e||1==e instanceof Backbone.Collection)return t;var r=_.map(e,function(e){return t.findWhere({key:e})},this);return new h(r)},defaultFormContentGutterView:function(e){return u}})}),n(\"models/app/appModel\",[],function(){return Backbone.Model.extend({defaults:{loading:!1},initialize:function(){this.on(\"change:clean\",this.changeStatus,this)},changeStatus:function(){i.channel(\"app\").trigger(\"change:clean\",this.get(\"clean\"))}})}),n(\"controllers/app/data\",[\"models/app/appModel\"],function(e){return Marionette.Object.extend({initialize:function(){var t=i.channel(\"app\").request(\"get:domainCollection\");this.model=new e({currentDrawer:!1,currentDomain:t.get(\"fields\"),clean:!0});var n=1==nfAdmin.mobile;this.model.set(\"mobile\",n),i.channel(\"app\").reply(\"is:mobile\",this.isMobile,this),i.channel(\"app\").reply(\"get:data\",this.getData,this),i.channel(\"app\").reply(\"get:setting\",this.getSetting,this),i.channel(\"app\").reply(\"get:currentDomain\",this.getCurrentDomain,this),i.channel(\"app\").reply(\"get:currentDrawer\",this.getCurrentDrawer,this),i.channel(\"drawer\").reply(\"get:current\",this.getCurrentDrawer,this),i.channel(\"app\").reply(\"update:currentDomain\",this.updateCurrentDomain,this),i.channel(\"app\").reply(\"update:currentDrawer\",this.updateCurrentDrawer,this),i.channel(\"app\").reply(\"update:setting\",this.updateSetting,this)},updateCurrentDomain:function(e){this.updateSetting(\"currentDomain\",e)},updateSetting:function(e,t){return this.model.set(e,t),!0},getSetting:function(e){return this.model.get(e)},getData:function(){return this.model},getCurrentDomain:function(){return this.model.get(\"currentDomain\")},updateCurrentDrawer:function(e){return this.updateSetting(\"currentDrawer\",e),!0},getCurrentDrawer:function(){var e=this.model.get(\"currentDrawer\");return i.channel(\"app\").request(\"get:drawer\",e)},isMobile:function(){return this.model.get(\"mobile\")}})}),n(\"controllers/app/drawerToggleSettingGroup\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"drawer\"),\"click:toggleSettingGroup\",this.toggleSettingGroup)},toggleSettingGroup:function(e,t){if(t.get(\"display\")){var n=!1;_.each(t.get(\"settings\").models,function(e){e.get(\"error\")&&(n=!0)}),n||t.set(\"display\",!1)}else t.set(\"display\",!0)}})}),n(\"controllers/app/updateDB\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"drawer\"),\"closed\",this.updateDB),i.channel(\"app\").reply(\"update:db\",this.updateDB,this),i.channel(\"formContent\").request(\"add:saveFilter\",this.defaultSaveFilter,10,this)},updateDB:function(e){if(i.channel(\"app\").request(\"get:setting\",\"clean\"))return!1;if(\"preview\"==(e=e||\"preview\"))var t=\"nf_preview_update\";else if(\"publish\"==e)var t=\"nf_save_form\";var n=i.channel(\"app\").request(\"get:formModel\");_.each(n.get(\"fields\").models,function(e,t){e.unset(\"jBox\",{silent:!0})});var r=i.channel(\"settings\").request(\"get:setting\",\"formContentData\");r||(r=i.channel(\"settings\").request(\"get:setting\",\"fieldContentsData\"));var a=i.channel(\"formContent\").request(\"get:saveFilters\"),l=_.without(a,void 0);if(r=_.first(l)(r),\"publish\"==e&&n.get(\"show_publish_options\")){i.channel(\"app\").request(\"open:drawer\",\"newForm\");var s=i.channel(\"app\").request(\"get:builderEl\");return jQuery(s).addClass(\"disable-main\"),!1}var o=i.channel(\"app\").request(\"get:formModel\"),c=JSON.parse(JSON.stringify(o));c.settings.formContentData=r;var d=o.get(\"fields\").removedIDs;_.each(c.fields,function(e){var t=e.id;delete e.id,delete e.parent_id;var n={};for(var i in e)e.hasOwnProperty(i)&&(null!==e[i]&&(n[i]=e[i]),delete e[i]);for(var r in n)null===n[r]&&delete n[r];e.settings=n,e.id=t}),c.deleted_fields=d;var d=o.get(\"actions\").removedIDs;_.each(c.actions,function(e){var t=e.id;delete e.id,delete e.parent_id;var n={};for(var i in e)e.hasOwnProperty(i)&&(null!==e[i]&&(n[i]=e[i]),delete e[i]);e.settings=n,e.id=t});for(var u in c.settings)null===c.settings[u]&&delete c.settings[u];if(c.deleted_actions=d,c=JSON.stringify(c),i.channel(\"app\").trigger(\"before:updateDB\",c),\"publish\"==e&&(i.channel(\"app\").request(\"update:setting\",\"loading\",!0),i.channel(\"app\").trigger(\"change:loading\"),i.channel(\"app\").request(\"is:mobile\")&&i.channel(\"notices\").request(\"add\",\"publishing\",\"Your Changes Are Being Published\",{autoClose:!1})),\"nf_save_form\"===t){var h=[];if(1e5<c.length&&(h=c.match(new RegExp(\".{1,100000}\",\"g\"))),1<h.length)this.saveChunkedForm(h,0,\"nf_batch_process\",e,n.get(\"id\"),!0);else{var g=this,p=null;jQuery.post(ajaxurl,{action:t,form:c,security:nfAdmin.ajaxNonce},function(t){p=t,g.handleFinalResponse(p,e)}).fail(function(t,n,i){g.handleFinalFailure(t,n,i,e)})}}else if(\"nf_preview_update\"===t){var g=this,p=null;jQuery.post(ajaxurl,{action:t,form:c,security:nfAdmin.ajaxNonce},function(t){p=t,g.handleFinalResponse(p,e)}).fail(function(t,n,i){g.handleFinalFailure(t,n,i,e)})}},saveChunkedForm:function(e,t,n,i,r,a){var l=e.length,s={action:n,batch_type:\"chunked_publish\",data:{new_publish:a,chunk_total:l,chunk_current:t,chunk:e[t],form_id:r},security:nfAdmin.batchNonce},o=this;jQuery.post(ajaxurl,s).then(function(a){try{var l=JSON.parse(a);\"success\"!==l.last_request||l.batch_complete?l.batch_complete&&o.handleFinalResponse(a,i):(console.log(\"Chunk \"+t+\" processed\"),o.saveChunkedForm(e,l.requesting,n,i,r,!1))}catch(e){console.log(\"There was an error in parsing the response\"),console.log(e)}}).fail(function(e,t,n){console.log(\"There was an error sending form data\"),console.log(n),o.handleFinalFailure(e,t,n,i)})},handleFinalResponse:function(e,t){try{e=JSON.parse(e),e.action=t,i.channel(\"app\").trigger(\"response:updateDB\",e),i.channel(\"app\").request(\"is:mobile\")}catch(e){console.log(\"Something went wrong!\"),console.log(e)}},handleFinalFailure:function(e,t,n,i){if(\"preview\"==i)return void console.log(n);alert(e.status+\" \"+n+\"\\r\\nAn error on the server caused your form not to publish.\\r\\nPlease contact Ninja Forms Support with your PHP Error Logs.\\r\\nhttps://ninjaforms.com/contact\")},defaultSaveFilter:function(e){return e.pluck(\"key\")}})}),n(\"models/app/formModel\",[],function(){return Backbone.Model.extend({initialize:function(){jQuery.isNumeric(this.get(\"id\"))?this.set(\"show_publish_options\",!1,{silent:!0}):this.set(\"show_publish_options\",!0,{silent:!0})}})}),n(\"controllers/app/formData\",[\"models/app/formModel\"],function(e){return Marionette.Object.extend({initialize:function(){this.model=new e({id:preloadedFormData.id}),this.model.set(\"fields\",i.channel(\"fields\").request(\"get:collection\")),this.model.set(\"actions\",i.channel(\"actions\").request(\"get:collection\")),this.model.set(\"settings\",i.channel(\"settings\").request(\"get:settings\")),i.channel(\"app\").reply(\"get:formModel\",this.getFormModel,this)},getFormModel:function(){return this.model}})}),n(\"controllers/app/previewLink\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"before:sendChanges\",this.disablePreview,this),this.listenTo(i.channel(\"app\"),\"response:sendChanges\",this.enablePreview,this),this.listenTo(i.channel(\"app\"),\"change:clean\",this.changePreviewNicename,this)},disablePreview:function(){i.channel(\"app\").request(\"get:domainCollection\").get(\"preview\").set(\"disabled\",!0)},changePreviewNicename:function(e){var t=i.channel(\"app\").request(\"get:domainCollection\"),n=t.get(\"preview\");if(e)var r=\"Preview Form\";else var r=\"Preview Changes\";n.set(\"nicename\",r)},enablePreview:function(){i.channel(\"app\").request(\"get:domainCollection\").get(\"preview\").set(\"disabled\",!1)}})}),n(\"controllers/app/menuButtons\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"click:publish\",this.publish),this.listenTo(i.channel(\"app\"),\"click:viewChanges\",this.viewChanges),this.listenTo(i.channel(\"app\"),\"click:publicLink\",this.publicLink)},publish:function(){i.channel(\"app\").request(\"update:db\",\"publish\")},viewChanges:function(){var e=i.channel(\"changes\").request(\"get:collection\");i.channel(\"app\").request(\"open:drawer\",\"viewChanges\",{collection:e})},publicLink:function(){i.channel(\"app\").request(\"open:drawer\",\"publicLink\")}})}),n(\"models/app/changeModel\",[],function(){return Backbone.Model.extend({defaults:{disabled:!1}})}),n(\"models/app/changeCollection\",[\"models/app/changeModel\"],function(e){return Backbone.Collection.extend({model:e,comparator:function(e){return-parseInt(e.cid.replace(\"c\",\"\"))}})}),n(\"controllers/app/trackChanges\",[\"models/app/changeCollection\",\"models/app/changeModel\"],function(e,t){return Marionette.Object.extend({initialize:function(){this.collection=new e,i.channel(\"changes\").reply(\"register:change\",this.registerChange,this),i.channel(\"changes\").reply(\"get:collection\",this.getCollection,this),this.listenTo(i.channel(\"app\"),\"change:clean\",this.maybeResetCollection)},registerChange:function(e,n,i,r,a){var a=void 0!==a?a:{};void 0===r.dashicon&&(r.dashicon=\"admin-generic\");var l=new t({action:e,model:n,changes:i,label:r,data:a});return this.collection.add(l),l},getCollection:function(){return this.collection},maybeResetCollection:function(e){e&&this.collection.reset()}})}),n(\"controllers/app/undoChanges\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"drawer\"),\"click:undoChanges\",this.undoChanges,this),this.listenTo(i.channel(\"drawer\"),\"click:undoSingle\",this.undoSingle,this)},undoChanges:function(){var e=i.channel(\"changes\").request(\"get:collection\");e.sort();var t=this;_.each(e.models,function(e){t.undoSingle(e,!0)}),e.reset(),i.channel(\"app\").request(\"update:db\"),i.channel(\"app\").request(\"update:setting\",\"clean\",!0),i.channel(\"app\").request(\"close:drawer\"),this.dispatchClick()},undoSingle:function(e,t){i.channel(\"changes\").request(\"undo:\"+e.get(\"action\"),e,t),this.dispatchClick()},dispatchClick:function(){if(!document.cookie.includes(\"nf_undo\")){var e=new Date;e.setTime(e.getTime()+6048e5);var t=\"expires=\"+e.toUTCString();document.cookie=\"nf_undo=1;\"+t+\";path=/\";var n={action:\"nf_undo_click\",security:nfAdmin.ajaxNonce};jQuery.post(ajaxurl,n)}}})}),n(\"controllers/app/publishResponse\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"response:updateDB\",this.publishResponse)},publishResponse:function(e){if(\"publish\"!==e.action)return!1;void 0!==e.data.new_ids&&(void 0!==e.data.new_ids.fields&&_.each(e.data.new_ids.fields,function(e,t){var n=i.channel(\"fields\").request(\"get:field\",t);n&&n.set(\"id\",e)}),void 0!==e.data.new_ids.actions&&_.each(e.data.new_ids.actions,function(e,t){var n=i.channel(\"actions\").request(\"get:action\",t);n&&n.set(\"id\",e)}),void 0!==e.data.new_ids.forms&&_.each(e.data.new_ids.forms,function(e,t){i.channel(\"app\").request(\"get:formModel\").set(\"id\",e),history.replaceState(\"\",\"\",\"admin.php?page=ninja-forms&form_id=\"+e)})),i.channel(\"app\").request(\"update:setting\",\"loading\",!1),i.channel(\"app\").trigger(\"change:loading\"),i.channel(\"app\").request(\"is:mobile\")&&i.channel(\"notices\").request(\"close\",\"publishing\"),i.channel(\"app\").trigger(\"app:published\",e),i.channel(\"app\").request(\"update:setting\",\"clean\",!0)}})}),n(\"controllers/app/changeDomain\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"click:menu\",this.changeAppDomain),i.channel(\"app\").reply(\"change:currentDomain\",this.changeAppDomain,this),i.channel(\"app\").reply(\"prevent:changeDomain\",this.preventChange,this),i.channel(\"app\").reply(\"enable:changeDomain\",this.enableChange,this),this.objPreventChange={}},changeAppDomain:function(e,t){if(this.maybePreventChange())return!1;if(void 0===t)var n=jQuery(e.target).data(\"domain\"),t=i.channel(\"app\").request(\"get:domainModel\",n);if(i.channel(\"app\").request(\"get:currentDrawer\")&&i.channel(\"app\").request(\"close:drawer\"),0==t.get(\"url\").length){var r=i.channel(\"app\").request(\"get:mainEl\");i.channel(\"app\").request(\"update:currentDomain\",t),jQuery(r).scrollTop(0),i.channel(\"app\").trigger(\"change:currentDomain\",t)}},maybePreventChange:function(){return 0!=Object.keys(this.objPreventChange).length},preventChange:function(e){this.objPreventChange[e]=!0},enableChange:function(e){delete this.objPreventChange[e]}})}),n(\"controllers/app/pushstate\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"change:currentDomain\",this.changePushState)},changePushState:function(){var e=i.channel(\"app\").request(\"get:currentDomain\");history.pushState(null,null,window.location.href+\"&domain=\"+e.get(\"id\"));var t=/domain=\\\\d+/,n=window.location.toString(),r=n.replace(t,\"\");console.log(r)}})}),n(\"controllers/app/hotkeys\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"main\"),\"render:main\",this.changeHotkeys),this.listenTo(i.channel(\"drawer\"),\"opened\",this.changeHotkeys),this.listenTo(i.channel(\"drawer\"),\"render:settingGroup\",this.changeHotkeys),this.listenTo(i.channel(\"hotkeys\"),\"add:newField\",this.addNewField),this.listenTo(i.channel(\"hotkeys\"),\"add:newAction\",this.addNewAction),this.listenTo(i.channel(\"hotkeys\"),\"changeDomain:fields\",this.changeDomainFields),this.listenTo(i.channel(\"hotkeys\"),\"changeDomain:actions\",this.changeDomainActions),this.listenTo(i.channel(\"hotkeys\"),\"changeDomain:settings\",this.changeDomainSettings),this.listenTo(i.channel(\"hotkeys\"),\"close:drawer\",this.closeDrawer)},changeHotkeys:function(){var e=i.channel(\"app\").request(\"get:currentDomain\");jQuery(document).off(\".nfDomainHotkeys\"),jQuery(\"input\").off(\".nfDomainHotkeys\"),e.get(\"hotkeys\")&&jQuery.each(e.get(\"hotkeys\"),function(e,t){jQuery(document).on(\"keydown.nfDomainHotkeys\",null,e,function(e){i.channel(\"hotkeys\").trigger(t,e)}),jQuery(\"input\").on(\"keydown.nfDomainHotkeys\",null,e,function(e){i.channel(\"hotkeys\").trigger(t,e)}),jQuery(\"textarea\").on(\"keydown.nfDomainHotkeys\",null,e,function(e){i.channel(\"hotkeys\").trigger(t,e)})})},addNewField:function(){\"addField\"!=i.channel(\"app\").request(\"get:currentDrawer\")?i.channel(\"app\").request(\"open:drawer\",\"addField\"):i.channel(\"app\").request(\"close:drawer\")},addNewAction:function(){\"addAction\"!=i.channel(\"app\").request(\"get:currentDrawer\")?i.channel(\"app\").request(\"open:drawer\",\"addAction\"):i.channel(\"app\").request(\"close:drawer\")},changeDomainFields:function(){var e=i.channel(\"app\").request(\"get:domainCollection\"),t=e.get(\"fields\");i.channel(\"app\").request(\"change:currentDomain\",{},t)},changeDomainActions:function(){var e=i.channel(\"app\").request(\"get:domainCollection\"),t=e.get(\"actions\");i.channel(\"app\").request(\"change:currentDomain\",{},t)},changeDomainSettings:function(){var e=i.channel(\"app\").request(\"get:domainCollection\"),t=e.get(\"settings\");i.channel(\"app\").request(\"change:currentDomain\",{},t)},closeDrawer:function(){i.channel(\"app\").request(\"close:drawer\")}})}),n(\"controllers/app/cleanState\",[],function(){return Marionette.Object.extend({initialize:function(){this.ignoreAttributes=[\"editActive\"],this.listenTo(i.channel(\"app\"),\"update:setting\",this.setAppClean)},setAppClean:function(e){for(var t in e.changedAttributes()){e.changedAttributes()[t]}i.channel(\"undo-\"+e.get(\"type\")).request(\"ignore:attributes\",this.ignoreAttributes)||this.ignoreAttributes;if(-1!=this.ignoreAttributes.indexOf(t))return!1;i.channel(\"app\").request(\"update:setting\",\"clean\",!1)}})}),n(\"controllers/app/coreUndo\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"changes\").reply(\"undo:changeSetting\",this.undoChangeSetting,this),i.channel(\"changes\").reply(\"undo:addObject\",this.undoAddObject,this),i.channel(\"changes\").reply(\"undo:removeObject\",this.undoRemoveObject,this),i.channel(\"changes\").reply(\"undo:duplicateObject\",this.undoDuplicateObject,this),i.channel(\"changes\").reply(\"undo:sortFields\",this.undoSortFields,this),i.channel(\"changes\").reply(\"undo:addListOption\",this.undoAddListOption,this),i.channel(\"changes\").reply(\"undo:removeListOption\",this.undoRemoveListOption,this),i.channel(\"changes\").reply(\"undo:sortListOptions\",this.undoSortListOptions,this)},undoChangeSetting:function(e,t){var n=e.get(\"model\"),i=e.get(\"changes\"),r=i.attr,a=i.before;n.set(r,a),this.maybeRemoveChange(e,t)},undoAddObject:function(e,t){var n=e.get(\"model\"),r=e.get(\"data\").collection;if(void 0!==r.newIDs&&delete r.newIDs[n.get(\"id\")],!t){var a=i.channel(\"changes\").request(\"get:collection\"),l=a.where({model:n});_.each(l,function(t){t!==e&&a.remove(t)})}r.remove(n),this.maybeRemoveChange(e,t)},undoDuplicateObject:function(e,t){var n=e.get(\"model\"),r=e.get(\"data\").collection;if(!t){var a=i.channel(\"changes\").request(\"get:collection\"),l=a.where({model:n});_.each(l,function(t){t!==e&&a.remove(t)})}r.remove(n),this.maybeRemoveChange(e,t)},undoRemoveObject:function(e,t){var n=e.get(\"model\"),r=e.get(\"data\").collection;if(i.channel(n.get(\"objectDomain\")).request(\"add\",n),delete r.removedIDs[n.get(\"id\")],!t){var a=i.channel(\"changes\").request(\"get:collection\"),l=a.where({model:n});_.each(l,function(t){t!==e&&t.set(\"disabled\",!1)})}r.trigger(\"reset\",r),this.maybeRemoveChange(e,t)},undoSortFields:function(e,t){var n=e.get(\"data\"),r=n.fields,a=i.channel(\"fields\").request(\"get:collection\");_.each(r,function(e){var t=e.before;e.model.set(\"order\",t)}),a.sort(),this.maybeRemoveChange(e,t)},undoAddListOption:function(e,t){var n=e.get(\"model\");if(!t){var r=i.channel(\"changes\").request(\"get:collection\"),a=r.where({model:n});_.each(a,function(t){t!==e&&r.remove(t)})}n.collection.remove(n),this.maybeRemoveChange(e,t)},undoRemoveListOption:function(e,t){var n=e.get(\"model\");if(e.get(\"data\").collection.add(n),!t){var r=i.channel(\"changes\").request(\"get:collection\"),a=r.where({model:n});_.each(a,function(t){t!==e&&t.set(\"disabled\",!1)})}this.maybeRemoveChange(e,t)},undoSortListOptions:function(e,t){var n=e.get(\"data\"),i=n.collection,r=n.objModels;_.each(r,function(e){var t=e.before;e.model.set(\"order\",t)}),i.sort(),this.maybeRemoveChange(e,t)},maybeRemoveChange:function(e,t){var t=void 0!==t&&t;if(!t){i.channel(\"app\").request(\"update:db\");var n=i.channel(\"changes\").request(\"get:collection\");n.remove(e),0==n.length&&(i.channel(\"app\").request(\"update:setting\",\"clean\",!0),i.channel(\"app\").request(\"close:drawer\"))}}})}),n(\"controllers/app/cloneModelDeep\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"app\").reply(\"clone:modelDeep\",this.cloneModelDeep,this)},cloneModelDeep:function(e){var t={};_.each(e.attributes,function(e,n){if(e instanceof Backbone.Collection){var r=i.channel(\"app\").request(\"clone:collectionDeep\",e);t[n]=r}else e instanceof Backbone.Model&&(t[n]=this.cloneModelDeep(e))},this);var n=e.clone();return _.each(t,function(e,t){n.set(t,e)}),n}})}),n(\"controllers/app/getSettingChildView\",[\"views/app/drawer/itemSetting\"],function(e){return Marionette.Object.extend({initialize:function(){i.channel(\"app\").reply(\"get:settingChildView\",this.getSettingChildView,this)},getSettingChildView:function(t){var n=t.get(\"type\");return i.channel(n).request(\"get:settingChildView\",t)||e}})}),n(\"controllers/app/changeSettingDefault\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"app\").reply(\"change:setting\",this.changeSetting,this),this.listenTo(i.channel(\"app\"),\"change:setting\",this.changeSetting,this)},changeSetting:function(e,t,n,r){var a=t.get(\"name\"),l=n.get(a),r=r||null;r||(r=i.channel(t.get(\"type\")).request(\"before:updateSetting\",e,n,a,t)),void 0===r&&(r=jQuery(e.target).val()),n.set(a,r,{settingModel:t}),i.channel(\"setting-\"+a).trigger(\"after:updateSetting\",n,t);var s=r,o={attr:a,before:l,after:s},c=i.channel(\"app\").request(\"get:currentDomain\"),d=(c.get(\"id\"),{object:n.get(\"objectType\"),label:n.get(\"label\"),change:\"Changed \"+t.get(\"label\")+\" from \"+l+\" to \"+s});i.channel(\"changes\").request(\"register:change\",\"changeSetting\",n,o,d)}})}),n(\"views/app/drawer/typeSettingFieldset\",[\"views/app/drawer/itemSetting\"],function(e){return Marionette.CompositeView.extend({template:\"#tmpl-nf-edit-setting-wrap\",childView:e,initialize:function(e){this.collection=this.model.get(\"settings\"),this.childViewOptions={dataModel:e.dataModel},this.dataModel=e.dataModel;var t=this.model.get(\"deps\");if(t)for(var n in t)t.hasOwnProperty(n)&&this.dataModel.on(\"change:\"+n,this.render,this);this.model.on(\"rerender\",this.render,this)},onBeforeDestroy:function(){var e=this.model.get(\"deps\");if(e)for(var t in e)e.hasOwnProperty(t)&&this.dataModel.off(\"change:\"+t,this.render)},onBeforeRender:function(){i.channel(\"app\").trigger(\"before:renderSetting\",this.model,this.dataModel),i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"before:renderSetting\",this.model,this.dataModel,this),i.channel(\"setting-\"+this.model.get(\"name\")).trigger(\"before:renderSetting\",this.model,this.dataModel,this)},onRender:function(){i.channel(\"setting-\"+this.model.get(\"name\")).trigger(\"render:setting\",this.model,this.dataModel,this),i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"render:setting\",this.model,this.dataModel,this)},templateHelpers:function(){var e=this;return{renderVisible:function(){if(!nfAdmin.devMode){if(\"help\"==this.name)return'style=\"display:none;\"';if(\"classes\"==this.name)return'style=\"display:none;\"';if(\"input_limit_set\"==this.name)return'style=\"display:none;\"';if(\"checkbox\"==e.dataModel.get(\"type\")&&\"checkbox_values\"==this.name)return'style=\"display:none;\"';if(\"date\"==e.dataModel.get(\"type\")&&\"year_range\"==this.name)return'style=\"display:none;\"'}if(this.deps)for(var t in this.deps)if(this.deps.hasOwnProperty(t)&&e.dataModel.get(t)!==this.deps[t])return'style=\"display:none;\"';return\"\"},renderSetting:function(){return i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-edit-setting-\"+this.type)(this)},renderClasses:function(){var e=\"\";return void 0!==this.width?e+=this.width:e+=\" one-half\",this.error&&(e+=\" nf-error\"),e},renderError:function(){return this.error?this.error:\"\"}}},attachHtml:function(e,t){jQuery(e.el).find(\".nf-field-sub-settings\").append(t.el)}})}),n(\"models/app/settingModel\",[],function(){return Backbone.Model.extend({defaults:{settings:!1,hide_merge_tags:!1,error:!1},initialize:function(){i.channel(\"app\").trigger(\"init:settingModel\",this),i.channel(this.get(\"type\")).trigger(\"init:settingModel\",this),i.channel(\"setting-name-\"+this.get(\"name\")).trigger(\"init:settingModel\",this),this.on(\"change:error\",this.maybePreventUI,this),void 0!==this.collection&&this.get(\"use_merge_tags\")&&void 0!==this.collection.options.objectType&&this.listenTo(i.channel(\"app\"),\"update:fieldKey\",this.updateKey)},updateKey:function(e){i.channel(\"app\").trigger(\"fire:updateFieldKey\",e,this)},maybePreventUI:function(){this.get(\"error\")?(i.channel(\"drawer\").request(\"prevent:close\",\"setting-\"+this.get(\"name\")+\"-error\"),i.channel(\"app\").request(\"prevent:changeDomain\",\"setting-\"+this.get(\"name\")+\"-error\")):(i.channel(\"drawer\").request(\"enable:close\",\"setting-\"+this.get(\"name\")+\"-error\"),i.channel(\"app\").request(\"enable:changeDomain\",\"setting-\"+this.get(\"name\")+\"-error\"))}})}),n(\"models/app/settingCollection\",[\"models/app/settingModel\"],function(e){return Backbone.Collection.extend({model:e,initialize:function(e,t){this.options=t||{}}})}),n(\"controllers/app/fieldset\",[\"views/app/drawer/typeSettingFieldset\",\"models/app/settingCollection\"],function(e,t){return Marionette.Object.extend({initialize:function(){i.channel(\"fieldset\").reply(\"get:settingChildView\",this.getSettingChildView,this),this.listenTo(i.channel(\"fieldset\"),\"init:settingModel\",this.createSettingsCollection)},getSettingChildView:function(t){return e},createSettingsCollection:function(e){e.set(\"settings\",new t(e.get(\"settings\")))}})}),n(\"controllers/app/toggleSetting\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"setting-type-toggle\").reply(\"renderOnChange\",function(){return!1}),i.channel(\"toggle\").reply(\"before:updateSetting\",this.updateSetting,this)},updateSetting:function(e,t,n,i){if(jQuery(e.target).attr(\"checked\"))var r=1;else var r=0;return r}})}),n(\"controllers/app/buttonToggleSetting\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"setting-type-button-toggle\").reply(\"renderOnChange\",function(){return!1}),i.channel(\"button-toggle\").reply(\"before:updateSetting\",this.updateSetting,this)},updateSetting:function(e,t,n,i){return e.target.value}})}),n(\"controllers/app/numberSetting\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"number\").reply(\"before:updateSetting\",this.updateSetting,this)},updateSetting:function(e,t,n,i){var r=i.get(\"min_val\"),a=i.get(\"max_val\");return void 0!==r&&null!==r&&e.target.value<r&&(t.set(\"value\",r),e.target.value=r),void 0!==a&&null!==a&&e.target.value>a&&(t.set(\"value\",a),e.target.value=a),e.target.value}})}),n(\"controllers/app/radioSetting\",[],function(){return Marionette.Object.extend({initialize:function(){console.log(i.channel(\"radio\")),i.channel(\"radio\").reply(\"before:updateSetting\",this.updateSetting,this)},updateSetting:function(e,t,n,i){console.log(\"test\")}})}),n(\"controllers/app/itemControls\",[],function(){return Marionette.Object.extend({deleting:!1,initialize:function(){this.listenTo(i.channel(\"app\"),\"click:edit\",this.clickEdit),this.listenTo(i.channel(\"app\"),\"click:delete\",this.maybeDelete),this.listenTo(i.channel(\"app\"),\"click:duplicate\",this.clickDuplicate)},clickEdit:function(e,t){if(!this.deleting){var n=i.channel(\"app\").request(\"get:currentDomain\"),r=n.get(\"id\"),a=i.channel(r).request(\"get:type\",t.get(\"type\"));i.channel(\"app\").request(\"open:drawer\",\"editSettings\",{model:t,groupCollection:a.get(\"settingGroups\")})}},maybeDelete:function(e,t){this.deleting=!0;var n=t.get(\"id\"),i=t.get(\"objectType\"),r=[\"html\",\"submit\",\"hr\",\"recaptcha\",\"spam\",\"creditcard\",\"creditcardcvc\",\"creditcardexpiration\",\"creditcardfullname\",\"creditcardnumber\",\"creditcardzip\"];if(\"field\"!=i.toLowerCase())this.clickDelete(e,t);else if(\"tmp\"===n.toString().substring(0,3)||-1!=jQuery.inArray(t.get(\"type\"),r))this.clickDelete(e,t);else{var a=Backbone.Radio.channel(\"app\").request(\"get:formModel\"),l={action:\"nf_maybe_delete_field\",security:nfAdmin.ajaxNonce,formID:a.get(\"id\"),fieldKey:t.get(\"key\"),fieldID:n},s=this;jQuery.post(ajaxurl,l).done(function(n){return JSON.parse(n).data.field_has_data?(s.doDeleteFieldModal(e,t),!1):(s.clickDelete(e,t),!1)})}},doDeleteFieldModal:function(e,t){var n=this,i={width:400,closeOnClick:!1,closeOnEsc:!0,content:nfi18n.fieldDataDeleteMsg,btnPrimary:{text:nfi18n.delete,callback:function(){r.toggleModal(!1),r.destroy(),n.clickDelete(e,t)}},btnSecondary:{text:nfi18n.cancel,callback:function(){r.toggleModal(!1),r.destroy(),n.deleting=!1}}},r=new NinjaModal(i)},clickDelete:function(e,t){var n=i.channel(\"app\").request(\"clone:modelDeep\",t),r={object:t.get(\"objectType\"),label:t.get(\"label\"),change:\"Removed\",dashicon:\"dismiss\"},a={collection:t.collection},l=i.channel(\"changes\").request(\"get:collection\"),s=l.where({model:t});_.each(s,function(e){var i=e.get(\"data\");void 0!==i.fields&&_.each(i.fields,function(e,r){e.model==t&&(i.fields[r].model=n)}),e.set(\"data\",i),e.set(\"model\",n),e.set(\"disabled\",!0)}),i.channel(\"changes\").request(\"register:change\",\"removeObject\",n,null,r,a);var o=i.channel(\"app\").request(\"get:currentDomain\"),c=o.get(\"id\");i.channel(c).request(\"delete\",t),this.deleting=!1},clickDuplicate:function(e,t){var n=i.channel(\"app\").request(\"clone:modelDeep\",t),r=i.channel(\"app\").request(\"get:currentDomain\"),a=r.get(\"id\");n.set(\"label\",n.get(\"label\")+\" Copy\");var l=i.channel(a).request(\"get:tmpID\");n.set(\"id\",l),i.channel(a).request(\"add\",n,!1,!1,\"duplicate\");var s={object:t.get(\"objectType\"),label:t.get(\"label\"),change:\"Duplicated\",dashicon:\"admin-page\"},o={collection:i.channel(a).request(\"get:collection\")};i.channel(\"changes\").request(\"register:change\",\"duplicateObject\",n,null,s,o),\nt.trigger(\"change:label\",t),i.channel(\"app\").request(\"update:db\")}})}),n(\"controllers/app/mergeTags\",[\"models/app/mergeTagCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.tagSectionCollection=new e;var t=this;_.each(mergeTags,function(n){if(n.tags)var i=new e(n.tags);else var i=\"\";t.tagSectionCollection.add({id:n.id,label:n.label,tags:i,default_group:n.default_group})});var n=this.tagSectionCollection.get(\"fields\").get(\"tags\"),r=i.channel(\"fields\").request(\"get:collection\");_.each(r.models,function(e){\"submit\"!==e.get(\"type\")&&n.add({id:e.get(\"id\"),label:e.get(\"label\"),tag:t.getFieldKeyFormat(e.get(\"key\"))})});var a=new e,l=i.channel(\"app\").request(\"get:formModel\"),s=l.get(\"settings\").get(\"calculations\");_.each(s.models,function(e){a.add({label:e.get(\"name\"),tag:\"{calc:\"+e.get(\"name\")+\"}\"})}),this.tagSectionCollection.get(\"calcs\").set(\"tags\",a),this.currentElement={},this.settingModel={},this.open=!1,this.listenTo(i.channel(\"mergeTags\"),\"click:mergeTag\",this.clickMergeTag),this.listenTo(i.channel(\"fields\"),\"add:field\",this.addFieldTags),this.listenTo(i.channel(\"fields\"),\"delete:field\",this.deleteFieldTags),this.listenTo(i.channel(\"option-repeater-calculations\"),\"update:option\",this.updateCalcTags),this.listenTo(i.channel(\"option-repeater-calculations\"),\"remove:option\",this.updateCalcTags),i.channel(\"mergeTags\").reply(\"update:currentElement\",this.updateCurrentElement,this),i.channel(\"mergeTags\").reply(\"update:currentSetting\",this.updateCurrentSetting,this),i.channel(\"mergeTags\").reply(\"get:collection\",this.getCollection,this),i.channel(\"mergeTags\").reply(\"get:mergeTag\",this.getSectionModel,this),this.listenTo(i.channel(\"fieldSetting-id\"),\"update:setting\",this.updateID),this.listenTo(i.channel(\"fieldSetting-key\"),\"update:setting\",this.updateKey),this.listenTo(i.channel(\"app\"),\"replace:fieldKey\",this.replaceFieldKey),i.channel(\"app\").reply(\"get:fieldKeyFormat\",this.getFieldKeyFormat,this)},initMergeTags:function(e){var t=i.channel(\"mergeTags\").request(\"get:view\"),n=this;this.jBoxes={};var n=this;jQuery(e.el).find(\".merge-tags\").each(function(){if(void 0===jQuery(this).data(\"jBox-id\")){var i=jQuery(this).jBox(\"Tooltip\",{title:\"Insert Merge Tag\",trigger:\"click\",position:{x:\"center\",y:\"bottom\"},closeOnClick:\"body\",closeOnEsc:!0,theme:\"TooltipBorder\",maxHeight:200,onOpen:function(){t.reRender(e.model),this.setContent(jQuery(\".merge-tags-content\"));var i=jQuery(this.target).prev(\".setting\");0==i.length&&(i=jQuery(e.el).find(\".setting\")),n.updateCurrentSetting(e.model),n.updateCurrentElement(i)},onClose:function(){}});jQuery(this).data(\"jBox-id\",i.id)}})},clickMergeTag:function(e,t){if(void 0!==this.settingModel.get(\"settingModel\")&&\"calculations\"==this.settingModel.get(\"settingModel\").get(\"name\")){console.log(t);var n=jQuery(this.currentElement).val(),i=jQuery(this.currentElement).caret(),r=i+t.get(\"tag\").length,a=void 0!==t.get(\"calcTag\")?t.get(\"calcTag\"):t.get(\"tag\");n=n.substr(0,i)+a+n.substr(i),jQuery(this.currentElement).val(n).caret(r).trigger(\"change\")}else if(\"rte\"==this.settingModel.get(\"type\"))jQuery(this.currentElement).summernote(\"insertText\",t.get(\"tag\"));else{var n=jQuery(this.currentElement).val(),i=jQuery(this.currentElement).caret(),r=i+t.get(\"tag\").length;n=n.substr(0,i)+t.get(\"tag\")+n.substr(i),jQuery(this.currentElement).val(n).caret(r).trigger(\"change\")}},addFieldTags:function(e){\"submit\"!==e.get(\"type\")&&this.tagSectionCollection.get(\"fields\").get(\"tags\").add({id:e.get(\"id\"),label:e.get(\"label\"),tag:this.getFieldKeyFormat(e.get(\"key\")),calcTag:this.getFieldKeyFormatCalc(e.get(\"key\"))})},deleteFieldTags:function(e){var t=e.get(\"id\"),n=this.tagSectionCollection.get(\"fields\").get(\"tags\").get(t);this.tagSectionCollection.get(\"fields\").get(\"tags\").remove(n)},updateCalcTags:function(t){var n=new e,r=i.channel(\"app\").request(\"get:formModel\"),a=r.get(\"settings\").get(\"calculations\");_.each(a.models,function(e){n.add({label:e.get(\"name\"),tag:\"{calc:\"+e.get(\"name\")+\"}\"})}),this.tagSectionCollection.get(\"calcs\").set(\"tags\",n)},openMergeTags:function(e){\"TEXTAREA\"!=jQuery(e.target)[0].tagName&&\"INPUT\"!=jQuery(e.target)[0].tagName||jQuery(e.target).parent().find(\".merge-tags\").click()},returnMergeTags:function(e){if(this.open){e.preventDefault();var t=this.fields.where({active:!0})[0];t&&this.clickMergeTag(e,t)}},upMergeTags:function(e){this.open&&(e.preventDefault(),this.changeActiveTag(\"up\"))},downMergeTags:function(e){this.open&&(e.preventDefault(),this.changeActiveTag(\"down\"))},changeActiveTag:function(e){if(\"down\"==e)var t=1;else var t=-1;if(0<this.fields.where({active:!0}).length){var n=this.fields.where({active:!0})[0],i=this.fields.indexOf(n);n.set(\"active\",!1);var r=this.fields.models[i+t];r&&r.set(\"active\",!0)}else 0<this.fields.where({active:!0})?console.log(\"system\"):0<this.userInfo.where({active:!0})?console.log(\"userinfo\"):0<this.fields.models.length?this.fields.models[0].set(\"active\",!0):this.system.models[0].set(\"active\",!0)},updateCurrentElement:function(e){this.currentElement=e},updateCurrentSetting:function(e){this.settingModel=e},getCollection:function(){return this.tagSectionCollection},getSectionModel:function(e){return this.tagSectionCollection.get(e)},updateOpen:function(e){this.open=e,_.each(this.tagSectionCollection.get(\"fields\").models,function(e){e.set(\"active\",!1)})},updateID:function(e){var t=this.getFieldKeyFormat(e.get(\"key\")),n=this.tagSectionCollection.get(\"fields\").get(\"tags\").find(function(e){return t==e.get(\"tag\")});void 0!==n&&n.set(\"id\",e.get(\"id\"))},updateKey:function(e){var t=e.get(\"key\"),n=this.tagSectionCollection.get(\"fields\").get(\"tags\").get(e.get(\"id\"));void 0!==n&&n.set(\"tag\",this.getFieldKeyFormat(t))},getFieldKeyFormat:function(e){return\"{field:\"+e+\"}\"},getFieldKeyFormatCalc:function(e){return\"{field:\"+e+\":calc}\"},replaceFieldKey:function(e,t,n){var i=this.getFieldKeyFormat(t._previousAttributes.key),r=this.getFieldKeyFormat(t.get(\"key\")),a=n.get(\"name\"),l=e.get(a);if(\"calculations\"==a&&void 0!==e.get(\"calculations\")){return e.get(\"calculations\").each(function(e){var t=i.slice(0,i.length-1)+\":calc}\",n=r.slice(0,r.length-1)+\":calc}\";if(\"string\"==typeof(l=e.get(\"eq\"))){var a=new RegExp(t,\"g\"),s=l.replace(a,n);a=new RegExp(i,\"g\"),s=s.replace(a,r),e.set(\"eq\",s)}}),!1}if(\"string\"==typeof l){var s=new RegExp(i,\"g\");newVal=l.replace(s,r),e.set(a,newVal)}}})}),n(\"models/app/mergeTagLookupCollection\",[\"models/app/mergeTagModel\"],function(e){return Backbone.Collection.extend({model:e})}),n(\"views/app/drawer/mergeTag\",[],function(){return Marionette.ItemView.extend({tagName:\"li\",template:\"#tmpl-nf-merge-tag-box-tag\",events:{click:\"insertTag\"},insertTag:function(){i.channel(\"mergeTags\").request(\"insert:tag\",this.model.get(\"tag\"))}})}),n(\"views/app/drawer/mergeTagList\",[\"views/app/drawer/mergeTag\"],function(e){return Marionette.CollectionView.extend({tagName:\"ul\",childView:e,calc:!1,initialize:function(){i.channel(\"merge-tags\").reply(\"update:taglist\",this.sectionFilter,this),i.channel(\"merge-tags\").reply(\"filtersearch\",this.searchFilter,this)},filter:function(e,t,n){return\"fields\"==e.get(\"section\")},sectionFilter:function(e,t){if(this.filter=function(t,n,i){return e==t.get(\"section\")},t&&(this.calc=!0),this.calc){var n=this.excludeFromCalcs();this.filter=function(t,i,r){return e==t.get(\"section\")&&-1==n.indexOf(t.get(\"tag\"))}}this.render(),i.channel(\"merge-tags\").trigger(\"after:filtersearch\",e)},searchFilter:function(e){if(this.calc)var t=this.excludeFromCalcs();this.filter=function(n,i,r){var a=n.get(\"label\").toLowerCase().indexOf(e.toLowerCase().replace(\":\",\"\"))>=0,l=n.get(\"tag\").toLowerCase().indexOf(e.toLowerCase())>=0;return(!this.calc||-1==t.indexOf(n.get(\"tag\")))&&(a||l)},this.render(),i.channel(\"merge-tags\").trigger(\"after:filtersearch\")},excludeFromCalcs:function(){var e=i.channel(\"fields\").request(\"get:collection\"),t=[],n=[\"product\",\"quantity\",\"total\",\"shipping\",\"date\"];return _.each(e.models,function(e){-1!=n.indexOf(e.get(\"type\"))&&t.push(\"{field:\"+e.get(\"key\")+\"}\")}),t}})}),n(\"views/app/drawer/mergeTagGroup\",[],function(){return Marionette.ItemView.extend({tagName:\"li\",template:\"#tmpl-nf-merge-tag-box-section\",events:{click:\"onClick\"},initialize:function(){this.listenTo(i.channel(\"merge-tags\"),\"after:filtersearch\",this.updateActive)},onClick:function(){this.updateTags()},updateTags:function(){i.channel(\"merge-tags\").request(\"update:taglist\",this.model.get(\"id\"))},updateActive:function(e){this.$el.removeClass(\"active\"),e==this.model.get(\"id\")&&this.$el.addClass(\"active\")},setActive:function(){this.$el.addClass(\"active\"),this.$el.siblings().removeClass(\"active\")}})}),n(\"views/app/drawer/mergeTagGroupList\",[\"views/app/drawer/mergeTagGroup\"],function(e){return Marionette.CollectionView.extend({tagName:\"ul\",childView:e,initialize:function(){this.listenTo(i.channel(\"merge-tags\"),\"open\",this.render,this)},filter:function(e,t,n){return 0<e.get(\"tags\").length}})}),n(\"views/app/drawer/mergeTagFilter\",[],function(){return Marionette.ItemView.extend({template:\"#tmpl-nf-merge-tag-box-filter\",events:{\"keyup input\":\"updateFilter\"},updateFilter:function(e){if(13==e.keyCode){var t=jQuery(\"#merge-tags-box .merge-tag-list ul li span\").first().data(\"tag\");return i.channel(\"mergeTags\").request(\"insert:tag\",t),jQuery(\"#merge-tags-box\").css(\"display\",\"none\"),jQuery(\"#merge-tags-box\").removeClass(),jQuery(\".merge-tag-focus\").removeClass(\"merge-tag-focus\"),void jQuery(\".merge-tag-focus-overlay\").removeClass(\"merge-tag-focus-overlay\")}var n=this.$el.find(\"input\").val();i.channel(\"merge-tags\").request(\"filtersearch\",n)}})}),n(\"views/app/drawer/mergeTagBox\",[],function(){return Marionette.LayoutView.extend({el:\"#merge-tags-box\",template:\"#tmpl-nf-merge-tag-box\",regions:{filter:\".merge-tag-filter\",sections:\".merge-tag-sections\",tags:\".merge-tag-list\"}})}),n(\"controllers/app/mergeTagBox\",[\"models/app/mergeTagModel\",\"models/app/mergeTagLookupCollection\",\"views/app/drawer/mergeTag\",\"views/app/drawer/mergeTagList\",\"views/app/drawer/mergeTagGroup\",\"views/app/drawer/mergeTagGroupList\",\"views/app/drawer/mergeTagFilter\",\"views/app/drawer/mergeTagBox\"],function(e,t,n,r,a,l,s,o){return Marionette.Object.extend({caret:0,old:\"\",initialize:function(){this.listenTo(i.channel(\"drawer\"),\"render:settingGroup\",function(){jQuery(\".merge-tags\").off(\"click\"),jQuery(\".merge-tags\").on(\"click\",this.mergeTagsButtonClick)}),this.listenTo(i.channel(\"app\"),\"after:appStart\",this.afterAppStart),this.listenTo(i.channel(\"app\"),\"before:renderSetting\",this.beforeRenderSetting),this.listenTo(i.channel(\"drawer\"),\"before:close\",this.beforeDrawerClose);var e=this;i.channel(\"mergeTags\").reply(\"set:caret\",function(t){e.caret=t}),i.channel(\"mergeTags\").reply(\"get:caret\",function(){return e.caret});var e=this;i.channel(\"mergeTags\").reply(\"set:old\",function(t){e.old=t}),i.channel(\"mergeTags\").reply(\"get:old\",function(){return e.old}),i.channel(\"mergeTags\").reply(\"insert:tag\",this.insertTag.bind(this)),this.listenTo(i.channel(\"option-repeater\"),\"add:option\",function(t){var n=\"#\"+t.cid+\" .has-merge-tags input.setting\";jQuery(n).on(\"focus\",function(t){e.focusCallback(t,n,\"option-repeater\")}),jQuery(n).on(\"keyup\",function(t){e.keyupCallback(t,n,\"option-repeater\")}),jQuery(n).siblings(\".nf-list-options .merge-tags\").off(\"click\"),jQuery(n).siblings(\".nf-list-options .merge-tags\").on(\"click\",this.mergeTagsButtonClick)}),this.listenTo(i.channel(\"drawer\"),\"opened\",function(){jQuery(\".nf-list-options .merge-tags\").off(\"click\"),jQuery(\".nf-list-options .merge-tags\").on(\"click\",this.mergeTagsButtonClick)}),this.listenTo(i.channel(\"setting-calculations-option\"),\"render:setting\",this.renderSetting),this.listenTo(i.channel(\"drawer\"),\"opened\",function(){jQuery(\".nf-list-options.calculations .merge-tags\").off(\"click\"),jQuery(\".nf-list-options.calculations .merge-tags\").on(\"click\",this.mergeTagsButtonClick)}),this.listenTo(i.channel(\"summernote\"),\"focus\",function(t,n){e.focusCallback(!1,n,\"rte\")}),this.listenTo(i.channel(\"summernote\"),\"keydown\",function(e,t){jQuery(t).closest(\".nf-setting\").find(\".setting\").summernote(\"saveRange\")}),this.listenTo(i.channel(\"summernote\"),\"keyup\",function(t,n){e.keyupCallback(t,n,\"rte\")}),this.listenTo(i.channel(\"drawer\"),\"opened\",function(){jQuery(\".note-editor .merge-tags\").off(\"click\"),jQuery(\".note-editor .merge-tags\").on(\"click\",this.mergeTagsButtonClick)}),jQuery(document).on(\"keyup\",function(e){27==e.keyCode&&(i.channel(\"mergeTags\").request(\"insert:tag\",\"\"),jQuery(\"#merge-tags-box\").css(\"display\",\"none\"),i.channel(\"drawer\").request(\"enable:close\"),jQuery(\"#merge-tags-box\").removeClass(),jQuery(\".merge-tag-focus\").blur(),jQuery(\".merge-tag-focus\").removeClass(\"merge-tag-focus\"),jQuery(\".merge-tag-focus-overlay\").removeClass(\"merge-tag-focus-overlay\"))}),this.listenTo(Backbone.Radio.channel(\"fields\"),\"add:field\",this.afterAppStart),this.listenTo(Backbone.Radio.channel(\"fields\"),\"delete:field\",this.afterAppStart),this.listenTo(Backbone.Radio.channel(\"fieldSetting-key\"),\"update:setting\",this.afterAppStart),this.listenTo(Backbone.Radio.channel(\"calcs\"),\"update:calc\",this.afterAppStart),this.listenTo(Backbone.Radio.channel(\"app\"),\"change:currentDomain\",this.afterAppStart)},afterAppStart:function(){var e=Backbone.Radio.channel(\"app\").request(\"get:currentDomain\"),n=i.channel(\"mergeTags\").request(\"get:collection\"),a=[];n.each(function(t){t.get(\"tags\").each(function(n){\"fields\"==e.get(\"id\")&&\"{submission:sequence}\"==n.get(\"tag\")||a.push({label:n.get(\"label\"),tag:n.get(\"tag\"),section:t.get(\"id\")})})});var c=new o;c.render();var d=new t(a),u=new r({collection:d}),h=new l({collection:n});c.getRegion(\"tags\").show(u),c.getRegion(\"sections\").show(h),c.getRegion(\"filter\").show(new s)},beforeRenderSetting:function(e,t){if(void 0!==e.get(\"use_merge_tags\")&&e.get(\"use_merge_tags\")){var n=e.get(\"name\");this.listenTo(i.channel(\"setting-\"+n),\"render:setting\",this.renderSetting)}},renderSetting:function(e,t,n){n.$el.find(\".merge-tags\").off(\"click\"),n.$el.find(\".merge-tags\").on(\"click\",this.mergeTagsButtonClick),0==jQuery(\"#merge-tags-box\").length&&this.afterAppStart(),jQuery(\"#nf-drawer\").on(\"scroll\",function(){if(0!=jQuery(\".merge-tag-focus\").length){var e=jQuery(\".merge-tag-focus\").closest(\".nf-setting\").find(\".note-editor\");if(0!=e.length)var t=e.offset().top-jQuery(window).scrollTop(),n=e.outerHeight();else var t=jQuery(\".merge-tag-focus\").offset().top-jQuery(window).scrollTop(),n=jQuery(\".merge-tag-focus\").outerHeight();var i=t+n,r=window.innerHeight,a=jQuery(\"#merge-tags-box\").outerHeight();i+a>r&&(i=t-a),0>i&&(i=t),jQuery(\"#merge-tags-box\").css(\"top\",i);var l=jQuery(\"#merge-tags-box\").outerHeight();jQuery(\"#nf-drawer\").css(\"padding-bottom\",l+\"px\");var s=jQuery(\".merge-tag-focus\").closest(\".nf-list-options-tbody\");if(0!=s.length){var o=s.offset().left-jQuery(window).scrollLeft();jQuery(\"#merge-tags-box\").css(\"left\",o)}else{var c=jQuery(\".merge-tag-focus\").closest(\".nf-settings\").offset().left-jQuery(window).scrollLeft();jQuery(\"#merge-tags-box\").css(\"left\",c),jQuery(\"#merge-tags-box\").css(\"width\",jQuery(\".merge-tag-focus\").closest(\".nf-settings\").width())}}}),jQuery(n.el).find(\".setting\").on(\"focus\",this.focusCallback),jQuery(n.el).find(\".setting\").on(\"keyup\",this.keyupCallback)},beforeDrawerClose:function(){jQuery(\"#merge-tags-box\").css(\"display\",\"none\"),i.channel(\"drawer\").request(\"enable:close\")},insertTag:function(e){var t=jQuery(\".merge-tag-focus\");if(0!=t.closest(\".nf-setting\").first().find(\".note-editable\").length&&(t=t.closest(\".nf-setting\").first().find(\".note-editable\")),1<t.length&&(t=t.first()),t.hasClass(\"note-editable\"))var n=t.closest(\".nf-setting\").find(\".setting\").summernote(\"code\");else var n=t.val();for(var r=i.channel(\"mergeTags\").request(\"get:old\"),a=e,l=i.channel(\"mergeTags\").request(\"get:caret\"),s=/{([a-zA-Z0-9]|:|_||-})*/g;match=s.exec(n);)if(r==match[0]){var o=n.slice(0,match.index)+a+n.slice(s.lastIndex);if(t.hasClass(\"note-editable\")){t.closest(\".nf-setting\").find(\".setting\").summernote(\"code\",o);var c=t,d=null;_.each(c[0].childNodes,function(e,t){if(!d&&(e.nodeValue||e.innerHTML)){if(e.nodeValue)var n=e.nodeValue;else if(e.innerHTML)var n=e.innerHTML;if(-1!=n.indexOf(a)){n=n.replace(/&nbsp;/g,\" \");var i=n.indexOf(a)+r.length;-1==l&&(l=n.indexOf(a)+1),l==i&&(d=c[0].childNodes[t])}}}),d||(d=c[0].childNodes[0]);var u=l-r.length+a.length,h=document.createRange(),g=window.getSelection();if(0!=d.childNodes.length)try{h.setStart(d.childNodes[0],u)}catch(e){console.log(d),console.log(\"error\")}else try{h.setStart(d,u)}catch(e){console.log(\"error\")}h.collapse(!0),g.removeAllRanges(),g.addRange(h)}else t.val(o),t.change(),t.caret(l-r.length+a.length)}jQuery(\"#merge-tags-box\").css(\"display\",\"none\"),i.channel(\"drawer\").request(\"enable:close\"),t.removeClass(\"merge-tag-focus\"),t.closest(\".merge-tag-focus-overlay\").removeClass(\"merge-tag-focus-overlay\")},mergeTagsButtonClick:function(e){var t=jQuery(this);if(t.siblings().hasClass(\"merge-tag-focus\"))return i.channel(\"mergeTags\").request(\"insert:tag\",\"\"),jQuery(\"#merge-tags-box\").css(\"display\",\"none\"),i.channel(\"drawer\").request(\"enable:close\"),jQuery(\".merge-tag-focus\").removeClass(\"merge-tag-focus\"),void jQuery(\".merge-tag-focus-overlay\").removeClass(\"merge-tag-focus-overlay\");if(0!==t.closest(\".nf-setting, .nf-table-row\").find(\".note-tools\").length){var n=t.closest(\".note-editor\").siblings(\".setting\").first();t.closest(\".nf-setting\").find(\".setting\").summernote(\"insertText\",\"{\"),i.channel(\"mergeTags\").request(\"set:caret\",-1)}else{var n=t.siblings(\".setting\").first(),r=n.val()||\"\";n.val(r+\"{\").change(),i.channel(\"mergeTags\").request(\"set:caret\",r.length+1)}t.parent().hasClass(\"note-tools\"),i.channel(\"mergeTags\").request(\"set:old\",\"{\"),n.addClass(\"merge-tag-focus\");var a=t.attr(\"autocomplete\");t.attr(\"autocomplete\",\"off\"),t.data(\"autocomplete\",a);var l=t.closest(\".nf-setting, .nf-table-row\");if(0!=l.find(\".note-editor\").length?l.find(\".note-editor\").addClass(\"merge-tag-focus-overlay\"):l.addClass(\"merge-tag-focus-overlay\"),\"eq\"==jQuery(e.target).prev(\"textarea\").data(\"id\"))var s=!0;else var s=!1;i.channel(\"merge-tags\").request(\"update:taglist\",\"fields\",s),jQuery(\"#merge-tags-box\").css(\"display\",\"block\"),i.channel(\"drawer\").request(\"prevent:close\"),jQuery(\".merge-tag-focus-overlay\").off(\"click\"),jQuery(\".merge-tag-focus-overlay\").on(\"click\",function(e){jQuery(e.target).hasClass(\"note-editor\")&&(i.channel(\"mergeTags\").request(\"insert:tag\",\"\"),jQuery(\"#merge-tags-box\").css(\"display\",\"none\"),i.channel(\"drawer\").request(\"enable:close\"),jQuery(\"#merge-tags-box\").removeClass(),jQuery(\".merge-tag-focus\").removeClass(\"merge-tag-focus\"),jQuery(\".merge-tag-focus-overlay\").removeClass(\"merge-tag-focus-overlay\"))}),setTimeout(function(){jQuery(\"#merge-tags-box\").find(\".merge-tag-filter\").find(\"input\").focus()},500)},focusCallback:function(e,t,n){var n=n||\"setting\",i=void 0===t?jQuery(this):jQuery(t);if(jQuery(\".merge-tag-focus\").each(function(e,t){this!=t&&t.removeClass(\"merge-tag-focus\")}),\"rte\"==n)var r=i.closest(\".nf-setting\").find(\".note-editor\").offset().top-jQuery(window).scrollTop(),a=i.closest(\".nf-setting\").find(\".note-editor\").outerHeight();else var r=i.offset().top-jQuery(window).scrollTop(),a=i.outerHeight();var l=r+a,s=window.innerHeight,o=jQuery(\"#merge-tags-box\").outerHeight();l+o>s&&(l=r-o),0>l&&(l=r),jQuery(\"#merge-tags-box\").css(\"top\",l);var c=i.closest(\".nf-list-options-tbody\");if(0!=c.length){var d=c.offset().left-jQuery(window).scrollLeft();jQuery(\"#merge-tags-box\").css(\"left\",d)}else if(\"rte\"==n){var u=i.closest(\".nf-setting\").find(\".note-editor\").offset().left-jQuery(window).scrollLeft();jQuery(\"#merge-tags-box\").css(\"left\",u),jQuery(\"#merge-tags-box\").css(\"width\",i.closest(\".nf-setting\").find(\".note-editor\").width())}else{var u=jQuery(this).closest(\".nf-settings\").offset().left-jQuery(window).scrollLeft();jQuery(\"#merge-tags-box\").css(\"left\",u),jQuery(\"#merge-tags-box\").css(\"width\",i.closest(\".nf-settings\").width())}var h=jQuery(this).data(\"id\")},keyupCallback:function(e,t,n){var n=n||\"setting\";if(13==e.keyCode){var r=jQuery(\"#merge-tags-box .merge-tag-list ul li span\").first().data(\"tag\");return i.channel(\"mergeTags\").request(\"insert:tag\",r),jQuery(\"#merge-tags-box\").css(\"display\",\"none\"),i.channel(\"drawer\").request(\"enable:close\"),jQuery(\"#merge-tags-box\").removeClass(),jQuery(\".merge-tag-focus\").removeClass(\"merge-tag-focus\"),void jQuery(\".merge-tag-focus-overlay\").removeClass(\"merge-tag-focus-overlay\")}if(void 0!==t)var a=jQuery(t);else var a=jQuery(this);var l=jQuery(this).data(\"id\");if(!l||\"eq\"!=l){if(\"rte\"==n){var s=a.summernote(\"createRange\");if(s)var o=s.so;else var o=0;a.closest(\".nf-setting\").find(\".setting\").summernote(\"saveRange\")}else var o=a.caret();if(i.channel(\"mergeTags\").request(\"set:caret\",o),\"rte\"==n)var c=a.summernote(\"code\").match(new RegExp(/{([a-zA-Z0-9]|:|_|-|})*/g));else var c=a.val().match(new RegExp(/{([a-zA-Z0-9]|:|_|-|})*/g));if(c=_.filter(c,function(e){return-1==e.indexOf(\"}\")}),0!==c.length){i.channel(\"mergeTags\").request(\"set:old\",c[0]),jQuery(\"#merge-tags-box\").css(\"display\",\"block\"),i.channel(\"drawer\").request(\"prevent:close\"),a.addClass(\"merge-tag-focus\");var d=jQuery(\"#merge-tags-box\").outerHeight();jQuery(\"#nf-drawer\").css(\"padding-bottom\",d+\"px\");var u=a.attr(\"autocomplete\");a.attr(\"autocomplete\",\"off\"),a.data(\"autocomplete\",u);var h=a.closest(\".nf-setting, .nf-table-row\");0!=h.find(\".note-editor\").length?h.find(\".note-editor\").addClass(\"merge-tag-focus-overlay\"):h.addClass(\"merge-tag-focus-overlay\"),h.off(\"click\"),h.on(\"click\",function(e){-1!==(jQuery(e.target).attr(\"class\")||[]).indexOf(\"merge-tag-focus-overlay\")&&(i.channel(\"mergeTags\").request(\"insert:tag\",\"\"),jQuery(\"#merge-tags-box\").css(\"display\",\"none\"),i.channel(\"drawer\").request(\"enable:close\"),jQuery(\"#merge-tags-box\").removeClass(),jQuery(\".merge-tag-focus\").removeClass(\"merge-tag-focus\"),jQuery(\".merge-tag-focus-overlay\").removeClass(\"merge-tag-focus-overlay\"))});c[0].replace(\"{\",\"\")}else jQuery(\"#merge-tags-box\").css(\"display\",\"none\"),i.channel(\"drawer\").request(\"enable:close\"),jQuery(\"#merge-tags-box\").removeClass(),jQuery(\".merge-tag-focus\").removeClass(\"merge-tag-focus\"),jQuery(\".merge-tag-focus-overlay\").removeClass(\"merge-tag-focus-overlay\")}}})}),n(\"controllers/app/itemSettingFill\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"before:renderSetting\",this.beforeRenderSetting)},beforeRenderSetting:function(e,t){e.get(\"fill\")}})}),n(\"controllers/app/confirmPublish\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"click:confirmPublish\",this.confirmPublish)},confirmPublish:function(){var e=i.channel(\"app\").request(\"get:formModel\");1==e.get(\"settings\").get(\"add_submit\")&&i.channel(\"fields\").request(\"add\",{type:\"submit\",label:\"Submit\",order:9999}),e.set(\"show_publish_options\",!1),i.channel(\"app\").request(\"update:db\",\"publish\")}})}),n(\"controllers/app/rte\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"setting-type-rte\").reply(\"renderOnChange\",function(){return!1}),this.listenTo(i.channel(\"rte\"),\"init:settingModel\",this.initSettingModel),this.listenTo(i.channel(\"setting-type-rte\"),\"render:setting\",this.renderSetting),this.listenTo(i.channel(\"setting-type-rte\"),\"destroy:setting\",this.destroySetting),this.listenTo(i.channel(\"setting-type-rte\"),\"click:extra\",this.clickExtra),this.meta_image_frame,jQuery.summernote.options.icons={align:\"dashicons dashicons-editor-alignleft\",alignCenter:\"dashicons dashicons-editor-aligncenter\",alignJustify:\"dashicons dashicons-editor-justify\",alignLeft:\"dashicons dashicons-editor-alignleft\",alignRight:\"dashicons dashicons-editor-alignright\",indent:\"dashicons dashicons-editor-indent\",outdent:\"dashicons dashicons-editor-outdent\",bold:\"dashicons dashicons-editor-bold\",caret:\"dashicons dashicons-arrow-down\",close:\"dashicons dashicons-dismiss\",code:\"dashicons dashicons-editor-code\",eraser:\"dashicons dashicons-editor-removeformatting\",italic:\"dashicons dashicons-editor-italic\",link:\"dashicons dashicons-admin-links\",unlink:\"dashicons dashicons-editor-unlink\",magic:\"dashicons dashicons-editor-paragraph\",minus:\"dashicons dashicons-minus\",orderedlist:\"dashicons dashicons-editor-ol\",redo:\"dashicons dashicons-redo\",square:\"dashicons fa-square\",table:\"dashicons dashicons-editor-table\",underline:\"dashicons dashicons-editor-underline\",undo:\"dashicons dashicons-undo\",unorderedlist:\"dashicons dashicons-editor-ul\"},this.currentContext={}},initSettingModel:function(e){e.set(\"hide_merge_tags\",!0)},initRTE:function(e,t,n){var r=this,a=function(e){return r.linkButton(e)},l=function(e){return r.mediaButton(e)},s=this.mergeTags(),o=[[\"paragraphStyle\",[\"style\"]],[\"fontStyle\",[\"bold\",\"italic\",\"underline\",\"clear\"]],[\"lists\",[\"ul\",\"ol\"]],[\"paragraph\",[\"paragraph\"]],[\"customGroup\",[\"linkButton\",\"unlink\"]],[\"table\",[\"table\"]],[\"actions\",[\"undo\",\"redo\"]],[\"tools\",[\"mediaButton\",\"mergeTags\",\"codeview\"]]];jQuery(n.el).find(\"div.setting\").summernote({toolbar:o,buttons:{linkButton:a,mergeTags:s,mediaButton:l},height:150,codemirror:{theme:\"monokai\",lineNumbers:!0,lineWrapping:!0,callbacks:{onBlur:function(n){var i=n.getValue();r.updateDataModel(e,t,i)}}},prettifyHtml:!0,callbacks:{onBlur:function(n,a){var l=jQuery(this).summernote(\"code\");r.updateDataModel(e,t,l),i.channel(\"summernote\").trigger(\"blur\",e,t,l)},onFocus:function(e,t){i.channel(\"summernote\").trigger(\"focus\",e,this,t)},onKeydown:function(e,t){i.channel(\"summernote\").trigger(\"keydown\",e,this,t)},onKeyup:function(e,t){i.channel(\"summernote\").trigger(\"keyup\",e,this,t)}}})},updateDataModel:function(e,t,n){var r=e.get(\"name\"),a=t.get(r),l=n,s={attr:r,before:a,after:l},o={object:t.get(\"objectType\"),label:t.get(\"label\"),change:\"Changed \"+e.get(\"label\")+\" from \"+a+\" to \"+l};i.channel(\"changes\").request(\"register:change\",\"changeSetting\",t,s,o),t.set(e.get(\"name\"),l)},renderSetting:function(e,t,n){this.initRTE(e,t,n);var i=jQuery(n.el).find(\".link-button\").next(\".dropdown-menu\").find(\"button\");i.replaceWith(function(){return jQuery(\"<div/>\",{class:jQuery(i).attr(\"class\"),html:this.innerHTML})})},destroySetting:function(e,t,n){this.removeRTE(e,t,n)},removeRTE:function(e,t,n){jQuery(n.el).find(\"div.setting\").summernote(\"destroy\")},drawerOpened:function(e,t,n){this.initRTE(e,t,n)},linkButton:function(e){var t=this,n=jQuery.summernote.ui,r=i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-rte-link-button\"),a=i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-rte-link-dropdown\");return n.buttonGroup([n.button({className:\"dropdown-toggle link-button\",contents:r({}),tooltip:\"Insert Link\",click:function(n){t.clickLinkButton(n,e)},data:{toggle:\"dropdown\"}}),n.dropdown([n.buttonGroup({children:[n.button({contents:a({}),tooltip:\"\"})]})])]).render()},mergeTags:function(e){var t=jQuery.summernote.ui,n=i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-rte-merge-tags-button\");return t.button({className:\"dropdown-toggle merge-tags\",contents:n({}),tooltip:\"Merge Tags\"}).render()},mediaButton:function(e){var t=this,n=jQuery.summernote.ui,r=i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-rte-media-button\");return n.button({className:\"dropdown-toggle\",contents:r({}),tooltip:\"Insert Media\",click:function(n){t.openMediaManager(n,e)}}).render()},openMediaManager:function(e,t){if(t.invoke(\"editor.createRange\"),t.invoke(\"editor.saveRange\"),this.currentContext=t,this.meta_image_frame)return void this.meta_image_frame.open();this.meta_image_frame=wp.media.frames.meta_image_frame=wp.media({title:\"Select a file\",button:{text:\"insert\"}});var n=this;this.meta_image_frame.on(\"select\",function(){var e=n.meta_image_frame.state().get(\"selection\").first().toJSON();n.insertMedia(e,t)}),this.meta_image_frame.open()},clickLinkButton:function(e,t){var n=t.invoke(\"editor.createRange\");t.invoke(\"editor.saveRange\");var i=n.toString();this.currentContext=t,jQuery(e.target).closest(\".note-customGroup > .note-btn-group\").on(\"hide.bs.dropdown\",function(e){return!1}),jQuery(e.target).closest(\".note-customGroup > .note-btn-group\").on(\"shown.bs.dropdown\",function(e){jQuery(e.target).parent().parent().find(\".link-text\").val(i),jQuery(e.target).parent().parent().find(\".link-url\").focus()})},clickExtra:function(e,t,n,i){var r=jQuery(e.target).parent().find(\".link-text\"),a=jQuery(e.target).parent().find(\".link-url\"),l=jQuery(e.target).parent().find(\".link-new-window\");if(this.currentContext.invoke(\"editor.restoreRange\"),jQuery(e.target).hasClass(\"insert-link\")){var s=r.val(),o=a.val(),c=!!l.prop(\"checked\");0!=s.length&&0!=o.length&&this.currentContext.invoke(\"editor.createLink\",{text:s,url:o,isNewWindow:c})}r.val(\"\"),a.val(\"\"),l.prop(\"checked\",!1),jQuery(e.target).closest(\"div.note-btn-group.open\").removeClass(\"open\")},insertMedia:function(e,t){this.currentContext.invoke(\"editor.restoreRange\"),\"image\"==e.type?this.currentContext.invoke(\"editor.insertImage\",e.url):this.currentContext.invoke(\"editor.createLink\",{text:e.title||e.filename,url:e.url})}})}),n(\"controllers/app/settingFieldSelect\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"field-select\"),\"init:settingModel\",this.trackKeyChanges),this.listenTo(i.channel(\"setting-type-field-select\"),\"before:renderSetting\",this.beforeRender),this.listenTo(i.channel(\"field-select\"),\"init:settingModel\",function(){this.listenTo(i.channel(\"app\"),\"change:setting\",this.maybeSwitchToFieldsDomain)}),this.listenTo(i.channel(\"app\"),\"change:currentDomain\",this.autoOpenDrawer),this.listenTo(i.channel(\"drawer\"),\"opened\",this.filterDrawerContents),this.listenTo(i.channel(\"drawer\"),\"closed\",this.SwitchToFieldsDomain)},trackKeyChanges:function(e){e.listenTo(i.channel(\"app\"),\"update:fieldKey\",e.updateKey),this.listenTo(i.channel(\"app\"),\"replace:fieldKey\",this.updateFieldMap)},updateFieldMap:function(e,t,n){var i=t._previousAttributes.key,r=t.get(\"key\");\"field-select\"==n.get(\"type\")&&e.get(n.get(\"name\"))==i&&e.set(n.get(\"name\"),r)},beforeRender:function(e,t){var n=i.channel(\"fields\").request(\"get:collection\"),r=e.get(\"field_types\"),a=[{label:\"--\",value:0}];_.each(n.models,function(n){if(t.cid!=n.cid&&(void 0===r||0==r.length||_.contains(r,n.get(\"type\")))){var i=e.get(\"field_filter\");if(i&&void 0!==i[n.get(\"type\")]){var l=!1;if(_.each(i[n.get(\"type\")],function(e,t){console.log(e+\":\"+n.get(t)),e!=n.get(t)&&(l=!0)}),l)return}var s=n.get(\"key\");switch(e.get(\"field_value_format\")){case\"key\":s=n.get(\"key\");break;case\"merge_tag\":default:s=\"{field:\"+n.get(\"key\")+\"}\"}a.push({label:n.get(\"label\"),value:s})}}),void 0!==r&&0!=r.length&&_.each(r,function(e){var t=i.channel(\"fields\").request(\"get:type\",e);a.push({label:\"-- Add \"+t.get(\"nicename\")+\" Field\",value:\"addField:\"+e})}),e.set(\"options\",a)},maybeSwitchToFieldsDomain:function(e,t,n){if(\"field-select\"==t.get(\"type\")){var r=t.get(\"name\"),a=n.get(r);if(a){var l=a.split(\":\");\"addField\"==l[0]&&(this.openDrawer=\"addField\",this.filterDrawer=l[1],n.set(r,\"\"),this.switchDomain=!0,i.channel(\"app\").request(\"close:drawer\"))}}},SwitchToFieldsDomain:function(){if(this.switchDomain){var e=i.channel(\"app\").request(\"get:domainModel\",\"fields\");i.channel(\"app\").request(\"change:currentDomain\",null,e),this.switchDomain=null}},autoOpenDrawer:function(){this.openDrawer&&(i.channel(\"app\").request(\"open:drawer\",this.openDrawer),this.openDrawer=null)},filterDrawerContents:function(){this.filterDrawer&&(i.channel(\"drawer-addField\").trigger(\"change:filter\",this.filterDrawer),this.filterDrawer=null)}})}),n(\"controllers/app/settingFieldList\",[\"views/app/drawer/typeSettingFieldset\",\"models/app/settingCollection\"],function(e,t){return Marionette.Object.extend({fieldListSettings:[],initialize:function(){this.listenTo(i.channel(\"field-list\"),\"init:settingModel\",this.registerFieldListSettings),this.listenTo(i.channel(\"fields\"),\"update:setting\",this.updateFieldListSettingKeys),i.channel(\"field-list\").reply(\"get:settingChildView\",this.getSettingChildView,this)},registerFieldListSettings:function(e){this.fieldListSettings.push(e.get(\"name\"))},updateFieldListSettingKeys:function(e){\nif(void 0!==e.changed.key){var t=e._previousAttributes.key,n=e.changed.key,i=this;_.each(Backbone.Radio.channel(\"actions\").request(\"get:collection\").models,function(e){_.each(e.attributes,function(r,a){var l=\"\";_.each(i.fieldListSettings,function(i){if(a==i+\"-\"+t&&l!=t){var r=e.get(i+\"-\"+t);e.set(i+\"-\"+n,r),e.set(i+\"-\"+t,0),l=t}})})})}},getSettingChildView:function(n){var r=_.filter(i.channel(\"fields\").request(\"get:collection\").models,function(e){return _.contains(n.get(\"field_types\"),e.get(\"type\"))}),a=_.map(r,function(e){return{name:n.get(\"name\")+\"-\"+e.get(\"key\"),type:\"toggle\",label:e.get(\"label\"),width:\"full\"}});return n.set(\"settings\",new t(a)),e}})}),n(\"controllers/app/settingHTML\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"setting-type-html\"),\"before:renderSetting\",this.init)},init:function(e,t){\"undefined\"!=e.get(\"mirror\")&&t.on(\"change:\"+e.get(\"mirror\"),this.update,e)},update:function(e,t){e.set(this.get(\"name\"),t)}})}),n(\"controllers/app/settingColor\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"setting-type-color\").reply(\"renderOnChange\",this.setRenderFalse),this.listenTo(i.channel(\"setting-type-color\"),\"destroy:setting\",this.closeColorPickers),this.listenTo(i.channel(\"setting-type-color\"),\"render:setting\",this.initColorPicker)},initColorPicker:function(e,t,n){var r=(e.get(\"name\"),jQuery(n.el).find(\"input\"));jQuery(r).wpColorPicker({change:function(n,r){i.channel(\"app\").request(\"change:setting\",n,e,t,r.color.toString())}})},setRenderFalse:function(){return!1},closeColorPickers:function(e,t,n){jQuery(n.el).find(\".wp-color-picker\").wpColorPicker(\"close\")}})}),n(\"controllers/app/changeMenu\",[],function(){return Marionette.Object.extend({editFormText:\"\",initialize:function(){this.editFormText=nfAdmin.editFormText||\"Edit Form\",this.listenTo(i.channel(\"app\"),\"after:appStart\",this.changeMenu),this.listenTo(i.channel(\"app\"),\"response:updateDB\",this.formPublish)},changeMenu:function(){var e=i.channel(\"app\").request(\"get:formModel\");this.isNewForm(e.id)?this.highlightAddNew():this.appendEditForm()},isNewForm:function(e){return isNaN(e)},highlightAddNew:function(){jQuery(\".wp-submenu li\").removeClass(\"current\"),jQuery('a[href=\"admin.php?page=ninja-forms&form_id=new\"]').parent().addClass(\"current\")},appendEditForm:function(){if(!(jQuery('li a:contains(\"'+this.editFormText+'\")').length>0)){var e,t,n;e=document.createTextNode(this.editFormText),t=document.createElement(\"a\"),t.appendChild(e),n=document.createElement(\"li\"),n.appendChild(t),n.classList.add(\"current\"),jQuery(\".wp-submenu li\").removeClass(\"current\"),jQuery('a[href=\"admin.php?page=ninja-forms#new-form\"]').parent().after(n)}},formPublish:function(e){if(\"publish\"!==e.action)return!1;this.changeMenu()}})}),n(\"controllers/app/mobile\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"click:menu\",this.closeMobileMenu)},closeMobileMenu:function(){var e=i.channel(\"app\").request(\"get:builderEl\");jQuery(e).removeClass(\"nf-menu-expand\")}})}),n(\"controllers/app/notices\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"notices\").reply(\"add\",this.addNotice,this),i.channel(\"notices\").reply(\"close\",this.closeNotice,this),this.notices={}},addNotice:function(e,t,n){var r={content:t,color:\"green\",zIndex:1e7,constructOnInit:!0,stack:!0,animation:{open:\"flip\",close:\"flip\"}},a={position:{x:\"center\",y:\"top\"},animation:{open:\"slide:top\",close:\"slide:left\"},autoClose:2e3,offset:{x:0,y:55}},l={attributes:{x:\"left\",y:\"bottom\"},autoClose:4e3};if(i.channel(\"app\").request(\"is:mobile\"))var s=a;else var s=l;s=jQuery.extend(s,r);var n=jQuery.extend(s,n);this.notices[e]=new jBox(\"Notice\",n)},closeNotice:function(e){void 0!==this.notices[e]&&this.notices[e].close()},openNotice:function(e){void 0!==this.notices[e]&&this.notices[e].open()}})}),n(\"controllers/app/unloadCheck\",[],function(){return Marionette.Object.extend({initialize:function(){jQuery(window).bind(\"beforeunload\",this.maybePrompt)},maybePrompt:function(e){if(!i.channel(\"app\").request(\"get:setting\",\"clean\"))return\"You have unsaved changes.\"}})}),n(\"controllers/app/formContentFilters\",[],function(){return Marionette.Object.extend({initialize:function(){this.viewFilters=[],this.saveFilters=[],this.loadFilters=[],i.channel(\"formContent\").reply(\"add:viewFilter\",this.addViewFilter,this),i.channel(\"formContent\").reply(\"add:saveFilter\",this.addSaveFilter,this),i.channel(\"formContent\").reply(\"add:loadFilter\",this.addLoadFilter,this),i.channel(\"formContent\").reply(\"get:viewFilters\",this.getViewFilters,this),i.channel(\"formContent\").reply(\"get:saveFilters\",this.getSaveFilters,this),i.channel(\"formContent\").reply(\"get:loadFilters\",this.getLoadFilters,this),i.channel(\"fieldContents\").reply(\"add:viewFilter\",this.addViewFilter,this),i.channel(\"fieldContents\").reply(\"add:saveFilter\",this.addSaveFilter,this),i.channel(\"fieldContents\").reply(\"add:loadFilter\",this.addLoadFilter,this),i.channel(\"fieldContents\").reply(\"get:viewFilters\",this.getViewFilters,this),i.channel(\"fieldContents\").reply(\"get:saveFilters\",this.getSaveFilters,this),i.channel(\"fieldContents\").reply(\"get:loadFilters\",this.getLoadFilters,this)},addViewFilter:function(e,t){this.viewFilters[t]=e},getViewFilters:function(){return this.viewFilters},addSaveFilter:function(e,t){this.saveFilters[t]=e},getSaveFilters:function(){return this.saveFilters},addLoadFilter:function(e,t){this.loadFilters[t]=e},getLoadFilters:function(){return this.loadFilters}})}),n(\"controllers/app/formContentGutterFilters\",[],function(){return Marionette.Object.extend({initialize:function(){this.leftFilters=[],this.rightFilters=[],i.channel(\"formContentGutters\").reply(\"add:leftFilter\",this.addLeftFilter,this),i.channel(\"formContentGutters\").reply(\"add:rightFilter\",this.addRightFilter,this),i.channel(\"formContentGutters\").reply(\"get:leftFilters\",this.getLeftFilters,this),i.channel(\"formContentGutters\").reply(\"get:rightFilters\",this.getRightFilters,this)},addLeftFilter:function(e,t){this.leftFilters[t]=e},addRightFilter:function(e,t){this.rightFilters[t]=e},getLeftFilters:function(){return this.leftFilters},getRightFilters:function(){return this.rightFilters}})}),n(\"controllers/app/cloneCollectionDeep\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"app\").reply(\"clone:collectionDeep\",this.cloneCollectionDeep,this)},cloneCollectionDeep:function(e){var t=[];return _.each(e.models,function(e){var n=i.channel(\"app\").request(\"clone:modelDeep\",e);t.push(n)}),new e.constructor(t,e.options)}})}),n(\"controllers/app/trackKeyDown\",[],function(){return Marionette.Object.extend({keys:[],initialize:function(){var e=this;jQuery(document).on(\"keydown\",function(t){e.keyDown(t,e)}),jQuery(document).on(\"keyup\",function(t){e.keyUp(t,e)}),i.channel(\"app\").reply(\"get:keydown\",this.getKeyDown,this)},keyDown:function(e,t){t.keys[e.keyCode]=e.keyCode},keyUp:function(e,t){-1!=t.keys.indexOf(e.keyCode)&&delete t.keys[e.keyCode]},getKeyDown:function(){return this.keys}})}),n(\"controllers/app/perfectScroll\",[],function(){return Marionette.Object.extend({movedPos:!1,initialize:function(){this.listenTo(i.channel(\"main\"),\"show:main\",this.initPerfectScroll),this.listenTo(i.channel(\"drawer\"),\"opened\",this.moveRail),this.listenTo(i.channel(\"drawer\"),\"before:closeDrawer\",this.resetRail)},initPerfectScroll:function(e){i.channel(\"app\").request(\"is:mobile\")||jQuery(e.el).parent().perfectScrollbar({suppressScrollX:!0}),jQuery(\"head\").append('<style id=\"ps-scrollbar-css\" type=\"text/css\"></style>')},moveRail:function(){var e=i.channel(\"app\").request(\"get:drawerEl\"),t=jQuery(e).outerWidth();jQuery(\"#ps-scrollbar-css\").text(\".ps-scrollbar-moved { right: \"+t+\"px !important; } \"),jQuery(\"#nf-main .ps-scrollbar-y-rail\").addClass(\"ps-scrollbar-moved \")},resetRail:function(){jQuery(\".ps-scrollbar-y-rail\").removeClass(\"ps-scrollbar-moved \")}})}),n(\"models/app/settingGroupModel\",[\"models/app/settingCollection\"],function(e){return Backbone.Model.extend({defaults:{display:!1},initialize:function(t){0==this.get(\"settings\")instanceof Backbone.Collection&&this.set(\"settings\",new e(this.get(\"settings\")))}})}),n(\"models/app/settingGroupCollection\",[\"models/app/settingGroupModel\"],function(e){return Backbone.Collection.extend({model:e})}),n(\"controllers/app/getNewSettingGroupCollection\",[\"models/app/settingGroupCollection\"],function(e){return Marionette.Object.extend({initialize:function(){i.channel(\"app\").reply(\"get:settingGroupCollectionDefinition\",this.getNewSettingGroupCollection,this)},getNewSettingGroupCollection:function(){return e}})}),n(\"controllers/app/settingMedia\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"setting-type-media\"),\"click:extra\",this.clickExtra)},clickExtra:function(e,t,n,i){var r=jQuery(e.target).parent().find(\".setting\");if(jQuery(e.target).hasClass(\"open-media-manager\")){if(this.meta_image_frame)return void this.meta_image_frame.open();this.meta_image_frame=wp.media.frames.meta_image_frame=wp.media({title:\"Select a file\",button:{text:\"insert\"}});var a=this;this.meta_image_frame.on(\"select\",function(){var e=a.meta_image_frame.state().get(\"selection\").first().toJSON();r.val(e.url).change()}),this.meta_image_frame.open()}}})}),n(\"controllers/app/publicLink\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"after:appStart\",this.validatePublicLink,this),i.channel(\"app\").reply(\"generate:publicLinkKey\",this.newPublicLinkKey,this)},newPublicLinkKey:function(){for(var e=i.channel(\"settings\").request(\"get:settings\"),t=i.channel(\"app\").request(\"get:formModel\").get(\"id\"),n=0;n<4;n++){t+=Math.random().toString(36).slice(-1)}return e.set(\"public_link_key\",t),t},validatePublicLink:function(){var e=i.channel(\"app\").request(\"get:formModel\").get(\"id\"),t=i.channel(\"settings\").request(\"get:settings\");if(void 0===t.get(\"public_link_key\"))return!1;if(0===t.get(\"public_link_key\").indexOf(e))return!1;var n=this.newPublicLinkKey(),r=nfAdmin.publicLinkStructure.replace(\"[FORM_ID]\",n);t.set(\"public_link\",r)}})}),n(\"models/app/typeModel\",[\"models/app/settingGroupCollection\"],function(e){return Backbone.Model.extend({initialize:function(){!1==this.get(\"settingGroups\")instanceof Backbone.Collection&&this.set(\"settingGroups\",new e(this.get(\"settingGroups\"))),i.channel(\"fields\").trigger(\"init:typeModel\",this)}})}),n(\"models/app/typeCollection\",[\"models/app/typeModel\"],function(e){return Backbone.Collection.extend({model:e,type:!1,initialize:function(e,t){_.each(t,function(e,t){this[t]=e},this)}})}),n(\"models/fields/typeSectionModel\",[],function(){return Backbone.Model.extend({defaults:{classes:\"\"}})}),n(\"models/fields/typeSectionCollection\",[\"models/fields/typeSectionModel\"],function(e){return Backbone.Collection.extend({model:e})}),n(\"controllers/fields/types\",[\"models/app/typeCollection\",\"models/fields/typeSectionCollection\"],function(e,t){return Marionette.Object.extend({initialize:function(){this.sections=new t(fieldTypeSections),this.listenTo(i.channel(\"fields\"),\"init:typeModel\",this.registerSection),this.collection=new e(fieldTypeData,{type:\"fields\"}),i.channel(\"fields\").reply(\"get:type\",this.getFieldType,this),i.channel(\"fields\").reply(\"get:typeCollection\",this.getTypeCollection,this),i.channel(\"fields\").reply(\"get:typeSections\",this.getTypeSections,this),i.channel(\"fields\").reply(\"get:savedFields\",this.getSavedFields,this),this.listenTo(i.channel(\"drawer\"),\"click:fieldType\",this.addField)},registerSection:function(e){\"fields\"==e.collection.type&&e.get(\"section\")&&this.sections.get(e.get(\"section\")).get(\"fieldTypes\").push(e.get(\"id\"))},getFieldType:function(e){return this.collection.get(e)},getTypeCollection:function(e){return this.collection},addField:function(e){var t=jQuery(e.target).data(\"id\");if(e.shiftKey)return void i.channel(\"fields\").request(\"add:stagedField\",t);var n=i.channel(\"fields\").request(\"add\",{type:t,label:i.channel(\"fields\").request(\"get:type\",t).get(\"nicename\")});console.log(n);var r={object:\"Field\",label:n.get(\"label\"),change:\"Added\",dashicon:\"plus-alt\"},a={collection:i.channel(\"fields\").request(\"get:collection\")};i.channel(\"changes\").request(\"register:change\",\"addObject\",n,null,r,a),i.channel(\"fields\").request(\"redraw:collection\")},getTypeSections:function(){return this.sections},getSavedFields:function(){this.sections.get(\"saved\")}})}),n(\"controllers/fields/fieldTypeDrag\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"drawer-addField\"),\"startDrag:type\",this.startDrag),this.listenTo(i.channel(\"drawer-addField\"),\"stopDrag:type\",this.stopDrag),i.channel(\"drawer-addField\").reply(\"get:typeHelperClone\",this.getCurrentDraggableHelperClone,this)},startDrag:function(e,t){this.drawerEl=i.channel(\"app\").request(\"get:drawerEl\"),this.mainEl=i.channel(\"app\").request(\"get:mainEl\"),jQuery(this.drawerEl)[0].style.setProperty(\"overflow\",\"visible\",\"important\"),this.draggableHelperClone=jQuery(t.helper).clone()},stopDrag:function(e,t){jQuery(this.drawerEl)[0].style.setProperty(\"overflow\",\"hidden\",\"important\")},getCurrentDraggableHelperClone:function(){return this.draggableHelperClone}})}),n(\"controllers/fields/stagingDrag\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"drawer-addField\"),\"startDrag:fieldStaging\",this.startDrag),this.listenTo(i.channel(\"drawer-addField\"),\"stopDrag:fieldStaging\",this.stopDrag)},startDrag:function(e,t){this.drawerEl=i.channel(\"app\").request(\"get:drawerEl\"),this.mainEl=i.channel(\"app\").request(\"get:mainEl\"),jQuery(this.drawerEl)[0].style.setProperty(\"overflow\",\"visible\",\"important\");var n=i.channel(\"fields\").request(\"get:staging\"),r=i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-staged-fields-drag\");jQuery(t.helper).html(r({num:n.models.length})),jQuery(t.helper).prop(\"id\",\"nf-staged-fields-drag\"),jQuery(t.item).css(\"opacity\",\"0.7\")},stopDrag:function(e,t){jQuery(this.drawerEl)[0].style.setProperty(\"overflow\",\"hidden\",\"important\")}})}),n(\"controllers/fields/staging\",[\"models/fields/stagingCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.collection=new e,i.channel(\"fields\").reply(\"add:stagedField\",this.addStagedField,this),i.channel(\"fields\").reply(\"remove:stagedField\",this.removeStagedField,this),i.channel(\"fields\").reply(\"get:staging\",this.getStagingCollection,this),i.channel(\"fields\").reply(\"sort:staging\",this.sortStagedFields,this),i.channel(\"fields\").reply(\"clear:staging\",this.clearStagedFields,this),this.listenTo(i.channel(\"drawer-addField\"),\"click:removeStagedField\",this.removeStagedField),this.listenTo(i.channel(\"drawer-addField\"),\"before:closeDrawer\",this.beforeCloseDrawer)},getStagingCollection:function(){return this.collection},addStagedField:function(e,t){var t=t||!1,n=i.channel(\"fields\").request(\"get:type\",e),r=\"nf-staged-field-\"+jQuery.now(),a={id:r,slug:n.get(\"type\"),nicename:n.get(\"nicename\"),icon:n.get(\"icon\")},l=this.collection.add(a);return t||i.channel(\"fields\").trigger(\"add:stagedField\",l),r},removeStagedField:function(e,t){this.collection.remove(t),i.channel(\"fields\").trigger(\"remove:stagedField\",t)},beforeCloseDrawer:function(){if(0!=this.collection.models.length){var e=i.channel(\"fields\").request(\"get:collection\");_.each(this.collection.models,function(t){var n=i.channel(\"fields\").request(\"get:tmpID\"),r={id:n,label:t.get(\"nicename\"),type:t.get(\"slug\")},a=i.channel(\"fields\").request(\"add\",r,!1),l={object:\"Field\",label:a.get(\"label\"),change:\"Added\",dashicon:\"plus-alt\"},s={collection:e};i.channel(\"changes\").request(\"register:change\",\"addObject\",a,null,l,s)}),e.trigger(\"reset\",e),this.collection.reset()}i.channel(\"fields\").request(\"sort:fields\",null,null,!1)},sortStagedFields:function(){var e=i.channel(\"app\").request(\"get:stagedFieldsEl\"),t=jQuery(e).sortable(\"toArray\");_.each(this.collection.models,function(e){var n=e.get(\"id\"),i=t.indexOf(n);e.set(\"order\",i)}),this.collection.sort()},clearStagedFields:function(){this.collection.reset()}})}),n(\"controllers/fields/stagingSortable\",[\"models/fields/stagingCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"drawer-addField\"),\"receive:stagedFields\",this.receiveStagedFields),this.listenTo(i.channel(\"drawer-addField\"),\"over:stagedFields\",this.overStagedFields),this.listenTo(i.channel(\"drawer-addField\"),\"out:stagedFields\",this.outStagedFields),this.listenTo(i.channel(\"drawer-addField\"),\"start:stagedFields\",this.startStagedFields),this.listenTo(i.channel(\"drawer-addField\"),\"stop:stagedFields\",this.stopStagedFields)},receiveStagedFields:function(e){if(jQuery(e.item).hasClass(\"nf-field-type-draggable\")){var t=jQuery(e.item).data(\"id\"),n=i.channel(\"fields\").request(\"add:stagedField\",t);jQuery(e.helper).prop(\"id\",n),i.channel(\"fields\").request(\"sort:staging\"),jQuery(e.helper).remove(),i.channel(\"drawer-addField\").trigger(\"drop:fieldType\",t)}},addActiveClass:function(){var e=i.channel(\"app\").request(\"get:stagedFieldsEl\");jQuery(e).addClass(\"nf-droppable-active\")},removeActiveClass:function(){var e=i.channel(\"app\").request(\"get:stagedFieldsEl\");jQuery(e).removeClass(\"nf-droppable-active\")},overStagedFields:function(e,t){if(jQuery(t.item).hasClass(\"nf-field-type-draggable\")){var n=jQuery(t.item).data(\"id\"),r=i.channel(\"fields\").request(\"get:type\",n),a=r.get(\"nicename\");this.currentHelper=t.helper,jQuery(t.helper).html(a+'<span class=\"dashicons dashicons-dismiss\"></span>'),jQuery(t.helper).removeClass(\"nf-field-type-button\").addClass(\"nf-item-dock\").css({opacity:\"0.8\",width:\"\",height:\"\"});var l=i.channel(\"app\").request(\"get:stagedFieldsEl\");jQuery(l).hasClass(\"ui-sortable\")&&jQuery(l).addClass(\"nf-droppable-hover\")}},outStagedFields:function(e){if(jQuery(e.item).hasClass(\"nf-field-type-draggable\")){var t=i.channel(\"drawer-addField\").request(\"get:typeHelperClone\");jQuery(this.currentHelper).html(jQuery(t).html()),jQuery(this.currentHelper).removeClass(\"nf-item-dock\").addClass(\"nf-field-type-button\");var n=i.channel(\"app\").request(\"get:stagedFieldsEl\");jQuery(n).hasClass(\"ui-sortable\")&&jQuery(n).removeClass(\"nf-droppable-hover\")}},startStagedFields:function(e){jQuery(e.item).show(),jQuery(e.item).css({display:\"inline\",opacity:\"0.7\"}),jQuery(e.helper).css(\"opacity\",\"0.5\")},stopStagedFields:function(e){jQuery(e.item).css(\"opacity\",\"\"),jQuery(e.helper).remove()}})}),n(\"controllers/fields/filterTypes\",[\"models/fields/typeSectionCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"drawer-addField\"),\"change:filter\",this.filterFieldTypes)},filterFieldTypes:function(t,n){if(\"\"!=jQuery.trim(t)){var r=[];_.each(this.filterCollection(t),function(e){r.push(e.get(\"id\"))});var a=new e([{id:\"filtered\",nicename:\"Filtered Fields\",fieldTypes:r}]),l=i.channel(\"app\").request(\"update:hiddenFields\")||[];l=l.concat([\"product\",\"quantity\",\"shipping\",\"total\"]);for(var s=a.models[0].get(\"fieldTypes\").length-1;s>=0;s--){-1<l.indexOf(a.models[0].get(\"fieldTypes\")[s])&&a.models[0].get(\"fieldTypes\").splice(s,1)}i.channel(\"drawer\").trigger(\"filter:fieldTypes\",a),void 0!==n&&n.addObject&&0<r.length&&(i.channel(\"fields\").request(\"add:stagedField\",r[0]),i.channel(\"drawer\").request(\"clear:filter\"))}else i.channel(\"drawer\").trigger(\"clear:filter\")},filterCollection:function(e){return e=e.toLowerCase(),i.channel(\"fields\").request(\"get:typeCollection\").filter(function(t){var n=!1;return-1!=t.get(\"type\").toLowerCase().indexOf(e)?n=!0:-1!=t.get(\"nicename\").toLowerCase().indexOf(e)&&(n=!0),t.get(\"tags\")&&0==e.indexOf(\"#\")&&_.each(t.get(\"tags\"),function(t){e.replace(\"#\",\"\").length>1&&-1!=t.toLowerCase().indexOf(e.replace(\"#\",\"\"))&&(n=!0)}),t.get(\"alias\")&&_.each(t.get(\"alias\"),function(t){-1!=t.toLowerCase().indexOf(e)&&(n=!0)}),n})}})}),n(\"views/fields/preview/element\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-field-input\",initialize:function(){var e=this.model.get(\"type\");if(this.model.set(\"value\",this.model.get(\"default\")),\"date\"==e&&this.model.get(\"date_default\")){var t=this.model.get(\"date_format\");\"default\"!=t&&\"\"!=t||(t=this.convertDateFormat(nfAdmin.dateFormat)),this.model.set(\"value\",moment().format(t))}\"phone\"==e&&(e=\"tel\"),\"spam\"==e&&(e=\"input\"),\"date\"==e&&(e=\"input\"),\"confirm\"==e&&(e=\"input\"),\"password\"==e&&(e=\"input\"),\"passwordconfirm\"==e&&(e=\"input\"),\"quantity\"==e&&(e=\"number\"),\"terms\"==e&&(e=\"listcheckbox\"),\"liststate\"==e&&(e=\"listselect\"),\"listcountry\"==e&&(e=\"listselect\"),\"listmultiselect\"==e&&(e=\"listselect\"),\"save\"==e&&(e=\"submit\"),this.template=\"#tmpl-nf-field-\"+e},onRender:function(){this.model.get(\"container_class\").includes(\"two-col-list\")&&(jQuery(this.el).find(\"> ul\").css(\"display\",\"grid\"),jQuery(this.el).find(\"> ul\").css(\"grid-template-columns\",\"repeat(2, 1fr)\")),this.model.get(\"container_class\").includes(\"three-col-list\")&&(jQuery(this.el).find(\"> ul\").css(\"display\",\"grid\"),jQuery(this.el).find(\"> ul\").css(\"grid-template-columns\",\"repeat(3, 1fr)\")),this.model.get(\"container_class\").includes(\"four-col-list\")&&(jQuery(this.el).find(\"> ul\").css(\"display\",\"grid\"),jQuery(this.el).find(\"> ul\").css(\"grid-template-columns\",\"repeat(4, 1fr)\"))},templateHelpers:function(){return{renderClasses:function(){},renderPlaceholder:function(){if(void 0!==this.placeholder)return'placeholder=\"'+jQuery.trim(this.placeholder)+'\"'},maybeDisabled:function(){if(void 0!==this.disable_input&&this.disable_input)return'disabled=\"disabled\"'},maybeRequired:function(){},maybeInputLimit:function(){},maybeDisableAutocomplete:function(){},maybeChecked:function(){if(\"checked\"==this.default_value)return' checked=\"checked\"'},renderOptions:function(){switch(this.type){case\"terms\":if(!this.taxonomy)return\"(No taxonomy selected)\";var e=fieldTypeData.find(function(e){return\"terms\"==e.id}).settingGroups.find(function(e){return\"primary\"==e.id}).settings.find(function(e){return\"taxonomy_terms\"==e.name}).settings,t=Object.keys(this),n=t.filter(function(e){return 0==e.indexOf(\"taxonomy_term_\")&&this[e]}.bind(this));return 0==n.length?\"(No available terms selected)\":n.reduce(function(t,n){return t+='<li><input type=\"checkbox\"><div>'+e.find(function(e){return n==e.name}).label+\"</div></li>\"}.bind(this),\"\");case\"liststate\":case\"listselect\":if(0==this.options.models.length)return\"\";var i=this.options.models.filter(function(e){return e.get(\"selected\")});return 0==i.length&&(i=this.options.models),\"<option>\"+i[0].get(\"label\")+\"</option>\";case\"listmultiselect\":return this.options.models.reduce(function(e,t){return e+=\"<option\"+(t.get(\"selected\")?' selected=\"selected\"':\"\")+\">\"+t.get(\"label\")+\"</option>\"},\"\");case\"listcheckbox\":return this.options.models.reduce(function(e,t){return e+='<li><input type=\"checkbox\"'+(t.get(\"selected\")?' checked=\"checked\"':\"\")+\"><div>\"+t.get(\"label\")+\"</div></li>\"},\"\");case\"listradio\":var r=!1;return this.options.models.reduce(function(e,t){return r=t.get(\"selected\")&&!r?' checked=\"checked\"':\"\",e+='<li><input type=\"radio\"'+r+\"><div>\"+t.get(\"label\")+\"</div></li>\"},\"\");case\"listcountry\":var a=this.default,l=window.fieldTypeData.find(function(e){return\"listcountry\"==e.id}).settingGroups.find(function(e){return\"primary\"==e.id}).settings.find(function(e){return\"default\"==e.name}).options.find(function(e){return a==e.value});return\"<option>\"+(void 0!==l?l.label:\"--\")+\"</option>\";default:return\"\"}},renderOtherAttributes:function(){var e=[];if(\"listmultiselect\"==this.type){e.push(\"multiple\");var t=this.multi_size||\"5\";e.push('size=\"'+t+'\"')}return e.join(\" \")},renderProduct:function(){},renderNumberDefault:function(){return this.value},renderCurrencyFormatting:function(){},renderRatings:function(){for(var e=\"\",t=0;t<this.number_of_stars;t++)e+='<i class=\"fa fa-star\" aria-hidden=\"true\"></i>&nbsp;';return e}}},convertDateFormat:function(e){return e=e.replace(\"D\",\"ddd\"),e=e.replace(\"d\",\"DD\"),e=e.replace(\"l\",\"dddd\"),e=e.replace(\"j\",\"D\"),e=e.replace(\"N\",\"\"),e=e.replace(\"S\",\"\"),e=e.replace(\"w\",\"d\"),e=e.replace(\"z\",\"\"),e=e.replace(\"W\",\"W\"),e=e.replace(\"M\",\"MMM\"),e=e.replace(\"F\",\"MMMM\"),e=e.replace(\"m\",\"MM\"),e=e.replace(\"n\",\"M\"),e=e.replace(\"t\",\"\"),e=e.replace(\"L\",\"\"),e=e.replace(\"o\",\"YYYY\"),e=e.replace(\"Y\",\"YYYY\"),e=e.replace(\"y\",\"YY\"),e=e.replace(\"a\",\"\"),e=e.replace(\"A\",\"\"),e=e.replace(\"B\",\"\"),e=e.replace(\"g\",\"\"),e=e.replace(\"G\",\"\"),e=e.replace(\"h\",\"\"),e=e.replace(\"H\",\"\"),e=e.replace(\"i\",\"\"),e=e.replace(\"s\",\"\"),e=e.replace(\"u\",\"\"),e=e.replace(\"v\",\"\"),e=e.replace(\"e\",\"\"),e=e.replace(\"I\",\"\"),e=e.replace(\"O\",\"\"),e=e.replace(\"P\",\"\"),e=e.replace(\"T\",\"\"),e=e.replace(\"Z\",\"\"),e=e.replace(\"c\",\"\"),e=e.replace(\"r\",\"\"),e=e.replace(\"u\",\"\")}})}),n(\"views/fields/preview/label\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-field-label\",initialize:function(){},onRender:function(){},templateHelpers:function(){return{renderLabelClasses:function(){},maybeRenderHelp:function(){}}}})}),n(\"views/fields/fieldItem\",[\"views/app/itemControls\",\"views/fields/preview/element\",\"views/fields/preview/label\"],function(e,t,n){return Marionette.LayoutView.extend({tagName:\"div\",template:\"#tmpl-nf-main-content-field\",doingShortcut:!1,regions:{itemControls:\".nf-item-controls\",previewLabel:\".nf-realistic-field--label\",previewElement:\".nf-realistic-field--element\"},initialize:function(){this.model.on(\"change:editActive\",this.render,this),this.model.on(\"change:label\",this.render,this),this.model.on(\"change:required\",this.render,this),this.model.on(\"change:id\",this.render,this)},onBeforeDestroy:function(){this.model.off(\"change:editActive\",this.render),this.model.off(\"change:label\",this.render),this.model.off(\"change:required\",this.render),this.model.off(\"change:id\",this.render)},onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el),this.itemControls.show(new e({model:this.model})),jQuery(this.el).disableSelection();var r=this.model.get(\"type\");\"phone\"==r&&(r=\"tel\"),\"spam\"==r&&(r=\"input\"),\"date\"==r&&(r=\"input\"),\"confirm\"==r&&(r=\"input\"),\"password\"==r&&(r=\"input\"),\"passwordconfirm\"==r&&(r=\"input\"),\"quantity\"==r&&(r=\"number\"),\"terms\"==r&&(r=\"listcheckbox\"),\"liststate\"==r&&(r=\"listselect\"),\"listcountry\"==r&&(r=\"listselect\"),\"listmultiselect\"==r&&(r=\"listselect\"),\"save\"==r&&(r=\"submit\");var a=[\"html\",\"hidden\",\"note\",\"recaptcha\"],l=jQuery(\"#tmpl-nf-field-\"+r).length;if(-1==a.indexOf(this.model.get(\"type\"))&&l){this.previewElement.show(new t({model:this.model}));-1==[\"submit\",\"save\",\"hr\"].indexOf(this.model.get(\"type\"))&&this.previewLabel.show(new n({model:this.model})),jQuery(this.el).find(\".nf-placeholder-label\").hide()}i.channel(\"app\").request(\"is:mobile\")&&jQuery(this.el).on(\"taphold\",function(e,t){jQuery(e.target).hasClass(\"nf-edit-settings\")||(jQuery(this).addClass(\"ui-sortable-helper drag-selected\"),jQuery(this).ClassyWiggle(\"start\",{degrees:[\".65\",\"1\",\".65\",\"0\",\"-.65\",\"-1\",\"-.65\",\"0\"],delay:50}))})},templateHelpers:function(){return{renderClasses:function(){var e=\"nf-field-wrap \"+this.type;return this.editActive&&(e+=\" active\"),e},renderRequired:function(){return 1==this.required?'<span class=\"required\">*</span>':\"\"},getFieldID:function(){return jQuery.isNumeric(this.id)?\"field-\"+this.id:this.id},renderIcon:function(){var e,t;return e=i.channel(\"fields\").request(\"get:type\",this.type),t=document.createElement(\"span\"),t.classList.add(\"fa\",\"fa-\"+e.get(\"icon\")),t.outerHTML},labelPosition:function(){return this.label_pos},renderDescriptionText:function(){return jQuery.trim(this.desc_text)}}},events:{\"mouseover .nf-item-control\":\"mouseoverItemControl\",mousedown:\"maybeShortcut\",click:\"maybeClickEdit\",singletap:\"maybeTapEdit\",swipeleft:\"swipeLeft\",swiperight:\"swipeRight\",tapend:\"tapend\"},maybeClickEdit:function(e){if(this.doingShortcut)return this.doingShortcut=!1,!1;(jQuery(e.target).parent().hasClass(\"nf-fields-sortable\")||jQuery(e.target).parent().hasClass(\"nf-field-wrap\")||jQuery(e.target).hasClass(\"nf-field-wrap\"))&&!i.channel(\"app\").request(\"is:mobile\")&&(jQuery(\":focus\").blur(),i.channel(\"app\").trigger(\"click:edit\",e,this.model))},maybeShortcut:function(e){var t=i.channel(\"app\").request(\"get:keydown\");return-1==t.indexOf(16)||(-1!=t.indexOf(68)?(i.channel(\"app\").trigger(\"click:delete\",e,this.model),this.doingShortcut=!0,!1):-1!=t.indexOf(67)?(this.doingShortcut=!0,i.channel(\"app\").trigger(\"click:duplicate\",e,this.model),!1):void 0)},maybeTapEdit:function(e){jQuery(e.target).parent().hasClass(\"nf-fields-sortable\")&&i.channel(\"app\").trigger(\"click:edit\",e,this.model)},swipeLeft:function(e,t){jQuery(t.startEvnt.target).closest(\"div\").find(\".nf-item-duplicate\").show(),jQuery(t.startEvnt.target).closest(\"div\").find(\".nf-item-delete\").show()},swipeRight:function(e,t){jQuery(t.startEvnt.target).closest(\"div\").find(\".nf-item-duplicate\").hide(),jQuery(t.startEvnt.target).closest(\"div\").find(\".nf-item-delete\").hide()},tapend:function(e,t){jQuery(this.el).ClassyWiggle(\"stop\"),jQuery(this.el).removeClass(\"ui-sortable-helper drag-selected\")},remove:function(){i.channel(\"fields\").request(\"get:removing\")?this.$el.hide(\"clip\",function(){jQuery(this).remove()}):this.$el.remove(),i.channel(\"fields\").request(\"set:removing\",!1)},mouseoverItemControl:function(e){jQuery(this.el).find(\".nf-item-control\").css(\"display\",\"\")}})}),n(\"controllers/fields/sortable\",[\"models/fields/fieldModel\",\"views/fields/fieldItem\"],function(e,t){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"drawer-addField\"),\"startDrag:type\",this.addActiveClass),this.listenTo(i.channel(\"drawer-addField\"),\"stopDrag:type\",this.removeActiveClass),this.listenTo(i.channel(\"drawer-addField\"),\"startDrag:fieldStaging\",this.addActiveClass),this.listenTo(i.channel(\"drawer-addField\"),\"stopDrag:fieldStaging\",this.removeActiveClass),i.channel(\"app\").reply(\"receive:fieldsSortable\",this.receiveFieldsSortable,this),i.channel(\"app\").reply(\"over:fieldsSortable\",this.overfieldsSortable,this),i.channel(\"app\").reply(\"out:fieldsSortable\",this.outFieldsSortable,this),i.channel(\"app\").reply(\"stop:fieldsSortable\",this.stopFieldsSortable,this),i.channel(\"app\").reply(\"start:fieldsSortable\",this.startFieldsSortable,this),i.channel(\"app\").reply(\"update:fieldsSortable\",this.updateFieldsSortable,this)},addActiveClass:function(){var e=i.channel(\"fields\").request(\"get:sortableEl\");jQuery(e).addClass(\"nf-droppable-active\")},removeActiveClass:function(){var e=i.channel(\"fields\").request(\"get:sortableEl\");jQuery(e).removeClass(\"nf-droppable-active\")},receiveFieldsSortable:function(e){if(jQuery(e.item).hasClass(\"nf-field-type-draggable\")){var t=jQuery(e.item).data(\"id\"),n=this.addField(t,!1);jQuery(e.helper).prop(\"id\",n),i.channel(\"fields\").request(\"sort:fields\"),jQuery(e.helper).remove(),i.channel(\"fields\").trigger(\"drop:fieldType\",t,n)}else if(jQuery(e.item).hasClass(\"nf-stage\")){var r=this;i.channel(\"fields\").request(\"sort:staging\");var a=i.channel(\"fields\").request(\"get:staging\"),l=i.channel(\"fields\").request(\"get:sortableEl\");if(jQuery(l).hasClass(\"ui-sortable\"))var s=jQuery(l).sortable(\"toArray\");else var s=[\"nf-staged-fields-drag\"];var o=s.indexOf(\"nf-staged-fields-drag\");_.each(a.models,function(e,t){var n=r.addField(e.get(\"slug\"));s.splice(o+t,0,n)});var o=s.indexOf(\"nf-staged-fields-drag\");s.splice(o,1),i.channel(\"fields\").request(\"sort:fields\",s),i.channel(\"fields\").request(\"clear:staging\"),jQuery(e.helper).remove()}},addField:function(e,t){t=t||!1;var n=i.channel(\"fields\").request(\"get:type\",e),r=i.channel(\"fields\").request(\"get:tmpID\"),a=i.channel(\"fields\").request(\"add\",{id:r,label:n.get(\"nicename\"),type:e},t),l={object:\"Field\",label:a.get(\"label\"),change:\"Added\",dashicon:\"plus-alt\"},s={collection:i.channel(\"fields\").request(\"get:collection\")};return i.channel(\"changes\").request(\"register:change\",\"addObject\",a,null,l,s),r},overfieldsSortable:function(n){if(jQuery(n.item).hasClass(\"nf-field-type-draggable\")){var r=jQuery(n.helper).data(\"id\"),a=i.channel(\"fields\").request(\"get:type\",r),l=(a.get(\"nicename\"),i.channel(\"fields\").request(\"get:sortableEl\"))\n;jQuery(l).width();this.currentHelper=n.helper;var s=new e({label:a.get(\"nicename\"),type:r}),o=new t({model:s}),c=o.render(),d=c.$el[0];jQuery(n.helper).html(d.outerHTML)}else if(jQuery(n.item).hasClass(\"nf-stage\")){var l=i.channel(\"fields\").request(\"get:sortableEl\");jQuery(l).hasClass(\"ui-sortable\")&&jQuery(l).addClass(\"nf-droppable-hover\")}},outFieldsSortable:function(e){if(jQuery(e.item).hasClass(\"nf-field-type-draggable\")){var t=i.channel(\"drawer-addField\").request(\"get:typeHelperClone\");jQuery(this.currentHelper).html(jQuery(t).html()),jQuery(this.currentHelper).removeClass(\"nf-field-wrap\").addClass(\"nf-field-type-button\").css({width:\"\",height:\"\"});var n=i.channel(\"fields\").request(\"get:sortableEl\");jQuery(n).hasClass(\"ui-sortable\")&&jQuery(n).removeClass(\"nf-droppable-hover\")}else if(jQuery(e.item).hasClass(\"nf-stage\")){var n=i.channel(\"fields\").request(\"get:sortableEl\");jQuery(n).hasClass(\"ui-sortable\")&&jQuery(n).removeClass(\"nf-droppable-hover\")}},stopFieldsSortable:function(e){jQuery(e.item).css(\"opacity\",\"\"),jQuery(e.helper).remove(),i.channel(\"fields\").trigger(\"sortable:stop\",e)},startFieldsSortable:function(e){if(!jQuery(e.item).hasClass(\"nf-field-type-draggable\")&&!jQuery(e.item).hasClass(\"nf-stage\")){if(jQuery(e.item).show(),jQuery(e.item).hasClass(\"nf-field-wrap\"))var t=jQuery(e.item).clone();else if(jQuery(e.item).parent().hasClass(\"layouts-cell\"))var t=$parentHelper.clone();else var t=jQuery(e.item).clone();t.find(\".nf-item-controls\").remove(),jQuery(e.helper).html(t.html()),jQuery(e.helper).css(\"opacity\",\"0.5\"),jQuery(e.item).css(\"opacity\",\"0.25\")}i.channel(\"fields\").trigger(\"sortable:start\",e)},updateFieldsSortable:function(e,t){if(i.channel(\"fields\").request(\"sort:fields\"),!jQuery(e.item).hasClass(\"nf-field-type-draggable\")&&!jQuery(e.item).hasClass(\"nf-stage\")){var n=i.channel(\"fields\").request(\"get:collection\"),r=jQuery(e.item).prop(\"id\").replace(\"field-\",\"\"),a=n.get(r),l={fields:[]};_.each(n.models,function(e){var t=e._previousAttributes.order,n=e.get(\"order\");l.fields.push({model:e,attr:\"order\",before:t,after:n})});var s={object:\"Field\",label:a.get(\"label\"),change:\"Re-ordered from \"+a._previousAttributes.order+\" to \"+a.get(\"order\"),dashicon:\"sort\"};i.channel(\"changes\").request(\"register:change\",\"sortFields\",a,null,s,l)}}})}),n(\"controllers/fields/data\",[\"models/fields/fieldCollection\",\"models/fields/fieldModel\"],function(e,t){return Marionette.Object.extend({adding:!1,removing:!1,initialize:function(){this.collection=new e(preloadedFormData.fields),this.collection.removedIDs={},i.channel(\"fields\").reply(\"get:collection\",this.getFieldCollection,this),i.channel(\"fields\").reply(\"get:field\",this.getField,this),i.channel(\"fields\").reply(\"redraw:collection\",this.redrawFieldCollection,this),i.channel(\"fields\").reply(\"get:tmpID\",this.getTmpFieldID,this),i.channel(\"fields\").reply(\"add\",this.addField,this),i.channel(\"fields\").reply(\"delete\",this.deleteField,this),i.channel(\"fields\").reply(\"sort:fields\",this.sortFields,this),i.channel(\"fields\").reply(\"get:adding\",this.getAdding,this),i.channel(\"fields\").reply(\"set:adding\",this.setAdding,this),i.channel(\"fields\").reply(\"get:removing\",this.getRemoving,this),i.channel(\"fields\").reply(\"set:removing\",this.setRemoving,this)},getFieldCollection:function(){return this.collection},redrawFieldCollection:function(){this.collection.trigger(\"reset\",this.collection)},getField:function(e){return this.collection.findWhere({key:e})?this.collection.findWhere({key:e}):this.collection.get(e)},addField:function(e,n,r,a){if(i.channel(\"fields\").request(\"set:adding\",!0),n=n||!1,a=a||\"\",r=void 0===r||r,!1==e instanceof Backbone.Model){void 0===e.id&&(e.id=this.getTmpFieldID());var l=new t(e)}else var l=e;if(jQuery.isNumeric(l.get(\"type\"))){var s=i.channel(\"fields\").request(\"get:type\",l.get(\"type\"));l.set(\"type\",s.get(\"parentType\"))}var o=this.collection.add(l,{silent:n});return i.channel(\"app\").request(\"update:setting\",\"clean\",!1),i.channel(\"fields\").trigger(\"add:field\",l),r&&i.channel(\"fields\").trigger(\"render:newField\",o,a),\"duplicate\"==a&&i.channel(\"fields\").trigger(\"render:duplicateField\",o,a),i.channel(\"fields\").trigger(\"after:addField\",l),l},updateFieldSetting:function(e,t,n){this.collection.get(e).set(t,n)},sortFields:function(e,t,n){null==n&&(n=!0);var r=i.channel(\"fields\").request(\"get:sortableEl\");if(jQuery(r).hasClass(\"ui-sortable\")){var e=e||jQuery(r).sortable(\"toArray\");_.each(this.collection.models,function(t){var n=(t.get(\"order\"),t.get(\"id\"));if(jQuery.isNumeric(n))var i=\"field-\"+n;else var i=n;var r=e.indexOf(i)+1;t.set(\"order\",r)}),this.collection.sort(),n&&(i.channel(\"app\").request(\"update:setting\",\"clean\",!1),i.channel(\"app\").request(\"update:db\"))}},deleteField:function(e){i.channel(\"fields\").trigger(\"delete:field\",e),this.removing=!0,this.collection.remove(e),i.channel(\"app\").request(\"update:setting\",\"clean\",!1),i.channel(\"app\").request(\"update:db\")},getTmpFieldID:function(){var e=this.collection.tmpNum;return this.collection.tmpNum++,\"tmp-\"+e},getAdding:function(){return this.adding},setAdding:function(e){this.adding=e},getRemoving:function(){return this.removing},setRemoving:function(e){this.removing=e}})}),n(\"models/app/optionRepeaterModel\",[],function(){return Backbone.Model.extend({defaults:{errors:{},max_options:0},initialize:function(){this.on(\"change:errors\",this.changeErrors,this)},changeErrors:function(e){if(0==_.size(e.get(\"errors\"))){var t=!1;_.each(e.collection.models,function(e){0!=_.size(e.get(\"errors\"))&&(t=!0)}),t||e.collection.settingModel.set(\"error\",!1)}else e.collection.settingModel.set(\"error\",!0)}})}),n(\"models/app/optionRepeaterCollection\",[\"models/app/optionRepeaterModel\"],function(e){return Backbone.Collection.extend({model:e,comparator:function(e){return parseInt(e.get(\"order\"))},initialize:function(e,t){this.on(\"sort\",this.changeCollection,this),this.on(\"add\",this.addOption,this),this.settingModel=t.settingModel},changeCollection:function(){i.channel(\"option-repeater\").trigger(\"sort:options\",this),void 0!==this.settingModel&&i.channel(\"option-repeater-\"+this.settingModel.get(\"name\")).trigger(\"sort:options\",this)},addOption:function(e,t){e.set(\"settingModel\",this.settingModel)}})}),n(\"views/app/drawer/optionRepeaterError\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",className:\"nf-error\",template:\"#tmpl-nf-edit-setting-option-repeater-error\",templateHelpers:function(){var e=this;return{renderErrors:function(){return void 0!==e.errors?e.errors[Object.keys(errors)[0]]:\"\"}}}})}),n(\"views/app/drawer/optionRepeaterOption\",[\"views/app/drawer/optionRepeaterError\"],function(e){return Marionette.LayoutView.extend({tagName:\"div\",className:\"nf-table-row\",template:\"#tmpl-nf-edit-setting-option-repeater-default-row\",id:function(){return this.model.cid},regions:{error:\".nf-option-error\"},initialize:function(e){this.settingModel=e.settingModel,this.dataModel=e.dataModel,this.collection=e.collection,this.columns=e.columns,this.parentView=e.parentView,this.model.on(\"change:errors\",this.renderErrors,this),void 0!==this.settingModel.get(\"tmpl_row\")&&(this.template=\"#\"+this.settingModel.get(\"tmpl_row\")),this.hasErrors=!1},onBeforeDestroy:function(){this.model.off(\"change\",this.render),this.model.off(\"change:errors\",this.renderErrors)},onBeforeRender:function(){if(this.model.get(\"label\")){var e=this.model.get(\"label\");this.model.set(\"label\",_.escape(e),{silent:!0})}},onRender:function(){if(i.channel(\"mergeTags\").request(\"init\",this),i.channel(\"setting-\"+this.settingModel.get(\"name\")+\"-option\").trigger(\"render:setting\",this.model,this.dataModel,this),this.model.get(\"label\")){var e=this.model.get(\"label\");this.model.set(\"label\",_.unescape(e),{silent:!0})}},onShow:function(){this.model.get(\"new\")&&(jQuery(this.el).find(\"input:first\").focus(),this.model.set(\"new\",!1))},events:{\"change .setting\":\"changeOption\",\"click .nf-delete\":\"deleteOption\",keyup:\"keyupOption\"},changeOption:function(e){i.channel(\"option-repeater\").trigger(\"change:option\",e,this.model,this.dataModel,this.settingModel,this)},deleteOption:function(e){i.channel(\"option-repeater\").trigger(\"click:deleteOption\",this.model,this.collection,this.dataModel,this)},keyupOption:function(e){this.maybeAddOption(e),i.channel(\"option-repeater\").trigger(\"keyup:option\",e,this.model,this.dataModel,this.settingModel,this),i.channel(\"option-repeater-\"+this.settingModel.get(\"name\")).trigger(\"keyup:option\",e,this.model,this.dataModel,this.settingModel,this)},maybeAddOption:function(e){13==e.keyCode&&\"calculations\"!=this.settingModel.get(\"name\")&&(i.channel(\"option-repeater\").trigger(\"click:addOption\",this.collection,this.dataModel,this),jQuery(this.parentView.children.findByIndex(this.parentView.children.length-1).el).find('[data-id=\"label\"]').focus())},renderErrors:function(){0==Object.keys(this.model.get(\"errors\"))?this.hasErrors&&(this.error.empty(),jQuery(this.el).removeClass(\"nf-error\")):(this.hasErrors=!0,this.error.show(new e({model:this.model})),jQuery(this.el).addClass(\"nf-error\"))},templateHelpers:function(){var e=this;return{getColumns:function(){var t=e.columns;return nfAdmin.devMode||(delete t.value,delete t.calc),t},renderFieldSelect:function(e,t){var n,r,a,l,s=i.channel(\"fields\").request(\"get:collection\");return n=document.createElement(\"option\"),n.value=\"\",n.label=\"--\",n.innerHTML=\"--\",r=document.createElement(\"select\"),r.classList.add(\"setting\"),r.setAttribute(\"data-id\",e),r.appendChild(n),s.each(function(e){var n=document.createElement(\"option\");t==e.get(\"key\")&&n.setAttribute(\"selected\",\"selected\"),n.value=e.get(\"key\"),n.innerHTML=e.formatLabel(),n.label=e.formatLabel(),r.appendChild(n)}),l=document.createElement(\"label\"),l.classList.add(\"nf-select\"),l.appendChild(r),a=document.createElement(\"div\"),a.style.bottom=\"6px\",l.appendChild(a),l.innerHTML},renderNonSaveFieldSelect:function(e,t){var n,r,a,l,s=i.channel(\"fields\").request(\"get:collection\");n=document.createElement(\"option\"),n.value=\"\",n.label=\"--\",n.innerHTML=\"--\",r=document.createElement(\"select\"),r.classList.add(\"setting\"),r.setAttribute(\"data-id\",e),r.appendChild(n);var o=[\"html\",\"submit\",\"hr\",\"recaptcha\",\"spam\",\"creditcard\",\"creditcardcvc\",\"creditcardexpiration\",\"creditcardfullname\",\"creditcardnumber\",\"creditcardzip\"];return s.each(function(e){if(-1!==jQuery.inArray(e.get(\"type\"),o))return\"\";var n=document.createElement(\"option\");t==e.get(\"key\")&&n.setAttribute(\"selected\",\"selected\"),n.value=e.get(\"key\"),n.innerHTML=e.formatLabel(),n.label=e.formatLabel(),r.appendChild(n)}),l=document.createElement(\"label\"),l.classList.add(\"nf-select\"),l.appendChild(r),a=document.createElement(\"div\"),a.style.bottom=\"6px\",l.appendChild(a),l.innerHTML},renderOptions:function(t,n){if(void 0!==e.options.columns[t]){var i=document.createElement(\"select\");return _.each(e.options.columns[t].options,function(e){var t=document.createElement(\"option\");n===e.value&&t.setAttribute(\"selected\",\"selected\"),t.setAttribute(\"value\",e.value),t.setAttribute(\"label\",e.label),t.innerText=e.label,i.appendChild(t)}),i.innerHTML}}}}})}),n(\"views/app/drawer/optionRepeaterEmpty\",[],function(){return Marionette.ItemView.extend({tagName:\"tr\",template:\"#tmpl-nf-edit-setting-option-repeater-empty\"})}),n(\"views/app/drawer/optionRepeaterComposite\",[\"views/app/drawer/optionRepeaterOption\",\"views/app/drawer/optionRepeaterEmpty\",\"models/app/optionRepeaterCollection\"],function(e,t,n){return Marionette.CompositeView.extend({template:\"#tmpl-nf-edit-setting-option-repeater-wrap\",childView:e,emptyView:t,reorderOnSort:!1,initialize:function(e){var t=e.dataModel.get(this.model.get(\"name\"));0==t instanceof Backbone.Collection&&(t=new n([],{settingModel:this.model}),t.add(e.dataModel.get(this.model.get(\"name\"))),e.dataModel.set(this.model.get(\"name\"),t,{silent:!0})),this.collection=t,this.dataModel=e.dataModel,this.childViewOptions={parentView:this,settingModel:this.model,collection:this.collection,dataModel:e.dataModel,columns:this.model.get(\"columns\")};var r=this.model.get(\"deps\");if(r)for(var a in r)r.hasOwnProperty(a)&&this.dataModel.on(\"change:\"+a,this.render,this);this.listenTo(i.channel(\"option-repeater\"),\"added:option\",this.maybeHideNew),this.listenTo(i.channel(\"option-repeater\"),\"removed:option\",this.maybeHideNew)},onBeforeDestroy:function(){var e=this.model.get(\"deps\");if(e)for(var t in e)e.hasOwnProperty(t)&&this.dataModel.off(\"change:\"+t,this.render)},onRender:function(){var e=this;jQuery(this.el).find(\".nf-list-options-tbody\").sortable({handle:\".handle\",helper:\"clone\",placeholder:\"nf-list-options-sortable-placeholder\",forcePlaceholderSize:!0,opacity:.95,tolerance:\"pointer\",start:function(e,t){i.channel(\"option-repeater\").request(\"start:optionSortable\",t)},stop:function(e,t){i.channel(\"option-repeater\").request(\"stop:optionSortable\",t)},update:function(t,n){i.channel(\"option-repeater\").request(\"update:optionSortable\",n,this,e)}}),e.setupTooltip(),e.maybeHideNew(e.collection),i.channel(\"setting-\"+this.model.get(\"name\")).trigger(\"render:setting\",this.model,this.dataModel,this)},onAttach:function(){var e=jQuery(this.el).find(\".nf-open-import-tooltip\"),t=jQuery(e).jBox(\"Tooltip\",{title:\"<h3>Please enter your options below:</h3>\",content:\"1\"==nfAdmin.devMode?jQuery(this.el).find(\".nf-dev-import-options\"):jQuery(this.el).find(\".nf-import-options\"),trigger:\"click\",closeOnClick:\"body\",closeButton:\"box\",offset:{x:20,y:0},addClass:\"import-options\",onOpen:function(){var e=this;setTimeout(function(){jQuery(e.content).find(\"textarea\").focus()},200)}});jQuery(this.el).find(\".nf-import\").on(\"click\",{view:this,jBox:t},this.clickImport),i.channel(\"setting-\"+this.model.get(\"name\")).trigger(\"attach:setting\",this.model,this.dataModel,this),i.channel(\"setting-type-\"+this.model.get(\"type\")).trigger(\"attach:setting\",this.model,this.dataModel,this)},setupTooltip:function(){jQuery(this.el).find(\".nf-list-options\").find(\".nf-help\").each(function(){var e=jQuery(this).next(\".nf-help-text\");jQuery(this).jBox(\"Tooltip\",{content:e,maxWidth:200,theme:\"TooltipBorder\",trigger:\"click\",closeOnClick:!0})})},templateHelpers:function(){var e=this;return{renderHeaders:function(){if(\"Field\"==e.dataModel.get(\"objectType\")&&-1!==e.dataModel.get(\"type\").indexOf(\"list\")){var t,n,i,r,a;t=document.createTextNode(nfi18n.valueChars),n=document.createElement(\"div\"),n.classList.add(\"nf-help-text\"),n.appendChild(t),i=document.createElement(\"span\"),i.classList.add(\"dashicons\",\"dashicons-admin-comments\"),r=document.createElement(\"a\"),r.classList.add(\"nf-help\"),r.setAttribute(\"href\",\"#\"),r.setAttribute(\"tabindex\",\"-1\"),r.appendChild(i),a=document.createElement(\"span\"),a.appendChild(r),a.appendChild(n),void 0!==e.model.get(\"columns\")&&void 0!==e.model.get(\"columns\").value&&-1==e.model.get(\"columns\").value.header.indexOf(a.innerHTML)&&(e.model.get(\"columns\").value.header+=a.innerHTML)}var l,s,o;return s=document.createElement(\"div\"),l=document.createElement(\"span\"),l.appendChild(s),nfAdmin.devMode||(delete this.columns.value,delete this.columns.calc),_.each(this.columns,function(e){var t,n;t=document.createRange().createContextualFragment(e.header),n=document.createElement(\"div\"),n.appendChild(t),l.appendChild(n)}),o=document.createElement(\"div\"),l.appendChild(o),l.innerHTML},renderSetting:function(){return i.channel(\"app\").request(\"get:template\",\"#tmpl-nf-edit-setting-\"+this.type)(this)},renderClasses:function(){var e=\"\";return void 0!==this.width?e+=this.width:e+=\" one-half\",this.error&&(e+=\" nf-error\"),e},renderVisible:function(){if(this.deps)for(var t in this.deps)if(this.deps.hasOwnProperty(t)&&e.dataModel.get(t)!==this.deps[t])return'style=\"display:none;\"';return\"\"},renderError:function(){return this.error?this.error:\"\"},renderFieldsetClasses:function(){return e.model.get(\"name\")},currencySymbol:function(){return i.channel(\"settings\").request(\"get:setting\",\"currency\")||nfi18n.currency_symbol}}},attachHtml:function(e,t){jQuery(e.el).find(\".nf-list-options-tbody\").append(t.el),i.channel(\"mergeTags\").request(\"init\",this)},events:{\"click .nf-add-new\":\"clickAddOption\",\"click .extra\":\"clickExtra\"},maybeHideNew:function(e){if(void 0===e.settingModel)return!1;var t=e.settingModel.get(\"max_options\");0!==t&&e.models.length>=t?jQuery(this.el).find(\".nf-add-new\").addClass(\"disabled\"):jQuery(this.el).find(\".nf-add-new\").removeClass(\"disabled\")},clickAddOption:function(e){i.channel(\"option-repeater\").trigger(\"click:addOption\",this.collection,this.dataModel),jQuery(this.children.findByIndex(this.children.length-1).el).find('[data-id=\"label\"]').focus()},clickExtra:function(e){i.channel(\"option-repeater\").trigger(\"click:extra\",e,this.collection,this.dataModel),i.channel(\"option-repeater-\"+this.model.get(\"name\")).trigger(\"click:extra\",e,this.model,this.collection,this.dataModel)},clickImport:function(e){var t=jQuery(e.data.jBox.content).find(\"textarea\"),n=t.val().trimLeft().trimRight();if(0==n.length)return e.data.jBox.close(),!1;var r=n.split(/\\n/);_.isArray(r)&&_.each(r,function(t){var n=t.split(\",\"),r=n[0],a=n[1]||jQuery.slugify(r,{separator:\"-\"}),l=n[2]||\"\";r=r.trimLeft().trimRight(),a=a.trimLeft().trimRight(),l=l.trimLeft().trimRight();var s=e.data.view.collection.add({label:n[0],value:a,calc:l}),r={object:\"field\",label:n[0],change:\"Option Added\",dashicon:\"plus-alt\"};i.channel(\"changes\").request(\"register:change\",\"addListOption\",s,null,r),i.channel(\"option-repeater-\"+e.data.view.model.get(\"name\")).trigger(\"add:option\",s),i.channel(\"option-repeater\").trigger(\"add:option\",s),i.channel(\"app\").trigger(\"update:setting\",s)},this),t.val(\"\"),e.data.jBox.close()}})}),n(\"controllers/app/optionRepeater\",[\"models/app/optionRepeaterModel\",\"models/app/optionRepeaterCollection\",\"views/app/drawer/optionRepeaterComposite\"],function(e,t,n){return Marionette.Object.extend({initialize:function(){i.channel(\"option-repeater\").reply(\"get:settingChildView\",this.getSettingChildView,this),this.listenTo(i.channel(\"option-repeater\"),\"change:option\",this.changeOption),this.listenTo(i.channel(\"option-repeater\"),\"click:addOption\",this.addOption),this.listenTo(i.channel(\"option-repeater\"),\"click:deleteOption\",this.deleteOption),i.channel(\"option-repeater\").reply(\"update:optionSortable\",this.updateOptionSortable,this),i.channel(\"option-repeater\").reply(\"stop:optionSortable\",this.stopOptionSortable,this),i.channel(\"option-repeater\").reply(\"start:optionSortable\",this.startOptionSortable,this),this.listenTo(i.channel(\"option-repeater\"),\"init:dataModel\",this.convertSettings)},changeOption:function(e,t,n,r,a){var l=jQuery(e.target).data(\"id\");if(\"selected\"==l)if(jQuery(e.target).attr(\"checked\"))var s=1;else var s=0;else var s=jQuery(e.target).val();var o=t.get(l);t.set(l,s),this.triggerDataModel(t,n);var c=s,d={attr:l,before:o,after:c},u={object:n.get(\"objectType\"),label:n.get(\"label\"),change:\"Option \"+t.get(\"label\")+\" \"+l+\" changed from \"+o+\" to \"+c};i.channel(\"changes\").request(\"register:change\",\"changeSetting\",t,d,u),i.channel(\"option-repeater\").trigger(\"update:option\",t,n,r,a),i.channel(\"option-repeater-option-\"+l).trigger(\"update:option\",e,t,n,r,a),i.channel(\"option-repeater-\"+r.get(\"name\")).trigger(\"update:option\",t,n,r,a)},addOption:function(t,n){var r={order:t.length,new:!0,options:{}};if(void 0!==t.settingModel){var a=t.settingModel.get(\"max_options\");if(0!==a&&t.models.length>=a)return;_.each(t.settingModel.get(\"columns\"),function(e,t){r[t]=e.default,void 0!==e.options&&(r.options[t]=e.options)})}var l=new e(r);t.add(l);var s={object:n.get(\"objectType\"),label:n.get(\"label\"),change:\"Option Added\",dashicon:\"plus-alt\"};i.channel(\"changes\").request(\"register:change\",\"addListOption\",l,null,s),void 0!==t.settingModel&&i.channel(\"option-repeater-\"+t.settingModel.get(\"name\")).trigger(\"add:option\",l),i.channel(\"option-repeater\").trigger(\"add:option\",l),i.channel(\"option-repeater\").trigger(\"added:option\",t),this.triggerDataModel(l,n)},deleteOption:function(e,t,n){var r=i.channel(\"app\").request(\"clone:modelDeep\",e),a={object:n.get(\"objectType\"),label:n.get(\"label\"),change:\"Option \"+r.get(\"label\")+\" Removed\",dashicon:\"dismiss\"},l={collection:t};i.channel(\"changes\").request(\"register:change\",\"removeListOption\",r,null,a,l);var s=i.channel(\"changes\").request(\"get:collection\"),o=s.where({model:e});_.each(o,function(e){\"object\"==typeof e.get(\"data\")&&_.each(e.get(\"data\"),function(e){e.model==e&&(e.model=r)}),e.set(\"model\",r),e.set(\"disabled\",!0)}),t.remove(e),i.channel(\"option-repeater\").trigger(\"remove:option\",e),i.channel(\"option-repeater\").trigger(\"removed:option\",t),i.channel(\"option-repeater-\"+t.settingModel.get(\"name\")).trigger(\"remove:option\",e),this.triggerDataModel(e,n)},triggerDataModel:function(e,t){i.channel(\"app\").trigger(\"update:setting\",e)},getSettingChildView:function(e){return n},updateOptionSortable:function(e,t,n){var r=jQuery(t).sortable(\"toArray\"),a=n.collection.get({cid:jQuery(e.item).prop(\"id\")}),l={collection:n.collection,objModels:[]};_.each(r,function(e,t){var i=n.collection.get({cid:e}),r=i.get(\"order\");i.set(\"order\",t);var a=t;l.objModels.push({model:i,attr:\"order\",before:r,after:a})}),n.collection.sort({silent:!0});var s={object:n.dataModel.get(\"objectType\"),label:n.dataModel.get(\"label\"),change:\"Option \"+a.get(\"label\")+\" re-ordered from \"+a._previousAttributes.order+\" to \"+a.get(\"order\"),dashicon:\"sort\"};i.channel(\"changes\").request(\"register:change\",\"sortListOptions\",a,null,s,l),this.triggerDataModel(a,n.dataModel),i.channel(\"option-repeater\").trigger(\"sort:option\",a,n),i.channel(\"option-repeater-\"+n.model.get(\"name\")).trigger(\"sort:option\",a,n)},stopOptionSortable:function(e){jQuery(e.item).css(\"opacity\",\"\")},startOptionSortable:function(e){jQuery(e.placeholder).find(\"div\").remove(),jQuery(e.item).css(\"opacity\",\"0.5\").show()},convertSettings:function(e,n){var i=e.get(n.get(\"name\"));0==i instanceof Backbone.Collection&&(i=new t([],{settingModel:n}),i.add(e.get(n.get(\"name\"))),e.set(n.get(\"name\"),i,{silent:!0}))}})}),n(\"controllers/fields/editActive\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"fields\").reply(\"clear:editActive\",this.clearEditActive,this),this.listenTo(i.channel(\"drawer-editSettings\"),\"before:closeDrawer\",this.clearEditActive)},clearEditActive:function(){var e=i.channel(\"fields\").request(\"get:collection\");_.each(e.models,function(e){e.set(\"editActive\",!1)})}})}),n(\"controllers/fields/fieldSettings\",[\"models/app/settingCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.collection=new e(fieldSettings,{objectType:\"fields\"}),i.channel(\"fields\").reply(\"get:settingModel\",this.getSettingModel,this),i.channel(\"fields\").reply(\"get:settingCollection\",this.getSettingCollection,this)},getSettingModel:function(e){return this.collection.findWhere({name:e})},getSettingCollection:function(){return this.collection}})}),n(\"controllers/fields/fieldCreditCard\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"fields\"),\"after:addField\",this.dropCreditCardField)},dropCreditCardField:function(e){if(\"creditcard\"==e.get(\"type\")){var t=e.get(\"order\");i.channel(\"fields\").request(\"delete\",e),_.each([\"creditcardfullname\",\"creditcardnumber\",\"creditcardcvc\",\"creditcardexpiration\",\"creditcardzip\"],function(e){var n=i.channel(\"fields\").request(\"get:type\",e),r={id:i.channel(\"fields\").request(\"get:tmpID\"),type:e,label:n.get(\"nicename\"),order:t};i.channel(\"fields\").request(\"add\",r)})}},stageCreditCardField:function(e){\"creditcard\"==e.get(\"slug\")&&(i.channel(\"fields\").request(\"remove:stagedField\",\"\",e),_.each([\"creditcardfullname\",\"creditcardnumber\",\"creditcardcvc\",\"creditcardexpiration\",\"creditcardzip\"],function(e){i.channel(\"fields\").request(\"add:stagedField\",e)}))}})}),n(\"controllers/fields/fieldList\",[\"models/app/optionRepeaterCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"option-repeater-option-label\"),\"update:option\",this.updateOptionLabel),this.listenTo(i.channel(\"option-repeater-option-value\"),\"update:option\",this.updateOptionValue),this.listenTo(i.channel(\"fields-list\"),\"init:fieldModel\",this.convertOptions)},updateOptionLabel:function(e,t,n,i,r){\"list\"==_.findWhere(fieldTypeData,{id:n.get(\"type\")}).parentType&&(t.get(\"manual_value\")||(value=jQuery.slugify(t.get(\"label\"),{separator:\"-\"}),t.set(\"value\",value),t.trigger(\"change\",t),jQuery(r.el).find('[data-id=\"value\"]').focus().select()))},updateOptionValue:function(e,t,n,i,r){if(\"Field\"==n.get(\"objectType\")){var a=t.get(\"value\"),l=/[^0-9a-zA-Z _@.-]/g;a=a.replace(l,\"\"),t.set(\"value\",a),r.render()}var s=_.findWhere(fieldTypeData,{id:n.get(\"type\")});void 0!==s&&\"list\"==s.parentType&&(t.set(\"manual_value\",!0),jQuery(r.el).find('[data-id=\"calc\"]').focus().select())},convertOptions:function(t){var n=t.get(\"options\"),r=i.channel(\"fields\").request(\"get:settingModel\",\"options\");0==n instanceof Backbone.Collection&&(n=new e([],{settingModel:r}),n.add(t.get(\"options\")),t.set(\"options\",n,{silent:!0}))}})}),n(\"controllers/fields/fieldPassword\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"fields\"),\"after:addField\",this.addField)},addField:function(e){if(\"password\"==e.get(\"type\")){var t=e.get(\"order\");this.insertField(\"passwordconfirm\",t+1).set(\"confirm_field\",e.get(\"key\"))}},insertField:function(e,t){var n=i.channel(\"fields\").request(\"get:type\",e),r={id:i.channel(\"fields\").request(\"get:tmpID\"),type:e,label:n.get(\"nicename\"),order:t};return i.channel(\"fields\").request(\"add\",r)}})}),n(\"controllers/fields/fieldQuantity\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"before:renderSetting\",this.beforeRenderSetting)},beforeRenderSetting:function(e,t,n){if(\"product_assignment\"==e.get(\"name\")){var i=this.getProductFields(e);e.set(\"options\",i)}},getProductFields:function(e){var t=[e.get(\"select_product\")],n=i.channel(\"fields\").request(\"get:collection\");return _.each(n.models,function(e){\"product\"==e.get(\"type\")&&t.push({label:e.get(\"label\"),value:e.get(\"id\")})}),t}})}),n(\"controllers/fields/fieldShipping\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"setting-shipping_options\"),\"render:setting\",this.addMask),this.listenTo(i.channel(\"setting-shipping_options-option\"),\"render:setting\",this.addMask)},addMask:function(e,t,n){jQuery(n.el).find('[data-id=\"value\"]').each(function(){jQuery(this).autoNumeric({aSign:\"$\",aSep:thousandsSeparator,aDec:decimalPoint})})}})}),n(\"controllers/fields/key\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"fields\"),\"add:field\",this.newFieldKey),this.listenTo(i.channel(\"fieldSetting-label\"),\"update:setting\",this.updateLabel),this.listenTo(i.channel(\"fieldSetting-key\"),\"update:setting\",this.updateKey),this.listenTo(i.channel(\"setting-key\"),\"keyup:setting\",this.keyUp)},newFieldKey:function(e){var t=new Date,n=t.valueOf(),i=this.slugify(e.get(\"type\")+\"_\"+n);e.set(\"key\",i,{silent:!0}),\"undefined\"==e.get(\"manual_key\")&&e.set(\"manual_key\",!1,{silent:!0})},updateLabel:function(e){if(!e.get(\"manual_key\")&&0!=jQuery.trim(e.get(\"label\")).length){delete e.changed.label;var t=new Date,n=t.valueOf(),i=this.slugify(e.get(\"label\")+\"_\"+n);-1==i.indexOf(\"_\")&&(i=\"field_\"+i),e.set(\"key\",i)}},updateKey:function(e){var t=e.get(\"key\");this.settingModel=i.channel(\"fields\").request(\"get:settingModel\",\"key\"),this.setError(t,e)},keyUp:function(e,t,n){n.set(\"manual_key\",!0),this.settingModel=t;var i=jQuery(e.target).val();this.setError(i,n)},setError:function(e,t){var n=!1;\"\"==jQuery.trim(e)?n=\"Field keys can't be empty. Please enter a key.\":e!=e.toLowerCase()?n=\"Field keys must be lowercase.\":e!=e.replace(\" \",\"_\")?n='Field keys must cannot use spaces. Separate with \"_\" instead.':\"_\"==e.slice(-1)?n='Field keys cannot end with a \"_\"':e!=this.slugify(e)?n=\"Invalid Format.\":e!=this.keyExists(e,t)&&(n=\"Field keys must be unique. Please enter another key.\"),n?this.settingModel.set(\"error\",n):(i.channel(\"app\").trigger(\"update:fieldKey\",t),this.settingModel.set(\"error\",!1))},keyExists:function(e,t){var n=this.slugify(e);0!=n.length&&(e=n);var r=i.channel(\"fields\").request(\"get:collection\"),a=1,l=e;return _.each(r.models,function(n){t!=n&&l==n.get(\"key\")&&(l=e+\"_\"+a,a++)}),e=l},slugify:function(e){return jQuery.slugify(e,{separator:\"_\"})}})}),n(\"controllers/fields/notices\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"fields\"),\"add:stagedField\",this.addStagedField)},addStagedField:function(e){i.channel(\"notices\").request(\"add\",\"addStagedField\",e.get(\"nicename\")+\" added to staging\")}})}),n(\"controllers/fields/mobile\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"fields\"),\"sortable:start\",this.startWiggle),this.listenTo(i.channel(\"fields\"),\"sortable:stop\",this.stopWiggle)},initWiggle:function(e){i.channel(\"app\").request(\"is:mobile\")&&jQuery(e.el).find(\".nf-field-wrap\").on(\"taphold\",function(){jQuery(this).ClassyWiggle(\"start\",{degrees:[\".65\",\"1\",\".65\",\"0\",\"-.65\",\"-1\",\"-.65\",\"0\"],delay:50})})},startWiggle:function(e){i.channel(\"app\").request(\"is:mobile\")&&(jQuery(e.item).removeClass(\"ui-sortable-helper\").ClassyWiggle(\"stop\"),jQuery(e.helper).css(\"opacity\",\"0.75\").ClassyWiggle(\"start\",{degrees:[\".5\",\"1\",\".5\",\"0\",\"-.5\",\"-1\",\"-.5\",\"0\"]}))},stopWiggle:function(e){i.channel(\"app\").request(\"is:mobile\")&&(jQuery(e.helper).ClassyWiggle(\"stop\"),jQuery(e.item).removeClass(\"ui-sortable-helper drag-selected\"))}})}),n(\"controllers/fields/savedFields\",[],function(){return Marionette.Object.extend({ignoreAttributes:[\"editActive\",\"order\",\"saved\",\"jBox\"],initialize:function(){this.listenTo(i.channel(\"fields\"),\"update:setting\",this.updateField),this.listenTo(i.channel(\"drawer\"),\"click:addSavedField\",this.clickAddSavedField,this)},updateField:function(e){if(e.get(\"saved\")){var t=!1,n=_.keys(e.changedAttributes()),i=this;_.each(n,function(e){-1==i.ignoreAttributes.indexOf(e)&&(t=!0)}),t&&e.set(\"saved\",!1)}},clickAddSavedField:function(e,t){var n=i.channel(\"app\").request(\"clone:modelDeep\",t),r=n.attributes;r.saved=!0,delete r.jBox,delete r.editActive,delete r.created_at,delete r.order,delete r.id,delete r.formID,delete r.parent_id;var a=i.channel(\"fields\").request(\"get:type\",r.type),l=_.clone(a.attributes),s=jQuery(e.target).parent().parent().find(\"input\").val();console.log(s),l.nicename=s,r.label=s,r.nicename=s,t.set(\"addSavedLoading\",!0);var o=JSON.stringify(r);jQuery.post(ajaxurl,{action:\"nf_create_saved_field\",field:o,security:nfAdmin.ajaxNonce},function(e){e=JSON.parse(e),l.id=e.data.id,l.nicename=s,l.settingDefaults=r;var n=i.channel(\"fields\").request(\"get:typeCollection\");n.add(l);i.channel(\"fields\").request(\"get:typeSections\").get(\"saved\").get(\"fieldTypes\").push(l.id),t.set(\"addSavedLoading\",!1),t.unset(\"addSavedLoading\",{silent:!0}),t.get(\"jBox\").close(),i.channel(\"notices\").request(\"add\",\"addSaved\",\"Saved Field Added\")})}})}),n(\"controllers/fields/fieldDatepicker\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"setting-type-datepicker\"),\"render:setting\",this.addDatepicker)},addDatepicker:function(e,t,n){pikadayResponsive(jQuery(n.el).find(\".setting\")[0])}})}),n(\"controllers/fields/fieldDisplayCalc\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"setting-calc_var\"),\"before:renderSetting\",this.beforeRenderSetting)},beforeRenderSetting:function(e,t,n){},getProductFields:function(e){var t=[e.get(\"select_product\")],n=i.channel(\"fields\").request(\"get:collection\");return _.each(n.models,function(e){\"product\"==e.get(\"type\")&&t.push({label:e.get(\"label\"),value:e.get(\"id\")})}),t}})}),n(\"controllers/actions/types\",[\"models/app/typeCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.installedActions=new e(_.filter(actionTypeData,function(e){return\"installed\"==e.section}),{slug:\"installed\",nicename:nfi18n.installed}),this.availableActions=new e(_.filter(actionTypeData,function(e){return\"available\"==e.section}),{slug:\"available\",\nnicename:nfi18n.available}),i.channel(\"actions\").reply(\"get:type\",this.getType,this),i.channel(\"actions\").reply(\"get:installedActions\",this.getInstalledActions,this),i.channel(\"actions\").reply(\"get:availableActions\",this.getAvailableActions,this)},getType:function(e){var t=this.installedActions.get(e);return t||(t=this.availableActions.get(e)),t},getInstalledActions:function(){return this.installedActions},getAvailableActions:function(){return this.availableActions},addStagedField:function(e){var t=jQuery(e.target).data(\"id\");i.channel(\"fields\").request(\"add:stagedField\",t)},getTypeSections:function(){return this.fieldTypeSections}})}),n(\"models/actions/actionModel\",[],function(){return Backbone.Model.extend({defaults:{objectType:\"Action\",objectDomain:\"actions\",editActive:!1},initialize:function(){this.on(\"change\",this.changeSetting,this);var e=i.channel(\"actions\").request(\"get:type\",this.get(\"type\"));if(void 0!==e){var t=this;_.each(e.get(\"settingDefaults\"),function(e,n){t.get(n)||t.set(n,e,{silent:!0})}),i.channel(\"actions\").trigger(\"init:actionModel\",this),i.channel(\"actions-\"+this.get(\"type\")).trigger(\"init:actionModel\",this),this.listenTo(i.channel(\"app\"),\"fire:updateFieldKey\",this.updateFieldKey)}},changeSetting:function(e,t){i.channel(\"actionSetting-\"+_.keys(this.changedAttributes())[0]).trigger(\"update:setting\",this,t.settingModel),i.channel(\"actions\").trigger(\"update:setting\",this,t.settingModel),i.channel(\"app\").trigger(\"update:setting\",this,t.settingModel)},updateFieldKey:function(e,t){i.channel(\"app\").trigger(\"replace:fieldKey\",this,e,t)}})}),n(\"models/actions/actionCollection\",[\"models/actions/actionModel\"],function(e){return Backbone.Collection.extend({model:e,comparator:\"order\",tmpNum:1,initialize:function(){this.on(\"add\",this.addAction,this),this.on(\"remove\",this.removeAction,this),this.newIDs=[]},addAction:function(e){this.newIDs.push(e.get(\"id\"))},removeAction:function(e){this.removedIDs[e.get(\"id\")]=e.get(\"id\")}})}),n(\"controllers/actions/data\",[\"models/actions/actionCollection\",\"models/actions/actionModel\"],function(e,t){return Marionette.Object.extend({initialize:function(){if(this.collection=new e(preloadedFormData.actions),this.collection.tmpNum=1,0!=this.collection.models.length){var t=this;_.each(this.collection.models,function(e){jQuery.isNumeric(e.get(\"id\"))||t.collection.tmpNum++})}this.collection.removedIDs={},i.channel(\"actions\").reply(\"get:collection\",this.getCollection,this),i.channel(\"actions\").reply(\"get:action\",this.getAction,this),i.channel(\"actions\").reply(\"get:tmpID\",this.getTmpID,this),i.channel(\"actions\").reply(\"add\",this.addAction,this),i.channel(\"actions\").reply(\"delete\",this.deleteAction,this)},getCollection:function(){return this.collection},getAction:function(e){return this.collection.get(e)},addAction:function(e,n){if(n=n||!1,!1==e instanceof Backbone.Model)var r=new t(e);else var r=e;return this.collection.add(r,{silent:n}),i.channel(\"app\").request(\"update:setting\",\"clean\",!1),r},deleteAction:function(e){this.collection.remove(e),i.channel(\"app\").request(\"update:setting\",\"clean\",!1),i.channel(\"app\").request(\"update:db\")},getTmpID:function(){var e=this.collection.tmpNum;return this.collection.tmpNum++,\"tmp-\"+e}})}),n(\"controllers/actions/actionSettings\",[\"models/app/settingCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.collection=new e(actionSettings,{objectType:\"actions\"}),i.channel(\"actions\").reply(\"get:settingModel\",this.getSettingModel,this)},getSettingModel:function(e){return this.collection.findWhere({name:e})}})}),n(\"controllers/actions/editActive\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"actions\").reply(\"clear:editActive\",this.clearEditActive,this),this.listenTo(i.channel(\"drawer-editSettings\"),\"before:closeDrawer\",this.clearEditActive)},clearEditActive:function(){var e=i.channel(\"actions\").request(\"get:collection\");_.each(e.models,function(e){e.set(\"editActive\",!1)})}})}),n(\"controllers/actions/emailFromSetting\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"actionSetting-from_address\"),\"update:setting\",this.updateFromAddress)},updateFromAddress:function(e,t){if(void 0!==t){var n=e.get(\"from_address\").trim();return\"{wp:admin_email}\"==n?t.set(\"warning\",!1):n&&!this.isValidEmail(n)||nfAdmin.home_url_host!=n.replace(/.*@/,\"\")?t.set(\"warning\",nfi18n.errorInvalidEmailFromAddress):t.set(\"warning\",!1)}},isValidEmail:function(e){return/^.+@.+\\..+$/.test(e)}})}),n(\"controllers/actions/addActionTypes\",[\"models/actions/actionCollection\",\"models/actions/actionModel\"],function(e,t){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"actions\"),\"click:addAction\",this.addAction),i.channel(\"actions\").reply(\"add:actionType\",this.addAction,this)},addAction:function(e){var t={id:i.channel(\"actions\").request(\"get:tmpID\"),type:e.get(\"id\"),label:e.get(\"settingDefaults\").label||e.get(\"nicename\")},n=i.channel(\"actions\").request(\"add\",t),r={object:\"Action\",label:n.get(\"label\"),change:\"Added\",dashicon:\"plus-alt\"},t={collection:i.channel(\"actions\").request(\"get:collection\")};i.channel(\"changes\").request(\"register:change\",\"addObject\",n,null,r,t),i.channel(\"app\").trigger(\"click:edit\",{},n)}})}),n(\"controllers/actions/typeDrag\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"drawer-addAction\"),\"startDrag:type\",this.startDrag),this.listenTo(i.channel(\"drawer-addAction\"),\"stopDrag:type\",this.stopDrag),i.channel(\"drawer-addAction\").reply(\"get:typeHelperClone\",this.getCurrentDraggableHelperClone,this)},startDrag:function(e,t){this.drawerEl=i.channel(\"app\").request(\"get:drawerEl\"),this.mainEl=i.channel(\"app\").request(\"get:mainEl\"),jQuery(this.drawerEl)[0].style.setProperty(\"overflow\",\"visible\",\"important\"),this.draggableHelperClone=jQuery(t.helper).clone()},stopDrag:function(e,t){jQuery(this.drawerEl)[0].style.setProperty(\"overflow\",\"hidden\",\"important\")},getCurrentDraggableHelperClone:function(){return this.draggableHelperClone}})}),n(\"controllers/actions/droppable\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"app\").reply(\"drop:actionType\",this.dropActionType,this)},dropActionType:function(e,t){var n=jQuery(t.helper).data(\"type\"),r=i.channel(\"actions\").request(\"get:type\",n);i.channel(\"actions\").request(\"add:actionType\",r)}})}),n(\"models/actions/typeModel\",[],function(){return Backbone.Model.extend({})}),n(\"models/actions/typeCollection\",[\"models/actions/typeModel\"],function(e){return Backbone.Collection.extend({model:e})}),n(\"controllers/actions/filterTypes\",[\"models/actions/typeCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"drawer-addAction\"),\"change:filter\",this.filterActionTypes)},filterActionTypes:function(t,n){if(\"\"!=jQuery.trim(t)){var r=[],a=i.channel(\"actions\").request(\"get:installedActions\");_.each(this.filterCollection(t,a),function(e){r.push(e)});var l=[],s=i.channel(\"actions\").request(\"get:availableActions\");_.each(this.filterCollection(t,s),function(e){l.push(e)});var o=new e(r);o.slug=\"installed\",o.nicename=\"Installed\";var c=new e(l);c.slug=\"available\",c.nicename=\"Available\",i.channel(\"drawer\").trigger(\"filter:actionTypes\",o,c),n.addObject&&0<o.length&&(i.channel(\"actions\").request(\"add:actionType\",o.models[0]),i.channel(\"drawer\").request(\"clear:filter\"))}else i.channel(\"drawer\").trigger(\"clear:filter\")},filterCollection:function(e,t){return e=e.toLowerCase(),t.filter(function(t){var n=!1;return-1!=t.get(\"id\").toLowerCase().indexOf(e)?n=!0:-1!=t.get(\"nicename\").toLowerCase().indexOf(e)&&(n=!0),t.get(\"tags\")&&0==e.indexOf(\"#\")&&_.each(t.get(\"tags\"),function(t){e.replace(\"#\",\"\").length>1&&-1!=t.toLowerCase().indexOf(e.replace(\"#\",\"\"))&&(n=!0)}),t.get(\"alias\")&&_.each(t.get(\"alias\"),function(t){-1!=t.toLowerCase().indexOf(e)&&(n=!0)}),n})}})}),n(\"controllers/actions/newsletterList\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"setting-newsletter_list\"),\"show:setting\",this.defaultFields),this.listenTo(i.channel(\"setting-type-newsletter_list\"),\"click:extra\",this.clickListUpdate),this.listenTo(i.channel(\"actionSetting-newsletter_list\"),\"update:setting\",this.maybeRenderFields),this.listenTo(i.channel(\"actionSetting-newsletter_list\"),\"update:setting\",this.maybeRenderGroups),this.listenTo(i.channel(\"setting-name-newsletter_list_fields\"),\"init:settingModel\",this.registerFieldsListener),this.listenTo(i.channel(\"setting-name-newsletter_list_groups\"),\"init:settingModel\",this.registerGroupsListener)},defaultFields:function(e,t){this.maybeRenderFields(t,e),this.maybeRenderGroups(t,e)},registerFieldsListener:function(e){e.listenTo(i.channel(\"newsletter_list_fields\"),\"update:fieldMapping\",this.updateFieldMapping,e)},registerGroupsListener:function(e){e.listenTo(i.channel(\"newsletter_list_groups\"),\"update:interestGroups\",this.updateInterestGroups,e)},clickListUpdate:function(e,t,n,i){var r={action:\"nf_\"+n.attributes.type+\"_get_lists\",security:nfAdmin.ajaxNonce},a=this;jQuery(e.srcElement).addClass(\"spin\"),jQuery.post(ajaxurl,r,function(e){var e=JSON.parse(e);a.updateLists(t,e.lists,i,n),n.set(\"newsletter_list\",e.lists[0].value,{settingModel:t})}).always(function(){jQuery(e.srcElement).removeClass(\"spin\")})},updateLists:function(e,t,n,i){e.set(\"options\",t),n.render()},maybeRenderFields:function(e,t){if(void 0!==t){var n=e.get(\"newsletter_list\"),r=t.get(\"options\");_.each(r,function(e){n==e.value&&i.channel(\"newsletter_list_fields\").trigger(\"update:fieldMapping\",e.fields)}),e.set(\"newsletter_list_fields\",0)}},maybeRenderGroups:function(e,t){if(void 0!==t){var n=e.get(\"newsletter_list\"),r=t.get(\"options\");_.each(r,function(e){n==e.value&&i.channel(\"newsletter_list_groups\").trigger(\"update:interestGroups\",e.groups)}),e.set(\"newsletter_list_fields\",0)}},updateFieldMapping:function(e){var t=this.get(\"settings\");t.reset(),_.each(e,function(e){t.add({name:e.value,type:\"textbox\",label:e.label,width:\"full\",use_merge_tags:{exclude:[\"user\",\"post\",\"system\",\"querystrings\"]}})}),this.set(\"settings\",t)},updateInterestGroups:function(e){var t=this.get(\"settings\");t.reset(),_.each(e,function(e){t.add({name:e.value,type:\"toggle\",label:e.label,width:\"full\"})}),this.set(\"settings\",t)}})}),n(\"controllers/actions/deleteFieldListener\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"actions\"),\"init:actionModel\",this.registerListener)},registerListener:function(e){e.listenTo(i.channel(\"fields\"),\"delete:field\",this.maybeUpdateSettings)},maybeUpdateSettings:function(e){var t,n=\"{field:\"+e.get(\"key\")+\"}\";_.each(this.attributes,function(e,i){if(_.isString(e))this.set(i,e.replace(n,\"\"));else if(_.isArray(e))_.each(e,function(r,a){_.isString(r)?console.log(\"string replace\"):_.isArray(r)?console.log(\"array search\"):_.isObject(r)&&(t=_.mapObject(r,function(t,i){return _.isString(t)&&-1!=t.indexOf(n)&&e.splice(a,1),t}),this.set(i,e))},this);else if(e instanceof Backbone.Collection){var r=e.filter(function(e){return _.every(e.attributes,function(e){return!_.isString(e)||-1==e.indexOf(n)})});this.set(i,r)}},this)}})}),n(\"controllers/actions/collectPaymentFields\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"before:renderSetting\",this.beforeRenderSetting)},beforeRenderSetting:function(e,t,n){if(\"field\"!=e.get(\"total_type\"))return!1;var r=this.getFields(e),a=t.get(\"payment_total\");a=a.replace(\"{field:\",\"\"),a=a.replace(\"}\",\"\");var l=i.channel(\"fields\").request(\"get:field\",a);void 0!==l&&void 0===_.findWhere(r,{value:t.get(\"payment_total\")})&&r.push({label:l.get(\"label\"),value:\"{field:\"+l.get(\"key\")+\"}\"}),e.set(\"options\",r)},getFields:function(e){var t=[e.get(\"default_options\")],n=i.channel(\"fields\").request(\"get:collection\");return _.each(n.models,function(e){\"number\"!=e.get(\"type\")&&\"total\"!=e.get(\"type\")&&\"checkbox\"!=e.get(\"type\")||t.push({label:e.get(\"label\"),value:\"{field:\"+e.get(\"key\")+\"}\"})}),t=_.sortBy(t,function(e){return e.label})}})}),n(\"controllers/actions/collectPaymentCalculations\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"before:renderSetting\",this.beforeRenderSetting)},beforeRenderSetting:function(e,t,n){if(\"calc\"==e.get(\"total_type\")){var r=i.channel(\"app\").request(\"get:formModel\"),a=this.getCalcs(r,e);e.set(\"options\",a)}},getCalcs:function(e,t){var n=[t.get(\"default_options\")],i=e.get(\"settings\").get(\"calculations\");return _.each(i.models,function(e){n.push({label:e.get(\"name\"),value:\"{calc:\"+e.get(\"name\")+\"}\"})}),n=_.sortBy(n,function(e){return e.label})}})}),n(\"controllers/actions/collectPaymentFixed\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"app\"),\"before:renderSetting\",this.beforeRenderSetting)},beforeRenderSetting:function(e,t,n){if(\"payment_total_type\"!=e.get(\"name\")||_.isEmpty(t.get(\"payment_total\")))return!1;(\"undefined\"==t.get(\"payment_total_type\")||_.isEmpty(t.get(\"payment_total_type\")))&&(-1!=t.get(\"payment_total\").indexOf(\"{field\")?t.set(\"payment_total_type\",\"field\"):-1!=t.get(\"payment_total\").indexOf(\"{calc\")?t.set(\"payment_total_type\",\"calc\"):t.set(\"payment_total_type\",\"fixed\"))}})}),n(\"controllers/actions/collectPayment\",[],function(e){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"actions-collectpayment\"),\"init:actionModel\",this.initCollectPayment),this.listenTo(i.channel(\"app\"),\"before:renderSetting\",this.maybeClearTotal)},initCollectPayment:function(e){e.listenTo(i.channel(\"calcs\"),\"update:calcName\",this.maybeUpdateTotal)},maybeError:function(){},maybeUpdateTotal:function(e,t){if(\"calc\"==this.get(\"payment_total_type\")){var n=this.get(\"payment_total\").replace(\"{calc:\"+t+\"}\",\"{calc:\"+e.get(\"name\")+\"}\");this.set(\"payment_total\",n)}},maybeClearTotal:function(e,t,n){\"fixed\"==t.get(\"payment_total_type\")&&(-1==t.get(\"payment_total\").indexOf(\"{field\")&&-1==t.get(\"payment_total\").indexOf(\"{calc\")||t.set(\"payment_total\",\"\"))}})}),n(\"controllers/actions/save\",[],function(e){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"actions-save\"),\"init:actionModel\",this.initSave)},initSave:function(e){this.model=e,this.listenTo(Backbone.Radio.channel(\"fields\"),\"add:field\",this.checkFieldAdded),this.listenTo(Backbone.Radio.channel(\"fields\"),\"delete:field\",this.checkFieldDeleted)},checkFieldAdded:function(e){if(\"email\"==e.get(\"type\")){\"\"===this.model.get(\"submitter_email\")&&this.model.set(\"submitter_email\",e.get(\"key\"))}},checkFieldDeleted:function(e){this.model.get(\"submitter_email\")==e.get(\"key\")&&this.model.set(\"submitter_email\",\"\")}})}),n(\"controllers/advanced/types\",[\"models/app/typeCollection\"],function(e){return Marionette.Object.extend({initialize:function(){if(this.collection=new e(formSettingTypeData),!nfAdmin.devMode){var t=this.collection.where({id:\"calculations\"});this.collection.remove(t)}i.channel(\"settings\").reply(\"get:type\",this.getType,this),i.channel(\"settings\").reply(\"get:typeCollection\",this.getCollection,this)},getType:function(e){return this.collection.get(e)},getCollection:function(){return this.collection}})}),n(\"models/advanced/settingsModel\",[],function(){return Backbone.Model.extend({defaults:{objectType:\"Form Setting\",editActive:!1},initialize:function(){this.bind(\"change\",this.changeSetting,this);var e=i.channel(\"settings\").request(\"get:collection\");_.each(e.models,function(e){void 0===this.get(e.get(\"name\"))&&this.set(e.get(\"name\"),e.get(\"value\"),{silent:!0}),i.channel(e.get(\"type\")).trigger(\"init:dataModel\",this,e)},this),this.listenTo(i.channel(\"app\"),\"fire:updateFieldKey\",this.updateFieldKey)},changeSetting:function(e,t){i.channel(\"app\").trigger(\"update:setting\",this,t.settingModel)},updateFieldKey:function(e,t){i.channel(\"app\").trigger(\"replace:fieldKey\",this,e,t)}})}),n(\"controllers/advanced/data\",[\"models/advanced/settingsModel\"],function(e){return Marionette.Object.extend({initialize:function(){this.model=new e(preloadedFormData.settings),i.channel(\"settings\").reply(\"get:settings\",this.getSettings,this),i.channel(\"settings\").reply(\"get:setting\",this.getSetting,this),i.channel(\"settings\").reply(\"update:setting\",this.updateSetting,this)},getSettings:function(){return this.model},updateSetting:function(e,t,n){n=n||!1,this.model.set(e,t,{silent:n})},getSetting:function(e){return this.model.get(e)}})}),n(\"controllers/advanced/formSettings\",[\"models/app/settingCollection\"],function(e){return Marionette.Object.extend({initialize:function(){this.collection=new e(formSettings,{objectType:\"settings\"}),i.channel(\"settings\").reply(\"get:settingModel\",this.getSettingModel,this),i.channel(\"settings\").reply(\"get:collection\",this.getSettingCollection,this)},getSettingModel:function(e){return this.collection.findWhere({name:e})},getSettingCollection:function(){return this.collection}})}),n(\"controllers/advanced/editActive\",[],function(){return Marionette.Object.extend({initialize:function(){i.channel(\"settings\").reply(\"clear:editActive\",this.clearEditActive,this),this.listenTo(i.channel(\"drawer-editSettings\"),\"before:closeDrawer\",this.clearEditActive)},clearEditActive:function(){var e=i.channel(\"settings\").request(\"get:typeCollection\");_.each(e.models,function(e){e.set(\"editActive\",!1)})}})}),n(\"controllers/advanced/clickEdit\",[\"models/advanced/settingsModel\"],function(e){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"settings\"),\"click:edit\",this.clickEdit)},clickEdit:function(e,t){var n=i.channel(\"settings\").request(\"get:settings\");i.channel(\"app\").request(\"open:drawer\",\"editSettings\",{model:n,groupCollection:t.get(\"settingGroups\"),typeModel:t}),i.channel(\"drawer\").request(\"get:preventClose\")||t.set(\"editActive\",!0)}})}),n(\"controllers/advanced/calculations\",[],function(){return Marionette.Object.extend({initialize:function(){this.listenTo(i.channel(\"option-repeater-calculations\"),\"keyup:option\",this.keyUp),this.listenTo(i.channel(\"option-repeater-calculations\"),\"update:option\",this.updateCalc),this.listenTo(i.channel(\"option-repeater-calculations\"),\"sort:option\",this.sortCalc)},keyUp:function(e,t){var n=jQuery(e.target).val(),i=jQuery(e.target).data(\"id\");\"name\"==i?(this.checkName(n,t),this.checkEQ(t.get(\"eq\"),t)):\"eq\"==i?this.checkEQ(n,t):\"dec\"==i&&this.checkDec(n,t)},updateCalc:function(e){this.checkName(e.get(\"name\"),e,!1),this.checkEQ(e.get(\"eq\"),e),this.checkDec(e.get(\"dec\"),e),Backbone.Radio.channel(\"calcs\").trigger(\"update:calc\",e)},sortCalc:function(e,t){this.checkAllCalcs(t.collection)},checkName:function(e,t,n){n=n||!0;var r=t.get(\"errors\"),a=t.collection.where({name:jQuery.trim(e)});if(e==t.get(\"name\")&&(a=[]),0!=a.length)r.nameExists=\"Calculation names must be unique. Please enter another name.\";else{var l=t.get(\"name\");t.set(\"name\",e,{silent:n}),i.channel(\"calcs\").trigger(\"update:calcName\",t,l),delete r.nameExists}t.set(\"errors\",r),t.trigger(\"change:errors\",t)},checkEQ:function(e,t){var n=t.get(\"errors\"),i=!1,r=!1,a=e.match(new RegExp(/{calc:(.*?)}/g));if(a){var l=t.collection;a=a.map(function(e){var a=e.replace(\"}\",\"\").replace(\"{calc:\",\"\"),s=l.findWhere({name:a});a==t.get(\"name\")?(n.selfRef=\"A calculation can't reference itself!\",i=!0):s&&s.get(\"order\")>t.get(\"order\")&&(r=!0,n.futureCalc=\"Can't reference a future calculation!\")})}i||delete n.selfRef,r||delete n.futureCalc,t.set(\"errors\",n),t.trigger(\"change:errors\",t)},checkDec:function(e,t){if(void 0===e)return!1;var n=t.get(\"errors\"),i=!1,r=Math.abs(parseInt(e.trim()));\"\"!==e.trim()&&r.toString()!==e.trim()&&(i=!0,n.nonIntDec=\"Decimals must be a non-negative integer!\"),i||delete n.nonIntDec,t.set(\"errors\",n),t.trigger(\"change:errors\",t)},checkAllCalcs:function(e){var t=this;e.models.map(function(e){t.checkName(e.get(\"name\"),e),t.checkEQ(e.get(\"eq\"),e),t.checkDec(e.get(\"dec\"),e)})}})}),n(\"controllers/loadControllers\",[\"controllers/app/remote\",\"controllers/app/drawer\",\"controllers/app/drawerConfig\",\"controllers/app/domainConfig\",\"controllers/app/data\",\"controllers/app/drawerToggleSettingGroup\",\"controllers/app/updateDB\",\"controllers/app/formData\",\"controllers/app/previewLink\",\"controllers/app/menuButtons\",\"controllers/app/trackChanges\",\"controllers/app/undoChanges\",\"controllers/app/publishResponse\",\"controllers/app/changeDomain\",\"controllers/app/pushstate\",\"controllers/app/hotkeys\",\"controllers/app/cleanState\",\"controllers/app/coreUndo\",\"controllers/app/cloneModelDeep\",\"controllers/app/getSettingChildView\",\"controllers/app/changeSettingDefault\",\"controllers/app/fieldset\",\"controllers/app/toggleSetting\",\"controllers/app/buttonToggleSetting\",\"controllers/app/numberSetting\",\"controllers/app/radioSetting\",\"controllers/app/itemControls\",\"controllers/app/mergeTags\",\"controllers/app/mergeTagBox\",\"controllers/app/itemSettingFill\",\"controllers/app/confirmPublish\",\"controllers/app/rte\",\"controllers/app/settingFieldSelect\",\"controllers/app/settingFieldList\",\"controllers/app/settingHTML\",\"controllers/app/settingColor\",\"controllers/app/changeMenu\",\"controllers/app/mobile\",\"controllers/app/notices\",\"controllers/app/unloadCheck\",\"controllers/app/formContentFilters\",\"controllers/app/formContentGutterFilters\",\"controllers/app/cloneCollectionDeep\",\"controllers/app/trackKeyDown\",\"controllers/app/perfectScroll\",\"controllers/app/getNewSettingGroupCollection\",\"controllers/app/settingMedia\",\"controllers/app/publicLink\",\"controllers/fields/types\",\"controllers/fields/fieldTypeDrag\",\"controllers/fields/stagingDrag\",\"controllers/fields/staging\",\"controllers/fields/stagingSortable\",\"controllers/fields/filterTypes\",\"controllers/fields/sortable\",\"controllers/fields/data\",\"controllers/app/optionRepeater\",\"controllers/fields/editActive\",\"controllers/fields/fieldSettings\",\"controllers/fields/fieldCreditCard\",\"controllers/fields/fieldList\",\"controllers/fields/fieldPassword\",\"controllers/fields/fieldQuantity\",\"controllers/fields/fieldShipping\",\"controllers/fields/key\",\"controllers/fields/notices\",\"controllers/fields/mobile\",\"controllers/fields/savedFields\",\"controllers/fields/fieldDatepicker\",\"controllers/fields/fieldDisplayCalc\",\"controllers/actions/types\",\"controllers/actions/data\",\"controllers/actions/actionSettings\",\"controllers/actions/editActive\",\"controllers/actions/emailFromSetting\",\"controllers/actions/addActionTypes\",\"controllers/actions/typeDrag\",\"controllers/actions/droppable\",\"controllers/actions/filterTypes\",\"controllers/actions/newsletterList\",\"controllers/actions/deleteFieldListener\",\"controllers/actions/collectPaymentFields\",\"controllers/actions/collectPaymentCalculations\",\"controllers/actions/collectPaymentFixed\",\"controllers/actions/collectPayment\",\"controllers/actions/save\",\"controllers/advanced/types\",\"controllers/advanced/data\",\"controllers/advanced/formSettings\",\"controllers/advanced/editActive\",\"controllers/advanced/clickEdit\",\"controllers/advanced/calculations\"],function(e,t,n,i,r,a,l,s,o,c,d,u,h,g,p,f,m,y,v,w,b,C,j,k,M,T,S,x,F,Q,_,q,D,O,A,E,L,V,R,z,N,B,I,H,P,G,$,K,W,U,J,Y,Z,X,ee,te,ne,ie,re,ae,le,se,oe,ce,de,ue,he,ge,pe,fe,me,ye,ve,we,be,Ce,je,ke,Me,Te,Se,xe,Fe,Qe,_e,qe,De,Oe,Ae,Ee,Le,Ve){return Marionette.Object.extend({initialize:function(){new N,new B,new f,new e,new t,new n,new i,new a,new o,new c,new d,new u,new h,new g,new m,new y,new v,new S,new _,new q,new D,new O,new A,new E,new $,new L,new V,new R,new z,new l,new I,new H,new P,new G,new K,new C,new ne,new W,new U,new J,new Y,new Z,new X,new ee,new b,new j,new k,new M,new T,new w,new ie,new re,new ae,new le,new se,new oe,new ce,new de,new ue,new he,new ge,new pe,new fe,new Te,new Se,new Fe,new _e,new qe,new me,new ye,new ve,new we,new be,new Ce,new je,new ke,new Me,new xe,new Qe,new De,new Ae,new Ve,new Oe,new Ee,new Le,new r,new te,new s,new x,new F,new Q}})}),n(\"views/fields/mainContentEmpty\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-main-content-fields-empty\",onBeforeDestroy:function(){jQuery(this.el).parent().removeClass(\"nf-fields-empty-droppable\").droppable(\"destroy\")},onRender:function(){this.$el=this.$el.children(),this.$el.unwrap(),this.setElement(this.$el)},onShow:function(){jQuery(this.el).parent().hasClass(\"ui-sortable\")&&jQuery(this.el).parent().sortable(\"destroy\"),jQuery(this.el).parent().addClass(\"nf-fields-empty-droppable\"),jQuery(this.el).parent().droppable({accept:function(e){if(jQuery(e).hasClass(\"nf-stage\")||jQuery(e).hasClass(\"nf-field-type-button\"))return!0},activeClass:\"nf-droppable-active\",hoverClass:\"nf-droppable-hover\",tolerance:\"pointer\",over:function(e,t){t.item=t.draggable,i.channel(\"app\").request(\"over:fieldsSortable\",t)},out:function(e,t){t.item=t.draggable,i.channel(\"app\").request(\"out:fieldsSortable\",t)},drop:function(e,t){t.item=t.draggable,i.channel(\"app\").request(\"receive:fieldsSortable\",t);var n=i.channel(\"fields\").request(\"get:collection\");n.trigger(\"reset\",n)}})}})}),n(\"views/app/formTitle\",[],function(){return Marionette.ItemView.extend({tagName:\"div\",template:\"#tmpl-nf-header-form-title\",initialize:function(){this.model.on(\"change:title\",this.render,this)},templateHelpers:function(){return{renderTitle:function(){var e=i.channel(\"app\").request(\"get:formModel\");return _.escape(e.get(\"settings\").get(\"title\"))}}}})}),n(\"views/loadViews\",[\"views/fields/fieldItem\",\"views/fields/mainContentEmpty\",\"views/app/formTitle\"],function(e,t,n){return Marionette.Object.extend({initialize:function(){i.channel(\"views\").reply(\"get:fieldItem\",this.getFieldItem),i.channel(\"views\").reply(\"get:mainContentEmpty\",this.getMainContentEmpty),i.channel(\"views\").reply(\"get:formTitle\",this.getFormTitle)},getFieldItem:function(t){return e},getMainContentEmpty:function(){return t},getFormTitle:function(){return n}})});var i=Backbone.Radio;jQuery(document).ready(function(e){t([\"views/app/builder\",\"controllers/loadControllers\",\"views/loadViews\"],function(t,n,r){(new(Marionette.Application.extend({initialize:function(e){var t=this;Marionette.Renderer.render=function(e,n){var e=t.template(e);return e(n)},i.channel(\"app\").trigger(\"before:loadControllers\",this);new n;i.channel(\"app\").trigger(\"after:loadControllers\",this),i.channel(\"app\").trigger(\"before:loadViews\",this);new r;i.channel(\"app\").trigger(\"after:loadViews\",this),i.channel(\"app\").reply(\"get:template\",this.template)},onStart:function(){new t;i.channel(\"app\").trigger(\"after:appStart\",this),0==nfAdmin.formID&&i.channel(\"app\").request(\"open:drawer\",\"addField\")},template:function(t){return _.template(e(t).html(),{evaluate:/<#([\\s\\S]+?)#>/g,interpolate:/\\{\\{\\{([\\s\\S]+?)\\}\\}\\}/g,escape:/\\{\\{([^\\}]+?)\\}\\}(?!\\})/g,variable:\"data\"})}}))).start()})}),n(\"main\",function(){})}();"],"file":"builder.js"}