diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 49 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/staff.js | 2 | ||||
-rw-r--r-- | web/cobrands/sass/_base.scss | 65 | ||||
-rw-r--r-- | web/cobrands/sass/_fixedthead.scss | 4 | ||||
-rw-r--r-- | web/js/jquery.fixedthead.js | 81 | ||||
-rw-r--r-- | web/vendor/geo.min.js | 85 |
6 files changed, 8 insertions, 278 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index ab4a5137f..7c7b3a9d0 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -217,7 +217,7 @@ fixmystreet.geolocate = { var spincolor = $('<span>').css("color","white").css("color") === $('#front-main').css("background-color") ? 'white' : 'yellow'; $link.append(' <img src="/cobrands/fixmystreet/images/spinner-' + spincolor + '.gif" alt="" align="bottom">'); } - geo_position_js.getCurrentPosition(function(pos) { + navigator.geolocation.getCurrentPosition(function(pos) { $link.find('img').remove(); success_callback(pos); }, function(err) { @@ -409,23 +409,15 @@ $.extend(fixmystreet.set_up, { }, report_geolocation: function() { - if (!geo_position_js.init()) { - return; - } - if ($('.js-geolocate').length) { - var link = $('.js-geolocate').attr('action'); - link = '<a href="' + link + '" id="geolocate_link">… ' + translation_strings.geolocate + '</a>'; - if ($('body.frontpage').length) { - $('.js-geolocate').after(link); - } else{ - $('.js-geolocate').append(link); - } + if ('geolocation' in navigator) { fixmystreet.geolocate.setup(function(pos) { var latitude = pos.coords.latitude; var longitude = pos.coords.longitude; var page = $('#geolocate_link').attr('href'); location.href = page + '?latitude=' + latitude + ';longitude=' + longitude; }); + } else { + $('#geolocate_link').hide(); } }, @@ -604,13 +596,6 @@ $.extend(fixmystreet.set_up, { } }, - fixed_thead: function() { - var thead = $('.nicetable thead'); - if (thead.fixedThead) { - thead.fixedThead(); - } - }, - report_list_filters: function() { // Hide the pin filter submit button. Not needed because we'll use JS // to refresh the map when the filter inputs are changed. @@ -623,12 +608,6 @@ $.extend(fixmystreet.set_up, { mobile_ui_tweaks: function() { //move 'skip this step' link on mobile $('.mobile #skip-this-step').addClass('chevron').wrap('<li>').parent().appendTo('#key-tools'); - - // nicetable - on mobile shift 'name' col to be a row - $('.mobile .nicetable th.title').remove(); - $('.mobile .nicetable td.title').each(function(i) { - $(this).attr('colspan', 5).insertBefore($(this).parent('tr')).wrap('<tr class="heading" />'); - }); }, on_mobile_nav_click: function() { @@ -808,26 +787,6 @@ $.extend(fixmystreet.set_up, { }); }, - promo_elements: function() { - // Add close buttons for .promo's - if ($('.promo').length) { - $('.promo').append('<a href="#" class="close-promo">x</a>'); - } - //only close its own parent - $('.promo').on('click', '.close-promo', function(e) { - e.preventDefault(); - $(this).parent('.promo').animate({ - 'height':0, - 'margin-bottom':0, - 'padding-top':0, - 'padding-bottom':0 - },{ - duration:500, - queue:false - }).fadeOut(500); - }); - }, - ajax_history: function() { $('#map_sidebar').on('click', '.item-list--reports a', function(e) { if (e.metaKey || e.ctrlKey) { diff --git a/web/cobrands/fixmystreet/staff.js b/web/cobrands/fixmystreet/staff.js index 32824a563..ffc529250 100644 --- a/web/cobrands/fixmystreet/staff.js +++ b/web/cobrands/fixmystreet/staff.js @@ -313,7 +313,7 @@ $.extend(fixmystreet.set_up, { }); } - if (geo_position_js.init()) { + if ('geolocation' in navigator) { fixmystreet.geolocate.setup(function(pos) { var latlon = new OpenLayers.LonLat(pos.coords.longitude, pos.coords.latitude); var bng = latlon.clone().transform( diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss index a3861738a..016967457 100644 --- a/web/cobrands/sass/_base.scss +++ b/web/cobrands/sass/_base.scss @@ -1832,67 +1832,6 @@ label .muted { } -table.nicetable { - width:100%; - margin-bottom:2em; - thead { - border-bottom:0.25em solid #ccc; - th { - font-size:0.75em; - } - } - tr { - &.a { - background:#f6f6f6; - } - &.gone { - color: #666666; - background-color: #cccccc; - } - &:hover { - background:#FFF5CC; - cursor:pointer; - } - td { - padding:0.25em; - a { - &:hover { - text-decoration:none; - } - } - } - } - .title { - text-align: $left; - } - .data { - width:12%; - } -} - -.promo { - margin: 0 -1em 1em; - color: $primary_text; - background: $primary; - padding:1em; - overflow:hidden; - position: relative; - .close-promo { - position:absolute; - top:0.5em; - #{$right}: 0.5em; - display:block; - width:16px; - height:16px; - text-indent:-999999px; - background:url($image-sprite) -341px -263px no-repeat; - @include border-radius(4px); - &:hover { - background:#222 url($image-sprite) -341px -223px no-repeat; - } - } -} - .alert { margin: 0 -1em 1em; background:#ff0000; @@ -2019,6 +1958,9 @@ table.nicetable { } } } +.no-js #geolocate_link { + display: none !important; +} #front-howto { #front_stats { @@ -2408,7 +2350,6 @@ table.nicetable { } @import "_admin"; -@import "_fixedthead"; @import "_dropzone"; @import "_multiselect"; @import "_autocomplete"; diff --git a/web/cobrands/sass/_fixedthead.scss b/web/cobrands/sass/_fixedthead.scss deleted file mode 100644 index c1896e5d8..000000000 --- a/web/cobrands/sass/_fixedthead.scss +++ /dev/null @@ -1,4 +0,0 @@ -.js-fixed-thead__clone { - position: fixed; - background: #fff; -}
\ No newline at end of file diff --git a/web/js/jquery.fixedthead.js b/web/js/jquery.fixedthead.js deleted file mode 100644 index 33e60f721..000000000 --- a/web/js/jquery.fixedthead.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - * jQuery.fixedThead.js - * By Zarino at mySociety - */ - -(function ($) { - - // Call this on a <thead> element and it'll be given a class - // of '.js-fixed-thead__clone' when you scroll down. eg: - // $('#my-table thead').fixedThead() - // - // You'll probably want to specify some CSS styles like: - // .js-fixed-thead__clone { position: fixed; background: #fff; } - - $.fn.fixedThead = function() { - - var calculateCloneDimensions = function calculateCloneDimensions($originalThead, $cloneThead){ - $cloneThead.css({ - width: $originalThead.width() - }); - - $('tr', $originalThead).each(function(tr_index, tr){ - $('th', tr).each(function(th_index, th){ - $cloneThead.find('tr:eq(' + tr_index + ') th:eq(' + th_index + ')').css({ - width: $(th).width() - }); - }); - }); - } - - var showOrHideClone = function showOrHideClone($table, $originalThead, $cloneThead){ - var bounds = $table[0].getBoundingClientRect(); - - // First we detect whether *any* of the table is visible, - // then, if it is, we position the fixed thead so that it - // never extends outside of the table bounds even when the - // visible portion of the table is shorter than the thead. - - if(bounds.top <= 0 && bounds.bottom >= 0){ - $cloneThead.css('display', $originalThead.css('display')); - - var rowHeight = $cloneThead.outerHeight(); - if(bounds.bottom < rowHeight){ - $cloneThead.css({ - top: (rowHeight - bounds.bottom) * -1 - }); - } else { - $cloneThead.css({ - top: 0 - }); - } - - } else { - $cloneThead.css('display', 'none'); - } - } - - return this.each(function() { - var $originalThead = $(this); - var $table = $originalThead.parent('table'); - var $cloneThead = $originalThead.clone().addClass('js-fixed-thead__clone'); - - $cloneThead.insertAfter($originalThead); - $cloneThead.css('display', 'none'); - - calculateCloneDimensions($originalThead, $cloneThead); - showOrHideClone($table, $originalThead, $cloneThead); - - $(window).resize(function(){ - calculateCloneDimensions($originalThead, $cloneThead); - showOrHideClone($table, $originalThead, $cloneThead); - }); - - $(window).scroll(function(){ - showOrHideClone($table, $originalThead, $cloneThead); - }); - }); - - }; - -}(jQuery)); diff --git a/web/vendor/geo.min.js b/web/vendor/geo.min.js deleted file mode 100644 index 4f44b30ca..000000000 --- a/web/vendor/geo.min.js +++ /dev/null @@ -1,85 +0,0 @@ -// geo-location-javascript v0.4.8 http://code.google.com/p/geo-location-javascript/ Copyright (c) 2009 Stan Wiechers. Licensed under the MIT licenses. - -var bb_success;var bb_error;var bb_blackberryTimeout_id=-1;function handleBlackBerryLocationTimeout() -{if(bb_blackberryTimeout_id!=-1) -{bb_error({message:"Timeout error",code:3});}} -function handleBlackBerryLocation() -{clearTimeout(bb_blackberryTimeout_id);bb_blackberryTimeout_id=-1;if(bb_success&&bb_error) -{if(blackberry.location.latitude==0&&blackberry.location.longitude==0) -{bb_error({message:"Position unavailable",code:2});} -else -{var timestamp=null;if(blackberry.location.timestamp) -{timestamp=new Date(blackberry.location.timestamp);} -bb_success({timestamp:timestamp,coords:{latitude:blackberry.location.latitude,longitude:blackberry.location.longitude}});} -bb_success=null;bb_error=null;}} -var geo_position_js=function(){var pub={};var provider=null;var u="undefined";pub.showMap=function(latitude,longitude) -{if(typeof(blackberry)!=u) -{blackberry.launch.newMap({"latitude":latitude*100000,"longitude":-longitude*100000});} -else -{window.location="http://maps.google.com/maps?q=loc:"+latitude+","+longitude;}} -pub.getCurrentPosition=function(success,error,opts) -{provider.getCurrentPosition(success,error,opts);} -pub.init=function() -{try -{if(typeof(geo_position_js_simulator)!=u) -{provider=geo_position_js_simulator;} -else if(typeof(bondi)!=u&&typeof(bondi.geolocation)!=u) -{provider=bondi.geolocation;} -else if(typeof(navigator.geolocation)!=u) -{provider=navigator.geolocation;pub.getCurrentPosition=function(success,error,opts) -{function _success(p) -{if(typeof(p.latitude)!=u) -{success({timestamp:p.timestamp,coords:{latitude:p.latitude,longitude:p.longitude}});} -else -{success(p);}} -provider.getCurrentPosition(_success,error,opts);}} -else if(typeof(window.blackberry)!=u&&blackberry.location.GPSSupported) -{if(typeof(blackberry.location.setAidMode)==u) -{return false;} -blackberry.location.setAidMode(2);pub.getCurrentPosition=function(success,error,opts) -{bb_success=success;bb_error=error;if(opts['timeout']) -{bb_blackberryTimeout_id=setTimeout("handleBlackBerryLocationTimeout()",opts['timeout']);} -else -{bb_blackberryTimeout_id=setTimeout("handleBlackBerryLocationTimeout()",60000);} -blackberry.location.onLocationUpdate("handleBlackBerryLocation()");blackberry.location.refreshLocation();} -provider=blackberry.location;} -else if(typeof(window.google)!="undefined"&&typeof(google.gears)!="undefined") -{provider=google.gears.factory.create('beta.geolocation');pub.getCurrentPosition=function(successCallback,errorCallback,options) -{function _successCallback(p) -{if(typeof(p.latitude)!="undefined") -{successCallback({timestamp:p.timestamp,coords:{latitude:p.latitude,longitude:p.longitude}});} -else -{successCallback(p);}} -provider.getCurrentPosition(_successCallback,errorCallback,options);}} -else if(typeof(Mojo)!=u&&typeof(Mojo.Service.Request)!="Mojo.Service.Request") -{provider=true;pub.getCurrentPosition=function(success,error,opts) -{parameters={};if(opts) -{if(opts.enableHighAccuracy&&opts.enableHighAccuracy==true) -{parameters.accuracy=1;} -if(opts.maximumAge) -{parameters.maximumAge=opts.maximumAge;} -if(opts.responseTime) -{if(opts.responseTime<5) -{parameters.responseTime=1;} -else if(opts.responseTime<20) -{parameters.responseTime=2;} -else -{parameters.timeout=3;}}} -r=new Mojo.Service.Request('palm://com.palm.location',{method:"getCurrentPosition",parameters:parameters,onSuccess:function(p){success({timestamp:p.timestamp,coords:{latitude:p.latitude,longitude:p.longitude,heading:p.heading}});},onFailure:function(e){if(e.errorCode==1) -{error({code:3,message:"Timeout"});} -else if(e.errorCode==2) -{error({code:2,message:"Position unavailable"});} -else -{error({code:0,message:"Unknown Error: webOS-code"+errorCode});}}});}} -else if(typeof(device)!=u&&typeof(device.getServiceObject)!=u) -{provider=device.getServiceObject("Service.Location","ILocation");pub.getCurrentPosition=function(success,error,opts) -{function callback(transId,eventCode,result){if(eventCode==4) -{error({message:"Position unavailable",code:2});} -else -{success({timestamp:null,coords:{latitude:result.ReturnValue.Latitude,longitude:result.ReturnValue.Longitude,altitude:result.ReturnValue.Altitude,heading:result.ReturnValue.Heading}});}} -var criteria=new Object();criteria.LocationInformationClass="BasicLocationInformation";provider.ILocation.GetLocation(criteria,callback);}}} -catch(e){if(typeof(console)!=u) -{console.log(e);} -return false;} -return provider!=null;} -return pub;}();
\ No newline at end of file |