mirror of
https://github.com/wassname/fullcalendar.git
synced 2026-09-12 12:21:04 +08:00
hack to get pageX/pageY working for jquery-simulate click
This commit is contained in:
+2
-1
@@ -14,13 +14,14 @@ module.exports = function(config) {
|
||||
'lib/jquery/jquery.js',
|
||||
'lib/jquery-ui/ui/jquery-ui.js',
|
||||
|
||||
// for jquery-simulate-ext
|
||||
// for jquery simulate
|
||||
'lib/jquery-simulate-ext/libs/bililiteRange.js',
|
||||
'lib/jquery-simulate-ext/libs/jquery.simulate.js',
|
||||
'lib/jquery-simulate-ext/src/jquery.simulate.ext.js',
|
||||
'lib/jquery-simulate-ext/src/jquery.simulate.drag-n-drop.js',
|
||||
'lib/jquery-simulate-ext/src/jquery.simulate.key-sequence.js',
|
||||
'lib/jquery-simulate-ext/src/jquery.simulate.key-combo.js',
|
||||
'tests/lib/jquery-simulate-hacks.js', // needs to be last
|
||||
|
||||
'lib/jquery-mockjax/jquery.mockjax.js',
|
||||
'lib/jasmine-jquery/lib/jasmine-jquery.js',
|
||||
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
(function($) {
|
||||
|
||||
/*
|
||||
Addresses a shortcoming with jquery-simulate[-ext] where a click event doesn't
|
||||
provide pageX/pageY coordinates. Should be the centered coordinates of the element.
|
||||
This file needs to be loaded after jquery-simulate and jquery-simulate-ext.
|
||||
*/
|
||||
|
||||
var originalMouseEvent = $.simulate.prototype.mouseEvent;
|
||||
|
||||
$.simulate.prototype.mouseEvent = function(type, options) {
|
||||
if (type === 'click' && options.pageX === undefined && options.pageY === undefined) {
|
||||
$.extend(options, findCenterPageXY(this.target));
|
||||
}
|
||||
// after this, jquery-simulate-ext will calculate screenX/screenY
|
||||
// and jquery-simulate will calculate clientX/clientY...
|
||||
return originalMouseEvent.apply(this, [ type, options ]);
|
||||
};
|
||||
|
||||
function findCenterPageXY( elem ) {
|
||||
var offset,
|
||||
$elem = $(elem),
|
||||
offset = $elem.offset();
|
||||
|
||||
return {
|
||||
pageX: Math.round(offset.left + $elem.outerWidth() / 2),
|
||||
pageY: Math.round(offset.top + $elem.outerHeight() / 2)
|
||||
};
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user