Mercurial > templog
comparison web/views/riot.min.js @ 482:9950ffa9a79b
set nearly working
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 04 Feb 2014 22:49:16 +0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
479:3ac15a9be1b6 | 482:9950ffa9a79b |
---|---|
1 /* Riot 0.9.8, @license MIT, (c) 2014 Moot Inc + contributors */ | |
2 (function(e){"use strict";e.observable=function(e){var t={},n=[].slice;e.on=function(n,r){if(typeof r==="function"){n.replace(/[^\s]+/g,function(e,n){(t[e]=t[e]||[]).push(r);r.typed=n>0})}return e};e.off=function(n){n.replace(/[^\s]+/g,function(e){t[e]=[]});if(n=="*")t={};return e};e.one=function(t,n){if(n)n.one=true;return e.on(t,n)};e.trigger=function(r){var o=n.call(arguments,1),u=t[r]||[];for(var i=0,a;a=u[i];++i){if(!(a.one&&a.done||a.busy)){a.busy=true;a.apply(e,a.typed?[r].concat(o):o);a.done=true;a.busy=false}}return e};return e};var t={};var n={"\\":"\\\\","\n":"\\n","\r":"\\r","\u2028":"\\u2028","\u2029":"\\u2029","'":"\\'"};var r={"&":"&",'"':""","<":"<",">":">"};e.render=function(e,r){if(!e)return"";t[e]=t[e]||new Function("_","return '"+e.replace(/[\\\n\r\u2028\u2029']/g,function(e){return n[e]}).replace(/\{\s*(\w+)\s*\}/g,"'+(_.$1?(_.$1+'').replace(/[&\"<>]/g,function(e){return ENTITIES_MAP[e];}):(_.$1===0?0:''))+'")+"'");return t[e](r)};if(typeof top!="object")return;var o,u=e.observable({}),i=window.addEventListener,a=document;function f(e){e=e.type?location.hash:e;if(e!=o)u.trigger("pop",e);o=e}if(i){i("popstate",f,false);a.addEventListener("DOMContentLoaded",f,false)}else{a.attachEvent("onreadystatechange",function(){if(a.readyState==="complete")f("")})}e.route=function(e){if(typeof e==="function")return u.on("pop",e);if(history.pushState)history.pushState(0,0,e);f(e)}})(typeof top=="object"?window.$||(window.$={}):exports); |