Some code cleaning for geo UI

This commit is contained in:
Sarven Capadisli 2010-01-08 13:58:23 +00:00
parent 69f567c7be
commit 54c18e68da
5 changed files with 32 additions and 34 deletions

View File

@ -51,8 +51,7 @@ var SN = { // StatusNet
NoticeLon: 'notice_data-lon',
NoticeLocationId: 'notice_data-location_id',
NoticeLocationNs: 'notice_data-location_ns',
NoticeLocationName: 'notice_data-location_name',
NoticeLocationCookieName: 'location_enabled',
NoticeGeoName: 'notice_data-geo_name',
NoticeDataGeo: 'notice_data-geo',
NoticeDataGeoSelected: 'notice_data-geo_selected'
}
@ -460,7 +459,7 @@ var SN = { // StatusNet
var NLon = $('#'+SN.C.S.NoticeLon).val();
var NLNS = $('#'+SN.C.S.NoticeLocationNs).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);
function removeNoticeDataGeo() {
@ -473,7 +472,7 @@ var SN = { // StatusNet
$('#'+SN.C.S.NoticeLocationId).val('');
$('#'+SN.C.S.NoticeDataGeo).attr('checked', false);
$.cookie(SN.C.S.NoticeLocationCookieName, 'disabled');
$.cookie(SN.C.S.NoticeDataGeo, 'disabled');
}
function getJSONgeocodeURL(geocodeURL, data) {
@ -497,10 +496,10 @@ var SN = { // StatusNet
NLN_text = location.name;
}
$('#'+SN.C.S.NoticeLocationName)
.replaceWith('<a id="notice_data-location_name"/>');
$('#'+SN.C.S.NoticeGeoName)
.replaceWith('<a id="notice_data-geo_name"/>');
$('#'+SN.C.S.NoticeLocationName)
$('#'+SN.C.S.NoticeGeoName)
.attr('href', location.url)
.text(NLN_text)
.click(function() {
@ -524,32 +523,31 @@ var SN = { // StatusNet
'NLNU': location.url,
'NDG': true
};
$.cookie(SN.C.S.NoticeLocationCookieName, JSON.stringify(cookieValue));
$.cookie(SN.C.S.NoticeDataGeo, JSON.stringify(cookieValue));
});
}
if (NDGe.length > 0) {
var cookieValue = $.cookie(SN.C.S.NoticeLocationCookieName);
if (cookieValue == 'disabled') {
if ($.cookie(SN.C.S.NoticeDataGeo) == 'disabled') {
NDGe.attr('checked', false);
}
else {
NDGe.attr('checked', true);
}
var NLE = $('#notice_data-location_wrap');
var geocodeURL = NLE.attr('title');
NLE.removeAttr('title');
var NGW = $('#notice_data-geo_wrap');
var geocodeURL = NGW.attr('title');
NGW.removeAttr('title');
$('label[for='+SN.C.S.NoticeDataGeo+']').attr('title', jQuery.trim($('label[for='+SN.C.S.NoticeDataGeo+']').text()));
NDGe.change(function() {
var NLN = $('#'+SN.C.S.NoticeLocationName);
var NLN = $('#'+SN.C.S.NoticeGeoName);
if (NLN.length > 0) {
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');
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.prepend('<span id="'+SN.C.S.NoticeLocationName+'">Geo</span> <button class="minimize">&#95;</button> <button class="close">&#215;</button>');
NDGS.prepend('<span id="'+SN.C.S.NoticeGeoName+'">Geo</span> <button class="minimize">&#95;</button> <button class="close">&#215;</button>');
var NLN = $('#'+SN.C.S.NoticeLocationName);
var NLN = $('#'+SN.C.S.NoticeGeoName);
NLN.addClass('processing');
$('#'+SN.C.S.NoticeDataGeoSelected+' button.close').click(function(){
@ -582,7 +580,7 @@ var SN = { // StatusNet
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) {
navigator.geolocation.getCurrentPosition(
function(position) {
@ -623,17 +621,17 @@ var SN = { // StatusNet
}
}
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.NoticeLon).val(cookieValue.NLon);
$('#'+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS);
$('#'+SN.C.S.NoticeLocationId).val(cookieValue.NLID);
$('#'+SN.C.S.NoticeDataGeo).attr('checked', cookieValue.NDG);
$('#'+SN.C.S.NoticeLocationName)
.replaceWith('<a id="notice_data-location_name"/>');
$('#'+SN.C.S.NoticeGeoName)
.replaceWith('<a id="notice_data-geo_name"/>');
$('#'+SN.C.S.NoticeLocationName)
$('#'+SN.C.S.NoticeGeoName)
.attr('href', cookieValue.NLNU)
.text(cookieValue.NLN)
.click(function() {

View File

@ -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_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')));
$this->out->checkbox('notice_data-geo', _('Share your location'), true);
$this->out->elementEnd('div');

View File

@ -555,7 +555,7 @@ margin-bottom:0;
line-height:1.618;
}
.form_notice #notice_data-attach_selected code,
.form_notice #notice_data-location_name {
.form_notice #notice_data-geo_name {
float:left;
width:80%;
display:block;
@ -575,7 +575,7 @@ font-size:0.8em;
float:left;
}
.form_notice #notice_data-location_wrap label {
.form_notice #notice_data-geo_wrap label {
position:absolute;
top:25px;
right:4px;
@ -585,16 +585,16 @@ width:16px;
height:16px;
display:block;
}
.form_notice #notice_data-location_wrap input {
.form_notice #notice_data-geo_wrap input {
display:none;
}
.form_notice #notice_data-location_wrap label {
.form_notice #notice_data-geo_wrap label {
font-weight:normal;
font-size:1em;
margin-bottom:0;
text-indent:-9999px;
}
.form_notice #notice_data-location_name {
.form_notice #notice_data-geo_name {
display:block;
padding-left:21px;
}

View File

@ -111,10 +111,10 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1);
text-shadow:none;
}
.form_notice span#notice_data-location_name {
.form_notice span#notice_data-geo_name {
background-position:0 47%;
}
.form_notice a#notice_data-location_name {
.form_notice a#notice_data-geo_name {
background-position:0 -1711px;
}
.form_notice label[for=notice_data-geo] {
@ -192,7 +192,7 @@ button.close,
.entity_silence input.submit,
.entity_delete input.submit,
.notice-options .repeated,
.form_notice a#notice_data-location_name,
.form_notice a#notice_data-geo_name,
.form_notice label[for=notice_data-geo],
button.minimize {
background-image:url(../../base/images/icons/icons-01.gif);

View File

@ -111,10 +111,10 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1);
text-shadow:none;
}
.form_notice span#notice_data-location_name {
.form_notice span#notice_data-geo_name {
background-position:0 47%;
}
.form_notice a#notice_data-location_name {
.form_notice a#notice_data-geo_name {
background-position:0 -1711px;
}
.form_notice label[for=notice_data-geo] {
@ -192,7 +192,7 @@ button.close,
.entity_silence input.submit,
.entity_delete input.submit,
.notice-options .repeated,
.form_notice a#notice_data-location_name,
.form_notice a#notice_data-geo_name,
.form_notice label[for=notice_data-geo],
button.minimize {
background-image:url(../../base/images/icons/icons-01.gif);