Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #212 from petermichaux/master

update to maria.js release candidate 1
  • Loading branch information...
commit 17188438e22b7073fd8a5b4b406a19d0669c70c4 2 parents 8f374e8 + 9448fd8
@addyosmani addyosmani authored
View
25 labs/architecture-examples/maria/lib/maria/maria.js
@@ -1656,7 +1656,7 @@ hormigas.ObjectSet.mixin = function(obj) {
hormigas.ObjectSet.call(obj);
};
/*
-Maria version 0 - an MVC framework for JavaScript applications
+Maria release candidate 1 - an MVC framework for JavaScript applications
Copyright (c) 2012, Peter Michaux
All rights reserved.
Licensed under the Simplified BSD License.
@@ -2215,14 +2215,16 @@ will automatically call your "initialize" method.
*/
maria.View = function(model, controller) {
maria.Node.call(this);
+ this.initialize();
this.setModel(model);
this.setController(controller);
- this.initialize();
};
maria.Node.mixin(maria.View.prototype);
-maria.View.prototype.initialize = function() {};
+maria.View.prototype.initialize = function() {
+ // to be overridden by concrete view subclasses
+};
maria.View.prototype.destroy = function() {
maria.purgeEventListener(this);
@@ -2472,15 +2474,23 @@ the same.
*/
maria.ElementView = function(model, controller, doc) {
- this._doc = doc || document;
maria.View.call(this, model, controller);
+ this.setDocument(doc);
};
maria.ElementView.prototype = new maria.View();
maria.ElementView.prototype.constructor = maria.ElementView;
maria.ElementView.prototype.getDocument = function() {
- return this._doc;
+ return this._doc || document;
+};
+
+maria.ElementView.prototype.setDocument = function(doc) {
+ this._doc = doc;
+ var childViews = this.childNodes;
+ for (var i = 0, ilen = childViews.length; i < ilen; i++) {
+ childViews[i].setDocument(doc);
+ }
};
maria.ElementView.prototype.getTemplate = function() {
@@ -2503,7 +2513,7 @@ maria.ElementView.prototype.build = function() {
maria.ElementView.prototype.buildTemplate = function() {
// parseHTML returns a DocumentFragment so take firstChild as the rootEl
- this._rootEl = maria.parseHTML(this.getTemplate(), this._doc).firstChild;
+ this._rootEl = maria.parseHTML(this.getTemplate(), this.getDocument()).firstChild;
};
(function() {
@@ -3052,7 +3062,8 @@ maria.ElementView.subclass = function(namespace, name, options) {
for (var key in uiActions) {
if (Object.prototype.hasOwnProperty.call(uiActions, key)) {
var methodName = uiActions[key];
- if (!Object.prototype.hasOwnProperty.call(properties, methodName)) {
+ if ((!Object.prototype.hasOwnProperty.call(properties, methodName)) &&
+ (!(methodName in this.prototype))) {
(function(methodName) {
properties[methodName] = function(evt) {
this.getController()[methodName](evt);
View
1  labs/architecture-examples/maria/src/index.html
@@ -16,7 +16,6 @@
</script>
<script src="../lib/maria/maria.js"></script>
-
<script src="../lib/aristocrat/aristocrat.js"></script>
<script src="js/namespace.js"></script>
View
9 labs/architecture-examples/maria/src/js/views/TodosAppView.js
@@ -7,11 +7,10 @@ maria.ElementView.subclass(checkit, 'TodosAppView', {
return this.find('.content'); // child views will be appended to this element
},
initialize: function() {
- var model = this.getModel();
- this.appendChild(new checkit.TodosInputView(model));
- this.appendChild(new checkit.TodosToolbarView(model));
- this.appendChild(new checkit.TodosListView(model));
- this.appendChild(new checkit.TodosStatsView(model));
+ this.appendChild(new checkit.TodosInputView());
+ this.appendChild(new checkit.TodosToolbarView());
+ this.appendChild(new checkit.TodosListView());
+ this.appendChild(new checkit.TodosStatsView());
},
insertBefore: function(newChild, oldChild) {
newChild.setModel(this.getModel());
Please sign in to comment.
Something went wrong with that request. Please try again.