Skip to content

Commit 043a6e4

Browse files
committed
first commit
0 parents  commit 043a6e4

20 files changed

+9690
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
jquery-openxtag-*

META.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "jQuery-OpenXTag",
3+
"version": 1.0,
4+
"author": [
5+
"Nikolay Morev <[email protected]>"
6+
],
7+
"abstract": "Insert OpenX ad tags using jQuery.",
8+
"license": "mit",
9+
"distribution_type": "plugin",
10+
"requires": {
11+
"jQuery": ""
12+
},
13+
"provides": {
14+
"jQuery.openxtag": {
15+
"version": 1.0,
16+
"file": "jquery.openxtag.js"
17+
}
18+
},
19+
"keywords": [
20+
"openx", "ads", "asyncronous", "invocation"
21+
],
22+
"meta-spec": {
23+
"version": 1.3,
24+
"url": "http://module-build.sourceforge.net/META-spec-v1.3.html"
25+
},
26+
"generated_by": "Nikolay Morev"
27+
}

Makefile

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
2+
# makefile from jquery sources
3+
4+
SRC_DIR = src
5+
TEST_DIR = test
6+
BUILD_DIR = build
7+
8+
PREFIX = .
9+
DIST_DIR = ${PREFIX}/dist
10+
11+
JS_ENGINE ?= `which node nodejs`
12+
COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
13+
14+
BASE_FILES = ${SRC_DIR}/jquery.openxtag.js
15+
16+
MODULES = ${BASE_FILES}
17+
18+
JQ = ${DIST_DIR}/jquery.openxtag.js
19+
JQ_MIN = ${DIST_DIR}/jquery.openxtag.min.js
20+
21+
JQ_VER = $(shell cat version.txt)
22+
VER = sed "s/@VERSION/${JQ_VER}/"
23+
TGZ = ./jquery-openxtag-${JQ_VER}
24+
25+
DATE=$(shell git log -1 --pretty=format:%ad)
26+
27+
all: core ${TGZ}.tar.gz
28+
29+
core: jquery min lint
30+
@@echo "Plugin build complete."
31+
32+
${DIST_DIR}:
33+
@@mkdir -p ${DIST_DIR}
34+
@@cp -r README examples ${DIST_DIR}
35+
36+
jquery: ${JQ}
37+
38+
${JQ}: ${MODULES} | ${DIST_DIR}
39+
@@echo "Building" ${JQ}
40+
41+
@@cat ${MODULES} | \
42+
sed 's/@DATE/'"${DATE}"'/' | \
43+
${VER} > ${JQ};
44+
45+
${TGZ}.tar.gz: ${DIST_DIR}
46+
@@rm -rf ${TGZ} ${TGZ}.tar.gz ${TGZ}.zip
47+
@@cp -r ${DIST_DIR} ${TGZ}
48+
@@tar cfz ${TGZ}.tar.gz ${TGZ}
49+
@@zip -r ${TGZ}.zip ${TGZ}
50+
51+
lint: jquery
52+
@@if test ! -z ${JS_ENGINE}; then \
53+
echo "Checking plugin against JSLint..."; \
54+
${JS_ENGINE} build/jslint-check.js; \
55+
else \
56+
echo "You must have NodeJS installed in order to test plugin against JSLint."; \
57+
fi
58+
59+
min: jquery ${JQ_MIN}
60+
61+
${JQ_MIN}: ${JQ}
62+
@@if test ! -z ${JS_ENGINE}; then \
63+
echo "Minifying plugin" ${JQ_MIN}; \
64+
${COMPILER} ${JQ} > ${JQ_MIN}; \
65+
else \
66+
echo "You must have NodeJS installed in order to minify plugin."; \
67+
fi
68+
69+
70+
clean:
71+
@@echo "Removing Distribution directory:" ${DIST_DIR} ${TGZ} ${TGZ}.tar.gz
72+
@@rm -rf ${DIST_DIR}
73+
@@rm -rf ${TGZ} ${TGZ}.tar.gz ${TGZ}.zip
74+
75+
.PHONY: all jquery lint min clean core

README

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
jQuery OpenX tag plugin
2+
3+
This plugin provides alternative jQuery-compatible way to insert OpenX ad
4+
invocation tags into various parts of your web page. It also features some
5+
additional improvements over standard OpenX tags:
6+
7+
* Ads are inserted asynchronously so that ad invocation code does not block
8+
page loading.
9+
* You can set and override invocation tag parameters in several places:
10+
globally for all ads that are loaded using the plugin, in ad insertion JS
11+
call, in ad placeholder class attribute with the help of jQuery Metadata
12+
plugin.
13+
* Callback on ad load.
14+
15+
The plugin was successfully tested with OpenX Community Edition version
16+
2.8.8-rc6 (the most recent at the moment).
17+
18+
Usage examples
19+
20+
Init OpenX tag plugin with required parameters:
21+
22+
$.openxtag('init', {
23+
delivery: 'http://openx.local/openx-now/www/delivery',
24+
deliverySSL: 'https://openx.local/openx-now/www/delivery'
25+
});
26+
27+
Load ad from OpenX zone 1 into web page element with id "zone1":
28+
29+
$('#zone1').openxtag('zone', 1);
30+
31+
Load ads from OpenX zone 1 into all elements with "banner" class with "block"
32+
option that instructs OpenX to skip banners that were already loaded on current
33+
page. The function from third argument is called on ad load.
34+
35+
$('.banner').openxtag('zone', 1, {
36+
block: true
37+
}, function () {
38+
console.log('loaded ad from zone ' + 1);
39+
});
40+
41+
Load all ads using invocation parameters set for each placeholder element in
42+
their HTML code.
43+
44+
$('.banner').openxtag('zone', function () {
45+
console.log('loaded ad');
46+
});
47+
48+
<div class="banner {zoneID: 1, source: 'zone1'}"></div>
49+
<div class="banner {zoneID: 1, source: 'zone2'}"></div>
50+
51+
Also see sample HTML pages in examples/
52+
53+
TODO
54+
add test suite
55+
remove callback, add event on ad load
56+

build/jslint-check.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
var JSLINT = require("./lib/jslint").JSLINT,
2+
print = require("sys").print,
3+
src = require("fs").readFileSync("dist/jquery.openxtag.js", "utf8");
4+
5+
JSLINT(src, { evil: true, forin: true, maxerr: 100 });
6+
7+
// All of the following are known issues that we think are 'ok'
8+
// (in contradiction with JSLint) more information here:
9+
// http://docs.jquery.com/JQuery_Core_Style_Guidelines
10+
var ok = {
11+
"Expected an identifier and instead saw 'undefined' (a reserved word).": true,
12+
"Use '===' to compare with 'null'.": true,
13+
"Use '!==' to compare with 'null'.": true,
14+
"Expected an assignment or function call and instead saw an expression.": true,
15+
"Expected a 'break' statement before 'case'.": true,
16+
"'e' is already defined.": true
17+
};
18+
19+
var e = JSLINT.errors, found = 0, w;
20+
21+
for ( var i = 0; i < e.length; i++ ) {
22+
w = e[i];
23+
24+
if ( !ok[ w.reason ] ) {
25+
found++;
26+
print( "\n" + w.evidence + "\n" );
27+
print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
28+
}
29+
}
30+
31+
if ( found > 0 ) {
32+
print( "\n" + found + " Error(s) found.\n" );
33+
34+
} else {
35+
print( "JSLint check passed.\n" );
36+
}

0 commit comments

Comments
 (0)