Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2013
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.46 KB | None | 0 0
  1. var MMAppStore,MMBanner,MMBrand,MMBridgeObject,MMCachedVideo,MMCalendar,MMCommand,MMDevice,MMFileManager,MMInlineVideo,MMInterstitial,MMJS,MMJSUtils,MMMedia,MMNotification,MMPassbook,MMPasteboard,MMSDKInterface,MMSocial,MRAID,__hasProp={}.hasOwnProperty,__extends=function(child,parent){for(var key in parent){if(__hasProp.call(parent,key))child[key]=parent[key];}function ctor(){this.constructor=child;}ctor.prototype=parent.prototype;child.prototype=new ctor();child.__super__=parent.prototype;return child;};String.prototype.trim=function(){return this.replace(RegExp("^\\s+|\\s+$","g"),"");};String.prototype.titleCase=function(){return this.replace(RegExp("\\w\\S*","g"),function(str){return str.charAt(0).toUpperCase().concat(str.substr(1).toLowerCase());});};if(typeof MMJS===typeof void 0){MMJSUtils=(function(){function MMJSUtils(){}
  2. MMJSUtils.ios_version=null;MMJSUtils.platform=null;MMJSUtils.sdk_version=null;MMJSUtils.params=null;MMJSUtils.isBridgeEnabled=function(){if(MMDevice.readyState!=="unknown"){return true;}
  3. return false;};MMJSUtils.isPre46=function(a){if(this.isBridgeEnabled()===true){return false;}
  4. if(a==null){return true;}
  5. return this.underVersion(a,"4.6.0");};MMJSUtils.underVersion=function(versionString,minVersion){var i,res,result,v1,v2;if(versionString==null){return false;}
  6. v1=versionString.split(".");v2=minVersion.split(".");i=0;result=0;while(i<Math.min(v1.length,v2.length)){res=v1[i]-v2[i];if(res!==0){result=res;break;}
  7. i++;}
  8. return result<0;};MMJSUtils.isVersion=function(versionString){var i,res,result,v1,v2;if(versionString==null){return false;}
  9. v1=versionString.split(".");v2=this.sdkVersion().split(".");i=0;result=0;while(i<Math.min(v1.length,v2.length)){res=v1[i]-v2[i];if(res!==0){result=res;break;}
  10. i++;}
  11. return result===0;};MMJSUtils.isIOS=function(){return this.getPlatform()==="ios";};MMJSUtils.isWindows=function(){return this.getPlatform()==="windows";};MMJSUtils.isBlackBerry=function(){return this.getPlatform()==="blackberry";};MMJSUtils.isAndroid=function(){return this.getPlatform()==="android";};MMJSUtils.getPlatform=function(){if(this.platform!=null){return this.platform;}
  12. if(navigator.platform.match(/(Android)/)!=null){this.platform="android";}else if(navigator.platform.match(/^(iPad|iPod|iPhone)/)!=null){this.platform="ios";}else{this.platform="android";}
  13. return this.platform;};MMJSUtils.sdkVersion=function(){var mmisdk,params;if(this.sdk_version!=null){return this.sdk_version;}
  14. if(MMJS.sdkVersion!=null){this.sdk_verison=MMJS.sdkVersion;return this.sdk_version;}
  15. params=this.getParams();if(params['sdkversion']!=null){mmisdk=params['sdkversion'].split('-');this.sdk_version=mmisdk[0];return this.sdk_version;}
  16. return null;};MMJSUtils.simulateRedirect=function(url){var eventFire,linkTag;linkTag=document.createElement("a");linkTag.id="mm_simulateLink";linkTag.setAttribute("href",url);linkTag.setAttribute("style","opacity:0");document.body.appendChild(linkTag);eventFire=function(el,etype){var evObj;if(el.fireEvent){return el.fireEvent("on"+etype);}else{evObj=document.createEvent("Events");evObj.initEvent(etype,true,false);return el.dispatchEvent(evObj);}};return window.setTimeout((function(){var element;element=linkTag;return eventFire(linkTag,"click");}),1);};MMJSUtils.modDuration=function(duration){if(!this.isAndroid()){return duration;}
  17. if(duration<100){return duration*1000;}else{return duration;}};MMJSUtils.getParams=function(){var n,name,pair,params,qs,value,_i,_len,_ref,_ref1;if(this.params!=null){return this.params;}
  18. params={};qs=window.location.search.substring(1);if(qs.length){_ref=(function(){var _j,_len,_ref,_results;_ref=qs.split('&');_results=[];for(_j=0,_len=_ref.length;_j<_len;_j++){pair=_ref[_j];_results.push(pair.split('='));}
  19. return _results;})();for(_i=0,_len=_ref.length;_i<_len;_i++){_ref1=_ref[_i],name=_ref1[0],value=_ref1[1];n=name.replace("mm_","");if(value!=null){params[n]=value;}}}
  20. this.params=params;return this.params;};MMJSUtils.consoleLog=function(_msg,_useAlert){if(_useAlert==null){_useAlert=false;}
  21. MMJS.eventTracking.push(_msg);if(this.isAndroid()){if(window.console!=null){window.console.log(_msg);}}else if(this.isWindows()){window.external.notify(_msg);}else{if(window.console!=null){ window.console.log(_msg);}
  22. if(_useAlert){alert(_msg);}}
  23. return false;};MMJSUtils.iOSVersion=function(){var _v;if(this.ios_version){return this.ios_version;}
  24. _v=navigator.appVersion.split(' OS ')[1];_v=_v.split(' ')[0].trim().split('_');_v.splice(1,0,'.');return this.ios_version=parseFloat(_v.join(''));};MMJSUtils.getLocation=function(func,error){if(navigator.geolocation){return navigator.geolocation.getCurrentPosition(func,error,{enableHighAccuracy:true});}else{return error({code:99});}};MMJSUtils.listenForBrowserReady=function(func){if(this.isWindows()){return document.attachEvent("onreadystatechange",func);}else{return document.addEventListener("DOMContentLoaded",func,false);}};MMJSUtils.postEvent=function(event){var evObj;if(document.createEvent){evObj=document.createEvent("Event");evObj.initEvent(event,true,true);return window.document.dispatchEvent(evObj);}else if(document.createEventObject||this.isWindows()){return document.body.fireEvent("on"+event);}};MMJSUtils.offset=function(_el){var coords,p_coords;coords=[_el.offsetLeft,_el.offsetTop];if(_el.offsetParent!=null){p_coords=this.offset(_el.offsetParent);coords[0]+=p_coords[0];coords[1]+=p_coords[1];}
  25. return coords;};return MMJSUtils;})();MMJS=(function(){function MMJS(){}
  26. MMJS.VERSION="1.3";MMJS.commandQueue=[];MMJS.androidInterface=window['interface'];MMJS.utils=MMJSUtils;MMJS.sdkReady=false;MMJS.executingCommand=false;MMJS.executingCommandDelay=0;MMJS.params=null;MMJS.platform=null;
  27. MMJS.callbacks={};MMJS.listeners={};MMJS.sdkVersion=null;MMJS.openCalled=false;MMJS.TYPE_STRING=typeof "";MMJS.TYPE_OBJECT=typeof[];MMJS.TYPE_FUNCTION=typeof function(){};MMJS.TYPE_NUMBER=typeof 0;MMJS.TYPE_UNDEFINED="undefined";MMJS.eventTracking=[];MMJS.setExecutingCommand=function(_executing,_time){if(_time==null){_time=10000;}
  28. this.logCallstack();return this.executingCommand=_executing;};MMJS.logCallstack=function(){var callstack,currentFunction,fn,fname;callstack=[];currentFunction=arguments.callee.caller;while(currentFunction){fn=currentFunction.toString();fname=fn.substring(fn.indexOf("function")+8,fn.indexOf(""))||"anonymous";callstack.push(fname);currentFunction=currentFunction.caller;}
  29. return MMJS.utils.consoleLog(callstack);};MMJS.debug=function(){var toLog;toLog=this.eventTracking.join("\n");console.log(toLog);return true;};MMJS.setSDKVersion=function(version){return this.sdkVersion=version;};MMJS.mmsdkOpenFunction=null;MMJS.shouldOpenWasCalled=false;MMJS.setupOverlay=function(url,params){if(params==null){params={};}
  30. return this.open(url,params,false);};MMJS.open=function(url,params,autoExpand){if(params==null){params={};}
  31. if(autoExpand==null){autoExpand=true;}
  32. mraid.setExpandProperties(params);return mraid.expand(url);};MMJS.close=function(duration){var modDuration;if(duration==null){duration=0;}
  33. modDuration=function(duration){if(duration<100){return duration*1000;}else{return duration;}};return setTimeout(function(){return MMJS.interstitial.close();},modDuration(duration));};MMJS.openExternal=function(url){if(this.utils.isBridgeEnabled()){return MMDevice.openUrl(url);}else{if(this.utils.isIOS()){return window.location="mmbrowser:://"+url;}else{return window.location="mmbrowser://"+url;}}};MMJS.removeEventListener=function(event,listener){return delete this.listeners[event];};MMJS.addEventListener=function(event,listener){return this.listeners[event]=listener;};MMJS.enqueueCommand=function(command){this.commandQueue.push(command);return this.utils.consoleLog("commandQueue "+MMJS.commandQueue);};MMJS.callback=function(response){var klass,klassFunction,method,response_data,result;result=response['result'];method=response['call'];response_data=response['response'];klass=response['class'];klassFunction=window[klass];if(typeof klassFunction===this.TYPE_FUNCTION){return klassFunction(method,response_data,result);}};return MMJS;})();MMSDKInterface=(function(){function MMSDKInterface(){this.state="loading";this.isReady=false;this.adProperties={};this.viewable=false;this.placementType="unknown";this.listeners={};this.adSize={};this.defaultPosition={};this.utils=MMJS.utils;}
  34. MMSDKInterface.prototype.setAdSize=function(_properties){if(this.defaultPosition!=null){this.defaultPosition=this.adSize;}
  35. if(this.adSize){if(this.adSize["height"]!==_properties["height"]||this.adSize["width"]!==_properties["width"]){this.adSize=_properties;mraid.fireEventCallbacks("sizeChange",_properties["width"],_properties["height"]);}}else{this.adSize=_properties;}
  36. return this.utils.consoleLog("Setting Ad Size "+JSON.stringify(_properties));};MMSDKInterface.prototype.setAdProperties=function(_adProperties){this.utils.consoleLog('setAdProperties: '+JSON.stringify(_adProperties));this.adProperties=_adProperties;if(this.adProperties!=null){if(this.adProperties["ad"]!=null){this.adSize=this.adProperties["ad"];}
  37. if(this.adProperties["device"]!=null){MMJS.device.setInfo(this.adProperties["device"]);}
  38. if(this.adProperties["supports"]!=null){return this.supportProperties=this.adProperties["supports"];}}};MMSDKInterface.prototype.setPlacementType=function(placementType){this.placementType=placementType;};MMSDKInterface.prototype.setState=function(_state){if(this.state!==_state){this.utils.consoleLog('MRAID state change from "'+this.state+'" to "'+_state+'"');this.state=_state;return mraid.fireEventCallbacks("stateChange",_state);}};MMSDKInterface.prototype.setViewable=function(_visible){if(this.viewable!==_visible){this.utils.consoleLog('MRAID viewable change: visible = '+_visible);this.viewable=_visible;return mraid.fireEventCallbacks("viewableChange",_visible);}};MMSDKInterface.prototype.ready=function(){if(this.state!=="loading"&&this.isReady===false){this.utils.consoleLog('MRAID ready.');this.utils.postEvent("sdkready");this.isReady=true;return mraid.fireEventCallbacks("ready");}};MMSDKInterface.prototype.error=function(message,action){return mraid.fireEventCallbacks("error",message,action);};return MMSDKInterface;})();MMCommand=(function(){MMCommand.url=null;MMCommand.platform=null;MMCommand.command=null;MMCommand.callback=null;function MMCommand(command,params){var func,functionName,name,query_args,timestamp,url;this.utils=MMJS.utils;this.platform=this.utils.getPlatform();this.command=command;url="mmsdk://"+command+"/";if(params!=null){query_args=[];timestamp=new Date().getTime();func=params["callback"];functionName=this.command.replace(".","_")+"_"+timestamp;MMJS.utils.consoleLog("command: "+command+"Callback function: "+func);MMJS.utils.consoleLog("command: "+command+" params "+JSON.stringify(params));MMJS.utils.consoleLog("Callback function: "+(typeof func));if(typeof func===MMJS.TYPE_STRING){window["MMJS"]["callbacks"][functionName]=function(response){var aFunc,context,i,namespaces;MMJS.utils.consoleLog("executing string function callback: "+functionName);if(response!=null){response['data']=response['response'];}
  39. namespaces=func.split(".");aFunc=namespaces.pop();i=0;context=window;while(i<namespaces.length){MMJS.utils.consoleLog("namespace: "+namespaces[i]);context=context[namespaces[i]];i++;}
  40. MMJS.utils.consoleLog("aFunc: "+aFunc);MMJS.utils.consoleLog("context: "+context);context[aFunc](response);return MMJS.setExecutingCommand(false);};}else if(typeof func===MMJS.TYPE_FUNCTION){window["MMJS"]["callbacks"][functionName]=function(response){if(response!=null){response['data']=response['response'];response['result']=parseInt(response['result']);}
  41. func(response);return MMJS.setExecutingCommand(false);};}else if(typeof func===MMJS.TYPE_UNDEFINED){window["MMJS"]["callbacks"][functionName]=function(response){MMJS.utils.consoleLog("executing undefined callback: "+functionName);MMJS.utils.consoleLog("no callback was specified");return MMJS.setExecutingCommand(false);};}
  42. params["callback"]="MMJS.callbacks."+functionName;this.callback=params["callback"];for(name in params){if(typeof name!==MMJS.TYPE_STRING){continue;}
  43. if(params[name]===void 0||params[name]===null){continue;}else{query_args.push(encodeURIComponent(name)+"="+encodeURIComponent(params[name]));}}
  44. if(query_args.length>0){url+="?"+query_args.join("&");}}
  45. MMJS.utils.consoleLog(url);this.url=url;this;}
  46. MMCommand.prototype.perform=function(){var iframe;this.utils.consoleLog("perform platform: "+this.platform);this.utils.consoleLog("current window.location: "+window.location);MMJS.executingCommand=true;this.utils.consoleLog("window.location: "+this.url);this.utils.consoleLog("Setting executingCommand = true: ");iframe=document.createElement("IFRAME");iframe.setAttribute("src",this.url);document.documentElement.appendChild(iframe);iframe.parentNode.removeChild(iframe);return iframe=null;};return MMCommand;})();MMBridgeObject=(function(){MMBridgeObject.className=null;function MMBridgeObject(){var m;this.utils=MMJS.utils;m=this.constructor.toString().match(/^\s*function\s+([^\s\(]+)/);if(m){this.className=m[1];}}
  47. MMBridgeObject.prototype.enqueue=function(method,params){MMJS.enqueueCommand(new MMCommand(this.className+"."+method,params));return true;};return MMBridgeObject;})();MMDevice=(function(_super){__extends(MMDevice,_super);function MMDevice(){return MMDevice.__super__.constructor.apply(this,arguments);}
  48. MMDevice.loadState="standby";MMDevice.loadTimeout=0;MMDevice.connection=null;MMDevice.prototype.setNetworkConnection=function(network){return this.connection=network;};MMDevice.prototype.setInfo=function(info){var evt,key,value;for(key in info){value=info[key];this[key]=value;}
  49. MMDevice.loadState="loaded";if(!this.utils.isWindows()){evt="deviceLoaded";this.utils.postEvent(evt);evt="deviceloaded";this.utils.postEvent(evt);}
  50. return true;};MMDevice.prototype.getInfo=function(callback){MMDevice.loadState="loading";return this.enqueue("getInfo",{callback:callback});};MMDevice.prototype.setMMDID=function(mmdid,callback){return this.enqueue("setMMDID",{mmdid:mmdid,callback:callback});};MMDevice.prototype.getAvailableSchemes=function(callback){return this.enqueue("getAvailableSchemes",{callback:callback});};MMDevice.prototype.isSchemeAvailable=function(scheme,callback){return this.enqueue("isSchemeAvailable",{scheme:scheme,callback:callback});};MMDevice.prototype.getAvailableSchemes=function(callback){return this.enqueue("getAvailableSchemes",{callback:callback});};MMDevice.prototype.getOrientation=function(callback){return this.enqueue("getOrientation",{callback:callback});};MMDevice.prototype.getLocation=function(callback){return this.enqueue("getLocation",{callback:callback});};MMDevice.prototype.showMap=function(location,callback){return this.enqueue("showMap",{location:location,callback:callback});};MMDevice.prototype.call=function(number,dial,callback){return this.enqueue("call",{number:number,callback:callback,dial:dial});};MMDevice.prototype.openUrl=function(url,callback){return this.enqueue("openUrl",{url:url,callback:callback});};MMDevice.prototype.openAppStore=function(appId,callback){return this.enqueue("openAppStore",{appId:appId,callback:callback});};MMDevice.prototype.composeSMS=function(number,message,callback){return this.composeSms(number,message,callback);};MMDevice.prototype.composeSms=function(number,message,callback){if(this.utils.isIOS()){return this.enqueue("composeSms",{number:number,message:message,callback:callback});}else{return this.enqueue("composeSms",{number:number,message:message,callback:callback});}};MMDevice.prototype.composeEmail=function(recipient,subject,message,callback){if(this.utils.isIOS()){return this.openUrl("mailto:?to="+encodeURIComponent(recipient)+"&subject="+encodeURIComponent(subject)+"&body="+encodeURIComponent(message),callback);}else{return this.enqueue("composeEmail",{recipient:recipient,subject:subject,message:message,callback:callback});}};MMDevice.prototype.getCompassHeading=function(callback){return this.enqueue("getCompassHeading",{callback:callback});};MMDevice.prototype.getBarometer=function(callback){return this.enqueue("getBarometer",{callback:callback});};MMDevice.prototype.enableHardwareAcceleration=function(enabled,callback){return this.enqueue("enableHardwareAcceleration",{enabled:enabled,callback:callback});};return MMDevice;})(MMBridgeObject);MMMedia=(function(_super){__extends(MMMedia,_super);function MMMedia(){return MMMedia.__super__.constructor.apply(this,arguments);}
  51. MMMedia.prototype.openFrontCamera=function(constrainWidth,constrainHeight,contentMode,callback){return this.enqueue("getPicture",{sourceType:'Camera',constrainWidth:constrainWidth,constrainHeight:constrainHeight,contentMode:contentMode,front:true,callback:callback});};MMMedia.prototype.openRearCamera=function(constrainWidth,constrainHeight,contentMode,callback){return this.enqueue("getPicture",{sourceType:'Camera',constrainWidth:constrainWidth,constrainHeight:constrainHeight,contentMode:contentMode,front:false,callback:callback});};MMMedia.prototype.getPicture=function(sourceType,constrainWidth,constrainHeight,contentMode,callback){return this.enqueue("getPicture",{sourceType:sourceType,constrainWidth:constrainWidth,constrainHeight:constrainHeight,contentMode:contentMode,callback:callback});};MMMedia.prototype.writeToPhotoLibrary=function(path,title,description,callback){return this.enqueue("writeToPhotoLibrary",{path:path,title:title,description:description,callback:callback});};MMMedia.prototype.isSourceTypeAvailable=function(sourceType,callback){return this.enqueue("isSourceTypeAvailable",{sourceType:sourceType,callback:callback});};MMMedia.prototype.availableSourceTypes=function(callback){return this.enqueue("availableSourceTypes",{callback:callback});};MMMedia.prototype.playVideo=function(path,callback){return this.enqueue("playVideo",{path:path,callback:callback});};MMMedia.prototype.playAudio=function(path,callback){return this.enqueue("playAudio",{path:path,"repeat":false,callback:callback});};MMMedia.prototype.playAudio=function(path,repeat,callback){return this.enqueue("playAudio",{path:path,repeat:repeat,callback:callback});};MMMedia.prototype.stopAudio=function(callback){return this.enqueue("stopAudio",{callback:callback});};MMMedia.prototype.playSound=function(path,callback){return this.enqueue("playSound",{path:path,callback:callback});};return MMMedia;})(MMBridgeObject);MMCalendar=(function(_super){__extends(MMCalendar,_super);function MMCalendar(){return MMCalendar.__super__.constructor.apply(this,arguments);}
  52. MMCalendar.prototype.addEvent=function(parameters,callback){return this.enqueue("addEvent",{"parameters":JSON.stringify(parameters),callback:callback});};return MMCalendar;})(MMBridgeObject);MMBanner=(function(_super){__extends(MMBanner,_super);function MMBanner(){return MMBanner.__super__.constructor.apply(this,arguments);}
  53. MMBanner.prototype.resize=function(parameters,callback){parameters["callback"]=callback;return this.enqueue("resize",parameters);};return MMBanner;})(MMBridgeObject);MMNotification=(function(_super){__extends(MMNotification,_super);function MMNotification(){return MMNotification.__super__.constructor.apply(this,arguments);}
  54. MMNotification.prototype.alert=function(title,message,cancelButton,buttons,callback){var params;params={title:title,message:message,cancelButton:cancelButton,callback:callback};if(buttons!=null){if(buttons!==""&&buttons!==null){params["buttons"]=buttons;}}
  55. return this.enqueue("alert",params);};MMNotification.prototype.vibrate=function(duration,callback){return this.enqueue("vibrate",{duration:duration,callback:callback});};return MMNotification;})(MMBridgeObject);MMFileManager=(function(_super){__extends(MMFileManager,_super);function MMFileManager(){return MMFileManager.__super__.constructor.apply(this,arguments);}
  56. MMFileManager.prototype.getFreeDiskSpace=function(callback){return this.enqueue("getFreeDiskSpace",{callback:callback});};MMFileManager.prototype.getDirectoryContents=function(path,callback){return this.enqueue("getDirectoryContents",{path:path,callback:callback});};MMFileManager.prototype.getFileContents=function(path,callback){return this.enqueue("getFileContents",{path:path,callback:callback});};MMFileManager.prototype.writeData=function(data,path,callback){return this.enqueue("writeData",{data:data,path:path,callback:callback});};MMFileManager.prototype.moveFile=function(fromPath,toPath,callback){return this.enqueue("moveFile",{fromPath:fromPath,toPath:toPath,callback:callback});};MMFileManager.prototype.removeAtPath=function(path,callback){return this.enqueue("removeAtPath",{path:path,callback:callback});};MMFileManager.prototype.downloadFile=function(url,path,callback){return this.enqueue("downloadFile",{url:url,path:path,callback:callback});};return MMFileManager;})(MMBridgeObject);MMInlineVideo=(function(_super){__extends(MMInlineVideo,_super);function MMInlineVideo(){return MMInlineVideo.__super__.constructor.apply(this,arguments);}
  57. MMInlineVideo.prototype.updateVideoSeekTime=function(currentSeekTime){if(this.timingCallback!=null){return this.timingCallback(currentSeekTime);}};MMInlineVideo.prototype.setTimingCallback=function(_timingCallback){return this.timingCallback=_timingCallback;};MMInlineVideo.prototype.playVideo=function(callback){return this.enqueue("playVideo",{callback:callback});};MMInlineVideo.prototype.stopVideo=function(callback){return this.enqueue("stopVideo",{callback:callback});};MMInlineVideo.prototype.pauseVideo=function(callback){return this.enqueue("pauseVideo",{callback:callback});};MMInlineVideo.prototype.resumeVideo=function(callback){return this.enqueue("resumeVideo",{callback:callback});};MMInlineVideo.prototype.removeVideo=function(callback){return this.enqueue("removeVideo",{callback:callback});};MMInlineVideo.prototype.setStreamVideoSource=function(streamVideoURI,callback){return this.enqueue("setStreamVideoSource",{streamVideoURI:streamVideoURI,callback:callback});};MMInlineVideo.prototype.adjustVideo=function(callback){return this.adjustVideoWithId('inlineVideo',callback);};MMInlineVideo.prototype.adjustVideoWithId=function(divId,callback){var frame,videoEl;videoEl=document.getElementById(divId);if(videoEl!=null){frame=this.calculateDivPosition(divId);frame["callback"]=callback;return this.enqueue("adjustVideo",frame);}else{return callback({"result":0,"response":"Div Id not found","class":"MMInlineVideo","call":"insertVideo"});}};MMInlineVideo.prototype.insertVideoWithId=function(divId,timingCallback,callback){var autoPlay,bodyHeight,bodyWidth,cachedVideoID,cachedVideoURI,frame,height,showControls,streamVideoURI,touchCallback,videoEl,width,x,y;videoEl=document.getElementById(divId);if(videoEl!=null){frame=this.calculateDivPosition(divId);if(timingCallback!=null){this.setTimingCallback(timingCallback);}
  58. x=frame['x'];y=frame['y'];width=frame['width'];height=frame['height'];bodyWidth=document.body.clientWidth;bodyHeight=document.body.clientHeight;cachedVideoURI=videoEl.getAttribute("cachedVideoURI");cachedVideoID =videoEl.getAttribute("cachedVideoID");touchCallback=videoEl.getAttribute("onTouch");streamVideoURI=videoEl.getAttribute("streamVideoURI");autoPlay=videoEl.getAttribute("autoPlay");showControls=videoEl.getAttribute("showControls");if(cachedVideoURI||streamVideoURI){return this.enqueue("insertVideo",{x:x,y:y,width:width,height:height,bodyWidth:bodyWidth,bodyHeight:bodyHeight,cachedVideoURI:cachedVideoURI,streamVideoURI:streamVideoURI,touchCallback:touchCallback,cachedVideoID:cachedVideoID,autoPlay:autoPlay,showControls:showControls,callback:callback});}else{return callback({"result":0,"response":"cachedVideoURI or streamVideoURI not found","class":"MMInlineVideo","call":"insertVideo"});}}else{return callback({"result":0,"response":"Div Id not found","class":"MMInlineVideo","call":"insertVideo"});}};MMInlineVideo.prototype.insertVideo=function(timingCallback,callback){return this.insertVideoWithId('inlineVideo',timingCallback,callback);};MMInlineVideo.prototype.calculateDivPosition=function(divId){var divEl,height,position,width,x,y;divEl=document.getElementById(divId);position=this.utils.offset(divEl);x=position[0];y=position[1];width=divEl.offsetWidth;height=divEl.offsetHeight;return{x:x,y:y,width:width,height:height};};return MMInlineVideo;})(MMBridgeObject);MMCachedVideo=(function(_super){__extends(MMCachedVideo,_super);function MMCachedVideo(){return MMCachedVideo.__super__.constructor.apply(this,arguments);}
  59. MMCachedVideo.timingCallback=null;MMCachedVideo.errorCallback=null;MMCachedVideo.prototype.updateVideoSeekTime=function(currentSeekTime){if(this.timingCallback!=null){return this.timingCallback(currentSeekTime);}};MMCachedVideo.prototype.setTimingCallback=function(timingCallback){return this.timingCallback=timingCallback;};MMCachedVideo.prototype.setError=function(error){if(this.errorCallback!=null){return this.errorCallback(error);}};MMCachedVideo.prototype.setErrorCallback=function(errorCallback){return this.errorCallback=errorCallback;};MMCachedVideo.prototype.restartVideo=function(callback){return this.enqueue("restartVideo",{callback:callback});};MMCachedVideo.prototype.endVideo=function(callback){return this.enqueue("endVideo",{callback:callback});};MMCachedVideo.prototype.pauseVideo=function(callback){return this.enqueue("pauseVideo",{callback:callback});};MMCachedVideo.prototype.playVideo=function(callback){return this.enqueue("playVideo",{callback:callback});};MMCachedVideo.prototype.availableCachedVideos=function(callback){return this.enqueue("availableCachedVideos",{callback:callback});};MMCachedVideo.prototype.playCachedVideo=function(videoId,callback){return this.enqueue("playCachedVideo",{videoId:videoId,callback:callback});};MMCachedVideo.prototype.cacheVideo=function(url,callback){return this.enqueue("cacheVideo",{url:url,callback:callback});};MMCachedVideo.prototype.videoIdExists=function(videoId,callback){return this.enqueue("videoIdExists",{videoId:videoId,callback:callback});};return MMCachedVideo;})(MMBridgeObject);MMInterstitial=(function(_super){__extends(MMInterstitial,_super);function MMInterstitial(){return MMInterstitial.__super__.constructor.apply(this,arguments);}
  60. MMInterstitial.animationTypes={"ios":["curl","flip","dissolve","slideup","none"],"android":["slideup","slidedown","explode","none"],"windows":["slideup","slidedown","explode","none"]};MMInterstitial.prototype.close=function(callback){return this.enqueue("close",{callback:callback});};MMInterstitial.prototype.open=function(url,callback){return this.enqueue("open",{url:url,callback:callback});};MMInterstitial.prototype.useCustomClose=function(useCustomClose,callback){return this.enqueue("useCustomClose",{useCustomClose:useCustomClose,callback:callback});}; MMInterstitial.prototype.setOrientation=function(properties,callback){properties["callback"]=callback;return this.enqueue("setOrientation",properties);};MMInterstitial.prototype.expandToExternalBrowser=function(url,callback){return this.enqueue("expandToExternalBrowser",{url:url,callback:callback});};MMInterstitial.prototype.expandWithProperties=function(url,properties,callback){var key,params,transitionType,value;params={callback:callback};if(url!=null){params["url"]=url;}
  61. MMJS.utils.consoleLog("expandWithProperties properties "+JSON.stringify(properties));if(properties!=null){for(key in properties){if(!__hasProp.call(properties,key))continue;value=properties[key];if(key==="transition"){transitionType=value;params[key]=transitionType;}else{params[key]=value;}}}
  62. return this.enqueue("expandWithProperties",params);};return MMInterstitial;})(MMBridgeObject);MMBrand=(function(_super){__extends(MMBrand,_super);function MMBrand(){return MMBrand.__super__.constructor.apply(this,arguments);}
  63. MMBrand.prototype.getInfo=function(callback){return this.enqueue("getInfo",{callback:callback});};return MMBrand;})(MMBridgeObject);MMAppStore=(function(_super){__extends(MMAppStore,_super);function MMAppStore(){return MMAppStore.__super__.constructor.apply(this,arguments);}
  64. MMAppStore.prototype.loadApp=function(appId,callback){return this.enqueue("loadApp",{appId:appId,callback:callback});};return MMAppStore;})(MMBridgeObject);MMPasteboard=(function(_super){__extends(MMPasteboard,_super);function MMPasteboard(){ return MMPasteboard.__super__.constructor.apply(this,arguments);}
  65. MMPasteboard.prototype.getPasteboardContents=function(pasteboardId,callback){var args;args={callback:callback};if(pasteboardId!=null){args["pasteboardId"]=pasteboardId;}
  66. return this.enqueue("getPasteboardContents",args);};MMPasteboard.prototype.writeToPasteboard=function(data,pasteboardId,callback){var args;args={data:data,callback:callback};if(pasteboardId!=null){args["pasteboardId"]=pasteboardId;}
  67. return this.enqueue("writeToPasteboard",args);};return MMPasteboard;})(MMBridgeObject);MMPassbook=(function(_super){__extends(MMPassbook,_super);function MMPassbook(){return MMPassbook.__super__.constructor.apply(this,arguments);}
  68. MMPassbook.prototype.isPassbookAvailable=function(callback){return this.enqueue("isPassbookAvailable",{callback:callback});};MMPassbook.prototype.addPassFromURL=function(url,callback){return this.enqueue("addPassFromURL",{url:url,callback:callback});};MMPassbook.prototype.isPassInstalled=function(url,identifier,serial,callback){if(url!=null){return this.enqueue("isPassInstalled",{url:url,callback:callback});}else{return this.enqueue("isPassInstalled",{identifier:identifier,serial:serial,callback:callback});}};MMPassbook.prototype.isPassURLInstalled=function(url,callback){return this.isPassInstalled(url,null,null,callback);};MMPassbook.prototype.isPassIdentifierInstalled=function(identifier,serial,callback){return this.isPassInstalled(null,identifier,serial,callback);};return MMPassbook;})(MMBridgeObject);MMSocial =(function(_super){__extends(MMSocial,_super);function MMSocial(){return MMSocial.__super__.constructor.apply(this,arguments);}
  69. MMSocial.prototype.tweet=function(message,callback){return this.enqueue("tweet",{message:message,callback:callback});};MMSocial.prototype.tweetWithContent=function(message,urls,images,callback){return this.enqueue("tweet",{message:message,"urls":urls.join(','),"images":images.join(','),callback:callback});};MMSocial.prototype.facebookPost=function(message,callback){return this.enqueue("facebookPost",{message:message,callback:callback});};MMSocial.prototype.facebookPostWithContent=function(message,urls,images,callback){return this.enqueue("facebookPost",{message:message,"urls":urls.join(','),"images":images.join(','),callback:callback});};MMSocial.prototype.authenticatedServices=function(callback){return this.enqueue("authenticatedServices",{callback:callback});};return MMSocial;})(MMBridgeObject);MRAID=(function(_super){__extends(MRAID,_super);function MRAID(){this.sdk=MMJS.sdk;this.utils=MMJS.utils;this.properties={width:null,height:null,useCustomClose:false,isModal:true};this.orientationProperties={allowOrientationChange:true,forceOrientation:'none'};this.resizeProperties={width:null,height:null,customClosePosition:'top-right',offsetX:0,offsetY:0,allowOffscreen:true};this.listeners={};}
  70. MRAID.prototype.getAdSize=function(){if(this.sdk.adSize!=null){this.utils.consoleLog("MRAID getAdSize "+JSON.stringify(this.sdk.adSize)); if(this.sdk.adSize["height"]>0&&this.sdk.adSize["width"]>0){return this.sdk.adSize;}}
  71. return null;};MRAID.prototype.callbackManager=function(response){var klass,method,response_data,result;result=response['result'];method=response['call'];response_data=response['response'];klass=response['class'];return this;};MRAID.prototype.getVersion=function(){return "2.0";};MRAID.prototype.close=function(){return MMJS.interstitial.close((function(response){if(response['result']<1){return mraid.fireEventCallbacks("error","Close failed","close");}}));};MRAID.prototype.expand=function(_url){var k,maxSize,props,v,_ref;this.utils.consoleLog('mraid.expand called with properties: '+JSON.stringify(this.getExpandProperties()));this.utils.consoleLog('mraid.expand url: '+_url);props=this.getExpandProperties();maxSize=this.getMaxSize();if((props!=null)&&(maxSize!=null)){if(props["height"]===maxSize["height"]&&props["width"]===maxSize["width"]){props["height"]=void 0;props["width"]=void 0;}}
  72. _ref=this.orientationProperties;for(k in _ref){v=_ref[k];props[k]=v;}
  73. return MMJS.interstitial.expandWithProperties(_url,props,(function(response){if(response['result']<1){return mraid.fireEventCallbacks("error","Expand failed","expand");}}));};MRAID.prototype.open=function(_url){return MMJS.interstitial.open(_url,(function(response){if(response['result']<1){return mraid.fireEventCallbacks("error","Open failed to open external url","open");}}));};MRAID.prototype.getExpandProperties=function(){var maxSize;maxSize=this.getMaxSize(); if(maxSize!=null){if(this.properties["height"]===null||this.properties["height"]===void 0){this.properties["height"]=maxSize["height"];}
  74. if(this.properties["width"]===null||this.properties["width"]===void 0){this.properties["width"]=maxSize["width"];}
  75. return this.properties;}else{return mraid.fireEventCallbacks("error","getExpandProperties failed","getExpandProperties");}};MRAID.prototype.setExpandProperties=function(_properties){this.utils.consoleLog('setExpandProperties: '+JSON.stringify(this.properties));return this.properties=_properties;};MRAID.prototype.getPlacementType=function(){return this.sdk.placementType;};MRAID.prototype.getState=function(){return this.sdk.state;};MRAID.prototype.useCustomClose=function(_customClose){this.properties["useCustomClose"]=_customClose;this.utils.consoleLog("Use Custom Close was called: "+_customClose);return MMJS.interstitial.useCustomClose(_customClose,(function(response){if(response['result']<1){return mraid.fireEventCallbacks("error","Use custom close failed to set","useCustomClose");}}));};MRAID.prototype.isViewable=function(){return this.sdk.viewable;};MRAID.prototype.removeEventListener=function(event,listener){var index;if(this.listeners[event]!=null){if(listener!=null){index=this.listeners[event].indexOf(listener);if(index<0){this.utils.consoleLog("Listner not found!");return false;}else{this.utils.consoleLog("'"+event+"' found listener: "+listener);}
  76. this.listeners[event].splice(index,1);return this.utils.consoleLog("'"+event+"' listeners: "+this.listeners[event]);}else{return delete this.listeners[event];}}};MRAID.prototype.addEventListener=function(event,listener){if(!(this.listeners[event]!=null)){this.listeners[event]=[];}
  77. this.utils.consoleLog("'"+event+"' added listener: "+listener);this.listeners[event].push(listener);return this.utils.consoleLog("'"+event+"' listeners: "+this.listeners[event]);};MRAID.prototype.fireEventCallbacks=function(eventName,parameter,action){var callback,_i,_len,_ref;this.utils.consoleLog("event callback: "+eventName);if(this.listeners[eventName]!=null){_ref=this.listeners[eventName];for(_i=0,_len=_ref.length;_i<_len;_i++){callback=_ref[_i];if(parameter!=null){if(action!=null){callback(parameter,action);}else{callback(parameter);}}else{callback();}}}};MRAID.prototype.resize=function(){var calledresizeProperties,maxSize;maxSize=this.getMaxSize();calledresizeProperties=this.getResizeProperties();if(calledresizeProperties["allowOffscreen"]===false){if(calledresizeProperties["width"]>maxSize["width"]||calledresizeProperties["height"]>maxSize["height"]){this.fireEventCallbacks("error","Resize is unsupported in this application.","resize");return;}}
  78. MMJS.banner.resize(calledresizeProperties,(function(response){if(response['result']<1){return mraid.fireEventCallbacks("error","Resize is unsupported in this application.","resize");}}));return null;};MRAID.prototype.getResizeProperties=function(){var adSize;adSize=this.getAdSize();if(adSize!=null){MMJS.utils.consoleLog("Ad Size was found");if(this.resizeProperties["height"]=== null){this.resizeProperties["height"]=adSize["height"];}
  79. if(this.resizeProperties["width"]===null){this.resizeProperties["width"]=adSize["width"];}
  80. return this.resizeProperties;}else{MMJS.utils.consoleLog("getResizeProperties failed");return mraid.fireEventCallbacks("error","getResizeProperties failed","getResizeProperties");}};MRAID.prototype.setResizeProperties=function(_properties){return this.resizeProperties=_properties;};MRAID.prototype.getCurrentPosition=function(){return this.sdk.adSize;};MRAID.prototype.getMaxSize=function(){if(this.sdk.adProperties["maxSize"]!=null){return{"height":this.sdk.adProperties["maxSize"]["height"],"width":this.sdk.adProperties["maxSize"]["width"]};}else{this.fireEventCallbacks("error","max size is unavailable","getMaxSize");}
  81. return null;};MRAID.prototype.getDefaultPosition=function(){return this.sdk.defaultPosition;};MRAID.prototype.getScreenSize=function(){MMJS.utils.consoleLog("getScreenSize: "+this.sdk.adProperties["screen"]);if(this.sdk.adProperties["screen"]!=null){return this.sdk.adProperties["screen"];}else{this.fireEventCallbacks("error","Screen size is unavailable","getScreenSize");}
  82. return null;};MRAID.prototype.supports=function(feature){if(feature!=null){return this.sdk.supportProperties[feature];}else{return this.sdk.supportProperties;}};MRAID.prototype.storePicture=function(URI){return MMJS.media.writeToPhotoLibrary(URI,"","",(function(response){if(response['result']<1){return mraid.fireEventCallbacks("error","Error storing picture","storePicture");}}));};MRAID.prototype.createCalendarEvent =function(parameters){return MMJS.calendar.addEvent(parameters,(function(response){if(response['result']<1){return mraid.fireEventCallbacks("error","Error adding calendar event","createCalendarEvent");}}));};MRAID.prototype.playVideo=function(URI){return MMJS.media.playVideo(URI,(function(response){if(response['result']<1){return mraid.fireEventCallbacks("error","Error playing video","playVideo");}}));};MRAID.prototype.getOrientationProperties=function(){return this.orientationProperties;};MRAID.prototype.setOrientationProperties=function(properties){this.orientationProperties=properties;if((this.getState()==="expanded"&&this.getPlacementType()==="inline")||(this.getPlacementType()==="interstitial")){return MMJS.interstitial.setOrientation(this.orientationProperties,"mraid.callbackManager");}};return MRAID;})(MMBridgeObject);(function(){if(typeof MMJS.sdk===MMJS.TYPE_UNDEFINED){MMJS.sdk=new MMSDKInterface;}
  83. if(typeof MMJS.device===MMJS.TYPE_UNDEFINED){MMJS.device=new MMDevice;}
  84. if(typeof MMJS.media===MMJS.TYPE_UNDEFINED){MMJS.media=new MMMedia;}
  85. if(typeof MMJS.fileManager===MMJS.TYPE_UNDEFINED){MMJS.fileManager=new MMFileManager;}
  86. if(typeof MMJS.notification===MMJS.TYPE_UNDEFINED){MMJS.notification=new MMNotification;}
  87. if(typeof MMJS.interstitial===MMJS.TYPE_UNDEFINED){MMJS.interstitial=new MMInterstitial;}
  88. if(typeof MMJS.cachedVideo===MMJS.TYPE_UNDEFINED){MMJS.cachedVideo=new MMCachedVideo;}
  89. if(typeof MMJS.brand===MMJS.TYPE_UNDEFINED){MMJS.brand=new MMBrand;}
  90. if(typeof MMJS.inlineVideo===MMJS.TYPE_UNDEFINED){MMJS.inlineVideo=new MMInlineVideo;}
  91. if(typeof MMJS.social===MMJS.TYPE_UNDEFINED){MMJS.social=new MMSocial;}
  92. if(typeof MMJS.passbook===MMJS.TYPE_UNDEFINED){MMJS.passbook=new MMPassbook;}
  93. if(typeof MMJS.calendar===MMJS.TYPE_UNDEFINED){MMJS.calendar=new MMCalendar;}
  94. if(typeof MMJS.banner===MMJS.TYPE_UNDEFINED){MMJS.banner=new MMBanner;}
  95. if(typeof MMJS.appstore===MMJS.TYPE_UNDEFINED){MMJS.appstore=new MMAppStore;}
  96. MMJS.appStore=MMJS.appstore;if(typeof MMJS.pasteboard===MMJS.TYPE_UNDEFINED){MMJS.pasteboard=new MMPasteboard;}
  97. if(typeof window.MMSDK===MMJS.TYPE_UNDEFINED){window.MMSDK=MMJS;}
  98. if(typeof MMSDK.sdk===MMJS.TYPE_UNDEFINED){MMSDK.sdk=MMJS.sdk;}
  99. if(typeof MMSDK.device===MMJS.TYPE_UNDEFINED){MMSDK.device=MMJS.device;}
  100. if(typeof MMSDK.media===MMJS.TYPE_UNDEFINED){MMSDK.media=MMJS.media;}
  101. if(typeof MMSDK.fileManager===MMJS.TYPE_UNDEFINED){ MMSDK.fileManager=MMJS.fileManager;}
  102. if(typeof MMSDK.notification===MMJS.TYPE_UNDEFINED){MMSDK.notification=MMJS.notification;}
  103. if(typeof MMSDK.interstitial===MMJS.TYPE_UNDEFINED){MMSDK.interstitial=MMJS.interstitial;}
  104. if(typeof MMJS.cachedVideo===MMJS.TYPE_UNDEFINED){MMSDK.cachedVideo=MMJS.cachedVideo;}
  105. if(typeof MMSDK.brand===MMJS.TYPE_UNDEFINED){MMSDK.brand=MMJS.brand;}
  106. if(typeof MMSDK.inlineVideo===MMJS.TYPE_UNDEFINED){MMSDK.inlineVideo=MMJS.inlineVideo;}
  107. if(typeof MMSDK.social===MMJS.TYPE_UNDEFINED){MMSDK.social=MMJS.social;}
  108. if(typeof MMSDK.passbook===MMJS.TYPE_UNDEFINED){MMSDK.passbook=MMJS.passbook;}
  109. if(typeof MMSDK.calendar===MMJS.TYPE_UNDEFINED){MMSDK.calendar=MMJS.calendar;}
  110. if(typeof MMSDK.banner===MMJS.TYPE_UNDEFINED){MMSDK.banner=MMJS.banner;}
  111. if(typeof MMSDK.appstore===MMJS.TYPE_UNDEFINED){MMSDK.appstore=MMJS.appstore;}
  112. MMSDK.appStore=MMJS.appstore;if(typeof MMSDK.pasteboard===MMJS.TYPE_UNDEFINED){MMSDK.pasteboard=MMJS.pasteboard;}
  113. if(typeof window.mraid===MMJS.TYPE_UNDEFINED){window.mraid=new MRAID;}
  114. if(typeof window.MM===MMJS.TYPE_UNDEFINED){return window.MM=MMJS;}})();MMJS.utils.listenForBrowserReady((function(){var timer;return timer=setInterval(function(){var command;if(MMJS.sdk.state!=="loading"){if(MMJS.executingCommand===false&&MMJS.commandQueue.length>0&&MMJS.executingCommandDelay===0){command=MMJS.commandQueue.shift();MMJS.utils.consoleLog("running command: "+command.url);try{return command.perform();}catch(e){return MMJS.utils.consoleLog("Failed to run command: "+e.messagealert);}}}},1);})());}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement