/* */ if (typeof(lpgadgets)=="undefined") lpgadgets = {}; lpgadgets.lp = lpgadgets.lp || {}; lpgadgets.lp.menu = function() { //define language packs var language = {}; language["en"] = ["Help", "About", "More gadgets", "Help", "About this gadget", "Visit LabPixies.com"]; language["he"] = ["עזרה","אודות", "גאג'טים נוספים", "אודות גאג'ט זה","בקרו באתרינו"]; language["iw"] = language["he"]; var targetUrl = "http://www.labpixies.com"; var menuImageDir = "http://cdn.labpixies.com/infra/images/menu/"; var addToToolbarUrl = "http://cdn.labpixies.com/gadget_page.php?inst_on_toolbar=1&id="; var openTimer=0; var closeTimer=0; var iconImage=null; var isOpen=false; var menuContainer, menuButton, iconContainer, logo, menu; var textDirection = "ltr"; var lang = "en"; var gadget_menu_element; var additionalParams; try { jQuery(document).ready(function(){reportCommScore();}); } catch (eewe) {} /** *Elm must be an html element */ function init(elementId, moreParams) { gadget_menu_element = $lp("#"+elementId); if (!gadget_menu_element) return; additionalParams = moreParams; //get settings from the gadget if (!additionalParams) additionalParams = {}; textDirection = additionalParams.textDirection || "ltr"; lang = additionalParams.lang || "en"; lang = language[lang] ? lang:"en"; addTopMenu(); } //report to commsocre function reportCommScore() { try { var img = new Image(1,1); var r1 = new String (Math.random()); r1 = r1.substring(2,11); //img.onload = function() {return;}; img.src = "http://static.labpixies.com/commscore/?rnd="+r1+"&CXNID=1000012."+_gadgetID+"NXC"; } catch (ee) {} } //return true if the menu should be disply on top function isTopMenu() { try { if (gadgets.views.getCurrentView().getName() == "canvas") return false; } catch (ee) {} return true; } function getCachedUrl(url) { if (typeof(_IG_GetCachedUrl) == "function") { return _IG_GetCachedUrl(url); } return url; } function addTopMenu() { //create and add the main container for the menu menuContainer = $lp("
"); menuContainer.css("background-image","url("+getCachedUrl(menuImageDir+"menu_middle.gif")+")"); gadget_menu_element.append(menuContainer); //create the image icon menuButton = $lp("") .hover( function(e){ $lp(this).attr("src",getCachedUrl(menuImageDir+"menu_on.gif")); noCloseDelayed(); }, function(e){ closeDelayed(); noOpenDelayed(); if (!isOpen) $lp(this).attr("src",getCachedUrl(menuImageDir+"menu_off.gif")); } ).click( function(e){if (isOpen) closeMenu(); else openMenu();} ); menuContainer.append(menuButton); //create the icon container iconContainer = $lp("
"); menuContainer.append(iconContainer); logo = $lp("") .hover( function(e){$lp(this).attr("src",getCachedUrl(menuImageDir+"pixies_on.gif"))}, function(e){$lp(this).attr("src",getCachedUrl(menuImageDir+"pixies_off.gif"))} ).click( function(e){window.open(targetUrl+"?gadget="+_gadgetID+"&source=menu&menu_item=logo","_blank");} ); menuContainer.append(logo); //add the menu menu = $lp("
"); menuContainer.append(menu); //add the items to the menu addItem(language[lang][2], language[lang][5], menuImageDir+"generic", function() { window.open("http://www.labpixies.com/?gadget="+_gadgetID+"&source=menu&menu_item=more","_blank"); }); addItem(language[lang][1], language[lang][4], menuImageDir+"about", function() { window.open("http://www.labpixies.com/gadget_page.php?id="+_gadgetID+"&gadget="+_gadgetID+"&source=menu&menu_item=about","_blank"); }); addItem(language[lang][0], language[lang][3], menuImageDir+"generic", function() { window.open("http://www.labpixies.com/support/?gadget="+_gadgetID+"&source=menu&menu_item=help","_blank"); }); } function addItem(lbl, longLbl, icon, callback) { var itm; var d = textDirection=="ltr"?"left":"right"; itm = $lp("
"+lbl+"
").click(function () { closeMenu(); callback(); }); itm.css({ "font":"normal 10px arial, Helvetica, sans-serif" ,"line-height":"16px" ,"color":"#0096d0" ,"background-color":"#ffffff" ,"border-bottom":"1px solid #0096d0" ,"width":"68px" ,"height":"16px" ,"padding":"0px 2px 0px 2px" ,'cursor':"pointer" ,'direction':textDirection }) .hover( function(e){noCloseDelayed();$lp(this).css({"color":"#ffffff","background-color":"#0096d0"})}, function(e){closeDelayed();$lp(this).css({"color":"#0096d0","background-color":"#ffffff"})} ); menu.append(itm); } /** will open the menu unless the timer will be canceld by the noOpenDelayed */ function openDelayed() { openTimer = setTimeout(openMenu,300); } /** canceld by the OpenDelayed */ function noOpenDelayed() { clearTimeout(openTimer); } /** actualy open the manu */ function openMenu() { if (!isOpen) { var off = menuButton.offset(); menu.css("top",off.top+15).css("left",off.left-34).show(); isOpen = true; } } /** will close the menu unless the timer will be canceld by the noOpenDelayed */ function closeDelayed() { closeTimer = setTimeout(closeMenu,300); } /** canceld by the OpenDelayed */ function noCloseDelayed() { clearTimeout(closeTimer); } function closeMenu() { if (isOpen) { $lp(menu).hide(); menuButton.attr("src",getCachedUrl(menuImageDir+"menu_off.gif")); isOpen = false; } } function AddIcon(imageUrl, title, clickCallback) { var icon = $lp("").click(clickCallback); iconContainer.append(icon); } return /** @scope lpgadgets.lp.menu*/ { deploy: function (div_element_id, additionalParams) { init(div_element_id, additionalParams); }, //this function is depricated addMenuItem: function(lbl, callback) { addItem(lbl,lbl, "http://cdn.labpixies.com/infra/images/menu/generic", callback); }, addLongMenuItem: function(lbl, longLbl, icon, callback) { addItem(lbl,longLbl, icon, callback); }, addIconItem: function (imageUrl, title, clickCallback) { AddIcon(imageUrl, title, clickCallback); } }; }();