Skip to content

Commit

Permalink
requirejs boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
talos committed Feb 23, 2012
1 parent 813d8c0 commit 812c5fe
Showing 1 changed file with 53 additions and 51 deletions.
104 changes: 53 additions & 51 deletions client/js/src/lib/jquery-svgpan.js
Expand Up @@ -105,63 +105,65 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of Andrea Leofreddi.
*/

/*global define, jQuery, window*/

(function (factory) {
"use strict";
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
/*jslint browser: true*/
/*global define*/

// (function (factory) {
// "use strict";
// if (typeof define === 'function' && define.amd) {
// // AMD. Register as an anonymous module.
// define(['jquery'], factory);
// } else {
// // Browser globals
// factory(jQuery);
// }
// }(function ($) {
define(['require', 'lib/jquery'], function (require) {
"use strict";

var Mousewheel = (function () {
function Mousewheel() {
var self = this;
this.watching = [];
this.trigger = function () { Mousewheel.prototype.trigger.apply(self, arguments); };
this.watch = function () { Mousewheel.prototype.watch.apply(self, arguments); };
}

Mousewheel.prototype.trigger = function (evt) {
var i = 0,
len = this.watching.length;

// Iterate through what we're watching & hit callbacks
while (i < len) {
this.watching[i][1](evt);
i += 1;
var $ = require('jquery'),
Mousewheel = (function () {
function Mousewheel() {
var self = this;
this.watching = [];
this.trigger = function () { Mousewheel.prototype.trigger.apply(self, arguments); };
this.watch = function () { Mousewheel.prototype.watch.apply(self, arguments); };
}
};

/**
* Watch an element with a callback. This will also do cleanup on the
* watched elements.
*
* @param $el {DOM} A jQuery-fied DOM element.
* @param callback A callback to call with the mousewheel event when it
* happens.
*/
Mousewheel.prototype.watch = function ($el, callback) {
var i = 0;
while (i < this.watching.length) {
if (this.watching[i][0].closest('html').length === 0) {
this.watching.splice(i, 1);
i -= 1;
Mousewheel.prototype.trigger = function (evt) {
var i = 0,
len = this.watching.length;

// Iterate through what we're watching & hit callbacks
while (i < len) {
this.watching[i][1](evt);
i += 1;
}
i += 1;
}
};

this.watching.push([$el, callback]);
};
/**
* Watch an element with a callback. This will also do cleanup on the
* watched elements.
*
* @param $el {DOM} A jQuery-fied DOM element.
* @param callback A callback to call with the mousewheel event when it
* happens.
*/
Mousewheel.prototype.watch = function ($el, callback) {
var i = 0;
while (i < this.watching.length) {
if (this.watching[i][0].closest('html').length === 0) {
this.watching.splice(i, 1);
i -= 1;
}
i += 1;
}

this.watching.push([$el, callback]);
};

return Mousewheel;
}()),
return Mousewheel;
}()),

mousewheel = new Mousewheel(),

Expand Down Expand Up @@ -428,4 +430,4 @@
}
});
};
}));
});

0 comments on commit 812c5fe

Please sign in to comment.