From 5358f78e824412919ddd8f3d7d2b0bf68a6292d4 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 4 Mar 2011 14:27:55 -0800 Subject: [PATCH] Reusable notice form fixes for geolocation --- js/util.js | 3 +-- lib/noticeform.php | 20 ++++++++++++++++++-- plugins/Realtime/realtimeupdate.css | 2 +- theme/biz/css/display.css | 6 +++--- theme/cloudy/css/display.css | 6 +++--- theme/default/css/display.css | 6 +++--- theme/identica/css/display.css | 6 +++--- theme/mnml/css/display.css | 6 +++--- theme/pigeonthoughts/css/display.css | 6 +++--- theme/rebase/css/display.css | 6 +++--- theme/victorian/css/display.css | 6 +++--- 11 files changed, 44 insertions(+), 29 deletions(-) diff --git a/js/util.js b/js/util.js index 3a901b6c09..1bd011cb0d 100644 --- a/js/util.js +++ b/js/util.js @@ -990,7 +990,7 @@ var SN = { // StatusNet var NLN = ''; // @fixme var NDGe = form.find('[name=notice_data-geo]'); var check = form.find('[name=notice_data-geo]'); - var label = $('label[for='+check.attr('id')+']'); + var label = form.find('label.notice_data-geo'); function removeNoticeDataGeo(error) { label @@ -1164,7 +1164,6 @@ var SN = { // StatusNet */ NoticeGeoStatus: function(form, status, lat, lon, url) { - var form = $('#form_notice'); var wrapper = form.find('.geo_status_wrapper'); if (wrapper.length == 0) { wrapper = $('
'); diff --git a/lib/noticeform.php b/lib/noticeform.php index ae8023275a..0f13147d00 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -94,6 +94,8 @@ class NoticeForm extends Form function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto=null, $lat=null, $lon=null, $location_id=null, $location_ns=null) { + $this->id_suffix = time(); + parent::__construct($out); $this->action = $action; @@ -125,7 +127,7 @@ class NoticeForm extends Form function id() { - return 'form_notice'; + return 'form_notice_' . $this->id_suffix; } /** @@ -208,7 +210,21 @@ class NoticeForm extends Form $this->out->elementStart('div', array('class' => 'notice_data-geo_wrap', 'title' => common_local_url('geocode'))); - $this->out->checkbox('notice_data-geo', _('Share my location'), true); + + // @fixme checkbox method allows no way to change the id without changing the name + //$this->out->checkbox('notice_data-geo', _('Share my location'), true); + $this->out->element('input', array( + 'name' => 'notice_data-geo', + 'type' => 'checkbox', + 'class' => 'checkbox', + 'id' => $this->id() . '-notice_data-geo', + 'checked' => true, // ? + )); + $this->out->text(' '); + $this->out->element('label', array('class' => 'notice_data-geo', + 'for' => $this->id() . '-notice_data-geo'), + _('Share my location')); + $this->out->elementEnd('div'); $this->out->inlineScript(' var NoticeDataGeo_text = {'. 'ShareDisable: ' .json_encode(_('Do not share my location')).','. diff --git a/plugins/Realtime/realtimeupdate.css b/plugins/Realtime/realtimeupdate.css index b277b30a14..7fd7fd5ed3 100644 --- a/plugins/Realtime/realtimeupdate.css +++ b/plugins/Realtime/realtimeupdate.css @@ -19,7 +19,7 @@ display:none; .realtime-popup #form_notice label[for=notice_data-attach], .realtime-popup #form_notice #notice_data-attach, -.realtime-popup #form_notice label[for=notice_data-geo] { +.realtime-popup #form_notice label.notice_data-geo { top:0; } diff --git a/theme/biz/css/display.css b/theme/biz/css/display.css index e562f7072a..0bb53f74a8 100644 --- a/theme/biz/css/display.css +++ b/theme/biz/css/display.css @@ -118,10 +118,10 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1); text-shadow:none; } -.form_notice label[for=notice_data-geo] { +.form_notice label.notice_data-geo { background-position:0 -1780px; } -.form_notice label[for=notice_data-geo].checked { +.form_notice label.notice_data-geo.checked { background-position:0 -1846px; } @@ -216,7 +216,7 @@ button.close, .entity_role_administrator input.submit, .entity_role_moderator input.submit, .notice-options .repeated, -.form_notice label[for=notice_data-geo], +.form_notice label.notice_data-geo, button.minimize, .form_reset_key input.submit, .entity_clear input.submit, diff --git a/theme/cloudy/css/display.css b/theme/cloudy/css/display.css index ab23896b2d..a5eabac4ad 100644 --- a/theme/cloudy/css/display.css +++ b/theme/cloudy/css/display.css @@ -1636,7 +1636,7 @@ button.close, .entity_silence input.submit, .entity_delete input.submit, .notice-options .repeated, -.form_notice label[for=notice_data-geo], +.form_notice label.notice_data-geo, button.minimize, .form_reset_key input.submit, .entity_clear input.submit, @@ -1746,10 +1746,10 @@ background-position:0 47%; .form_notice a#notice_data-geo_name { background-position:0 -1711px; } -.form_notice label[for=notice_data-geo] { +.form_notice label.notice_data-geo { background-position:0 -1780px; } -.form_notice label[for=notice_data-geo].checked { +.form_notice label.notice_data-geo.checked { background-position:0 -1846px; } diff --git a/theme/default/css/display.css b/theme/default/css/display.css index 63554aae18..fbd3afb12c 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -116,10 +116,10 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1); text-shadow:none; } -.form_notice label[for=notice_data-geo] { +.form_notice label.notice_data-geo { background-position:0 -1780px; } -.form_notice label[for=notice_data-geo].checked { +.form_notice label.notice_data-geo.checked { background-position:0 -1846px; } @@ -196,7 +196,7 @@ button.close, .entity_role_administrator input.submit, .entity_role_moderator input.submit, .notice-options .repeated, -.form_notice label[for=notice_data-geo], +.form_notice label.notice_data-geo, button.minimize, .form_reset_key input.submit, .entity_clear input.submit, diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index 211c539dcb..fba72a09d6 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -117,10 +117,10 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1); text-shadow:none; } -.form_notice label[for=notice_data-geo] { +.form_notice label.notice_data-geo { background-position:0 -1780px; } -.form_notice label[for=notice_data-geo].checked { +.form_notice label.notice_data-geo.checked { background-position:0 -1846px; } @@ -197,7 +197,7 @@ button.close, .entity_role_administrator input.submit, .entity_role_moderator input.submit, .notice-options .repeated, -.form_notice label[for=notice_data-geo], +.form_notice label.notice_data-geo, button.minimize, .form_reset_key input.submit, .entity_clear input.submit, diff --git a/theme/mnml/css/display.css b/theme/mnml/css/display.css index f5b80b0e95..57ad426c55 100644 --- a/theme/mnml/css/display.css +++ b/theme/mnml/css/display.css @@ -271,7 +271,7 @@ button.close, .entity_role_administrator input.submit, .entity_role_moderator input.submit, .notice-options .repeated, -.form_notice label[for=notice_data-geo], +.form_notice label.notice_data-geo, button.minimize, .form_reset_key input.submit, .entity_clear input.submit, @@ -286,10 +286,10 @@ button.minimize, background-color:transparent; } -.form_notice label[for=notice_data-geo] { +.form_notice label.notice_data-geo { background-position:0 -1780px; } -.form_notice label[for=notice_data-geo].checked { +.form_notice label.notice_data-geo.checked { background-position:0 -1846px; } .form_notice label[for=notice_data-attach] { diff --git a/theme/pigeonthoughts/css/display.css b/theme/pigeonthoughts/css/display.css index 155a473519..b4f2f297b0 100644 --- a/theme/pigeonthoughts/css/display.css +++ b/theme/pigeonthoughts/css/display.css @@ -84,10 +84,10 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1); text-shadow:none; } -.form_notice label[for=notice_data-geo] { +.form_notice label.notice_data-geo { background-position:0 -1780px; } -.form_notice label[for=notice_data-geo].checked { +.form_notice label.notice_data-geo.checked { background-position:0 -1846px; } @@ -233,7 +233,7 @@ button.close, .entity_silence input.submit, .entity_delete input.submit, .notice-options .repeated, -.form_notice label[for=notice_data-geo], +.form_notice label.notice_data-geo, button.minimize, .form_reset_key input.submit, .entity_clear input.submit, diff --git a/theme/rebase/css/display.css b/theme/rebase/css/display.css index 4038ab614a..32df41b93a 100644 --- a/theme/rebase/css/display.css +++ b/theme/rebase/css/display.css @@ -1771,7 +1771,7 @@ button.close, .entity_role_administrator input.submit, .entity_role_moderator input.submit, .notice-options .repeated, -.form_notice label[for=notice_data-geo], +.form_notice label.notice_data-geo, button.minimize, .form_reset_key input.submit, .entity_clear input.submit, @@ -1924,10 +1924,10 @@ background-position:0 -1054px; .form_notice label[for=notice_data-attach] { background-position: 0 -328px; } -.form_notice label[for=notice_data-geo] { +.form_notice label.notice_data-geo { background-position: 0 -1780px; } -.form_notice label[for=notice_data-geo].checked { +.form_notice label.notice_data-geo.checked { background-position: 0 -1846px; } diff --git a/theme/victorian/css/display.css b/theme/victorian/css/display.css index 3ab7fc601a..6252fdf908 100644 --- a/theme/victorian/css/display.css +++ b/theme/victorian/css/display.css @@ -294,10 +294,10 @@ input.submit:focus { text-shadow:none; } -.form_notice label[for=notice_data-geo] { +.form_notice label.notice_data-geo { background-position:0 -1780px; } -.form_notice label[for=notice_data-geo].checked { +.form_notice label.notice_data-geo.checked { background-position:0 -1846px; } @@ -373,7 +373,7 @@ button.close, .entity_role_administrator input.submit, .entity_role_moderator input.submit, .notice-options .repeated, -.form_notice label[for=notice_data-geo], +.form_notice label.notice_data-geo, button.minimize, .form_reset_key input.submit, .entity_clear input.submit, -- 2.39.2