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($) {
|
jQuery(function($) {
|
||||||
// dom ready
|
// dom ready
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
|
define('ajax', ['./mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
||||||
|
"use strict";
|
||||||
/**
|
/**
|
||||||
* MailPoet Ajax
|
* MailPoet Ajax
|
||||||
**/
|
**/
|
||||||
(function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
MailPoet.Ajax = {
|
MailPoet.Ajax = {
|
||||||
version: 0.1,
|
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 helpers
|
||||||
Handlebars.registerHelper('concat', function() {
|
Handlebars.registerHelper('concat', function() {
|
||||||
var size = (arguments.length - 1),
|
var size = (arguments.length - 1),
|
||||||
@@ -138,3 +139,4 @@ Handlebars.registerHelper('ellipsis', function (str, limit, append) {
|
|||||||
Handlebars.registerHelper('getNumber', function (string) {
|
Handlebars.registerHelper('getNumber', function (string) {
|
||||||
return parseInt(string, 10);
|
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:
|
MailPoet Modal:
|
||||||
@@ -74,8 +76,6 @@
|
|||||||
MailPoet.Modal.loading(false); // hides loading indicator
|
MailPoet.Modal.loading(false); // hides loading indicator
|
||||||
|
|
||||||
==================================================================================================*/
|
==================================================================================================*/
|
||||||
(function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
MailPoet.Modal = {
|
MailPoet.Modal = {
|
||||||
version: 0.8,
|
version: 0.8,
|
||||||
@@ -636,4 +636,4 @@
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(window.MailPoet = window.MailPoet || {}, jQuery);
|
});
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
define('notice', ['./mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
||||||
|
"use strict";
|
||||||
/*==================================================================================================
|
/*==================================================================================================
|
||||||
|
|
||||||
MailPoet Notice:
|
MailPoet Notice:
|
||||||
@@ -37,8 +39,6 @@
|
|||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
==================================================================================================*/
|
==================================================================================================*/
|
||||||
(function(){
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
MailPoet.Notice = {
|
MailPoet.Notice = {
|
||||||
version: 0.2,
|
version: 0.2,
|
||||||
@@ -172,4 +172,4 @@
|
|||||||
}, options));
|
}, 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 -->
|
<!-- javascripts -->
|
||||||
<%= javascript(
|
<%= javascript(
|
||||||
'ajax.js',
|
'src/admin.js'
|
||||||
'notice.js',
|
|
||||||
'modal.js',
|
|
||||||
'lib/handlebars.min.js',
|
|
||||||
'handlebars_helpers.js'
|
|
||||||
)%>
|
)%>
|
||||||
|
|
||||||
<!-- handlebars templates -->
|
<!-- handlebars templates -->
|
||||||
|
@@ -5,7 +5,7 @@ var path = require('path'),
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
context: __dirname ,
|
context: __dirname ,
|
||||||
entry: {
|
entry: {
|
||||||
mailpoet: './assets/js/mailpoet',
|
admin: './assets/js/admin.js',
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: './assets/js/src',
|
path: './assets/js/src',
|
||||||
@@ -41,5 +41,8 @@ module.exports = {
|
|||||||
alias: {
|
alias: {
|
||||||
'hbs': 'handlebars-loader'
|
'hbs': 'handlebars-loader'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
externals: {
|
||||||
|
'jquery': 'jQuery',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user