in partnership with mediatemple

Ticket #427 (closed enhancement: fixed)

Opened 9 months ago

Last modified 3 months ago

Tooltips are outdated if you chance title attribute after Tips initialization.

Reported by: KnX Owned by: kamicane
Type: enhancement Priority: minor
Milestone: Mootools version 1.3 Component: Core
Keywords: Tips Cc:

Description

Tooltip text is built at initialization time and not when the tooltip is displayed.
If you change the title after Tips is initialized it won't be updated.

Change History

Changed 9 months ago by KnX

Here is a patch, as a nice side effect, you gain the adopt(el) method to add elements to an existing Tips object.

*** Tips.js Tue Aug 07 17:13:52 2007
--- Mine/Tips.js Tue Aug 28 21:55:52 2007
*************** var Tips = new Class({
*** 85,91 ****

}

}).inject(document.body);
this.wrapper = new Element('div').inject(this.toolTip);

! $$(elements).each(this.build, this);

},


build: function(el){

--- 85,104 ----

}

}).inject(document.body);
this.wrapper = new Element('div').inject(this.toolTip);

! $$(elements).each(this.adopt, this);
! },
!
! adopt: function(element){
! el.addEvent('mouseenter', function(event){
! this.build(el);
! this.start(el);
! if (!this.options.fixed) this.locate(event);
! else this.position(el);
! }.bind(this));
! if (!this.options.fixed) el.addEvent('mousemove', this.locate.bind(this));
! var end = this.end.bind(this);
! el.addEvent('mouseleave', end);
! el.addEvent('trash', end);

},


build: function(el){

*************** var Tips = new Class({
*** 104,118 ****

}
if (el.$attributes.myTitle && el.$attributes.myTitle.length > this.options.maxTitleChars)

el.$attributes.myTitle = el.$attributes.myTitle.substr(0, this.options.maxTitleChars - 1) + "…";

- el.addEvent('mouseenter', function(event){
- this.start(el);
- if (!this.options.fixed) this.locate(event);
- else this.position(el);
- }.bind(this));
- if (!this.options.fixed) el.addEvent('mousemove', this.locate.bind(this));
- var end = this.end.bind(this);
- el.addEvent('mouseleave', end);
- el.addEvent('trash', end);

},


start: function(el){

--- 117,122 ----

Changed 9 months ago by anonymous

Sorry I forgot the code block, this is a readable version :

*** Tips.js	Tue Aug 07 17:13:52 2007
--- Mine/Tips.js	Tue Aug 28 21:55:52 2007
*************** var Tips = new Class({
*** 85,91 ****
  			}
  		}).inject(document.body);
  		this.wrapper = new Element('div').inject(this.toolTip);
! 		$$(elements).each(this.build, this);
  	},
  
  	build: function(el){
--- 85,104 ----
  			}
  		}).inject(document.body);
  		this.wrapper = new Element('div').inject(this.toolTip);
! 		$$(elements).each(this.adopt, this);
! 	},
! 
! 	adopt: function(element){
! 		el.addEvent('mouseenter', function(event){
! 			this.build(el);
! 			this.start(el);
! 			if (!this.options.fixed) this.locate(event);
! 			else this.position(el);
! 		}.bind(this));
! 		if (!this.options.fixed) el.addEvent('mousemove', this.locate.bind(this));
! 		var end = this.end.bind(this);
! 		el.addEvent('mouseleave', end);
! 		el.addEvent('trash', end);
  	},
  
  	build: function(el){
*************** var Tips = new Class({
*** 104,118 ****
  		}
  		if (el.$attributes.myTitle && el.$attributes.myTitle.length > this.options.maxTitleChars)
  			el.$attributes.myTitle = el.$attributes.myTitle.substr(0, this.options.maxTitleChars - 1) + "…";
- 		el.addEvent('mouseenter', function(event){
- 			this.start(el);
- 			if (!this.options.fixed) this.locate(event);
- 			else this.position(el);
- 		}.bind(this));
- 		if (!this.options.fixed) el.addEvent('mousemove', this.locate.bind(this));
- 		var end = this.end.bind(this);
- 		el.addEvent('mouseleave', end);
- 		el.addEvent('trash', end);
  	},
  
  	start: function(el){
--- 117,122 ----

Changed 8 months ago by ibolmo

  • milestone changed from Mootools version 1.2 to Mootools version 1.3

Will be considered for the 1.3, since we'll need to clean the Plugins for the move into the Forge.

Changed 6 months ago by kamicane

  • owner set to kamicane
  • status changed from new to assigned
  • component set to Core

Changed 6 months ago by kamicane

  • milestone changed from Mootools version 1.3 to Mootools version 1.2

Changed 6 months ago by anonymous

Is there an updated workaround for use with 1.2 beta?

Changed 4 months ago by kamicane

  • milestone changed from Mootools version 1.2 to Mootools version 1.3

Changed 3 months ago by kamicane

  • status changed from assigned to closed
  • resolution set to fixed

implemented in [1445]

You can now detach, then change the title attribute, then attach.

Note: See TracTickets for help on using tickets.