|
|
Thread Tools | Display Modes |
|
#1
|
|
|
Scripting dude-volunteer
|
Hiding menu items - style menu, share menu, buy menu
This describe a customization that allows you to hide any menu item in the style menu (to only offer certain viewing styles) or in the Share menu (to only offer certain sharing options) or the Buy menu (particularly to hide the Buy All Digital Downloads menu item).
For example, you could change the style menu from this: ![]() to this: ![]() To use this, there are simply two steps: Step 1 Copy this code into your bottom javascript: Code:
//------------------------------------------------------------------------------------------------------------------------------------------
// Script to allow you to use CSS to hide any individual menu items in the Share or Style menus
// This script will add a class name to each top level menu item in the Share and Style menus.
// That class name will be of the form "buttonname_menuitemname_menuitem".
// The class name will be all lowercase and any spaces or other non-alpha numeric chars in it will be converted to underscores.
// Here are some examples of class names:
// share_be_social_menuitem
// share_social_bookmarking_menuitem
// style_traditional_menuitem
//
// And some example CSS to hide a menu item would look like this:
// .share_be_social_menuitem {display:none;}
// .style_traditional_menuitem {display:none;}
//
// You can also hide menu items only in certain contexts using all the normal Smugmug CSS classifiers.
// To hide social bookmarking only in your vacation category, you would use CSS like this:
// .category_Vaction .share_be_social_menuitem {display:none;}
//
// Version 1.1
//------------------------------------------------------------------------------------------------------------------------------------------
YE.onContentReady("viewingStylesButton", TagMenuItemsSetup);
YE.onContentReady("shareButton", TagMenuItemsSetup);
YE.onContentReady("buyButton", TagMenuItemsSetup);
function TagMenuItemsSetup()
{
// now that the object is created, we can register an interest in the beforeShowEvent
// we can't modify the menu until then because of lazyLoading
var button = YAHOO.widget.Button.getButton(this.id);
var menu = button.getMenu();
if (!menu) return;
var menuName = button.get("label");
menu.beforeShowEvent.subscribe(TagMenuItems);
function TagMenuItems(event, args, data)
{
// called in the context of the menu
try
{
// get the list of menu items in our menu
var menuItems = this.getItems();
// look through each menu item to see if it matches anything in our stylesToRemove array
for (var i = 0; i < menuItems.length; i++)
{
// get the text value from the menu item and make it into a new class name
var newClassName = menuItems[i].cfg.config.text.value;
newClassName = menuName + "_" + newClassName + "_menuitem";
newClassName = newClassName.replace(/\s+|\&[a-z]+;|[^_a-zA-Z0-9-]/g, "_"); // replace illegal CSS chars with underscore
// add the new class name to the menu item so we can hide/style it with pure CSS
YD.addClass(menuItems[i].id, newClassName.toLowerCase());
// if this item itself is a sub-menu, then register for it's show event too
var submenu = menuItems[i].cfg.getProperty("submenu");
if (submenu)
{
submenu.beforeShowEvent.subscribe(TagMenuItems);
}
}
// no need to call this again everytime we show the menu
this.beforeShowEvent.unsubscribe(TagMenuItems);
} catch (e) {} // catch any exceptions and ignore them - errors will just cause the styles not to get removed, but not affect any other scripts
}
}
Add the appropriate CSS to hide whatever menu items you want. This code adds a unique classname to every menu item and submenu item in the Share and Style menus. You can then use that classname in a CSS rule to hide whatever menu items you don't want to display. You can do this globally or combine it with any other CSS modifiers to only do it in a category, in a subcategory, in a gallery, etc... The CSS to hide a menu item looks like this: .share_get_a_link_menuitem {display:none;} The name of the menu button comes first. Then, the name of the menu item that you want to hide is next, then the text menuitem is last. Any spaces or non-alpha numeric chars in the menu item are converted to underscores. It is always all lowercase regardless of what is in the menu. To hide the StumbleUpon menu item in the Social Bookmarking submenu of the share button, you would use this: .share_stumbleupon_menuitem {display:none;} To hide the slideshow view from the Style menu, you would use this: .style_slideshow_menuitem {display:none;} To hide the slideshow view from the Style menu, but only when you are not logged in, you would use this: .notLoggedIn .style_slideshow_menuitem {display:none;} To hide the Buy All Digital Downloads menu item, you would add this: .buy_all_digital_downloads_menuitem {display: none;} And so on... This customization is more flexible than the previous version here, so I would suggest using this new one instead.
__________________
--John Homepage • Popular JFriend's javascript customizations • Secrets for getting fast answers on Dgrin Always include a link to your site when posting a question Last edited by jfriend; Feb-09-2011 at 09:16 AM. |
|
|
|
|
#2
|
|
|
He who caN
|
great tool, but is there a way to hide the "Get a link" option from visitors, and keep it when I am logged in as the admin?
thank you. |
|
|
|
|
#3
|
||
|
Scripting dude-volunteer
|
Quote:
.notLoggedIn .share_get_a_link_menuitem {display:none;}
__________________
--John Homepage • Popular JFriend's javascript customizations • Secrets for getting fast answers on Dgrin Always include a link to your site when posting a question |
|
|
|
||
|
#4
|
|
|
He who caN
|
not that its a big shock or anything, but it worked.
thank you very much! ![]()
|
|
|
|
|
#5
|
|
|
Soooo Beginner Grinner
|
Adding "old journal" style back into the drop-down list?
Could this code be modified to add the Old Journal style back into the drop-down list? Thanks.
|
|
|
|
|
#6
|
||
|
"tweak 'til it squeaks"
|
Quote:
style just doesn't do it for html type pages.
__________________
Al My Website my Blog Mozilla Firefox Web Developer Firebug Customization FAQ Banner/Navbar/Slideshow Tutor |
|
|
|
||
|
#7
|
||
|
Scripting dude-volunteer
|
Quote:
__________________
--John Homepage • Popular JFriend's javascript customizations • Secrets for getting fast answers on Dgrin Always include a link to your site when posting a question |
|
|
|
||
|
#8
|
||
|
Scripting dude-volunteer
|
Quote:
__________________
--John Homepage • Popular JFriend's javascript customizations • Secrets for getting fast answers on Dgrin Always include a link to your site when posting a question |
|
|
|
||
|
#9
|
|
|
Ella
|
Concerning this thread:
http://www.dgrin.com/showthread.php?t=163966 Would also like to have "get a Link" option when logged in ...Is that possible with changes noted in above thread. Bill |
|
|
|
|
#10
|
||
|
Scripting dude-volunteer
|
Quote:
.notLoggedIn #shareButton {display:none;}
__________________
--John Homepage • Popular JFriend's javascript customizations • Secrets for getting fast answers on Dgrin Always include a link to your site when posting a question |
|
|
|
||
|
#11
|
|
|
Ella
|
Thanks
|
|
|
|
|
#12
|
|
|
Major grins
|
Can this code be used to hide items from the Buy menu?
I gave it a try as best I could, which was limited to adding the following to the CSS instead of something share or style menu related. .buy_this_photo_menuitem {display:none;} It doesn't appear to have worked and I'm clueless as to what would need to change in the java to make it work...? |
|
|
|
|
#13
|
||
|
Scripting dude-volunteer
|
Quote:
__________________
--John Homepage • Popular JFriend's javascript customizations • Secrets for getting fast answers on Dgrin Always include a link to your site when posting a question |
|
|
|
||
|
#14
|
||
|
Major grins
|
Quote:
Not a major problem, but if it was possible to take it out, I'd prefer it not there! |
|
|
|
||
|
#15
|
|
|
Scripting dude-volunteer
|
Tweaked this code slightly to work with the Buy menu too. The code in the first post will now work with the Buy menu, the Share menu and the Style menu. Items can be removed or formatted from any of those menus or their resulting sub-menus.
__________________
--John Homepage • Popular JFriend's javascript customizations • Secrets for getting fast answers on Dgrin Always include a link to your site when posting a question |
|
|
|
|
#16
|
||
|
panasonikon
|
Quote:
|
|
|
|
||
|
#17
|
|
|
Big grins
|
Hi,
I'm trying to hide the "Create a Card" item from the 'Buy' menu. I've created this CSS code: .buy_create_a_card_menuitem {display: none;} but it doesn't appear to be working. Any suggestions? The gallery I'm working from is http://www.michaellockhartphoto.com/Galleries/Waterfalls/15171536_d7dUv#1177472851_iJiDQ Thanks! Michael
__________________
Michael Lockhart Photography | Like me on Facebook and I'll like you too! | Don't forget to read my Blog | Follow me on Twitter! |
|
|
|
|
#18
|
||
|
Scripting dude-volunteer
|
Quote:
.click_here_to_buy_create_a_card_menuitem {display: none;}
__________________
--John Homepage • Popular JFriend's javascript customizations • Secrets for getting fast answers on Dgrin Always include a link to your site when posting a question |
|
|
|
||
|
#19
|
|
|
Big grins
|
Ah, makes perfect sense. Thank you sir!
Michael
__________________
Michael Lockhart Photography | Like me on Facebook and I'll like you too! | Don't forget to read my Blog | Follow me on Twitter! |
|
|
|
|
#20
|
||
|
Big grins
|
Quote:
Thank you. |
|
|
|
||
| Tell The World! | |
| Thread Tools | |
| Display Modes | |
|
|