/** * Millennial Media JS Library (MM.js) * Copyright 2010-2013, Millennial Media * * Version: 1.4 * Built on Mon Jun 24 2013 14:08:11 GMT-0700 (PDT). */ // Generated by CoffeeScript 1.6.2 var MMAppStore, MMBanner, MMBrand, MMBridgeObject, MMCachedVideo, MMCalendar, MMCommand, MMDevice, MMFileManager, MMInlineVideo, MMInterstitial, MMJS, MMJSUtils, MMListenerManager, MMMedia, MMMicrophone, MMNotification, MMPassbook, MMPasteboard, MMSDKInterface, MMSocial, MMSpeechkit, MRAID, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, __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() {} MMJSUtils.ios_version = null; MMJSUtils.platform = null; MMJSUtils.sdk_version = null; MMJSUtils.params = null; MMJSUtils.isBridgeEnabled = function() { if (MMDevice.readyState !== "unknown") { return true; } return false; }; MMJSUtils.isPre46 = function(a) { if (this.isBridgeEnabled() === true) { return false; } if (a == null) { return true; } return this.underVersion(a, "4.6.0"); }; MMJSUtils.underVersion = function(versionString, minVersion) { var i, res, result, v1, v2; if (versionString == null) { return false; } 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; } i++; } return result < 0; }; MMJSUtils.isVersion = function(versionString) { var i, res, result, v1, v2; if (versionString == null) { return false; } 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; } i++; } 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; } 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"; } return this.platform; }; MMJSUtils.sdkVersion = function() { var mmisdk, params; if (this.sdk_version != null) { return this.sdk_version; } if (MMJS.sdkVersion != null) { this.sdk_verison = MMJS.sdkVersion; return this.sdk_version; } params = this.getParams(); if (params['sdkversion'] != null) { mmisdk = params['sdkversion'].split('-'); this.sdk_version = mmisdk[0]; return this.sdk_version; } 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; } 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; } 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('=')); } 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; } } } this.params = params; return this.params; }; MMJSUtils.consoleLog = function(_msg, _useAlert) { if (_useAlert == null) { _useAlert = false; } 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); } if (_useAlert) { alert(_msg); } } return false; }; MMJSUtils.iOSVersion = function() { var _v; if (this.ios_version) { return this.ios_version; } _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]; } return coords; }; return MMJSUtils; })(); MMJS = (function() { function MMJS() {} 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; 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; } 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; } 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 = {}; } return this.open(url, params, false); }; MMJS.open = function(url, params, autoExpand) { if (params == null) { params = {}; } if (autoExpand == null) { autoExpand = true; } mraid.setExpandProperties(params); return mraid.expand(url); }; MMJS.close = function(duration) { var modDuration; if (duration == null) { duration = 0; } 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; }; /* JS<=>SDK Bridge */ 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.adSize = {}; this.defaultPosition = {}; this.utils = MMJS.utils; this.speechResults = null; this.speechStatus = "unknown"; this.speechAudioLevel = 0; this.speechBackgroundAudioLevel = 0; this.audioPosition = 0; this.microphoneState = "ready"; this.microphoneAudioLevel = 0; } MMSDKInterface.prototype.setAdSize = function(_properties) { if (this.defaultPosition != null) { this.defaultPosition = this.adSize; } if (this.adSize) { if (this.adSize["height"] !== _properties["height"] || this.adSize["width"] !== _properties["width"]) { this.adSize = _properties; MMJS.listenerManager.fireEventCallbacks("sizeChange", _properties["width"], _properties["height"]); } } else { this.adSize = _properties; } 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"]; } if (this.adProperties["device"] != null) { MMJS.device.setInfo(this.adProperties["device"]); } 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 MMJS.listenerManager.fireEventCallbacks("stateChange", _state); } }; MMSDKInterface.prototype.setViewable = function(_visible) { if (this.viewable !== _visible) { this.utils.consoleLog('MRAID viewable change: visible = ' + _visible); this.viewable = _visible; return MMJS.listenerManager.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 MMJS.listenerManager.fireEventCallbacks("ready"); } }; MMSDKInterface.prototype.error = function(message, action) { return MMJS.listenerManager.fireEventCallbacks("error", message, action); }; MMSDKInterface.prototype.voiceStateChange = function(_status) { this.speechStatus = _status; return MMJS.listenerManager.fireEventCallbacks("voiceStateChange", _status); }; MMSDKInterface.prototype.audioLevelChange = function(_audioLevel) { this.speechAudioLevel = _audioLevel; return MMJS.listenerManager.fireEventCallbacks("audioLevelChange", _audioLevel); }; MMSDKInterface.prototype.recognitionResult = function(_results) { this.speechResults = _results; return MMJS.listenerManager.fireEventCallbacks("recognitionResult", _results); }; MMSDKInterface.prototype.voiceError = function(_error) { return MMJS.listenerManager.fireEventCallbacks("voiceError", _error); }; MMSDKInterface.prototype.backgroundAudioLevel = function(_backgroundAudioLevel) { this.speechBackgroundAudioLevel = _backgroundAudioLevel; return MMJS.listenerManager.fireEventCallbacks("backgroundAudioLevel", _backgroundAudioLevel); }; MMSDKInterface.prototype.audioCached = function() { return MMJS.listenerManager.fireEventCallbacks("audioCached"); }; MMSDKInterface.prototype.audioStarted = function() { return MMJS.listenerManager.fireEventCallbacks("audioStarted"); }; MMSDKInterface.prototype.audioPositionChange = function(_position) { this.audioPosition = _position; return MMJS.listenerManager.fireEventCallbacks("audioPositionChange", _position); }; MMSDKInterface.prototype.audioCompleted = function() { return MMJS.listenerManager.fireEventCallbacks("audioCompleted"); }; MMSDKInterface.prototype.customVoiceWordsAdded = function() { return MMJS.listenerManager.fireEventCallbacks("customVoiceWordsAdded"); }; MMSDKInterface.prototype.customVoiceWordsDeleted = function() { return MMJS.listenerManager.fireEventCallbacks("customVoiceWordsDeleted"); }; MMSDKInterface.prototype.microphoneStateChange = function(_mpState) { this.microphoneState = _mpState; return MMJS.listenerManager.fireEventCallbacks("microphoneStateChange", _mpState); }; MMSDKInterface.prototype.microphoneAudioLevelChange = function(_mpaudioLevel) { this.microphoneAudioLevel = _mpaudioLevel; return MMJS.listenerManager.fireEventCallbacks("microphoneAudioLevelChange", _mpaudioLevel); }; return MMSDKInterface; })(); MMListenerManager = (function() { function MMListenerManager() { this.listeners = {}; this.utils = MMJS.utils; } MMListenerManager.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); } this.listeners[event].splice(index, 1); return this.utils.consoleLog("'" + event + "' listeners: " + this.listeners[event]); } else { return delete this.listeners[event]; } } }; MMListenerManager.prototype.addEventListener = function(event, listener) { if (this.listeners[event] == null) { this.listeners[event] = []; } this.utils.consoleLog("'" + event + "' added listener: " + listener); this.listeners[event].push(listener); return this.utils.consoleLog("'" + event + "' listeners: " + this.listeners[event]); }; MMListenerManager.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(); } } } }; return MMListenerManager; })(); 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']; } 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++; } 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']); } 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); }; } params["callback"] = "MMJS.callbacks." + functionName; this.callback = params["callback"]; for (name in params) { if (typeof name !== MMJS.TYPE_STRING) { continue; } if (params[name] === void 0 || params[name] === null) { continue; } else { query_args.push(encodeURIComponent(name) + "=" + encodeURIComponent(params[name])); } } if (query_args.length > 0) { url += "?" + query_args.join("&"); } } MMJS.utils.consoleLog(url); this.url = url; this; } 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]; } } 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() { _ref = MMDevice.__super__.constructor.apply(this, arguments); return _ref; } 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; } MMDevice.loadState = "loaded"; if (!this.utils.isWindows()) { evt = "deviceLoaded"; this.utils.postEvent(evt); evt = "deviceloaded"; this.utils.postEvent(evt); } 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() { _ref1 = MMMedia.__super__.constructor.apply(this, arguments); return _ref1; } 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 }); }; MMMedia.prototype.getDeviceVolume = function(callback) { return this.enqueue("getDeviceVolume", { callback: callback }); }; return MMMedia; })(MMBridgeObject); MMCalendar = (function(_super) { __extends(MMCalendar, _super); function MMCalendar() { _ref2 = MMCalendar.__super__.constructor.apply(this, arguments); return _ref2; } 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() { _ref3 = MMBanner.__super__.constructor.apply(this, arguments); return _ref3; } 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() { _ref4 = MMNotification.__super__.constructor.apply(this, arguments); return _ref4; } 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; } } 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() { _ref5 = MMFileManager.__super__.constructor.apply(this, arguments); return _ref5; } 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() { _ref6 = MMInlineVideo.__super__.constructor.apply(this, arguments); return _ref6; } 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); } 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() { _ref7 = MMCachedVideo.__super__.constructor.apply(this, arguments); return _ref7; } 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() { _ref8 = MMInterstitial.__super__.constructor.apply(this, arguments); return _ref8; } 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; } 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; } } } return this.enqueue("expandWithProperties", params); }; return MMInterstitial; })(MMBridgeObject); MMBrand = (function(_super) { __extends(MMBrand, _super); function MMBrand() { _ref9 = MMBrand.__super__.constructor.apply(this, arguments); return _ref9; } MMBrand.prototype.getInfo = function(callback) { return this.enqueue("getInfo", { callback: callback }); }; return MMBrand; })(MMBridgeObject); MMAppStore = (function(_super) { __extends(MMAppStore, _super); function MMAppStore() { _ref10 = MMAppStore.__super__.constructor.apply(this, arguments); return _ref10; } 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() { _ref11 = MMPasteboard.__super__.constructor.apply(this, arguments); return _ref11; } MMPasteboard.prototype.getPasteboardContents = function(pasteboardId, callback) { var args; args = { callback: callback }; if (pasteboardId != null) { args["pasteboardId"] = pasteboardId; } 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; } return this.enqueue("writeToPasteboard", args); }; return MMPasteboard; })(MMBridgeObject); MMPassbook = (function(_super) { __extends(MMPassbook, _super); function MMPassbook() { _ref12 = MMPassbook.__super__.constructor.apply(this, arguments); return _ref12; } 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() { _ref13 = MMSocial.__super__.constructor.apply(this, arguments); return _ref13; } 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); MMSpeechkit = (function(_super) { __extends(MMSpeechkit, _super); function MMSpeechkit() { _ref14 = MMSpeechkit.__super__.constructor.apply(this, arguments); return _ref14; } MMSpeechkit.prototype.startRecording = function(language, recognizer, endOfSpeech, callback) { return this.enqueue("startRecording", { language: language, recognizer: recognizer, endOfSpeech: endOfSpeech, callback: callback }); }; MMSpeechkit.prototype.endRecording = function(callback) { return this.enqueue("endRecording", { callback: callback }); }; MMSpeechkit.prototype.sampleBackgroundAudioLevel = function(callback) { return this.enqueue("sampleBackgroundAudioLevel", { callback: callback }); }; MMSpeechkit.prototype.textToSpeech = function(language, text, callback) { return this.enqueue("textToSpeech", { language: language, text: text, callback: callback }); }; MMSpeechkit.prototype.releaseVoice = function(callback) { MMJS.sdk.speechResults = []; MMJS.sdk.speechAudioLevel = 0; MMJS.sdk.speechBackgroundAudioLevel = 0; MMJS.sdk.speechStatus = "Released"; return this.enqueue("releaseVoice", { callback: callback }); }; MMSpeechkit.prototype.cacheAudio = function(url, callback) { return this.enqueue("cacheAudio", { url: url, callback: callback }); }; MMSpeechkit.prototype.playAudio = function(url, properties, callback) { properties["url"] = url; properties["callback"] = callback; return this.enqueue("playAudio", properties); }; MMSpeechkit.prototype.stopAudio = function(callback) { return this.enqueue("stopAudio", { callback: callback }); }; MMSpeechkit.prototype.addCustomVoiceWords = function(words, callback) { return this.enqueue("addCustomVoiceWords", { words: words, callback: callback }); }; MMSpeechkit.prototype.deleteCustomVoiceWords = function(words, callback) { return this.enqueue("deleteCustomVoiceWords", { words: words, callback: callback }); }; MMSpeechkit.prototype.getSessionId = function(callback) { return this.enqueue("getSessionId", { callback: callback }); }; MMSpeechkit.prototype.getRecognitionResults = function() { return MMJS.sdk.speechResults; }; MMSpeechkit.prototype.getBackgroundNoiseLevel = function() { return MMJS.sdk.speechBackgroundAudioLevel; }; MMSpeechkit.prototype.getAudioLevel = function() { return MMJS.sdk.speechAudioLevel; }; MMSpeechkit.prototype.getVoiceState = function() { return MMJS.sdk.speechStatus; }; MMSpeechkit.prototype.getAudioPosition = function() { return MMJS.sdk.audioPosition; }; return MMSpeechkit; })(MMBridgeObject); MMMicrophone = (function(_super) { __extends(MMMicrophone, _super); function MMMicrophone() { _ref15 = MMMicrophone.__super__.constructor.apply(this, arguments); return _ref15; } MMMicrophone.prototype.startRecording = function(path, duration, callbackRate, callback) { return this.enqueue("startRecording", { path: path, duration: duration, callbackRate: callbackRate, callback: callback }); }; MMMicrophone.prototype.stopRecording = function(callback) { return this.enqueue("stopRecording", { callback: callback }); }; MMMicrophone.prototype.isRecordingAllowed = function(callback) { return this.enqueue("isRecordingAllowed", { callback: callback }); }; MMMicrophone.prototype.getMicrophoneAudioLevel = function() { return MMJS.sdk.microphoneAudioLevel; }; MMMicrophone.prototype.getMicrophoneState = function() { return MMJS.sdk.microphoneState; }; return MMMicrophone; })(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.audioProperties = { loop: false, controls: false }; } 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; } } 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 MMJS.listenerManager.fireEventCallbacks("error", "Close failed", "close"); } })); }; MRAID.prototype.expand = function(_url) { var k, maxSize, props, v, _ref16; 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; } } _ref16 = this.orientationProperties; for (k in _ref16) { v = _ref16[k]; props[k] = v; } return MMJS.interstitial.expandWithProperties(_url, props, (function(response) { if (response['result'] < 1) { return MMJS.listenerManager.fireEventCallbacks("error", "Expand failed", "expand"); } })); }; MRAID.prototype.open = function(_url) { return MMJS.interstitial.open(_url, (function(response) { if (response['result'] < 1) { return MMJS.listenerManager.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"]; } if (this.properties["width"] === null || this.properties["width"] === void 0) { this.properties["width"] = maxSize["width"]; } return this.properties; } else { return MMJS.listenerManager.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 MMJS.listenerManager.fireEventCallbacks("error", "Use custom close failed to set", "useCustomClose"); } })); }; MRAID.prototype.isViewable = function() { return this.sdk.viewable; }; MRAID.prototype.removeEventListener = function(event, listener) { return MMJS.listenerManager.removeEventListener(event, listener); }; MRAID.prototype.addEventListener = function(event, listener) { return MMJS.listenerManager.addEventListener(event, listener); }; MRAID.prototype.fireEventCallbacks = function(eventName, parameter, action) { return MMJS.listenerManager.fireEventCallbacks(eventName, parameter, action); }; 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; } } 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"]; } if (this.resizeProperties["width"] === null) { this.resizeProperties["width"] = adSize["width"]; } return this.resizeProperties; } else { MMJS.utils.consoleLog("getResizeProperties failed"); return MMJS.listenerManager.fireEventCallbacks("error", "Resize is unsupported in this application.", "resize"); } }; 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 { MMJS.listenerManager.fireEventCallbacks("error", "getResizeProperties failed", "getResizeProperties"); } 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"); } 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 MMJS.listenerManager.fireEventCallbacks("error", "Error storing picture", "storePicture"); } })); }; MRAID.prototype.createCalendarEvent = function(parameters) { return MMJS.calendar.addEvent(parameters, (function(response) { if (response['result'] < 1) { return MMJS.listenerManager.fireEventCallbacks("error", "Error adding calendar event", "createCalendarEvent"); } })); }; MRAID.prototype.playVideo = function(URI) { return MMJS.media.playVideo(URI, (function(response) { if (response['result'] < 1) { return MMJS.listenerManager.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"); } }; MRAID.prototype.startRecording = function(languageCode) { return MMJS.speechkit.startRecording(languageCode, "dictation", "short", function(response) { if (response['result'] < 1) { return MMJS.listenerManager.fireEventCallbacks("voiceError", "Start recording failed", "startRecording"); } }); }; MRAID.prototype.endRecording = function() { return MMJS.speechkit.endRecording(function(response) { if (response['result'] < 1) { return MMJS.listenerManager.fireEventCallbacks("voiceError", "End recording failed", "endRecording"); } }); }; MRAID.prototype.textToSpeech = function(text, languageCode) { return MMJS.speechkit.textToSpeech(languageCode, text, function(response) { if (response['result'] < 1) { return MMJS.listenerManager.fireEventCallbacks("voiceError", "Text to Speech failed", "textToSpeech"); } }); }; MRAID.prototype.playAudio = function(url, options) { if (options != null) { options["loop"] = this.audioProperties["loop"]; options["controls"] = this.audioProperties["controls"]; } return MMJS.speechkit.playAudio(url, this.audioProperties, function(response) { if (response['result'] < 1) { return MMJS.listenerManager.fireEventCallbacks("voiceError", "Playing audio failed", "playAudio"); } }); }; MRAID.prototype.stopAudio = function() { return MMJS.speechkit.stopAudio(function(response) { if (response['result'] < 1) { return MMJS.listenerManager.fireEventCallbacks("voiceError", "Stop playing audio failed", "stopAudio"); } }); }; MRAID.prototype.cacheAudio = function(url) { return MMJS.speechkit.cacheAudio(url, function(response) { if (response['result'] < 1) { return MMJS.listenerManager.fireEventCallbacks("voiceError", "Audio caching failed", "cacheAudio"); } }); }; MRAID.prototype.sampleBackgroundAudioLevel = function() { return MMJS.speechkit.sampleBackgroundAudioLevel(function(response) { if (response['result'] < 1) { return MMJS.listenerManager.fireEventCallbacks("voiceError", "Sampling of background audio failed", "sampleBackgroundAudioLevel"); } }); }; MRAID.prototype.releaseVoice = function() { return MMJS.speechkit.releaseVoice(function() {}); }; MRAID.prototype.addCustomVoiceWords = function(words) { return MMJS.speechkit.addCustomVoiceWords(words, function(response) { if (response['result'] < 1) { return MMJS.listenerManager.fireEventCallbacks("voiceError", "Adding custom words failed", "addCustomVoiceWords"); } }); }; MRAID.prototype.deleteCustomVoiceWords = function(words) { return MMJS.speechkit.deleteCustomVoiceWords(words, function(response) { if (response['result'] < 1) { return MMJS.listenerManager.fireEventCallbacks("voiceError", "Deleting custom words failed", "deleteCustomVoiceWords"); } }); }; MRAID.prototype.getRecognitionResults = function() { return MMJS.speechkit.getRecognitionResults(); }; MRAID.prototype.getAudioLevel = function() { return MMJS.speechkit.getAudioLevel(); }; MRAID.prototype.getVoiceState = function() { return MMJS.speechkit.getVoiceState(); }; MRAID.prototype.getAudioPosition = function() { return MMJS.speechkit.getAudioPosition(); }; return MRAID; })(MMBridgeObject); (function() { if (typeof MMJS.sdk === MMJS.TYPE_UNDEFINED) { MMJS.sdk = new MMSDKInterface; } if (typeof MMJS.device === MMJS.TYPE_UNDEFINED) { MMJS.device = new MMDevice; } if (typeof MMJS.media === MMJS.TYPE_UNDEFINED) { MMJS.media = new MMMedia; } if (typeof MMJS.fileManager === MMJS.TYPE_UNDEFINED) { MMJS.fileManager = new MMFileManager; } if (typeof MMJS.notification === MMJS.TYPE_UNDEFINED) { MMJS.notification = new MMNotification; } if (typeof MMJS.interstitial === MMJS.TYPE_UNDEFINED) { MMJS.interstitial = new MMInterstitial; } if (typeof MMJS.cachedVideo === MMJS.TYPE_UNDEFINED) { MMJS.cachedVideo = new MMCachedVideo; } if (typeof MMJS.brand === MMJS.TYPE_UNDEFINED) { MMJS.brand = new MMBrand; } if (typeof MMJS.inlineVideo === MMJS.TYPE_UNDEFINED) { MMJS.inlineVideo = new MMInlineVideo; } if (typeof MMJS.social === MMJS.TYPE_UNDEFINED) { MMJS.social = new MMSocial; } if (typeof MMJS.passbook === MMJS.TYPE_UNDEFINED) { MMJS.passbook = new MMPassbook; } if (typeof MMJS.calendar === MMJS.TYPE_UNDEFINED) { MMJS.calendar = new MMCalendar; } if (typeof MMJS.banner === MMJS.TYPE_UNDEFINED) { MMJS.banner = new MMBanner; } if (typeof MMJS.appstore === MMJS.TYPE_UNDEFINED) { MMJS.appstore = new MMAppStore; } MMJS.appStore = MMJS.appstore; if (typeof MMJS.pasteboard === MMJS.TYPE_UNDEFINED) { MMJS.pasteboard = new MMPasteboard; } if (typeof MMJS.listenerManager === MMJS.TYPE_UNDEFINED) { MMJS.listenerManager = new MMListenerManager; } if (typeof MMJS.speechkit === MMJS.TYPE_UNDEFINED) { MMJS.speechkit = new MMSpeechkit; } if (typeof MMJS.microphone === MMJS.TYPE_UNDEFINED) { MMJS.microphone = new MMMicrophone; } if (typeof window.MMSDK === MMJS.TYPE_UNDEFINED) { window.MMSDK = MMJS; } if (typeof MMSDK.sdk === MMJS.TYPE_UNDEFINED) { MMSDK.sdk = MMJS.sdk; } if (typeof MMSDK.device === MMJS.TYPE_UNDEFINED) { MMSDK.device = MMJS.device; } if (typeof MMSDK.media === MMJS.TYPE_UNDEFINED) { MMSDK.media = MMJS.media; } if (typeof MMSDK.fileManager === MMJS.TYPE_UNDEFINED) { MMSDK.fileManager = MMJS.fileManager; } if (typeof MMSDK.notification === MMJS.TYPE_UNDEFINED) { MMSDK.notification = MMJS.notification; } if (typeof MMSDK.interstitial === MMJS.TYPE_UNDEFINED) { MMSDK.interstitial = MMJS.interstitial; } if (typeof MMJS.cachedVideo === MMJS.TYPE_UNDEFINED) { MMSDK.cachedVideo = MMJS.cachedVideo; } if (typeof MMSDK.brand === MMJS.TYPE_UNDEFINED) { MMSDK.brand = MMJS.brand; } if (typeof MMSDK.inlineVideo === MMJS.TYPE_UNDEFINED) { MMSDK.inlineVideo = MMJS.inlineVideo; } if (typeof MMSDK.social === MMJS.TYPE_UNDEFINED) { MMSDK.social = MMJS.social; } if (typeof MMSDK.passbook === MMJS.TYPE_UNDEFINED) { MMSDK.passbook = MMJS.passbook; } if (typeof MMSDK.calendar === MMJS.TYPE_UNDEFINED) { MMSDK.calendar = MMJS.calendar; } if (typeof MMSDK.banner === MMJS.TYPE_UNDEFINED) { MMSDK.banner = MMJS.banner; } if (typeof MMSDK.appstore === MMJS.TYPE_UNDEFINED) { MMSDK.appstore = MMJS.appstore; } MMSDK.appStore = MMJS.appstore; if (typeof MMSDK.pasteboard === MMJS.TYPE_UNDEFINED) { MMSDK.pasteboard = MMJS.pasteboard; } if (typeof MMSDK.speechkit === MMJS.TYPE_UNDEFINED) { MMSDK.speechkit = MMJS.speechkit; } if (typeof MMSDK.microphone === MMJS.TYPE_UNDEFINED) { MMSDK.microphone = MMJS.microphone; } if (typeof window.mraid === MMJS.TYPE_UNDEFINED) { window.mraid = new MRAID; } if (typeof window.MM === MMJS.TYPE_UNDEFINED) { return window.MM = MMJS; } })(); MMJS.utils.listenForBrowserReady((function() { var timer; return timer = setInterval(function() { var command, e; 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 (_error) { e = _error; return MMJS.utils.consoleLog("Failed to run command: " + e.messagealert); } } } }, 1); })()); }