Loading ...
Sorry, an error occurred while loading the content.

PATCH:YAHOO.widget.Tooltip 2.2.0a

Expand Messages
  • Matt Miller
    This patch adds the ability to specify a tooltip css class other than the default yui-tt , giving the ability to have tooltips with different styles in the
    Message 1 of 2 , Mar 2 9:39 AM
    • 0 Attachment
      This patch adds the ability to specify a tooltip css class other than
      the default "yui-tt", giving the ability to have tooltips with
      different styles in the same page. It also adds the ability to
      specify custom X and Y offsets for the tooltip.

      - Matt Miller



      --- yui_2.2.0a\yui\container\container.js 2007-02-16
      18:28:34.000000000 -0600
      +++ yui_2.2.0a_modified\yui\container\container.js 2007-03-02
      11:14:56.000000000 -0600
      @@ -2648,17 +2648,17 @@
      YAHOO.util.Event.addListener(window, "load",
      deferredInit, this, true);
      } else {
      YAHOO.widget.Tooltip.superclass.init.call(this, el);

      this.beforeInitEvent.fire(YAHOO.widget.Tooltip);

      - YAHOO.util.Dom.addClass(this.element,
      YAHOO.widget.Tooltip.CSS_TOOLTIP);
      -
      if (userConfig) {
      this.cfg.applyConfig(userConfig, true);
      }
      +
      + YAHOO.util.Dom.addClass(this.element,
      this.cfg.getProperty("cssclass"));

      this.cfg.queueProperty("visible",false);
      this.cfg.queueProperty("constraintoviewport",true);

      this.setBody("");
      this.render(this.cfg.getProperty("container"));
      @@ -2670,12 +2670,20 @@
      /**
      * Initializes the class's configurable properties which can be
      changed using the Overlay's Config object (cfg).
      * @method initDefaultConfig
      */
      YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() {
      YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this);
      +
      + /**
      + * Specifies the css class of the tooltip.
      + * @config cssclass
      + * @type String
      + * @default YAHOO.widget.Tooltip.CSS_TOOLTIP
      + */
      + this.cfg.addProperty("cssclass", {
      value:YAHOO.widget.Tooltip.CSS_TOOLTIP } );

      /**
      * Specifies whether the Tooltip should be kept from
      overlapping its context element.
      * @config preventoverlap
      * @type Boolean
      * @default true
      @@ -2702,12 +2710,28 @@
      * The number of milliseconds to wait before hiding a Tooltip
      on mouseover.
      * @config hidedelay
      * @type Number
      * @default 250
      */
      this.cfg.addProperty("hidedelay", {
      value:250, handler:this.configHideDelay,
      validator:this.cfg.checkNumber } );
      +
      + /**
      + * The number of pixels to offset the tooltip's top.
      + * @config yoffset
      + * @type Number
      + * @default 25
      + */
      + this.cfg.addProperty("yoffset", { value:25,
      validator:this.cfg.checkNumber } );
      +
      + /**
      + * The number of pixels to offset the tooltip's left.
      + * @config xoffset
      + * @type Number
      + * @default 25
      + */
      + this.cfg.addProperty("xoffset", { value:25,
      validator:this.cfg.checkNumber } );

      /**
      * Specifies the Tooltip's text.
      * @config text
      * @type String
      * @default null
      @@ -2885,13 +2909,14 @@
      * @method doShow
      * @param {DOMEvent} e The current DOM event
      * @return {Number} The process ID of the timeout function
      associated with doShow
      */
      YAHOO.widget.Tooltip.prototype.doShow = function(e, context) {

      - var yOffset = 25;
      + var xOffset = this.cfg.getProperty("xoffset");
      + var yOffset = this.cfg.getProperty("yoffset");
      if (this.browser == "opera" && context.tagName == "A") {
      yOffset += 12;
      }

      var me = this;
      return setTimeout(
      @@ -2899,13 +2924,13 @@
      if (me._tempTitle) {
      me.setBody(me._tempTitle);
      } else {
      me.cfg.refireEvent("text");
      }

      - me.moveTo(me.pageX, me.pageY + yOffset);
      + me.moveTo(me.pageX + xOffset, me.pageY +
      yOffset);
      if (me.cfg.getProperty("preventoverlap")) {
      me.preventOverlap(me.pageX, me.pageY);
      }

      YAHOO.util.Event.removeListener
      (context, "mousemove", me.onContextMouseMove);
    Your message has been successfully submitted and would be delivered to recipients shortly.