From 98ce7daf5650ebd7e6f6bbaca6e57069ffccae55 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 29 Dec 2009 16:17:17 -0500 Subject: Implement user interface for user to preview what location they are sharing with a notice --- lib/noticeform.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/noticeform.php') diff --git a/lib/noticeform.php b/lib/noticeform.php index 593a1e932..d85de9c22 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -220,5 +220,11 @@ class NoticeForm extends Form 'name' => 'status_submit', 'type' => 'submit', 'value' => _('Send'))); + if($this->user->shareLocation()) { + $this->out->elementStart('div',array('id' => 'notice_data-location_enabled_container', 'data-geocode-url' => common_local_url('geocode'))); + $this->out->checkbox('notice_data-location_enabled',_('Share your location ')); + $this->out->element('a', array('style' => 'display: none', 'target' => '_blank', 'id' => 'notice_data-location_name'), _('Finding your location...')); + $this->out->elementEnd('div'); + } } } -- cgit v1.2.3-54-g00ecf From 024704e0b70cb29107929cc2cce0ddc6b2d2e42b Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 30 Dec 2009 20:26:23 +0100 Subject: Remove trailing space in checkbox text. --- lib/noticeform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/noticeform.php') diff --git a/lib/noticeform.php b/lib/noticeform.php index d85de9c22..76715c35a 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -222,7 +222,7 @@ class NoticeForm extends Form 'value' => _('Send'))); if($this->user->shareLocation()) { $this->out->elementStart('div',array('id' => 'notice_data-location_enabled_container', 'data-geocode-url' => common_local_url('geocode'))); - $this->out->checkbox('notice_data-location_enabled',_('Share your location ')); + $this->out->checkbox('notice_data-location_enabled',_('Share your location')); $this->out->element('a', array('style' => 'display: none', 'target' => '_blank', 'id' => 'notice_data-location_name'), _('Finding your location...')); $this->out->elementEnd('div'); } -- cgit v1.2.3-54-g00ecf From 4985582880b56f23226dfffb3f81140d8d4c055f Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 31 Dec 2009 12:43:33 +0000 Subject: Fixed Event end name --- lib/noticeform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/noticeform.php') diff --git a/lib/noticeform.php b/lib/noticeform.php index 76715c35a..0af497099 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -203,7 +203,7 @@ class NoticeForm extends Form $this->out->hidden('notice_data-location_id', empty($this->location_id) ? null : $this->location_id, 'location_id'); $this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? null : $this->location_ns, 'location_ns'); - Event::handle('StartShowNoticeFormData', array($this)); + Event::handle('EndShowNoticeFormData', array($this)); } } -- cgit v1.2.3-54-g00ecf From 58714808443204ecbd98b9763aeaeb1929341213 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 31 Dec 2009 12:52:39 +0000 Subject: Moved shareLocation data from formActions() to formData() --- lib/noticeform.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/noticeform.php') diff --git a/lib/noticeform.php b/lib/noticeform.php index 0af497099..bfdab7738 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -203,6 +203,13 @@ class NoticeForm extends Form $this->out->hidden('notice_data-location_id', empty($this->location_id) ? null : $this->location_id, 'location_id'); $this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? null : $this->location_ns, 'location_ns'); + if($this->user->shareLocation()) { + $this->out->elementStart('div',array('id' => 'notice_data-location_enabled_container', 'data-geocode-url' => common_local_url('geocode'))); + $this->out->checkbox('notice_data-location_enabled',_('Share your location')); + $this->out->element('a', array('style' => 'display: none', 'target' => '_blank', 'id' => 'notice_data-location_name'), _('Finding your location...')); + $this->out->elementEnd('div'); + } + Event::handle('EndShowNoticeFormData', array($this)); } } @@ -220,11 +227,5 @@ class NoticeForm extends Form 'name' => 'status_submit', 'type' => 'submit', 'value' => _('Send'))); - if($this->user->shareLocation()) { - $this->out->elementStart('div',array('id' => 'notice_data-location_enabled_container', 'data-geocode-url' => common_local_url('geocode'))); - $this->out->checkbox('notice_data-location_enabled',_('Share your location')); - $this->out->element('a', array('style' => 'display: none', 'target' => '_blank', 'id' => 'notice_data-location_name'), _('Finding your location...')); - $this->out->elementEnd('div'); - } } } -- cgit v1.2.3-54-g00ecf From 923e27b01a81c70ab52bc1b5856368143d0d32cf Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 31 Dec 2009 14:23:11 +0000 Subject: Fix to grab and use the actual lat/lon values from the user profile --- lib/noticeform.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/noticeform.php') diff --git a/lib/noticeform.php b/lib/noticeform.php index bfdab7738..c60ac29c3 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -110,6 +110,8 @@ class NoticeForm extends Form $this->user = common_current_user(); } + $this->profile = $this->user->getProfile(); + if (common_config('attachments', 'uploads')) { $this->enctype = 'multipart/form-data'; } @@ -198,10 +200,11 @@ class NoticeForm extends Form $this->out->hidden('notice_return-to', $this->action, 'returnto'); } $this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto'); - $this->out->hidden('notice_data-lat', empty($this->lat) ? null : $this->lat, 'lat'); - $this->out->hidden('notice_data-lon', empty($this->lon) ? null : $this->lon, 'lon'); - $this->out->hidden('notice_data-location_id', empty($this->location_id) ? null : $this->location_id, 'location_id'); - $this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? null : $this->location_ns, 'location_ns'); + + $this->out->hidden('notice_data-lat', empty($this->profile->lat) ? null : $this->profile->lat, 'lat'); + $this->out->hidden('notice_data-lon', empty($this->profile->lon) ? null : $this->profile->lon, 'lon'); + $this->out->hidden('notice_data-location_id', empty($this->profile->location_id) ? null : $this->profile->location_id, 'location_id'); + $this->out->hidden('notice_data-location_ns', empty($this->profile->location_ns) ? null : $this->profile->location_ns, 'location_ns'); if($this->user->shareLocation()) { $this->out->elementStart('div',array('id' => 'notice_data-location_enabled_container', 'data-geocode-url' => common_local_url('geocode'))); -- cgit v1.2.3-54-g00ecf From 4efa841ba330cedd4ad71349a8196f18d5546cb8 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 31 Dec 2009 14:24:27 +0000 Subject: If user doesn't want to share their location (which is globally set from their profile settings), don't bother to output form data for lat/long in the notice form. --- lib/noticeform.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/noticeform.php') diff --git a/lib/noticeform.php b/lib/noticeform.php index c60ac29c3..50b2e6893 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -201,12 +201,12 @@ class NoticeForm extends Form } $this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto'); - $this->out->hidden('notice_data-lat', empty($this->profile->lat) ? null : $this->profile->lat, 'lat'); - $this->out->hidden('notice_data-lon', empty($this->profile->lon) ? null : $this->profile->lon, 'lon'); - $this->out->hidden('notice_data-location_id', empty($this->profile->location_id) ? null : $this->profile->location_id, 'location_id'); - $this->out->hidden('notice_data-location_ns', empty($this->profile->location_ns) ? null : $this->profile->location_ns, 'location_ns'); + if ($this->user->shareLocation()) { + $this->out->hidden('notice_data-lat', empty($this->profile->lat) ? null : $this->profile->lat, 'lat'); + $this->out->hidden('notice_data-lon', empty($this->profile->lon) ? null : $this->profile->lon, 'lon'); + $this->out->hidden('notice_data-location_id', empty($this->profile->location_id) ? null : $this->profile->location_id, 'location_id'); + $this->out->hidden('notice_data-location_ns', empty($this->profile->location_ns) ? null : $this->profile->location_ns, 'location_ns'); - if($this->user->shareLocation()) { $this->out->elementStart('div',array('id' => 'notice_data-location_enabled_container', 'data-geocode-url' => common_local_url('geocode'))); $this->out->checkbox('notice_data-location_enabled',_('Share your location')); $this->out->element('a', array('style' => 'display: none', 'target' => '_blank', 'id' => 'notice_data-location_name'), _('Finding your location...')); -- cgit v1.2.3-54-g00ecf From c986f59143b1969dc4ae324409295728b1d06e82 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 31 Dec 2009 14:34:07 +0000 Subject: If user is sharing their location (based on profile setting), then enable it for form notice by default. This can be overriden by the cookie to preserve states. --- lib/noticeform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/noticeform.php') diff --git a/lib/noticeform.php b/lib/noticeform.php index 50b2e6893..f45e6629b 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -208,7 +208,7 @@ class NoticeForm extends Form $this->out->hidden('notice_data-location_ns', empty($this->profile->location_ns) ? null : $this->profile->location_ns, 'location_ns'); $this->out->elementStart('div',array('id' => 'notice_data-location_enabled_container', 'data-geocode-url' => common_local_url('geocode'))); - $this->out->checkbox('notice_data-location_enabled',_('Share your location')); + $this->out->checkbox('notice_data-location_enabled', _('Share your location'), true); $this->out->element('a', array('style' => 'display: none', 'target' => '_blank', 'id' => 'notice_data-location_name'), _('Finding your location...')); $this->out->elementEnd('div'); } -- cgit v1.2.3-54-g00ecf From 0320bf2fb3cdd4b9e6b635485421833fde447da8 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 31 Dec 2009 15:46:43 +0000 Subject: Use the location setting profile as secondary --- lib/noticeform.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/noticeform.php') diff --git a/lib/noticeform.php b/lib/noticeform.php index f45e6629b..5afa41e25 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -202,10 +202,10 @@ class NoticeForm extends Form $this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto'); if ($this->user->shareLocation()) { - $this->out->hidden('notice_data-lat', empty($this->profile->lat) ? null : $this->profile->lat, 'lat'); - $this->out->hidden('notice_data-lon', empty($this->profile->lon) ? null : $this->profile->lon, 'lon'); - $this->out->hidden('notice_data-location_id', empty($this->profile->location_id) ? null : $this->profile->location_id, 'location_id'); - $this->out->hidden('notice_data-location_ns', empty($this->profile->location_ns) ? null : $this->profile->location_ns, 'location_ns'); + $this->out->hidden('notice_data-lat', empty($this->lat) ? (empty($this->profile->lat) ? null : $this->profile->lat) : $this->lat, 'lat'); + $this->out->hidden('notice_data-lon', empty($this->lon) ? (empty($this->profile->lon) ? null : $this->profile->lon) : $this->lon, 'lon'); + $this->out->hidden('notice_data-location_id', empty($this->location_id) ? (empty($this->profile->location_id) ? null : $this->profile->location_id) : $this->location_id, 'location_id'); + $this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? (empty($this->profile->location_ns) ? null : $this->profile->location_ns) : $this->location_ns, 'location_ns'); $this->out->elementStart('div',array('id' => 'notice_data-location_enabled_container', 'data-geocode-url' => common_local_url('geocode'))); $this->out->checkbox('notice_data-location_enabled', _('Share your location'), true); -- cgit v1.2.3-54-g00ecf From 8872d91483b689d168244ff0df2fa4b5b23a38cc Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 31 Dec 2009 16:44:24 +0000 Subject: Removed style information out of HTML --- lib/noticeform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/noticeform.php') diff --git a/lib/noticeform.php b/lib/noticeform.php index 5afa41e25..98f15ca09 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -209,7 +209,7 @@ class NoticeForm extends Form $this->out->elementStart('div',array('id' => 'notice_data-location_enabled_container', 'data-geocode-url' => common_local_url('geocode'))); $this->out->checkbox('notice_data-location_enabled', _('Share your location'), true); - $this->out->element('a', array('style' => 'display: none', 'target' => '_blank', 'id' => 'notice_data-location_name'), _('Finding your location...')); + $this->out->element('a', array('id' => 'notice_data-location_name'), _('Finding your location...')); $this->out->elementEnd('div'); } -- cgit v1.2.3-54-g00ecf From dde6415a6a91eb6670a80279a344ab6cc56ef17d Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 31 Dec 2009 18:08:21 +0000 Subject: Moved JavaScript dependant stuff out of noticeform. --- js/util.js | 29 ++++++++++++++++++++++------- lib/noticeform.php | 4 ++-- 2 files changed, 24 insertions(+), 9 deletions(-) (limited to 'lib/noticeform.php') diff --git a/js/util.js b/js/util.js index 8ac0cbd66..41b3fdb25 100644 --- a/js/util.js +++ b/js/util.js @@ -440,8 +440,20 @@ var SN = { // StatusNet NoticeLocationAttach: function() { if ($('#notice_data-location_enabled').length > 0) { if (navigator.geolocation) { - $('#notice_data-location_enabled').change(function() { + var NLE = $('#notice_data-location_wrap'); + var geocodeURL = NLE.attr('title'); + + NLE.change(function() { + NLE.removeAttr('title'); + $.cookie(SN.C.S.NoticeLocationCookieName, $('#notice_data-location_enabled').attr('checked')); + + var NLN = $('#'+SN.C.S.NoticeLocationName); + if (NLN.length > 0) { + NLN.remove(); + } + + NLE.append('Geo'); NLN = $('#'+SN.C.S.NoticeLocationName); if ($('#notice_data-location_enabled').attr('checked') === true) { @@ -458,8 +470,9 @@ var SN = { // StatusNet 'token': $('#token').val() }; - $.getJSON($('#notice_data-location_enabled_container').attr('data-geocode-url'), data, function(location) { - NLN.removeClass('processing'); + $.getJSON(geocodeURL, data, function(location) { + NLN.replaceWith(''); + NLN = $('#'+SN.C.S.NoticeLocationName); if (typeof(location.location_ns) != 'undefined') { $('#'+SN.C.S.NoticeLocationNs).val(location.location_ns); @@ -470,12 +483,14 @@ var SN = { // StatusNet } if (typeof(location.name) == 'undefined') { - NLN.text(position.coords.latitude + ';' + position.coords.longitude); + NLN_text = position.coords.latitude + ';' + position.coords.longitude; } else { - NLN.text(location.name); - NLN.attr('href',location.url); + NLN_text = location.name; } + + NLN.attr('href', location.url); + NLN.text(NLN_text); }); }); } @@ -490,7 +505,7 @@ var SN = { // StatusNet var cookieVal = $.cookie(SN.C.S.NoticeLocationCookieName); $('#notice_data-location_enabled').attr('checked',(cookieVal == null || cookieVal == 'true')); - $('#notice_data-location_enabled').change(); + NLE.change(); } } }, diff --git a/lib/noticeform.php b/lib/noticeform.php index 98f15ca09..7ed880442 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -207,9 +207,9 @@ class NoticeForm extends Form $this->out->hidden('notice_data-location_id', empty($this->location_id) ? (empty($this->profile->location_id) ? null : $this->profile->location_id) : $this->location_id, 'location_id'); $this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? (empty($this->profile->location_ns) ? null : $this->profile->location_ns) : $this->location_ns, 'location_ns'); - $this->out->elementStart('div',array('id' => 'notice_data-location_enabled_container', 'data-geocode-url' => common_local_url('geocode'))); + $this->out->elementStart('div', array('id' => 'notice_data-location_wrap', + 'title' => common_local_url('geocode'))); $this->out->checkbox('notice_data-location_enabled', _('Share your location'), true); - $this->out->element('a', array('id' => 'notice_data-location_name'), _('Finding your location...')); $this->out->elementEnd('div'); } -- cgit v1.2.3-54-g00ecf From 01dbee2ba5280d97ddd0bb82217e8b3e7680e67b Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 31 Dec 2009 18:41:10 +0000 Subject: Initial UI for geo location share option in notice form --- js/util.js | 2 +- lib/noticeform.php | 1 + theme/base/css/display.css | 15 +++++++++++++++ theme/identica/css/display.css | 4 ++++ 4 files changed, 21 insertions(+), 1 deletion(-) (limited to 'lib/noticeform.php') diff --git a/js/util.js b/js/util.js index 0969ba5e2..dd7a74a7a 100644 --- a/js/util.js +++ b/js/util.js @@ -455,7 +455,7 @@ var SN = { // StatusNet NLN.remove(); } - NLE.append('Geo'); + NLE.prepend('Geo'); NLN = $('#'+SN.C.S.NoticeLocationName); if ($('#notice_data-location_enabled').attr('checked') === true) { diff --git a/lib/noticeform.php b/lib/noticeform.php index 7ed880442..d35655a0b 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -208,6 +208,7 @@ class NoticeForm extends Form $this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? (empty($this->profile->location_ns) ? null : $this->profile->location_ns) : $this->location_ns, 'location_ns'); $this->out->elementStart('div', array('id' => 'notice_data-location_wrap', + 'class' => 'success', 'title' => common_local_url('geocode'))); $this->out->checkbox('notice_data-location_enabled', _('Share your location'), true); $this->out->elementEnd('div'); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 29c7ee963..d6a50ac60 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -566,6 +566,21 @@ overflow:auto; float:right; font-size:0.8em; } +.form_notice #notice_data-location_wrap input { +margin-right:7px; +float:left; +} +.form_notice #notice_data-location_wrap label { +font-weight:normal; +font-size:1em; +} +.form_notice #notice_data-location_name { +display:block; +line-height:1.6; +} +.form_notice span#notice_data-location_name { +padding-left:18px; +} button.close { width:16px; diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index e86ee2437..78a0707ce 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -111,6 +111,10 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1); text-shadow:none; } +.form_notice #notice_data-location_name { +background-position:0 47%; +} + a, .form_settings input.form_action-primary, .notice-options input, -- cgit v1.2.3-54-g00ecf