mirror of
https://github.com/wezm/wezm.net.git
synced 2024-12-19 02:39:54 +00:00
Replace Mojo with Handlebars
This commit is contained in:
parent
7cae1a5c83
commit
ae91faf428
5 changed files with 1427 additions and 69 deletions
|
@ -2,7 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<%= render '_head' %>
|
<%= render '_head' %>
|
||||||
<script src="/js/mojo.js" type="text/javascript" charset="utf-8"></script>
|
<script src="/js/handlebars.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script src="/js/home.js" type="text/javascript" charset="utf-8"></script>
|
<script src="/js/home.js" type="text/javascript" charset="utf-8"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="home">
|
<body class="home">
|
||||||
|
@ -45,5 +45,11 @@
|
||||||
<a href="http://www.flickr.com/photos/wezm/" class="more">More »</a>
|
<a href="http://www.flickr.com/photos/wezm/" class="more">More »</a>
|
||||||
</section>
|
</section>
|
||||||
<%= render '_footer' %>
|
<%= render '_footer' %>
|
||||||
|
<script id="image-template" type="text/x-handlebars-template">
|
||||||
|
<li>
|
||||||
|
<a href="{{href}}" rel="prettyPhoto[flickr]"><img src="{{src}}" alt="{{alt}}" /></a>
|
||||||
|
</li>
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<%= render '_head' %>
|
<%= render '_head' %>
|
||||||
<script src="/js/jquery.flot.min.js" type="text/javascript" charset="utf-8"></script>
|
<script src="/js/jquery.flot.min.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<!--[if IE lt 9]><script language="javascript" type="text/javascript" src="/js/excanvas.min.js"></script><![endif]-->
|
<!--[if IE lt 9]><script language="javascript" type="text/javascript" src="/js/excanvas.min.js"></script><![endif]-->
|
||||||
<script src="/js/mojo.js" type="text/javascript" charset="utf-8"></script>
|
<script src="/js/handlebars.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script src="/js/weather.js" type="text/javascript" charset="utf-8"></script>
|
<script src="/js/weather.js" type="text/javascript" charset="utf-8"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="weather">
|
<body class="weather">
|
||||||
|
|
1417
output/js/handlebars.js
Normal file
1417
output/js/handlebars.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,5 @@
|
||||||
jQuery(function () {
|
jQuery(function () {
|
||||||
function render_image(o) {
|
var image_template = Handlebars.compile($('#image-template').html());
|
||||||
return '<li>\n\
|
|
||||||
<a href="' + (Mojo.escape(Mojo.normalize(o.href))) + '" rel="prettyPhoto[flickr]"><img src="' + (Mojo.escape(Mojo.normalize(o.src))) + '" alt="' + (Mojo.escape(Mojo.normalize(o.alt))) + '" /></a>\n\
|
|
||||||
</li>';
|
|
||||||
};
|
|
||||||
|
|
||||||
function populate_flickr(data, text_status) {
|
function populate_flickr(data, text_status) {
|
||||||
var ul = $("#flickr ul");
|
var ul = $("#flickr ul");
|
||||||
|
@ -15,7 +11,7 @@ jQuery(function () {
|
||||||
src: '/images/photos.jpg',
|
src: '/images/photos.jpg',
|
||||||
alt: photo.attr('title')
|
alt: photo.attr('title')
|
||||||
};
|
};
|
||||||
var li = $(render_image(image));
|
var li = $(image_template(image));
|
||||||
$('img', li).css('left', (i * -75) + 'px');
|
$('img', li).css('left', (i * -75) + 'px');
|
||||||
li.css("background-position", (i * -75) + 'px -75px');
|
li.css("background-position", (i * -75) + 'px -75px');
|
||||||
ul.append(li);
|
ul.append(li);
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
|
|
||||||
// Mojo - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
|
|
||||||
|
|
||||||
;(function(){
|
|
||||||
Mojo = {
|
|
||||||
|
|
||||||
// --- Version
|
|
||||||
|
|
||||||
version: '0.3.0',
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Escape HTML.
|
|
||||||
*
|
|
||||||
* @param {string} html
|
|
||||||
* @return {string}
|
|
||||||
* @api public
|
|
||||||
*/
|
|
||||||
|
|
||||||
escape : function(html) {
|
|
||||||
if (!html) return
|
|
||||||
return html.toString()
|
|
||||||
.replace(/&/gmi, '&')
|
|
||||||
.replace(/"/gmi, '"')
|
|
||||||
.replace(/>/gmi, '>')
|
|
||||||
.replace(/</gmi, '<')
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalize _object_ for output.
|
|
||||||
*
|
|
||||||
* @param {object}object
|
|
||||||
* @return {mixed}
|
|
||||||
* @api public
|
|
||||||
*/
|
|
||||||
|
|
||||||
normalize: function(object, property) {
|
|
||||||
if(property === undefined)
|
|
||||||
return typeof object == 'function' ? object() : object
|
|
||||||
else
|
|
||||||
return typeof object[property] == 'function' ? object[property]() : object[property]
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enumerate _object_'s _prop_, buffering _fn_'s
|
|
||||||
* return value.
|
|
||||||
*
|
|
||||||
* @param {object} object
|
|
||||||
* @param {object} prop
|
|
||||||
* @return {string}
|
|
||||||
* @api private
|
|
||||||
*/
|
|
||||||
|
|
||||||
enumerate: function(object, prop, fn) {
|
|
||||||
if (!prop) return ''
|
|
||||||
if (!(prop instanceof Array)) return fn(object)
|
|
||||||
for (var buf = [], i = 0, len = prop.length; i < len; ++i)
|
|
||||||
buf.push(fn(prop[i]))
|
|
||||||
return buf.join(' ')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})()
|
|
Loading…
Reference in a new issue