[ 9 posts ]

Dave M G

  • Username: Dave M G
  • Joined: Fri Sep 25, 2009 9:34 pm
  • Posts: 32
  • Offline
  • Profile

How can I remove text from carousel navigation buttons

Post Posted: Tue Mar 09, 2010 3:36 am
+0-
I am using the YUI 2.8 carousel

I have managed to get enough control of the CSS to style the "previous page" and "next page" buttons to change their postion, color, background images, and everything.

The one thing I can not for the life of me figure out how to do, though, is get rid of the text that says "previous page" and "next page". I can't just use CSS to hide it, so how can I get rid of it? I notice some of the examples don't have text on their buttons, but how they accomplish that is totally opaque.

Also, I would like to not display the "page one, page two, page three" links at all. I have used CSS to set them to "display:none", but if possible, I'd like the Javascript to not display them at all.

If someone can help me with these, I'd really appreciate it.

Thank you.

Matt Parker

YUI Contributor

  • Username: mattatlamplight
  • Joined: Mon Apr 20, 2009 12:03 pm
  • Posts: 465
  • Location: London UK
  • GitHub: mattparker
  • Gists: mattparker
  • Offline
  • Profile

Re: How can I remove text from carousel navigation buttons

Post Posted: Tue Mar 09, 2010 12:47 pm
+0-
Hi,

I tend to use Firebug to poke around the css when I can't work out how to do it... it's often the quickest way for me!

I don't know the carousel much, but looking at the first example on the yui page, the button text is 'hidden' by using padding: there's a padding-left of 50px which moves it out beyond the right-hand side of the button. This is on the button html element. On the parent of the button, a span element, there's some overflow:hidden and dimensions, which will make sure the text stays out of shot.

I should think you can do something similar on the other page links. In other widgets I think sometimes you see 'text-indent; -9999px' or something like that to get things off screen when they're not needed.

Matt

Andres Narvaez

YUI Contributor

  • Username: andresn
  • Joined: Thu Sep 24, 2009 12:02 pm
  • Posts: 34
  • Twitter: DrDrace
  • GitHub: andresn
  • Gists: andresn
  • Offline
  • Profile

Re: How can I remove text from carousel navigation buttons

Post Posted: Tue Mar 09, 2010 3:20 pm
+0-
YAHOO.widget.Carousel.prototype.CLASSES.STRINGS.NEXT_BUTTON_TEXT = "";
YAHOO.widget.Carousel.prototype.CLASSES.STRINGS.PREVIOUS_BUTTON_TEXT = "";

Your Carousel init code here.

For more string options, open up Carousel.js and do a search for "STRINGS:"

Andres Narvaez

YUI Contributor

  • Username: andresn
  • Joined: Thu Sep 24, 2009 12:02 pm
  • Posts: 34
  • Twitter: DrDrace
  • GitHub: andresn
  • Gists: andresn
  • Offline
  • Profile

Re: How can I remove text from carousel navigation buttons

Post Posted: Tue Mar 09, 2010 3:25 pm
+0-
Have to post these answers on the fly, but yea, regarding disabling pagination, you'll have to go with CSS, make sure you're selectors have enough weight to override Caraousel's defaults:

#container1 #selector2 .etc .yui-carousel-nav ul {
display:none;
}

Andres Narvaez

YUI Contributor

  • Username: andresn
  • Joined: Thu Sep 24, 2009 12:02 pm
  • Posts: 34
  • Twitter: DrDrace
  • GitHub: andresn
  • Gists: andresn
  • Offline
  • Profile

Re: How can I remove text from carousel navigation buttons

Post Posted: Tue Mar 09, 2010 3:27 pm
+0-
*your =)

Dave M G

  • Username: Dave M G
  • Joined: Fri Sep 25, 2009 9:34 pm
  • Posts: 32
  • Offline
  • Profile

Re: How can I remove text from carousel navigation buttons

Post Posted: Tue Mar 09, 2010 11:24 pm
+0-
Thank you for responding.

I tried these:

YAHOO.widget.Carousel.prototype.CLASSES.STRINGS.NEXT_BUTTON_TEXT = "";
YAHOO.widget.Carousel.prototype.CLASSES.STRINGS.PREVIOUS_BUTTON_TEXT = "";

But anywhere I place them in the code causes the carousel to break. Either it ceases to work completely, or one part, such as the image animation, stops working.

This is what I have:

(function () {

var carousel;

YAHOO.util.Event.onDOMReady(function (ev) {
var carousel = new YAHOO.widget.Carousel("messagebox", {

animation: {
speed: 0.5
}

});

carousel.set("numVisible", 1);

carousel.render(); // get ready for rendering the widget
carousel.show(); // display the widget
});
})();


Where exactly would I put in the code to over ride the text strings?

Thank you for any advice.

Andres Narvaez

YUI Contributor

  • Username: andresn
  • Joined: Thu Sep 24, 2009 12:02 pm
  • Posts: 34
  • Twitter: DrDrace
  • GitHub: andresn
  • Gists: andresn
  • Offline
  • Profile

Re: How can I remove text from carousel navigation buttons

Post Posted: Wed Mar 10, 2010 5:27 pm
+0-
Er, remove the CLASSES part so it looks like this:

YAHOO.widget.Carousel.prototype.STRINGS.NEXT_BUTTON_TEXT = "";
YAHOO.widget.Carousel.prototype.STRINGS.PREVIOUS_BUTTON_TEXT = "";

And you can place this anywhere before your Carousel instantiation code:
var carousel = new YAHOO.widget.Carousel("messagebox", {

Andres Narvaez

YUI Contributor

  • Username: andresn
  • Joined: Thu Sep 24, 2009 12:02 pm
  • Posts: 34
  • Twitter: DrDrace
  • GitHub: andresn
  • Gists: andresn
  • Offline
  • Profile

Re: How can I remove text from carousel navigation buttons

Post Posted: Wed Mar 10, 2010 5:31 pm
+0-
One important note, it's important for accessibility reasons (screen readers) to leave the text in. Did you try something in your CSS like text-indent: -10000px ?

Dave M G

  • Username: Dave M G
  • Joined: Fri Sep 25, 2009 9:34 pm
  • Posts: 32
  • Offline
  • Profile

[SOLVED]

Post Posted: Wed Mar 10, 2010 8:13 pm
+0-
Thank you for clarifying the code.

It works perfectly now.

Also, that is a good point about usability. In this particular case I am designing for a closed system where I have enough leeway to remove the text entirely. However, that's a tip I am going to remember for sites intended for general use.

Thanks to everyone who responded. Please consider this question resolved.
  [ 9 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum