1 //======================================================================
2 // Hack the Gamma menus
3 // make your own insertion/submenus, etc
5 // you will need the FlickrLocaliser for this to work properly.
7 // see the flickrmoremenus.user.js script for a longuer example.
8 //======================================================================
12 var menutool = new FlickrGammaMenu();
14 //1- insert a menu with subitems:
17 menutool.createMenuLink('http://www.flickr.com/photos/'+userId,"Your Photos",false,true)+
18 menutool.createMenuLink('http://www.flickr.com/photos/'+userId+'/popular-interesting/',"Interesting Popular",true,false)+
19 menutool.insertMenu(yourphotos,'candy_nav_menu_you',"Your Photos",'A Sub Menu ...',true);
21 //2- insert directly a menu item:
22 menutool.insertItem("http://www.flickr.com/people/"+this.userId+"/contacts/rev/",'candy_nav_menu_contacts',"People Search","Reverse Contacts",false,true);
27 //release 14 August 2007
28 //author: Pierre Andrews
30 // --------------------------------------------------------------------
31 // Copyright (C) 2007 Pierre Andrews
32 // This script can be redistributed under the terms of the GNU LGPL, without
33 // modification of this licence and copyright notice. Attribution to the author should be
34 // kept at least in the source of the scripts.
36 // This program is free software; you can redistribute it and/or
37 // modify it under the terms of the GNU Lesser General Public License
38 // as published by the Free Software Foundation; either version 2
39 // of the License, or (at your option) any later version.
41 // This program is distributed in the hope that it will be useful,
42 // but WITHOUT ANY WARRANTY; without even the implied warranty of
43 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44 // GNU General Public License for more details.
46 // The GNU General Public License is available by visiting
47 // http://www.gnu.org/copyleft/lgpl.html
49 // Free Software Foundation, Inc.
50 // 51 Franklin Street, Fifth Floor
51 // Boston, MA 02110-1301
56 var FlickrGammaMenu = function() {
60 FlickrGammaMenu.prototype = {
61 mapper: new FlickrLocaliser({
63 'Your Photos' : 'Your Photos',
64 "Contact List" : "Contact List",
65 'People Search' : 'People Search',
66 'FlickrMail' : 'FlickrMail',
67 'Your Archives' : 'Your Archives',
68 'Your Sets' : 'Your Sets',
69 'Calendar' : 'Calendar'
72 'Your Photos' : 'Vos photos',
73 "Contact List" : "Liste de contacts",
74 'People Search' : 'Recherche de personnes',
75 'FlickrMail' : 'FlickrMail',
76 'Your Archives' : 'Vos archives',
77 'Your Sets' : 'Vos albums',
78 'Calendar' : 'Calendrier'
81 'Your Photos' : 'Le tue foto',
82 "Contact List" : "Lista contatti",
83 'People Search' : 'Ricerca di persone',
84 'FlickrMail' : 'FlickrMail',
85 'Your Archives' : 'I tuoi archivi',
86 'Your Sets' : 'I tuoi set',
87 'Calendar' : 'Calendario'
90 'Your Photos' : 'Ihre Fotos',
91 "Contact List" : "Kontaktliste",
92 'People Search' : 'Benutzer suchen',
93 'FlickrMail' : 'FlickrMail',
94 'Your Archives' : 'Ihre Archive',
95 'Your Sets' : 'Ihre Alben',
96 'Calendar' : 'Kalender'
99 'Your Photos' : 'Tus fotos',
100 "Contact List" : "Lista de contactos",
101 'People Search' : 'Búsqueda de personas',
102 'FlickrMail' : 'Flickrcorreo',
103 'Your Archives' : 'Tus archivos',
104 'Your Sets' : 'Tus álbumes ',
105 'Calendar' : 'Calendario'
108 'Your Photos' : 'Fotos',
109 "Contact List" : "Lista de contatos",
110 'People Search' : 'Busca de pessoas',
111 'FlickrMail' : 'E-mail do Flickr',
112 'Your Archives' : 'Arquivos',
113 'Your Sets' : 'Ãlbuns',
114 'Calendar' : 'Calendário'
117 'Your Photos' : 'ë´ ì¬ì§',
118 "Contact List" : "ì´ì 목ë¡",
119 'People Search' : 'ì¬ë 찾기',
120 'FlickrMail' : 'FlickrMail',
121 'Your Archives' : 'ì§ëê¸ ë³´ê¸°',
122 'Your Sets' : 'ì¸í¸',
123 'Calendar' : 'ë¬ë ¥'
126 'Your Photos' : 'ä½ çç¸ç',
127 "Contact List" : "èªå·±äººåå",
128 'People Search' : 'æå°ç¨æ¶',
129 'FlickrMail' : 'FlickrMail',
130 'Your Archives' : 'ä½ çè³æ庫',
131 'Your Sets' : 'ä½ çç¸çé',
132 'Calendar' : 'æ¥æ',
137 //insert a new menu item in on of the main menus
138 // href the link on that element or a javascript function to call
139 // menu is the id of the main menu where to insert the new menu item (e.g. 'candy_nav_menu_you')
140 // item is the item "title" before which to insert the new menu item (or to replacE) (e.g. 'Your Sets')
141 // title is the title of your new item
142 // replace is a boolean to know if we replace 'item' or just add a new one
144 //returns: the a element created
145 insertItem: function(href,menu,item,title,replace,line_above) {
147 var menu_you = document.getElementById(menu);
148 var you_a = menu_you.getElementsByTagName('a');
150 item = this.mapper.localise(item);
151 for(var i=0;i<you_a.length;i++) {
152 if( you_a[i].innerHTML == item ) {
159 GM_log('impossible to find insertion point');
163 var batch = document.createElement('a');
164 if(typeof(href) == "function") {
165 batch.addEventListener("click",href,true);
166 batch.href = 'javascript:;';
169 batch.innerHTML = title;
170 if(line_above) batch.className = "menu_item_line_above";
171 your_set.parentNode.insertBefore(batch, your_set);
172 if(replace) your_set.parentNode.removeChild(your_set);
178 // menu is the id of the main menu
179 // item is the item innerHTML
180 //returns: the element removed
181 removeItem: function(menu,item) {
182 var menu_you = document.getElementById(menu);
183 var you_a = menu_you.getElementsByTagName('a');
185 for(var i=0;i<you_a.length;i++) {
186 if( you_a[i].innerHTML == item ) {
192 GM_log('impossible to find insertion point');
195 your_set.parentNode.removeChild(your_set);
199 createMenuLink: function(href,title,line_above,first) {
200 return '<a '+((first)?' style="padding-top:3px;"':'')+((line_above)?' class="menu_item_line_above"':'')+'" href="'+href+'">'+title+'</a>\n'
204 // innerHTML is the content of the menu (you should create that with createMenuLink calls)
205 // menu is the id of the main menu where to insert the new menu item (e.g. 'candy_nav_menu_you')
206 // item is the item "title" before which to insert the new menu item (or to replacE) (e.g. 'Your Sets')
207 // title is the title of your new item
208 // replace is a boolean to know if we replace 'item' or just add a new one
209 insertMenu: function(innerHTML,menu,item,title,replace) {
211 // insert pulldown menu, from .CK super batch edit script
212 var menu_you = document.getElementById(menu);
213 var you_a = menu_you.getElementsByTagName('a');
215 if(replace) item = this.mapper.localise(item);
216 for(var i=0;i<you_a.length;i++) {
217 if( you_a[i].innerHTML == item ) {
224 GM_log('impossible to find insertion point');
227 var onclickHandler1 = function() {
228 if( batch.clickat == 'body' ) {
229 batch.clickat = null;
232 if( b_menu.style.display == 'none' ) {
233 b_menu.style.display = 'inline';
235 b_menu.style.display = 'none';
238 var batch = this.insertItem(onclickHandler1,menu,item,title,replace);
239 var b_menu = document.createElement('div');
241 batch.clickat = null;
242 batch.onclickHandler1 = onclickHandler1;
243 batch.onclickHandler2 = function() {
244 batch.removeEventListener('click', batch.onclickHandler2, true);
245 batch.addEventListener('click', batch.onclickHandler1, true);
246 b_menu.style.display = 'none';
247 batch.status = false;
249 batch.onclickHandler3 = function() {
250 b_menu.style.display = 'none';
252 b_menu.style.display = 'none';
253 b_menu.style.left = '70px';
254 b_menu.style.marginTop = '-19px';
255 b_menu.className = 'candy_menu';
256 b_menu.innerHTML = innerHTML;
258 batch.parentNode.insertBefore(b_menu, batch.nextSibling);
260 document.body.addEventListener('click',
262 if( b_menu.style.display == 'inline' ) {
263 b_menu.style.display = 'none';
264 batch.clickat = 'body';
265 } else batch.clickat = null;