diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100755 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100755 index 0000000..0adc71d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100755 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/webtester.iml b/.idea/webtester.iml new file mode 100755 index 0000000..24643cc --- /dev/null +++ b/.idea/webtester.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index f9b88dd..bfb9244 --- a/README.md +++ b/README.md @@ -3,9 +3,6 @@ MRAID WebTester is a community-driven tool to run MRAID ad units in a web enviro !! This project is currently unattended and is not scheduled for updates !! -### Using the tool - -!! The online tool at http://webtester.mraid.org/ is no longer maintained. Users wishing to run the webtester should do so locally. !! === PREPARE: One the first screen, provide the properties for your test environment diff --git a/compliance/docs/MRAID_Test_Ad-Expandable.pdf b/compliance/docs/MRAID_Test_Ad-Expandable.pdf old mode 100644 new mode 100755 diff --git a/compliance/docs/MRAID_Test_Ad-Fullpage.pdf b/compliance/docs/MRAID_Test_Ad-Fullpage.pdf old mode 100644 new mode 100755 diff --git a/compliance/docs/MRAID_Test_Ad-Resize.pdf b/compliance/docs/MRAID_Test_Ad-Resize.pdf old mode 100644 new mode 100755 diff --git a/compliance/docs/MRAID_Test_Ad-Resize_Errors.pdf b/compliance/docs/MRAID_Test_Ad-Resize_Errors.pdf old mode 100644 new mode 100755 diff --git a/compliance/docs/MRAID_Test_Ad-Two_Part_Expandable.pdf b/compliance/docs/MRAID_Test_Ad-Two_Part_Expandable.pdf old mode 100644 new mode 100755 diff --git a/compliance/docs/MRAID_Test_Ad-Video_Interstitial.pdf b/compliance/docs/MRAID_Test_Ad-Video_Interstitial.pdf old mode 100644 new mode 100755 diff --git a/css/main.css b/css/main.css old mode 100644 new mode 100755 index 19e4066..72b05c2 --- a/css/main.css +++ b/css/main.css @@ -140,7 +140,7 @@ div[class~=consoleFrame] { line-height: 1.6; } -#adURI, #adFragment { +#adURI, #adFragment ,#adHeadScript{ width:70%; } diff --git a/css/reset.css b/css/reset.css old mode 100644 new mode 100755 diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100755 index 0000000..e166233 --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1,106 @@ +# MRAID WebTester Architecture + +The MRAID WebTester is a web-based tool designed to test Mobile Rich Media Ad Interface Definitions (MRAID) implementations. This document outlines the architecture and core components of the system. + +## Project Structure + +``` +webtester/ +├── css/ # Style sheets for the application +├── jquery/ # jQuery and UI libraries +├── img/ # Image assets +├── widgets/ # UI widget implementations +├── safari/ # Core MRAID implementation +│ ├── main.js # Application logic +│ └── mraidview.js # MRAID view implementation +├── compliance/ # IAB compliance test ads +│ ├── units/ # Test ad units +│ └── docs/ # Compliance documentation +├── index.html # Main application entry point +├── htmlproxy.php # Proxy for HTML content +├── imageDownload.php # Helper for image downloads +├── favicon.ico # Site favicon +├── LICENSE # BSD License +└── README.md # Project documentation +``` + +## Core Components + +### 1. User Interface (index.html) + +The UI is divided into three main tabs: + +1. **Prepare**: Configure test environment properties + - Device geometry (ad sizes, screen sizes) + - API version selection (MRAID v1 or v2) + - Placement type (Inline or Interstitial) + - Off-screen option + - Native features to emulate (sms, tel, calendar, etc.) + +2. **Flight**: Input ad code for testing + - Head script inclusion + - HTML tag source input + +3. **Test**: Run and monitor the ad + - Console output for logging + - Orientation controls + - Error and info filtering + +### 2. Core MRAID Implementation (safari/mraidview.js) + +This is the heart of the application, providing a web-based MRAID container implementation. Key components: + +- **Constants**: Defines MRAID versions, placements, states, events, and features +- **Event Handling**: System for registering and triggering event listeners +- **MRAID Bridge**: Implementation of the MRAID API specification +- **Rendering Engine**: Creates and manages the ad frame/window + +The implementation follows the MRAID specification flow: +1. Initialize properties (version, supports) +2. Create ad window +3. Initialize ad frame and bridge +4. Set up event listeners +5. Signal ready state to the ad + +### 3. Application Logic (safari/main.js) + +Controls the application flow and user interaction: + +- **Event Listeners**: For console logging and error reporting +- **Form Handling**: Processing user input from the Prepare tab +- **Rendering**: Functions to render ads from HTML or URLs +- **Utilities**: Helper functions for orientation changes, query string parsing, etc. + +### 4. Compliance Testing (compliance/units/) + +Contains IAB-created test ad units for validating MRAID implementations: + +- Interstitial ads +- Resize functionality (with error testing) +- Two-part expand tests +- Full-page ad examples +- Video support tests + +## Data Flow + +1. User configures test environment in the Prepare tab +2. User inputs ad HTML/script in the Flight tab +3. System renders the ad in a popup window with MRAID container +4. MRAID events and method calls are logged to the console +5. User can manipulate the environment (e.g., orientation) to test ad behavior + +## Integration Points + +- **Query String Parameter**: The `adtag` parameter allows direct injection of HTML into the Flight tab +- **Console Logging**: All MRAID interactions are logged to the console for debugging + +## Technical Constraints + +- Project is no longer actively maintained +- Uses older versions of jQuery and related libraries +- Implementation specifically designed for MRAID v1 and v2 (not newer versions) +- Some browser security policies may affect functionality when running locally + +--- + +This architecture document should be updated if any feature changes or enhancements are made to the system. \ No newline at end of file diff --git a/favicon.ico b/favicon.ico old mode 100644 new mode 100755 diff --git a/htmlproxy.php b/htmlproxy.php old mode 100644 new mode 100755 diff --git a/img/crisp-logo.svg b/img/crisp-logo.svg old mode 100644 new mode 100755 diff --git a/img/github-logo.png b/img/github-logo.png old mode 100644 new mode 100755 diff --git a/img/iab-compliant-mraid-2.0.eps b/img/iab-compliant-mraid-2.0.eps old mode 100644 new mode 100755 diff --git a/img/iab-webtester-logo.png b/img/iab-webtester-logo.png old mode 100644 new mode 100755 diff --git a/img/iab-webtester-logo.psd b/img/iab-webtester-logo.psd old mode 100644 new mode 100755 diff --git a/img/notch.png b/img/notch.png old mode 100644 new mode 100755 diff --git a/index.html b/index.html old mode 100644 new mode 100755 index b372723..735a8ff --- a/index.html +++ b/index.html @@ -44,7 +44,7 @@ orientationWidget.init(); load(); - var adtag = getQueryStringValue('adtag'), + var adtag = getQueryStringValue('adtag'), fragmentArea; if (adtag && adtag !== '') { @@ -75,14 +75,14 @@
- +

