/* Gallery */ function init_gallery() { // We only want these styles applied when javascript is enabled $('div.content').css('display', 'block'); // Initially set opacity on thumbs and add // additional styling for hover effect on thumbs var onMouseOutOpacity = 0.67; $('#thumbs ul.thumbs li, div.navigation a.pageLink').opacityrollover({ mouseOutOpacity: onMouseOutOpacity, mouseOverOpacity: 1.0, fadeSpeed: 'fast', exemptionSelector: '.selected' }); // Initialize Advanced Galleriffic Gallery var gallery = $('#thumbs').galleriffic({ delay: 2500, numThumbs: 8, preloadAhead: 10, enableTopPager: false, enableBottomPager: false, imageContainerSel: '#slideshow', controlsContainerSel: '#controls', captionContainerSel: '#caption', loadingContainerSel: '#loading', renderSSControls: true, renderNavControls: true, playLinkText: translate('gallery_play'), pauseLinkText: translate('gallery_pause'), prevLinkText: '‹ ' + translate('gallery_previous'), nextLinkText: translate('gallery_next') + ' ›', nextPageLinkText: translate('gallery_next') + ' ›', prevPageLinkText: '‹ ' + translate('gallery_previous'), enableHistory: true, autoStart: false, syncTransitions: true, defaultTransitionDuration: 900, onSlideChange: function(prevIndex, nextIndex) { // 'this' refers to the gallery, which is an extension of $('#thumbs') this.find('ul.thumbs').children() .eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end() .eq(nextIndex).fadeTo('fast', 1.0); // Update the photo index display this.$captionContainer.find('div.photo-index') .html('Photo : '+ (nextIndex+1) +' / '+ this.data.length); }, onPageTransitionOut: function(callback) { this.fadeTo('fast', 0.0, callback); }, onPageTransitionIn: function() { var prevPageLink = this.find('a.prev').css('visibility', 'hidden'); var nextPageLink = this.find('a.next').css('visibility', 'hidden'); // Show appropriate next / prev page links if (this.displayedPage > 0) prevPageLink.css('visibility', 'visible'); var lastPage = this.getNumPages() - 1; if (this.displayedPage < lastPage) nextPageLink.css('visibility', 'visible'); this.fadeTo('fast', 1.0); } }); /**************** Event handlers for custom next / prev page links **********************/ gallery.find('a.prev').click(function(e) { gallery.previousPage(); e.preventDefault(); }); gallery.find('a.next').click(function(e) { gallery.nextPage(); e.preventDefault(); }); /****************************************************************************************/ /**** Functions to support integration of galleriffic with the jquery.history plugin ****/ // PageLoad function // This function is called when: // 1. after calling $.historyInit(); // 2. after calling $.historyLoad(); // 3. after pushing "Go Back" button of a browser function pageload(hash) { // alert("pageload: " + hash); // hash doesn't contain the first # character. if(hash) { $.galleriffic.gotoImage(hash); } else { gallery.gotoIndex(0); } } // Initialize history plugin. // The callback is called at once by present location.hash. $.historyInit(pageload, "advanced.html"); // set onlick event for buttons using the jQuery 1.3 live method $("a[rel='history']").live('click', function(e) { if (e.button != 0) return true; var hash = this.href; hash = hash.replace(/^.*#/, ''); // moves to a new page. // pageload is called at once. // hash don't contain "#", "?" $.historyLoad(hash); return false; }); /****************************************************************************************/ } function deleteImg(elem, id_gallery, img) { $.ajax({ url: '/resource/ajaxdelimg', type : "POST", data : {id : id_gallery, img : img}, success : function (msg) { $(elem).parents('tr.tr_img').remove(); if ($("#imgList tbody>tr.tr_img").length <= 0) { $("#imgList tbody>tr.no_row").css("display", "table-row"); } } }); } function addImg(data) { img = data.name; var clonedRow = $("#imgList tfoot>tr").clone(); $(".img_min img", clonedRow).attr('src', $(".img_min img", clonedRow).attr('src') + img); $(".img_min input", clonedRow).val(img); $(".img_file", clonedRow).html(img); var regex = new RegExp("('')", "g"); var tmp = $(".del_button .img_tool a", clonedRow).attr("onclick"); tmp = tmp.replace(regex,"'"+img+"'"); $(".del_button .img_tool a", clonedRow).attr("onclick", tmp); $("#imgList tbody>tr.no_row").css("display", "none"); $("#imgList tbody").append(clonedRow); } /* News */ function add_news () { $.ajax({ url: '/news/ajaxgetform', type : "POST", async: false, success : function (msg) { show_form_news (msg); } }); }; function edit_news (id) { $.ajax({ url: '/news/ajaxgetform', type : "POST", data : { "newsid" : id }, async: false, success : function (msg) { show_form_news (msg); } }); }; function delete_news (id) { $.ajax({ url: '/news/ajaxdeletenews', type : "POST", data : { "newsid" : id }, async: false, success : function (msg) { $("#news" + id).remove(); } }); }; function show_form_news (content) { $("#popup_dialog").html(content); $("#popup_dialog").dialog({ title: translations["title_add"], modal: true, resizable : false, width : 500, height : "auto", position : "center", open : function () { var buttons = new Object(); buttons[translations["ok"]] = function() { $.ajax({ url: '/news/ajaxaddnews', type : "POST", data : $("#NEWS").serialize(), async: false, success : function (msg) { if (typeof $(msg).attr('replace') != "undefined") { if($(msg).attr('replace')) { $("#myNews tbody tr#" + $(msg).attr('id')).replaceWith(msg); } else { $("#myNews tbody").append(msg); } $("#popup_dialog").dialog('close'); } else { $("#popup_dialog #NEWS").parent().html(msg); } } }); }; buttons[translations["cancel"]] = function() {$(this).dialog('close');}; $(this).dialog("option", "buttons", buttons); } }); $("#popup_dialog").dialog("open"); } /* RSS */ function load(id) { $("#page").load("/resource/ajaxrss/id/"+id); }; /*function more (elem) { $(elem).animate({ height : "toggle" }, 1000, function() { var img = $(this).prev().find(".more img"); var lib = $(this).prev().find(".more span") if ($(this).css("display") === "none") { img.attr("src", APPLICATION_URL_IMG+"common/toggle_plus.png"); lib.html("More"); } else { img.attr("src", APPLICATION_URL_IMG+"common/toggle_minus.png"); lib.html("Less"); } }); }*/ function more (elem) { var img = $(elem).prev().find(".more img"); var lib = $(elem).prev().find(".more span"); if ($(elem).css("display") === "none") { $(elem).css("display", "block"); img.attr("src", APPLICATION_URL_IMG+"common/toggle_minus.png"); lib.html("Less"); } else { $(elem).css("display", "none"); img.attr("src", APPLICATION_URL_IMG+"common/toggle_plus.png"); lib.html("More"); } }