Application
SPA starter template.
by gorebash
HTML
<script src="http://fbug.googlecode.com/svn/lite/branches/firebug1.4/content/firebug-lite-dev.js"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap-1.0.0.min.css">
<div class="container-fluid">
<div class="page-header">
<h1>Actions</h1>
<h2>HI</h2>
</div>
<button id="async" class="btn primary">Get Async</button><br /><br />
<button id="sync" class="btn primary">Get Sync</button><br /><br />
<button id="clr" class="btn">Clear Cache</button>
</div>
JavaScript
$(function() {
APP.init({trace:true});
$("h1").Plugins().highlight({color:"#ff6600"}).background({color:"#ccc"});
$("h2").Plugins().highlight({color:"#ffcc33"});
APP.subscribe("nato24", function(e, data) {
console.log(data);
});
$("#async").click(function() {
//async
APP.Cache.get("nato24", getTwitterFeed, true);
});
$("#sync").click(function() {
//sync
APP.log(APP.Cache.get("date", getDate));
});
$("#clr").click(function() {
APP.Cache.clear();
});
var getTwitterFeed = function(callback) {
$.ajax({
url: "http://twitter.com/status/user_timeline/nato24.json?count=10&callback=?",
dataType: "jsonp",
success: callback
});
};
var getDate = function() {
return new Date();
};
});
//APP STARTER TEMPLATE
(function (APP, $, undefined) {
var settings = {
trace : false
};
APP.init = function(options) {
$.extend(settings, options);
$.fn.Plugins = function() {
console.log(
"hello");
for(var p in APP.Plugins) {
this[p] = APP.Plugins[p];
}
return this;
};
};
APP.log = function () {
if (window.console && window.console.log && settings.trace) {
console.log.apply(this, Array.prototype.slice.call(arguments));
}
};
APP.subscribe = function (event, fn) {
$(document).bind(event, fn);
};
APP.unsubscribe = function (event) {
$(document).unbind(event);
};
APP.publish = function (event, args) {
$({ ownerDocument: document }).trigger(event, args);
};
APP.Plugins = (function() {
var highlight = function(options) {
var settings = {
color: "#000000"
...