count = 0,
slots = {},
+ min_width = {},
+ max_width = {},
+ width,
+ rendered = {},
queue = [],
output = [];
* 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_".
*/
$.openx = function( options ) {
'delivery': '/www/delivery',
'fl': 'fl.js',
'selector': '.oa',
- 'cache': true
+ 'min_prefix': 'min_',
+ 'max_prefix': 'max_',
},
options
);
for(name in OA_zones) {
$(settings.selector).each(function() {
var
- id;
+ id,
+ classes,
+ i,
+ min = new RegExp('^' + settings.min_prefix + '([0-9]+)$'),
+ max = new RegExp('^' + settings.max_prefix + '([0-9]+)$'),
+ match;
if (this.id === name) {
id = 'oa_' + ++count;
slots[id] = this;
+ min_width[id] = 0;
+ max_width[id] = Number.MAX_VALUE;
+ classes = this.className.split(/\s+/);
+ for (i=0; i<classes.length; i++) {
+ match = min.exec(classes[i]);
+ if (match)
+ min_width[id] = match[1];
+ match = max.exec(classes[i]);
+ if (match)
+ max_width[id] = match[1];
+ }
+ rendered[id] = false;
}
});
}
+ /** Set initial window-width */
+ width = $(document).width();
+
/** Fetch the JavaScript for Flash and schedule the initial fetch */
$.getScript(domain + settings.delivery + '/' + settings.fl, fetch_ads);
/** Order banners for all zones that were found on the page */
src += '?zones=';
for(id in slots) {
- queue.push(id);
- src += escape(id + '=' + OA_zones[slots[id].id] + "|");
+ if (width >= min_width[id] && width <= max_width[id]) {
+ queue.push(id);
+ src += escape(id + '=' + OA_zones[slots[id].id] + "|");
+ rendered[id] = true;
+ }
}
src += '&nz=1'; // << We want to fetch named zones!