1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /** * Flotr Event Adapter */ (function () { var F = Flotr, bean = F.bean; F.EventAdapter = { observe: function(object, name, callback) { bean.add(object, name, callback); return this; }, fire: function(object, name, args) { bean.fire(object, name, args); if (typeof(Prototype) != 'undefined') Event.fire(object, name, args); // @TODO Someone who uses mootools, add mootools adapter for existing applciations. return this; }, stopObserving: function(object, name, callback) { bean.remove(object, name, callback); return this; }, eventPointer: function(e) { if (!F._.isUndefined(e.touches) && e.touches.length > 0) { return { x : e.touches[0].pageX, y : e.touches[0].pageY }; } else if (!F._.isUndefined(e.changedTouches) && e.changedTouches.length > 0) { return { x : e.changedTouches[0].pageX, y : e.changedTouches[0].pageY }; } else if (e.pageX || e.pageY) { return { x : e.pageX, y : e.pageY }; } else if (e.clientX || e.clientY) { var d = document, b = d.body, de = d.documentElement; return { x: e.clientX + b.scrollLeft + de.scrollLeft, y: e.clientY + b.scrollTop + de.scrollTop }; } } }; })(); |