X-Git-Url: http://juplo.de/gitweb/?a=blobdiff_plain;f=jquery.openx.js;h=889a5395cc33ddabc0c7e289b4f766429ae207ac;hb=4d83599b3e9a91d7bdfb0ef3c84dbef31ba80f75;hp=549553879307b443de6536107f52e0ddf827cffb;hpb=c8dd729f1206ea3f69fdf1cfe70d25a397259058;p=openx diff --git a/jquery.openx.js b/jquery.openx.js index 5495538..889a539 100644 --- a/jquery.openx.js +++ b/jquery.openx.js @@ -29,8 +29,14 @@ count = 0, slots = {}, + min_width = {}, + max_width = {}, + width, + rendered = {}, + visible = {}, + rendering = false, + resize_timer, queue = [], - ads = [], output = []; @@ -59,6 +65,13 @@ * (only needed, when it is not the default-value 443). * * + * Seldom needed special Server-Settings (these parameters are only needed, + * if the default delivery-configration of the OpenX-Server was changed): + * + * path: string Path to delivery-scripts. DEFAULT: "/www/delivery". + * fl: string Flash-Include-Script. DEFAULT: "fl.js". + * + * * Delivery-Options (for details and explanations see the see: * http://www.openx.com/docs/2.8/userguide/single%20page%20call): * @@ -79,11 +92,25 @@ * charset: string Charset used, when delivering the banner-codes. * If empty, the charset is guessed by OpenX. Examples * for sensible values: "UTF-8", "ISO-8859-1". + * + * + * Other settings: + * + * selector: string A selector for selecting the DOM-elements, that + * should display ad-banners. DEFAULT: ".oa". + * See: http://api.jquery.com/category/selectors/ + * min_prefix: string Prefix for the encoding of the minmal width as + * CSS-classname. DEFAULT: "min_". + * max_prefix: string Prefix for the encoding of the maximal width as + * CSS-classname. DEFAULT: "max_". + * resize_delay: number Number of milliseconds to wait, before a + * recalculation of the visible ads is scheduled. + * If the value is choosen to small, a recalculation + * might be scheduled, while resizing is still in + * progress. DEFAULT: 200. */ $.openx = function( options ) { - var name, src, errors = [], i; - if (domain) { if (console.error) { console.error('jQuery.openx was already initialized!'); @@ -98,12 +125,9 @@ _options = options; - if (!options.server) - errors.push('Required option "server" is missing!'); - if (errors.length > 0) { + if (!options.server) { if (console.error) { - for (i=0; i= min_width[id] && width <= max_width[id]; + if (visible[id]) { + if (!rendered[id]) { + queue.push(id); + src += escape(id + '=' + OA_zones[slots[id].id] + "|"); + rendered[id] = true; + } + else { + /** Unhide already fetched visible banners */ + $(slots[id]).slideDown(); + } + } + else { + /** Hide unvisible banners */ + $(slots[id]).hide(); + } + } src += '&nz=1'; // << We want to fetch named zones! /** @@ -177,7 +264,7 @@ if (settings.blockcampaign === 1) src += '&blockcampaign=1'; if (settings.target) - src += '&target' + settings.target; + src += '&target=' + settings.target; if (settings.withtext === 1) src += '&withtext=1'; if (settings.charset) @@ -187,25 +274,23 @@ if (typeof OA_source !== 'undefined') src += "&source=" + escape(OA_source); - /** Chain-load the scripts (next script to load is fl.js */ - $.getScript(src, load_flash); + /** Signal, that this task is done / in progress */ + width = undefined; - } - - function load_flash() { - - $.getScript(domain + '/www/delivery/fl.js', init_ads); + /** Fetch data from OpenX and schedule the render-preparation */ + $.getScript(src, init_ads); } function init_ads() { - var i, id; + var i, id, ads = []; for (i=0; i 0) { + while (queue.length > 0) { var result, src, inline; - id = ads.shift(); - node = slots[id]; + id = queue.shift(); + node = $(slots[id]); node.slideDown(); @@ -264,7 +349,7 @@ /** script-tag with src-URL! */ if (OA_output[id].length > 0) /** The banner-code was not rendered completely yet! */ - ads.unshift(id); + queue.unshift(id); /** Load the script and halt all work until the script is loaded and executed... */ $.getScript(result[1], render_ads); // << jQuery.getScript() generates onload-Handler for _all_ browsers ;) return; @@ -280,6 +365,12 @@ id = undefined; node = undefined; + rendering = false; + + /** Restart rendering, if new task was queued */ + if (width) + fetch_ads(); + } /** This function is used to overwrite document.write and document.writeln */ @@ -291,7 +382,7 @@ for (var i=0; i