From 17636f4fd26c9745806bc1bb39f810172bf5a6f6 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 25 Aug 2010 13:51:16 -0700 Subject: [PATCH] View modifications, refactored stream javascript to another file --- app/views/layouts/application.html.haml | 2 +- public/javascripts/stream.js | 48 ++++++++++++++++++++++ public/javascripts/view.js | 52 +----------------------- public/stylesheets/application.css | 8 +++- public/stylesheets/sass/application.sass | 12 +++++- 5 files changed, 67 insertions(+), 55 deletions(-) create mode 100644 public/javascripts/stream.js diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 9d4fe4b37..240805716 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -17,7 +17,7 @@ = javascript_include_tag 'fancybox/jquery.fancybox-1.3.1.pack' - = javascript_include_tag 'view', 'image_picker', 'group_nav' + = javascript_include_tag 'view', 'image_picker', 'group_nav', 'stream' = render 'js/websocket_js' = csrf_meta_tag diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js new file mode 100644 index 000000000..7eeb2ed5a --- /dev/null +++ b/public/javascripts/stream.js @@ -0,0 +1,48 @@ +$(document).ready(function(){ + $('.comment_set').each(function(index) { + var $this = $(this); + if($this.children().length > 1) { + $this.parent().show(); + var show_comments_toggle = $(this).parent().prev().children(".show_post_comments"); + show_comments_toggle.html("hide comments ("+ ($(this).children().length - 1) + ")"); + }; + }); + + $("#stream li").live('mouseover',function() { + $(this).children(".destroy_link").fadeIn(0); + }); + + $("#stream li").live('mouseout',function() { + $(this).children(".destroy_link").fadeOut(0); + }); + + $(".show_post_comments").live('click', function(event) { + event.preventDefault(); + if( $(this).hasClass( "visible")) { + $(this).html($(this).html().replace("hide", "show")); + $(this).closest("li").children(".content").children(".comments").fadeOut(100); + } else { + $(this).html($(this).html().replace("show", "hide")); + $(this).closest("li").children(".content").children(".comments").fadeIn(100); + } + $(this).toggleClass( "visible" ); + }); + + $(".comment_box").live('focus', function(evt){ + var $this = $(this); + $this.attr("rows", 2); + $this.parents("p").parents("form").children("p").children(".comment_submit").fadeIn(200); + }); + + $(".comment_box").live('blur', function(evt){ + var $this = $(this); + if( $this.val() == '' ) { + $this.parents("p").parents("form").children("p").children(".comment_submit").fadeOut(0); + $this.attr("rows", 1); + } + }); + + $(".comment_submit").live('click', function(evt){ + $this.parents("p").parents("form").children("p").children(".comment_box").attr("rows", 1); + }); +});//end document ready diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 5f70b8f4b..62888422a 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -1,12 +1,5 @@ $(document).ready(function(){ - $('.comment_set').each(function(index) { - if($(this).children().length > 1) { - $(this).parent().show(); - var show_comments_toggle = $(this).parent().prev().children(".show_post_comments"); - show_comments_toggle.html("hide comments ("+ ($(this).children().length - 1) + ")"); - }; - }); $('#debug_info').click(function() { $('#debug_more').toggle('fast', function() { @@ -18,26 +11,6 @@ $(document).ready(function(){ $('#flash_notice, #flash_error, #flash_alert').delay(2500).slideUp(130); - $("#stream li").live('mouseover',function() { - $(this).children(".destroy_link").fadeIn(0); - }); - - $("#stream li").live('mouseout',function() { - $(this).children(".destroy_link").fadeOut(0); - }); - - $(".show_post_comments").live('click', function(event) { - event.preventDefault(); - if( $(this).hasClass( "visible")) { - $(this).html($(this).html().replace("hide", "show")); - $(this).closest("li").children(".content").children(".comments").fadeOut(100); - } else { - $(this).html($(this).html().replace("show", "hide")); - $(this).closest("li").children(".content").children(".comments").fadeIn(100); - } - $(this).toggleClass( "visible" ); - }); - //Called with $(selector).clearForm() $.fn.clearForm = function() { return this.each(function() { @@ -61,27 +34,6 @@ $(document).ready(function(){ speed: 3000 }); - - //comments///// - - $(".comment_box").live('focus', function(evt){ - var $this = $(this); - $this.attr("rows", 2); - $this.parents("p").parents("form").children("p").children(".comment_submit").fadeIn(200); - }); - - $(".comment_box").live('blur', function(evt){ - var $this = $(this); - if( $this.val() == '' ) { - $this.parents("p").parents("form").children("p").children(".comment_submit").fadeOut(0); - $this.attr("rows", 1); - } - }); - - $(".comment_submit").live('click', function(evt){ - $this.parents("p").parents("form").children("p").children(".comment_box").attr("rows", 1); - }); - //buttons////// @@ -109,9 +61,7 @@ $(document).ready(function(){ $(this).fadeIn("slow"); }); - $(".delete").hover(function(){ - $(this).toggleClass("button"); - }); + });//end document ready diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 1578b5950..18c040055 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -138,6 +138,8 @@ li.message { li.message .avatar { float: left; margin-right: 15px; } + li.message .delete:hover { + background: #eeeeee; } li.message .content span.from { color: black; font-weight: normal; @@ -465,6 +467,8 @@ h1.big_text { padding-right: 0.3em; } #group_nav ul > li:hover { background-color: #333333; } + #group_nav ul > li:hover a { + color: #999999; } #group_nav ul > li a { color: #999999; } #group_nav ul > li a:hover { @@ -472,12 +476,14 @@ h1.big_text { #group_nav ul .⚙ { margin-left: 4px; } #group_nav ul .⚙ a { - color: #333333; } + color: black; } #group_nav ul .selected { background-color: white; color: black; } #group_nav ul .selected:hover { background-color: #eeeeee; } + #group_nav ul .selected .⚙ a { + color: #333333; } #add_photo_loader { position: absolute; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 2b6216eba..6c5c0c117 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -160,7 +160,9 @@ li.message :margin :right 15px - + .delete:hover + :background #eee + .content span.from :color #000 @@ -591,6 +593,9 @@ h1.big_text &:hover :background :color #333 + a + :color #999 + a :color #999 @@ -601,7 +606,7 @@ h1.big_text :margin :left 4px a - :color #333 + :color #000 .selected :background @@ -610,6 +615,9 @@ h1.big_text &:hover :background :color #eee + .⚙ + a + :color #333 #add_photo_loader