style changes and refactoring
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
/**
|
||||
* Cookie plugin
|
||||
*
|
||||
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a cookie with the given name and value and other optional parameters.
|
||||
*
|
||||
* @example $.cookie('the_cookie', 'the_value');
|
||||
* @desc Set the value of a cookie.
|
||||
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
|
||||
* @desc Create a cookie with all available options.
|
||||
* @example $.cookie('the_cookie', 'the_value');
|
||||
* @desc Create a session cookie.
|
||||
* @example $.cookie('the_cookie', null);
|
||||
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
|
||||
* used when the cookie was set.
|
||||
*
|
||||
* @param String name The name of the cookie.
|
||||
* @param String value The value of the cookie.
|
||||
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
|
||||
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
|
||||
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
|
||||
* If set to null or omitted, the cookie will be a session cookie and will not be retained
|
||||
* when the the browser exits.
|
||||
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
|
||||
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
|
||||
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
|
||||
* require a secure protocol (like HTTPS).
|
||||
* @type undefined
|
||||
*
|
||||
* @name $.cookie
|
||||
* @cat Plugins/Cookie
|
||||
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the value of a cookie with the given name.
|
||||
*
|
||||
* @example $.cookie('the_cookie');
|
||||
* @desc Get the value of a cookie.
|
||||
*
|
||||
* @param String name The name of the cookie.
|
||||
* @return The value of the cookie.
|
||||
* @type String
|
||||
*
|
||||
* @name $.cookie
|
||||
* @cat Plugins/Cookie
|
||||
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
||||
*/
|
||||
jQuery.cookie = function(name, value, options) {
|
||||
if (typeof value != 'undefined') { // name and value given, set cookie
|
||||
options = options || {};
|
||||
if (value === null) {
|
||||
value = '';
|
||||
options.expires = -1;
|
||||
}
|
||||
var expires = '';
|
||||
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
|
||||
var date;
|
||||
if (typeof options.expires == 'number') {
|
||||
date = new Date();
|
||||
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
|
||||
} else {
|
||||
date = options.expires;
|
||||
}
|
||||
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
|
||||
}
|
||||
// CAUTION: Needed to parenthesize options.path and options.domain
|
||||
// in the following expressions, otherwise they evaluate to undefined
|
||||
// in the packed version for some reason...
|
||||
var path = options.path ? '; path=' + (options.path) : '';
|
||||
var domain = options.domain ? '; domain=' + (options.domain) : '';
|
||||
var secure = options.secure ? '; secure' : '';
|
||||
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
|
||||
} else { // only name given, get cookie
|
||||
var cookieValue = null;
|
||||
if (document.cookie && document.cookie != '') {
|
||||
var cookies = document.cookie.split(';');
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = jQuery.trim(cookies[i]);
|
||||
// Does this cookie string begin with the name we want?
|
||||
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
}
|
||||
};
|
||||
@@ -21,33 +21,6 @@ root.Qrammer =
|
||||
num = 0.0 if isNaN(num) || num == '' || num == null
|
||||
'€ ' + parseFloat(num).toFixed(2)
|
||||
|
||||
|
||||
build_product_list_as_modal: ->
|
||||
wrapper = $('<div class="modal"></div>')
|
||||
callback_wrapper = ->
|
||||
wrapper.modal('hide')
|
||||
callback()
|
||||
header = $('<div class="modal-header"></div>')
|
||||
.append('<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>')
|
||||
.append('<h3>Product list</h3>').appendTo(wrapper)
|
||||
|
||||
body = $('<div class="modal-body"></div>')
|
||||
table = $('<table class="table"></table>').appendTo(body)
|
||||
tbody = $('<tbody></tbody>').appendTo(table)
|
||||
for product_id, info of window.active_products_list
|
||||
row = $('<tr></tr>').appendTo(tbody)
|
||||
row.append('<td>'+info.product.name+'</td>')
|
||||
row.append('<td>'+info.number+'</td>')
|
||||
row.append('<td>'+Qrammer.currency(info.product.price * info.number)+'</td>')
|
||||
|
||||
body.appendTo(wrapper)
|
||||
|
||||
footer = $('<div class="modal-footer"></div>')
|
||||
.append($('<a href="#" class="btn">Close</a>').click(-> wrapper.modal('hide')))
|
||||
.append($('<a href="#" class="btn btn-primary">Yes</a>').click(callback_wrapper))
|
||||
.appendTo(wrapper)
|
||||
wrapper.modal()
|
||||
|
||||
jQuery.ajaxSetup
|
||||
'beforeSend': (xhr) ->
|
||||
xhr.setRequestHeader("Accept", "text/javascript")
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
||||
// GO AFTER THE REQUIRES BELOW.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require jquery-ui
|
||||
//= require twitter/bootstrap
|
||||
//= require_directory .
|
||||
//= require_self
|
||||
var path_mapping = {
|
||||
user_root: '/user',
|
||||
join_occupied_table: '/user/join_occupied_table',
|
||||
list_products_for_table: '/user/list_products_for_table',
|
||||
list_products: '/user/list_products'
|
||||
}
|
||||
function redirect_to(mapping, variables){
|
||||
variables || (variables = {});
|
||||
var vars = []
|
||||
for(var name in variables){
|
||||
vars.push(name + '=' +variables[name])
|
||||
}
|
||||
window.location = path_mapping[mapping] + '?' + vars.join('&')
|
||||
}
|
||||
function currency(num) {
|
||||
if (isNaN(num) || num === '' || num === null) {
|
||||
num = 0.0;
|
||||
}
|
||||
return '€ ' + parseFloat(num).toFixed(2);
|
||||
}
|
||||
+4
-4
@@ -86,12 +86,12 @@ root.Qsupplier=
|
||||
|
||||
row.append($('<td class="numeric"></td>').text(list.table_number))
|
||||
row.append($('<td></td>').text(list.section_title))
|
||||
row.append($('<td class="currency"></td>').html(Qrammer.currency(list.total_amount)))
|
||||
row.append($('<td class="currency"></td>').html(currency(list.total_amount)))
|
||||
td_buttons = $('<td class="actions"></td>')
|
||||
td_buttons.append(needs_help_btn).append(' ') if list.needs_help
|
||||
td_buttons.append(close_btn)
|
||||
row.append(td_buttons)
|
||||
#foot.append('<tr><td></td><td class="currency"><strong>'+Qrammer.currency(res.total_amount)+'</strong></td></tr>');
|
||||
#foot.append('<tr><td></td><td class="currency"><strong>'+currency(res.total_amount)+'</strong></td></tr>');
|
||||
)
|
||||
|
||||
load_active_orders: () ->
|
||||
@@ -125,10 +125,10 @@ root.Qsupplier=
|
||||
row.append($('<td></td>').text(order_txts.join(', ')))
|
||||
row.append($('<td class="numeric"></td>').text(order.table_number))
|
||||
row.append($('<td></td>').text(order.section_title))
|
||||
row.append($('<td class="currency"></td>').html(Qrammer.currency(order.total_amount)))
|
||||
row.append($('<td class="currency"></td>').html(currency(order.total_amount)))
|
||||
td_buttons = $('<td class="actions"></td>')
|
||||
td_buttons.append(process_btn).append(' ') if order.state == 'placed'
|
||||
td_buttons.append(delivered_btn)
|
||||
row.append(td_buttons)
|
||||
#foot.append('<tr><td></td><td class="currency"><strong>'+Qrammer.currency(res.total_amount)+'</strong></td></tr>');
|
||||
#foot.append('<tr><td></td><td class="currency"><strong>'+currency(res.total_amount)+'</strong></td></tr>');
|
||||
)
|
||||
@@ -12,8 +12,20 @@
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require jquery-ui
|
||||
//= require twitter/bootstrap
|
||||
// require twitter/bootstrap
|
||||
//= require twitter/bootstrap/bootstrap-transition
|
||||
// require twitter/bootstrap/bootstrap-alert
|
||||
//= require twitter/bootstrap/bootstrap-modal
|
||||
//= require twitter/bootstrap/bootstrap-dropdown
|
||||
//= require twitter/bootstrap/bootstrap-scrollspy
|
||||
//= require twitter/bootstrap/bootstrap-tab
|
||||
//= require twitter/bootstrap/bootstrap-tooltip
|
||||
//= require twitter/bootstrap/bootstrap-popover
|
||||
//= require twitter/bootstrap/bootstrap-button
|
||||
//= require twitter/bootstrap/bootstrap-collapse
|
||||
// require twitter/bootstrap/bootstrap-carousel
|
||||
//= require twitter/bootstrap/bootstrap-typeahead
|
||||
//= require twitter/bootstrap/bootstrap-affix
|
||||
//= require_directory .
|
||||
//= require_self
|
||||
var path_mapping = {
|
||||
|
||||
@@ -133,6 +133,7 @@ window.Quser=
|
||||
if res.table_number
|
||||
$('.table-number').text(res.table_number)
|
||||
delete(res['table_number'])
|
||||
body.find('tr').remove()
|
||||
for category, products of res
|
||||
body.append('<tr><td colspan="4"><h4>'+category+'<h4></td></tr>')
|
||||
for product in products
|
||||
|
||||
Reference in New Issue
Block a user