From 8b0d20dec749c2931484260ae3354ee05bf25e05 Mon Sep 17 00:00:00 2001 From: OhaiBBQ Date: Mon, 1 Nov 2010 14:45:51 -0700 Subject: [PATCH] Small optimizations --- public/javascripts/image_picker.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/public/javascripts/image_picker.js b/public/javascripts/image_picker.js index 2692ffee9..eacf7822d 100644 --- a/public/javascripts/image_picker.js +++ b/public/javascripts/image_picker.js @@ -2,16 +2,15 @@ * licensed under the Affero General Public License version 3 or later. See * the COPYRIGHT file. */ - - -$(document).ready( function() { +$(document).ready(function() { $('div#image_picker div.small_photo').click( function() { - $('#image_url_field').val($(this).attr('id')); + var $this = $(this); + document.getElementById("image_url_field").value = this.id; - $('div#image_picker div.small_photo').removeClass('selected'); - $("div#image_picker div.small_photo input[type='checkbox']").attr("checked", false); + $('div#image_picker div.small_photo.selected').removeClass('selected') + .children("input[type='checkbox']").attr("checked", false); - $(this).addClass('selected'); - $(this).children("input[type='checkbox']").attr("checked", true); + $this.addClass('selected') + .children("input[type='checkbox']").attr("checked", true); }); });