From 077d8fd2fef6a9ac2fe8cd7a79dafa267ffe5fcc Mon Sep 17 00:00:00 2001 From: Andrej Kacian Date: Thu, 4 Aug 2011 21:23:57 +0200 Subject: [PATCH 1/5] Fixes #1587 by changing globe icon tooltip when switching between public and limited post in publisher. --- app/views/shared/_publisher.html.haml | 2 +- config/locales/diaspora/en.yml | 1 - config/locales/javascript/javascript.en.yml | 2 ++ public/javascripts/publisher.js | 10 +++++++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/views/shared/_publisher.html.haml b/app/views/shared/_publisher.html.haml index da22fe96b..d899c3d02 100644 --- a/app/views/shared/_publisher.html.haml +++ b/app/views/shared/_publisher.html.haml @@ -40,7 +40,7 @@ = t("shared.publisher.click_to_share_with") - if aspect == :all || aspect == :profile = status.hidden_field(:public) - = image_tag "icons/globe.png", :title => t('.public'), :class => 'public_icon dim', :width => 16, :height => 16 + = image_tag "icons/globe.png", :title => t('javascripts.publisher.limited'), :class => 'public_icon dim', :width => 16, :height => 16 - if current_user.services - for service in current_user.services = image_tag "social_media_logos/#{service.provider}-16x16.png", :title => service.provider.titleize, :class => "service_icon dim", :id =>"#{service.provider}", :maxchar => "#{service.class::MAX_CHARACTERS}" diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index e46ecb82a..9060cff59 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -662,7 +662,6 @@ en: share_with: "share with" whats_on_your_mind: "What's on your mind?" publishing_to: "publishing to: " - public: "Public" click_to_share_with: "Click to share with: " discard_post: "Discard post" add_contact: diff --git a/config/locales/javascript/javascript.en.yml b/config/locales/javascript/javascript.en.yml index ac4ac2ff4..f32bb50f7 100644 --- a/config/locales/javascript/javascript.en.yml +++ b/config/locales/javascript/javascript.en.yml @@ -29,6 +29,8 @@ en: search_for: "Search for {{name}}" publisher: at_least_one_aspect: "You must publish to at least one aspect" + limited: "Limited - your post will only be seen by people you are sharing with" + public: "Public - your post will be visible to everyone and found by search engines" infinite_scroll: no_more: "No more posts." web_sockets: diff --git a/public/javascripts/publisher.js b/public/javascripts/publisher.js index e86e6aea5..6f60543b6 100644 --- a/public/javascripts/publisher.js +++ b/public/javascripts/publisher.js @@ -291,7 +291,15 @@ var Publisher = { $(this).toggleClass("dim"); var public_field= $("#publisher #status_message_public"); - (public_field.val() == 'false') ? (public_field.val('true')) : (public_field.val('false')); + if (public_field.val() == 'false') { + public_field.val('true'); + $(this).attr('title', Diaspora.widgets.i18n.t('publisher.public')); + } else { + public_field.val('false'); + $(this).attr('title', Diaspora.widgets.i18n.t('publisher.limited')); + } + + $(this).mouseover(); }); }, toggleServiceField: function(service){ From 2716316dac12fbca21265f380a764e4be3dfa287 Mon Sep 17 00:00:00 2001 From: Andrej Kacian Date: Thu, 4 Aug 2011 21:35:42 +0200 Subject: [PATCH 2/5] Add jasmine test for #1587 fix. --- spec/javascripts/publisher-spec.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/javascripts/publisher-spec.js b/spec/javascripts/publisher-spec.js index 80a4042cd..e87cc0a87 100644 --- a/spec/javascripts/publisher-spec.js +++ b/spec/javascripts/publisher-spec.js @@ -131,8 +131,13 @@ describe("Publisher", function() { $(".public_icon").click(); expect($('#publisher #status_message_public').val()).toBe('true'); - - + }); + it('toggles the tooltip on the clicked icon', function(){ + Publisher.bindPublicIcon(); + $(".public_icon").click(); + expect($(".public_icon")).toHaveAttr('title', Diaspora.widgets.i18n.t('javascripts.publisher.limited')); + $(".public_icon").click(); + expect($(".public_icon")).toHaveAttr('title', Diaspora.widgets.i18n.t('javascripts.publisher.public')); }); }); describe("bindServiceIcons", function() { From 6cf42fb8ba5a340bfb3459c69a66bf3412b7e856 Mon Sep 17 00:00:00 2001 From: Andrej Kacian Date: Sat, 6 Aug 2011 22:48:49 +0200 Subject: [PATCH 3/5] Better stab at the jasmine test. --- public/javascripts/publisher.js | 2 +- spec/javascripts/publisher-spec.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/public/javascripts/publisher.js b/public/javascripts/publisher.js index 6f60543b6..ef5449194 100644 --- a/public/javascripts/publisher.js +++ b/public/javascripts/publisher.js @@ -289,7 +289,7 @@ var Publisher = { bindPublicIcon: function(){ $(".public_icon").bind("click", function(evt){ $(this).toggleClass("dim"); - var public_field= $("#publisher #status_message_public"); + var public_field = $("#publisher #status_message_public"); if (public_field.val() == 'false') { public_field.val('true'); diff --git a/spec/javascripts/publisher-spec.js b/spec/javascripts/publisher-spec.js index e87cc0a87..8498f94d5 100644 --- a/spec/javascripts/publisher-spec.js +++ b/spec/javascripts/publisher-spec.js @@ -110,6 +110,9 @@ describe("Publisher", function() { describe("bindPublicIcon", function() { beforeEach( function(){ spec.loadFixture('aspects_index_services'); + Diaspora.widgets.i18n.loadLocale( + { 'publisher' : + { 'public' : 'is public', 'limited' : 'is limited' } }, 'en'); }); it('gets called on initialize', function(){ @@ -134,10 +137,12 @@ describe("Publisher", function() { }); it('toggles the tooltip on the clicked icon', function(){ Publisher.bindPublicIcon(); + expect($(".public_icon")).toHaveAttr('title', 'is public'); + $(".public_icon").click(); - expect($(".public_icon")).toHaveAttr('title', Diaspora.widgets.i18n.t('javascripts.publisher.limited')); + expect($(".public_icon")).toHaveAttr('title', 'is limited'); $(".public_icon").click(); - expect($(".public_icon")).toHaveAttr('title', Diaspora.widgets.i18n.t('javascripts.publisher.public')); + expect($(".public_icon")).toHaveAttr('title', 'is public'); }); }); describe("bindServiceIcons", function() { From 4efff1cd7748e10edf409b00380f0b3121605531 Mon Sep 17 00:00:00 2001 From: Andrej Kacian Date: Sun, 7 Aug 2011 00:44:02 +0200 Subject: [PATCH 4/5] Use Tipsy functions to update the onscreen tooltip instead of mouseover() --- public/javascripts/publisher.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/javascripts/publisher.js b/public/javascripts/publisher.js index ef5449194..77950f6e2 100644 --- a/public/javascripts/publisher.js +++ b/public/javascripts/publisher.js @@ -299,7 +299,8 @@ var Publisher = { $(this).attr('title', Diaspora.widgets.i18n.t('publisher.limited')); } - $(this).mouseover(); + $(this).tipsy(true).fixTitle(); + $(this).tipsy(true).show(); }); }, toggleServiceField: function(service){ From e5b6850556a088908eaa8163f02eabfd96aba18d Mon Sep 17 00:00:00 2001 From: Andrej Kacian Date: Sun, 7 Aug 2011 00:44:37 +0200 Subject: [PATCH 5/5] Fix the test --- spec/javascripts/publisher-spec.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/javascripts/publisher-spec.js b/spec/javascripts/publisher-spec.js index 8498f94d5..56894f794 100644 --- a/spec/javascripts/publisher-spec.js +++ b/spec/javascripts/publisher-spec.js @@ -137,12 +137,10 @@ describe("Publisher", function() { }); it('toggles the tooltip on the clicked icon', function(){ Publisher.bindPublicIcon(); - expect($(".public_icon")).toHaveAttr('title', 'is public'); - $(".public_icon").click(); - expect($(".public_icon")).toHaveAttr('title', 'is limited'); + expect($(".public_icon")).toHaveAttr('original-title', 'is public'); $(".public_icon").click(); - expect($(".public_icon")).toHaveAttr('title', 'is public'); + expect($(".public_icon")).toHaveAttr('original-title', 'is limited'); }); }); describe("bindServiceIcons", function() {