Skip to content
Browse files

Merge branch 'master' into feature/modularize

Conflicts:
	Gruntfile.js
	lib/aura.js
	lib/base.js
	lib/ext/mediator.js
  • Loading branch information...
2 parents 64a3b3e + 95ddfe8 commit e267c254fc14b02620feea05a7fcbb5c1a9627c0 @sbellity committed
Showing with 50 additions and 11 deletions.
  1. +3 −0 .gitmodules
  2. +1 −1 Gruntfile.js
  3. +1 −0 docs
  4. +1 −2 lib/base.js
  5. +3 −2 lib/ext/mediator.js
  6. +13 −5 lib/ext/widgets.js
  7. +28 −1 spec/lib/ext/widgets_spec.js
View
3 .gitmodules
@@ -0,0 +1,3 @@
+[submodule "docs"]
+ path = docs
+ url = git@github.com:tony/aura-docs.git
View
2 Gruntfile.js
@@ -86,7 +86,7 @@ module.exports = function(grunt) {
mocha: {
aura: {
- options: {
+ options: {
urls: ['http://localhost:' + port + "/spec/index.html"]
}
}
1 docs
@@ -0,0 +1 @@
+Subproject commit e340080e3b46e2ac48e65bb9bb9e85b5d82c8360
View
3 lib/base.js
@@ -22,7 +22,6 @@
});
}
-
define(['module', 'underscore', 'jquery', './platform'], function(module, _, $) {
var console = window.console || {};
@@ -30,7 +29,7 @@
if (!require.s.contexts._.config.paths.aura) {
require.config({ paths: { aura: module.uri.replace(/base.js$/, '') }});
}
-
+
var base = {};
// base.config = baseConfig;
View
5 lib/ext/mediator.js
@@ -1,7 +1,7 @@
define('aura/ext/mediator', function() {
'use strict';
-
+
return {
name: 'mediator',
@@ -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); };
View
18 lib/ext/widgets.js
@@ -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("@");
@@ -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 });
});
}
View
29 spec/lib/ext/widgets_spec.js
@@ -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...

0 comments on commit e267c25

Please sign in to comment.
Something went wrong with that request. Please try again.