Skip to content

Commit 1ed352c

Browse files
committed
ElementQueries now using requirejs and AMD loading module
1 parent c3e6c7b commit 1ed352c

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/ElementQueries.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,31 @@
44
* https://github.com/marcj/css-element-queries/blob/master/LICENSE.
55
*/
66
;
7-
(function() {
7+
(function(factory) {
8+
// Eastablish root object
9+
var root = (typeof self == 'object' && self.self == self && self) ||
10+
(typeof global == 'object' && global.global == global && global);
11+
12+
// Setup with dependency
13+
if (typeof define === 'function' && define.amd) {
14+
define([
15+
'jquery',
16+
'ResizeSensor',
17+
'exports'
18+
], function (jQuery, ResizeSensor, exports) {
19+
return factory(root, exports, jQuery, ResizeSensor);
20+
});
21+
} else {
22+
root.ElementQueries = factory(root);
23+
}
24+
}(function(root, ElementQueries, jQuery, ResizeSensor) {
25+
var previousElementQueries = root.ElementQueries;
826
/**
927
*
1028
* @type {Function}
1129
* @constructor
1230
*/
13-
var ElementQueries = this.ElementQueries = function() {
31+
var ElementQueries = function() {
1432

1533
this.withTracking = false;
1634
var elements = [];
@@ -338,5 +356,11 @@
338356
window.attachEvent('onload', ElementQueries.init);
339357
}
340358
domLoaded(ElementQueries.init);
341-
342-
})();
359+
360+
ElementQueries.noConflict = function() {
361+
root.ElementQueries = previousElementQueries;
362+
return this;
363+
};
364+
365+
return ElementQueries;
366+
}));

0 commit comments

Comments
 (0)