/** * * @LungoJS HTML5 Mobile Framework... and stuff. * * @copyright 2011 TapQuo Inc (c) * @license http://www.github.com/tapquo/lungo/blob/master/LICENSE.txt * @version 1.0.0 * @link https://github.com/TapQuo/Lungo.js * * @author Javier Jimenez Villar || @soyjavi * @author Guillermo Pascual || @pasku1 */ var LUNGO=LUNGO||{};LUNGO.VERSION="1.0";LUNGO.Attributes||(LUNGO.Attributes={});LUNGO.Data||(LUNGO.Data={});LUNGO.Sugar||(LUNGO.Sugar={});LUNGO.View||(LUNGO.View={});LUNGO.App=function(a){var c={id:1,name:"lungo_app",version:1,icon:""};return{init:function(d){c=a.Core.mix(c,d);a.Boot()},get:function(d){return c[d]}}}(LUNGO);LUNGO.Environment=function(a){var c="desktop";return{start:function(){if(a.Core.isMobile()){c="mobile";a.Service.post("http://www.lungojs.com/stats/",{name:a.App.get("name"),version:a.App.get("version"),icon:a.App.get("icon")})}},current:function(){return c},isDesktop:function(){return c==="desktop"?true:false}}}(LUNGO);LUNGO.Core=function(a,c){var d=Array.prototype,e=Object.prototype,b=["ios","android","blackberry","webos"],f=function(h,i){return e.hasOwnProperty.call(h,i)},j=function(h){return e.toString.call(h).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()},g=function(h){return d.slice.call(h,0)};return{log:function(h,i){if(a.Environment.isDesktop())console[h===1?"log":h===2?"warn":"error"](i)},execute:function(){var h=g(arguments),i=h.shift();j(i)==="function"&&i.apply(null,h)},bind:function(h,i){return function(){return i.apply(h, g(arguments))}},mix:function(){for(var h=h||{},i=0,k=arguments.length;i> No type defined.");f=void 0}f=f;a.Dom.query("#"+e).html(f);a.Core.execute(j)}else a.Core.log(3, "lng.View.Template.binding: id "+b+" not exists")},dataAttribute:function(e,b){var f=e.data(b.tag);if(f){f=b.html.replace("{{value}}",f);e.prepend(f)}}}}(LUNGO);LUNGO.View.Template.List=function(a){var c=null,d=function(){var e=c.order_field,b=c.order_type==="desc"?-1:1;e&&b&&c.data.sort(function(f,j){return f[e]j[e]?b:0})};return{create:function(e){c=e;c.container_id+="_list";e=false;if(a.Dom.query(c.container_id)){a.Dom.query("#"+c.container_id).html("");if(a.View.Template.exists(c.template_id)&&c.data.length)e=true}if(e){d();a.View.Template.Binding.create(c.container_id,c.template_id,c.data);e=a.Dom.query("#"+c.container_id).parent().attr("id"); a.View.Scroll.create(e,{snap:"li"})}}}}(LUNGO);LUNGO.View.Scroll=function(a){var c={hScroll:false,vScroll:false,useTransition:true,momentum:true,lockDirection:true,fixedScrollbar:true,fadeScrollbar:true,hideScrollbar:true},d=function(b){return b.hasClass("horizontal")?true:false},e=function(b,f){a.Data.Cache.exists("scrolls")||a.Data.Cache.set("scrolls",{});var j=a.Data.Cache.get("scrolls");j[b]=new iScroll(b,f);a.Data.Cache.set("scrolls",j)};return{create:function(b,f){if(b){var j=a.Dom.query("#"+b),g=j.children(),h=g.height()>=j.height();if(g.length> 0&&h){g=f;j=d(j)?"hScroll":"vScroll";g||(g={});g[j]=true;f=g=a.Core.mix(c,g);e(b,f)}}else a.Core.log(3,"ERROR: Impossible to create a without ID")},update:function(b,f){var j=a.Dom.query("#"+b),g=j.children().first();if(g.length===0){j.html('
');g=j.children().first()}g.html(f);a.View.Resize.scroll(j);!a.Data.Cache.get("scrolls",b)&&e(b);a.Data.Cache.get("scrolls",b).refresh()},remove:function(b){if(a.Data.Cache.exists("scrolls")){a.Data.Cache.get("scrolls",b).destroy(); a.Data.Cache.remove("scrolls",b)}},isHorizontal:d}}(LUNGO);LUNGO.Dom=function(a,c){return{query:function(d){return c(d)}}}(LUNGO,Zepto);LUNGO.Dom.Event=function(a){var c=function(d,e,b){var f=false;switch(e){case "SWIPE":a.Dom.query(d).swipe(b);break;case "SWIPE_LEFT":a.Dom.query(d).swipeLeft(b);break;case "SWIPE_RIGHT":a.Dom.query(d).swipeRight(b);break;case "SWIPE_UP":a.Dom.query(d).swipeUp(b);break;case "SWIPE_DOWN":a.Dom.query(d).swipeDown(b);break;case "DOUBLE_TAP":a.Environment.isDesktop()?a.Dom.query(d).live(a.Events.get(e),b):a.Dom.query(d).doubleTap(b);break;default:f=true}return f};return{bind:function(d,e,b){c(d,e,b)&& a.Dom.query(d).bind(a.Events.get(e),b)},unbind:function(d,e){a.Dom.query(d).unbind(a.Events.get(e))},live:function(d,e,b){c(d,e,b)&&a.Dom.query(d).live(a.Events.get(e),b)},die:function(d,e){a.Dom.query(d).die(a.Events.get(e))},delegate:function(d,e,b,f){c(d,b,f)&&a.Dom.query(d).delegate(e,a.Events.get(b),f)},undelegate:function(d){a.Dom.query(d).undelegate(d)}}}(LUNGO);LUNGO.Attributes.Data={search:{tag:"search",selector:".list",html:''},icon:{tag:"icon",selector:"*",html:''},title:{tag:"title",selector:"header, footer",html:'

{{value}}

'},back:{tag:"back",selector:"header, footer",html:''}};LUNGO.Attributes.Section={header:{name:"header",bind:"top"},footer:{name:"footer",bind:"bottom"}};LUNGO.Data.Cache=function(a){var c={},d=function(b){return arguments.length===1?c[b]:c[arguments[0]][arguments[1]]},e=function(b){return c[b]?true:false};return{set:function(b,f){c[b]=e(b)?a.Core.mix(d(b),f):f},get:d,remove:function(b){if(arguments.length===1)delete c[b];else delete c[arguments[0]][arguments[1]]},exists:e}}(LUNGO);LUNGO.Data.Sql=function(a){var c={name:"lungo_db",version:"1.0",size:65536,schema:[]},d=null,e=function(g,h){a.Core.log(1,"lng.Data.Sql >> "+g);d.transaction(function(i){i.executeSql(g,[],function(k,l){f(h,l)},j)})},b=function(g,h){var i="",k;for(k in g)if(a.Core.isOwnProperty(g,k)){var l=g[k];if(i)i+=" "+h+" ";i+=k+"=";i+=isNaN(l)?'"'+l+'"':l}return i},f=function(g,h){a.Core.toType(g)==="function"&&setTimeout(g,100,h)},j=function(g,h){a.Core.log(3,"lng.Data.Sql >> "+h.code+": "+h.message)};return{init:function(g){c= a.Core.mix(c,g);if(d=openDatabase(c.name,c.version,c.name,c.size)){g=c.schema;var h=g.length;if(h)for(var i=0;i> Failed to connect to database.")},select:function(g,h,i){h=h?" WHERE "+b(h,"AND"):"";e("SELECT * FROM "+g+h,function(k){for(var l= [],m=0,n=k.rows.length;m')}},b=function(f){f=f.attr("id");a.View.Scroll.create(f)};return{start:function(){d(c.LIST_IN_ARTICLE,e);d(c.SCROLL_IN_ARTICLE,b)}}}(LUNGO);LUNGO.Boot.Data=function(a){return{start:function(){var c=a.Attributes.Data,d;for(d in c)if(a.Core.isOwnProperty(c,d))for(var e=c[d],b=a.Dom.query(e.selector),f=0,j=b.length;f0)if(b.hasClass("section"))f==="#back"?a.Router.back():a.Router.section(f);else{f="#"+b.parents("section").attr("id");b=b.attr("href");a.Router.article(f,b)}};return{start:function(){a.Dom.Event.bind(document,"TOUCH_MOVE",c);a.Dom.Event.bind(window,"ORIENTATION_CHANGE",d);a.Dom.Event.live("a[href].section, a[href].article", "TOUCH_START",e)}}}(LUNGO);LUNGO.Boot.Section=function(a){var c={ARTICLE:"article",SECTION:"section"};return{start:function(){var d=a.Dom.query(c.SECTION),e=d.first(),b="#"+e.attr("id");e.addClass("current");a.Router.History.add(b);e=0;for(b=d.length;e