]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Moved JavaScript dependant stuff out of noticeform.
authorSarven Capadisli <csarven@status.net>
Thu, 31 Dec 2009 18:08:21 +0000 (18:08 +0000)
committerSarven Capadisli <csarven@status.net>
Thu, 31 Dec 2009 18:08:21 +0000 (18:08 +0000)
js/util.js
lib/noticeform.php

index 8ac0cbd66a3730af5f5a3d1477df8b403d96ab97..41b3fdb25d9fb8c692b6819c2af61adf3d988faf 100644 (file)
@@ -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('<span id="'+SN.C.S.NoticeLocationName+'">Geo</span>');
                         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('<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);
@@ -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();
                 }
             }
         },
index 98f15ca096e3a3c7c510981ad77d9493cd6d0e73..7ed880442f17b0725648ba1292d82c2a41ae7103 100644 (file)
@@ -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');
             }