// 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": {
			"notification-inbox": {
				"assets": {
					"js": {
						"admin.js": function (exports, module, require) {
							eval("/**\n * Created by Dan Brinzaru on 4/9/2019.\n */\n\nTD_Inbox = TD_Inbox || {};\n\n( function ( $ ) {\n\n\tvar notificationsList = require( './views/notificationsList' ),\n\t\tnotification_counter = require( './views/notificationCounter' );\n\n\tvar notificationCollection = require( './collections/notifications' );\n\n\t$( function () {\n\t\tvar collection = new notificationCollection( TD_Inbox.data );\n\t\tvar view = new notificationsList( {\n\t\t\tel: $( '.tvd-inbox-holder' ),\n\t\t\tcollection: collection\n\t\t} );\n\n\t\tview.render();\n\n\t\tnew notification_counter( {\n\t\t\tel: $( '.ni-inbox-counter' ),\n\t\t\tcollection: collection\n\t\t} ).render();\n\n\t\tif ( $( '.tvd-ni-notifications' ).length && $( '.tvd-inbox-holder' ).length ) {\n\t\t\t$( document ).click( function ( event ) {\n\n\t\t\t\tif ( $( event.target ).is( '.tvd-ni-notifications, .ni-counter-holder' ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t/**\n\t\t\t\t * click outside the wrapper\n\t\t\t\t */\n\t\t\t\tif ( $( event.target ).closest( '.tvd-inbox-holder' ).length <= 0 ) {\n\t\t\t\t\t$( \"body\" ).find( \".tvd-inbox-holder\" ).hide();\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} )\n\n} )( jQuery );\n//# sourceURL=thrive-dashboard/inc/notification-inbox/assets/js/admin.js");
						},
						"collections": {
							"base.js": function (exports, module, require) {
								eval("/**\n * Created by Dan Brinzaru on 4/25/2019.\n */\n\nmodule.exports = Backbone.Collection.extend( {\n\t/**\n\t * helper function to get the last item of a collection\n\t *\n\t * @return Backbone.Model\n\t */\n\tlast: function () {\n\t\treturn this.at( this.size() - 1 );\n\t}\n} );\n//# sourceURL=thrive-dashboard/inc/notification-inbox/assets/js/collections/base.js");
							},
							"notifications.js": function (exports, module, require) {
								eval("/**\n * Created by Dan Brinzaru on 4/25/2019.\n */\n\nvar baseCollection = require( './base' );\n\nvar model = require( './../models/notification' );\n\nmodule.exports = baseCollection.extend( {\n\tmodel: model\n} );\n//# sourceURL=thrive-dashboard/inc/notification-inbox/assets/js/collections/notifications.js");
							}
						},
						"models": {
							"notification.js": function (exports, module, require) {
								eval("/**\n * Created by Dan Brinzaru on 4/9/2019.\n */\n\nmodule.exports = Backbone.Model.extend( {\n\n\tidAttribute: 'ID',\n\n\tdefaults: {\n\t\ttitle: '',\n\t\tread: 0\n\t},\n\n\tinitialize: function ( attrs ) {\n\t\tthis.set( 'read', attrs.read === 0 ? 'unread' : 'read' );\n\t},\n\n\tget_action: function () {\n\t\treturn 'notification';\n\t},\n\n\turl: function () {\n\n\t\tvar url = ajaxurl + ( this.get_action() + '&' + this.get_route() );\n\n\t\tif ( $.isNumeric( this.get( 'ID' ) ) ) {\n\t\t\turl += '&ID=' + this.get( 'ID' );\n\t\t}\n\n\t\treturn url;\n\t}\n} );\n//# sourceURL=thrive-dashboard/inc/notification-inbox/assets/js/models/notification.js");
							}
						},
						"views": {
							"base.js": function (exports, module, require) {
								eval("/**\n * Created by Dan Brinzaru on 4/25/2019.\n */\n\n( function ( $ ) {\n\tmodule.exports = Backbone.View.extend( {\n\t\trender: function () {\n\t\t\treturn this;\n\t\t}\n\t} )\n\n} )( jQuery );\n//# sourceURL=thrive-dashboard/inc/notification-inbox/assets/js/views/base.js");
							},
							"notification.js": function (exports, module, require) {
								eval("/**\n * Created by Dan Brinzaru on 4/9/2019.\n */\n\n( function ( $ ) {\n\n\tvar base = require( './base' );\n\n\tmodule.exports = base.extend( {\n\t\trender: function () {\n\t\t\tthis.$el.append( TVE_Dash.tpl( 'ni-notification' )( {model: this.model} ) );\n\n\t\t\treturn this;\n\t\t}\n\t} );\n\n} )( jQuery );\n//# sourceURL=thrive-dashboard/inc/notification-inbox/assets/js/views/notification.js");
							},
							"notificationCounter.js": function (exports, module, require) {
								eval("/**\n * Created by Dan Brinzaru on 4/25/2019.\n */\n\n( function ( $ ) {\n\n\tvar base = require( './base' );\n\n\tmodule.exports = base.extend( {\n\t\tevents: {\n\t\t\t'click .tvd-ni-notifications': 'open',\n\t\t\t'click .ni-counter-holder': 'open'\n\t\t},\n\t\tinitialize: function () {\n\n\t\t\tvar self = this;\n\t\t\tthis.listenTo( this.collection, 'change:read', self.render );\n\t\t\tthis.collection.on( 'bulk_update', function () {\n\t\t\t\tself.render();\n\t\t\t} );\n\t\t},\n\t\trender: function () {\n\t\t\tthis.$( '.ni-counter-holder' ).html( TD_Inbox.total_unread );\n\n\t\t\tif ( TD_Inbox.total_unread >= 1 ) {\n\t\t\t\tthis.$( '.ni-counter-holder' ).show();\n\t\t\t} else {\n\t\t\t\tthis.$( '.ni-counter-holder' ).hide();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\topen: function () {\n\t\t\t$( '.tvd-inbox-holder' ).toggle();\n\t\t}\n\t} );\n\n} )( jQuery );\n//# sourceURL=thrive-dashboard/inc/notification-inbox/assets/js/views/notificationCounter.js");
							},
							"notificationDetail.js": function (exports, module, require) {
								eval("/**\n * Created by Dan Brinzaru on 4/25/2019.\n */\n\n( function ( $ ) {\n\n\tvar base = require( './base' );\n\n\tmodule.exports = base.extend( {\n\t\trender: function () {\n\t\t\tthis.$el.html( TVE_Dash.tpl( 'ni-notification-detail' )( {model: this.model} ) );\n\n\t\t\t/**\n\t\t\t * Set read status only for unreaded notifications\n\t\t\t */\n\t\t\tif ( this.model.get( 'read' ) === 'unread' ) {\n\t\t\t\tthis.save();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tsave: function () {\n\t\t\tvar self = this;\n\t\t\t$.ajax( {\n\t\t\t\ttype: 'POST',\n\t\t\t\turl: TD_Inbox.ajaxurl,\n\t\t\t\tdata: {\n\t\t\t\t\t'action': 'thrv_notifications',\n\t\t\t\t\t'notification_id': self.model.get( 'id' ),\n\t\t\t\t\t'_nonce': TD_Inbox.admin_nonce,\n\t\t\t\t}\n\t\t\t} ).success( function ( response ) {\n\n\t\t\t\tvar response = JSON.parse( response );\n\t\t\t\tif ( typeof response.total_unread !== 'undefined' ) {\n\t\t\t\t\tTD_Inbox.total_unread = response.total_unread;\n\n\t\t\t\t\tif ( TD_Inbox.total_unread >= 1 ) {\n\t\t\t\t\t\tself.$( '.ni-counter-holder' ).show();\n\t\t\t\t\t}\n\t\t\t\t\tself.model.set( {read: \"read\"} );\n\t\t\t\t}\n\n\t\t\t} ).error( function ( response ) {\n\t\t\t\tTVE_Dash.err( response.responseJSON.error );\n\t\t\t} );\n\t\t}\n\t} );\n\n} )( jQuery );\n//# sourceURL=thrive-dashboard/inc/notification-inbox/assets/js/views/notificationDetail.js");
							},
							"notificationsList.js": function (exports, module, require) {
								eval("/**\n * Created by Dan Brinzaru on 4/9/2019.\n */\n\nvar baseView = require( './base' );\n\nvar notification_view = require( './notification' );\nvar notification_detail = require( './notificationDetail' );\nvar notificationModel = require( './../models/notification' );\n\n( function ( $ ) {\n\n\tvar headerView = baseView.extend( {\n\t\tevents: {\n\t\t\t'click .tvd-ni-mark-read': 'readAll'\n\t\t},\n\t\trender: function () {\n\t\t\tthis.$el.html(\n\t\t\t\tTVE_Dash.tpl( 'notification-header' )( {} )\n\t\t\t);\n\n\t\t\tif ( this.collection.where( {read: 'unread'} ).length === 0 ) {\n\t\t\t\tthis.$( '.tvd-ni-mark-read' ).addClass( 'tvd-ni-disabled' );\n\t\t\t}\n\n\t\t\tif ( this.collection.length == 0 ) {\n\t\t\t\tthis.$( '.tvd-ni-mark-read' ).empty();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\t/**\n\t\t * Bulk read\n\t\t */\n\t\treadAll: function ( event ) {\n\n\t\t\tthis.collection.each( function ( model ) {\n\t\t\t\tmodel.set( {read: \"read\"}, {silent: true} );\n\t\t\t} );\n\n\t\t\tthis.saveData();\n\n\t\t\tthis.collection.trigger( 'render' );\n\t\t\tthis.render();\n\n\t\t\tevent.stopPropagation();\n\t\t},\n\t\tsaveData: function () {\n\t\t\tvar self = this;\n\t\t\t$.ajax( {\n\t\t\t\ttype: 'POST',\n\t\t\t\turl: TD_Inbox.ajaxurl,\n\t\t\t\tdata: {\n\t\t\t\t\t'action': 'thrv_bulkread',\n\t\t\t\t\t'_nonce': TD_Inbox.admin_nonce,\n\t\t\t\t}\n\t\t\t} ).success( function ( response ) {\n\t\t\t\tvar response = JSON.parse( response );\n\t\t\t\tif ( typeof response.total_unread !== 'undefined' ) {\n\t\t\t\t\tTD_Inbox.total_unread = response.total_unread;\n\t\t\t\t\tself.collection.trigger( 'bulk_update' );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\n\tmodule.exports = baseView.extend( {\n\n\t\theaderView: null,\n\n\t\tevents: {\n\t\t\t'click .td-inbox-item': 'renderNotification',\n\t\t\t'click .ni-go-back': 'render',\n\t\t\t'click .tvd-ni-close': 'close',\n\t\t\t'click .tvd-ni-load-inner': 'loadMore'\n\t\t},\n\t\tinitialize: function () {\n\t\t\tvar self = this;\n\t\t\tthis.collection.on( 'render', function () {\n\t\t\t\tself.render();\n\t\t\t} );\n\t\t},\n\t\trender: function ( event ) {\n\t\t\tthis.$( '.tvd-notification-wrapper' ).html(\n\t\t\t\t'<div class=\"tvd-notifications-list\"></div><div class=\"tvd-load-more\"></div>'\n\t\t\t);\n\n\t\t\tif ( this.headerView ) {\n\t\t\t\tthis.headerView.undelegateEvents();\n\t\t\t}\n\t\t\tthis.headerView = new headerView( {\n\t\t\t\tel: this.$( '.tvd-notification-header' ),\n\t\t\t\tcollection: this.collection\n\t\t\t} ).render();\n\n\t\t\tthis.renderList();\n\n\t\t\tif ( this.collection.length === 0 ) {\n\t\t\t\tthis.$( '.tvd-load-more' ).append( '<span class=\"tvd-ni-no-data\">' + TD_Inbox.t.no_data + '</span>' );\n\t\t\t} else {\n\t\t\t\tif ( this.collection.length < parseInt( TD_Inbox.total ) ) {\n\t\t\t\t\tthis.$( '.tvd-load-more' ).html( '<span class=\"tvd-ni-load\"><span class=\"tvd-ni-load-inner\">' + TD_Inbox.t.more_10 + '</span></span>' );\n\t\t\t\t} else {\n\t\t\t\t\tthis.$( '.tvd-load-more' ).html( '<span class=\"tvd-ni-no-more-data\">' + TD_Inbox.t.no_more_data + '</span>' );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( event && event.target ) {\n\t\t\t\tevent.stopPropagation();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\trenderList: function () {\n\t\t\tthis.$( '.tvd-notifications-list' ).empty();\n\n\t\t\tthis.collection.each( function ( model ) {\n\t\t\t\tnew notification_view( {\n\t\t\t\t\t\tmodel: model,\n\t\t\t\t\t\tel: this.$( '.tvd-notifications-list' )\n\t\t\t\t\t}\n\t\t\t\t).render();\n\t\t\t}, this );\n\t\t},\n\t\trenderNotification: function ( e ) {\n\t\t\tvar id = e.currentTarget.dataset.id,\n\t\t\t\tmodel = this.collection.findWhere( {'id': id} );\n\n\t\t\tnew notification_detail( {\n\t\t\t\tmodel: model,\n\t\t\t\tel: this.$( '.tvd-notification-wrapper' )\n\t\t\t} ).render();\n\n\t\t\tthis.$( '.tvd-notification-header' ).empty();\n\n\t\t\te.stopPropagation();\n\t\t},\n\t\tclose: function () {\n\t\t\tthis.$el.toggle();\n\t\t},\n\t\tloadMore: function ( e ) {\n\n\t\t\tthis.doAjaxCall( 'thrv_load_more', {\n\t\t\t\tlimit: TD_Inbox.limit,\n\t\t\t\toffset: TD_Inbox.offset\n\t\t\t} );\n\n\t\t\tif ( this.collection.length >= parseInt( TD_Inbox.total ) ) {\n\t\t\t\tthis.$( '.tvd-load-more' ).empty();\n\t\t\t\tthis.$( '.tvd-load-more' ).html( '<span class=\"tvd-ni-no-more-data\">' + TD_Inbox.t.no_more_data + '</span>' );\n\t\t\t}\n\n\t\t\te.stopPropagation();\n\t\t},\n\t\tdoAjaxCall: function ( action, data ) {\n\n\t\t\tvar self = this;\n\t\t\tvar $loadMoreText = this.$( '.tvd-ni-load-inner' );\n\t\t\tvar loadMoreText = $loadMoreText.text();\n\n\t\t\t$loadMoreText.text( 'Loading...' );\n\n\t\t\t$.ajax( {\n\t\t\t\ttype: 'POST',\n\t\t\t\turl: TD_Inbox.ajaxurl,\n\t\t\t\tdata: _.extend( {\n\t\t\t\t\t'action': action,\n\t\t\t\t\t'_nonce': TD_Inbox.admin_nonce\n\t\t\t\t}, data )\n\t\t\t} ).success( function ( response ) {\n\t\t\t\tTD_Inbox.offset = parseInt( TD_Inbox.limit ) + parseInt( TD_Inbox.offset );\n\n\t\t\t\t_.each( response, function ( item ) {\n\t\t\t\t\tself.collection.add( new notificationModel( item ) );\n\t\t\t\t} );\n\n\t\t\t\tif ( self.collection.length === parseInt( TD_Inbox.total ) ) {\n\t\t\t\t\tself.$( '.tvd-load-more' ).html( '<span class=\"tvd-ni-no-more-data\">' + TD_Inbox.t.no_more_data + '</span>' );\n\t\t\t\t}\n\t\t\t\tself.renderList();\n\t\t\t} ).always( function () {\n\t\t\t\tif ( $loadMoreText.length ) {\n\t\t\t\t\t$loadMoreText.text( loadMoreText );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n} )( jQuery );\n//# sourceURL=thrive-dashboard/inc/notification-inbox/assets/js/views/notificationsList.js");
							}
						}
					}
				}
			}
		}
	}
})("thrive-dashboard/inc/notification-inbox/assets/js/admin");
