Commit 17188438 authored by Addy Osmani's avatar Addy Osmani

Merge pull request #212 from petermichaux/master

update to maria.js release candidate 1
parents 8f374e8d 9448fd8f
...@@ -1656,7 +1656,7 @@ hormigas.ObjectSet.mixin = function(obj) { ...@@ -1656,7 +1656,7 @@ hormigas.ObjectSet.mixin = function(obj) {
hormigas.ObjectSet.call(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 Copyright (c) 2012, Peter Michaux
All rights reserved. All rights reserved.
Licensed under the Simplified BSD License. Licensed under the Simplified BSD License.
...@@ -2215,14 +2215,16 @@ will automatically call your "initialize" method. ...@@ -2215,14 +2215,16 @@ will automatically call your "initialize" method.
*/ */
maria.View = function(model, controller) { maria.View = function(model, controller) {
maria.Node.call(this); maria.Node.call(this);
this.initialize();
this.setModel(model); this.setModel(model);
this.setController(controller); this.setController(controller);
this.initialize();
}; };
maria.Node.mixin(maria.View.prototype); 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.View.prototype.destroy = function() {
maria.purgeEventListener(this); maria.purgeEventListener(this);
...@@ -2472,15 +2474,23 @@ the same. ...@@ -2472,15 +2474,23 @@ the same.
*/ */
maria.ElementView = function(model, controller, doc) { maria.ElementView = function(model, controller, doc) {
this._doc = doc || document;
maria.View.call(this, model, controller); maria.View.call(this, model, controller);
this.setDocument(doc);
}; };
maria.ElementView.prototype = new maria.View(); maria.ElementView.prototype = new maria.View();
maria.ElementView.prototype.constructor = maria.ElementView; maria.ElementView.prototype.constructor = maria.ElementView;
maria.ElementView.prototype.getDocument = function() { 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() { maria.ElementView.prototype.getTemplate = function() {
...@@ -2503,7 +2513,7 @@ maria.ElementView.prototype.build = function() { ...@@ -2503,7 +2513,7 @@ maria.ElementView.prototype.build = function() {
maria.ElementView.prototype.buildTemplate = function() { maria.ElementView.prototype.buildTemplate = function() {
// parseHTML returns a DocumentFragment so take firstChild as the rootEl // 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() { (function() {
...@@ -3052,7 +3062,8 @@ maria.ElementView.subclass = function(namespace, name, options) { ...@@ -3052,7 +3062,8 @@ maria.ElementView.subclass = function(namespace, name, options) {
for (var key in uiActions) { for (var key in uiActions) {
if (Object.prototype.hasOwnProperty.call(uiActions, key)) { if (Object.prototype.hasOwnProperty.call(uiActions, key)) {
var methodName = 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) { (function(methodName) {
properties[methodName] = function(evt) { properties[methodName] = function(evt) {
this.getController()[methodName](evt); this.getController()[methodName](evt);
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
</script> </script>
<script src="../lib/maria/maria.js"></script> <script src="../lib/maria/maria.js"></script>
<script src="../lib/aristocrat/aristocrat.js"></script> <script src="../lib/aristocrat/aristocrat.js"></script>
<script src="js/namespace.js"></script> <script src="js/namespace.js"></script>
......
...@@ -7,11 +7,10 @@ maria.ElementView.subclass(checkit, 'TodosAppView', { ...@@ -7,11 +7,10 @@ maria.ElementView.subclass(checkit, 'TodosAppView', {
return this.find('.content'); // child views will be appended to this element return this.find('.content'); // child views will be appended to this element
}, },
initialize: function() { initialize: function() {
var model = this.getModel(); this.appendChild(new checkit.TodosInputView());
this.appendChild(new checkit.TodosInputView(model)); this.appendChild(new checkit.TodosToolbarView());
this.appendChild(new checkit.TodosToolbarView(model)); this.appendChild(new checkit.TodosListView());
this.appendChild(new checkit.TodosListView(model)); this.appendChild(new checkit.TodosStatsView());
this.appendChild(new checkit.TodosStatsView(model));
}, },
insertBefore: function(newChild, oldChild) { insertBefore: function(newChild, oldChild) {
newChild.setModel(this.getModel()); newChild.setModel(this.getModel());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment