YAHOO.photoViewer.initGallry = function() { // Build the configuration object used to create the Photoviewer var cnt = 0, v, vs = []; for (i=1; i<4; i++) { var el = lib.d.get("lightbox" + i); if (el) { switch (i) { case 1: v = {"lightbox1": {}}; break; case 2: v = {"lightbox2": {}}; break; case 3: v = {"lightbox3": {}}; break; } v[el.id] = { properties: { id: el.id, grow: 0.2, fade: 0.2, modal: true, dragable: true, fixedcenter: true, loadFrom: "html", position: "absolute", easing: YAHOO.util.Easing.easeBothStrong, buttonText:{ next: " ", prev: " ", close: "close" } } }; vs[cnt++] = v; } else { el = lib.d.get("gallry" + i); if (el) { switch (i) { case 1: v = {"gallry1": {}}; break; case 2: v = {"gallry2": {}}; break; case 3: v = {"gallry3": {}}; break; } v[el.id] = { properties: { id: el.id, grow: 0.2, fade: 0.2, modal: true, dragable: true, fixedcenter: true, loadFrom: "html", position: "absolute", easing: YAHOO.util.Easing.easeBothStrong, buttonText:{ next: "next", prev: "prev", close: "close" }, slideShow: { loop:false, duration:5000, autoStart:false, playMode:"ordered", controlsText: { play: "play", pause: "pause", stop: "stop", display: "({0} of {1})" } } } }; vs[cnt++] = v; } } } if (vs.length) { var tmpObj = { viewers: vs }; // Convert the array/object into a JSON string var jsonStr = YAHOO.lang.JSON.stringify(tmpObj); // Clean up the string - remove array brackets and extra curly braces - prep for turning it back into an object jsonStr = jsonStr.replace(/\:\[\{/, ":{"); jsonStr = jsonStr.replace(/\},\{/g, ","); jsonStr = jsonStr.replace(/\]\}/, "}"); YAHOO.photoViewer.config = YAHOO.lang.JSON.parse(jsonStr); } // If on the thumbnails page... if (false) { // ...add the "hovered" class to the images when the mouse enters, and remove the class when it leaves. if (YAHOO.env.ua.ie != 0) { } else { } var allImgs = YAHOO.util.Selector.query("div.photoViewer img", "mainContentBox", false); lib.e.addListener(allImgs, "mouseover", function(e) { var el = lib.e.getTarget(e); lib.d.addClass(el, "hovered"); }); lib.e.addListener(allImgs, "mouseout", function(e) { var el = lib.e.getTarget(e); lib.d.removeClass(el, "hovered"); }); // ...code the "Close Window" link so that it closes the window/tab. var a = lib.d.get("closeWindow"); if (a) { lib.e.addListener(a, "click", function(e) { lib.e.preventDefault(e); window.open("","_parent",""); window.close(); }); } // ...display Caption/Credit in a tooltip when hovering over the thumbnails. var anchors = YAHOO.util.Selector.query("div.photoViewer a", "mainContentBox", false); var aTT = new YAHOO.widget.Tooltip("aTT", { showdelay: 400, context: anchors, effect: {effect: YAHOO.widget.ContainerEffect.FADE, duration: 0.3} }); aTT.contextTriggerEvent.subscribe( function(type, args) { var context = args[0]; // Default to "No Caption" var txt = "
No Caption
"; var caption = (context.getAttribute("rel")) ? context.getAttribute("rel") : ""; var credit = (context.getAttribute("name")) ? context.getAttribute("name") : ""; if (caption.length || credit.length) { txt = "
"; if (caption.length) { txt += caption; if (credit.length) txt += "
" + credit + "
"; } else { txt += credit; } txt += "
"; } this.cfg.setProperty("text", txt); } ); } } YAHOO.util.Event.onDOMReady(YAHOO.photoViewer.initGallry); // Need to call this again to create the photoViewers - better way? (Called inside of photoviewer_base.js) YAHOO.util.Event.onDOMReady(YAHOO.photoViewer.controller.init, YAHOO.photoViewer.controller, YAHOO.photoViewer.controller);