From 19e8aa5c352bb200dfc29b536df0079c23e282bc Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 26 Aug 2010 11:06:35 -0700 Subject: [PATCH] Refactored view js --- app/views/albums/index.html.haml | 6 ++++++ app/views/albums/show.html.haml | 5 +---- app/views/layouts/application.html.haml | 2 -- public/javascripts/photos.js | 24 ++++++++++++++++++++++++ public/javascripts/view.js | 22 ++++------------------ 5 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 public/javascripts/photos.js diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 47d2f68a9..2be320629 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -1,3 +1,9 @@ +- content_for :head do + :javascript + $(document).ready(function(){ + $("#add_album_button").fancybox(); + }); + .back= link_to "⇧ home", root_path %h1.big_text Albums diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index f67fb5d33..18e042ad9 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -1,8 +1,5 @@ - content_for :head do - :javascript - $(document).ready(function(){ - reset_photo_fancybox(); - }); + = javascript_include_tag 'photos', 'jquery.html5_upload' .album_id{:id => @album.id, :style => "display:hidden;"} .back= link_to '⇧ albums', albums_path diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 328ab1650..cd3579319 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -23,8 +23,6 @@ = csrf_meta_tag = yield(:head) - = javascript_include_tag 'jquery.html5_upload' - %body - flash.each do |name, msg| = content_tag :div, msg, :id => "flash_#{name}" diff --git a/public/javascripts/photos.js b/public/javascripts/photos.js new file mode 100644 index 000000000..b04585402 --- /dev/null +++ b/public/javascripts/photos.js @@ -0,0 +1,24 @@ +$(document).ready(function(){ + reset_photo_fancybox(); + + $("#add_photo_button").fancybox({ + 'onClosed' : function(){ + if($("#add_photo_button").hasClass("uploading_complete")){ + $("#add_photo_button").removeClass("uploading_complete"); + reset_photo_fancybox(); + } + } + }); + + $(".image_thumb img").load( function() { + $(this).fadeIn("slow"); + }); + +});//end document ready + +function reset_photo_fancybox(){ + album_id = $(".album_id")[0].id; + ajax = $.get("/photos/new?album_id=" + album_id, function(){ + $("#new_photo_pane").html(ajax.responseText) + }); +} diff --git a/public/javascripts/view.js b/public/javascripts/view.js index c50439768..f9fa6d194 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -20,25 +20,16 @@ $(document).ready(function(){ //buttons////// - $("#add_album_button").fancybox(); $("#add_group_button").fancybox(); $("#add_request_button").fancybox({ 'titleShow': false }); - $("#add_photo_button").fancybox({ - 'onClosed' : function(){ - if($("#add_photo_button").hasClass("uploading_complete")){ - $("#add_photo_button").removeClass("uploading_complete"); - reset_photo_fancybox(); - } - } - }); + + //pane_toggler_button("photo"); $("input[type='submit']").addClass("button"); - $(".image_thumb img").load( function() { - $(this).fadeIn("slow"); - }); + $(".image_cycle img").load( function() { $(this).fadeIn("slow"); @@ -48,12 +39,7 @@ $(document).ready(function(){ });//end document ready -function reset_photo_fancybox(){ - album_id = $(".album_id")[0].id; - ajax = $.get("/photos/new?album_id=" + album_id, function(){ - $("#new_photo_pane").html(ajax.responseText) - }); -} + function pane_toggler_button( name ) {