Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add plugin version compiled with Google Closure Compiler

  • Loading branch information...
commit 3b489cb075b88370e6414d0343c6d5423ebc7738 1 parent 24d6eb7
@kolyuchiy kolyuchiy authored
View
2  .gitignore
@@ -1 +1,3 @@
jquery-openxtag-*
+dist/README.md
+dist/examples
View
11 Makefile
@@ -10,6 +10,7 @@ DIST_DIR = ${PREFIX}/dist
JS_ENGINE ?= `which node nodejs`
COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
+CLOSURE_COMPILER = java -jar ~/Applications/closure-compiler/compiler.jar
BASE_FILES = ${SRC_DIR}/jquery.openxtag.js
@@ -17,6 +18,7 @@ MODULES = ${BASE_FILES}
JQ = ${DIST_DIR}/jquery.openxtag.js
JQ_MIN = ${DIST_DIR}/jquery.openxtag.min.js
+JQ_CC = ${DIST_DIR}/jquery.openxtag.cc.js
JQ_VER = $(shell cat version.txt)
VER = sed "s/@VERSION/${JQ_VER}/"
@@ -31,7 +33,7 @@ core: jquery min lint
${DIST_DIR}:
@@mkdir -p ${DIST_DIR}
- @@cp -r README examples ${DIST_DIR}
+ @@cp -r README.md examples ${DIST_DIR}
jquery: ${JQ}
@@ -56,7 +58,7 @@ lint: jquery
echo "You must have NodeJS installed in order to test plugin against JSLint."; \
fi
-min: jquery ${JQ_MIN}
+min: jquery ${JQ_MIN} ${JQ_CC}
${JQ_MIN}: ${JQ}
@@if test ! -z ${JS_ENGINE}; then \
@@ -66,6 +68,11 @@ ${JQ_MIN}: ${JQ}
echo "You must have NodeJS installed in order to minify plugin."; \
fi
+${JQ_CC}: ${JQ}
+ @@echo "Closure compiling plugin" ${JQ_CC}; \
+ ${CLOSURE_COMPILER} --compilation_level ADVANCED_OPTIMIZATIONS --js ${JQ} \
+ --externs examples/jquery-1.6.2rc1-ab1504f.min.js --externs examples/jquery.metadata.js \
+ --warning_level QUIET > ${JQ_CC};
clean:
@@echo "Removing Distribution directory:" ${DIST_DIR} ${TGZ} ${TGZ}.tar.gz
View
2  build/jslint-check.js
@@ -21,7 +21,7 @@ var e = JSLINT.errors, found = 0, w;
for ( var i = 0; i < e.length; i++ ) {
w = e[i];
- if ( !ok[ w.reason ] ) {
+ if ( !ok[ w.reason ] && !w.reason.match(/is better written in dot notation\./)) {
found++;
print( "\n" + w.evidence + "\n" );
print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
View
8 dist/jquery.openxtag.cc.js
@@ -0,0 +1,8 @@
+var h=null;
+(function(b){function l(a,f){return this.each(function(){var a=b(this),e=b.extend({},f);typeof b.metadata!="undefined"&&(e=b.extend(e,a.metadata()));m(e);var g=e.zoneID;g==h&&b.error('please set "zoneID" option for openxtag jsZone');var c=n(e);c.zoneid=g;c.cb=Math.floor(Math.random()*99999999999);document.MAX_used||(document.MAX_used=",");document.MAX_used!=","&&(c.exclude=document.MAX_used);if(document.context)c.context=document.context;document.a&&(c.mmm_fo=1);b.ajax({url:(location.protocol=="https:"?
+e.deliverySSL:e.delivery)+"/"+e.jsTagScript,data:c,dataType:"html",async:e.forceAsync,success:function(b){o('<script type="text/javascript">'+b+"<\/script>",a)}})})}function o(a,f){var d=0;(function(a){if(a.match(/document\.write|<script/)){var g=document.write,c="";document.write=function(a){c+=a};f.append(a);document.write=g;d++;d>p&&b.error("openxtag: document.write loop stopped after "+p+" iterations");arguments.callee(c)}else f.append(a),typeof success=="function"&&setTimeout(success,0)})(a)}
+function r(a,f,d,e){if(typeof f=="object"||typeof f=="function")e=d,d=f,f=h;typeof d=="function"&&(e=d,d=h);d=b.extend(i,d);f!=h&&(d.zoneID=f);return a.apply(this,[f,d,e])}function m(a){location.protocol=="https:"?typeof a.deliverySSL!="string"&&b.error('please set "deliverySSL" option for openxtag'):typeof a.delivery!="string"&&b.error('please set "delivery" option for openxtag')}function n(a){var b={charset:a.charset,target:a.target,source:a.source,extra:a.extra,loc:window.location.href};typeof a.block!=
+"undefined"&&(b.block=a.block?1:0);typeof a.blockcampaign!="undefined"&&(b.blockcampaign=a.blockcampaign?1:0);if(document.referrer)b.referer=document.referrer;return b}var p=10,i={jsPrefix:"OA_",swfObjectJS:"fl.js",delivery:h,deliverySSL:h,jsTagScript:"ajs.php",spcTagScript:"spc.php",charset:"UTF-8",zoneID:h,target:void 0,source:void 0,blockcampaign:void 0,block:void 0,forceAsync:!1,extra:void 0},q={zone:l,jsZone:l,spc:function(a,f){var d={},e=0,g=this.each(function(){var a=b(this),c=b.extend({},
+f);typeof b.metadata!="undefined"&&(c=b.extend(c,a.metadata()));c=c.zoneID;c==h&&b.error('please set "zoneID" option for openxtag jsZone');var g="z"+e;d[g]=c;a.data("openxtag",{zn:g});e++}),c=b.extend({},f);m(c);var j=n(c);j.zones=Object.keys(d).map(function(a){return a+"="+d[a]}).join("|");j.nz=1;j.r=Math.floor(Math.random()*99999999999);var i=this;b.ajax({url:(location.protocol=="https:"?c.deliverySSL:c.delivery)+"/"+c.spcTagScript,data:j,dataType:"html",async:c.forceAsync,success:function(a){b.getScript((location.protocol==
+"https:"?c.deliverySSL:c.delivery)+"/"+c.swfObjectJS,function(){var d=eval("(function () {"+a+";return "+c.jsPrefix+"output;})()");i.each(function(){var a=b(this);o(d[a.data("openxtag").zn],a)})})}});return g}};b.fn.extend({openxtag:function(a){if(q[a])return r.apply(this,[q[a]].concat(Array.prototype.slice.call(arguments,1)));else b.error("Method "+a+" does not exist on jQuery.openxtag")}});var k={init:function(a){i=b.extend(i,a)}};b.extend({openxtag:function(a){if(k[a])return k[a].apply(this,Array.prototype.slice.call(arguments,
+1));else if(typeof a==="object"||!a)return k.init.apply(this,arguments);else b.error("Method "+a+" does not exist on jQuery.openxtag")}})})(jQuery);
View
153 dist/jquery.openxtag.js
@@ -4,7 +4,7 @@
* Tested with OpenX Community Edition 2.8.8-rc6
*
* @version 1.0
- * @date Thu Jul 14 21:35:51 2011 +0400
+ * @date Fri Jul 15 12:53:31 2011 +0400
* @requires jQuery
* @url http://plugins.jquery.com/project/openxtag
*
@@ -15,23 +15,27 @@
(function ($) {
+ // NOTE Use strings instead of symbolic names if that name will be used
+ // externally. It is needed to preserve the name after closure compiler
+ // advanced optimization
+
var _loopIterations = 10;
var defaults = {
- jsPrefix: 'OA_',
- swfObjectJS: 'fl.js',
- delivery: null,
- deliverySSL: null,
- jsTagScript: 'ajs.php',
- spcTagScript: 'spc.php',
- charset: 'UTF-8',
- zoneID: null,
- target: undefined,
- source: undefined,
- blockcampaign: undefined, // bool option
- block: undefined, // bool option
- forceAsync: false, // not compatible with block(campaign) parameters
- extra: undefined // object of key-value pairs for custom parameters
+ 'jsPrefix': 'OA_',
+ 'swfObjectJS': 'fl.js',
+ 'delivery': null,
+ 'deliverySSL': null,
+ 'jsTagScript': 'ajs.php',
+ 'spcTagScript': 'spc.php',
+ 'charset': 'UTF-8',
+ 'zoneID': null,
+ 'target': undefined,
+ 'source': undefined,
+ 'blockcampaign': undefined, // bool option
+ 'block': undefined, // bool option
+ 'forceAsync': false, // not compatible with block(campaign) parameters
+ 'extra': undefined // object of key-value pairs for custom parameters
};
var init = function (options) {
@@ -88,7 +92,7 @@
var settings = $.extend(defaults, options);
if (zoneID != null) {
- settings.zoneID = zoneID;
+ settings['zoneID'] = zoneID;
}
return func.apply(this, [zoneID, settings, success]);
@@ -101,12 +105,12 @@
// check for required parameters
if (location.protocol == 'https:') {
- if (typeof settings.deliverySSL != 'string') {
+ if (typeof settings['deliverySSL'] != 'string') {
$.error('please set "deliverySSL" option for openxtag');
}
}
else {
- if (typeof settings.delivery != 'string') {
+ if (typeof settings['delivery'] != 'string') {
$.error('please set "delivery" option for openxtag');
}
}
@@ -116,23 +120,23 @@
// {{{ function _buildStandardRequestParameters() { ... }
function _buildStandardRequestParameters(settings) {
var data = {
- charset: settings.charset,
- target: settings.target,
- source: settings.source,
- extra: settings.extra,
- loc: window.location.href
+ 'charset': settings['charset'],
+ 'target': settings['target'],
+ 'source': settings['source'],
+ 'extra': settings['extra'],
+ 'loc': window.location.href
};
- if (typeof settings.block != 'undefined') {
- data.block = settings.block ? 1 : 0;
+ if (typeof settings['block'] != 'undefined') {
+ data['block'] = settings['block'] ? 1 : 0;
}
- if (typeof settings.blockcampaign != 'undefined') {
- data.blockcampaign = settings.blockcampaign ? 1 : 0;
+ if (typeof settings['blockcampaign'] != 'undefined') {
+ data['blockcampaign'] = settings['blockcampaign'] ? 1 : 0;
}
if (document.referrer) {
- data.referer = document.referrer;
+ data['referer'] = document.referrer;
}
return data;
@@ -152,36 +156,36 @@
_validateSettings(thesettings);
- var zoneID = thesettings.zoneID;
+ var zoneID = thesettings['zoneID'];
if (zoneID == null) {
$.error('please set "zoneID" option for openxtag jsZone');
}
var data = _buildStandardRequestParameters(thesettings);
- data.zoneid = zoneID;
- data.cb = Math.floor(Math.random()*99999999999);
+ data['zoneid'] = zoneID;
+ data['cb'] = Math.floor(Math.random()*99999999999);
// only needed for OpenX < 2.4
- if (!document.MAX_used) {
- document.MAX_used = ',';
+ if (!document['MAX_used']) {
+ document['MAX_used'] = ',';
}
- if (document.MAX_used != ',') {
- data.exclude = document.MAX_used;
+ if (document['MAX_used'] != ',') {
+ data['exclude'] = document['MAX_used'];
}
if (document.context) {
- data.context = document.context;
+ data['context'] = document.context;
}
if (document.mmm_fo) {
- data.mmm_fo = 1;
+ data['mmm_fo'] = 1;
}
- var scriptURL = (location.protocol == 'https:' ? thesettings.deliverySSL : thesettings.delivery) + '/' + thesettings.jsTagScript;
+ var scriptURL = (location.protocol == 'https:' ? thesettings['deliverySSL'] : thesettings['delivery']) + '/' + thesettings['jsTagScript'];
$.ajax({
url: scriptURL,
data: data,
dataType: 'html',
- async: thesettings.forceAsync, // should be disabled for block(campaign)
+ async: thesettings['forceAsync'], // should be disabled for block(campaign)
success: function (data) {
_documentWriteSafeAppend('<script type="text/javascript">' + data + '</script>', $this);
}
@@ -210,14 +214,14 @@
thesettings = $.extend(thesettings, $this.metadata());
}
- var zoneID = thesettings.zoneID;
+ var zoneID = thesettings['zoneID'];
if (zoneID == null) {
$.error('please set "zoneID" option for openxtag jsZone');
}
var zoneName = 'z' + i;
zones[zoneName] = zoneID;
- $this.data('openxtag', { zoneName: zoneName });
+ $this.data('openxtag', { 'zn': zoneName });
i++;
});
@@ -226,24 +230,24 @@
_validateSettings(thesettings);
var data = _buildStandardRequestParameters(thesettings);
- data.zones = Object.keys(zones).map(function (key) { return key + '=' + zones[key]; }).join('|');
- data.nz = 1; // named zones
- data.r = Math.floor(Math.random()*99999999999);
+ data['zones'] = Object.keys(zones).map(function (key) { return key + '=' + zones[key]; }).join('|');
+ data['nz'] = 1; // named zones
+ data['r'] = Math.floor(Math.random()*99999999999);
- var scriptURL = (location.protocol == 'https:' ? thesettings.deliverySSL : thesettings.delivery) + '/' + thesettings.spcTagScript;
+ var scriptURL = (location.protocol == 'https:' ? thesettings['deliverySSL'] : thesettings['delivery']) + '/' + thesettings['spcTagScript'];
var that = this;
$.ajax({
url: scriptURL,
data: data,
dataType: 'html',
- async: thesettings.forceAsync, // should be disabled for block(campaign)
+ async: thesettings['forceAsync'], // should be disabled for block(campaign)
success: function (data) {
- var flJsURL = (location.protocol == 'https:' ? thesettings.deliverySSL : thesettings.delivery) + '/' + thesettings.swfObjectJS;
+ var flJsURL = (location.protocol == 'https:' ? thesettings['deliverySSL'] : thesettings['delivery']) + '/' + thesettings['swfObjectJS'];
$.getScript(flJsURL, function () {
- var output = eval('(function () {' + data + ';return ' + thesettings.jsPrefix + 'output;})()');
+ var output = eval('(function () {' + data + ';return ' + thesettings['jsPrefix'] + 'output;})()');
that.each(function () {
var $this = $(this);
- _documentWriteSafeAppend(output[$this.data('openxtag').zoneName], $this);
+ _documentWriteSafeAppend(output[$this.data('openxtag')['zn']], $this);
});
});
}
@@ -254,9 +258,9 @@
/// }}} spcTag
var fnMethods = {
- zone: jsZone,
- jsZone: jsZone,
- spc: spcTag
+ 'zone': jsZone,
+ 'jsZone': jsZone,
+ 'spc': spcTag
};
// {{{ function $.fn.openxtag(method) { ... }
@@ -270,8 +274,9 @@
* $('.banner').openxtag('zone', 1);
*
* @descr Loads ads into elements
- * @param string type Type of ad invocation tag. Currently only "jsZone" is
- * supported. "zone" is alias for "jsZone".
+ * @param string type Type of ad invocation tag. Currently supported types
+ * are 'jsZone' for JavaScript invocation tag and 'spc' for Single Page Call
+ * tag. "zone" is alias for "jsZone".
* @param number zoneID ID of OpenX zone to load banner from.
* @param object options An object containing settings to override the
* defaults (see init).
@@ -281,19 +286,19 @@
* @cat Plugins/OpenXTag
* @see http://www.openx.org/docs/tutorials/comparisons-between-invocation-tags types of OpenX ad invocation tags
*/
- $.fn.openxtag = function (method) {
- if (fnMethods[method]) {
- return _genericZoneCall.apply(this, [ fnMethods[method] ].concat(Array.prototype.slice.call(arguments, 1)));
- } else if (typeof method === 'object' || !method) {
- return fnMethods.init.apply(this, arguments);
- } else {
- $.error('Method ' + method + ' does not exist on jQuery.openxtag');
- }
- };
+ $.fn.extend({
+ 'openxtag': function (method) {
+ if (fnMethods[method]) {
+ return _genericZoneCall.apply(this, [ fnMethods[method] ].concat(Array.prototype.slice.call(arguments, 1)));
+ } else {
+ $.error('Method ' + method + ' does not exist on jQuery.openxtag');
+ }
+ }
+ });
// }}} $.fn.openxtag
var methods = {
- init: init
+ 'init': init
};
// {{{ function $.openxtag(method) { ... }
@@ -361,15 +366,17 @@
* @type undefined
* @see http://www.openx.org/docs/2.8/userguide/zone%20invocation
*/
- $.openxtag = function (method) {
- if (methods[method]) {
- return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
- } else if (typeof method === 'object' || !method) {
- return methods.init.apply(this, arguments);
- } else {
- $.error('Method ' + method + ' does not exist on jQuery.openxtag');
- }
- };
+ $.extend({
+ 'openxtag': function (method) {
+ if (methods[method]) {
+ return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
+ } else if (typeof method === 'object' || !method) {
+ return methods.init.apply(this, arguments);
+ } else {
+ $.error('Method ' + method + ' does not exist on jQuery.openxtag');
+ }
+ }
+ });
// }}} $.openxtag
})(jQuery);
View
4 dist/jquery.openxtag.min.js
@@ -4,11 +4,11 @@
* Tested with OpenX Community Edition 2.8.8-rc6
*
* @version 1.0
- * @date Thu Jul 14 21:35:51 2011 +0400
+ * @date Fri Jul 15 12:53:31 2011 +0400
* @requires jQuery
* @url http://plugins.jquery.com/project/openxtag
*
* @author Nikolay Morev <kolia@denivip.ru>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*
- */(function($){function _buildStandardRequestParameters(a){var b={charset:a.charset,target:a.target,source:a.source,extra:a.extra,loc:window.location.href};typeof a.block!="undefined"&&(b.block=a.block?1:0),typeof a.blockcampaign!="undefined"&&(b.blockcampaign=a.blockcampaign?1:0),document.referrer&&(b.referer=document.referrer);return b}function _validateSettings(a){location.protocol=="https:"?typeof a.deliverySSL!="string"&&$.error('please set "deliverySSL" option for openxtag'):typeof a.delivery!="string"&&$.error('please set "delivery" option for openxtag')}function _genericZoneCall(a,b,c,d){if(typeof b=="object"||typeof b=="function")d=c,c=b,b=null;typeof c=="function"&&(d=c,c=null);var e=$.extend(defaults,c);b!=null&&(e.zoneID=b);return a.apply(this,[b,e,d])}function _documentWriteSafeAppend(a,b){var c=0;(function(a){if(a.match(/document\.write|<script/)){var d=document.write,e="";document.write=function(a){e+=a},b.append(a),document.write=d,c++,c>_loopIterations&&$.error("openxtag: document.write loop stopped after "+_loopIterations+" iterations"),arguments.callee(e)}else b.append(a),typeof success=="function"&&setTimeout(success,0)})(a)}var _loopIterations=10,defaults={jsPrefix:"OA_",swfObjectJS:"fl.js",delivery:null,deliverySSL:null,jsTagScript:"ajs.php",spcTagScript:"spc.php",charset:"UTF-8",zoneID:null,target:undefined,source:undefined,blockcampaign:undefined,block:undefined,forceAsync:!1,extra:undefined},init=function(a){defaults=$.extend(defaults,a)},jsZone=function(a,b,c){return this.each(function(){var a=$(this),c=$.extend({},b);typeof $.metadata!="undefined"&&(c=$.extend(c,a.metadata())),_validateSettings(c);var d=c.zoneID;d==null&&$.error('please set "zoneID" option for openxtag jsZone');var e=_buildStandardRequestParameters(c);e.zoneid=d,e.cb=Math.floor(Math.random()*99999999999),document.MAX_used||(document.MAX_used=","),document.MAX_used!=","&&(e.exclude=document.MAX_used),document.context&&(e.context=document.context),document.mmm_fo&&(e.mmm_fo=1);var f=(location.protocol=="https:"?c.deliverySSL:c.delivery)+"/"+c.jsTagScript;$.ajax({url:f,data:e,dataType:"html",async:c.forceAsync,success:function(b){_documentWriteSafeAppend('<script type="text/javascript">'+b+"</script>",a)}})})},iFrameZone=function(a,b,c){},spcTag=function(zoneID,settings,success){var zones={},i=0,chainObj=this.each(function(){var a=$(this),b=$.extend({},settings);typeof $.metadata!="undefined"&&(b=$.extend(b,a.metadata()));var c=b.zoneID;c==null&&$.error('please set "zoneID" option for openxtag jsZone');var d="z"+i;zones[d]=c,a.data("openxtag",{zoneName:d}),i++}),thesettings=$.extend({},settings);_validateSettings(thesettings);var data=_buildStandardRequestParameters(thesettings);data.zones=Object.keys(zones).map(function(a){return a+"="+zones[a]}).join("|"),data.nz=1,data.r=Math.floor(Math.random()*99999999999);var scriptURL=(location.protocol=="https:"?thesettings.deliverySSL:thesettings.delivery)+"/"+thesettings.spcTagScript,that=this;$.ajax({url:scriptURL,data:data,dataType:"html",async:thesettings.forceAsync,success:function(data){var flJsURL=(location.protocol=="https:"?thesettings.deliverySSL:thesettings.delivery)+"/"+thesettings.swfObjectJS;$.getScript(flJsURL,function(){var output=eval("(function () {"+data+";return "+thesettings.jsPrefix+"output;})()");that.each(function(){var a=$(this);_documentWriteSafeAppend(output[a.data("openxtag").zoneName],a)})})}});return chainObj},fnMethods={zone:jsZone,jsZone:jsZone,spc:spcTag};$.fn.openxtag=function(a){if(fnMethods[a])return _genericZoneCall.apply(this,[fnMethods[a]].concat(Array.prototype.slice.call(arguments,1)));if(typeof a=="object"||!a)return fnMethods.init.apply(this,arguments);$.error("Method "+a+" does not exist on jQuery.openxtag")};var methods={init:init};$.openxtag=function(a){if(methods[a])return methods[a].apply(this,Array.prototype.slice.call(arguments,1));if(typeof a=="object"||!a)return methods.init.apply(this,arguments);$.error("Method "+a+" does not exist on jQuery.openxtag")}})(jQuery)
+ */(function($){function _buildStandardRequestParameters(a){var b={charset:a.charset,target:a.target,source:a.source,extra:a.extra,loc:window.location.href};typeof a.block!="undefined"&&(b.block=a.block?1:0),typeof a.blockcampaign!="undefined"&&(b.blockcampaign=a.blockcampaign?1:0),document.referrer&&(b.referer=document.referrer);return b}function _validateSettings(a){location.protocol=="https:"?typeof a.deliverySSL!="string"&&$.error('please set "deliverySSL" option for openxtag'):typeof a.delivery!="string"&&$.error('please set "delivery" option for openxtag')}function _genericZoneCall(a,b,c,d){if(typeof b=="object"||typeof b=="function")d=c,c=b,b=null;typeof c=="function"&&(d=c,c=null);var e=$.extend(defaults,c);b!=null&&(e.zoneID=b);return a.apply(this,[b,e,d])}function _documentWriteSafeAppend(a,b){var c=0;(function(a){if(a.match(/document\.write|<script/)){var d=document.write,e="";document.write=function(a){e+=a},b.append(a),document.write=d,c++,c>_loopIterations&&$.error("openxtag: document.write loop stopped after "+_loopIterations+" iterations"),arguments.callee(e)}else b.append(a),typeof success=="function"&&setTimeout(success,0)})(a)}var _loopIterations=10,defaults={jsPrefix:"OA_",swfObjectJS:"fl.js",delivery:null,deliverySSL:null,jsTagScript:"ajs.php",spcTagScript:"spc.php",charset:"UTF-8",zoneID:null,target:undefined,source:undefined,blockcampaign:undefined,block:undefined,forceAsync:!1,extra:undefined},init=function(a){defaults=$.extend(defaults,a)},jsZone=function(a,b,c){return this.each(function(){var a=$(this),c=$.extend({},b);typeof $.metadata!="undefined"&&(c=$.extend(c,a.metadata())),_validateSettings(c);var d=c.zoneID;d==null&&$.error('please set "zoneID" option for openxtag jsZone');var e=_buildStandardRequestParameters(c);e.zoneid=d,e.cb=Math.floor(Math.random()*99999999999),document.MAX_used||(document.MAX_used=","),document.MAX_used!=","&&(e.exclude=document.MAX_used),document.context&&(e.context=document.context),document.mmm_fo&&(e.mmm_fo=1);var f=(location.protocol=="https:"?c.deliverySSL:c.delivery)+"/"+c.jsTagScript;$.ajax({url:f,data:e,dataType:"html",async:c.forceAsync,success:function(b){_documentWriteSafeAppend('<script type="text/javascript">'+b+"</script>",a)}})})},iFrameZone=function(a,b,c){},spcTag=function(zoneID,settings,success){var zones={},i=0,chainObj=this.each(function(){var a=$(this),b=$.extend({},settings);typeof $.metadata!="undefined"&&(b=$.extend(b,a.metadata()));var c=b.zoneID;c==null&&$.error('please set "zoneID" option for openxtag jsZone');var d="z"+i;zones[d]=c,a.data("openxtag",{zn:d}),i++}),thesettings=$.extend({},settings);_validateSettings(thesettings);var data=_buildStandardRequestParameters(thesettings);data.zones=Object.keys(zones).map(function(a){return a+"="+zones[a]}).join("|"),data.nz=1,data.r=Math.floor(Math.random()*99999999999);var scriptURL=(location.protocol=="https:"?thesettings.deliverySSL:thesettings.delivery)+"/"+thesettings.spcTagScript,that=this;$.ajax({url:scriptURL,data:data,dataType:"html",async:thesettings.forceAsync,success:function(data){var flJsURL=(location.protocol=="https:"?thesettings.deliverySSL:thesettings.delivery)+"/"+thesettings.swfObjectJS;$.getScript(flJsURL,function(){var output=eval("(function () {"+data+";return "+thesettings.jsPrefix+"output;})()");that.each(function(){var a=$(this);_documentWriteSafeAppend(output[a.data("openxtag").zn],a)})})}});return chainObj},fnMethods={zone:jsZone,jsZone:jsZone,spc:spcTag};$.fn.extend({openxtag:function(a){if(fnMethods[a])return _genericZoneCall.apply(this,[fnMethods[a]].concat(Array.prototype.slice.call(arguments,1)));$.error("Method "+a+" does not exist on jQuery.openxtag")}});var methods={init:init};$.extend({openxtag:function(a){if(methods[a])return methods[a].apply(this,Array.prototype.slice.call(arguments,1));if(typeof a=="object"||!a)return methods.init.apply(this,arguments);$.error("Method "+a+" does not exist on jQuery.openxtag")}})})(jQuery)
View
144 src/jquery.openxtag.js
@@ -15,23 +15,27 @@
(function ($) {
+ // NOTE Use strings instead of symbolic names if that name will be used
+ // externally. It is needed to preserve the name after closure compiler
+ // advanced optimization
+
var _loopIterations = 10;
var defaults = {
- jsPrefix: 'OA_',
- swfObjectJS: 'fl.js',
- delivery: null,
- deliverySSL: null,
- jsTagScript: 'ajs.php',
- spcTagScript: 'spc.php',
- charset: 'UTF-8',
- zoneID: null,
- target: undefined,
- source: undefined,
- blockcampaign: undefined, // bool option
- block: undefined, // bool option
- forceAsync: false, // not compatible with block(campaign) parameters
- extra: undefined // object of key-value pairs for custom parameters
+ 'jsPrefix': 'OA_',
+ 'swfObjectJS': 'fl.js',
+ 'delivery': null,
+ 'deliverySSL': null,
+ 'jsTagScript': 'ajs.php',
+ 'spcTagScript': 'spc.php',
+ 'charset': 'UTF-8',
+ 'zoneID': null,
+ 'target': undefined,
+ 'source': undefined,
+ 'blockcampaign': undefined, // bool option
+ 'block': undefined, // bool option
+ 'forceAsync': false, // not compatible with block(campaign) parameters
+ 'extra': undefined // object of key-value pairs for custom parameters
};
var init = function (options) {
@@ -88,7 +92,7 @@
var settings = $.extend(defaults, options);
if (zoneID != null) {
- settings.zoneID = zoneID;
+ settings['zoneID'] = zoneID;
}
return func.apply(this, [zoneID, settings, success]);
@@ -101,12 +105,12 @@
// check for required parameters
if (location.protocol == 'https:') {
- if (typeof settings.deliverySSL != 'string') {
+ if (typeof settings['deliverySSL'] != 'string') {
$.error('please set "deliverySSL" option for openxtag');
}
}
else {
- if (typeof settings.delivery != 'string') {
+ if (typeof settings['delivery'] != 'string') {
$.error('please set "delivery" option for openxtag');
}
}
@@ -116,23 +120,23 @@
// {{{ function _buildStandardRequestParameters() { ... }
function _buildStandardRequestParameters(settings) {
var data = {
- charset: settings.charset,
- target: settings.target,
- source: settings.source,
- extra: settings.extra,
- loc: window.location.href
+ 'charset': settings['charset'],
+ 'target': settings['target'],
+ 'source': settings['source'],
+ 'extra': settings['extra'],
+ 'loc': window.location.href
};
- if (typeof settings.block != 'undefined') {
- data.block = settings.block ? 1 : 0;
+ if (typeof settings['block'] != 'undefined') {
+ data['block'] = settings['block'] ? 1 : 0;
}
- if (typeof settings.blockcampaign != 'undefined') {
- data.blockcampaign = settings.blockcampaign ? 1 : 0;
+ if (typeof settings['blockcampaign'] != 'undefined') {
+ data['blockcampaign'] = settings['blockcampaign'] ? 1 : 0;
}
if (document.referrer) {
- data.referer = document.referrer;
+ data['referer'] = document.referrer;
}
return data;
@@ -152,36 +156,36 @@
_validateSettings(thesettings);
- var zoneID = thesettings.zoneID;
+ var zoneID = thesettings['zoneID'];
if (zoneID == null) {
$.error('please set "zoneID" option for openxtag jsZone');
}
var data = _buildStandardRequestParameters(thesettings);
- data.zoneid = zoneID;
- data.cb = Math.floor(Math.random()*99999999999);
+ data['zoneid'] = zoneID;
+ data['cb'] = Math.floor(Math.random()*99999999999);
// only needed for OpenX < 2.4
- if (!document.MAX_used) {
- document.MAX_used = ',';
+ if (!document['MAX_used']) {
+ document['MAX_used'] = ',';
}
- if (document.MAX_used != ',') {
- data.exclude = document.MAX_used;
+ if (document['MAX_used'] != ',') {
+ data['exclude'] = document['MAX_used'];
}
if (document.context) {
- data.context = document.context;
+ data['context'] = document.context;
}
if (document.mmm_fo) {
- data.mmm_fo = 1;
+ data['mmm_fo'] = 1;
}
- var scriptURL = (location.protocol == 'https:' ? thesettings.deliverySSL : thesettings.delivery) + '/' + thesettings.jsTagScript;
+ var scriptURL = (location.protocol == 'https:' ? thesettings['deliverySSL'] : thesettings['delivery']) + '/' + thesettings['jsTagScript'];
$.ajax({
url: scriptURL,
data: data,
dataType: 'html',
- async: thesettings.forceAsync, // should be disabled for block(campaign)
+ async: thesettings['forceAsync'], // should be disabled for block(campaign)
success: function (data) {
_documentWriteSafeAppend('<script type="text/javascript">' + data + '</script>', $this);
}
@@ -210,14 +214,14 @@
thesettings = $.extend(thesettings, $this.metadata());
}
- var zoneID = thesettings.zoneID;
+ var zoneID = thesettings['zoneID'];
if (zoneID == null) {
$.error('please set "zoneID" option for openxtag jsZone');
}
var zoneName = 'z' + i;
zones[zoneName] = zoneID;
- $this.data('openxtag', { zoneName: zoneName });
+ $this.data('openxtag', { 'zn': zoneName });
i++;
});
@@ -226,24 +230,24 @@
_validateSettings(thesettings);
var data = _buildStandardRequestParameters(thesettings);
- data.zones = Object.keys(zones).map(function (key) { return key + '=' + zones[key]; }).join('|');
- data.nz = 1; // named zones
- data.r = Math.floor(Math.random()*99999999999);
+ data['zones'] = Object.keys(zones).map(function (key) { return key + '=' + zones[key]; }).join('|');
+ data['nz'] = 1; // named zones
+ data['r'] = Math.floor(Math.random()*99999999999);
- var scriptURL = (location.protocol == 'https:' ? thesettings.deliverySSL : thesettings.delivery) + '/' + thesettings.spcTagScript;
+ var scriptURL = (location.protocol == 'https:' ? thesettings['deliverySSL'] : thesettings['delivery']) + '/' + thesettings['spcTagScript'];
var that = this;
$.ajax({
url: scriptURL,
data: data,
dataType: 'html',
- async: thesettings.forceAsync, // should be disabled for block(campaign)
+ async: thesettings['forceAsync'], // should be disabled for block(campaign)
success: function (data) {
- var flJsURL = (location.protocol == 'https:' ? thesettings.deliverySSL : thesettings.delivery) + '/' + thesettings.swfObjectJS;
+ var flJsURL = (location.protocol == 'https:' ? thesettings['deliverySSL'] : thesettings['delivery']) + '/' + thesettings['swfObjectJS'];
$.getScript(flJsURL, function () {
- var output = eval('(function () {' + data + ';return ' + thesettings.jsPrefix + 'output;})()');
+ var output = eval('(function () {' + data + ';return ' + thesettings['jsPrefix'] + 'output;})()');
that.each(function () {
var $this = $(this);
- _documentWriteSafeAppend(output[$this.data('openxtag').zoneName], $this);
+ _documentWriteSafeAppend(output[$this.data('openxtag')['zn']], $this);
});
});
}
@@ -254,9 +258,9 @@
/// }}} spcTag
var fnMethods = {
- zone: jsZone,
- jsZone: jsZone,
- spc: spcTag
+ 'zone': jsZone,
+ 'jsZone': jsZone,
+ 'spc': spcTag
};
// {{{ function $.fn.openxtag(method) { ... }
@@ -282,17 +286,19 @@
* @cat Plugins/OpenXTag
* @see http://www.openx.org/docs/tutorials/comparisons-between-invocation-tags types of OpenX ad invocation tags
*/
- $.fn.openxtag = function (method) {
- if (fnMethods[method]) {
- return _genericZoneCall.apply(this, [ fnMethods[method] ].concat(Array.prototype.slice.call(arguments, 1)));
- } else {
- $.error('Method ' + method + ' does not exist on jQuery.openxtag');
- }
- };
+ $.fn.extend({
+ 'openxtag': function (method) {
+ if (fnMethods[method]) {
+ return _genericZoneCall.apply(this, [ fnMethods[method] ].concat(Array.prototype.slice.call(arguments, 1)));
+ } else {
+ $.error('Method ' + method + ' does not exist on jQuery.openxtag');
+ }
+ }
+ });
// }}} $.fn.openxtag
var methods = {
- init: init
+ 'init': init
};
// {{{ function $.openxtag(method) { ... }
@@ -360,15 +366,17 @@
* @type undefined
* @see http://www.openx.org/docs/2.8/userguide/zone%20invocation
*/
- $.openxtag = function (method) {
- if (methods[method]) {
- return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
- } else if (typeof method === 'object' || !method) {
- return methods.init.apply(this, arguments);
- } else {
- $.error('Method ' + method + ' does not exist on jQuery.openxtag');
- }
- };
+ $.extend({
+ 'openxtag': function (method) {
+ if (methods[method]) {
+ return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
+ } else if (typeof method === 'object' || !method) {
+ return methods.init.apply(this, arguments);
+ } else {
+ $.error('Method ' + method + ' does not exist on jQuery.openxtag');
+ }
+ }
+ });
// }}} $.openxtag
})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.