diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/cobrands/fixmystreet/barnet.png | bin | 0 -> 52852 bytes | |||
-rw-r--r-- | web/cobrands/fixmystreet/base.scss | 10 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 122 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/images/ie_logo.gif | bin | 2400 -> 2384 bytes | |||
-rw-r--r-- | web/cobrands/fixmystreet/layout.scss | 7 | ||||
-rw-r--r-- | web/js/fixmystreet.js | 7 | ||||
-rw-r--r-- | web/js/jquery.placeholder.min.js | 2 | ||||
-rw-r--r-- | web/js/map-OpenLayers.js | 9 | ||||
-rw-r--r-- | web/js/placeholder_polyfill/placeholder_polyfill.jquery.min.js | 23 | ||||
-rw-r--r-- | web/js/placeholder_polyfill/placeholder_polyfill.min.css | 2 | ||||
-rw-r--r-- | web/js/southampton.js | 16 |
11 files changed, 110 insertions, 88 deletions
diff --git a/web/cobrands/fixmystreet/barnet.png b/web/cobrands/fixmystreet/barnet.png Binary files differnew file mode 100644 index 000000000..0b373fb30 --- /dev/null +++ b/web/cobrands/fixmystreet/barnet.png diff --git a/web/cobrands/fixmystreet/base.scss b/web/cobrands/fixmystreet/base.scss index 068f33ab6..b0e312375 100644 --- a/web/cobrands/fixmystreet/base.scss +++ b/web/cobrands/fixmystreet/base.scss @@ -285,12 +285,22 @@ h4.static-with-rule{ } } :-moz-placeholder { + color:#888888; font: { style:italic; size:0.9375em; } } :-ms-placeholder { + color:#888888; + font: { + style:italic; + size:0.9375em; + } +} +//this only gets used when the browser doesn't support @placeholder +.placeholder { + color:#888888; font: { style:italic; size:0.9375em; diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 29aecef52..c2801c880 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -3,15 +3,6 @@ * FixMyStreet JavaScript */ -//test for and load placeholder polyfill if neccessary -Modernizr.load({ - test: Modernizr.input.placeholder, - nope: [ - '/js/placeholder_polyfill/placeholder_polyfill.min.css', - '/js/placeholder_polyfill/placeholder_polyfill.jquery.min.js' - ] -}); - function form_category_onchange() { var cat = $('#form_category'); var args = { @@ -91,55 +82,76 @@ $(function(){ $html.removeClass('no-js').addClass('js'); + // Preload the new report pin document.createElement('img').src = '/i/pin-green.png'; - //add mobile class if small screen - if (Modernizr.mq('only screen and (max-width:47.9375em)')) { - $html.addClass('mobile'); - $('#map_box').css({ height: '10em' }); - if (typeof fixmystreet !== 'undefined' && fixmystreet.page == 'around') { - // Immediately go full screen map if on around page - $('#site-header').hide(); + var last_type; + $(window).resize(function(){ + var type = $('#site-header').css('borderTopWidth'); + if (type == '4px') { type = 'mobile'; } + else if (type == '0px') { type = 'desktop'; } + else { return; } + if (last_type == type) { return; } + if (type == 'mobile') { + $html.addClass('mobile'); + $('#map_box').prependTo('.content').css({ + zIndex: '', position: '', + top: '', left: '', right: '', bottom: '', + width: '', height: '10em', + margin: '' + }); + if (typeof fixmystreet !== 'undefined') { + fixmystreet.state_map = ''; // XXX + } + if (typeof fixmystreet !== 'undefined' && fixmystreet.page == 'around') { + // Immediately go full screen map if on around page + $('#site-header').hide(); + $('#map_box').prependTo('.wrapper').css({ + position: 'absolute', + top: 0, left: 0, right: 0, bottom: 0, + height: 'auto', + margin: 0 + }); + $('#fms_pan_zoom').css({ top: '2.75em !important' }); + $('.big-green-banner') + .addClass('mobile-map-banner') + .appendTo('#map_box') + .text('Place pin on map') + .prepend('<a href="/">home</a>'); + } + } else { + // Make map full screen on non-mobile sizes. + $html.removeClass('mobile'); + var map_pos = 'fixed', map_height = '100%'; + if ($html.hasClass('ie6')) { + map_pos = 'absolute'; + map_height = $(window).height(); + } $('#map_box').prependTo('.wrapper').css({ - position: 'absolute', + zIndex: 0, position: map_pos, top: 0, left: 0, right: 0, bottom: 0, - height: 'auto', + width: '100%', height: map_height, margin: 0 }); - // Bit yucky, but the ID doesn't exist yet. - $("<style>#fms_pan_zoom { top: 2.75em !important; }</style>").appendTo(document.documentElement); - $('.big-green-banner') - .addClass('mobile-map-banner') - .removeClass('.big-green-banner') - .appendTo('#map_box') - .text('Place pin on map') - .prepend('<a href="/">home</a>'); - } - } else { - // Make map full screen on non-mobile sizes. - var map_pos = 'fixed', map_height = '100%'; - if ($html.hasClass('ie6')) { - map_pos = 'absolute'; - map_height = $(window).height(); - } - $('#map_box').prependTo('.wrapper').css({ - zIndex: 0, position: map_pos, - top: 0, left: 0, right: 0, bottom: 0, - width: '100%', height: map_height, - margin: 0 - }); - if (typeof fixmystreet !== 'undefined') { - fixmystreet.state_map = 'full'; + if (typeof fixmystreet !== 'undefined') { + fixmystreet.state_map = 'full'; + } + if (typeof fixmystreet !== 'undefined' && fixmystreet.page == 'around') { + // Remove full-screen-ness + $('#site-header').show(); + $('#fms_pan_zoom').css({ top: '4.75em !important' }); + $('.big-green-banner') + .removeClass('mobile-map-banner') + .prependTo('#side') + .text('Click map to report a problem'); + } } - } + last_type = type; + }); - //heightfix the desktop .content div - if(Modernizr.mq('only screen and (min-width:48em)')) { - if (!($('body').hasClass('frontpage'))){ - heightFix(window, '.content', -176); - } - } + //add mobile class if small screen + $(window).resize(); $('#pc').focus(); @@ -546,6 +558,18 @@ $.fn.drawer = function(id, ajax) { 'overlayColor': '#000000' }); + /* + * heightfix the desktop .content div + * + * this must be kept near the end so that the + * rendered height is used after any page manipulation (such as tabs) + */ + if (!$('html.mobile').length) { + if (!($('body').hasClass('frontpage'))){ + heightFix(window, '.content', -176); + } + } + }); /* diff --git a/web/cobrands/fixmystreet/images/ie_logo.gif b/web/cobrands/fixmystreet/images/ie_logo.gif Binary files differindex 66dd1de22..cfcbd258b 100644 --- a/web/cobrands/fixmystreet/images/ie_logo.gif +++ b/web/cobrands/fixmystreet/images/ie_logo.gif diff --git a/web/cobrands/fixmystreet/layout.scss b/web/cobrands/fixmystreet/layout.scss index 6247c7474..ff75409ec 100644 --- a/web/cobrands/fixmystreet/layout.scss +++ b/web/cobrands/fixmystreet/layout.scss @@ -570,8 +570,15 @@ body.twothirdswidthpage { .ie6, .ie7 { #user-meta { z-index:1; + p { + top:-2em; + } } } +.ie6 #user-meta { + width:57em; //ie6 doesn't like max-width +} + // Wraps around #key-tools box - sticks to the bottom of the screen on desktop diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js index b1a8f1889..834aa4ed3 100644 --- a/web/js/fixmystreet.js +++ b/web/js/fixmystreet.js @@ -8,7 +8,7 @@ function form_category_onchange() { var args = { category: cat.val() }; - + if ( typeof fixmystreet !== 'undefined' ) { args.latitude = fixmystreet.latitude; args.longitude = fixmystreet.longitude; @@ -159,8 +159,9 @@ $(function(){ timer = window.setTimeout(email_alert_close, 2000); }); - - $('#form_category').change( form_category_onchange ); + // Using delegate here because we *might* be running under a cobrand which isn't jQuery 1.7+ + // Delegation is necessary because #form_category may be replaced during the lifetime of the page + $("#problem_form").delegate("select#form_category", "change", form_category_onchange ); // Geolocation if (geo_position_js.init()) { diff --git a/web/js/jquery.placeholder.min.js b/web/js/jquery.placeholder.min.js new file mode 100644 index 000000000..122277a31 --- /dev/null +++ b/web/js/jquery.placeholder.min.js @@ -0,0 +1,2 @@ +/*! http://mths.be/placeholder v2.0.5 by @mathias */ +;(function(f,h,$){var a='placeholder' in h.createElement('input'),d='placeholder' in h.createElement('textarea'),i=$.fn,c=$.valHooks,k,j;if(a&&d){j=i.placeholder=function(){return this};j.input=j.textarea=true}else{j=i.placeholder=function(){var l=this;l.filter((a?'textarea':':input')+'[placeholder]').not('.placeholder').bind({'focus.placeholder':b,'blur.placeholder':e}).data('placeholder-enabled',true).trigger('blur.placeholder');return l};j.input=a;j.textarea=d;k={get:function(m){var l=$(m);return l.data('placeholder-enabled')&&l.hasClass('placeholder')?'':m.value},set:function(m,n){var l=$(m);if(!l.data('placeholder-enabled')){return m.value=n}if(n==''){m.value=n;if(m!=h.activeElement){e.call(m)}}else{if(l.hasClass('placeholder')){b.call(m,true,n)||(m.value=n)}else{m.value=n}}return l}};a||(c.input=k);d||(c.textarea=k);$(function(){$(h).delegate('form','submit.placeholder',function(){var l=$('.placeholder',this).each(b);setTimeout(function(){l.each(e)},10)})});$(f).bind('beforeunload.placeholder',function(){$('.placeholder').each(function(){this.value=''})})}function g(m){var l={},n=/^jQuery\d+$/;$.each(m.attributes,function(p,o){if(o.specified&&!n.test(o.name)){l[o.name]=o.value}});return l}function b(m,n){var l=this,o=$(l);if(l.value==o.attr('placeholder')&&o.hasClass('placeholder')){if(o.data('placeholder-password')){o=o.hide().next().show().attr('id',o.removeAttr('id').data('placeholder-id'));if(m===true){return o[0].value=n}o.focus()}else{l.value='';o.removeClass('placeholder')}}}function e(){var q,l=this,p=$(l),m=p,o=this.id;if(l.value==''){if(l.type=='password'){if(!p.data('placeholder-textinput')){try{q=p.clone().attr({type:'text'})}catch(n){q=$('<input>').attr($.extend(g(this),{type:'text'}))}q.removeAttr('name').data({'placeholder-password':true,'placeholder-id':o}).bind('focus.placeholder',b);p.data({'placeholder-textinput':q,'placeholder-id':o}).before(q)}p=p.removeAttr('id').hide().prev().attr('id',o).show()}p.addClass('placeholder');p[0].value=p.attr('placeholder')}else{p.removeClass('placeholder')}}}(this,document,jQuery));
\ No newline at end of file diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 6ffcb5c1d..89c862847 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -210,6 +210,10 @@ $(function(){ displayProjection: new OpenLayers.Projection("EPSG:4326") }); + if ($('html').hasClass('mobile')) { + $('#fms_pan_zoom').css({ top: '2.75em !important' }); + } + fixmystreet.layer_options = OpenLayers.Util.extend({ zoomOffset: fixmystreet.zoomOffset, transitionEffect: 'resize', @@ -428,11 +432,6 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { }, function(data) { $('#councils_text').html(data.councils_text); $('#form_category_row').html(data.category); - /* Need to reset this here as it gets removed when we replace - the HTML for the dropdown */ - if ( data.has_open311 > 0 ) { - $('#form_category').change( form_category_onchange ); - } }); $('#side-form, #site-logo').show(); diff --git a/web/js/placeholder_polyfill/placeholder_polyfill.jquery.min.js b/web/js/placeholder_polyfill/placeholder_polyfill.jquery.min.js deleted file mode 100644 index 0c2f19be5..000000000 --- a/web/js/placeholder_polyfill/placeholder_polyfill.jquery.min.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* HTML5 placeholder polyfill -* -* code: https://github.com/ginader/HTML5-placeholder-polyfill -* please report issues at: https://github.com/ginader/HTML5-placeholder-polyfill/issues -* -* Copyright (c) 2012 Dirk Ginader (ginader.de) -* Dual licensed under the MIT and GPL licenses: -* http://www.opensource.org/licenses/mit-license.php -* http://www.gnu.org/licenses/gpl.html -* -* Version: 1.8 -*/ -(function(e){var b=false;function c(f,g){if(e.trim(f.val())===""){f.data("placeholder").removeClass(g.hideClass);}else{f.data("placeholder").addClass(g.hideClass); -}}function a(h,g){var f=g.is("textarea");h.css({width:g.innerWidth()-(f?20:4),height:g.innerHeight()-6,lineHeight:g.css("line-height"),whiteSpace:f?"normal":"nowrap",overflow:"hidden"}).offset(g.offset()); -}function d(f){if(b&&window.console&&window.console.log){window.console.log(f);}}e.fn.placeHolder=function(f){var g=this;this.options=e.extend({className:"placeholder",visibleToScreenreaders:true,visibleToScreenreadersHideClass:"placeholder-hide-exept-screenreader",visibleToNoneHideClass:"placeholder-hide"},f); -this.options.hideClass=this.options.visibleToScreenreaders?this.options.visibleToScreenreadersHideClass:this.options.visibleToNoneHideClass;return e(this).each(function(){var h=e(this),l=h.attr("placeholder"),m=h.attr("id"),i,k,j; -i=h.closest("label")[0];h.attr("placeholder","");if(!i&&!m){d("the input element with the placeholder needs an id!");return;}i=i||e('label[for="'+m+'"]'); -if(!i){d("the input element with the placeholder needs a label!");return;}i.removeClass("visuallyhidden").addClass("visuallyhidden-with-placeholder");k=e('<span class="'+g.options.className+'">'+l+"</span>").appendTo(i); -j=(k.width()>h.width());if(j){k.attr("title",l);}a(k,h);h.data("placeholder",k);k.data("input",k);k.click(function(){e(this).data("input").focus();});h.focusin(function(){e(this).data("placeholder").addClass(g.options.hideClass); -});h.focusout(function(){c(e(this),g.options);});c(h,g.options);e(document).bind("fontresize",function(){a(k,h);});if(e.event.special.resize){e("textarea").bind("resize",function(n){a(k,h); -});}else{e("textarea").css("resize","none");}});};e(function(){if("placeholder" in e("<input>")[0]){return;}e("input[placeholder], textarea[placeholder]").placeHolder({visibleToScreenreaders:true}); -});})(jQuery);
\ No newline at end of file diff --git a/web/js/placeholder_polyfill/placeholder_polyfill.min.css b/web/js/placeholder_polyfill/placeholder_polyfill.min.css deleted file mode 100644 index 602cf1fe3..000000000 --- a/web/js/placeholder_polyfill/placeholder_polyfill.min.css +++ /dev/null @@ -1,2 +0,0 @@ -label span.placeholder{position:absolute;font-size:75%;color:#999;font-family:sans-serif;padding:4px 3px;z-index:1}label span.placeholder-hide-exept-screenreader{clip:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px);padding:0!important;border:0!important;height:1px!important;width:1px!important;overflow:hidden} -label span.placeholder-hide{display:none}label.visuallyhidden-with-placeholder{clip:auto!important;height:auto!important;overflow:visible!important;position:absolute!important;left:-999em}
\ No newline at end of file diff --git a/web/js/southampton.js b/web/js/southampton.js index 1f3e16105..c0fa48b06 100644 --- a/web/js/southampton.js +++ b/web/js/southampton.js @@ -15,13 +15,16 @@ $(function(){ } }).blur(function(){ var input = $(this); - if (input.val() == '' || input.val() == input.attr('placeholder')) { + if (input.val() === '' || input.val() == input.attr('placeholder')) { input.css({ 'color': '#999999' }); input.val(input.attr('placeholder')); } }).blur(); - - $('#form_category').change(function(){ + + // use on() here because the #form_category may be replaced + // during the page's lifetime + $("#problem_form").on("change.southampton", "select#form_category", + function() { var category = $(this).val(); if ('Potholes' == category) { if (!$('#potholes_extra').length) { @@ -39,12 +42,13 @@ $(function(){ '<option>Deeper than a tennis ball' + '</select></div></div>'; $('#form_title').closest('div.form-field').after(qns); - } + } $('#potholes_extra').show('fast'); } else { $('#potholes_extra').hide('fast'); - } - }).change(); + } + } + ).change(); // change called to trigger (in case we've come in with potholes selected) }); |