Skip to content

Commit 358f045

Browse files
committed
Add namespace option
1 parent 8e87f3c commit 358f045

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

jquery.dfp.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
refreshExisting: true,
7676
disablePublisherConsole: false,
7777
disableInitialLoad: false,
78-
noFetch: false
78+
noFetch: false,
79+
namespace: undefined
7980
};
8081

8182
if (typeof options.setUrlTargeting === 'undefined' || options.setUrlTargeting)
@@ -349,7 +350,7 @@
349350
*/
350351
getName = function ($adUnit) {
351352

352-
return $adUnit.data('adunit') || $adUnit.attr('id');
353+
return $adUnit.data('adunit') || dfpOptions.namespace || $adUnit.attr('id');
353354

354355
},
355356

jquery.dfp.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/spec/adUnitSpec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,26 @@ describe('Ad units', function () {
5050

5151
});
5252

53+
it("Google ad unit object get attached to the ad unit container (with namespace)", function () {
54+
var namespace = 'my-long-namespace';
55+
56+
runs(function () {
57+
$('body').append('<div class="adunit"></div>');
58+
$.dfp({dfpID: 'xxxxxxx', namespace: namespace});
59+
}, "Kick off loader");
60+
61+
waitsFor(function () {
62+
if (typeof window.googletag.getVersion === 'function') {
63+
return true;
64+
} else {
65+
return false;
66+
}
67+
}, "getVersion function to exist", 5000);
68+
69+
runs(function () {
70+
expect($('.adunit').data('googleAdUnit').getName()).toEqual('/xxxxxxx/' + namespace);
71+
});
72+
73+
});
74+
5375
});

0 commit comments

Comments
 (0)