You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/01/16 00:25:06 UTC
[3/8] removed sammy, using angular now
http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e93025ac/attachments/sammy/plugins/sammy.path_location_proxy.js
----------------------------------------------------------------------
diff --git a/attachments/sammy/plugins/sammy.path_location_proxy.js b/attachments/sammy/plugins/sammy.path_location_proxy.js
deleted file mode 100644
index 13f9014..0000000
--- a/attachments/sammy/plugins/sammy.path_location_proxy.js
+++ /dev/null
@@ -1,29 +0,0 @@
-(function($) {
-
- Sammy = Sammy || {};
-
- // `Sammy.PathLocationProxy` is a simple Location Proxy that just
- // gets and sets window.location. This allows you to use
- // Sammy to route on the full URL path instead of just the hash. It
- // will take a full refresh to get the app to change state.
- //
- // To read more about location proxies, check out the
- // documentation for `Sammy.HashLocationProxy`
- Sammy.PathLocationProxy = function(app) {
- this.app = app;
- };
-
- Sammy.PathLocationProxy.prototype = {
- bind: function() {},
- unbind: function() {},
-
- getLocation: function() {
- return [window.location.pathname, window.location.search].join('');
- },
-
- setLocation: function(new_location) {
- return window.location = new_location;
- }
- };
-
-})(jQuery);
http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e93025ac/attachments/sammy/plugins/sammy.pure.js
----------------------------------------------------------------------
diff --git a/attachments/sammy/plugins/sammy.pure.js b/attachments/sammy/plugins/sammy.pure.js
deleted file mode 100644
index 16fe3df..0000000
--- a/attachments/sammy/plugins/sammy.pure.js
+++ /dev/null
@@ -1,756 +0,0 @@
-(function($) {
-
-/*!
- PURE Unobtrusive Rendering Engine for HTML
-
- Licensed under the MIT licenses.
- More information at: http://www.opensource.org
-
- Copyright (c) 2010 Michael Cvilic - BeeBole.com
-
- Thanks to Rog Peppe for the functional JS jump
- revision: 2.47
-*/
-
-var $p, pure = $p = function(){
- var sel = arguments[0],
- ctxt = false;
-
- if(typeof sel === 'string'){
- ctxt = arguments[1] || false;
- }
- return $p.core(sel, ctxt);
-};
-
-$p.core = function(sel, ctxt, plugins){
- //get an instance of the plugins
- var plugins = getPlugins(),
- templates = [];
-
- //search for the template node(s)
- switch(typeof sel){
- case 'string':
- templates = plugins.find(ctxt || document, sel);
- if(templates.length === 0) {
- error('The template "' + sel + '" was not found');
- }
- break;
- case 'undefined':
- error('The template root is undefined, check your selector');
- break;
- default:
- templates = [sel];
- }
-
- for(var i = 0, ii = templates.length; i < ii; i++){
- plugins[i] = templates[i];
- }
- plugins.length = ii;
-
- // set the signature string that will be replaced at render time
- var Sig = '_s' + Math.floor( Math.random() * 1000000 ) + '_',
- // another signature to prepend to attributes and avoid checks: style, height, on[events]...
- attPfx = '_a' + Math.floor( Math.random() * 1000000 ) + '_',
- // rx to parse selectors, e.g. "+tr.foo[class]"
- selRx = /^(\+)?([^\@\+]+)?\@?([^\+]+)?(\+)?$/,
- // set automatically attributes for some tags
- autoAttr = {
- IMG:'src',
- INPUT:'value'
- },
- // check if the argument is an array - thanks salty-horse (Ori Avtalion)
- isArray = Array.isArray ?
- function(o) {
- return Array.isArray(o);
- } :
- function(o) {
- return Object.prototype.toString.call(o) === "[object Array]";
- };
-
- return plugins;
-
-
- /* * * * * * * * * * * * * * * * * * * * * * * * * *
- core functions
- * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-
- // error utility
- function error(e){
- if(typeof console !== 'undefined'){
- console.log(e);
- }else{ alert(e); }
- throw('pure error: ' + e);
- }
-
- //return a new instance of plugins
- function getPlugins(){
- var plugins = $p.plugins,
- f = function(){};
- f.prototype = plugins;
-
- // do not overwrite functions if external definition
- f.prototype.compile = plugins.compile || compile;
- f.prototype.render = plugins.render || render;
- f.prototype.autoRender = plugins.autoRender || autoRender;
- f.prototype.find = plugins.find || find;
-
- // give the compiler and the error handling to the plugin context
- f.prototype._compiler = compiler;
- f.prototype._error = error;
-
- return new f();
- }
-
- // returns the outer HTML of a node
- function outerHTML(node){
- // if IE take the internal method otherwise build one
- return node.outerHTML || (
- function(n){
- var div = document.createElement('div'), h;
- div.appendChild( n.cloneNode(true) );
- h = div.innerHTML;
- div = null;
- return h;
- })(node);
- }
-
- // returns the string generator function
- function wrapquote(qfn, f){
- return function(ctxt){
- return qfn('' + f.call(ctxt.context, ctxt));
- };
- }
-
- // default find using querySelector when available on the browser
- function find(n, sel){
- if(typeof n === 'string'){
- sel = n;
- n = false;
- }
- if(typeof document.querySelectorAll !== 'undefined'){
- return (n||document).querySelectorAll( sel );
- }else{
- error('You can test PURE standalone with: iPhone, FF3.5+, Safari4+ and IE8+\n\nTo run PURE on your browser, you need a JS library/framework with a CSS selector engine');
- }
- }
-
- // create a function that concatenates constant string
- // sections (given in parts) and the results of called
- // functions to fill in the gaps between parts (fns).
- // fns[n] fills in the gap between parts[n-1] and parts[n];
- // fns[0] is unused.
- // this is the inner template evaluation loop.
- function concatenator(parts, fns){
- return function(ctxt){
- var strs = [ parts[ 0 ] ],
- n = parts.length,
- fnVal, pVal, attLine, pos;
-
- for(var i = 1; i < n; i++){
- fnVal = fns[i]( ctxt );
- pVal = parts[i];
-
- // if the value is empty and attribute, remove it
- if(fnVal === ''){
- attLine = strs[ strs.length - 1 ];
- if( ( pos = attLine.search( /[\w]+=\"?$/ ) ) > -1){
- strs[ strs.length - 1 ] = attLine.substring( 0, pos );
- pVal = pVal.substr( 1 );
- }
- }
-
- strs[ strs.length ] = fnVal;
- strs[ strs.length ] = pVal;
- }
- return strs.join('');
- };
- }
-
- // parse and check the loop directive
- function parseloopspec(p){
- var m = p.match( /^(\w+)\s*<-\s*(\S+)?$/ );
- if(m === null){
- error('bad loop spec: "' + p + '"');
- }
- if(m[1] === 'item'){
- error('"item<-..." is a reserved word for the current running iteration.\n\nPlease choose another name for your loop.');
- }
- if( !m[2] || (m[2] && (/context/i).test(m[2]))){ //undefined or space(IE)
- m[2] = function(ctxt){return ctxt.context;};
- }
- return {name: m[1], sel: m[2]};
- }
-
- // parse a data selector and return a function that
- // can traverse the data accordingly, given a context.
- function dataselectfn(sel){
- if(typeof(sel) === 'function'){
- return sel;
- }
- //check for a valid js variable name with hyphen(for properties only), $, _ and :
- var m = sel.match(/^[a-zA-Z\$_\@][\w\$:-]*(\.[\w\$:-]*[^\.])*$/);
- if(m === null){
- var found = false, s = sel, parts = [], pfns = [], i = 0, retStr;
- // check if literal
- if(/\'|\"/.test( s.charAt(0) )){
- if(/\'|\"/.test( s.charAt(s.length-1) )){
- retStr = s.substring(1, s.length-1);
- return function(){ return retStr; };
- }
- }else{
- // check if literal + #{var}
- while((m = s.match(/#\{([^{}]+)\}/)) !== null){
- found = true;
- parts[i++] = s.slice(0, m.index);
- pfns[i] = dataselectfn(m[1]);
- s = s.slice(m.index + m[0].length, s.length);
- }
- }
- if(!found){
- error('bad data selector syntax: ' + sel);
- }
- parts[i] = s;
- return concatenator(parts, pfns);
- }
- m = sel.split('.');
- return function(ctxt){
- var data = ctxt.context;
- if(!data){
- return '';
- }
- var v = ctxt[m[0]],
- i = 0;
- if(v && v.item){
- data = v.item;
- i += 1;
- }
- var n = m.length;
- for(; i < n; i++){
- if(!data){break;}
- data = data[m[i]];
- }
- return (!data && data !== 0) ? '':data;
- };
- }
-
- // wrap in an object the target node/attr and their properties
- function gettarget(dom, sel, isloop){
- var osel, prepend, selector, attr, append, target = [];
- if( typeof sel === 'string' ){
- osel = sel;
- var m = sel.match(selRx);
- if( !m ){
- error( 'bad selector syntax: ' + sel );
- }
-
- prepend = m[1];
- selector = m[2];
- attr = m[3];
- append = m[4];
-
- if(selector === '.' || ( !selector && attr ) ){
- target[0] = dom;
- }else{
- target = plugins.find(dom, selector);
- }
- if(!target || target.length === 0){
- return error('The node "' + sel + '" was not found in the template');
- }
- }else{
- // autoRender node
- prepend = sel.prepend;
- attr = sel.attr;
- append = sel.append;
- target = [dom];
- }
-
- if( prepend || append ){
- if( prepend && append ){
- error('append/prepend cannot take place at the same time');
- }else if( isloop ){
- error('no append/prepend/replace modifiers allowed for loop target');
- }else if( append && isloop ){
- error('cannot append with loop (sel: ' + osel + ')');
- }
- }
- var setstr, getstr, quotefn, isStyle, isClass, attName, setfn;
- if(attr){
- isStyle = (/^style$/i).test(attr);
- isClass = (/^class$/i).test(attr);
- attName = isClass ? 'className' : attr;
- setstr = function(node, s) {
- node.setAttribute(attPfx + attr, s);
- if (attName in node && !isStyle) {
- node[attName] = '';
- }
- if (node.nodeType === 1) {
- node.removeAttribute(attr);
- isClass && node.removeAttribute(attName);
- }
- };
- if (isStyle || isClass) {//IE no quotes special care
- if(isStyle){
- getstr = function(n){ return n.style.cssText; };
- }else{
- getstr = function(n){ return n.className; };
- }
- quotefn = function(s){ return s.replace(/\"/g, '"'); };
- }else {
- getstr = function(n){ return n.getAttribute(attr); };
- quotefn = function(s){ return s.replace(/\"/g, '"').replace(/\s/g, ' '); };
- }
- if(prepend){
- setfn = function(node, s){ setstr( node, s + getstr( node )); };
- }else if(append){
- setfn = function(node, s){ setstr( node, getstr( node ) + s); };
- }else{
- setfn = function(node, s){ setstr( node, s ); };
- }
- }else{
- if (isloop) {
- setfn = function(node, s) {
- var pn = node.parentNode;
- if (pn) {
- //replace node with s
- pn.insertBefore(document.createTextNode(s), node.nextSibling);
- pn.removeChild(node);
- }
- };
- } else {
- if (prepend) {
- setfn = function(node, s) { node.insertBefore(document.createTextNode(s), node.firstChild); };
- } else if (append) {
- setfn = function(node, s) { node.appendChild(document.createTextNode(s));};
- } else {
- setfn = function(node, s) {
- while (node.firstChild) { node.removeChild(node.firstChild); }
- node.appendChild(document.createTextNode(s));
- };
- }
- }
- quotefn = function(s) { return s; };
- }
- return { attr: attr, nodes: target, set: setfn, sel: osel, quotefn: quotefn };
- }
-
- function setsig(target, n){
- var sig = Sig + n + ':';
- for(var i = 0; i < target.nodes.length; i++){
- // could check for overlapping targets here.
- target.set( target.nodes[i], sig );
- }
- }
-
- // read de loop data, and pass it to the inner rendering function
- function loopfn(name, dselect, inner, sorter, filter){
- return function(ctxt){
- var a = dselect(ctxt),
- old = ctxt[name],
- temp = { items : a },
- filtered = 0,
- length,
- strs = [],
- buildArg = function(idx, temp, ftr, len){
- ctxt.pos = temp.pos = idx;
- ctxt.item = temp.item = a[ idx ];
- ctxt.items = a;
- //if array, set a length property - filtered items
- typeof len !== 'undefined' && (ctxt.length = len);
- //if filter directive
- if(typeof ftr === 'function' && ftr(ctxt) === false){
- filtered++;
- return;
- }
- strs.push( inner.call(temp, ctxt ) );
- };
- ctxt[name] = temp;
- if( isArray(a) ){
- length = a.length || 0;
- // if sort directive
- if(typeof sorter === 'function'){
- a.sort(sorter);
- }
- //loop on array
- for(var i = 0, ii = length; i < ii; i++){
- buildArg(i, temp, filter, length - filtered);
- }
- }else{
- if(a && typeof sorter !== 'undefined'){
- error('sort is only available on arrays, not objects');
- }
- //loop on collections
- for(var prop in a){
- a.hasOwnProperty( prop ) && buildArg(prop, temp, filter);
- }
- }
-
- typeof old !== 'undefined' ? ctxt[name] = old : delete ctxt[name];
- return strs.join('');
- };
- }
- // generate the template for a loop node
- function loopgen(dom, sel, loop, fns){
- var already = false, ls, sorter, filter, prop;
- for(prop in loop){
- if(loop.hasOwnProperty(prop)){
- if(prop === 'sort'){
- sorter = loop.sort;
- continue;
- }else if(prop === 'filter'){
- filter = loop.filter;
- continue;
- }
- if(already){
- error('cannot have more than one loop on a target');
- }
- ls = prop;
- already = true;
- }
- }
- if(!ls){
- error('Error in the selector: ' + sel + '\nA directive action must be a string, a function or a loop(<-)');
- }
- var dsel = loop[ls];
- // if it's a simple data selector then we default to contents, not replacement.
- if(typeof(dsel) === 'string' || typeof(dsel) === 'function'){
- loop = {};
- loop[ls] = {root: dsel};
- return loopgen(dom, sel, loop, fns);
- }
- var spec = parseloopspec(ls),
- itersel = dataselectfn(spec.sel),
- target = gettarget(dom, sel, true),
- nodes = target.nodes;
-
- for(i = 0; i < nodes.length; i++){
- var node = nodes[i],
- inner = compiler(node, dsel);
- fns[fns.length] = wrapquote(target.quotefn, loopfn(spec.name, itersel, inner, sorter, filter));
- target.nodes = [node]; // N.B. side effect on target.
- setsig(target, fns.length - 1);
- }
- }
-
- function getAutoNodes(n, data){
- var ns = n.getElementsByTagName('*'),
- an = [],
- openLoops = {a:[],l:{}},
- cspec,
- isNodeValue,
- i, ii, j, jj, ni, cs, cj;
- //for each node found in the template
- for(i = -1, ii = ns.length; i < ii; i++){
- ni = i > -1 ?ns[i]:n;
- if(ni.nodeType === 1 && ni.className !== ''){
- //when a className is found
- cs = ni.className.split(' ');
- // for each className
- for(j = 0, jj=cs.length;j<jj;j++){
- cj = cs[j];
- // check if it is related to a context property
- cspec = checkClass(cj, ni.tagName);
- // if so, store the node, plus the type of data
- if(cspec !== false){
- isNodeValue = (/nodevalue/i).test(cspec.attr);
- if(cspec.sel.indexOf('@') > -1 || isNodeValue){
- ni.className = ni.className.replace('@'+cspec.attr, '');
- if(isNodeValue){
- cspec.attr = false;
- }
- }
- an.push({n:ni, cspec:cspec});
- }
- }
- }
- }
- return an;
-
- function checkClass(c, tagName){
- // read the class
- var ca = c.match(selRx),
- attr = ca[3] || autoAttr[tagName],
- cspec = {prepend:!!ca[1], prop:ca[2], attr:attr, append:!!ca[4], sel:c},
- i, ii, loopi, loopil, val;
- // check in existing open loops
- for(i = openLoops.a.length-1; i >= 0; i--){
- loopi = openLoops.a[i];
- loopil = loopi.l[0];
- val = loopil && loopil[cspec.prop];
- if(typeof val !== 'undefined'){
- cspec.prop = loopi.p + '.' + cspec.prop;
- if(openLoops.l[cspec.prop] === true){
- val = val[0];
- }
- break;
- }
- }
- // not found check first level of data
- if(typeof val === 'undefined'){
- val = isArray(data) ? data[0][cspec.prop] : data[cspec.prop];
- // nothing found return
- if(typeof val === 'undefined'){
- return false;
- }
- }
- // set the spec for autoNode
- if(isArray(val)){
- openLoops.a.push( {l:val, p:cspec.prop} );
- openLoops.l[cspec.prop] = true;
- cspec.t = 'loop';
- }else{
- cspec.t = 'str';
- }
- return cspec;
- }
- }
-
- // returns a function that, given a context argument,
- // will render the template defined by dom and directive.
- function compiler(dom, directive, data, ans){
- var fns = [];
- // autoRendering nodes parsing -> auto-nodes
- ans = ans || data && getAutoNodes(dom, data);
- if(data){
- var j, jj, cspec, n, target, nodes, itersel, node, inner;
- // for each auto-nodes
- while(ans.length > 0){
- cspec = ans[0].cspec;
- n = ans[0].n;
- ans.splice(0, 1);
- if(cspec.t === 'str'){
- // if the target is a value
- target = gettarget(n, cspec, false);
- setsig(target, fns.length);
- fns[fns.length] = wrapquote(target.quotefn, dataselectfn(cspec.prop));
- }else{
- // if the target is a loop
- itersel = dataselectfn(cspec.sel);
- target = gettarget(n, cspec, true);
- nodes = target.nodes;
- for(j = 0, jj = nodes.length; j < jj; j++){
- node = nodes[j];
- inner = compiler(node, false, data, ans);
- fns[fns.length] = wrapquote(target.quotefn, loopfn(cspec.sel, itersel, inner));
- target.nodes = [node];
- setsig(target, fns.length - 1);
- }
- }
- }
- }
- // read directives
- var target, dsel;
- for(var sel in directive){
- if(directive.hasOwnProperty(sel)){
- dsel = directive[sel];
- if(typeof(dsel) === 'function' || typeof(dsel) === 'string'){
- // set the value for the node/attr
- target = gettarget(dom, sel, false);
- setsig(target, fns.length);
- fns[fns.length] = wrapquote(target.quotefn, dataselectfn(dsel));
- }else{
- // loop on node
- loopgen(dom, sel, dsel, fns);
- }
- }
- }
- // convert node to a string
- var h = outerHTML(dom), pfns = [];
- // IE adds an unremovable "selected, value" attribute
- // hard replace while waiting for a better solution
- h = h.replace(/<([^>]+)\s(value\=""|selected)\s?([^>]*)>/ig, "<$1 $3>");
-
- // remove attribute prefix
- h = h.split(attPfx).join('');
-
- // slice the html string at "Sig"
- var parts = h.split( Sig ), p;
- // for each slice add the return string of
- for(var i = 1; i < parts.length; i++){
- p = parts[i];
- // part is of the form "fn-number:..." as placed there by setsig.
- pfns[i] = fns[ parseInt(p, 10) ];
- parts[i] = p.substring( p.indexOf(':') + 1 );
- }
- return concatenator(parts, pfns);
- }
- // compile the template with directive
- // if a context is passed, the autoRendering is triggered automatically
- // return a function waiting the data as argument
- function compile(directive, ctxt, template){
- var rfn = compiler( ( template || this[0] ).cloneNode(true), directive, ctxt);
- return function(context){
- return rfn({context:context});
- };
- }
- //compile with the directive as argument
- // run the template function on the context argument
- // return an HTML string
- // should replace the template and return this
- function render(ctxt, directive){
- var fn = typeof directive === 'function' ? directive : plugins.compile( directive, false, this[0] );
- for(var i = 0, ii = this.length; i < ii; i++){
- this[i] = replaceWith( this[i], fn( ctxt, false ));
- }
- context = null;
- return this;
- }
-
- // compile the template with autoRender
- // run the template function on the context argument
- // return an HTML string
- function autoRender(ctxt, directive){
- var fn = plugins.compile( directive, ctxt, this[0] );
- for(var i = 0, ii = this.length; i < ii; i++){
- this[i] = replaceWith( this[i], fn( ctxt, false));
- }
- context = null;
- return this;
- }
-
- function replaceWith(elm, html) {
- var ne,
- ep = elm.parentNode,
- depth = 0;
- switch (elm.tagName) {
- case 'TBODY': case 'THEAD': case 'TFOOT':
- html = '<TABLE>' + html + '</TABLE>';
- depth = 1;
- break;
- case 'TR':
- html = '<TABLE><TBODY>' + html + '</TBODY></TABLE>';
- depth = 2;
- break;
- case 'TD': case 'TH':
- html = '<TABLE><TBODY><TR>' + html + '</TR></TBODY></TABLE>';
- depth = 3;
- break;
- }
- tmp = document.createElement('SPAN');
- tmp.style.display = 'none';
- document.body.appendChild(tmp);
- tmp.innerHTML = html;
- ne = tmp.firstChild;
- while (depth--) {
- ne = ne.firstChild;
- }
- ep.insertBefore(ne, elm);
- ep.removeChild(elm);
- document.body.removeChild(tmp);
- elm = ne;
-
- ne = ep = null;
- return elm;
- }
-};
-
-$p.plugins = {};
-
-$p.libs = {
- dojo:function(){
- if(typeof document.querySelector === 'undefined'){
- $p.plugins.find = function(n, sel){
- return dojo.query(sel, n);
- };
- }
- },
- domassistant:function(){
- if(typeof document.querySelector === 'undefined'){
- $p.plugins.find = function(n, sel){
- return $(n).cssSelect(sel);
- };
- }
- DOMAssistant.attach({
- publicMethods : [ 'compile', 'render', 'autoRender'],
- compile:function(directive, ctxt){ return $p(this).compile(directive, ctxt); },
- render:function(ctxt, directive){ return $( $p(this).render(ctxt, directive) )[0]; },
- autoRender:function(ctxt, directive){ return $( $p(this).autoRender(ctxt, directive) )[0]; }
- });
- },
- jquery:function(){
- if(typeof document.querySelector === 'undefined'){
- $p.plugins.find = function(n, sel){
- return jQuery(n).find(sel);
- };
- }
- jQuery.fn.extend({
- compile:function(directive, ctxt){ return $p(this[0]).compile(directive, ctxt); },
- render:function(ctxt, directive){ return jQuery( $p( this[0] ).render( ctxt, directive ) ); },
- autoRender:function(ctxt, directive){ return jQuery( $p( this[0] ).autoRender( ctxt, directive ) ); }
- });
- },
- mootools:function(){
- if(typeof document.querySelector === 'undefined'){
- $p.plugins.find = function(n, sel){
- return $(n).getElements(sel);
- };
- }
- Element.implement({
- compile:function(directive, ctxt){ return $p(this).compile(directive, ctxt); },
- render:function(ctxt, directive){ return $p(this).render(ctxt, directive); },
- autoRender:function(ctxt, directive){ return $p(this).autoRender(ctxt, directive); }
- });
- },
- prototype:function(){
- if(typeof document.querySelector === 'undefined'){
- $p.plugins.find = function(n, sel){
- n = n === document ? n.body : n;
- return typeof n === 'string' ? $$(n) : $(n).select(sel);
- };
- }
- Element.addMethods({
- compile:function(element, directive, ctxt){ return $p(element).compile(directive, ctxt); },
- render:function(element, ctxt, directive){ return $p(element).render(ctxt, directive); },
- autoRender:function(element, ctxt, directive){ return $p(element).autoRender(ctxt, directive); }
- });
- },
- sizzle:function(){
- if(typeof document.querySelector === 'undefined'){
- $p.plugins.find = function(n, sel){
- return Sizzle(sel, n);
- };
- }
- },
- sly:function(){
- if(typeof document.querySelector === 'undefined'){
- $p.plugins.find = function(n, sel){
- return Sly(sel, n);
- };
- }
- }
-};
-
-// get lib specifics if available
-(function(){
- var libkey =
- typeof dojo !== 'undefined' && 'dojo' ||
- typeof DOMAssistant !== 'undefined' && 'domassistant' ||
- typeof jQuery !== 'undefined' && 'jquery' ||
- typeof MooTools !== 'undefined' && 'mootools' ||
- typeof Prototype !== 'undefined' && 'prototype' ||
- typeof Sizzle !== 'undefined' && 'sizzle' ||
- typeof Sly !== 'undefined' && 'sly';
-
- libkey && $p.libs[libkey]();
-})();
-
-
- Sammy = Sammy || {};
-
- // `Sammy.Pure` is a simple wrapper around the pure.js templating engine for
- // use in Sammy apps.
- //
- // See http://beebole.com/pure/ for detailed documentation.
- Sammy.Pure = function(app, method_alias) {
-
- var pure = function(template, data, directives) {
- return $(template).autoRender(data, directives);
- };
-
- // set the default method name/extension
- if (!method_alias) method_alias = 'pure';
- app.helper(method_alias, pure);
-
- };
-
-})(jQuery);
http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e93025ac/attachments/sammy/plugins/sammy.storage.js
----------------------------------------------------------------------
diff --git a/attachments/sammy/plugins/sammy.storage.js b/attachments/sammy/plugins/sammy.storage.js
deleted file mode 100644
index d97ab93..0000000
--- a/attachments/sammy/plugins/sammy.storage.js
+++ /dev/null
@@ -1,577 +0,0 @@
-(function($) {
-
- Sammy = Sammy || {};
-
- // Sammy.Store is an abstract adapter class that wraps the multitude of in
- // browser data storage into a single common set of methods for storing and
- // retreiving data. The JSON library is used (through the inclusion of the
- // Sammy.JSON) plugin, to automatically convert objects back and forth from
- // stored strings.
- //
- // Sammy.Store can be used directly, but within a Sammy.Application it is much
- // easier to use the `Sammy.Storage` plugin and its helper methods.
- //
- // Sammy.Store also supports the KVO pattern, by firing DOM/jQuery Events when
- // a key is set.
- //
- // ### Example
- //
- // // create a new store named 'mystore', tied to the #main element, using HTML5 localStorage
- // // Note: localStorage only works on browsers that support it
- // var store = new Sammy.Store({name: 'mystore', element: '#element', type: 'local'});
- // store.set('foo', 'bar');
- // store.get('foo'); //=> 'bar'
- // store.set('json', {obj: 'this is an obj'});
- // store.get('json'); //=> {obj: 'this is an obj'}
- // store.keys(); //=> ['foo','json']
- // store.clear('foo');
- // store.keys(); //=> ['json']
- // store.clearAll();
- // store.keys(); //=> []
- //
- // ### Arguments
- //
- // The constructor takes a single argument which is a Object containing these possible options.
- //
- // * `name` The name/namespace of this store. Stores are unique by name/type. (default 'store')
- // * `element` A selector for the element that the store is bound to. (default 'body')
- // * `type` The type of storage/proxy to use (default 'memory')
- //
- // Extra options are passed to the storage constructor.
- // Sammy.Store supports the following methods of storage:
- //
- // * `memory` Basic object storage
- // * `data` jQuery.data DOM Storage
- // * `cookie` Access to document.cookie. Limited to 2K
- // * `local` HTML5 DOM localStorage, browswer support is currently limited.
- // * `session` HTML5 DOM sessionStorage, browswer support is currently limited.
- //
- Sammy.Store = function(options) {
- var store = this;
- this.options = options || {};
- this.name = this.options.name || 'store';
- this.element = this.options.element || 'body';
- this.$element = $(this.element);
- if ($.isArray(this.options.type)) {
- $.each(this.options.type, function(i, type) {
- if (Sammy.Store.isAvailable(type)) {
- store.type = type;
- return false;
- }
- });
- } else {
- this.type = this.options.type || 'memory';
- }
- this.meta_key = this.options.meta_key || '__keys__';
- this.storage = new Sammy.Store[Sammy.Store.stores[this.type]](this.name, this.element, this.options);
- };
-
- Sammy.Store.stores = {
- 'memory': 'Memory',
- 'data': 'Data',
- 'local': 'LocalStorage',
- 'session': 'SessionStorage',
- 'cookie': 'Cookie'
- };
-
- $.extend(Sammy.Store.prototype, {
- // Checks for the availability of the current storage type in the current browser/config.
- isAvailable: function() {
- if ($.isFunction(this.storage.isAvailable)) {
- return this.storage.isAvailable();
- } else {
- true;
- }
- },
- // Checks for the existance of `key` in the current store. Returns a boolean.
- exists: function(key) {
- return this.storage.exists(key);
- },
- // Sets the value of `key` with `value`. If `value` is an
- // object, it is turned to and stored as a string with `JSON.stringify`.
- // It also tries to conform to the KVO pattern triggering jQuery events on the
- // element that the store is bound to.
- //
- // ### Example
- //
- // var store = new Sammy.Store({name: 'kvo'});
- // $('body').bind('set-kvo-foo', function(e, data) {
- // Sammy.log(data.key + ' changed to ' + data.value);
- // });
- // store.set('foo', 'bar'); // logged: foo changed to bar
- //
- set: function(key, value) {
- var string_value = (typeof value == 'string') ? value : JSON.stringify(value);
- key = key.toString();
- this.storage.set(key, string_value);
- if (key != this.meta_key) {
- this._addKey(key);
- this.$element.trigger('set-' + this.name, {key: key, value: value});
- this.$element.trigger('set-' + this.name + '-' + key, {key: key, value: value});
- };
- // always return the original value
- return value;
- },
- // Returns the set value at `key`, parsing with `JSON.parse` and
- // turning into an object if possible
- get: function(key) {
- var value = this.storage.get(key);
- if (typeof value == 'undefined' || value == null || value == '') {
- return value;
- }
- try {
- return JSON.parse(value);
- } catch(e) {
- return value;
- }
- },
- // Removes the value at `key` from the current store
- clear: function(key) {
- this._removeKey(key);
- return this.storage.clear(key);
- },
- // Clears all the values for the current store.
- clearAll: function() {
- var self = this;
- this.each(function(key, value) {
- self.clear(key);
- });
- },
- // Returns the all the keys set for the current store as an array.
- // Internally Sammy.Store keeps this array in a 'meta_key' for easy access.
- keys: function() {
- return this.get(this.meta_key) || [];
- },
- // Iterates over each key value pair passing them to the `callback` function
- //
- // ### Example
- //
- // store.each(function(key, value) {
- // Sammy.log('key', key, 'value', value);
- // });
- //
- each: function(callback) {
- var i = 0,
- keys = this.keys(),
- returned;
-
- for (i; i < keys.length; i++) {
- returned = callback(keys[i], this.get(keys[i]));
- if (returned === false) { return false; }
- };
- },
- // Filters the store by a filter function that takes a key value.
- // Returns an array of arrays where the first element of each array
- // is the key and the second is the value of that key.
- //
- // ### Example
- //
- // var store = new Sammy.Store;
- // store.set('one', 'two');
- // store.set('two', 'three');
- // store.set('1', 'two');
- // var returned = store.filter(function(key, value) {
- // // only return
- // return value === 'two';
- // });
- // // returned => [['one', 'two'], ['1', 'two']];
- //
- filter: function(callback) {
- var found = [];
- this.each(function(key, value) {
- if (callback(key, value)) {
- found.push([key, value]);
- }
- return true;
- });
- return found;
- },
- // Works exactly like filter except only returns the first matching key
- // value pair instead of all of them
- first: function(callback) {
- var found = false;
- this.each(function(key, value) {
- if (callback(key, value)) {
- found = [key, value];
- return false;
- }
- });
- return found;
- },
- // Returns the value at `key` if set, otherwise, runs the callback
- // and sets the value to the value returned in the callback.
- //
- // ### Example
- //
- // var store = new Sammy.Store;
- // store.exists('foo'); //=> false
- // store.fetch('foo', function() {
- // return 'bar!';
- // }); //=> 'bar!'
- // store.get('foo') //=> 'bar!'
- // store.fetch('foo', function() {
- // return 'baz!';
- // }); //=> 'bar!
- //
- fetch: function(key, callback) {
- if (!this.exists(key)) {
- return this.set(key, callback.apply(this));
- } else {
- return this.get(key);
- }
- },
- // loads the response of a request to `path` into `key`.
- //
- // ### Example
- //
- // In /mytemplate.tpl:
- //
- // My Template
- //
- // In app.js:
- //
- // var store = new Sammy.Store;
- // store.load('mytemplate', '/mytemplate.tpl', function() {
- // s.get('mytemplate') //=> My Template
- // });
- //
- load: function(key, path, callback) {
- var s = this;
- $.get(path, function(response) {
- s.set(key, response);
- if (callback) { callback.apply(this, [response]); }
- });
- },
-
- _addKey: function(key) {
- var keys = this.keys();
- if ($.inArray(key, keys) == -1) { keys.push(key); }
- this.set(this.meta_key, keys);
- },
- _removeKey: function(key) {
- var keys = this.keys();
- var index = $.inArray(key, keys);
- if (index != -1) { keys.splice(index, 1); }
- this.set(this.meta_key, keys);
- }
- });
-
- // Tests if the type of storage is available/works in the current browser/config.
- // Especially useful for testing the availability of the awesome, but not widely
- // supported HTML5 DOM storage
- Sammy.Store.isAvailable = function(type) {
- try {
- return Sammy.Store[Sammy.Store.stores[type]].prototype.isAvailable();
- } catch(e) {
- return false;
- }
- };
-
- // Memory ('memory') is the basic/default store. It stores data in a global
- // JS object. Data is lost on refresh.
- Sammy.Store.Memory = function(name, element) {
- this.name = name;
- this.element = element;
- this.namespace = [this.element, this.name].join('.');
- Sammy.Store.Memory.store = Sammy.Store.Memory.store || {};
- Sammy.Store.Memory.store[this.namespace] = Sammy.Store.Memory.store[this.namespace] || {};
- this.store = Sammy.Store.Memory.store[this.namespace];
- };
- $.extend(Sammy.Store.Memory.prototype, {
- isAvailable: function() { return true; },
- exists: function(key) {
- return (typeof this.store[key] != "undefined");
- },
- set: function(key, value) {
- return this.store[key] = value;
- },
- get: function(key) {
- return this.store[key];
- },
- clear: function(key) {
- delete this.store[key];
- }
- });
-
- // Data ('data') stores objects using the jQuery.data() methods. This has the advantadge
- // of scoping the data to the specific element. Like the 'memory' store its data
- // will only last for the length of the current request (data is lost on refresh/etc).
- Sammy.Store.Data = function(name, element) {
- this.name = name;
- this.element = element;
- this.$element = $(element);
- };
- $.extend(Sammy.Store.Data.prototype, {
- isAvailable: function() { return true; },
- exists: function(key) {
- return (typeof this.$element.data(this._key(key)) != "undefined");
- },
- set: function(key, value) {
- return this.$element.data(this._key(key), value);
- },
- get: function(key) {
- return this.$element.data(this._key(key));
- },
- clear: function(key) {
- this.$element.removeData(this._key(key));
- },
- _key: function(key) {
- return ['store', this.name, key].join('.');
- }
- });
-
- // LocalStorage ('local') makes use of HTML5 DOM Storage, and the window.localStorage
- // object. The great advantage of this method is that data will persist beyond
- // the current request. It can be considered a pretty awesome replacement for
- // cookies accessed via JS. The great disadvantage, though, is its only available
- // on the latest and greatest browsers.
- //
- // For more info on DOM Storage:
- // [https://developer.mozilla.org/en/DOM/Storage]
- // [http://www.w3.org/TR/2009/WD-webstorage-20091222/]
- //
- Sammy.Store.LocalStorage = function(name, element) {
- this.name = name;
- this.element = element;
- };
- $.extend(Sammy.Store.LocalStorage.prototype, {
- isAvailable: function() {
- return ('localStorage' in window) && (window.location.protocol != 'file:');
- },
- exists: function(key) {
- return (this.get(key) != null);
- },
- set: function(key, value) {
- return window.localStorage.setItem(this._key(key), value);
- },
- get: function(key) {
- return window.localStorage.getItem(this._key(key));
- },
- clear: function(key) {
- window.localStorage.removeItem(this._key(key));;
- },
- _key: function(key) {
- return ['store', this.element, this.name, key].join('.');
- }
- });
-
- // .SessionStorage ('session') is similar to LocalStorage (part of the same API)
- // and shares similar browser support/availability. The difference is that
- // SessionStorage is only persistant through the current 'session' which is defined
- // as the length that the current window is open. This means that data will survive
- // refreshes but not close/open or multiple windows/tabs. For more info, check out
- // the `LocalStorage` documentation and links.
- Sammy.Store.SessionStorage = function(name, element) {
- this.name = name;
- this.element = element;
- };
- $.extend(Sammy.Store.SessionStorage.prototype, {
- isAvailable: function() {
- return ('sessionStorage' in window) &&
- (window.location.protocol != 'file:') &&
- ($.isFunction(window.sessionStorage.setItem));
- },
- exists: function(key) {
- return (this.get(key) != null);
- },
- set: function(key, value) {
- return window.sessionStorage.setItem(this._key(key), value);
- },
- get: function(key) {
- var value = window.sessionStorage.getItem(this._key(key));
- if (value && typeof value.value != "undefined") { value = value.value }
- return value;
- },
- clear: function(key) {
- window.sessionStorage.removeItem(this._key(key));;
- },
- _key: function(key) {
- return ['store', this.element, this.name, key].join('.');
- }
- });
-
- // .Cookie ('cookie') storage uses browser cookies to store data. JavaScript
- // has access to a single document.cookie variable, which is limited to 2Kb in
- // size. Cookies are also considered 'unsecure' as the data can be read easily
- // by other sites/JS. Cookies do have the advantage, though, of being widely
- // supported and persistent through refresh and close/open. Where available,
- // HTML5 DOM Storage like LocalStorage and SessionStorage should be used.
- //
- // .Cookie can also take additional options:
- //
- // * `expires_in` Number of seconds to keep the cookie alive (default 2 weeks).
- // * `path` The path to activate the current cookie for (default '/').
- //
- // For more information about document.cookie, check out the pre-eminint article
- // by ppk: [http://www.quirksmode.org/js/cookies.html]
- //
- Sammy.Store.Cookie = function(name, element, options) {
- this.name = name;
- this.element = element;
- this.options = options || {};
- this.path = this.options.path || '/';
- // set the expires in seconds or default 14 days
- this.expires_in = this.options.expires_in || (14 * 24 * 60 * 60);
- };
- $.extend(Sammy.Store.Cookie.prototype, {
- isAvailable: function() {
- return ('cookie' in document) && (window.location.protocol != 'file:');
- },
- exists: function(key) {
- return (this.get(key) != null);
- },
- set: function(key, value) {
- return this._setCookie(key, value);
- },
- get: function(key) {
- return this._getCookie(key);
- },
- clear: function(key) {
- this._setCookie(key, "", -1);
- },
- _key: function(key) {
- return ['store', this.element, this.name, key].join('.');
- },
- _getCookie: function(key) {
- var escaped = this._key(key).replace(/(\.|\*|\(|\)|\[|\])/g, '\\$1');
- var match = document.cookie.match("(^|;\\s)" + escaped + "=([^;]*)(;|$)")
- return (match ? match[2] : null);
- },
- _setCookie: function(key, value, expires) {
- if (!expires) { expires = (this.expires_in * 1000) }
- var date = new Date();
- date.setTime(date.getTime() + expires);
- var set_cookie = [
- this._key(key), "=", value,
- "; expires=", date.toGMTString(),
- "; path=", this.path
- ].join('');
- document.cookie = set_cookie;
- }
- });
-
- // Sammy.Storage is a plugin that provides shortcuts for creating and using
- // Sammy.Store objects. Once included it provides the `store()` app level
- // and helper methods. Depends on Sammy.JSON (or json2.js).
- Sammy.Storage = function(app) {
- this.use(Sammy.JSON);
-
- this.stores = this.stores || {};
-
- // `store()` creates and looks up existing `Sammy.Store` objects
- // for the current application. The first time used for a given `'name'`
- // initializes a `Sammy.Store` and also creates a helper under the store's
- // name.
- //
- // ### Example
- //
- // var app = $.sammy(function() {
- // this.use(Sammy.Storage);
- //
- // // initializes the store on app creation.
- // this.store('mystore', {type: 'cookie'});
- //
- // this.get('#/', function() {
- // // returns the Sammy.Store object
- // this.store('mystore');
- // // sets 'foo' to 'bar' using the shortcut/helper
- // // equivilent to this.store('mystore').set('foo', 'bar');
- // this.mystore('foo', 'bar');
- // // returns 'bar'
- // // equivilent to this.store('mystore').get('foo');
- // this.mystore('foo');
- // // returns 'baz!'
- // // equivilent to:
- // // this.store('mystore').fetch('foo!', function() {
- // // return 'baz!';
- // // })
- // this.mystore('foo!', function() {
- // return 'baz!';
- // });
- //
- // this.clearMystore();
- // // equivilent to:
- // // this.store('mystore').clearAll()
- // });
- //
- // });
- //
- // ### Arguments
- //
- // * `name` The name of the store and helper. the name must be unique per application.
- // * `options` A JS object of options that can be passed to the Store constuctor on initialization.
- //
- this.store = function(name, options) {
- // if the store has not been initialized
- if (typeof this.stores[name] == 'undefined') {
- // create initialize the store
- var clear_method_name = "clear" + name.substr(0,1).toUpperCase() + name.substr(1);
- this.stores[name] = new Sammy.Store($.extend({
- name: name,
- element: this.element_selector
- }, options || {}));
- // app.name()
- this[name] = function(key, value) {
- if (typeof value == 'undefined') {
- return this.stores[name].get(key);
- } else if ($.isFunction(value)) {
- return this.stores[name].fetch(key, value);
- } else {
- return this.stores[name].set(key, value)
- }
- };
- // app.clearName();
- this[clear_method_name] = function() {
- return this.stores[name].clearAll();
- }
- // context.name()
- this.helper(name, function() {
- return this.app[name].apply(this.app, arguments);
- });
- // context.clearName();
- this.helper(clear_method_name, function() {
- return this.app[clear_method_name]();
- });
- }
- return this.stores[name];
- };
-
- this.helpers({
- store: function() {
- return this.app.store.apply(this.app, arguments);
- }
- });
- };
-
- // Sammy.Session is an additional plugin for creating a common 'session' store
- // for the given app. It is a very simple wrapper around `Sammy.Storage`
- // that provides a simple fallback mechanism for trying to provide the best
- // possible storage type for the session. This means, `LocalStorage`
- // if available, otherwise `Cookie`, otherwise `Memory`.
- // It provides the `session()` helper through `Sammy.Storage#store()`.
- //
- // See the `Sammy.Storage` plugin for full documentation.
- //
- Sammy.Session = function(app, options) {
- this.use(Sammy.Storage);
- // check for local storage, then cookie storage, then just use memory
- this.store('session', $.extend({type: ['local', 'cookie', 'memory']}, options));
- };
-
- // Sammy.Cache provides helpers for caching data within the lifecycle of a
- // Sammy app. The plugin provides two main methods on `Sammy.Application`,
- // `cache` and `clearCache`. Each app has its own cache store so that
- // you dont have to worry about collisions. As of 0.5 the original Sammy.Cache module
- // has been deprecated in favor of this one based on Sammy.Storage. The exposed
- // API is almost identical, but Sammy.Storage provides additional backends including
- // HTML5 Storage. `Sammy.Cache` will try to use these backends when available
- // (in this order) `LocalStorage`, `SessionStorage`, and `Memory`
- Sammy.Cache = function(app, options) {
- this.use(Sammy.Storage);
- // set cache_partials to true
- this.cache_partials = true;
- // check for local storage, then session storage, then just use memory
- this.store('cache', $.extend({type: ['local', 'session', 'memory']}, options));
- };
-
-})(jQuery);
http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e93025ac/attachments/sammy/plugins/sammy.template.js
----------------------------------------------------------------------
diff --git a/attachments/sammy/plugins/sammy.template.js b/attachments/sammy/plugins/sammy.template.js
deleted file mode 100644
index f24c23e..0000000
--- a/attachments/sammy/plugins/sammy.template.js
+++ /dev/null
@@ -1,117 +0,0 @@
-(function($) {
-
- // Simple JavaScript Templating
- // John Resig - http://ejohn.org/ - MIT Licensed
- // adapted from: http://ejohn.org/blog/javascript-micro-templating/
- // originally $.srender by Greg Borenstein http://ideasfordozens.com in Feb 2009
- // modified for Sammy by Aaron Quint for caching templates by name
- var srender_cache = {};
- var srender = function(name, template, data) {
- // target is an optional element; if provided, the result will be inserted into it
- // otherwise the result will simply be returned to the caller
- if (srender_cache[name]) {
- fn = srender_cache[name];
- } else {
- if (typeof template == 'undefined') {
- // was a cache check, return false
- return false;
- }
- // Generate a reusable function that will serve as a template
- // generator (and which will be cached).
- fn = srender_cache[name] = new Function("obj",
- "var p=[],print=function(){p.push.apply(p,arguments);};" +
-
- // Introduce the data as local variables using with(){}
- "with(obj){p.push(\"" +
-
- // Convert the template into pure JavaScript
- template
- .replace(/[\r\t\n]/g, " ")
- .replace(/\"/g, '\\"')
- .split("<%").join("\t")
- .replace(/((^|%>)[^\t]*)/g, "$1\r")
- .replace(/\t=(.*?)%>/g, "\",$1,\"")
- .split("\t").join("\");")
- .split("%>").join("p.push(\"")
- .split("\r").join("")
- + "\");}return p.join('');");
- }
-
- if (typeof data != 'undefined') {
- return fn(data);
- } else {
- return fn;
- }
- };
-
- Sammy = Sammy || {};
-
- // <tt>Sammy.Template</tt> is a simple plugin that provides a way to create
- // and render client side templates. The rendering code is based on John Resig's
- // quick templates and Greg Borenstien's srender plugin.
- // This is also a great template/boilerplate for Sammy plugins.
- //
- // Templates use <% %> tags to denote embedded javascript.
- //
- // ### Examples
- //
- // Here is an example template (user.template):
- //
- // <div class="user">
- // <div class="user-name"><%= user.name %></div>
- // <% if (user.photo_url) { %>
- // <div class="photo"><img src="<%= user.photo_url %>" /></div>
- // <% } %>
- // </div>
- //
- // Given that is a publicly accesible file, you would render it like:
- //
- // $.sammy(function() {
- // // include the plugin
- // this.use(Sammy.Template);
- //
- // this.get('#/', function() {
- // // the template is rendered in the current context.
- // this.user = {name: 'Aaron Quint'};
- // // partial calls template() because of the file extension
- // this.partial('user.template');
- // })
- // });
- //
- // You can also pass a second argument to use() that will alias the template
- // method and therefore allow you to use a different extension for template files
- // in <tt>partial()</tt>
- //
- // // alias to 'tpl'
- // this.use(Sammy.Template, 'tpl');
- //
- // // now .tpl files will be run through srender
- // this.get('#/', function() {
- // this.partial('myfile.tpl');
- // });
- //
- Sammy.Template = function(app, method_alias) {
-
- // *Helper:* Uses simple templating to parse ERB like templates.
- //
- // ### Arguments
- //
- // * `template` A String template. '<% %>' tags are evaluated as Javascript and replaced with the elements in data.
- // * `data` An Object containing the replacement values for the template.
- // data is extended with the <tt>EventContext</tt> allowing you to call its methods within the template.
- // * `name` An optional String name to cache the template.
- //
- var template = function(template, data, name) {
- // use name for caching
- if (typeof name == 'undefined') name = template;
- return srender(name, template, $.extend({}, this, data));
- };
-
- // set the default method name/extension
- if (!method_alias) method_alias = 'template';
- // create the helper at the method alias
- app.helper(method_alias, template);
-
- };
-
-})(jQuery);
http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e93025ac/attachments/sammy/plugins/sammy.title.js
----------------------------------------------------------------------
diff --git a/attachments/sammy/plugins/sammy.title.js b/attachments/sammy/plugins/sammy.title.js
deleted file mode 100644
index 9874a1e..0000000
--- a/attachments/sammy/plugins/sammy.title.js
+++ /dev/null
@@ -1,59 +0,0 @@
-(function($) {
-
- Sammy = Sammy || {};
-
- // Sammy.Title is a very simple plugin to easily set the document's title.
- // It supplies a helper for setting the title (`title()`) within routes,
- // and an app level method for setting the global title (`setTitle()`)
- Sammy.Title = function() {
-
- // setTitle allows setting a global title or a function that modifies the
- // title for each route/page.
- //
- // ### Example
- //
- // // setting a title prefix
- // $.sammy(function() {
- //
- // this.setTitle('My App -');
- //
- // this.get('#/', function() {
- // this.title('Home'); // document's title == "My App - Home"
- // });
- // });
- //
- // // setting a title with a function
- // $.sammy(function() {
- //
- // this.setTitle(function(title) {
- // return [title, " /// My App"].join('');
- // });
- //
- // this.get('#/', function() {
- // this.title('Home'); // document's title == "Home /// My App";
- // });
- // });
- //
- this.setTitle = function(title) {
- if (!$.isFunction(title)) {
- this.title_function = function(additional_title) {
- return [title, additional_title].join(' ');
- }
- } else {
- this.title_function = title;
- }
- };
-
- // *Helper* title() sets the document title, passing it through the function
- // defined by setTitle() if set.
- this.helper('title', function() {
- var new_title = $.makeArray(arguments).join(' ');
- if (this.app.title_function) {
- new_title = this.app.title_function(new_title);
- }
- document.title = new_title;
- });
-
- };
-
-})(jQuery);