Skip to content

Instantly share code, notes, and snippets.

@jacksonp
Last active August 29, 2015 14:01
Show Gist options
  • Save jacksonp/b0dd4608c8be831c5c50 to your computer and use it in GitHub Desktop.
Save jacksonp/b0dd4608c8be831c5c50 to your computer and use it in GitHub Desktop.
code for ScotchApp-0.0.1.apk
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi">
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.4.2/pure-min.css">
<style>
.app {
width: 300px;
margin: 0 auto;
}
button {
width: 260px;
}
</style>
<title>Scotch</title>
<div class="app"></div>
<script src="http://yui.yahooapis.com/3.16.0/build/yui/yui-min.js"></script>
<script>
YUI().use('app', function (Y) {
'use strict';
// 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>';
html += '<p><button class="pure-button pure-button-disabled">Highland</button>';
html += '<p><button class="pure-button pure-button-disabled">Islands</button>';
html += '<p><button class="pure-button pure-button-disabled">Islay</button>';
html += '<p><button class="pure-button pure-button-disabled">Lowland</button>';
html += '<p><button class="pure-button pure-button-disabled">Speyside</button>';
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 had over 30 distilleries and ' +
'proclaimed itself "the whisky capital of the world". However, a focus ' +
'on quantity rather than quality, and the combination of prohibition ' +
'and the Great Depression in the United States, led to most ' +
'distilleries going out of business. Today only three active ' +
'distilleries remain in Campbeltown: Glen Scotia, Glengyle, and ' +
'Springbank.<br>- Wikipedia';
this.get('container').setHTML(html);
return this;
},
events : {
'button' : {
click : function (e) {
app.showView('home');
}
}
}
});
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>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.4.2/pure-min.css">
<script src="http://yui.yahooapis.com/3.16.0/build/yui/yui-min.js"></script>
<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>
@triptych
Copy link

These need to be one per gist otherwise it embeds them all at once. I created three new gists for the blog post.

https://gist.github.com/triptych/48649fe0093bcde01df1
https://gist.github.com/triptych/1a72987f89f5b5093d97
https://gist.github.com/triptych/d6e013a2565ad37002be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment