// This file was generated by modules-webmake (modules for web) project.
// See: https://github.com/medikoo/modules-webmake

(function (modules) {
	'use strict';

	var resolve, getRequire, wmRequire, notFoundError, findFile
	  , extensions = {".js":[],".json":[],".css":[],".html":[]}
	  , envRequire = typeof require === 'function' ? require : null;

	notFoundError = function (path) {
		var error = new Error("Could not find module '" + path + "'");
		error.code = 'MODULE_NOT_FOUND';
		return error;
	};
	findFile = function (scope, name, extName) {
		var i, ext;
		if (typeof scope[name + extName] === 'function') return name + extName;
		for (i = 0; (ext = extensions[extName][i]); ++i) {
			if (typeof scope[name + ext] === 'function') return name + ext;
		}
		return null;
	};
	resolve = function (scope, tree, path, fullPath, state, id) {
		var name, dir, exports, module, fn, found, ext;
		path = path.split('/');
		name = path.pop();
		if ((name === '.') || (name === '..')) {
			path.push(name);
			name = '';
		}
		while ((dir = path.shift()) != null) {
			if (!dir || (dir === '.')) continue;
			if (dir === '..') {
				scope = tree.pop();
				id = id.slice(0, id.lastIndexOf('/'));
			} else {
				tree.push(scope);
				scope = scope[dir];
				id += '/' + dir;
			}
			if (!scope) throw notFoundError(fullPath);
		}
		if (name && (typeof scope[name] !== 'function')) {
			found = findFile(scope, name, '.js');
			if (!found) found = findFile(scope, name, '.json');
			if (!found) found = findFile(scope, name, '.css');
			if (!found) found = findFile(scope, name, '.html');
			if (found) {
				name = found;
			} else if ((state !== 2) && (typeof scope[name] === 'object')) {
				tree.push(scope);
				scope = scope[name];
				id += '/' + name;
				name = '';
			}
		}
		if (!name) {
			if ((state !== 1) && scope[':mainpath:']) {
				return resolve(scope, tree, scope[':mainpath:'], fullPath, 1, id);
			}
			return resolve(scope, tree, 'index', fullPath, 2, id);
		}
		fn = scope[name];
		if (!fn) throw notFoundError(fullPath);
		if (fn.hasOwnProperty('module')) return fn.module.exports;
		exports = {};
		fn.module = module = { exports: exports, id: id + '/' + name };
		fn.call(exports, exports, module, getRequire(scope, tree, id));
		return module.exports;
	};
	wmRequire = function (scope, tree, fullPath, id) {
		var name, path = fullPath, t = fullPath.charAt(0), state = 0;
		if (t === '/') {
			path = path.slice(1);
			scope = modules['/'];
			if (!scope) {
				if (envRequire) return envRequire(fullPath);
				throw notFoundError(fullPath);
			}
			id = '/';
			tree = [];
		} else if (t !== '.') {
			name = path.split('/', 1)[0];
			scope = modules[name];
			if (!scope) {
				if (envRequire) return envRequire(fullPath);
				throw notFoundError(fullPath);
			}
			id = name;
			tree = [];
			path = path.slice(name.length + 1);
			if (!path) {
				path = scope[':mainpath:'];
				if (path) {
					state = 1;
				} else {
					path = 'index';
					state = 2;
				}
			}
		}
		return resolve(scope, tree, path, fullPath, state, id);
	};
	getRequire = function (scope, tree, id) {
		return function (path) {
			return wmRequire(scope, [].concat(tree), path, id);
		};
	};
	return getRequire(modules, [], '');
})({
	"thrive-dashboard": {
		"inc": {
			"script-manager": {
				"assets": {
					"js": {
						"admin": {
							"models.js": function (exports, module, require) {
								eval("( function ( $ ) {\n\n\tvar utils = require( '../utils.js' ),\n\t\tmodels = {};\n\n\tmodels.ScriptItem = Backbone.Model.extend( {\n\t\tidAttribute: 'id',\n\t\tdefaults: {\n\t\t\tlabel: '',\n\t\t\tstatus: {\n\t\t\t\tlp: true,\n\t\t\t\tttb: true\n\t\t\t},\n\t\t\tplacement: '',\n\t\t\tcode: '',\n\t\t\torder: 0,\n\t\t\ticon: 'nonstandard'\n\t\t},\n\n\t\turl: function () {\n\t\t\treturn TVD_SM_CONST.routes.scripts + ( this.get( 'id' ) ? '/' + this.get( 'id' ) : '' );\n\t\t},\n\n\t\t/**\n\t\t * Set nonce header before every Backbone sync.\n\t\t *\n\t\t * @param {string} method.\n\t\t * @param {Backbone.Model} model.\n\t\t * @param {{beforeSend}, *} options.\n\t\t * @returns {*}.\n\t\t */\n\t\tsync: function ( method, model, options ) {\n\t\t\tvar beforeSend;\n\n\t\t\toptions = options || {};\n\n\t\t\toptions.cache = false;\n\t\t\toptions.url = this.url();\n\n\t\t\tif ( ! _.isUndefined( TVD_SM_CONST.nonce ) && ! _.isNull( TVD_SM_CONST.nonce ) ) {\n\t\t\t\tbeforeSend = options.beforeSend;\n\n\t\t\t\toptions.beforeSend = function ( xhr ) {\n\t\t\t\t\txhr.setRequestHeader( 'X-WP-Nonce', TVD_SM_CONST.nonce );\n\n\t\t\t\t\tif ( beforeSend ) {\n\t\t\t\t\t\treturn beforeSend.apply( this, arguments );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn Backbone.sync( method, model, options );\n\t\t}\n\t} );\n\n\tmodels.collections = {\n\t\tScriptCollection: Backbone.Collection.extend( {\n\n\t\t\tmodel: models.ScriptItem,\n\t\t\tcomparator: 'order',\n\t\t\turl: function () {\n\t\t\t\treturn TVD_SM_CONST.routes.scripts;\n\t\t\t},\n\t\t\t/**\n\t\t\t * Set nonce header before every Backbone sync.\n\t\t\t *\n\t\t\t * @param {string} method.\n\t\t\t * @param {Backbone.Model} model.\n\t\t\t * @param {{beforeSend}, *} options.\n\t\t\t * @returns {*}.\n\t\t\t */\n\t\t\tsync: function ( method, model, options ) {\n\t\t\t\tvar beforeSend;\n\n\t\t\t\toptions = options || {};\n\n\t\t\t\toptions.cache = false;\n\n\t\t\t\tif ( ! _.isUndefined( TVD_SM_CONST.nonce ) && ! _.isNull( TVD_SM_CONST.nonce ) ) {\n\t\t\t\t\tbeforeSend = options.beforeSend;\n\n\t\t\t\t\toptions.beforeSend = function ( xhr ) {\n\t\t\t\t\t\txhr.setRequestHeader( 'X-WP-Nonce', TVD_SM_CONST.nonce );\n\n\t\t\t\t\t\tif ( beforeSend ) {\n\t\t\t\t\t\t\treturn beforeSend.apply( this, arguments );\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn Backbone.sync( method, model, options );\n\t\t\t}\n\t\t} )\n\t};\n\n\tmodule.exports = models;\n} )\n( jQuery );\n//# sourceURL=thrive-dashboard/inc/script-manager/assets/js/admin/models.js");
							},
							"routes.js": function (exports, module, require) {
								eval("( function ( $ ) {\n\t_.templateSettings = {\n\t\tevaluate: /<#([\\s\\S]+?)#>/g,\n\t\tinterpolate: /<#=([\\s\\S]+?)#>/g,\n\t\tescape: /<#-([\\s\\S]+?)#>/g\n\t};\n\n\tvar ScriptManager = ScriptManager || {};\n\n\t$.extend( ScriptManager, {\n\t\tsm_router: Backbone.Router.extend( {\n\n\t\t\tview: null,\n\t\t\t$el: $( '#tvd-sm-container' ),\n\n\t\t\troutes: {\n\t\t\t\t'': 'dashboard'\n\t\t\t},\n\n\t\t\tdashboard: function () {\n\t\t\t\tif ( this.view ) {\n\t\t\t\t\tthis.view.remove();\n\t\t\t\t}\n\t\t\t\tthis.view = new ScriptManager.views.ScriptDashboard( {\n\t\t\t\t\tel: this.$el\n\t\t\t\t} )\n\t\t\t}\n\t\t} ),\n\n\t\tutils: require( '../utils' ),\n\t\tmodels: require( './models' ),\n\t\tviews: require( './views' )\n\t} );\n\n\tScriptManager.router = new ScriptManager.sm_router();\n\n\tBackbone.history.start( {hashchange: true} );\n} )( jQuery );\n//# sourceURL=thrive-dashboard/inc/script-manager/assets/js/admin/routes.js");
							},
							"views.js": function (exports, module, require) {
								eval("( function ( $ ) {\n\n\tvar utils = require( '../utils' ),\n\t\tmodels = require( './models' ),\n\t\tviews = {},\n\t\tscriptsCollection,\n\t\tdoingAjax = false;\n\n\tviews.ScriptDashboard = Backbone.View.extend( {\n\t\ttemplate: utils._t( 'dashboard' ),\n\n\t\tevents: {\n\t\t\t'click .tvd-add-modal': 'addScript',\n\t\t\t'click #tvd-sm-theme-link': 'setLinkTarget'\n\t\t},\n\n\t\tinitialize: function () {\n\t\t\tthis.breadcrumbs = new views.Breadcrumbs( {\n\t\t\t\tel: this.$el.closest( '#tvd-sm-wrapper' ).prev()\n\t\t\t} );\n\n\t\t\tthis.render();\n\n\t\t\t$( '#tvd-delete-page-level-scripts' ).on( 'click', function () {\n\t\t\t\tTVE_Dash.modal( views.DeletePageLevelScriptsModal );\n\t\t\t} );\n\n\t\t\tscriptsCollection = new models.collections.ScriptCollection( TVD_SM_CONST.scripts );\n\n\t\t\t/* initialize the 3 groups of scripts */\n\t\t\tnew views.ScriptGroup( {\n\t\t\t\tcollection: scriptsCollection,\n\t\t\t\t_type: 'head',\n\t\t\t\tel: this.$( '#tvd-sm-container-head' )\n\t\t\t} );\n\n\t\t\tnew views.ScriptGroup( {\n\t\t\t\tcollection: scriptsCollection,\n\t\t\t\t_type: 'body_open',\n\t\t\t\tel: this.$( '#tvd-sm-container-body-open' )\n\t\t\t} );\n\n\t\t\tnew views.ScriptGroup( {\n\t\t\t\tcollection: scriptsCollection,\n\t\t\t\t_type: 'body_close',\n\t\t\t\tel: this.$( '#tvd-sm-container-body-close' )\n\t\t\t} );\n\t\t},\n\n\t\trender: function () {\n\t\t\tthis.$el.html( this.template() );\n\t\t},\n\n\t\taddScript: function () {\n\t\t\tTVE_Dash.modal( views.AddEditScriptModal, {\n\t\t\t\tcollection: scriptsCollection,\n\t\t\t\tmessage: TVD_SM_CONST.translations.add_script\n\t\t\t} );\n\t\t},\n\n\t\tsetLinkTarget: function () {\n\t\t\tlocalStorage.setItem( 'ThriveOptionsSelectedItem', 'analytics-options' )\n\t\t}\n\t} );\n\n\t/* Contains ScriptItems and is responsible of rendering and re-rendering them when they change. */\n\tviews.ScriptGroup = Backbone.View.extend( {\n\t\t\tinitialize: function ( options ) {\n\t\t\t\tvar self = this;\n\n\t\t\t\tthis.options = options;\n\n\t\t\t\t/* adds dragging inside and between groups */\n\t\t\t\tthis.$el.sortable( {\n\t\t\t\t\taxis: 'y',\n\t\t\t\t\tconnectWith: $( '.tvd-sm-script-group' ),\n\t\t\t\t\thandle: '.tvd-icon-handle',\n\n\t\t\t\t\tstart: function ( event, ui ) {\n\t\t\t\t\t\tui.item.addClass( 'tvd-sm-script-drag' );\n\t\t\t\t\t},\n\n\t\t\t\t\tstop: function ( event, ui ) {\n\t\t\t\t\t\tui.item.removeClass( 'tvd-sm-script-drag' );\n\t\t\t\t\t},\n\n\t\t\t\t\tupdate: function ( event, ui ) {\n\t\t\t\t\t\tvar parent = ui.item.parent()[ 0 ];\n\n\t\t\t\t\t\tif ( ! ui.sender && this === parent ) {\n\t\t\t\t\t\t\tself.updateOrder( event, ui );\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if ( this !== parent ) {\n\t\t\t\t\t\t\tif ( self.collection.where( {placement: self.options._type} ).length === 1 ) {\n\t\t\t\t\t\t\t\tself.$el.append( self.renderEmpty().$el );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t},\n\t\t\t\t\treceive: function ( event, ui ) {\n\t\t\t\t\t\tself.updateOrder( event, ui );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\t/* re-renders each time a script is moved between ScriptGroups */\n\t\t\t\tthis.listenTo( this.collection, 'change', function ( model, options ) {\n\t\t\t\t\t/* the add event is flagged with noChange to avoid unnecessary rendering */\n\t\t\t\t\tif ( options.flag !== 'noChange' ) {\n\t\t\t\t\t\tthis.render();\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\t/* each time a script is added or deleted, renders the ScriptGroup with that placement */\n\t\t\t\tthis.listenTo( this.collection, 'add destroy', function ( model ) {\n\t\t\t\t\tif ( model.attributes.placement === this.options._type ) {\n\t\t\t\t\t\tthis.render();\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\tthis.render();\n\t\t\t},\n\n\t\t\tupdateOrder: function ( event, ui ) {\n\t\t\t\tvar self = this,\n\t\t\t\t\tnewScripts = this.$el.sortable( 'toArray', {attribute: 'data-id'} );\n\n\t\t\t\t$.post( {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'X-WP-Nonce': TVD_SM_CONST.nonce\n\t\t\t\t\t},\n\t\t\t\t\turl: TVD_SM_CONST.routes.scripts_order,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tscripts: newScripts\n\t\t\t\t\t},\n\t\t\t\t\tsuccess: function () {\n\t\t\t\t\t\t/* custom reset */\n\t\t\t\t\t\tvar order = 0;\n\t\t\t\t\t\t_.each( newScripts, function ( scriptId ) {\n\t\t\t\t\t\t\t\tself.collection.get( scriptId ).set( {order: order ++}, {silent: true} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t\t/* update placement */\n\t\t\t\t\t\tif ( ui.sender ) {\n\t\t\t\t\t\t\tvar model = self.collection.get( ui.item.data( 'id' ) );\n\t\t\t\t\t\t\tmodel.save(\n\t\t\t\t\t\t\t\t{placement: event.target.dataset.placement},\n\t\t\t\t\t\t\t\t{silent: true} );\n\n\t\t\t\t\t\t\t/* check if group was empty before */\n\t\t\t\t\t\t\tif ( self.$el.hasClass( 'tvd-sm-no-scripts' ) ) {\n\t\t\t\t\t\t\t\t/* remove the empty css */\n\t\t\t\t\t\t\t\tself.$el.empty().removeClass( 'tvd-sm-no-scripts' );\n\t\t\t\t\t\t\t\tself.renderOne( model );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\n\t\t\trenderOne: function ( item ) {\n\t\t\t\tthis.$el.append( new views.ScriptItem( {\n\t\t\t\t\tmodel: item\n\t\t\t\t} ).render().$el );\n\t\t\t},\n\n\t\t\t/*  when there are no scripts in the group, add specific text */\n\t\t\trenderEmpty: function () {\n\t\t\t\tthis.$el.append( TVD_SM_CONST.translations.no_scripts_in_this_group ).addClass( 'tvd-sm-no-scripts' );\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\trender: function () {\n\t\t\t\tthis.$el.empty();\n\t\t\t\tthis.$el.attr( 'data-placement', this.options._type );\n\t\t\t\tthis.collection.sort();\n\n\t\t\t\tvar currentCollection = this.collection.where( {placement: this.options._type} );\n\t\t\t\t_.each( currentCollection, function ( script ) {\n\t\t\t\t\tthis.renderOne( script );\n\t\t\t\t}, this );\n\n\t\t\t\t/* if there are no scripts in this section, add specific text */\n\t\t\t\tif ( currentCollection.length === 0 ) {\n\t\t\t\t\tthis.$el.append( this.renderEmpty().$el );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t/* if a group had no scripts and then something gets added, remove the empty class */\n\t\t\t\t\tif ( this.$el.hasClass( 'tvd-sm-no-scripts' ) ) {\n\t\t\t\t\t\tthis.$el.removeClass( 'tvd-sm-no-scripts' );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t}\n\t\t}\n\t);\n\n\t/* ScriptItem = one line in a ScriptGroup */\n\tviews.ScriptItem = Backbone.View.extend( {\n\t\tclassName: 'tvd-sm-script-item',\n\t\ttemplate: utils._t( 'script-item' ),\n\t\tevents: {\n\t\t\t'click .tvd-edit-modal': 'editScript',\n\t\t\t'click .tvd-delete-modal': 'deleteScript',\n\t\t\t'change .tvd-sm-script-elem-switch': 'toggleEnable'\n\t\t},\n\n\t\tinitialize: function () {\n\t\t\t/* when the model is changed, re-render */\n\t\t\tthis.listenTo( this.model, 'change', this.render );\n\t\t},\n\n\t\ttoggleEnable: function ( event ) {\n\t\t\tvar self = this;\n\n\t\t\t/* wait for the current enable request to finish */\n\t\t\tif ( doingAjax ) {\n\t\t\t\tsetTimeout( function () {\n\t\t\t\t\tself.toggleEnable( event );\n\t\t\t\t}, 200 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t/* set the flag to true so other callbacks have to wait */\n\t\t\tdoingAjax = true;\n\n\t\t\tvar new_status = this.model.get( 'status' );\n\t\t\tnew_status[ event.target.dataset.location ] = event.target.checked;\n\n\t\t\tthis.model.set( 'status', new_status ).save( {}, {\n\t\t\t\tflag: 'noChange',\n\t\t\t\tsuccess: function () {\n\t\t\t\t\tdoingAjax = false;\n\t\t\t\t\tTVE_Dash.success( TVD_SM_CONST.translations.edit_success );\n\t\t\t\t},\n\t\t\t\terror: function () {\n\t\t\t\t\tTVE_Dash.err( TVD_SM_CONST.translations.edit_error );\n\t\t\t\t}\n\t\t\t} );\n\t\t},\n\n\t\tformIconClass: function () {\n\t\t\treturn 'tvd-sm-icon img-' + this.model.get( 'icon' );\n\t\t},\n\n\t\trender: function () {\n\t\t\tthis.$el.html( this.template( {model: this.model} ) );\n\t\t\t/* add the id of the model to the DOM */\n\t\t\tthis.$el.attr( 'data-id', this.model.get( 'id' ) );\n\t\t\tthis.$el.attr( 'data-placement', this.model.get( 'placement' ) );\n\t\t\treturn this;\n\t\t},\n\n\t\teditScript: function () {\n\t\t\tTVE_Dash.modal( views.AddEditScriptModal, {\n\t\t\t\tmodel: this.model,\n\t\t\t\tmessage: TVD_SM_CONST.translations.edit_script\n\t\t\t} );\n\t\t},\n\n\t\tdeleteScript: function () {\n\t\t\tTVE_Dash.modal( views.DeleteScriptModal, {\n\t\t\t\tmodel: this.model,\n\t\t\t\tclassName: 'tvd-modal tvd-sm-delete-script'\n\t\t\t} );\n\t\t}\n\t} );\n\n\t/* Adds or edits ScriptItems according to where the modal was opened from. */\n\tviews.AddEditScriptModal = TVE_Dash.views.Modal.extend( {\n\t\ttemplate: utils._t( 'modal-add-edit-script' ),\n\t\tevents: {\n\t\t\t'click .tvd-submit': 'save',\n\t\t\t'change #tvd-sm-script-code': 'recognizeScript',\n\t\t\t'focusin .tvd-sm-form-element': 'focusLabel',\n\t\t\t'blur .tvd-sm-form-element': 'blurLabel'\n\t\t},\n\n\t\tsave: function () {\n\t\t\tvar newScript = {\n\t\t\t\tlabel: this.$( '#tvd-sm-script-name' ).val(),\n\t\t\t\tstatus: {\n\t\t\t\t\tttb: this.$( '#tvd-sm-script-checkbox-ttb' ).is( ':checked' ),\n\t\t\t\t\tlp: this.$( '#tvd-sm-script-checkbox-lp' ).is( ':checked' )\n\t\t\t\t},\n\t\t\t\tplacement: this.$( '#tvd-sm-script-placement' ).val(),\n\t\t\t\tcode: this.$( '#tvd-sm-script-code' ).val(),\n\t\t\t\ticon: this.$( '#tvd-sm-script-icon' ).val()\n\t\t\t};\n\n\t\t\tif ( ! TVD_SM_CONST.is_ttb_active || ! TVD_SM_CONST.is_tar_active ) {\n\t\t\t\tnewScript.status = {\n\t\t\t\t\tttb: TVD_SM_CONST.is_ttb_active,\n\t\t\t\t\tlp: TVD_SM_CONST.is_ttb_active\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* validation checks */\n\t\t\tif ( ! this.validate( newScript ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t/* escape html from the label field */\n\t\t\tnewScript.label = $( '<div>' ).html( newScript.label ).text();\n\n\t\t\t/* if unrecognized, assign nonstandard icon */\n\t\t\tif ( ! newScript.icon ) {\n\t\t\t\tnewScript.icon = 'nonstandard';\n\t\t\t}\n\n\t\t\tif ( typeof this.collection !== 'undefined' ) {\n\t\t\t\tthis.addScript( newScript );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.editScript( newScript );\n\t\t\t}\n\t\t},\n\n\t\taddScript: function ( newScript ) {\n\t\t\tvar self = this,\n\t\t\t\tcurrentCollection = this.collection.where( {placement: newScript.placement} );\n\n\t\t\t/* set the order to be the order of the last element + 1 */\n\t\t\tnewScript.order = currentCollection.length > 0 ? currentCollection[ currentCollection.length - 1 ].get( 'order' ) + 1 : 0;\n\n\t\t\t/* adds the new model to the collection. This triggers the add event inside ScriptGroup which re-renders the view  */\n\t\t\tthis.collection.create( newScript, {\n\t\t\t\tsuccess: function () {\n\t\t\t\t\tself.close();\n\t\t\t\t},\n\t\t\t\terror: function () {\n\t\t\t\t\tTVE_Dash.err( TVD_SM_CONST.translations.add_error );\n\t\t\t\t},\n\t\t\t\tflag: 'noChange'\n\t\t\t} );\n\t\t},\n\t\teditScript: function ( newScript ) {\n\t\t\tvar self = this,\n\t\t\t\tcurrentCollection = scriptsCollection.where( {placement: newScript.placement} );\n\n\t\t\t/* if new placement != old placement */\n\t\t\tif ( this.model.get( 'placement' ) !== newScript.placement ) {\n\t\t\t\tnewScript.order = currentCollection.length > 0 ? currentCollection[ currentCollection.length - 1 ].get( 'order' ) + 1 : 0;\n\t\t\t}\n\n\t\t\t/* saves the new model, overwriting the old one. Triggers the change event inside ScriptGroup.*/\n\t\t\tthis.model.save( newScript, {\n\t\t\t\tsuccess: function () {\n\t\t\t\t\tself.close();\n\t\t\t\t},\n\t\t\t\terror: function () {\n\t\t\t\t\tTVE_Dash.err( TVD_SM_CONST.translations.edit_error );\n\t\t\t\t}\n\t\t\t} );\n\t\t},\n\n\t\t/* validates the input fields */\n\t\tvalidate: function ( newScript ) {\n\t\t\tvar code = newScript.code,\n\t\t\t\tlabel = newScript.label,\n\t\t\t\tplacement = newScript.placement;\n\n\t\t\t/* check if the inputs are empty */\n\t\t\tif ( ! code ) {\n\t\t\t\tthis.$( '#tvd-sm-code-empty' ).show();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.$( '#tvd-sm-code-empty' ).hide();\n\n\t\t\tif ( ! label ) {\n\t\t\t\tthis.$( '#tvd-sm-label-empty' ).show();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.$( '#tvd-sm-label-empty' ).hide();\n\n\t\t\tif ( ! placement ) {\n\t\t\t\tthis.$( '#tvd-sm-placement-empty' ).show();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.$( '#tvd-sm-placement-empty' ).hide();\n\n\t\t\t/* check if the provided script properly closes any <script>, <noscript>, <iframe> tags */\n\t\t\tif ( ! this.checkTags( code ) ) {\n\t\t\t\tthis.$( '#tvd-sm-code-invalid' ).show();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.$( '#tvd-sm-code-invalid' ).hide();\n\t\t\treturn true;\n\t\t},\n\n\t\tcheckTags: function ( code ) {\n\t\t\t/* number of opened tags of a type has to be equal to the number of closed tags */\n\t\t\tif ( typeof _.find( [ 'script', 'noscript', 'iframe' ], function ( elem ) {\n\t\t\t\treturn code.split( '<' + elem ).length !== code.split( '</' + elem + '>' ).length\n\t\t\t} ) === 'undefined' ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\n\t\trecognizeScript: function () {\n\t\t\tvar code = this.$( '#tvd-sm-script-code' ).val(),\n\t\t\t\tsearchKey =\n\t\t\t\t\t/* for every key */\n\t\t\t\t\t_.findKey( TVD_SM_CONST.recognized_scripts.keywords, function ( keywords ) {\n\t\t\t\t\t\t/* for every keyword */\n\t\t\t\t\t\treturn _.find( keywords, function ( keyword ) {\n\t\t\t\t\t\t\treturn code.indexOf( keyword ) !== - 1;\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\n\t\t\t/* if we found a matching keyword */\n\t\t\tif ( typeof searchKey !== 'undefined' ) {\n\t\t\t\tvar data = TVD_SM_CONST.recognized_scripts.data[ searchKey ];\n\t\t\t\tthis.$( '#tvd-sm-script-name' ).val( searchKey );\n\t\t\t\tthis.$( '#tvd-sm-script-placement' ).val( data.placement ).change();\n\t\t\t\t/* the icon name is hidden */\n\t\t\t\tthis.$( '#tvd-sm-script-icon' ).val( data.icon );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.$( '#tvd-sm-script-icon' ).val( 'nonstandard' );\n\t\t\t}\n\t\t},\n\t\t/* add class to the focused label inside the modal */\n\t\tfocusLabel: function ( event ) {\n\t\t\t$( event.target ).closest( '.tvd-sm-form-element' ).addClass( 'tvd-sm-focused-label' );\n\n\t\t\tif ( event.target.classList.contains( 'select2-selection' ) ) {\n\t\t\t\tthis.$( '#tvd-sm-script-placement' ).select2( 'open' )\n\t\t\t}\n\t\t},\n\t\t/* remove class from the unfocused label inside the modal */\n\t\tblurLabel: function ( event ) {\n\t\t\t$( event.target ).closest( '.tvd-sm-form-element' ).removeClass( 'tvd-sm-focused-label' );\n\t\t}\n\t} );\n\n\t/* Deletes a ScriptItem . */\n\tviews.DeleteScriptModal = TVE_Dash.views.Modal.extend( {\n\t\ttemplate: utils._t( 'modal-delete-script' ),\n\t\tevents: {\n\t\t\t'click .tvd-submit': 'delete'\n\t\t},\n\n\t\tdelete: function () {\n\t\t\tthis.model.destroy( {\n\t\t\t\terror: function () {\n\t\t\t\t\tTVE_Dash.err( TVD_SM_CONST.translations.delete_error );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tthis.close();\n\t\t}\n\t} );\n\n\t/* Deletes all page-level scripts. */\n\tviews.DeletePageLevelScriptsModal = TVE_Dash.views.Modal.extend( {\n\t\ttemplate: utils._t( 'modal-delete-page-level-scripts' ),\n\t\tevents: {\n\t\t\t'click .tvd-submit': 'delete'\n\t\t},\n\n\t\tdelete: function () {\n\t\t\t$.post( {\n\t\t\t\theaders: {\n\t\t\t\t\t'X-WP-Nonce': TVD_SM_CONST.nonce\n\t\t\t\t},\n\t\t\t\turl: TVD_SM_CONST.routes.clear_page_level_scripts,\n\t\t\t\tsuccess: function () {\n\t\t\t\t\tTVE_Dash.success( TVD_SM_CONST.translations.delete_page_level_success );\n\t\t\t\t},\n\t\t\t\terror: function () {\n\t\t\t\t\tTVE_Dash.err( TVD_SM_CONST.translations.delete_page_level_error );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tthis.close();\n\t\t}\n\t} );\n\n\tviews.Breadcrumbs = Backbone.View.extend( {\n\t\ttemplate: utils._t( 'breadcrumbs' ),\n\t\tinitialize: function () {\n\t\t\tthis.render();\n\t\t},\n\t\trender: function () {\n\t\t\tthis.$el.html( this.template() );\n\t\t\treturn this;\n\t\t}\n\t} );\n\n\tmodule.exports = views;\n\n} )( jQuery );\n//# sourceURL=thrive-dashboard/inc/script-manager/assets/js/admin/views.js");
							}
						},
						"utils.js": function (exports, module, require) {
							eval("(function ( $ ) {\n\n\tmodule.exports = {\n\t\t_t: function ( path ) {\n\t\t\tvar html = $( 'script#' + path ).html() || '';\n\t\t\treturn _.template( html );\n\t\t}\n\t}\n})( jQuery );\n//# sourceURL=thrive-dashboard/inc/script-manager/assets/js/utils.js");
						}
					}
				}
			}
		}
	}
})("thrive-dashboard/inc/script-manager/assets/js/admin/routes");
