spacetours.ad/AdUnit/iAd/iAd.js
/** |
* |
* Copyright © 2009, 2010 Apple Inc. All rights reserved. |
* |
**/ |
/* iAd JS Version: 1.3 - r1873 */ |
var iAd={};iAd.VERSION="1.3";iAd.IS_IPAD=navigator.platform=="iPad";iAd.HAS_HIDPI_DISPLAY=window.devicePixelRatio>=2;iAd.SUPPORTS_TOUCHES="createTouch"in document;iAd.START_EVENT=iAd.SUPPORTS_TOUCHES?"touchstart":"mousedown";iAd.MOVE_EVENT=iAd.SUPPORTS_TOUCHES?"touchmove":"mousemove";iAd.END_EVENT=iAd.SUPPORTS_TOUCHES?"touchend":"mouseup";iAd.Utils={assetsPath:"",registeredHTMLViewLoadingClasses:[]};iAd.Utils.t=function(a,b){return iAd.Utils.t3d(a,b,0)}; |
iAd.Utils.t3d=function(a,b,c){return"translate3d("+a+"px, "+b+"px, "+c+"px)"};iAd.Utils.r3d=function(a,b,c,d){return"rotate3d("+a+", "+b+", "+c+", "+d+"rad)"};iAd.Utils.px=function(a){return a+"px"};iAd.Utils.degreesToRadians=function(a){return a/360*Math.PI*2};iAd.Utils.radiansToDegrees=function(a){return a/(Math.PI*2)*360};iAd.Utils.copyPropertiesFromSourceToTarget=function(a,b){for(var c in a)b[c]=a[c]}; |
iAd.Utils.cloneObject=function(a){var b={};iAd.Utils.copyPropertiesFromSourceToTarget(a,b);return b};iAd.Utils.dashedStringToCamelCase=function(a){a=a.split("-");return a.shift()+a.map(iAd.Utils.capitalizeString).join("")};iAd.Utils.capitalizeString=function(a){return a.charAt(0).toUpperCase()+a.substr(1)};iAd.Utils.camelCaseStringToDashed=function(a){return a.replace(/([A-Z])/g,function(b){return"-"+b.toLowerCase()})}; |
iAd.Utils.escapeRegExp=function(a){var b=RegExp("[.*+?|()\\[\\]{}\\\\]","g");return a.replace(b,"\\$&")};iAd.Utils.objectIsFunction=function(a){return typeof a=="function"};iAd.Utils.objectIsUndefined=function(a){return a===undefined};iAd.Utils.objectIsString=function(a){return typeof a=="string"||a instanceof String};iAd.Utils.objectIsArray=function(a){return a instanceof Array};iAd.Utils.objectHasMethod=function(a,b){return a!==null&&!this.objectIsUndefined(a[b])&&this.objectIsFunction(a[b])}; |
iAd.Utils.resolveObjectPath=function(a,b){if(!(a[0]==="."||a[0]==="")){for(var c=a.split("."),d=window,e=0,f=c.length;d!=null&&e<f;e++){if(b&&d[c[e]]==null)d[c[e]]={};d=d[c[e]]}return d}};iAd.Utils.disableScrolling=function(a){a.stopPropagation();window.addEventListener("touchmove",iAd.Utils.preventEventDefault,true);window.addEventListener("touchend",iAd.Utils.restoreScrollingBehavior,true);window.addEventListener("touchcancel",iAd.Utils.restoreScrollingBehavior,true)}; |
iAd.Utils.preventEventDefault=function(a){a.preventDefault()};iAd.Utils.restoreScrolling=function(){window.removeEventListener("touchmove",iAd.Utils.preventEventDefault,true);window.removeEventListener("touchend",iAd.Utils.restoreScrollingBehavior,true);window.removeEventListener("touchcancel",iAd.Utils.restoreScrollingBehavior,true)};iAd.Utils.createUIEvent=function(a,b){return iAd.SUPPORTS_TOUCHES?this.createEventWithTouch(a,b):this.createEventWithMouse(a,b)}; |
iAd.Utils.createEventWithTouch=function(a,b){var c=document.createEvent("TouchEvent");c.initTouchEvent(a,b.bubbles,b.cancelable,window,b.detail,b.screenX,b.screenY,b.clientX,b.clientY,b.ctrlKey,b.altKey,b.shiftKey,b.metaKey,b.touches,b.targetTouches,b.changedTouches,b.scale,b.rotation);return c}; |
iAd.Utils.createEventWithMouse=function(a,b){var c=document.createEvent("MouseEvent");c.initMouseEvent(a,b.bubbles,b.cancelable,document.defaultView,b.detail,b.screenX,b.screenY,b.clientX,b.clientY,b.ctrlKey,b.altKey,b.shiftKey,b.metaKey,b.metaKey,b.button,b.relatedTarget);return c}; |
iAd.Utils.init=function(){iAd.HAS_HIDPI_DISPLAY&&document.body.addClassName("ad-HiDPI");iAd.IS_IPAD&&document.body.addClassName("ad-iPad");for(var a=/\/?iAd(-\w+)?\.cssz?(\?.*)?$/,b,c,d=0;d<document.styleSheets.length;d++){b=document.styleSheets[d];if(b.href){b=b.href.split("/");c=b.pop();if(a.test(c)){b.push("assets/");iAd.Utils.assetsPath=b.join("/");break}}}a=document.querySelector("."+iAd.RootView.cssClassName);if(a!==null)iAd.RootView._sharedRoot=new iAd.RootView(a)}; |
iAd.Utils.setupDisplayNames=function(a,b){var c=b||a.displayName||a.name;for(var d in a)if(!a.__lookupGetter__(d)){var e=a[d];if(iAd.Utils.objectIsFunction(e))e.displayName=iAd.Utils.createDisplayName(c,d)}for(d in a.prototype)if(!a.prototype.__lookupGetter__(d)){e=a.prototype[d];if(iAd.Utils.objectIsFunction(e))e.displayName=iAd.Utils.createDisplayName(c,d)}};iAd.Utils.createDisplayName=function(a,b){return a+"."+b+"()"}; |
iAd.Utils.createNodeFromString=function(a){var b=document.createRange();b.selectNode(document.body);for(a=b.createContextualFragment(a).firstChild;a.nodeType!=Node.ELEMENT_NODE&&a.nextSibling;)a=a.nextSibling;return a};iAd.Utils.makeEventHandlerWithString=function(a){var b=new Function(a);return function(c){b.call(null,c)}};iAd.Utils.registerClassForHTMLViewLoading=function(a){iAd.Utils.registeredHTMLViewLoadingClasses.push(a)}; |
iAd.Utils.getViewWithLayer=function(a){for(var b=iAd.Utils.registeredHTMLViewLoadingClasses,c=iAd.View,d,e=0;e<b.length;e++){d=b[e];if(a.hasClassName(d.cssClassName)){c=d;break}}return new c(a)};iAd.Utils.viewsForClassAndNode=function(a,b){var c=[];if(!a.hasOwnProperty("cssClassName"))return c;for(var d=b.querySelectorAll("."+a.cssClassName),e=0;e<d.length;e++)c.push(d[e]._view);return c}; |
iAd.Utils.isElementInDocument=function(a){if(a===undefined||a===null||a.ownerDocument!==document)return false;for(var b=document.body;a!==b&&a.parentNode;)a=a.parentNode;return a===b};iAd.Utils.elementForNode=function(a){return a.nodeType===Node.ELEMENT_NODE?a:a.parentElement};window.addEventListener("DOMContentLoaded",iAd.Utils.init,false);iAd.Utils.setupDisplayNames(iAd.Utils,"iAd.Utils");iAd.EventTriage={}; |
iAd.EventTriage.handleEvent=function(a){this instanceof iAd.Object&&this.callSuper(a);var b=a.type;b="handle"+b.charAt(0).toUpperCase()+b.substr(1);iAd.Utils.objectHasMethod(this,b)&&this[b](a)};iAd.Utils.setupDisplayNames(iAd.EventTriage,"iAd.EventTriage");iAd.EventTarget={};iAd.EventTarget.addEventListener=function(a,b,c){this.eventTarget.addEventListener(a,b,c)};iAd.EventTarget.removeEventListener=function(a,b,c){this.eventTarget.removeEventListener(a,b,c)};iAd.EventTarget.dispatchEvent=function(a){this.eventTarget.dispatchEvent(a)}; |
iAd.EventTarget.dispatchNotification=function(a,b,c){if(iAd.Utils.objectHasMethod(b,a)){var d=[this];if(c)d=d.concat(c.map(function(e){return e[1]}));b[a].apply(b,d)}this.dispatchEvent(this.createEvent(a,c))};iAd.EventTarget.createEvent=function(a,b){var c=document.createEvent("Event");c.initEvent(a,true,false);if(!c.ad)c.ad={};c.ad.sender=this;if(b)for(var d=0;d<b.length;d++)c.ad[b[d][0]]=b[d][1];return c};iAd.Utils.setupDisplayNames(iAd.EventTarget,"iAd.EventTarget");iAd.PropertyTriage={}; |
iAd.PropertyTriage.handlePropertyChange=function(a,b){var c="handle"+b.charAt(0).toUpperCase()+b.substr(1)+"Change";iAd.Utils.objectHasMethod(this,c)&&this[c](a)};iAd.Utils.setupDisplayNames(iAd.PropertyTriage,"iAd.PropertyTriage");Element.prototype.hasClassName=function(a){return RegExp("(?:^|\\s+)"+a+"(?:\\s+|$)").test(this.className)};Element.prototype.addClassName=function(a){if(this.hasClassName(a))return false;else{this.className=[this.className,a].join(" ");return true}}; |
Element.prototype.removeClassName=function(a){if(this.hasClassName(a)){this.className=this.className.replace(RegExp("(?:^|\\s+)"+a+"(?:\\s+|$)","g")," ");return true}return false};Element.prototype.toggleClassName=function(a,b){if(b==null)b=!this.hasClassName(a);this[b?"addClassName":"removeClassName"](a)};iAd.Utils.setupDisplayNames(Element,"Element"); |
Node.prototype.getNearestView=function(){for(var a=this;iAd.Utils.objectIsUndefined(a._view)&&a.parentNode;)a=a.parentNode;return iAd.Utils.objectIsUndefined(a._view)?null:a._view};iAd.Utils.setupDisplayNames(Node,"Node"); |
iAd.Class=function(a){if(typeof a==="string")a={name:a};a=a||{};a.symbol=a.symbol===undefined?a.name:a.symbol;a.name=a.name||"AnonymousClass";a.superclass=a.superclass||iAd.Object;var b=function(){b.processed||iAd.Class.processAllClasses();b.prototype.init.apply(this,arguments)};b.processed=false;iAd.Class.unprocessedClasses.push(b);b.displayName=b._name=a.name;iAd.Utils.copyPropertiesFromSourceToTarget(a,b);if(a.symbol&&typeof a.symbol==="string"){var c=a.symbol.split(".");a=c.pop();if(c=c.length? |
iAd.Utils.resolveObjectPath(c.join("."),true):window)c[a]=b}return b};iAd.Class.unprocessedClasses=[];iAd.Class.processAllClasses=function(){for(var a,b=0;b<iAd.Class.unprocessedClasses.length;b++){a=iAd.Class.unprocessedClasses[b];a.processed||iAd.Class.processClassAndHierarchy(a)}iAd.Class.unprocessedClasses=[]}; |
iAd.Class.processClassAndHierarchy=function(a){for(var b=[a],c=a;c=c.superclass;)b.push(c);var d;for(c=b.length-1;c>=0;c--){d=b[c];d.processed||iAd.Class.processClass(d)}for(c=b.length-1;c>=0;c--){d=b[c];iAd.Utils.objectHasMethod(d,"initialize")&&d.initialize.apply(a)}}; |
iAd.Class.processClass=function(a){a.mixins&&iAd.Class.mixin(a.prototype,a.mixins);for(var b=a.synthesizedProperties||[],c=0;c<b.length;c++)iAd.Class.synthesizeProperty(a.prototype,b[c]);for(var d in a.prototype)a.prototype.__lookupGetter__(d)||iAd.Class.processMethod(a,d);if(a!==iAd.Object)a.prototype.__proto__=a.superclass.prototype;a.processed=true}; |
iAd.Class.synthesizeProperty=function(a,b){var c=b.charAt(0).toUpperCase()+b.substr(1),d="get"+c,e="set"+c,f="_"+b;iAd.Utils.objectHasMethod(a,e)||(a[e]=function(i){this[f]=i});c=function(i){this[e](i);this.notifyPropertyChange(b)};c.displayName="Setter for ."+b+" on "+a.constructor.displayName;iAd.Utils.objectHasMethod(a,d)||(a[d]=function(){return this[f]});var g=function(){return this[d]()};g.displayName="Getter for ."+b+" on "+a.constructor.displayName;Object.defineProperty(a,b,{get:g,set:c})}; |
iAd.Class.processMethod=function(a,b){var c=a.prototype[b];if(iAd.Utils.objectIsFunction(c)){c._class=a;c._name=b;c.displayName=iAd.Utils.createDisplayName(a.displayName,b)}};iAd.Class.mixin=function(a,b){for(var c,d=0;d<b.length;d++){c=b[d];for(var e in c)a.hasOwnProperty(e)||(a[e]=c[e])}};iAd.Class.synthesizeProperties=function(a,b){iAd.Class.processClassAndHierarchy(a);for(var c=0;c<b.length;c++)iAd.Class.synthesizeProperty(a.prototype,b[c])}; |
iAd.Class.processMethods=function(a,b){iAd.Class.processClassAndHierarchy(a);for(var c=0;c<b.length;c++)iAd.Class.processMethod(a,b[c])};iAd.Utils.setupDisplayNames(iAd.Class,"iAd.Class");iAd.Class("iAd.Object");iAd.Object.PROPERTY_CHANGED="handlePropertyChange";iAd.Object.prototype.init=function(){this.observedProperties={}}; |
iAd.Object.prototype.callSuper=function(){var a=iAd.Object.prototype.callSuper.caller;if(iAd.Utils.objectHasMethod(a,"superclass"))a.superclass.apply(this,arguments);else{var b=a._class.superclass.prototype;a=a._name;if(iAd.Utils.objectHasMethod(b,a))return b[a].apply(this,arguments)}};iAd.Object.prototype.isPropertyObserved=function(a){return!iAd.Utils.objectIsUndefined(this.observedProperties[a])}; |
iAd.Object.prototype.addPropertyObserver=function(a,b,c){var d=this.observedProperties[a];if(this.isPropertyObserved(a)){if(d.targets.indexOf(b)>-1)return}else d=this.observedProperties[a]={targets:[],methodNames:[]};c=c||iAd.Object.PROPERTY_CHANGED;if(iAd.Utils.objectHasMethod(b,c)){d.targets.push(b);d.methodNames.push(c)}}; |
iAd.Object.prototype.removePropertyObserver=function(a,b){if(!this.isPropertyObserved(a))return false;var c=this.observedProperties[a],d=c.targets.indexOf(b),e=d>-1;if(e){c.targets.splice(d,1);c.methodNames.splice(d,1);c.targets.length==0&&delete this.observedProperties[a]}return e};iAd.Object.prototype.notifyPropertyChange=function(a){if(this.isPropertyObserved(a)){var b=this.observedProperties[a],c=b.targets;b=b.methodNames;for(var d=0;d<c.length;d++)c[d][b[d]](this,a)}}; |
iAd.Object.prototype.callMethodNameAfterDelay=function(a,b){var c=this,d=Array.prototype.slice.call(arguments,2),e=function(){c[a].apply(c,d)};e.displayName=iAd.Utils.createDisplayName(this.constructor.displayName||this.constructor.name,a);return setTimeout(e,b)};iAd.Point=function(a,b){this.x=a!=null&&!isNaN(a)?a:0;this.y=b!=null&&!isNaN(b)?b:0};iAd.Point.fromEvent=function(a){a=a.touches&&a.touches.length>0?a.touches[0]:a;return new iAd.Point(a.pageX,a.pageY)}; |
iAd.Point.fromEventInElement=function(a,b){a=a.touches&&a.touches.length>0?a.touches[0]:a;return window.webkitConvertPointFromPageToNode(b,new WebKitPoint(a.pageX,a.pageY))};iAd.Point.prototype.toString=function(){return"iAd.Point["+this.x+","+this.y+"]"};iAd.Point.prototype.copy=function(){return new iAd.Point(this.x,this.y)};iAd.Point.prototype.equals=function(a){return this.x==a.x&&this.y==a.y};iAd.Utils.setupDisplayNames(iAd.Point,"iAd.Point"); |
iAd.Size=function(a,b){this.width=a!=null&&!isNaN(a)?a:0;this.height=b!=null&&!isNaN(b)?b:0};iAd.Size.ZERO_SIZE=new iAd.Size(0,0);iAd.Size.prototype.toString=function(){return"iAd.Size["+this.width+","+this.height+"]"};iAd.Size.prototype.copy=function(){return new iAd.Size(this.width,this.height)};iAd.Size.prototype.equals=function(a){return this.width==a.width&&this.height==a.height};iAd.Utils.setupDisplayNames(iAd.Size); |
iAd.EdgeInsets=function(a,b,c,d){this.top=a;this.right=b;this.bottom=c;this.left=d};iAd.Class({name:"iAd.Image",synthesizedProperties:["url","width","height","loaded"]});iAd.Image.HIDPI_SUFFIX="@2x";iAd.Image.prototype.init=function(a,b){this.callSuper();this.scaleFactor=1;this.element=new Image;this.element.addEventListener("load",this,false);this.hasHiDPIVersion=b;this.resolvedURL=null;this.url=a;this._height=this._width=0}; |
iAd.Image.prototype.appendSuffix=function(a){var b="("+iAd.Utils.escapeRegExp(iAd.Image.HIDPI_SUFFIX)+"|"+iAd.Utils.escapeRegExp(encodeURIComponent(iAd.Image.HIDPI_SUFFIX))+")(\\.[^\\./]+)?$";if(!RegExp(b,"i").test(a))if(/\.[^\.\/]+/.test(a)){b=a.lastIndexOf(".");a=a.substr(0,b)+iAd.Image.HIDPI_SUFFIX+a.substr(b)}else a+=iAd.Image.HIDPI_SUFFIX;return a};iAd.Image.prototype.getWidth=function(){return this.element.width*this.scaleFactor}; |
iAd.Image.prototype.getHeight=function(){return this.element.height*this.scaleFactor};iAd.Image.prototype.handleEvent=function(){this.loaded=true};iAd.Image.prototype.setUrl=function(a){if(this._url!=a){this._url=a;this._loaded=false;if(this.hasHiDPIVersion&&iAd.HAS_HIDPI_DISPLAY){this.resolvedURL=this.appendSuffix(a);this.scaleFactor=0.5}else this.resolvedURL=a;this.element.src=this.resolvedURL}};iAd.Class("iAd.Animator");iAd.Animator.LINEAR_TYPE=0;iAd.Animator.SPLINES_TYPE=1; |
iAd.Animator.INVALID_ARGS_EXCEPTION=2;iAd.Animator.ANIMATION_DID_ITERATE="animationDidIterate";iAd.Animator.ANIMATION_DID_END="animationDidEnd"; |
iAd.Animator.prototype.init=function(a,b,c){if(arguments.length!=2&&arguments.length!=3&&arguments.length!=7)throw iAd.Animator.INVALID_ARGS_EXCEPTION;this.animating=this.ready=false;this.timer=null;this.duration=a;this.delegate=b;if(iAd.Utils.objectHasMethod(this.delegate,iAd.Animator.ANIMATION_DID_ITERATE)){if(arguments.length>=2){this.type=iAd.Animator.SPLINES_TYPE;this.x1=c[0];this.y1=c[1];this.x2=c[2];this.y2=c[3];this.setup()}else this.type=iAd.Animator.LINEAR_TYPE;this.ready=true}}; |
iAd.Animator.prototype.setup=function(){this.cx=3*this.x1;this.bx=3*(this.x2-this.x1)-this.cx;this.ax=1-this.cx-this.bx;this.cy=3*this.y1;this.by=3*(this.y2-this.y1)-this.cy;this.ay=1-this.cy-this.by;var a=this.duration/1E3*240;this.curve=Array(a);for(var b=1/(a-1),c=0;c<a;c++){var d=c*b;this.curve[c]={x:this.ax*Math.pow(d,3)+this.bx*Math.pow(d,2)+this.cx*d,y:this.ay*Math.pow(d,3)+this.by*Math.pow(d,2)+this.cy*d}}}; |
iAd.Animator.prototype.start=function(){if(this.ready){this.animating=true;this.lastIndex=0;this.startTime=(new Date).getTime();this.iterate()}else{var a=this;this.timer=setTimeout(function(){a.start()},0)}};iAd.Animator.prototype.stop=function(){this.animating=false;clearTimeout(this.timer)}; |
iAd.Animator.prototype.iterate=function(){var a=(new Date).getTime()-this.startTime;if(a<this.duration){a=a/this.duration;if(this.type==iAd.Animator.SPLINES_TYPE)for(var b=0,c=this.lastIndex;c<this.curve.length;c++){var d=this.curve[c];if(d.x>=a&&c>0){b=this.curve[c-1];if(a-b.x<d.x-a){this.lastIndex=c-1;b=b.y}else{this.lastIndex=c;b=d.y}break}}this.delegate[iAd.Animator.ANIMATION_DID_ITERATE](this.type==iAd.Animator.SPLINES_TYPE?b:a);var e=this;this.timer=setTimeout(function(){e.iterate()},0)}else{this.delegate[iAd.Animator.ANIMATION_DID_ITERATE](1); |
iAd.Utils.objectHasMethod(this.delegate,iAd.Animator.ANIMATION_DID_END)&&this.delegate[iAd.Animator.ANIMATION_DID_END]();this.animating=false}};iAd.Class({name:"iAd.Transition",mixins:[iAd.EventTarget]});iAd.Transition.DID_COMPLETE_DELEGATE="transitionDidComplete";iAd.Transition.DEFAULTS={duration:0.5,delay:0,removesTargetUponCompletion:false,revertsToOriginalValues:false}; |
iAd.Transition.STYLES=["-webkit-transition-property","-webkit-transition-duration","-webkit-transition-timing-function","-webkit-transition-delay","-webkit-transition"];iAd.Transition.WIDTH_REG_EXP=RegExp(/\$width/g);iAd.Transition.HEIGHT_REG_EXP=RegExp(/\$height/g); |
iAd.Transition.prototype.init=function(a){this.revertsToOriginalValues=this.removesTargetUponCompletion=this.delegate=this.timingFunction=this.to=this.from=this.delay=this.duration=this.properties=this.target=null;this.defaultsApplied=false;this.archivedStyles=null;this.archivedValues=[];iAd.Utils.copyPropertiesFromSourceToTarget(a,this)}; |
iAd.Transition.prototype.applyDefaults=function(){if(!this.defaultsApplied){for(var a in iAd.Transition.DEFAULTS)if(this[a]===null)this[a]=iAd.Transition.DEFAULTS[a];this.defaultsApplied=true}};iAd.Transition.prototype.archiveTransitionStyles=function(){if(this.archivedStyles===null){var a=this.target instanceof iAd.View?this.target.layer:this.target;this.archivedStyles=[];for(var b=0;b<iAd.Transition.STYLES.length;b++)this.archivedStyles.push(a.style.getPropertyValue(iAd.Transition.STYLES[b]))}}; |
iAd.Transition.prototype.restoreTransitionStyles=function(){for(var a=0;a<iAd.Transition.STYLES.length;a++)this.element.style.setProperty(iAd.Transition.STYLES[a],this.archivedStyles[a],"");this.archivedStyles=null};iAd.Transition.prototype.archiveBaseValues=function(){if(this.revertsToOriginalValues)if(this.target instanceof iAd.View)for(var a=0;a<this.properties.length;a++)this.archivedValues.push(this.target[this.properties[a]]);else for(a=0;a<this.properties.length;a++)this.archivedValues.push(this.target.layer.style.getPropertyValue(this.properties[a]))}; |
iAd.Transition.prototype.restoreBaseValues=function(){if(this.target instanceof iAd.View)for(var a=0;a<this.properties.length;a++)this.target[this.properties[a]]=this.archivedValues[a];else for(a=0;a<this.properties.length;a++)this.target.layer.style.setProperty(this.properties[a],this.archivedValues[a],null)}; |
iAd.Transition.prototype.start=function(){if(iAd.Transaction.openTransactions>0)iAd.Transaction.addTransition(this);else{this.applyDefaults();if(this.from===null)this.applyToState();else{this.applyFromState();var a=this;setTimeout(function(){a.applyToState()},0)}}}; |
iAd.Transition.prototype.applyFromState=function(){if(this.from!==null){this.applyDefaults();this.archiveTransitionStyles();if(this.target instanceof iAd.View)for(var a=this.target.layer.style.webkitTransitionDuration=0;a<this.properties.length;a++)this.target[this.properties[a]]=this.processTransitionValue(this.from[a]);else for(a=this.target.style.webkitTransitionDuration=0;a<this.properties.length;a++)this.target.style.setProperty(this.properties[a],this.from[a],"")}}; |
iAd.Transition.prototype.applyToState=function(){this.applyDefaults();this.archiveTransitionStyles();this.archiveBaseValues();var a=this.target instanceof iAd.View;this.cssProperties=[];for(var b=[],c=0;c<this.properties.length;c++){var d=a?this.target.cssPropertyNameForJSProperty(this.properties[c]):this.properties[c];if(!(this.cssProperties.indexOf(d)>-1)){var e=iAd.Utils.objectIsArray(this.duration)?this.duration[c]:this.duration,f=iAd.Utils.objectIsArray(this.timingFunction)?this.timingFunction[c]: |
this.timingFunction,g=iAd.Utils.objectIsArray(this.delay)?this.delay[c]:this.delay;b.push([d,e+"s",f,g+"s"].join(" "));this.cssProperties.push(d)}}this.eventTarget=this.element=a?this.target.layer:this.target;e!==0&&this.element.addEventListener("webkitTransitionEnd",this,false);this.completedTransitions=0;this.element.style.webkitTransition=b.join(", ");if(a)for(c=0;c<this.properties.length;c++)this.target[this.properties[c]]=this.processTransitionValue(this.to[c]);else for(c=0;c<this.properties.length;c++)this.target.style.setProperty(this.properties[c], |
this.to[c],"")}; |
iAd.Transition.prototype.handleEvent=function(a){if(a.target===this.element){this.completedTransitions++;if(this.completedTransitions==this.cssProperties.length){this.dispatchNotification(iAd.Transition.DID_COMPLETE_DELEGATE,this.delegate);this.element.removeEventListener("webkitTransitionEnd",this,false);if(this.removesTargetUponCompletion){a=this.target;this.target instanceof iAd.View?a.removeFromSuperview():a.parentNode.removeChild(a)}else this.restoreTransitionStyles();this.revertsToOriginalValues&&this.restoreBaseValues()}}}; |
iAd.Transition.prototype.processTransitionValue=function(a){if(!iAd.Utils.objectIsString(a))return a;a=a.replace(iAd.Transition.WIDTH_REG_EXP,iAd.Utils.px(this.target.size.width));return a.replace(iAd.Transition.HEIGHT_REG_EXP,iAd.Utils.px(this.target.size.height))};iAd.Transaction={transitions:[],openTransactions:0,defaults:{},defaultsStates:[]};iAd.Transaction.begin=function(){if(this.openTransactions==0){this.transitions=[];this.defaults={}}else this.defaultsStates.push(this.defaults);this.openTransactions++}; |
iAd.Transaction.addTransition=function(a){for(var b in this.defaults)if(a[b]===null)a[b]=this.defaults[b];this.transitions.push(a)};iAd.Transaction.commit=function(){if(this.openTransactions!=0){this.openTransactions--;if(this.openTransactions!=0)this.defaults=this.defaultsStates.pop();else{for(var a=this.transitions,b=0;b<a.length;b++)a[b].applyFromState();setTimeout(function(){for(var c=0;c<a.length;c++)a[c].applyToState()},0)}}};iAd.Utils.setupDisplayNames(iAd.Transaction,"iAd.Transaction");iAd.Class("iAd.Animation"); |
iAd.Animation.DID_COMPLETE_DELEGATE="animationDidComplete";iAd.Animation.DEFAULTS={duration:1,delay:0,removesTargetUponCompletion:false,timingFunction:"ease"};iAd.Animation.STYLES=["-webkit-animation-name","-webkit-animation-timing-function","-webkit-animation-duration","-webkit-animation-iteration-count","-webkit-animation-direction","-webkit-animation-delay","-webkit-animation"]; |
iAd.Animation.prototype.init=function(a){this.rule=iAd.Animation.createRule();this.delay=this.duration=this.target=null;this.keyframes=[];this.removesTargetUponCompletion=this.delegate=this.timingFunction=null;iAd.Utils.copyPropertiesFromSourceToTarget(a,this);this.setup()}; |
iAd.Animation.prototype.setup=function(){for(var a in iAd.Animation.DEFAULTS)if(this[a]===null)this[a]=iAd.Animation.DEFAULTS[a];this.archiveAnimationStyles();var b=this.target.layer.style;for(a=0;a<iAd.Animation.STYLES;a++)b.setProperty(iAd.Animation.STYLES[a],"","");for(a=0;a<this.keyframes.length;a++){b=this.keyframes[a];for(var c=b.offset*100+"% {",d=0;d<b.values.length;d+=2)c+=this.target.cssPropertyNameForJSProperty(b.values[d])+": "+b.values[d+1]+";";c+="}";this.rule.insertRule(c)}}; |
iAd.Animation.prototype.start=function(){var a=this.target.layer.style;a.webkitAnimationName=this.rule.name;a.webkitAnimationDuration=this.duration+"s";a.webkitAnimationDelay=this.delay+"s";a.webkitAnimationTimingFunction=this.timingFunction;this.target.layer.addEventListener("webkitAnimationEnd",this,false)};iAd.Animation.prototype.archiveAnimationStyles=function(){this.archivedStyles=[];for(var a=0;a<iAd.Animation.STYLES.length;a++)this.archivedStyles.push(this.target.layer.style.getPropertyValue(iAd.Animation.STYLES[a]))}; |
iAd.Animation.prototype.restoreAnimationStyles=function(){for(var a=0;a<iAd.Animation.STYLES.length;a++)this.target.layer.style.setProperty(iAd.Animation.STYLES[a],this.archivedStyles[a],"")}; |
iAd.Animation.prototype.handleEvent=function(a){if(a.currentTarget===this.target.layer){a=this.keyframes[this.keyframes.length-1].values;for(var b=0;b<a.length;b+=2)this.target[a[b]]=a[b+1];iAd.Utils.objectHasMethod(this.delegate,iAd.Animation.DID_COMPLETE_DELEGATE)&&this.delegate[iAd.Animation.DID_COMPLETE_DELEGATE](this);this.removesTargetUponCompletion?this.target.removeFromSuperview():this.restoreAnimationStyles()}};iAd.Animation.counter=0; |
iAd.Animation.createRule=function(){var a=document.styleSheets[0],b="iAd-Animation-"+this.counter++;b=a.insertRule("@-webkit-keyframes "+b+" { }",a.rules.length);return a.rules.item(b)};iAd.Class("iAd.ViewLayerInsertionNotificationHelper");iAd.ViewLayerInsertionNotificationHelper.prototype.init=function(){this.callSuper();this.views=[];document.addEventListener("DOMSubtreeModified",this,true)}; |
iAd.ViewLayerInsertionNotificationHelper.prototype.considerView=function(a){if(this.views.indexOf(a)==-1){a._ignoreView=false;this.views.push(a)}};iAd.ViewLayerInsertionNotificationHelper.prototype.handleEvent=function(){this.processViews()}; |
iAd.ViewLayerInsertionNotificationHelper.prototype.processViews=function(){if(!(this.views.length<1)){for(var a,b=0;b<this.views.length;++b){a=this.views[b];for(var c=a.superview;c&&!a._ignoreView;c=c.superview)if("_ignoreView"in c)a._ignoreView=true}for(;this.views.length>0;){a=this.views.pop();if(a._ignoreView)delete a._ignoreView;else{delete a._ignoreView;a.dispatchNotificationOfLayerInsertionIntoDocument()}}}}; |
iAd.Class({name:"iAd.View",superclass:iAd.Object,mixins:[iAd.EventTarget],synthesizedProperties:["id","position","size","transform","anchorPoint","doubleSided","zIndex","opacity","clipsToBounds","hidden","transitionsEnabled","transitionsDuration","hostingLayer","userInteractionEnabled","declarativeLayerWasInititalized","eventTarget"],cssClassName:"ad-view",collectionAccessor:"views"}); |
iAd.View.prototype.init=function(a){this.callSuper();if(iAd.Utils.objectIsString(a))a=document.querySelector(a);this.layer=a||document.createElement("div");this.superview=null;this.subviews=[];this.autoresizesSubviews=this.tracksAllTouchesOnceTouchesBegan=true;this.autoresizingMask=iAd.View.AUTORESIZING_NONE;this.layerIsInDocument=false;this._position=new iAd.Point;this._size=new iAd.Size;this._anchorPoint=new iAd.Point(0.5,0.5);this._doubleSided=true;this._zIndex=0;this._transform=iAd.Utils.t(0, |
0);this._transitionsEnabled=this._clipsToBounds=false;this._transitionsDuration=0.5;this._hostingLayer=null;this._userInteractionEnabled=false;this.usesDeclarativeBacking=a instanceof Element;this._declarativeLayerWasInititalized=false;if(this.usesDeclarativeBacking){if(iAd.Utils.isElementInDocument(this.layer)){this.layerIsInDocument=true;this.initWithDeclarativeBacking();this.layerWasInsertedIntoDocument()}}else{this.createLayer();this.setupCSSClasses()}this.layer.addEventListener("DOMNodeInsertedIntoDocument", |
this,true);this.layer.addEventListener("DOMNodeRemovedFromDocument",this,true);this.layer._view=this};iAd.View.MANAGED_BY_VIEW_CONTROLLER_ATTR="ad-managed-by-view-controller";iAd.View.AUTORESIZING_NONE=0;iAd.View.AUTORESIZING_FLEXIBLE_LEFT_MARGIN=1;iAd.View.AUTORESIZING_FLEXIBLE_WIDTH=2;iAd.View.AUTORESIZING_FLEXIBLE_RIGHT_MARGIN=4;iAd.View.AUTORESIZING_FLEXIBLE_TOP_MARGIN=8;iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT=16;iAd.View.AUTORESIZING_FLEXIBLE_BOTTOM_MARGIN=32; |
iAd.View.PROPERTY_MAPPING={opacity:"opacity",transform:"-webkit-transform",position:"-webkit-transform",anchorPoint:"-webkit-transform-origin",doubleSided:"-webkit-backface-visibility",zIndex:"z-index"};iAd.View.ATTRIBUTE_PREFIX="ad-";iAd.View.LAYER_STYLE_DID_CHANGE_EVENT="viewLayerStyleDidChange";iAd.View.prototype.createLayer=function(){this.layerWasCreated()}; |
iAd.View.prototype.initWithDeclarativeBacking=function(){this.setupLayer();this.setupCSSClasses();this.readPropertiesFromLayerComputedStyle(window.getComputedStyle(this.layer));this.readPropertiesFromLayerAttributes(this.layer.attributes);this.declarativeLayerWasInititalized=true};iAd.View.prototype.setupLayer=function(){this.lookupViewLayersInLayer(this.hostingLayer);this.layerWasCreated()}; |
iAd.View.prototype.lookupViewLayersInLayer=function(a){var b=iAd.Utils.registeredHTMLViewLoadingClasses;for(a=a.firstElementChild;a;){for(var c,d=false,e=0;e<b.length;e++){c=b[e];if(a.hasClassName(c.cssClassName)){c=new c(a);c._indexInSuperviewSubviews=this.subviews.push(c)-1;c.willMoveToSuperview(this);c.superview=this;c.didMoveToSuperview();d=true;break}}d||this.lookupViewLayersInLayer(a);a=a.nextElementSibling}}; |
iAd.View.prototype.setupCSSClasses=function(){for(var a=this.constructor;a.superclass;){(cssClassName=a.cssClassName)&&this.layer.addClassName(cssClassName);if(a===iAd.View)break;a=a.superclass}}; |
iAd.View.prototype.readPropertiesFromLayerComputedStyle=function(a){this._size.width=parseInt(a.width);this._size.height=parseInt(a.height);this._position.x=parseInt(a.left);this._position.y=parseInt(a.top);this._zIndex=parseInt(a.zIndex);this._clipsToBounds=a.overflow=="hidden";this._doubleSided=a.webkitBackfaceVisibility=="visible";this._transform=a.webkitTransform}; |
iAd.View.prototype.readPropertiesFromLayerAttributes=function(a){this.layer.hasAttribute(iAd.View.MANAGED_BY_VIEW_CONTROLLER_ATTR)&&this.createManagingViewController();for(var b,c,d=0;d<a.length;d++){b=a.item(d);c=b.name;c.indexOf(iAd.View.ATTRIBUTE_PREFIX)==0&&this.setValueForAttribute(b.value,c)}};iAd.View.prototype.createManagingViewController=function(){new iAd.ViewController({id:this.layer.hasAttribute("id")?this.layer.getAttribute("id"):"",properties:{view:this}})}; |
iAd.View.prototype.setValueForAttribute=function(a,b){var c=this.propertyNameForAttribute(b);switch(typeof this[c]){case "string":this[c]=a;break;case "number":this[c]=parseFloat(a);break;case "boolean":this[c]=a!="false";break;default:this[c]=a}};iAd.View.prototype.propertyNameForAttribute=function(a){return iAd.Utils.dashedStringToCamelCase(a.substr(iAd.View.ATTRIBUTE_PREFIX.length))};iAd.View.prototype.atttributeNameForProperty=function(a){return iAd.View.ATTRIBUTE_PREFIX+iAd.Utils.camelCaseStringToDashed(a)}; |
iAd.View.prototype.setLayerStyle=function(a){var b=[];for(var c in a){this.layer.style.setProperty(c,a[c]);b.push(c)}this.dispatchEvent(this.createEvent(iAd.View.LAYER_STYLE_DID_CHANGE_EVENT,[["changedProperties",b]]))};iAd.View.prototype.toString=function(){return[this.constructor.displayName,"[",this._size.width,"x",this._size.height,"@",this._position.x,",",this._position.y,"]"].join("")};iAd.View.prototype.getId=function(){return this.layer.id}; |
iAd.View.prototype.setId=function(a){this.layer.id=a};iAd.View.prototype.setPosition=function(a){if(!this._position.equals(a)){this._position=a;this.updateLayerTransform()}};iAd.View.prototype.setSize=function(a){if(!this._size.equals(a)){var b=this._size.copy();this._size=a;this.setLayerStyle({width:a.width+"px",height:a.height+"px"});this.autoresizesSubviews&&!b.equals(iAd.Size.ZERO_SIZE)&&this.resizeSubviewsWithOldSize(b)}};iAd.View.prototype.setTransform=function(a){this._transform=a;this.updateLayerTransform()}; |
iAd.View.prototype.setAnchorPoint=function(a){this._anchorPoint=a;this.setLayerStyle({"-webkit-transform-origin":Math.round(a.x*100)+"% "+Math.round(a.y*100)+"% 0"})};iAd.View.prototype.setDoubleSided=function(a){this._doubleSided=a;this.setLayerStyle({"-webkit-backface-visibility":a?"visible":"hidden"})};iAd.View.prototype.setZIndex=function(a){this._zIndex=a;this.setLayerStyle({"z-index":a})}; |
iAd.View.prototype.updateLayerTransform=function(){this.setLayerStyle({"-webkit-transform":iAd.Utils.t(this._position.x,this._position.y)+this._transform})};iAd.View.prototype.getOpacity=function(){return Number(window.getComputedStyle(this.layer).opacity)};iAd.View.prototype.setOpacity=function(a){this.setLayerStyle({opacity:a})}; |
iAd.View.prototype.setTransitionsEnabled=function(a){a?this.setLayerStyle({"-webkit-transition-property":"-webkit-transform, opacity","-webkit-transition-duration":this._transitionsDuration+"s"}):this.setLayerStyle({"-webkit-transition-duration":"0s"});this._transitionsEnabled=a};iAd.View.prototype.setTransitionsDuration=function(a){this.setLayerStyle({"-webkit-transition-duration":a+"s"});this._transitionsDuration=a}; |
iAd.View.prototype.setClipsToBounds=function(a){this._clipsToBounds=a;this.setLayerStyle({overflow:a?"hidden":"visible"})};iAd.View.prototype.getHostingLayer=function(){return this._hostingLayer!=null?this._hostingLayer:this.layer};iAd.View.prototype.addSubview=function(a){return this.insertSubviewAtIndex(a,this.subviews.length)}; |
iAd.View.prototype.removeFromSuperview=function(){if(this.superview!=null){this.willMoveToSuperview(null);this.superview.willRemoveSubview(this);var a=this._indexInSuperviewSubviews;this.superview.subviews.splice(a,1);for(a=a;a<this.superview.subviews.length;a++)this.superview.subviews[a]._indexInSuperviewSubviews=a;this.layer.parentNode.removeChild(this.layer);this.superview=null;this.didMoveToSuperview()}}; |
iAd.View.prototype.insertSubviewAtIndex=function(a,b){if(!(b>this.subviews.length)){a.superview===this&&b--;a.removeFromSuperview();a.willMoveToSuperview(this);this.subviews.splice(b,0,a);a._indexInSuperviewSubviews=b;for(var c=b+1;c<this.subviews.length;c++)this.subviews[c]._indexInSuperviewSubviews=c;c=this.hostingLayer;b==this.subviews.length-1?c.appendChild(a.layer):c.insertBefore(a.layer,this.subviews[b+1].layer);a.superview=this;a.didMoveToSuperview();this.didAddSubview(a);return a}}; |
iAd.View.prototype.insertSubviewAfterSubview=function(a,b){if(b.superview===this){var c=b._indexInSuperviewSubviews+1;c<this.subviews.length?this.insertSubviewAtIndex(a,c):this.addSubview(a);return a}};iAd.View.prototype.insertSubviewBeforeSubview=function(a,b){if(b.superview===this)return this.insertSubviewAtIndex(a,b._indexInSuperviewSubviews)}; |
iAd.View.prototype.exchangeSubviewsAtIndices=function(a,b){if(!(a>=this.subviews.length||b>=this.subviews.length)){var c=this.subviews[a],d=this.subviews[b];this.subviews[a]=d;this.subviews[b]=c;c._indexInSuperviewSubviews=b;d._indexInSuperviewSubviews=a;c=c.layer;d=d.layer;var e=this.hostingLayer,f=c.nextSibling,g=d.nextSibling;f!=null?e.insertBefore(d,f):e.appendChild(d);g!=null?e.insertBefore(c,g):e.appendChild(c)}}; |
iAd.View.prototype.isDescendantOfView=function(a){for(var b=false,c=this;c.superview!=null;){if(c.superview===a){b=true;break}c=c.superview}return b};iAd.View.prototype.layerWasCreated=function(){};iAd.View.prototype.willMoveToSuperview=function(){};iAd.View.prototype.didMoveToSuperview=function(){};iAd.View.prototype.didAddSubview=function(){};iAd.View.prototype.willRemoveSubview=function(){}; |
iAd.View.prototype.layerWasInsertedIntoDocument=function(){if(this.usesDeclarativeBacking){this.declarativeLayerWasInititalized||this.initWithDeclarativeBacking();var a=window.getComputedStyle(this.layer);if(isNaN(this._size.width)){this._size.width=parseInt(a.width);this._size.height=parseInt(a.height)}if(isNaN(this._position.x)){this._position.x=parseInt(a.left);this._position.y=parseInt(a.top)}}this.layerIsInDocument=true};iAd.View.prototype.layerWasRemovedFromDocument=function(){}; |
iAd.View.prototype.handleLayerInsertionIntoDocument=function(a){if(!(a.target!==this.layer||this.layer.ownerDocument!==document||this.layerIsInDocument)){a.stopPropagation();iAd.View.layerInsertionNotificationHelper.considerView(this)}}; |
iAd.View.prototype.dispatchNotificationOfLayerInsertionIntoDocument=function(){for(var a=[],b=[].concat(this.subviews),c=0;b.length>0;){var d=b.shift();if(typeof d==="number")c=d;else{if(a[c]===undefined)a[c]=[];a[c].push(d);b=b.concat(c+1,d.subviews)}}for(;a.length>0;)for(b=a.pop();b.length>0;)b.pop().layerWasInsertedIntoDocument();this.layerWasInsertedIntoDocument()}; |
iAd.View.prototype.handleLayerRemovalFromDocument=function(a){if(a.target===this.layer&&this.layer.ownerDocument===document){a.stopPropagation();this.layerIsInDocument=false;this.layerWasRemovedFromDocument()}};iAd.View.prototype.setUserInteractionEnabled=function(a){if(this._userInteractionEnabled!=a){this.layer[(a?"add":"remove")+"EventListener"](iAd.START_EVENT,this,false);this._userInteractionEnabled=a}}; |
iAd.View.prototype.handleEvent=function(a){switch(a.type){case iAd.START_EVENT:this.touchesBegan(a);break;case iAd.MOVE_EVENT:this.touchesMoved(a);break;case iAd.END_EVENT:this.touchesEnded(a);break;case "touchcancel":this.touchesCancelled(a);break;case "DOMNodeInsertedIntoDocument":this.handleLayerInsertionIntoDocument(a);break;case "DOMNodeRemovedFromDocument":this.handleLayerRemovalFromDocument(a)}}; |
iAd.View.prototype.touchesBegan=function(){if(this.tracksAllTouchesOnceTouchesBegan){window.addEventListener(iAd.MOVE_EVENT,this,true);window.addEventListener(iAd.END_EVENT,this,true);window.addEventListener("touchcancel",this,true)}};iAd.View.prototype.touchesMoved=function(a){a.preventDefault()};iAd.View.prototype.touchesEnded=function(){window.removeEventListener(iAd.MOVE_EVENT,this,true);window.removeEventListener(iAd.END_EVENT,this,true);window.removeEventListener("touchcancel",this,true)}; |
iAd.View.prototype.touchesCancelled=function(){window.removeEventListener(iAd.MOVE_EVENT,this,true);window.removeEventListener(iAd.END_EVENT,this,true);window.removeEventListener("touchcancel",this,true)};iAd.View.prototype.pointInside=function(a){return a.x>=0&&a.x<=this.size.width&&a.y>=0&&a.y<=this.size.height};iAd.View.prototype.resizeSubviewsWithOldSize=function(a){for(var b=0;b<this.subviews.length;b++)this.subviews[b].resizeWithOldSuperviewSize(a)}; |
iAd.View.prototype.resizeWithOldSuperviewSize=function(a){var b=this._position.copy(),c=this._size.copy(),d=this.autoresizingMask;switch((d&iAd.View.AUTORESIZING_FLEXIBLE_LEFT_MARGIN)+(d&iAd.View.AUTORESIZING_FLEXIBLE_WIDTH)+(d&iAd.View.AUTORESIZING_FLEXIBLE_RIGHT_MARGIN)){case iAd.View.AUTORESIZING_FLEXIBLE_LEFT_MARGIN:b.x+=this.superview._size.width-a.width;break;case iAd.View.AUTORESIZING_FLEXIBLE_WIDTH:c.width=this.superview._size.width-(a.width-this._size.width);break;case iAd.View.AUTORESIZING_FLEXIBLE_LEFT_MARGIN| |
iAd.View.AUTORESIZING_FLEXIBLE_WIDTH:var e=a.width-this._size.width-this._position.x;b.x=this._position.x/(a.width-e)*(this.superview._size.width-e);c.width=this.superview._size.width-b.x-e;break;case iAd.View.AUTORESIZING_FLEXIBLE_LEFT_MARGIN|iAd.View.AUTORESIZING_FLEXIBLE_RIGHT_MARGIN:e=a.width-this._size.width-this._position.x;b.x+=(this.superview._size.width-a.width)*(this.position.x/(this.position.x+e));break;case iAd.View.AUTORESIZING_FLEXIBLE_RIGHT_MARGIN|iAd.View.AUTORESIZING_FLEXIBLE_WIDTH:e= |
a.width-this._size.width-this._position.x;scaled_right_margin=e/(a.width-this._position.x)*(this.superview._size.width-this._position.x);c.width=this.superview._size.width-b.x-scaled_right_margin;break;case iAd.View.AUTORESIZING_FLEXIBLE_LEFT_MARGIN|iAd.View.AUTORESIZING_FLEXIBLE_WIDTH|iAd.View.AUTORESIZING_FLEXIBLE_RIGHT_MARGIN:b.x=this._position.x/a.width*this.superview._size.width;c.width=this._size.width/a.width*this.superview._size.width}switch((d&iAd.View.AUTORESIZING_FLEXIBLE_TOP_MARGIN)+(d& |
iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT)+(d&iAd.View.AUTORESIZING_FLEXIBLE_BOTTOM_MARGIN)){case iAd.View.AUTORESIZING_FLEXIBLE_TOP_MARGIN:b.y+=this.superview._size.height-a.height;break;case iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT:c.height=this.superview._size.height-(a.height-this._size.height);break;case iAd.View.AUTORESIZING_FLEXIBLE_TOP_MARGIN|iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT:d=a.height-this._size.height-this._position.y;b.y=this._position.y/(a.height-d)*(this.superview._size.height-d);c.height= |
this.superview._size.height-b.y-d;break;case iAd.View.AUTORESIZING_FLEXIBLE_TOP_MARGIN|iAd.View.AUTORESIZING_FLEXIBLE_BOTTOM_MARGIN:d=a.height-this._size.height-this._position.y;b.y+=(this.superview._size.height-a.height)*(this.position.y/(this.position.y+d));break;case iAd.View.AUTORESIZING_FLEXIBLE_BOTTOM_MARGIN|iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT:d=a.height-this._size.height-this._position.y;scaled_bottom_margin=d/(a.height-this._position.y)*(this.superview._size.height-this._position.y);c.height= |
this.superview._size.height-b.y-scaled_bottom_margin;break;case iAd.View.AUTORESIZING_FLEXIBLE_TOP_MARGIN|iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT|iAd.View.AUTORESIZING_FLEXIBLE_BOTTOM_MARGIN:b.y=this._position.y/a.height*this.superview._size.height;c.height=this._size.height/a.height*this.superview._size.height}this.position=b;this.size=c};iAd.View.prototype.cssPropertyNameForJSProperty=function(a){return iAd.View.PROPERTY_MAPPING[a]}; |
iAd.View.prototype.applyTransition=function(a,b){if(a===null)return null;var c=new iAd.Transition(a);c.target=this;if(b){var d=c.from;c.from=c.to;c.to=d}if(a.base)for(d=0;d<a.base.length;d+=2)this[a.base[d]]=a.base[d+1];c.start();return c};iAd.View.prototype.descendantViewsOfClass=function(a){return iAd.Utils.viewsForClassAndNode(a,this.layer)};iAd.View.prototype.getEventTarget=function(){return this.layer}; |
iAd.View.getViewById=function(a){return(a=document.getElementById(a))&&!iAd.Utils.objectIsUndefined(a._view)?a._view:null};iAd.View.initialize=function(){var a=this;if(this.hasOwnProperty("cssClassName")){Object.defineProperty(this,"views",{get:function(){return iAd.Utils.viewsForClassAndNode(a,document)}});iAd.Utils.registerClassForHTMLViewLoading(this);a.hasOwnProperty("collectionAccessor")&&Object.defineProperty(iAd.View.prototype,this.collectionAccessor,{get:function(){return this.descendantViewsOfClass(a)}})}}; |
iAd.View.layerInsertionNotificationHelper=new iAd.ViewLayerInsertionNotificationHelper;iAd.View.TRANSITION_DISSOLVE_OUT={properties:["opacity"],from:[1],to:[0]};iAd.View.TRANSITION_DISSOLVE_IN={properties:["opacity"],from:[0],to:[1]};iAd.View.TRANSITION_ZOOM_IN={properties:["opacity","transform"],from:[0,"scale(0.2)"],to:[1,"scale(1)"]};iAd.View.TRANSITION_ZOOM_OUT={properties:["opacity","transform"],from:[0,"scale(1.2)"],to:[1,"scale(1)"]}; |
iAd.View.TRANSITION_CROSS_SPIN_RIGHT={properties:["opacity","transform"],from:[0,"rotate(20deg)"],to:[1,"rotate(0)"]};iAd.View.TRANSITION_CROSS_SPIN_LEFT={properties:["opacity","transform"],from:[0,"rotate(-20deg)"],to:[1,"rotate(0)"]};iAd.View.TRANSITION_FLIP_LEFT_OUT={properties:["transform"],from:["perspective(800) rotateY(0deg)"],to:["perspective(800) rotateY(-180deg)"]};iAd.View.TRANSITION_FLIP_LEFT_IN={properties:["transform"],from:["perspective(800) rotateY(180deg)"],to:["perspective(800) rotateY(0deg)"]}; |
iAd.View.TRANSITION_FLIP_RIGHT_OUT={properties:["transform"],from:["perspective(800) rotateY(0deg)"],to:["perspective(800) rotateY(180deg)"]};iAd.View.TRANSITION_FLIP_RIGHT_IN={properties:["transform"],from:["perspective(800) rotateY(-180deg)"],to:["perspective(800) rotateY(0deg)"]};iAd.View.TRANSITION_CUBE_LEFT_OUT={base:["anchorPoint",new iAd.Point(1,0.5)],properties:["transform"],from:["perspective(800) rotateY(0deg) translateZ(0)"],to:["perspective(800) rotateY(-90deg) translateZ($width)"]}; |
iAd.View.TRANSITION_CUBE_LEFT_IN={base:["anchorPoint",new iAd.Point(0,0.5)],properties:["transform"],from:["perspective(800) rotateY(90deg) translateZ($width)"],to:["perspective(800) rotateY(0deg) translateZ(0)"]};iAd.View.TRANSITION_CUBE_RIGHT_OUT={base:["anchorPoint",new iAd.Point(0,0.5)],properties:["transform"],from:["perspective(800) rotateY(0deg) translateZ(0)"],to:["perspective(800) rotateY(90deg) translateZ($width)"]}; |
iAd.View.TRANSITION_CUBE_RIGHT_IN={base:["anchorPoint",new iAd.Point(1,0.5)],properties:["transform"],from:["perspective(800) rotateY(-90deg) translateZ($width)"],to:["perspective(800) rotateY(0deg) translateZ(0)"]};iAd.View.TRANSITION_DOOR_OPEN_LEFT_OUT={base:["anchorPoint",new iAd.Point(0,0.5),"zIndex",1],properties:["transform"],from:["perspective(800) rotateY(0deg)"],to:["perspective(800) rotateY(-90deg)"]}; |
iAd.View.TRANSITION_DOOR_CLOSE_LEFT_IN={base:["anchorPoint",new iAd.Point(0,0.5),"zIndex",2],properties:["transform"],from:["perspective(800) rotateY(-90deg)"],to:["perspective(800) rotateY(0deg)"]};iAd.View.TRANSITION_DOOR_OPEN_RIGHT_OUT={base:["anchorPoint",new iAd.Point(1,0.5),"zIndex",1],properties:["transform"],from:["perspective(800) rotateY(0deg)"],to:["perspective(800) rotateY(90deg)"]}; |
iAd.View.TRANSITION_DOOR_CLOSE_RIGHT_IN={base:["anchorPoint",new iAd.Point(1,0.5),"zIndex",2],properties:["transform"],from:["perspective(800) rotateY(90deg)"],to:["perspective(800) rotateY(0deg)"]};iAd.View.TRANSITION_REVOLVE_TOWARDS_LEFT_OUT={base:["anchorPoint",new iAd.Point(0,0.5)],properties:["transform","opacity"],from:["perspective(800) rotateY(0deg)",1],to:["perspective(800) rotateY(-90deg)",0]}; |
iAd.View.TRANSITION_REVOLVE_TOWARDS_LEFT_IN={base:["anchorPoint",new iAd.Point(0,0.5)],properties:["transform"],from:["perspective(800) rotateY(90deg)"],to:["perspective(800) rotateY(0deg)"]};iAd.View.TRANSITION_REVOLVE_AWAY_LEFT_OUT={base:["anchorPoint",new iAd.Point(0,0.5)],properties:["transform"],from:["perspective(800) rotateY(0deg)"],to:["perspective(800) rotateY(90deg)"]}; |
iAd.View.TRANSITION_REVOLVE_AWAY_LEFT_IN={base:["anchorPoint",new iAd.Point(0,0.5)],properties:["transform","opacity"],from:["perspective(800) rotateY(-90deg)",0],to:["perspective(800) rotateY(0deg)",1]};iAd.View.TRANSITION_REVOLVE_TOWARDS_RIGHT_OUT={base:["anchorPoint",new iAd.Point(1,0.5)],properties:["transform","opacity"],from:["perspective(800) rotateY(0deg)",1],to:["perspective(800) rotateY(90deg)",0]}; |
iAd.View.TRANSITION_REVOLVE_TOWARDS_RIGHT_IN={base:["anchorPoint",new iAd.Point(1,0.5)],properties:["transform"],from:["perspective(800) rotateY(-90deg)"],to:["perspective(800) rotateY(0deg)"]};iAd.View.TRANSITION_REVOLVE_AWAY_RIGHT_OUT={base:["anchorPoint",new iAd.Point(1,0.5)],properties:["transform"],from:["perspective(800) rotateY(0deg)"],to:["perspective(800) rotateY(-90deg)"]}; |
iAd.View.TRANSITION_REVOLVE_AWAY_RIGHT_IN={base:["anchorPoint",new iAd.Point(1,0.5)],properties:["transform","opacity"],from:["perspective(800) rotateY(90deg)",0],to:["perspective(800) rotateY(0deg)",1]};iAd.View.TRANSITION_SPIN_OUT={properties:["transform","opacity"],from:["perspective(800) rotate(0)",1],to:["perspective(800) rotate(-180deg)",0]}; |
iAd.View.TRANSITION_SPIN_IN={base:["zIndex",1],properties:["transform","opacity"],from:["perspective(800) rotate(-180deg)",0],to:["perspective(800) rotate(0)",1]};iAd.View.TRANSITION_SCALE_IN={base:["zIndex",1],properties:["transform"],from:["scale(0.01)"],to:["scale(1)"]};iAd.View.TRANSITION_SCALE_OUT={base:["zIndex",1],properties:["transform"],from:["scale(1)"],to:["scale(0.01)"]};iAd.Class({name:"iAd.RootView",superclass:iAd.View,synthesizedProperties:["disablesDefaultScrolling"],cssClassName:"ad-root-view"}); |
iAd.RootView.prototype.init=function(a){this.callSuper(a);this.disablesDefaultScrolling=true;if(this.layer===document.body){this.size=new iAd.Size(window.innerWidth,window.innerHeight);this.layer.removeClassName("ad-view");window.addEventListener("resize",this,false)}};iAd.RootView.prototype.setDisablesDefaultScrolling=function(a){this.layer[a?"addEventListener":"removeEventListener"](iAd.MOVE_EVENT,iAd.Utils.preventEventDefault,false);this._disablesDefaultScrolling=a}; |
iAd.RootView.prototype.handleEvent=function(a){this.callSuper(a);if(a.type=="resize"){this.size=new iAd.Size(window.innerWidth,window.innerHeight);window.scrollTo(0,0)}};iAd.RootView._sharedRoot=null;Object.defineProperty(iAd.RootView,"sharedRoot",{get:function(){if(iAd.RootView._sharedRoot===null)iAd.RootView._sharedRoot=new iAd.RootView(document.body);return iAd.RootView._sharedRoot},set:function(a){iAd.RootView._sharedRoot=a}}); |
iAd.Class({name:"iAd.ScrollIndicator",superclass:iAd.View,synthesizedProperties:["visible","width","height","indicatorStyle"]});iAd.ScrollIndicator.THICKNESS=7;iAd.ScrollIndicator.END_SIZE=3;iAd.ScrollIndicator.TYPE_HORIZONTAL="ad-horizontal";iAd.ScrollIndicator.TYPE_VERTICAL="ad-vertical"; |
iAd.ScrollIndicator.prototype.init=function(a){this.callSuper();this.type=a;this.layer.addClassName(a);this._visible=false;this._height=this._width=iAd.ScrollIndicator.THICKNESS;this.positionBeforeHide=this.position=new iAd.Point(-iAd.ScrollIndicator.THICKNESS,-iAd.ScrollIndicator.THICKNESS);this.lastPositionUpdateInHide=false;this._indicatorStyle=iAd.ScrollView.INDICATOR_STYLE_DEFAULT;this.visible=false}; |
iAd.ScrollIndicator.prototype.createLayer=function(){this.callSuper();this.layer.addClassName("ad-scroll-indicator");this.layer.addEventListener("webkitTransitionEnd",this,false);this.start=this.layer.appendChild(document.createElement("div"));this.middle=this.layer.appendChild(document.createElement("div"));this.end=this.layer.appendChild(document.createElement("div"))}; |
iAd.ScrollIndicator.prototype.setPosition=function(a){a.x=Math.round(a.x);a.y=Math.round(a.y);this.callSuper(a);this.lastPositionUpdateInHide=false};iAd.ScrollIndicator.prototype.setSize=function(a){this.width=a.width;this.height=a.height;this._size=a}; |
iAd.ScrollIndicator.prototype.setIndicatorStyle=function(a){this._indicatorStyle=a;this.layer.removeClassName(this._indicatorStyle);this.layer.addClassName(this._indicatorStyle);var b=this.type===iAd.ScrollIndicator.TYPE_HORIZONTAL?"-3px 0":"0 -3px";this.middle.style.background='url("'+iAd.Utils.assetsPath+(iAd.HAS_HIDPI_DISPLAY?"Hi":"Lo")+"DPI/scroll-"+a.substr(3)+'.png") '+b}; |
iAd.ScrollIndicator.prototype.setWidth=function(a){this.middle.style.webkitTransform="translate3d(0,0,0) scale("+(a-iAd.ScrollIndicator.END_SIZE*2)+",1)";this.end.style.webkitTransform="translate3d("+(a-iAd.ScrollIndicator.END_SIZE)+"px,0,0)";this._width=a}; |
iAd.ScrollIndicator.prototype.setHeight=function(a){this.middle.style.webkitTransform="translate3d(0,0,0) scale(1,"+(a-iAd.ScrollIndicator.END_SIZE*2)+")";this.end.style.webkitTransform="translate3d(0,"+(a-iAd.ScrollIndicator.END_SIZE)+"px,0)";this._height=a}; |
iAd.ScrollIndicator.prototype.setVisible=function(a){if(a){this.fading=false;this.opacity=1;this.position=this.lastPositionUpdateInHide?this.positionBeforeHide:this.position}else if(!this.fading){this.fading=true;this.opacity=0;this.lastPositionUpdateInHide=true;this.positionBeforeHide=this.position}this._visible=a};iAd.ScrollIndicator.prototype.flash=function(){this.flashing=true}; |
iAd.ScrollIndicator.prototype.handleEvent=function(a){if(a.type=="webkitTransitionEnd"){this.callSuper(a);if(this.flashing)this.flashing=false;else if(this.fading){this.position=new iAd.Point(-iAd.ScrollIndicator.THICKNESS,-iAd.ScrollIndicator.THICKNESS);this.fading=false}}}; |
iAd.Class({name:"iAd.ScrollView",superclass:iAd.View,synthesizedProperties:["contentOffset","contentSize","indicatorStyle","scrollEnabled","scrollIndicatorInsets","horizontalScrollIndicator","verticalScrollIndicator","tracking"],cssClassName:"ad-scroll-view",collectionAccessor:"scrollViews"});iAd.ScrollView.WILL_BEGIN_DRAGGING="scrollViewWillBeginDragging";iAd.ScrollView.DID_END_SCROLLING_ANIMATION="scrollViewDidEndScrollingAnimation";iAd.ScrollView.DID_SCROLL="scrollViewDidScroll"; |
iAd.ScrollView.DID_END_DRAGGING="scrollViewDidEndDragging";iAd.ScrollView.WILL_BEGIN_DECELERATING="scrollViewWillBeginDecelerating";iAd.ScrollView.DID_END_DECELERATING="scrollViewDidEndDecelerating";iAd.ScrollView.MINIMUM_TRACKING_FOR_DRAG=5;iAd.ScrollView.PAGING_TRANSITION_DURATION="0.25s";iAd.ScrollView.MIN_INDICATOR_LENGTH=34;iAd.ScrollView.ACCELERATION=15;iAd.ScrollView.MAX_TIME_FOR_TRACKING_DATA_POINTS=100;iAd.ScrollView.DECELERATION_FRICTION_FACTOR=0.95; |
iAd.ScrollView.DESIRED_ANIMATION_FRAME_RATE=1E3/60;iAd.ScrollView.MINIMUM_VELOCITY=0.05;iAd.ScrollView.PENETRATION_DECELERATION=0.08;iAd.ScrollView.PENETRATION_ACCELERATION=0.15;iAd.ScrollView.MIN_VELOCITY_FOR_DECELERATION=1;iAd.ScrollView.MIN_VELOCITY_FOR_DECELERATIONWithPaging=4;iAd.ScrollView.MAX_VELOCITY_FOR_BOUNCING_WITH_PAGING=20;iAd.ScrollView.CONTENT_TOUCHES_DELAY=150;iAd.ScrollView.AUTOMATED_CONTENT_SIZE=-1;iAd.ScrollView.INDICATOR_STYLE_DEFAULT="ad-indicator-default"; |
iAd.ScrollView.INDICATOR_STYLE_BLACK="ad-indicator-black";iAd.ScrollView.INDICATOR_STYLE_WHITE="ad-indicator-white"; |
iAd.ScrollView.prototype.init=function(a){this._contentOffset=new iAd.Point;this._contentSize=iAd.ScrollView.AUTOMATED_CONTENT_SIZE;this.adjustedContentSize=new iAd.Size;this.dragging=this._tracking=false;this.verticalScrollEnabled=this.horizontalScrollEnabled=true;this.decelerating=false;this.decelerationTimer=null;this._indicatorStyle="";this.showsVerticalScrollIndicator=this.showsHorizontalScrollIndicator=true;this.scrollIndicatorsNeedFlashing=false;this._scrollIndicatorInsets=new iAd.EdgeInsets(0, |
0,0,0);this.pagingEnabled=false;this.bounces=true;this.delegate=null;this._scrollEnabled=this.canCancelContentTouches=this.delaysContentTouches=true;this._setContentOffsetAnimatedCalledFromSetter=false;this.beginTouchesInContentTimer=null;this.callSuper(a);this.userInteractionEnabled=true;this.layer.addEventListener("webkitTransitionEnd",this,false);this.hostingLayer.addEventListener("webkitTransitionEnd",this,false);this.layer.addEventListener(iAd.START_EVENT,this,true);this.layer.addEventListener("focus", |
this,true);this.shouldPreventSelectElementFocus=false;this.eventsToIgnoreDueToDispatching=0};iAd.ScrollView.prototype.createLayer=function(){this.callSuper();this._hostingLayer=this.layer.appendChild(document.createElement("div"));this._hostingLayer.className="ad-hosting-layer";this.clipsToBounds=true;this.indicatorStyle=iAd.ScrollView.INDICATOR_STYLE_DEFAULT}; |
iAd.ScrollView.prototype.setupLayer=function(){this.callSuper();this._hostingLayer=this.layer.querySelector(".ad-hosting-layer");try{var a=new WebKitCSSMatrix(window.getComputedStyle(this._hostingLayer).webkitTransform);this._contentOffset.x=-a.e;this._contentOffset.y=-a.f}catch(b){}this.indicatorStyle=this.layer.hasAttribute("ad-indicator-style")?this.layer.getAttribute("ad-indicator-style"):iAd.ScrollView.INDICATOR_STYLE_DEFAULT}; |
iAd.ScrollView.prototype.setValueForAttribute=function(a,b){switch(b){case "ad-scroll-indicator-inset-left":this._scrollIndicatorInsets.left=parseInt(a);break;case "ad-scroll-indicator-inset-top":this._scrollIndicatorInsets.top=parseInt(a);break;case "ad-scroll-indicator-inset-right":this._scrollIndicatorInsets.right=parseInt(a);break;case "ad-scroll-indicator-inset-bottom":this._scrollIndicatorInsets.bottom=parseInt(a);break;case "ad-indicator-style":this.indicatorStyle=a==""?iAd.ScrollView.INDICATOR_STYLE_DEFAULT: |
a;break;default:this.callSuper(a,b)}};iAd.ScrollView.prototype.setSize=function(a){this.callSuper(a);if(this._contentSize!==iAd.ScrollView.AUTOMATED_CONTENT_SIZE||this.layerIsInDocument)this.adjustContentSize(true)};iAd.ScrollView.prototype.layerWasInsertedIntoDocument=function(){this.callSuper();this._contentSize===iAd.ScrollView.AUTOMATED_CONTENT_SIZE&&this.adjustContentSize(true)};iAd.ScrollView.prototype.setScrollEnabled=function(a){(this._scrollEnabled=a)||this.interruptTrackingInteraction()}; |
iAd.ScrollView.prototype.setContentOffset=function(a){this._setContentOffsetAnimatedCalledFromSetter=true;this.setContentOffsetAnimated(a,false)}; |
iAd.ScrollView.prototype.setContentOffsetAnimated=function(a,b){if(!a.equals(this._contentOffset)){this._contentOffset=a;if(!this.dragging&&!this.decelerating){this.adjustContentSize(false);this._contentOffset.x=Math.max(Math.min(this.maxPoint.x,this._contentOffset.x),0);this._contentOffset.y=Math.max(Math.min(this.maxPoint.y,this._contentOffset.y),0)}this.hostingLayer.style.webkitTransform=iAd.Utils.t(-this._contentOffset.x,-this._contentOffset.y);if(b){this.scrollTransitionsNeedRemoval=true;this.hostingLayer.style.webkitTransitionDuration= |
iAd.ScrollView.PAGING_TRANSITION_DURATION}else this.didScroll(false);if(!b){this.horizontalScrollEnabled&&this.showsHorizontalScrollIndicator&&this.updateHorizontalScrollIndicator();this.verticalScrollEnabled&&this.showsVerticalScrollIndicator&&this.updateVerticalScrollIndicator()}this._setContentOffsetAnimatedCalledFromSetter||this.notifyPropertyChange("contentOffset");this._setContentOffsetAnimatedCalledFromSetter=false}}; |
iAd.ScrollView.prototype.snapContentOffsetToBounds=function(a){var b=false,c=new iAd.Point;if(this.pagingEnabled&&a){c.x=Math.round(this._contentOffset.x/this._size.width)*this._size.width;c.y=Math.round(this._contentOffset.y/this._size.height)*this._size.height;b=true}else if(this.bounces){c.x=Math.max(Math.min(this.maxPoint.x,this._contentOffset.x),0);c.y=Math.max(Math.min(this.maxPoint.y,this._contentOffset.y),0);b=c.x!=this._contentOffset.x||c.y!=this._contentOffset.y}b&&this.setContentOffsetAnimated(c, |
a)};iAd.ScrollView.prototype.getContentSize=function(){var a=this._contentSize;if(a===iAd.ScrollView.AUTOMATED_CONTENT_SIZE){a=new iAd.Size(this._hostingLayer.offsetWidth,this._hostingLayer.offsetHeight);if(this.subviews.length)for(var b=0;b<this.subviews.length;b++){var c=this.subviews[b];a.width=Math.max(a.width,c.position.x+c.size.width);a.height=Math.max(a.height,c.position.y+c.size.height)}}return a};iAd.ScrollView.prototype.setContentSize=function(a){this._contentSize=a;this.adjustContentSize(false)}; |
iAd.ScrollView.prototype.adjustContentSize=function(a){if(a){var b=new iAd.Point;if(this.adjustedContentSize.width!=0)b.x=this._contentOffset.x/this.adjustedContentSize.width;if(this.adjustedContentSize.height!=0)b.y=this._contentOffset.y/this.adjustedContentSize.height}this.adjustedContentSize.width=Math.max(this._size.width,this.contentSize.width);this.adjustedContentSize.height=Math.max(this._size.height,this.contentSize.height);this.maxPoint=new iAd.Point(this.adjustedContentSize.width-this._size.width, |
this.adjustedContentSize.height-this._size.height);if(a)this.contentOffset=new iAd.Point(Math.min(b.x*this.adjustedContentSize.width,this.maxPoint.x),Math.min(b.y*this.adjustedContentSize.height,this.maxPoint.y))};iAd.ScrollView.prototype.setIndicatorStyle=function(a){this._indicatorStyle=a;if(this.hasOwnProperty("_horizontalScrollIndicator"))this.horizontalScrollIndicator.indicatorStyle=a;if(this.hasOwnProperty("_verticalScrollIndicator"))this.verticalScrollIndicator.indicatorStyle=a}; |
iAd.ScrollView.prototype.setScrollIndicatorInsets=function(a){this._scrollIndicatorInsets=a;this.hasOwnProperty("_horizontalScrollIndicator")&&this.horizontalScrollIndicator.visible&&this.updateHorizontalScrollIndicator();this.hasOwnProperty("_verticalScrollIndicator")&&this.verticalScrollIndicator.visible&&this.updateVerticalScrollIndicator()}; |
iAd.ScrollView.prototype.createHorizontalScrollIndicator=function(){this._horizontalScrollIndicator=new iAd.ScrollIndicator(iAd.ScrollIndicator.TYPE_HORIZONTAL);this.layer.appendChild(this._horizontalScrollIndicator.layer);this._horizontalScrollIndicator.indicatorStyle=this._indicatorStyle}; |
iAd.ScrollView.prototype.createVerticalScrollIndicator=function(){this._verticalScrollIndicator=new iAd.ScrollIndicator(iAd.ScrollIndicator.TYPE_VERTICAL);this.layer.appendChild(this._verticalScrollIndicator.layer);this._verticalScrollIndicator.indicatorStyle=this._indicatorStyle};iAd.ScrollView.prototype.getHorizontalScrollIndicator=function(){this.hasOwnProperty("_horizontalScrollIndicator")||this.createHorizontalScrollIndicator();return this._horizontalScrollIndicator}; |
iAd.ScrollView.prototype.getVerticalScrollIndicator=function(){this.hasOwnProperty("_verticalScrollIndicator")||this.createVerticalScrollIndicator();return this._verticalScrollIndicator}; |
iAd.ScrollView.prototype.updateHorizontalScrollIndicator=function(){var a=this.verticalScrollEnabled&&this.showsVerticalScrollIndicator?iAd.ScrollIndicator.END_SIZE*2:1,b=this._size.width-this._scrollIndicatorInsets.left-this._scrollIndicatorInsets.right-a,c=Math.max(iAd.ScrollView.MIN_INDICATOR_LENGTH,Math.round(this._size.width/this.adjustedContentSize.width*b));b=this._contentOffset.x/(this.adjustedContentSize.width-this._size.width)*(b-a-c)+this._scrollIndicatorInsets.left;var d=this._size.height- |
iAd.ScrollIndicator.THICKNESS-1-this._scrollIndicatorInsets.bottom;if(this._contentOffset.x<0){c=Math.round(Math.max(c+this._contentOffset.x,iAd.ScrollIndicator.THICKNESS));b=1+this._scrollIndicatorInsets.left}else if(this._contentOffset.x>this.maxPoint.x){c=Math.round(Math.max(c+this.adjustedContentSize.width-this._size.width-this._contentOffset.x,iAd.ScrollIndicator.THICKNESS));b=this._size.width-c-a-this._scrollIndicatorInsets.right}this.horizontalScrollIndicator.position=new iAd.Point(b,d);this.horizontalScrollIndicator.width= |
c}; |
iAd.ScrollView.prototype.updateVerticalScrollIndicator=function(){var a=this.horizontalScrollEnabled&&this.showsHorizontalScrollIndicator?iAd.ScrollIndicator.END_SIZE*2:1,b=this._size.height-this._scrollIndicatorInsets.top-this._scrollIndicatorInsets.bottom-a,c=Math.max(iAd.ScrollView.MIN_INDICATOR_LENGTH,Math.round(this._size.height/this.adjustedContentSize.height*b)),d=this._size.width-iAd.ScrollIndicator.THICKNESS-1-this._scrollIndicatorInsets.right;b=this._contentOffset.y/(this.adjustedContentSize.height-this._size.height)* |
(b-a-c)+this._scrollIndicatorInsets.top;if(this._contentOffset.y<0){c=Math.round(Math.max(c+this._contentOffset.y,iAd.ScrollIndicator.THICKNESS));b=1+this._scrollIndicatorInsets.top}else if(this._contentOffset.y>this.maxPoint.y){c=Math.round(Math.max(c+this.adjustedContentSize.height-this._size.height-this._contentOffset.y,iAd.ScrollIndicator.THICKNESS));b=this._size.height-c-a-this._scrollIndicatorInsets.bottom}this.verticalScrollIndicator.position=new iAd.Point(d,b);this.verticalScrollIndicator.height= |
c};iAd.ScrollView.prototype.flashScrollIndicators=function(a){if(a)this.scrollIndicatorsNeedFlashing=true;else{if(this.horizontalScrollEnabled&&this.showsHorizontalScrollIndicator&&this.adjustedContentSize.width>this._size.width){this.updateHorizontalScrollIndicator();this.horizontalScrollIndicator.flash()}if(this.verticalScrollEnabled&&this.showsVerticalScrollIndicator&&this.adjustedContentSize.height>this._size.height){this.updateVerticalScrollIndicator();this.verticalScrollIndicator.flash()}}}; |
iAd.ScrollView.prototype.hideScrollIndicators=function(){if(this.hasOwnProperty("_horizontalScrollIndicator"))this.horizontalScrollIndicator.visible=false;if(this.hasOwnProperty("_verticalScrollIndicator"))this.verticalScrollIndicator.visible=false};iAd.ScrollView.prototype.showHorizontalScrollIndicator=function(){this.horizontalScrollIndicator.visible=true};iAd.ScrollView.prototype.showVerticalScrollIndicator=function(){this.verticalScrollIndicator.visible=true}; |
iAd.ScrollView.prototype.handleEvent=function(a){if(a.type=="focus"&&this.shouldPreventSelectElementFocus){a.stopPropagation();a.preventDefault();this.originalTarget.blur()}else if(this.eventsToIgnoreDueToDispatching>0)this.eventsToIgnoreDueToDispatching--;else if(a.type==iAd.START_EVENT&&a.eventPhase==Event.CAPTURING_PHASE&&!a.hasOwnProperty("_synthetic"))this.touchesBeganInCapturePhase(a);else if(a.type=="webkitTransitionEnd")this.transitionEnded(a);else if(a.type!="touchcancel"||!a.hasOwnProperty("_synthetic"))this.callSuper(a)}; |
iAd.ScrollView.prototype.touchesBeganInCapturePhase=function(a){if(!(!this.delaysContentTouches||!this._scrollEnabled||a.hasOwnProperty("_synthetic"))){a.stopPropagation();this.beginTracking(a)}};iAd.ScrollView.prototype.touchesBegan=function(a){this.beginTracking(a)}; |
iAd.ScrollView.prototype.touchesMoved=function(a){var b=this.getInitialTouch(a);if(b!==null){this.lastKnownTouchPosition=iAd.Point.fromEvent(b);if(!this.contentTouchesCouldNotBeCancelled){this.callSuper(a);this.touchesHaveMoved=true;b=iAd.Point.fromEventInElement(b,this.layer);var c=b.x-this.startTouchPosition.x,d=b.y-this.startTouchPosition.y;if(!this.dragging)if(Math.abs(c)>=iAd.ScrollView.MINIMUM_TRACKING_FOR_DRAG&&this.horizontalScrollEnabled||Math.abs(d)>=iAd.ScrollView.MINIMUM_TRACKING_FOR_DRAG&& |
this.verticalScrollEnabled)this.beginDragging(a);if(this.dragging){a.stopPropagation();c=this.horizontalScrollEnabled?this.startContentOffset.x-c:this._contentOffset.x;d=this.verticalScrollEnabled?this.startContentOffset.y-d:this._contentOffset.y;if(this.bounces){c-=(c>this.maxPoint.x?c-this.maxPoint.x:c<0?c:0)/2;d-=(d>this.maxPoint.y?d-this.maxPoint.y:d<0?d:0)/2}else{c=Math.max(Math.min(this.maxPoint.x,c),0);d=Math.max(Math.min(this.maxPoint.y,d),0)}if(this.firstDrag){this.firstDrag=false;this.startTouchPosition= |
b;return}this.contentOffset=new iAd.Point(c,d)}this.addTrackingDataPoint(a.timeStamp,this._contentOffset.copy())}}}; |
iAd.ScrollView.prototype.touchesEnded=function(a){if(this.getInitialTouch(a)!==null){this.stopTrackingTouches();if(this.contentTouchesCouldNotBeCancelled)if(this.isOriginalTargetElementAtPoint(this.lastKnownTouchPosition))this.dispatchClickToContent();else{if(this.originalTarget.localName=="select")this.shouldPreventSelectElementFocus=true}else{if(this.dragging){this.dragging=false;a.preventDefault();if(this.originalTarget.localName=="select")this.shouldPreventSelectElementFocus=true;a.stopPropagation(); |
this.purgeTrackingDataPointsWithTime(a.timeStamp);if(this.trackingDataPoints.length>1){this._contentOffsetBeforeDeceleration=this._contentOffset.copy();this.startDecelerationAnimation()}this.dispatchNotification(iAd.ScrollView.DID_END_DRAGGING,this.delegate)}else if(this.isOriginalTargetElementAtPoint(this.lastKnownTouchPosition)){this.dispatchTapSequenceToContent();this.dispatchClickToContent()}else if(this.originalTarget.localName=="select")this.shouldPreventSelectElementFocus=true;else a.preventDefault(); |
if(!this.decelerating){this.snapContentOffsetToBounds(true);this.hideScrollIndicators()}}}};iAd.ScrollView.prototype.touchesCancelled=function(){this.stopTrackingTouches()};iAd.ScrollView.prototype.getInitialTouch=function(a){if(!iAd.SUPPORTS_TOUCHES)return a;for(var b,c=0;c<a.changedTouches.length;c++){b=a.changedTouches[c];if(b.identifier==this.initialTouchIdentifier)return b}return null}; |
iAd.ScrollView.prototype.beginTracking=function(a){if(!this._tracking){this.stopDecelerationAnimation();this.lastKnownTouchPosition=iAd.Point.fromEvent(a);var b=iAd.SUPPORTS_TOUCHES?a.targetTouches[0]:a;this.initialTouchIdentifier=b.identifier;this.originalTarget=iAd.Utils.elementForNode(b.target);this.originalEvent=a;this.originalTarget.localName!="select"&&a.preventDefault();this.hostingLayer.style.webkitTransitionDuration=0;this.adjustContentSize(false);this.snapContentOffsetToBounds(false);this.tracking= |
true;this.touchesHaveMoved=this.dragging=false;this.beginTouchesInContentTimer=null;this.contentTouchesCouldNotBeCancelled=this.shouldPreventSelectElementFocus=this.touchesInContentBegan=false;var c=this._contentOffset.copy();this.trackingDataPoints=[];this.addTrackingDataPoint(a.timeStamp,c);this.startContentOffset=c;this.startTouchPosition=iAd.Point.fromEventInElement(b,this.layer);if(this.delaysContentTouches)this.beginTouchesInContentTimer=this.callMethodNameAfterDelay("beginTouchesInContent", |
iAd.ScrollView.CONTENT_TOUCHES_DELAY);else this.beginTouchesInContent();window.addEventListener(iAd.MOVE_EVENT,this,true);window.addEventListener(iAd.END_EVENT,this,true);window.addEventListener("touchcancel",this,true)}}; |
iAd.ScrollView.prototype.beginDragging=function(){this.cancelTouchesInContent(event);this.dispatchNotification(iAd.ScrollView.WILL_BEGIN_DRAGGING,this.delegate);this.firstDrag=this.dragging=true;if(this.horizontalScrollEnabled&&this.showsHorizontalScrollIndicator&&this.adjustedContentSize.width>this._size.width)if(this.hasOwnProperty("_horizontalScrollIndicator"))this.showHorizontalScrollIndicator();else{this.createHorizontalScrollIndicator();this.callMethodNameAfterDelay("showHorizontalScrollIndicator", |
0)}if(this.verticalScrollEnabled&&this.showsVerticalScrollIndicator&&this.adjustedContentSize.height>this._size.height)if(this.hasOwnProperty("_verticalScrollIndicator"))this.showVerticalScrollIndicator();else{this.createVerticalScrollIndicator();this.callMethodNameAfterDelay("showVerticalScrollIndicator",0)}}; |
iAd.ScrollView.prototype.stopTrackingTouches=function(){this.tracking=false;window.removeEventListener(iAd.MOVE_EVENT,this,true);window.removeEventListener(iAd.END_EVENT,this,true);window.removeEventListener("touchcancel",this,true);window.clearTimeout(this.beginTouchesInContentTimer)}; |
iAd.ScrollView.prototype.interruptTrackingInteraction=function(a){this.contentTouchesCouldNotBeCancelled=a;if(this.dragging){this.dragging=false;this.snapContentOffsetToBounds(true);this.dispatchNotification(iAd.ScrollView.DID_END_DRAGGING,this.delegate);this.hideScrollIndicators()}};iAd.ScrollView.prototype.isOriginalTargetElementAtPoint=function(a){return this.originalTarget===document.elementFromPoint(a.x,a.y)}; |
iAd.ScrollView.prototype.beginTouchesInContent=function(){if(this.touchesShouldBeginInContentElementAndView(this.originalEvent,this.originalTarget,this.originalTarget.getNearestView())){this.touchesInContentBegan=true;var a=iAd.Utils.createUIEvent(iAd.START_EVENT,this.originalEvent);a._synthetic=true;this.originalTarget.dispatchEvent(a);this.canCancelContentTouches||this.interruptTrackingInteraction(true)}};iAd.ScrollView.prototype.touchesShouldBeginInContentElementAndView=function(){return true}; |
iAd.ScrollView.prototype.cancelTouchesInContent=function(a){if(this.canCancelContentTouches&&this.touchesInContentBegan&&!this.touchesShouldCancelInContentElementAndView(this.originalTarget,this.originalTarget.getNearestView()))this.interruptTrackingInteraction(true);else{a=iAd.Utils.createUIEvent("touchcancel",a);a._synthetic=true;this.originalTarget.dispatchEvent(a);window.clearTimeout(this.beginTouchesInContentTimer)}}; |
iAd.ScrollView.prototype.touchesShouldCancelInContentElementAndView=function(a,b){return!(b instanceof iAd.Control)};iAd.ScrollView.prototype.dispatchTapSequenceToContent=function(){this.eventsToIgnoreDueToDispatching=2;var a=iAd.Utils.createUIEvent(iAd.START_EVENT,this.originalEvent),b=iAd.Utils.createUIEvent(iAd.END_EVENT,this.originalEvent);a._synthetic=true;b._synthetic=true;this.originalTarget.dispatchEvent(a);this.originalTarget.dispatchEvent(b)}; |
iAd.ScrollView.prototype.dispatchClickToContent=function(){if(iAd.SUPPORTS_TOUCHES){var a=this.getInitialTouch(this.originalEvent),b=document.createEvent("MouseEvent");b.initMouseEvent("click",true,true,document.defaultView,0,a.screenX,a.screenY,a.clientX,a.clientY,0,0,0,0,0,0,null);b._synthetic=true;this.originalTarget.dispatchEvent(b)}}; |
iAd.ScrollView.prototype.purgeTrackingDataPointsWithTime=function(a){for(;this.trackingDataPoints.length>0;){if(a-this.trackingDataPoints[0].time<=iAd.ScrollView.MAX_TIME_FOR_TRACKING_DATA_POINTS)break;this.trackingDataPoints.shift()}};iAd.ScrollView.prototype.addTrackingDataPoint=function(a,b){this.purgeTrackingDataPointsWithTime(a);this.trackingDataPoints.push({time:a,contentOffset:b})}; |
iAd.ScrollView.prototype.transitionEnded=function(a){if(this.scrollIndicatorsNeedFlashing&&a.currentTarget===this.layer){this.scrollIndicatorsNeedFlashing=false;this.flashScrollIndicators()}if(this.scrollTransitionsNeedRemoval&&a.currentTarget===this.hostingLayer){this.scrollTransitionsNeedRemoval=false;this.hostingLayer.style.webkitTransitionDuration=0;this.didScroll(true)}}; |
iAd.ScrollView.prototype.didScroll=function(a){a&&this.dispatchNotification(iAd.ScrollView.DID_END_SCROLLING_ANIMATION,this.delegate);this.dispatchNotification(iAd.ScrollView.DID_SCROLL,this.delegate)}; |
iAd.ScrollView.prototype.startDecelerationAnimation=function(){if(!(this.bounces&&(this._contentOffset.x>this.maxPoint.x||this._contentOffset.y>this.maxPoint.y||this._contentOffset.x<0||this._contentOffset.y<0))){var a=this.trackingDataPoints[0],b=this.trackingDataPoints[this.trackingDataPoints.length-1],c=new iAd.Point(b.contentOffset.x-a.contentOffset.x,b.contentOffset.y-a.contentOffset.y);a=(b.time-a.time)/iAd.ScrollView.ACCELERATION;this.decelerationVelocity=new iAd.Point(c.x/a,c.y/a);this.minDecelerationPoint= |
new iAd.Point(0,0);this.maxDecelerationPoint=this.maxPoint.copy();if(this.pagingEnabled){this.minDecelerationPoint.x=Math.max(0,Math.floor(this._contentOffsetBeforeDeceleration.x/this._size.width)*this._size.width);this.minDecelerationPoint.y=Math.max(0,Math.floor(this._contentOffsetBeforeDeceleration.y/this._size.height)*this._size.height);this.maxDecelerationPoint.x=Math.min(this.maxPoint.x,Math.ceil(this._contentOffsetBeforeDeceleration.x/this._size.width)*this._size.width);this.maxDecelerationPoint.y= |
Math.min(this.maxPoint.y,Math.ceil(this._contentOffsetBeforeDeceleration.y/this._size.height)*this._size.height)}this.penetrationDeceleration=iAd.ScrollView.PENETRATION_DECELERATION;this.penetrationAcceleration=iAd.ScrollView.PENETRATION_ACCELERATION;if(this.pagingEnabled)this.penetrationDeceleration*=5;c=this.pagingEnabled?iAd.ScrollView.MIN_VELOCITY_FOR_DECELERATIONWithPaging:iAd.ScrollView.MIN_VELOCITY_FOR_DECELERATION;if(Math.abs(this.decelerationVelocity.x)>c||Math.abs(this.decelerationVelocity.y)> |
c){this.decelerating=true;this.decelerationTimer=this.callMethodNameAfterDelay("stepThroughDecelerationAnimation",iAd.ScrollView.DESIRED_ANIMATION_FRAME_RATE);this.lastFrame=new Date;this.dispatchNotification(iAd.ScrollView.WILL_BEGIN_DECELERATING,this.delegate)}}};iAd.ScrollView.prototype.stopDecelerationAnimation=function(){this.decelerating=false;clearTimeout(this.decelerationTimer)}; |
iAd.ScrollView.prototype.stepThroughDecelerationAnimation=function(a){if(this.decelerating){var b=new Date,c=b-this.lastFrame;c=a?0:Math.round(c/iAd.ScrollView.DESIRED_ANIMATION_FRAME_RATE)-1;for(var d=0;d<c;d++)this.stepThroughDecelerationAnimation(true);c=this._contentOffset.x+this.decelerationVelocity.x;d=this._contentOffset.y+this.decelerationVelocity.y;if(!this.bounces){var e=Math.max(Math.min(this.maxPoint.x,c),0);if(e!=c){c=e;this.decelerationVelocity.x=0}e=Math.max(Math.min(this.maxPoint.y, |
d),0);if(e!=d){d=e;this.decelerationVelocity.y=0}}if(a){this._contentOffset.x=c;this._contentOffset.y=d}else this.contentOffset=new iAd.Point(c,d);if(!this.pagingEnabled){this.decelerationVelocity.x*=iAd.ScrollView.DECELERATION_FRICTION_FACTOR;this.decelerationVelocity.y*=iAd.ScrollView.DECELERATION_FRICTION_FACTOR}e=Math.abs(this.decelerationVelocity.x);var f=Math.abs(this.decelerationVelocity.y);if(!a&&e<=iAd.ScrollView.MINIMUM_VELOCITY&&f<=iAd.ScrollView.MINIMUM_VELOCITY){this.hideScrollIndicators(); |
this.decelerationAnimationCompleted()}else{if(!a)this.decelerationTimer=this.callMethodNameAfterDelay("stepThroughDecelerationAnimation",iAd.ScrollView.DESIRED_ANIMATION_FRAME_RATE);if(this.bounces){e=new iAd.Point(0,0);if(c<this.minDecelerationPoint.x)e.x=this.minDecelerationPoint.x-c;else if(c>this.maxDecelerationPoint.x)e.x=this.maxDecelerationPoint.x-c;if(d<this.minDecelerationPoint.y)e.y=this.minDecelerationPoint.y-d;else if(d>this.maxDecelerationPoint.y)e.y=this.maxDecelerationPoint.y-d;if(e.x!= |
0){if(this.pagingEnabled&&Math.abs(this.decelerationVelocity.x)>=iAd.ScrollView.MAX_VELOCITY_FOR_BOUNCING_WITH_PAGING){this.decelerationAnimationCompleted();return}if(e.x*this.decelerationVelocity.x<=0)this.decelerationVelocity.x+=e.x*this.penetrationDeceleration;else this.decelerationVelocity.x=e.x*this.penetrationAcceleration}if(e.y!=0){if(this.pagingEnabled&&Math.abs(this.decelerationVelocity.y)>=iAd.ScrollView.MAX_VELOCITY_FOR_BOUNCING_WITH_PAGING){this.decelerationAnimationCompleted();return}if(e.y* |
this.decelerationVelocity.y<=0)this.decelerationVelocity.y+=e.y*this.penetrationDeceleration;else this.decelerationVelocity.y=e.y*this.penetrationAcceleration}}if(!a)this.lastFrame=b}}}; |
iAd.ScrollView.prototype.decelerationAnimationCompleted=function(){this.stopDecelerationAnimation();this.pagingEnabled&&this.setContentOffsetAnimated(new iAd.Point(Math.round(this._contentOffset.x/this._size.width)*this._size.width,Math.round(this._contentOffset.y/this._size.height)*this._size.height),false);this.snapContentOffsetToBounds(false);this.dispatchNotification(iAd.ScrollView.DID_END_DECELERATING,this.delegate)}; |
iAd.Class({name:"iAd.TableView",superclass:iAd.ScrollView,synthesizedProperties:["tableStyle","separatorStyle"],cssClassName:"ad-table-view",mixins:[iAd.PropertyTriage],collectionAccessor:"tableViews"});iAd.TableView.CELL_FOR_ROW_AT_PATH="tableViewCellForRowAtPath";iAd.TableView.NUMBERS_OF_SECTIONS_IN_TABLE_VIEW="numberOfSectionsInTableView";iAd.TableView.NUMBERS_OF_ROWS_IN_SECTION="tableViewNumberOfRowsInSection";iAd.TableView.TITLE_FOR_HEADER_IN_SECTION="tableViewTitleForHeaderInSection"; |
iAd.TableView.TITLE_FOR_FOOTER_IN_SECTION="tableViewTitleForFooterInSection";iAd.TableView.DID_SELECT_ROW_AT_PATH="tableViewDidSelectRowAtPath";iAd.TableView.DID_SELECT_ACCESSORY_FOR_ROW_AT_PATH="tableViewDidSelectAccessoryForRowAtPath";iAd.TableView.STYLE_PLAIN="ad-plain";iAd.TableView.STYLE_CUSTOM="ad-custom";iAd.TableView.STYLE_GROUPED="ad-grouped";iAd.TableView.PLAIN_HEADER_HEIGHT=23; |
iAd.TableView.prototype.init=function(a){this._tableStyle=iAd.TableView.STYLE_CUSTOM;this._separatorStyle=iAd.TableViewCell.SEPARATOR_STYLE_SINGLE_LINE;this.touchedAccessory=this.touchedCell=this.dataSource=this.delegate=null;this.shouldPreventScrolling=false;this.numberOfSections=1;this.numberOfRows=[];this.sections=[];this.headers=[];this.sectionMetrics=[];this.selectedCell=null;this.populated=false;this.callSuper(a);this.horizontalScrollEnabled=false}; |
iAd.TableView.prototype.setupLayer=function(){this.callSuper();if(this.layer.hasClassName(iAd.TableView.STYLE_PLAIN))this._tableStyle=iAd.TableView.STYLE_PLAIN;else if(this.layer.hasClassName(iAd.TableView.STYLE_GROUPED))this._tableStyle=iAd.TableView.STYLE_GROUPED;if(this.layer.hasClassName(iAd.TableViewCell.SEPARATOR_STYLE_SINGLE_LINE_ETCHED))this._separatorStyle=iAd.TableViewCell.SEPARATOR_STYLE_SINGLE_LINE_ETCHED;else if(this.layer.hasClassName(iAd.TableViewCell.SEPARATOR_STYLE_NONE))this._separatorStyle= |
iAd.TableViewCell.SEPARATOR_STYLE_NONE}; |
iAd.TableView.prototype.layerWasCreated=function(){this.callSuper();this.sections=this.layer.querySelectorAll(".ad-hosting-layer > .ad-section");this.numberOfSections=this.sections.length;this.headers=[];this.numberOfRows=[];for(var a=0;a<this.numberOfSections;a++){for(var b=this.sections[a].querySelectorAll(".ad-table-view-cell"),c,d=0;d<b.length;d++){c=b[d]._view;c._tableViewDataSourcePath=new iAd.CellPath(a,d);c._table=this}this.headers[a]=this.layer.querySelector(".ad-hosting-layer > .ad-section:nth-of-type("+(a+ |
1)+") > h1");this.numberOfRows[a]=b.length}this.populated=true};iAd.TableView.prototype.layerWasInsertedIntoDocument=function(){this.callSuper();this.notifyCellsOfInsertionIntoDocument();this.updateSectionMetrics()};iAd.TableView.prototype.setContentOffsetAnimated=function(a,b){this.callSuper(a,b);this.updateSectionHeaders()};iAd.TableView.prototype.setTableStyle=function(a){this.layer.removeClassName(this._tableStyle);this.layer.addClassName(a);this._tableStyle=a}; |
iAd.TableView.prototype.setSeparatorStyle=function(a){this.layer.removeClassName(this._separatorStyle);this.layer.addClassName(a);this._separatorStyle=a};iAd.TableView.prototype.numberOfRowsInSection=function(a){if(!(a>this.numberOfSections-1))return this.numberOfRows[a]}; |
iAd.TableView.prototype.cellForRowAtPath=function(a){if(a.section>this.numberOfSections-1||a.row>this.numberOfRows[a.section])return null;return this.hostingLayer.querySelector(".ad-section:nth-of-type("+(a.section+1)+") .ad-cells > ."+iAd.TableViewCell.cssClassName+":nth-of-type("+(a.row+1)+")")._view};iAd.TableView.prototype.pathForCell=function(a){return a._tableViewDataSourcePath}; |
iAd.TableView.prototype.notifyCellsOfInsertionIntoDocument=function(){if(this.layerIsInDocument&&this.populated)for(var a=this.hostingLayer.querySelectorAll(".ad-table-view-cell"),b=0;b<a.length;b++)a[b]._view.layerWasInsertedIntoDocument()}; |
iAd.TableView.prototype.reloadData=function(){if(!iAd.Utils.objectHasMethod(this.dataSource,iAd.TableView.CELL_FOR_ROW_AT_PATH)||!iAd.Utils.objectHasMethod(this.dataSource,iAd.TableView.NUMBERS_OF_ROWS_IN_SECTION))console.error("An iAd.TableView's dataSource must implement all required methods");else{this._hostingLayer.innerText="";this.sections=[];this.headers=[];this.numberOfSections=1;if(iAd.Utils.objectHasMethod(this.dataSource,iAd.TableView.NUMBERS_OF_SECTIONS_IN_TABLE_VIEW))this.numberOfSections= |
this.dataSource[iAd.TableView.NUMBERS_OF_SECTIONS_IN_TABLE_VIEW](this);if(this.numberOfSections<1)console.error("An iAd.TableView must have at least one section");else{for(var a=0;a<this.numberOfSections;a++){var b=document.createElement("div");b.className="ad-section";this.sections[a]=b;if(iAd.Utils.objectHasMethod(this.dataSource,iAd.TableView.TITLE_FOR_HEADER_IN_SECTION)){var c=this.dataSource[iAd.TableView.TITLE_FOR_HEADER_IN_SECTION](this,a);if(c!==null){var d=b.appendChild(document.createElement("h1")); |
d.innerText=c;this.headers[a]=d}}c=this.dataSource[iAd.TableView.NUMBERS_OF_ROWS_IN_SECTION](this,a);if(c>0){d=b.appendChild(document.createElement("div"));d.className="ad-cells";for(var e=0;e<c;e++){var f=new iAd.CellPath(a,e),g=this.dataSource[iAd.TableView.CELL_FOR_ROW_AT_PATH](this,f);g._tableViewDataSourcePath=f;g._table=this;d.appendChild(g.layer)}}if(iAd.Utils.objectHasMethod(this.dataSource,iAd.TableView.TITLE_FOR_FOOTER_IN_SECTION)){d=this.dataSource[iAd.TableView.TITLE_FOR_FOOTER_IN_SECTION](this, |
a);if(d!==null)b.appendChild(document.createElement("span")).innerText=d}this.numberOfRows[a]=c;this._hostingLayer.appendChild(b)}this.populated=true;this.updateSectionMetrics();this.notifyCellsOfInsertionIntoDocument()}}};iAd.TableView.prototype.updateSectionMetrics=function(){if(!(!this.layerIsInDocument||this._tableStyle!==iAd.TableView.STYLE_PLAIN||!this.populated)){this.sectionMetrics=[];for(var a=0;a<this.sections.length;a++)this.sectionMetrics[a]={y:this.sections[a].offsetTop,height:this.sections[a].offsetHeight}}}; |
iAd.TableView.prototype.touchesBeganInCapturePhase=function(a){this.wasDeceleratingWhenTouchesBegan=this.decelerating;this.callSuper(a);if(!this.wasDeceleratingWhenTouchesBegan){this.touchedCell=null;a=a.target.getNearestView();if(a instanceof iAd.TableViewCell){a.userInteractionEnabled=true;this.touchedCell=a}}}; |
iAd.TableView.prototype.touchesEnded=function(a){this.callSuper(a);if(this.touchedCell!==null){this.touchedCell.userInteractionEnabled=false;this.touchedCell.selected&&this.touchedCell!==this.selectedCell&&this.selectRowAtPath(this.touchedCell._tableViewDataSourcePath)}};iAd.TableView.prototype.touchesCancelled=function(a){this.callSuper(a);if(this.touchedCell!==null)this.touchedCell.userInteractionEnabled=false}; |
iAd.TableView.prototype.pathForSelectedRow=function(){if(this.selectedCell===null)return null;return this.pathForCell(this.selectedCell)};iAd.TableView.prototype.deselectRowAtPathAnimated=function(a,b){if(a!==null){var c=this.cellForRowAtPath(a);c!==null&&this.markCellAsSelectedAnimated(c,false,b)}}; |
iAd.TableView.prototype.selectRowAtPath=function(a){var b=this.cellForRowAtPath(a);if(b===null)throw Error("No cell at "+a.toString());this.deselectRowAtPathAnimated(this.pathForSelectedRow(),false);this.selectedCell=b;this.markCellAsSelectedAnimated(this.selectedCell,true,false);this.dispatchNotification(iAd.TableView.DID_SELECT_ROW_AT_PATH,this.delegate,[["path",a]])}; |
iAd.TableView.prototype.markCellAsSelectedAnimated=function(a,b,c){a instanceof iAd.TableViewCell?a.setSelectedAnimated(b,c):a.toggleClassName(iAd.Control.STATE_SELECTED_CSS,b)};iAd.TableView.prototype.disclosureButtonWasSelectedAtPath=function(a){this.cellForRowAtPath(a).accessoryType===iAd.TableViewCell.ACCESSORY_DETAIL_DISCLOSURE_BUTTON&&this.dispatchNotification(iAd.TableView.DID_SELECT_ACCESSORY_FOR_ROW_AT_PATH,this.delegate,[["path",a]])}; |
iAd.TableView.prototype.updateSectionHeaders=function(){if(!(this.sectionMetrics.length!=this.numberOfSections||this.tableStyle!==iAd.TableView.STYLE_PLAIN))for(var a=this.contentOffset.y,b=0;b<this.numberOfSections;b++){var c=this.headers[b];if(!(c===undefined||c===null)){var d=this.sectionMetrics[b],e=d.y,f=e+d.height,g=f-a,i=0;if(g>0&&g<iAd.TableView.PLAIN_HEADER_HEIGHT-1)i=d.height-iAd.TableView.PLAIN_HEADER_HEIGHT;else if(e<=a&&f>a)i=Math.abs(e-a)-1;c.style.webkitTransform=iAd.Utils.t(0,i)}}}; |
iAd.CellPath=function(a,b){this.section=a||0;this.row=b||0};iAd.CellPath.prototype.toString=function(){return"iAd.CellPath with section "+this.section+" and row "+this.row};iAd.Class({name:"iAd.TableViewCell",superclass:iAd.View,synthesizedProperties:["text","detailedText","selectionStyle","accessoryType","selected"],cssClassName:"ad-table-view-cell",collectionAccessor:"tableViewCells"});iAd.TableViewCell.ACCESSORY_NONE="ad-no-accessory";iAd.TableViewCell.ACCESSORY_DISCLOSURE_INDICATOR="ad-disclosure-accessory"; |
iAd.TableViewCell.ACCESSORY_DETAIL_DISCLOSURE_BUTTON="ad-detail-accessory";iAd.TableViewCell.SELECTION_STYLE_NONE="ad-no-selection";iAd.TableViewCell.SELECTION_STYLE_BLUE="ad-blue-selection";iAd.TableViewCell.SELECTION_STYLE_GRAY="ad-gray-selection";iAd.TableViewCell.STYLE_DEFAULT="ad-style-default";iAd.TableViewCell.STYLE_VALUE_1="ad-style-value-1";iAd.TableViewCell.STYLE_VALUE_2="ad-style-value-2";iAd.TableViewCell.STYLE_SUBTITLE="ad-style-subtitle";iAd.TableViewCell.STYLE_CUSTOM="ad-style-custom"; |
iAd.TableViewCell.SEPARATOR_STYLE_NONE="ad-separator-none";iAd.TableViewCell.SEPARATOR_STYLE_SINGLE_LINE="ad-separator-single-line";iAd.TableViewCell.SEPARATOR_STYLE_SINGLE_LINE_ETCHED="ad-separator-single-line-etched";iAd.TableViewCell.ACCESSORY_DISCLOSURE_INDICATOR_WIDTH=10;iAd.TableViewCell.ACCESSORY_DETAIL_DISCLOSURE_BUTTON_WIDTH=44;iAd.TableViewCell.STYLE_VALUE_1_MARGIN=10; |
iAd.TableViewCell.prototype.init=function(a,b){this.cellStyle=b||iAd.TableViewCell.STYLE_DEFAULT;this._selectionStyle=iAd.TableViewCell.SELECTION_STYLE_BLUE;this._accessoryType=iAd.TableViewCell.ACCESSORY_NONE;this._selected=false;this.callSuper(a)}; |
iAd.TableViewCell.prototype.setupLayer=function(){this.callSuper();this.createLayerContents();if(this.layer.hasClassName(iAd.TableViewCell.STYLE_VALUE_1))this.cellStyle=iAd.TableViewCell.STYLE_VALUE_1;else if(this.layer.hasClassName(iAd.TableViewCell.STYLE_VALUE_2))this.cellStyle=iAd.TableViewCell.STYLE_VALUE_2;else if(this.layer.hasClassName(iAd.TableViewCell.STYLE_SUBTITLE))this.cellStyle=iAd.TableViewCell.STYLE_SUBTITLE;else if(this.layer.hasClassName(iAd.TableViewCell.STYLE_CUSTOM))this.cellStyle= |
iAd.TableViewCell.STYLE_CUSTOM;if(this.layer.hasClassName(iAd.TableViewCell.ACCESSORY_DISCLOSURE_INDICATOR))this._accessoryType=iAd.TableViewCell.ACCESSORY_DISCLOSURE_INDICATOR;else if(this.layer.hasClassName(iAd.TableViewCell.ACCESSORY_DETAIL_DISCLOSURE_BUTTON))this._accessoryType=iAd.TableViewCell.ACCESSORY_DETAIL_DISCLOSURE_BUTTON};iAd.TableViewCell.prototype.createLayer=function(){this.callSuper();this.layer.addClassName(this.cellStyle);this.createLayerContents()}; |
iAd.TableViewCell.prototype.layerWasCreated=function(){this.callSuper();this.cellStyle===iAd.TableViewCell.STYLE_CUSTOM&&this.layer.addClassName(iAd.TableViewCell.STYLE_CUSTOM);this.updateTextLayout()}; |
iAd.TableViewCell.prototype.createLayerContents=function(){this.layer.setAttribute("role","button");this.accessory=new iAd.Button(null,iAd.Button.TYPE_DETAIL_DISCLOSURE);this.accessory.addEventListener(iAd.Control.TOUCH_UP_INSIDE_EVENT,this,false);this.addSubview(this.accessory);this.textLabel=this.layer.appendChild(document.createElement("span"));this.textLabel.addClassName("ad-text-label");this.detailedTextLabel=this.layer.appendChild(document.createElement("span"));this.detailedTextLabel.addClassName("ad-detailed-text-label")}; |
iAd.TableViewCell.prototype.handleEvent=function(a){if(a.type==iAd.Control.TOUCH_UP_INSIDE_EVENT&&a.currentTarget===this.accessory.layer){a=this._table;var b=this._tableViewDataSourcePath;a!==undefined&&b!==undefined&&a.disclosureButtonWasSelectedAtPath(b)}else this.callSuper(a)};iAd.TableViewCell.prototype.touchesBegan=function(a){this.callSuper(a);this.selected=true};iAd.TableViewCell.prototype.touchesCancelled=function(a){this.callSuper(a);this.selected=false}; |
iAd.TableViewCell.prototype.getText=function(){return this.textLabel.innerText};iAd.TableViewCell.prototype.setText=function(a){this.textLabel.innerText=a;this.updateTextLayout()};iAd.TableViewCell.prototype.getDetailedText=function(){return this.detailedTextLabel.innerText};iAd.TableViewCell.prototype.setDetailedText=function(a){this.detailedTextLabel.innerText=a;this.updateTextLayout()}; |
iAd.TableViewCell.prototype.setSelectionStyle=function(a){this.layer.removeClassName(this._selectionStyle);this.layer.addClassName(a);this._selectionStyle=a};iAd.TableViewCell.prototype.setAccessoryType=function(a){this.layer.removeClassName(this._accessoryType);this.layer.addClassName(a);this._accessoryType=a};iAd.TableViewCell.prototype.setSelected=function(a){this.setSelectedAnimated(a,false)}; |
iAd.TableViewCell.prototype.setSelectedAnimated=function(a){if(this._selected!=a){this._selected=a;this.layer.toggleClassName(iAd.Control.STATE_SELECTED_CSS,a)}};iAd.TableViewCell.prototype.layerWasInsertedIntoDocument=function(){this.callSuper();this.updateTextLayout()}; |
iAd.TableViewCell.prototype.updateTextLayout=function(){if(!(this.cellStyle!=iAd.TableViewCell.STYLE_VALUE_1||!this.layerIsInDocument)){var a=this.textLabel.offsetWidth-2*iAd.TableViewCell.STYLE_VALUE_1_MARGIN;this.textLabel.style.right="auto !important";this.detailedTextLabel.style.right="auto !important";var b=Math.min(this.textLabel.offsetWidth,a),c=Math.min(this.detailedTextLabel.offsetWidth,a);this.textLabel.setAttribute("style","");this.detailedTextLabel.setAttribute("style","");if(b+c>a){a= |
Math.floor(b/(b+c)*a);if(b>c){this.textLabel.style.width=iAd.Utils.px(a);this.detailedTextLabel.style.left=iAd.Utils.px(a+iAd.TableViewCell.STYLE_VALUE_1_MARGIN*2)}else{this.textLabel.style.width=iAd.Utils.px(a+iAd.TableViewCell.STYLE_VALUE_1_MARGIN);this.detailedTextLabel.style.left=iAd.Utils.px(a+iAd.TableViewCell.STYLE_VALUE_1_MARGIN*3)}}}}; |
iAd.Class({name:"iAd.CarouselView",superclass:iAd.View,synthesizedProperties:["rotation","snapsToCells","cellPadding","cellLength","orientation"],cssClassName:"ad-carousel-view",collectionAccessor:"carouselViews"});iAd.CarouselView.VERTICAL_ORIENTATION=0;iAd.CarouselView.HORIZONTAL_ORIENTATION=1;iAd.CarouselView.SELECTION_ROTATION_DURATION=0.5;iAd.CarouselView.SNAP_ROTATION_DURATION=0.25;iAd.CarouselView.NUMBERS_OF_CELLS_DELEGATE="carouselViewNumberOfCells"; |
iAd.CarouselView.CELL_FOR_INDEX_DELEGATE="carouselViewCellForIndex";iAd.CarouselView.WILL_SELECT_CELL_AT_INDEX_DELEGATE="carouselViewWillSelectCellAtIndex";iAd.CarouselView.DID_SELECT_CELL_AT_INDEX_DELEGATE="carouselViewDidSelectCellAtIndex";iAd.CarouselView.CELL_ACTIVE_CSS="ad-active";iAd.CarouselView.PERSPECTIVE=1E3; |
iAd.CarouselView.prototype.init=function(a){this.delegate=this.dataSource=null;this.centersSelection=true;this.centerSelectionDuration=-1;this.numberOfCells=0;this.cellSize=new iAd.Size;this.touchedCell=null;this.showingHighlight=this.busySelecting=false;this.currentHighlightCell=null;this.trackingMoved=false;this._rotation=0;this._snapsToCells=false;this._orientation=iAd.CarouselView.VERTICAL_ORIENTATION;this._cellLength=100;this._cellPadding=0;this.trackingPoints=[];this.animator=new iAd.Animator(2E3, |
this,[0.211196,0.811224,0.641221,0.979592]);this.callSuper(a);this.hostingLayer.addEventListener("webkitTransitionEnd",this,false);this.userInteractionEnabled=true};iAd.CarouselView.prototype.setupLayer=function(){this.callSuper();this.aligner=this.layer.querySelector(".ad-aligner");this.hostingLayer=this.aligner.querySelector(".ad-hosting-layer");this.numberOfCells=this.hostingLayer.childElementCount}; |
iAd.CarouselView.prototype.createLayer=function(){this.callSuper();this.aligner=this.layer.appendChild(document.createElement("div"));this.aligner.className="ad-aligner";this.hostingLayer=this.aligner.appendChild(document.createElement("ul"));this.hostingLayer.className="ad-hosting-layer"}; |
iAd.CarouselView.prototype.setValueForAttribute=function(a,b){if(b=="ad-orientation")this.orientation=a=="horizontal"?iAd.CarouselView.HORIZONTAL_ORIENTATION:iAd.CarouselView.VERTICAL_ORIENTATION;else this.callSuper(a,b)};iAd.CarouselView.prototype.initWithDeclarativeBacking=function(){this.callSuper();for(var a=this.hostingLayer.firstElementChild,b=0;a;){a._index=b;a.addEventListener(iAd.START_EVENT,this,false);a=a.nextElementSibling;b++}this.updateLayout()}; |
iAd.CarouselView.prototype.setSize=function(a){if(!a.equals(iAd.Size.ZERO_SIZE)){var b=this._size;if(!b.equals(a)){if(!b.equals(iAd.Size.ZERO_SIZE)){b=this.isVertical()?a.height/b.height:a.width/b.width;this._cellLength*=b;this._cellPadding*=b}this._size=a;this.updateLayout()}}};iAd.CarouselView.prototype.isVertical=function(){return this._orientation==iAd.CarouselView.VERTICAL_ORIENTATION}; |
iAd.CarouselView.prototype.reloadData=function(){if(iAd.Utils.objectHasMethod(this.dataSource,iAd.CarouselView.NUMBERS_OF_CELLS_DELEGATE)&&iAd.Utils.objectHasMethod(this.dataSource,iAd.CarouselView.CELL_FOR_INDEX_DELEGATE)){this.hostingLayer.textContent="";this.numberOfCells=this.dataSource[iAd.CarouselView.NUMBERS_OF_CELLS_DELEGATE](this);for(var a=0;a<this.numberOfCells;a++){var b=this.hostingLayer.appendChild(this.dataSource[iAd.CarouselView.CELL_FOR_INDEX_DELEGATE](this,a));b.addEventListener(iAd.START_EVENT, |
this,false);b._index=a}this.updateLayout();this.rotation=0}}; |
iAd.CarouselView.prototype.updateLayout=function(){if(!(this.usesDeclarativeBacking&&!this.declarativeLayerWasInititalized)){var a=this.isVertical();if(a){this.cellSize.width=this.size.width;this.cellSize.height=this.cellLength}else{this.cellSize.width=this.cellLength;this.cellSize.height=this.size.height}this.radius=Math.ceil(this.numberOfCells*((a?this.cellSize.height:this.cellSize.width)+this._cellPadding))/(2*Math.PI);this.updateSize();this.aligner.style.webkitTransform="translateZ("+-this.radius+ |
"px)";for(var b=a?1:0,c=a?0:1,d=360/this.numberOfCells,e=a?-this.cellSize.height/2:0,f=a?0:-this.cellSize.width/2,g=this.hostingLayer.firstElementChild;g;){g.style.top=e+"px";g.style.left=f+"px";g.style.width=this.cellSize.width+"px";g.style.height=this.cellSize.height+"px";g.style.webkitTransform="rotate3d("+b+", "+c+", 0, "+-d*g._index+"deg) translateZ("+this.radius+"px)";g=g.nextElementSibling}this.hostingLayer.style.left=(a?0:this._size.width/2)+"px";this.hostingLayer.style.top=(a?this._size.height/ |
2:0)+"px";this.setLayerStyle({"-webkit-perspective-origin":(a?this.cellSize.width/2:this._size.width/2)+"px "+(a?this._size.height/2:this.cellSize.height/2)+"px"})}}; |
iAd.CarouselView.prototype.updateSize=function(){var a=this.radius,b=iAd.CarouselView.PERSPECTIVE,c;if(this.isVertical()){c=this.cellSize.width;a=b/(b+a-(this.cellSize.height+this._cellPadding)/2)*2*a}else{c=b/(b+a-(this.cellSize.width+this._cellPadding)/2)*2*a;a=this.cellSize.height}this._size=new iAd.Size(Math.ceil(c),Math.ceil(a));this.notifyPropertyChange("size")}; |
iAd.CarouselView.prototype.setRotation=function(a){if(!isNaN(a)){this._rotation=a%360;a=this.isVertical();this.hostingLayer.style.webkitTransform="rotate3d("+(a?1:0)+", "+(a?0:1)+", 0, "+this._rotation+"deg)"}};iAd.CarouselView.prototype.setCellPadding=function(a){if(a!=this._cellPadding){this._cellPadding=a;this.updateLayout()}};iAd.CarouselView.prototype.setCellLength=function(a){if(this._cellLength!=a){this._cellLength=a;this.updateLayout()}}; |
iAd.CarouselView.prototype.setOrientation=function(a){if(a!=this._orientation){this._orientation=a;this.setRotation(this.rotation);this.updateLayout()}};iAd.CarouselView.prototype.handleEvent=function(a){if(!(this.busySelecting&&a.type!="webkitTransitionEnd")){this.callSuper(a);a.type=="webkitTransitionEnd"&&this.transitionEnded(a)}}; |
iAd.CarouselView.prototype.touchesBegan=function(a){if(a.currentTarget!==this.layer){this.callSuper(a);this.touchedCell=a.currentTarget;this.hostingLayer.style.webkitTransitionDuration=0;(this.wasStopppedDuringAnimation=this.animator.animating)?this.stopAnimation():this.highlightCurrentCell();this.startRotation=this.rotation;this.startTouchPosition=iAd.Point.fromEventInElement(a,this.layer);this.startXAngle=Math.acos((this.startTouchPosition.x-this.position.x-this.radius)/this.radius);this.startYAngle= |
Math.acos((this.startTouchPosition.y-this.position.y-this.radius)/this.radius);this.trackingMoved=false;this.trackingPoints=[];this.storeEventLocation(this.startTouchPosition)}}; |
iAd.CarouselView.prototype.touchesMoved=function(a){this.callSuper(a);this.removeCellHighlight();a=iAd.Point.fromEventInElement(a,this.layer);this.storeEventLocation(a);this.trackingMoved=true;a=this.isVertical()?-(this.startYAngle-Math.acos((a.y-this.position.y-this.radius)/this.radius)):this.startXAngle-Math.acos((a.x-this.position.x-this.radius)/this.radius);this.rotation=this.startRotation+iAd.Utils.radiansToDegrees(a)}; |
iAd.CarouselView.prototype.touchesEnded=function(a){this.callSuper(a);if(this.touchedCell!=null&&!this.trackingMoved&&!this.wasStopppedDuringAnimation){this.busySelecting=true;a=this.touchedCell._index*(360/this.numberOfCells);var b=a==this.rotation;this.cellIsBeingSelected(b);if(b||!this.centersSelection){this.cellWasSelected(b);this.busySelecting=false;this.removeCellHighlight()}else{b=Math.abs(a-this.rotation);if(b>90)b=a<this.rotation?a+360-this.rotation:this.rotation+360-a;var c=this.centerSelectionDuration; |
if(c<0)c=Math.min(60,b)/60*iAd.CarouselView.SELECTION_ROTATION_DURATION;this.hostingLayer.style.webkitTransitionDuration=Math.max(0.1,c)+"s";this.rotation=a}}else this.startAnimating();if(!this.animator.animating&&!this.busySelecting&&this.snapsToCells){this.hostingLayer.style.webkitTransitionDuration=iAd.CarouselView.SNAP_ROTATION_DURATION+"s";this.rotation=Math.round(this.rotation/(360/this.numberOfCells))*(360/this.numberOfCells)}}; |
iAd.CarouselView.prototype.transitionEnded=function(){if(this.busySelecting){this.busySelecting=false;this.cellWasSelected(this.touchedCell,false);this.removeCellHighlight()}};iAd.CarouselView.prototype.storeEventLocation=function(a){this.trackingPoints.push({pos:this.isVertical()?a.y:a.x,date:new Date});this.trackingPoints.length>10&&this.trackingPoints.shift()}; |
iAd.CarouselView.prototype.startAnimating=function(){for(var a=-1,b=this.trackingPoints.length-1;b>0;--b)if(this.trackingPoints[b].pos!=0){a=b-1;break}if(a<0)return false;var c=a+1;b=this.trackingPoints[c].date-this.trackingPoints[a].date;a=this.trackingPoints[c].pos-this.trackingPoints[a].pos;if(Math.abs(a)<3||b>35)return false;a=-Math.atan(a/this.radius);b=Math.abs(a);b=b<0.075?90:b<0.15?180:b<0.225?270:360;a=a<0?this.isVertical()?"top-":"right-":this.isVertical()?"bottom-":"left-";if(a=="left-"|| |
a=="top-")b=-b;this.rotationBeforeAnimation=this.rotation;this.animationAngle=b;if(this.snapsToCells){a=this.rotation+this.animationAngle;this.animationAngle-=a-Math.round(a/(360/this.numberOfCells))*(360/this.numberOfCells)}this.animator.start();return true};iAd.CarouselView.prototype.animationDidIterate=function(a){this.rotation=this.rotationBeforeAnimation+a*this.animationAngle};iAd.CarouselView.prototype.stopAnimation=function(){this.animator.stop()}; |
iAd.CarouselView.prototype.highlightCurrentCell=function(){if(this.touchedCell!=null){this.currentHighlightCell!=null&&this.removeCellHighlight();this.touchedCell.addClassName(iAd.CarouselView.CELL_ACTIVE_CSS);this.currentHighlightCell=this.touchedCell;this.showingHighlight=true}}; |
iAd.CarouselView.prototype.removeCellHighlight=function(){if(!(!this.showingHighlight||this.touchedCell==null)){this.currentHighlightCell.removeClassName(iAd.CarouselView.CELL_ACTIVE_CSS);this.currentHighlightCell=null;this.showingHighlight=false}};iAd.CarouselView.prototype.cellIsBeingSelected=function(a){this.dispatchNotification(iAd.CarouselView.WILL_SELECT_CELL_AT_INDEX_DELEGATE,this.delegate,[["index",this.touchedCell._index],["isInstantaneous",a]])}; |
iAd.CarouselView.prototype.cellWasSelected=function(a){this.dispatchNotification(iAd.CarouselView.DID_SELECT_CELL_AT_INDEX_DELEGATE,this.delegate,[["index",this.touchedCell._index],["wasInstantaneous",a]])};iAd.Class({name:"iAd.NavigationBar",superclass:iAd.View,synthesizedProperties:["barStyle","items","topItem","backItem","busy"],cssClassName:"ad-navigation-bar",collectionAccessor:"navigationBars"});iAd.NavigationBar.STYLE_DEFAULT="ad-default";iAd.NavigationBar.STYLE_BLACK="ad-black"; |
iAd.NavigationBar.STYLE_BLACK_TRANSLUCENT="ad-black-translucent";iAd.NavigationBar.DEFAULT_HEIGHT=44;iAd.NavigationBar.ANIMATION_DURATION=0.35;iAd.NavigationBar.SHOULD_PUSH_ITEM_DELEGATE="navigationBarShouldPushItem";iAd.NavigationBar.DID_PUSH_ITEM_DELEGATE="navigationBarDidPushItem";iAd.NavigationBar.SHOULD_POP_ITEM_DELEGATE="navigationBarShouldPopItem";iAd.NavigationBar.DID_POP_ITEM_DELEGATE="navigationBarDidPopItem"; |
iAd.NavigationBar.prototype.init=function(a){this.delegate=null;this._barStyle=iAd.NavigationBar.STYLE_DEFAULT;this._items=[];this._busy=false;this.itemsToSetupAfterAnimatedChange=null;this.callSuper(a);if(!this.usesDeclarativeBacking)this.barStyle=iAd.NavigationBar.STYLE_DEFAULT}; |
iAd.NavigationBar.prototype.setupLayer=function(){this.callSuper();this.barStyle=this.layer.hasClassName(iAd.NavigationBar.STYLE_BLACK)?iAd.NavigationBar.STYLE_BLACK:this.layer.hasClassName(iAd.NavigationBar.STYLE_BLACK_TRANSLUCENT)?iAd.NavigationBar.STYLE_BLACK_TRANSLUCENT:iAd.NavigationBar.STYLE_DEFAULT};iAd.NavigationBar.prototype.setSize=function(a){this.callSuper(new iAd.Size(a.width,iAd.NavigationBar.DEFAULT_HEIGHT));this.updateTopItemLayout()}; |
iAd.NavigationBar.prototype.willMoveToSuperview=function(a){if(a!==null&&!this.usesDeclarativeBacking&&this._size.width==0)this.size=new iAd.Size(a._size.width,iAd.NavigationBar.DEFAULT_HEIGHT)};iAd.NavigationBar.prototype.layerWasInsertedIntoDocument=function(){this.callSuper();this.updateTopItemLayout()};iAd.NavigationBar.prototype.setBarStyle=function(a){this.layer.removeClassName(this._barStyle);this.layer.addClassName(a);this._barStyle=a}; |
iAd.NavigationBar.prototype.getTopItem=function(){return this._items.length>0?this._items[this._items.length-1]:null};iAd.NavigationBar.prototype.getBackItem=function(){return this._items.length>1?this._items[this._items.length-2]:null};iAd.NavigationBar.prototype.handleEvent=function(a){this.callSuper(a);this.busy&&a.type=="webkitTransitionEnd"&&this.transitionsEnded()};iAd.NavigationBar.prototype.setItems=function(a){this.setItemsAnimated(a,false)}; |
iAd.NavigationBar.prototype.setItemsAnimated=function(a,b){if(!(this.busy||a.length==0)){iAd.Transaction.begin();for(var c=this.topItem,d=a.length>1?a[a.length-2]:null,e=a[a.length-1],f=0;f<this._items.length;f++)this._items[f].navigationBar=null;for(f=0;f<a.length;f++)a[f].navigationBar=this;if(c===null){if(this.shouldPushItem(e)){this.addItemViews(e,null);e.sizeItemsAndComputePositionsWithBackItem(null);e.updateLayout();this._items=a;this.dispatchNotification(iAd.NavigationBar.DID_PUSH_ITEM_DELEGATE, |
this.delegate,[["item",e]])}iAd.Transaction.commit()}else if(c===e){for(this.removeViewsForItem(c);this.subviews.length;)this.subviews[0].removeFromSuperview();this.addItemViews(e,d);e.sizeItemsAndComputePositionsWithBackItem(d);e.updateLayout();this._items=a;iAd.Transaction.commit()}else if((f=this._items.indexOf(e)==-1)&&!this.shouldPushItem(e)||!f&&!this.shouldPopItem(c))iAd.Transaction.commit();else{this.addItemViews(e,d);e.sizeItemsAndComputePositionsWithBackItem(d);this.itemsAfterTransition= |
a;this.transitionToItem(e,c,f,b)}}};iAd.NavigationBar.prototype.pushNavigationItemAnimated=function(a,b){if(!this.busy){iAd.Transaction.begin();this.shouldPushItem(a)&&this.setItemsAnimated(this._items.concat([a]),b);iAd.Transaction.commit()}};iAd.NavigationBar.prototype.popNavigationItemAnimated=function(a){if(!(this.busy||this._items.length<2)){iAd.Transaction.begin();this.shouldPopItem(this.topItem)&&this.setItemsAnimated(this._items.slice(0,this._items.length-1),a);iAd.Transaction.commit()}}; |
iAd.NavigationBar.prototype.addItemViews=function(a,b){for(var c=[a._leftBarButtonItem||(b!==null?b.backBarButtonItem:null)||null,a.rightBarButtonItem,a.titleView],d=0;d<c.length;d++){a=c[d];if(!(iAd.Utils.objectIsUndefined(a)||a===null)){var e=a.view;if(e.superview===null||e.superview!==this)this.addSubview(e)}}}; |
iAd.NavigationBar.prototype.transitionToItem=function(a,b,c,d){this.busy=d;this.previousItem=b;this.transitionWentForward=c;iAd.Transaction.defaults.duration=d?iAd.NavigationBar.ANIMATION_DURATION:0;iAd.Transaction.defaults.properties=["opacity","position"];if(b._leftBarButtonItem!==null)b._leftBarButtonItem!==a._leftBarButtonItem&&(new iAd.Transition({target:b._leftBarButtonItem.view,properties:["opacity"],to:[0]})).start();else if(b.leftButton!==null){var e=c?-b.leftButton.view.size.width-iAd.NavigationItem.LEFT_BUTTON_LEFT_MARGIN: |
a.positions.title;(new iAd.Transition({target:b.leftButton.view,to:[0,new iAd.Point(e,0)]})).start()}e=c?iAd.NavigationItem.LEFT_BUTTON_LEFT_MARGIN:this.size.width;(new iAd.Transition({target:b.titleView.view,to:[0,new iAd.Point(e,0)]})).start();b._rightBarButtonItem!==null&&b._rightBarButtonItem!==a._rightBarButtonItem&&(new iAd.Transition({target:b._rightBarButtonItem.view,properties:["opacity"],to:[0]})).start();if(a._leftBarButtonItem!==null){if(a._leftBarButtonItem!==b._leftBarButtonItem){a._leftBarButtonItem.view.position= |
new iAd.Point(a.positions.leftButton,0);(new iAd.Transition({target:a._leftBarButtonItem.view,properties:["opacity"],from:[0],to:[1]})).start()}}else if(a.leftButton!==null){e=c?b.positions.title:-b.leftButton.view.size.width-iAd.NavigationItem.LEFT_BUTTON_LEFT_MARGIN;(new iAd.Transition({target:a.leftButton.view,from:[0,new iAd.Point(e,0)],to:[a.hidesBackButton?0:1,new iAd.Point(a.positions.leftButton,0)]})).start()}e=c?this.size.width:iAd.NavigationItem.LEFT_BUTTON_LEFT_MARGIN;(new iAd.Transition({target:a.titleView.view, |
from:[0,new iAd.Point(e,0)],to:[1,new iAd.Point(a.positions.title,0)]})).start();if(a._rightBarButtonItem!==null&&a._rightBarButtonItem!==b._rightBarButtonItem){a._rightBarButtonItem.view.position=new iAd.Point(a.positions.rightButton,0);(new iAd.Transition({target:a._rightBarButtonItem.view,properties:["opacity"],from:[0],to:[1]})).start()}d&&b.titleView.view.layer.addEventListener("webkitTransitionEnd",this,false);iAd.Transaction.commit();d||this.transitionsEnded()}; |
iAd.NavigationBar.prototype.transitionsEnded=function(){this._items=this.itemsAfterTransition;this.busy=false;this.transitionWentForward?this.dispatchNotification(iAd.NavigationBar.DID_PUSH_ITEM_DELEGATE,this.delegate,[["item",this.topItem]]):this.dispatchNotification(iAd.NavigationBar.DID_POP_ITEM_DELEGATE,this.delegate,[["item",this.previousItem]]);this.removeViewsForItem(this.previousItem)}; |
iAd.NavigationBar.prototype.removeViewsForItem=function(a){a.leftButton!==null&&a.leftButton!==this.topItem.leftButton&&a.leftButton.view.removeFromSuperview();a.titleView.view.removeFromSuperview();a._rightBarButtonItem!==null&&a._rightBarButtonItem!==a._rightBarButtonItem&&a._rightBarButtonItem.view.removeFromSuperview();a.leftButton!==null&&a.leftButton.removeEventListener(iAd.Control.TOUCH_UP_INSIDE_EVENT,this,false)}; |
iAd.NavigationBar.prototype.updateTopItemLayout=function(){this._items.length>0&&this.topItem.updateLayoutIfTopItem()};iAd.NavigationBar.prototype.shouldPushItem=function(a){this.dispatchNotification(iAd.NavigationBar.SHOULD_PUSH_ITEM_DELEGATE,this.delegate,[["item",a]]);return true};iAd.NavigationBar.prototype.shouldPopItem=function(a){this.dispatchNotification(iAd.NavigationBar.SHOULD_POP_ITEM_DELEGATE,this.delegate,[["item",a]]);return true}; |
iAd.Class({name:"iAd.NavigationItem",mixins:[iAd.EventTriage],synthesizedProperties:["title","backBarButtonItem","leftBarButtonItem","rightBarButtonItem","hidesBackButton"]});iAd.NavigationItem.LEFT_BUTTON_LEFT_MARGIN=5;iAd.NavigationItem.LEFT_BUTTON_RIGHT_MARGIN=8;iAd.NavigationItem.RIGHT_BUTTON_LEFT_MARGIN=11;iAd.NavigationItem.RIGHT_BUTTON_RIGHT_MARGIN=5; |
iAd.NavigationItem.prototype.init=function(a){this.callSuper();this._title="";this._backBarButtonItem=new iAd.BarButtonItem(iAd.BarButtonItem.TYPE_BACK);this._hidesBackButton=false;this._rightBarButtonItem=this._leftBarButtonItem=null;this.titleView=new iAd.BarButtonItem(iAd.BarButtonItem.TYPE_PLAIN);this.titleView.view.layer.setAttribute("role","header");this.viewController=this.navigationBar=this.positions=this.buttons=null;this.title=a||"";this._backBarButtonItem.addEventListener(iAd.Control.TOUCH_UP_INSIDE_EVENT, |
this,false)};iAd.NavigationItem.prototype.handleControlTouchUpInside=function(){if(!this._hidesBackButton)if(this.viewController!==null&&this.viewController.parentViewController!==null)this.viewController.parentViewController.popViewControllerAnimated(true);else this.navigationBar!==null&&this.navigationBar.popNavigationItemAnimated(true)};iAd.NavigationItem.prototype.setTitle=function(a){this._title=a;this.updateLayoutIfTopItem()}; |
iAd.NavigationItem.prototype.setBackBarButtonItem=function(a){if(this.navigationBar!==null&&this.navigationBar.backItem===this){this._backBarButtonItem!==null&&this._backBarButtonItem.view.removeFromSuperview();this._backBarButtonItem=a;this.navigationBar.addSubview(this._backBarButtonItem.view);this.navigationBar.topItem.updateLayoutIfTopItem()}else this._backBarButtonItem=a;this._backBarButtonItem!==null&&this._backBarButtonItem.addEventListener(iAd.Control.TOUCH_UP_INSIDE_EVENT,this,false)}; |
iAd.NavigationItem.prototype.setHidesBackButton=function(a){this.setHidesBackButtonAnimated(a,false)}; |
iAd.NavigationItem.prototype.setLeftBarButtonItem=function(a){if(this.navigationBar!==null&&this.navigationBar.topItem===this){this.getDefaultBackButton();this.leftButton!==null&&this.leftButton.view.removeFromSuperview();a=(this._leftBarButtonItem=a)||this.getDefaultBackButton();if(a!==null){this.navigationBar.addSubview(a.view);if(this._leftBarButtonItem===null&&!this.hidesBackButton)a.view.opacity=1}this.updateLayoutIfTopItem()}else this._leftBarButtonItem=a}; |
iAd.NavigationItem.prototype.setRightBarButtonItem=function(a){if(this.navigationBar!==null&&this.navigationBar.topItem===this){this._rightBarButtonItem!==null&&this._rightBarButtonItem.view.removeFromSuperview();this._rightBarButtonItem=a;this.navigationBar.addSubview(this._rightBarButtonItem.view);this.updateLayoutIfTopItem()}else this._rightBarButtonItem=a}; |
iAd.NavigationItem.prototype.setHidesBackButtonAnimated=function(a,b){var c=this.getDefaultBackButton();if(this._hidesBackButton!=a){this._hidesBackButton=a;if(c!==null){c.view.transitionsEnabled=b;c.view.opacity=a?0:1}}}; |
iAd.NavigationItem.prototype.setLeftBarButtonItemAnimated=function(a,b){if(!b||this.navigationBar===null||this.navigationBar.topItem!==this)this.leftBarButtonItem=a;else{iAd.Transaction.begin();iAd.Transaction.defaults.duration=0.5;iAd.Transaction.defaults.properties=["opacity"];var c=this.leftButton;c!==null&&(new iAd.Transition({target:c.view,to:[0],removesTargetUponCompletion:true})).start();c=(this._leftBarButtonItem=a)||this.getDefaultBackButton();if(c!==null){this.navigationBar.addSubview(c.view); |
if(this._leftBarButtonItem!==null||!this._hidesBackButton)(new iAd.Transition({target:c.view,from:[0],to:[1]})).start()}this.updateLayoutIfTopItem();iAd.Transaction.commit()}}; |
iAd.NavigationItem.prototype.setRightBarButtonItemAnimated=function(a,b){if(!b||this.navigationBar===null||this.navigationBar.topItem!==this)this.rightBarButtonItem=a;else{iAd.Transaction.begin();iAd.Transaction.defaults.duration=0.5;iAd.Transaction.defaults.properties=["opacity"];var c=this._rightBarButtonItem;c!==null&&(new iAd.Transition({target:c.view,to:[0],removesTargetUponCompletion:true})).start();this._rightBarButtonItem=a;if(this._rightBarButtonItem!==null){this.navigationBar.addSubview(this._rightBarButtonItem.view); |
(new iAd.Transition({target:this._rightBarButtonItem.view,from:[0],to:[1]})).start()}this.updateLayoutIfTopItem();iAd.Transaction.commit()}};iAd.NavigationItem.prototype.getDefaultBackButton=function(){return this.navigationBar!==null&&this.navigationBar.backItem!==null?this.navigationBar.backItem.backBarButtonItem:null}; |
iAd.NavigationItem.prototype.sizeItemsAndComputePositionsWithBackItem=function(a){if(this.navigationBar!==null){var b=this._leftBarButtonItem||(a!==null?a.backBarButtonItem:null),c=this._rightBarButtonItem!==null?this._rightBarButtonItem.view.size.width:0,d=this.navigationBar.size.width-iAd.NavigationItem.LEFT_BUTTON_LEFT_MARGIN-iAd.NavigationItem.RIGHT_BUTTON_RIGHT_MARGIN;if(b!==null)d-=iAd.NavigationItem.LEFT_BUTTON_RIGHT_MARGIN;if(this._rightBarButtonItem!==null)d-=iAd.NavigationItem.RIGHT_BUTTON_LEFT_MARGIN+ |
c;var e=0;if(b!==null){b.maxWidth=this.navigationBar.size.width/2;if(b!==this._leftBarButtonItem&&b.title==""&&b.image===null)b.title=a.title;e=b.view.size.width}this.titleView.maxWidth=0;this.titleView.title=this._title;var f=this.titleView.view.size.width;if(f+e>d){if(b!==null){b.maxWidth=Math.min(Math.max(d/3,d-f),b.maxWidth);e=b.view.size.width}this.titleView.maxWidth=d-e;f=this.titleView.view.size.width}d=iAd.NavigationItem.LEFT_BUTTON_LEFT_MARGIN;a=this.navigationBar.size.width-iAd.NavigationItem.RIGHT_BUTTON_RIGHT_MARGIN- |
c;e=d+(b!=null?e+iAd.NavigationItem.LEFT_BUTTON_RIGHT_MARGIN:0);c=a-f-(c>0?iAd.NavigationItem.RIGHT_BUTTON_LEFT_MARGIN:0);var g=f=(this.navigationBar.size.width-f)/2;if(f>c||f<e)g=Math.abs(f-e)<Math.abs(f-c)?e:c;this.leftButton=b;this.positions={leftButton:d,title:g,rightButton:a}}}; |
iAd.NavigationItem.prototype.updateLayout=function(){if(!(this.positions===null||this.button===null)){if(this.leftButton!=null)this.leftButton.view.position=new iAd.Point(this.positions.leftButton,0);if(this._rightBarButtonItem!=null)this._rightBarButtonItem.view.position=new iAd.Point(this.positions.rightButton,0);this.titleView.view.position=new iAd.Point(this.positions.title,0)}}; |
iAd.NavigationItem.prototype.updateLayoutIfTopItem=function(){if(!(this.navigationBar===null||this.navigationBar.topItem!==this)){this.sizeItemsAndComputePositionsWithBackItem(this.navigationBar.backItem);this.updateLayout()}};iAd.Class({name:"iAd.TabBar",superclass:iAd.View,synthesizedProperties:["items","selectedItem"],cssClassName:"ad-tab-bar",collectionAccessor:"tabBars"});iAd.TabBar.DEFAULT_HEIGHT=49;iAd.TabBar.CUSTOMIZE_GRID_CELL_SIZE=80;iAd.TabBar.DID_SELECT_ITEM="tabBarDidSelectItem"; |
iAd.TabBar.WILL_BEGIN_CUSTOMIZING_ITEMS="tabBarWillBeginCustomizingItems";iAd.TabBar.DID_BEGIN_CUSTOMIZING_ITEMS="tabBarDidBeginCustomizingItems";iAd.TabBar.WILL_END_CUSTOMIZING_ITEMS_CHANGED="tabBarWillEndCustomizingItemsChanged";iAd.TabBar.DID_END_CUSTOMIZING_ITEMS_CHANGED="tabBarDidEndCustomizingItemsChanged"; |
iAd.TabBar.prototype.init=function(a){this.delegate=null;this.isCustomizing=false;this._items=[];this._selectedItem=null;this.callSuper(a);this.layer.addEventListener("webkitTransitionEnd",this,false)}; |
iAd.TabBar.prototype.readPropertiesFromLayerComputedStyle=function(a){this.callSuper(a);a=[];for(var b=this.layer.querySelectorAll("."+iAd.TabBarItemView.cssClassName),c,d=0;d<b.length;d++){c=b[d]._view;c.addEventListener(iAd.Control.TOUCH_DOWN_EVENT,this,false);a.push(new iAd.TabBarItem(c))}this.items=a};iAd.TabBar.prototype.setSize=function(a){a.height=iAd.TabBar.DEFAULT_HEIGHT;this.callSuper(a);this.updateLayout()}; |
iAd.TabBar.prototype.willMoveToSuperview=function(a){if(a!==null){if(this._size.width==0)this.size=new iAd.Size(a.size.width,iAd.TabBar.DEFAULT_HEIGHT);if(this._position.y==0)this.position=new iAd.Point(0,a.size.height-iAd.TabBar.DEFAULT_HEIGHT)}}; |
iAd.TabBar.prototype.setSelectedItem=function(a){if(this._selectedItem!==a){if(this._selectedItem!=null)this._selectedItem.view.selected=false;a.view.selected=true;this._selectedItem=a;this.dispatchNotification(iAd.TabBar.DID_SELECT_ITEM,this.delegate,[["item",a]])}};iAd.TabBar.prototype.setItems=function(a){this.setItemsAnimated(a,false)}; |
iAd.TabBar.prototype.setItemsAnimated=function(a,b){for(var c=0;c<this._items.length;c++){var d=this._items[c],e=d.view;if(a.indexOf(d)==-1)if(e.transitionsEnabled=b){e.needsRemoval=true;e.transform="scale(0.001)";e.opacity=0}else e.removeFromSuperview()}var f=(this.size.width-4)/a.length;for(c=0;c<a.length;c++){d=a[c];e=d.view;e.position=new iAd.Point(2+Math.round(c*f),0);e.size=new iAd.Size(Math.round(f),iAd.TabBarItemView.HEIGHT);e.transitionsEnabled=b;if(e.superview!==this){this.addSubview(e); |
e.addEventListener(iAd.Control.TOUCH_DOWN_EVENT,this,false)}}this._items=a;if((this.selectedItem==null||this.selectedItem.view.superview!==this||this.selectedItem.view.needsRemoval)&&a.length>0)this.selectedItem=a[0]};iAd.TabBar.prototype.updateLayout=function(){this._items.length>0&&this.setItemsAnimated(this._items,false)};iAd.TabBar.prototype.handleEvent=function(a){this.callSuper(a);switch(a.type){case iAd.Control.TOUCH_DOWN_EVENT:this.selectedItem=a.ad.sender.tabBarItem;break;case "webkitTransitionEnd":this.removeItemViewIfNeeded(a.target._control)}}; |
iAd.TabBar.prototype.removeItemViewIfNeeded=function(a){if(a.needsRemoval){a.removeFromSuperview();a.needsRemoval=false;a.transitionsEnabled=false;a.transform="scale(1)";a.opacity=1}}; |
iAd.TabBar.prototype.beginCustomizingItems=function(a){this.dispatchNotification(iAd.TabBar.WILL_BEGIN_CUSTOMIZING_ITEMS,this.delegate,[["items",a]]);this.isCustomizing=true;this.itemsPriorToCustomization=this._items;this.customizingItems=a;this.dispatchNotification(iAd.TabBar.DID_BEGIN_CUSTOMIZING_ITEMS,this.delegate,[["items",a]])}; |
iAd.TabBar.prototype.endCustomizingAnimated=function(){this.dispatchNotification(iAd.TabBar.WILL_END_CUSTOMIZING_ITEMS_CHANGED,this.delegate,[["items",this.customizingItems],["changed",true]]);this.isCustomizing=false;this.dispatchNotification(iAd.TabBar.DID_END_CUSTOMIZING_ITEMS_CHANGED,this.delegate,[["items",this.customizingItems],["changed",true]])};iAd.Class({name:"iAd.Toolbar",superclass:iAd.View,synthesizedProperties:["items","barStyle"],cssClassName:"ad-toolbar",collectionAccessor:"toolbars"}); |
iAd.Toolbar.DEFAULT_HEIGHT=44;iAd.Toolbar.EDGE_MARGIN=6;iAd.Toolbar.ITEM_MARGIN=10;iAd.Toolbar.STYLE_DEFAULT="ad-default";iAd.Toolbar.STYLE_BLACK="ad-black";iAd.Toolbar.STYLE_BLACK_TRANSLUCENT="ad-black-translucent";iAd.Toolbar.ANIMATION_DURATION=0.2;iAd.Toolbar.FADE_OUT_TRANSITION={properties:["transform","opacity"],to:["scale(0.01)",0]};iAd.Toolbar.prototype.init=function(a){this._items=[];this._barStyle="";this.callSuper(a);if(!this.usesDeclarativeBacking)this.barStyle=iAd.Toolbar.STYLE_DEFAULT}; |
iAd.Toolbar.prototype.setupLayer=function(){this.callSuper();if(this.layer.hasClassName(iAd.Toolbar.STYLE_BLACK))this._barStyle=iAd.Toolbar.STYLE_BLACK;else if(this.layer.hasClassName(iAd.Toolbar.STYLE_BLACK_TRANSLUCENT))this._barStyle=iAd.Toolbar.STYLE_BLACK_TRANSLUCENT;else this.barStyle=iAd.Toolbar.STYLE_DEFAULT}; |
iAd.Toolbar.prototype.layerWasCreated=function(){this.callSuper();this.glow=this.layer.appendChild(document.createElement("div"));this.glow.className="ad-glow";this.layer.addEventListener("webkitTransitionEnd",this,false);this.clipsToBounds=true}; |
iAd.Toolbar.prototype.readPropertiesFromLayerAttributes=function(a){this.callSuper(a);a=[];for(var b,c=0;c<this.subviews.length;c++){b=this.subviews[c];b.willMoveToSuperview(this);a.push(new iAd.BarButtonItem(null,b));b.didMoveToSuperview()}this.setItemsAnimated(a,false)};iAd.Toolbar.prototype.setPosition=function(a){this.callSuper(a);this.layerIsInDocument&&this.callMethodNameAfterDelay("updateBackgroundWithPosition",0)}; |
iAd.Toolbar.prototype.setSize=function(a){a.height=iAd.Toolbar.DEFAULT_HEIGHT;this.callSuper(a);this.updateLayout()};iAd.Toolbar.prototype.willMoveToSuperview=function(a){if(a!==null&&this._size.width==0)this.size=new iAd.Size(a.size.width,iAd.Toolbar.DEFAULT_HEIGHT)};iAd.Toolbar.prototype.layerWasInsertedIntoDocument=function(){this.updateBackgroundWithPosition()};iAd.Toolbar.prototype.setBarStyle=function(a){this.layer.removeClassName(this._barStyle);this.layer.addClassName(a);this._barStyle=a}; |
iAd.Toolbar.prototype.setItems=function(a){this.setItemsAnimated(a,false)}; |
iAd.Toolbar.prototype.setItemsAnimated=function(a,b){iAd.Transaction.begin();iAd.Transaction.defaults.duration=b?iAd.Toolbar.ANIMATION_DURATION:0;for(var c=0;c<this._items.length;c++){var d=this._items[c],e=d.view;if(a.indexOf(d)==-1)if(b){e.needsRemoval=true;e.applyTransition(iAd.Toolbar.FADE_OUT_TRANSITION)}else e.removeFromSuperview()}for(c=0;c<a.length;c++){d=a[c];e=d.view;if(e.superview!==this){d._newItem=true;this.addSubview(e);e.addPropertyObserver("size",this);d.type==iAd.BarButtonItem.TYPE_PLAIN&& |
e.addEventListener(iAd.Control.TOUCH_STATE_CHANGE_EVENT,this,false)}}var f=e=0;for(c=0;c<a.length;c++){d=a[c];if(d.type==iAd.BarButtonItem.TYPE_FLEXIBLE_SPACE)e++;else f+=d.view.size.width}c=this.size.width-f-iAd.Toolbar.ITEM_MARGIN*(a.length-1)-iAd.Toolbar.EDGE_MARGIN*2;f=e>0?c/e:0;var g=iAd.Toolbar.EDGE_MARGIN,i;for(c=0;c<a.length;c++){i=iAd.Toolbar.ITEM_MARGIN;d=a[c];e=d.view;if(d.type==iAd.BarButtonItem.TYPE_FLEXIBLE_SPACE)g+=f;else if(d.type==iAd.BarButtonItem.TYPE_FIXED_SPACE){g+=e.size.width; |
i=0}else{var h=new iAd.Point(g,(this.size.height-e.size.height)/2);if(d._newItem){e.position=h;d._newItem=false;b&&e.applyTransition(iAd.View.TRANSITION_DISSOLVE_IN)}else e.applyTransition({properties:["position"],to:[h]});g+=e.size.width}g+=i}iAd.Transaction.commit();this._items=a};iAd.Toolbar.prototype.updateLayout=function(){this._items.length>0&&this.setItemsAnimated(this._items,false)}; |
iAd.Toolbar.prototype.updateBackgroundWithPosition=function(){this.layer.toggleClassName("ad-top",window.webkitConvertPointFromNodeToPage(this.layer,new WebKitPoint(0,0)).y==0)}; |
iAd.Toolbar.prototype.handleEvent=function(a){this.callSuper(a);if(a.type=="webkitTransitionEnd"){if(a.target!==this.layer)if(a.target!==this.glow)this.removeItemViewIfNeeded(a.target._control);else if(this.glow.style.opacity==0)this.glow.style.display="none"}else if(a.type==iAd.Control.TOUCH_STATE_CHANGE_EVENT){a=a.ad.sender;this.glow.style.webkitTransform=iAd.Utils.t(a.position.x+a.size.width/2-50,0);this.glow.style.opacity=a.touchInside?1:0;this.glow.style.display="block"}}; |
iAd.Toolbar.prototype.removeItemViewIfNeeded=function(a){if(a.needsRemoval){a.removeFromSuperview();a.needsRemoval=false;a.transitionsEnabled=false;a.transform="scale(1)";a.opacity=1}};iAd.Toolbar.prototype.handlePropertyChange=function(){this.setItemsAnimated(this._items,false)};iAd.Class({name:"iAd.ProgressView",superclass:iAd.View,synthesizedProperties:["progress","progressViewStyle","width"],cssClassName:"ad-progress-view",collectionAccessor:"progressViews"});iAd.ProgressView.STYLE_DEFAULT="ad-default"; |
iAd.ProgressView.STYLE_BAR="ad-bar";iAd.ProgressView.DEFAULT_HEIGHT=9;iAd.ProgressView.BAR_HEIGHT=11;iAd.ProgressView.prototype.init=function(a,b){this._progress=0;this._progressViewStyle=b||iAd.ProgressView.STYLE_DEFAULT;this.callSuper(a)};iAd.ProgressView.prototype.setupLayer=function(){this.callSuper();this.progressViewStyle=this.layer.hasClassName(iAd.ProgressView.STYLE_BAR)?iAd.ProgressView.STYLE_BAR:iAd.ProgressView.STYLE_DEFAULT}; |
iAd.ProgressView.prototype.createLayer=function(){this.callSuper();this.layer.addClassName(this._progressViewStyle)};iAd.ProgressView.prototype.layerWasCreated=function(){this.callSuper();this.bar=this.layer.appendChild(document.createElement("div"))};iAd.ProgressView.prototype.readPropertiesFromLayerAttributes=function(a){this.callSuper(a);this.updateBar()}; |
iAd.ProgressView.prototype.setSize=function(a){a.height=this._progressViewStyle==iAd.ProgressView.STYLE_DEFAULT?iAd.ProgressView.DEFAULT_HEIGHT:iAd.ProgressView.BAR_HEIGHT;this.callSuper(a);this.updateBar()};iAd.ProgressView.prototype.willMoveToSuperview=function(a){if(a instanceof iAd.Toolbar)this.progressViewStyle=iAd.ProgressView.STYLE_BAR};iAd.ProgressView.prototype.getWidth=function(){return this.size.width};iAd.ProgressView.prototype.setWidth=function(a){this.size=new iAd.Size(a,0)}; |
iAd.ProgressView.prototype.setProgress=function(a){a=Math.max(Math.min(a,1),0);if(a!=this._progress){this._progress=a;this.updateBar()}};iAd.ProgressView.prototype.setProgressViewStyle=function(a){if(a!=this._progressViewStyle){this.layer.removeClassName(this._progressViewStyle);this.layer.addClassName(a);this._progressViewStyle=a}};iAd.ProgressView.prototype.updateBar=function(){this.bar.style.width=iAd.Utils.px(this.size.width*this._progress)}; |
iAd.Class({name:"iAd.Control",superclass:iAd.View,synthesizedProperties:["state","enabled","selected","highlighted","touchLayer"],cssClassName:"ad-control",collectionAccessor:"controls"});iAd.Control.prototype.init=function(a){this.tag=0;this._enabled=true;this._highlighted=this._selected=false;this._touchLayer=null;this.callSuper(a);this.touchInside=this.tracking=false;this.layer._control=this;this.userInteractionEnabled=true};iAd.Control.INSIDE_PADDING=iAd.IS_IPAD?25:70; |
iAd.Control.TOUCH_DOWN_EVENT="controlTouchDown";iAd.Control.TOUCH_DRAG_INSIDE_EVENT="controlTouchDragInside";iAd.Control.TOUCH_DRAG_OUTSIDE_EVENT="controlTouchDragOutside";iAd.Control.TOUCH_DRAG_ENTER_EVENT="controlTouchDragEnter";iAd.Control.TOUCH_DRAG_EXIT_EVENT="controlTouchDragExit";iAd.Control.TOUCH_UP_INSIDE_EVENT="controlTouchUpInside";iAd.Control.TOUCH_UP_OUTSIDE_EVENT="controlTouchUpOutside";iAd.Control.TOUCH_CANCEL_EVENT="controlTouchCancel";iAd.Control.VALUE_CHANGE_EVENT="controlValueChange"; |
iAd.Control.TOUCH_STATE_CHANGE_EVENT="controlTouchStateChange";iAd.Control.STATE_NORMAL=0;iAd.Control.STATE_NORMAL_CSS="ad-normal";iAd.Control.STATE_HIGHLIGHTED=1;iAd.Control.STATE_HIGHLIGHTED_CSS="ad-highlighted";iAd.Control.STATE_DISABLED=2;iAd.Control.STATE_DISABLED_CSS="ad-disabled";iAd.Control.STATE_SELECTED=4;iAd.Control.STATE_SELECTED_CSS="ad-selected"; |
iAd.Control.synthesizedEvents=[iAd.Control.TOUCH_DOWN_EVENT,iAd.Control.TOUCH_DRAG_INSIDE_EVENT,iAd.Control.TOUCH_DRAG_OUTSIDE_EVENT,iAd.Control.TOUCH_DRAG_ENTER_EVENT,iAd.Control.TOUCH_DRAG_EXIT_EVENT,iAd.Control.TOUCH_UP_INSIDE_EVENT,iAd.Control.TOUCH_UP_OUTSIDE_EVENT,iAd.Control.TOUCH_CANCEL_EVENT,iAd.Control.VALUE_CHANGE_EVENT,iAd.Control.TOUCH_STATE_CHANGE_EVENT]; |
iAd.Control.prototype.setupLayer=function(){this.callSuper();for(var a=this.constructor.synthesizedEvents,b,c,d=0;d<a.length;d++){b=a[d];c="ad-on"+b.toLowerCase();this.layer.hasAttribute(c)&&this.addEventListener(b,iAd.Utils.makeEventHandlerWithString(this.layer.getAttribute(c)),false)}};iAd.Control.prototype.setUserInteractionEnabled=function(a){if(this._userInteractionEnabled!=a){this.touchLayer[(a?"add":"remove")+"EventListener"](iAd.START_EVENT,this,false);this._userInteractionEnabled=a}}; |
iAd.Control.prototype.getState=function(){return iAd.Control.STATE_NORMAL|(this._highlighted?iAd.Control.STATE_HIGHLIGHTED:0)|(this._enabled?0:iAd.Control.STATE_DISABLED)|(this._selected?iAd.Control.STATE_SELECTED:0)};iAd.Control.prototype.setEnabled=function(a){if(a!=this._enabled){this.layer.toggleClassName(iAd.Control.STATE_DISABLED_CSS,!a);this.userInteractionEnabled=this._enabled=a;this.notifyPropertyChange("state")}}; |
iAd.Control.prototype.setSelected=function(a){if(a!=this._selected){this.layer.toggleClassName(iAd.Control.STATE_SELECTED_CSS,a);this._selected=a;this.notifyPropertyChange("state")}};iAd.Control.prototype.setHighlighted=function(a){if(a!=this._highlighted){this.layer.toggleClassName(iAd.Control.STATE_HIGHLIGHTED_CSS,a);this._highlighted=a;this.notifyPropertyChange("state")}};iAd.Control.prototype.getTouchLayer=function(){return this._touchLayer!=null?this._touchLayer:this.layer}; |
iAd.Control.prototype.touchesBegan=function(a){this.callSuper(a);if(this._enabled){a.preventDefault();this.highlighted=this.touchInside=true;this.dispatchEvent(this.createUIEvent(iAd.Control.TOUCH_DOWN_EVENT,a));this.dispatchEvent(this.createEvent(iAd.Control.TOUCH_STATE_CHANGE_EVENT));this.lastProcessedEvent=a}}; |
iAd.Control.prototype.touchesMoved=function(a){this.callSuper(a);this.tracking=true;var b=this.pointInsidePaddedBounds(iAd.Point.fromEventInElement(a,this.layer)),c=b?iAd.Control.TOUCH_DRAG_INSIDE_EVENT:iAd.Control.TOUCH_DRAG_OUTSIDE_EVENT;if(b!=this.touchInside){c=(this.highlighted=this.touchInside=b)?iAd.Control.TOUCH_DRAG_ENTER_EVENT:iAd.Control.TOUCH_DRAG_EXIT_EVENT;this.dispatchEvent(this.createEvent(iAd.Control.TOUCH_STATE_CHANGE_EVENT))}this.dispatchEvent(this.createUIEvent(c,a));this.lastProcessedEvent= |
a};iAd.Control.prototype.touchesEnded=function(a){this.callSuper(a);this.highlighted=this.tracking=false;this.dispatchEvent(this.createUIEvent(this.touchInside?iAd.Control.TOUCH_UP_INSIDE_EVENT:iAd.Control.TOUCH_UP_OUTSIDE_EVENT,this.lastProcessedEvent));this.touchInside=false;this.dispatchEvent(this.createEvent(iAd.Control.TOUCH_STATE_CHANGE_EVENT))}; |
iAd.Control.prototype.touchesCancelled=function(a){this.callSuper(a);this.highlighted=this.tracking=false;this.dispatchEvent(this.createUIEvent(iAd.Control.TOUCH_CANCEL_EVENT,a))};iAd.Control.prototype.createUIEvent=function(a,b){var c=iAd.Utils.createUIEvent(a,b);if(!c.ad)c.ad={};c.ad.sender=this;return c};iAd.Control.prototype.pointInsidePaddedBounds=function(a){var b=iAd.Control.INSIDE_PADDING;return a.x>=-b&&a.x<=this.size.width+b&&a.y>=-b&&a.y<=this.size.height+b}; |
iAd.Control.isNodeInControlHierarchyBoundedByElement=function(a,b){for(;a.parentNode;){if(a.hasOwnProperty("_view")&&a._view instanceof iAd.Control)return true;if(a===b)break;a=a.parentNode}return false};iAd.Control.initialize=function(){if(!this.hasOwnProperty("synthesizedEvents"))this.synthesizedEvents=[];for(var a=this;a.superclass;){a=a.superclass;if(a.hasOwnProperty("synthesizedEvents"))this.synthesizedEvents=this.synthesizedEvents.concat(a.synthesizedEvents)}}; |
iAd.Class({name:"iAd.BarItem",synthesizedProperties:["enabled","image","imageOffset","title"]});iAd.BarItem.DISABLED_CSS="ad-disabled";iAd.BarItem.prototype.init=function(){this.callSuper();this._enabled=true;this._imageOffset=this._image=null;this._title="";this.tag=0};iAd.Class({name:"iAd.BarButton",superclass:iAd.Control,synthesizedProperties:["maxWidth","width","type","buttonStyle","image","imageOffset","title"],cssClassName:"ad-bar-button",collectionAccessor:"barButtons"}); |
iAd.BarButton.DEFAULT_HEIGHT=30;iAd.BarButton.POINTY_X_OFFSET=3;iAd.BarButton.prototype.init=function(a,b){this._width=this._maxWidth=0;this._buttonStyle=this._type="";this._imageOffset=this._image=null;this._title="";this.usesAutomaticImageOffset=true;this.callSuper(a);if(!this.usesDeclarativeBacking){this.type=b!=null?b:iAd.BarButtonItem.TYPE_SQUARE;this.buttonStyle=iAd.BarButtonItem.STYLE_DEFAULT}}; |
iAd.BarButton.prototype.setupLayer=function(){this.callSuper();if(this.layer.hasClassName(iAd.BarButtonItem.STYLE_BLACK))this._buttonStyle=iAd.BarButtonItem.STYLE_BLACK;else if(this.layer.hasClassName(iAd.BarButtonItem.STYLE_DEFAULT))this._buttonStyle=iAd.BarButtonItem.STYLE_DEFAULT;else if(this.layer.hasClassName(iAd.BarButtonItem.STYLE_DONE))this._buttonStyle=iAd.BarButtonItem.STYLE_DONE;if(this.layer.hasClassName(iAd.BarButtonItem.TYPE_PLAIN))this._type=iAd.BarButtonItem.TYPE_PLAIN;else if(this.layer.hasClassName(iAd.BarButtonItem.TYPE_SQUARE))this._type= |
iAd.BarButtonItem.TYPE_SQUARE;else if(this.layer.hasClassName(iAd.BarButtonItem.TYPE_BACK))this._type=iAd.BarButtonItem.TYPE_BACK;else if(this.layer.hasClassName(iAd.BarButtonItem.TYPE_FLEXIBLE_SPACE))this._type=iAd.BarButtonItem.TYPE_FLEXIBLE_SPACE;else if(this.layer.hasClassName(iAd.BarButtonItem.TYPE_FIXED_SPACE))this._type=iAd.BarButtonItem.TYPE_FIXED_SPACE;this.width=this.layer.hasAttribute("ad-width")?parseInt(this.layer.getAttribute("ad-width"),10):0}; |
iAd.BarButton.prototype.layerWasCreated=function(){this.callSuper();this.layer.setAttribute("role","button");this.background=this.layer.appendChild(document.createElement("div"));this.icon=this.layer.appendChild(document.createElement("img"))};iAd.BarButton.prototype.readPropertiesFromLayerComputedStyle=function(a){this.callSuper(a);a=parseInt(a.maxWidth,10);this.maxWidth=isNaN(a)?0:a}; |
iAd.BarButton.prototype.setValueForAttribute=function(a,b){switch(b){case "ad-image":this.image=new iAd.Image(a);break;case "ad-image-offset-x":this.imageOffset=new iAd.Point(parseInt(a,10),this.imageOffset.y);break;case "ad-image-offset-y":this.imageOffset=new iAd.Point(this.imageOffset.x,parseInt(a,10));break;default:this.callSuper(a,b)}};iAd.BarButton.prototype.layerWasInsertedIntoDocument=function(){this.callSuper();this._title!=""&&this._width==0&&this.autoSizeTitle()}; |
iAd.BarButton.prototype.getSize=function(){return new iAd.Size(this._maxWidth==0?this._size.width:Math.min(this._maxWidth,this._size.width),this._size.height)};iAd.BarButton.prototype.setSize=function(a){a.height=iAd.BarButton.DEFAULT_HEIGHT;this.callSuper(a)};iAd.BarButton.prototype.touchesBegan=function(a){this.type==iAd.BarButtonItem.TYPE_FLEXIBLE_SPACE||this.type==iAd.BarButtonItem.TYPE_FIXED_SPACE?a.preventDefault():this.callSuper(a)}; |
iAd.BarButton.prototype.setMaxWidth=function(a){this.background.style.maxWidth=a==0?"inherit":iAd.Utils.px(a);this._maxWidth=a;this._width==0&&this.autoSizeTitle()};iAd.BarButton.prototype.setWidth=function(a){if(a==0){this.autoSizeTitle();this.autoSizeImage()}else{this._width=a;this.size=new iAd.Size(a,iAd.BarButton.DEFAULT_HEIGHT)}this.positionImage()}; |
iAd.BarButton.prototype.autoSizeTitle=function(){if(this._title!=""&&this.layerIsInDocument){this.setLayerStyle({width:"auto"});var a=parseInt(window.getComputedStyle(this.layer).width);this.size=new iAd.Size(a,this._size.height)}};iAd.BarButton.prototype.autoSizeImage=function(){if(this._image!==null){var a=this.getBorderXOffsets();this.size=new iAd.Size(this._image.width+a.left+a.right,this._size.height)}}; |
iAd.BarButton.prototype.setTitle=function(a){this._title=this.background.innerText=a;this._width==0&&this.autoSizeTitle()};iAd.BarButton.prototype.setImage=function(a){this.icon.src=a.resolvedURL;this._image=a;a.loaded?this.positionImage():a.addPropertyObserver("loaded",this)};iAd.BarButton.prototype.getImageOffset=function(){return new iAd.Point(parseInt(this.icon.style.left),parseInt(this.icon.style.top))}; |
iAd.BarButton.prototype.setImageOffset=function(a){this.icon.style.left=iAd.Utils.px(a.x);this.icon.style.top=iAd.Utils.px(a.y);this.usesAutomaticImageOffset=false}; |
iAd.BarButton.prototype.positionImage=function(){if(!(this._image===null||!this.usesAutomaticImageOffset)){this.icon.height=Math.min(this._image.height,this.size.height);var a=new iAd.Point((this._size.width-this._image.width)/2,(iAd.BarButton.DEFAULT_HEIGHT-this._image.height)/2);if(this._type==iAd.BarButtonItem.TYPE_BACK)a.x+=iAd.BarButton.POINTY_X_OFFSET;this.imageOffset=a;this.usesAutomaticImageOffset=true}}; |
iAd.BarButton.prototype.setType=function(a){this.layer.removeClassName(this._type);this.layer.addClassName(a);this._type=a};iAd.BarButton.prototype.setButtonStyle=function(a){this.layer.removeClassName(this._buttonStyle);this.layer.addClassName(a);this._buttonStyle=a}; |
iAd.BarButton.prototype.getBorderXOffsets=function(){var a=window.getComputedStyle(this.background),b=a.getPropertyCSSValue("border-left-width");a=a.getPropertyCSSValue("border-right-width");return{left:b!==null?b.getFloatValue(CSSPrimitiveValue.CSS_PX):0,right:a!==null?a.getFloatValue(CSSPrimitiveValue.CSS_PX):0}};iAd.BarButton.prototype.handlePropertyChange=function(){this._width==0&&this.autoSizeImage();this.positionImage()}; |
iAd.BarButton.prototype.dispatchEvent=function(a){a.barButtonItem=this.barButtonItem;this.callSuper(a)};iAd.Class({name:"iAd.BarButtonItem",superclass:iAd.BarItem,mixins:[iAd.EventTarget],synthesizedProperties:["maxWidth","customView","width","type","style"]});iAd.BarButtonItem.TYPE_PLAIN="ad-plain";iAd.BarButtonItem.TYPE_SQUARE="ad-square";iAd.BarButtonItem.TYPE_BACK="ad-back";iAd.BarButtonItem.TYPE_FLEXIBLE_SPACE="ad-flexible-space";iAd.BarButtonItem.TYPE_FIXED_SPACE="ad-fixed-space"; |
iAd.BarButtonItem.STYLE_BLACK="ad-black";iAd.BarButtonItem.STYLE_DEFAULT="ad-default";iAd.BarButtonItem.STYLE_DONE="ad-done";iAd.BarButtonItem.prototype.init=function(a,b){this.callSuper();this.view=b||new iAd.BarButton(null,a);this.view.isCustomView=!(this.view instanceof iAd.BarButton);this.view.barButtonItem=this;this.eventTarget=this.view};iAd.BarButtonItem.prototype.getEnabled=function(){return!this.view.isCustomView?this.view.enabled:this.view.userInteractionEnabled}; |
iAd.BarButtonItem.prototype.setEnabled=function(a){if(this.view.isCustomView)this.view.userInteractionEnabled=a;else this.view.enabled=a};iAd.BarButtonItem.prototype.getMaxWidth=function(){return!this.view.isCustomView?this.view.maxWidth:0};iAd.BarButtonItem.prototype.setMaxWidth=function(a){if(!this.view.isCustomView)this.view.maxWidth=a};iAd.BarButtonItem.prototype.getWidth=function(){return!this.view.isCustomView?this.view.width:this.view.size.width}; |
iAd.BarButtonItem.prototype.setWidth=function(a){if(this.view.isCustomView)this.view.size=new iAd.Size(a,this.view.size.height);else this.view.width=a};iAd.BarButtonItem.prototype.getTitle=function(){return!this.view.isCustomView?this.view.title:""};iAd.BarButtonItem.prototype.setTitle=function(a){if(!this.view.isCustomView)this.view.title=a};iAd.BarButtonItem.prototype.getImage=function(){return!this.view.isCustomView?this.view.image:null}; |
iAd.BarButtonItem.prototype.setImage=function(a){if(!this.view.isCustomView)this.view.image=a};iAd.BarButtonItem.prototype.getImageOffset=function(){return!this.view.isCustomView?this.view.imageOffset:null};iAd.BarButtonItem.prototype.setImageOffset=function(a){if(!this.view.isCustomView)this.view.imageOffset=a};iAd.BarButtonItem.prototype.getType=function(){return!this.view.isCustomView?this.view.type:""};iAd.BarButtonItem.prototype.setType=function(a){if(!this.view.isCustomView)this.view.type=a}; |
iAd.BarButtonItem.prototype.getStyle=function(){return!this.view.isCustomView?this.view.buttonStyle:""};iAd.BarButtonItem.prototype.setStyle=function(a){if(!this.view.isCustomView)this.view.buttonStyle=a};iAd.BarButtonItem.prototype.getCustomView=function(){return this.view.isCustomView?this.view:null};iAd.BarButtonItem.prototype.setCustomView=function(a){if(a!==this.view){if(!this.view.isCustomView)this.view=undefined;a.isCustomView=true;a.barButtonItem=this;this.view=a}}; |
iAd.Class({name:"iAd.Slider",superclass:iAd.Control,synthesizedProperties:["minimumValue","maximumValue","value"],cssClassName:"ad-slider",collectionAccessor:"sliders"});iAd.Slider.DEFAULT_HEIGHT=23;iAd.Slider.TOUCHED_CSS="ad-touched";iAd.Slider.prototype.init=function(a){this.continuous=true;this._minimumValue=0;this._maximumValue=1;this._value=0;this.thumbSize=new iAd.Size(23,23);this.callSuper(a)}; |
iAd.Slider.prototype.layerWasCreated=function(){this.callSuper();this.fill=this.layer.appendChild(document.createElement("div"));this.fill.className="ad-slider-fill";this.leftFill=this.fill.appendChild(document.createElement("div"));this.middleFill=this.fill.appendChild(document.createElement("div"));this.rightFill=this.fill.appendChild(document.createElement("div"));this.thumb=this.layer.appendChild(document.createElement("div"));this.thumb.className="ad-slider-thumb";this._touchLayer=this.thumb}; |
iAd.Slider.prototype.setSize=function(a){a.height=iAd.Slider.DEFAULT_HEIGHT;this.callSuper(a)};iAd.Slider.prototype.setMinimumValue=function(a){if(!(a>=this.maximumValue)){this._minimumValue=a;if(this.value<a)this.value=a;else this.updateThumb()}};iAd.Slider.prototype.setMaximumValue=function(a){if(!(a<=this.minimumValue)){this._maximumValue=a;if(this.value>a)this.value=a;else this.updateThumb()}};iAd.Slider.prototype.setValue=function(a){this.setValueAnimated(a,false)}; |
iAd.Slider.prototype.setValueAnimated=function(a,b){a=Math.max(Math.min(a,this.maximumValue),this.minimumValue);if(a!=this._value){var c=b?"0.25s":"0s";this.thumb.style.webkitTransitionDuration=c;this.middleFill.style.webkitTransitionDuration=c;this.rightFill.style.webkitTransitionDuration=c;this._value=a;this.updateThumb();this.continuous&&this.notifyValueChanged()}}; |
iAd.Slider.prototype.updateThumb=function(){var a=(this.value-this.minimumValue)/(this.maximumValue-this.minimumValue),b=a*(this.size.width+2-this.thumbSize.width);this.updateGutterWithOffset(a);this.thumb.style.webkitTransform=iAd.Utils.t(b,0)};iAd.Slider.prototype.updateGutterWithOffset=function(a){a=a*(this.size.width-16);this.middleFill.style.webkitTransform="scale("+(a+1)+", 1)";this.rightFill.style.webkitTransform=iAd.Utils.t(a,0)};iAd.Slider.prototype.notifyValueChanged=function(){this.dispatchEvent(this.createEvent(iAd.Control.VALUE_CHANGE_EVENT))}; |
iAd.Slider.prototype.touchesBegan=function(a){this.callSuper(a);var b=window.getComputedStyle(this.thumb);this.thumbSize=new iAd.Size(parseInt(b.width,10),parseInt(b.height,10));this.maxX=this.size.width-this.thumbSize.width;this.internalX=iAd.Point.fromEventInElement(a,this.touchLayer).x;this.startValue=this.value;this.valueRange=this.maximumValue-this.minimumValue;this.thumb.addClassName(iAd.Slider.TOUCHED_CSS)}; |
iAd.Slider.prototype.touchesMoved=function(a){this.callSuper(a);this.value=this.minimumValue+(iAd.Point.fromEventInElement(a,this.layer).x-this.internalX)/this.maxX*this.valueRange};iAd.Slider.prototype.touchesEnded=function(a){this.callSuper(a);!this.continuous&&this.startValue!=this.value&&this.notifyValueChanged();this.thumb.removeClassName(iAd.Slider.TOUCHED_CSS)};iAd.Slider.prototype.touchesCancelled=function(a){this.callSuper(a);this.setValue(this.startValue,true);this.thumb.removeClassName(iAd.Slider.TOUCHED_CSS)}; |
iAd.Class({name:"iAd.TabBarItemView",superclass:iAd.Control,synthesizedProperties:["title","image","badgeValue"],cssClassName:"ad-tab-bar-item"});iAd.TabBarItemView.HEIGHT=44;iAd.TabBarItemView.prototype.init=function(a){if(!iAd.TabBarItemView.selectedMaskImage)iAd.TabBarItemView.selectedMaskImage=new iAd.Image(iAd.Utils.assetsPath+"tab-bar-blue-gradient-mask.png",true);this._image=this._title="";this._badgeValue=0;this.callSuper(a)}; |
iAd.TabBarItemView.prototype.layerWasCreated=function(){this.callSuper();this.canvasContainer=this.layer.appendChild(document.createElement("div"));this.defaultCanvas=this.canvasContainer.appendChild(document.createElement("canvas"));this.selectedCanvas=this.canvasContainer.appendChild(document.createElement("canvas"));this.canvasContainer.className="ad-image";this.label=this.layer.appendChild(document.createElement("div"));this.label.className="ad-title";this.badge=this.layer.appendChild(document.createElement("div")); |
this.badge.className="ad-badge";this.badgeContent=this.badge.appendChild(document.createElement("span"))};iAd.TabBarItemView.prototype.setValueForAttribute=function(a,b){if(b=="ad-image")this.image=new iAd.Image(a);else this.callSuper(a,b)};iAd.TabBarItemView.prototype.setSize=function(a){this.callSuper(a);this.badgeContent.style.maxWidth=iAd.Utils.px(this.size.width-12);this.updateBadgePosition();this.updateImagePosition()}; |
iAd.TabBarItemView.prototype.didMoveToSuperview=function(){this.callSuper();this.callMethodNameAfterDelay("updateBadgePosition",0)};iAd.TabBarItemView.prototype.setTitle=function(a){this._title=this.label.textContent=a};iAd.TabBarItemView.prototype.setImage=function(a){this._image=a;a.loaded?this.updateCanvasImages():a.addPropertyObserver("loaded",this,"updateCanvasImages")}; |
iAd.TabBarItemView.prototype.setBadgeValue=function(a){this._badgeValue=a;if(a>0){this.badge.style.display="block";this.badgeContent.textContent=a;this.updateBadgePosition()}else this.badge.style.display="none"};iAd.TabBarItemView.prototype.updateBadgePosition=function(){if(this.superview!=null)if(this.badge.offsetWidth<this.size.width/2)this.badge.style.left=iAd.Utils.px(Math.round(this.size.width/2));else this.badge.style.right=iAd.Utils.px(-4)}; |
iAd.TabBarItemView.prototype.updateImagePosition=function(){this.canvasContainer.style.left=iAd.Utils.px((this._size.width-iAd.TabBarItemView.selectedMaskImage.width)/2-3)};iAd.TabBarItemView.prototype.updateCanvasImages=function(){if(!(this._image===null||!this._image.loaded)){this.drawImage(this.defaultCanvas,false);this.drawImage(this.selectedCanvas,true)}}; |
iAd.TabBarItemView.prototype.drawImage=function(a,b){var c=iAd.TabBarItemView.selectedMaskImage,d=c.element.width,e=c.element.height;a.width=d;a.height=e;var f=a.getContext("2d");f.clearRect(0,0,d,e);f.globalCompositeOperation="source-over";f.drawImage(this._image.element,(d-this._image.element.width)/2,(e-this._image.element.height)/2);f.globalCompositeOperation="source-in";if(b)f.drawImage(c.element,0,0);else{c=f.createLinearGradient(0,0,0,e);c.addColorStop(0,"rgb(69%, 69%, 69%)");c.addColorStop(1, |
"rgb(31%, 31%, 31%)");f.fillStyle=c;f.fillRect(0,0,d,e)}};iAd.Class({name:"iAd.TabBarItem",superclass:iAd.BarItem,synthesizedProperties:["badgeValue"]});iAd.TabBarItem.prototype.init=function(a){this.callSuper();this.view=a||new iAd.TabBarItemView(null);this.view.tabBarItem=this};iAd.TabBarItem.initWithTitleImageAndTag=function(a,b,c){var d=new iAd.TabBarItem;d.title=a;d.image=b;d.tag=c;return d};iAd.TabBarItem.prototype.getTitle=function(){return this.view.title}; |
iAd.TabBarItem.prototype.setTitle=function(a){this.view.title=a};iAd.TabBarItem.prototype.getImage=function(){return this.view.image};iAd.TabBarItem.prototype.setImage=function(a){this.view.image=a};iAd.TabBarItem.prototype.getBadgeValue=function(){return this.view.badgeValue};iAd.TabBarItem.prototype.setBadgeValue=function(a){this.view.badgeValue=a};iAd.TabBarItem.prototype.getEnabled=function(){return this.view.enabled};iAd.TabBarItem.prototype.setEnabled=function(a){this.view.enabled=a}; |
iAd.Class({name:"iAd.RatingControl",superclass:iAd.Control,synthesizedProperties:["width","value"],cssClassName:"ad-rating-control",collectionAccessor:"ratingControls"});iAd.RatingControl.STAR_HEIGHT=21;iAd.RatingControl.STAR_WIDTH=21;iAd.RatingControl.MIN_VALUE=0;iAd.RatingControl.MAX_VALUE=5;iAd.RatingControl.MIN_MARGIN=10;iAd.RatingControl.FILLED_CSS="ad-filled"; |
iAd.RatingControl.prototype.init=function(a){this.margin=iAd.RatingControl.MIN_MARGIN;this.numStars=iAd.RatingControl.MAX_VALUE-iAd.RatingControl.MIN_VALUE;this.minWidth=this.numStars*iAd.RatingControl.STAR_WIDTH+(this.numStars-1)*iAd.RatingControl.MIN_MARGIN;this.stars=[];this._value=0;this.callSuper(a);this.size=new iAd.Size};iAd.RatingControl.prototype.layerWasCreated=function(){this.callSuper();for(var a=0;a<this.numStars;a++)this.stars.push(this.layer.appendChild(document.createElement("div")))}; |
iAd.RatingControl.prototype.setSize=function(a){a.width=Math.max(this.minWidth,a.width);a.height=iAd.RatingControl.STAR_HEIGHT;this.callSuper(a);this.margin=(this.size.width-this.numStars*iAd.RatingControl.STAR_WIDTH)/(this.numStars-1);for(a=0;a<this.numStars-1;a++)this.stars[a].style.marginRight=iAd.Utils.px(this.margin)};iAd.RatingControl.prototype.getWidth=function(){return this.size.width};iAd.RatingControl.prototype.setWidth=function(a){this.size=new iAd.Size(a,0)}; |
iAd.RatingControl.prototype.setValue=function(a){a=Math.max(Math.min(a,iAd.RatingControl.MAX_VALUE),iAd.RatingControl.MIN_VALUE);if(a!=this._value){this._value=a;for(var b=0;b<this.numStars;b++)this.stars[b].className=b>=a-iAd.RatingControl.MIN_VALUE?"":iAd.RatingControl.FILLED_CSS;this.dispatchEvent(this.createEvent(iAd.Control.VALUE_CHANGE_EVENT))}};iAd.RatingControl.prototype.touchesBegan=function(a){this.callSuper(a);this.startX=iAd.Point.fromEventInElement(a,this.layer).x;this.startValue=this.value}; |
iAd.RatingControl.prototype.touchesMoved=function(a){this.callSuper(a);this.setValueFromX(iAd.Point.fromEventInElement(a,this.layer).x)};iAd.RatingControl.prototype.touchesEnded=function(a){this.tracking||this.setValueFromX(this.startX);this.callSuper(a)};iAd.RatingControl.prototype.touchesCancelled=function(a){this.callSuper(a);this.value=this.startValue}; |
iAd.RatingControl.prototype.setValueFromX=function(a){this.value=Math.floor((a+iAd.RatingControl.STAR_WIDTH+this.margin+this.margin/2)/(iAd.RatingControl.STAR_WIDTH+this.margin))};iAd.Class({name:"iAd.PageControl",superclass:iAd.Control,synthesizedProperties:["currentPage","numberOfPages","hidesForSinglePage"],cssClassName:"ad-page-control",collectionAccessor:"pageControls"});iAd.PageControl.DEFAULT_SIZE=6;iAd.PageControl.MARGIN=10;iAd.PageControl.SELECTED_CSS="ad-selected"; |
iAd.PageControl.prototype.init=function(a){this.dots=[];this.defersCurrentPageDisplay=false;this._numberOfPages=this._currentPage=0;this._hidesForSinglePage=false;this.callSuper(a);this.layer.addEventListener(iAd.Control.TOUCH_UP_INSIDE_EVENT,this,false)};iAd.PageControl.prototype.setSize=function(a){a.width=Math.max(a.width,iAd.PageControl.DEFAULT_SIZE);a.height=Math.max(a.height,iAd.PageControl.DEFAULT_SIZE);this.callSuper(a);this.updateLayout()}; |
iAd.PageControl.prototype.setCurrentPage=function(a){if(!(this._currentPage==a||a<0||a>=this.numberOfPages)){this._currentPage=a;this.defersCurrentPageDisplay||this.updateCurrentPageDisplay();this.dispatchEvent(this.createEvent(iAd.Control.VALUE_CHANGE_EVENT))}}; |
iAd.PageControl.prototype.setNumberOfPages=function(a){if(!(this._numberOfPages==a||a<0)){if(this.dots.length>a)for(;this.dots.length>a;)this.layer.removeChild(this.dots.pop());else for(;this.dots.length<a;)this.dots.push(this.layer.appendChild(document.createElement("div")));this._numberOfPages=a;this.updateCurrentPageDisplay();this.updateLayout();this.updateVisibility()}};iAd.PageControl.prototype.setHidesForSinglePage=function(a){this._hidesForSinglePage=a;this.updateVisibility()}; |
iAd.PageControl.prototype.updateCurrentPageDisplay=function(){var a=this.layer.querySelector("."+iAd.PageControl.SELECTED_CSS);a&&a.removeClassName(iAd.PageControl.SELECTED_CSS);this.currentPage>=0&&this.currentPage<this.dots.length&&this.dots[this.currentPage].addClassName(iAd.PageControl.SELECTED_CSS)};iAd.PageControl.prototype.sizeForNumberOfPages=function(a){return a*(iAd.PageControl.DEFAULT_SIZE+iAd.PageControl.MARGIN)}; |
iAd.PageControl.prototype.updateLayout=function(){this.setLayerStyle({"padding-left":iAd.Utils.px((this.size.width-this.sizeForNumberOfPages(this._numberOfPages))/2),"padding-top":iAd.Utils.px((this.size.height-iAd.PageControl.DEFAULT_SIZE)/2)})};iAd.PageControl.prototype.updateVisibility=function(){this.setLayerStyle({visibility:this.numberOfPages==1&&this.hidesForSinglePage?"hidden":"visible"})}; |
iAd.PageControl.prototype.handleEvent=function(a){this.callSuper(a);if(a.type==iAd.Control.TOUCH_UP_INSIDE_EVENT)if(!(this.numberOfPages<=1)){a=iAd.Point.fromEventInElement(a,this.layer).x;var b=this.dots[this.currentPage].offsetLeft;if(a<=b-iAd.PageControl.MARGIN/2)this.currentPage--;else a>=b+iAd.PageControl.DEFAULT_SIZE+iAd.PageControl.MARGIN/2&&this.currentPage++}}; |
iAd.Class({name:"iAd.SegmentedControl",superclass:iAd.Control,synthesizedProperties:["width","segmentedControlStyle","numberOfSegments","selectedSegmentIndex","momentary"],cssClassName:"ad-segmented-control",collectionAccessor:"segmentedControls"});iAd.SegmentedControl.cachedCanvasBackgroundImages=[];iAd.SegmentedControl.NO_SEGMENT=-1;iAd.SegmentedControl.STYLE_PLAIN="ad-plain";iAd.SegmentedControl.STYLE_BORDERED="ad-bordered";iAd.SegmentedControl.STYLE_BAR="ad-bar"; |
iAd.SegmentedControl.STYLE_BAR_BLACK="ad-bar-black";iAd.SegmentedControl.SEGMENT_SELECTED_CSS="ad-selected";iAd.SegmentedControl.SEGMENT_MOMENTARY_SELECTION_TIMER=200;iAd.SegmentedControl.prototype.init=function(a,b){this._width=0;this._segmentedControlStyle="";this._numberOfSegments=0;this._selectedSegmentIndex=iAd.SegmentedControl.NO_SEGMENT;this._momentary=false;this.canvasBackgroundImage=null;this.callSuper(a);!iAd.Utils.objectIsUndefined(b)&&iAd.Utils.objectIsArray(b)&&this.populateWithItems(b)}; |
iAd.SegmentedControl.prototype.createLayer=function(){this.callSuper();this.segmentedControlStyle=iAd.SegmentedControl.STYLE_PLAIN}; |
iAd.SegmentedControl.prototype.readPropertiesFromLayerComputedStyle=function(a){this.callSuper(a);if(this.layer.hasClassName(iAd.SegmentedControl.STYLE_BORDERED))this._segmentedControlStyle=iAd.SegmentedControl.STYLE_BORDERED;else if(this.layer.hasClassName(iAd.SegmentedControl.STYLE_BAR))this._segmentedControlStyle=iAd.SegmentedControl.STYLE_BAR;else this.segmentedControlStyle=iAd.SegmentedControl.STYLE_PLAIN;this.updateCanvasBackgroundImage()}; |
iAd.SegmentedControl.prototype.setSize=function(a){a.height=this._segmentedControlStyle==iAd.SegmentedControl.STYLE_BAR||this._segmentedControlStyle==iAd.SegmentedControl.STYLE_BAR_BLACK?30:44;this.callSuper(a);this.updateLayout()};iAd.SegmentedControl.prototype.layerWasInsertedIntoDocument=function(){this.updateLayout()}; |
iAd.SegmentedControl.prototype.didAddSubview=function(a){this.updateLayout();this._selectedSegmentIndex!=iAd.SegmentedControl.NO_SEGMENT&&a._indexInSuperviewSubviews<=this._selectedSegmentIndex&&this.selectedSegmentIndex++};iAd.SegmentedControl.prototype.willMoveToSuperview=function(a){if(a instanceof iAd.Toolbar)this.segmentedControlStyle=a.barStyle===iAd.Toolbar.STYLE_DEFAULT?iAd.SegmentedControl.STYLE_BAR:iAd.SegmentedControl.STYLE_BAR_BLACK};iAd.SegmentedControl.prototype.getWidth=function(){return this.size.width}; |
iAd.SegmentedControl.prototype.setWidth=function(a){this.size=new iAd.Size(a,0)};iAd.SegmentedControl.prototype.setSegmentedControlStyle=function(a){this.layer.removeClassName(this._segmentedControlStyle);this.layer.addClassName(a);this._segmentedControlStyle=a;this.updateCanvasBackgroundImage();this.width=this.width;this.updateAllSegmentBackgrounds()};iAd.SegmentedControl.prototype.getNumberOfSegments=function(){return this.subviews.length}; |
iAd.SegmentedControl.prototype.setSelectedSegmentIndex=function(a){if(!(a<-1||a>=this.subviews.length||a==this._selectedSegmentIndex)){if(this._selectedSegmentIndex!=iAd.SegmentedControl.NO_SEGMENT&&this._selectedSegmentIndex>=0&&this._selectedSegmentIndex<this.subviews.length){var b=this.subviews[this._selectedSegmentIndex];b.layer.removeClassName(iAd.SegmentedControl.SEGMENT_SELECTED_CSS);b.drawBackgroundCanvas(this._selectedSegmentIndex,this.subviews.length,false)}if(a!=iAd.SegmentedControl.NO_SEGMENT){b= |
this.subviews[a];b.layer.addClassName(iAd.SegmentedControl.SEGMENT_SELECTED_CSS);b.drawBackgroundCanvas(a,this.subviews.length,true)}this._selectedSegmentIndex=a;if(!this._momentary||a!=iAd.SegmentedControl.NO_SEGMENT)this.dispatchEvent(this.createEvent(iAd.Control.VALUE_CHANGE_EVENT))}};iAd.SegmentedControl.prototype.setMomentary=function(a){if(this._momentary!=a){this._momentary=a;this.selectedSegmentIndex=iAd.SegmentedControl.NO_SEGMENT}}; |
iAd.SegmentedControl.prototype.updateCanvasBackgroundImage=function(){var a=iAd.HAS_HIDPI_DISPLAY?"HiDPI":"LoDPI";if(iAd.IS_IPAD&&this._segmentedControlStyle===iAd.SegmentedControl.STYLE_BAR)a="iPad";a=iAd.Utils.assetsPath+a+"/segmented-control-"+this._segmentedControlStyle.substr(3)+".png";if(!(this.canvasBackgroundImage!==null&&a==this.canvasBackgroundImage.url)){for(var b=iAd.SegmentedControl.cachedCanvasBackgroundImages,c=null,d,e=0;e<b.length;e++){d=b[e];if(d.url==a){c=d;break}}if(c!==null)this.canvasBackgroundImage= |
c;else{this.canvasBackgroundImage=new iAd.Image(a,false);this.canvasBackgroundImage.loaded||this.canvasBackgroundImage.addPropertyObserver("loaded",this,"canvasBackgroundImageDidLoad")}}};iAd.SegmentedControl.prototype.canvasBackgroundImageDidLoad=function(a){var b=iAd.SegmentedControl.cachedCanvasBackgroundImages;b.indexOf(a)==-1&&b.push(a);a===this.canvasBackgroundImage&&this.updateAllSegmentBackgrounds()}; |
iAd.SegmentedControl.prototype.populateWithItems=function(a){for(var b=0;b<a.length;b++){var c=a[b];if(c instanceof iAd.Image)this.insertSegmentWithImageAtIndexAnimated(c,this.numberOfSegments,false);else iAd.Utils.objectIsString(c)&&this.insertSegmentWithTitleAtIndexAnimated(c,this.numberOfSegments,false)}this.updateLayout()}; |
iAd.SegmentedControl.prototype.updateLayout=function(){if(!(this.size.width<=0)){for(var a=0,b=0,c=0;c<this.subviews.length;c++){var d=this.subviews[c];if(d.width>0)a+=d.width;else b++}a=Math.round(b>0?(this.size.width-a)/b:0);b=this._segmentedControlStyle==iAd.SegmentedControl.STYLE_BAR||this._segmentedControlStyle==iAd.SegmentedControl.STYLE_BAR_BLACK?6:10;var e=-b;for(c=0;c<this.subviews.length;c++){d=this.subviews[c];var f=d.width==0?a:d.width;d.setLayerStyle({left:iAd.Utils.px(e)});if(c==this.subviews.length- |
1)f=this.size.width-e-b;this.setActualWidthForSegmentAtIndex(f,c);e+=f;d.drawBackgroundCanvas(c,this.subviews.length,c==this._selectedSegmentIndex)}}};iAd.SegmentedControl.prototype.updateAllSegmentBackgrounds=function(){for(var a=this.subviews,b=0;b<a.length;b++)a[b].drawBackgroundCanvas(b,a.length,b==this._selectedSegmentIndex)};iAd.SegmentedControl.prototype.setImageForSegmentAtIndex=function(a,b){b=Math.max(Math.min(b,this.subviews.length-1),0);this.subviews[b].image=a}; |
iAd.SegmentedControl.prototype.imageForSegmentAtIndex=function(a){a=Math.min(a,this.subviews.length-1);return a>=0?this.subviews[a].image:null};iAd.SegmentedControl.prototype.setTitleForSegmentAtIndex=function(a,b){b=Math.max(Math.min(b,this.subviews.length-1),0);this.subviews[b].title=a};iAd.SegmentedControl.prototype.titleForSegmentAtIndex=function(a){a=Math.min(a,this.subviews.length-1);return a>=0?this.subviews[a].title:null}; |
iAd.SegmentedControl.prototype.insertSegmentWithImageAtIndexAnimated=function(a,b){b=Math.max(Math.min(b,this.subviews.length),0);var c=new iAd.Segment;this.insertSubviewAtIndex(c,b);this.setImageForSegmentAtIndex(a,b);c.drawBackgroundCanvas(b,this.subviews.length,false)}; |
iAd.SegmentedControl.prototype.insertSegmentWithTitleAtIndexAnimated=function(a,b){b=Math.max(Math.min(b,this.subviews.length),0);var c=new iAd.Segment;this.insertSubviewAtIndex(c,b);this.setTitleForSegmentAtIndex(a,b);c.drawBackgroundCanvas(b,this.subviews.length,false)}; |
iAd.SegmentedControl.prototype.removeSegmentAtIndexAnimated=function(a){a=Math.max(Math.min(a,this.subviews.length-1),0);if(!(a>=this.subviews.length)){this.subviews[a].removeFromSuperview();this.updateLayout();if(this._selectedSegmentIndex!=iAd.SegmentedControl.NO_SEGMENT)if(a<this._selectedSegmentIndex)this.selectedSegmentIndex--;else if(a==this._selectedSegmentIndex)this.selectedSegmentIndex=iAd.SegmentedControl.NO_SEGMENT}};iAd.SegmentedControl.prototype.removeAllSegments=function(){for(;this.subviews.length;)this.subviews[0].removeFromSuperview()}; |
iAd.SegmentedControl.prototype.setWidthForSegmentAtIndex=function(a,b){b=Math.max(Math.min(b,this.subviews.length-1),0);this.subviews[b].width=a;this.setActualWidthForSegmentAtIndex(a,b);this.updateLayout()};iAd.SegmentedControl.prototype.widthForSegmentAtIndex=function(a){a=Math.max(Math.min(a,this.subviews.length-1),0);return this.subviews[a].width}; |
iAd.SegmentedControl.prototype.setActualWidthForSegmentAtIndex=function(a,b){b=Math.max(Math.min(b,this.subviews.length-1),0);this.subviews[b].size=new iAd.Size(a,this.size.height)};iAd.SegmentedControl.prototype.touchesBegan=function(a){this.callSuper(a);this.selectedSegmentIndex=a.target.getNearestView()._indexInSuperviewSubviews;if(this._momentary){var b=this;setTimeout(function(){b.selectedSegmentIndex=iAd.SegmentedControl.NO_SEGMENT},iAd.SegmentedControl.SEGMENT_MOMENTARY_SELECTION_TIMER)}}; |
iAd.Class({name:"iAd.Segment",superclass:iAd.View,synthesizedProperties:["title","image"],cssClassName:"ad-segment"});iAd.Segment.canvasInstances=0;iAd.Segment.prototype.init=function(a){this._title="";this._image=null;this.callSuper(a);if(this.usesDeclarativeBacking)this.width=this._size.width};iAd.Segment.prototype.createLayer=function(){this.callSuper();this.width=0}; |
iAd.Segment.prototype.layerWasCreated=function(){this.callSuper();this.label=this.layer.appendChild(document.createElement("span"));this.icon=this.layer.appendChild(document.createElement("img"));this.backgroundCanvasId="ad-segment-"+iAd.Segment.canvasInstances++;this.setLayerStyle({"background-image":"-webkit-canvas("+this.backgroundCanvasId+")"})};iAd.Segment.prototype.setValueForAttribute=function(a,b){if(b=="ad-image")this.image=new iAd.Image(a);else this.callSuper(a,b)}; |
iAd.Segment.prototype.setSize=function(a){this.callSuper(a);this._image!==null&&this.positionImage()};iAd.Segment.prototype.setTitle=function(a){this._title=this.label.textContent=a};iAd.Segment.prototype.setImage=function(a){this.icon.src=a.resolvedURL;this._image=a;a.loaded?this.positionImage():a.addPropertyObserver("loaded",this)};iAd.Segment.prototype.handlePropertyChange=function(){this.positionImage()}; |
iAd.Segment.prototype.positionImage=function(){this.icon.style.left=iAd.Utils.px((this.size.width-this._image.width)/2);this.icon.style.top=iAd.Utils.px((this.size.height-this._image.height)/2)}; |
iAd.Segment.prototype.drawBackgroundCanvas=function(a,b,c){var d=this.superview.canvasBackgroundImage;if(!(d===null||!d.loaded)){d=d.element;var e=iAd.HAS_HIDPI_DISPLAY?2:1,f=this.size.width*e,g=this.size.height*e,i=this.superview.segmentedControlStyle;i=i==iAd.SegmentedControl.STYLE_BAR||i==iAd.SegmentedControl.STYLE_BAR_BLACK;var h=document.getCSSCanvasContext("2d",this.backgroundCanvasId,f,g);this.setLayerStyle({"background-size":this.size.width+"px "+this.size.height+"px"});h.clearRect(0,0,f, |
g);if(b==1){if(c)if(i){h.drawImage(d,0,0,6*e,g,0,0,6*e,g);h.drawImage(d,5*e,0,1*e,g,6*e,0,f-12*e,g);h.drawImage(d,6*e,0,6*e,g,f-6*e,0,6*e,g)}else{h.drawImage(d,0,0,11*e,g,0,0,11*e,g);h.drawImage(d,27*e,0,1*e,g,11*e,0,f-22*e,g);h.drawImage(d,11*e,0,11*e,g,f-11*e,0,11*e,g)}}else if(a==0)if(i){if(c){h.drawImage(d,0,0,6*e,g,0,0,6*e,g);h.drawImage(d,5*e,0,1*e,g,6*e,0,f-6*e,g)}h.drawImage(d,12*e,0,1*e,g,f-1*e,0,1*e,g)}else{if(c){h.drawImage(d,0,0,11*e,g,0,0,11*e,g);h.drawImage(d,27*e,0,1*e,g,11*e,0,f-18* |
e,g);h.drawImage(d,28*e,0,6*e,g,f-7*e,0,6*e,g)}h.drawImage(d,34*e,0,1*e,g,f-1*e,0,1*e,g)}else if(a==b-1){if(c)if(i){h.drawImage(d,5*e,0,1*e,g,0,0,f-6*e,g);h.drawImage(d,6*e,0,6*e,g,f-6*e,0,6*e,g)}else{h.drawImage(d,22*e,0,6*e,g,0,0,6*e,g);h.drawImage(d,27*e,0,1*e,g,6*e,0,f-17*e,g);h.drawImage(d,11*e,0,11*e,g,f-11*e,0,11*e,g)}}else if(i){c&&h.drawImage(d,5*e,0,1*e,g,0,0,f,g);h.drawImage(d,12*e,0,1*e,g,f-1*e,0,1*e,g)}else{if(c){h.drawImage(d,22*e,0,6*e,g,0,0,6*e,g);h.drawImage(d,27*e,0,1*e,g,6*e,0, |
f-13*e,g);h.drawImage(d,28*e,0,6*e,g,f-7*e,0,6*e,g)}h.drawImage(d,34*e,0,1*e,g,f-1*e,0,1*e,g)}}};iAd.Class({name:"iAd.Switch",superclass:iAd.Control,synthesizedProperties:["on"],cssClassName:"ad-switch",collectionAccessor:"switches"});iAd.Switch.DOWN_CSS="ad-dragging";iAd.Switch.SNAP_CSS="ad-snap";iAd.Switch.WIDTH=93;iAd.Switch.HEIGHT=27;iAd.Switch.DRAG_IDLE=0;iAd.Switch.CAN_DRAG=1;iAd.Switch.IS_DRAGGING=2;iAd.Switch.SLIDE_DISTANCE=54;iAd.Switch.BUTTON_WIDTH=40;iAd.Switch.DRAG_MAX=70; |
iAd.Switch.DRAG_MIN=16;iAd.Switch.DRAG_GUTTER=5;iAd.Switch.CAP_WIDTH=4;iAd.Switch.LEFT_CAP_TRACK_CSS="ad-left-cap ad-track-cap";iAd.Switch.LEFT_CAP_BUTTON_CSS="ad-left-cap ad-button-cap";iAd.Switch.RIGHT_CAP_TRACK_CSS="ad-right-cap ad-track-cap";iAd.Switch.RIGHT_CAP_BUTTON_CSS="ad-right-cap ad-button-cap"; |
iAd.Switch.prototype.init=function(a){this._on=false;this.callSuper(a);this.dragOffsetX=iAd.Switch.DRAG_MAX;if(!this.usesDeclarativeBacking)this.size=new iAd.Size(iAd.Switch.WIDTH,iAd.Switch.HEIGHT);this.on=this._on}; |
iAd.Switch.prototype.layerWasCreated=function(){this.callSuper();this.leftCap=this.layer.appendChild(document.createElement("div"));this.leftCap.className=iAd.Switch.LEFT_CAP_TRACK_CSS;this.rightCap=this.layer.appendChild(document.createElement("div"));this.rightCap.className=iAd.Switch.RIGHT_CAP_BUTTON_CSS;this.slideContainer=this.layer.appendChild(document.createElement("div"));this.slideContainer.className="ad-slide-container";this.slider=this.slideContainer.appendChild(document.createElement("div")); |
this.slider.className="ad-switch-slider";this.slider.addEventListener("webkitTransitionEnd",this,false);this.button=this.slider.appendChild(document.createElement("div"));this.button.className="ad-switch-button";this.slider.appendChild(document.createElement("div")).className="ad-label-off";this.slider.appendChild(document.createElement("div")).className="ad-label-on"};iAd.Switch.prototype.setSize=function(a){a.width=iAd.Switch.WIDTH;a.height=iAd.Switch.HEIGHT;this.callSuper(a)}; |
iAd.Switch.prototype.setOnAnimated=function(a,b){if(b){if(!(a&&this.dragOffsetX==iAd.Switch.DRAG_MAX||!a&&this.dragOffsetX==iAd.Switch.DRAG_MIN)){this.leftCap.className=iAd.Switch.LEFT_CAP_TRACK_CSS;this.rightCap.className=iAd.Switch.RIGHT_CAP_TRACK_CSS}this.slider.addClassName(iAd.Switch.SNAP_CSS)}else{if(a){this.leftCap.className=iAd.Switch.LEFT_CAP_TRACK_CSS;this.rightCap.className=iAd.Switch.RIGHT_CAP_BUTTON_CSS}else{this.leftCap.className=iAd.Switch.LEFT_CAP_BUTTON_CSS;this.rightCap.className= |
iAd.Switch.RIGHT_CAP_TRACK_CSS}this.slider.removeClassName(iAd.Switch.SNAP_CSS)}if(a){this.slider.style.webkitTransform=iAd.Utils.t(-iAd.Switch.CAP_WIDTH,0);this.dragOffsetX=iAd.Switch.DRAG_MAX}else{this.slider.style.webkitTransform=iAd.Utils.t(-iAd.Switch.SLIDE_DISTANCE-iAd.Switch.CAP_WIDTH,0);this.dragOffsetX=iAd.Switch.DRAG_MIN}this._on=a;this.dispatchEvent(this.createEvent(iAd.Control.VALUE_CHANGE_EVENT))};iAd.Switch.prototype.setOn=function(a){this.setOnAnimated(a,false)}; |
iAd.Switch.prototype.handleEvent=function(a){this.callSuper(a);a.type=="webkitTransitionEnd"&&this.transitionEnded()};iAd.Switch.prototype.transitionEnded=function(){this.slider.removeClassName(iAd.Switch.SNAP_CSS);if(this._on){this.slider.style.webkitTransform=iAd.Utils.t(-iAd.Switch.CAP_WIDTH,0);this.rightCap.className=iAd.Switch.RIGHT_CAP_BUTTON_CSS}else{this.slider.style.webkitTransform=iAd.Utils.t(-iAd.Switch.SLIDE_DISTANCE-iAd.Switch.CAP_WIDTH,0);this.leftCap.className=iAd.Switch.LEFT_CAP_BUTTON_CSS}}; |
iAd.Switch.prototype.touchesBegan=function(a){this.callSuper(a);a=iAd.Point.fromEventInElement(a,this.layer);if(!this._on&&a.x<iAd.Switch.BUTTON_WIDTH||this.on&&a.x>iAd.Switch.SLIDE_DISTANCE){this.layer.addClassName(iAd.Switch.DOWN_CSS);this.dragState=iAd.Switch.CAN_DRAG}}; |
iAd.Switch.prototype.touchesMoved=function(a){this.callSuper(a);if(this.dragState>=iAd.Switch.CAN_DRAG){this.slider.removeClassName(iAd.Switch.SNAP_CSS);this.dragState=iAd.Switch.IS_DRAGGING;this.rightCap.className=iAd.Switch.RIGHT_CAP_TRACK_CSS;this.leftCap.className=iAd.Switch.LEFT_CAP_TRACK_CSS;a=iAd.Point.fromEventInElement(a,this.layer);var b=iAd.Switch.BUTTON_WIDTH/2;this.dragOffsetX=a.x;if(this.dragOffsetX>iAd.Switch.DRAG_MAX-iAd.Switch.DRAG_GUTTER)if(this.dragOffsetX>=iAd.Switch.DRAG_MAX){this.dragOffsetX= |
iAd.Switch.DRAG_MAX;this.rightCap.className=iAd.Switch.RIGHT_CAP_BUTTON_CSS}else this.dragOffsetX=iAd.Switch.DRAG_MAX-iAd.Switch.DRAG_GUTTER;else if(this.dragOffsetX<iAd.Switch.DRAG_MIN+iAd.Switch.DRAG_GUTTER)if(this.dragOffsetX<iAd.Switch.DRAG_MIN){this.dragOffsetX=iAd.Switch.DRAG_MIN;this.leftCap.className=iAd.Switch.LEFT_CAP_BUTTON_CSS}else this.dragOffsetX=iAd.Switch.DRAG_MIN+iAd.Switch.DRAG_GUTTER;this.slider.style.webkitTransform=iAd.Utils.t(-iAd.Switch.SLIDE_DISTANCE-(b-this.dragOffsetX),0)}}; |
iAd.Switch.prototype.touchesEnded=function(a){this.callSuper(a);if(this.dragState===iAd.Switch.IS_DRAGGING)if(this.dragOffsetX<iAd.Switch.WIDTH/2)this.setOnAnimated(false,true);else this.dragOffsetX>iAd.Switch.WIDTH/2?this.setOnAnimated(true,true):this.setOnAnimated(this.on,true);else this.setOnAnimated(!this._on,true);this.layer.removeClassName(iAd.Switch.DOWN_CSS);this.dragState=iAd.Switch.DRAG_IDLE}; |
iAd.Class({name:"iAd.SearchBar",superclass:iAd.View,mixins:[iAd.EventTriage],synthesizedProperties:["barStyle","placeholder","text","showsCancelButton","editing","showsBookmarkButton"],cssClassName:"ad-search-bar",collectionAccessor:"searchBars"});iAd.SearchBar.DEFAULT_HEIGHT=44;iAd.SearchBar.STYLE_DEFAULT="ad-default";iAd.SearchBar.STYLE_BLACK="ad-black";iAd.SearchBar.STYLE_BLACK_TRANSLUCENT="ad-black-translucent";iAd.SearchBar.TEXT_DID_CHANGE="searchBarTextDidChange"; |
iAd.SearchBar.TEXT_DID_BEGIN_EDITING="searchBarTextDidBeginEditing";iAd.SearchBar.TEXT_DID_END_EDITING="searchBarTextDidEndEditing";iAd.SearchBar.CANCEL_BUTTON_CLICKED="searchBarCancelButtonClicked";iAd.SearchBar.BOOKMARK_BUTTON_CLICKED="searchBarBookmarkButtonClicked";iAd.SearchBar.SHOWS_CANCEL_BUTTON_CSS="ad-shows-cancel-button";iAd.SearchBar.DISPLAYS_PLACEHOLDER="ad-displays-placeholder";iAd.SearchBar.SHOWS_BOOKMARK_BUTTON_CSS="ad-shows-bookmark-button"; |
iAd.SearchBar.prototype.init=function(a){this.delegate=null;this._barStyle=iAd.SearchBar.STYLE_DEFAULT;this._text=this._placeholder="";this.hasBeenExplicitelySized=this._showsBookmarkButton=this._editing=this._showsCancelButton=false;this.callSuper(a);this.field.addEventListener("focus",this,false);this.field.addEventListener("blur",this,false);this.field.addEventListener("input",this,false);this.field.parentNode.addEventListener("submit",this,false);this.button.addEventListener(iAd.Control.TOUCH_UP_INSIDE_EVENT, |
this,false);this.emptyButton.addEventListener(iAd.Control.TOUCH_UP_INSIDE_EVENT,this,false);this.button.view.addPropertyObserver("size",this,"updateLayout");this.autoresizesSubviews=false};iAd.SearchBar.prototype.setupLayer=function(){this.callSuper();if(this.layer.hasClassName(iAd.SearchBar.STYLE_BLACK))this._barStyle=iAd.SearchBar.STYLE_BLACK;else if(this.layer.hasClassName(iAd.SearchBar.STYLE_BLACK_TRANSLUCENT))this._barStyle=iAd.SearchBar.STYLE_BLACK_TRANSLUCENT}; |
iAd.SearchBar.prototype.layerWasCreated=function(){this.callSuper();var a=this.layer.appendChild(document.createElement("form"));this.label=a.appendChild(document.createElement("div"));this.field=a.appendChild(document.createElement("input"));this.field.type="text";this.button=new iAd.BarButtonItem;this.button.title="Cancel";this.addSubview(this.button.view);this.emptyButton=this.addSubview(new iAd.Button(null,iAd.Button.TYPE_CUSTOM))}; |
iAd.SearchBar.prototype.setSize=function(a){a.height=iAd.SearchBar.DEFAULT_HEIGHT;this.callSuper(a);this.hasBeenExplicitelySized=true;this.updateLayout()};iAd.SearchBar.prototype.updateLayout=function(){var a=this.showsCancelButton?this.button.view.size.width+5:0;this.field.parentNode.style.right=iAd.Utils.px(a+5);this.emptyButton.layer.style.right=iAd.Utils.px(a+10)}; |
iAd.SearchBar.prototype.didMoveToSuperview=function(){this.callSuper();if(!(this.hasBeenExplicitelySized||this.superview===null||this.usesDeclarativeBacking)){this.size=new iAd.Size(this.superview.size.width,iAd.SearchBar.DEFAULT_HEIGHT);this.hasBeenExplicitelySized=false}};iAd.SearchBar.prototype.setBarStyle=function(a){this.layer.removeClassName(this._barStyle);this.layer.addClassName(a);this._barStyle=a};iAd.SearchBar.prototype.setPlaceholder=function(a){this._placeholder=a;this.checkForPlaceholderDisplay()}; |
iAd.SearchBar.prototype.getText=function(){return this.field.value};iAd.SearchBar.prototype.setText=function(a){this.label.innerText=a;this.field.value=a;this.dispatchNotification(iAd.SearchBar.TEXT_DID_CHANGE,this.delegate,["searchText",a]);this.checkForPlaceholderDisplay()};iAd.SearchBar.prototype.setShowsCancelButton=function(a){if(this._showsCancelButton!=a){this.layer.toggleClassName(iAd.SearchBar.SHOWS_CANCEL_BUTTON_CSS,a);this._showsCancelButton=a;this.updateLayout()}}; |
iAd.SearchBar.prototype.setShowsBookmarkButton=function(a){if(this._showsBookmarkButton!=a){this._showsBookmarkButton=a;this.checkForPlaceholderDisplay()}};iAd.SearchBar.prototype.checkForPlaceholderDisplay=function(){var a=this.text=="";this.layer.toggleClassName(iAd.SearchBar.DISPLAYS_PLACEHOLDER,a);a&&this._showsBookmarkButton&&this.layer.toggleClassName(iAd.SearchBar.SHOWS_BOOKMARK_BUTTON_CSS,this.text=="");if(a)this.label.innerText=this._placeholder}; |
iAd.SearchBar.prototype.setEditing=function(a){this._editing=a;this.field[a?"focus":"blur"]()};iAd.SearchBar.prototype.handleFocus=function(){this.dispatchNotification(iAd.SearchBar.TEXT_DID_BEGIN_EDITING,this.delegate);this.editing=true};iAd.SearchBar.prototype.handleBlur=function(){this.dispatchNotification(iAd.SearchBar.TEXT_DID_END_EDITING,this.delegate);this.label.innerText=this.field.value;this.checkForPlaceholderDisplay();this.editing=false}; |
iAd.SearchBar.prototype.handleInput=function(){this.checkForPlaceholderDisplay();this.dispatchNotification(iAd.SearchBar.TEXT_DID_CHANGE,this.delegate,["searchText",this.field.value])};iAd.SearchBar.prototype.handleSubmit=function(a){a.preventDefault();this.editing=false}; |
iAd.SearchBar.prototype.handleControlTouchUpInside=function(a){if(a.ad.sender===this.emptyButton)if(this.text=="")this.dispatchNotification(iAd.SearchBar.BOOKMARK_BUTTON_CLICKED,this.delegate);else{this.text="";this.checkForPlaceholderDisplay()}else this.dispatchNotification(iAd.SearchBar.CANCEL_BUTTON_CLICKED,this.delegate)};iAd.Class({name:"iAd.PickerComponent",superclass:iAd.ScrollView}); |
iAd.PickerComponent.prototype.init=function(a,b){this.callSuper();this.delegate=this;this.index=a;this.rows=b;this.showsVerticalScrollIndicator=this.horizontalScrollEnabled=this.clipsToBounds=false};iAd.PickerComponent.prototype.getSelectedRow=function(){return this._selectedRow=Math.min(Math.max(Math.round((this.contentOffset.y+iAd.PickerView.COMPONENT_TOP_MARGIN-iAd.PickerView.COMPONENT_BOTTOM_MARGIN)/iAd.PickerView.DEFAULT_ROW_HEIGHT),0),this.rows-1)}; |
iAd.PickerComponent.prototype.startDecelerationAnimation=function(){this.callSuper();this.expectedContentOffsetY=null;if(this.decelerating){var a=(this.contentOffset.y+this.decelerationVelocity.y/(1-iAd.ScrollView.DECELERATION_FRICTION_FACTOR)+iAd.PickerView.COMPONENT_TOP_MARGIN-iAd.PickerView.COMPONENT_BOTTOM_MARGIN)/iAd.PickerView.DEFAULT_ROW_HEIGHT,b=Math.min(Math.max(Math.round(a),0),this.rows-1);if(a>=0&&a<=this.rows-1){this.expectedContentOffsetY=b*iAd.PickerView.DEFAULT_ROW_HEIGHT;this.decelerationVelocity.y= |
(1-iAd.ScrollView.DECELERATION_FRICTION_FACTOR)*(this.expectedContentOffsetY-this.contentOffset.y)}}};iAd.PickerComponent.prototype.scrollViewDidEndDecelerating=function(){if(this.expectedContentOffsetY!==null)this.contentOffset=new iAd.Point(this.contentOffset.x,this.expectedContentOffsetY);this.superview.notifyDelegateOfRowInComponentSelection(this.rowAtY(this.contentOffset.y),this.index)}; |
iAd.PickerComponent.prototype.beginTracking=function(a){this.callSuper(a);a=this.rowAtY(iAd.Point.fromEventInElement(a,this.hostingLayer).y);this.touchedRow=a>=0&&a<=this.rows-1?a:-1}; |
iAd.PickerComponent.prototype.touchesEnded=function(a){var b=this.dragging;this.callSuper(a);if(!(a.eventPhase==Event.BUBBLING_PHASE||this.decelerating))if(b)this.superview.selectRowInComponentAnimated(this.getSelectedRow(),this.index,true);else this.touchedRow!=-1&&this.superview.selectRowInComponentAnimated(this.touchedRow,this.index,true)};iAd.PickerComponent.prototype.rowAtY=function(a){return Math.floor((a-iAd.PickerView.COMPONENT_TOP_MARGIN)/iAd.PickerView.DEFAULT_ROW_HEIGHT)}; |
iAd.Class({name:"iAd.PickerView",superclass:iAd.View,synthesizedProperties:["showsSelectionIndicator"]});iAd.PickerView.NUMBER_OF_COMPONENTS="numberOfComponentsInPickerView";iAd.PickerView.NUMBER_OF_ROWS_IN_COMPONENT="pickerViewNumberOfRowsInComponent";iAd.PickerView.ROW_HEIGHT_FOR_COMPONENT="pickerViewRowHeightForComponent";iAd.PickerView.WIDTH_FOR_COMPONENT="pickerViewWidthForComponent";iAd.PickerView.TITLE_FOR_ROW_FOR_COMPONENT="pickerViewTitleForRowForComponent"; |
iAd.PickerView.VIEW_FOR_ROW_FOR_COMPONENT="pickerViewViewForRowForComponent";iAd.PickerView.DID_SELECT_ROW_IN_COMPONENT="pickerViewDidSelectRowInComponent";iAd.PickerView.DEFAULT_WIDTH=320;iAd.PickerView.DEFAULT_HEIGHT=216;iAd.PickerView.DEFAULT_ROW_HEIGHT=39;iAd.PickerView.COMPONENT_TOP_MARGIN=89;iAd.PickerView.COMPONENT_BOTTOM_MARGIN=88; |
iAd.PickerView.prototype.init=function(){this.callSuper();this.numberOfComponents=0;this.dataSource=this.delegate=null;this._showsSelectionIndicator=false;this.components=[];this._size=new iAd.Size(iAd.PickerView.DEFAULT_WIDTH,iAd.PickerView.DEFAULT_HEIGHT);this.clipsToBounds=true}; |
iAd.PickerView.prototype.createLayer=function(){this.callSuper();this.layer.addClassName("ad-picker-view");var a=this.layer.appendChild(document.createElement("div"));a.className="ad-frame";this.componentsBackground=a.appendChild(document.createElement("div"));this.indicatorsBackground=a.appendChild(document.createElement("div"));this.hostingLayer=a.appendChild(document.createElement("div"));this.shadowOverlay=a.appendChild(document.createElement("div"));this.frameOverlay=a.appendChild(document.createElement("div")); |
this.indicatorsOverlay=a.appendChild(document.createElement("div"))};iAd.PickerView.prototype.setSize=function(a){a.width=iAd.PickerView.DEFAULT_WIDTH;a.height=iAd.PickerView.DEFAULT_HEIGHT;this.callSuper(a)};iAd.PickerView.prototype.setShowsSelectionIndicator=function(a){this.layer.toggleClassName("ad-shows-selection-indicator",a);this._showsSelectionIndicator=a}; |
iAd.PickerView.prototype.numberOfRowsInComponent=function(a){if(a<0||a>=this.numberOfComponents)throw Error("iAd.PickerView.numberOfRowsInComponent - no component "+a);return this.components[a].rows}; |
iAd.PickerView.prototype.updateNumberOfComponents=function(){if(iAd.Utils.objectHasMethod(this.dataSource,iAd.PickerView.NUMBER_OF_COMPONENTS)){this.numberOfComponents=this.dataSource[iAd.PickerView.NUMBER_OF_COMPONENTS](this);if(this.numberOfComponents<1)throw Error("iAd.PickerView must have at least one component");}else throw Error("the iAd.PickerView dataSource must implement "+iAd.PickerView.NUMBER_OF_COMPONENTS);}; |
iAd.PickerView.prototype.reloadAllComponents=function(){this.updateNumberOfComponents();for(var a=this.numberOfComponents;a<this.components.length;a++)if(this.components[a]!==undefined){this.components[a].removeFromSuperview();this.components[a]=undefined}for(a=0;a<this.numberOfComponents;a++)this.reloadComponent(a);this.updateComponentsLayout()}; |
iAd.PickerView.prototype.reloadComponent=function(a){a>this.numberOfComponents&&this.updateNumberOfComponents();if(a<0||a>=this.numberOfComponents)throw Error("iAd.PickerView.reloadComponent was called with an invalid component : "+a);if(iAd.Utils.objectHasMethod(this.dataSource,iAd.PickerView.NUMBER_OF_ROWS_IN_COMPONENT))var b=this.dataSource[iAd.PickerView.NUMBER_OF_ROWS_IN_COMPONENT](this,a);else throw Error("the iAd.PickerView dataSource must implement "+iAd.PickerView.NUMBER_OF_ROWS_IN_COMPONENT); |
var c=null;if(iAd.Utils.objectHasMethod(this.delegate,iAd.PickerView.TITLE_FOR_ROW_FOR_COMPONENT))c=this.delegate[iAd.PickerView.TITLE_FOR_ROW_FOR_COMPONENT];else if(iAd.Utils.objectHasMethod(this.delegate,iAd.PickerView.VIEW_FOR_ROW_FOR_COMPONENT))c=this.delegate[iAd.PickerView.VIEW_FOR_ROW_FOR_COMPONENT];else throw Error("the iAd.PickerView delegate must implement either "+iAd.PickerView.TITLE_FOR_ROW_FOR_COMPONENT+" or "+iAd.PickerView.VIEW_FOR_ROW_FOR_COMPONENT);if(this.components[a]===undefined)this.components[a]= |
this.addSubview(new iAd.PickerComponent(a,b));var d=this.components[a];d.hostingLayer.innerText="";for(var e=d.subviews=0;e<b;e++){var f=c.call(this.delegate,this,e,a);if(f instanceof iAd.View)d.addSubview(f);else{var g=document.createElement("div");g.className="ad-title-row";g.innerText=f;d.hostingLayer.appendChild(g)}}}; |
iAd.PickerView.prototype.updateComponentsLayout=function(){this.componentsBackground.innerText="";this.indicatorsBackground.innerText="";for(var a=300/this.numberOfComponents,b=iAd.Utils.objectHasMethod(this.delegate,iAd.PickerView.WIDTH_FOR_COMPONENT),c=0,d=0;d<this.numberOfComponents;d++){var e=this.components[d],f=b?this.delegate[iAd.PickerView.WIDTH_FOR_COMPONENT](this,d):a;e.position=new iAd.Point(c,0);e.size=new iAd.Size(f,iAd.PickerView.DEFAULT_HEIGHT);e.contentSize=new iAd.Size(f,this.components[d].rows* |
iAd.PickerView.DEFAULT_ROW_HEIGHT+iAd.PickerView.COMPONENT_TOP_MARGIN+iAd.PickerView.COMPONENT_BOTTOM_MARGIN);c+=f;this.componentsBackground.appendChild(document.createElement("div")).style.width=iAd.Utils.px(f);this.indicatorsBackground.appendChild(document.createElement("div")).style.width=iAd.Utils.px(f)}this.frameOverlay.parentNode.style.width=iAd.Utils.px(c+20);this.frameOverlay.parentNode.style.left=iAd.Utils.px((320-c-20)/2)}; |
iAd.PickerView.prototype.selectRowInComponentAnimated=function(a,b,c){if(b<0||b>=this.numberOfComponents)throw Error("iAd.PickerView.selectRowInComponentAnimated - no component "+b);if(a<0||a>=this.numberOfRowsInComponent(b))throw Error("iAd.PickerView.selectRowInComponentAnimated - no row "+a+" in component "+b);this.components[b].setContentOffsetAnimated(new iAd.Point(0,a*iAd.PickerView.DEFAULT_ROW_HEIGHT),c);this.notifyDelegateOfRowInComponentSelection(a,b)}; |
iAd.PickerView.prototype.selectedRowInComponent=function(a){if(a<0||a>=this.numberOfComponents)throw Error("iAd.PickerView.selectedRowInComponent - no component "+a);return this.components[a].getSelectedRow()};iAd.PickerView.prototype.notifyDelegateOfRowInComponentSelection=function(a,b){this.dispatchNotification(iAd.PickerView.DID_SELECT_ROW_IN_COMPONENT,this.delegate,[["row",a],["component",b]])};iAd.PickerView.prototype.viewForRowForComponent=function(){}; |
iAd.Class({name:"iAd.Button",superclass:iAd.Control,synthesizedProperties:["currentTitle","autosized"],cssClassName:"ad-button",collectionAccessor:"buttons"});iAd.Button.TYPE_CUSTOM="ad-custom-type";iAd.Button.TYPE_ROUNDED_RECT="ad-rounded-rect-type";iAd.Button.TYPE_DETAIL_DISCLOSURE="ad-detail-disclosure-type";iAd.Button.TYPE_INFO_LIGHT="ad-info-light-type";iAd.Button.TYPE_INFO_DARK="ad-info-dark-type";iAd.Button.TYPE_CONTACT_ADD="ad-contact-add-type";iAd.Button.DEFAULT_HEIGHT=37; |
iAd.Button.prototype.init=function(a,b){this.type=b||iAd.Button.TYPE_ROUNDED_RECT;this._autosized=true;this.titles=[""];this.titleLabel=null;this.callSuper(a)};iAd.Button.prototype.setupLayer=function(){this.callSuper();if(this.layer.hasClassName(iAd.Button.TYPE_ROUNDED_RECT))this.type=iAd.Button.TYPE_ROUNDED_RECT;else if(this.layer.hasClassName(iAd.Button.TYPE_CUSTOM))this.type=iAd.Button.TYPE_CUSTOM;this.layer.addClassName(this.type)}; |
iAd.Button.prototype.createLayer=function(){this.callSuper();this.layer.addClassName(this.type)};iAd.Button.prototype.layerWasCreated=function(){this.callSuper();if(this.type===iAd.Button.TYPE_ROUNDED_RECT||this.type===iAd.Button.TYPE_CUSTOM)this.titleLabel=this.addSubview(new iAd.Label);this.syncTitleToState();this.addPropertyObserver("state",this,"syncTitleToState")}; |
iAd.Button.prototype.setValueForAttribute=function(a,b){switch(b){case "ad-title-for-normal-state":this.setTitleForState(a,iAd.Control.STATE_NORMAL);break;case "ad-title-for-highlighted-state":this.setTitleForState(a,iAd.Control.STATE_HIGHLIGHTED);break;case "ad-title-for-disabled-state":this.setTitleForState(a,iAd.Control.STATE_DISABLED);break;case "ad-title-for-selected-state":this.setTitleForState(a,iAd.Control.STATE_SELECTED);break;default:this.callSuper(a,b)}}; |
iAd.Button.prototype.getSize=function(){var a=window.getComputedStyle(this.layer);return new iAd.Size(parseInt(a.width),parseInt(a.height))};iAd.Button.prototype.setSize=function(a){this._autoSized=false;this.callSuper(a)};iAd.Button.prototype.getCurrentTitle=function(){if(this.titleLabel==null)return null;return this.titleLabel.text};iAd.Button.prototype.setAutosized=function(a){a&&this.setLayerStyle({width:"auto",height:iAd.Utils.px(iAd.Button.DEFAULT_HEIGHT)});this._autosized=a}; |
iAd.Button.prototype.titleForState=function(a){return this.titles[a]||null};iAd.Button.prototype.setTitleForState=function(a,b){this.titles[b]=a;b==this.state&&this.syncTitleToState()};iAd.Button.prototype.syncTitleToState=function(){if(this.titleLabel!=null)this.titleLabel.text=this.titles[this.state]||this.titles[iAd.Control.STATE_NORMAL]}; |
iAd.FlowView=iAd.Class({name:"iAd.FlowView",superclass:iAd.View,synthesizedProperties:["frontCellIndex","sidePadding","frontZOffset","sideZOffset","cellGap","dragMultiplier","cellRotation","flipDuration","perspective","priorityOrdering","delegateIndexNotificationDelay","trackCamera"],cssClassName:"ad-flow-view",collectionAccessor:"flowViews"});iAd.FlowView.NUMBER_OF_CELLS_DELEGATE="flowViewNumberOfCells";iAd.FlowView.CELL_AT_INDEX_DELEGATE="flowViewCellAtIndex"; |
iAd.FlowView.DID_TAP_FRONT_CELL_NOTIFICATION="flowViewDidTapFrontCell";iAd.FlowView.DID_SELECT_CELL_NOTIFICATION="flowViewDidSelectCell";iAd.FlowView.DID_BEGIN_SWIPE_NOTIFICATION="flowViewDidBeginSwipe";iAd.FlowView.DID_END_SWIPE_NOTIFICATION="flowViewDidEndSwipe";iAd.FlowView.ACCELERATION=8;iAd.FlowView.MAX_TRACKING_TIME=200;iAd.FlowView.SWIPE_THRESHOLD_ANGLE=iAd.Utils.degreesToRadians(45);iAd.FlowView.DECELERATION_FRICTION_FACTOR=0.9;iAd.FlowView.DESIRED_ANIMATION_FRAME_RATE=1E3/60; |
iAd.FlowView.MINIMUM_VELOCITY=0.05;iAd.FlowView.MIN_VELOCITY_FOR_DECELERATION=1;iAd.FlowView.NUM_MOVE_EVENTS=3;iAd.FlowView.PENETRATION_DECELERATION=0.03;iAd.FlowView.PENETRATION_ACCELERATION=0.08; |
iAd.FlowView.prototype.init=function(a){this.delegate=this.dataSource=null;this._frontCellIndex=0;this._sidePadding=160;this._frontZOffset=0;this._sideZOffset=-100;this._cellGap=25;this._cellRotation=45;this._dragMultiplier=1;this._flipDuration=0.5;this._perspective=400;this._delegateIndexNotificationDelay=250;this._priorityOrdering=false;this._trackCamera=true;this._numCells=0;this._cells=[];this._cellWrappers=[];this._cellRotations=[];this._cameraOffset=0;this.timerSet=false;this._moveHistory=[]; |
this.callSuper(a);this.userInteractionEnabled=true}; |
iAd.FlowView.prototype.layerWasCreated=function(){this.callSuper();this.camera=this.layer.appendChild(document.createElement("div"));this.camera.addClassName("ad-flow-view-camera");this.hostingLayer=this.camera;var a=this.layer.querySelectorAll("ul > li");this._numCells=a.length;if(this._numCells>0){for(var b=0;b<this._numCells;b++){var c=this.camera.appendChild(document.createElement("div"));c._orderIndex=b;c.addClassName("ad-flow-view-cell-wrapper");this._cellWrappers.push(c);var d=a[b];d._orderIndex= |
b;d._layoutIndex=this.layoutIndexForOrderIndex(b);d.addClassName("ad-flow-view-cell");this._cells.push(d);c.appendChild(d);this._cellRotations.push(null)}this.layer.removeChild(this.layer.querySelector("ul"))}};iAd.FlowView.prototype.layerWasInsertedIntoDocument=function(){this.callSuper();this.layout()};iAd.FlowView.prototype.setFlipDuration=function(a){this._flipDuration=a};iAd.FlowView.prototype.setCellGap=function(a){this._cellGap=a;this.layout()}; |
iAd.FlowView.prototype.setSidePadding=function(a){this._sidePadding=a;this.layout()};iAd.FlowView.prototype.setFrontZOffset=function(a){this._frontZOffset=a;this.layout()};iAd.FlowView.prototype.setSideZOffset=function(a){this._sideZOffset=a;this.layout()};iAd.FlowView.prototype.setCellRotation=function(a){this._cellRotation=a;this.layout()}; |
iAd.FlowView.prototype.setPriorityOrdering=function(a){this._priorityOrdering=a;for(a=0;a<this._numCells;a++)this._cells[a]._layoutIndex=this.layoutIndexForOrderIndex(a);this.layout()};iAd.FlowView.prototype.setPerspective=function(a){this._perspective=a;this.setLayerStyle({"-webkit-perspective":this._perspective})}; |
iAd.FlowView.prototype.setFrontCellIndex=function(a){if(a>=0&&a<this._numCells){if(a!=this._frontCellIndex){this.changedTime=new Date;if(!this.timerSet){this.timerSet=true;this.callMethodNameAfterDelay("testForInteractionDelegate",this._delegateIndexNotificationDelay)}}this._frontCellIndex=a;this.layoutCells()}}; |
iAd.FlowView.prototype.reloadData=function(){if(!(!this.dataSource||!iAd.Utils.objectHasMethod(this.dataSource,iAd.FlowView.NUMBER_OF_CELLS_DELEGATE)||!iAd.Utils.objectHasMethod(this.dataSource,iAd.FlowView.CELL_AT_INDEX_DELEGATE))){this.hostingLayer.textContent="";this._cells=[];this._cellWrappers=[];this._numCells=this.dataSource[iAd.FlowView.NUMBER_OF_CELLS_DELEGATE](this);for(var a,b=0;b<this._numCells;b++){a=this.dataSource[iAd.FlowView.CELL_AT_INDEX_DELEGATE](this,b);a._orderIndex=b;a._layoutIndex= |
this.layoutIndexForOrderIndex(b);a.addClassName("ad-flow-view-cell");this._cells.push(a);var c=document.createElement("div");c._orderIndex=b;c.addClassName("ad-flow-view-cell-wrapper");this._cellWrappers.push(c);c.appendChild(a);this.camera.appendChild(c);this._cellRotations.push(null)}this.layout()}};iAd.FlowView.prototype.layoutIndexForOrderIndex=function(a){if(this._priorityOrdering){var b=Math.floor((this._numCells-1)/2);return a%2==1?b+Math.ceil(a/2):b-Math.floor(a/2)}else return a}; |
iAd.FlowView.prototype.orderIndexForLayoutIndex=function(a){if(this._priorityOrdering){a=a-Math.floor((this._numCells-1)/2);return a>0?a*2-1:a*-2}else return a}; |
iAd.FlowView.prototype.testForInteractionDelegate=function(){var a=new Date;if(a-this.changedTime<this._delegateIndexNotificationDelay)this.callMethodNameAfterDelay("testForInteractionDelegate",this._delegateIndexNotificationDelay-(a-this.changedTime));else{this.timerSet=false;this.dispatchNotification(iAd.FlowView.DID_SELECT_CELL_NOTIFICATION,this.delegate,[["cellIndex",this.frontCellIndex]])}};iAd.FlowView.prototype.layout=function(){this.layoutCells();this.centerCamera()}; |
iAd.FlowView.prototype.animateCamera=function(a){this.camera.style.webkitTransitionDuration=a?"":"0s"};iAd.FlowView.prototype.centerCamera=function(){this._cameraOffset=this._frontCellIndex*this._cellGap;this.layoutCamera()};iAd.FlowView.prototype.layoutCamera=function(){this.camera.style.webkitTransform=iAd.Utils.t(this._cameraOffset*-1,0)}; |
iAd.FlowView.prototype.layoutCells=function(){for(var a=0;a<this._numCells;a++){var b=this._cells[a]._layoutIndex,c=this._frontCellIndex-b,d=Math.abs(c),e=b*this._cellGap-this.sidePadding,f=this._cellRotation,g=0.1*d+this._sideZOffset;if(c==0){e=b*this._cellGap;f=0;g=this._frontZOffset}else if(c<0){e=this._frontCellIndex*this._cellGap+this.sidePadding+d*this._cellGap;f=-this._cellRotation}this._cellRotations[a]=f;b=iAd.Utils.t3d(e,0,g);f=iAd.Utils.r3d(0,1,0,iAd.Utils.degreesToRadians(f));this._cells[a].style.webkitTransform= |
f;this._cellWrappers[a].style.webkitTransform=b}};iAd.FlowView.prototype.cellAtIndex=function(a){return this._cells[a]};iAd.FlowView.prototype.indexAtPoint=function(a,b){for(var c=document.elementFromPoint(a,b);c&&c._orderIndex===undefined;)c=c.parentNode;return c?c._orderIndex:this._frontCellIndex}; |
iAd.FlowView.prototype.touchesBegan=function(a){if(!(this.tracking||a.touches&&a.touches.length>1)){this.stopDecelerationAnimation();this.downTime=a.timeStamp;this.downIndex=this._frontCellIndex;this.downTimePosition=this.downOffset=this._cameraOffset;this.downPoint=iAd.Point.fromEventInElement(a,this.layer);this.tracking=true;this.trackingMoved=false;this._trackCamera&&this.animateCamera(false);this.callSuper(a)}}; |
iAd.FlowView.prototype.touchesMoved=function(a){if(!(a.touches&&a.touches.length>1)){this.lastEventTime=a.timeStamp;var b=iAd.Point.fromEventInElement(a,this.layer),c=b.x-this.downPoint.x,d=b.y-this.downPoint.y;if(this.trackingMoved){if(this.trackingMoved){a.preventDefault();this._cameraOffset=this.downOffset-c;if(this._cameraOffset<0)this._cameraOffset/=2;else if(this._cameraOffset>(this._numCells-1)*this._cellGap)this._cameraOffset=((this._numCells-1)*this._cellGap+this._cameraOffset)/2;if(!this._trackCamera)this._cameraOffset= |
Math.round(this._cameraOffset/this._cellGap)*this._cellGap;this.layoutCamera();b=this.downIndex-Math.round(c/this._cellGap);if(b!=this._frontCellIndex)this.frontCellIndex=b;this._moveHistory.push({time:a.timeStamp,offset:this._cameraOffset})>iAd.FlowView.NUM_MOVE_EVENTS&&this._moveHistory.shift();if(this.lastEventTime-this.downTime>iAd.FlowView.MAX_TRACKING_TIME){this.downTime=this.lastEventTime;this.downTimePosition=this._cameraOffset}}}else if(!(Math.abs(c)<3&&Math.abs(d)<3)){var e=false;if(c!= |
0&&d!=0)e=Math.abs(Math.atan(d/c))<=iAd.FlowView.SWIPE_THRESHOLD_ANGLE;else if(c!=0)e=true;if(e){this.trackingMoved=true;this.downPoint=b;this.dispatchNotification(iAd.FlowView.DID_BEGIN_SWIPE_NOTIFICATION,this.delegate)}else{this.tracking=false;this.touchesCancelled(a)}}}}; |
iAd.FlowView.prototype.touchesEnded=function(a){a.preventDefault();if(!(a.touches&&a.touches.length>1)){this.callSuper(a);this.tracking=false;a=a.timeStamp;if(!this.trackingMoved&&this.frontCellIndex==this.downIndex&&a-this.downTime<300){a=this._cells[this.indexAtPoint(this.downPoint.x,this.downPoint.y)]._layoutIndex;this.dispatchNotification(iAd.FlowView.DID_TAP_FRONT_CELL_NOTIFICATION,this.delegate,[["cellIndex",this.frontCellIndex]]);this.frontCellIndex=a;this._trackCamera&&this.animateCamera(true); |
this.centerCamera()}else a-this.lastEventTime<=iAd.FlowView.MAX_TRACKING_TIME?this.startDecelerationAnimation():this.swipeEnded();this._moveHistory=[]}};iAd.FlowView.prototype.swipeEnded=function(){this._trackCamera&&this.animateCamera(true);this.centerCamera();this.dispatchNotification(iAd.FlowView.DID_END_SWIPE_NOTIFICATION,this.delegate)}; |
iAd.FlowView.prototype.getOffsetVelocity=function(){var a=this._moveHistory.length;if(a<2)return 0;return(this._moveHistory[a-1].offset-this._moveHistory[a-2].offset)/(this._moveHistory[a-1].time-this._moveHistory[a-2].time)}; |
iAd.FlowView.prototype.startDecelerationAnimation=function(){this.decelerationVelocity=this.getOffsetVelocity();this.minDecelerationPoint=0;this.maxDecelerationPoint=(this._numCells-1)*this._cellGap;this.penetrationDeceleration=iAd.FlowView.PENETRATION_DECELERATION;this.penetrationAcceleration=iAd.FlowView.PENETRATION_ACCELERATION;if(Math.abs(this.decelerationVelocity)>iAd.FlowView.MIN_VELOCITY_FOR_DECELERATION){var a=this._cameraOffset+this.decelerationVelocity/(1-iAd.FlowView.DECELERATION_FRICTION_FACTOR), |
b=Math.round(a/this._cellGap);if(b>=0&&b<=this._numCells-1){this.decelerationVelocity=(1-iAd.FlowView.DECELERATION_FRICTION_FACTOR)*(b*this._cellGap-this._cameraOffset);a=this._cameraOffset+this.decelerationVelocity/(1-iAd.FlowView.DECELERATION_FRICTION_FACTOR)}a=Math.max(0,Math.min(this._numCells-1,Math.round(a/this._cellGap)));if(a!=this._frontCellIndex)this.frontCellIndex=a;this.decelerating=true;this.decelerationTimer=this.callMethodNameAfterDelay("stepThroughDecelerationAnimation",iAd.FlowView.DESIRED_ANIMATION_FRAME_RATE); |
this.lastFrame=new Date}else this.swipeEnded()};iAd.FlowView.prototype.stopDecelerationAnimation=function(){this.decelerating=false;clearTimeout(this.decelerationTimer)}; |
iAd.FlowView.prototype.stepThroughDecelerationAnimation=function(a){if(this.decelerating){var b=new Date,c=b-this.lastFrame;c=a?0:Math.round(c/iAd.FlowView.DESIRED_ANIMATION_FRAME_RATE)-1;for(var d=0;d<c;d++)this.stepThroughDecelerationAnimation(true);this._cameraOffset=c=this._cameraOffset+this.decelerationVelocity;a||this.layoutCamera();this.decelerationVelocity*=iAd.FlowView.DECELERATION_FRICTION_FACTOR;d=Math.abs(this.decelerationVelocity);if(!a&&d<=iAd.FlowView.MINIMUM_VELOCITY){this.decelerating= |
false;this.swipeEnded()}else{if(!a)this.decelerationTimer=this.callMethodNameAfterDelay("stepThroughDecelerationAnimation",iAd.FlowView.DESIRED_ANIMATION_FRAME_RATE);d=0;if(c<this.minDecelerationPoint)d=this.minDecelerationPoint-c;else if(c>this.maxDecelerationPoint)d=this.maxDecelerationPoint-c;if(d!=0)if(d*this.decelerationVelocity<=0)this.decelerationVelocity+=d*this.penetrationDeceleration;else this.decelerationVelocity=d*this.penetrationAcceleration;if(!a)this.lastFrame=b}}}; |
iAd.Class({name:"iAd.Label",superclass:iAd.View,synthesizedProperties:["numberOfLines","text","verticalAlignment"],cssClassName:"ad-label",collectionAccessor:"labels"});iAd.Label.VERTICAL_ALIGNMENT_TOP="top";iAd.Label.VERTICAL_ALIGNMENT_MIDDLE="middle";iAd.Label.VERTICAL_ALIGNMENT_BOTTOM="bottom";iAd.Label.prototype.init=function(a){this._numberOfLines=1;this._verticalAlignment=iAd.Label.VERTICAL_ALIGNMENT_MIDDLE;this.callSuper(a)}; |
iAd.Label.prototype.layerWasCreated=function(){this.callSuper();this._textContainer=document.createElement("div");this._textContainer.innerText=this.layer.innerText;this.layer.innerText="";this.layer.appendChild(this._textContainer)};iAd.Label.prototype.getText=function(){return this._textContainer.innerText};iAd.Label.prototype.setText=function(a){this._textContainer.innerText=a}; |
iAd.Label.prototype.setNumberOfLines=function(a){this._numberOfLines=a;if(a==0){this._textContainer.style.webkitLineClamp="100%";this._textContainer.style.overflow="visible"}else{this._textContainer.style.webkitLineClamp=a;this._textContainer.style.overflow="hidden"}};iAd.Label.prototype.setVerticalAlignment=function(a){this._verticalAlignment=a;var b="center";if(a==iAd.Label.VERTICAL_ALIGNMENT_TOP)b="start";else if(a==iAd.Label.VERTICAL_ALIGNMENT_BOTTOM)b="end";this.setLayerStyle({"-webkit-box-pack":b})}; |
iAd.Class({name:"iAd.ImageView",superclass:iAd.View,synthesizedProperties:["autoSized","image","highlightedImage","highlighted"],cssClassName:"ad-image-view",collectionAccessor:"imageViews"});iAd.ImageView.prototype.init=function(a){this._autoSized=true;this._highlighted=false;this._highlightedImage=this._image=null;this.didCheckForAutoSizing=this.touchInside=false;this.callSuper(a)}; |
iAd.ImageView.prototype.setValueForAttribute=function(a,b){switch(b){case "ad-image":this.image=new iAd.Image(a,this.layer.hasAttribute("ad-has-hidpi-version"));break;case "ad-highlighted-image":this.highlightedImage=new iAd.Image(a,this.layer.hasAttribute("ad-has-hidpi-version"));break;default:this.callSuper(a,b)}};iAd.ImageView.prototype.setImage=function(a){this._image=a;this.syncImageToCurrentState()}; |
iAd.ImageView.prototype.setHighlightedImage=function(a){this.userInteractionEnabled=a!==null;this._highlightedImage=a;this.syncImageToCurrentState()};iAd.ImageView.prototype.setHighlighted=function(a){if(a!=this._highlighted){this._highlighted=a;this.syncImageToCurrentState()}};iAd.ImageView.prototype.setAutoSized=function(a){this._autoSized=a;this.syncImageToCurrentState()}; |
iAd.ImageView.prototype.syncImageToCurrentState=function(){var a=this.highlighted?this.highlightedImage:this.image;if(a)if(a.loaded){this.setLayerStyle({"background-image":"url("+a.element.src+")"});if(!this.didCheckForAutoSizing){this._autoSized=this.size.equals(iAd.Size.ZERO_SIZE);this.didCheckForAutoSizing=true}if(this.autoSized)this.size=new iAd.Size(a.width,a.height)}else a.addPropertyObserver("loaded",this,"syncImageToCurrentState")}; |
iAd.ImageView.prototype.touchesBegan=function(a){this.callSuper(a);this.highlighted=this.touchInside=true};iAd.ImageView.prototype.touchesMoved=function(a){this.callSuper(a);this.highlighted=this.touchInside=this.pointInside(iAd.Point.fromEventInElement(a,this.layer))};iAd.ImageView.prototype.touchesEnded=function(a){this.callSuper(a);this.touchInside=this.highlighted=false}; |
iAd.Class({name:"iAd.ViewController",superclass:iAd.Object,mixins:[iAd.EventTarget],synthesizedProperties:["view","title","loading","viewWasProcessed","contentView"]}); |
iAd.ViewController.prototype.init=function(a){this.stateChangeDelegate=this.requiredFilesLoadDelegate=null;this.callSuper();this.configuration={};this.openRequests=[];this.loadedContentViewLayer=null;this.viewIsLoaded=this.loadedAllRequiredFiles=this.shouldSetUpContentViewUponLoad=false;if(iAd.Utils.objectIsString(a))this.configuration={id:a};else if(a!==undefined&&a!==null)this.configuration=a;this._contentView=this._view=null;this._title="";this._toolbarItems=this._navigationItem=this._tabBarItem= |
null;this.hidesBottomBarWhenPushed=this._viewWasProcessed=false;this.outlets={};this.eventTarget=document;this.searchDisplayController=this.modalTransitionStyle=this.parentViewController=this.modalViewController=null;this.wasBackItemTransition=iAd.ViewController.TRANSITION_IN_FROM_LEFT;this.becomesBackItemTransition=iAd.ViewController.TRANSITION_OUT_TO_LEFT;this.wasTopItemTransition=iAd.ViewController.TRANSITION_OUT_TO_RIGHT;this.becomesTopItemTransition=iAd.ViewController.TRANSITION_IN_FROM_RIGHT; |
this.becomesHiddenTransition=iAd.View.TRANSITION_DISSOLVE_OUT;this.becomesVisibleTransition=iAd.View.TRANSITION_DISSOLVE_IN;this.buildInAnimationNames=[];this.buildOutAnimationNames=[];this.buildOutAnimationsShouldDelayTransition=false;if(this.configuration.hasOwnProperty("id"))iAd.ViewController.instances[this.configuration.id]=this;iAd.Utils.copyPropertiesFromSourceToTarget(this.configuration.properties,this)};iAd.ViewController.instances={};iAd.ViewController.WILL_LOAD_REQUIRED_FILES="viewControllerWillLoadRequiredFiles"; |
iAd.ViewController.PROGRESS_LOADING_REQUIRED_FILES="viewControllerProgressLoadingRequiredFiles";iAd.ViewController.DID_LOAD_REQUIRED_FILES="viewControllerDidLoadRequiredFiles";iAd.ViewController.DID_ENTER_STATE="viewControllerDidEnterState";iAd.ViewController.DID_EXIT_STATE="viewControllerDidExitState";iAd.ViewController.VIEW_WILL_APPEAR_STATE="ad-view-will-appear";iAd.ViewController.VIEW_DID_APPEAR_STATE="ad-view-did-appear";iAd.ViewController.VIEW_WILL_DISAPPEAR_STATE="ad-view-will-disappear"; |
iAd.ViewController.VIEW_DID_DISAPPEAR_STATE="ad-view-did-disappear";iAd.ViewController.APPEARANCE_STATES=[iAd.ViewController.VIEW_WILL_APPEAR_STATE,iAd.ViewController.VIEW_DID_APPEAR_STATE,iAd.ViewController.VIEW_WILL_DISAPPEAR_STATE,iAd.ViewController.VIEW_DID_DISAPPEAR_STATE];iAd.ViewController.VIEW_WILL_APPEAR_EVENT="viewControllerViewWillAppear";iAd.ViewController.VIEW_DID_APPEAR_EVENT="viewControllerViewDidAppear";iAd.ViewController.VIEW_WILL_DISAPPEAR_EVENT="viewControllerViewWillDisappear"; |
iAd.ViewController.VIEW_DID_DISAPPEAR_EVENT="viewControllerViewDidDisappear";iAd.ViewController.VIEW_DID_LOAD="viewControllerViewDidLoad";iAd.ViewController.TRANSITION_IN_FROM_RIGHT={properties:["transform"],from:["translateX($width)"],to:["translateX(0)"]};iAd.ViewController.TRANSITION_IN_FROM_LEFT={properties:["transform"],from:["translateX(-$width)"],to:["translateX(0)"]};iAd.ViewController.TRANSITION_OUT_TO_RIGHT={properties:["transform"],from:["translateX(0)"],to:["translateX($width)"]}; |
iAd.ViewController.TRANSITION_OUT_TO_LEFT={properties:["transform"],from:["translateX(0)"],to:["translateX(-$width)"]};iAd.ViewController.DECLARATIVE_MIME_TYPE="application/vnd.apple.iadjs; type=view-controllers";iAd.ViewController.prototype.getView=function(){this._view===null&&this.loadView();return this._view}; |
iAd.ViewController.prototype.setView=function(a){this._view instanceof iAd.View&&delete this._view._viewController;a._viewController=this;this._view=a;a.usesDeclarativeBacking&&a.layer.hasAttribute("ad-content-view")?this.loadContentView(a.layer.getAttribute("ad-content-view")):this.processView()};iAd.ViewController.prototype.setContentView=function(a){a.superview=this._view;this._view.subviews.push(a);this._contentView=a}; |
iAd.ViewController.prototype.loadView=function(){this._view=new iAd.View;this._view._viewController=this;this.configuration.hasOwnProperty("requiredFileURIs")?this.loadContentView():this.processView()}; |
iAd.ViewController.prototype.loadContentView=function(a){if(a){if(!this.configuration.hasOwnProperty("requiredFileURIs"))this.configuration.requiredFileURIs={};this.configuration.requiredFileURIs.contentView=a}if(this.loading)this.shouldSetUpContentViewUponLoad=true;else if(this.loadedAllRequiredFiles)this.setupContentViewFromLayer();else{this.shouldSetUpContentViewUponLoad=true;this.loadRequiredFiles()}};iAd.ViewController.prototype.isViewLoaded=function(){return this.viewIsLoaded}; |
iAd.ViewController.prototype.viewDidLoad=function(){this.dispatchEvent(this.createEvent(iAd.ViewController.VIEW_DID_LOAD))};iAd.ViewController.prototype.setTitle=function(a){this._title=a;if(this.parentViewController instanceof iAd.TabBarController)this.tabBarItem.title=a;else if(this.parentViewController instanceof iAd.NavigationController)this.navigationItem.title=a};iAd.ViewController.prototype.isInState=function(a){return this.view.layer.hasClassName(a)}; |
iAd.ViewController.prototype.enterState=function(a){var b=this.view.layer.addClassName(a);b&&this.dispatchNotification(iAd.ViewController.DID_ENTER_STATE,this.stateChangeDelegate,[["state",a]]);return b};iAd.ViewController.prototype.exitState=function(a){var b=this.view.layer.removeClassName(a);b&&this.dispatchNotification(iAd.ViewController.DID_EXIT_STATE,this.stateChangeDelegate,[["state",a]]);return b}; |
iAd.ViewController.prototype.enterExclusiveAppearanceState=function(a){for(var b,c=0;c<iAd.ViewController.APPEARANCE_STATES.length;c++){b=iAd.ViewController.APPEARANCE_STATES[c];this[(b===a?"enter":"exit")+"State"](b)}};iAd.ViewController.prototype.viewWillAppear=function(a){this.dispatchEvent(this.createEvent(iAd.ViewController.VIEW_WILL_APPEAR_EVENT,[["animated",a]]));this.enterExclusiveAppearanceState(iAd.ViewController.VIEW_WILL_APPEAR_STATE)}; |
iAd.ViewController.prototype.viewDidAppear=function(a){this.dispatchEvent(this.createEvent(iAd.ViewController.VIEW_DID_APPEAR_EVENT,[["animated",a]]));this.enterExclusiveAppearanceState(iAd.ViewController.VIEW_DID_APPEAR_STATE)};iAd.ViewController.prototype.viewWillDisappear=function(a){this.dispatchEvent(this.createEvent(iAd.ViewController.VIEW_WILL_DISAPPEAR_EVENT,[["animated",a]]));this.enterExclusiveAppearanceState(iAd.ViewController.VIEW_WILL_DISAPPEAR_STATE)}; |
iAd.ViewController.prototype.viewDidDisappear=function(a){this.dispatchEvent(this.createEvent(iAd.ViewController.VIEW_DID_DISAPPEAR_EVENT,[["animated",a]]));this.enterExclusiveAppearanceState(iAd.ViewController.VIEW_DID_DISAPPEAR_STATE)};iAd.ViewController.prototype.presentModalViewControllerAnimated=function(a){this.modalViewController=a};iAd.ViewController.prototype.dismissModalViewControllerAnimated=function(){this.modalViewController=null}; |
iAd.ViewController.prototype.parentControllerOfKind=function(a){for(var b=this,c=null;b.parentViewController!==null;){if(b instanceof a){c=b;break}b=b.parentViewController}return c};iAd.ViewController.prototype.getLoading=function(){return this.openRequests.length>0}; |
iAd.ViewController.prototype.loadRequiredFiles=function(){if(!this.loadedAllRequiredFiles){this.dispatchNotification(iAd.ViewController.WILL_LOAD_REQUIRED_FILES,this.requiredFilesLoadDelegate);this.numberOfLoadedRequiredFiles=this.totalNumberOfRequiredFiles=0;this.configuration.requiredFileURIs.hasOwnProperty("contentView")&&this.loadFilesOfType([this.configuration.requiredFileURIs.contentView],"html");this.configuration.requiredFileURIs.hasOwnProperty("stylesheets")&&this.loadFilesOfType(this.configuration.requiredFileURIs.stylesheets, |
"css");this.configuration.requiredFileURIs.hasOwnProperty("scripts")&&this.loadFilesOfType(this.configuration.requiredFileURIs.scripts,"js");this.configuration.requiredFileURIs.hasOwnProperty("images")&&this.loadFilesOfType(this.configuration.requiredFileURIs.images,"image")}};iAd.ViewController.prototype.loadFilesOfType=function(a,b){for(var c=0;c<a.length;c++)this.openRequest(a[c],b)}; |
iAd.ViewController.prototype.openRequest=function(a,b){this.totalNumberOfRequiredFiles++;var c;c=b=="image"?new Image:new XMLHttpRequest;this.openRequests.push(c);c._url=a;c._type=b;c.addEventListener("load",this,false);c.addEventListener("error",this,false);if(b=="image")c.src=a;else{c.open("GET",a,true);try{c.send()}catch(d){this.requestDidFail(c)}}}; |
iAd.ViewController.prototype.handleEvent=function(a){var b=a.type;switch(b){case "load":this.handleLoadEvent(a);break;case "error":this.requestDidFail(a.target)}for(var c,d=0;d<iAd.ViewController.viewProcessors.length;d++){c=iAd.ViewController.viewProcessors[d];c.hasOwnProperty("handler")&&c.hasOwnProperty("eventTypes")&&c.eventTypes.indexOf(b)!=-1&&this[c.handler](a)}}; |
iAd.ViewController.prototype.handleLoadEvent=function(a){a=a.target;switch(a._type){case "css":this.stylesheetDidLoad(a);break;case "js":this.scriptDidLoad(a);break;case "html":this.htmlDidLoad(a)}this.requestDidComplete(a)};iAd.ViewController.prototype.requestDidFail=function(a){console.warn("iAd.ViewController \u2014 could not load required file with URI "+a._url);this.requestDidComplete(a)}; |
iAd.ViewController.prototype.requestDidComplete=function(a){var b=this.openRequests.indexOf(a);b!=-1&&this.openRequests.splice(b,1);this.numberOfLoadedRequiredFiles++;this.totalNumberOfRequiredFiles>0&&this.dispatchNotification(iAd.ViewController.PROGRESS_LOADING_REQUIRED_FILES,this.requiredFilesLoadDelegate,[["progess",this.numberOfLoadedRequiredFiles/this.totalNumberOfRequiredFiles],["url",a._url]]);if(!this.loading){this.loadedAllRequiredFiles=true;this.dispatchNotification(iAd.ViewController.DID_LOAD_REQUIRED_FILES, |
this.requiredFilesLoadDelegate);this.notifyPropertyChange("loading");this.shouldSetUpContentViewUponLoad&&this.setupContentViewFromLayer()}};iAd.ViewController.prototype.stylesheetDidLoad=function(a){var b=document.createElement("style");b.innerText=a.responseText;document.head.appendChild(b)};iAd.ViewController.prototype.scriptDidLoad=function(a){var b=document.createElement("script");b.type="text/javascript";b.src=a._url;document.head.appendChild(b)}; |
iAd.ViewController.prototype.htmlDidLoad=function(a){this.loadedContentViewLayer=iAd.Utils.createNodeFromString(a.responseText)}; |
iAd.ViewController.prototype.setupContentViewFromLayer=function(){var a=this.loadedContentViewLayer;this._view.layer.appendChild(a);if(!a.hasAttribute("id")&&this.configuration.hasOwnProperty("id"))a.id=this.configuration.id;this.contentView=iAd.Utils.getViewWithLayer(a);this.contentView.declarativeLayerWasInititalized?this.processView():this.contentView.addPropertyObserver("declarativeLayerWasInititalized",this,"processView")}; |
iAd.ViewController.prototype.processView=function(){if(!this._view.layer.hasAttribute("id")&&this.configuration.hasOwnProperty("id"))this._view.id=this.configuration.id+(this.configuration.hasOwnProperty("requiredFileURIs")&&this.configuration.requiredFileURIs.hasOwnProperty("contentView")?"-container":"");for(var a=0;a<iAd.ViewController.viewProcessors.length;a++)this[iAd.ViewController.viewProcessors[a].processor]();if(!this.viewIsLoaded){this.viewIsLoaded=true;this.viewDidLoad()}this.viewWasProcessed= |
true};iAd.ViewController.prototype.processOutlets=function(){for(var a,b=this.view.layer.querySelectorAll("[ad-outlet]"),c=0;c<b.length;c++){a=b[c];this.outlets[a.getAttribute("ad-outlet")]=a.hasOwnProperty("_view")?a._view:a}};iAd.ViewController.prototype.processActions=function(){for(var a,b=this.view.layer.querySelectorAll("[ad-action]"),c=0;c<b.length;c++){a=b[c];a.addEventListener(iAd.Control.TOUCH_UP_INSIDE_EVENT,this,false);a.addEventListener("click",this,false)}}; |
iAd.ViewController.prototype.handleActionsAnchorActivation=function(a){var b=a.currentTarget;if(b.hasAttribute("ad-action"))if(!(a.type=="click"&&iAd.Control.isNodeInControlHierarchyBoundedByElement(a.target,b))){b=b.getAttribute("ad-action");iAd.Utils.objectHasMethod(this,b)&&this[b](a)}};iAd.ViewController.viewProcessors=[{processor:"processOutlets"},{processor:"processActions",handler:"handleActionsAnchorActivation",eventTypes:[iAd.Control.TOUCH_UP_INSIDE_EVENT,"click"]}]; |
iAd.ViewController.addViewProcessor=function(a){iAd.ViewController.viewProcessors.push(a)};iAd.ViewController.init=function(){for(var a=document.scripts,b,c=0;c<a.length;c++){b=a[c];b.type==iAd.ViewController.DECLARATIVE_MIME_TYPE&&iAd.ViewController.handleScriptElementForDeclarativeViewControllers(b)}}; |
iAd.ViewController.handleScriptElementForDeclarativeViewControllers=function(a){if(a.src!=""){var b=new XMLHttpRequest;b._url=a.src;b.addEventListener("load",this,false);b.addEventListener("error",this,false);b.open("GET",b._url,true);b.send()}else{a=Function("undefined","return ("+a.innerText+");")();iAd.ViewController.handleDeclarativeViewControllerDefinitions(a)}}; |
iAd.ViewController.handleEvent=function(a){var b=a.target;switch(a.type){case "load":a=Function("undefined","return ("+b.responseText+");")();iAd.ViewController.handleDeclarativeViewControllerDefinitions(a);break;case "error":console.error("Failed to read content from JSON file "+b._url)}};iAd.ViewController.handleDeclarativeViewControllerDefinitions=function(a){if(iAd.Utils.objectIsArray(a))for(var b=0;b<a.length;b++)iAd.ViewController.viewControllerWithConfiguration(a[b]);else iAd.ViewController.viewControllerWithConfiguration(a)}; |
iAd.ViewController.viewControllerWithConfiguration=function(a){return new (iAd.ViewController.constructorMap[a.type]||iAd.ViewController)(a)};iAd.ViewController.constructorMap={};iAd.ViewController.initialize=function(){iAd.ViewController.constructorMap[this.displayName]=this};window.addEventListener("DOMContentLoaded",iAd.ViewController.init,false);iAd.Class({name:"iAd.RootViewController",superclass:iAd.ViewController}); |
iAd.RootViewController.prototype.init=function(){this.callSuper({id:"root",properties:{view:iAd.RootView.sharedRoot}});iAd.RootViewController.sharedRootViewController=this}; |
Object.defineProperty(iAd.RootViewController,"sharedRootViewController",{get:function(){if(!iAd.RootViewController.hasOwnProperty("_sharedRootViewController"))iAd.RootViewController.sharedRootViewController=new iAd.RootViewController;return iAd.RootViewController._sharedRootViewController},set:function(a){iAd.RootViewController._sharedRootViewController=a}});iAd.Class({name:"iAd.TransitionController",superclass:iAd.ViewController,synthesizedProperties:["visibleViewController","cachedViewControllers"]}); |
iAd.TransitionController.WILL_MAKE_VIEW_CONTROLLER_VISIBLE="transitionControllerWillMakeViewControllerVisibleAnimated";iAd.TransitionController.DID_MAKE_VIEW_CONTROLLER_VISIBLE="transitionControllerDidMakeViewControllerVisibleAnimated";iAd.TransitionController.VIEW_IS_VISIBLE_STATE="ad-transition-controller-visible";iAd.TransitionController.VIEW_IS_HIDDEN_STATE="ad-transition-controller-hidden";iAd.TransitionController.VIEW_BUILDS_IN_STATE="ad-view-builds-in"; |
iAd.TransitionController.VIEW_BUILDS_OUT_STATE="ad-view-builds-out";iAd.TransitionController.VIEW_IDLE_STATE="ad-view-is-idle";iAd.TransitionController.DEFAULT_TRANSITION_DURATION=0.35;iAd.TransitionController.prototype.init=function(a,b){this.callSuper(a);this._cachedViewControllers=[];this.previouslyVisibleViewController=this.delegate=this._visibleViewController=null;this.busy=false;if(b!==undefined)this.visibleViewController=b}; |
iAd.TransitionController.prototype.loadView=function(){this.callSuper();this._view.layer.addClassName("ad-transition-controller-view")};iAd.TransitionController.prototype.setCachedViewControllers=function(a){var b,c,d=this._cachedViewControllers;for(c=0;c<d.length;c++){b=d[c];b!==this._visibleViewController&&a.indexOf(b)==-1&&b.view.removeFromSuperview()}for(c=0;c<a.length;c++){b=a[c];b!==this._visibleViewController&&d.indexOf(b)==-1&&this.attachViewController(b)}this._cachedViewControllers=[].concat(a)}; |
iAd.TransitionController.prototype.attachViewController=function(a){a.isViewLoaded()||a.loadView();a.view.layer.addClassName("ad-waiting-on-display");a.view.superview!==this&&this._view.addSubview(a.view)};iAd.TransitionController.prototype.setVisibleViewController=function(a){this.setVisibleViewControllerAnimated(a,false)}; |
iAd.TransitionController.prototype.setVisibleViewControllerAnimated=function(a,b){if(!(this.busy||this._visibleViewController===a)){this.transitionIsDelayedByPreviouslyVisibleViewController=false;this.previouslyVisibleViewController=this._visibleViewController;if(this.previouslyVisibleViewController!==null){this.previouslyVisibleViewController.exitState(iAd.TransitionController.VIEW_IS_VISIBLE_STATE);this.previouslyVisibleViewController.enterState(iAd.TransitionController.VIEW_IS_HIDDEN_STATE);this.previouslyVisibleViewController.exitState(iAd.TransitionController.VIEW_IDLE_STATE); |
if(this.previouslyVisibleViewController.buildOutAnimationNames.length>0){iAd.ViewControllerBuildStateManager.manage(iAd.TransitionController.VIEW_BUILDS_OUT_STATE,this.previouslyVisibleViewController,this);if(this.previouslyVisibleViewController.buildOutAnimationsShouldDelayTransition)this.transitionIsDelayedByPreviouslyVisibleViewController=true}}if(a===null)this.performTransitionToViewController(a,b);else{this.attachViewController(a);this.nextVisibleViewController=a;this.willUseAnimationToTransitionToNextVisibleViewController= |
b;if(a.loading)a.addPropertyObserver("viewWasProcessed",this,"viewControllerFinishedProcessingView");else this.transitionIsDelayedByPreviouslyVisibleViewController||this.performTransitionToViewController(a,b)}}}; |
iAd.TransitionController.prototype.performTransitionToViewController=function(a,b){a!==null&&a.view.layer.removeClassName("ad-waiting-on-display");a.exitState(iAd.TransitionController.VIEW_IS_HIDDEN_STATE);a.enterState(iAd.TransitionController.VIEW_IS_VISIBLE_STATE);a.exitState(iAd.TransitionController.VIEW_IDLE_STATE);a.buildInAnimationNames.length>0&&iAd.ViewControllerBuildStateManager.manage(iAd.TransitionController.VIEW_BUILDS_IN_STATE,a,this);iAd.Transaction.begin();this.dispatchNotification(iAd.TransitionController.WILL_MAKE_VIEW_CONTROLLER_VISIBLE, |
this.delegate,[["newlyVisibleViewController",a],["previouslyVisibleViewController",this.previouslyVisibleViewController],["animated",b]]);var c,d=null;this.busy=b;iAd.Transaction.defaults.duration=b?iAd.TransitionController.DEFAULT_TRANSITION_DURATION:0;if(this.previouslyVisibleViewController!==null){c=b?this.previouslyVisibleViewController.becomesHiddenTransition:null;if(c!==null)c=this.viewForTransition(this.previouslyVisibleViewController).applyTransition(c,false)}if(a!==null){d=b?a.becomesVisibleTransition: |
null;if(d!==null)d=this.viewForTransition(a).applyTransition(d,false)}if(d instanceof iAd.Transition)d.delegate=this;else if(d instanceof iAd.Transition)c.delegate=this;else b=false;this.previouslyVisibleViewController!==null&&this.previouslyVisibleViewController.viewWillDisappear(b);a!==null&&a.viewWillAppear(b);this._visibleViewController=a;iAd.Transaction.commit();b||this.transitionDidComplete()}; |
iAd.TransitionController.prototype.viewControllerFinishedProcessingView=function(a){a.removePropertyObserver("viewWasProcessed",this);this.transitionIsDelayedByPreviouslyVisibleViewController||this.performTransitionToViewController(a,this.willUseAnimationToTransitionToNextVisibleViewController)};iAd.TransitionController.prototype.viewForTransition=function(a){var b=a.view;if(b.size.equals(iAd.Size.ZERO_SIZE)&&a.contentView!==null)b=a.contentView;return b}; |
iAd.TransitionController.prototype.viewControllerExitedBuildState=function(a,b){if(this.transitionIsDelayedByPreviouslyVisibleViewController&&b===iAd.TransitionController.VIEW_BUILDS_OUT_STATE){this.transitionIsDelayedByPreviouslyVisibleViewController=false;this.nextVisibleViewController.viewWasProcessed&&this.performTransitionToViewController(this.nextVisibleViewController,this.willUseAnimationToTransitionToNextVisibleViewController)}else b===iAd.TransitionController.VIEW_BUILDS_IN_STATE&&!this.busy&& |
a.enterState(iAd.TransitionController.VIEW_IDLE_STATE)}; |
iAd.TransitionController.prototype.transitionDidComplete=function(){var a=this.busy;if(this.previouslyVisibleViewController!==null){this._cachedViewControllers.indexOf(this.previouslyVisibleViewController)==-1?this.previouslyVisibleViewController.view.removeFromSuperview():this.previouslyVisibleViewController.view.layer.addClassName("ad-waiting-on-display");this.previouslyVisibleViewController.viewDidDisappear(a)}if(this._visibleViewController!==null){this._visibleViewController.viewDidAppear(a); |
if(this._visibleViewController.buildInAnimationNames.length<0||!this._visibleViewController.isInState(iAd.TransitionController.VIEW_BUILDS_IN_STATE))this._visibleViewController.enterState(iAd.TransitionController.VIEW_IDLE_STATE)}this.busy=false;this.dispatchNotification(iAd.TransitionController.DID_MAKE_VIEW_CONTROLLER_VISIBLE,this.delegate,[["newlyVisibleViewController",this._visibleViewController],["previouslyVisibleViewController",this.previouslyVisibleViewController],["animated",a]])}; |
iAd.ViewController.prototype.getTransitionController=function(){return this.parentControllerOfKind(iAd.TransitionController)};iAd.ViewController.prototype.processTransitionAnchors=function(){for(var a,b=this.view.layer.querySelectorAll("[ad-transitions-to]"),c=0;c<b.length;c++){a=b[c];a.addEventListener(iAd.Control.TOUCH_UP_INSIDE_EVENT,this,false);a.addEventListener("click",this,false)}}; |
iAd.ViewController.prototype.handleTransitionAnchorActivation=function(a){var b=a.currentTarget;if(b.hasAttribute("ad-transitions-to"))if(!(a.type=="click"&&iAd.Control.isNodeInControlHierarchyBoundedByElement(a.target,b))){a=b.getAttribute("ad-transitions-to");iAd.ViewController.instances.hasOwnProperty(a)&&iAd.RootViewController.sharedRootViewController.transitionController.setVisibleViewControllerAnimated(iAd.ViewController.instances[a],true)}}; |
iAd.ViewController.addViewProcessor({processor:"processTransitionAnchors",handler:"handleTransitionAnchorActivation",eventTypes:[iAd.Control.TOUCH_UP_INSIDE_EVENT,"click"]});iAd.Class.synthesizeProperties(iAd.ViewController,["transitionController"]);iAd.Class.processMethods(iAd.ViewController,["processTransitionAnchors","handleTransitionAnchorActivation"]); |
iAd.RootViewController.prototype.getTransitionController=function(){if(!this.hasOwnProperty("_transitionController")){var a=iAd.RootView.sharedRoot,b=new iAd.TransitionController;b.view.size=a.size.copy();b.view.autoresizingMask=iAd.View.AUTORESIZING_FLEXIBLE_WIDTH&iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT;b.delegate=this;a.addSubview(b.view,0);this._transitionController=b}return this._transitionController};iAd.Class.synthesizeProperties(iAd.RootViewController,["transitionController"]); |
iAd.ViewControllerBuildStateManager=function(a,b,c){this.state=a;this.viewController=b;this.transitionController=c;b.enterState(a);b.view.layer.addEventListener("webkitAnimationEnd",this,true);this.animationNames=b[this.state===iAd.TransitionController.VIEW_BUILDS_OUT_STATE?"buildOutAnimationNames":"buildInAnimationNames"];this.runningAnimations=this.animationNames.length}; |
iAd.ViewControllerBuildStateManager.prototype.handleEvent=function(a){if(this.animationNames.indexOf(a.animationName)!=-1){this.runningAnimations--;if(this.runningAnimations<=0){a.currentTarget.removeEventListener("webkitAnimationEnd",this,true);this.viewController.exitState(this.state);this.transitionController.viewControllerExitedBuildState(this.viewController,this.state)}}};iAd.ViewControllerBuildStateManager.manage=function(a,b,c){new iAd.ViewControllerBuildStateManager(a,b,c)}; |
iAd.Class({name:"iAd.NavigationController",superclass:iAd.ViewController,synthesizedProperties:["viewControllers","topViewController","visibleViewController","navigationBarHidden","toolbarHidden"]});iAd.NavigationController.WILL_SHOW_VIEW_CONTROLLER="navigationControllerWillShowViewControllerAnimated";iAd.NavigationController.DID_SHOW_VIEW_CONTROLLER="navigationControllerDidShowViewControllerAnimated";iAd.NavigationController.HIDE_SHOW_BAR_DURATION=0.2; |
iAd.NavigationController.prototype.init=function(a,b){this.callSuper(a);this.delegate=null;this._viewControllers=[];this._navigationBarHidden=false;this._toolbarHidden=true;this.navigationBar=new iAd.NavigationBar;this.toolbar=null;this.requiresDeferredHostViewSizeUpdate=false;this.delayedSetOperationArguments=this.previousController=null;this.backingTransitionController=new iAd.TransitionController;this.backingTransitionController.delegate=this;if(b!==undefined)this.viewControllers=[b]}; |
iAd.NavigationController.prototype.loadView=function(){this.callSuper();this._view=new iAd.NavigationView(this);this._view.layer.addClassName("ad-navigation-controller-view");this._view.clipsToBounds=true;this._view.addSubview(this.navigationBar);this.navigationBar.autoresizingMask=iAd.View.AUTORESIZING_FLEXIBLE_WIDTH;this.navigationBar.size=new iAd.Size(window.innerWidth,iAd.NavigationBar.DEFAULT_HEIGHT);this.hostView=this._view.addSubview(this.backingTransitionController.view);this.hostView.layer.addClassName("ad-navigation-controller-host-view"); |
this.toolbar=this._view.addSubview(new iAd.Toolbar);this.toolbar.autoresizingMask=iAd.View.AUTORESIZING_FLEXIBLE_WIDTH;this.toolbar.size=new iAd.Size(window.innerWidth,iAd.Toolbar.DEFAULT_HEIGHT);this._view.addPropertyObserver("size",this,"sizeChanged");this._view.size=new iAd.Size(window.innerWidth,window.innerHeight);this._view.autoresizingMask=iAd.View.AUTORESIZING_FLEXIBLE_WIDTH|iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT}; |
iAd.NavigationController.prototype.viewMovedToNewSuperview=function(){var a=this.navigationBar.topItem;a!==null&&a.updateLayoutIfTopItem()}; |
iAd.NavigationController.prototype.sizeChanged=function(){var a=-iAd.NavigationBar.DEFAULT_HEIGHT,b=0,c=this._view.size.height;if(!this._navigationBarHidden){a=0;b+=iAd.NavigationBar.DEFAULT_HEIGHT}this._toolbarHidden||(c-=iAd.Toolbar.DEFAULT_HEIGHT);this.navigationBar.position=new iAd.Point(0,a);this.toolbar.position=new iAd.Point(0,c);this.hostView.position=new iAd.Point(0,b);this.updateHostViewSize()}; |
iAd.NavigationController.prototype.updateHostViewSize=function(){var a=this._view.size.height;this._navigationBarHidden||(a-=iAd.NavigationBar.DEFAULT_HEIGHT);this._toolbarHidden||(a-=iAd.Toolbar.DEFAULT_HEIGHT);this.hostView.size=new iAd.Size(this._view.size.width,a)};iAd.NavigationController.prototype.getTopViewController=function(){return this.viewControllers.length>0?this.viewControllers[this.viewControllers.length-1]:null}; |
iAd.NavigationController.prototype.getVisibleViewController=function(){var a=this.topViewController;return a.modalViewController||a};iAd.NavigationController.prototype.getViewControllers=function(){return this.delayedSetOperationArguments!==null?this.delayedSetOperationArguments[0]:this._viewControllers};iAd.NavigationController.prototype.setViewControllers=function(a){this.setViewControllersAnimated(a,false)}; |
iAd.NavigationController.prototype.setViewControllersAnimated=function(a,b){if(a.length!=0)if(this.backingTransitionController.busy||this.navigationBar.busy)this.delayedSetOperationArguments=arguments;else{iAd.Transaction.begin();this.isViewLoaded()||this.loadView();var c=this._viewControllers.length>0?this._viewControllers[this._viewControllers.length-1]:null,d=a[a.length-1],e=this._viewControllers.indexOf(d)!=-1;this.dispatchNotification(iAd.NavigationController.WILL_SHOW_VIEW_CONTROLLER,this.delegate, |
[["viewController",d],["animated",b]]);for(var f=0;f<this._viewControllers.length;f++)this._viewControllers[f].parentViewController=null;for(f=0;f<a.length;f++)a[f].parentViewController=this;d.view.size=this.hostView.size.copy();d.view.autoresizingMask=iAd.View.AUTORESIZING_FLEXIBLE_WIDTH|iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT;if(c===null){d.becomesVisibleTransition=d.becomesTopItemTransition;this.backingTransitionController.visibleViewController=d}else if(c!==d){c.becomesHiddenTransition=e?c.wasTopItemTransition: |
c.becomesBackItemTransition;d.becomesVisibleTransition=e?d.wasBackItemTransition:d.becomesTopItemTransition;this.backingTransitionController.setVisibleViewControllerAnimated(d,b)}this._viewControllers=a;c=[];for(f=0;f<a.length;f++)c.push(a[f].navigationItem);this.navigationBar.setItemsAnimated(c,b);d=d.toolbarItems;d!==null&&this.toolbar.setItemsAnimated(d,b);iAd.Transaction.commit()}}; |
iAd.NavigationController.prototype.pushViewControllerAnimated=function(a,b){this.setViewControllersAnimated(this.viewControllers.concat([a]),b)};iAd.NavigationController.prototype.popViewControllerAnimated=function(a){if(this.viewControllers.length>1){var b=this.topViewController;this.setViewControllersAnimated(this.viewControllers.slice(0,this.viewControllers.length-1),a);return b}return null}; |
iAd.NavigationController.prototype.popToRootViewControllerAnimated=function(a){return this.popToViewControllerAnimated(this.viewControllers[0],a)};iAd.NavigationController.prototype.popToViewControllerAnimated=function(a,b){var c=this.viewControllers.indexOf(a);if(c<0||c>=this.viewControllers.length-1)return[];var d=this.viewControllers.slice(c+1);this.setViewControllersAnimated(this.viewControllers.slice(0,c+1),b);return d}; |
iAd.NavigationController.prototype.setNavigationBarHidden=function(a){this.setNavigationBarHiddenAnimated(a,false)}; |
iAd.NavigationController.prototype.setNavigationBarHiddenAnimated=function(a,b){if(this._navigationBarHidden!=a){this._navigationBarHidden=a;if(this.isViewLoaded()){iAd.Transaction.begin();iAd.Transaction.defaults.duration=b?iAd.NavigationController.HIDE_SHOW_BAR_DURATION:0;iAd.Transaction.defaults.properties=["position"];(new iAd.Transition({target:this.navigationBar,to:[new iAd.Point(0,a?-iAd.NavigationBar.DEFAULT_HEIGHT:0)]})).start();(new iAd.Transition({target:this.hostView,to:[new iAd.Point(0, |
a?0:iAd.NavigationBar.DEFAULT_HEIGHT)],delegate:this})).start();iAd.Transaction.commit();if(!b||a)this.updateHostViewSize();else this.requiresDeferredHostViewSizeUpdate=true}}};iAd.NavigationController.prototype.transitionDidComplete=function(){if(this.requiresDeferredHostViewSizeUpdate){this.requiresDeferredHostViewSizeUpdate=false;this.updateHostViewSize()}};iAd.NavigationController.prototype.setToolbarHidden=function(a){this.setToolbarHiddenAnimated(a,false)}; |
iAd.NavigationController.prototype.setToolbarHiddenAnimated=function(a,b){if(this._toolbarHidden!=a){this._toolbarHidden=a;if(this.isViewLoaded()){(new iAd.Transition({target:this.toolbar,properties:["position"],to:[new iAd.Point(0,this._view.size.height-(a?0:iAd.NavigationBar.DEFAULT_HEIGHT))],duration:b?iAd.NavigationController.HIDE_SHOW_BAR_DURATION:0,delegate:this})).start();if(!b||a)this.updateHostViewSize();else this.requiresDeferredHostViewSizeUpdate=true}}}; |
iAd.NavigationController.prototype.transitionControllerDidMakeViewControllerVisibleAnimated=function(a,b,c,d){this.dispatchNotification(iAd.NavigationController.DID_SHOW_VIEW_CONTROLLER,this.delegate,[["viewController",b],["animated",d]]);this.performDelayedSetOperation()}; |
iAd.NavigationController.prototype.performDelayedSetOperation=function(){if(this.delayedSetOperationArguments!==null)if(this.navigationBar.busy)this.navigationBar.addPropertyObserver("busy",this,"navigationBarBusyStateChanged");else{this.setViewControllersAnimated(this.delayedSetOperationArguments[0],this.delayedSetOperationArguments[1]);this.delayedSetOperationArguments=null}}; |
iAd.NavigationController.prototype.navigationBarBusyStateChanged=function(){if(!this.navigationBar.busy){this.navigationBar.removePropertyObserver("busy",this,"navigationBarBusyStateChanged");this.performDelayedSetOperation()}};iAd.Class({name:"iAd.NavigationView",superclass:iAd.View});iAd.NavigationView.prototype.init=function(a){this.callSuper();this.viewController=a};iAd.NavigationView.prototype.didMoveToSuperview=function(a){this.callSuper(a);a!==null&&this.viewController.viewMovedToNewSuperview()}; |
iAd.ViewController.prototype.getNavigationController=function(){return this.parentControllerOfKind(iAd.NavigationController)};iAd.ViewController.prototype.getNavigationItem=function(){if(this._navigationItem===null){this._navigationItem=new iAd.NavigationItem(this.title);this._navigationItem.viewController=this}return this._navigationItem};iAd.ViewController.prototype.setToolbarItems=function(a){this.setToolbarItemsAnimated(a,false)}; |
iAd.ViewController.prototype.setToolbarItemsAnimated=function(a,b){this._toolbarItems=a;var c=this.parentViewController;c!==null&&c instanceof iAd.NavigationController&&c.toolbar.setItemsAnimated(a,b)};iAd.Class.synthesizeProperties(iAd.ViewController,["navigationController","navigationItem","toolbarItems"]);iAd.Class.processMethods(iAd.ViewController,["setToolbarItemsAnimated"]); |
iAd.Class({name:"iAd.TabBarController",superclass:iAd.ViewController,synthesizedProperties:["viewControllers","selectedViewController","selectedIndex"]});iAd.TabBarController.SHOULD_SELECT_VIEW_CONTROLLER="tabBarControllerShouldSelectViewController";iAd.TabBarController.DID_SELECT_VIEW_CONTROLLER="tabBarControllerDidSelectViewController";iAd.TabBarControllerMaxItems=5; |
iAd.TabBarController.prototype.init=function(a){this.callSuper(a);this.delegate=null;this.tabBar=new iAd.TabBar;this._viewControllers=[];this.customizableViewControllers=[];this.moreNavigationController=null;this.tabBar.delegate=this}; |
iAd.TabBarController.prototype.loadView=function(){this.callSuper();this._view=new iAd.View(this);this._view.layer.addClassName("ad-tab-bar-controller-view");this._view.size=new iAd.Size(window.innerWidth,window.innerHeight);this._view.autoresizingMask=iAd.View.AUTORESIZING_FLEXIBLE_WIDTH|iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT;this.hostView=this._view.addSubview(new iAd.View);this.hostView.layer.addClassName("ad-tab-bar-controller-host-view");this.hostView.size=new iAd.Size(this._view.size.width,this._view.size.height- |
iAd.TabBar.DEFAULT_HEIGHT);this.hostView.autoresizingMask=iAd.View.AUTORESIZING_FLEXIBLE_WIDTH|iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT;this._view.addSubview(this.tabBar);this.tabBar.autoresizingMask=iAd.View.AUTORESIZING_FLEXIBLE_WIDTH|iAd.View.AUTORESIZING_FLEXIBLE_TOP_MARGIN}; |
iAd.TabBarController.prototype.tabBarDidSelectItem=function(){for(;this.hostView.subviews.length;)this.hostView.subviews[0].removeFromSuperview();var a=this.selectedViewController,b=a.view;a.viewWillAppear(false);b.size=this.hostView.size.copy();b.autoresizingMask=iAd.View.AUTORESIZING_FLEXIBLE_WIDTH|iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT;this.hostView.addSubview(b);iAd.Utils.objectHasMethod(this.delegate,iAd.TabBarController.DID_SELECT_VIEW_CONTROLLER)&&this.delegate[iAd.TabBarController.DID_SELECT_VIEW_CONTROLLER](this, |
a);a.viewDidAppear(false)};iAd.TabBarController.prototype.setViewControllers=function(a){this.setViewControllersAnimated(a,false)};iAd.TabBarController.prototype.setViewControllersAnimated=function(a,b){this._viewControllers=a;for(var c=[],d=0;d<a.length;d++)c.push(a[d].tabBarItem);this.tabBar.setItemsAnimated(c,b)};iAd.TabBarController.prototype.getSelectedViewController=function(){var a=null,b=this.selectedIndex;if(b>=0&&b<this._viewControllers.length)a=this._viewControllers[b];return a}; |
iAd.TabBarController.prototype.setSelectedViewController=function(a){if(this._viewControllers.indexOf(a)!=-1)this.tabBar.selectedItem=a.tabBarItem};iAd.TabBarController.prototype.getSelectedIndex=function(){return this.tabBar.items.indexOf(this.tabBar.selectedItem)};iAd.TabBarController.prototype.setSelectedIndex=function(a){if(a>=0&&a<this._viewControllers.length)this.tabBar.selectedItem=this._viewControllers[a]};iAd.ViewController.prototype.getTabBarController=function(){return this.parentControllerOfKind(iAd.TabBarController)}; |
iAd.ViewController.prototype.getTabBarItem=function(){if(this._tabBarItem===null){this._tabBarItem=new iAd.TabBarItem;this._tabBarItem.title=this.title;this._tabBarItem.viewController=this}return this._tabBarItem};iAd.Class.synthesizeProperties(iAd.ViewController,["tabBarController","tabBarItem"]);iAd.Class({name:"iAd.PageController",superclass:iAd.ViewController,synthesizedProperties:["viewControllers","scrollsInfinitely"]});iAd.PageController.DEFAULT_PAGE_CONTROL_HEIGHT=38; |
iAd.PageController.prototype.init=function(a,b){this.callSuper(a);this._scrollsInfinitely=this.shouldIgnoreCurrentPageChange=this.animatingToNewPage=this.subviewsWereCreated=false;this.pageControl=this.scrollView=null;this.viewControllers=b||[]};iAd.PageController.prototype.loadView=function(){this.callSuper();if(!this.configuration.hasOwnProperty("requiredFileURIs")){this.view=new iAd.PageControllerView;this.createSubviews()}}; |
iAd.PageController.prototype.viewDidLoad=function(){this.callSuper();if(this.contentView!==null){this.scrollView=this.outlets.scrollView;this.pageControl=this.outlets.pageControl;this.didCreateSubviews()}};iAd.PageController.prototype.setViewControllers=function(a){this._viewControllers=a;if(this.subviewsWereCreated){this.pageControl.numberOfPages=a.length;this.layoutPages()}}; |
iAd.PageController.prototype.setScrollsInfinitely=function(a){if(this._scrollsInfinitely!=a){this._scrollsInfinitely=a;this.subviewsWereCreated&&this.layoutPages()}};iAd.PageController.prototype.createSubviews=function(){this._view.size=new iAd.Size(window.innerWidth,window.innerHeight);this.scrollView=this._view.addSubview(new iAd.ScrollView);this.pageControl=this._view.addSubview(new iAd.PageControl);this.didCreateSubviews()}; |
iAd.PageController.prototype.didCreateSubviews=function(){this.scrollView.size=this._view.size.copy();this.scrollView.verticalScrollEnabled=false;this.scrollView.showsHorizontalScrollIndicator=false;this.scrollView.autoresizingMask=iAd.View.AUTORESIZING_FLEXIBLE_WIDTH|iAd.View.AUTORESIZING_FLEXIBLE_HEIGHT;this.pageControl.position=new iAd.Point(0,this._view.size.height-iAd.PageController.DEFAULT_PAGE_CONTROL_HEIGHT);this.pageControl.size=new iAd.Size(this.scrollView.size.width,iAd.PageController.DEFAULT_PAGE_CONTROL_HEIGHT); |
this.pageControl.autoresizingMask=iAd.View.AUTORESIZING_FLEXIBLE_TOP_MARGIN|iAd.View.AUTORESIZING_FLEXIBLE_WIDTH;this.scrollView.pagingEnabled=true;this.pageControl.numberOfPages=this._viewControllers.length;this.pageControl.addEventListener(iAd.Control.VALUE_CHANGE_EVENT,this,false);this.scrollView.delegate=this;this.scrollView.addPropertyObserver("tracking",this,"scrollViewTrackingDidChange");this.subviewsWereCreated=true;this.layoutPages()}; |
iAd.PageController.prototype.updateStateProperties=function(){this.pageWidth=this.scrollView.size.width;this.currentPage=this.pageControl.currentPage;this.canScrollLeft=this.scrollsInfinitely||this.currentPage!=0;this.canScrollRight=this.scrollsInfinitely||this.currentPage!=this._viewControllers.length-1}; |
iAd.PageController.prototype.layoutPages=function(){this.updateStateProperties();for(var a=this.canScrollLeft?this.paddedIndex(this.currentPage-1):-1,b=this.canScrollRight?this.paddedIndex(this.currentPage+1):-1,c,d,e=0;e<this._viewControllers.length;e++){c=this._viewControllers[e];if(e==a)d=0;else if(e==this.currentPage)d=this.canScrollLeft?this.pageWidth:0;else if(e==b)d=this.canScrollLeft?this.pageWidth*2:this.pageWidth;else{c.isViewLoaded()&&c.view.removeFromSuperview();continue}c=c.view;c.position= |
new iAd.Point(d,0);c.size=this.scrollView.size.copy();c.superview!==this.scrollView&&this.scrollView.addSubview(c)}this.scrollView.contentOffset=new iAd.Point(this.canScrollLeft?this.pageWidth:0,0)};iAd.PageController.prototype.handleEvent=function(a){this.callSuper(a);if(a.type==iAd.Control.VALUE_CHANGE_EVENT)if(this.shouldIgnoreCurrentPageChange)this.shouldIgnoreCurrentPageChange=false;else this.syncScrollViewToPageControl(this.pageControl.currentPage)}; |
iAd.PageController.prototype.syncScrollViewToPageControl=function(){var a=this._viewControllers[this.pageControl.currentPage].view;if(this.scrollView.subviews.indexOf(a)==-1)this.layoutPages();else if(a.position.x!=this.scrollView.contentOffset.x){this.animatingToNewPage=true;this.scrollView.setContentOffsetAnimated(new iAd.Point(a.position.x,0),true)}}; |
iAd.PageController.prototype.scrollViewTrackingDidChange=function(){if(this.scrollView.tracking){this.updateStateProperties();var a=this.scrollView.contentOffset.x+(this.canScrollLeft?0:this.pageWidth),b=this.paddedIndex(this.currentPage-1+Math.round(a/this.pageWidth));if(b!=this.currentPage){this.shouldIgnoreCurrentPageChange=true;this.pageControl.currentPage=b;this.layoutPages();this.scrollView.contentOffset=new iAd.Point(this.scrollView.contentOffset.x>a?a+this.pageWidth:a-this.pageWidth,0)}}}; |
iAd.PageController.prototype.scrollViewMayHaveMovedToNewPage=function(){this.updateStateProperties();var a=Math.round(this.currentPage+(this.scrollView.contentOffset.x-(this.canScrollLeft?this.pageWidth:0))/this.pageWidth);if(this.currentPage!==a){this.pageControl.currentPage=this.paddedIndex(a);this.layoutPages()}};iAd.PageController.prototype.scrollViewDidEndScrollingAnimation=function(){if(this.animatingToNewPage){this.animatingToNewPage=false;this.layoutPages()}else this.scrollViewMayHaveMovedToNewPage()}; |
iAd.PageController.prototype.scrollViewWillBeginDecelerating=function(){if(this.scrollView.bounces){this.updateStateProperties();var a=this.scrollView.decelerationVelocity.x<0,b=this.paddedIndex(this.currentPage+(a?-1:1)),c=this.scrollsInfinitely||b!=0;b=this.scrollsInfinitely||b!=this._viewControllers.length-1;if(!(a&&!c||!a&&!b)){if(a){c=this.currentPage-2;a=-this.pageWidth}else{c=this.currentPage+2;a=this.pageWidth*(this.canScrollLeft?3:2)}c=this._viewControllers[this.paddedIndex(c)].view;c.position= |
new iAd.Point(a,0);c.size=this.scrollView.size.copy();this.scrollView.addSubview(c)}}};iAd.PageController.prototype.scrollViewDidEndDecelerating=function(){this.scrollViewMayHaveMovedToNewPage()};iAd.PageController.prototype.paddedIndex=function(a){return(a+this.pageControl.numberOfPages)%this.pageControl.numberOfPages}; |
iAd.PageController.pageControllerWithView=function(a){var b=new iAd.PageController({id:a.layer.hasAttribute("id")?a.layer.getAttribute("id"):"",properties:{view:a}});b.scrollView=b.outlets.scrollView;b.pageControl=b.outlets.pageControl;b.didCreateSubviews();for(var c=[],d=b.scrollView.subviews,e=0;e<d.length;e++){a=d[e];a._viewController===undefined&&a.createManagingViewController();c.push(a._viewController)}b.viewControllers=c;return b}; |
iAd.Class({name:"iAd.PageControllerView",superclass:iAd.View,cssClassName:"ad-page-controller-view"});iAd.PageControllerView.prototype.init=function(a){this.callSuper(a)};iAd.PageControllerView.prototype.readPropertiesFromLayerAttributes=function(a){iAd.PageController.pageControllerWithView(this);this.callSuper(a)};iAd.PageControllerView.prototype.setValueForAttribute=function(a,b){if(b=="ad-scrolls-infinitely")this._viewController.scrollsInfinitely=a!="false";else this.callSuper(a,b)}; |
iAd.Class({name:"iAd.Analytics",superclass:iAd.Object,synthesizedProperties:["logsToConsole"]});iAd.Analytics.ANALYTICS_FORMAT_VERSION=1.1;iAd.Analytics.ANALYTICS_DUMP_RATE=3500;iAd.Analytics.ANALYTICS_OBJECT_ID_METHOD="analyticsObjectId";iAd.Analytics.ANALYTICS_CATEGORY_METHOD="analyticsCategory";iAd.Analytics.ANALYTICS_SHOULD_REPORT_FOR_EVENT_OF_TYPE_METHOD="analyticsShouldReportForEventOfType";iAd.Analytics.ANALYTICS_CONTEXT_FOR_EVENT_METHOD="analyticsContextForEvent"; |
iAd.Analytics.prototype.init=function(){this.callSuper();this._observedObjects=[];this._queue=[];this._logsToConsole=false;this._logger=this._defaultLogger=function(b){window.hasOwnProperty("ad")&&window.ad.reportClickEvent(b)};var a=this;setInterval(function(){var b=a._queue,c,d=b.length,e;for(e=0;e<d;e+=1){c=b.shift();if(!(!a._logger||typeof a._logger!=="function")){var f=void 0;f=void 0;f={v:iAd.Analytics.ANALYTICS_FORMAT_VERSION};f[c.time]={s:c.source,n:c.name,t:c.type,a:c.args};f=JSON.stringify(f); |
a._logger(f)}}},iAd.Analytics.ANALYTICS_DUMP_RATE)};iAd.Analytics.prototype.getLogsToConsole=function(){return this._logsToConsole};iAd.Analytics.prototype.setLogsToConsole=function(a){a=!!a;if(a!==this._logsToConsole)this._logger=a===true?function(b){window.console.log("[ANALYTICS]: "+b);this._defaultLogger(b)}:this.defaultLogger}; |
iAd.Analytics.prototype.registerEventsForObject=function(a,b){if(a){if(typeof a.map==="function"){var c=this;a.map(function(d){document.addEventListener(d,c,false)})}else document.addEventListener(a,this,false);this._observedObjects.push(b)}}; |
iAd.Analytics.prototype.handleEvent=function(a){var b=a.ad.sender||a.target;if(b){if(iAd.Utils.objectHasMethod(b,iAd.Analytics.ANALYTICS_SHOULD_REPORT_FOR_EVENT_OF_TYPE_METHOD))if(b[iAd.Analytics.ANALYTICS_SHOULD_REPORT_FOR_EVENT_OF_TYPE_METHOD](a.type)!==true)return;var c=Date.now(),d;d=iAd.Utils.objectHasMethod(b,iAd.Analytics.ANALYTICS_OBJECT_ID_METHOD)?b[iAd.Analytics.ANALYTICS_OBJECT_ID_METHOD]():b.toString();var e="";if(iAd.Utils.objectHasMethod(b,iAd.Analytics.ANALYTICS_CATEGORY_METHOD))e= |
b[iAd.Analytics.ANALYTICS_CATEGORY_METHOD]();var f="";if(iAd.Utils.objectHasMethod(b,iAd.Analytics.ANALYTICS_CONTEXT_FOR_EVENT_METHOD))f=b[iAd.Analytics.ANALYTICS_CONTEXT_FOR_EVENT_METHOD](a);a=a.type;switch(a){case "viewControllerViewWillAppear":a="viewWillAppear";break;case "viewControllerViewDidAppear":a="viewDidAppear";break;case "viewControllerViewWillDisappear":a="viewWillDisappear";break;case "viewControllerViewDidDisappear":a="viewDidDisappear"}this._queue.push({time:c,source:d,name:a,type:e, |
args:f})}};Object.defineProperty(iAd.Analytics,"sharedObject",{get:function(){if(!iAd.Analytics.hasOwnProperty("_sharedObject"))iAd.Analytics.sharedObject=new iAd.Analytics;return iAd.Analytics._sharedObject},set:function(a){iAd.Analytics._sharedObject=a}}); |
(function(){iAd.ViewController||console.warn("ANALYTICS: iAd.ViewController has not been processed and cannot be augmented.");iAd.Class.processMethod(iAd.ViewController,"init");var a=iAd.ViewController.prototype.init;iAd.ViewController.prototype.init=function(){a.apply(this,arguments);iAd.Analytics.sharedObject.registerEventsForObject([iAd.ViewController.VIEW_WILL_APPEAR_EVENT,iAd.ViewController.VIEW_DID_APPEAR_EVENT,iAd.ViewController.VIEW_WILL_DISAPPEAR_EVENT,iAd.ViewController.VIEW_DID_DISAPPEAR_EVENT], |
this)}})();iAd.ViewController.prototype.analyticsObjectId=function(){return this.configuration.id};iAd.Class.processMethod(iAd.ViewController,"analyticsObjectId");iAd.ViewController.prototype.analyticsCategory=function(){return"view"};iAd.Class.processMethod(iAd.ViewController,"analyticsCategory");iAd.ViewController.prototype.analyticsContextForEvent=function(a){return a.ad.animated?"animated":"not animated"};iAd.Class.processMethod(iAd.ViewController,"analyticsContextForEvent"); |
Copyright © 2011 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2011-03-08