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 123a74d34..5aa791b3c 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); + } }); } @@ -85,16 +94,16 @@ 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({ 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() { @@ -117,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 diff --git a/public/javascripts/contact-list.js b/public/javascripts/contact-list.js index 6f544ac05..18bbc1360 100644 --- a/public/javascripts/contact-list.js +++ b/public/javascripts/contact-list.js @@ -4,18 +4,18 @@ */ -$(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'); $("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); }); @@ -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..1ee6cbcf9 100644 --- a/public/javascripts/custom-mobile-scripting.js +++ b/public/javascripts/custom-mobile-scripting.js @@ -3,9 +3,9 @@ * the COPYRIGHT file. */ -$(document).bind("mobileinit", function(){ - $.extend( $.mobile , { - ajaxLinksEnabled : false, - ajaxFormsEnabled : false +$(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 1e348c849..1c2541278 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) { @@ -26,8 +26,8 @@ $(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']); + $(".edit_photo input[type='text']").val(json.photo.caption); + $("#caption").html(json.photo.caption); $("#show_photo").find("img").fadeTo(200,1); $("#photo_spinner").hide(); }); @@ -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); }); // right/left hotkeys diff --git a/public/javascripts/rails.js b/public/javascripts/rails.js index 99e20ea8e..247c3ca60 100644 --- a/public/javascripts/rails.js +++ b/public/javascripts/rails.js @@ -1,18 +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 = ''; - $(this).blur(); + if ($(this).is('form')) { + return $(':input', this).clearForm(); + } + 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).attr('name') == 'photos[]') { + $(this).val(''); + } + $(this).blur(); }); }; @@ -106,7 +107,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 9cfe749d7..4900ad799 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'); }); @@ -68,7 +68,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; @@ -112,7 +112,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); //collapse publisher $("#publisher").addClass("closed"); $("#photodropzone").find('li').remove(); @@ -124,7 +124,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!'); @@ -146,7 +146,7 @@ var Stream = { show = (text.indexOf("show") != -1); 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..e932e49db 100644 --- a/public/javascripts/validation.js +++ b/public/javascripts/validation.js @@ -14,13 +14,17 @@ 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(); } }, 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 { diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 9c45e737c..a2f1b3b2d 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 a6bd2554e..d1af18fff 100644 --- a/public/javascripts/web-socket-receiver.js +++ b/public/javascripts/web-socket-receiver.js @@ -13,40 +13,43 @@ var WebSocketReceiver = { onMessage: function(evt) { var obj = jQuery.parseJSON(evt.data); - if(obj['class'] == 'notifications'){ + if(obj['class'] == 'notifications') { WebSocketReceiver.processNotification(obj); - - }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(){}); } @@ -73,15 +76,17 @@ var WebSocketReceiver = { }, 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( @@ -94,7 +99,7 @@ var WebSocketReceiver = { toggler.html().replace(/\d+/,$('.comments', post).find('li').length -1) ); - if( !$(".comments", post).is(':visible') ){ + if( !$(".comments", post).is(':visible') ) { toggler.click(); } @@ -105,22 +110,23 @@ var WebSocketReceiver = { } }, - 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(); @@ -128,22 +134,24 @@ var WebSocketReceiver = { } }, - 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 ) }, @@ -151,8 +159,9 @@ var WebSocketReceiver = { var c = document.location.search.charAt(document.location.search.length-1); return ((c =='') || (c== '1')); }, - debug: function(str){ - $("#debug").append("
" + str); + debug: function(str) { + $("#debug").append("
" + str); } }; -var WSR = WebSocketReceiver +var WSR = WebSocketReceiver; +