Skip to content

Commit

Permalink
V1.0.6 (#26)
Browse files Browse the repository at this point in the history
* Update dist versions

* 1.0.6
  • Loading branch information
jansav committed Nov 11, 2016
1 parent 8b15d9c commit 6f4c418
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppr-js",
"version": "1.0.5",
"version": "1.0.6",
"authors": [
"Janne Savolainen"
],
Expand Down
72 changes: 58 additions & 14 deletions dist/ppr.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,38 +89,38 @@
// AMD
// istanbul ignore next
if (typeof define === 'function' && define.amd) {
define('ppr.library.event_bus_prototype', ['jquery', 'lodash'], factory);
define('ppr.library.event_bus_prototype', [
'ppr.config',
'jquery',
'lodash'
], factory);
}

// Node, CommonJS
else if (typeof exports === 'object') {
module.exports = factory(
require('../ppr.config'),
require('jquery'),
require('lodash'));
}

// Browser globals
// istanbul ignore next
else {
root.ppr.library.event_bus_prototype = factory(root.vendor.$, root.vendor._);
root.ppr.library.event_bus_prototype = factory(root.ppr.config, root.vendor.$, root.vendor._);
}
})(this, function($, _) {
})(this, function(Config, $, _) {

'use strict';

/**
* EventBus constructor
* @constructor
* @param {Object} configs list of configurations
*/
var EventBus = function(configs) {
var EventBus = function() {

this.eventList = {};
this.messageIndex = {};

this.configList = $.extend({}, {
debug: false
}, configs);
};

EventBus.prototype = {
Expand Down Expand Up @@ -153,7 +153,7 @@
log: function(action, message, data) {

// Logging is disabled
if (this.configList.debug !== true) {
if (Config.get('event_bus.debug', false) !== true) {
return false;
}

Expand Down Expand Up @@ -678,6 +678,31 @@
}

return result;
},

/**
* Legacy browser compatible replacement for Object.assign
* From: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
*/
assign: function(target) {
// We must check against these specific cases.
if (target === undefined || target === null) {
throw new TypeError('Cannot convert undefined or null to object');
}

var output = Object(target);
for (var index = 1; index < arguments.length; index++) {
var source = arguments[index];
if (source !== undefined && source !== null) {
for (var nextKey in source) {
if (source.hasOwnProperty(nextKey)) {
output[nextKey] = source[nextKey];
}
}
}
}

return output;
}
};
});
Expand Down Expand Up @@ -1283,6 +1308,13 @@
cacheData: {},
cacheSubscribers: [],

/**
* Create and return a new component based on this one
*/
createComponent: function(obj) {
return ObjectUtils.assign({}, this, obj);
},

/**
* Function to be called when build is finished
*/
Expand Down Expand Up @@ -1458,7 +1490,7 @@

'use strict';

return $.extend(true, {}, BasePrototype, {
return BasePrototype.createComponent({

componentLoaderWrapper: null,

Expand Down Expand Up @@ -1645,14 +1677,21 @@

return {

eventBus: new EventBusPrototype(Config.get('event_bus', {})),
eventBus: new EventBusPrototype(),
name: null,
node: null,
components: {},
data: null,

cacheComponentReady: [],

/**
* Create and return a new page based on this one
*/
createPage: function(obj) {
return ObjectUtils.assign({}, this, obj);
},

/**
* Function to be triggered when build is done
*/
Expand Down Expand Up @@ -1730,8 +1769,13 @@

UniversalLoader.load(namespace, loaderParams, function(ComponentPrototype) {

// No component instance found
if (typeof ComponentPrototype === 'undefined') {
return false;
}

// Instantiate prototype
var instance = new function() { return $.extend(true, {}, ComponentPrototype); };
var instance = ComponentPrototype.createComponent({});

// Remember instance
_this.components[params.id] = instance;
Expand Down Expand Up @@ -2031,7 +2075,7 @@
UniversalLoader.load(namespace, loaderParams, function(PagePrototype) {

// Instantiate prototype
var instance = new function() { return $.extend(true, {}, PagePrototype); };
var instance = PagePrototype.createPage({});

instance.initialize(params);

Expand Down

0 comments on commit 6f4c418

Please sign in to comment.