Some code cleaning for geo UI
This commit is contained in:
parent
69f567c7be
commit
54c18e68da
42
js/util.js
42
js/util.js
@ -51,8 +51,7 @@ var SN = { // StatusNet
|
|||||||
NoticeLon: 'notice_data-lon',
|
NoticeLon: 'notice_data-lon',
|
||||||
NoticeLocationId: 'notice_data-location_id',
|
NoticeLocationId: 'notice_data-location_id',
|
||||||
NoticeLocationNs: 'notice_data-location_ns',
|
NoticeLocationNs: 'notice_data-location_ns',
|
||||||
NoticeLocationName: 'notice_data-location_name',
|
NoticeGeoName: 'notice_data-geo_name',
|
||||||
NoticeLocationCookieName: 'location_enabled',
|
|
||||||
NoticeDataGeo: 'notice_data-geo',
|
NoticeDataGeo: 'notice_data-geo',
|
||||||
NoticeDataGeoSelected: 'notice_data-geo_selected'
|
NoticeDataGeoSelected: 'notice_data-geo_selected'
|
||||||
}
|
}
|
||||||
@ -460,7 +459,7 @@ var SN = { // StatusNet
|
|||||||
var NLon = $('#'+SN.C.S.NoticeLon).val();
|
var NLon = $('#'+SN.C.S.NoticeLon).val();
|
||||||
var NLNS = $('#'+SN.C.S.NoticeLocationNs).val();
|
var NLNS = $('#'+SN.C.S.NoticeLocationNs).val();
|
||||||
var NLID = $('#'+SN.C.S.NoticeLocationId).val();
|
var NLID = $('#'+SN.C.S.NoticeLocationId).val();
|
||||||
var NLN = $('#'+SN.C.S.NoticeLocationName).text();
|
var NLN = $('#'+SN.C.S.NoticeGeoName).text();
|
||||||
var NDGe = $('#'+SN.C.S.NoticeDataGeo);
|
var NDGe = $('#'+SN.C.S.NoticeDataGeo);
|
||||||
|
|
||||||
function removeNoticeDataGeo() {
|
function removeNoticeDataGeo() {
|
||||||
@ -473,7 +472,7 @@ var SN = { // StatusNet
|
|||||||
$('#'+SN.C.S.NoticeLocationId).val('');
|
$('#'+SN.C.S.NoticeLocationId).val('');
|
||||||
$('#'+SN.C.S.NoticeDataGeo).attr('checked', false);
|
$('#'+SN.C.S.NoticeDataGeo).attr('checked', false);
|
||||||
|
|
||||||
$.cookie(SN.C.S.NoticeLocationCookieName, 'disabled');
|
$.cookie(SN.C.S.NoticeDataGeo, 'disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getJSONgeocodeURL(geocodeURL, data) {
|
function getJSONgeocodeURL(geocodeURL, data) {
|
||||||
@ -497,10 +496,10 @@ var SN = { // StatusNet
|
|||||||
NLN_text = location.name;
|
NLN_text = location.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#'+SN.C.S.NoticeLocationName)
|
$('#'+SN.C.S.NoticeGeoName)
|
||||||
.replaceWith('<a id="notice_data-location_name"/>');
|
.replaceWith('<a id="notice_data-geo_name"/>');
|
||||||
|
|
||||||
$('#'+SN.C.S.NoticeLocationName)
|
$('#'+SN.C.S.NoticeGeoName)
|
||||||
.attr('href', location.url)
|
.attr('href', location.url)
|
||||||
.text(NLN_text)
|
.text(NLN_text)
|
||||||
.click(function() {
|
.click(function() {
|
||||||
@ -524,32 +523,31 @@ var SN = { // StatusNet
|
|||||||
'NLNU': location.url,
|
'NLNU': location.url,
|
||||||
'NDG': true
|
'NDG': true
|
||||||
};
|
};
|
||||||
$.cookie(SN.C.S.NoticeLocationCookieName, JSON.stringify(cookieValue));
|
$.cookie(SN.C.S.NoticeDataGeo, JSON.stringify(cookieValue));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NDGe.length > 0) {
|
if (NDGe.length > 0) {
|
||||||
var cookieValue = $.cookie(SN.C.S.NoticeLocationCookieName);
|
if ($.cookie(SN.C.S.NoticeDataGeo) == 'disabled') {
|
||||||
if (cookieValue == 'disabled') {
|
|
||||||
NDGe.attr('checked', false);
|
NDGe.attr('checked', false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NDGe.attr('checked', true);
|
NDGe.attr('checked', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var NLE = $('#notice_data-location_wrap');
|
var NGW = $('#notice_data-geo_wrap');
|
||||||
var geocodeURL = NLE.attr('title');
|
var geocodeURL = NGW.attr('title');
|
||||||
NLE.removeAttr('title');
|
NGW.removeAttr('title');
|
||||||
|
|
||||||
$('label[for='+SN.C.S.NoticeDataGeo+']').attr('title', jQuery.trim($('label[for='+SN.C.S.NoticeDataGeo+']').text()));
|
$('label[for='+SN.C.S.NoticeDataGeo+']').attr('title', jQuery.trim($('label[for='+SN.C.S.NoticeDataGeo+']').text()));
|
||||||
|
|
||||||
NDGe.change(function() {
|
NDGe.change(function() {
|
||||||
var NLN = $('#'+SN.C.S.NoticeLocationName);
|
var NLN = $('#'+SN.C.S.NoticeGeoName);
|
||||||
if (NLN.length > 0) {
|
if (NLN.length > 0) {
|
||||||
NLN.remove();
|
NLN.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#'+SN.C.S.NoticeDataGeo).attr('checked') === true || $.cookie(SN.C.S.NoticeLocationCookieName) === null) {
|
if ($('#'+SN.C.S.NoticeDataGeo).attr('checked') === true || $.cookie(SN.C.S.NoticeDataGeo) === null) {
|
||||||
$('label[for='+SN.C.S.NoticeDataGeo+']').addClass('checked');
|
$('label[for='+SN.C.S.NoticeDataGeo+']').addClass('checked');
|
||||||
|
|
||||||
var S = '<div id="'+SN.C.S.NoticeDataGeoSelected+'" class="'+SN.C.S.Success+'"/>';
|
var S = '<div id="'+SN.C.S.NoticeDataGeoSelected+'" class="'+SN.C.S.Success+'"/>';
|
||||||
@ -563,9 +561,9 @@ var SN = { // StatusNet
|
|||||||
}
|
}
|
||||||
|
|
||||||
NDGS = $('#'+SN.C.S.NoticeDataGeoSelected);
|
NDGS = $('#'+SN.C.S.NoticeDataGeoSelected);
|
||||||
NDGS.prepend('<span id="'+SN.C.S.NoticeLocationName+'">Geo</span> <button class="minimize">_</button> <button class="close">×</button>');
|
NDGS.prepend('<span id="'+SN.C.S.NoticeGeoName+'">Geo</span> <button class="minimize">_</button> <button class="close">×</button>');
|
||||||
|
|
||||||
var NLN = $('#'+SN.C.S.NoticeLocationName);
|
var NLN = $('#'+SN.C.S.NoticeGeoName);
|
||||||
NLN.addClass('processing');
|
NLN.addClass('processing');
|
||||||
|
|
||||||
$('#'+SN.C.S.NoticeDataGeoSelected+' button.close').click(function(){
|
$('#'+SN.C.S.NoticeDataGeoSelected+' button.close').click(function(){
|
||||||
@ -582,7 +580,7 @@ var SN = { // StatusNet
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($.cookie(SN.C.S.NoticeLocationCookieName) === null || $.cookie(SN.C.S.NoticeLocationCookieName) == 'disabled') {
|
if ($.cookie(SN.C.S.NoticeDataGeo) === null || $.cookie(SN.C.S.NoticeDataGeo) == 'disabled') {
|
||||||
if (navigator.geolocation) {
|
if (navigator.geolocation) {
|
||||||
navigator.geolocation.getCurrentPosition(
|
navigator.geolocation.getCurrentPosition(
|
||||||
function(position) {
|
function(position) {
|
||||||
@ -623,17 +621,17 @@ var SN = { // StatusNet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var cookieValue = JSON.parse($.cookie(SN.C.S.NoticeLocationCookieName));
|
var cookieValue = JSON.parse($.cookie(SN.C.S.NoticeDataGeo));
|
||||||
$('#'+SN.C.S.NoticeLat).val(cookieValue.NLat);
|
$('#'+SN.C.S.NoticeLat).val(cookieValue.NLat);
|
||||||
$('#'+SN.C.S.NoticeLon).val(cookieValue.NLon);
|
$('#'+SN.C.S.NoticeLon).val(cookieValue.NLon);
|
||||||
$('#'+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS);
|
$('#'+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS);
|
||||||
$('#'+SN.C.S.NoticeLocationId).val(cookieValue.NLID);
|
$('#'+SN.C.S.NoticeLocationId).val(cookieValue.NLID);
|
||||||
$('#'+SN.C.S.NoticeDataGeo).attr('checked', cookieValue.NDG);
|
$('#'+SN.C.S.NoticeDataGeo).attr('checked', cookieValue.NDG);
|
||||||
|
|
||||||
$('#'+SN.C.S.NoticeLocationName)
|
$('#'+SN.C.S.NoticeGeoName)
|
||||||
.replaceWith('<a id="notice_data-location_name"/>');
|
.replaceWith('<a id="notice_data-geo_name"/>');
|
||||||
|
|
||||||
$('#'+SN.C.S.NoticeLocationName)
|
$('#'+SN.C.S.NoticeGeoName)
|
||||||
.attr('href', cookieValue.NLNU)
|
.attr('href', cookieValue.NLNU)
|
||||||
.text(cookieValue.NLN)
|
.text(cookieValue.NLN)
|
||||||
.click(function() {
|
.click(function() {
|
||||||
|
@ -207,7 +207,7 @@ 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_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->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',
|
$this->out->elementStart('div', array('id' => 'notice_data-geo_wrap',
|
||||||
'title' => common_local_url('geocode')));
|
'title' => common_local_url('geocode')));
|
||||||
$this->out->checkbox('notice_data-geo', _('Share your location'), true);
|
$this->out->checkbox('notice_data-geo', _('Share your location'), true);
|
||||||
$this->out->elementEnd('div');
|
$this->out->elementEnd('div');
|
||||||
|
@ -555,7 +555,7 @@ margin-bottom:0;
|
|||||||
line-height:1.618;
|
line-height:1.618;
|
||||||
}
|
}
|
||||||
.form_notice #notice_data-attach_selected code,
|
.form_notice #notice_data-attach_selected code,
|
||||||
.form_notice #notice_data-location_name {
|
.form_notice #notice_data-geo_name {
|
||||||
float:left;
|
float:left;
|
||||||
width:80%;
|
width:80%;
|
||||||
display:block;
|
display:block;
|
||||||
@ -575,7 +575,7 @@ font-size:0.8em;
|
|||||||
float:left;
|
float:left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form_notice #notice_data-location_wrap label {
|
.form_notice #notice_data-geo_wrap label {
|
||||||
position:absolute;
|
position:absolute;
|
||||||
top:25px;
|
top:25px;
|
||||||
right:4px;
|
right:4px;
|
||||||
@ -585,16 +585,16 @@ width:16px;
|
|||||||
height:16px;
|
height:16px;
|
||||||
display:block;
|
display:block;
|
||||||
}
|
}
|
||||||
.form_notice #notice_data-location_wrap input {
|
.form_notice #notice_data-geo_wrap input {
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
.form_notice #notice_data-location_wrap label {
|
.form_notice #notice_data-geo_wrap label {
|
||||||
font-weight:normal;
|
font-weight:normal;
|
||||||
font-size:1em;
|
font-size:1em;
|
||||||
margin-bottom:0;
|
margin-bottom:0;
|
||||||
text-indent:-9999px;
|
text-indent:-9999px;
|
||||||
}
|
}
|
||||||
.form_notice #notice_data-location_name {
|
.form_notice #notice_data-geo_name {
|
||||||
display:block;
|
display:block;
|
||||||
padding-left:21px;
|
padding-left:21px;
|
||||||
}
|
}
|
||||||
|
@ -111,10 +111,10 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1);
|
|||||||
text-shadow:none;
|
text-shadow:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form_notice span#notice_data-location_name {
|
.form_notice span#notice_data-geo_name {
|
||||||
background-position:0 47%;
|
background-position:0 47%;
|
||||||
}
|
}
|
||||||
.form_notice a#notice_data-location_name {
|
.form_notice a#notice_data-geo_name {
|
||||||
background-position:0 -1711px;
|
background-position:0 -1711px;
|
||||||
}
|
}
|
||||||
.form_notice label[for=notice_data-geo] {
|
.form_notice label[for=notice_data-geo] {
|
||||||
@ -192,7 +192,7 @@ button.close,
|
|||||||
.entity_silence input.submit,
|
.entity_silence input.submit,
|
||||||
.entity_delete input.submit,
|
.entity_delete input.submit,
|
||||||
.notice-options .repeated,
|
.notice-options .repeated,
|
||||||
.form_notice a#notice_data-location_name,
|
.form_notice a#notice_data-geo_name,
|
||||||
.form_notice label[for=notice_data-geo],
|
.form_notice label[for=notice_data-geo],
|
||||||
button.minimize {
|
button.minimize {
|
||||||
background-image:url(../../base/images/icons/icons-01.gif);
|
background-image:url(../../base/images/icons/icons-01.gif);
|
||||||
|
@ -111,10 +111,10 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1);
|
|||||||
text-shadow:none;
|
text-shadow:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form_notice span#notice_data-location_name {
|
.form_notice span#notice_data-geo_name {
|
||||||
background-position:0 47%;
|
background-position:0 47%;
|
||||||
}
|
}
|
||||||
.form_notice a#notice_data-location_name {
|
.form_notice a#notice_data-geo_name {
|
||||||
background-position:0 -1711px;
|
background-position:0 -1711px;
|
||||||
}
|
}
|
||||||
.form_notice label[for=notice_data-geo] {
|
.form_notice label[for=notice_data-geo] {
|
||||||
@ -192,7 +192,7 @@ button.close,
|
|||||||
.entity_silence input.submit,
|
.entity_silence input.submit,
|
||||||
.entity_delete input.submit,
|
.entity_delete input.submit,
|
||||||
.notice-options .repeated,
|
.notice-options .repeated,
|
||||||
.form_notice a#notice_data-location_name,
|
.form_notice a#notice_data-geo_name,
|
||||||
.form_notice label[for=notice_data-geo],
|
.form_notice label[for=notice_data-geo],
|
||||||
button.minimize {
|
button.minimize {
|
||||||
background-image:url(../../base/images/icons/icons-01.gif);
|
background-image:url(../../base/images/icons/icons-01.gif);
|
||||||
|
Loading…
Reference in New Issue
Block a user