%= javascript_include_tag 'jquery.jcrop' %> <%= content_for :javascript do %> // fancy box to crop the image <%= render :partial => 'logos/crop_logo.js.erb', :locals => { :form_id => 'select_logo_form', :url_form => logos_path({ :upload => :yes}), :container_id => 'resultado', :aspect_ratio => Logo::ASPECT_RATIO_S, :crop_size => 188, :on_success => 'onCropLogoFormSuccess' } %> $(document).ready(function() { if ($("#create_space #public").is(':checked')) { $('#new_space_webconf_area').hide(); $('#moderatorPW').attr('disabled', true); $('#attendeePW').attr('disabled', true); } else { $('#new_space_webconf_area').show(); $('#moderatorPW').removeAttr('disabled'); $('#attendeePW').removeAttr('disabled'); } }); // function executed after the crop fancy box is shown onCropLogoFormSuccess = function() { $('#crop_logo_form').ajaxForm({ beforeSubmit:function() { $("#selected_logo_image").attr('src', ""); }, target: '#resultado', success: function() { $('#resultado').fadeIn('slow'); $("#space_image").attr('value', "tmp/" + rand + "/uploaded_logo.png"); $("#selected_logo_image").attr('src', "/images/" + "tmp/" + rand + "/uploaded_logo.png?" + (new Date()).getTime()); $.fancybox.close(); closeUploadLogo(); } }); } selectDefaultImage = function(image){ $("#space_image").attr('value', "default_space_logos/" + image); $("#selected_logo_image").attr('src', "/images/default_space_logos/" + image); } selectGeneratedImage = function(image){ $("#space_image").attr('value', image); $("#selected_logo_image").attr('src', "/images/" + image + "?" + (new Date()).getTime()); } $("#selected_logo_image").attr('src', "/images/" + ($("#space_image").val())); closeTextLogo = function(){ $("#default_text_logo").hide(0); $("#open_text_logo_link").show(); $("#close_text_logo_link").hide(); } openTextLogo = function(){ $("#default_text_logo").show(0); $("#open_text_logo_link").hide(); $("#close_text_logo_link").show(); } closeGallery = function (){ $("#default_space_images").hide(0); $("#open_gallery_link").show(); $("#close_gallery_link").hide(); } openGallery = function (){ $("#default_space_images").show(0); $("#close_gallery_link").show(); $("#open_gallery_link").hide(); } closeUploadLogo = function(){ $("#default_upload_logo").hide(0); $("#open_upload_logo_link").show(); $("#close_upload_logo_link").hide(); } openUploadLogo = function (){ $("#default_upload_logo").show(0); $("#open_upload_logo_link").hide(); $("#close_upload_logo_link").show(); } var dateTime = new Date(); var rand = dateTime.getHours() + "" + dateTime.getMinutes() + "" + dateTime.getSeconds() + "" + dateTime.getMilliseconds(); //$("#logo_rand").attr('value', dateTime.getHours() + "" + dateTime.getMinutes() + "" + dateTime.getSeconds() + "" + dateTime.getMilliseconds()); $("#logo_rand").attr('value', rand); $("#space_rand_value").attr('value', rand); $("#generate_text_logo_button").livequery('click',function(){ $.get('/logos/new?text='+ ($("#space_text_logo").val()) + '&rand_name=' + rand , function(data) { $('#generated_text_logos').html(data); }); }); $("#create_space_button").livequery('click',function(){ // Validate name var name = ($('#space_name').val()); if (name == "") { $("#error_name").show(); var destination_add = $('#new_space_anchor').offset().top; $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination_add}, 1100, function() { window.location.hash = '#new_space_anchor'; }); } else { $("#error_name").hide(); } // Validate description var description = ($('#space_description').val()); if (description == "") { $("#error_description").show(); var destination_add = $('#new_space_anchor').offset().top; $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination_add}, 1100, function() { window.location.hash = '#new_space_anchor'; }); } else { $("#error_description").hide(); } if ((name != "") && (description != "")) { $("form#space_new_form").submit(); } }); /* $('#select_logo_form').ajaxForm({ // target identifies the element(s) to update with the server response target: '#resultado', // success identifies the function to invoke when the server response // has been received; here we apply a fade-in effect to the new content success: function() { $('#resultado').fadeIn('slow'); size = 188; $("#croplogo").Jcrop({ onSelect: cropImage, onChange: cropImage, bgColor : 'white', }); $('#crop_logo_form').ajaxForm({ beforeSubmit:function() { $("#selected_logo_image").attr('src', ""); }, target: '#resultado', success: function() { $('#resultado').fadeIn('slow'); $("#space_image").attr('value', "tmp/" + rand + "/uploaded_logo.png"); $("#selected_logo_image").attr('src', "/images/" + "tmp/" + rand + "/uploaded_logo.png?" + (new Date()).getTime()); closeUploadLogo(); } }); } }); function cropImage (c){ $("#crop_size_x").val(c.x); $("#crop_size_y").val(c.y); $("#crop_size_height").val(c.h); $("#crop_size_width").val(c.w); }; */ $('#space_logo img.tooltip_update_logo').qtip({ content: '<%= escape_javascript(t("tooltip.update_logo")) %>', position: {adjust: { screen: true }}, show: 'mouseover', hide: { when: 'mouseout', fixed: true }, style: 'mystyle' }); $('#space_new_form img[tooltip]').each(function() { $(this).qtip({ content: $(this).attr('tooltip'), // Use the tooltip attribute of the element for the content position: {adjust: { screen: true }}, show: 'mouseover', hide: { when: 'mouseout', fixed: true }, style: 'mystyle' // Give it a crea mstyle to make it stand out }); }); $("#create_space #public").livequery('click', function(event) { $('#new_space_webconf_area').toggle(0); if ($(this).is(':checked')) { $('#moderatorPW').attr('disabled', true); $('#attendeePW').attr('disabled', true); } else { $('#moderatorPW').removeAttr('disabled'); $('#attendeePW').removeAttr('disabled'); } }); $("#create_space #hideMPW").livequery('click', function(event) { if ($(this).is(':checked')) { changeInputTextType("#moderatorPW", 'text'); } else { changeInputTextType("#moderatorPW", 'password'); } }); $("#create_space #hideAPW").livequery('click', function(event) { if ($(this).is(':checked')) { changeInputTextType("#attendeePW", 'text'); } else { changeInputTextType("#attendeePW", 'password'); } }); <% end %>