diff options
Diffstat (limited to 'web')
26 files changed, 1284 insertions, 68 deletions
diff --git a/web/.gitignore b/web/.gitignore index 124be032a..d6e2f1a1a 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -1,4 +1,4 @@ /down.html /_Inline -/bci-live-creation.png -/bci-live-line.png +/fms-live-creation.png +/fms-live-line.png diff --git a/web/cobrands/barnet/layout.scss b/web/cobrands/barnet/layout.scss index 97b27cfff..483f1f20f 100644 --- a/web/cobrands/barnet/layout.scss +++ b/web/cobrands/barnet/layout.scss @@ -231,7 +231,7 @@ body.frontpage { .general-sidebar-notes { - left: 25em; + left: 25.5em; width: 14em; font-size: 1.2em; p { diff --git a/web/cobrands/fixmybarangay/_colours.scss b/web/cobrands/fixmybarangay/_colours.scss new file mode 100644 index 000000000..fcaba8924 --- /dev/null +++ b/web/cobrands/fixmybarangay/_colours.scss @@ -0,0 +1,9 @@ +/* COLOURS */ + +$primary: #fff; //E6DBD6 +$primary_b: #000000; +$primary_text: #222222; + +$contrast1: #00BD08; +$contrast1_dark: #4B8304; +$contrast2: #AA8D11; diff --git a/web/cobrands/fixmybarangay/base.scss b/web/cobrands/fixmybarangay/base.scss new file mode 100644 index 000000000..71c2d8205 --- /dev/null +++ b/web/cobrands/fixmybarangay/base.scss @@ -0,0 +1,56 @@ +@import "../fixmystreet/_h5bp"; +@import "./_colours"; +@import "../fixmystreet/_mixins"; +@import "compass"; + +@import "../fixmystreet/_base"; + +#site-logo{ + width: 225px !important; + background: url('images/sprite.png') -3px -3px no-repeat; +} + +#barangay_buttons { + padding: 1em; +} + +.yellow-btn, +a.yellow-btn, +button.yellow-btn, +input.yellow-btn{ + @include button-reset(#FFD000, #cc9000, #aa7000, #300, #FFD000, #cc9000, #aa7000, #300); + &:visited, &:hover { + color:#300; + } +} + +body.mappage .nav-wrapper div.nav-wrapper-2 { + background: url('images/city6.png') 30% 0% repeat-x; + border-bottom: 2px solid #333; +} +#main-nav ul#main-menu li a.report-a-problem-btn:hover { + background: #fff; +} + + +// Replace Sprite with cobrand sprite +.ie6 #site-logo, +.ie7 #site-logo, +.ie6 body.frontpage #site-logo, +.ie6 #main-nav ul#mysoc-menu li a#mysoc-logo, +.ie7 #main-nav ul#mysoc-menu li a#mysoc-logo, +#fms_pan_zoom_panup, #fms_pan_zoom_pandown, +#fms_pan_zoom_panleft, +#fms_pan_zoom_panright, +#fms_pan_zoom_zoomin, +#fms_pan_zoom_zoomout, +.button-right, +a.button-right, +:hover.button-right, +a:hover.button-right, +.button-left, +a.button-left, +:hover.button-left, +a:hover.button-left { + background-image: url('images/sprite.png'); +}
\ No newline at end of file diff --git a/web/cobrands/fixmybarangay/config.rb b/web/cobrands/fixmybarangay/config.rb new file mode 100644 index 000000000..cab97b18f --- /dev/null +++ b/web/cobrands/fixmybarangay/config.rb @@ -0,0 +1,25 @@ +# Require any additional compass plugins here. + +# Set this to the root of your project when deployed: +http_path = "/" +css_dir = "" +sass_dir = "" +images_dir = "" +javascripts_dir = "" + +# You can select your preferred output style here (can be overridden via the command line): +# output_style = :expanded or :nested or :compact or :compressed + +# To enable relative paths to assets via compass helper functions. Uncomment: +# relative_assets = true + +# To disable debugging comments that display the original location of your selectors. Uncomment: +# line_comments = false + +# If you prefer the indented syntax, you might want to regenerate this +# project again passing --syntax sass, or you can uncomment this: +# preferred_syntax = :sass +# and then run: +# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass + +line_comments = false # by Compass.app diff --git a/web/cobrands/fixmybarangay/images/city6.png b/web/cobrands/fixmybarangay/images/city6.png Binary files differnew file mode 100644 index 000000000..63d7e674c --- /dev/null +++ b/web/cobrands/fixmybarangay/images/city6.png diff --git a/web/cobrands/fixmybarangay/images/city7.png b/web/cobrands/fixmybarangay/images/city7.png Binary files differnew file mode 100644 index 000000000..cea65cb82 --- /dev/null +++ b/web/cobrands/fixmybarangay/images/city7.png diff --git a/web/cobrands/fixmybarangay/images/ie_front_logo.gif b/web/cobrands/fixmybarangay/images/ie_front_logo.gif Binary files differnew file mode 100644 index 000000000..2eeda87ef --- /dev/null +++ b/web/cobrands/fixmybarangay/images/ie_front_logo.gif diff --git a/web/cobrands/fixmybarangay/images/ie_logo.png b/web/cobrands/fixmybarangay/images/ie_logo.png Binary files differnew file mode 100644 index 000000000..454297104 --- /dev/null +++ b/web/cobrands/fixmybarangay/images/ie_logo.png diff --git a/web/cobrands/fixmybarangay/images/pat3.png b/web/cobrands/fixmybarangay/images/pat3.png Binary files differnew file mode 100644 index 000000000..a0f755de9 --- /dev/null +++ b/web/cobrands/fixmybarangay/images/pat3.png diff --git a/web/cobrands/fixmybarangay/images/sprite.png b/web/cobrands/fixmybarangay/images/sprite.png Binary files differnew file mode 100644 index 000000000..cbde4ac7f --- /dev/null +++ b/web/cobrands/fixmybarangay/images/sprite.png diff --git a/web/cobrands/fixmybarangay/layout.scss b/web/cobrands/fixmybarangay/layout.scss new file mode 100644 index 000000000..ccbf00748 --- /dev/null +++ b/web/cobrands/fixmybarangay/layout.scss @@ -0,0 +1,135 @@ +@import "_colours"; +@import "../fixmystreet/_layout"; + +@mixin box_round($radius) { + -webkit-border-radius: $radius; /* Safari 3-4, iOS 1-3.2, Android ≤1.6 */ + border-radius: $radius; /* Opera 10.5, IE9+, Safari 5, Chrome, Firefox 4+, iOS 4, Android 2.1+ */ + + /* useful if you don't want a bg color from leaking outside the border: */ + -moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box; +} + +body { + background: #C7B299; + background-image: url(images/pat3.png); + + .wrapper{ + background: url('images/city7.png') 30% 0% repeat-x; + } +} + + + body.frontpage { + #site-logo{ + width: 370px !important; + height: 70px; + background: url('images/sprite.png') -3px -106px no-repeat; + } + + .wrapper{ + background: url('images/city7.png') 30% 0% repeat-x; + } +} +#main-nav ul#mysoc-menu li a#mysoc-logo { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIkAAAAyCAMAAABf9whNAAAA0lBMVEUAAABAQEBAQEBAQEBNTU1NTU1AQEBNTU1AQEBAQEBAQEBAQEBAQEBAQEBAQEBNTU1NTU1AQEBNTU1AQEBNTU1AQEBAQEBNTU2Mxj9NTU33kx5NTU1NTU1NTU3tHCRmLZEpq+JNTU2TJ4/tHCSTJ4/87iEpq+L3kx5NTU387iH87iHtHCSTJ4/3kx51K5CTJ49mLZGMxj/tHCSx0zVmLZH6wSBmLZFmLZFDdb/zYCFbuZGMxj/3kx5AQEBNTU0pq+LtHCSMxj/3kx787iFmLZGTJ49ns3BGAAAAPXRSTlMAQL+AQIAQECBwMGBQj98gn5/Pr+/vzzC/r79wYI9wv69QcK+vcICfv68QQBAwj0AwMBBggIBQr3BwgEBgSmaQCwAAAflJREFUeF7t1Ndy2zAQhtGfAAX2IpFUseSSOLGd3nt27bT3f6UsQHusRFcKmVxkcGa4wvCG34AQ8V/wPM/zPM8zSaOaxGBHtFpF+IfikqwYO0LmELfiHH/XlLokSBrsiurtPdGkMJJFWFWTSQUZC0RhWMFNRQWuvTw9RS/VOolNEBgAudYpkE5pHqRpEACIZQ4x4RkztxMWd6KWa2DDvFDUBeg9urr6cPAZMIqEDogCmDmJKdwtlbjXOCc1sIRnhyxj0vIMNbeQMUNun5DBOTo6/3oASMhUF6krka3IM1lkikqdGaICMVE2sKSNICkR1sxYyMag5TWQd7bFPH4G8eT8zcOUKIGwJUYuSE7hzoldlZAwM7Dkwg4GQjtmXMtvBZHNiZJ7P+5C3P/2oH9SXyKXo1yJq0sbmmLMkg23h7xCryR1W5L8WqKsmz1BSbqjfNSSiMUGMEB/Bp8ePwdeLF/ZAn1TEssFR1MJIZmyGLUENXNrI8pCK6IMx99fn50tvyyBcuvEKuqKXDcuocgAQ/I7conMGgA5BfD23fvLy4/LT0Ba/v4vphRxR9dnlmIMU4ULO0IgsgPr/rya3H7F4JycoCf3sq0vW5ICiLXO3YtsMC4JqbG3uCFKMSb3nYuwNyLKMK6Q6wj7a7oMY4vwJwwG8TzP8zzP834CEcRJKkEhVogAAAAASUVORK5CYII="); +} +#front-main { + color: $primary_text; + background: rgba(255,255,255,0.1); + margin-top: 70px; + + #postcodeForm { + margin-left: 0; + margin-right: 0; + } + + a { + text-decoration:none; + } + + p { + padding-bottom:4px; + } +} + +.nav-wrapper { + .nav-wrapper-2 { + border-top: solid 4px $primary; + @include border-image(none); + } +} +#main-nav { + ul { + &#mysoc-menu { + background:$primary; + padding: 1px 0.5em; + } + &#main-menu{ + padding: 3px 0; + li{ + a{ + //@extend .report-a-problem-btn; + color: #fff; + padding: 0.7em; + background-color: rgba(0,0,0,0); + background-image: none; + &:hover{ + background-color: rgba(0,0,0,0.8); + } + } + } + } + + } +} +body.mappage #main-nav ul#main-menu li a, +body.mappage #main-nav ul#main-menu li span, +body #main-nav ul#main-menu li a, +body #main-nav ul#main-menu li span +{ + color: #fff; + padding: 0.7em; + background-color: rgba(0,0,0,0); + background-image: none; + @include box_round(0.35em); + margin-left: 3px; + + &.report-a-problem-btn{ + color: #fff; + padding: 0.7em; + background-color: rgba(0,0,0,0); + background-image: none; + margin: 0; + } + + &.fmb-bgy-btn { + color: #fcc921; + } + + + &:hover{ + background-color: rgba(0,0,0,0.75); + background-image: none; + } + +} + + +#user-meta { + max-width: 96%; +} + + + +#front-howto { + #front_stats { + border-top: 0.25em solid #000; + div { + big { + color: #000; + } + } + } +} + +@import "message_manager";
\ No newline at end of file diff --git a/web/cobrands/fixmybarangay/message_manager.scss b/web/cobrands/fixmybarangay/message_manager.scss new file mode 100644 index 000000000..9d9555640 --- /dev/null +++ b/web/cobrands/fixmybarangay/message_manager.scss @@ -0,0 +1,174 @@ +@import "_colours"; + +$mm_status_message_color: #a66; +$mm_border_color: #eee; + +$color_reply_bg: #cccccc; +$color_bg_reply_0: #E8E8E8; +$color_bg_reply_1: #DEDEDE; +$color_bg_reply_2: #D6D6D6; +$color_bg_reply_3: #D1D1D1; +$color_bg_reply_4: #C9C9C9; +$color_bg_reply_5: #BFBFBF; +$color_bg_reply_6: #B8B8B8; +$color_bg_mm_list: #F6F6F6; + +$weak_text_color: #666; + +#message_manager { + + #message-control { + #mm-username-container { + display: none; // hidden during dev + padding: 8px; + text-align: right; + color: $mm_status_message_color; + font-style: italic; + span { + color: #000; + font-style: normal; + } + } + #mm-status-message-container { + min-height: 1.4em; + margin: 0 0 8px 0.5em; + padding: 8px 4px; + color: $mm_status_message_color; + font-style: italic; + } + #mm-login-container { + display: none; // only shown on/after a 403 + border: 1px solid $mm_border_color; + padding: 0 1em; + margin: 1em; + input { + margin-bottom: 1em; + } + } + } + + #mm-message-list { + ul { + list-style-type: none; + padding: 0; + margin: 0; + li, ul.mm-reply-thread li { + position: relative; + clear: both; + margin: 4px 0 0 0; + padding: 0; + cursor: pointer; + background-color: $color_bg_mm_list; + p { + background-color: inherit; + margin: 0.25em 0 0 0; + padding: 0.5em 1em; + &:hover { background-color: #efe;} + .msg-info-box { + font-style: italic; + font-size: 90%; + color: #666; + border-top: 1px dashed #666; + padding:4px 0 0 0; + margin: 4px 0 0 0; + display: none; + } + } + ul.mm-reply-thread { + li { + margin:0; + } + .mm-reply { + background-color: #ccc; + &:hover {background-color: #eef;} + } + .mm-reply-0 { margin-left: 0em; background-color: $color_bg_reply_0;} + .mm-reply-1 { margin-left: 1em; background-color: $color_bg_reply_1;} + .mm-reply-2 { margin-left: 2em; background-color: $color_bg_reply_2;} + .mm-reply-3 { margin-left: 3em; background-color: $color_bg_reply_3;} + .mm-reply-4 { margin-left: 4em; background-color: $color_bg_reply_4;} + .mm-reply-5 { margin-left: 5em; background-color: $color_bg_reply_5;} + .mm-reply-6 { margin-left: 6em; background-color: $color_bg_reply_6;} + } + &:hover { background-color: #efe;} + &.msg-is-locked { background-color: #fdd;} + &.msg-is-busy { background-color: #ffd;} + &.msg-is-owned { background-color: #dfd;} + &.msg-is-active { + background-color: $contrast1; color:#fff; + p:hover { background-color: $contrast1; color:#fff; } // fix for mouseover on p + } + span.msg-tag { + width: 3em; + float:left; + } + input[type=radio] { + display: block; + float: left; + } + label, span.msg-text { + display: block; + font-weight: normal; + margin: 0.1em 0 0.1em 4.5em; + } + .mm-msg-action { + display: none; + padding: 0.2em 0.4em; + color: white; + text-align: center; + position: absolute; + top: 4px; + &:hover { background-color: black;} + } + .mm-hide { + right:0px; + background-color: red; + } + .mm-info { + right:1.5em; + background-color: blue; + } + .mm-rep { + right:2.6em; + background-color: green; + } + } + } + } + p.mm-empty { + margin: 1em; + } +} +#show_messages, #add_support, #reply-submit { // COPY TO UPDATE button + margin: 1em; +} + +#reply-form-container, +#hide-form-container { + p { + color: #000; + } + #hide-form, + #reply-form{ + margin-top: 2em; + textarea { + min-height: 3em; + margin-bottom: 0.5em; + } + } + #mm-boilerplate-replies-box, #mm-boilerplate-hide-reasons-box { + overflow: hidden; + display: none; + } +} +div#mm-admin-buttons { + display:block; + text-align: right; + float:right; + font-size:80%; + padding:4px 8px 4px 0; + a { + display: block; + } + +} diff --git a/web/cobrands/fixmybarangay/message_manager_client.js b/web/cobrands/fixmybarangay/message_manager_client.js new file mode 100644 index 000000000..fa04063c8 --- /dev/null +++ b/web/cobrands/fixmybarangay/message_manager_client.js @@ -0,0 +1,686 @@ +/* + * creates a message_manage object that uses the Message Manager API: + * include this file, then initialise the object when the page is loaded with + * message_manager.config(settings) + * + * i.e., you *must* do something like: + * + * $(document).ready(function() { + * message_manager.config({url_root:'http://yourdomain.com/messages'}) + * } + * + * You'll need to set the url_root, but you can leave everything else to default + * provided your HTML ids and classes are the same as ours (which they might be: + * see the Message Manager's dummy client (at /client) to see the HTML we use). + * + * The (optional) single parameter for .config() is a hash of name-value pairs: + * + * url_root accepts the root URL to the message manager. + * + * want_unique_locks normally MM clients should relinquish all other locks + * when claiming a new one so want_unique_locks defaults + * to true; but you can set it explicitly here. + * + * mm_name name of Message Manager (used in error messages shown + * to user, e.g., "please log in to Message Manager") + * + * msg_prefix all message <li> items have this as their ID prefix + * + * want_nice_msgs don't use language like "lock granted" + * + * *_selector these are the jQuery selects that will be used to find + * the respective elements: + * + * message_list_selector: list of messages + * status_selector: status message display + * login_selector: login form + * + * + * Summary of all methods: + * message_manager.config([options]) + * message_manager.setup_click_listener([options]) + * message_manager.get_available_messages([options]) + * message_manager.request_lock(msg_id, [options]) (default use: client code doesn't need to call this explicitly) + * message_manager.assign_fms_id(msg_id, fms_id, [options]) + * message_manager.hide(msg_id, reason_text, [options]) + * message_manager.reply(msg_id, reply_text, [options]) + * message_manager.show_info(msg_id) + * message_manager.sign_out() + * + * Note: options are {name:value, ...} hashes and often include "callback" which is a function that is executed on success + * but see the docs (request_lock executes callback if the call is successful even if the lock was denied, for example). + * Some methods take 'callback' as the only option, but you still need to pass it as a named option. +*/ + +var message_manager = (function() { + + // default/config values: to be overridden using "config({name:value, ...})" + + var _url_root = 'http://www.example.com/message_manager/'; + var _want_unique_locks = true; + var _msg_prefix = "msg-"; + var _username; + var _mm_name = "Message Manager"; + var _use_fancybox = true; // note: currently *must* have fancybox! + var _want_nice_msgs = false; + + // cached jQuery elements, populated by the (mandatory) call to config() + var $message_list_element; + var $status_element; + var $login_element; + var $htauth_username; + var $htauth_password; + var $hide_reasons; + var $boilerplate_replies; + + var msg_no_config_err = "Config error: no Message Manager URL has been specified"; + + var msg_trying_for_lock = ["Trying for lock...", "Checking message..." ]; + var msg_checking_lock = ["Checking lock...", "Checking message..." ]; + var msg_claiming_lock = ["Claiming lock...", "Checking message..." ]; + var msg_lock_granted_ok = ["Lock granted OK", "Checking message... OK"]; + var msg_lock_denied = ["", "Someone is working with that message right now!"]; + + function get_msg(msg) { + return msg[_want_nice_msgs? 1 : 0]; + } + + var config = function(settings) { + var selectors = { + message_list_selector: '#mm-message-list', + status_selector: '#mm-status-message-container', + login_selector: '#mm-login-container', + username_selector: '#mm-received-username', + htauth_username_selector: '#mm-htauth-username', + htauth_password_selector: '#mm-htauth-password', + boilerplate_hide_reasons: '#mm-boilerplate-hide-reasons-box', + boilerplate_replies: '#mm-boilerplate-replies-box' + }; + if (settings) { + if (typeof settings.url_root === 'string') { + _url_root = settings.url_root; + if (_url_root.length > 0 && _url_root.charAt(_url_root.length-1) !== "/") { + _url_root+="/"; + } + } + if (typeof settings.want_unique_locks !== 'undefined') { + _want_unique_locks = settings.want_unique_locks; + } + if (typeof settings.msg_prefix === 'string') { + _msg_prefix = settings.msg_prefix; + } + for (var sel in selectors) { + if (typeof settings[sel] === 'string') { + selectors[sel] = settings[sel]; + } + } + if (typeof settings.mm_name === 'string') { + _mm_name = settings.mm_name; + } + if (typeof settings.want_nice_msgs !== 'undefined') { + _want_nice_msgs = settings.want_nice_msgs; + } + } + $message_list_element = $(selectors.message_list_selector); + $status_element = $(selectors.status_selector); + $login_element = $(selectors.login_selector); + $htauth_username = $(selectors.htauth_username_selector); + $htauth_password = $(selectors.htauth_password_selector); + $hide_reasons = $(selectors.boilerplate_hide_reasons); + $boilerplate_replies = $(selectors.boilerplate_replies); + if (typeof settings.url_root === 'string' && _url_root.length===0) { + say_status(msg_no_config_err); + } + }; + + // btoa doesn't work on all browers? + var make_base_auth = function(user, password) { + var tok = user + ':' + password; + var hash = btoa(tok); + return "Basic " + hash; + }; + + var get_current_auth_credentials = function() { + var base_auth = ""; + var htauth_un = ""; + var htauth_pw = ""; + if ($htauth_username.size()) { + htauth_un = $htauth_username.val(); + htauth_pw = $htauth_password.val(); + } + if (htauth_un.length === 0 && Modernizr.sessionstorage && sessionStorage.getItem('mm_auth')) { + base_auth = sessionStorage.getItem('mm_auth'); + } else { + base_auth = make_base_auth(htauth_un, htauth_pw); + if (Modernizr.sessionstorage) { + sessionStorage.mm_auth = base_auth; + } + } + return base_auth; + }; + + var sign_out = function() { // clear_current_auth_credentials + if (Modernizr.sessionstorage) { + sessionStorage.removeItem('mm_auth'); + } + if ($htauth_password) { + $htauth_password.val(''); + } + }; + + var show_login_form = function(suggest_username) { + $('.mm-msg', $message_list_element).remove(); // remove (old) messages + if ($htauth_username.size() && ! $htauth_username.val()) { + $htauth_username.val(suggest_username); + } + $login_element.stop().slideDown(); + }; + + var say_status = function (msg) { + if ($status_element) { + $status_element.stop().show().text(msg); + } + }; + + var extract_replies = function(replies, depth) { + var $ul = ""; + if (replies && replies.length > 0) { + $ul = $('<ul class="mm-reply-thread"/>'); + for (var i=0; i<replies.length; i++) { + $ul.append(get_message_li(replies[i], depth)); + } + } + return $ul; + }; + + var get_message_li = function(message_root, depth) { + var msg = message_root.Message; // or use label value + var lockkeeper = message_root.Lockkeeper.username; + var escaped_text = $('<div/>').text(msg.message).html(); + var $p = $('<p/>'); + var $hide_button = $('<a class="mm-msg-action mm-hide" id="mm-hide-' + msg.id + '" href="#hide-form-container">X</a>'); + var $info_button = $('<span class="mm-msg-action mm-info" id="mm-info-' + msg.id + '">i</span>'); + var $reply_button = $('<a class="mm-msg-action mm-rep" id="mm-rep-' + msg.id + '" href="#reply-form-container">reply</a>'); + if (_use_fancybox) { + $reply_button.fancybox(); + $hide_button.fancybox(); + } + if (depth === 0) { + var tag = (!msg.tag || msg.tag === 'null')? ' ' : msg.tag; + tag = $('<span class="msg-tag"/>').html(tag); + var radio = depth > 0? null : $('<input type="radio"/>').attr({ + 'id': 'mm_text_' + msg.id, + 'name': 'mm_text', + 'value': escaped_text + }).wrap('<p/>').parent().html(); + var label = $('<label/>', { + 'class': 'msg-text', + 'for': 'mm_text_' + msg.id + }).text(escaped_text).wrap('<p/>').parent().html(); + $p.append(tag).append(radio).append(label); + } else { + $p.text(escaped_text).addClass('mm-reply mm-reply-' + depth); + } + var $litem = $('<li id="' + _msg_prefix + msg.id + '" class="mm-msg">').append($p).append($hide_button).append($info_button); + if (msg.is_outbound != 1) { + $litem.append($reply_button); + } + if (lockkeeper) { + $litem.addClass(lockkeeper == _username? 'msg-is-owned' : 'msg-is-locked'); + } + var info_text = ""; + if (msg.is_outbound == 1) { + info_text = 'sent on ' + msg.created + ' by ' + msg.sender_token; + } else { + info_text = 'received on ' + msg.created + ' from ' + '<abbr title="'+ msg.sender_token + '">user</abbr>'; + } + $p.append('<div class="msg-info-box" id="msg-info-box-' + msg.id + '">' + info_text + '</div>'); + if (message_root.children) { + $litem.append(extract_replies(message_root.children, depth+1)); + } + return $litem; + }; + + var show_available_messages = function(data, anim_duration) { + var messages = data.messages; + _username = data.username; + var $output = $message_list_element; + if (anim_duration > 0) { + $output.stop().fadeOut(anim_duration, function(){ + render_available_messages(data, anim_duration); + }); + } else { + render_available_messages(data, anim_duration); + } + }; + + // render allows animation (if required) to hide messages before repainting and then revealing them + var render_available_messages = function(data, anim_duration) { + var messages = data.messages; + _username = data.username; + var $output = $message_list_element; + if (messages instanceof Array) { + if (messages.length === 0) { + $output.html('<p class="mm-empty">No messages available.</p>'); + } else { + var $ul = $('<ul class="mm-root"/>'); + for(var i=0; i< messages.length; i++) { + var litem = get_message_li(messages[i], 0); + $ul.append(litem); + } + $output.empty().append($ul); + } + } else { + $output.html('<p>No messages (server did not send a list).</p>'); + } + if (anim_duration > 0) { + $output.slideDown(anim_duration); + } + }; + + // accept an element (e.g., message_list) and add the click event to the *radio button* within it + // A bit specific to expect li's perhaps. + // options are passed through to the lock + var setup_click_listener = function(options) { + $message_list_element.on('click', 'input[type=radio]', function(event) { + var $li = $(this).closest('li'); + var id = $li.attr('id').replace(_msg_prefix, ''); + if ($li.hasClass('msg-is-locked')) { + say_status(get_msg(msg_trying_for_lock)); + } else if ($li.hasClass('msg-is-owned')) { + say_status(get_msg(msg_checking_lock)); + } else { + say_status(get_msg(msg_claiming_lock)); + } + request_lock(id, options); + }); + // clicking the reply button loads the id into the (modal/fancybox) reply form + $message_list_element.on('click', '.mm-rep', function(event) { + $('#reply_to_msg_id').val($(this).closest('li').attr('id').replace(_msg_prefix, '')); + }); + // clicking the hide button loads the id into the (modal/fancybox) hide form + $message_list_element.on('click', '.mm-hide', function(event) { + $('#hide_msg_id').val($(this).closest('li').attr('id').replace(_msg_prefix, '')); + // $('#hide-form-message-text').val(TODO); + }); + }; + + // gets messages or else requests login + // options: suggest_username, if provided, is preloaded into the login form if provided + // anim_duration: duration of fade/reveal (0, by defaut, does no animation) + var get_available_messages = function(options) { + var base_auth = get_current_auth_credentials(); + var suggest_username = ""; + var anim_duration = 0; + var callback = null; + if (options) { + if (typeof(options.callback) === 'function') { + callback = options.callback; + } + if (typeof options.suggest_username === 'string') { + suggest_username = options.suggest_username; + } + if (typeof options.anim_duration === 'string' || typeof options.anim_duration === 'number') { + anim_duration = parseInt(options.anim_duration, 10); + if (isNaN(anim_duration)) { + anim_duration = 0; + } + } + } + if (base_auth === "") { + show_login_form(suggest_username); + return; + } + $login_element.stop().hide(); + if (_url_root.length === 0) { + say_status(msg_no_config_err); + } else { + $.ajax({ + dataType: "json", + type: "post", + url: _url_root +"messages/available.json", + beforeSend: function (xhr){ + xhr.setRequestHeader('Authorization', get_current_auth_credentials()); + xhr.withCredentials = true; + }, + success: function(data, textStatus) { + show_available_messages(data, anim_duration); + if (typeof(callback) === "function") { + callback.call($(this), data); // execute callback + } + }, + error: function(jqXHR, textStatus, errorThrown) { + var st = jqXHR.status; + if (st == 401 || st == 403) { + var msg = (st == 401 ? "Invalid username or password for" : "Access denied: please log in to") + " " + _mm_name; + say_status(msg); + show_login_form(suggest_username); + } else { + var err_msg = "Unable to load messages: "; + if (st === 0 && textStatus === 'error') { // x-domain hard to detect, sometimes intermittent? + err_msg += "maybe try refreshing page?"; + } else { + err_msg += textStatus + " (" + st + ")"; + } + say_status(err_msg); + } + } + }); + } + }; + + var request_lock = function(msg_id, options) { + var $li = $('#' + _msg_prefix + msg_id); + var lock_unique = _want_unique_locks; + var callback = null; + if (options) { + if (typeof(options.callback) === 'function') { + callback = options.callback; + } + if (typeof(options.lock_unique) !== undefined && options.lock_unique !== undefined) { + lock_unique = options.lock_unique; + } + } + $li.addClass('msg-is-busy'); + $.ajax({ + dataType:"json", + type:"post", + url: _url_root +"messages/" + + (lock_unique? "lock_unique" : "lock") + + "/" + msg_id + ".json", + beforeSend: function (xhr){ + xhr.setRequestHeader('Authorization', get_current_auth_credentials()); + xhr.withCredentials = true; + }, + success:function(data, textStatus) { + if (data.success) { + if (lock_unique) { + $('.msg-is-owned', $message_list_element).removeClass('msg-is-owned'); + } + $li.removeClass('msg-is-busy msg-is-locked').addClass('msg-is-owned'); + say_status(get_msg(msg_lock_granted_ok)); // to data['data']['Lockkeeper']['username']? + } else { + $li.removeClass('msg-is-busy').addClass('msg-is-locked'); + say_status(get_msg(msg_lock_denied) || ("lock failed: " + data.error)); + } + if (typeof(callback) === "function") { // note callbacks must check data['success'] + callback.call($(this), data); // returned data['data'] is 'Message', 'Source', 'Lockkeeper' for success + } + }, + error: function(jqXHR, textStatus, errorThrown) { + $li.removeClass('msg-is-busy'); + say_status("error: " + textStatus + ": " + errorThrown); + } + }); + }; + + var assign_fms_id = function(msg_id, fms_id, options) { + var check_li_exists = false; + var is_async = true; + var callback = null; + if (options) { + if (typeof(options.callback) === 'function') { + callback = options.callback; + } + if (typeof(options.check_li_exists) !== undefined && options.check_li_exists !== undefined) { + check_li_exists = true; // MM dummy + } + if (typeof(options.is_async) !== undefined && options.is_async !== undefined) { + is_async = options.is_async; + } + } + var $li = $('#' + _msg_prefix + msg_id); + if (check_li_exists) { + if ($li.size() === 0) { + say_status("Couldn't find message with ID " + msg_id); + return; + } + } + if (isNaN(parseInt(fms_id,10))) { + say_status("missing FMS id"); + return; + } + $li.addClass('msg-is-busy'); + $.ajax({ + async:is_async, + dataType:"json", + type:"post", + data: {fms_id: fms_id}, + url: _url_root +"messages/assign_fms_id/" + msg_id + ".json", + beforeSend: function (xhr){ + xhr.setRequestHeader('Authorization', get_current_auth_credentials()); + xhr.withCredentials = true; + }, + success:function(data, textStatus) { + if (data.success) { + $li.removeClass('msg-is-busy msg-is-locked').addClass('msg-is-owned').fadeOut('slow'); // no longer available + say_status("OK: report ID was assigned to message."); + if (typeof(callback) === "function") { + callback.call($(this), data.data); // returned data['data'] is 'Message', 'Source', 'Lockkeeper' for success + } + } else { + $li.removeClass('msg-is-busy').addClass('msg-is-locked'); + say_status("failed: " + data.error); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + say_status("error: " + textStatus + ": " + errorThrown); + $li.removeClass('msg-is-busy'); + } + }); + }; + + var reply = function(msg_id, reply_text, options) { + if (_use_fancybox){ + $.fancybox.close(); + } + var callback = null; + var check_li_exists = false; + if (options) { + if (typeof(options.callback) === 'function') { + callback = options.callback; + } + if (typeof(options.check_li_exists) !== undefined && options.check_li_exists !== undefined) { + check_li_exists = true; // MM dummy + } + } + var $li = $('#' + _msg_prefix + msg_id); + if (check_li_exists) { + if ($li.size() === 0) { + say_status("Couldn't find message with ID " + msg_id); + return; + } + } + reply_text = $.trim(reply_text); + if (reply_text === '') { + say_status("No reply sent: message was empty!"); + return; + } + $li.addClass('msg-is-busy'); + $.ajax({ + dataType:"json", + type:"post", + data: {reply_text: reply_text}, + url: _url_root +"messages/reply/" + msg_id + ".json", + beforeSend: function (xhr){ + xhr.setRequestHeader('Authorization', get_current_auth_credentials()); + xhr.withCredentials = true; + }, + success:function(data, textStatus) { + if (data.success) { + $li.removeClass('msg-is-busy msg-is-locked').addClass('msg-is-owned'); // no longer available + say_status("Reply sent OK"); + if (typeof(callback) === "function") { + callback.call($(this), data.data); // returned data['data'] is null but may change in future + } + } else { + $li.removeClass('msg-is-busy').addClass('msg-is-locked'); + say_status("Reply failed: " + data.error); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + say_status("Reply error: " + textStatus + ": " + errorThrown); + $li.removeClass('msg-is-busy'); + } + }); + }; + + var hide = function(msg_id, reason_text, options) { + if (_use_fancybox){ + $.fancybox.close(); + } + var callback = null; + var check_li_exists = false; + if (options) { + if (typeof(options.callback) === 'function') { + callback = options.callback; + } + if (typeof(options.check_li_exists) !== undefined && options.check_li_exists !== undefined) { + check_li_exists = true; // MM dummy + } + } + var $li = $('#' + _msg_prefix + msg_id); + if (check_li_exists) { + if ($li.size() === 0) { + say_status("Couldn't find message with ID " + msg_id); + return; + } + } + reason_text = $.trim(reason_text); + $li.addClass('msg-is-busy'); + $.ajax({ + dataType:"json", + type:"post", + data: {reason_text: reason_text}, + url: _url_root +"messages/hide/" + msg_id + ".json", + beforeSend: function (xhr){ + xhr.setRequestHeader('Authorization', get_current_auth_credentials()); + xhr.withCredentials = true; + }, + success:function(data, textStatus) { + if (data.success) { + $li.removeClass('msg-is-busy msg-is-locked').addClass('msg-is-owned').fadeOut('slow'); // no longer available + say_status("Message hidden"); + if (typeof(callback) === "function") { + callback.call($(this), data.data); + } + } else { + $li.removeClass('msg-is-busy').addClass('msg-is-locked'); + say_status("Hide failed: " + data.error); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + say_status("Hide error: " + textStatus + ": " + errorThrown); + $li.removeClass('msg-is-busy'); + } + }); + }; + + var show_info = function(msg_id) { + var $info = $("#msg-info-box-" + msg_id); + if ($info.size()==1) { + if ($info.is(':hidden')) { + $info.slideDown(); + } else { + $info.slideUp(); + } + } + }; + + // if boilerplate is not already in local storage, make ajax call and load them + // otherwise, populate the boilerplate select lists: these are currently the + // reasons for hiding a message, and pre-loaded replies.message-manager.dev.mysociety.org + // NB no auth required on this call + var populate_boilerplate_strings = function(boilerplate_type, options) { + if (Modernizr.sessionstorage && sessionStorage.getItem('boilerplate_' + boilerplate_type)) { + populate_boilerplate(boilerplate_type, sessionStorage.getItem('boilerplate_' + boilerplate_type)); + return; + } + var callback = null; + if (options) { + if (typeof(options.callback) === 'function') { + callback = options.callback; + } + } + $.ajax({ + dataType:"json", + type:"get", + url: _url_root +"boilerplate_strings/index/" + boilerplate_type + ".json", + success:function(data, textStatus) { + if (data.success) { + var raw_data = data.data; + var select_html = get_select_tag_html(data.data, boilerplate_type); + if (Modernizr.sessionstorage) { + sessionStorage.setItem('boilerplate_' + boilerplate_type, select_html); + } + populate_boilerplate(boilerplate_type, select_html); + if (typeof(callback) === "function") { + callback.call($(this), data.data); + } + } else { + // console.log("failed to load boilerplate"); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + // console.log("boilerplate error: " + textStatus + ": " + errorThrown); + } + }); + }; + + // TODO flatten all HTML in boilerplate text + var get_select_tag_html = function(boilerplate_data, boilerplate_type) { + var html = "<option value=''>--none--</option>\n"; + var qty_langs = 0; + var qty_strings = 0; + if (boilerplate_data.langs) { + for (var i=0; i< boilerplate_data.langs.length; i++) { + var lang = boilerplate_data.langs[i]; + var options = ""; + for (var j in boilerplate_data[lang]) { + if (boilerplate_data[lang].hasOwnProperty(j)) { + options += "<option>" + boilerplate_data[lang][j] + "</option>\n"; + qty_strings++; + } + } + if (boilerplate_data.langs.length > 1) { // really need pretty name for language + options = '<optgroup label="' + lang + '">\n' + options + '</optgroup>\n'; + } + html += options; + } + } + if (qty_strings === 0) { + html = ''; + } + return html; + }; + + // actually load the select tag + var populate_boilerplate = function(boilerplate_type, html) { + var $target = null; + switch(boilerplate_type) { + case 'hide-reason': $target = $hide_reasons; break; + case 'reply': $target = $boilerplate_replies; break; + } + if ($target) { + if (html) { + $target.show().find('select').html(html); + } else { + $target.hide(); + } + } + }; + + // revealed public methods: + return { + config: config, + setup_click_listener: setup_click_listener, + get_available_messages: get_available_messages, + request_lock: request_lock, + assign_fms_id: assign_fms_id, + reply: reply, + hide: hide, + show_info: show_info, + sign_out: sign_out, + populate_boilerplate_strings: populate_boilerplate_strings + }; +})(); diff --git a/web/cobrands/fixmybarangay/messages.js b/web/cobrands/fixmybarangay/messages.js new file mode 100644 index 000000000..aebf35156 --- /dev/null +++ b/web/cobrands/fixmybarangay/messages.js @@ -0,0 +1,26 @@ +$(function(){ + + var mm = $('#message_manager'); + + $.getJSON('/cobrands/fixmybarangay/test-texts.json', function(data) { + var items = []; + $.each(data, function(k, v) { + var item = $('<input type="radio"/>').attr({ + 'id': 'mm_text_' + v.id, + 'name': 'mm_text', + 'value': v.text + }).wrap('<p/>').parent().html(); + var label = $('<label/>', { + 'class': 'inline', + 'for': 'mm_text_' + v.id + }).text(v.text).wrap('<p/>').parent().html(); + item = '<li><p>' + item + ' ' + label + '</p></li>'; + items.push(item); + }); + mm.html(items.join('')); + mm.find('input').click(function(){ + $('#form_detail').val( $('input[name=mm_text]:checked').val() ); + }); + }); + +}); diff --git a/web/cobrands/fixmybarangay/position_map.js b/web/cobrands/fixmybarangay/position_map.js new file mode 100644 index 000000000..753b5f854 --- /dev/null +++ b/web/cobrands/fixmybarangay/position_map.js @@ -0,0 +1,22 @@ +function position_map_box() { + var $html = $('html'); + if ($html.hasClass('ie6')) { + $('#map_box').prependTo('.wrapper').css({ + zIndex: 0, position: 'absolute', + top: 0, left: 0, right: 0, bottom: 0, + width: '100%', height: $(window).height(), + margin: 0 + }); + } else { + $('#map_box').prependTo('.wrapper').css({ + zIndex: 0, position: 'fixed', + top: 0, left: 0, right: 0, bottom: 0, + width: '100%', height: '100%', + margin: 0 + }); + } +} + +function map_fix() {} +var slide_wards_down = 0; + diff --git a/web/cobrands/fixmybarangay/test-texts.json b/web/cobrands/fixmybarangay/test-texts.json new file mode 100644 index 000000000..7acde1e32 --- /dev/null +++ b/web/cobrands/fixmybarangay/test-texts.json @@ -0,0 +1,17 @@ +[ + { + "id" : 1, + "number" : "032-9999999", + "text" : "Pothole on corner of G. De Vera and T. Padilla" + }, + { + "id" : 2, + "number" : "032-1234567", + "text" : "Broken street light on Rahmann Street" + }, + { + "id" : 3, + "number" : "+63 917 0000000", + "text" : "F. Manalo giant pothole" + } +] diff --git a/web/cobrands/fixmystreet/_base.scss b/web/cobrands/fixmystreet/_base.scss index 5d71c33e6..1173e3061 100644 --- a/web/cobrands/fixmystreet/_base.scss +++ b/web/cobrands/fixmystreet/_base.scss @@ -585,6 +585,10 @@ p.label-valid { background-image:url('/cobrands/fixmystreet/images/sprite.png'); background-position:center -2563px; } + &.share { + background-image: url('/cobrands/fixmystreet/images/share.png'); + background-position: center 25%; + } &.chevron { background-image:url('/cobrands/fixmystreet/images/sprite.png'); background-position:center -2716px; @@ -631,6 +635,13 @@ p.label-valid { } } +#report-updates-data img { + float: right; +} + +#report-share iframe { + vertical-align: top; +} //footer blocks #footer-mobileapps { @@ -1146,25 +1157,29 @@ a:hover.button-left { } } &.map_complete { - background:none; - display:block; - border-bottom:4px solid #fff; + height: 100%; + background: none; + display: block; + border-bottom: 4px solid #fff; a#try_again { - display:block; - margin:0 auto 6em auto; - background:rgba(0, 0, 0, 0.8); + position: absolute; + display: block; + left: 25%; + bottom: 0; + margin-bottom: 6em; + background: rgba(0, 0, 0, 0.8); @include border-radius(0.5em); } a#mob_ok { - position:absolute; - right:1em; - bottom:0; - height:20px; - padding-top:30px; - display:block; - width:4em; - background:#fff url('/cobrands/fixmystreet/images/sprite.png') 12px -4140px no-repeat; - color:#000; + position: absolute; + display: block; + right: 1em; + bottom: 0; + height: 20px; + padding-top: 30px; + width: 4em; + background: #fff url('/cobrands/fixmystreet/images/sprite.png') 12px -4140px no-repeat; + color: #000; } } } @@ -1306,9 +1321,6 @@ table.nicetable { &.a { background:#f6f6f6; } - &:nth-child(even) { - background:#f6f6f6; - } &.gone { color: #666666; background-color: #cccccc; diff --git a/web/cobrands/fixmystreet/_layout.scss b/web/cobrands/fixmystreet/_layout.scss index 56b2f41d5..855e453b8 100644 --- a/web/cobrands/fixmystreet/_layout.scss +++ b/web/cobrands/fixmystreet/_layout.scss @@ -203,7 +203,7 @@ h1 { margin-top: 3em; margin-bottom: -1em; margin-left: 0.5em; - padding: 1em 1em 3em; + padding: 1em 1em 10em; background: #fff; @include box-shadow(0px 0px 6px 1px #000); } @@ -589,6 +589,11 @@ body.twothirdswidthpage { background-image:url(/cobrands/fixmystreet/images/sprite.png); background-position:right -3074px; } + &.share { + min-width: 5em; + background-image: url(/cobrands/fixmystreet/images/share.png); + background-position: 90% 50%; + } &.chevron { background-image:url(/cobrands/fixmystreet/images/sprite.png); background-position:right -3225px; @@ -618,6 +623,15 @@ body.twothirdswidthpage { padding-top: 0; } +// If JS is disabled, these are still CSS positioned, so don't want behind shining through. +#report-share, #report-updates-data { + background-color: #fff; +} +// Prevent gap in non-JS, and looks better with JS, due to some padding/margin effect. +#report-updates-data fieldset { + margin-bottom: 0; +} + // pokes over the RHS with a little triangle .big-green-banner { top:auto; @@ -732,7 +746,7 @@ textarea.form-error { .no-js #report-a-problem-sidebar { position: static; width: auto; - @include box-shadow(rgba(0, 0, 0, 0), 0, 0, 0); + @include box-shadow(rgba(0, 0, 0, 0) 0 0 0); .sidebar-tips, .sidebar-notes { font-size:1em; @@ -758,6 +772,14 @@ textarea.form-error { } } +/* Adjust the above so text flow can be different from display */ +#forgotten-pw { + position: relative; + left: 27em; + top: -7em; + margin-bottom: -7em; // So no gap in main flow +} + // Frontpage body.frontpage { @@ -1012,7 +1034,7 @@ body.frontpage { .general-sidebar-notes { position: static; width: auto; - @include box-shadow(rgba(0, 0, 0, 0), 0, 0, 0); + @include box-shadow(rgba(0, 0, 0, 0) 0 0 0); .sidebar-tips, .sidebar-notes { font-size:1em; diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index c8ed8ae51..714699386 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -92,8 +92,7 @@ $(function(){ $('.big-green-banner') .addClass('mobile-map-banner') .appendTo('#map_box') - .text('Place pin on map') - .prepend('<a href="/">home</a>'); + .html('<a href="/">Home</a> Place pin on map'); } $('span.report-a-problem-btn').on('click.reportBtn', function(){ $('html, body').animate({scrollTop:0}, 500); @@ -247,23 +246,34 @@ $(function(){ // A sliding drawer from the bottom of the page, small version // that doesn't change the main content at all. -$.fn.small_drawer = function(id) { - this.toggle(function(){ - var $this = $(this), d = $('#' + id); - if (!$this.addClass('hover').data('setup')) { - d.hide().removeClass('hidden-js').css({ +(function($){ + + var opened; + + $.fn.small_drawer = function(id) { + this.toggle(function(){ + if (opened) { + opened.click(); + } + var $this = $(this), d = $('#' + id); + if (!$this.addClass('hover').data('setup')) { + d.hide().removeClass('hidden-js').css({ padding: '1em', background: '#fff' - }); - $this.data('setup', true); - } - d.slideDown(); - }, function(e){ - var $this = $(this), d = $('#' + id); - $this.removeClass('hover'); - d.slideUp(); - }); -}; + }); + $this.data('setup', true); + } + d.slideDown(); + opened = $this; + }, function(e){ + var $this = $(this), d = $('#' + id); + $this.removeClass('hover'); + d.slideUp(); + opened = null; + }); + }; + +})(jQuery); // A sliding drawer from the bottom of the page, large version $.fn.drawer = function(id, ajax) { @@ -338,6 +348,7 @@ $.fn.drawer = function(id, ajax) { $('#key-tool-around-updates').drawer('updates_ajax', true); } $('#key-tool-report-updates').small_drawer('report-updates-data'); + $('#key-tool-report-share').small_drawer('report-share'); // Go directly to RSS feed if RSS button clicked on alert page // (due to not wanting around form to submit, though good thing anyway) diff --git a/web/cobrands/fixmystreet/images/share.png b/web/cobrands/fixmystreet/images/share.png Binary files differnew file mode 100644 index 000000000..6eb1b6cdb --- /dev/null +++ b/web/cobrands/fixmystreet/images/share.png diff --git a/web/cobrands/southampton/css.scss b/web/cobrands/southampton/css.scss index 3bc2f1b54..592e72f2b 100644 --- a/web/cobrands/southampton/css.scss +++ b/web/cobrands/southampton/css.scss @@ -64,4 +64,8 @@ $darker: #768EB5; #update_form { clear: right; } + + .update-img { + text-align: left; + } } diff --git a/web/css/core.scss b/web/css/core.scss index 72e483dfa..c7fac1717 100644 --- a/web/css/core.scss +++ b/web/css/core.scss @@ -431,6 +431,16 @@ $map_width: 500px; font-size: smaller; } + .update-img { + text-align: center; + } + .update-img span { + display: none; + } + #updates .update-img { + text-align: left; + } + // RSS feed XSL #rss_items { diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js index b689d501c..6ae4ed92d 100644 --- a/web/js/fixmystreet.js +++ b/web/js/fixmystreet.js @@ -134,10 +134,12 @@ $(function(){ // Geolocation if (geo_position_js.init()) { + var link = '<a href="#LINK" id="geolocate_link">… or locate me automatically</a>'; + $('form[action="/alert/list"]').append(link.replace('LINK','alert/list')); if ($('body.frontpage').length) { - $('#postcodeForm').after('<a href="#" id="geolocate_link">… or locate me automatically</a>'); + $('#postcodeForm').after(link.replace('LINK','around')); } else{ - $('#postcodeForm').append('<a href="#" id="geolocate_link">… or locate me automatically</a>'); + $('#postcodeForm').append(link.replace('LINK','around')); } $('#geolocate_link').click(function(e) { var $link = $(this); @@ -152,7 +154,8 @@ $(function(){ $link.find('img').remove(); var latitude = pos.coords.latitude; var longitude = pos.coords.longitude; - location.href = '/around?latitude=' + latitude + ';longitude=' + longitude; + var page = $link.attr('href').substr(1); + location.href = '/' + page + '?latitude=' + latitude + ';longitude=' + longitude; }, function(err) { $link.find('img').remove(); if (err.code == 1) { // User said no diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index d98994d84..0a5f339f5 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -70,26 +70,30 @@ function fms_markers_list(pins, transform) { } function fixmystreet_onload() { - if ( fixmystreet.area ) { - var area = new OpenLayers.Layer.Vector("KML", { - strategies: [ new OpenLayers.Strategy.Fixed() ], - protocol: new OpenLayers.Protocol.HTTP({ - url: "/mapit/area/" + fixmystreet.area + ".kml?simplify_tolerance=0.0001", - format: new OpenLayers.Format.KML() - }) - }); - fixmystreet.map.addLayer(area); - area.events.register('loadend', null, function(a,b,c) { - var bounds = area.getDataExtent(); - if (bounds) { - var center = bounds.getCenterLonLat(); - var z = fixmystreet.map.getZoomForExtent(bounds); - if ( z < 13 && $('html').hasClass('mobile') ) { - z = 13; - } - fixmystreet.map.setCenter(center, z, false, true); + if ( fixmystreet.area.length ) { + for (var i=0; i<fixmystreet.area.length; i++) { + var area = new OpenLayers.Layer.Vector("KML", { + strategies: [ new OpenLayers.Strategy.Fixed() ], + protocol: new OpenLayers.Protocol.HTTP({ + url: "/mapit/area/" + fixmystreet.area[i] + ".kml?simplify_tolerance=0.0001", + format: new OpenLayers.Format.KML() + }) + }); + fixmystreet.map.addLayer(area); + if ( fixmystreet.area.length == 1 ) { + area.events.register('loadend', null, function(a,b,c) { + var bounds = area.getDataExtent(); + if (bounds) { + var center = bounds.getCenterLonLat(); + var z = fixmystreet.map.getZoomForExtent(bounds); + if ( z < 13 && $('html').hasClass('mobile') ) { + z = 13; + } + fixmystreet.map.setCenter(center, z, false, true); + } + }); } - }); + } } var pin_layer_style_map = new OpenLayers.StyleMap({ @@ -333,7 +337,7 @@ $(function(){ $('#sub_map_links').show(); //only on mobile $('#mob_sub_map_links').remove(); - $('.mobile-map-banner').text('Place pin on map'); + $('.mobile-map-banner').html('<a href="/">Home</a> Place pin on map'); fixmystreet.page = 'around'; }); @@ -528,7 +532,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { ).css({ position: 'relative', width: width, height: height, marginBottom: '1em' }); // Making it relative here makes it much easier to do the scrolling later - $('.mobile-map-banner').text('Right place?'); + $('.mobile-map-banner').html('<a href="/">Home</a> Right place?'); // mobile user clicks 'ok' on map $('#mob_ok').toggle(function(){ diff --git a/web/js/modernizr.custom.js b/web/js/modernizr.custom.js index c4d6ffdfc..026c0efad 100644 --- a/web/js/modernizr.custom.js +++ b/web/js/modernizr.custom.js @@ -1,4 +1,4 @@ -/* Modernizr 2.5.3 (Custom Build) | MIT & BSD
- * Build: http://www.modernizr.com/download/#-shiv-load
+/* Modernizr 2.6.1 (Custom Build) | MIT & BSD
+ * Build: http://modernizr.com/download/#-sessionstorage-shiv-load
*/
-;window.Modernizr=function(a,b,c){function t(a){i.cssText=a}function u(a,b){return t(prefixes.join(a+";")+(b||""))}function v(a,b){return typeof a===b}function w(a,b){return!!~(""+a).indexOf(b)}function x(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:v(f,"function")?f.bind(d||b):f}return!1}var d="2.5.3",e={},f=b.documentElement,g="modernizr",h=b.createElement(g),i=h.style,j,k={}.toString,l={},m={},n={},o=[],p=o.slice,q,r={}.hasOwnProperty,s;!v(r,"undefined")&&!v(r.call,"undefined")?s=function(a,b){return r.call(a,b)}:s=function(a,b){return b in a&&v(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=p.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(p.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(p.call(arguments)))};return e});for(var y in l)s(l,y)&&(q=y.toLowerCase(),e[q]=l[y](),o.push((e[q]?"":"no-")+q));return t(""),h=j=null,function(a,b){function g(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function h(){var a=k.elements;return typeof a=="string"?a.split(" "):a}function i(a){var b={},c=a.createElement,e=a.createDocumentFragment,f=e();a.createElement=function(a){var e=(b[a]||(b[a]=c(a))).cloneNode();return k.shivMethods&&e.canHaveChildren&&!d.test(a)?f.appendChild(e):e},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+h().join().replace(/\w+/g,function(a){return b[a]=c(a),f.createElement(a),'c("'+a+'")'})+");return n}")(k,f)}function j(a){var b;return a.documentShived?a:(k.shivCSS&&!e&&(b=!!g(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")),f||(b=!i(a)),b&&(a.documentShived=b),a)}var c=a.html5||{},d=/^<|^(?:button|form|map|select|textarea)$/i,e,f;(function(){var a=b.createElement("a");a.innerHTML="<xyz></xyz>",e="hidden"in a,f=a.childNodes.length==1||function(){try{b.createElement("a")}catch(a){return!0}var c=b.createDocumentFragment();return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}()})();var k={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:j};a.html5=k,j(b)}(this,b),e._version=d,e}(this,this.document),function(a,b,c){function d(a){return o.call(a)=="[object Function]"}function e(a){return typeof a=="string"}function f(){}function g(a){return!a||a=="loaded"||a=="complete"||a=="uninitialized"}function h(){var a=p.shift();q=1,a?a.t?m(function(){(a.t=="c"?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){a!="img"&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l={},o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};y[c]===1&&(r=1,y[c]=[],l=b.createElement(a)),a=="object"?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),a!="img"&&(r||y[c]===2?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i(b=="c"?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),p.length==1&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&o.call(a.opera)=="[object Opera]",l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return o.call(a)=="[object Array]"},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,i){var j=b(a),l=j.autoCallback;j.url.split(".").pop().split("?").shift(),j.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]||h),j.instead?j.instead(a,e,f,g,i):(y[j.url]?j.noexec=!0:y[j.url]=1,f.load(j.url,j.forceCSS||!j.forceJS&&"css"==j.url.split(".").pop().split("?").shift()?"c":c,j.noexec,j.attrs,j.timeout),(d(e)||d(l))&&f.load(function(){k(),e&&e(j.origUrl,i,g),l&&l(j.origUrl,i,g),y[j.url]=2})))}function i(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var j,l,m=this.yepnope.loader;if(e(a))g(a,0,m,0);else if(w(a))for(j=0;j<a.length;j++)l=a[j],e(l)?g(l,0,m,0):w(l)?B(l):Object(l)===l&&i(l,m);else Object(a)===a&&i(a,m)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}}(this,document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))};
\ No newline at end of file +;window.Modernizr=function(a,b,c){function t(a){i.cssText=a}function u(a,b){return t(prefixes.join(a+";")+(b||""))}function v(a,b){return typeof a===b}function w(a,b){return!!~(""+a).indexOf(b)}function x(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:v(f,"function")?f.bind(d||b):f}return!1}var d="2.6.1",e={},f=b.documentElement,g="modernizr",h=b.createElement(g),i=h.style,j,k={}.toString,l={},m={},n={},o=[],p=o.slice,q,r={}.hasOwnProperty,s;!v(r,"undefined")&&!v(r.call,"undefined")?s=function(a,b){return r.call(a,b)}:s=function(a,b){return b in a&&v(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=p.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(p.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(p.call(arguments)))};return e}),l.sessionstorage=function(){try{return sessionStorage.setItem(g,g),sessionStorage.removeItem(g),!0}catch(a){return!1}};for(var y in l)s(l,y)&&(q=y.toLowerCase(),e[q]=l[y](),o.push((e[q]?"":"no-")+q));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)s(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,enableClasses&&(f.className+=" "+(b?"":"no-")+a),e[a]=b}return e},t(""),h=j=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e<g;e++)d.createElement(f[e]);return d}function p(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return r.shivMethods?n(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+l().join().replace(/\w+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(r,b.frag)}function q(a){a||(a=b);var c=m(a);return r.shivCSS&&!f&&!c.hasCSS&&(c.hasCSS=!!k(a,"article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}")),j||p(a,c),a}var c=a.html5||{},d=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,e=/^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i,f,g="_html5shiv",h=0,i={},j;(function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i<a.length;i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&&h(j,l);else Object(a)===a&&h(a,l)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}}(this,document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))};
\ No newline at end of file |