/** * LungoJS HTML5 Mobile Framework,... and stuff. * * @copyright 2011 TapQuo Inc (c) * @license http://www.github.com/tapquo/lungo/blob/master/LICENSE.txt * @version 1.1.1 * @link https://github.com/TapQuo/Lungo.js * * @author Javier Jimenez Villar || @soyjavi * @author Guillermo Pascual || @pasku1 */ var LUNGO=LUNGO||{};LUNGO.VERSION="1.1.1";LUNGO.Attributes||(LUNGO.Attributes={});LUNGO.Data||(LUNGO.Data={});LUNGO.Sugar||(LUNGO.Sugar={});LUNGO.View||(LUNGO.View={});LUNGO.Device||(LUNGO.Device={});LUNGO.App=function(a){var b={id:1,name:"lungo_app",version:1,icon:""};return{init:function(e){b=a.Core.mix(b,e);a.Boot()},get:function(e){return b[e]}}}(LUNGO);LUNGO.Core=function(a,b){var e=Array.prototype,d=function(g,i){return b.isOwnProperty(g,i)},c=function(g){return b.toType(g)},f=function(g){return e.slice.call(g,0)};return{log:function(g,i){a.Core.isMobile()||console[g===1?"log":g===2?"warn":"error"](i)},execute:function(){var g=f(arguments),i=g.shift();c(i)==="function"&&i.apply(null,g)},bind:function(g,i){return function(){return i.apply(g,f(arguments))}},mix:function(){for(var g=g||{},i=0,h=arguments.length;i0)c=true;else a.Core.log(3,"Lungo.Router ERROR: The target "+d+" does not exists.");return c};return{section:function(d){d=d.indexOf("#")?"#"+d:d;if(e("section"+d)){a.dom(a.Router.History.current()).removeClass(b.SHOW).addClass(b.HIDE);a.dom(d).addClass(b.SHOW);a.Router.History.add(d)}},article:function(d,c){e(d+" article"+c)&&a.View.Article.show(d,c)},back:function(){a.dom(a.Router.History.current()).removeClass(b.SHOW); a.Router.History.removeLast();a.dom(a.Router.History.current()).removeClass(b.HIDE).addClass(b.SHOW)}}}(LUNGO);LUNGO.Router.History=function(){var a=[],b=function(){return a[a.length-1]};return{add:function(e){e!==b()&&a.push(e)},current:b,removeLast:function(){a.length-=1}}}();LUNGO.View.Article=function(a){var b={ARTICLE:"article",NAVIGATION_ITEM:"a"},e={ACTIVE:"current"};return{show:function(d,c){var f=d+" "+b.NAVIGATION_ITEM;a.dom(f).removeClass(e.ACTIVE);f=a.dom(f+'[href="'+c+'"]');f.addClass(e.ACTIVE);(f=f.data("title"))&&a.dom(d+" header .title, "+d+" footer .title").text(f);a.dom(d+" "+b.ARTICLE).removeClass(e.ACTIVE);a.dom(c).addClass(e.ACTIVE)}}}(LUNGO);LUNGO.View.Resize=function(a){return{scroll:function(b){var e=b.children().first(),d=e.children().first();if(a.View.Scroll.isHorizontal(b)){d=e.children().length*d.width();e.style("width",d+"px")}else{var c=e.children().length;b=Math.floor(b.width()/d.width());d=Math.ceil(c/b)*d.height();e.style("height",d+"px")}},article:function(b,e,d,c){e=b.children(e);if(e.length>0){c=e[c]();b.children("article").style(d,c+"px")}},toolbars:function(){for(var b=".toolbar nav",e=a.dom(b),d=0,c=e.length;d> No type defined.");f=void 0}f=f;a.dom("#"+d).html(f);a.Core.execute(g)}else a.Core.log(3, "lng.View.Template.binding: id "+c+" not exists")},dataAttribute:function(d,c){var f=d.data(c.tag);if(f){f=c.html.replace("{{value}}",f);d.prepend(f)}}}}(LUNGO);LUNGO.View.Template.List=function(a){var b=null,e=function(){var d=b.order_field,c=b.order_type==="desc"?-1:1;d&&c&&b.data.sort(function(f,g){return f[d]g[d]?c:0})};return{create:function(d){b=d;b.container_id+="_list";d=false;var c=!!a.dom(b.container_id),f=a.View.Template.exists(b.template_id);if(c&&f){a.dom("#"+b.container_id).html("");c=a.Core.toType(b.data);if(c==="array"||c==="object")d=true}if(d){e();a.View.Template.Binding.create(b.container_id,b.template_id,b.data);d=a.dom("#"+ b.container_id).parent().attr("id");a.View.Scroll.create(d,{snap:"li"})}}}}(LUNGO);LUNGO.View.Scroll=function(a){var b={hScroll:false,vScroll:false,useTransition:true,momentum:true,lockDirection:true,fixedScrollbar:true,fadeScrollbar:true,hideScrollbar:true},e=function(c){return c.hasClass("horizontal")?true:false},d=function(c,f){a.Data.Cache.exists("scrolls")||a.Data.Cache.set("scrolls",{});var g=a.Data.Cache.get("scrolls");if(g[c])g[c].refresh();else g[c]=new iScroll(c,f);a.Data.Cache.set("scrolls",g)};return{create:function(c,f){if(c){var g=a.dom("#"+c);setTimeout(function(){var i= false,h=g[0];if(h.clientHeight without ID")},update:function(c,f){var g=a.dom("#"+c),i=g.children().first();if(i.length===0){g.html('
');i=g.children().first()}i.html(f);a.View.Resize.scroll(g);!a.Data.Cache.get("scrolls", c)&&d(c);a.Data.Cache.get("scrolls",c).refresh()},remove:function(c){if(a.Data.Cache.exists("scrolls")){a.Data.Cache.get("scrolls",c).destroy();a.Data.Cache.remove("scrolls",c)}},isHorizontal:e}}(LUNGO);LUNGO.View.Aside=function(a){return{toggle:function(b){a.dom(b+" article").toggleClass("aside")}}}(LUNGO);LUNGO.View.Element=function(a){var b={BUBBLE:".bubble.count"};return{count:function(e,d){var c=a.dom(e);if(c)if(d>0){var f=c.children(b.BUBBLE);if(f.length>0)f.html(d);else{f=LUNGO.Attributes.Data.Count.html.replace("{{value}}",d);c.append(f)}}else c.children(b.BUBBLE).remove()}}}(LUNGO);LUNGO.Attributes.Data={Search:{tag:"search",selector:".list",html:''},Count:{tag:"count",selector:"*",html:'{{value}}'},Search:{tag:"search",selector:"*",html:''},Icon:{tag:"icon",selector:"*",html:''},Image:{tag:"image", selector:"*",html:''},Title:{tag:"title",selector:"header, footer, article",html:'{{value}}'},Back:{tag:"back",selector:"header, footer",html:''}};LUNGO.Data.Cache=function(a){var b={},e=function(c){return arguments.length===1?b[c]:b[arguments[0]][arguments[1]]},d=function(c){return b[c]?true:false};return{set:function(c,f){b[c]=d(c)?a.Core.mix(e(c),f):f},get:e,remove:function(c){if(arguments.length===1)delete b[c];else delete b[arguments[0]][arguments[1]]},exists:d}}(LUNGO);LUNGO.Data.Sql=function(a){var b={name:"lungo_db",version:"1.0",size:65536,schema:[]},e=null,d=function(h,j){a.Core.log(1,"lng.Data.Sql >> "+h);e.transaction(function(k){k.executeSql(h,[],function(l,m){f(j,m)},i)})},c=function(h,j){var k="",l;for(l in h)if(a.Core.isOwnProperty(h,l)){var m=h[l];if(k)k+=" "+j+" ";k+=l+"=";k+=isNaN(m)?'"'+m+'"':m}return k},f=function(h,j){a.Core.toType(h)==="function"&&setTimeout(h,100,j)},g=function(h,j){var k="",l="",m;for(m in j)if(a.Core.isOwnProperty(j,m)){var n= j[m];k+=k?", "+m:m;if(l)l+=", ";l+=isNaN(n)?'"'+n+'"':n}d("INSERT INTO "+h+" ("+k+") VALUES ("+l+")")},i=function(h,j){a.Core.log(3,"lng.Data.Sql >> "+j.code+": "+j.message)};return{init:function(h){b=a.Core.mix(b,h);if(e=openDatabase(b.name,b.version,b.name,b.size)){h=b.schema;var j=h.length;if(j)for(var k=0;k> Failed to connect to database.")},select:function(h,j,k){j=j?" WHERE "+c(j,"AND"):"";d("SELECT * FROM "+h+j,function(l){for(var m=[],n=0,o=l.rows.length;n')}},c=function(g){g=g.attr("id");a.View.Scroll.create(g)},f=function(g){g.append(" ")};return{start:function(){e(b.LIST_IN_ARTICLE,d);e(b.SCROLL_IN_ARTICLE, c);e(b.CHECKBOX_IN_ARTICLE,f)}}}(LUNGO);LUNGO.Boot.Data=function(a){return{start:function(){var b=a.Attributes.Data,e;for(e in b)if(a.Core.isOwnProperty(b,e))for(var d=b[e],c=a.dom(d.selector),f=0,g=c.length;f="4."&&e.style("position","fixed")}d=0;for(c=e.length;d