Skip to content

Commit

Permalink
Merge pull request tastejs#212 from petermichaux/master
Browse files Browse the repository at this point in the history
update to maria.js release candidate 1
  • Loading branch information
addyosmani committed Jul 7, 2012
2 parents 8f374e8 + 9448fd8 commit 1718843
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
25 changes: 18 additions & 7 deletions labs/architecture-examples/maria/lib/maria/maria.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion labs/architecture-examples/maria/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 4 additions & 5 deletions labs/architecture-examples/maria/src/js/views/TodosAppView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 1718843

Please sign in to comment.