Browse Source

Wrap constructor in universal module definition

pull/26/head
i-like-robots 11 years ago
parent
commit
4db744e186
  1. 6
      .jshintrc
  2. 25
      dist/echo.js
  3. 4
      dist/echo.min.js
  4. 23
      src/echo.js

6
.jshintrc

@ -17,5 +17,9 @@
"unused": true, "unused": true,
"strict": true, "strict": true,
"trailing": true, "trailing": true,
"smarttabs": true "smarttabs": true,
"globals": {
"define": false,
"module": false
}
} }

25
dist/echo.js vendored

@ -1,8 +1,23 @@
/*! Echo v1.4.0 | (c) 2013 @toddmotto | MIT license | github.com/toddmotto/echo */ /*! Echo v1.4.0 | (c) 2014 @toddmotto | MIT license | github.com/toddmotto/echo */
window.Echo = (function (window, document, undefined) { (function (name, context, definition) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) {
define(definition);
}
else if (typeof module !== 'undefined' && module.exports) {
module.exports = definition();
}
else {
context[name] = definition();
}
})('Echo', this, function() {
'use strict';
function Echo() {
var store = [], offset, throttle, poll; var store = [], offset, throttle, poll;
var _inView = function (el) { var _inView = function (el) {
@ -49,4 +64,8 @@ window.Echo = (function (window, document, undefined) {
render: _throttle render: _throttle
}; };
})(window, document); }
return Echo;
});

4
dist/echo.min.js vendored

@ -1,2 +1,2 @@
/*! Echo v1.4.0 | (c) 2013 @toddmotto | MIT license | github.com/toddmotto/echo */ /*! Echo v1.4.0 | (c) 2014 @toddmotto | MIT license | github.com/toddmotto/echo */
window.Echo=function(a,b){"use strict";var c,d,e,f=[],g=function(d){var e=d.getBoundingClientRect();return(e.top>=0&&e.left>=0&&e.top)<=(a.innerHeight||b.documentElement.clientHeight)+parseInt(c)},h=function(){for(var a=f.length;a--;){var b=f[a];g(b)&&(b.src=b.getAttribute("data-echo"),f.splice(a,1))}},i=function(){clearTimeout(e),e=setTimeout(h,d)},j=function(e){var g=b.querySelectorAll("[data-echo]"),h=e||{};c=h.offset||0,d=h.throttle||250;for(var j=0;j<g.length;j++)f.push(g[j]);i(),b.addEventListener?a.addEventListener("scroll",i,!1):a.attachEvent("onscroll",i)};return{init:j,render:i}}(window,document); !function(a,b,c){"use strict";"function"==typeof define&&define.amd?define(c):"undefined"!=typeof module&&module.exports?module.exports=c():b[a]=c()}("Echo",this,function(){"use strict";function a(){var a,b,c,d=[],e=function(b){var c=b.getBoundingClientRect();return(c.top>=0&&c.left>=0&&c.top)<=(window.innerHeight||document.documentElement.clientHeight)+parseInt(a)},f=function(){for(var a=d.length;a--;){var b=d[a];e(b)&&(b.src=b.getAttribute("data-echo"),d.splice(a,1))}},g=function(){clearTimeout(c),c=setTimeout(f,b)},h=function(c){var e=document.querySelectorAll("[data-echo]"),f=c||{};a=f.offset||0,b=f.throttle||250;for(var h=0;h<e.length;h++)d.push(e[h]);g(),document.addEventListener?window.addEventListener("scroll",g,!1):window.attachEvent("onscroll",g)};return{init:h,render:g}}return a});

23
src/echo.js

@ -1,7 +1,22 @@
window.Echo = (function (window, document, undefined) { (function (name, context, definition) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) {
define(definition);
}
else if (typeof module !== 'undefined' && module.exports) {
module.exports = definition();
}
else {
context[name] = definition();
}
})('Echo', this, function() {
'use strict';
function Echo() {
var store = [], offset, throttle, poll; var store = [], offset, throttle, poll;
var _inView = function (el) { var _inView = function (el) {
@ -48,4 +63,8 @@ window.Echo = (function (window, document, undefined) {
render: _throttle render: _throttle
}; };
})(window, document); }
return Echo;
});

Loading…
Cancel
Save