Testing ES6

This commit is contained in:
dominiclord
2015-12-07 16:50:04 -05:00
parent 822dd4c8b6
commit 581da4d658
10 changed files with 96 additions and 104 deletions

3
.babelrc Normal file
View File

@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}

View File

@@ -33,6 +33,7 @@ module.exports = function(grunt) {
'sass',
'svgstore',
'postcss',
'babel',
'uglify',
'cssmin',
'svgmin',

11
grunt_tasks/babel.js Normal file
View File

@@ -0,0 +1,11 @@
module.exports = {
options: {
sourceMap: true,
presets: ['es2015']
},
dist: {
files: {
'www/modules/boilerplate/assets/scripts/dist/app.js': 'www/modules/boilerplate/assets/scripts/dist/app.js'
}
}
};

View File

@@ -1,7 +1,7 @@
module.exports = {
javascript: {
files: ['www/modules/boilerplate/assets/scripts/src/**/*.js'],
tasks: ['concat', 'notify:concat']
tasks: ['concat', 'babel', 'notify:concat']
},
sass: {
files: ['www/modules/boilerplate/assets/styles/src/**/*.scss'],

View File

@@ -4,8 +4,10 @@
"author": "Locomotive <info@locomotive.ca>",
"devDependencies": {
"autoprefixer": "0.0.0",
"babel-preset-es2015": "^6.3.13",
"glob": "0.0.0",
"grunt": "0.0.0",
"grunt-babel": "^6.0.0",
"grunt-browser-sync": "0.0.0",
"grunt-contrib-concat": "0.0.0",
"grunt-contrib-cssmin": "0.0.0",

View File

@@ -1,18 +1,17 @@
'use strict';
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
/* jshint esnext: true */
// ==========================================================================
// Globals
// ==========================================================================
var app = window.app || {};
app.globals = {
init : function() {
// Global modules
// ==========================================================================
// app.parallax.init();
}
app.globals = function () {
// Global app modules
// ==========================================================================
// this.parallax.init();
};
// ==========================================================================
@@ -23,9 +22,7 @@ app.templates = app.templates || {};
app.templates.generic = {
init : function() {
}
init: function init() {}
};
@@ -37,79 +34,70 @@ app.widgets = app.widgets || {};
app.widgets.generic = {
init : function() {
}
init: function init() {}
};
/* jshint esnext: true */
// ==========================================================================
// App
// ==========================================================================
var app = window.app || {};
app.init = function() {
'use strict';
var self = this;
self.params = {
app.init = function () {
this.elements = {
html: document.documentElement,
body: document.body
};
self.elements = {
html : document.documentElement,
body : document.body
this.params = {
current_modules: [],
current_template: this.elements.html.getAttribute('data-template'),
current_widgets: []
};
self.templates = self.templates || {};
self.widgets = self.widgets || {};
this.templates = this.templates || {};
this.widgets = this.widgets || {};
// Globals
// ==========================================================================
if (typeof self.globals === 'object') {
self.globals.init();
if (typeof this.globals === 'function') {
this.globals();
}
// Modules
// ==========================================================================
self.params.current_modules = [];
var modules = document.querySelectorAll('[data-app]');
for (var m = 0; m < modules.length; m++) {
var dataApp = modules[m].getAttribute('data-app');
if (typeof self[dataApp] === 'object' && self.params.current_modules.indexOf(dataApp) === -1) {
self[dataApp].init();
self.params.current_modules.push(dataApp);
}
}
for (var i = 0, len = modules.length; i < len; i++) {
var ident = modules[i].getAttribute('data-app');
if (_typeof(this[ident]) === 'object' && this.params.current_modules.indexOf(ident) === -1) {
this[ident].init();
this.params.current_modules.push(ident);
}
}
// Template
// ==========================================================================
self.params.current_template = self.elements.body.getAttribute('data-template');
if (typeof self.templates[ self.params.current_template ] === 'object') {
self.templates[ self.params.current_template ].init();
if (_typeof(this.templates[this.params.current_template]) === 'object') {
this.templates[this.params.current_template].init();
}
// Widgets
// ==========================================================================
self.params.current_widgets = [];
var widgets = document.querySelectorAll('[data-widget]');
for (var w = 0; w < widgets.length; w++) {
var dataWidget = widgets[w].getAttribute('data-widget');
if (typeof self.widgets[dataWidget] === 'object' && self.params.current_widgets.indexOf(dataWidget) === -1) {
self.widgets[dataWidget].init();
self.params.current_widgets.push(dataWidget);
}
}
for (var i = 0, len = widgets.length; i < len; i++) {
var ident = widgets[i].getAttribute('data-widget');
if (_typeof(this.widgets[ident]) === 'object' && this.params.current_widgets.indexOf(ident) === -1) {
this.widgets[ident].init();
this.params.current_widgets.push(ident);
}
}
};
// Init
// ==========================================================================
$(function() {
$(function () {
app.init();
});
//# sourceMappingURL=app.js.map

View File

@@ -1,66 +1,58 @@
/* jshint esnext: true */
// ==========================================================================
// App
// ==========================================================================
var app = window.app || {};
app.init = function() {
'use strict';
var self = this;
self.params = {
app.init = function () {
this.elements = {
html: document.documentElement,
body: document.body
};
self.elements = {
html : document.documentElement,
body : document.body
this.params = {
current_modules: [],
current_template: this.elements.html.getAttribute('data-template'),
current_widgets: []
};
self.templates = self.templates || {};
self.widgets = self.widgets || {};
this.templates = this.templates || {};
this.widgets = this.widgets || {};
// Globals
// ==========================================================================
if (typeof self.globals === 'object') {
self.globals.init();
if (typeof this.globals === 'function') {
this.globals();
}
// Modules
// ==========================================================================
self.params.current_modules = [];
var modules = document.querySelectorAll('[data-app]');
for (var m = 0; m < modules.length; m++) {
var dataApp = modules[m].getAttribute('data-app');
if (typeof self[dataApp] === 'object' && self.params.current_modules.indexOf(dataApp) === -1) {
self[dataApp].init();
self.params.current_modules.push(dataApp);
}
}
for (let i = 0, len = modules.length; i < len; i++) {
let ident = modules[i].getAttribute('data-app');
if (typeof this[ident] === 'object' && this.params.current_modules.indexOf(ident) === -1) {
this[ident].init();
this.params.current_modules.push(ident);
}
}
// Template
// ==========================================================================
self.params.current_template = self.elements.body.getAttribute('data-template');
if (typeof self.templates[ self.params.current_template ] === 'object') {
self.templates[ self.params.current_template ].init();
if (typeof this.templates[this.params.current_template] === 'object') {
this.templates[this.params.current_template].init();
}
// Widgets
// ==========================================================================
self.params.current_widgets = [];
var widgets = document.querySelectorAll('[data-widget]');
for (var w = 0; w < widgets.length; w++) {
var dataWidget = widgets[w].getAttribute('data-widget');
if (typeof self.widgets[dataWidget] === 'object' && self.params.current_widgets.indexOf(dataWidget) === -1) {
self.widgets[dataWidget].init();
self.params.current_widgets.push(dataWidget);
}
}
for (let i = 0, len = widgets.length; i < len; i++) {
let ident = widgets[i].getAttribute('data-widget');
if (typeof this.widgets[ident] === 'object' && this.params.current_widgets.indexOf(ident) === -1) {
this.widgets[ident].init();
this.params.current_widgets.push(ident);
}
}
};
// Init

View File

@@ -1,16 +1,11 @@
/* jshint esnext: true */
// ==========================================================================
// Globals
// ==========================================================================
var app = window.app || {};
app.globals = {
init : function() {
// Global modules
// ==========================================================================
// app.parallax.init();
}
app.globals = function() {
// Global app modules
// ==========================================================================
// this.parallax.init();
};

View File

@@ -6,7 +6,7 @@ app.templates = app.templates || {};
app.templates.generic = {
init : function() {
init: function() {
}

View File

@@ -6,7 +6,7 @@ app.widgets = app.widgets || {};
app.widgets.generic = {
init : function() {
init: function() {
}