var currentPage = 0; var totalPages = 1; var showImageBorderTimeout; var clicks = 0; var tooltipsApplied = false; function getThumbnailSize() { var size = $('#thumb_size').slider('value'); $('#album .thumbnail').css({'width':size+8, 'min-height':size+8, 'height': size+8}); $('#album .thumbnail .inner').css({'width':size+8, 'height': size+8}); $('#album .thumbnail img').css({'max-width':size, 'max-height':size}); setCookie('thumbnailSize', size, {path: '/', expires: 0}); } jQuery(function($) { limitFilesQuantity = 20; $('#progressbar').progressbar(); $('#dialog-menu').dialog({ autoOpen: false, width: 400, position: ['center', 'center'], height: 'auto', modal: true, resizable: false, draggable: false }); $('#dialog-limit').dialog({ autoOpen: false, width: 'auto', position: ['center', 'center'], height: 'auto', modal: true, resizable: false, draggable: false }); $('#dialog-upload').dialog({ autoOpen: false, width: 600, position: ['center', 'center'], height: 'auto', modal: true, resizable: false, draggable: false, open: function() { var uploader = $('#uploader').plupload('getUploader'); uploader.settings.multipart_params.album_id = $('#album_id').val(); $('.plupload_droptext').show(); return; }, close: function() { var uploader = $('#uploader').plupload('getUploader'); uploader.stop(); if(uploader.total.uploaded > 0) document.location.href = '/events/' + $('#event_id').val() + '/album'; return false; } }); $('#dialog-quotation').dialog({ autoOpen: false, width: 470, position: ['center', 'center'], height: 'auto', modal: true, resizable: false, draggable: false, open: function(){ if(!tooltipsApplied) { $('#share42 a').tooltip({showURL: false}); $('#quotationUrls a').zclip({ path:'/skin/js/ZeroClipboard.swf', copy:function(){return $(this).attr('href')}, clickAfter: false, setHandCursor: true, afterCopy: function(){ flushSpinnerMessage(Travvi.s('js.code_copied_in_clipboard')); } }); tooltipsApplied = true; } } }); $('#dialog-limit a.submit').button(); $('#dialog-limit a.submit.next').click(function(){ var up = $('#uploader').plupload('getUploader'); while (up.files.length > limitFilesQuantity) { up.removeFile(up.files[up.files.length - 1]); } $('#dialog-limit').dialog('close'); $('#uploader_start').button('enable').click(); return false; }); $('#dialog-limit a.submit.cancel').click(function(){ $('#dialog-limit').dialog('close'); return false; }); $('#breadcrumbs a').tooltip({showURL: false}); $(window).resize(function() { if(screen.width < 1280) { $('a.expander').hide(); } else { $('a.expander').show(); } $('#dialog-upload').dialog('option', {position: ['center', 'center']}); $('#dialog-menu').dialog('option', {position: ['center', 'center']}); $( "#dialog-quotation" ).dialog('option', {position: ['center', 'center']}); }).resize(); $(window).scroll(function() { $('#dialog-upload').dialog('option', {position: ['center', 'center']}); $('#dialog-menu').dialog('option', {position: ['center', 'center']}); $( "#dialog-quotation" ).dialog('option', {position: ['center', 'center']}); }); $.history.init(function(hash){ var urlParams = /^(\d+)?\/?(upload)?$/.exec(hash); if(!urlParams) return false; var prevPage = currentPage; currentPage = urlParams[1] ? urlParams[1] : 1; if(prevPage != currentPage) { Spinner.show(); $('#main_panel_container').load('/event_album_page/' + $('#event_id').val() + '/' + currentPage); } if(urlParams[2]) { $('#dialog-upload').dialog('open'); document.location.hash="#"; } }, { unescape: ",/" }); $('a.dialog_quotation_opener').click(function(){ $('#dialog-quotation').dialog('open'); return false; }); $( "#SWFcaller" ).button({ disabled: true }); $( "#btnCancel" ).button(); $( "#btnSuccess" ).button(); $( "a#btnCancel", "#dialog-upload" ).click(function(){ $('#dialog-upload').dialog('close'); return false; }); $('#pbDetails').click(function(){ $('#dialog-upload table').toggle(); return false; }); $( "#btnSuccess" ).click(function(){ $('#dialog-upload').dialog('close'); return false; }); $('.menuCaller').click(function(){ $('#dialog-menu').dialog('open'); return false; }); $('#upload_caller').click(function(){ $('#dialog-upload').dialog('open'); $('#dialog-menu').dialog('close'); return false; }); $('#album a.left').tooltip({showURL: false}); $('#album a.right').tooltip({showURL: false, positionLeft: true, left: -5}); $('a.lock').tooltip({showURL: false, positionLeft: true, left: -5}); var thumb_size = getCookie('thumbnailSize'); $('#thumb_size').slider({ min: 80, max: 200, value: thumb_size ? thumb_size : 149, slide: getThumbnailSize, change: getThumbnailSize }); $("#thumb_size .ui-slider-handle").unbind('keydown'); $('#visitCounter').tooltip({showURL: false, positionLeft: true, left: -5}); $('#button_holder a').tooltip({showURL: false}); $('#arrow2_left').click(function(){ $.history.load(currentPage - 1); return false; }); $('#arrow2_right').click(function(){ $.history.load(parseInt(currentPage) + 1); return false; }); $('#paginator #current_page').live('change', function(){ var page = $(this).val(); if ( page >= 1 && page <= totalPages) { $.history.load(page); } else { $(this).animate({ backgroundColor: "#8239AF" }, 100).animate({ backgroundColor: "#C0C0C0" }, 1000, function(){$(this).val(currentPage);}); } return false; }); $('.thumbnail img').live('mouseenter', function(){ var el = this; showImageBorderTimeout = setTimeout(function(){ $(el).addClass('selected'); }, 400); }).live('mouseleave', function(){ clearTimeout(showImageBorderTimeout); $(this).removeClass('selected'); }); $(document).bind('keydown', function(e){ switch (e.keyCode) { case 37: // left arrow if ($('#arrow2_left:visible').length) { $('#arrow2_left').click();} break; case 39: //right arrow if ($('#arrow2_right:visible').length) { $('#arrow2_right').click();} break; } }); $('.thumbnail a.ie_trick').live('click', function(){ var obj = this; document.location.href = $(obj).attr('href'); return false; }); $('#bottom_right_container a.button').button(); $('#placesContainer a.button').button(); $('#bottom_right ul a').click(function(){ $('#bottom_right .items').hide(); $($(this).attr('href')).show(); $('#bottom_right ul a, #bottom_right a.arrow5').removeClass('current'); $(this).addClass('current'); return false; }); $('#bottom_right a.arrow5').click(function(){ $('#bottom_right .items').hide(); $('#bottom_right ul a').removeClass('current'); $(this).addClass('current'); return false; }); $('#bottom_right ul a.map_caller').click(function(){ if(map) { map.invalidateSize().fitBounds(markers.getBounds().extend(objmarker.getLatLng())); } return false; }); $('#map_canvas .leaflet-control-layers-list input:radio').checkbox({cls:'jquery-radiobutton-white',empty: '/skin/images/empty.png'}); $('#map_canvas .leaflet-control-layers-list').append('
'); var another_slide = function(amount) { var content = $('#map_canvas .leaflet-control-layers-base'), container = $('#map_canvas .leaflet-control-layers-list'), delta = container.actual('height') - content.actual('height'); if (delta < 0) { content.css('marginTop', delta*(1-amount/100)); } } $( "#map_canvas #layersSlider" ).slider({ value: 100, orientation: "vertical", min: 0, max: 100, step: 1, slide: function( event, ui ) { another_slide(ui.value); }, change: function( event, ui ) { another_slide(ui.value); } }); $('#map_canvas .leaflet-control-layers-list').mousewheel(function(e, delta){ delta *= 5; var obj = $( "#map_canvas #layersSlider"); var newVal = obj.slider('option', 'value') + delta; newVal = Math.max(obj.slider('option', 'min'), Math.min(obj.slider('option', 'max'),newVal)); obj.slider('option', 'value', newVal); return false; }); $('#map_canvas .jquery-radiobutton-white').hover(function(){ $('#map_canvas .leaflet-control-layers').addClass('leaflet-control-layers-expanded'); }, function(){ $('#map_canvas .leaflet-control-layers').removeClass('leaflet-control-layers-expanded'); }); $('#dialog-groupFormAdd').dialog({ autoOpen: false, width: 'auto', position: ['center', 'center'], height: 'auto', modal: true, resizable: false, draggable: false, open: function(){ Spinner.show(); $('#dialog-groupFormAdd .groupsList').load('/user/object_lists/get/'+$('#object_id').val(), function(){ $('#dialog-groupFormAdd input:checkbox').checkbox({cls:'jquery-checkbox-white', empty: '/skin/images/empty.png'}); var content = $('#dialog-groupFormAdd .groupsList'), container = $('#dialog-groupFormAdd .groupsListContainer'), delta = container.actual('height') - content.actual('outerHeight'); if (delta < 0) { $('#dialog-groupFormAdd .slider').show(); } else { $('#dialog-groupFormAdd .slider').hide(); } $('#dialog-groupFormAdd').dialog('option', {position: ['center', 'center']}); Spinner.hide(); }); } }); $('#groupFormCaller').tooltip({showURL: false}).click(function(){ actionCandidates = [$(this).data('id')]; $('#dialog-groupFormAdd').dialog('open'); return false; }); $('#dialog-groupFormAdd a').button(); $('#dialog-groupFormAdd a[title]').tooltip({showURL: false}); $('#dialog-groupFormAdd a.edit').click(function(){ $('#dialog-groupFormAdd').dialog('close'); $('#dialog-groupEditForm').dialog('open'); return false; }); $('#dialog-groupFormAdd a.cancel').click(function(){ $('#dialog-groupFormAdd').dialog('close'); return false; }); $('#dialog-groupFormAdd a.ok').click(function(){ var lists = [], extended = []; $('#dialog-groupFormAdd .groupsList input:checkbox:checked').each(function(){ if($.isNumeric($(this).val())) { lists.push($(this).val()); } else { extended.push($(this).val()); } }); $.ajax({ url: '/user/object_lists/save_objects', data: {ids: actionCandidates, lists: lists, extended: extended }, type: 'post', dataType: 'script' }); $('#dialog-groupFormAdd').dialog('close'); //reloadContactsPanel(); return false; }); $('#dialog-groupFormAdd .slider').slider({ value: 100, orientation: "vertical", min: 0, max: 100, step: 1, slide: function( event, ui ) { var content = $('#dialog-groupFormAdd .groupsList'), container = $('#dialog-groupFormAdd .groupsListContainer'), delta = container.actual('height') - content.actual('outerHeight'); if (delta < 0) { content.css('marginTop', delta*(1-ui.value/100)); } }, change: function( event, ui ) { var content = $('#dialog-groupFormAdd .groupsList'), container = $('#dialog-groupFormAdd .groupsListContainer'), delta = container.actual('height') - content.actual('outerHeight'); if (delta < 0) { content.css('marginTop', delta*(1-ui.value/100)); } } }); $('#dialog-groupFormAdd .groupsListContainer').mousewheel(function(e, delta){ delta *= 5; var obj = $( "#dialog-groupFormAdd .slider" ); var newVal = obj.slider('option', 'value') + delta; newVal = Math.max(obj.slider('option', 'min'), Math.min(obj.slider('option', 'max'),newVal)); obj.slider('option', 'value', newVal); return false; }); $('#setVisitedContainer').on('click', '#setVisited' ,function(){ $.ajax({ url: '/user/object_lists/set_properties', data: {id: $('#object_id').val(), prop: 'visited' }, type: 'post', dataType: 'script' }); return false; }); Spinner.hide(); });