From 4515ba631f4bd1498c8fad6f168a600e2c3f56e9 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 15 Dec 2010 19:25:35 -0500 Subject: [PATCH 1/3] some JS refactoring --- public/javascripts/aspect-contacts.js | 15 ++++---- public/javascripts/aspect-edit.js | 38 +++++++++++-------- public/javascripts/contact-list.js | 10 ++--- public/javascripts/custom-mobile-scripting.js | 4 +- public/javascripts/mobile.js | 8 ++-- public/javascripts/photo-show.js | 15 ++------ public/javascripts/rails.js | 24 ++++++------ 7 files changed, 58 insertions(+), 56 deletions(-) diff --git a/public/javascripts/aspect-contacts.js b/public/javascripts/aspect-contacts.js index 85ceffcc8..ee00bd67f 100644 --- a/public/javascripts/aspect-contacts.js +++ b/public/javascripts/aspect-contacts.js @@ -3,16 +3,15 @@ * the COPYRIGHT file. */ -$("#edit_aspect_trigger").live("click", - function(){ +$("#edit_aspect_trigger").live("click", function() { EditPane.toggle(); - } -); +}); var EditPane = { setTranslations: function(translations) { EditPane.translations = translations; }, + toggle: function() { if( $("#edit_aspect_pane").hasClass("active") ) { EditPane.fadeOut(); @@ -21,22 +20,22 @@ var EditPane = { } }, - fadeIn: function(){ + fadeIn: function() { var trigger = $("#edit_aspect_trigger"); $("#edit_aspect_pane").addClass("active"); - $(".contact_pictures").fadeOut(200, function(){ + $(".contact_pictures").fadeOut(200, function() { $("#edit_aspect_pane").fadeIn(200); trigger.html(EditPane.translations.doneEditing); }); }, - fadeOut: function(){ + fadeOut: function() { var trigger = $("#edit_aspect_trigger"); trigger.html(EditPane.translations.editAspect); $("#edit_aspect_pane").removeClass("active"); - $("#edit_aspect_pane").fadeOut(200, function(){ + $("#edit_aspect_pane").fadeOut(200, function() { $(".contact_pictures").fadeIn(200); }); } diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 3b21d95b1..46087146d 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -49,8 +49,13 @@ var AspectEdit = { $.ajax({ type: "DELETE", url: "/requests/" + person.attr('data-guid'), - data: {"accept" : true, "aspect_id" : dropzone.attr('data-aspect_id') }, - success: function() { AspectEdit.onDeleteRequestSuccess(person, dropzone); } + data: { + "accept": true, + "aspect_id": dropzone.attr('data-aspect_id') + }, + success: function() { + AspectEdit.onDeleteRequestSuccess(person, dropzone); + } }); } @@ -59,11 +64,15 @@ var AspectEdit = { $.ajax({ url: "/aspects/move_contact/", data: { - "person_id" : person.attr('data-guid'), - "from" : person.attr('data-aspect_id'), - "to" : { "to" : dropzone.attr('data-aspect_id') } + "person_id": person.attr('data-guid'), + "from": person.attr('data-aspect_id'), + "to": { + "to": dropzone.attr('data-aspect_id') + } }, - success: function() { AspectEdit.onMovePersonSuccess(person, dropzone); } + success: function() { + AspectEdit.onMovePersonSuccess(person, dropzone); + } }); } @@ -86,8 +95,7 @@ var AspectEdit = { if( $(".person[data-guid='"+ person_id +"']").length == 1) { AspectEdit.alertUser("You cannot remove the person from the last aspect"); - } - else { + } else { if (!person.hasClass('request')) { $.ajax({ @@ -118,7 +126,11 @@ var AspectEdit = { $.ajax({ type: "PUT", url: link, - data: {"aspect" : {"name" : $this.text() }} + data: { + "aspect": { + "name" : $this.text() + } + } }); } //update all other aspect links @@ -159,13 +171,9 @@ var AspectEdit = { var old_request_count = request_html.match(/\d+/); if (old_request_count == 1) { - $new_requests.html( - request_html.replace(/ \(\d+\)/, '') - ); + $new_requests.html( request_html.replace(/ \(\d+\)/, '') ); } else { - $new_requests.html( - request_html.replace(/\d+/, old_request_count - 1) - ); + $new_requests.html( request_html.replace(/\d+/, old_request_count - 1) ); } }, diff --git a/public/javascripts/contact-list.js b/public/javascripts/contact-list.js index 6f544ac05..4c5405380 100644 --- a/public/javascripts/contact-list.js +++ b/public/javascripts/contact-list.js @@ -4,10 +4,10 @@ */ -$(document).ready( function(){ +$(document).ready(function() { var List = { - initialize: function(){ - $(".contact_list_search").keyup(function(e){ + initialize: function() { + $(".contact_list_search").keyup(function(e) { var search = $(this); var list = $(this).siblings("ul").first(); var query = new RegExp(search.val(),'i'); @@ -65,10 +65,10 @@ $(document).ready( function(){ $(this).fadeTo(200,1); }); - $('.added').live('mouseover', function(){ + $('.added').live('mouseover', function() { $(this).addClass("remove"); $(this).children("img").attr("src","/images/icons/monotone_close_exit_delete.png"); - }).live('mouseout', function(){ + }).live('mouseout', function() { $(this).removeClass("remove"); $(this).children("img").attr("src","/images/icons/monotone_check_yes.png"); }); diff --git a/public/javascripts/custom-mobile-scripting.js b/public/javascripts/custom-mobile-scripting.js index 60d555ef9..1bd9eec42 100644 --- a/public/javascripts/custom-mobile-scripting.js +++ b/public/javascripts/custom-mobile-scripting.js @@ -3,8 +3,8 @@ * the COPYRIGHT file. */ -$(document).bind("mobileinit", function(){ - $.extend( $.mobile , { +$(document).bind("mobileinit", function() { + $.extend($.mobile, { ajaxLinksEnabled : false, ajaxFormsEnabled : false }); diff --git a/public/javascripts/mobile.js b/public/javascripts/mobile.js index 65e8de4d4..616b145c6 100644 --- a/public/javascripts/mobile.js +++ b/public/javascripts/mobile.js @@ -4,16 +4,16 @@ */ var Mobile = { - initialize : function(){ + initialize: function() { $('#aspect_picker').change(Mobile.changeAspect); }, - changeAspect : function() { + changeAspect: function() { Mobile.windowLocation('/aspects/' + $('#aspect_picker option:selected').val()); }, - windowLocation : function(url) { + windowLocation: function(url) { window.location = url; - }, + } }; diff --git a/public/javascripts/photo-show.js b/public/javascripts/photo-show.js index 55df7d9d1..66611bb5d 100644 --- a/public/javascripts/photo-show.js +++ b/public/javascripts/photo-show.js @@ -3,7 +3,7 @@ * the COPYRIGHT file. */ -$(document).ready( function(){ +$(document).ready(function() { //edit photo $("#edit_photo_toggle").bind('click', function(evt) { @@ -36,26 +36,19 @@ $(document).ready( function(){ $('.make_profile_photo').bind('ajax:loading', function(data, json, xhr) { var person_id = $(this).closest(".photo_options").attr('data-actor_person'); - $("img[data-person_id='"+ person_id +"']").each( function() { - $(this).fadeTo(200,0.3); - }); + $("img[data-person_id='" + person_id + "']").fadeTo(200, 0.3); }); $('.make_profile_photo').bind('ajax:success', function(data, json, xhr) { json = $.parseJSON(json); - $("img[data-person_id='"+ json['person_id'] +"']").each( function() { - $(this).fadeTo(200,1); - this.src = json['image_url_small']; - }); + $("img[data-person_id='" + json['person_id'] + "']").fadeTo(200, 1).attr('src', json.image_url_small); }); $('.make_profile_photo').bind('ajax:failure', function(data, json, xhr) { var person_id = $(this).closest(".photo_options").attr('data-actor_person'); alert("Failed to update profile photo!"); - $("img[data-person_id='"+ person_id +"']").each( function() { - $(this).fadeTo(200,1); - }); + $("img[data-person_id='" + person_id + "']").fadeTo(200, 1); }); }); diff --git a/public/javascripts/rails.js b/public/javascripts/rails.js index 99e20ea8e..8fbc9ca87 100644 --- a/public/javascripts/rails.js +++ b/public/javascripts/rails.js @@ -1,17 +1,19 @@ /* Clear form plugin - called using $("elem").clearForm(); */ $.fn.clearForm = function() { return this.each(function() { - var type = this.type, tag = this.tagName.toLowerCase(); - if (tag == 'form') - return $(':input',this).clearForm(); - if (type == 'text' || type == 'password' || tag == 'textarea') - this.value = ''; - else if (type == 'checkbox' || type == 'radio') - this.checked = false; - else if (tag == 'select') - this.selectedIndex = -1; - else if (this.name == 'photos[]') - this.value = ''; + var type = this.type, tag = this.tagName.toLowerCase(); + if (tag == 'form') { + return $(':input',this).clearForm(); + } + if (type == 'text' || type == 'password' || tag == 'textarea') { + this.value = ''; + } else if (type == 'checkbox' || type == 'radio') { + this.checked = false; + } else if (tag == 'select') { + this.selectedIndex = -1; + } else if (this.name == 'photos[]') { + this.value = ''; + } $(this).blur(); }); }; From 77c102cce650185b05fba8bdc415c8dd0d651073 Mon Sep 17 00:00:00 2001 From: lfortin Date: Thu, 16 Dec 2010 23:46:28 -0500 Subject: [PATCH 2/3] more JS formatting --- public/javascripts/photo-show.js | 4 +- public/javascripts/rails.js | 22 +++--- public/javascripts/stream.js | 12 ++-- public/javascripts/validation.js | 4 +- public/javascripts/view.js | 2 +- public/javascripts/web-socket-receiver.js | 84 +++++++++++++---------- 6 files changed, 70 insertions(+), 58 deletions(-) diff --git a/public/javascripts/photo-show.js b/public/javascripts/photo-show.js index 66611bb5d..f076b8907 100644 --- a/public/javascripts/photo-show.js +++ b/public/javascripts/photo-show.js @@ -27,7 +27,7 @@ $(document).ready(function() { $('.edit_photo').bind('ajax:success', function(data, json, xhr) { json = $.parseJSON(json); $(".edit_photo input[type='text']").val(json['photo']['caption']); - $("#caption").html(json['photo']['caption']); + $("#caption").html(json.photo.caption); $("#show_photo").find("img").fadeTo(200,1); $("#photo_spinner").hide(); }); @@ -42,7 +42,7 @@ $(document).ready(function() { $('.make_profile_photo').bind('ajax:success', function(data, json, xhr) { json = $.parseJSON(json); - $("img[data-person_id='" + json['person_id'] + "']").fadeTo(200, 1).attr('src', json.image_url_small); + $("img[data-person_id='" + json.person_id + "']").fadeTo(200, 1).attr('src', json.image_url_small); }); $('.make_profile_photo').bind('ajax:failure', function(data, json, xhr) { diff --git a/public/javascripts/rails.js b/public/javascripts/rails.js index 8fbc9ca87..443173f16 100644 --- a/public/javascripts/rails.js +++ b/public/javascripts/rails.js @@ -2,19 +2,19 @@ $.fn.clearForm = function() { return this.each(function() { var type = this.type, tag = this.tagName.toLowerCase(); - if (tag == 'form') { - return $(':input',this).clearForm(); + if ($(this).is('form')) { + return $(':input', this).clearForm(); } - if (type == 'text' || type == 'password' || tag == 'textarea') { - this.value = ''; - } else if (type == 'checkbox' || type == 'radio') { - this.checked = false; - } else if (tag == 'select') { + if ($(this).is(':text') || $(this).is(':password') || $(this).is('textarea')) { + $(this).val(''); + } else if ($(this).is(':checkbox') || $(this).is(':radio')) { + $(this).attr('checked', false); + } else if ($(this).is('select')) { this.selectedIndex = -1; - } else if (this.name == 'photos[]') { - this.value = ''; + } else if ($(this).attr('name') == 'photos[]') { + $(this).val(''); } - $(this).blur(); + $(this).blur(); }); }; @@ -108,7 +108,7 @@ jQuery(function ($) { e.preventDefault(); }); - $('a[data-method]:not([data-remote])').live('click', function (e){ + $('a[data-method]:not([data-remote])').live('click', function (e) { var link = $(this), href = link.attr('href'), method = link.attr('data-method'), diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js index 8d0aa62a7..4e19a4168 100644 --- a/public/javascripts/stream.js +++ b/public/javascripts/stream.js @@ -11,7 +11,7 @@ var Stream = { $stream.not(".show").delegate("a.show_post_comments", "click", Stream.toggleComments); // publisher textarea reset - $publisher.find("textarea").bind("blur", function(){ + $publisher.find("textarea").bind("blur", function() { $(this).css('height','42px'); }); @@ -20,7 +20,7 @@ var Stream = { $(this).closest("form").children(".comment_box").attr("rows", 1); }); - $stream.delegate("textarea.comment_box", "keydown", function(e){ + $stream.delegate("textarea.comment_box", "keydown", function(e) { if (e.shiftKey && e.keyCode === 13) { $(this).closest("form").submit(); } @@ -62,7 +62,7 @@ var Stream = { $videoContainer = $this.parent().siblings("div.video-container"); if ($videoContainer.length > 0) { - $videoContainer.slideUp('fast', function () { + $videoContainer.slideUp('fast', function() { $videoContainer.detach(); }); return; @@ -96,7 +96,7 @@ var Stream = { $(".new_status_message").bind('ajax:success', function(data, json, xhr) { json = $.parseJSON(json); - WebSocketReceiver.addPostToStream(json['post_id'], json['html']); + WebSocketReceiver.addPostToStream(json.post_id, json.html); }); $(".new_status_message").bind('ajax:failure', function(data, html, xhr) { alert('failed to post message!'); @@ -104,7 +104,7 @@ var Stream = { $(".new_comment").live('ajax:success', function(data, json, xhr) { json = $.parseJSON(json); - WebSocketReceiver.processComment(json['post_id'], json['comment_id'], json['html'], false); + WebSocketReceiver.processComment(json.post_id, json.comment_id, json.html, false); }); $(".new_comment").live('ajax:failure', function(data, html, xhr) { alert('failed to post message!'); @@ -126,7 +126,7 @@ var Stream = { if( commentBlockMore.hasClass("inactive") ) { - commentBlockMore.fadeIn(150, function(){ + commentBlockMore.fadeIn(150, function() { commentBlockMore.removeClass("inactive"); commentBlockMore.removeClass("hidden"); }); diff --git a/public/javascripts/validation.js b/public/javascripts/validation.js index 923fb7fce..097edb334 100644 --- a/public/javascripts/validation.js +++ b/public/javascripts/validation.js @@ -14,7 +14,9 @@ var Validation = { }, events: { usernameKeypress: function(evt) { - if(evt.keyCode === 0) { return; } + if(evt.keyCode === 0) { + return; + } if(!Validation.rules.username.characters.test(this.value + String.fromCharCode(evt.keyCode))) { evt.preventDefault(); } diff --git a/public/javascripts/view.js b/public/javascripts/view.js index b21d589a5..94ff6e224 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -49,7 +49,7 @@ var View = { $(this.fancyBoxButtons.selectors.join(", ")) .fancybox({ 'titleShow': false, - 'hideOnOverlayClick' : false + 'hideOnOverlayClick': false }); /* Autoexpand textareas */ diff --git a/public/javascripts/web-socket-receiver.js b/public/javascripts/web-socket-receiver.js index d0d74dd38..46d9da6c1 100644 --- a/public/javascripts/web-socket-receiver.js +++ b/public/javascripts/web-socket-receiver.js @@ -13,39 +13,43 @@ var WebSocketReceiver = { onMessage: function(evt) { var obj = jQuery.parseJSON(evt.data); - if(obj['notice']){ - WebSocketReceiver.processNotification(obj['notice']); + if(obj.notice) { + WebSocketReceiver.processNotification(obj.notice); - }else if (obj['class'] == 'people'){ + } else if (obj['class'] == 'people') { WSR.debug("got a " + obj['class']); WebSocketReceiver.processPerson(obj); - }else{ - WSR.debug("got a " + obj['class'] + " for aspects " + obj['aspect_ids']); + } else { + WSR.debug("got a " + obj['class'] + " for aspects " + obj.aspect_ids); - if (obj['class']=="retractions"){ - WebSocketReceiver.processRetraction(obj['post_id']); + if (obj['class']=="retractions") { + WebSocketReceiver.processRetraction(obj.post_id); - }else if (obj['class']=="comments"){ - WebSocketReceiver.processComment(obj['post_id'], obj['comment_id'], obj['html'], {'notification':obj['notification'], 'mine?':obj['mine?'], 'my_post?':obj['my_post?']}) + } else if (obj['class']=="comments") { + WebSocketReceiver.processComment(obj.post_id, obj.comment_id, obj.html, { + 'notification': obj.notification, + 'mine?': obj['mine?'], + 'my_post?': obj['my_post?'] + }); - }else{ - WebSocketReceiver.processPost(obj['class'], obj['post_id'], obj['html'], obj['aspect_ids']) + } else { + WebSocketReceiver.processPost(obj['class'], obj.post_id, obj.html, obj.aspect_ids); } } }, -processPerson: function(response){ + processPerson: function(response) { form = $('.webfinger_form'); form.siblings('#loader').hide(); result_ul = form.siblings('#request_result'); - if(response['status'] == 'fail'){ + if(response.status == 'fail') { result_ul.siblings('.error').show(); - result_ul.find('.error').text(response['response']).show(); - }else{ - $('#people_stream').prepend(response['html']).slideDown('slow', function(){}); + result_ul.find('.error').text(response.response).show(); + } else { + $('#people_stream').prepend(response.html).slideDown('slow', function(){}); var first_li = result_ul.find('li:first'); first_li.hide() - first_li.after(response['html']); + first_li.after(response.html); result_ul.find("[name='request[into]']").val(result_ul.attr('aspect_id')); result_ul.children(':nth-child(2)').slideDown('fast', function(){}); } @@ -57,15 +61,17 @@ processPerson: function(response){ }, processRetraction: function(post_id){ - $("*[data-guid='"+post_id+"']").fadeOut(400, function(){$(this).remove()}); - if($("#main_stream")[0].childElementCount == 0){ + $("*[data-guid='" + post_id + "']").fadeOut(400, function() { + $(this).remove(); + }); + if($("#main_stream")[0].childElementCount == 0) { $("#no_posts").fadeIn(200); } }, - processComment: function(postId, commentId, html, opts){ + processComment: function(postId, commentId, html, opts) { - if( $(".comment[data-guid='"+commentId+"']").length == 0 ){ + if( $(".comment[data-guid='"+commentId+"']").length == 0 ) { post = $("*[data-guid='"+postId+"']'"); $('.comments li:last', post ).before( @@ -78,33 +84,34 @@ processPerson: function(response){ toggler.html().replace(/\d+/,$('.comments', post).find('li').length -1) ); - if( !$(".comments", post).is(':visible') ){ + if( !$(".comments", post).is(':visible') ) { toggler.click(); } } if( !opts['mine?'] && opts['my_post?']) { - WebSocketReceiver.processNotification(opts['notification']); + WebSocketReceiver.processNotification(opts.notification); } } }, - processPost: function(className, postId, html, aspectIds){ - if(WebSocketReceiver.onPageForAspects(aspectIds)){ + processPost: function(className, postId, html, aspectIds) { + if(WebSocketReceiver.onPageForAspects(aspectIds)) { WebSocketReceiver.addPostToStream(postId, html); } }, - addPostToStream: function(postId, html){ - if( $(".message[data-guid='"+postId+"']").length == 0 ){ - var showMessage = function(){ $("#main_stream:not('.show')").prepend( - $(html).fadeIn("fast", function(){ + addPostToStream: function(postId, html) { + if( $(".message[data-guid='" + postId + "']").length == 0 ) { + var showMessage = function() { + $("#main_stream:not('.show')").prepend( + $(html).fadeIn("fast", function() { $("#main_stream").find("label").first().inFieldLabels(); }) ); }; - if( $("#no_posts").is(":visible") ){ + if( $("#no_posts").is(":visible") ) { $("#no_posts").fadeOut(400, showMessage()).hide(); } else { showMessage(); @@ -112,22 +119,24 @@ processPerson: function(response){ } }, - onPageForClass: function(className){ + onPageForClass: function(className) { return (location.href.indexOf(className) != -1 ); }, - onPageForAspects: function(aspectIds){ - if(location.pathname == '/aspects' && WebSocketReceiver.onPageOne()){ + onPageForAspects: function(aspectIds) { + if(location.pathname == '/aspects' && WebSocketReceiver.onPageOne()) { return true } var found = false; $.each(aspectIds, function(index, value) { - if(WebSocketReceiver.onPageForAspect(value)){ found = true }; + if(WebSocketReceiver.onPageForAspect(value)) { + found = true; + }; }); return found; }, - onPageForAspect: function(aspectId){ + onPageForAspect: function(aspectId) { return (location.href.indexOf(aspectId) != -1 ) }, @@ -135,8 +144,9 @@ processPerson: function(response){ var c = document.location.search.charAt(document.location.search.length-1); return ((c =='') || (c== '1')); }, - debug: function(str){ + debug: function(str) { $("#debug").append("

" + str); } }; -var WSR = WebSocketReceiver +var WSR = WebSocketReceiver; + From 0393ac5a6f05ff86f4bebd3ddec06b20e9402ff5 Mon Sep 17 00:00:00 2001 From: lfortin Date: Sun, 19 Dec 2010 00:15:00 -0500 Subject: [PATCH 3/3] more JS formatting --- public/javascripts/aspect-edit.js | 7 ++++--- public/javascripts/contact-list.js | 8 ++++---- public/javascripts/custom-mobile-scripting.js | 4 ++-- public/javascripts/photo-show.js | 2 +- public/javascripts/rails.js | 1 - public/javascripts/validation.js | 4 +++- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 46087146d..5481e1fec 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -101,9 +101,10 @@ var AspectEdit = { $.ajax({ type: "POST", url: "/aspects/remove_from_aspect", - data:{ - 'person_id' : person_id, - 'aspect_id' : person.attr('data-aspect_id') } + data: { + 'person_id': person_id, + 'aspect_id': person.attr('data-aspect_id') + } }); } person.fadeOut(400, function() { diff --git a/public/javascripts/contact-list.js b/public/javascripts/contact-list.js index 4c5405380..18bbc1360 100644 --- a/public/javascripts/contact-list.js +++ b/public/javascripts/contact-list.js @@ -14,8 +14,8 @@ $(document).ready(function() { $("li", list).each( function() { var element = $(this); - if( !element.text().match(query) ){ - if( !element.hasClass('invis') ){ + if( !element.text().match(query) ) { + if( !element.hasClass('invis') ) { element.addClass('invis').fadeOut(100); } } else { @@ -40,8 +40,8 @@ $(document).ready(function() { } } - $(".aspect_badge[guid='"+json['aspect_id']+"']", ".aspects").remove(); - $(this).parent().html(json['button_html']); + $(".aspect_badge[guid='" + json.aspect_id + "']", ".aspects").remove(); + $(this).parent().html(json.button_html); $(this).fadeTo(200,1); }); diff --git a/public/javascripts/custom-mobile-scripting.js b/public/javascripts/custom-mobile-scripting.js index 1bd9eec42..1ee6cbcf9 100644 --- a/public/javascripts/custom-mobile-scripting.js +++ b/public/javascripts/custom-mobile-scripting.js @@ -5,7 +5,7 @@ $(document).bind("mobileinit", function() { $.extend($.mobile, { - ajaxLinksEnabled : false, - ajaxFormsEnabled : false + ajaxLinksEnabled: false, + ajaxFormsEnabled: false }); }); diff --git a/public/javascripts/photo-show.js b/public/javascripts/photo-show.js index f076b8907..084ba6560 100644 --- a/public/javascripts/photo-show.js +++ b/public/javascripts/photo-show.js @@ -26,7 +26,7 @@ $(document).ready(function() { $('.edit_photo').bind('ajax:success', function(data, json, xhr) { json = $.parseJSON(json); - $(".edit_photo input[type='text']").val(json['photo']['caption']); + $(".edit_photo input[type='text']").val(json.photo.caption); $("#caption").html(json.photo.caption); $("#show_photo").find("img").fadeTo(200,1); $("#photo_spinner").hide(); diff --git a/public/javascripts/rails.js b/public/javascripts/rails.js index 443173f16..247c3ca60 100644 --- a/public/javascripts/rails.js +++ b/public/javascripts/rails.js @@ -1,7 +1,6 @@ /* Clear form plugin - called using $("elem").clearForm(); */ $.fn.clearForm = function() { return this.each(function() { - var type = this.type, tag = this.tagName.toLowerCase(); if ($(this).is('form')) { return $(':input', this).clearForm(); } diff --git a/public/javascripts/validation.js b/public/javascripts/validation.js index 097edb334..e932e49db 100644 --- a/public/javascripts/validation.js +++ b/public/javascripts/validation.js @@ -22,7 +22,9 @@ var Validation = { } }, emailKeypress: function(evt) { - if(evt.keyCode === 0) { return; } + if(evt.keyCode === 0) { + return; + } if(!Validation.rules.email.characters.test(this.value + String.fromCharCode(evt.keyCode))) { $('#user_email').css('border-color', '#8B0000'); } else {