client/player/test/emission_fichiers/jquery_002.js
author wakimd
Tue, 16 Nov 2010 14:15:07 +0100
changeset 9 22ab430e9b64
permissions -rw-r--r--
Corrections on models and general structure
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     1
/*! Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     2
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     3
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     4
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     5
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     6
 *
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     7
 * Version: 3.0.2
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     8
 * 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     9
 * Requires: 1.2.2+
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    10
 */
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    11
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    12
(function($) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    13
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    14
var types = ['DOMMouseScroll', 'mousewheel'];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    15
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    16
$.event.special.mousewheel = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    17
	setup: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    18
		if ( this.addEventListener )
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    19
			for ( var i=types.length; i; )
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    20
				this.addEventListener( types[--i], handler, false );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    21
		else
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    22
			this.onmousewheel = handler;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    23
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    24
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    25
	teardown: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    26
		if ( this.removeEventListener )
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    27
			for ( var i=types.length; i; )
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    28
				this.removeEventListener( types[--i], handler, false );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    29
		else
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    30
			this.onmousewheel = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    31
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    32
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    33
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    34
$.fn.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    35
	mousewheel: function(fn) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    36
		return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    37
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    38
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    39
	unmousewheel: function(fn) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    40
		return this.unbind("mousewheel", fn);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    41
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    42
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    43
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    44
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    45
function handler(event) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    46
	var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    47
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    48
	event = $.event.fix(event || window.event);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    49
	event.type = "mousewheel";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    50
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    51
	if ( event.wheelDelta ) delta = event.wheelDelta/120;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    52
	if ( event.detail     ) delta = -event.detail/3;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    53
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    54
	// Add events and delta to the front of the arguments
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    55
	args.unshift(event, delta);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    56
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    57
	return $.event.handle.apply(this, args);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    58
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    59
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    60
})(jQuery);