/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Two Different Classes with Mootools Tooltip

Hello,

I’m trying to use Mootools Tooltip, which includes the following code:

[url]http://demos111.mootools.net/Tips[/url]

It’s pretty straight-forward. The main customization I do is setting the width of the hover box in CSS.

However, I’m trying to use Tips in the same website, but I want two different widths.

So one where the css would look like the normal default settings:

[CODE]
.tool-tip {
color: #fff;
width: 139px;
z-index: 13000;
}

.tool-title {
font-weight: bold;
font-size: 11px;
margin: 0;
color: #9FD4FF;
padding: 8px 8px 4px;
background: url(bubble.png) top left;
}

.tool-text {
font-size: 11px;
padding: 4px 8px 8px;
background: url(bubble.png) bottom right;
}

.custom-tip {
color: #000;
width: 130px;
z-index: 13000;
}

.custom-title {
font-weight: bold;
font-size: 11px;
margin: 0;
color: #3E4F14;
padding: 8px 8px 4px;
background: #C3DF7D;
border-bottom: 1px solid #B5CF74;
}

.custom-text {
font-size: 11px;
padding: 4px 8px 8px;
background: #CFDFA7;
}
[/CODE]

And then another where I want to set just the width to a different setting for a new class:

[CODE]
.tool-tip2 {
color: #fff;
width: 39px; // here
z-index: 13000;
}
.custom-tip2 {
color: #000;
width: 30px; // and here
z-index: 13000;
}
[/CODE]

But as I understand it, the Mootools .js file is only set for tool-tip and custom-tip, not for tool-tip2 and custom-tip2. I’m not sure where to find this, and I’m not sure how to change it to include the second class either.

I’m afraid I’m quite a noob in Javascript. Been trying to find an answer on google for a while now, but haven’t been able to come up with anything yet =/.

Any help would be greatly appreciated!!

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 30.2010 — You have to write another js method for the 2nd tip. Look at the demos code.
Copy linkTweet thisAlerts:
@boxofmochiauthorMay 30.2010 — What I want is basically Tips 2 from the js code, so if I duplicated it:
[CODE]
/* Tips 1 */
var Tips1 = new Tips($$('.Tips1'));

/* Tips 2 */
var Tips2 = new Tips($$('.Tips2'), {
initialize:function(){
this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
},
onShow: function(toolTip) {
this.fx.start(1);
},
onHide: function(toolTip) {
this.fx.start(0);
}
});

/* Tips 2b */
var Tips2b = new Tips($$('.Tips2b'), {
initialize:function(){
this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
},
onShow: function(toolTip) {
this.fx.start(1);
},
onHide: function(toolTip) {
this.fx.start(0);
}
});

/* Tips 3 */
var Tips3 = new Tips($$('.Tips3'), {
showDelay: 400,
hideDelay: 400,
fixed: true
});

/* Tips 4 */
var Tips4 = new Tips($$('.Tips4'), {
className: 'custom'
});
[/CODE]


[b]as Tips 2b[/b] how do I style it so that the width is smaller?
Copy linkTweet thisAlerts:
@FangMay 30.2010 — The className refers to the pre-fix of the selector var Tips4 = new Tips($$('.Tips4'), {
className: '[COLOR="Blue"]narrow[/COLOR]'
});

.[COLOR="Blue"]narrow[/COLOR]-tip {
color: #fff;
width: 39px;
z-index: 13000;
}
.narrow-title {
color: #000;
width: 30px;
z-index: 13000;
}
.narrow-text {
}
Copy linkTweet thisAlerts:
@boxofmochiauthorMay 30.2010 — Worked like a charm - thank you so much!

The only question I have left is really...if I wanted the same settings as in Tips2, and put them in Tips4 like so:
[CODE]
/* Tips 1 */
var Tips1 = new Tips($$('.Tips1'));

/* Tips 2 */
var Tips2 = new Tips($$('.Tips2'), {
initialize:function(){
this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
},
onShow: function(toolTip) {
this.fx.start(1);
},
onHide: function(toolTip) {
this.fx.start(0);
}
});

/* Tips 2b */
var Tips2b = new Tips($$('.Tips2b'), {
initialize:function(){
this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
},
onShow: function(toolTip) {
this.fx.start(1);
},
onHide: function(toolTip) {
this.fx.start(0);
}
});

/* Tips 3 */
var Tips3 = new Tips($$('.Tips3'), {
showDelay: 400,
hideDelay: 400,
fixed: true
});

/* Tips 4 */
var Tips4 = new Tips($$('.Tips4'), {
className: 'narrow'
initialize:function(){
this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
},
onShow: function(toolTip) {
this.fx.start(1);
},
onHide: function(toolTip) {
this.fx.start(0);
}
});
[/CODE]

I get an error right from where "initialize:function(){" starts in Tips4. Is there a way to include the same settings as Tips2, but with the customized className?
Copy linkTweet thisAlerts:
@FangMay 31.2010 — missing comma:/* Tips 4 */
var Tips4 = new Tips($$('.Tips4'), {
className: 'narrow'[B][COLOR="red"],[/COLOR][/B]
initialize:function(){
Copy linkTweet thisAlerts:
@boxofmochiauthorMay 31.2010 — Awesome, thank you so much!!
×

Success!

Help @boxofmochi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...