Skip to content

Instantly share code, notes, and snippets.

View ericf's full-sized avatar

Eric Ferraiuolo ericf

View GitHub Profile
YUI.add('router', function(Y) {
/**
Provides URL-based routing using HTML5 `pushState()` or the location hash.
@module app
@submodule router
@since 3.4.0
**/
@ericf
ericf / app.js
Created May 18, 2012 14:49
Nest Y.App POC
YUI({
modules: {
'router': {
fullpath: 'router-fixes.js',
requires: ['array-extras', 'base-build', 'history'],
optional: ['querystring-parse']
}
}
}).use('app-base', 'app-transitions', function (Y) {
Y.SquareList = Y.Base.create('squareList', Y.ModelList, [], { /* ... */ });
Y.Game = Y.Base.create('game', Y.Model, [], {
initializer: function () {
this._squareList = new Y.SquareList();
},
_getSquareList: function () {
return this._squareList;
},
var foo = 'foo',
bar = 'bar',
baz, zee;
baz = {
bla : true,
blaBla: false
};
zee = {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Y.App + Y.TabView</title>
</head>
<body class="yui3-skin-sam">
<script src="http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js"></script>
<script>
YUI({
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Example App</title>
</head>
<body>
<h1></h1>
// Creates a new App and View instance.
var app = new Y.App(),
view = new Y.View();
// Overrides the view's `render()` method to render text into its `container`.
view.render = function () {
this.get('container').set('text', 'Hello World!');
return this;
};
UserPageView = Y.Base.create('userPageView', Y.View, [], {
initializer: function () {
var user = this.get('model'),
repos = this.get('modelList');
// This view serves as a "page"-level view containing two sub-views to
// which it delegates rendering and stitches together the resulting UI.
// Sub-views are created to render the `User` and `RepoList`.
this.userView = new UserView({model: user});
this.repoListView = new RepoListView({modelList: repos});
// Creates a Person model which has a `name` attribute.
Y.Person = Y.Base.create('person', Y.Model, [], {}, {
ATTRS: {
name: {}
}
});
// Creates a HelloView which can say hello to a Person, or to the World if a
// Person model is not specified.
Y.HelloView = Y.Base.create('helloView', Y.View, [], {
var app = new Y.App(),
view = new Y.View();
view.render = function () {
this.get('container').set('text', 'Hello World!');
return this;
};
app.render().showView(view.render());