este-library-oldschool
Version:
Library for github.com/steida/este.git
79 lines (70 loc) • 2.4 kB
JavaScript
// Generated by github.com/steida/coffee2closure 900.1.18
/**
@fileoverview View for este.App. It should watches user actions and delegate
them on view model. este.app.Presenter should watch model changes, persist
them, then rerender view. For view rendering, we can use Closure Template or
Facebook react.
@see este.demos.app.todomvc.todos.list.View
*/
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.superClass_ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
goog.provide('este.app.View');
goog.require('este.ui.Component');
goog.require('goog.dom.classlist');
/**
@constructor
@extends {este.ui.Component}
*/
este.app.View = function() {
este.app.View.superClass_.constructor.call(this);
}
extend(este.app.View, superClass);
/**
Optional view element className.
@type {string}
*/
este.app.View.prototype.className = '';
/**
This helper method allows us to generate URL for concrete presenter, so we
don't have to hardcode URLs in code. All URLs should be defined only at one
place. In app.start method.
Example: this.createUrl app.products.list.Presenter, 'id': 123
@type {Function}
*/
este.app.View.prototype.createUrl = null;
/**
Redirect to another presenter from code.
Example: this.redirect app.products.list.Presenter, 'id': 123
@type {Function}
*/
este.app.View.prototype.redirect = null;
/**
Scroll position for Este app screen.
@type {goog.math.Coordinate}
*/
este.app.View.prototype.scroll = null;
/**
@override
*/
este.app.View.prototype.createDom = function() {
este.app.View.superClass_.createDom.call(this);
goog.dom.classlist.add(this.getElement(), 'e-app-view');
if (this.className) {
goog.dom.classlist.add(this.getElement(), this.className);
}
};
/**
Use this method for events registration.
This method should be overridden.
@override
*/
este.app.View.prototype.enterDocument = function() {
este.app.View.superClass_.enterDocument.call(this);
this.update();
};
/**
Use this method for DOM update. This method is called when view is shown
by default. You should call it when model is changed.
This method should be overridden.
*/
este.app.View.prototype.update = function() {};