-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remoteoffers extension v 1.2 with better logging and minified distrib…
…ution version
- Loading branch information
Showing
2 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*! | ||
* adobe.target.ext.remoteoffers.js v0.1.2 | ||
* | ||
* Copyright 1996-2016. Adobe Systems Incorporated. All rights reserved. | ||
* | ||
* Example: | ||
adobe.target.ext.remoteoffers.init( | ||
[ | ||
{ | ||
'url': '/promotion1.html', //remote offer url (required, must be same domain) | ||
'selector': '.menu a', //CSS selector of element to deliver offer to | ||
'callbackSuccess': function(){}, //successful callback | ||
'callbackError': function(){}, //error handler | ||
'method': 'replace' //method to handle offer injection into DOM: 'append' (default) or 'replace' | ||
}, | ||
{ | ||
'url': '/promotion2.html', | ||
'selector': '#banner' | ||
} | ||
], | ||
{debug:true} | ||
); | ||
*/ | ||
!function(e){"use strict";e.target=e.target||{},e.target.ext=e.target.ext||{},e.target.ext.remoteoffers=e.target.ext.remoteoffers||{},e.target.ext.remoteoffers.init=function(e,t){var r=t.debug&&t.debug===!0&&console&&console.info?function(e){console.info("ATX:"+e)}:function(){},o=function(e,t,o){r("XHR to "+e);var n=new XMLHttpRequest;n.onreadystatechange=function(){4==n.readyState&&(200==n.status?t(n.responseText):o(n.status))},n.open("GET",e,!0),n.send()},n=function(e){var t=document.getElementsByTagName("head")[0];if(t){var r=document.createElement("style");r.setAttribute("type","text/css"),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e)),t.insertBefore(r,t.firstChild)}},a=function(e,t,a,c,s){r("getOffer");var i=t+"{visibility:hidden}";n(i),o(e,function(o){r("Call success, applyOffer "+e+" to "+t);var n=document.querySelector(t);if(n){if("string"==typeof s&&"replace"===s){var c=document.createElement("div");n.parentNode.replaceChild(c,n),n=c,r("method:"+s)}adobe.target.applyOffer({element:n,offer:[{type:"html",content:o}]})}"function"==typeof a&&(r("Success handler"),a())},function(o){r("Error loading content for '"+e+"', status: '"+o);var n=document.querySelector(t);n&&(n.style.visibility="visible"),"function"==typeof c&&(r("Error handler"),c())})};!function(){for(var t=0;t<e.length;t++){var o=e[t];o.url&&o.selector?a(o.url,o.selector,o.callbackSuccess,o.callbackError,o.method):r("Error:missing URL or selector")}}()}}(adobe); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters