Skip to content

Commit

Permalink
Merge branch 'master' into feature/modularize
Browse files Browse the repository at this point in the history
Conflicts:
	Gruntfile.js
	lib/aura.js
	lib/base.js
	lib/ext/mediator.js
  • Loading branch information
sbellity committed Jan 26, 2013
2 parents 64a3b3e + 95ddfe8 commit e267c25
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "docs"]
path = docs
url = git@github.com:tony/aura-docs.git
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = function(grunt) {

mocha: {
aura: {
options: {
options: {
urls: ['http://localhost:' + port + "/spec/index.html"]
}
}
Expand Down
1 change: 1 addition & 0 deletions docs
Submodule docs added at e34008
3 changes: 1 addition & 2 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
});
}


define(['module', 'underscore', 'jquery', './platform'], function(module, _, $) {
var console = window.console || {};

// Auto configure aura path... if not set yet...
if (!require.s.contexts._.config.paths.aura) {
require.config({ paths: { aura: module.uri.replace(/base.js$/, '') }});
}

var base = {};

// base.config = baseConfig;
Expand Down
5 changes: 3 additions & 2 deletions lib/ext/mediator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define('aura/ext/mediator', function() {

'use strict';

return {

name: 'mediator',
Expand All @@ -10,7 +10,8 @@ define('aura/ext/mediator', function() {

init: function(app) {
var EventEmitter = require('eventemitter');
var mediator = new EventEmitter();
var mediatorConfig = app.config.mediator || { wildcard: true, delimiter: ".", maxListeners: 20, newListener: true };
var mediator = new EventEmitter(mediatorConfig);
app.core.mediator = mediator;
app.sandbox.on = function() { mediator.on.apply(mediator, arguments); };
app.sandbox.off = function() { mediator.off.apply(mediator, arguments); };
Expand Down
18 changes: 13 additions & 5 deletions lib/ext/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ define('aura/ext/widgets', function() {
* @param {String|DomNode} el the element
* @return {Object} An object that contains the widget's options
*/
function parseWidgetOptions(el) {
function parseWidgetOptions(el, namespace) {
var options = { el: el, require: {} }, widgetName, widgetSource;
var data = core.dom.data(el);

// Here we go through all the data attributes of the element to build the options object
core.util.each(data, function(k,v) {
var key = core.util.decamelize(k).toLowerCase();
if (key !== 'aura_widget') {
var key = core.util.decamelize(k).toLowerCase().replace(new RegExp("^" + namespace +"_"), '');
if (key !== 'widget') {
options[key] = v;
} else {
var ref = v.split("@");
Expand Down Expand Up @@ -218,8 +218,16 @@ define('aura/ext/widgets', function() {
}
var list = [];
if (widgets && core.dom.find(widgets)) {
core.dom.find('[data-aura-widget]', widgets || 'body').each(function() {
var options = parseWidgetOptions(this), widgetName, widgetLocation;
var appNamespace = app.config.namespace;
var selector = ["[data-aura-widget]"];
if (appNamespace) { selector.push("[data-" + appNamespace + "-widget]"); }
selector = selector.join(",");
core.dom.find(selector, widgets || 'body').each(function() {
var ns = "aura";
if (appNamespace && this.getAttribute('data-' + appNamespace +'-widget')) {
ns = appNamespace;
}
var options = parseWidgetOptions(this, ns);
list.push({ name: options.name, options: options });
});
}
Expand Down
29 changes: 28 additions & 1 deletion spec/lib/ext/widgets_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,34 @@ define(['aura/aura', 'aura/ext/widgets'], function(aura, ext) {

});


describe("Using alternate namespace for data-attributes...", function() {

var app, options, myAltWidget = makeSpyWidget('alt_namespace', {
initialize: function() {
options = this.options;
}
});


before(function(done) {
app = aura({ namespace: 'super' });
var container = buildAppMarkup('<div data-super-widget="alt_namespace" data-super-genial="yep"></div>');
app.start({ widgets: container }).done(function() {
setTimeout(done, 0);
});
});

it("Data attributes with alternate namespace should be recognized", function() {
myAltWidget.should.have.been.called;
});

it("It should take the right options too...", function() {
options.genial.should.equal("yep");
});

});


describe("Creating new Widget Types", function() {

// A Very simple Widget type...
Expand Down

0 comments on commit e267c25

Please sign in to comment.