Skip to content

Instantly share code, notes, and snippets.

@triptych
Created May 14, 2014 21:41
Show Gist options
  • Save triptych/d6e013a2565ad37002be to your computer and use it in GitHub Desktop.
Save triptych/d6e013a2565ad37002be to your computer and use it in GitHub Desktop.
code for ScotchApp-0.0.1.apk
<script>
YUI().use('app', function (Y) {
// Initial view:
Y.HomeView = Y.Base.create('homeView', Y.View, [], {
render : function () {
var html = '<h1>Scotch Regions</h1>';
html += '<p><button class="pure-button">Cambletown</button>';
// more html content
this.get('container').setHTML(html);
return this;
},
events : {
'button' : {
click : function (e) {
app.showView('cambletown');
}
}
}
});
// A sample view we can go to and back from:
Y.CambletownView = Y.Base.create('cambletownView', Y.View, [], {
render : function () {
var html = '<h1>Cambletown</h1>';
html += '<p><button class="pure-button">Home</button>';
html += '<p>At one point Cambletown [...snip...]';
this.get('container').setHTML(html);
return this;
},
events : {
'button' : {
click : function (e) {
app.showView('home');
}
}
}
});
// Initialize and render the app.
var app = new Y.App({
transitions : true,
viewContainer : '.app',
views: {
home: {
type : 'HomeView',
preserve : true
},
cambletown: {
type : 'CambletownView',
parent : 'home'
}
}
});
app.render();
app.showView('home');
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment