diff options
Diffstat (limited to 'web/cobrands')
-rw-r--r-- | web/cobrands/fixmybarangay/_colours.scss | 9 | ||||
-rw-r--r-- | web/cobrands/fixmybarangay/base.scss | 56 | ||||
-rw-r--r-- | web/cobrands/fixmybarangay/config.rb | 25 | ||||
-rw-r--r-- | web/cobrands/fixmybarangay/images/city6.png | bin | 0 -> 227275 bytes | |||
-rw-r--r-- | web/cobrands/fixmybarangay/images/city7.png | bin | 0 -> 126124 bytes | |||
-rw-r--r-- | web/cobrands/fixmybarangay/images/ie_front_logo.gif | bin | 0 -> 3473 bytes | |||
-rw-r--r-- | web/cobrands/fixmybarangay/images/ie_logo.png | bin | 0 -> 2143 bytes | |||
-rw-r--r-- | web/cobrands/fixmybarangay/images/pat3.png | bin | 0 -> 3028 bytes | |||
-rw-r--r-- | web/cobrands/fixmybarangay/images/sprite.png | bin | 0 -> 17752 bytes | |||
-rw-r--r-- | web/cobrands/fixmybarangay/layout.scss | 130 | ||||
-rw-r--r-- | web/cobrands/fixmybarangay/message_manager.scss | 133 | ||||
-rw-r--r-- | web/cobrands/fixmybarangay/message_manager_client.js | 500 | ||||
-rw-r--r-- | web/cobrands/fixmybarangay/messages.js | 26 | ||||
-rw-r--r-- | web/cobrands/fixmybarangay/position_map.js | 22 | ||||
-rw-r--r-- | web/cobrands/fixmybarangay/test-texts.json | 17 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/_layout.scss | 4 |
16 files changed, 920 insertions, 2 deletions
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..0f575806a --- /dev/null +++ b/web/cobrands/fixmybarangay/layout.scss @@ -0,0 +1,130 @@ +@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; + } + + &: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..e9db9a6ce --- /dev/null +++ b/web/cobrands/fixmybarangay/message_manager.scss @@ -0,0 +1,133 @@ +@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; + +#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;} + } + 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;} + 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-rep { + right:1.4em; + background-color: green; + } + } + } + } + p.mm-empty { + margin: 1em; + } +} +#show_messages, #add_support, #reply-submit { // COPY TO UPDATE button + margin: 1em; +} +#reply-form-container { + #reply-form{ + margin-top: 2em; + border: 1px solid $mm_border_color; + background-color: #fff; + } +} diff --git a/web/cobrands/fixmybarangay/message_manager_client.js b/web/cobrands/fixmybarangay/message_manager_client.js new file mode 100644 index 000000000..e2c69c6a3 --- /dev/null +++ b/web/cobrands/fixmybarangay/message_manager_client.js @@ -0,0 +1,500 @@ +/* + * message_manager.config(settings) + * + * Accepts settings for the Message Manager client. Even if you accept all the defaults, + * you *MUST* call config when the page is loaded (i.e., call message_manager.config()) + * + * The (optional) single parameter 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. + * + * msg_prefix all message <li> items have this as their ID prefix + * + * mm_name name of Message Manager (used in error messages shown + * to user, e.g., "please log in to Message Manager" + * + * *_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, [options]) + * message_manager.reply(msg_id, reply_text, [options]) + * + * 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! + + // 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 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' + }; + if (settings) { + if (typeof settings.url_root === 'string') { + _url_root = settings.url_root; + if (_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; + } + } + $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); + }; + + // 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'); // FF doesn't support .clear()? + } + 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 = $('<span class="mm-msg-action mm-hide" id="mm-hide-' + msg.id + '">X</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(); + } + 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); + if (msg.is_outbound != 1) { + $litem.append($reply_button); + } + if (lockkeeper) { + $litem.addClass(lockkeeper == _username? 'msg-is-owned' : 'msg-is-locked'); + } + if (message_root.children) { + $litem.append(extract_replies(message_root.children, depth+1)); + } + return $litem; + }; + + var show_available_messages = function(data) { + 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>'); + } + }; + + // 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("Trying for lock..."); + } else if ($li.hasClass('msg-is-owned')) { + say_status("Checking lock..."); + } else { + say_status("Trying for 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, '')); + }); + }; + + // gets messages or else requests login + // options: suggest_username, if provided, is preloaded into the login form if provided + var get_available_messages = function(options) { + var base_auth = get_current_auth_credentials(); + var suggest_username = ""; + if (options) { + if (typeof(options.callback) === 'function') { + callback = options.callback; + } + if (typeof options.suggest_username === 'string') { + suggest_username = options.suggest_username; + } + } + if (base_auth === "") { + show_login_form(suggest_username); + return; + } + $login_element.stop().hide(); + $.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); + 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("Lock granted OK"); // to data['data']['Lockkeeper']['username']? + } else { + $li.removeClass('msg-is-busy').addClass('msg-is-locked'); + say_status("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; + 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("FMS ID assigned"); // to data['data']['Lockkeeper']['username']? + 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 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("won't send empty reply"); + 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("failed: " + data.error); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + say_status("error: " + textStatus + ": " + errorThrown); + $li.removeClass('msg-is-busy'); + } + }); + }; + + var hide = function(msg_id, options) { + 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; + } + } + $li.addClass('msg-is-busy'); + $.ajax({ + dataType:"json", + type:"post", + 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("failed: " + data.error); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + say_status("error: " + textStatus + ": " + errorThrown); + $li.removeClass('msg-is-busy'); + } + }); + }; + + // 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, + sign_out: sign_out + }; +})(); 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/_layout.scss b/web/cobrands/fixmystreet/_layout.scss index 56b2f41d5..0973e645d 100644 --- a/web/cobrands/fixmystreet/_layout.scss +++ b/web/cobrands/fixmystreet/_layout.scss @@ -732,7 +732,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; @@ -1012,7 +1012,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; |