Wrap existing JS modules in AMD module style
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
define('admin', [
|
||||
'./ajax',
|
||||
'notice.js',
|
||||
'modal.js',
|
||||
'lib/handlebars.min.js',
|
||||
'handlebars_helpers.js'
|
||||
], function() {
|
||||
jQuery(function($) {
|
||||
// dom ready
|
||||
$(function() {
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,8 +1,8 @@
|
||||
define('ajax', ['./mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
||||
"use strict";
|
||||
/**
|
||||
* MailPoet Ajax
|
||||
**/
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
MailPoet.Ajax = {
|
||||
version: 0.1,
|
||||
@@ -64,4 +64,4 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
})(window.MailPoet = window.MailPoet || {}, jQuery);
|
||||
});
|
||||
|
@@ -1,3 +1,4 @@
|
||||
define('handlebars_helpers', ['lib/handlebars.min.js'], function(Handlebars) {
|
||||
// Handlebars helpers
|
||||
Handlebars.registerHelper('concat', function() {
|
||||
var size = (arguments.length - 1),
|
||||
@@ -138,3 +139,4 @@ Handlebars.registerHelper('ellipsis', function (str, limit, append) {
|
||||
Handlebars.registerHelper('getNumber', function (string) {
|
||||
return parseInt(string, 10);
|
||||
});
|
||||
});
|
||||
|
9
assets/js/mailpoet.js
Normal file
9
assets/js/mailpoet.js
Normal file
@@ -0,0 +1,9 @@
|
||||
define('mailpoet', [], function() {
|
||||
// A placeholder for MailPoet object
|
||||
var MailPoet = {};
|
||||
|
||||
// Expose MailPoet globally
|
||||
window.MailPoet = MailPoet;
|
||||
|
||||
return MailPoet;
|
||||
});
|
@@ -1,3 +1,5 @@
|
||||
define('modal', ['./mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
||||
"use strict";
|
||||
/*==================================================================================================
|
||||
|
||||
MailPoet Modal:
|
||||
@@ -74,8 +76,6 @@
|
||||
MailPoet.Modal.loading(false); // hides loading indicator
|
||||
|
||||
==================================================================================================*/
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
MailPoet.Modal = {
|
||||
version: 0.8,
|
||||
@@ -636,4 +636,4 @@
|
||||
return this;
|
||||
}
|
||||
};
|
||||
})(window.MailPoet = window.MailPoet || {}, jQuery);
|
||||
});
|
||||
|
@@ -1,3 +1,5 @@
|
||||
define('notice', ['./mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
||||
"use strict";
|
||||
/*==================================================================================================
|
||||
|
||||
MailPoet Notice:
|
||||
@@ -37,8 +39,6 @@
|
||||
}, 500);
|
||||
|
||||
==================================================================================================*/
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
MailPoet.Notice = {
|
||||
version: 0.2,
|
||||
@@ -172,4 +172,4 @@
|
||||
}, options));
|
||||
}
|
||||
};
|
||||
})(window.MailPoet = window.MailPoet || {}, jQuery);
|
||||
});
|
||||
|
1166
assets/js/src/admin.js
Normal file
1166
assets/js/src/admin.js
Normal file
File diff suppressed because one or more lines are too long
@@ -23,11 +23,7 @@
|
||||
|
||||
<!-- javascripts -->
|
||||
<%= javascript(
|
||||
'ajax.js',
|
||||
'notice.js',
|
||||
'modal.js',
|
||||
'lib/handlebars.min.js',
|
||||
'handlebars_helpers.js'
|
||||
'src/admin.js'
|
||||
)%>
|
||||
|
||||
<!-- handlebars templates -->
|
||||
|
@@ -5,7 +5,7 @@ var path = require('path'),
|
||||
module.exports = {
|
||||
context: __dirname ,
|
||||
entry: {
|
||||
mailpoet: './assets/js/mailpoet',
|
||||
admin: './assets/js/admin.js',
|
||||
},
|
||||
output: {
|
||||
path: './assets/js/src',
|
||||
@@ -41,5 +41,8 @@ module.exports = {
|
||||
alias: {
|
||||
'hbs': 'handlebars-loader'
|
||||
}
|
||||
},
|
||||
externals: {
|
||||
'jquery': 'jQuery',
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user