diff --git a/app-build.js b/app-build.js new file mode 100644 index 0000000..c87fb0b --- /dev/null +++ b/app-build.js @@ -0,0 +1,395 @@ + +(function(){kit={};if(!window.opus){opus={};} +opus.nop=function(){};opus.nob={};opus.registry={add:opus.nop};var extraNames,empty={};for(var i in{toString:1}){extraNames=[];break;} +kit._extraNames=extraNames=extraNames||["hasOwnProperty","valueOf","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","constructor"];kit._mixin=function(target,source){var name,s,i;for(name in source){s=source[name];if(!(name in target)||(target[name]!==s&&(!(name in empty)||empty[name]!==s))){target[name]=s;}} +if(source){for(i=0;(names=extraNames[i]);i++){s=source[name];if(!(name in target)||(target[name]!==s&&(!(name in empty)||empty[name]!==s))){target[name]=s;}}} +return target;};kit.mixin=function(obj,props){if(!obj){obj={};} +for(var i=1,l=arguments.length;i2){return kit._hitchArgs.apply(kit,arguments);} +if(!method){method=scope;scope=null;} +if(kit.isString(method)){scope=scope||kit.global;if(!scope[method]){throw(['kit.hitch: scope["',method,'"] is null (scope="',scope,'")'].join(''));} +return function(){return scope[method].apply(scope,arguments||[]);};} +return!scope?method:function(){return method.apply(scope,arguments||[]);};};kit.nop=function(){};kit.delegate=function(obj,props){kit.nop.prototype=obj;var neo=new kit.nop();if(props){kit.mixin(neo,props);} +return neo;};kit.byId=function(id,doc){return(typeof id=="string")?(doc||document).getElementById(id):id;};kit.time=function(inName){kit.time.timers[inName]=new Date().getTime();kit.lastTimer=inName;};kit.time.timers={};kit.timeEnd=function(inName){var n=inName||kit.lastTimer;var dt=new Date().getTime()-kit.time.timers[n];console.log(n+": "+dt+"ms");return dt;};kit.macroize=function(inText,inMap,inPattern){var working,result=inText,pattern=inPattern||kit.macroize.pattern;var fn=function(macro,name){working=true;return inMap[name]||"";};do{prevent=0;working=false;result=result.replace(pattern,fn);}while(working&&(prevent++<100));return result;};kit.macroize.pattern=/{\$([^}]*)}/g;opus.easing={cubicIn:function(n){return Math.pow(n,3);},cubicOut:function(n){return Math.pow(n-1,3)+1;},expoOut:function(n){return(n==1)?1:(-1*Math.pow(2,-10*n)+1);},quadInOut:function(n){n=n*2;if(n<1){return Math.pow(n,2)/2;} +return-1*((--n)*(n-2)-1)/2;}};kit.fixEvent=function(e){e=e||window.event;if(e.srcElement){e.target=e.srcElement;} +return e;};kit.stopEvent=function(e){e.preventDefault();e.stopPropagation();};kit.connect=function(obj,event,context,method){var f=obj[event];obj[event]=function(){var args=kit._toArray(arguments);f.apply(obj,args);return context[method].apply(context,args);} +return{obj:obj,event:event,original:f};} +kit.disconnect=function(h){if(h&&h.obj){h.obj[h.event]=h.original;delete h.obj;delete h.original;}};kit.objectToQuery=function(map){var enc=encodeURIComponent;var pairs=[];var backstop={};for(var name in map){var value=map[name];if(value!=backstop[name]){var assign=enc(name)+"=";if(kit.isArray(value)){for(var i=0;i1?nv[1]:true;} +return args;};opus.job=function(inJobName,inJob,inWait){opus.job.stop(inJobName);opus.job._jobs[inJobName]=setTimeout(function(){opus.job.stop(inJobName);inJob();},inWait);};opus.job.stop=function(inJobName){if(opus.job._jobs[inJobName]){clearTimeout(opus.job._jobs[inJobName]);delete opus.job._jobs[inJobName];}};opus.job._jobs={};opus.path={pattern:/\$([^\/\\]*)(\/)?/g,rewrite:function(inPath){var working,result=inPath;do{working=false;result=result.replace(this.pattern,function(macro,name){working=true;var path=opus.paths[name];return path?(path.charAt(path.length-1)=="/"?path:path+"/"):"";});}while(working);return result;},getExtension:function(inPath){var n=inPath;var i=n.lastIndexOf(".");if((i>=0)&&(i>=n.lastIndexOf("/"))){return n.slice(i-n.length);} +return"";},getName:function(inPath){var n=inPath;var i=n.lastIndexOf("/")+1;if(i){n=n.slice(i-n.length);} +var i=n.lastIndexOf(".");if(i>=0){n=n.slice(0,i-n.length);} +return n;},getFolder:function(inPath){var n=inPath;var i=n.lastIndexOf("/")+1;if(i){return n.slice(0,i-n.length);} +return"";},isRelative:function(inPath){return((inPath[0]!="/")&&(inPath[0]!="$")&&(inPath.slice(0,4)!="http"));}};opus.findScript=function(inName){var l=inName.length;var scripts=document.getElementsByTagName("script");for(var i=0,s,src;(s=scripts[i]);i++){src=s.getAttribute("src");if(src&&src.slice(-l)==inName){return src.slice(0,-l);}}};opus.escapeXml=function(inXml){return inXml.replace(/&/gm,"&").replace(//gm,">").replace(/"/gm,""").replace(/'/gm,"'");};opus.isJavaEnabled=function(){return navigator.javaEnabled()&&(navigator.mimeTypes["application/x-java-applet"]!=null);};if(!opus.paths){opus.paths={};} +if(!opus.paths.opus){opus.args=opus.argify(location.search);opus.paths.opus=opus.findScript("opus-m.js");} +opus.xhr={getXMLHttpRequest:function(){try{return new XMLHttpRequest();}catch(e){} +try{return new ActiveXObject('Msxml2.XMLHTTP');}catch(e){} +try{return new ActiveXObject('Microsoft.XMLHTTP');}catch(e){} +return null;},request:function(inParams){var xhr=this.getXMLHttpRequest();var method=inParams.method||"GET";xhr.open(method,inParams.url,true);this.makeReadyStateHandler(xhr,inParams.callback);if(inParams.headers){for(var key in inParams.headers){xhr.setRequestHeader(key,inParams.headers[key]);}} +xhr.send(inParams.body||null);},makeReadyStateHandler:function(inXhr,inCallback){inXhr.onreadystatechange=function(){if(inXhr.readyState==4){inCallback&&inCallback.apply(null,[inXhr.responseText,inXhr]);}}}}; +opus.declare=function(className,props){var dd=arguments.callee;var superclass=props.isa;var mixins=props.mixins;delete props.mixins;if(mixins){kit.forEach(mixins,function(m,i){if(!m){throw(className+": mixin #"+i+" is null");} +superclass=dd._delegate(superclass,m);});} +var ctor=dd._delegate(superclass);props=props||{};ctor.extend(props);var init=props.hasOwnProperty("constructor")?props.constructor:null;kit.extend(ctor,{declaredClass:className,_constructor:init});ctor.prototype.constructor=ctor;return kit.setObject(className,ctor);};kit.mixin(opus.declare,{_delegate:function(base,mixin){var dd=opus.declare,bp=(base||0).prototype,mp=mixin?mixin.prototype:null;var ctor=dd._makeCtor();kit.mixin(ctor,{superclass:bp,mixin:mp,extend:dd._extend});if(base){ctor.prototype=kit.delegate(bp);} +kit.extend(ctor,dd._core,mp,{_constructor:null,preamble:null});ctor.prototype.constructor=ctor;ctor.prototype.declaredClass=(bp||0).declaredClass+'_'+(mp?mp.declaredClass:"Object");return ctor;},_extend:function(props){var i,fn;for(i in props){if((typeof props[i]=='function')&&!0[i]){fn=props[i];fn.nom=i;fn.ctor=this;}} +kit.extend(this,props);},_makeCtor:function(){return function(){this._construct(arguments);};},_core:{_construct:function(args){var c=args.callee,s=c.superclass,ct=s&&s.constructor,m=c.mixin,mct=m&&m.constructor,a=args,ii,fn;if(ct&&ct.apply){ct.apply(this,a);} +if(mct&&mct.apply){mct.apply(this,a);} +if((ii=c.prototype._constructor)){ii.apply(this,args);} +if(this.constructor.prototype==c.prototype&&(ct=this.postscript)){ct.apply(this,args);}},_findMixin:function(mixin){var c=this.constructor,p,m;while(c){p=c.superclass;m=c.mixin;if(m==mixin||(m instanceof mixin.constructor)){return p;} +if(m&&m._findMixin&&(m=m._findMixin(mixin))){return m;} +c=p&&p.constructor;}},_findMethod:function(name,method,ptype,has){var p=ptype,c,m,f;do{c=p.constructor;m=c.mixin;if(m&&(m=this._findMethod(name,method,m,has))){return m;} +if((f=p[name])&&(has==(f==method))){return p;} +p=c.superclass;}while(p);return!has&&(p=this._findMixin(ptype))&&this._findMethod(name,method,p,has);},inherited:function(name,args,newArgs){var a=arguments;if(typeof a[0]!="string"){newArgs=args;args=name;name=args.callee.nom;} +a=newArgs||args;var c=args.callee,p=this.constructor.prototype,fn,mp;if(this[name]!=c||p[name]==c){mp=(c.ctor||0).superclass||this._findMethod(name,c,p,true);if(!mp){throw(this.declaredClass+': inherited method "'+name+'" mismatch');} +p=this._findMethod(name,c,mp,false);} +fn=p&&p[name];if(!fn){throw(mp.declaredClass+': inherited method "'+name+'" not found');} +return fn.apply(this,a);}}}); +opus.Class=function(inName,inProperties){var ctor=opus.declare(inName,inProperties);var statics=inProperties.statics;delete inProperties.statics;kit.mixin(ctor,statics);var isa=inProperties.isa;if(isa&&isa.subclass){isa.subclass(ctor,inProperties);} +return ctor;};opus.hasProperties=function(inObject){for(var n in inObject){return true;}};opus.apply=function(inObject,inMethod,inArgs){if(inObject){if(kit.isString(inMethod)){inMethod=inObject[inMethod];} +if(inMethod){return inMethod.apply(inObject,inArgs||[]);}}};opus.difference=function(inObjectA,inObjectB){var p$={};for(var n in inObjectA){if(inObjectA[n]!=inObjectB[n]){p$[n]=inObjectA[n];}} +return p$;};opus.combine=function(inObjectA,inObjectB){var aValue,bValue;for(var name in inObjectB){bValue=inObjectB[name];if(kit.isFunction(aValue)||kit.isFunction(bValue)||!kit.isObject(bValue)){inObjectA[name]=bValue;}else{aValue=inObjectA[name];if(kit.isObject(aValue)){opus.combine(aValue,bValue);}else{inObjectA[name]=kit.clone(bValue);}}}};opus.Class("opus.Object",{published:{},setProperty:function(inName,inValue){var fn='set'+inName.charAt(0).toUpperCase()+inName.slice(1);if(this[fn]){this[fn](inValue);}},getProperty:function(inName){var fn='get'+inName.charAt(0).toUpperCase()+inName.slice(1);if(this[fn]){return this[fn]();}},propertyChanged:function(inName,inValue){},getPublishedProperties:function(){return this.constructor.getPublishedProperties();},publishProperty:function(inName,inInfo){this.published[inName]=inInfo;opus.Object.publishProperty(this,inName,inInfo);},__console:function(inMethod,inArgs){if(console.firebug){console[inMethod].apply(console,inArgs);}else{console.log.call(console,inArgs.join(" "));}},_console:function(inMethod,inArgs){this.__console(inMethod,[inArgs.callee.caller.ctor.prototype.declaredClass+"."+inArgs.callee.caller.nom+"(): "].concat(kit._toArray(inArgs)));},log:function(){this._console("log",arguments);},warn:function(){this._console("warn",arguments);},error:function(){this._console("error",arguments);}});kit.mixin(opus.Object,{_makeSetter:function(inName,icf,ocf){return function(inValue){this[inName]=inValue;if(this[icf]){this[icf](inName,inValue);} +if(this[ocf]){this[ocf](inName,this[inName]);} +this.propertyChanged(inName,this[inName]);};},_makeGetter:function(inName){return function(){return this[inName];};},_makeHandler:function(inName){return function(){if(this.dispatch){var cbn=this[inName];if(cbn){return this.dispatch(cbn,arguments);}}};},publishProperty:function(inObject,inName,inInfo){if(kit.isString(inInfo)||(typeof inInfo=="number")||(typeof inInfo=="boolean")){inInfo={value:inInfo};} +var o=inObject;if(inInfo.event){var h=this._makeHandler(inName);h.nom=inInfo.event;o[inInfo.event]=h;}{var cap=inName.charAt(0).toUpperCase()+inName.slice(1);var ocf=inName+"Changed";var icf=inInfo.onchange;var fn="set"+cap;if(!o[fn]||o[fn].auto){o[fn]=this._makeSetter(inName,icf,ocf);o[fn].auto=true;} +fn="get"+cap;if(!o[fn]){o[fn]=this._makeGetter(inName);} +if("value"in inInfo){o[inName]=inInfo.value;}} +return inInfo;},publishProperties:function(inCtor,inProperties){for(var n in inProperties){inProperties[n]=this.publishProperty(inCtor.prototype,n,inProperties[n]);}},statics:{subclass:function(inCtor,inProperties){kit.mixin(inCtor,opus.Object.statics);opus.Object.publishProperties(inCtor,inProperties.published||inProperties.publish);},getPublishedProperties:function(){var published={},p=this.prototype;var stack=[];while(p){if(p.published){stack.push(p.published);} +p=p.constructor.superclass;} +while(stack.length){opus.combine(published,stack.pop());} +return published;}}});kit.mixin(opus.Object,opus.Object.statics); +opus.$={};opus.findConstructorForType=function(inTypeName){var type=inTypeName||"Component";return kit.getObject("opus."+type)||kit.getObject(type);};opus._notifiedMissing={};opus.createComponent=function(inComponentProps){var ctor=opus.findConstructorForType(inComponentProps.type);if(!ctor){if(!opus._notifiedMissing[inComponentProps.type]){opus._notifiedMissing[inComponentProps.type]=true;console.log('opus.createComponent: "'+inComponentProps.type+'" not found.');} +ctor=opus.Control;} +return new ctor(inComponentProps);};opus.Class("opus.Updateable",{beginUpdate:function(){this._updating=true;},isUpdating:function(){return this._updating;},endUpdate:function(){this._updating=false;}});opus.Class("opus.Component",{isa:opus.Object,mixins:[opus.Updateable],toString:function(){return(this.name||"(anon)")+": "+this.type;},published:{name:{value:"",group:"Common"}},owner:null,components:null,constructor:function(inConfiguration){this.$={};},postscript:function(inConfig){this.importProperties(inConfig||opus.nob);this.create();this.postCreate();},importProperties:function(inConfig){if(inConfig){for(var n in inConfig){this[n]=inConfig[n];}} +if(!this.type){this.type=this.declaredClass.replace(/opus\./g,'');}},create:function(){this.createComponents(this.components,{owner:this});this.components=this.$;},postCreate:function(){this.ownerChanged();if(!this.owner||this.owner.readied){this.ready();}},ready:function(){if(!this.name){this.nameComponent(this);} +this.generateGlobalId();this.registerGlobalId();for(var n in this.$){this.$[n].ready();} +this.readied=true;},destructor:function(){opus.destroying=true;this.unregisterGlobalId();this.destructComponents();if(this.owner){this.owner.removeComponent(this);} +this.destroyed=true;opus.destroying=false;},destructComponents:function(){do{var n=null;for(n in this.$){this.$[n].destructor();break;}}while(n);this.components=this.$={};},destroy:function(){this.markForDestroy();this.destructor();this.notifyUpdate("destroy");},destroyComponents:function(){this.markForDestroy();this.destructComponents();this.unMarkForDestroy();},markForDestroy:function(){if(!this._destroying){this._destroying=true;this.markComponentsForDestroy();}},markComponentsForDestroy:function(){for(var n in this.$){this.$[n].markForDestroy();}},unMarkForDestroy:function(){this._destroying=false;}});opus.Component.extend({ownerChanged:function(){if(this.owner){this.owner.addComponent(this);}},setName:function(inName){if(this.owner&&!this.owner.renameComponent(this,inName)){return;} +this.name=inName;this.nameChanged(inName);},nameChanged:function(){this.notifyUpdate("nameChanged");},findDispatchTarget:function(inName){if(this.owner[inName]){return this.owner;}else return this.owner.dispatchProxy||this.owner;},dispatch:function(inName,inArguments){var target=this.findDispatchTarget(inName);if(target){var fn=target[inName];if(fn){return fn.apply(target,[this].concat(kit._toArray(inArguments)));}}},addComponent:function(inComponent){if(!inComponent.name){this.nameComponent(inComponent);} +this.$[inComponent.name]=inComponent;},removeComponent:function(inComponent){delete this.$[inComponent.name];},renameComponent:function(inComponent,inName){if(this.$[inName]){return false;} +delete this.$[inComponent.name];this.$[inName]=inComponent;return true;},nameComponent:function(inComponent){var prefix=(inComponent.type||"notype").split(".").pop();prefix=prefix.charAt(0).toLowerCase()+prefix.slice(1);this._componentNameMap=this._componentNameMap||{};var i=this._componentNameMap[prefix]||1;for(var name;Boolean(this.$[name=prefix+String(i)]);i++){} +this._componentNameMap[prefix]=Number(i)+1;inComponent.name=name;},getRootComponent:function(){return this.owner?this.owner.getRootComponent():this;},findComponent:function(inName){var c=this.$[inName];return(c||!this.owner)?c:this.owner.findComponent(inName);},findProperty:function(inName){var p=this[inName];return(p||!this.owner)?p:this.owner.findProperty(inName);},rewritePath:function(inPath){return opus.path.rewrite(inPath);},isDesigning:function(){return false;}});opus.Component.extend({generateGlobalId:function(){this.globalId=!this.owner?"":((this.owner.globalId?this.owner.globalId+"-":"")+this.name);},registerGlobalId:function(){if(this.globalId&&!this.noEvents){opus.$[this.globalId]=this;}},unregisterGlobalId:function(){if(this.globalId){delete opus.$[this.globalId];}}});opus.Component.extend({adjustSubcomponentProps:function(inProps){if(!inProps.type){inProps.type=this.defaultType;} +inProps.owner=inProps.owner||this.childOwner||this.owner||this;},installComponent:function(inComponent,inChildProps){},createComponent:function(inConfiguration,inDefault){var props={};if(inDefault){props=kit.mixin(props,inDefault);} +kit.mixin(props,inConfiguration);this.adjustSubcomponentProps(props);return opus.createComponent(props);},createComponents:function(inComponents,inChildProps){for(var i=0,c;inComponents&&(c=inComponents[i]);i++){if(c instanceof opus.Component){this.installComponent(c,inChildProps);}else{this.createComponent(c,inChildProps);}}},notifyUpdate:function(inUpdateInfo){if(this.owner&&this.readied&&(!this._destroying||this.destroyed)){this.owner.componentUpdated(this,inUpdateInfo);}},componentUpdated:function(inComponent,inUpdateInfo){}});opus.Component.extend({exportProperties:function(){var props={},v,p,p$=this.getPublishedProperties();for(var n in p$){p=p$[n];if(!p.noExport){v=this.getProperty(n);if(v!==this.constructor.prototype[n]){props[n]=v;}}} +props.type=this.type||this.declaredClass.split(".").pop();return props;},exportComponents:function(inRoot){var comps=[],c;if(this==inRoot){for(var i in this.$){c=this.$[i];if(this.shouldExportComponent(c,inRoot)){comps.push(c.exportComponent(inRoot));}}} +return comps;},shouldExportComponent:function(inComponent,inRoot){return(inComponent.owner==inRoot)&&(!(inComponent instanceof opus.Control))&&!inComponent.noExport;},exportComponent:function(inRoot){var props=this.exportProperties();var comps=this.exportComponents(inRoot||this);if(comps.length){props.components=comps;} +return props;},write:function(inRoot){return this.exportComponent(inRoot);},serialize:function(inRoot){return dojo.toJson(this.write(inRoot),true);}}); +opus.Class("opus.DomNode",{node:null,_append:function(){if(this.node){var pn=this.parentNode&&kit.byId(this.parentNode);if(pn){pn.appendChild(this.node);}}},_remove:function(){if(this.node&&this.node.parentNode){this.node.parentNode.removeChild(this.node);}},setNode:function(inNode){var n=kit.byId(inNode);if(n!=this.node){this._remove();this.node=n;this._append();}},setParentNode:function(inParentNode){if(!inParentNode){this._remove();} +this.parentNode=inParentNode;this._append();},addChildNode:function(inNode){this.node.appendChild(inNode);},insertNodeAt:function(inNode,inAt){var sib=this.node.childNodes[inAt];this.node.insertBefore(inNode,sib);},show:function(){this.node.style.display="";},hide:function(){this.node.style.display="none";},attributesToNode:function(inAttributes){for(var n in inAttributes){var v=inAttributes[n];if(n=="className"){n="class";} +if(v===null){this.node.removeAttribute(n);}else{this.node.setAttribute(n,v);}}},stylesToNode:function(inStyles){this.node.style.cssText=opus.stylesToHtml(inStyles);},boxToNode:function(inBox){var s=this.node.style,u="px";if(("w"in inBox)&&inBox.w>=0){s.width=inBox.w+u;} +if(("h"in inBox)&&inBox.h>=0){s.height=inBox.h+u;} +if(inBox.l!==undefined){s.left=inBox.l+u;} +if(inBox.t!==undefined){s.top=inBox.t+u;}}});opus.Class("opus.AbstractDomNodeBuilder",{isa:opus.DomNode,content:"",nodeTag:"div",getContent:function(){return this.content;},getDomStyles:function(){},getDomAttributes:function(){},generateHtml:function(){var c=this.getContent();var h='<' ++this.nodeTag ++opus.attributesToHtml(this.getDomAttributes()) ++' style="'+opus.stylesToHtml(this.getDomStyles())+'"';if(this.nodeTag=="img"){h+='/>';}else{h+='>' ++c ++'';} +return h;},renderDomAttributes:function(){this.attributesToNode(this.getDomAttributes());},renderDomStyles:function(){this.stylesToNode(this.getDomStyles());},renderDomContent:function(){this.node.innerHTML=this.getContent();},renderDom:function(){this.renderDomAttributes();this.renderDomStyles();this.renderDomContent();},renderNode:function(){this.setNode(document.createElement(this.nodeTag));this.renderDom();},render:function(){if(this.node){this.renderDom();}else{this.renderNode();}}});opus.Class("opus.DomNodeBuilder",{isa:opus.AbstractDomNodeBuilder,constructor:function(){this.domStyles={};this.domAttributes={};},getDomStyles:function(){return this.domStyles;},getDomAttributes:function(){return this.domAttributes;}});opus.stylesToHtml=function(inStyles){var n,v,h='';for(n in inStyles){v=inStyles[n];if(v!==null&&v!==undefined&&v!==""){if(kit.isIE&&n=='opacity'){if(v>=0.99){continue;} +n='filter';v="progid:DXImageTransform.Microsoft.Alpha(opacity="+Math.floor(v*100)+")";} +h+=n+':'+v+';';}} +return h;};opus.attributesToHtml=function(inAttributes){var n,v,h='';for(n in inAttributes){v=inAttributes[n];if(n=="className"){n="class";} +if(v!==null){h+=' '+n+'="'+v+'"';}} +return h;}; +opus.Class("opus.Style",{defaultStyles:{padding:"",margin:"",border:"",bold:false,italic:false,underline:false,position:"absolute"},nullClient:{styleChanged:function(){}},constructor:function(inClient){this.styles=kit.clone(this.defaultStyles);this.runtimeStyles={};this.client=inClient||this.nullClient;},getComputedStyle:function(){var cs=kit.mixin({},this.styles);kit.mixin(cs,this.runtimeStyles);return cs;},_combineStyles:function(inStyles,inNew){for(var n in inNew){var v=inNew[n];if(v===null){delete inStyles[n];}else{inStyles[n]=v;}}},_addStyles:function(inStyles){this._combineStyles(this.styles,inStyles);},addStyles:function(inStyles){this._addStyles(inStyles);this.stylesChanged();},_addRuntimeStyles:function(inStyles){this._combineStyles(this.runtimeStyles,inStyles);},addRuntimeStyles:function(inStyles){this._addRuntimeStyles(inStyles);this.stylesChanged();},stylesChanged:function(){this.client.styleChanged();},exportProperties:function(){return opus.difference(this.styles,this.defaultStyles);}}); +opus.Box={add:function(ioBoxA,inBoxB){ioBoxA.l+=("l"in inBoxB)?inBoxB.l:0;ioBoxA.t+=("t"in inBoxB)?inBoxB.t:0;ioBoxA.w+=("w"in inBoxB)?inBoxB.w:0;ioBoxA.h+=("h"in inBoxB)?inBoxB.h:0;return ioBoxA;},grow:function(inBox,inAmount){return{l:inBox.l-inAmount,t:inBox.t-inAmount,w:inBox.w+inAmount+inAmount,h:inBox.h+inAmount+inAmount};},inside:function(inX,inY,inBox,inMargin){var m=inMargin||0;return(inX>inBox.l+m&&inXinBox.t+m&&inY=0&&this.w!=inW){this.w=inW;this.boundsDirty=this.sizeDirty=true;} +if(inH>=0&&this.h!=inH){this.h=inH;this.boundsDirty=this.sizeDirty=true;} +this.b=this.t+this.h;this.r=this.l+this.w;this.boundsChanged();},setBounds:function(inL,inT,inW,inH){if(arguments.length==1){this.doSetBounds(inL.l,inL.t,inL.w,inL.h);}else{this.doSetBounds(inL,inT,inW,inH);}},getBounds:function(){return{l:this.l,t:this.t,w:this.w,h:this.h,r:this.r,b:this.b};}});opus.Class("opus.StyledBounds",{isa:opus.Bounds,constructor:function(){this.paddingExtents={l:0,t:0,r:0,b:0};this.borderExtents={l:0,t:0,r:0,b:0};this.marginExtents={l:0,t:0,r:0,b:0};this.superMarginExtents={l:0,t:0,r:0,b:0};this.nonClientExtents={w:0,h:0};this.scrollbarExtents={w:0,h:0};},_sides:{Left:"l",Top:"t",Right:"r",Bottom:"b"},setExtents:function(inStyle,inName){var v=Number(inStyle[inName]);var ex=this[inName+"Extents"]={l:v,t:v,r:v,b:v};var ss=this._sides;for(var s in ss){var ns=inName+s;if(ns in inStyle){ex[ss[s]]=inStyle[ns];}} +ex.w=ex.l+ex.r;ex.h=ex.t+ex.b;},updateMetrics:function(inStyle){this.setExtents(inStyle,"border");this.setExtents(inStyle,"padding");this.setExtents(inStyle,"margin");this._updateMetrics();},_updateMetrics:function(){var sme=this.superMarginExtents;sme.w=sme.l+sme.r;sme.h=sme.t+sme.b;var me=this.marginExtents;me.w=me.l+me.r;me.h=me.t+me.b;var pe=this.paddingExtents;var be=this.borderExtents;var nce=this.nonClientExtents;nce.w=sme.w+me.w+pe.w+be.w;nce.h=sme.h+me.h+pe.h+be.h;},getClientBounds:function(){return{l:this.paddingExtents.l,t:this.paddingExtents.t,w:this.w-this.nonClientExtents.w-this.scrollbarExtents.w,h:this.h-this.nonClientExtents.h-this.scrollbarExtents.h};},setClientSize:function(inSize){inSize.w+=this.nonClientExtents.w+this.scrollbarExtents.w;inSize.h+=this.nonClientExtents.h+this.scrollbarExtents.h;this.setBounds(inSize);},clientToMarginSize:function(inSize){inSize.w+=this.nonClientExtents.w+this.scrollbarExtents.w;inSize.h+=this.nonClientExtents.h+this.scrollbarExtents.h;return inSize;},getStrictBounds:function(){return{l:this.l,t:this.t,w:this.w-this.nonClientExtents.w,h:this.h-this.nonClientExtents.h};},getNonClientEdges:function(){var ex={};for(var i=0,n;(n=['l','t','r','b'][i]);i++){ex[n]=this.marginExtents[n]+this.borderExtents[n]+this.paddingExtents[n];} +return ex;},addDomOffset:function(ioBox){ioBox.l+=this.marginExtents.l+this.borderExtents.l;ioBox.t+=this.marginExtents.t+this.borderExtents.t;}}); +opus._importPropMap={l:"left",t:"top",r:"right",b:"bottom",w:"width",h:"height",style:"styles",vAlign:"verticalAlign",hAlign:"horizontalAlign"};opus._exportPropMap={left:"l",top:"t",right:"r",bottom:"b",width:"w",height:"h",verticalAlign:"vAlign",horizontalAlign:"hAlign"};opus.Class("opus.Control",{isa:opus.Component,mixins:[opus.AbstractDomNodeBuilder],published:{hint:{value:null,group:"Common"},showing:{value:true,group:"Common"},content:{value:"",noInspect:true,group:"Common"},textSelection:{value:"",options:["","none","text"],noInspect:true},left:{value:null,onchange:"geometryChanged",group:"Geometry"},right:{value:null,onchange:"geometryChanged",group:"Geometry"},width:{value:null,onchange:"geometryChanged",group:"Geometry"},top:{value:null,onchange:"geometryChanged",group:"Geometry"},bottom:{value:null,onchange:"geometryChanged",group:"Geometry"},height:{value:null,onchange:"geometryChanged",group:"Geometry"},plane:{value:0,onchange:"styleChanged",group:"Geometry"},horizontalAlign:{value:"",onchange:"alignmentChanged",options:["","left","center","right"],group:"Geometry"},verticalAlign:{value:"",onchange:"alignmentChanged",options:["","top","center","bottom"],group:"Geometry"},style:{noExport:true,editor:{type:"StyleEditor"}},inFlow:{value:true,noInspect:true},_struts:{noExport:true,editor:{type:"SpringStrutEditor"},group:"Resize Behavior"},_size_ops:{noExport:true,editor:{type:"SizeOperations"},group:"Sizing Tools"},onclick:{event:"clickHandler"},ondblclick:{event:"dblclickHandler"},onmouseover:{event:"mouseoverHandler"},onmouseout:{event:"mouseoutHandler"},onmousedown:{event:"mousedownHandler"},onmouseup:{event:"mouseupHandler"},oncontextmenu:{event:"contextmenuHandler"},onshowingchanged:{event:"doShowingChanged"}},defaultStyles:{borderColor:"lightblue"},constructor:function(){this.style=new opus.Style(this);this.bounds=new opus.StyledBounds(this);this._neverFlowed=true;},importProperties:function(inProps){opus.reindex(inProps,opus._importPropMap);this.style._addStyles(this.defaultStyles);this.style._addStyles(this.styles);if(inProps.styles){this.style._addStyles(inProps.styles);delete inProps.styles;} +this.styleChanged();this.inherited(arguments);},create:function(){this.inherited(arguments);},postCreate:function(){this.managerChanged();this.parseGeometry();this.inherited(arguments);},destructor:function(){var selfDestroy=!this.isAncestorDestroying();if(selfDestroy){this.setNode(null);} +var p=this.parent;this.setManager(null);if(selfDestroy&&p){p.reflow();} +this.inherited(arguments);},isAncestorDestroying:function(){return this.parent&&(this.parent._destroying||this.parent.isAncestorDestroying());},isDesigning:function(){if("_designing"in this){return this._designing;} +var d=false;var p=this.manager;if(p&&p.isDesigning()){d=true;}else{if(opus["Designer"]){while(p&&!d){d=p instanceof opus.Designer;p=p.manager;}}} +this._designing=d;return d;},show:function(){this.setShowing(true);},hide:function(){this.setShowing(false);},showingChanged:function(){this.doShowingChanged();this.styleChanged();this.reflowParent();},textSelectionChanged:function(){this.attributesChanged();this.styleChanged();}});opus.Control.extend({setManager:function(inManager){if(this.manager){this.manager.removeControl(this);} +this.manager=inManager;this.managerChanged();},managerChanged:function(){if(this.manager){this.manager.addControl(this);}},reflowParent:function(){if(!this.isUpdating()){if(this.parent){this.parent.reflow();}else{this.renderBounds();}}}});opus.Control.extend({setParent:function(inParent){if(this.parent){this.parent.removeChild(this);} +this.parent=inParent;if(this.parent){this.parent.addChild(this);}},getRootControl:function(){return this.parent?this.parent.getRootControl():this;},isDescendantOf:function(inAncestor){var p=this;while(p&&p!=inAncestor){p=p.parent;} +return inAncestor&&(p==inAncestor);},findProperty:function(inName){var p=this[inName];return p?p:this.parent?this.parent.findProperty(inName):this.owner?this.owner.findProperty(inName):null;}});opus.Control.extend({parseGeometry:function(){this._left=opus.splitUnits(this.left);this._top=opus.splitUnits(this.top);this._width=opus.splitUnits(this.width);this._height=opus.splitUnits(this.height);this._right=opus.splitUnits(this.right);this._bottom=opus.splitUnits(this.bottom);},setGeometry:function(inGeometry){this.left=inGeometry.l;this.top=inGeometry.t;this.right=inGeometry.r;this.bottom=inGeometry.b;this.width=inGeometry.w;this.height=inGeometry.h;this.geometryChanged();},geometryChanged:function(){this.parseGeometry();this.reflowParent();},alignmentChanged:function(){this.bounds.sizeDirty=true;this.reflowParent();}});opus.Control.extend({setBounds:function(){this.bounds.setBounds.apply(this.bounds,arguments);if(this.bounds.boundsDirty){this.renderBounds();}},getBounds:function(){var b=this.bounds.getBounds();if(this.node){if(isNaN(b.l)){b.l=this.node.offsetLeft;} +if(isNaN(b.t)){b.t=this.node.offsetTop;} +if(!(b.w>0)){b.w=this.node.offsetWidth;} +if(!(b.h>0)){b.h=this.node.offsetHeight;} +b.r=b.l+b.w;b.b=b.t+b.h;} +return b;},getClientBounds:function(){return this.bounds.getClientBounds();},addDomOffset:function(ioBox){this.bounds.addDomOffset(ioBox);},addScrollOffset:function(ioBox){ioBox.l-=this.node.scrollLeft;ioBox.t-=this.node.scrollTop;},calcFrameOffset:function(inAncestor,inInside){var p=this;var off={l:0,t:0};if(!this.node){return off;} +if(inInside){p.addDomOffset(off);} +while(p&&p!=inAncestor){if(!("l"in p.bounds)){if(p.node){off.l+=p.node.offsetLeft;}}else{off.l+=p.bounds.l;} +if(!("t"in p.bounds)){if(p.node){off.t+=p.node.offsetTop;}}else{off.t+=p.bounds.t;} +p=p.parent;if(p){p.addScrollOffset(off);} +if(p&&p!=inAncestor){p.addDomOffset(off);}} +return off;}});opus.Control.extend({boundsChanged:function(){},contentChanged:function(){this.renderContent();},styleChanged:function(){var s=this.style.getComputedStyle();this.bounds.updateMetrics(s);this.boundsChanged();this.renderStyles();},attributesChanged:function(){this.renderAttributes();},canRender:function(){return!this.isUpdating()&&Boolean(this.node);},renderNode:function(){if(this.parent){this.parent.doFlow();this.setParentNode(this.parent.node);} +this.inherited(arguments);this.nodeRendered();},renderDom:function(){this.renderAttributes();this.renderStyles();this.renderContent();},renderAttributes:function(){if(this.canRender()){this.renderDomAttributes();}},renderStyles:function(){if(this.canRender()){this.renderDomStyles();this.stylesRendered();}},renderContent:function(){if(this.canRender()){this.renderDomContent();this.contentRendered();}},getDomAttributes:function(){var a$={id:this.globalId,ctype:this.declaredClass,onfocus:"opus.bubble(arguments[0])",onblur:"opus.bubble(arguments[0])",onscroll:"opus.bubble(arguments[0])",title:this.hint};if(kit.isIE&&this.textSelection){a$.onSelectStart=this.textSelection=="none"?"return false;":"return true;";} +kit.mixin(a$,this.attributes);this.modifyDomAttributes(a$);return a$;},modifyDomAttributes:function(inAttributes){},_expandStyleValue:function(inValues,inName,inDefault,inUnits){var r=[],v;for(var p in{Top:1,Right:1,Bottom:1,Left:1}){v=inValues[inName+p];r.push((v===undefined?inDefault:v)+inUnits);} +return r.join(" ");},getDomStyles:function(){var s=this.style.getComputedStyle();var s$={position:s.position,"float":s.float,overflow:s.overflow||(s.clip&&"hidden"),"overflow-x":s.overflowX,"overflow-y":s.overflowY,display:this.showing?s.display:"none",opacity:s.opacity,cursor:s.cursor,"z-index":(s.zIndex||this.plane)?this.plane*100+(s.zIndex||0):null,"background-color":s.bgColor,"background-image":s.bgImage?'url('+this.rewritePath(s.bgImage)+')':null,"background-repeat":s.bgRepeat||null,"background-position":s.bgPosition||null,"border-style":s.borderStyle||"solid","color":s.textColor||s.color,"text-align":s.textAlign,"text-decoration":s.underline?"underline":"","font-weight":s.bold?"bold":"","font-style":s.italic?"italic":"","font-family":s.fontFamily,"font-size":s.fontSize,"white-space":s.oneLine?"nowrap":s.whiteSpace,"vertical-align":s.verticalAlign};this.getBoundsStyles(s$,s);s$["-moz-user-select"]=s$["-webkit-user-select"]=this.textSelection;var fn=this._expandStyleValue;s$.padding=fn(s,"padding",s.padding||0,"px");s$["border-width"]=fn(s,"border",s.border||0,"px");s$["border-color"]=fn(s,"borderColor",s.borderColor||"inherit","");s$.margin=fn(s,"margin",s.margin||0,"px");var ns$=this.modifyDomStyles(s$,s);return ns$||s$;},getBoundsStyles:function(inStyles,inComputedStyles){var b=this.bounds.getStrictBounds();kit.mixin(inStyles,{left:isNaN(b.l)?null:b.l+"px",top:isNaN(b.t)?null:b.t+"px",width:b.w>=0?b.w+"px":null,height:b.h>=0?b.h+"px":null,right:inComputedStyles.right,bottom:inComputedStyles.bottom,"line-height":inComputedStyles.oneLine&&b.h>=0?b.h+"px":null});},modifyDomStyles:function(inStyles,inComputedStyles){},renderBounds:function(){if(this.canRender()){var b=this.bounds.getStrictBounds();this.boxToNode(b);var s=this.style.getComputedStyle();if(s.position){this.node.style.position=s.position;} +if(s["float"]){this.node.style.cssFloat=this.node.style.styleFloat=s["float"];} +if(s.oneLine&&b.h>=0){this.node.style.lineHeight=b.h+"px";} +this.boundsRendered();}},boundsRendered:function(){this.bounds.boundsDirty=false;},stylesRendered:function(){this.boundsRendered();},contentRendered:function(){},nodeRendered:function(){if(this.globalId){this.setNode(this.globalId);}},getNode:function(){if(!this.node){this.setNode(this.globalId);} +return this.node;}});opus.Control.extend({exportProperties:function(){var props=this.inherited(arguments);opus.reindex(props,opus._exportPropMap);if(this.parent&&props.type==this.parent.defaultControlType){delete props.type;} +var styles=opus.difference(this.style.exportProperties(),this.defaultStyles);if(opus.hasProperties(styles)){props.styles=styles;} +return props;}}); +opus.layoutRegistry={layoutMap:{},register:function(inName,inCtor){this.layoutMap[inName]=new inCtor();},fetch:function(inName){return this.layoutMap[inName]||(this._def=(this._def||new opus.Layout()));}};opus.extentToPx=function extentToPx(inExtent,inSpan){return(!inExtent)?0:(inExtent.units!="%")?inExtent.value:inExtent.value*inSpan*0.01;};opus.pxToExtent=function pxToExtent(inPx,inSpan,inExtent){return(!inExtent||inExtent.units!="%")?Math.round(inPx):opus.round(inPx/inSpan*100)+"%";};opus.Class("opus.Layout",{isa:opus.Object,styles:{position:"static"},setup:function(inChild){inChild.style._addRuntimeStyles(this.styles);},flow:function(inC$,inB,inContainer){inContainer.flowing=true;try{this._flow(inC$,inB,inContainer);}finally{inContainer.flowing=false;}},_flow:function(inC$,inB,inContainer){for(var i=0,c,b;(c=inC$[i]);i++){b=this.geometryToBounds(c,inB,inContainer);c.bounds.setBounds(b);if(c.flow){c.flow();}}},geometryToBounds:function(c,cb,p){var b={};if(c._width){b.w=opus.extentToPx(c._width,cb.w);} +if(c._height){b.h=opus.extentToPx(c._height,cb.h);} +b.l=opus.extentToPx(c._left,cb.w)+cb.l;b.t=opus.extentToPx(c._top,cb.h)+cb.t;if(c._right){var rpx=opus.extentToPx(c._right,cb.w);if(c._left){var lpx=b.l-cb.l;if(c._width){b.l+=((cb.w-lpx-rpx)-b.w)/2;}else{b.w=cb.w-lpx-rpx;}}else{b.l=cb.w-rpx-b.w+cb.l;}} +switch(c.horizontalAlign){case'left':b.l=cb.l;break;case'right':b.l=cb.w-b.w;break;case'center':b.l=Math.max(cb.l,(cb.w-b.w)/2);break;} +if(c._bottom){var bpx=opus.extentToPx(c._bottom,cb.h);if(c._top){var tpx=b.t-cb.t;if(c._height){b.t+=((cb.h-tpx-bpx)-b.h)/2;}else{b.h=cb.h-tpx-bpx;}}else{b.t=cb.h-bpx-b.h+cb.t;}} +switch(c.verticalAlign){case'top':b.t=cb.t;break;case'bottom':b.t=cb.h-b.h;break;case'center':b.t=Math.max(cb.t,(cb.h-b.h)/2);break;} +return b;}});opus.Class("opus.layout.Relative",{isa:opus.Layout,styles:{position:"relative"},geometryToBounds:function(c,cb,p){c.top=null;var b=this.inherited(arguments);b.l-=cb.l;delete b.t;if(c.node){c.node.style.top="";} +return b;}});opus.layoutRegistry.register("relative",opus.layout.Relative);opus.Class("opus.layout.None",{isa:opus.Layout,_flow:function(inC$,inB,inContainer){for(var i=0,c;(c=inC$[i]);i++){if(c.flow){c.flow();}}}});opus.layoutRegistry.register("none",opus.layout.None);opus.Class("opus.layout.Inline",{isa:opus.layout.None,styles:{position:"static",display:"inline"}});opus.layoutRegistry.register("inline",opus.layout.Inline); +opus.Class("opus.layout.Absolute",{isa:opus.Layout,styles:{position:"absolute"},constructor:function(){this.hints=[];},_flow:function(inC$,inB,inContainer){this.maxw=0;this.inherited(arguments);},geometryToBounds:function(c,cb,p){var b=this.inherited(arguments);this.maxR=Math.max(this.maxR,b.l+b.w);return b;}});opus.layoutRegistry.register("absolute",opus.layout.Absolute); +opus.Class("opus.layout.HBox",{isa:opus.Layout,styles:{position:"absolute"},_try_flow:function(inC$,inContainer){var b={};var cb=inContainer.getClientBounds();var ex=this.calcExtents(inC$,cb,inContainer);cb.w=Math.round(ex.free*ex.elastic);var maxh=0,l=cb.l;for(var i=0,c;c=inC$[i];i++){b=this.geometryToBounds(c,cb,inContainer);b.l=l;c.bounds.setBounds(b);if(c.flow){c.flow();} +l+=c.bounds.w;maxh=Math.max(maxh,c.bounds.h);} +b.maxh=maxh;return b;},_flow:function(inC$,inB,inContainer){var c=inContainer;c.bounds.scrollbarExtents={h:c._overflowed?17:0,w:0};var b=this._try_flow(inC$,c);if(c.scroll!==false){var overflow=((c.horizontalAlign!="fit"||c.width!="auto")&&b.l>inB.w+inB.l+8)?"auto":null;if(Boolean(overflow)!=Boolean(c._overflowed)){c._overflowed=!c._overflowed;c.bounds.scrollbarExtents={h:c._overflowed?17:0,w:0};b=this._try_flow(inC$,c);} +var ox=c.style.styles.overflowX;if(!(ox==overflow)){c.style.addRuntimeStyles({overflowX:overflow});c.bounds.dirty();}} +if(c.horizontalAlign=="fit"||c.width=="auto"){c.bounds.setClientSize({w:b.l-inB.l});} +if(c.verticalAlign=="fit"||c.height=="auto"){c.bounds.setClientSize({h:b.maxh});}},calcExtents:function(inC$,inB,inContainer){var fixed=0,elastic=0;for(var i=0,c;c=inC$[i];i++){if(c._width){if(c._width.units=="%"){elastic+=c._width.value;}else{fixed+=c._width.value}}} +return{fixed:fixed,free:inB.w-fixed,elastic:(elastic>100)?100.0/elastic:1.0}},suggest:function(inHit,ioSuggest,inB,inDrag){kit.mixin(ioSuggest,{i:0,l:0,t:inB.t,h:inB.h,w:2});for(var i=0,c;c=this.dropList[i];i++){if(inHit.l<(c.bounds.l+c.bounds.w/2)){ioSuggest.i=i;ioSuggest.l=Math.max(0,c.bounds.l-1);return;} +ioSuggest.i=i+1;ioSuggest.l=c.bounds.l+c.bounds.w;}}});opus.layoutRegistry.register("hbox",opus.layout.HBox);opus.layoutRegistry.register("columns",opus.layout.HBox);opus.Class("opus.layout.VBox",{isa:opus.Layout,styles:{position:"absolute"},_try_flow:function(inC$,inContainer){var cb=inContainer.getClientBounds();var b={l:cb.l,t:cb.t};for(var i=0,c,gb;c=inC$[i];i++){if(c.height=="auto"){gb=this.geometryToBounds(c,cb,inContainer);c.bounds.setBounds({w:gb.w});if(c.flow){c.flow();}}} +var ex=this.calcExtents(inC$,cb,inContainer);cb.h=ex.free*ex.elastic;var maxw=0,t=b.t;for(var i=0,c;c=inC$[i];i++){b=this.geometryToBounds(c,cb,inContainer);b.h=b.h||0;b.t=t;c.bounds.setBounds(b);if(c.flow){c.flow();} +t+=c.bounds.h;maxw=Math.max(maxw,c.bounds.w);} +b.t=t;b.maxw=maxw;return b;},_flow:function(inC$,inB,inContainer){var c=inContainer;c.bounds.scrollbarExtents={w:c._overflowed?17:0,h:0};var b=this._try_flow(inC$,c);if(c.scroll!==false){var overflow=((c.verticalAlign!="fit"&&c.height!="auto")&&b.t>inB.h+inB.t+8)?"auto":null;if(Boolean(overflow)!=Boolean(c._overflowed)){c._overflowed=!c._overflowed;c.bounds.scrollbarExtents={w:c._overflowed?17:0,h:0};b=this._try_flow(inC$,c);} +var oy=c.style.styles.overflowY;if(!(oy==overflow)){c.style.addRuntimeStyles({overflowY:overflow});c.bounds.dirty();}} +if(c.verticalAlign=="fit"||c.height=="auto"){var h=b.t-inB.t;if(h<=0){if(c.isDesigning()){h=null;}} +c.bounds.setClientSize({h:h});} +if(c.horizontalAlign=="fit"||c.width=="auto"){c.bounds.setClientSize({w:b.maxw});} +if(c.parent&&(c.width=="auto"||c.height=="auto")&&!c.parent.flowing&&c.bounds.sizeDirty){c.bounds.sizeDirty=false;c.parent.reflow();}},calcExtents:function(inC$,inB,inContainer){var fixed=0,elastic=0;for(var i=0,c;c=inC$[i];i++){if(c.height=="auto"){fixed+=c.bounds.h;}else if(c._height){if(c._height.units=="%"){elastic+=c._height.value;}else{fixed+=c._height.value}}} +return{fixed:fixed,free:inB.h-fixed,elastic:(elastic>100)?100.0/elastic:1.0}},suggest:function(inHit,ioSuggest,inB,inDrag){kit.mixin(ioSuggest,{i:0,t:inB.t,l:inB.l,w:inB.w,h:2});for(var i=0,c;c=this.dropList[i];i++){if(inHit.t<(c.bounds.t+c.bounds.h/2)){ioSuggest.i=i;ioSuggest.t=Math.max(0,c.bounds.t-1);return;} +ioSuggest.i=i+1;ioSuggest.t=c.bounds.t+c.bounds.h;}}});opus.layoutRegistry.register("vbox",opus.layout.VBox);opus.layoutRegistry.register("rows",opus.layout.VBox); +opus.Class("opus.layout.Float",{isa:opus.layout.Relative,styles:{float:"left",position:"relative"},geometryToBounds:function(c,cb,p){var b=this.inherited(arguments);delete b.l;return b;}});opus.layoutRegistry.register("float",opus.layout.Float); +opus.Class("opus.layout.Grid",{isa:opus.Layout,styles:{},published:{layoutCellWidth:{value:100},layoutCellHeight:{value:100}},getLayoutCellWidth:function(inContainer){return inContainer.layoutCellWidth||this.layoutCellWidth;},getLayoutCellHeight:function(inContainer){return inContainer.layoutCellHeight||this.layoutCellHeight;},_flow:function(inC$,inB,inContainer){var cr=inContainer;var ex=this.calcExtents(inC$,inB,cr);cr.bounds.scrollbarExtents={w:ex.overflow?17:0,h:0};if(cr.height=="auto"){cr.bounds.setClientSize({h:ex.h});}else if(cr.scroll){if(cr.style.styles.overflowY!=ex.overflow){cr.style.addStyles({overflowY:ex.overflow});cr.bounds.boundsDirty=cr.bounds.sizeDirty=true;}} +var cb=cr.getClientBounds();var cw=this.getLayoutCellWidth(cr);var ch=this.getLayoutCellHeight(cr);var ew=0;if(cr.layoutStretchColumns||this.layoutStretchColumns){cw=cb.w/ex.columns;}else{ew=(cb.w-ex.columns*cw)/2;} +var b={t:cb.t,l:cb.l+ew,w:cw,h:ch};for(var i=0,c;c=inC$[i];i++){c.bounds.setBounds(b);if(c.flow){c.flow();} +b.l+=cw;if(i%ex.columns==ex.columns-1){b.l=cb.l+ew;b.t+=ch;}}},calcHeight:function(inC$,inContainer,inCols){var rows=Math.ceil(inC$.length/inCols);return rows*this.getLayoutCellHeight(inContainer);},calcExtents:function(inC$,inB,inContainer){var w=inB.w+inContainer.bounds.scrollbarExtents.w;var cw=this.getLayoutCellWidth(inContainer);var ch=this.getLayoutCellHeight(inContainer);var columns=Math.max(Math.floor(w/cw),1);var h=this.calcHeight(inC$,inContainer,columns);var overflow=(h>inB.h);if(overflow&&inContainer.height!="auto"){columns=Math.max(Math.floor((w-17)/cw),1);} +return{columns:columns,h:h,overflow:overflow?"auto":null};}});opus.layoutRegistry.register("grid",opus.layout.Grid); +opus.Class("opus.ContainerBase",{isa:opus.Control,defaultControlType:"Control",defaultContainerType:"Container",constructor:function(inProps){this.c$=[];},create:function(){this.inherited(arguments);this.createChrome(this.chrome);this.createControls(this.controls);},importProperties:function(inProps){opus.reindex(inProps,{layout:"layoutKind"});this.inherited(arguments);},installComponent:function(inComponent,inChildProps){this.inherited(arguments);if(inComponent instanceof opus.Control){inComponent.setManager(this);}},createChrome:function(inChrome){if(inChrome){this.createComponents(inChrome,{owner:this});}},createControls:function(inControls){if(inControls){this.createComponents(inControls);}},destructor:function(){this.destructControls();this.inherited(arguments);this.c$=null;},destructControls:function(){var c$=[].concat(this.getControls());for(var i=0,c;(c=c$[i]);i++){c.destructor();}},destroyControls:function(){this.markForDestroy();this.destructControls();this.unMarkForDestroy();this.reflow();this.renderContent();},markForDestroy:function(){if(!this._destroying){this.markControlsForDestroy();} +this.inherited(arguments);},markControlsForDestroy:function(inList){var m$=this.getControls();for(var i=0,c;(c=m$[i]);i++){c.markForDestroy();}}});opus.ContainerBase.extend({getControlParent:function(){return this.controlParent||this.$.client||this;},isContainerClient:function(){return this.owner&&this.owner.getControlParent&&(this.owner.getControlParent()==this);},addControl:function(inControl){var p=(inControl.owner==this)?this:this.getControlParent();inControl.setParent(p);},removeControl:function(inControl){inControl.setParent(null);},getControls:function(){var c$;if(this.$.client){c$=this.$.client.c$;if(!c$){console.error("Container.getControls: tried to get c$ on a non-container 'client' object (which has no controls)");c$=[];} +return c$;}else{if(!this.c$){console.error("Container.getControls: tried to get c$ on a container that has been destroyed");return[];} +c$=[];for(var i=0,c;(c=this.c$[i]);i++){if(c.owner!=this){c$.push(c);}} +return c$;}},indexOf:function(inControl){var c$=this.getControls();for(var i=0,c;(c=c$[i]);i++){if(c==inControl){return i;}} +return-1;},controlAtIndex:function(inIndex){return(this.getControls())[inIndex];}});opus.ContainerBase.extend({adjustSubcomponentProps:function(inProps){if(!inProps.type){inProps.type=inProps.controls?this.defaultContainerType:this.defaultControlType;} +if(!inProps.manager){inProps.manager=this;} +this.inherited(arguments);},addChild:function(inChild){this.c$.push(inChild);},removeChild:function(inChild){var i=this.indexOfChild(inChild);if(i>=0){this.c$.splice(i,1);return i;}},indexOfChild:function(inChild){for(var i=0,c;(c=this.c$[i]);i++){if(c==inChild){return i;}} +return-1;},moveChild:function(inChild,inBeforeIndex){var i=this.removeChild(inChild);var delta=(i>=0&&iw){h=w/ar;}else{w=h*ar;}} +this.$.image.setWidth(w);this.$.image.setHeight(h);},boundsChanged:function(){if(this.$.image&&this.$.image.node){this.adjustSize();}},altChanged:function(){this.$.image.setAlt(this.alt);},srcChanged:function(){this.image.src=this.rewritePath(this.src);if(!this.src){this.imageLoaded();}},imageLoaded:function(e){if(!this.$.image||!this.$.image.canRender()){this._loadTimeout=setTimeout(kit.hitch(this,"imageLoaded"),1);return;} +this._loadTimeout=null;this.$.image.setSrc(this.image.src);this.adjustSize();this.$.image.show();},imageError:function(e){}}); +Ares={setupStage:function(){if(!this.viewOwner){this.viewOwner=new opus.Component();}},setupSceneAssistant:function(inSceneAssistant,inName){this.setupStage();var sc=inSceneAssistant.controller;Ares.mojoSceneController=sc;if(!inSceneAssistant.view){this.setupView(inSceneAssistant,inName);} +this.installControllerGet(sc);},setupView:function(inSceneAssistant,inName){var sc=inSceneAssistant.controller;with(sc.sceneElement){if(!sc.scrollingEnabled){parentNode.style.height="100%";parentNode.parentNode.style.height="100%";} +style.height="100%";} +var n=this.fetchSceneNode(sc.sceneElement);var name=inName||n.getAttribute("kind")||sc.sceneName;this.makeViewForAssistant(name,inSceneAssistant,n);},setupDialog:function(inSceneAssistant,inDialog,inName){inSceneAssistant.controller=inDialog._mojoController.scene;inSceneAssistant.dialog=inDialog;if(!inSceneAssistant.view){var n=this.fetchDialogNode();if(n){this.makeViewForAssistant(inName,inSceneAssistant,n,{type:"Palm.Mojo.DialogView"});}}},makeViewForAssistant:function(inName,inAssistant,inNode,inProps){var props={type:"View",owner:this.viewOwner,parentNode:inNode,chrome:[{name:inName,type:inName,modelProxy:inAssistant,sceneController:inAssistant.controller,dispatchProxy:inAssistant}],layoutKind:"vbox",scroll:false,h:"100%",w:"100%"};if(inProps){props=kit.mixin(props,inProps);} +var view=opus.createComponent(props);this.attachViewToAssistant(inAssistant,view);return view;},attachViewToAssistant:function(inAssistant,inView){inAssistant.view=inView;inAssistant.doc=inAssistant.view.c$[0];inAssistant.$=inAssistant.doc.$;},installControllerGet:function(inSceneController){inSceneController._get=inSceneController.get;inSceneController.get=this._controllerGet;},_controllerGet:function(inId){var n=this._get(inId);if(n){return n;}else{var c=this.assistant.view.$[inId]||this.assistant.$[inId];if(c){return c.fetchMojoNode?c.fetchMojoNode():(c.getNode?c.getNode():c);}}},fetchSceneNode:function(inNode){var nodes=inNode.querySelectorAll(".ares");return nodes.length?nodes[0]:inNode;},fetchDialogNode:function(){var nodes=document.body.querySelectorAll("div[x-mojo-dialog] > .palm-dialog-wrapper");return nodes.length&&nodes[0];},cleanupSceneAssistant:function(inSceneAssistant){var n=inSceneAssistant.view.node;if(n){Mojo.removeAllEventListenersRecursive(n);} +inSceneAssistant.view.destroy();inSceneAssistant.view=inSceneAssistant.$=inSceneAssistant.doc=null;}}; +Palm=window["Palm"]||{};Palm.fetchTypedValue=function(inValue){if(inValue=="false"){inValue=false;}else if(inValue=="true"){inValue=true;}else if(String(Number(inValue))==String(inValue)){inValue=Number(inValue);} +return inValue;} +Palm.fetchJsonValue=function(inValue,inDefault){var v=inValue;if(kit.isString(v)){try{v=opus.json.from(v);}catch(x){console.log("Malformed JSON",x);v=null;}} +return v||inDefault;} +opus.Class("Palm.Mojo.WidgetMixin",{scroll:false,constructor:function(){this.attributes={};this.mojoAttributes={};this._mojoConnections=[];},destructor:function(){this.destroyWidget();this.inherited(arguments);},destroyWidget:function(){if(this.mwc){Mojo.Controller.WidgetController.prototype.aresCleanup.call(this.mwc);this.mwc=null;var node=this.fetchMojoNode();if(node){node._mojoController=undefined;} +kit.forEach(this._mojoConnections,kit.disconnect);this._mojoConnections=[];if(this.isDesigning()&&!this.isModelInUse()){this.deleteModel();}}},ready:function(){this.inherited(arguments);if(this.owner.mojoRendering){this.applyMojoClassAttribute();this.setupWidget(this.fetchMojoControl().globalId);}},generateHtml:function(){this.destroyWidget();return this.inherited(arguments);},fetchMojoControl:function(){return this;},applyMojoClassAttribute:function(){this.fetchMojoControl().attributes["x-mojo-element"]=this.mojoClass;},renderWidget:function(){if(this.isRendering()||this.owner.mojoRendering){return;} +this._rendering=true;if(this.mojoClass){this.createWidget();} +this._rendering=false;},setupWidget:function(inId){this.fetchSceneController().setupWidget(inId,this.mojoAttributes,this.fetchModel());},createWidget:function(){this.populateModel();var node=this.fetchMojoNode();node.setAttribute("x-mojo-element",this.mojoClass);this.setupWidget(node.id);try{this.mwc=new Mojo.Controller.WidgetController(node,this.fetchSceneController());}catch(e){console.log("Error creating widget",e);} +if(this.mwc){this.postCreateWidget();}},postCreateWidget:function(){this.mwc.cleanup=opus.nop;this.mwc.element.removeEventListener('DOMNodeRemovedFromDocument',this.mwc.cleanupHandler,false);this._mojoConnections.push(kit.connect(this.mwc,"setModel",this,"mojoModelReplaced"));this.generateModelReference();},isRendering:function(){return this._rendering;},reRenderWidget:function(){if(this.canRender()){this.destroyWidget();this.renderWidget();}},fetchSceneController:function(){return this.owner.sceneController||Ares.mojoSceneController;},fetchModelProxy:function(){return this.owner.modelProxy||Ares.mojoSceneController.assistant;},fetchMojoNode:function(){return this.getNode();},mojoModelReplaced:function(){this.generateModelReference();},generateModelReference:function(){var modelProxy=this.fetchModelProxy();modelProxy.widgetModels=modelProxy.widgetModels||{};modelProxy.widgetModels[this.name]=this.fetchModel();},populateModel:function(){var props=this.published;var model=this.fetchModel();var p,v,mp;for(var i in props){p=props[i];if(p.isModelData){mp=p.modelPropertyName?this[p.modelPropertyName]:(p.modelProperty?p.modelProperty:i);v=model[mp];if(v===undefined){this.setProperty(i,this[i]);}}}},fetchModel:function(){if(this.mwc){return this.mwc.model;}else{var modelProxy=this.fetchModelProxy();var model;if(modelProxy.fetchWidgetModel){model=modelProxy.fetchWidgetModel(this);}else if(this.modelName){model=modelProxy[this.modelName]||(modelProxy[this.modelName]={});}else{model=this.model||(this.model={});} +return model;}},isModelInUse:function(){var m=this.fetchModel();var c=this.fetchSceneController();for(var i=0,w;w=c._modelWatchers[i];i++){if(m===w.model){return true;}}},deleteModel:function(){if(this.modelName){var modelProxy=this.fetchModelProxy();delete modelProxy[this.modelName];} +this.model={};},modelNameChanged:function(){this.reRenderWidget();},fetchModelProperty:function(inProperty,inDefault){var model=this.fetchModel();var v=model&&model[inProperty];return v===undefined?inDefault||this[inProperty]:v;},modelChanged:function(){var mojoController=this.fetchSceneController();if(this.mwc&&mojoController){mojoController.modelChanged(this.fetchModel());}},modelPropertyChanged:function(inModelProperty,inValue){var model=this.fetchModel();model[inModelProperty]=arguments.length<2?this[inModelProperty]:inValue;this.modelChanged();},deleteModelProperty:function(inModelProperty){var model=this.fetchModel();delete model[inModelProperty];this.modelChanged();},mojoAttributeChanged:function(inMojoAttribute,inValue){this.mojoAttributes[inMojoAttribute]=arguments.length<2?this[inMojoAttribute]:inValue;this.reRenderWidget();},deleteMojoAttribute:function(inMojoAttribute){delete this.mojoAttributes[inMojoAttribute];this.reRenderWidget();}});opus.Class("Palm.Mojo.ControlMixin",{isa:opus.Object,published:{onclick:{noInspect:true},ondblclick:{noInspect:true},onmouseover:{noInspect:true},onmouseout:{noInspect:true},onmousedown:{noInspect:true},onmouseup:{noInspect:true},oncontextmenu:{noInspect:true},onshowingchanged:{noInspect:true},ontap:{event:Mojo.Event.tap+"Handler"},onhold:{event:Mojo.Event.hold+"Handler"},onholdEnd:{event:Mojo.Event.holdEnd+"Handler"},hint:{noInspect:true},className:""},constructor:function(){this.attributes={};},create:function(){this.inherited(arguments);this.classNameChanged();},classNameChanged:function(){if(this.className){this.attributes.className=this.className;this.attributesChanged();}}});opus.Class("Palm.Mojo.Widget",{isa:opus.Control,mixins:[Palm.Mojo.WidgetMixin,Palm.Mojo.ControlMixin],defaultStyles:{},published:{modelName:{value:"",model:true,group:"Model"},content:{noInspect:true}},nodeRendered:function(){this.inherited(arguments);this.reRenderWidget();}});Mojo.Controller.WidgetController.prototype.aresCleanup=function(){if(Number(Mojo.Version.use)<311){this._cleanupWithoutDelay();}else{Mojo.Controller.WidgetController.prototype.cleanup.call(this);}} +Mojo.Controller.WidgetController.prototype._cleanupWithoutDelay=function(){if(this.reparenting){return;} +this.scene.removeWatcher(this.assistant);if(this.assistant.remeasure||this.assistant.subtreeShown){this.stopListening(this.scene.sceneElement,Mojo.Event.subtreeShown,this._maybeSubtreeShown);} +if(this.assistant.remeasure||this.assistant.orientationChange){this.stopListening(this.scene.sceneElement,Mojo.Event.orientationChange,this._maybeOrientationChange);} +if(this.assistant.subtreeHidden){this.stopListening(this.scene.sceneElement,Mojo.Event.subtreeHidden,this._maybeSubtreeHidden);} +if(this.assistant.cleanup){this.assistant.cleanup();} +if(this.element){Mojo.removeAllEventListenersRecursive(this.element);} +delete this.element;} +opus.View.extend({create:function(){this._resizeListener=kit.hitch(this,"resize");window.addEventListener("resize",this._resizeListener,false);this.inherited(arguments);},destructor:function(){window.removeEventListener("resize",this._resizeListener,false);this.inherited(arguments);}});opus.Class("Palm.Mojo.DialogView",{isa:opus.View,minHeight:50,create:function(){this.inherited(arguments);this.setHeight("auto");},adjustSize:function(){var n=this.getSizeNode();if(n){if(n.clientWidth==0){return;} +var gcs=document.defaultView.getComputedStyle(n,null);var pw=parseFloat(gcs.paddingLeft)+parseFloat(gcs.paddingRight);this.setBounds({w:Math.max(n.clientWidth-pw,this.minWidth),h:Math.max(this.bounds.h||0,this.minHeight)});}},}); +opus.bubble=function(e){if(e){opus.dispatcher.dispatch(kit.fixEvent(e));}};opus.Class("opus.Dispatcher",{isa:opus.Object,constructor:function(){this.captures=[];this.connect();},events:["click","dblclick","contextmenu","mousedown","mouseup","mouseover","mouseout","mousemove","keypress","keyup","keydown","focus","blur","paste","change","load","error","scroll",Mojo.Event.tap,Mojo.Event.flick,Mojo.Event.keypress,Mojo.Event.hold,Mojo.Event.holdEnd,Mojo.Event.propertyChange,Mojo.Event.filter,Mojo.Event.filterImmediate,Mojo.Event.imageViewChanged,Mojo.Event.scrollStarting,Mojo.Event.progressComplete,Mojo.Event.listChange,Mojo.Event.listTap,Mojo.Event.listAdd,Mojo.Event.listDelete,Mojo.Event.listReorder,Mojo.Event.progressIconTap,Mojo.Event.progressComplete,"mousewheel","DOMMouseScroll"],connect:function(){this.connects=[];this.node=document;this.hitchedDispatch=kit.hitch(this,"dispatch");for(var i=0,n;(n=this.events[i]);i++){this.node.addEventListener(n,this.hitchedDispatch,false);} +this.node._dispatcher=true;},disconnect:function(){for(var i=0,n;(n=this.events[i]);i++){this.node.removeEventListener(n,this.hitchedDispatch,false);}},findDispatchTarget:function(inNode){var t,n=inNode;try{while(n&&!t){t=opus.$[n.id];n=n.parentNode;}}catch(x){} +return t;},dispatchBubble:function(e,c){while(c){if(this.dispatchToTarget(e,c,"")===true){return true;} +c=c.parent;} +return false;},dispatchToTarget:function(e,c,suffix){var isMouseOverOut=(e.type=="mouseover"||e.type=="mouseout");if(isMouseOverOut){if(this.shouldIgnoreMouseOverOut(e,c)){return true;} +var synth={type:"child"+e.type,dispatchTarget:e.dispatchTarget};this.dispatchBubble(synth,c.parent);} +var type=e.type;if(e.type=="DOMMouseScroll"){type="mousewheel";} +var fn=type+"Handler"+suffix;if(c[fn]&&!c.noEvents){var args=[e];if(!(c instanceof Palm.Mojo.Widget||c instanceof Palm.Mojo.WidgetContainer)){args.push(e.dispatchTarget);} +if(c[fn].apply(c,args)!==true){return false;} +return true;}},shouldIgnoreMouseOverOut:function(e,c){var rdt=this.findDispatchTarget(e.relatedTarget);return rdt&&rdt.isDescendantOf(c);},dispatch:function(e){e.cap=e.type.charAt(0).toUpperCase()+e.type.slice(1);var c=this.findDispatchTarget(e.target);e.dispatchTarget=c;var captured=false;if(this.captureTarget&&(e.type!="load")&&(e.type!="error")){if(!c||!c.isDescendantOf(this.captureTarget)){c=this.captureTarget;captured=true;}} +if(c){var handled=this.dispatchBubble(e,c);if(captured&&(e.type=="mouseout"||this.forwardEvents)){handled=this.forward(e);}}},forward:function(e){var c=e.dispatchTarget;return c&&this.dispatchBubble(e,c);},capture:function(inTarget,inShouldForward){if(this.captureTarget){this.captures.push(this.captureTarget);} +this.forwardEvents=inShouldForward;this.captureTarget=inTarget;},release:function(){this.captureTarget=this.captures.pop();}});if(opus.dispatcher){console.warn("Mojo/source/Dispatcher.js: Mojo replacement dispatcher detects an existing Dispatcher: you should not load opus-depends and Palm-Mojo packages at the same time (use opus-Ares instead of opus)");opus.dispatcher.connect=function(){};} +opus.dispatcher=new opus.Dispatcher(); +opus.Class("Palm.Mojo.Container",{isa:opus.Container,mixins:[Palm.Mojo.ControlMixin],published:{scroll:{value:false,noInspect:true}},defaultStyles:{border:"",borderColor:null},width:"100%",height:100,layoutKind:"vbox"}); +opus.Class("Palm.Mojo.Panel",{isa:Palm.Mojo.Container,published:{focusHighlight:true,layoutKind:{options:["absolute","vbox","hbox"],group:"Common",noInspect:false}},create:function(){this.inherited(arguments);this.focusHighlightChanged();},focusHighlightChanged:function(){this.attributes["x-mojo-focus-highlight"]=this.focusHighlight;this.attributesChanged();}}); +opus.Class("Palm.Mojo.WidgetContainer",{isa:Palm.Mojo.Container,mixins:[Palm.Mojo.WidgetMixin],layoutKind:"vbox",width:"100%",height:"300",published:{modelName:{value:"",model:true,group:"Model"},content:{noInspect:true}},fetchMojoControl:function(){return this.$.client;},fetchMojoNode:function(){var c=this.fetchMojoControl();return c?c.getNode():this.getNode();},contentRendered:function(){this.reRenderWidget();this.inherited(arguments);},createWidget:function(){var c=this.fetchMojoControl();if(c!=this){c.setNode(c.globalId);} +this.inherited(arguments);}}); +opus.declare("Mojo.Widget.OpusHtml",{setup:function(){this.initializeDefaultValues();this.renderWidget();this.updateDisabledState();},updateDisabledState:function(){this.disabled=this.controller.model[this.disabledProperty];var n=this.controller.element;if(this.disabled){n.removeAttribute('x-mojo-tap-highlight');n.addClassName('disabled');}else{n.setAttribute('x-mojo-tap-highlight','momentary');n.removeClassName('disabled');}},initializeDefaultValues:function(){this.disabledProperty=this.controller.attributes.disabledProperty||Mojo.Widget.defaultDisabledProperty;this.renderCallback=this.controller.attributes.renderCallback;},renderWidget:function(){var templateFile=this.controller.attributes.templateFile;this.controller.element.innerHTML=Mojo.View.render({object:this.controller.model,formatters:this.controller.attributes.formatters||{},inline:templateFile?"":this.controller.attributes.inlineTemplate||" ",template:templateFile});if(this.renderCallback){this.renderCallback();}},handleModelChanged:function(){this.renderWidget();this.updateDisabledState();}});opus.Class("Palm.Mojo.Html",{isa:Palm.Mojo.Widget,mojoClass:"OpusHtml",width:"100%",height:60,published:{onformat:{event:"doFormat"},content:{noInspect:false,editor:{editorKind:"Palm.Ares.CodePropertyEditor"}},templateFile:{value:"",onchange:"mojoAttributeChanged"}},create:function(){this.inherited(arguments);this.mojoAttributeChanged("templateFile");this.contentChanged();},createWidget:function(){this.mojoAttributes.formatters=this.doFormat();this.inherited(arguments);},fetchInlineTemplate:function(){return this.content;},updateInlineTemplate:function(){this.mojoAttributeChanged("inlineTemplate",this.fetchInlineTemplate());},contentChanged:function(){this.updateInlineTemplate();}}); +opus.Class("Palm.Mojo.Button",{isa:Palm.Mojo.Widget,published:{disabled:{value:false,isModelData:true},buttonClass:{value:"primary",group:"Common",editorKind:"Combo",editor:{editorKind:"Combo"},options:["primary","secondary","dismissal","affirmative","negative"],isModelData:true,modelProperty:"buttonClass"},label:{value:"Button",isModelData:true,modelPropertyName:"labelPropertyName"},labelPropertyName:{value:"label",model:true,group:"Model"}},width:"100%",height:60,minHeight:60,maxHeight:60,mojoClass:"Button",create:function(){this.inherited(arguments);this.labelPropertyNameChanged();},labelChanged:function(){this.modelPropertyChanged(this.labelPropertyName,this.label);},getLabel:function(){return this.fetchModelProperty(this.labelPropertyName,this.label);},labelPropertyNameChanged:function(){this.mojoAttributeChanged("labelProperty",this.labelPropertyName);},getDisabled:function(){return this.fetchModelProperty(this.disabledPropertyName,this.disabled);},disabledChanged:function(){this.modelPropertyChanged("disabled");},buttonClassChanged:function(){this.modelPropertyChanged("buttonClass",this.buttonClass);}});opus.Class("Palm.Mojo.ActivityButton",{isa:Palm.Mojo.Button,published:{active:false,disabled:{value:false,isModelData:true},buttonClass:{value:"primary",group:"Common",editorKind:"Combo",editor:{editorKind:"Combo"},options:["primary","secondary","dismissal","affirmative","negative"],isModelData:true,modelProperty:"buttonClass"},label:{value:"Button",isModelData:true,modelPropertyName:"labelPropertyName"}},create:function(){this.inherited(arguments);this.mojoAttributes.type=Mojo.Widget.activityButton;},renderWidget:function(){this.inherited(arguments);this.activeChanged();},activeChanged:function(){this.node.mojo[this.active?"activate":"deactivate"]();}}); +opus.Class("Palm.Mojo.CheckBox",{isa:Palm.Mojo.Widget,published:{value:{value:true,isModelData:true,modelPropertyName:"valuePropertyName"},valuePropertyName:{value:"value",model:true,group:"Model"},disabled:{value:false,isModelData:true,modelPropertyName:"disabledPropertyName"},disabledPropertyName:{value:"disabled",model:true,group:"Model"},trueValue:"true",falseValue:"false",onchange:{event:Mojo.Event.propertyChange+"Handler"}},defaultStyles:{margin:4},width:40,height:34,minHeight:34,maxHeight:34,mojoClass:"CheckBox",create:function(){this.inherited(arguments);this.valuePropertyNameChanged();this.disabledPropertyNameChanged();this.trueValueChanged();this.falseValueChanged();},getValue:function(){return this.fetchModelProperty(this.valuePropertyName,this.value);},getDisabled:function(){return this.fetchModelProperty(this.disabledPropertyName,this.disabled);},disabledChanged:function(){this.modelPropertyChanged(this.disabledPropertyName,this.disabled);},valueChanged:function(){this.modelPropertyChanged(this.valuePropertyName,this.value);},valuePropertyNameChanged:function(){this.mojoAttributeChanged("modelProperty",this.valuePropertyName);},disabledPropertyNameChanged:function(){this.mojoAttributeChanged("disabledProperty",this.disabledPropertyName);},trueValueChanged:function(){this.trueValue=Palm.fetchTypedValue(this.trueValue);this.mojoAttributeChanged("trueValue");},falseValueChanged:function(){this.falseValue=Palm.fetchTypedValue(this.falseValue);this.mojoAttributeChanged("falseValue");}}); +opus.Class("Palm.Mojo.DatePicker",{isa:Palm.Mojo.Widget,mojoClass:"DatePicker",width:"100%",height:60,minHeight:60,maxHeight:60,published:{date:{value:"",isModelData:true,modelPropertyName:"datePropertyName"},datePropertyName:{value:"date",model:true,group:"Model"},label:{value:"Date"},labelPlacement:{value:Mojo.Widget.labelPlacementLeft,options:[Mojo.Widget.labelPlacementLeft,Mojo.Widget.labelPlacementRight],onchange:"mojoAttributeChanged"},month:{value:true,onchange:"mojoAttributeChanged"},day:{value:true,onchange:"mojoAttributeChanged"},year:{value:true,onchange:"mojoAttributeChanged"},maxYear:{value:2099,onchange:"mojoAttributeChanged"},minYear:{value:1900,onchange:"mojoAttributeChanged"},onchange:{event:Mojo.Event.propertyChange+"Handler"}},create:function(){this.inherited(arguments);this.datePropertyNameChanged();this.labelChanged();this.mojoAttributeChanged("labelPlacement");this.mojoAttributeChanged("month");this.mojoAttributeChanged("day");this.mojoAttributeChanged("year");this.mojoAttributeChanged("maxYear");this.mojoAttributeChanged("minYear");},labelChanged:function(){this.mojoAttributeChanged("label",this.label?this.label:" ");},getDate:function(){var d=this.fetchModelProperty(this.datePropertyName,this.date);return d instanceof Date?d.toString():d;},dateChanged:function(){this.modelPropertyChanged(this.datePropertyName,this.date?new Date(this.date):new Date());},datePropertyNameChanged:function(){this.mojoAttributeChanged("modelProperty",this.datePropertyName);}}); +opus.fetchNodeHeight=function(inNode){var h=0;for(var i=0,cn=inNode.childNodes,c;c=cn[i];i++){if(c.nodeType==1){h+=c.offsetHeight;}} +return h;} +opus.Class("Palm.Mojo.List",{isa:Palm.Mojo.WidgetContainer,scroll:false,mojoClass:"List",width:"100%",height:250,preventScrollerWatch:true,published:{ontap:{noInspect:true},items:{editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true},isModelData:true,modelPropertyName:"itemsPropertyName",group:"Data"},useSampleData:{value:true,group:"Data"},itemsPropertyName:{value:"items",model:true,group:"Model"},title:{value:"",isModelData:true,modelProperty:"listTitle"},itemDesigner:{value:"Show",noExport:true,group:"Items",editor:{type:"opus.DefaultInspectorField",onValue:"Hide",offValue:"Show",editorKind:"Palm.Ares.EditorToggleButton"}},itemTemplateFile:{value:"",group:"Items"},itemHtml:{value:'
\n\t#{label}\n
',group:"Items",editor:{editorKind:"Palm.Ares.CodePropertyEditor"}},listTemplateFile:{value:""},nullItemTemplateFile:{value:""},emptyTemplateFile:{value:""},dividerTemplateFile:{value:""},onlistchange:{event:Mojo.Event.listChange+"Handler"},onlisttap:{event:Mojo.Event.listTap+"Handler"},onlistadd:{event:Mojo.Event.listAdd+"Handler"},onlistdelete:{event:Mojo.Event.listDelete+"Handler"},onlistreorder:{event:Mojo.Event.listReorder+"Handler"},onitemrendered:{event:"doItemRendered"},onfetchitems:{event:"doItemsCallback"},onformat:{event:"doFormat"},ondividerfunction:{event:"doDividerFunction"},renderLimit:20,lookAhead:15,addItemLabel:{value:"",onchange:"mojoAttributeChanged",group:"Items"},swipeToDelete:{value:true,onchange:"mojoAttributeChanged",group:"Items"},reorderable:{value:true,onchange:"mojoAttributeChanged",group:"Items"},rowTapHighlight:true,rowFocusHighlight:true,rowIsTextField:false,layoutKind:{noInspect:true}},chrome:[{name:"client",h:"100%",w:"100%",showing:false,type:"Palm.Mojo.Container",layoutKind:"vbox",scroll:false},{name:"list",h:"100%",w:"100%",type:"Palm.Mojo.Container",scroll:false}],create:function(){if(!this.isDesigning()){this.template=this.controls;this.controls=[];} +this.inherited(arguments);this.itemContent=this.createComponent({name:"itemContent",type:"Component",owner:this});},postCreate:function(){this.inherited(arguments);this.itemsPropertyNameChanged();this.useSampleDataChanged();this.onformatChanged();this.mojoAttributeChanged("addItemLabel");this.mojoAttributeChanged("swipeToDelete");this.mojoAttributeChanged("reorderable");this.renderLimitChanged();this.lookAheadChanged();this.dividerTemplateFileChanged();this.itemTemplateFileChanged();this.listTemplateFileChanged();this.nullItemTemplateFileChanged();this.emptyTemplateFileChanged();this.onfetchitemsChanged();this.ondividerfunctionChanged();this.onitemrenderedChanged();},fetchMojoControl:function(){return this.$.list;},destroyWidget:function(){this.inherited(arguments);this.itemContent.destroyComponents();this.invalidateListTemplates();},createWidget:function(){if(this.isDesigning()){this.updateTemplate();} +this.updateMojoInlineTemplate();this.inherited(arguments);},postCreateWidget:function(){var bg=this.mwc.assistant.bigItemsList;if(bg){this._mojoConnections.push(kit.connect(bg,"noticeAddedItems",this,"deferFitHeightToContent"));this._mojoConnections.push(kit.connect(bg,"noticeRemovedItems",this,"deferFitHeightToContent"));} +if(this.mwc.assistant){this._mojoConnections.push(kit.connect(this.mwc.assistant,"renderItemsBefore",this,"deferFitHeightToContent"));} +this.deferFitHeightToContent();if(!this.isNativeRendering()){this.mwc.assistant.orientationChange=kit.hitch(this,"deferOrientationChange");} +this.mwc.assistant.maybeVisible=true;},invalidateListTemplates:function(){var templates=[this.dividerTemplateFile,this.listTemplateFile,this.itemTemplateFile,this.nullItemTemplateFile,this.emptyTemplateFile];for(var i=0,c=templates.length;iinitPageSize){allModels=itemModels;itemModels=allModels.slice(0,initPageSize);itemModelsLength=itemModels.length;this.isFirstRequest=undefined;secondRunFunc=this.renderItemsBefore.bind(this,allModels.slice(initPageSize),beforeNode);} +this.log("renderItemsBefore");renderedItems=[];formattedModels=[];for(i=0;i0){this.setHeight(h);}}},updateSizeMonitoring:function(){if(this.multiline&&this.autoHeight&&!this.isDesigning()){this.startMonitoringSize();}else{this.stopMonitoringSize();}},startMonitoringSize:function(){this._sizeMonitor=setInterval(kit.hitch(this,"fitToInputSize"),250);},stopMonitoringSize:function(){clearInterval(this._sizeMonitor);},maxLengthChanged:function(){this.mojoAttributeChanged("maxLength",this.maxLength!=""?Number(this.maxLength):undefined);}}); +opus.Class("Palm.Mojo.PasswordField",{isa:Palm.Mojo.TextField,published:{value:{value:"",isModelData:true,modelPropertyName:"valuePropertyName"},disabled:{value:false,isModelData:true,modelPropertyName:"disabledPropertyName"}},mojoClass:"PasswordField"}); +opus.Class("Palm.Mojo.TimePicker",{isa:Palm.Mojo.Widget,width:"100%",height:60,minHeight:60,maxHeight:60,mojoClass:"TimePicker",published:{time:{value:"",isModelData:true,modelPropertyName:"timePropertyName"},timePropertyName:{value:"time",model:true,group:"Model"},label:{value:"Time"},labelPlacement:{value:Mojo.Widget.labelPlacementLeft,options:[Mojo.Widget.labelPlacementLeft,Mojo.Widget.labelPlacementRight],onchange:"mojoAttributeChanged"},minuteInterval:5,onchange:{event:Mojo.Event.propertyChange+"Handler"}},create:function(){this.inherited(arguments);this.timePropertyNameChanged();this.labelChanged();this.mojoAttributeChanged("labelPlacement");this.minuteIntervalChanged();},labelChanged:function(){this.mojoAttributeChanged("label",this.label?this.label:" ");},getTime:function(){var d=this.fetchModelProperty(this.timePropertyName,this.time);return d instanceof Date?d.toString():d;},timeChanged:function(){this.modelPropertyChanged(this.timePropertyName,this.makeJsDateFromTime(this.time));},timePropertyNameChanged:function(){this.mojoAttributeChanged("modelProperty",this.timePropertyName);},makeJsDateFromTime:function(inTimeString){var bad="Invalid Date";var d=new Date(inTimeString);if(d==bad){var now=new Date();d=new Date(now.toLocaleDateString()+" "+this.time);} +if(d==bad){d=new Date();} +return d;},minuteIntervalChanged:function(){this.mojoAttributeChanged("minuteInterval",Number(this.minuteInterval));}}); +opus.Class("Palm.Mojo.ToggleButton",{isa:Palm.Mojo.Widget,width:96,height:50,minHeight:50,maxHeight:50,mojoClass:"ToggleButton",published:{value:{value:false,isModelData:true,modelPropertyName:"valuePropertyName"},valuePropertyName:{value:"value",model:true,group:"Model"},disabled:{value:false,isModelData:true,modelPropertyName:"disabledPropertyName"},disabledPropertyName:{value:"disabled",model:true,group:"Model"},trueValue:"true",falseValue:"false",trueLabel:{value:"On",onchange:"mojoAttributeChanged"},falseLabel:{value:"Off",onchange:"mojoAttributeChanged"},onchange:{event:Mojo.Event.propertyChange+"Handler"}},create:function(){this.inherited(arguments);this.valuePropertyNameChanged();this.disabledPropertyNameChanged();this.trueValueChanged();this.falseValueChanged();this.mojoAttributeChanged("trueLabel");this.mojoAttributeChanged("falseLabel");},getValue:function(){return this.fetchModelProperty(this.valuePropertyName,this.value);},valueChanged:function(){this.value=Palm.fetchTypedValue(this.value);this.modelPropertyChanged(this.valuePropertyName,this.value);},valuePropertyNameChanged:function(){this.mojoAttributeChanged("modelProperty",this.valuePropertyName);},getDisabled:function(){return this.fetchModelProperty(this.disabledPropertyName,this.disabled);},disabledChanged:function(){this.modelPropertyChanged(this.disabledPropertyName,this.disabled);},disabledPropertyNameChanged:function(){this.mojoAttributeChanged("disabledProperty",this.disabledPropertyName);},trueValueChanged:function(){this.trueValue=Palm.fetchTypedValue(this.trueValue);this.mojoAttributeChanged("falseValue");},falseValueChanged:function(){this.falseValue=Palm.fetchTypedValue(this.falseValue);this.mojoAttributeChanged("falseValue");}}); +opus.Class("Palm.Mojo.IntegerPicker",{isa:Palm.Mojo.Widget,published:{value:{value:0,isModelData:true,modelPropertyName:"valuePropertyName"},valuePropertyName:{value:"value",model:true,group:"Model"},label:{value:"Integer"},labelPlacement:{value:Mojo.Widget.labelPlacementLeft,options:[Mojo.Widget.labelPlacementLeft,Mojo.Widget.labelPlacementRight],onchange:"mojoAttributeChanged"},min:{value:0},max:{value:10},padNumbers:{value:false,onchange:"mojoAttributeChanged"},onchange:{event:Mojo.Event.propertyChange+"Handler"}},mojoClass:"IntegerPicker",width:"100%",height:60,minHeight:60,maxHeight:60,create:function(){this.inherited(arguments);this.valuePropertyNameChanged();this.labelChanged();this.mojoAttributeChanged("labelPlacement");this.minChanged();this.maxChanged();this.mojoAttributeChanged("padNumbers");},labelChanged:function(){this.mojoAttributeChanged("label",this.label?this.label:" ");},getValue:function(){return this.fetchModelProperty(this.valuePropertyName,this.value);},valueChanged:function(){this.modelPropertyChanged(this.valuePropertyName,Number(this.value)||0);},valuePropertyNameChanged:function(){this.mojoAttributeChanged("modelProperty",this.valuePropertyName);},maxChanged:function(){this.mojoAttributeChanged("max",Number(this.max));},minChanged:function(){this.mojoAttributeChanged("min",Number(this.min));}}); +opus.Class("Palm.Mojo.ListSelector",{isa:Palm.Mojo.Widget,published:{value:{value:"",isModelData:true,modelPropertyName:"valuePropertyName"},valuePropertyName:{value:"value",model:true,group:"Model"},disabled:{value:false,isModelData:true,modelPropertyName:"disabledPropertyName"},disabledPropertyName:{value:"disabled",model:true,group:"Model"},choices:{value:"[{label: 'One', value: '1'},{label: 'Two', value: '2'},{label: 'Three', value: '3'}]",isModelData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},label:{value:"Pick One",onchange:"mojoAttributeChanged"},labelPlacement:{options:[Mojo.Widget.labelPlacementRight,Mojo.Widget.labelPlacementLeft],onchange:"mojoAttributeChanged"},multiline:{value:false,onchange:"mojoAttributeChanged"},onchange:{event:Mojo.Event.propertyChange+"Handler"}},mojoClass:"ListSelector",width:"100%",height:60,minHeight:60,maxHeight:60,create:function(){this.inherited(arguments);this.mojoAttributeChanged("label");this.mojoAttributeChanged("labelPlacement");this.mojoAttributeChanged("multiline");},renderWidget:function(){this.inherited(arguments);if(this.isDesigning()){this.mwc.assistant.openSelector=opus.nop;}},getValue:function(){return this.fetchModelProperty(this.valuePropertyName,this.value);},getDisabled:function(){return this.fetchModelProperty(this.disabledPropertyName,this.disabled);},getChoices:function(){return this.fetchModelProperty("choices");},valueChanged:function(){this.value=Palm.fetchTypedValue(this.value);if(this.value===""){this.deleteModelProperty(this.valuePropertyName);}else{this.modelPropertyChanged(this.valuePropertyName,this.value);}},valuePropertyNameChanged:function(){this.mojoAttributeChanged("modelProperty",this.valuePropertyName);},disabledChanged:function(){this.modelPropertyChanged(this.disabledPropertyName,this.disabled);},disabledPropertyNameChanged:function(){this.mojoAttributeChanged("disabledProperty",this.disabledPropertyName);},choicesChanged:function(){this.choices=Palm.fetchJsonValue(this.choices,[]);this.modelPropertyChanged("choices");}}); +opus.Class("Palm.Mojo.Label",{isa:Palm.Mojo.Html,width:"100%",height:50,published:{content:{noExport:true,noInspect:true},templateFile:{noInspect:true},className:"",kind:{value:"label",options:["label","title"],onchange:"classNameChanged"},label:{value:"Label",isModelData:true,modelPropertyName:"labelPropertyName"},labelPropertyName:{value:"label",model:true,group:"Model"}},create:function(){this.attributes={};this.classNameChanged();this.labelPropertyNameChanged();this.inherited(arguments);},classNameChanged:function(){this.attributes.className=this.className?this.className:this.kind;this.attributesChanged();},fetchInlineTemplate:function(){return"#{"+this.labelPropertyName+"}";},getLabel:function(){return this.fetchModelProperty(this.labelPropertyName,this.label);},labelChanged:function(){this.modelPropertyChanged(this.labelPropertyName,this.label);if(!this.isRendering()){this.updateInlineTemplate();}},labelPropertyNameChanged:function(){this.updateInlineTemplate();}}); +opus.Class("Palm.Mojo.ImageView",{isa:Palm.Mojo.Widget,width:"100%",height:"100%",mojoClass:"ImageView",published:{highResolutionLoadTimeout:{value:1.2,onchange:"mojoAttributeChanged"},extractfsParams:{value:"",onchange:"mojoAttributeChanged"},lowResExtractFSParams:{value:"",onchange:"mojoAttributeChanged"},noExtractFS:{value:true,onchange:"mojoAttributeChanged"},limitZoom:{value:false,onchange:"mojoAttributeChanged"},panInsetX:{value:0,onchange:"mojoAttributeChanged"},panInsetY:{value:0,onchange:"mojoAttributeChanged"},onLeftFunction:{event:"navigateLeft",isModelData:true},onRightFunction:{event:"navigateRight",isModelData:true},onImageViewChanged:{event:Mojo.Event.imageViewChanged+"Handler"},centerUrl:{value:"",noInspect:true},rightUrl:{value:"",noInspect:true},leftUrl:{value:"",noInspect:true},images:{value:[],editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},index:0,wrap:true},postCreate:function(){this.inherited(arguments);this.mojoAttributeChanged("highResolutionLoadTimeout");this.mojoAttributeChanged("extractfsParams");this.mojoAttributeChanged("lowResExtractFSParams");this.mojoAttributeChanged("noExtractFS");this.mojoAttributeChanged("limitZoom");this.mojoAttributeChanged("panInsetX");this.mojoAttributeChanged("panInsetY");},resize:function(){if(this.mwc){var n=this.fetchMojoNode();this.mwc.assistant.manualSize(n.clientWidth,n.clientHeight);}},renderWidget:function(){this.inherited(arguments);if(this.hasImages()){this.setIndex(this.index);}},onLeftFunctionChanged:function(){this.modelPropertyChanged("onLeftFunction",kit.hitch(this,"doNavigateLeft"));},onRightFunctionChanged:function(){this.modelPropertyChanged("onRightFunction",kit.hitch(this,"doNavigateRight"));},doNavigateLeft:function(){if(this.hasImages()){this.prevIndex();} +this.navigateLeft();},doNavigateRight:function(){if(this.hasImages()){this.nextIndex();} +this.navigateRight();},imagesChanged:function(){this.indexChanged();},hasImages:function(){return this.images.length;},isValidIndex:function(inIndex){return(inIndex>=0&&inIndex<=this.images.length-1);},calcIndex:function(inDelta){var i=this.index+inDelta;if(!this.isValidIndex(i)){i=!this.wrap?-1:inDelta>0?0:this.images.length-1;} +return i;},indexChanged:function(){this.index=Number(this.index);this.index=this.isValidIndex(this.index)?this.index:0;var left=this.images[this.calcIndex(-1)];var center=this.images[this.index];var right=this.images[this.calcIndex(1)];this.setCenterUrl(center);if(left){this.setLeftUrl(left);} +if(right){this.setRightUrl(right);}},nextIndex:function(){var i=this.calcIndex(1);if(this.isValidIndex(i)){this.setIndex(i);}},prevIndex:function(){var i=this.calcIndex(-1);if(this.isValidIndex(i)){this.setIndex(i);}},centerUrlChanged:function(){if(this.mwc){var p=this.centerUrl?this.rewritePath(this.centerUrl):"";this.fetchMojoNode().mojo.centerUrlProvided(p);}},leftUrlChanged:function(){if(this.mwc){var p=this.leftUrl?this.rewritePath(this.leftUrl):"";this.fetchMojoNode().mojo.leftUrlProvided(p);}},rightUrlChanged:function(){if(this.mwc){var p=this.rightUrl?this.rewritePath(this.rightUrl):"";this.fetchMojoNode().mojo.rightUrlProvided(p);}}}); +opus.Class("Palm.Mojo.WebView",{isa:Palm.Mojo.Widget,published:{virtualpageheight:"",virtualpagewidth:"",url:"",minFontSize:"",topMargin:"",cacheAdapter:true,interrogateClicks:true,showClickedLink:true},width:"100%",height:300,mojoClass:"WebView",create:function(){this.inherited(arguments);this.virtualpageheightChanged();this.virtualpagewidthChanged();this.urlChanged();this.minFontSizeChanged();this.topMarginChanged();this.cacheAdapterChanged();this.interrogateClicksChanged();this.showClickedLinkChanged();},virtualpageheightChanged:function(){this.mojoAttributeChanged("virtualpageheight",Number(this.virtualpageheight)||undefined);},virtualpagewidthChanged:function(){this.mojoAttributeChanged("virtualpagewidth",Number(this.virtualpagewidth)||undefined);},urlChanged:function(){if(this.mwc){this.mwc.assistant.openURL(this.url||undefined);}else{this.mojoAttributeChanged("url",this.url||undefined);}},pageIdentifierChanged:function(){this.mojoAttributeChanged("pageIdentifier",this.pageIdentifier||undefined);},minFontSizeChanged:function(){this.mojoAttributeChanged("minFontSize",Number(this.minFontSize)||undefined);},topMarginChanged:function(){this.mojoAttributeChanged("topMargin",Number(this.topMargin)||"");},cacheAdapterChanged:function(){this.mojoAttributeChanged("cacheAdapter");},interrogateClicksChanged:function(){this.mojoAttributeChanged("interrogateClicks");},showClickedLinkChanged:function(){this.mojoAttributeChanged("showClickedLink",this.showClickedLink||undefined);}}); +opus.Class("Palm.Mojo.Scroller",{isa:Palm.Mojo.WidgetContainer,mojoClass:"Scroller",published:{mode:{value:"vertical",options:["free","horizontal","vertical","dominant","horizontal-snap","vertical-snap"],onchange:"mojoAttributeChanged"},snapElements:{value:"",isModelData:true},onchange:{event:Mojo.Event.propertyChange+"Handler"},onscrollstarting:{event:"doScrollStarting"},onflick:{noInspect:true},snapIndex:{value:0,isModelData:true},scrollPosition:{value:{},noInspect:true},scrolleeSuspended:{value:false,noInspect:true},layoutKind:{options:["absolute","vbox","hbox"],group:"Common",noInspect:false}},attributes:{"x-mojo-element":"Scroller"},scroll:false,dropTarget:true,styles:{cursor:"move",overflow:"hidden"},chrome:[{name:"client",type:"Palm.Mojo.Container",w:"100%",h:"100%",layoutKind:"vbox",scroll:false,styles:{overflow:"visible"}}],create:function(){this.inherited(arguments);this.layoutKindChanged();this.mojoAttributeChanged("mode");},destructor:function(){this.disconnectScrollee();this.inherited(arguments);},destroyWidget:function(){this.disconnectScrollListener();if(this.mwc){this.mwc.stopListening(this.mwc.element,Mojo.Event.dragStart,this.mwc.assistant.dragStartHandler);this.mwc.stopListening(this.mwc.element,Mojo.Event.flick,this.mwc.assistant.flickHandler);} +this.inherited(arguments);},layoutKindChanged:function(){this.layout=opus.layoutRegistry.fetch("vbox");this.$.client.setLayoutKind(this.layoutKind);this.reflow();},fetchMojoControl:function(){return this;},disconnectScrollListener:function(){if(this.scrollListener){var c=this.fetchSceneController();var n=this.fetchMojoNode();if(n){c.stopListening(n,Mojo.Event.scrollStarting,this.scrollListener);}}},disconnectScrollee:function(){kit.forEach(this._resizeConnects,kit.disconnect);},contentRendered:function(){this.inherited(arguments);this.watchScrollee();},postCreateWidget:function(){this.inherited(arguments);this.onscrollstartingChanged();},mousewheelHandler:function(e){if(this.mwc){var delta=(e.axis==e.VERTICAL_AXIS&&-e.detail*10)||e.wheelDeltaY;if(delta){var p=this.getScrollPosition();p.top=p.top+delta;this.setScrollPosition(p);}}},watchScrollee:function(){this.disconnectScrollee();for(var i=0,c;(c=this.$.client.c$[i])&&!c.showing;i++);if(c&&!c.preventScrollerWatch){this._resizeConnects=[kit.connect(c,"contentRendered",this,"reset"),kit.connect(c,"boundsRendered",this,"validate")];if(c.nodeSizeChanged){this._resizeConnects.push(kit.connect(c,"nodeSizeChanged",this,"validate"));}} +this.reset();},reset:function(){if(this.mwc&&!this.scrolleeSuspended){var mojo=this.fetchMojoNode().mojo;mojo.scrollTo(0,0);this.validate();}},validate:function(){if(this.mwc&&!this.scrolleeSuspended){var mojo=this.fetchMojoNode().mojo;mojo.validateScrollPosition();}},getSnapElements:function(){return this.isDesigning()?this.snapElements:this.fetchModelProperty("snapElements");},snapElementsChanged:function(){var snaps=kit.isString(this.snapElements)?this.makeSnapElements(this.snapElements):this.snapElements;if(snaps){this.modelPropertyChanged("snapElements",snaps);}},makeSnapElements:function(inSnapString){var component=this.getSnapComponent();if(component){var nodes=this.fetchNodeList(inSnapString);if(nodes.length){snaps={};snaps[component]=nodes;return snaps;}}},fetchNodeList:function(inList){var list=kit.isString(inList)?inList.split(','):inList||"";var r=[];var controller=this.fetchSceneController();for(var i=0,n,c;n=list[i];i++){n=n.replace(/ /g,"");c=this.owner.$[n];n=controller.get(n)||(c&&(c.fetchMojoNode?c.fetchMojoNode():(c.getNode?c.getNode():null)));if(n){r.push(n);}} +return r;},getSnapComponent:function(){if(this.mode=="horizontal-snap"){return"x";} +if(this.mode=="vertical-snap"){return"y";}},getSnapIndex:function(){return this.isDesigning()?this.snapIndex:this.fetchModelProperty("snapIndex");},snapIndexChanged:function(){this.modelPropertyChanged("snapIndex");},onscrollstartingChanged:function(){this.disconnectScrollListener();if(this.onscrollstarting){var c=this.fetchSceneController();this.scrollListener=kit.hitch(this,"doScrollStarting");c.listen(this.fetchMojoNode(),Mojo.Event.scrollStarting,this.scrollListener);}},getScrollPosition:function(){if(this.mwc){this.scrollPosition=this.fetchMojoNode().mojo.getState();} +return this.scrollPosition;},scrollPositionChanged:function(){if(this.mwc){this.fetchMojoNode().mojo.setState(this.scrollPosition);}}});opus.Class("Palm.Mojo.FadeScroller",{isa:Palm.Mojo.Container,dropTarget:true,published:{mode:{value:"vertical",options:["free","horizontal","vertical","dominant","horizontal-snap","vertical-snap"],onchange:"mojoAttributeChanged"},scrollPosition:{value:{},noInspect:true},scrolleeSuspended:{value:false,noInspect:true},},layoutKind:"absolute",chrome:[{w:"100%",h:27,attributes:{"x-mojo-scroll-fade":"top"},styles:{bgImage:"$Palm-Mojo/images/top-fade-dark.png",zIndex:10},layoutKind:"vbox",controls:[{type:"Image",hAlign:"center",w:24,h:24,src:"$Palm-Mojo/images/arrow-up.png"}]},{name:"scroller",type:"Palm.Mojo.Scroller",w:"100%",h:"100%"},{w:"100%",h:27,b:0,attributes:{"x-mojo-scroll-fade":"bottom"},styles:{bgImage:"$Palm-Mojo/images/bottom-fade-dark.png",zIndex:10},layoutKind:"vbox",controls:[{type:"Image",hAlign:"center",w:24,h:24,src:"$Palm-Mojo/images/arrow-down.png"}]}],create:function(){this.inherited(arguments);this.modeChanged();},modeChanged:function(){this.$.scroller.setMode(this.mode);},getControlParent:function(){return this.$.scroller.$.client;},watchScrollee:function(){this.$.scroller.watchScrollee();},disconnectScrollee:function(){this.$.scroller.disconnectScrollee();},getScrollPosition:function(){return this.$.scroller.getScrollPosition();},scrollPositionChanged:function(){this.$.scroller.scrollPositionChanged();},getControls:function(){return this.$.scroller.getControls();},scrolleeSuspendedChanged:function(){this.$.scroller.setScrolleeSuspended(this.scrolleeSuspended);}}); +opus.Class("Palm.Mojo.Drawer",{isa:Palm.Mojo.WidgetContainer,mojoClass:"Drawer",h:300,published:{open:{value:true,isModelData:true,modelPropertyName:"openPropertyName"},openPropertyName:{value:"open",model:true,group:"Model"},unstyled:{value:false,onchange:"mojoAttributeChanged"},titleToggleOpen:true,titleShowing:false,titleLabel:"",onchange:{event:Mojo.Event.propertyChange+"Handler"},openHeight:{value:300,noInspect:true},layoutKind:{options:["absolute","vbox","hbox"],group:"Common",noInspect:false}},styles:{overflow:"hidden"},chrome:[{name:"titleContainer",type:"Container",attributes:{className:"palm-row drawer-button"},h:50,w:"100%",showing:false,onclick:"titleClicked",styles:{marginBottom:-1},controls:[{name:"titleLabel",styles:{paddingLeft:10,paddingRight:10,oneLine:true},h:"100%",w:"100%"}]},{name:"clientContainer",type:"Palm.Mojo.Container",w:"100%",h:"100%",layoutKind:"vbox",scroll:false,controls:[{name:"client",type:"Palm.Mojo.Container",w:"100%",layoutKind:"vbox",scroll:false}]}],create:function(){this.inherited(arguments);this.$.client.scrollHandler=kit.hitch(this,"clientScrollHandler");if(!this.getOpen()){this.height=this.getClosedHeight();} +this.layoutKindChanged();this.openPropertyNameChanged();this.mojoAttributeChanged("unstyled");this.titleShowingChanged();this.titleLabelChanged();this.openHeightChanged();},scrollHandler:function(e){if(!this.isDesigning()){this.node.scrollTop=0;kit.stopEvent(e);}},clientScrollHandler:function(e){return true;},layoutKindChanged:function(){this.layout=opus.layoutRegistry.fetch("vbox");this.$.client.setLayoutKind(this.layoutKind);this.reflow();},fetchMojoControl:function(){return this.$.clientContainer;},destroyWidget:function(){var n=this.fetchMojoNode();if(n&&this.mwc){n.appendChild(this.$.client.node);n.removeChild(this.mwc.assistant.wrapper);} +this.inherited(arguments);},setHeight:function(){if(this.getOpen()||this._animating){this.inherited(arguments);}},getClosedHeight:function(){return this.titleShowing?this.$.titleContainer.getHeight():0;},heightChanged:function(){if(!this._animating&&this.getOpen()){this.setOpenHeight(this.height=="auto"?"auto":this.getBounds().h);}},openHeightChanged:function(){this.$.clientContainer.setHeight(this.openHeight=="auto"?"auto":this.openHeight-this.getClosedHeight());this.$.client.setHeight(this.openHeight=="auto"?"auto":"100%");this.updateInternalHeight();},renderBounds:function(){this.inherited(arguments);this.updateInternalHeight();},updateInternalHeight:function(){if(this.mwc){var b=this.$.client.getBounds();var a=this.mwc.assistant;a.wrapper.style.height=a.contentDiv.style.height=b.h+"px";}},postCreateWidget:function(){this.animationQueue=Mojo.Animation.queueForElement(this.fetchMojoNode());this.mwc.assistant.updateFromModel=kit.hitch(this,"mojoUpdateFromModel");this.updateInternalHeight();},mojoUpdateFromModel:function(){var a=this.mwc.assistant;if(a.wasOpen!==a.controller.model[a.propName]){if(this._animation){this._animation.complete();} +var newHeight=this.getClosedHeight()+(a.wasOpen?0:this.$.client.getBounds().h);this.doAnimation(newHeight);a.wasOpen=a.controller.model[a.propName];}},doAnimation:function(inHeight){this._animating=true;this._animation=Mojo.Animation.animateValue(this.animationQueue,'bezier',kit.hitch(this,"updateAnimationHeight"),{onComplete:kit.hitch(this,"finishAnimation"),from:this.bounds.h,to:inHeight,duration:0.3,curve:Mojo.Animation.easeOut});},updateAnimationHeight:function(inHeight){inHeight=Math.round(inHeight);this.setHeight(inHeight);},finishAnimation:function(){this.setHeight(this.getOpen()?this.openHeight:this.getClosedHeight());this._animating=false;this._animation=null;},openPropertyNameChanged:function(){this.mojoAttributeChanged("property",this.openPropertyName);},openChanged:function(){this.modelPropertyChanged(this.openPropertyName,this.open);},getOpen:function(){return this.fetchModelProperty(this.openPropertyName,this.open);},openDrawer:function(){this.setOpen(true);},closeDrawer:function(){this.setOpen(false);},toggleOpen:function(){this.setOpen(!this.getOpen());},titleClicked:function(e){if(this.titleToggleOpen){opus.job("toggle",kit.hitch(this,"toggleOpen"),10);}},titleShowingChanged:function(){this.$.titleContainer.setShowing(this.titleShowing);},titleLabelChanged:function(){this.$.titleLabel.setContent(this.titleLabel);}}); +opus.Class("Palm.Mojo.Collapsible",{isa:Palm.Mojo.Drawer,published:{open:{value:true,isModelData:true,modelPropertyName:"openPropertyName"},unstyled:{value:true,onchange:"mojoAttributeChanged",noInspect:true},titleToggleOpen:{value:true,noInspect:true},titleShowing:{value:true,noInspect:true},titleLabel:"Collapsible"},chrome:[{name:"titleContainer",type:"Palm.Mojo.Container",h:40,w:"100%",showing:true,onclick:"titleClicked",controls:[{name:"titleLabel",h:"100%",w:"100%"}]},{name:"clientContainer",type:"Palm.Mojo.Container",w:"100%",h:"100%",layoutKind:"vbox",scroll:false,controls:[{name:"client",type:"Container",w:"100%",layoutKind:"vbox",scroll:false}]}],ready:function(){this.inherited(arguments);this.titleLabelChanged();},titleLabelChanged:function(){var c=this.titleLabel;var es=(this.getOpen()?"expanded":"closed");var content=''+''+''+''+''+''+''+''+'
'+c+'
';this.$.titleLabel.setContent(content);this.arrowNode=kit.byId(this.globalId+"-arrow");},nodesRendered:function(){this.inherited(arguments);this.arrowNode=kit.byId(this.globalId+"-arrow");},doAnimation:function(inHeight){if(this.arrowNode){this.arrowNode.className="palm-arrow-"+(this.getOpen()?"expanded":"closed");} +this.inherited(arguments);}}); +opus.Class("Palm.Mojo.RichTextEdit",{isa:Palm.Mojo.Widget,published:{value:{value:"Rich!",isModelData:true,onchange:"modelPropertyChanged"}},width:"100%",height:200,mojoClass:"RichTextEdit",getValue:function(){return this.fetchModelProperty("value");}}); +opus.Class("Palm.Mojo.Header",{isa:opus.Control,mixins:[Palm.Mojo.ControlMixin],width:"100%",height:50,defaultStyles:{border:null},plane:2000,published:{content:{noExport:true,noInspect:true},label:{value:""}},create:function(){this.inherited(arguments);this.label=this.label||this.content;this.labelChanged();},classNameChanged:function(){var cn="palm-header";if(this.className){cn+=" "+this.className;} +this.attributes.className=cn;this.attributesChanged();},modifyDomStyles:function(inStyles,inComputedStyles){inStyles.position=this.isDesigning()?inStyles.position:"fixed";inStyles["border-width"]=null;},labelChanged:function(){this.setContent(this.label);}}); +opus.Class("Palm.Mojo.Group",{isa:Palm.Mojo.Panel,width:"100%",height:95,autoRows:true,published:{label:{value:"Label"}},chrome:[{name:"client",type:"Palm.Mojo.Container",layoutKind:"vbox",styles:{overflow:"hidden"},h:"100%",w:"100%",scroll:false}],create:function(){this.inherited(arguments);this.layoutKindChanged();this.heightChanged();},layoutKindChanged:function(){this.layout=opus.layoutRegistry.fetch("vbox");this.$.client.setLayoutKind(this.layoutKind);this.reflow();},getContent:function(){var id=this.globalId;var c=this.inherited(arguments);return'
'+ +(this.label?'
'+this.label+'
':'')+'
'+c+'
'+'
';},contentRendered:function(){this.inherited(arguments);this.contentNode=kit.byId(this.globalId+"-content");this.groupNode=kit.byId(this.globalId+"-group");this.labelNode=kit.byId(this.globalId+"-label");this.updateInternalHeight();},fetchInternalHeight:function(){return Math.max(0,this.$.client.getBounds().h-2);},updateInternalHeight:function(){if(this.contentNode){this.contentNode.style.height=this.fetchInternalHeight()+"px";}},heightChanged:function(){this.$.client.setHeight(this.getHeight()=="auto"?"auto":"100%")},labelChanged:function(){this.contentChanged();this.reflow();},getClientBounds:function(){var b=this.inherited(arguments);var th=this.label?24:0;b.t+=9+th;b.h-=th+19;b.l+=9;b.w-=18;return b;},boundsChanged:function(){if(this.getHeight()=="auto"){var th=this.label?24:0;this.bounds.h=Math.max(30,this.bounds.h);this.bounds.h+=19+th;}else{this.inherited(arguments);}},boundsRendered:function(){this.bounds.boundsDirty=false;this.updateInternalHeight();},controlDropped:function(inChild,inDropInfo){var c=inChild;if(this.autoRows&&!(c instanceof Palm.Mojo.Container)){c=this.fetchAutoRow(c);c.parent.dropChild(c,inDropInfo);this.updateRows();}else{this.inherited(arguments);} +return inChild;},fetchAutoRow:function(inControl){var isTextField=(inControl instanceof Palm.Mojo.TextField);var r=this.createComponent({type:"Palm.Mojo.Row",isTextField:isTextField,height:"auto",dropTarget:true});r.renderNode();r.parentNode=null;inControl.setManager(r);inControl.reflowParent();if(inControl.node){r.$.client.insertNodeAt(inControl.node,0);}else{inControl.renderNode();inControl.parentNode=null;} +return r;},updateRows:function(){var c$=this.getControls();for(var i=0,c;c=c$[i];i++){if(c.getControls&&!c.getControls().length&&c instanceof Palm.Mojo.Row&&c.getHeight()=="auto"){c.destructor();}}}}); +opus.Class("Palm.Mojo.Row",{isa:Palm.Mojo.Panel,scroll:false,defaultStyles:{overflow:"hidden"},width:"100%",height:52,published:{tapHighlight:{value:true,onchange:"contentChanged"},focusHighlight:{value:true,onchange:"contentChanged"},autoRowType:true,rowType:{value:"single",options:["single","first","middle","last"]},isTextField:false},chrome:[{name:"client",type:"Palm.Mojo.Container",h:"100%",w:"100%",styles:{overflow:"hidden"},layoutKind:"vbox",scroll:false}],create:function(){this.inherited(arguments);this.isTextFieldChanged();this.layoutKindChanged();this.heightChanged();},layoutKindChanged:function(){this.layout=opus.layoutRegistry.fetch(this.layoutKind=="relative"?"relative":"vbox");this.$.client.setLayoutKind(this.layoutKind);this.reflow();},isTextFieldChanged:function(){this.style.addRuntimeStyles({marginTop:0});this.style.addRuntimeStyles({paddingTop:this.isTextField?1:0});var cp=this.isTextField?10:0;this.$.client.style.addRuntimeStyles({paddingLeft:cp,paddingRight:cp});this.contentChanged();},getContent:function(){var c=this.inherited(arguments);var focusHighlight=this.focusHighlight?' x-mojo-focus-highlight="true"':'';var tapHighlight=this.tapHighlight?' x-mojo-touch-feedback="delayed"':'';var highlights=focusHighlight+tapHighlight;var h=this.fetchInternalHeight();var sizeStyle=h?'style="height: '+h+'px;"':"";var sizeInfo=' id="'+this.globalId+'-sizeNode"'+sizeStyle;if(this.isTextField){return'
'+'
'+''+ +c+'
'+'
'+'';}else{return'
'+''+ +c+'
'+'';}},contentRendered:function(){this.inherited(arguments);this.sizeNode=kit.byId(this.globalId+"-sizeNode");this.typeNode=kit.byId(this.globalId+"-typeNode");this.updateInternalHeight();},boundsRendered:function(){this.inherited(arguments);if(this.autoRowType&&this.parent){this.doAutoRowType();} +this.updateInternalHeight();},doAutoRowType:function(){var c$=this.parent.getControls();var type=c$.length==1?"single":(this==c$[0]?"first":(this==c$[c$.length-1]?"last":"middle"));this.setRowType(type);},rowTypeChanged:function(){if(this.typeNode){this.typeNode.className="palm-row "+this.rowType;}},fetchInternalHeight:function(){if(this.$.client.layoutKind!="relative"){return this.$.client.getBounds().h;}},updateInternalHeight:function(){if((this.layoutKind!="relative")&&this.sizeNode){this.sizeNode.style.height=this.fetchInternalHeight()+"px";}},heightChanged:function(){this.$.client.setHeight(this.getHeight()=="auto"?"auto":(this.layoutKind=="relative"?null:"100%"));this.updateInternalHeight();}}); +opus.Class("Palm.Mojo.PageHeader",{isa:opus.Control,mixins:[Palm.Mojo.ControlMixin],width:"100%",height:52,defaultStyles:{borderStyle:"none",overflow:"hidden"},published:{content:{noInspect:true,noExport:true},title:{value:"Title",onchange:"contentChanged"},subtitle:{value:"Subtitle",onchange:"contentChanged"},multiline:{value:false,onchange:"contentChanged"},icon:{value:"",onchange:"contentChanged",editor:{editorKind:"ImagePathEditor"}},html:{value:"",onchange:"contentChanged"}},iconSize:32,getContent:function(){return'
'+'
'+ +this.generateHeaderContent()+'
'+'
';},generateHeaderContent:function(){if(this.html){return this.html;}else{var tbm=Math.max(Math.floor((52-this.iconSize)/2),0);var rlm=Math.max(Math.floor((56-this.iconSize)/2),0);var iconStyle='margin: '+tbm+'px '+rlm+'px; height: '+this.iconSize+'px; width: '+this.iconSize+'px;';var icon=this.icon?'
':"";return icon+'
'+this.title+'
'+ +(this.subtitle&&this.multiline?'
'+this.subtitle+'
':"");}}}); +opus.Class("Palm.Mojo.ProgressBar",{isa:Palm.Mojo.Widget,published:{progress:{value:0.5,isModelData:true,modelPropertyName:"progressPropertyName"},progressPropertyName:{value:"progress",model:true,group:"Model"},title:{value:"Progress",isModelData:true,onchange:"modelPropertyChanged"},image:{value:"",isModelData:true,onchange:"modelPropertyChanged"},icon:{value:"",onchange:"mojoAttributeChanged"},iconPath:{value:"",onchange:"mojoAttributeChanged"},onprogressicontap:{event:Mojo.Event.progressIconTap+"Handler"},onprogresscomplete:{event:Mojo.Event.progressComplete+"Handler"}},width:"100%",height:34,minHeight:34,maxHeight:34,defaultStyles:{margin:12},mojoClass:"ProgressBar",create:function(){this.inherited(arguments);this.progressPropertyNameChanged();this.mojoAttributeChanged("icon");this.mojoAttributeChanged("iconPath");},getTitle:function(){return this.fetchModelProperty("title");},getProgress:function(){return this.fetchModelProperty(this.progressPropertyName,this.progress);},getImage:function(){return this.fetchModelProperty("image");},progressChanged:function(){this.modelPropertyChanged(this.progressPropertyName,this.progress);},progressPropertyNameChanged:function(){this.mojoAttributeChanged("modelProperty",this.progressPropertyName);}}); +opus.Class("Palm.Mojo.ProgressSlider",{isa:Palm.Mojo.Widget,published:{slider:{value:30,isModelData:true,modelPropertyName:"sliderPropertyName"},sliderPropertyName:{value:"slider",model:true,group:"Model"},progress:{value:0.5,isModelData:true,modelPropertyName:"progressPropertyName"},progressPropertyName:{value:"progress",model:true,group:"Model"},progressStartValue:{value:0,isModelData:true,modelPropertyName:"progressStartValuePropertyName"},progressStartValuePropertyName:{value:"progressStart",model:true,group:"Model"},minValue:{value:0,isModelData:true,onchange:"modelPropertyChanged"},maxValue:{value:100,isModelData:true,onchange:"modelPropertyChanged"},round:{value:true,onchange:"mojoAttributeChanged"},updateInterval:{value:0,onchange:"mojoAttributeChanged"},cancellable:{value:false,onchange:"mojoAttributeChanged"},onchange:{event:Mojo.Event.propertyChange+"Handler"},onprogressComplete:{event:Mojo.Event.progressComplete+"Handler"},},defaultStyles:{margin:12,overflow:"visible"},width:"100%",height:34,minHeight:34,maxHeight:34,mojoClass:"ProgressSlider",create:function(){this.inherited(arguments);this.sliderPropertyNameChanged();this.progressPropertyNameChanged();this.progressStartValuePropertyNameChanged();this.mojoAttributeChanged("cancellable");this.mojoAttributeChanged("round");this.mojoAttributeChanged("updateInterval");},classNameChanged:function(){var cn="stream-buffer-bar";if(this.className){cn+=" "+this.className;} +this.attributes.className=cn;this.attributesChanged();},getSlider:function(){return this.fetchModelProperty(this.sliderPropertyName,this.slider);},sliderChanged:function(){this.modelPropertyChanged(this.sliderPropertyName,this.slider);},sliderPropertyNameChanged:function(){this.mojoAttributeChanged("sliderProperty",this.sliderPropertyName);},getProgress:function(){return this.fetchModelProperty(this.progressPropertyName,this.progress);},progressChanged:function(){this.modelPropertyChanged(this.progressPropertyName,this.progress);},progressPropertyNameChanged:function(){this.mojoAttributeChanged("progressProperty",this.progressPropertyName);},getProgressStartValue:function(){return this.fetchModelProperty(this.progressStartValuePropertyName,this.progressStartValue);},progressStartValueChanged:function(){this.modelPropertyChanged(this.progressStartValuePropertyName,this.progressStartValue);},progressStartValuePropertyNameChanged:function(){this.mojoAttributeChanged("progressStartProperty",this.progressStartValuePropertyName);},getMinValue:function(){return this.fetchModelProperty("minValue");},getMaxValue:function(){return this.fetchModelProperty("maxValue");}}); +opus.Class("Palm.Mojo.FilterField",{isa:Palm.Mojo.Widget,published:{disabled:{value:false,isModelData:true,modelPropertyName:"disabledPropertyName"},disabledPropertyName:{value:"disabled",model:true,group:"Model"},delay:{value:300,onchange:"mojoAttributeChanged"},onfilter:{event:Mojo.Event.filter+"Handler"},onfilterImmediate:{event:Mojo.Event.filterImmediate+"Handler"}},width:"100%",mojoClass:"FilterField",height:0,minHeight:0,maxHeight:0,create:function(){this.inherited(arguments);this.content="";this.mojoAttributeChanged("delay");this.disabledPropertyNameChanged();},nodeRendered:function(){if(this.isDesigning()){opus.Control.prototype.nodeRendered.call(this);}else{this.inherited(arguments);}},disabledPropertyNameChanged:function(){this.mojoAttributeChanged("disabledProperty",this.disabledPropertyName);},disabledChanged:function(){this.modelPropertyChanged(this.disabledPropertyName,this.disabled);},boundsChanged:function(){this.bounds.h=0;this.inherited(arguments);}}); +opus.Class("Palm.Mojo.StatusIndicator",{isa:opus.Control,mixins:[Palm.Mojo.ControlMixin],width:36,height:36,published:{statusType:{value:"status-available",onchange:"attributesChanged",options:["status-available","status-available partial","status-away","status-busy","status-busy partial","status-idle","status-offline"]}},modifyDomAttributes:function(inAttributes){inAttributes.className="icon "+this.statusType;}}); +opus.Class("Palm.Mojo.AccountIcon",{isa:opus.Control,mixins:[Palm.Mojo.ControlMixin],width:60,height:60,published:{accountType:{value:"aim",onchange:"attributesChanged",options:["aim","aol","eas","facebook","favorites","generic","google","googletalk","linkedin","local","msn","photobucket","sim","youtube","yahoo"]},size:{value:"small",onchange:"attributesChanged",options:["small","medium"]}},modifyDomAttributes:function(inAttributes){inAttributes.className="icon palm-account-icon "+this.accountType+(this.size=="medium"?" medium":"");}}); +opus.Class("Palm.Picture",{isa:opus.Picture,src:"",mixins:[Palm.Mojo.ControlMixin]}); +opus.Class("Palm.Mojo.Divider",{isa:Palm.Mojo.Html,width:"100%",height:34,published:{content:{noExport:true,noInspect:true},templateFile:{noInspect:true},label:{value:"Label",isModelData:true,modelPropertyName:"labelPropertyName"},labelPropertyName:{value:"label",model:true,group:"Model"},kind:{value:"text",options:["text","blank","alpha"],onchange:"contentChanged"}},getLabel:function(){return this.fetchModelProperty(this.labelPropertyName,this.label);},labelChanged:function(){this.modelPropertyChanged(this.labelPropertyName,this.label);if(!this.isRendering()){this.updateInlineTemplate();}},labelPropertyNameChanged:function(){this.updateInlineTemplate();},fetchInlineTemplate:function(){var c="#{"+this.labelPropertyName+"}";switch(this.kind){case"text":return''+''+''+''+'
'+c+'
';case"blank":return'
';case"alpha":return'
'+'
'+c+'
'+'
';}}}); +opus.Class("Palm.Mojo.Service",{isa:opus.Component,published:{onSuccess:{event:"doSuccess"},onFailure:{event:"doFailure"}},url:"",method:"",constructor:function(){this.parameters={};},fetchSceneController:function(){return this.owner.sceneController||Ares.mojoSceneController;},isReady:function(){return!Boolean(this.handle);},execute:function(inMethod,inParams,inCallbackMethod,inErrbackMethod){if(this.isReady()){this.handle=this.fetchSceneController().serviceRequest(this.url,{method:inMethod||this.method,parameters:inParams||this.parameters,onSuccess:kit.hitch(this,inCallbackMethod||"success"),onFailure:kit.hitch(this,inErrbackMethod||"failure")});}else{this.failure();}},cancel:function(){if(this.handle&&this.handle.cancel){this.handle.cancel();this.finish();}},finish:function(){if(!this.subscribe||(this.handle&&this.handle.cancelled)){this.handle=null;}},success:function(){this.finish();this.doSuccess.apply(this,arguments);},failure:function(inResponse){Mojo.Log.warn("Service Error "+(inResponse||""));this.finish();this.doFailure.apply(this,arguments);},makeServiceData:function(){var data={},p$=this.published,p;for(var i in p$){p=p$[i];if(p.isServiceData){data[p.servicePropertyName||i]=this[i];}} +return data;},populate:function(inData){if(inData){var p$=this.published,p,sp;for(var i in p$){p=p$[i];sp=p.servicePropertyName||i;if(p.isServiceData&&(sp in inData)){this["set"+kit.cap(i)](inData[sp]);}}}}}); +opus.Class("Palm.Mojo.ServiceCall",{isa:Palm.Mojo.Service,published:{url:"",method:"",parameters:{value:{},editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}}}}); +opus.Class("Palm.Mojo.Gps",{isa:Palm.Mojo.Service,url:"palm://com.palm.location",published:{accuracy:1,maximumAge:0,responseTime:1,subscribe:true},getCurrentPosition:function(){this.execute("getCurrentPosition",{accuracy:Number(this.accuracy),maximumAge:Number(this.maximumAge),responseTime:Number(this.responseTime)});},startTracking:function(){this.execute("startTracking",{subscribe:this.subscribe});}}); +opus.Class("Palm.Mojo.Location",{isa:Palm.Mojo.Service,url:"palm://com.palm.location",published:{latitude:38.898748,longitude:-77.037684},getReverseLocation:function(){this.execute("getReverseLocation",{latitude:Number(this.latitude),longitude:Number(this.longitude)});}}); +opus.Class("Palm.Mojo.SystemSound",{isa:Palm.Mojo.Service,url:"palm://com.palm.audio/systemsounds",method:"playFeedback",published:{sound:{value:"shuffling_01",options:["appclose","back_01","browser_01","card_01","card_02","card_03","card_04","card_05","default_425hz","delete_01","discardingapp_01","down2","dtmf_0","dtmf_1","dtmf_2","dtmf_3","dtmf_4","dtmf_5","dtmf_6","dtmf_7","dtmf_8","dtmf_9","dtmf_asterisk","dtmf_pound","error_01","error_02","error_03","focusing","launch_01","launch_02","launch_03","pagebackwards","pageforward_01","shuffle_02","shuffle_03","shuffle_04","shuffle_05","shuffle_06","shuffle_07","shuffle_08","shuffling_01","shutter","switchingapps_01","switchingapps_02","switchingapps_03","tones_3beeps_otasp_done","unassigned","up2"]}},execute:function(){this.parameters.name=this.sound;this.inherited(arguments);},playSound:function(){this.execute();}}); +opus.Class("Palm.Mojo.ViewFile",{isa:Palm.Mojo.Service,published:{fileUrl:{value:""}},url:"palm://com.palm.applicationManager",method:"open",execute:function(){this.parameters.target=this.fileUrl;this.inherited(arguments);},viewFile:function(){this.execute();}}); +opus.Class("Palm.Mojo.Download",{isa:Palm.Mojo.Service,published:{fileUrl:{value:"",servicePropertyName:"target",isServiceData:true},mime:{value:"",isServiceData:true},targetDir:{value:"/media/internal/downloads",isServiceData:true},targetFilename:{value:"",isServiceData:true},keepFilenameOnRedirect:{value:true,isServiceData:true},subscribe:{value:true,isServiceData:true}},url:"palm://com.palm.downloadmanager/",success:function(response){if(response&&response.ticket){this.ticket=response.ticket;} +this.inherited(arguments);if(response&&response.completed){this.cancel();}},failure:function(response){if(response&&response.ticket){this.ticket=response.ticket;} +this.inherited(arguments);if(response&&response.completed){this.cancel();}},download:function(){var d=this.makeServiceData();this.execute("download",d);},deleteDownload:function(){this.callTicketMethod("deleteDownloadedFile");},cancelDownload:function(){this.callTicketMethod("cancelDownload");},downloadStatusQuery:function(){this.callTicketMethod("downloadStatusQuery");},callTicketMethod:function(inMethod){if(this.ticket){this.execute(inMethod,{ticket:this.ticket});}else{this.failure("No download ticket");}}}); +opus.Class("Palm.Mojo.Downloads",{isa:Palm.Mojo.Service,published:{},url:"palm://com.palm.downloadmanager/",method:"listPending",listPending:function(){this.execute();}}); +opus.Class("Palm.Mojo.Upload",{isa:Palm.Mojo.Service,published:{fileName:{value:"",isServiceData:true},uploadUrl:{value:"",servicePropertyName:"url",isServiceData:true},fileLabel:{value:"",isServiceData:true},contentType:{value:"",isServiceData:true},postParameters:{value:{},isServiceData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},cookies:{value:{},isServiceData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},customHttpHeaders:{value:[],isServiceData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},subscribe:{value:true,isServiceData:true}},url:"palm://com.palm.downloadmanager/",method:"upload",execute:function(){this.parameters=this.makeServiceData();this.inherited(arguments);},upload:function(){this.execute();}}); +opus.Class("Palm.Mojo.Camera",{isa:Palm.Mojo.Service,published:{filename:""},create:function(){this.successHandler=kit.hitch(this,"success");this.inherited(arguments);},destructor:function(){this.stopListening();this.inherited(arguments);},execute:function(){this.listen();this.fetchSceneController().stageController.pushScene({appId:'com.palm.app.camera',name:'capture'},{sublaunch:true,filename:this.filename});},launch:function(){this.execute();},listen:function(){var controller=this.fetchSceneController();controller.listen(controller.sceneElement,Mojo.Event.activate,this.successHandler,false);},stopListening:function(){var controller=this.fetchSceneController();controller.stopListening(controller.sceneElement,Mojo.Event.activate,this.successHandler,false);},success:function(response){this.stopListening();this.inherited(arguments);}}); +opus.Class("Palm.Mojo.PeoplePicker",{isa:Palm.Mojo.Service,published:{exclusions:{value:[],editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},message:""},create:function(){this.successHandler=kit.hitch(this,"success");this.inherited(arguments);},destructor:function(){this.stopListening();this.inherited(arguments);},execute:function(){this.listen();this.fetchSceneController().stageController.pushScene({appId:"com.palm.app.contacts",name:"list"},{mode:"picker",exclusions:this.exclusions,message:this.message});},launch:function(){this.execute();},listen:function(){var controller=this.fetchSceneController();controller.listen(controller.sceneElement,Mojo.Event.activate,this.successHandler,false);},stopListening:function(){var controller=this.fetchSceneController();controller.stopListening(controller.sceneElement,Mojo.Event.activate,this.successHandler,false);},success:function(response){this.stopListening();this.inherited(arguments);}}); +opus.Class("Palm.Mojo.Connection",{isa:Palm.Mojo.Service,url:"palm://com.palm.connectionmanager",method:"getstatus",getStatus:function(){this.execute();}}); +opus.Class("Palm.Mojo.Alarm",{isa:Palm.Mojo.Service,published:{alarmAt:"",alarmIn:"","key":"",uri:"palm://com.palm.applicationManager/open",params:{value:{},editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},wakeup:true},url:"palm://com.palm.power/timeout",set:function(){var data={key:this.key,uri:this.uri,params:this.params,wakeup:this.wakeup} +if(this.alarmAt){data.at=this.alarmAt;}else if(this.alarmIn){data["in"]=this.alarmIn;} +this.execute("set",data);},clear:function(){this.execute("clear",{key:this.key});}}); +opus.Class("Palm.Mojo.Account",{isa:Palm.Mojo.Service,published:{accountId:{value:"",isServiceData:true},displayName:{value:"",isServiceData:true},dataTypes:{value:'["CONTACTS", "CALENDAR"]',isServiceData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},domain:{value:"com.palmdts",isServiceData:true},icons:{vallue:"",isServiceData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},isDataReadOnly:{value:false,isServiceData:true},username:{value:"",isServiceData:true}},url:"palm://com.palm.accounts/crud",create:function(){this.inherited(arguments);this.dataTypesChanged();this.iconsChanged();},getAccount:function(){this.execute("getAccount",this.makeServiceData(),"processGet");},createAccount:function(){this.execute("createAccount",this.makeServiceData(),"processCommit");},updateAccount:function(){this.execute("updateAccount",this.makeServiceData(),"processCommit");},deleteAccount:function(){this.execute("deleteAccount",this.makeServiceData(),"processDelete");},processGet:function(inResponse){this.populate(inResponse);this.success.apply(this,kit._toArray(arguments));},processCommit:function(inResponse){this.setAccountId(inResponse.accountId);this.success.apply(this,kit._toArray(arguments));},processDelete:function(inResponse){this.success.apply(this,kit._toArray(arguments));},dataTypesChanged:function(){this.dataTypes=Palm.fetchJsonValue(this.dataTypes,[]);},iconsChanged:function(){this.icons=Palm.fetchJsonValue(this.icons,{});}}); +opus.Class("Palm.Mojo.Accounts",{isa:Palm.Mojo.Service,url:"palm://com.palm.accounts/crud",method:"listAccounts",listAccounts:function(){this.execute();}}); +opus.Class("Palm.Mojo.Keys",{isa:Palm.Mojo.Service,published:{keyType:{value:"audio",options:["audio","switches","media","headset"]},subscribe:true},method:"status",execute:function(){this.url="palm://com.palm.keys/"+this.keyType;this.parameters={subscribe:this.subscribe};this.inherited(arguments);},getKeys:function(){this.execute();}}); +opus.Class("Palm.Mojo.Launch",{isa:Palm.Mojo.Service,published:{applicationId:{value:"",isServiceData:true,servicePropertyName:"id"},params:{value:{},isServiceData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}}},url:"palm://com.palm.applicationManager",method:"launch",execute:function(){this.parameters=this.makeServiceData();this.inherited(arguments);},launch:function(){this.execute();}}); +opus.Class("Palm.Mojo.LaunchEmail",{isa:Palm.Mojo.Launch,published:{applicationId:{value:"com.palm.app.email",noInspect:true,isServiceData:true,servicePropertyName:"id"},params:{noInspect:true,isServiceData:true},accountId:"",attachements:{value:[],editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},recipients:{value:[],editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},subject:"",message:""},method:"open",execute:function(){this.params=this.makeParams();this.inherited(arguments);},launch:function(){this.inherited(arguments);},makeParams:function(){return{account:this.accountId,attachments:this.attachments,recipients:this.recipients,summary:this.subject,text:this.message};}}); +opus.Class("Palm.Mojo.LaunchContacts",{isa:Palm.Mojo.Launch,published:{applicationId:{value:"com.palm.app.contacts",noInspect:true,isServiceData:true,servicePropertyName:"id"},params:{noInspect:true,isServiceData:true},launchType:{value:"newContact",options:["newContact","addToExisting"]},addresses:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},anniversary:{value:"",isContactData:true},birthday:{value:"",isContactData:true},children:{value:"",isContactData:true},companyName:{value:"",isContactData:true},customFields:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},displayText:{value:"",isContactData:true},emailAddresses:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},externalId:{value:"",isContactData:true},extraDetails:{value:"",isContactData:true},firstName:{value:"",isContactData:true},id:{value:"",isContactData:true},imAvatarLoc:{value:"",isContactData:true},imNames:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},incomingPic:{value:"",isContactData:true},jobTitle:{value:"",isContactData:true},lastName:{value:"",isContactData:true},listPic:{value:"",isContactData:true},middleName:{value:"",isContactData:true},nickname:{value:"",isContactData:true},notes:{value:"",isContactData:true},phoneNumbers:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},pictureLoc:{value:"",isContactData:true},pictureLocBig:{value:"",isContactData:true},pictureLocSquare:{value:"",isContactData:true},prefix:{value:"",isContactData:true},spouse:{value:"",isContactData:true},suffix:{value:"",isContactData:true},contactUrl:{value:"",isContactData:true},urls:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}}},method:"open",execute:function(){this.params={launchType:this.launchType,contact:this.makeContactData()};this.inherited(arguments);},launch:function(){this.inherited(arguments);},makeContactData:function(){var data={},p$=this.published,p;for(var i in p$){p=p$[i];if(p.isContactData){data[i]=this[i];}} +return data;}}); +opus.Class("Palm.Mojo.LaunchMaps",{isa:Palm.Mojo.Launch,published:{applicationId:{value:"com.palm.app.maps",noInspect:true,isServiceData:true,servicePropertyName:"id"},params:{noInspect:true,isServiceData:true},location:{value:{},editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},layer:"",query:"",mapType:"",zoom:""},method:"open",execute:function(){this.params=this.makeParams();this.inherited(arguments);},launch:function(){this.inherited(arguments);},makeParams:function(){return{location:this.location,layer:this.layer,query:this.query,type:this.mapType,zoom:this.zoom}}}); +opus.Class("Palm.Mojo.LaunchMessaging",{isa:Palm.Mojo.Launch,published:{applicationId:{value:"com.palm.app.messaging",noInspect:true,isServiceData:true,servicePropertyName:"id"},params:{noInspect:true,isServiceData:true},attachment:"",composeRecipients:{value:[],editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},contactPointId:{value:[],editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},messageText:"",personId:""},method:"launch",execute:function(){this.params=this.makeParams();this.inherited(arguments);},launch:function(){this.inherited(arguments);},makeParams:function(){return{attachment:this.attachment,composeRecipients:this.composeRecipients,contactPointId:this.contactPointId,messageText:this.messageText,personId:this.personId};}}); +opus.Class("Palm.Mojo.Display",{isa:Palm.Mojo.Service,published:{subscribe:{value:true,isServiceData:true}},url:"palm://com.palm.display",method:"status",execute:function(){this.parameters=this.makeServiceData();this.inherited(arguments);},status:function(){this.execute();}}); +opus.Class("Palm.Mojo.Power",{isa:Palm.Mojo.Service,published:{id:"",duration:""},url:"palm://com.palm.power/com/palm/power",execute:function(){this.parameters={id:this.id,duration_ms:Number(this.duration)};this.inherited(arguments);},startActivity:function(){this.execute("activityStart");},endActivity:function(){this.execute("activityEnd");}}); +opus.Class("Palm.Mojo.Preferences",{isa:Palm.Mojo.Service,published:{preferenceData:{value:{},editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},subscribe:false},url:"palm://com.palm.systemservice",getPreferences:function(){var keys=[];for(var i in this.preferenceData){keys.push(i);} +this.execute("getPreferences",{keys:keys},"processGet");},processGet:function(inResponse,inRequest){this.populate(inResponse);this.success(inResponse,inRequest);},populate:function(inPreferences){for(var i in inPreferences){if(i in this.preferenceData){this.preferenceData[i]=inPreferences[i];}}},setPreferences:function(){this.execute("setPreferences",this.preferenceData);}}); +opus.Class("Palm.Mojo.PreferenceValues",{isa:Palm.Mojo.Service,published:{key:""},url:"palm://com.palm.systemservice",method:"getPreferenceValues",execute:function(){this.parameters={key:this.key};this.inherited(arguments);},getPreferenceValues:function(){this.execute();}}); +opus.Class("Palm.Mojo.Time",{isa:Palm.Mojo.Service,published:{subscribe:false},url:"palm://com.palm.systemservice/time",method:"getSystemTime",execute:function(){this.parameters={subscribe:this.subscribe};this.inherited(arguments);},getSystemTime:function(){this.execute();}}); +opus.Class("Palm.Mojo.TrackChanges",{isa:Palm.Mojo.Service,published:{accountId:{value:"",isServiceData:true},trackerId:{value:"",isServiceData:true},token:{value:"",isServiceData:true},changeType:{value:"contacts",options:["contacts","calendar"]}},execute:function(){this.url="palm://com.palm."+this.changeType+"/crud";this.parameters=this.makeServiceData();this.inherited(arguments);},startTracking:function(){this.execute("startTracking");},getChanges:function(){this.execute("getChanges");},doneWithChanges:function(){this.execute("doneWithChanges");},sucess:function(inResponse){if(inResponse.token){this.token=inResponse.token;} +this.inherited(arguments);}}); +opus.Class("Palm.Mojo.Contact",{isa:Palm.Mojo.Service,published:{accountId:{value:"",isServiceData:true},externalId:{value:"",isServiceData:true},trackChange:{value:false,isServiceData:true},id:{value:"",isContactData:true},addresses:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},anniversary:{value:"",isContactData:true},birthday:{value:"",isContactData:true},children:{value:"",isContactData:true},companyName:{value:"",isContactData:true},customFields:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},displayText:{value:"",isContactData:true},emailAddresses:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},externalId:{value:"",isContactData:true},extraDetails:{value:"",isContactData:true},firstName:{value:"",isContactData:true},id:{value:"",isContactData:true},imAvatarLoc:{value:"",isContactData:true},imNames:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},incomingPic:{value:"",isContactData:true},jobTitle:{value:"",isContactData:true},lastName:{value:"",isContactData:true},listPic:{value:"",isContactData:true},middleName:{value:"",isContactData:true},nickname:{value:"",isContactData:true},notes:{value:"",isContactData:true},phoneNumbers:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},pictureLoc:{value:"",isContactData:true},pictureLocBig:{value:"",isContactData:true},pictureLocSquare:{value:"",isContactData:true},prefix:{value:"",isContactData:true},spouse:{value:"",isContactData:true},suffix:{value:"",isContactData:true},contactUrl:{value:"",isContactData:true,servicePropertyName:"url"},urls:{value:[],isContactData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}}},url:"palm://com.palm.contacts/crud",getContact:function(){var data=this.makeServiceData();data.id=this.getId();this.execute("getContact",data,"processGet");},createContact:function(){var data=this.makeServiceData();data.contact=this.makeContactData();this.execute("createContact",data,"processCommit");},updateContact:function(){var data=this.makeServiceData();data.contact=this.makeContactData();data.id=this.getId();this.execute("updateContact",data,"processCommit");},deleteContact:function(){var data=this.makeServiceData();data.id=this.getId();this.execute("deleteContact",data,"processDelete");},processGet:function(inResponse){this.populate(inResponse);this.success.apply(this,kit._toArray(arguments));},processCommit:function(inResponse){if(inResponse.id){this.setId(inResponse.id);} +this.success.apply(this,kit._toArray(arguments));},processDelete:function(inResponse){this.success.apply(this,kit._toArray(arguments));},makeContactData:function(){var data={},p$=this.published,p;for(var i in p$){p=p$[i];if(p.isContactData){data[p.servicePropertyName||i]=this[i];}} +return data;},populate:function(inResponse){this.inherited(arguments);var p$=this.published,p,sp;for(var i in p$){p=p$[i];sp=p.servicePropertyName||i;if(p.isContactData&&(sp in inResponse)){this["set"+kit.cap(i)](inResponse[sp]);}}}}); +opus.Class("Palm.Mojo.Contacts",{isa:Palm.Mojo.Service,published:{accountId:"",filter:"",limit:100,offset:0},url:"palm://com.palm.contacts/crud",method:"listContacts",execute:function(){this.parameters={accountId:this.accountId,filter:this.filter,limit:Number(this.limit),offset:Number(this.offset)};this.inherited(arguments);},listContacts:function(){this.execute();}}); +opus.Class("Palm.Mojo.Calendars",{isa:Palm.Mojo.Service,published:{accountId:""},url:"palm://com.palm.calendar/crud",method:"listCalendars",execute:function(){this.parameters={accountId:this.accountId};this.inherited(arguments);},listCalendars:function(){this.execute();}}); +opus.Class("Palm.Mojo.Calendar",{isa:Palm.Mojo.Service,published:{accountId:"",calendarId:{value:"",isServiceData:true},externalId:{value:"",isServiceData:true},calendarName:{value:"",isServiceData:true,servicePropertyName:"name"},trackChange:{value:true,isServiceData:true}},url:"palm://com.palm.calendar/crud",getCalendar:function(){var p={accountId:this.accountId,calendarId:this.calendarId,externalId:this.externalId};this.execute("getCalendar",p,"processGet");},createCalendar:function(){var p={accountId:this.accountId,calendar:this.makeServiceData()} +this.execute("createCalendar",p,"processCommit");},updateCalendar:function(){var p={calendar:this.makeServiceData()};this.execute("updateCalendar",p,"processCommit");},deleteCalendar:function(){var p={calendarId:this.calendarId,trackChange:this.trackChange};this.execute("deleteCalendar",p,"processDelete");},processGet:function(inResponse){this.populate(inResponse);this.success.apply(this,kit._toArray(arguments));},processCommit:function(inResponse){if(inResponse.calendarId){this.setCalendarId(inResponse.calendarId);} +this.success.apply(this,kit._toArray(arguments));},processDelete:function(inResponse){this.success.apply(this,kit._toArray(arguments));}}); +opus.Class("Palm.Mojo.Events",{isa:Palm.Mojo.Service,url:"palm://com.palm.calendar/crud",method:"listEvents",published:{calendarId:"",endTimestamp:0,limit:100,offset:0,startTimestamp:0,tzFormqt:""},execute:function(){this.parameters={calendarId:this.calendarId,endTimestamp:Number(this.endTimestamp),limit:Number(this.limit),offset:Number(this.offset),startTimestamp:Number(this.startTimestamp),tzFormqt:this.tzFormqt};this.inherited(arguments);},listEvents:function(){this.execute();}}); +opus.Class("Palm.Mojo.Event",{isa:Palm.Mojo.Service,published:{accountId:"",calendarId:"",externalId:"",eventId:{value:"",isServiceData:true},alarm:{value:"",isServiceData:true},allDay:{value:false,isServiceData:true},attendees:{value:"",isServiceData:true,editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},endTimestamp:{value:0,isServiceData:true},endValidity:{value:"",isServiceData:true},externalId:{value:"",isServiceData:true},location:{value:"",isServiceData:true},note:{value:"",isServiceData:true},originalStartTimestamp:{value:0,isServiceData:true},parentId:{value:"",isServiceData:true},rrule:{value:"",isServiceData:true},rruleTZ:{value:"",isServiceData:true},subject:{value:"",isServiceData:true},startTimestamp:{value:"",isServiceData:true},trackChange:{value:true,isServiceData:true}},url:"palm://com.palm.calendar/crud",startTimestampChanged:function(){this.startTimestamp=Number(this.startTimestamp);},endTimestampChanged:function(){this.endTimestamp=Number(this.endTimestamp);},originalStartTimestampChanged:function(){this.originalStartTimestamp=Number(this.originalStartTimestamp);},getEvent:function(){var p={accountId:this.accountId,eventId:this.eventId,externalId:this.externalId,tzFormat:"id"};this.execute("getEvent",p,"processGet");},createEvent:function(){var p={calendarId:this.calendarId,event:this.makeServiceData(),trackChange:this.trackChange} +this.execute("createEvent",p,"processCommit");},updateEvent:function(){var p=this.makeServiceData();this.execute("updateEvent",p,"processCommit");},deleteEvent:function(){var p={eventId:this.eventId,trackChange:this.trackChange};this.execute("deleteEvent",p,"processDelete");},processGet:function(inResponse){this.populate(inResponse);this.success.apply(this,kit._toArray(arguments));},processCommit:function(inResponse){if(inResponse.eventId){this.setEventId(inResponse.eventId);} +this.success.apply(this,kit._toArray(arguments));},processDelete:function(inResponse){this.setEventId("");this.success.apply(this,kit._toArray(arguments));}}); +opus.Class("Palm.Mojo.WebService",{isa:Palm.Mojo.Service,published:{url:{value:""},method:{value:"GET",options:["GET","POST","PUT","DELETE"]},parametersString:{value:""},parameters:{value:{},editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},handleAs:{value:"text",options:["text","json","xml"]},contentType:"application/x-www-form-urlencoded",headers:{value:{},editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}}},create:function(){this.inherited(arguments);this.srvReady=true;},destroy:function(){this.cancel();this.inherited(arguments);},isReady:function(){return this.srvReady;},cancel:function(){this.cancelled=true;},finish:function(){this.srvReady=true;},execute:function(inMethod,inParams,inCallbackMethod,inErrbackMethod){if(!this.isReady()){return;} +this.srvReady=false;this.cancelled=false;var success=kit.hitch(this,inCallbackMethod||"success");var failure=kit.hitch(this,inErrbackMethod||"failure");var url=this.url;var method=inMethod||this.method;var params=inParams||this.parameters;params=kit.isObject(params)?kit.objectToQuery(params):params;if(this.parametersString){params=params+(params?"&":"")+this.parametersString;} +if(method=="GET"&¶ms){url+=(url.include('?')?'&':'?')+params;params=null;} +var headers={};headers["Content-Type"]=this.contentType;kit.mixin(headers,this.headers);opus.xhr.request({url:url,method:method,callback:kit.hitch(this,"requestCompleted",this.handleAs,success,failure),body:params,headers:headers});},requestCompleted:function(inHandleAs,inSuccess,inFailure,inResponseText,inXhr){if(this.cancelled){console.log("skip processing callback due to cancel() was called.");this.finish();}else{if(inXhr.status&&inXhr.status!=0&&(inXhr.status>=200&&inXhr.status<300)){response=this.processResponse(inXhr,inHandleAs);inSuccess&&inSuccess.apply(null,[response,inXhr]);}else{inFailure&&inFailure.apply(null,[inXhr]);}}},processResponse:function(inXhr,inHandleAs){switch(inHandleAs){case"json":try{var resp=inXhr.responseText;return resp&&eval("("+resp+")");}catch(e){console.log("responseText is not in JSON format");return resp;} +case"xml":return inXhr.responseXML;default:return inXhr.responseText;}}}); +opus.Class("Palm.Mojo.FeedService",{isa:Palm.Mojo.WebService,published:{method:{value:"GET",noInspect:true},parametersString:{noInspect:true},parameters:{noInspect:true},handleAs:{value:"xml",noInspect:true},contentType:{value:"application/x-www-form-urlencoded",noInspect:true},headers:{noInspect:true}},processResponse:function(inXhr,inHandleAs){var response=this.inherited(arguments);if(response){return this.processFeedResponse(response);}else{return{};}},processFeedResponse:function(inXmlDoc){if(inXmlDoc.getElementsByTagName("channel").length>0){var propNames={"title":"title","link":"link","description":"description","language":"language"};var itemPropNames={"title":"title","link":"link","description":"description","pubDate":"date","guid":"id"};return this.parseFeed(inXmlDoc,"channel",propNames,"item",itemPropNames);}else if(inXmlDoc.getElementsByTagName("feed").length>0){var propNames={"title":"title","link:href":"link","subtitle":"description","language":"language"};var itemPropNames={"title":"title","link:href":"link","content":"description","updated":"date","id":"id"};return this.parseFeed(inXmlDoc,"feed",propNames,"entry",itemPropNames);}},parseFeed:function(inXmlDoc,inFeedNodeName,inFeedPropNames,inFeedItemNodeName,inFeedItemPropNames){var feedData={};var feedNode=inXmlDoc.getElementsByTagName(inFeedNodeName)[0];this.populateFeedProps(feedNode,feedData,inFeedPropNames);var items=inXmlDoc.getElementsByTagName(inFeedItemNodeName);this.populateFeedItems(items,feedData,inFeedItemPropNames);return feedData;},populateFeedProps:function(inChannel,ioFeedData,inNames){for(n in inNames){for(var i=0,node;node=inChannel.childNodes[i];i++){var v=this.findPropValue(node,n);if(v){ioFeedData[inNames[n]]=v;break;}}}},populateFeedItems:function(inItems,ioFeedData,inNames){var feedItems=[];for(var i=0,item;item=inItems[i];i++){var d={};for(n in inNames){d[inNames[n]]=this.getItemPropValue(item,n);} +feedItems.push(d);} +ioFeedData["items"]=feedItems;},getItemPropValue:function(inItem,inName){for(var i=0,node;node=inItem.childNodes[i];i++){var v=this.findPropValue(node,inName);if(v){return v;}}},findPropValue:function(inNode,inName){var names=inName.split(":");if(inNode.nodeName==names[0]){if(names.length==1){return inNode.firstChild&&inNode.firstChild.nodeValue;}else if(names.length==2){for(var i=0,attr;attr=inNode.attributes[i];i++){if(attr.name==names[1]){return attr.value;}}}}}}); +opus.Class("Palm.Mojo.FeedList",{isa:Palm.Mojo.List,published:{itemHtml:'
\n\t
\n\t\t#{-title}\n\t\t
#{-description}
\n\t
\n
',feedUrl:"http://feeds2.feedburner.com/pdnblog",autoPopulate:true,onFeedSuccess:{event:"doFeedSuccess"},onFeedFailure:{event:"doFeedFailure"}},create:function(){this.inherited(arguments);this.feedService=this.createComponent({type:"Palm.Mojo.FeedService",owner:this,onSuccess:"feedSuccess",onFailure:"feedFailure"});this.feedUrlChanged();},populateFeed:function(){this.feedService.execute();},feedSuccess:function(inSender,inResponse,inRequest){this.setItems(inResponse.items);this.doFeedSuccess.apply(this,arguments);},feedFailure:function(inSender,inError){this.doFeedFailure.apply(this,arguments);},feedUrlChanged:function(){this.feedService.setUrl(this.feedUrl);if(!this.isDesigning()&&this.autoPopulate){this.populateFeed();}}}); +opus.Class("Palm.Mojo.Wallpaper",{isa:Palm.Mojo.Service,published:{importUrl:"",focusX:"",focusY:"",scale:"",wallpaperFile:"",wallpaperName:"",wallpaperThumbFile:{vale:"",noInspect:true}},url:"palm://com.palm.systemservice/wallpaper",focusXChanged:function(){this.focusX=this.focusX?Number(this.focusX):"";},focusYChanged:function(){this.focusY=this.focusY?Number(this.focusY):"";},scaleChanged:function(){this.scale=this.scale?Number(this.scale):"";},importWallpaper:function(){var p={target:this.importUrl};if(this.focusX){p.focusX=this.focusX;} +if(this.focusY){p.focusY=this.focusY;} +if(this.scale){p.scale=this.scale;} +this.execute("importWallpaper",p,"processInfo");},updateWallpaperInfo:function(){var p={wallpaperName:this.wallpaperName,wallpaperFile:this.wallpaperFile};this.execute("info",p,"processInfo");},processInfo:function(inResponse,inRequest){var w=inResponse.wallpaper;if(w){this.setWallpaperFile(w.wallpaperFile);this.setWallpaperName(w.wallpaperName);this.setWallpaperThumbFile(w.wallpaperThumbFile);} +this.finish();this.setSystemWallpaper();},deleteWallpaper:function(){this.execute("deleteWallpaper",{wallpaperName:this.wallpaperName});},setSystemWallpaper:function(){var url=this.url;this.url="palm://com.palm.systemservice";var w={wallpaperName:this.wallpaperName,wallpaperFile:this.wallpaperFile,wallpaperThumbFile:this.wallpaperThumbFile};this.execute("setPreferences",{wallpaper:w});this.url=url;},getSystemWallpaper:function(){var url=this.url;this.url="palm://com.palm.systemservice";this.execute("getPreferences",{keys:["wallpaper"]},"processInfo");this.url=url;}}); +opus.Class("Palm.Mojo.Audio",{isa:opus.Component,published:{url:{value:""},progress:{value:0,noInspect:true},autoPlay:false,loop:false,audioClass:{value:"media",options:["media","defaultapp"]},onPlay:{event:"doPlay"},onPause:{event:"doPause"},onEnded:{event:"doEnded"},onError:{event:"doError"},onTimeUpdate:{event:"doTimeUpdate"}},constructor:function(){},create:function(){this.inherited(arguments);this.createPlayer();this.audioClassChanged();this.urlChanged();},destroy:function(){this.disconnectEvents();delete this.player;this.inherited(arguments);},createPlayer:function(){this.player=new Audio();this.connectEvents();},connectEvents:function(){this.connectEvent('play',kit.hitch(this,"doPlay"),false);this.connectEvent('pause',kit.hitch(this,"doPause"),false);this.connectEvent('timeupdate',kit.hitch(this,"processTimeUpdate"),false);this.connectEvent('error',kit.hitch(this,"doError"),false);},getProgress:function(){var d=this.player.duration;return d?this.player.currentTime/d:0;},progressChanged:function(){this.player.currentTime=this.progress*this.player.duration},currentTimeChanged:function(){this.player.currentTime=this.currentTime;},processTimeUpdate:function(e){if(this.player.currentTime==this.player.duration){this.processEnded(e);} +this.doTimeUpdate(e);},processEnded:function(e){this.doEnded();if(this.loop){this.play();}},connectEvent:function(){var args=kit._toArray(arguments);this._connections=this._connections||[];this._connections.push(args);this.player.addEventListener.apply(this.player,args);},disconnectEvents:function(){for(var i=0,c;c=this._connections[i];i++){this.player.removeEventListener.apply(this.player,c);} +this._connections=[];},urlChanged:function(){this.player.src=this.url;if(this.autoPlay){this.play();}},audioClassChanged:function(){if(this.player.mojo){this.player.mojo.audioClass=this.audioClass}else{this.player.mojo={audioClass:this.audioClass};}},play:function(){this.player.play();},pause:function(){this.player.pause();},stop:function(){this.player.stop();}});Palm.Mojo.Audio.pool=[]; +opus.Class("Palm.Mojo.Map",{isa:opus.Control,mixins:[Palm.Mojo.ControlMixin],published:{latitude:37.393056,longitude:-122.040532,zoom:14,mapOptions:{value:{},editor:{editorKind:"Palm.Ares.CodePropertyEditor",isJson:true}},mapTypeId:{value:"ROADMAP",options:["ROADMAP","SATELLITE","HYBRID","TERRAIN"]},showMarker:true},width:"100%",height:300,nodeRendered:function(){this.inherited(arguments);Palm.Map.loadGoogleScript(kit.hitch(this,"renderMap"));},constructor:function(){this._connections=[];},createMap:function(){var center=new google.maps.LatLng(this.latitude,this.longitude);var options={zoom:this.zoom,center:center,mapTypeId:google.maps.MapTypeId[this.mapTypeId]} +kit.mixin(options,this.mapOptions);this.map=new google.maps.Map(this.node,options);this.showMarkerChanged();this.connectEvent("gesturestart",kit.hitch(this,"handleGestureStart"),false);this.connectEvent("gesturechange",kit.hitch(this,"handleGestureChange"),false);this.connectEvent("gestureend",kit.hitch(this,"handleGestureEnd"),false);},destroyMap:function(){this.disconnectEvents();this.map=null;},renderMap:function(){this.destroyMap();this.createMap();},handleGestureStart:function(e){this.map.setOptions({draggable:false});this.previousScale=e.scale;},handleGestureChange:function(e){e.stop();var d=this.previousScale-e.scale;if(Math.abs(d)>0.25){var z=this.map.getZoom()+(d>0?-1:+1);this.map.setZoom(z);this.previousScale=e.scale;}},handleGestureEnd:function(e){e.stop();this.map.setOptions({draggable:true});},latitudeChanged:function(){this.latitude=Number(this.latitude);this.updateCenter();},longitudeChanged:function(){this.longitude=Number(this.longitude);this.updateCenter();},zoomChanged:function(){this.zoom=Number(this.zoom);if(this.map){this.map.setZoom(this.zoom);}},updateCenter:function(){if(this.map){this.map.setCenter(new google.maps.LatLng(this.latitude,this.longitude));this.showMarkerChanged();}},mapOptionsChanged:function(){if(this.map){this.map.setOptions(this.mapOptions);}},mapTypeIdChanged:function(){this.map.setMapTypeId(google.maps.MapTypeId[this.mapTypeId]);},showMarkerChanged:function(){if(this.centerMarker){this.clearMarker(this.centerMarker);} +this.centerMarker=(this.showMarker?this.setMarker(this.map.getCenter()):null);},setMarker:function(inLatLng){if(this.map){return new google.maps.Marker({position:inLatLng,map:this.map});}},clearMarker:function(inMarker){inMarker.setMap(null);},connectEvent:function(){var args=kit._toArray(arguments);this._connections=this._connections||[];this._connections.push(args);this.node.addEventListener.apply(this.node,args);},disconnectEvents:function(){for(var i=0,c;c=this._connections[i];i++){this.node.removeEventListener.apply(this.node,c);} +this._connections=[];}});Palm.Map={scriptLoadedCbs:[],alreadyCalled:false,loadGoogleScript:function(inCallback){if(window["google"]&&window["google"]["maps"]){inCallback&&inCallback();}else{this.scriptLoadedCbs.push(inCallback);if(!this.alreadyCalled){this.alreadyCalled=true;var script=document.createElement("script");script.type="text/javascript";script.src="http://maps.google.com/maps/api/js?sensor=true&callback=Palm.Map.scriptLoaded";document.body.appendChild(script);}}},scriptLoaded:function(){for(var i=0,c;c=this.scriptLoadedCbs[i];i++){c();} +this.scriptLoadedCbs=[];}}; \ No newline at end of file diff --git a/app.js b/app.js new file mode 100644 index 0000000..11b9acc --- /dev/null +++ b/app.js @@ -0,0 +1,16 @@ +opus.depends({ + paths: { + "Ares": "/Ares", + "mojo": "/usr/palm/frameworks/mojo/", + "opus": "$Ares/foss/opus/opus", + "Palm": "$Ares/ide", + "controls": "$opus/library/controls/", + "AresLib": "$Palm/library/Ares", + "MojoLib": "$Palm/library/Mojo/", + "Palm-Mojo": "$MojoLib/" + }, + nobuild: [ + "$mojo/mojo.js", + "app-build.js" + ] +}); \ No newline at end of file diff --git a/app/assistants/app-assistant.js b/app/assistants/app-assistant.js new file mode 100644 index 0000000..9fb9783 --- /dev/null +++ b/app/assistants/app-assistant.js @@ -0,0 +1,36 @@ +function AppAssistant() {} + +AppAssistant.prototype.setup = function() { + this.loadFirstSceneHandler = this.loadFirstScene.bind(this); + this.loadDashboardHandler = this.loadDashboard.bind(this); + window.document.addEventListener(Mojo.Event.stageDeactivate, this.onDeactivateHandler.bind(this)); + window.document.addEventListener(Mojo.Event.stageActivate, this.onActivateHandler.bind(this)); +}; + +AppAssistant.prototype.onDeactivateHandler = function(event) { + var dashboardController = this.controller.getStageController('dashboard'); + if (!dashboardController) { + this.controller.createStageWithCallback({ + name: 'dashboard', + lightweight: true, + clickableWhenLocked: true + }, + this.loadDashboardHandler, 'dashboard'); + } +}; + +AppAssistant.prototype.onActivateHandler = function(event) { + var dashboardController = this.controller.getStageController('dashboard'); + if (dashboardController) { + this.appController = Mojo.Controller.getAppController(); + this.appController.closeStage('dashboard'); + } +}; + + AppAssistant.prototype.loadFirstScene = function(stageController) { + stageController.pushScene('gridScene'); + }; + + AppAssistant.prototype.loadDashboard = function(stageController) { + stageController.pushScene('dashboard', DashPlayerInstance); + }; \ No newline at end of file diff --git a/app/assistants/dashboard-assistant.js b/app/assistants/dashboard-assistant.js new file mode 100644 index 0000000..09dab03 --- /dev/null +++ b/app/assistants/dashboard-assistant.js @@ -0,0 +1,146 @@ +/* Copyright 2009 Palm, Inc. All rights reserved. */ + +/*globals Mojo PowerManagerService Util Element AppAssistant */ +var DashboardAssistant = function(musicPlayer) { + this.musicPlayer = musicPlayer; + this.toggle = false; + // if there isn't anything in the musicPlayer, don't open up the dashboard + if (this.musicPlayer === 0) { + Mojo.Controller.getAppController().closeStage('dashboard'); + } + + this.appController = Mojo.Controller.getAppController(); + this.locked = false; + this.setupListeners = function() { + this.musicPlayer.audio().addEventListener('ended', this.trackEnded.bind(this), false); + this.musicPlayer.audio().addEventListener('play', this.trackChange.bind(this), false); + this.musicPlayer.audio().addEventListener('pause', this.trackPaused.bind(this), false); + }; + this.removeListeners = function() { + this.musicPlayer.audio().removeEventListener('ended', this.trackEnded.bind(this), false); + this.musicPlayer.audio().removeEventListener('play', this.trackChange.bind(this), false); + this.musicPlayer.audio().removeEventListener('pause', this.trackPaused.bind(this), false); + }; +}; + +DashboardAssistant.prototype = { + setup: function() { + this.controller.get('dashboard-player').addEventListener(Mojo.Event.tap, this.tapHandler.bindAsEventListener(this)); + if (typeof this.musicPlayer !== "undefined" && this.musicPlayer !== 0) { + if (typeof this.musicPlayer.audio() !== "undefined") { + this.setupListeners(); + this.updateSong(); + } + } + }, + + handleLockEvent: function(event) { + this.locked = !!event.locked; + }, + cleanup: function() { + this.removeListeners(); + Ares.cleanupSceneAssistant(this); + }, + + updateSong: function(arg) { + if (typeof arg === "undefined") { + Mojo.Log.info("Updating the dashboard"); + var song = this.musicPlayer.song(); + var data = { + title: song.name, + artist: song.artist, + pause: this.musicPlayer.isPlaying() ? "pause" : "", + unlike: this.musicPlayer.liked() ? "unlike" : "" + }; + var renderedInfo = Mojo.View.render({ + object: data, + template: 'dashboard/dashboard-player' + }); + // Insert the HTML into the DOM, replacing the existing content. + this.controller.get('dashboard-player').update(renderedInfo); + myNewString = this.musicPlayer.photo().replace("original", "max200"); + strarray = myNewString.split("."); + if (strarray[strarray.length - 1] === "jpeg" || strarray[strarray.length - 1] === "gif") myNewString = Mojo.appPath + "/images/8tracksDash2.png"; + // the template render doesn't do this properly, doing it manually + this.controller.get('dashboard-player-art').style.background = "url(\"" + myNewString + "\") center center no-repeat"; + }else{ + Mojo.Log.info("Updating the dashboard"); + var data = { + title: arg, + artist: "", + pause: this.musicPlayer.isPlaying() ? "pause" : "", + unlike: this.musicPlayer.liked() ? "unlike" : "" + }; + var renderedInfo = Mojo.View.render({ + object: data, + template: 'dashboard/dashboard-player' + }); + // Insert the HTML into the DOM, replacing the existing content. + this.controller.get('dashboard-player').update(renderedInfo); + myNewString = this.musicPlayer.photo().replace("original", "max200"); + strarray = myNewString.split("."); + if (strarray[strarray.length - 1] === "jpeg" || strarray[strarray.length - 1] === "gif") myNewString = Mojo.appPath + "/images/8tracksDash2.png"; + // the template render doesn't do this properly, doing it manually + //var thumbUrl = this.musicPlayer.photo();//Util.albumArtLargeUrlFormatter(song.thumbnails[0]); + this.controller.get('dashboard-player-art').style.background = "url(\"" + myNewString + "\") center center no-repeat"; + } + }, + trackEnded: function(event) { + this.musicPlayer = DashPlayerInstance; + this.updateSong(); + }, + trackChange: function(event) { + this.musicPlayer = DashPlayerInstance; + this.updateSong(); + }, + trackPaused: function(event) { + if (!this.musicPlayer.isPlaying()) { + this.controller.get('playpause').removeClassName("pause"); + } else { + this.controller.get('playpause').addClassName("pause"); + } + }, + togglePlay: function() { + if (this.musicPlayer.isPlaying()) { + this.controller.get('playpause').removeClassName("pause"); + this.musicPlayer.audio().pause(); + } else { + this.controller.get('playpause').addClassName("pause"); + this.musicPlayer.audio().play(); + } + }, + + toggleLike: function() { + if (this.musicPlayer.liked()) { + this.controller.get('likeunlike').removeClassName("unlike"); + this.musicPlayer.toggleLike(false); + } else { + this.controller.get('likeunlike').addClassName("unlike"); + this.musicPlayer.toggleLike(true); + } + }, + + updatePausePlayIcon: function() { + if (this.musicPlayer.isPlaying()) { + this.controller.get('playpause').addClassName("pause"); + } else { + this.controller.get('playpause').removeClassName("pause"); + } + }, + + tapHandler: function(event) { + var id = event.target.id; + if (id === 'playpause') { + this.togglePlay(); + } else if (id === 'next') { + this.musicPlayer.skipTrack(); + this.updateSong("Retrieving Next..."); + } else if (id === 'likeunlike') { + this.toggleLike(); + } else { + if (!this.locked) { + //AppAssistant.appManagerService.relaunchMusicPlayer(); + } + } + } +}; \ No newline at end of file diff --git a/app/assistants/gridScene-assistant.js b/app/assistants/gridScene-assistant.js new file mode 100644 index 0000000..c0eeb4d --- /dev/null +++ b/app/assistants/gridScene-assistant.js @@ -0,0 +1,803 @@ +function GridSceneAssistant(argFromPusher, pagecount, setid, loggedin, username, password, userid) { + this.loggedin = loggedin; + this.userid = -1; + this.mixCount = 4; + if (loggedin) { + this.userid = userid; + this.username = username; + this.password = password; + this.mixCount = 7; + } + this.sCount = 1; + this.tracks = argFromPusher; + this.setid = setid; + this.currentpage = 1; + this.type = "recent"; + this.typelabel = "Latest"; + this.loaded = false; + this.getNextMix = function(count, total) { + return count % total; + }; + + this.pagecount = Math.round(parseInt(pagecount, 0) / 10); + this.writeDescription = function() { + if (this.typelabel == "My Mixes") { + this.$.divider1.setLabel(this.typelabel + " (" + this.currentpage + "/" + this.pagecount + ")"); //Latest Mixes ( 1/10) + } else { + this.$.divider1.setLabel(this.typelabel + " Mixes (" + this.currentpage + "/" + this.pagecount + ")"); //Latest Mixes ( 1/10) + } + this.controller.get('scroller2').mojo.revealTop(); + }; + this.popUp = function(title, message) { + this.controller.showAlertDialog({ + title: title, + message: message, + choices: [ + { + label: "OK", + value: "", + type: 'dismiss' + } + ] + }); + }; + this.fillList = function(tracks, setid) { + if (typeof setid !== "undefined") { + this.setid = setid; + } + var list = new Array(tracks.length); + for (var i = 0; i < tracks.length; i++) { + var name = tracks[i].name; + var tag = tracks[i].tag_list_cache; + if (name !== null) { + if (name.length > 30) { + name = name.substring(0, 30) + "..."; + } + } + if (tag !== null) { + if (tag.length > 30) { + tag = tag.substring(0, 30) + "..."; + } + } + list[i] = { + title: name, + leftImage: tracks[i].cover_urls.sq56.toString() === "/images/mix_covers/sq56.gif" ? Mojo.appPath + "/images/no_image.png" : tracks[i].cover_urls.sq56, + tag: tag, + mixInfo: tracks[i], + set_id: this.setid, + type: "mix" + }; + } + listModel = { + items: list + }; + return { + getList: function() { + return listModel; + } + }; + }; + this.fillUserList = function(users) { + var list = new Array(users.length); + for (var i = 0; i < users.length; i++) { + var bio = "No Bio Info"; + if (users[i].bio_html !== null) { + if (users[i].bio_html.indexOf("

") >= 0) { + bio = users[i].bio_html.split("

")[1]; + bio = bio.split("

")[0]; + if (bio.length > 50) { + bio = bio.substring(0, 50) + "..."; + } + } + } + list[i] = { + title: users[i].login, + leftImage: users[i].avatar_urls.sq56.toString() === "/images/avatars/sq56.jpg" ? Mojo.appPath + "/images/no_image.png" : users[i].avatar_urls.sq56, + tag: bio, + mixID: users[i].id, + type: "user", + userinfo: users[i] + //set_id: this.setid + }; + } + listModel = { + items: list + }; + return { + getList: function() { + return listModel; + } + }; + }; +} + +GridSceneAssistant.prototype = { + setup: function() { + this.cmdMenuModel = { + visible: true, + items: [ + { + items: [{ + width: 30 + }] + }, + { + items: [{ + icon: "back", + command: 'back', + label: $L("Back"), + disabled: this.currentpage === 1 + },{ + icon: "forward", + command: 'fwd', + label: $L("Forward") + }] + }, + { + items: [{ + label: 'Latest', + command: 'type' + }] + }] + }; + + this.controller.setupWidget(Mojo.Menu.commandMenu, { + //spacerHeight: 0, + menuClass: 'no-fade' + }, + this.cmdMenuModel); + this.feedMenuModel = { + visible: true, + items: [ + { + items: [{ + width: 0 + }, + { + label: "8tracks", + width: 320 + }] + }] + }; + this.controller.setupWidget(Mojo.Menu.viewMenu, { + spacerHeight: 0, + menuClass: 'no-fade' + }, + this.feedMenuModel); + + this.cookie2 = new Mojo.Model.Cookie("prefs"); + var thm = "none"; + if (this.cookie2.get()) { + thm = this.cookie2.get().theme + } + + this.appMenuModel = { + items: [ + { + label: this.loggedin ? "Logout " + this.username : "Login", + command: this.loggedin ? 'logout' : 'login', + shortcut: 'l' + }, + { + label: "Support", + command: 'support' + }, + { + label: $L("Themes"), + items: [ + { + label: "Dark", + command: 'dark', + iconPath: thm == 'dark' ? Mojo.appPath + "/images/check_mark.png" : "none" + }, + { + label: "Light", + command: 'lite', + iconPath: thm == 'lite' ? Mojo.appPath + "/images/check_mark.png" : "none" + }, + { + label: "Light2", + command: 'lite2', + iconPath: thm == 'lite2' ? Mojo.appPath + "/images/check_mark.png" : "none" + }, + { + label: "Flat White", + command: 'flat', + iconPath: thm == 'flat' ? Mojo.appPath + "/images/check_mark.png" : "none" + }, + { + label: "Blue", + command: 'blue', + iconPath: thm == 'blue' ? Mojo.appPath + "/images/check_mark.png" : "none" + }, + { + label: "Red", + command: 'red', + iconPath: thm == 'red' ? Mojo.appPath + "/images/check_mark.png" : "none" + } + ] + } + ] + }; + this.controller.setupWidget(Mojo.Menu.appMenu, {}, + this.appMenuModel); + this.controller.document.addEventListener("keyup", this.keyupHandler.bind(this), true); + Ares.setupSceneAssistant(this); + }, + cleanup: function() { + this.controller.document.removeEventListener("keyup", this.keyupHandler.bind(this), true); + Ares.cleanupSceneAssistant(this); + }, + activate: function(response, username, password) { + this.cookie2 = new Mojo.Model.Cookie("prefs"); + if (this.cookie2.get()) { + props = themeLookup(this.cookie2.get().theme); + this.controller.get('gridScene').style.backgroundImage = props.URL; + this.$.list1.style.addStyles({ + textColor: props.textColor + }); + } + if (response) { + if (typeof response.search === "undefined") { + this.loggedin = response.loggedin; + this.username = response.username; + this.password = response.password; + this.userid = response.id; + this.appMenuModel.items[0].command = "logout"; + this.appMenuModel.items[0].label = "Logout " + this.username; + this.mixCount = 7; + this.controller.modelChanged(this.appMenuModel, this); + } + } + if (!this.loaded) { + this.showBanner("Just Type to Search..."); + this.loaded = true; + } + if (this.type != "followed") { + f = this.fillList(this.tracks); + this.controller.setWidgetModel("list1", f.getList()); + this.writeDescription(); + } else { + var onComplete = function(transport) { + if (transport.status === 200) { + this.currentpage = 1; + this.pagecount = Math.round(parseInt(transport.responseJSON.total_entries, 0) / 10); + this.$.divider1.setLabel("Followed Users (" + this.currentpage + "/" + this.pagecount + ")"); //Latest Mixes ( 1/10) + this.controller.get('scroller2').mojo.revealTop(); + this.cmdMenuModel.items[2].items[0].label = this.typelabel; + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.cmdMenuModel.items[2].items[0].label = this.typelabel; + //this.cmdMenuModel.items[2].items[0].command = this.type; + this.controller.modelChanged(this.cmdMenuModel, this); + f = this.fillUserList(transport.responseJSON.users); + this.controller.setWidgetModel("list1", f.getList()); + } + this.showSpinner(false); + }; + var onFailure = function(transport) { + this.popUp("Oops!", "Couldn't retreive page " + this.currentpage); + }; + url = "http://8tracks.com/users/" + this.userid + "/follows_users.json"; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + } + this.showSpinner(false); + }, + showBanner: function(message) { + Mojo.Controller.getAppController().showBanner(message, { + source: 'notification' + }); + }, + keyupHandler: function(event) { + if (Mojo.Char.isValidWrittenChar(event.keyCode) || Mojo.Char.isDigit(event.keyCode)) { + if (event.srcElement.innerHTML.indexOf("mojo-scene-gridScene-scene-scroller") > 0 && event.srcElement.innerHTML.indexOf("mojo-scene-gridScene-scene-scroller") < 10) { + this.controller.stageController.pushScene('searchScrene', event.keyCode, this.userid); + } + } + }, + MixChange: function(direction) { + this.sCount = this.getNextMix(this.sCount + direction, this.mixCount); + if (this.sCount < 1) { + this.sCount = this.mixCount; + } else if (this.sCount > this.mixCount) { + this.sCount = 1; + } + switch (this.sCount) { + case 1: + reload = true; + if (this.type !== "recent") { + this.type = "recent"; + this.typelabel = "Latest"; + } + break; + case 2: + if (this.type !== "popular") { + reload = true; + this.type = "popular"; + this.typelabel = "Popular"; + } + // popular + break; + case 3: + // hot + if (this.type !== "hot") { + reload = true; + this.type = "hot"; + this.typelabel = "Hot"; + } + break; + case 4: + // random + if (this.type !== "random") { + reload = true; + this.type = "random"; + this.typelabel = "Random"; + } + break; + case 5: + if (this.type !== "liked") { + reload = true; + this.type = "liked"; + this.typelabel = "Liked"; + } + break; + case 6: + if (this.type !== "mine") { + reload = true; + this.type = "mine"; + this.typelabel = "My Mixes"; + } + break; + case 7: + if (this.type !== "followed") { + reload = true; + this.type = "followed"; + this.typelabel = "Following"; + } + break; + } + if (reload && this.type !== "followed") { + var onComplete = function(transport) { + this.currentpage = 1; + this.controller.modelChanged(this.cmdMenuModel, this); + this.tracks = transport.responseJSON.mixes; + this.setid = transport.responseJSON.mix_set_id; + this.pagecount = Math.ceil(parseInt(transport.responseJSON.total_entries, 0) / 10); + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount; + this.cmdMenuModel.items[2].items[0].label = this.typelabel; + //this.cmdMenuModel.items[2].items[0].command = this.type; + this.controller.modelChanged(this.cmdMenuModel,this); + this.writeDescription(); + f = this.fillList(this.tracks, transport.responseJSON.mix_set_id); + this.controller.setWidgetModel("list1", f.getList()); + this.showSpinner(false); + }; + var onFailure = function(transport) { + this.showSpinner(false); + this.popUp("Oops!", "Couldn't retreive page " + this.currentpage); + }; + var url = ""; + if (this.type === "liked") { + url = "http://8tracks.com/users/" + this.userid + "/mixes.json?view=liked"; + } else if (this.type === "mine") { + url = "http://8tracks.com/users/" + this.userid + "/mixes.json"; + } else { + url = "http://8tracks.com/mixes.json?page=1&sort=" + this.type; + } + this.request(url, onComplete.bind(this), onFailure.bind(this)); + } else if (reload && this.type === "followed") { + var onComplete = function(transport) { + if (transport.status === 200) { + this.currentpage = 1; + this.pagecount = Math.ceil(parseInt(transport.responseJSON.total_entries, 0) / 10); + this.$.divider1.setLabel("Followed Users (" + this.currentpage + "/" + this.pagecount + ")"); //Latest Mixes ( 1/10) + this.controller.get('scroller2').mojo.revealTop(); + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount; + this.cmdMenuModel.items[2].items[0].label = this.typelabel; + //this.cmdMenuModel.items[2].items[0].command = this.type; + this.controller.modelChanged(this.cmdMenuModel,this); + f = this.fillUserList(transport.responseJSON.users); + this.controller.setWidgetModel("list1", f.getList()); + } + this.showSpinner(false); + }; + var onFailure = function(transport) { + this.popUp("Oops!", "Couldn't retreive page " + this.currentpage); + }; + url = "http://8tracks.com/users/" + this.userid + "/follows_users.json"; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + } + }, + showSpinner: function(show) { + if (!show) { + this.feedMenuModel.items[0].items[1].width = 320; + this.feedMenuModel.items[0].items[0].width = 0; + this.controller.modelChanged(this.feedMenuModel, this); + } else { + this.feedMenuModel.items[0].items[1].width = 275; + this.feedMenuModel.items[0].items[0].width = 45; + this.controller.modelChanged(this.feedMenuModel, this); + } + this.$.spinner1.setSpinning(show); + }, + popupChoose: function(event) { + var reload = false; + switch (event) { + case "l_mixes": + reload = true; + this.sCount = 1; + if (this.type !== "recent") { + this.type = "recent"; + this.typelabel = "Latest"; + } + break; + case 'p_mixes': + this.sCount = 2; + if (this.type !== "popular") { + reload = true; + this.type = "popular"; + this.typelabel = "Popular"; + } + // popular + break; + case 'h_mixes': + // hot + this.sCount = 3; + if (this.type !== "hot") { + reload = true; + this.type = "hot"; + this.typelabel = "Hot"; + } + break; + case 'r_mixes': + // random + this.sCount = 4; + if (this.type !== "random") { + reload = true; + this.type = "random"; + this.typelabel = "Random"; + } + break; + case 'liked': + this.sCount = 5; + if (this.type !== "liked") { + reload = true; + this.type = "liked"; + this.typelabel = "Liked"; + } + break; + case 'mine': + this.sCount = 6; + if (this.type !== "mine") { + reload = true; + this.type = "mine"; + this.typelabel = "My Mixes"; + } + break; + case 'followed': + this.sCount = 7; + if (this.type !== "followed") { + reload = true; + this.type = "followed"; + this.typelabel = "Following"; + } + break; + } + if (reload && this.type !== "followed") { + var onComplete = function(transport) { + this.currentpage = 1; + this.tracks = transport.responseJSON.mixes; + this.setid = transport.responseJSON.mix_set_id; + this.pagecount = Math.ceil(parseInt(transport.responseJSON.total_entries, 0) / 10); + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount; + this.cmdMenuModel.items[2].items[0].label = this.typelabel; + // this.cmdMenuModel.items[2].items[0].command = this.type; + this.controller.modelChanged(this.cmdMenuModel, this); + this.writeDescription(); + f = this.fillList(this.tracks, transport.responseJSON.mix_set_id); + this.controller.setWidgetModel("list1", f.getList()); + this.showSpinner(false); + }; + var onFailure = function(transport) { + this.showSpinner(false); + this.popUp("Oops!", "Couldn't retreive page " + this.currentpage); + }; + var url = ""; + if (this.type === "liked") { + url = "http://8tracks.com/users/" + this.userid + "/mixes.json?view=liked"; + } else if (this.type === "mine") { + url = "http://8tracks.com/users/" + this.userid + "/mixes.json"; + } else { + url = "http://8tracks.com/mixes.json?page=1&sort=" + this.type; + } + this.request(url, onComplete.bind(this), onFailure.bind(this)); + } else if (reload && this.type === "followed") { + var onComplete = function(transport) { + if (transport.status === 200) { + this.currentpage = 1; + this.pagecount = Math.ceil(parseInt(transport.responseJSON.total_entries, 0) / 10); + this.$.divider1.setLabel("Followed Users (" + this.currentpage + "/" + this.pagecount + ")"); //Latest Mixes ( 1/10) + this.controller.get('scroller2').mojo.revealTop(); + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount; + this.cmdMenuModel.items[2].items[0].label = this.typelabel; + // this.cmdMenuModel.items[2].items[0].command = this.type; + this.controller.modelChanged(this.cmdMenuModel, this); + f = this.fillUserList(transport.responseJSON.users); + this.controller.setWidgetModel("list1", f.getList()); + } + this.showSpinner(false); + }; + var onFailure = function(transport) { + this.popUp("Oops!", "Couldn't retreive page " + this.currentpage); + }; + url = "http://8tracks.com/users/" + this.userid + "/follows_users.json"; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + } + }, + request: function(url, onComplete, onFailure) { + this.showSpinner(true); + var myAjax = new Ajax.Request(url, { + method: "get", + evalJSON: 'force', + contentType: 'application/x-www-form-urlencoded', + requestHeaders: { + "USER_AGENT": navigator.userAgent + }, + onComplete: onComplete, + onFailure: onFailure + }); + }, + getPreviousPage: function() { + if (this.currentpage - 1 > 0) { + this.currentpage -= 1; + var onComplete = function(transport) { + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount; + this.controller.modelChanged(this.cmdMenuModel, this); + this.tracks = transport.responseJSON.mixes; + this.writeDescription(); + f = this.fillList(this.tracks); + this.controller.setWidgetModel("list1", f.getList()); + this.showSpinner(false); + }; + var onFailure = function(transport) { + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.controller.modelChanged(this.cmdMenuModel, this); + this.showSpinner(false); + this.popUp("Oops!", "Couldn't retreive page " + this.currentpage); + }; + if (this.type === "liked") { + url = "http://8tracks.com/users/" + this.userid + "/mixes.json?view=liked&page=" + this.currentpage; + } else { + url = "http://8tracks.com/mixes.json?page=" + this.currentpage + "&sort=" + this.type; + } + this.request(url, onComplete.bind(this), onFailure.bind(this)); + } + }, + getNextPage: function() { + this.currentpage += 1; + var onComplete = function(transport) { + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount; + this.controller.modelChanged(this.cmdMenuModel, this); + this.tracks = transport.responseJSON.mixes; + this.writeDescription(); + f = this.fillList(this.tracks); + this.controller.setWidgetModel("list1", f.getList()); + this.showSpinner(false); + }; + var onFailure = function(transport) { + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount; + this.cmdMenuModel.items[2].items[0].label = this.typelabel; + this.showSpinner(false); + this.popUp("Oops!", "Couldn't retreive page " + this.currentpage); + }; + if (this.type === "liked") { + url = "http://8tracks.com/users/" + this.userid + "/mixes.json?view=liked&page=" + this.currentpage; + } else { + url = "http://8tracks.com/mixes.json?page=" + this.currentpage + "&sort=" + this.type; + } + this.request(url, onComplete.bind(this), onFailure.bind(this)); + }, + list1Listtap: function(inSender, event) { + if (event.item.type === "mix") { + this.controller.stageController.pushScene('mixDetailsScene', event.item.mixInfo, event.item.set_id, this.userid, this.username, this.password); + } else { + this.controller.stageController.pushScene('userInfo', event.item.userinfo, this.userid, this.username, this.password); + } + } +}; + +GridSceneAssistant.prototype.handleCommand = function(event) { + this.controller = Mojo.Controller.stageController.activeScene(); + var resetCheck = function(command) { + for (i = 0; i < this.appMenuModel.items[2].items.length; i++) { + if (this.appMenuModel.items[2].items[i].command == command) { + this.appMenuModel.items[2].items[i].iconPath = Mojo.appPath + "/images/check_mark.png"; + } else { + this.appMenuModel.items[2].items[i].iconPath = "none"; + } + } + }.bind(this); + if (event.type == Mojo.Event.command) { + switch (event.command) { + case 'fwd': + if (this.currentpage < this.pagecount) { + this.getNextPage(); + } + break; + case 'back': + if (this.currentpage !== 1) { + this.getPreviousPage(); + } + break; + case 'search': + this.controller.stageController.pushScene('searchScrene'); + break; + case 'dark': + this.cookie = new Mojo.Model.Cookie("prefs"); + this.cookie.put({ + theme: event.command + }); + props = themeLookup(event.command); + this.controller.get('gridScene').style.backgroundImage = props.URL; + this.$.list1.style.addStyles({ + textColor: props.textColor + }); + resetCheck(event.command); + break; + case 'lite': + this.cookie = new Mojo.Model.Cookie("prefs"); + this.cookie.put({ + theme: event.command + }); + props = themeLookup(event.command); + this.controller.get('gridScene').style.backgroundImage = props.URL; + this.$.list1.style.addStyles({ + textColor: props.textColor + }); + resetCheck(event.command); + break; + case 'lite2': + this.cookie = new Mojo.Model.Cookie("prefs"); + this.cookie.put({ + theme: event.command + }); + props = themeLookup(event.command); + this.controller.get('gridScene').style.backgroundImage = props.URL; + this.$.list1.style.addStyles({ + textColor: props.textColor + }); + resetCheck(event.command); + break; + case 'flat': + this.cookie = new Mojo.Model.Cookie("prefs"); + this.cookie.put({ + theme: event.command + }); + props = themeLookup(event.command); + this.controller.get('gridScene').style.backgroundImage = props.URL; + this.$.list1.style.addStyles({ + textColor: props.textColor + }); + resetCheck(event.command); + break; + case 'blue': + this.cookie = new Mojo.Model.Cookie("prefs"); + this.cookie.put({ + theme: event.command + }); + props = themeLookup(event.command); + this.controller.get('gridScene').style.backgroundImage = props.URL; + this.$.list1.style.addStyles({ + textColor: props.textColor + }); + resetCheck(event.command); + break; + case 'red': + this.cookie = new Mojo.Model.Cookie("prefs"); + this.cookie.put({ + theme: event.command + }); + props = themeLookup(event.command); + this.controller.get('gridScene').style.backgroundImage = props.URL; + this.$.list1.style.addStyles({ + textColor: props.textColor + }); + resetCheck(event.command); + break; + case 'login': + this.controller.stageController.pushScene('login'); + break; + case 'logout': + this.cookie = new Mojo.Model.Cookie("credentials"); + this.cookie.put({ + username: "", + password: "", + token: 0 + }); + this.loggedin = false; + this.username = ""; + this.password = ""; + this.userid = -1; + this.mixCount = 4; + this.appMenuModel.items[0].command = "login"; + this.appMenuModel.items[0].label = "Login"; + this.controller.modelChanged(this.appMenuModel, this); + break; + case 'support': + this.controller.serviceRequest("palm://com.palm.applicationManager", { + method: 'open', + parameters: { + id: "com.palm.app.email", + params: { + summary: "8tracks Support Request: v1.2.9", + recipients: [{ + type: "email", + role: 1, + value: "GTestaSoftware@gmail.com", + contactDisplay: "8tracks Support" + }] + } + } + }); + break; + case 'type': + this.controller.popupSubmenu({ + onChoose: this.popupChoose, + placeNear: event.originalEvent.target, + items: [ + { + label: 'Latest', + command: 'l_mixes', + iconPath: this.type == 'recent' ? Mojo.appPath + "/images/check_mark.png" : "none" + }, + { + label: 'Popular', + command: 'p_mixes', + iconPath: this.type == 'popular' ? Mojo.appPath + "/images/check_mark.png" : "none" + }, + { + label: 'Hot', + command: 'h_mixes', + iconPath: this.type == 'hot' ? Mojo.appPath + "/images/check_mark.png" : "none" + }, + { + label: 'Random', + command: 'r_mixes', + iconPath: this.type == 'random' ? Mojo.appPath + "/images/check_mark.png" : "none" + }, + { + label: 'Liked', + command: 'liked', + disabled: !this.loggedin, + iconPath: this.type == 'liked' ? Mojo.appPath + "/images/check_mark.png" : "none" + }, + { + label: 'My Mixes', + command: 'mine', + disabled: !this.loggedin, + iconPath: this.type == 'mine' ? Mojo.appPath + "/images/check_mark.png" : "none" + }, + { + label: 'Following', + command: 'followed', + disabled: !this.loggedin, + iconPath: this.type == 'followed' ? Mojo.appPath + "/images/check_mark.png" : "none" + }] + }); + break; + } + } else if (event.type === Mojo.Event.back) { + event.stop(); + this.MixChange(-1); + } else if (event.type === Mojo.Event.forward) { + event.stop(); + this.MixChange(1); + + } +}; \ No newline at end of file diff --git a/app/assistants/login-assistant.js b/app/assistants/login-assistant.js new file mode 100644 index 0000000..d3c6dae --- /dev/null +++ b/app/assistants/login-assistant.js @@ -0,0 +1,99 @@ +function LoginAssistant(argFromPusher) { + this.popUp = function(title, message) { + this.controller.showAlertDialog({ + title: title, + message: message, + choices: [ + { + label: "OK", + value: "", + type: 'dismiss' + } + ] + }); + }; +} + +LoginAssistant.prototype = { + setup: function() { + Ares.setupSceneAssistant(this); + }, + cleanup: function() { + Ares.cleanupSceneAssistant(this); + }, + showSpinner: function(show) { + this.controller.get('activityButton1').mojo[(show ? 'activate' : 'deactivate')](); + }, + activate: function(args) { + this.cookie2 = new Mojo.Model.Cookie("prefs"); + if (this.cookie2.get()) { + props = themeLookup(this.cookie2.get().theme); + this.controller.get('login').style.backgroundImage = props.URL; + this.$.textField1.style.addStyles({ + textColor: props.textColor + }); + this.$.passwordField1.style.addStyles({ + textColor: props.textColor + }); + } + }, + + login: function(username, password) { + var postdata = "login=" + username + "&password=" + password; + + var myAjax = new Ajax.Request(url, { + method: "post", + parameters: postdata, + onComplete: onComplete, + onFailure: onFailure + }); + }, + + requestLogin: function(onComplete, onFailure) { + url = "http://8tracks.com/sessions.json"; + this.username = this.controller.get("textField1").mojo.getValue(); + this.password = this.controller.get("passwordField1").mojo.getValue(); + + var postdata = "login=" + this.username + "&password=" + this.password; + + var myAjax = new Ajax.Request(url, { + method: "post", + parameters: postdata, + onComplete: onComplete, + onFailure: onFailure + }); + }, + showBanner: function(message) { + Mojo.Controller.getAppController().showBanner(message, { + source: 'notification' + }); + }, + activityButton1Tap: function(inSender, event) { + this.showSpinner(true); + var onComplete = function(transport) { + if (transport.responseJSON.status === "200 OK") { + this.cookie = new Mojo.Model.Cookie("credentials"); + this.cookie.put({ + username: this.username, + password: this.password, + token: transport.responseJSON.auth_token + }); + this.showBanner("You are now logged in as " + this.username); + var data = { + loggedin: true, + username: this.username, + password: this.password, + id: transport.responseJSON.current_user.id + }; + this.controller.stageController.popScene(data); + } else { + this.popUp(tranport.responseJSON.status, transport.responseJSON.statusText); + } + }; + var onFailure = function(transport) { + this.popUp(tranport.responseJSON.status, transport.responseJSON.statusText); + }; + this.requestLogin(onComplete.bind(this), onFailure.bind(this)); + this.showSpinner(false); + } +}; \ No newline at end of file diff --git a/app/assistants/main-assistant.js b/app/assistants/main-assistant.js new file mode 100644 index 0000000..0265587 --- /dev/null +++ b/app/assistants/main-assistant.js @@ -0,0 +1,8 @@ +function MainAssistant() { +} + +MainAssistant.prototype.cleanup = function() { + // launch the dashboard when the main card scene is discarded + Mojo.Controller.getAppController().assistant.handleLaunch({action: 'dashboard'}); + MainAssistant.prototype.cleanup = function() {}; // changing the cleanup method so that it doesn't launch a dashboard the second time +} diff --git a/app/assistants/mixDetailsScene-assistant.js b/app/assistants/mixDetailsScene-assistant.js new file mode 100644 index 0000000..019dc4f --- /dev/null +++ b/app/assistants/mixDetailsScene-assistant.js @@ -0,0 +1,357 @@ +function MixDetailsSceneAssistant(argFromPusher, setid, userid, username, password) { + this.userid = -1; + if (userid !== -1) { + this.loggedin = true; + this.userid = userid; + this.username = username; + this.password = password; + this.cookie = new Mojo.Model.Cookie("credentials"); + if (this.cookie.get()) { + this.token = this.cookie.get().token; + } + } + this.mixInfo = argFromPusher; + this.liked = this.mixInfo.liked_by_current_user; + this.setid = setid; + this.writeDetails = function(name, description, tags) { + this.$.name.setLabel(name); + this.$.description.setLabel(description); + this.$.tags.setLabel(tags); + }; + this.setPicture = function(picture) { + this.$.picture1.setSrc(picture); + }; + this.setUserInfo = function(info) { + this.$.creator.setLabel(info); + }; + this.checkBoxState = function(checked) { + this.$.checkBox1.setValue(checked); + }; + this.showBanner = function(message) { + Mojo.Controller.getAppController().showBanner(message, { + source: 'notification' + }); + }; + this.popUp = function(title, message) { + this.showBanner(message); + }; +} + +MixDetailsSceneAssistant.prototype = { + setup: function() { + if (this.userid === -1) { + this.cmdMenuModel = { + visible: true, + items: [ + { + items: [{ + iconPath: 'images/user_info.png', + label: $L('Info'), + command: 'info' + }] + },{ + items: [{ + label: $L('Listen'), + command: 'play' + }] + }] + }; + } else { + if (!this.liked) { + this.cmdMenuModel = { + visible: true, + items: [ + { + items: [{ + iconPath: 'images/user_info.png', + label: $L('Info'), + command: 'info' + }] + }, + { + items: [{ + iconPath: 'images/mixlikeheart2.png', + label: $L('Like'), + command: 'like' + }] + }, + { + items: [{ + label: $L('Listen'), + command: 'play' + }] + }] + }; + } else { + this.cmdMenuModel = { + visible: true, + items: [ + { + items: [{ + iconPath: 'images/user_info.png', + label: $L('Info'), + command: 'info' + }] + }, + { + items: [{ + iconPath: 'images/mixunlikeheart1.png', + label: $L('Unlike'), + command: 'unlike' + }] + }, + { + items: [{ + label: $L('Listen'), + command: 'play' + }] + }] + }; + } + } + + this.controller.setupWidget(Mojo.Menu.commandMenu, { + menuClass: 'no-fade' + }, + this.cmdMenuModel); + this.feedMenuModel = { + visible: true, + items: [ + { + items: [{ + width: 0 + }, + { + label: this.mixInfo.name, + width: 320 + }] + } + ] + }; + this.controller.setupWidget(Mojo.Menu.viewMenu, { + spacerHeight: 0, + menuClass: 'no-fade' + }, + this.feedMenuModel); + + this.appMenuModel = { + items: [ + { + label: "Share Mix...", + command: 'share' + } + ] + }; + this.controller.setupWidget(Mojo.Menu.appMenu, {}, + this.appMenuModel); + Ares.setupSceneAssistant(this); + }, + cleanup: function() { + Ares.cleanupSceneAssistant(this); + }, + activate: function(data) { + this.cookie2 = new Mojo.Model.Cookie("prefs"); + if (this.cookie2.get()) { + props = themeLookup(this.cookie2.get().theme); + this.controller.get('mixDetailsScene').style.backgroundImage = props.URL; + this.$.tags.style.addStyles({ + textColor: props.textColor + }); + this.$.name.style.addStyles({ + textColor: props.textColor + }); + this.$.description.style.addStyles({ + textColor: props.textColor + }); + this.$.creator.style.addStyles({ + textColor: props.textColor + }); + } + if (typeof data !== "undefined") { + if (data.mixInfo.name != this.mixInfo.name) { + this.mixInfo = data.mixInfo; + this.feedMenuModel.items[0].items[1].label = this.mixInfo.name; + this.controller.modelChanged(this.feedMenuModel, this); + } + if (this.loggedin && this.liked !== data.likedMix) { + response = { + responseJSON: { + status: "200 OK", + bypass: true + } + }; + if (data.likedMix) { + this.LikedComplete(response); + } else { + this.UnLikedComplete(response); + } + if(typeof data.error !== "undefined"){ + switch(data.error){ + case 1: + break; + case 2: + break; + case 3: + break; + default: + this.showBanner("There was an error playing that last mix!"); + break; + } + } + } + } + this.showSpinner(false); + this.writeDetails(this.mixInfo.name, this.mixInfo.description, this.mixInfo.tag_list_cache); + this.setPicture(this.mixInfo.user.avatar_urls.sq56); + this.setUserInfo(this.mixInfo.user.login); + }, + + showSpinner: function(show) { + if (!show) { + this.feedMenuModel.items[0].items[1].width = 320; + this.feedMenuModel.items[0].items[0].width = 0; + this.controller.modelChanged(this.feedMenuModel, this); + } else { + this.feedMenuModel.items[0].items[1].width = 275; + this.feedMenuModel.items[0].items[0].width = 45; + this.controller.modelChanged(this.feedMenuModel, this); + } + this.$.spinner1.setSpinning(show); + }, + request: function(url, onComplete, onFailure) { + this.showSpinner(true); + var myAjax = new Ajax.Request(url, { + method: "get", + evalJSON: 'force', + contentType: 'application/x-www-form-urlencoded', + requestHeaders: { + "USER_AGENT": navigator.userAgent + }, + onComplete: onComplete, + onFailure: onFailure + }); + }, + playMix: function() { + var onComplete = function(transport) { + if (transport.status == 200) { + this.showSpinner(false); + this.controller.stageController.pushScene('player', this.mixInfo, this.token, transport.responseJSON, this.mixInfo.cover_urls.original, this.setid, this.userid, this.username, this.password, this.cmdMenuModel.items[1].items[0].command); + } + }; + var onFailure = function(transport) { + this.showSpinner(false); + this.popUp(transport.responseJSON.status, transport.responseJSON.notices[0]); + }; + var url = "http://8tracks.com/sets/" + this.token + "/play.json?mix_id=" + this.mixInfo.id; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + }, + loadPlaylist: function() { + var onComplete = function(transport) { + if (transport.status == 200) { + this.token = transport.responseJSON.play_token; + this.playMix(); + } else { + this.popUp("Error", "Didn't Get 200 from json response"); + } + }; + var onFailure = function() { + this.showSpinner(false); + this.popUp("Oops", "failed to get play_token"); + }; + var url = "http://8tracks.com/sets/new.json"; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + }, + Like: function() { + var onFailure = function(transport) { + this.popUp("Error", "Could not add mix to your liked mix. Try to login again"); + }; + + var postdata = "login=" + this.username + "&password=" + this.password; + var url = "http://8tracks.com/mixes/" + this.mixInfo.id + "/like.json"; + var myAjax = new Ajax.Request(url, { + method: "post", + requestHeader: postdata, + onComplete: this.LikedComplete.bind(this), + onFailure: onFailure.bind(this) + }); + }, + LikedComplete: function(response) { + if (response.responseJSON.status === "200 OK") { + if (typeof response.responseJSON.bypass === "undefined") { + this.popUp("Success", "Mixed added to your Liked list"); + } + this.liked = true; + this.cmdMenuModel.items[1].items[0].iconPath = 'images/mixunlikeheart1.png'; + this.cmdMenuModel.items[1].items[0].label = "Unlike"; + this.cmdMenuModel.items[1].items[0].command = "unlike"; + this.controller.modelChanged(this.cmdMenuModel, this); + } else { + this.popUp(response.responseJSON.status, response.responseJSON.notices); + } + }, + UnLike: function() { + var onFailure = function(transport) { + this.popUp("Error", "Could not remove mix to your liked mix. Try to login again"); + }; + var postdata = "login=" + this.username + "&password=" + this.password; + url = "http://8tracks.com/mixes/" + this.mixInfo.id + "/unlike.json"; + var myAjax = new Ajax.Request(url, { + method: "post", + requestHeader: postdata, + onComplete: this.UnLikedComplete.bind(this), + onFailure: onFailure.bind(this) + }); + }, + UnLikedComplete: function(response) { + if (response.responseJSON.status === "200 OK") { + if (typeof response.responseJSON.bypass === "undefined") { + this.popUp("Success", "Mixed removed from your Liked list"); + } + this.liked = false; + this.cmdMenuModel.items[1].items[0].iconPath = 'images/mixlikeheart2.png'; + this.cmdMenuModel.items[1].items[0].label = "Like"; + this.cmdMenuModel.items[1].items[0].command = "like"; + this.controller.modelChanged(this.cmdMenuModel, this); + } else { + this.popUp(response.responseJSON.status, response.responseJSON.notices); + } + } +}; + +MixDetailsSceneAssistant.prototype.handleCommand = function(event) { + this.controller = Mojo.Controller.stageController.activeScene(); + if (event.type == Mojo.Event.command) { + switch (event.command) { + case 'play': + this.loadPlaylist(); + break; + case 'info': + this.controller.stageController.pushScene('userInfo', this.mixInfo.user, this.userid, this.username, this.password); + break; + case 'like': + this.Like(); + break; + case 'unlike': + this.UnLike(); + break; + case 'share': + this.controller.serviceRequest("palm://com.palm.applicationManager", { + method: 'open', + parameters: { + id: "com.palm.app.email", + params: { + summary: "Checkout this 8tracks mix!", + text: "Checkout this Mix: \n" + this.mixInfo.name + "\nwww.8tracks.com" + this.mixInfo.path + } + } + }); + break; + } + } else if (event.type === Mojo.Event.back) { + data = { + search: true + }; + event.stop(); + this.controller.stageController.popScene(data); + } +}; \ No newline at end of file diff --git a/app/assistants/player-assistant.js b/app/assistants/player-assistant.js new file mode 100644 index 0000000..e037971 --- /dev/null +++ b/app/assistants/player-assistant.js @@ -0,0 +1,909 @@ +function PlayerAssistant(argFromPusher, token, response, mixphoto, setid, userid, username, password, liked) { + this.mixID = argFromPusher; + this.token = token; + this.userid = -1; + this.loggedin = false; + if (userid !== -1) { + this.liked = liked == "unlike"; + this.userid = userid; + this.username = username; + this.password = password; + this.loggedin = true; + } + this.toggle = false; + this.tracks = new Array(); + this.tracks.push(response.set.track); + this.trackinfo = response; + this.mphoto = mixphoto.toString() === "/images/mix_covers/original.gif" ? Mojo.appPath + "/images/tracks_01.png" : mixphoto; + this.lastsong = false; + this.songProps = new Array(); //skipped durations liked + this.toReadableTime = function(duration) { + var minutes = parseFloat(duration) / 60.0; + var seconds = Math.round((minutes % 1) * 60); + var s = (seconds / 100).toFixed(2); + var s1 = seconds.toString().split("."); + return s1[0].toString().length > 1 ? Math.floor(minutes) + ":" + s1[0] : Math.floor(minutes) + ":0" + s1[0]; + }; + this.listindex = 0; + this.setid = setid; + this.songstate = 1; + this.headsetService = undefined; + this.setupListeners = function() { + this.audio1.addEventListener('ended', this.trackEnded.bind(this), false); + this.audio1.addEventListener('play', this.trackPlay.bind(this), false); + this.audio1.addEventListener('playing', this.trackPlaying.bind(this), false); + this.audio1.addEventListener('pause', this.trackPaused.bind(this), false); + this.audio1.addEventListener('timeupdate', this.updateScrubber.bind(this), false); + this.audio1.addEventListener('stalled', this.trackStalled.bind(this), false); + this.audio1.addEventListener('error', this.trackError.bind(this), false); + this.audio1.addEventListener('canplay', this.trackReady.bind(this), false); + this.audio1.addEventListener('ratechange', this.trackRateChange.bind(this), false); + this.audio1.addEventListener('durationchange', this.trackDurationChanged.bind(this), false); + }; + this.removeListeners = function() { + this.audio1.removeEventListener('pause', this.trackPaused.bind(this), false); + this.audio1.removeEventListener('play', this.trackPlay.bind(this), false); + this.audio1.removeEventListener('playing', this.trackPlaying.bind(this), false); + this.audio1.removeEventListener('Ended', this.trackEnded.bind(this), false); + this.audio1.removeEventListener('timeupdate', this.updateScrubber.bind(this), false); + this.audio1.removeEventListener('stalled', this.trackStalled.bind(this), false); + this.audio1.removeEventListener('error', this.trackError.bind(this), false); + this.audio1.removeEventListener('canplay', this.trackReady.bind(this), false); + this.audio1.removeEventListener('ratechange', this.trackRateChange.bind(this), false); + this.audio1.removeEventListener('durationchange', this.trackDurationChanged.bind(this), false); + }; + this.writeDescription = function() { + this.$.divider2.setLabel("Tracks(" + this.tracks.length + ")"); + }; + this.downloaded = false; + if (typeof this.audio1 !== "object") { + this.audio1 = new Audio(); + } + this.sound = new Audio(); + this.sound.autoplay = true; + this.downloadImage = function(url, onSuccess, onFailure) { + if (!this.downloaded) { + split = url.split("/"); + name = split[split.length - 1]; + name = name.split(".")[0] + "." + name.split(".")[2]; + this.controller.serviceRequest('palm://com.palm.downloadmanager/', { + method: 'download', + parameters: { + target: url, + targetDir: "/media/internal/files/8tracks", + targetFilename: name, + keepFilenameOnRedirect: false, + subscribe: false + }, + onSuccess: onSuccess, + onFailure: onFailure + }); + this.downloaded = true; + } + }; + this.fillList = function(tracks) { + this.list = new Array(tracks.length); + for (var i = 0; i < tracks.length; i++) { + if (i !== tracks.length - 1) { + if (this.songProps[i].skipped) { + this.list[i] = { + title: tracks[i].name, + currentartist: tracks[i].performer, + skipped: tracks[i].name, + likeImage: this.songProps[i].liked === true ? "images/likedstar.png" : "images/unlikedstar.png", + duration: this.songProps[i].duration.toString() === "NaN:NaN" ? "?" : this.songProps[i].duration, + liked: this.songProps[i].liked + }; + } else { + this.list[i] = { + title: tracks[i].name, + currentartist: tracks[i].performer, + oldsong: tracks[i].name, + likeImage: this.songProps[i].liked === true ? "images/likedstar.png" : "images/unlikedstar.png", + duration: this.songProps[i].duration.toString() == "NaN:NaN" ? "?" : this.songProps[i].duration, + liked: this.songProps[i].liked + }; + } + } else { + if (this.songProps[i].set === false) { + this.songProps[i].liked = tracks[i].faved_by_current_user; + this.songProps[i].set = true; + } + this.list[i] = { + title: tracks[i].name, + currentartist: tracks[i].performer, + currentsong: tracks[i].name, + likeImage: "images/speaker.png", + duration: "...", + liked: this.songProps[i].liked + }; + } + } + listModel = { + items: this.list.reverse() + }; + return { + getList: function() { + return listModel; + } + }; + }; + this.populateList = function() { + f = this.fillList(this.tracks); + this.controller.setWidgetModel("list1", f.getList()); + }; + this.banner = function(message) { + Mojo.Controller.getAppController().showBanner(message, { + source: 'notification' + }); + }; +} + +PlayerAssistant.prototype = { + setup: function() { + this.feedMenuModel = { + visible: true, + items: [ + { + items: [{ + width: 0 + }, + { + label: this.mixID.name, + width: 320 + }] + }] + }; + this.controller.setupWidget(Mojo.Menu.viewMenu, { + spacerHeight: 0, + menuClass: 'no-fade' + }, + this.feedMenuModel); + this.cmdMenuModel = { + visible: true, + items: [ + {}, + { + items: [{ + iconPath: 'images/pause1.png', + label: $L('Pause'), + command: '0' + },{ + iconPath: 'images/forward.png', + label: $L('Forward'), + command: 'fwd' + }] + },{}] + }; + + this.controller.setupWidget(Mojo.Menu.commandMenu, { + //spacerHeight: 0, + menuClass: 'no-fade' + }, + this.cmdMenuModel); + this.cookie3 = new Mojo.Model.Cookie("nmp"); + if (!this.cookie3.get()) { + nmpState = 'autoplay'; + } else { + nmpState = this.cookie3.get().answer; + } + + this.appMenuModel = { + items: [ + { + label: "Share Mix...", + command: 'share' + }, + { + label: this.liked ? "Unlike Mix" : "Like Mix", + command: this.liked ? 'unlike' : 'like', + disabled: !this.loggedin + }, + { + label: "Auto-play Next Mix", + command: nmpState == 'autoplay' ? "return" : "autoplay", + iconPath: nmpState == 'autoplay' ? Mojo.appPath + "/images/check_mark.png" : "none" + } + ] + }; + + if (!this.loggedin) { + this.appMenuModel.items[1].label = "Like Mix (Login Required)"; + } + this.controller.setupWidget(Mojo.Menu.appMenu, {}, + this.appMenuModel); + + this.controller.setupWidget("progressbarId", this.attributes = { + title: "Progress Bar", + image: "images/header-icon.png", + modelProperty: "progress" + }, + this.model = { + iconPath: "../images/progress-bar-background.png", + progress: 0 + }); + + this.headsetService = new Mojo.Service.Request('palm://com.palm.keys/headset', { + method: 'status', + parameters: { + 'subscribe': true + }, + onFailure: function() { + Mojo.Log.error("Could not subscribe to headset events"); + }, + onSuccess: this.handleheadset.bind(this) + }); + + if (this.audio1.currentSrc.length > 0) { + this.removeListeners(); + this.audio1.pause(); + this.audio1 = 0; + this.audio1 = new Audio(); + } + this.setupListeners(); + Ares.setupSceneAssistant(this); + }, + cleanup: function() { + this.audio1.pause(); + this.removeListeners(); + this.audio1 = 0; + if (this.headsetService) { + this.headsetService.cancel(); + } + DashPlayerInstance = 0; + Ares.cleanupSceneAssistant(this); + }, + activate: function() { + this.showSpinner(true); + this.cookie2 = new Mojo.Model.Cookie("prefs"); + if (this.cookie2.get()) { + props = themeLookup(this.cookie2.get().theme); + this.controller.get('player').style.backgroundImage = props.URL; + this.$.list1.style.addStyles({ + textColor: props.textColor + }); + } + this.$.picture1.setSrc(this.mphoto); + + songprop = { + skipped: false, + duration: 0, + liked: false, + set: false + }; + this.songProps.push(songprop); + this.writeDescription(); + this.populateList(); + if (!this.audio1.paused) { + this.audio1.pause(); + } + this.audio1.src = this.trackinfo.set.track.url; + this.audio1.load(); + + DashPlayerInstance = new DashboardPlayer(); + DashPlayerInstance.setSkipEvent(this.skipTrack.bind(this)); + DashPlayerInstance.setLikeToggleEvent(this.setLikeStateCurrent.bind(this)); + DashPlayerInstance.update(this.audio1, this.mphoto, this.trackinfo); + }, + showSpinner: function(show) { + if (!show) { + this.feedMenuModel.items[0].items[1].width = 320; + this.feedMenuModel.items[0].items[0].width = 0; + this.controller.modelChanged(this.feedMenuModel, this); + } else { + this.feedMenuModel.items[0].items[1].width = 275; + this.feedMenuModel.items[0].items[0].width = 45; + this.controller.modelChanged(this.feedMenuModel, this); + } + this.$.spinner1.setSpinning(show); + }, + + showBanner: function(message) { + Mojo.Controller.getAppController().showBanner(message, { + source: 'notification' + }); + }, + handleheadset: function(payload) { + if (payload.state == "double_click") { + this.skipTrack(); + } else if (payload.state == "single_click") { + this.toggleSongState(); + } + }, + modifyListElementDuration: function() { + if (this.audio1.duration.toString() !== "Infinity" || this.audio1.duration.toString() !== "undefined") { + if (this.list[0].duration === "...") { + this.list[0].duration = this.toReadableTime(this.audio1.duration); + listModel = { + items: this.list.reverse() + }; + this.controller.modelChanged("list1", listModel); + } + } + }, + updateScrubber: function(event) { + if (this.audio1.duration.toString() !== "NaN") { + var time = (parseFloat(this.audio1.currentTime) / parseFloat(this.audio1.duration)); + this.model.progress = time; + this.controller.modelChanged(this.model, this); + if (this.audio1.currentTime + 2 > this.audio1.buffered.end()) { + if (Math.ceil(this.audio1.buffered.end()) != Math.ceil(this.audio1.duration)) { + this.songState(0); + this.load(); + } + } + } + }, + + requestNext: function(url, onComplete, onFailure) { + this.showSpinner(true); + this.model.progress = 0; + this.controller.modelChanged(this.model, this); + var myAjax = new Ajax.Request(url, { + method: "get", + evalJSON: 'force', + contentType: 'application/x-www-form-urlencoded', + requestHeaders: { + "USER_AGENT": navigator.userAgent + }, + onComplete: onComplete, + onFailure: onFailure + }); + }, + loadNextMix2: function() { + this.cookie3 = new Mojo.Model.Cookie("nmp"); + if (this.cookie3.get()) { + if (this.cookie3.get().answer === 'autoplay') { + this.loadNextMix(); + } else { + this.controller.stageController.popScene("finished"); + } + } else { + this.askForNMPref(); + } + }, + loadNextMix: function() { + var onComplete = function(transport) { + if (transport.status == 200) { + this.showBanner(" New Mix: " + transport.responseJSON.next_mix.name); + this.mphoto = transport.responseJSON.next_mix.cover_urls.original; + this.$.picture1.setSrc(this.mphoto); + this.model.progress = 0; + this.controller.modelChanged(this.model, this); + this.mixID = transport.responseJSON.next_mix; + this.feedMenuModel.items[0].items[1].label = this.mixID.name; + this.controller.modelChanged(this.feedMenuModel, this); + this.setid = this.mixID.id; + var onComplete = function(transport) { + if (transport.status == 200) { + this.audio1.pause(); + this.audio1.src = transport.responseJSON.set.track.url; + this.audio1.load(); + var response = transport.responseJSON; + this.tracks = []; + this.tracks = new Array(); + this.tracks.push(response.set.track); + this.trackinfo = response; + DashPlayerInstance.update(this.audio1, this.mphoto, this.trackinfo); + this.lastsong = false; + this.songProps = []; + this.songProps = new Array(); + songprop = { + skipped: false, + duration: 0, + liked: false, + set: false + }; + this.songProps.push(songprop); + this.listindex = 0; + this.songstate = 1; + this.showBanner("Now Playing: " + transport.responseJSON.set.track.performer + " - " + transport.responseJSON.set.track.name); + this.populateList(); + this.writeDescription(); + } + }; + var onFailure = function(transport) { + this.showSpinner(false); + this.popUp("", ""); + }; + var url = "http://8tracks.com/sets/" + this.token + "/play.json?mix_id=" + this.mixID.id; + this.requestNext(url, onComplete.bind(this), onFailure.bind(this)); + } + }; + var onFailure = function(transport) { + this.controller.stageController.popScene(true); + }; + url = "http://8tracks.com/sets/" + this.token + "/play_next_mix.json?mix_id=" + this.mixID.id; + this.requestNext(url, onComplete.bind(this), onFailure.bind(this)); + }, + skipTrack: function() { + var onComplete = function(transport) { + if (transport.status == 200) { + this.lastsong = transport.responseJSON.set.at_end; + if (!this.lastsong) { + this.model.progress = 0; + this.controller.modelChanged(this.model, this); + if (typeof this.audio1 !== "undefined") { + dur = this.toReadableTime(this.audio1.duration); + } else { + dur = 0; + } + this.songProps[this.songProps.length - 1].skipped = true; + this.songProps[this.songProps.length - 1].duration = dur; + props = { + skipped: false, + duration: 0, + liked: false + }; + this.songProps.push(props); + this.audio1.pause(); + this.lastsong = transport.responseJSON.set.at_end; + this.track = transport.response; + this.audio1.src = transport.responseJSON.set.track.url; + this.showBanner("Now Playing: " + transport.responseJSON.set.track.performer + " - " + transport.responseJSON.set.track.name); + this.audio1.load(); + this.tracks.push(transport.responseJSON.set.track); + this.trackinfo = transport.responseJSON; + DashPlayerInstance.update(this.audio1, this.mphoto, this.trackinfo); + this.populateList(); + this.writeDescription(); + } else { + this.loadNextMix2(); + } + } else if (transport.status === "403 Forbidden") { + this.sound.src = Mojo.appPath + "/sounds/error.mp3"; + this.sound.play(); + this.Popup("Oops!", "Can't skip anymore"); + } + }; + var onFailure = function(transport) { + this.showSpinner(false); + this.Popup("Oops", "No more skips allowed..."); + }; + var url = "http://8tracks.com/sets/46048603/skip.json?mix_id=" + this.mixID.id; + this.requestNext(url, onComplete.bind(this), onFailure.bind(this)); + }, + askForNMPref: function() { + this.controller.showAlertDialog({ + onChoose: this.setMixPref.bind(this), + title: "Nex Mix Preference", + message: "What do you want to do now?", + choices: [ + { + label: "Auto Play", + value: "autoplay", + type: 'affirmative' + },{ + label: "Back to Mix Details", + value: "return", + type: 'negative' + } + ] + }); + }, + setMixPref: function(response, noskip) { + switch (response) { + case 'autoplay': + this.cookie3 = new Mojo.Model.Cookie("nmp"); + this.cookie3.put({ + answer: 'autoplay' + }); + // this.appMenuModel.items[2].label = "Auto-play Next Mix"; + this.appMenuModel.items[2].command = 'return'; + this.appMenuModel.items[2].iconPath = Mojo.appPath + "/images/check_mark.png";//false; + this.controller.modelChanged(this.appMenuModel, this); + if (typeof noskip === "undefined") { + this.showBanner("Selection Saved"); + this.loadNextMix(); + } + break; + case 'return': + this.cookie3 = new Mojo.Model.Cookie("nmp"); + this.cookie3.put({ + answer: 'return' + }); + //this.appMenuModel.items[2].label = "Auto-play Next Mix: Off"; + this.appMenuModel.items[2].command = 'autoplay'; + this.appMenuModel.items[2].iconPath = ""; + //this.appMenuModel.items[2].iconPath = Mojo.appPath + "images\check_mark.png";//false; + this.controller.modelChanged(this.appMenuModel, this); + if (typeof noskip === "undefined") { + this.showBanner("Selection Saved"); + this.controller.stageController.popScene("finished"); + } + break; + } + }, + nextTrack: function() { + var onComplete = function(transport) { + if (transport.status == 200) { + this.lastsong = transport.responseJSON.set.at_end; + if (!this.lastsong) { + this.model.progress = 0; + this.controller.modelChanged(this.model, this); + if (typeof this.audio1 !== "undefined") { + dur = this.toReadableTime(this.audio1.duration); + } else { + dur = 0; + } + this.songProps[this.songProps.length - 1].duration = dur; + props = { + skipped: false, + duration: 0, + liked: false + }; + this.songProps.push(props); + this.audio1.pause(); + this.track = transport.response; + this.audio1.src = transport.responseJSON.set.track.url; + this.showBanner("Now Playing: " + transport.responseJSON.set.track.performer + " - " + transport.responseJSON.set.track.name); + this.audio1.load(); + this.tracks.push(transport.responseJSON.set.track); + this.trackinfo = transport.responseJSON; + DashPlayerInstance.update(this.audio1, this.mphoto, this.trackinfo); + this.populateList(); + this.writeDescription(); + } else { + this.loadNextMix2(); + } + } else if (transport.status === "403 Forbidden") { + this.showSpinner(false); + this.banner("Can't skip anymore"); + } + }; + var onFailure = function(transport) { + this.Popup("Oops", "Error getting next track..."); + }; + var url = "http://8tracks.com/sets/46048603/next.json?mix_id=" + this.mixID.id; + this.requestNext(url, onComplete.bind(this), onFailure.bind(this)); + }, + + Popup: function(title, message) { + this.controller.showAlertDialog({ + title: title, + message: message, + choices: [ + { + label: "OK", + value: "", + type: 'dismiss' + } + ] + }); + }, + picture1Hold: function(inSender, event) { + var onSucces = function() { + this.Popup("Yay", "file downloaded"); + }; + var onFailure = function() { + this.Popup("Crap", "didn't download"); + }; + this.downloadImage(this.mphoto, onSucces.bind(this), onFailure.bind(this)); + event.stop(); + }, + + trackEnded: function(event) { + this.nextTrack(); + }, + trackPaused: function(event) { + this.songState(0); + }, + trackStalled: function(event) { + //this.showSpinner(true); + }, + trackError: function(event) { + this.showSpinner(false); + var title = ""; + var message = ""; + this.sound.pause(); + this.sound.src = Mojo.appPath + "/sounds/error.mp3"; + this.sound.load(); + this.sound.play(); + switch (this.audio1.error.code) { + case 1: + title = "Denied"; + message = "8tracks denied this song for you to stream!"; + this.Popup(title, message); + break; + case 2: + title = "Network Error"; + message = "There is a problem fetching this song from the 8tracks servers.. Let's try the next one!"; + this.Popup(title, message); + break; + case 3: + title = "Decode Error"; + message = "Error decoding the song!"; + this.Popup(title, message); + break; + case 4: + title = "Not Supported type!"; + message = "How did this happen?!"; + this.Popup(title, message); + break; + } + this.Popup(title, message); + if (!this.lastsong) { + this.nextTrack(); + } else { + data = { + error: 1 + }; + this.controller.stageController.popScene(data); + } + }, + trackPlay: function(event) { + this.songState(1); + }, + + trackPlaying: function(event) { + this.showSpinner(false); + }, + trackReady: function(event) { + this.audio1.play(); + }, + trackRateChange: function(event) { + var buffer = this.audio1.buffered; + }, + trackDurationChanged: function(event) { + this.modifyListElementDuration(); + }, + picture1Tap: function(inSender, event) { + this.toggleSongState(); + }, + toggleSongState: function() { + if (!this.songstate) { + this.songstate = 1; + } else { + this.songstate = 0; + } + this.controller.modelChanged(this.cmdMenuModel, this); + this.songState(this.songstate); + }, + songState: function(state) { + if (state) { + this.songstate = state; + this.audio1.play(); + this.cmdMenuModel.items[1].items[0].iconPath = 'images/pause1.png'; + this.cmdMenuModel.items[1].items[0].label = "Pause"; + this.cmdMenuModel.items[1].items[0].command = "0"; + } else { + this.songstate = state; + this.audio1.pause(); + this.cmdMenuModel.items[1].items[0].iconPath = 'images/playselected.png'; + this.cmdMenuModel.items[1].items[0].label = "Play"; + this.cmdMenuModel.items[1].items[0].command = "1"; + } + this.controller.modelChanged(this.cmdMenuModel, this); + }, + list1Listtap: function(inSender, event) { + this.listindex = event.index; + if (!this.loggedin) { + this.controller.popupSubmenu({ + onChoose: this.popupHandler, + placeNear: event.originalEvent.target, + items: [ + { + label: 'Buy', + command: 'buy' + }, + { + label: 'Write it down', + command: 'save' + }] + }); + } else { + var selected = this.tracks[this.tracks.length - this.listindex - 1]; + //if (!event.item.liked) { + this.controller.popupSubmenu({ + onChoose: this.popupHandler, + placeNear: event.originalEvent.target, + items: [ + { + label: 'Buy', + command: 'buy' + }, + { + label: 'Write it down', + command: 'save' + }, + { + label: event.item.liked ? "Unlike" : "Like", + command: event.item.liked ? 'unlksong' : 'lksong' + }] + }); + } + }, + Buy: function(link, artist, song) { + var onFailure = function(transport) { + this.popUp("crap", ""); + }; + this.controller.serviceRequest('palm://com.palm.applicationManager', { + method: 'launch', + parameters: { + id: 'com.palm.app.amazonstore', + params: { + artist: artist, + song: song + } + }, + onFailure: onFailure.bind(this) + }); + }, + writeDown: function(artist, track) { + var onSuccess = function(transport) { + + }; + var onFailure = function(transport) { + this.popUp("crap", ""); + }; + this.controller.serviceRequest('palm://com.palm.applicationManager', { + method: 'launch', + parameters: { + id: 'com.palm.app.notes', + params: { + text: artist + ": " + track + } + }, + onFailure: onFailure.bind(this), + onSuccess: onSuccess.bind(this) + }); + }, + setLikeStateCurrent: function(state){ + song = this.tracks[this.tracks.length - 1]; + this.songProps[this.songProps.length - 1].liked = state; + this.setLikeState(song, !state); + }, + setLikeState: function(song, state) { + this.song = song; + var onFailure = function(transport) { + this.Popup("Error", "Could not Like this song! Try to login again..."); + }; + var postdata = "login=" + this.username + "&password=" + this.password; + if (!state) { + url = "http://8tracks.com/tracks/" + song.id + "/fav.json"; + myAjax = new Ajax.Request(url, { + method: "post", + requestHeader: postdata, + onComplete: this.songLiked.bind(this), + onFailure: onFailure.bind(this) + }); + } else { + url = "http://8tracks.com/tracks/" + song.id + "/unfav.json"; + myAjax = new Ajax.Request(url, { + method: "post", + requestHeader: postdata, + onSuccess: this.songUnliked.bind(this), + onFailure: onFailure.bind(this) + }); + } + }, + songLiked: function(transport) { + this.banner("You like " + this.song.name); + this.populateList(); + }, + songUnliked: function(transport) { + this.banner("You don't like " + this.song.name + " anymore"); + this.populateList(); + }, + Like: function() { + var onFailure = function(transport) { + this.showBanner("Could not add mix to your liked mix. Try to login again"); + }; + var postdata = "login=" + this.username + "&password=" + this.password; + var url = "http://8tracks.com/mixes/" + this.mixID.id + "/like.json"; + var myAjax = new Ajax.Request(url, { + method: "post", + requestHeader: postdata, + onComplete: this.LikedComplete.bind(this), + onFailure: onFailure.bind(this) + }); + }, + LikedComplete: function(response) { + if (response.responseJSON.status === "200 OK") { + this.showBanner("Mixed added to your Liked list"); + this.liked = true; + this.appMenuModel.items[1].command = "unlike"; + this.appMenuModel.items[1].label = "Unlike Mix"; + this.controller.modelChanged(this.appMenuModel, this); + } else { + this.popUp(response.responseJSON.status, response.responseJSON.notices); + } + }, + UnLike: function() { + var onFailure = function(transport) { + this.showBanner("Could not remove mix to your liked mix. Try to login again"); + }; + var postdata = "login=" + this.username + "&password=" + this.password; + url = "http://8tracks.com/mixes/" + this.mixID.id + "/unlike.json"; + var myAjax = new Ajax.Request(url, { + method: "post", + requestHeader: postdata, + onComplete: this.UnLikedComplete.bind(this), + onFailure: onFailure.bind(this) + }); + }, + UnLikedComplete: function(response) { + this.showBanner("Mixed removed from your Liked list"); + this.liked = false; + this.appMenuModel.items[1].command = "like"; + this.appMenuModel.items[1].label = "Like Mix"; + this.controller.modelChanged(this.appMenuModel, this); + } +}; + +PlayerAssistant.prototype.handleCommand = function(event) { + this.controller = Mojo.Controller.stageController.activeScene(); + if (event.type == Mojo.Event.command) { + switch (event.command) { + case 'fwd': + //this.loadNextMix2(); + this.sound.pause(); + this.sound.src = Mojo.appPath + "/sounds/nextmix.mp3"; + this.sound.load(); + this.sound.play(); + this.skipTrack(); + break; + case 'back': + this.getPreviousPage(); + break; + case '1': + this.songState(1); + break; + case '0': + this.songState(0); + break; + case 'share': + this.controller.serviceRequest("palm://com.palm.applicationManager", { + method: 'open', + parameters: { + id: "com.palm.app.email", + params: { + summary: "Checkout this 8tracks mix!", + text: "Checkout this Mix: \n" + this.mixID.name + "\nwww.8tracks.com" + this.mixID.path + } + } + }); + break; + case 'like': + this.Like(); + break; + case 'unlike': + this.UnLike(); + break; + case 'return': + this.setMixPref('return', true); + break; + case 'autoplay': + this.setMixPref('autoplay', true); + break; + } + } else if (event.type === Mojo.Event.back) { + data = { + mixInfo: this.mixID, + likedMix: this.liked + }; + event.stop(); + this.controller.stageController.popScene(data); + } +}; + +PlayerAssistant.prototype.popupHandler = function(command) { + this.controller = Mojo.Controller.stageController.activeScene(); + var selected = this.tracks[this.tracks.length - this.listindex - 1]; + switch (command) { + case "buy": + this.Buy(selected.buy_link, selected.performer, selected.name); + break; + case "save": + this.writeDown(selected.performer, selected.name); + break; + case "lksong": + this.songProps[this.tracks.length - this.listindex - 1].liked = true; + this.setLikeState(selected, false); + break; + case "unlksong": + this.songProps[this.tracks.length - this.listindex - 1].liked = false; + this.setLikeState(selected, true); + break; + } +}; \ No newline at end of file diff --git a/app/assistants/searchScrene-assistant.js b/app/assistants/searchScrene-assistant.js new file mode 100644 index 0000000..1f88969 --- /dev/null +++ b/app/assistants/searchScrene-assistant.js @@ -0,0 +1,224 @@ +function SearchScreneAssistant(argFromPusher, userid) { + this.popUp = function(title, message) { + this.controller.showAlertDialog({ + title: title, + message: message, + choices: [ + { + label: "OK", + value: "", + type: 'dismiss' + } + ] + }); + }; + if (typeof argFromPusher !== 0 && argFromPusher.toString().length === 2) { + this.character = Mojo.Char.isValidWrittenChar(argFromPusher); + } else { + this.character = ""; + } + this.userid = -1; + cookie = new Mojo.Model.Cookie("credentials"); + if (cookie.get()) { + this.userid = typeof userid === "undefined" ? -1 : userid; + this.username = cookie.get().username; + this.password = cookie.get().password; + } + this.tracks = ""; + this.fillList = function(tracks, setid) { + if (typeof setid !== "undefined") { + this.setid = setid; + } + var list = new Array(tracks.length); + for (var i = 0; i < tracks.length; i++) { + var name = tracks[i].name; + var tag = tracks[i].tag_list_cache; + if (name !== null) { + if (name.length > 30) { + name = name.substring(0, 50) + "..."; + } + } + if (tag !== null) { + if (tag.length > 60) { + tag = tag.substring(0, 50) + "..."; + } + } + list[i] = { + title: name, + leftImage: tracks[i].cover_urls.sq56.toString() === "/images/mix_covers/sq56.gif" ? Mojo.appPath + "/images/no_image.png" : tracks[i].cover_urls.sq56, + tag: tag, + mixInfo: tracks[i], + set_id: this.setid, + type: "mix" + }; + } + listModel = { + items: list + }; + return { + getList: function() { + return listModel; + } + }; + }; + this.currentpage = 1; + this.pagecount = 1; + this.writeDescription = function() { + this.$.divider2.setLabel("page: " + this.currentpage + "/" + this.pagecount); + this.controller.get('scroller1').mojo.revealTop(); + }; +} + +SearchScreneAssistant.prototype = { + setup: function() { + this.cmdMenuModel = { + visible: true, + items: [ + {}, + { + items: [{ + icon: "back", + command: 'back', + label: $L("Back"), + disabled: this.currentpage === 1 + },{ + icon: "forward", + command: 'fwd', + label: $L("Forward"), + disabled: this.pagecount === this.currentpage + }] + }, + {} + ] + }; + this.controller.setupWidget(Mojo.Menu.commandMenu, { + spacerHeight: 0, + menuClass: 'no-fade' + }, + this.cmdMenuModel); + this.controller.document.addEventListener("keyup", this.keyupHandler.bind(this), true); + Ares.setupSceneAssistant(this); + }, + cleanup: function() { + this.controller.document.removeEventListener("keyup", this.keyupHandler.bind(this), true); + Ares.cleanupSceneAssistant(this); + }, + activate: function(data) { + this.cookie2 = new Mojo.Model.Cookie("prefs"); + if (this.cookie2.get()) { + props = themeLookup(this.cookie2.get().theme); + this.controller.get('searchScrene').style.backgroundImage = props.URL; + this.$.list1.style.addStyles({ + textColor: props.textColor + }); + } + this.controller.get('textField3').mojo.focus(); + this.controller.get('textField3').mojo.setValue(this.character); + this.showSpinner(false); + if (this.character !== "" && typeof data === "undefined") { + this.search(); + } + }, + showSpinner: function(show) { + this.$.spinner1.setSpinning(show); + }, + request: function(url, onComplete, onFailure) { + this.showSpinner(true); + var myAjax = new Ajax.Request(url, { + method: "get", + evalJSON: 'force', + contentType: 'application/x-www-form-urlencoded', + requestHeaders: { + "USER_AGENT": navigator.userAgent + }, + onComplete: onComplete, + onFailure: onFailure + }); + }, + + search: function() { + var onComplete = function(transport) { + this.currentpage = 1; + this.pagecount = Math.ceil(parseInt(transport.responseJSON.total_entries, 0) / 10); + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount; + this.controller.modelChanged(this.cmdMenuModel, this); + this.tracks = transport.responseJSON.mixes; + this.writeDescription(); + f = this.fillList(this.tracks); + this.controller.setWidgetModel("list1", f.getList()); + this.showSpinner(false); + }; + var onFailure = function(transport) { + this.showSpinner(false); + this.popUp("Oops!", "Search Error"); + }; + this.character = this.controller.get('textField3').mojo.getValue(); + url = "http://8tracks.com/mixes.json?q=" + this.controller.get('textField3').mojo.getValue() + "&page=" + this.currentpage; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + }, + + keyupHandler: function(event) { + if (event.keyCode !== 27) { + this.search(); + } + }, + + list1Listtap: function(inSender, event) { + this.controller.stageController.pushScene('mixDetailsScene', event.item.mixInfo, event.item.set_id, this.userid, this.username, this.password); + }, + getNextPage: function() { + this.currentpage += 1; + var onComplete = function(transport) { + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount; + this.controller.modelChanged(this.cmdMenuModel, this); + this.tracks = transport.responseJSON.mixes; + f = this.fillList(this.tracks); + this.controller.setWidgetModel("list1", f.getList()); + this.writeDescription(); + this.showSpinner(false); + }; + var onFailure = function(transport) { + this.showSpinner(false); + this.popUp("Oops!", "Couldn't retreive page " + this.currentpage); + }; + url = "http://8tracks.com/mixes.json?q=" + this.controller.get('textField3').mojo.getValue() + "&page=" + this.currentpage; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + }, + getPreviousPage: function() { + if (this.currentpage - 1 > 0) { + this.currentpage -= 1; + var onComplete = function(transport) { + this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1; + this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount; + this.controller.modelChanged(this.cmdMenuModel, this); + this.tracks = transport.responseJSON.mixes; + f = this.fillList(this.tracks); + this.controller.setWidgetModel("list1", f.getList()); + this.writeDescription(); + this.showSpinner(false); + }; + var onFailure = function(transport) { + this.showSpinner(false); + this.popUp("Oops!", "Couldn't retreive page " + this.currentpage); + }; + url = "http://8tracks.com/mixes.json?q=" + this.controller.get('textField3').mojo.getValue() + "&page=" + this.currentpage; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + } + } +}; + +SearchScreneAssistant.prototype.handleCommand = function(event) { + this.controller = Mojo.Controller.stageController.activeScene(); + if (event.type == Mojo.Event.command) { + switch (event.command) { + case 'fwd': + this.getNextPage().bind(this); + break; + case 'back': + this.getPreviousPage().bind(this); + break; + } + } +}; \ No newline at end of file diff --git a/app/assistants/splash-assistant.js b/app/assistants/splash-assistant.js new file mode 100644 index 0000000..a95842a --- /dev/null +++ b/app/assistants/splash-assistant.js @@ -0,0 +1,142 @@ +function SplashAssistant(argFromPusher) { + this.popUp = function(title, message) { + this.controller.showAlertDialog({ + title: title, + message: message, + choices: [ + { + label: "OK", + value: "", + type: 'dismiss' + } + ] + }); + }; + this.loggedin = false; + this.username = ""; + this.password = ""; +} + +function toggleLoading(onOff){ + if (onOff == "on"){ + $('loading').show(); + }else{ + $('loading').hide(); + } +} + +SplashAssistant.prototype = { + setup: function() { + Ares.setupSceneAssistant(this); + }, + cleanup: function() { + Ares.cleanupSceneAssistant(this); + }, + activate: function() { + this.$.picture1.setSrc(Mojo.appPath + "images/tracks_01.png"); + this.cookie = new Mojo.Model.Cookie("credentials"); + if (this.cookie.get()) { + this.username = this.cookie.get().username; + this.password = this.cookie.get().password; + if(this.cookie.get().username !== ""){ + this.requestLogin(); + } + else{ + this.checkConnection(); + } + }else{ + this.checkConnection(); + } + }, + checkConnection: function() { + this.controller.serviceRequest('palm://com.palm.connectionmanager', { + method: 'getstatus', + parameters: { + subscribe: true + }, + onSuccess: this.begin.bind(this), + onFailure: this.error.bind(this) + }); + }, + + requestLogin: function() { + var onComplete = function(transport){ + if(transport.responseJSON.status === "200 OK"){ + this.loggedin = true; + var getUserInfo = function(transport){ + this.userid = transport.responseJSON.user.id; + this.begin(); + }; + url = "http://8tracks.com/users/" + this.username + ".json"; + var failure = function(transport){ + this.popUp("Login Error","Check Credentials"); + this.begin(); + }; + this.requestDemo(url,getUserInfo.bind(this), failure.bind(this)); + } + }; + var onFailure = function(transport){ + this.checkConnection(); + }; + url = "http://8tracks.com/sessions.json"; + var postdata = "login=" + this.username + "&password=" + this.password; + var myAjax = new Ajax.Request(url, { + method: "post", + parameters: postdata, + onComplete: onComplete.bind(this), + onFailure: onFailure.bind(this) + }); + }, + + requestDemo: function(url, onComplete, onFailure) { + var myAjax = new Ajax.Request(url, { + method: "get", + evalJSON: 'force', + contentType: 'application/x-www-form-urlencoded', + requestHeaders: { + "USER_AGENT": navigator.userAgent + }, + onComplete: onComplete, + onFailure: onFailure + }); + }, + + begin: function(inSender, event) { + var onComplete = function(transport) { + if (200 === transport.status) { + var tracks = transport.responseJSON.mixes; + this.controller.stageController.swapScene('gridScene', tracks, transport.responseJSON.total_entries, transport.responseJSON.mix_set_id, this.loggedin, this.username, this.password, this.userid); + } + }; + + var onFailure = function(transport) { + this.popUp("Error!","Could not connect to 8tracks server. Check your connection and try again"); + Mojo.Log.info("Failed to login"); + }; + + var url = "http://8tracks.com/mixes.json?sort=recent"; + this.requestDemo(url, onComplete.bind(this), onFailure.bind(this)); + }, + + push: function(response) { + if (response.isInternetConnectionAvailable) { + this.controller.stageController.pushScene({ + 'name': 'main', + transition: Mojo.Transition.zoomFade, + disableSceneScroller: true + }); + } else { + this.popUp("No Network Available", "Unable to connect to a network."); + } + }, + + error: function(response) { + this.popUp("No Network Available", "Unable to connect to a network."); + } +}; + +SplashAssistant.prototype.handleCommand = function(event){ + if(event.type == Mojo.Event.back){ + event.stop(); + } +}; \ No newline at end of file diff --git a/app/assistants/stage-assistant.js b/app/assistants/stage-assistant.js new file mode 100644 index 0000000..4790ee7 --- /dev/null +++ b/app/assistants/stage-assistant.js @@ -0,0 +1,7 @@ +function StageAssistant() { +} + +StageAssistant.prototype.setup = function() { + this.controller.pushScene({name: "splash", disableSceneScroller: true}); + this.controller.setWindowOrientation("up"); +}; \ No newline at end of file diff --git a/app/assistants/userInfo-assistant.js b/app/assistants/userInfo-assistant.js new file mode 100644 index 0000000..d0d98b4 --- /dev/null +++ b/app/assistants/userInfo-assistant.js @@ -0,0 +1,279 @@ +function UserInfoAssistant(argFromPusher) { + this.userInfo = argFromPusher; + this.token = 0; + this.mixInfo = 0; + this.loggedin = false; + this.cookie = new Mojo.Model.Cookie("credentials"); + if (this.cookie.get()) { + this.username = this.cookie.get().username; + this.password = this.cookie.get().password; + if (this.cookie.get().username !== "") { + this.loggedin = true; + } + }else{ + this.setid = -1; + this.username = ""; + this.password= ""; + } + this.fillList = function(tracks) { + var list = new Array(tracks.length); + for (var i = 0; i < tracks.length; i++) { + var name = tracks[i].name; + var tag = tracks[i].tag_list_cache; + if (name !== null) { + if (name.length > 30) { + name = name.substring(0, 30) + "..."; + } + } + if (tag !== null) { + if (tag.length > 30) { + tag = tag.substring(0, 30) + "..."; + } + } + list[i] = { + title: name, + leftImage: tracks[i].cover_urls.sq56.toString() === "/images/mix_covers/sq56.gif" ? Mojo.appPath + "/images/no_image.png" : tracks[i].cover_urls.sq56, + tag: tag, + mixInfo: tracks[i] + }; + } + listModel = { + items: list + }; + return { + getList: function() { + return listModel; + } + }; + }; + this.writeUserDetails = function(info1, info2) { + if (info1 === null) { + this.$.label3.setLabel("No bio available"); + } else if (info1.indexOf("

") >= 0) { + info1 = info1.split("

")[1]; + info1 = info1.split("

")[0]; + this.$.label3.setLabel(info1); + } else { + this.$.label3.setLabel(info1); + } + }; + this.popUp = function(title, message) { + Mojo.Controller.getAppController().showBanner(message, { + source: 'notification' + }); + }; +} + +UserInfoAssistant.prototype = { + setup: function() { + this.cmdMenuModel = { + visible: true, + items: [ + { + items: [{},{},{ + label: $L('Follow'), + command: 'flw' + }] + }] + }; + + this.controller.setupWidget(Mojo.Menu.commandMenu, { + //spacerHeight: 0, + menuClass: 'no-fade' + }, + this.cmdMenuModel); + this.feedMenuModel = { + visible: true, + items: [ + { + items: [{ + width: 0 + }, + { + label: this.userInfo.login, + width: 320 + }] + } + ] + }; + this.controller.setupWidget(Mojo.Menu.viewMenu, { + spacerHeight: 0, + menuClass: 'no-fade' + }, + this.feedMenuModel); + + Ares.setupSceneAssistant(this); + }, + cleanup: function() { + Ares.cleanupSceneAssistant(this); + }, + activate: function() { + this.cookie2 = new Mojo.Model.Cookie("prefs"); + if (this.cookie2.get()) { + props = themeLookup(this.cookie2.get().theme); + this.controller.get('userInfo').style.backgroundImage = props.URL; + this.$.label3.style.addStyles({ + textColor: props.textColor + }); + this.$.list1.style.addStyles({textColor: props.textColor}); + } + this.showSpinner(false); + this.getUserInfo(); + this.listMixes(); + }, + showSpinner: function(show) { + if (!show) { + this.feedMenuModel.items[0].items[1].width = 320; + this.feedMenuModel.items[0].items[0].width = 0; + this.controller.modelChanged(this.feedMenuModel, this); + } else { + this.feedMenuModel.items[0].items[1].width = 275; + this.feedMenuModel.items[0].items[0].width = 45; + this.controller.modelChanged(this.feedMenuModel, this); + } + this.$.spinner1.setSpinning(show); + }, + listMixes: function() { + var onComplete = function(transport) { + if (transport.status === 200) { + var mixes = transport.responseJSON.mixes; + f = this.fillList(mixes); + this.$.divider1.setLabel("Mixes (" + mixes.length + ")"); + this.controller.setWidgetModel("list1", f.getList()); + } + }; + var onFailure = function(transport) {}; + url = "http://8tracks.com/users/" + this.userInfo.login + "/mixes.json"; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + }, + getUserInfo: function() { + var onComplete = function(transport) { + if (transport.status === 200) { + var image = transport.responseJSON.user.avatar_urls.sq100.toString() === "/images/avatars/sq100.jpg" ? Mojo.appPath + "/images/unknownUser.jpg" : transport.responseJSON.user.avatar_urls.sq100; + this.$.picture1.setSrc(image); + this.writeUserDetails(transport.responseJSON.user.bio_html, ""); + if (!transport.responseJSON.user.followed_by_current_user) { + this.cmdMenuModel.items[0].items[2].label = "Follow"; + this.cmdMenuModel.items[0].items[2].command = "flw"; + this.controller.modelChanged(this.cmdMenuModel, this); + } else { + this.cmdMenuModel.items[0].items[2].label = "Unfollow"; + this.cmdMenuModel.items[0].items[2].command = "uflw"; + this.controller.modelChanged(this.cmdMenuModel, this); + } + } + }; + var onFailure = function(transport) { + this.popUp("Oops", "Error retrieving user data!"); + }; + url = "http://8tracks.com/users/" + this.userInfo.login + ".json"; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + }, + request: function(url, onComplete, onFailure) { + var myAjax = new Ajax.Request(url, { + method: "get", + evalJSON: 'force', + contentType: 'application/x-www-form-urlencoded', + requestHeaders: { + "USER_AGENT": navigator.userAgent + }, + onComplete: onComplete, + onFailure: onFailure + }); + }, + list1Listtap: function(inSender, event) { + this.showSpinner(true); + this.mixInfo = event.item.mixInfo; + this.loadPlaylist(); + }, + loadPlaylist: function() { + var onComplete = function(transport) { + if (transport.status == 200) { + this.token = transport.responseJSON.play_token; + this.playMix(); + } else { + this.popUp("Error", "Didn't Get 200 from json response"); + } + }; + var onFailure = function() { + this.popUp("Oops", "failed to get play_token"); + }; + var url = "http://8tracks.com/sets/new.json"; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + }, + playMix: function() { + var onComplete = function(transport) { + if (transport.status == 200) { + this.showSpinner(false); + this.controller.stageController.pushScene('player', this.mixInfo, this.token, transport.responseJSON, this.mixInfo.cover_urls.original, this.setid, this.username.toLowerCase(), this.username, this.password); + } + }; + var onFailure = function(transport) { + this.popUp("", ""); + }; + var url = "http://8tracks.com/sets/" + this.token + "/play.json?mix_id=" + this.mixInfo.id; + this.request(url, onComplete.bind(this), onFailure.bind(this)); + }, + followUser: function() { + var postdata = "login=" + this.username + "&password=" + this.password; + //var postdata = this.token; + var url = "http://8tracks.com/users/" + this.userInfo.id + "/follow.json"; + var onFailure = function(transport) { + this.popUp("Error", "Could not follow user. Try to login again"); + }; + var myAjax = new Ajax.Request(url, { + method: "post", + requestHeader: postdata, + onComplete: this.followedComplete.bind(this), + onFailure: onFailure.bind(this) + }); + }, + unFollowUser: function() { + var postdata = "login=" + this.username + "&password=" + this.password; + //var postdata = this.token; + var url = "http://8tracks.com/users/" + this.userInfo.id + "/unfollow.json"; + var onFailure = function(transport) { + this.popUp("Error", "Could not unfollow user. Try to login again"); + }; + var myAjax = new Ajax.Request(url, { + method: "post", + parameters: postdata, + onComplete: this.unFollowedComplete.bind(this), + onFailure: onFailure.bind(this) + }); + }, + followedComplete: function(transport) { + if (transport.responseJSON.status == "200 OK") { + this.popUp("Success", "You are now following " + this.userInfo.login); + this.cmdMenuModel.items[0].items[2].label = "Unfollow"; + this.cmdMenuModel.items[0].items[2].command = "uflw"; + this.controller.modelChanged(this.cmdMenuModel, this); + } else { + this.popUp(transport.responseJSON.status, transport.responseJSON.notices); + } + }, + unFollowedComplete: function(transport) { + if (transport.responseJSON.status == "200 OK") { + this.popUp("Success", "You have stopped following " + this.userInfo.login); + this.cmdMenuModel.items[0].items[2].label = "Follow"; + this.cmdMenuModel.items[0].items[2].command = "flw"; + this.controller.modelChanged(this.cmdMenuModel, this); + } else { + this.popUp(transport.responseJSON.status, transport.responseJSON.notices); + } + } +}; + +UserInfoAssistant.prototype.handleCommand = function(event) { + this.controller = Mojo.Controller.stageController.activeScene(); + if (event.type == Mojo.Event.command) { + switch (event.command) { + case 'flw': + this.followUser(); + break; + case 'uflw': + this.unFollowUser(); + break; + } + } +}; \ No newline at end of file diff --git a/app/views/dashboard/dashboard-player.html b/app/views/dashboard/dashboard-player.html new file mode 100644 index 0000000..3bbbec1 --- /dev/null +++ b/app/views/dashboard/dashboard-player.html @@ -0,0 +1,12 @@ +
+ +
+ +
+
+
#{title}
+
#{artist}
+ +
+
+
\ No newline at end of file diff --git a/app/views/dashboard/dashboard-scene.html b/app/views/dashboard/dashboard-scene.html new file mode 100644 index 0000000..b5d13ce --- /dev/null +++ b/app/views/dashboard/dashboard-scene.html @@ -0,0 +1 @@ +
diff --git a/app/views/gridScene/gridScene-chrome.js b/app/views/gridScene/gridScene-chrome.js new file mode 100644 index 0000000..9e21f75 --- /dev/null +++ b/app/views/gridScene/gridScene-chrome.js @@ -0,0 +1,91 @@ +opus.Gizmo({ + name: "gridScene", + dropTarget: true, + type: "Palm.Mojo.Panel", + h: "100%", + styles: { + zIndex: 2, + bgImage: "images/white-1.jpg" + }, + chrome: [ + { + name: "label1", + label: "", + type: "Palm.Mojo.Label", + l: 0, + t: 0, + h: 13 + }, + { + name: "spinner1", + type: "Palm.Mojo.Spinner", + l: 0, + r: "270", + t: 49 + }, + { + name: "divider1", + label: "Latest Mixes ( 1/10)", + type: "Palm.Mojo.Divider", + l: 0, + t: 49 + }, + { + name: "scroller2", + scrollPosition: { + left: 0, + top: 0 + }, + type: "Palm.Mojo.Scroller", + l: 0, + t: 0, + h: "100%", + styles: { + cursor: "move", + overflow: "hidden" + }, + controls: [ + { + name: "list1", + dropTarget: true, + items: [ + { + item: 0, + label: "Zero", + value: "0" + }, + { + item: 1, + label: "One", + value: "1" + }, + { + item: 2, + label: "Two", + value: "2" + }, + { + item: 3, + label: "Three", + value: "3" + } + ], + useSampleData: false, + title: undefined, + itemHtml: "
\n
 #{title}
 #{tag}
\n
\n", + onlisttap: "list1Listtap", + swipeToDelete: false, + reorderable: false, + type: "Palm.Mojo.List", + l: 0, + t: 0, + h: 108, + vAlign: "center", + styles: { + textColor: "white" + } + } + ] + } + ] +}); \ No newline at end of file diff --git a/app/views/gridScene/gridScene-scene.html b/app/views/gridScene/gridScene-scene.html new file mode 100644 index 0000000..e69de29 diff --git a/app/views/login/login-chrome.js b/app/views/login/login-chrome.js new file mode 100644 index 0000000..a7d6415 --- /dev/null +++ b/app/views/login/login-chrome.js @@ -0,0 +1,88 @@ +opus.Gizmo({ + name: "login", + dropTarget: true, + type: "Palm.Mojo.Panel", + h: "100%", + styles: { + zIndex: 2, + bgImage: "images/white-1.jpg" + }, + chrome: [ + { + name: "header1", + label: "Login Info", + type: "Palm.Mojo.Header", + l: 0, + t: 0 + }, + { + name: "group1", + dropTarget: true, + label: "Username", + type: "Palm.Mojo.Group", + l: 0, + t: 0, + styles: { + opacity: 1 + }, + controls: [ + { + name: "row1", + dropTarget: true, + isTextField: true, + type: "Palm.Mojo.Row", + l: 0, + t: 0, + h: "auto", + controls: [ + { + name: "textField1", + hintText: "", + type: "Palm.Mojo.TextField" + } + ] + } + ] + }, + { + name: "group2", + dropTarget: true, + label: "password", + type: "Palm.Mojo.Group", + l: 0, + t: 145, + styles: { + opacity: 1 + }, + controls: [ + { + name: "row2", + dropTarget: true, + isTextField: true, + type: "Palm.Mojo.Row", + l: 0, + t: 0, + h: "auto", + controls: [ + { + name: "passwordField1", + hintText: "", + type: "Palm.Mojo.PasswordField", + l: 0, + t: 52 + } + ] + } + ] + }, + { + name: "activityButton1", + ontap: "activityButton1Tap", + disabled: undefined, + label: "Login", + type: "Palm.Mojo.ActivityButton", + l: 0, + t: 240 + } + ] +}); \ No newline at end of file diff --git a/app/views/login/login-scene.html b/app/views/login/login-scene.html new file mode 100644 index 0000000..e69de29 diff --git a/app/views/mixDetailsScene/mixDetailsScene-chrome.js b/app/views/mixDetailsScene/mixDetailsScene-chrome.js new file mode 100644 index 0000000..ac107e2 --- /dev/null +++ b/app/views/mixDetailsScene/mixDetailsScene-chrome.js @@ -0,0 +1,225 @@ +opus.Gizmo({ + name: "mixDetailsScene", + dropTarget: true, + type: "Palm.Mojo.Panel", + h: "100%", + styles: { + zIndex: 2, + bgImage: "images/white-1.jpg" + }, + chrome: [ + { + name: "label3", + label: "", + type: "Palm.Mojo.Label", + l: 0, + t: 0, + h: 11 + }, + { + name: "spinner1", + type: "Palm.Mojo.Spinner", + l: 0, + r: "270", + t: 10 + }, + { + name: "scroller1", + scrollPosition: { + left: 0, + top: 0 + }, + type: "Palm.Mojo.Scroller", + l: 0, + t: 0, + h: "100%", + styles: { + cursor: "move", + overflow: "hidden" + }, + controls: [ + { + name: "group7", + dropTarget: true, + label: "Mix Name", + type: "Palm.Mojo.Group", + l: 0, + t: 0, + h: 109, + styles: { + borderColor: "" + }, + controls: [ + { + name: "row1", + dropTarget: true, + rowType: "first", + type: "Palm.Mojo.Row", + l: 0, + t: 0, + h: "auto" + }, + { + name: "scroller2", + scrollPosition: { + left: 0, + top: 0 + }, + type: "Palm.Mojo.Scroller", + l: 0, + t: 0, + h: "100%", + styles: { + cursor: "move", + overflow: "hidden" + }, + controls: [ + { + name: "name", + type: "Palm.Mojo.Label", + l: 8, + w: 294, + t: 0, + h: 65, + styles: { + textColor: "", + fontFamily: "prelude medium" + } + } + ] + } + ] + }, + { + name: "group8", + dropTarget: true, + label: "Description", + type: "Palm.Mojo.Group", + l: 0, + t: 95, + h: 146, + controls: [ + { + name: "scroller5", + scrollPosition: { + left: 0, + top: 0 + }, + type: "Palm.Mojo.Scroller", + l: 0, + t: 0, + h: "100%", + styles: { + cursor: "move", + overflow: "hidden", + fontFamily: "prelude medium" + }, + controls: [ + { + name: "description", + type: "Palm.Mojo.Label", + l: 11, + w: 291, + t: "10", + h: 43, + styles: { + textColor: "", + fontFamily: "prelude medium" + } + } + ] + } + ] + }, + { + name: "group9", + dropTarget: true, + label: "Tags", + type: "Palm.Mojo.Group", + l: 0, + t: 241, + h: 99, + controls: [ + { + name: "row3", + dropTarget: true, + type: "Palm.Mojo.Row", + l: 0, + t: 0, + h: "100%", + controls: [ + { + name: "tags", + kind: "title", + label: "Tags", + type: "Palm.Mojo.Label", + l: 0, + t: 0, + h: "100%", + styles: { + textColor: "", + textAlign: "center", + fontFamily: "prelude medium" + } + } + ] + } + ] + }, + { + name: "group1", + dropTarget: true, + label: "Created by:", + type: "Palm.Mojo.Group", + l: 0, + t: 340, + h: 211, + controls: [ + { + name: "row4", + dropTarget: true, + rowType: "first", + type: "Palm.Mojo.Row", + l: 0, + t: 0, + controls: [ + { + name: "creator", + kind: "title", + type: "Palm.Mojo.Label", + l: 7, + w: 295, + t: 0, + styles: { + textColor: "", + fontFamily: "prelude medium" + } + } + ] + }, + { + name: "row6", + dropTarget: true, + rowType: "last", + type: "Palm.Mojo.Row", + l: 0, + t: 52, + h: "auto", + controls: [ + { + name: "picture1", + ontap: "picture1Tap", + type: "Palm.Picture", + l: 72, + w: 150, + t: 0, + h: 111 + } + ] + } + ] + } + ] + } + ] +}); \ No newline at end of file diff --git a/app/views/mixDetailsScene/mixDetailsScene-scene.html b/app/views/mixDetailsScene/mixDetailsScene-scene.html new file mode 100644 index 0000000..e69de29 diff --git a/app/views/player/player-chrome.js b/app/views/player/player-chrome.js new file mode 100644 index 0000000..fe3b46b --- /dev/null +++ b/app/views/player/player-chrome.js @@ -0,0 +1,130 @@ +opus.Gizmo({ + name: "player", + dropTarget: true, + type: "Palm.Mojo.Panel", + h: "100%", + styles: { + zIndex: 2, + bgImage: "images/white-1.jpg" + }, + components: [ + { + name: "audio1", + autoPlay: true, + onTimeUpdate: "audio1TimeUpdate", + type: "Palm.Mojo.Audio" + }, + { + name: "sound", + autoPlay: true, + type: "Palm.Mojo.Audio" + } + ], + chrome: [ + { + name: "label1", + label: "", + type: "Palm.Mojo.Label", + l: 0, + t: 0, + h: 8 + }, + { + name: "spinner1", + type: "Palm.Mojo.Spinner", + l: 0, + r: "270", + t: 49 + }, + { + name: "label3", + label: "", + type: "Palm.Mojo.Label", + l: 0, + t: 46, + h: 17 + }, + { + name: "picture1", + ontap: "picture1Tap", + onhold: "picture1Hold", + type: "Palm.Picture", + l: 0, + w: 321, + t: 56, + h: 143 + }, + { + name: "html1", + content: "

", + type: "Palm.Mojo.Html", + l: 0, + t: 200, + h: 32 + }, + { + name: "divider2", + label: "tracks", + type: "Palm.Mojo.Divider", + l: 0, + t: 173 + }, + { + name: "scroller2", + scrollPosition: { + left: 0, + top: 0 + }, + type: "Palm.Mojo.Scroller", + l: 0, + t: 0, + h: "100%", + styles: { + cursor: "move", + overflow: "hidden" + }, + controls: [ + { + name: "list1", + dropTarget: true, + items: [ + { + item: 0, + label: "Zero", + value: "0" + }, + { + item: 1, + label: "One", + value: "1" + }, + { + item: 2, + label: "Two", + value: "2" + }, + { + item: 3, + label: "Three", + value: "3" + } + ], + useSampleData: false, + title: undefined, + itemHtml: "
\n
 #{currentsong}#{oldsong}#{skipped}
 #{currentartist} - #{duration}
\n
\n", + onlisttap: "list1Listtap", + swipeToDelete: false, + reorderable: false, + type: "Palm.Mojo.List", + l: 0, + t: 0, + h: 285, + styles: { + textColor: "black", + bgImage: "" + } + } + ] + } + ] +}); \ No newline at end of file diff --git a/app/views/player/player-scene.html b/app/views/player/player-scene.html new file mode 100644 index 0000000..e69de29 diff --git a/app/views/searchScrene/searchScrene-chrome.js b/app/views/searchScrene/searchScrene-chrome.js new file mode 100644 index 0000000..fbafbb1 --- /dev/null +++ b/app/views/searchScrene/searchScrene-chrome.js @@ -0,0 +1,107 @@ +opus.Gizmo({ + name: "searchScrene", + dropTarget: true, + type: "Palm.Mojo.Panel", + t: 0, + h: 452, + styles: { + zIndex: 2, + bgImage: "images/white-1.jpg" + }, + chrome: [ + { + name: "divider1", + label: "just type", + type: "Palm.Mojo.Divider", + l: 0, + t: 0 + }, + { + name: "textField3", + autoHeight: false, + autoFocus: true, + hintText: "search", + focusMode: "select", + onchange: "textField3Change", + type: "Palm.Mojo.TextField", + l: 0, + t: 34, + styles: { + bgColor: "", + bgImage: "" + } + }, + { + name: "divider2", + label: "page 1/10", + type: "Palm.Mojo.Divider", + l: 0, + t: 78 + }, + { + name: "scroller1", + ontap: "", + onchange: "", + scrollPosition: { + left: 0, + top: 0 + }, + type: "Palm.Mojo.Scroller", + l: 0, + t: 120, + h: 292, + styles: { + cursor: "move", + overflow: "hidden" + }, + controls: [ + { + name: "list1", + dropTarget: true, + items: [ + { + item: 0, + label: "Zero", + value: "0" + }, + { + item: 1, + label: "One", + value: "1" + }, + { + item: 2, + label: "Two", + value: "2" + }, + { + item: 3, + label: "Three", + value: "3" + } + ], + useSampleData: false, + title: undefined, + itemHtml: "
\n
 #{title}
 #{tag}
\n
\n", + onlisttap: "list1Listtap", + swipeToDelete: false, + reorderable: false, + type: "Palm.Mojo.List", + l: 0, + t: 0, + h: 285, + styles: { + textColor: "white" + } + } + ] + }, + { + name: "spinner1", + type: "Palm.Mojo.Spinner", + l: 0, + r: "270", + t: 391 + } + ] +}); \ No newline at end of file diff --git a/app/views/searchScrene/searchScrene-scene.html b/app/views/searchScrene/searchScrene-scene.html new file mode 100644 index 0000000..e69de29 diff --git a/app/views/splash/splash-chrome.js b/app/views/splash/splash-chrome.js new file mode 100644 index 0000000..37ab1d5 --- /dev/null +++ b/app/views/splash/splash-chrome.js @@ -0,0 +1,32 @@ +opus.Gizmo({ + name: "splash", + dropTarget: true, + type: "Palm.Mojo.Panel", + l: 0, + r: 0, + w: 320, + b: 0, + h: 452, + styles: { + zIndex: 2, + bgImage: "images/White_Crystal.jpg" + }, + chrome: [ + { + name: "label1", + label: "", + type: "Palm.Mojo.Label", + l: 0, + t: 0, + h: 91 + }, + { + name: "picture1", + type: "Palm.Picture", + l: 0, + w: 321, + t: 0, + h: 234 + } + ] +}); \ No newline at end of file diff --git a/app/views/splash/splash-scene.html b/app/views/splash/splash-scene.html new file mode 100644 index 0000000..e69de29 diff --git a/app/views/userInfo/userInfo-chrome.js b/app/views/userInfo/userInfo-chrome.js new file mode 100644 index 0000000..b0f4f01 --- /dev/null +++ b/app/views/userInfo/userInfo-chrome.js @@ -0,0 +1,140 @@ +opus.Gizmo({ + name: "userInfo", + dropTarget: true, + type: "Palm.Mojo.Panel", + t: 0, + h: 452, + styles: { + zIndex: 2, + bgImage: "images/white-1.jpg" + }, + chrome: [ + { + name: "label1", + label: "", + type: "Palm.Mojo.Label", + l: 0, + t: 0, + h: 10 + }, + { + name: "spinner1", + type: "Palm.Mojo.Spinner", + l: 0, + r: "270", + t: 20 + }, + { + name: "scroller4", + scrollPosition: { + left: 0, + top: 0 + }, + type: "Palm.Mojo.Scroller", + l: 0, + t: 0, + h: "100%", + styles: { + cursor: "move", + overflow: "hidden" + }, + controls: [ + { + name: "label2", + label: "", + type: "Palm.Mojo.Label", + l: 0, + t: 0, + h: 16 + }, + { + name: "picture1", + type: "Palm.Picture", + l: 95, + w: 130, + t: 0, + h: 117 + }, + { + name: "group1", + dropTarget: true, + label: "Bio", + type: "Palm.Mojo.Group", + l: 0, + t: 133, + h: 148, + controls: [ + { + name: "scroller5", + scrollPosition: { + left: 0, + top: 0 + }, + type: "Palm.Mojo.Scroller", + l: 0, + t: 0, + h: "100%", + styles: { + cursor: "move", + overflow: "hidden" + }, + controls: [ + { + name: "label3", + label: "", + type: "Palm.Mojo.Label", + l: 0, + t: 0 + } + ] + } + ] + }, + { + name: "divider1", + label: "Mixes", + type: "Palm.Mojo.Divider", + l: 0, + t: 281 + }, + { + name: "list1", + dropTarget: true, + items: [ + { + item: 0, + label: "Zero", + value: "0" + }, + { + item: 1, + label: "One", + value: "1" + }, + { + item: 2, + label: "Two", + value: "2" + }, + { + item: 3, + label: "Three", + value: "3" + } + ], + useSampleData: false, + title: undefined, + itemHtml: "
\n
 #{title}
 #{tag}
\n'; + //console.log("(css): " + path); + } else if (path.slice(-2) == "js") { + // js + //console.log("(js): " + path); + } else { + // package + // must encoded like so: + // [folder]/[name of package without extension] + var parts = path.split("/"); + var name = parts.pop(); + var folder = parts.join("/") + (parts.length ? "/" : ""); + opus.paths[name] = folder; + //console.log("make alias: " + name + ": " + folder); + path = folder + name + "-depends.js"; + //console.log("(depends): " + path); + } + if (!tag) { + tag = ''; + } + document.write(tag); + }, + depends: function(inDepends) { + //console.info("processing dependencies"); + var d; + if (d = inDepends.paths) { + for (var n in d) { + opus.paths[n] = d[n]; + } + } + if (d = inDepends.nobuild) { + for (i=0; b=d[i]; i++) { + this._depend(b); + } + } + if (d = inDepends.build) { + for (var i=0, b; b=d[i]; i++) { + this._depend(b); + } + } + } +}; + +(function(){ + if (!opus.paths.opus) { + opus.paths.opus = opus.locateScript("bootloader.js"); + } + opus.args = opus.argify(location.search); + var app = opus.args.app || (opus.args.debug ? "depends.js" : "app.js"); + document.write(''); + opus._tryDebug = function() { + app = "depends.js"; + document.write(''); + }; +})(); \ No newline at end of file diff --git a/ares_version.json b/ares_version.json new file mode 100644 index 0000000..7bb393e --- /dev/null +++ b/ares_version.json @@ -0,0 +1,4 @@ +{ + "Mojo": "0.1.0 (311)", + "Ares": "1.0.4" +} \ No newline at end of file diff --git a/dashboard.html b/dashboard.html new file mode 100644 index 0000000..d4474ff --- /dev/null +++ b/dashboard.html @@ -0,0 +1,15 @@ + + + + + Music Player + + + + + + + + + + \ No newline at end of file diff --git a/depends.js b/depends.js new file mode 100644 index 0000000..919a3d6 --- /dev/null +++ b/depends.js @@ -0,0 +1,37 @@ +opus.depends({ + paths: { + Ares: "/Ares", + opus: opus.args.apache ? "$Ares/foss/opus/opus" : "/opus/opus", + Palm: opus.args.apache ? "$Ares/ide" : "/ide", + mojo: "/usr/palm/frameworks/mojo/", + controls: "$opus/library/controls/", + AresLib: "$Palm/library/Ares", + MojoLib: "$Palm/library/Mojo/" + }, + nobuild: [ + "$mojo/mojo.js" + ], + build: [ + "$AresLib/source/kit.js", + "$opus/source/util.js", + "$opus/source/xhr.js", + "$opus/source/declare.js", + "$opus/source/Object.js", + "$opus/source/Component.js", + "$opus/source/DomNode.js", + "$opus/source/Style.js", + "$opus/source/Bounds.js", + "$opus/source/Control.js", + "$opus/source/layout/Layout.js", + "$opus/source/layout/Absolute.js", + "$opus/source/layout/Box.js", + "$opus/source/layout/Float.js", + "$opus/source/layout/Grid.js", + "$opus/source/Container.js", + "$opus/source/View.js", + "$opus/source/Json.js", + "$opus/source/Gizmo.js", + "$controls/source/Image.js", + "$MojoLib/Palm-Mojo" + ] +}); \ No newline at end of file diff --git a/framework_config.json b/framework_config.json new file mode 100644 index 0000000..ceb0536 --- /dev/null +++ b/framework_config.json @@ -0,0 +1,7 @@ +{ + "logLevel": 99, + "debuggingEnabled": true, + "timingEnabled": false, + "logEvents": false, + "escapeHTMLInTemplates" : true +} \ No newline at end of file diff --git a/icon.jpg b/icon.jpg new file mode 100644 index 0000000..1763a1e Binary files /dev/null and b/icon.jpg differ diff --git a/images/8tracks.png b/images/8tracks.png new file mode 100644 index 0000000..23d468b Binary files /dev/null and b/images/8tracks.png differ diff --git a/images/8tracksDash.png b/images/8tracksDash.png new file mode 100644 index 0000000..783d30f Binary files /dev/null and b/images/8tracksDash.png differ diff --git a/images/8tracksDash2.png b/images/8tracksDash2.png new file mode 100644 index 0000000..bd451ae Binary files /dev/null and b/images/8tracksDash2.png differ diff --git a/images/8tracks_logo.jpg b/images/8tracks_logo.jpg new file mode 100644 index 0000000..56392ce Binary files /dev/null and b/images/8tracks_logo.jpg differ diff --git a/images/White_Crystal.jpg b/images/White_Crystal.jpg new file mode 100644 index 0000000..ebe25f0 Binary files /dev/null and b/images/White_Crystal.jpg differ diff --git a/images/blue.jpg b/images/blue.jpg new file mode 100644 index 0000000..7d03f8f Binary files /dev/null and b/images/blue.jpg differ diff --git a/images/check_mark.png b/images/check_mark.png new file mode 100644 index 0000000..b435424 Binary files /dev/null and b/images/check_mark.png differ diff --git a/images/dashboard/album-art-overlay.png b/images/dashboard/album-art-overlay.png new file mode 100644 index 0000000..cac6a16 Binary files /dev/null and b/images/dashboard/album-art-overlay.png differ diff --git a/images/dashboard/dashboard_buttons.png b/images/dashboard/dashboard_buttons.png new file mode 100644 index 0000000..b77c7b0 Binary files /dev/null and b/images/dashboard/dashboard_buttons.png differ diff --git a/images/forward.png b/images/forward.png new file mode 100644 index 0000000..42fb24f Binary files /dev/null and b/images/forward.png differ diff --git a/images/greydiant.jpg b/images/greydiant.jpg new file mode 100644 index 0000000..f37a9f0 Binary files /dev/null and b/images/greydiant.jpg differ diff --git a/images/likedstar.png b/images/likedstar.png new file mode 100644 index 0000000..45f3a93 Binary files /dev/null and b/images/likedstar.png differ diff --git a/images/loading.gif b/images/loading.gif new file mode 100644 index 0000000..d9e135c Binary files /dev/null and b/images/loading.gif differ diff --git a/images/menu-icon-music-pause.png b/images/menu-icon-music-pause.png new file mode 100644 index 0000000..c7565dc Binary files /dev/null and b/images/menu-icon-music-pause.png differ diff --git a/images/menu-icon-music-play.png b/images/menu-icon-music-play.png new file mode 100644 index 0000000..8f3ea04 Binary files /dev/null and b/images/menu-icon-music-play.png differ diff --git a/images/mini_icon.png b/images/mini_icon.png new file mode 100644 index 0000000..bb68945 Binary files /dev/null and b/images/mini_icon.png differ diff --git a/images/mixlikeheart1.png b/images/mixlikeheart1.png new file mode 100644 index 0000000..12e2713 Binary files /dev/null and b/images/mixlikeheart1.png differ diff --git a/images/mixlikeheart2.png b/images/mixlikeheart2.png new file mode 100644 index 0000000..30a6e99 Binary files /dev/null and b/images/mixlikeheart2.png differ diff --git a/images/mixunlikeheart1.png b/images/mixunlikeheart1.png new file mode 100644 index 0000000..3d345aa Binary files /dev/null and b/images/mixunlikeheart1.png differ diff --git a/images/no_image.png b/images/no_image.png new file mode 100644 index 0000000..44f40a8 Binary files /dev/null and b/images/no_image.png differ diff --git a/images/overlay.png b/images/overlay.png new file mode 100644 index 0000000..2a38754 Binary files /dev/null and b/images/overlay.png differ diff --git a/images/pause1.png b/images/pause1.png new file mode 100644 index 0000000..f130e84 Binary files /dev/null and b/images/pause1.png differ diff --git a/images/playselected.png b/images/playselected.png new file mode 100644 index 0000000..048bc02 Binary files /dev/null and b/images/playselected.png differ diff --git a/images/playunselected.png b/images/playunselected.png new file mode 100644 index 0000000..6f7a78b Binary files /dev/null and b/images/playunselected.png differ diff --git a/images/pure.jpg b/images/pure.jpg new file mode 100644 index 0000000..859fd53 Binary files /dev/null and b/images/pure.jpg differ diff --git a/images/red.png b/images/red.png new file mode 100644 index 0000000..44726f8 Binary files /dev/null and b/images/red.png differ diff --git a/images/speaker.png b/images/speaker.png new file mode 100644 index 0000000..825ee95 Binary files /dev/null and b/images/speaker.png differ diff --git a/images/tracks_01.png b/images/tracks_01.png new file mode 100644 index 0000000..d3abd08 Binary files /dev/null and b/images/tracks_01.png differ diff --git a/images/trans-blue.png b/images/trans-blue.png new file mode 100644 index 0000000..4e16a5c Binary files /dev/null and b/images/trans-blue.png differ diff --git a/images/trans50.png b/images/trans50.png new file mode 100644 index 0000000..ea88a72 Binary files /dev/null and b/images/trans50.png differ diff --git a/images/unknownUser.jpg b/images/unknownUser.jpg new file mode 100644 index 0000000..9051865 Binary files /dev/null and b/images/unknownUser.jpg differ diff --git a/images/unlikedstar.png b/images/unlikedstar.png new file mode 100644 index 0000000..bba0b65 Binary files /dev/null and b/images/unlikedstar.png differ diff --git a/images/user_info.png b/images/user_info.png new file mode 100644 index 0000000..c9f6d88 Binary files /dev/null and b/images/user_info.png differ diff --git a/images/white-1.jpg b/images/white-1.jpg new file mode 100644 index 0000000..30028b0 Binary files /dev/null and b/images/white-1.jpg differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..3aa0269 --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + + 8tracks + + + + + diff --git a/lib/audio.js b/lib/audio.js new file mode 100644 index 0000000..700055f --- /dev/null +++ b/lib/audio.js @@ -0,0 +1,77 @@ +/* Copyright 2009 Palm, Inc. All rights reserved. */ + +/*globals Mojo, clearInterval, AppAssistant, MojoLoader, Audio, MediaKeyControlHandler, StatusBroadcaster, Playlist, HTMLMediaElement, setInterval*/ + +function DashboardPlayer() { + var _audioObj = 0; // initialized to 0 + var _photo = 0; // initialized to 0 + var _song = 0; // initialized to 0 + var _skipTrack = 0; + var _loaded = false; + var _likeToggle = false; + var _liked = false; + + this.singletonInstance = null; + + // Get the instance of the Cats class + // If there’s none, instanciate one + var getInstance = function() { + if (!this.singletonInstance) { + this.singletonInstance = createInstance(); + } + return this.singletonInstance; + }; + + // Create an instance of the Cats class + var createInstance = function() { + // Here, you return all public methods and variables + return { + update: function(audio, pht, info) { + _audioObj = audio; + _photo = pht; + _song = { + name: info.set.track.name, + artist: info.set.track.performer + }; + _liked = info.set.track.faved_by_current_user; + _loaded = true; + _isPlaying = true; + }, + setSkipEvent: function(skipFunc){ + _skipTrack = skipFunc; + }, + setLikeToggleEvent: function(toggleLike){ + _likeToggle = toggleLike; + }, + song: function() { + return _song; + }, + photo: function() { + return _photo; + }, + audio: function() { + return _audioObj; + }, + loaded: function() { + return _loaded; + }, + isPlaying: function(){ + return !_audioObj.paused; + }, + liked: function(state){ + return _liked; + }, + toggleLike: function(state){ + _liked = state; + _likeToggle(state); + }, + skipTrack: function(){ + _skipTrack(); + } + }; + }; + + return getInstance(); +} + +DashPlayerInstance = 0; \ No newline at end of file diff --git a/lib/themeManager.js b/lib/themeManager.js new file mode 100644 index 0000000..b71e2a2 --- /dev/null +++ b/lib/themeManager.js @@ -0,0 +1,53 @@ +function themeLookup(color) { + switch (color) { + case 'dark': + ret = { + URL: "url(images/greydiant.jpg)", + textColor: "white" + }; + return ret; + break; + case 'lite': + ret = { + URL: "url(images/white-1.jpg)", + textColor: "white" + }; + return ret; + break; + case 'lite2': + ret = { + URL: "url(images/white-1.jpg)", + textColor: "black" + }; + return ret; + break; + case 'red': + ret = { + URL: "url(images/red.png)", + textColor: "white" + }; + return ret; + break; + case 'blue': + ret = { + URL: "url(images/blue.jpg)", + textColor: "black" + }; + return ret; + break; + case 'flat': + ret = { + URL: "url(images/pure.jpg)", + textColor: "black" + }; + return ret; + break; + default: + ret = { + URL: "url(images/white-1.jpg)", + textColor: "white" + }; + return ret; + break; + } + }; \ No newline at end of file diff --git a/sounds/error.mp3 b/sounds/error.mp3 new file mode 100644 index 0000000..7c3e9f2 Binary files /dev/null and b/sounds/error.mp3 differ diff --git a/sounds/nextmix.mp3 b/sounds/nextmix.mp3 new file mode 100644 index 0000000..64f4977 Binary files /dev/null and b/sounds/nextmix.mp3 differ diff --git a/sounds/nextmix2.mp3 b/sounds/nextmix2.mp3 new file mode 100644 index 0000000..284df36 Binary files /dev/null and b/sounds/nextmix2.mp3 differ diff --git a/sources.json b/sources.json new file mode 100644 index 0000000..6878e37 --- /dev/null +++ b/sources.json @@ -0,0 +1,92 @@ +[ + {"source": "lib/themeManager.js"}, + { "source": "app/assistants/main-assistant.js" }, + { "source": "app/assistants/app-assistant.js" }, + { "source": "lib/audio.js" }, + { + "source": "app/assistants/dashboard-assistant.js" + }, + { + "source": "app/assistants/stage-assistant.js" + }, + { + "source": "app/views/main/main-chrome.js", + "scenes": "main" + }, + { + "source": "app/assistants/main-assistant.js", + "scenes": "main" + }, + { + "source": "app/assistants/signedin-assistant.js", + "scenes": "signedin" + }, + { + "source": "app/views/signedin/signedin-chrome.js", + "scenes": "signedin" + }, + { + "source": "app/assistants/player-assistant.js", + "scenes": "player" + }, + { + "source": "app/views/player/player-chrome.js", + "scenes": "player" + }, + { + "source": "app/views/signMeUp/signMeUp-chrome.js", + "scenes": "signMeUp" + }, + { + "source": "app/views/userInfo/userInfo-chrome.js", + "scenes": "userInfo" + }, + { + "source": "app/assistants/mixDetailsScene-assistant.js", + "scenes": "mixDetailsScene" + }, + { + "source": "app/views/mixDetailsScene/mixDetailsScene-chrome.js", + "scenes": "mixDetailsScene" + }, + { + "source": "app/assistants/gridScene-assistant.js", + "scenes": "gridScene" + }, + { + "source": "app/views/gridScene/gridScene-chrome.js", + "scenes": "gridScene" + }, + { + "source": "app/assistants/splash-assistant.js", + "scenes": "splash" + }, + { + "source": "app/views/splash/splash-chrome.js", + "scenes": "splash" + }, + { + "source": "app/assistants/searchScrene-assistant.js", + "scenes": "searchScrene" + }, + { + "source": "app/views/searchScrene/searchScrene-chrome.js", + "scenes": "searchScrene" + }, + { + "source": "app/assistants/userInfo-assistant.js", + "scenes": "userInfo" + }, + { + "source": "app/views/userInfo/userInfo-chrome.js", + "scenes": "userInfo" + }, + { + "source": "app/assistants/login-assistant.js", + "scenes": "login" + }, + { + "source": "app/views/login/login-chrome.js", + "scenes": "login" + } +] \ No newline at end of file diff --git a/stylesheets/dashboard.css b/stylesheets/dashboard.css new file mode 100644 index 0000000..bf94eb8 --- /dev/null +++ b/stylesheets/dashboard.css @@ -0,0 +1,56 @@ +/* Copyright 2009 Palm, Inc. All rights reserved. */ + +.palm-dashboard-controls-container { + position: absolute; + right: 0; + z-index: 1; +} + +.control-button { + width: 48px; + height: 48px; + float: right; + background: url(../images/dashboard/dashboard_buttons.png) top left no-repeat; +} +.like-button.like { + width: 56px; + height: 56px; + float: right; + background: url(../images/unlikedstar.png) center center no-repeat; +} +.like-button.unlike { + width: 56px; + height: 56px; + float: right; + background: url(../images/likedstar.png) center center no-repeat; +} +.control-button.selected { background-position-y: -48px; } + +.control-button.pause { background-position-x: -48px; } +.control-button.next { background-position-x: -96px; } +.control-button.previous { background-position-x: -142px; } + +.dashboard-notification-module .album-art { + position: absolute; + right: -8px; + top: 3px; + -webkit-transform: rotate(-3deg); + width: 185px; + height: 50px; +} + +.dashboard-notification-module .album-art-overlay { + position: absolute; + right: 0px; + top: -2px; + width: 185px; + height: 51px; + background: url(../images/dashboard/album-art-overlay.png) center center no-repeat; +} + +.palm-dashboard-text, +.dashboard-title { + z-index: 1; + position: relative; + margin-right: 168px; +} \ No newline at end of file diff --git a/stylesheets/list.css b/stylesheets/list.css new file mode 100644 index 0000000..ee495ff --- /dev/null +++ b/stylesheets/list.css @@ -0,0 +1,15 @@ +.title{ + font-size: 14pt; + font-family: Arial; + padding: 2pt; +} +img { + padding: 2pt; + float: left; + //display: block; +} +.second { + font-family: Helvetica; + color: #808080; + font-size: 11pt; +} \ No newline at end of file diff --git a/stylesheets/styles b/stylesheets/styles new file mode 100644 index 0000000..0237922 --- /dev/null +++ b/stylesheets/styles @@ -0,0 +1,23 @@ +#loading{ + height: 480px; + width: 100%; + display: block; + position: absolute; + top: 0; + left: 0; + background: url(../images/trans50.png); + z-index: -1; + margin: 0; + padding: 0; +} +#loading-box{ + padding: 8px; + -webkit-border-radius: 10px; + background-color: #000; + color: #fff; + width: 50px; + margin-top: -50px; +} +.hidden{ + display: none; +} \ No newline at end of file