/*************** validation for upload/post form ****************/ function filePresent(n) { return ($('.v'+n+' input[type=file]').val() != '') || $('.v'+n+' img').length !=0; } function hasOptic(n){ var optic_value = $('.v'+n+' select').val() // "" | "double" | etc return optic_value != ''; } function displayError(msg) { $('form div.error').text(msg).slideDown(); } window.validateUpload = function (frm){ console.log('validateUpload', hasOptic(1), hasOptic(2), filePresent(1), filePresent(2)) if(!(filePresent(1) || filePresent(2))) { displayError('Please upload at least one file in order to enter the contest.'); return false; } if( (filePresent(1) && !hasOptic(1)) ||(filePresent(2) && !hasOptic(2))) { displayError("Please specify the optic for each file you enter in the contest"); return false; } return true; } /**********************************************/ function enable_firebug_fallback() { var cl = function(msg) { } window.console = { log:cl, info:cl, notice:cl, warn:cl, error:cl, dir:cl }; } if(!window.console || !window.console.firebug) enable_firebug_fallback(); window.URL = function(uri) { return '/kubotacontest/' + uri; }; jQuery.fn.slideshowize = function(interval, opts /* required width, height */) { // assumes div [ a[img], ... ] // view var $wrapper = $('
').prependTo(this).css({position:'relative', width:opts.width, height:opts.height}); var $controls = $('
').appendTo(this).css({zIndex:20}); var $images = $(this).find('a').hide().css({position:'absolute',top:0,left:0}).fadeOut(0); console.log('slideshowize', $wrapper, $images); // model var i = 0; var last_advance_forced = false; // initial state var $incoming, $outgoing; $outgoing = $images.eq(i).prependTo($wrapper).fadeIn(1); $wrapper.height($outgoing.height() + $controls.height()); // controller var advance = function(to) { if(to === undefined) { if(last_advance_forced) { last_advance_forced = false; return false; } i = (i + 1) % $images.length; } else { last_advance_forced = true; i = to; } $incoming = $images.eq(i); // console.info(i, $outgoing, '>', $incoming); $incoming.css('z-index',10).prependTo($wrapper).fadeIn(1); $outgoing.css('z-index',11).fadeOut(1000, function() { $outgoing.remove(); $outgoing = $incoming; }); $wrapper.trigger('advance.slideshowize'); $('a', $controls).removeClass('current').eq(i).addClass('current'); var min_height = $incoming.height() + $controls.height(); if ($wrapper.height() < min_height) { $wrapper.height(min_height); } } // play controls $images.each(function(i, e) { $("  ").click(function(){advance(i);}).appendTo($controls); }); // start setInterval(function(){advance();}, interval); } /** * Match Heights Plugin * Match the heights of targeted elements * * Version 1.2 * Updated 12/17/2009 * Copyright (c) 2009 Mike Avello * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * Usage: $(object).matchHeights([minHeight], [maxHeight]); * Example 1: $(".cols").matchHeights(); Sets all objects to the same height. * Example 2: $(".cols").matchHeights(400); Sets all objects to at least 400px tall. * Example 3: $(".cols").matchHeights(100,300); at least 100 but no more than 300. * Example 4: $(".cols, .cols2").matchHeights(); * */ $.fn.matchHeights = function(minHeight, maxHeight) { tallest = (minHeight) ? minHeight : 0; this.each(function() { if($(this).height() > tallest) { tallest = $(this).height(); } }); if((maxHeight) && tallest > maxHeight) tallest = maxHeight; return this.each(function() { extra = $(this).outerHeight() - ($(this).innerHeight() - parseInt($(this).css("padding-top")) - parseInt($(this).css("padding-bottom"))); ($.browser.msie && $.browser.version == 6.0) ? $(this).css({'height': tallest - extra}) : $(this).css({'min-height': tallest - extra}); }); } jQuery(function(){ $('#upload-photos,#update-photos').click(function(){ tb_show('upload', URL('update_form?height=480')); return false; }); // $('#update-photos,').click(function(){ // tb_show('update', URL('update_form?height=480')); // return false; // }); $('.entries .pager a').live('click', function() { var page = $(this).text(); var url = $(this).attr('href'); $.get(url, null, function(rsp, xhr) { $('#entries_wrapper').html(rsp); }); return false; }); $('.entries a.libo').live('click', function() { $(this).lightbox.start(this); return false; }); $('body .tb_hide').live('click', function() { tb_remove(); return false; }); $('a.login-to-vote').live('click', function() { alert('Please log in to vote'); window.location.hash = '#voting-login'; $('input [name*=email]').focus() $('input').effect('highlight').effect('highlight') }); $('a.cast-vote').click(function() { var id = this.href.split('/').pop(); tb_show('Vote', URL('vote/'+id)); // $.post('/getpublished/vote/'+id, {}, function(json, xhr){ // console.dir(json); // }, 'json'); return false; }); }); // jQuery.fn.lightbox = function() {} // stub to suppress error from DOC_ROOT/js/script.js