diff options
-rw-r--r-- | classes/Memcached_DataObject.php | 1 | ||||
-rw-r--r-- | js/util.js | 157 | ||||
-rw-r--r-- | theme/default/css/display.css | 21 |
3 files changed, 118 insertions, 61 deletions
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index a3a69e667..aab1cace6 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -66,7 +66,6 @@ class Memcached_DataObject extends DB_DataObject // Clear this out so we don't accidentally break global // state in *this* process. $this->_DB_resultid = null; - // We don't have any local DBO refs, so clear these out. $this->_link_loaded = false; } diff --git a/js/util.js b/js/util.js index 2d108118a..af6e0ff20 100644 --- a/js/util.js +++ b/js/util.js @@ -178,12 +178,13 @@ var SN = { // StatusNet }, FormNoticeXHR: function(form) { + var NDG, NLat, NLon, NLNS, NLID; form_id = form.attr('id'); form.append('<input type="hidden" name="ajax" value="1"/>'); form.ajaxForm({ dataType: 'xml', timeout: '60000', - beforeSend: function(xhr) { + beforeSend: function(formData) { if ($('#'+form_id+' #'+SN.C.S.NoticeDataText)[0].value.length === 0) { form.addClass(SN.C.S.Warning); return false; @@ -191,6 +192,13 @@ var SN = { // StatusNet form.addClass(SN.C.S.Processing); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).addClass(SN.C.S.Disabled); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).attr(SN.C.S.Disabled, SN.C.S.Disabled); + + NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked'); + NLat = $('#'+SN.C.S.NoticeLat).val(); + NLon = $('#'+SN.C.S.NoticeLon).val(); + NLNS = $('#'+SN.C.S.NoticeLocationNs).val(); + NLID = $('#'+SN.C.S.NoticeLocationId).val(); + return true; }, error: function (xhr, textStatus, errorThrown) { @@ -273,6 +281,12 @@ var SN = { // StatusNet form.removeClass(SN.C.S.Processing); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled); + + $('#'+SN.C.S.NoticeDataGeo).attr('checked', NDG); + $('#'+SN.C.S.NoticeLat).val(NLat); + $('#'+SN.C.S.NoticeLon).val(NLon); + $('#'+SN.C.S.NoticeLocationNs).val(NLNS); + $('#'+SN.C.S.NoticeLocationId).val(NLID); } }); }, @@ -442,6 +456,11 @@ var SN = { // StatusNet }, NoticeLocationAttach: function() { + var NLat = $('#'+SN.C.S.NoticeLat).val(); + var NLon = $('#'+SN.C.S.NoticeLon).val(); + var NLNS = $('#'+SN.C.S.NoticeLocationNs).val(); + var NLID = $('#'+SN.C.S.NoticeLocationId).val(); + function removeNoticeDataGeo() { $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked'); $('#'+SN.C.S.NoticeDataGeoSelected).hide(); @@ -451,56 +470,90 @@ var SN = { // StatusNet $('#'+SN.C.S.NoticeLocationId).val(''); } + function getJSONgeocodeURL(geocodeURL, data) { + $.getJSON(geocodeURL, data, function(location) { + NLN = $('#'+SN.C.S.NoticeLocationName); + NLN.replaceWith('<a id="notice_data-location_name"/>'); + NLN = $('#'+SN.C.S.NoticeLocationName); + + if (typeof(location.location_ns) != 'undefined') { + $('#'+SN.C.S.NoticeLocationNs).val(location.location_ns); + } + + if (typeof(location.location_id) != 'undefined') { + $('#'+SN.C.S.NoticeLocationId).val(location.location_id); + } + + if (typeof(location.name) == 'undefined') { + NLN_text = position.coords.latitude + ';' + position.coords.longitude; + } + else { + NLN_text = location.name; + } + + NLN.attr('href', location.url); + NLN.text(NLN_text); + NLN.click(function() { + window.open(location.url); + + return false; + }); + }); + } + var NDG = $('#'+SN.C.S.NoticeDataGeo); if (NDG.length > 0) { + var cookieVal = $.cookie(SN.C.S.NoticeLocationCookieName); + NDG.attr('checked', (cookieVal === null || cookieVal == 'true')); + var NLE = $('#notice_data-location_wrap'); var geocodeURL = NLE.attr('title'); NLE.removeAttr('title'); $('label[for='+SN.C.S.NoticeDataGeo+']').attr('title', jQuery.trim($('label[for='+SN.C.S.NoticeDataGeo+']').text())); - if (navigator.geolocation) { - NDG.change(function() { - $.cookie(SN.C.S.NoticeLocationCookieName, $('#'+SN.C.S.NoticeDataGeo).attr('checked')); + NDG.change(function() { + $.cookie(SN.C.S.NoticeLocationCookieName, $('#'+SN.C.S.NoticeDataGeo).attr('checked')); - var NLN = $('#'+SN.C.S.NoticeLocationName); - if (NLN.length > 0) { - NLN.remove(); - } + var NLN = $('#'+SN.C.S.NoticeLocationName); + if (NLN.length > 0) { + NLN.remove(); + } + + if ($('#'+SN.C.S.NoticeDataGeo).attr('checked') === true) { + $('label[for='+SN.C.S.NoticeDataGeo+']').addClass('checked'); var S = '<div id="'+SN.C.S.NoticeDataGeoSelected+'" class="'+SN.C.S.Success+'"/>'; var NDGS = $('#'+SN.C.S.NoticeDataGeoSelected); + if (NDGS.length > 0) { NDGS.replaceWith(S); } else { $('#'+SN.C.S.FormNotice).append(S); } + NDGS = $('#'+SN.C.S.NoticeDataGeoSelected); - NDGS.prepend('<span id="'+SN.C.S.NoticeLocationName+'">Geo</span>'); + NDGS.prepend('<span id="'+SN.C.S.NoticeLocationName+'">Geo</span> <button class="minimize">_</button> <button class="close">×</button>'); var NLN = $('#'+SN.C.S.NoticeLocationName); + NLN.addClass('processing'); - if ($('#'+SN.C.S.NoticeDataGeo).attr('checked') === true) { - NLN.addClass('processing'); - $('label[for='+SN.C.S.NoticeDataGeo+']').addClass('checked'); + $('#'+SN.C.S.NoticeDataGeoSelected+' button.close').click(function(){ + $('#'+SN.C.S.NoticeDataGeoSelected).remove(); + $('#'+SN.C.S.NoticeDataGeo).attr('checked', false); + $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked'); - NDGS.append('<button class="minimize">_</button> <button class="close">×</button>'); - - $('#'+SN.C.S.NoticeDataGeoSelected+' button.close').click(function(){ - $('#'+SN.C.S.NoticeDataGeoSelected).remove(); - $('#'+SN.C.S.NoticeDataGeo).attr('checked', false); - $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked'); - - return false; - }); + return false; + }); - $('#'+SN.C.S.NoticeDataGeoSelected+' button.minimize').click(function(){ - $('#'+SN.C.S.NoticeDataGeoSelected).hide(); + $('#'+SN.C.S.NoticeDataGeoSelected+' button.minimize').click(function(){ + $('#'+SN.C.S.NoticeDataGeoSelected).hide(); - return false; - }); + return false; + }); + if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( function(position) { $('#'+SN.C.S.NoticeLat).val(position.coords.latitude); @@ -512,34 +565,7 @@ var SN = { // StatusNet 'token': $('#token').val() }; - $.getJSON(geocodeURL, data, function(location) { - NLN = $('#'+SN.C.S.NoticeLocationName); - NLN.replaceWith('<a id="notice_data-location_name"/>'); - NLN = $('#'+SN.C.S.NoticeLocationName); - - if (typeof(location.location_ns) != 'undefined') { - $('#'+SN.C.S.NoticeLocationNs).val(location.location_ns); - } - - if (typeof(location.location_id) != 'undefined') { - $('#'+SN.C.S.NoticeLocationId).val(location.location_id); - } - - if (typeof(location.name) == 'undefined') { - NLN_text = position.coords.latitude + ';' + position.coords.longitude; - } - else { - NLN_text = location.name; - } - - NLN.attr('href', location.url); - NLN.text(NLN_text); - NLN.click(function() { - window.open(location.url); - - return false; - }); - }); + getJSONgeocodeURL(geocodeURL, data); }, function(error) { @@ -550,13 +576,26 @@ var SN = { // StatusNet ); } else { - removeNoticeDataGeo(); + if (NLat.length > 0 && NLon.length > 0) { + var data = { + 'lat': NLat, + 'lon': NLon, + 'token': $('#token').val() + }; + + getJSONgeocodeURL(geocodeURL, data); + } + else { + removeNoticeDataGeo(); + $('#'+SN.C.S.NoticeDataGeo).remove(); + $('label[for='+SN.C.S.NoticeDataGeo+']').remove(); + } } - }).change(); - - var cookieVal = $.cookie(SN.C.S.NoticeLocationCookieName); - NDG.attr('checked', (cookieVal === null || cookieVal == 'true')); - } + } + else { + removeNoticeDataGeo(); + } + }).change(); } }, diff --git a/theme/default/css/display.css b/theme/default/css/display.css index 50209bfd3..0c8db45e7 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -111,6 +111,19 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1); text-shadow:none; } +.form_notice span#notice_data-location_name { +background-position:0 47%; +} +.form_notice a#notice_data-location_name { +background-position:0 -1711px; +} +.form_notice label[for=notice_data-geo] { +background-position:0 -1780px; +} +.form_notice label[for=notice_data-geo].checked { +background-position:0 -1846px; +} + a, .form_settings input.form_action-primary, .notice-options input, @@ -177,7 +190,10 @@ button.close, .entity_sandbox input.submit, .entity_silence input.submit, .entity_delete input.submit, -.notice-options .repeated { +.notice-options .repeated, +.form_notice a#notice_data-location_name, +.form_notice label[for=notice_data-geo], +button.minimize { background-image:url(../../base/images/icons/icons-01.gif); background-repeat:no-repeat; background-color:transparent; @@ -239,6 +255,9 @@ background-color:#EFF3DC; button.close { background-position:0 -1120px; } +button.minimize { +background-position:0 -1912px; +} #anon_notice { background-color:#87B4C8; |