Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

event-hover-debug.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. Copyright (c) 2010, Yahoo! Inc. All rights reserved.
  3. Code licensed under the BSD License:
  4. http://developer.yahoo.com/yui/license.html
  5. version: 3.4.0
  6. build: nightly
  7. */
  8. YUI.add('event-hover', function(Y) {
  9. /**
  10. * Adds support for a "hover" event. The event provides a convenience wrapper
  11. * for subscribing separately to mouseenter and mouseleave. The signature for
  12. * subscribing to the event is</p>
  13. *
  14. * <pre><code>node.on("hover", overFn, outFn);
  15. * node.delegate("hover", overFn, outFn, ".filterSelector");
  16. * Y.on("hover", overFn, outFn, ".targetSelector");
  17. * Y.delegate("hover", overFn, outFn, "#container", ".filterSelector");
  18. * </code></pre>
  19. *
  20. * <p>Additionally, for compatibility with a more typical subscription
  21. * signature, the following are also supported:</p>
  22. *
  23. * <pre><code>Y.on("hover", overFn, ".targetSelector", outFn);
  24. * Y.delegate("hover", overFn, "#container", outFn, ".filterSelector");
  25. * </code></pre>
  26. *
  27. * @module event
  28. * @submodule event-hover
  29. */
  30. var isFunction = Y.Lang.isFunction,
  31. noop = function () {},
  32. conf = {
  33. processArgs: function (args) {
  34. // Y.delegate('hover', over, out, '#container', '.filter')
  35. // comes in as ['hover', over, out, '#container', '.filter'], but
  36. // node.delegate('hover', over, out, '.filter')
  37. // comes in as ['hover', over, containerEl, out, '.filter']
  38. var i = isFunction(args[2]) ? 2 : 3;
  39. return (isFunction(args[i])) ? args.splice(i,1)[0] : noop;
  40. },
  41. on: function (node, sub, notifier, filter) {
  42. var args = (sub.args) ? sub.args.slice() : [];
  43. args.unshift(null);
  44. sub._detach = node[(filter) ? "delegate" : "on"]({
  45. mouseenter: function (e) {
  46. e.phase = 'over';
  47. notifier.fire(e);
  48. },
  49. mouseleave: function (e) {
  50. var thisObj = sub.context || this;
  51. args[0] = e;
  52. e.type = 'hover';
  53. e.phase = 'out';
  54. sub._extra.apply(thisObj, args);
  55. }
  56. }, filter);
  57. },
  58. detach: function (node, sub, notifier) {
  59. sub._detach.detach();
  60. }
  61. };
  62. conf.delegate = conf.on;
  63. conf.detachDelegate = conf.detach;
  64. Y.Event.define("hover", conf);
  65. }, '3.4.0' ,{requires:['event-mouseenter']});