From 99ed646a3df645fe1a50a83b76b269ea472341a5 Mon Sep 17 00:00:00 2001 From: Vadymus Date: Fri, 3 Jun 2016 20:58:41 -0400 Subject: [PATCH] remoteoffers extension v 1.2 with better logging and minified distribution version --- .../adobe.target.ext.remoteoffers.min.js | 24 +++++++++++++++++++ .../adobe.target.ext.remoteoffers.js | 13 +++++----- 2 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 dist/remoteoffers/adobe.target.ext.remoteoffers.min.js diff --git a/dist/remoteoffers/adobe.target.ext.remoteoffers.min.js b/dist/remoteoffers/adobe.target.ext.remoteoffers.min.js new file mode 100644 index 00000000..cab57f9c --- /dev/null +++ b/dist/remoteoffers/adobe.target.ext.remoteoffers.min.js @@ -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