properties

Device geometry:
- +
Default ad size (w x h): x @@ -111,15 +111,15 @@

properties

- +
-

API version to test: +

API version to test:

-

Placement: +

Placement:
+ Use script's URL. When this option is checked, paste a URL of the script instead of its source +

tag source

@@ -179,7 +184,7 @@

tag source

- +

console

@@ -205,7 +210,7 @@

controls

- +
diff --git a/jquery/jquery.easing.1.3.js b/jquery/jquery.easing.1.3.js old mode 100644 new mode 100755 diff --git a/jquery/jquery.event.drag-2.2.js b/jquery/jquery.event.drag-2.2.js old mode 100644 new mode 100755 diff --git a/jquery/jquery.indicated-tabs.js b/jquery/jquery.indicated-tabs.js old mode 100644 new mode 100755 diff --git a/jquery/jquery.min.1.7.2.js b/jquery/jquery.min.1.7.2.js old mode 100644 new mode 100755 diff --git a/jquery/jquery.tools.min.js b/jquery/jquery.tools.min.js old mode 100644 new mode 100755 diff --git a/safari/ad.html b/safari/ad.html old mode 100644 new mode 100755 diff --git a/safari/device.html b/safari/device.html old mode 100644 new mode 100755 diff --git a/safari/main.js b/safari/main.js old mode 100644 new mode 100755 index 52cabe3..d31d88f --- a/safari/main.js +++ b/safari/main.js @@ -18,10 +18,10 @@ function load() { now = new Date(); console.innerHTML = [ - formatInfoTime(now), - ' INFO ', - message, - '
', + formatInfoTime(now), + ' INFO ', + message, + '
', console.innerHTML ].join(''); } @@ -33,9 +33,9 @@ function load() { now = new Date(); console.innerHTML = [ - formatInfoTime(now), - ' ERROR ', - message, '
', + formatInfoTime(now), + ' ERROR ', + message, '
', console.innerHTML ].join(''); } @@ -77,7 +77,7 @@ function contains(array, item) { return true; } } - + return false; } @@ -98,13 +98,18 @@ function nextStep() { function renderHtmlAd() { var form = document.forms.setup; prepareMraidView(form); + if (form.adHeadScriptIsURI.checked) { + mraidview.setAdHeadScript("document.write('');"); + } else { + mraidview.setAdHeadScript(form.adHeadScript.value); + } mraidview.setUseHtml(true, form.adFragment.value); mraidview.render(); $('[href=#tabs-3]').click(); // switch to third tab } function prepareMraidView(form) { -/* +/* Note: This must be served from a webserver when using Chrome, otherwise you'll run into cross-domain limitations. For more information see: http://74.125.153.99/support/forum/p/Chrome/thread?tid=0ba628caf22b4a31&hl=en diff --git a/safari/mraid-main.js b/safari/mraid-main.js old mode 100644 new mode 100755 diff --git a/safari/mraid-vpaid.js b/safari/mraid-vpaid.js old mode 100644 new mode 100755 diff --git a/safari/mraid.js b/safari/mraid.js old mode 100644 new mode 100755 index 53ea83a..ec42530 --- a/safari/mraid.js +++ b/safari/mraid.js @@ -7,14 +7,15 @@ * be found in the AUTHORS file in the root of the source tree. */ -function mraidJsId() { - if (typeof (mraid) === 'undefined') { - console.log('mraid not found yet'); - } else { - clearInterval(idInterval); - mraid.info('mraid.js identification script included'); - mraidview.scriptFound = true; - } -} - -var idInterval = setInterval(mraidJsId, 500); \ No newline at end of file +// function mraidJsId() { +// if (typeof (mraid) === 'undefined') { +// console.log('mraid not found yet'); +// } else { +// clearInterval(idInterval); +// mraid.info('mraid.js identification script included'); +// mraidview.scriptFound = true; +// } +// } +// +// var idInterval = setInterval(mraidJsId, 500); +window.mraid = window.mraid || window.parent.mraid || {} diff --git a/safari/mraidview-bridge.js b/safari/mraidview-bridge.js old mode 100644 new mode 100755 diff --git a/safari/mraidview.js b/safari/mraidview.js old mode 100644 new mode 100755 index d77c571..e993638 --- a/safari/mraidview.js +++ b/safari/mraidview.js @@ -8,27 +8,27 @@ */ - /* - * Code flow is - * (0) prepareMraidView initializes version and "supports" properties +/* + * Code flow is + * (0) prepareMraidView initializes version and "supports" properties INFO MRAID version 2.0 INFO placement type inline INFO [sms,tel,calendar,storePicture,inlineVideo] - * (1) buttons on interface call renderAd() - Flight tab>ad fragment or renderHtmlAd - Flight tab>ad url + * (1) buttons on interface call renderAd() - Flight tab>ad fragment or renderHtmlAd - Flight tab>ad url INFO rendering INFO creating adWindow - * (.) onload event of new browser window + * (.) onload event of new browser window INFO adWindow loaded - * (2) render() calls initAdFrame() + * (2) render() calls initAdFrame() INFO initializing ad frame - * (3) initAdFrame() calls initAdBridge() and loadHtml() + * (3) initAdFrame() calls initAdBridge() and loadHtml() INFO initializing bridge object [object Object] - * (4) initAdBridge() calls - * (a) EventListeners.add for info reporting + * (4) initAdBridge() calls + * (a) EventListeners.add for info reporting INFO activating info - * (b) EventListeners.add for error reporting + * (b) EventListeners.add for error reporting INFO activating error - * (c) pushChange() for initialization of all other properties + * (c) pushChange() for initialization of all other properties INFO controller initialized INFO setting state to loading INFO setting screenSize to {'width':320,'height':480} @@ -39,66 +39,66 @@ INFO setting maxSize to {'width':320,'height':480} INFO merging expandProperties with {'width':0,'height':0,'useCustomClose':false,'isModal':false} INFO setting supports to [screen] - * (5) pushChange() calls the addEventListener() method in mraid-main.js - * (6) addEventListener() calls changeHandlers.[listener] - * (7) changeHandlers.state() through signalReady, send ready event + * (5) pushChange() calls the addEventListener() method in mraid-main.js + * (6) addEventListener() calls changeHandlers.[listener] + * (7) changeHandlers.state() through signalReady, send ready event INFO activating ready - * (8) identification script loaded + * (8) identification script loaded INFO mraid.js identification script found - */ + */ -(function() { +(function () { var mraidview = window.mraidview = {}; // CONSTANTS /////////////////////////////////////////////////////////////// var VERSIONS = mraidview.VERSIONS = { - V1 : '1.0', - V2 : '2.0' + V1: '1.0', + V2: '2.0' }; var PLACEMENTS = mraidview.PLACEMENTS = { - UNKNOWN : 'unknown', + UNKNOWN: 'unknown', - INLINE : 'inline', - INTERSTITIAL : 'interstitial' + INLINE: 'inline', + INTERSTITIAL: 'interstitial' } var STATES = mraidview.STATES = { - UNKNOWN :'unknown', + UNKNOWN: 'unknown', - LOADING :'loading', - DEFAULT :'default', - RESIZED :'resized', - EXPANDED :'expanded', - HIDDEN :'hidden' + LOADING: 'loading', + DEFAULT: 'default', + RESIZED: 'resized', + EXPANDED: 'expanded', + HIDDEN: 'hidden' }; var EVENTS = mraidview.EVENTS = { - INFO :'info', - ORIENTATIONCHANGE :'orientationChange', - - READY :'ready', - ERROR :'error', - STATECHANGE :'stateChange', - VIEWABLECHANGE :'viewableChange', - SIZECHANGE :'sizeChange', + INFO: 'info', + ORIENTATIONCHANGE: 'orientationChange', + + READY: 'ready', + ERROR: 'error', + STATECHANGE: 'stateChange', + VIEWABLECHANGE: 'viewableChange', + SIZECHANGE: 'sizeChange', }; var FEATURES = mraidview.FEATURES = { - SMS :'sms', - TEL :'tel', - CALENDAR :'calendar', - STOREPICTURE:'storePicture', - INLINEVIDEO :'inlineVideo', - VPAID :'vpaid' + SMS: 'sms', + TEL: 'tel', + CALENDAR: 'calendar', + STOREPICTURE: 'storePicture', + INLINEVIDEO: 'inlineVideo', + VPAID: 'vpaid' }; // EVENT HANDLING /////////////////////////////////////////////////////////////// var listeners = {}; - var broadcastEvent = function() { + var broadcastEvent = function () { var args = new Array(arguments.length); for (var i = 0; i < arguments.length; i++) args[i] = arguments[i]; @@ -112,17 +112,17 @@ INFO mraid.js identification script found mraidview.broadcastEvent = broadcastEvent; - mraidview.addEventListener = function(event, listener, scope) { + mraidview.addEventListener = function (event, listener, scope) { var key = String(listener) + String(scope); var map = listeners[event] if (!map) { map = {}; listeners[event] = map; } - map[key] = {scope:(scope?scope:{}),func:listener}; + map[key] = { scope: (scope ? scope : {}), func: listener }; }; - mraidview.removeEventListener = function(event, listener, scope) { + mraidview.removeEventListener = function (event, listener, scope) { var key = String(listener) + String(scope); var map = listeners[event]; if (map) { @@ -223,18 +223,18 @@ INFO mraid.js identification script found // PUBLIC ACCESSOR METHODS /////////////////////////////////////////////////////////////// - mraidview.getAdContent = function() { + mraidview.getAdContent = function () { return adContent; }; - mraidview.setScreenSize = function(width, height) { + mraidview.setScreenSize = function (width, height) { screenSize.width = width; screenSize.height = height; orientation = (width >= height) ? 90 : 0; adContainerOrientation = orientation; }; - mraidview.setDefaultPosition = function(x, y, width, height) { + mraidview.setDefaultPosition = function (x, y, width, height) { defaultPosition.x = parseInt(x); defaultPosition.y = parseInt(y); defaultPosition.width = parseInt(width); @@ -242,7 +242,7 @@ INFO mraid.js identification script found currentPosition = defaultPosition; }; - mraidview.setMaxAdPosition= function(x, y, width, height) { + mraidview.setMaxAdPosition = function (x, y, width, height) { maxSize.x = x; maxSize.y = y; if (orientation % 180 === 0) { @@ -254,12 +254,15 @@ INFO mraid.js identification script found } }; - mraidview.setAdURI = function(uri, fragment) { + mraidview.setAdURI = function (uri, fragment) { adURI = uri; adURIFragment = (fragment) ? true : false; }; + mraidview.setAdHeadScript = function (script) { + adHeadScript = script; + } - mraidview.setUseHtml = function(useThisHtml, html) { + mraidview.setUseHtml = function (useThisHtml, html) { useHtml = useThisHtml; if (useHtml) { adHtml = html; @@ -268,32 +271,32 @@ INFO mraid.js identification script found } }; - mraidview.resetSupports = function() { + mraidview.resetSupports = function () { supports = []; }; - mraidview.setSupports = function(feature, doesSupport) { + mraidview.setSupports = function (feature, doesSupport) { if (doesSupport) { supports.push(feature); broadcastEvent(EVENTS.INFO, stringify(supports)); } }; - mraidview.setVersion = function(value) { + mraidview.setVersion = function (value) { mraidview.version = value; broadcastEvent(EVENTS.INFO, 'MRAID version ' + value); }; - mraidview.setPlacement = function(value) { + mraidview.setPlacement = function (value) { placement = mraidview.placement = value; broadcastEvent(EVENTS.INFO, 'placement type ' + value); }; - mraidview.setOffScreen = function(value) { + mraidview.setOffScreen = function (value) { offscreen = value; }; - mraidview.rotateOrientation = function() { + mraidview.rotateOrientation = function () { mraidview.setOrientation(orientation = (orientation + 90) % 180); }; @@ -321,7 +324,7 @@ INFO mraid.js identification script found width: maxSize.height, height: maxSize.width, x: maxSize.y - dx, - y:maxSize.x + dx + y: maxSize.x + dx }); if (state === STATES.EXPANDED) { setAdResizeContainerStyle((adExpandedContainer || adResizeContainer), { @@ -436,9 +439,9 @@ INFO mraid.js identification script found counter = 10; if (!adFrame || !adWindow || !adWindow.document || !adFrame.contentWindow) { broadcastEvent(EVENTS.INFO, 'creating adWindow'); - adWindow = window.open((offscreen) ? 'safari/device-pages.html': 'safari/device.html', 'adWindow', 'left=1000,width='+screenSize.width+',height='+screenSize.height+',menubar=no,location=no,toolbar=no,status=no,personalbar=no,resizable=no,scrollbars=no,chrome=no,all=no'); + adWindow = window.open((offscreen) ? 'safari/device-pages.html' : 'safari/device.html', 'adWindow', 'left=1000,width=' + screenSize.width + ',height=' + screenSize.height + ',menubar=no,location=no,toolbar=no,status=no,personalbar=no,resizable=no,scrollbars=no,chrome=no,all=no'); - adWindow.onload = function() { + adWindow.onload = function () { broadcastEvent(EVENTS.INFO, 'adWindow loaded'); adWindowAdj.x = window.outerWidth - screenSize.width; @@ -446,7 +449,7 @@ INFO mraid.js identification script found adWindow.document.getElementsByTagName('body')[0].style.width = screenSize.width + 'px'; adWindow.document.getElementsByTagName('body')[0].style.height = screenSize.height + 'px'; adContainer = adWindow.document.getElementById('adContainer'); - adContainer.addEventListener('ViewableChange', function(e) { + adContainer.addEventListener('ViewableChange', function (e) { changeViewable(); }); adResizeContainer = adWindow.document.getElementById('adResizeContainer'); @@ -464,16 +467,18 @@ INFO mraid.js identification script found loadAd(); }; } else { - adWindow.close(); - adWindow = null; - mraidview.render(); + dispatchEvent(new Event('load')); + // adWindow.close(); + // adWindow = null; + // mraidview.render(); + // adWindow.load } }; // PRIVATE METHODS /////////////////////////////////////////////////////////////// var clone = function (obj) { - var f = function () {}; + var f = function () { }; f.prototype = obj; return new f(); }; @@ -489,7 +494,7 @@ INFO mraid.js identification script found return '[' + out.join(',') + ']'; } else { for (var p in obj) { - out.push('\''+p+'\':'+obj[p]); + out.push('\'' + p + '\':' + obj[p]); } return '{' + out.join(',') + '}'; } @@ -544,12 +549,12 @@ INFO mraid.js identification script found x: 0, y: 0, width: defaultPosition.width, - height:defaultPosition.height + height: defaultPosition.height }; isViewable = false; }; - var showMraidCloseButton = function(toggle) { + var showMraidCloseButton = function (toggle) { var closeDiv = closeEventRegion; var pos; @@ -575,7 +580,7 @@ INFO mraid.js identification script found } else if (/bottom/i.test(pos)) { closeDiv.style.bottom = '0px'; } else { - closeDiv.style.top = [(resizeProperties.height - 50 ) / 2, 'px'].join(''); + closeDiv.style.top = [(resizeProperties.height - 50) / 2, 'px'].join(''); } if (/left/i.test(pos)) { @@ -583,7 +588,7 @@ INFO mraid.js identification script found } else if (/right/i.test(pos)) { closeDiv.style.right = '0px'; } else { - closeDiv.style.left = [(resizeProperties.width - 50 ) / 2, 'px'].join(''); + closeDiv.style.left = [(resizeProperties.width - 50) / 2, 'px'].join(''); } } else { closeDiv.style.top = '0'; @@ -591,14 +596,14 @@ INFO mraid.js identification script found } closeDiv.style.display = 'block'; - broadcastEvent (EVENTS.INFO, 'adding MRAID close button'); + broadcastEvent(EVENTS.INFO, 'adding MRAID close button'); } else { closeDiv.style.display = 'none'; - broadcastEvent (EVENTS.INFO, 'removing MRAID close button'); + broadcastEvent(EVENTS.INFO, 'removing MRAID close button'); } }; - var loadAd = function() { + var loadAd = function () { var doc; reset(); @@ -625,7 +630,7 @@ INFO mraid.js identification script found } } - if (orientation % 180 === 0){ + if (orientation % 180 === 0) { setMaxAdArea(maxSize); } else { setMaxAdArea({ @@ -697,7 +702,7 @@ INFO mraid.js identification script found } } if (adURIFragment) { - document.cookie = 'uri='+encodeURIComponent(uri); + document.cookie = 'uri=' + encodeURIComponent(uri); } }; })(); @@ -706,7 +711,7 @@ INFO mraid.js identification script found if (window.jQuery !== undefined) { jQuery.get(qs, success); } - } catch(e) { + } catch (e) { } }; @@ -732,8 +737,8 @@ INFO mraid.js identification script found currentPosition.y = defaultPosition.y + resizeProperties.offsetY; currentPosition.width = resizeProperties.width; currentPosition.height = resizeProperties.height; - size.width = currentPosition.width = resizeProperties.width; - size.height = currentPosition.height = resizeProperties.height; + size.width = currentPosition.width = resizeProperties.width; + size.height = currentPosition.height = resizeProperties.height; adBridge.pushChange({ currentPosition: currentPosition, size: size @@ -750,11 +755,11 @@ INFO mraid.js identification script found maxDiv.style.top = [size.y, 'px'].join(''); !adBridge || adBridge.pushChange({ maxSize: - size + size }); }; - var setExpandProperties = function(size){ + var setExpandProperties = function (size) { !adBridge || adBridge.pushChange({ expandProperties: size }); @@ -807,14 +812,14 @@ INFO mraid.js identification script found }); }; - var getSupports = function(feature) { + var getSupports = function (feature) { for (var i = 0; i < supports.length; i++) { if (supports[i] == feature) return true; } return false; }; - var getHighestZindex = function() { + var getHighestZindex = function () { var zi = 0; var eles = document.getElementsByTagName('*'); var ele; @@ -828,7 +833,7 @@ INFO mraid.js identification script found return zi; }; - var endExpanded = function() { + var endExpanded = function () { if (adExpandedContainer) { adResizeContainer.appendChild(closeEventRegion); adExpandedContainer.parentNode.removeChild(adExpandedContainer); @@ -841,13 +846,13 @@ INFO mraid.js identification script found mraidview.setOrientation(orientation); }; - var setResizeProperties = function(properties) { + var setResizeProperties = function (properties) { resizeProperties.validated = false; if (!properties || !properties.width || !properties.height) { adFrame.contentWindow.broadcastEvent( EVENTS.ERROR, - 'missing properties for setResizeProperties' , + 'missing properties for setResizeProperties', 'setResizeProperties' ); } @@ -869,7 +874,7 @@ INFO mraid.js identification script found if (!properties.allowOffscreen) { if (properties.width > maxSizeWidth || properties.height > maxSizeHeight) { - adFrame.contentWindow.broadcastEvent(EVENTS.ERROR, 'invalid properties for setResizeProperties: width or height is too big' , 'setResizeProperties'); + adFrame.contentWindow.broadcastEvent(EVENTS.ERROR, 'invalid properties for setResizeProperties: width or height is too big', 'setResizeProperties'); } else { posX = Math.max(0, Math.min(maxSizeWidth - properties.width, defaultPosition.x + properties.offsetX)); posY = Math.max(0, Math.min(maxSizeHeight - properties.height, defaultPosition.y + properties.offsetY)); @@ -928,7 +933,7 @@ INFO mraid.js identification script found mraidview.setOrientation(orientation, true); } - if (typeof(properties.allowOrientationChange) === 'boolean') { + if (typeof (properties.allowOrientationChange) === 'boolean') { orientationProperties.allowOrientationChange = properties.allowOrientationChange; } }; @@ -1058,14 +1063,14 @@ INFO mraid.js identification script found adExpandedContainer.appendChild(closeEventRegion); adContainer.parentNode.appendChild(adExpandedContainer); - adExpandedContainer.style['z-index'] = getHighestZindex()+1; + adExpandedContainer.style['z-index'] = getHighestZindex() + 1; topAdContainer = adFrameExpanded; } acs.position = 'absolute'; setAdResizeContainerStyle(ac, maxSize); -// topAdContainer['z-index'] = getHighestZindex()+1; + // topAdContainer['z-index'] = getHighestZindex()+1; if (!uri || uri == '') { adBridge.pushChange({ @@ -1084,9 +1089,9 @@ INFO mraid.js identification script found }, this); - bridge.addEventListener('close', closeAd , this); + bridge.addEventListener('close', closeAd, this); - bridge.addEventListener('hide', function() { + bridge.addEventListener('hide', function () { adFrame.style.display = 'none'; adResizeContainer.disabled = 'none'; adContainer.style.display = 'none'; @@ -1108,7 +1113,7 @@ INFO mraid.js identification script found }); }, this); - bridge.addEventListener('open', function(URL) { + bridge.addEventListener('open', function (URL) { broadcastEvent(EVENTS.INFO, 'opening ' + URL); window.open(URL, '_blank', [ 'left=1000', @@ -1131,7 +1136,7 @@ INFO mraid.js identification script found window.open(URL, '_blank'); }, this); - bridge.addEventListener('storePicture', function(URL) { + bridge.addEventListener('storePicture', function (URL) { var allow = confirm('CONFIRM: Store this image to gallery?\nURL:' + URL); if (allow) { @@ -1142,7 +1147,7 @@ INFO mraid.js identification script found } }, this); - bridge.addEventListener('resize', function(uri) { + bridge.addEventListener('resize', function (uri) { if (state === STATES.EXPANDED) { adFrame.contentWindow.broadcastEvent(EVENTS.ERROR, 'Can not expand a resized ad', 'resize'); @@ -1252,7 +1257,7 @@ INFO mraid.js identification script found }); }; - var initAdFrame = function() { + var initAdFrame = function () { if (this.detachEvent) { this.detachEvent("onload", initAdFrame); } else { @@ -1263,6 +1268,14 @@ INFO mraid.js identification script found var win = this.contentWindow; var doc = win.document; var adScreen = {}; + // Load ad from external script + if (adHeadScript) { + broadcastEvent(EVENTS.INFO, 'attaching head script'); + var adScript = doc.createElement('script'); + adScript.setAttribute('type', 'text/javascript'); + adScript.innerHTML = adHeadScript; + doc.getElementsByTagName('head')[0].appendChild(adScript); + } var bridgeJS = doc.createElement('script'); for (var prop in win.screen) { @@ -1392,8 +1405,8 @@ INFO mraid.js identification script found var isAdViewAble = function () { var viewableAttr = adContainer.getAttribute('data-isViewable'); - return ((typeof(viewableAttr) === 'string' && viewableAttr === 'true') || - (typeof(viewableAttr) === 'boolean' && viewableAttr)); + return ((typeof (viewableAttr) === 'string' && viewableAttr === 'true') || + (typeof (viewableAttr) === 'boolean' && viewableAttr)); }; var setAdOrientation = function (degree) { @@ -1429,7 +1442,7 @@ INFO mraid.js identification script found } }; - var updateAdSize = function (val){ + var updateAdSize = function (val) { setMaxAdArea(val); setExpandProperties(val); }; diff --git a/widgets/css/devicesize-widget.css b/widgets/css/devicesize-widget.css old mode 100644 new mode 100755 diff --git a/widgets/css/orientation-widget.css b/widgets/css/orientation-widget.css old mode 100644 new mode 100755 diff --git a/widgets/img/icon_timer.gif b/widgets/img/icon_timer.gif old mode 100644 new mode 100755 diff --git a/widgets/img/orientation-sprite.png b/widgets/img/orientation-sprite.png old mode 100644 new mode 100755 diff --git a/widgets/img/orientation-to-landscape.png b/widgets/img/orientation-to-landscape.png old mode 100644 new mode 100755 diff --git a/widgets/img/orientation-to-portrait.png b/widgets/img/orientation-to-portrait.png old mode 100644 new mode 100755 diff --git a/widgets/img/timer-off.gif b/widgets/img/timer-off.gif old mode 100644 new mode 100755 diff --git a/widgets/img/timer-on.gif b/widgets/img/timer-on.gif old mode 100644 new mode 100755 diff --git a/widgets/js/devicesize-widget.js b/widgets/js/devicesize-widget.js old mode 100644 new mode 100755 diff --git a/widgets/js/orientation-widget.js b/widgets/js/orientation-widget.js old mode 100644 new mode 100755