end of day commit
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
jQuery ->
|
||||
$("a[rel=popover]").popover()
|
||||
$(".tooltip").tooltip()
|
||||
$("a[rel=tooltip]").tooltip()
|
||||
$("a[rel=tooltip]").tooltip()
|
||||
$('input.currency').each(->
|
||||
obj = $(this)
|
||||
original_width = obj.width()
|
||||
obj.wrap("<div class='input-prepend'>")
|
||||
currency_sign = $("<span class='add-on'>€</span>")
|
||||
obj.before(currency_sign)
|
||||
obj.css('width', (original_width - currency_sign.outerWidth())+'px')
|
||||
)
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
};
|
||||
@@ -59,8 +59,8 @@ root.Quser=
|
||||
row.append($('<td class="currency"></td>').html(Qrammer.currency(order.total_amount)))
|
||||
foot.append('<tr><td></td><td class="currency"><strong>'+Qrammer.currency(res.total_amount)+'</strong></td></tr>')
|
||||
)
|
||||
order_selected_products: ()->
|
||||
h = {}
|
||||
order_selected_products: (h)->
|
||||
h ||= {}
|
||||
for product_id, info of window.active_products_list
|
||||
h['products['+product_id+']'] = info.number
|
||||
$.post('/user/order_selected_products', h, ((res) -> Quser.handle_response(res)), 'json')
|
||||
@@ -92,48 +92,67 @@ root.Quser=
|
||||
table.show()
|
||||
|
||||
load_active_list_products: ->
|
||||
$.get('/user/list_products.json', (res) ->
|
||||
window.products = res
|
||||
Quser.populate_products_table('/user/list_products.json', true)
|
||||
load_table_products: (table_id, occupied)->
|
||||
Quser.populate_products_table('/user/list_products_for_table.json?table_id='+table_id, !occupied)
|
||||
populate_products_table: (src, include_order_buttons)->
|
||||
$.get(src, (res) ->
|
||||
body = $('#products-table tbody')
|
||||
for category, products of window.products
|
||||
for category, products of res
|
||||
body.append('<tr><td colspan="4"><h4>'+category+'<h4></td></tr>')
|
||||
for product in products
|
||||
row = $('<tr></tr>')
|
||||
button = $('<button class="btn btn-mini btn-primary">Add</button>')
|
||||
callback = ((prod) ->
|
||||
->
|
||||
product_count_holder = $('#order-product-count-'+prod._id)
|
||||
count = parseInt(product_count_holder.text())
|
||||
product_count_holder.text(1)
|
||||
Quser.add_product(prod, count)
|
||||
)(product)
|
||||
button.click(callback)
|
||||
row.append('<td>'+product.name+'</td>')
|
||||
order_product_count = $('<span id="order-product-count-'+product._id+'" class="order-product-count">1</span>')
|
||||
order_count_minus = $('<span class="btn btn-info btn-mini">-</span>')
|
||||
order_count_minus.click(->
|
||||
val_holder = $(this).siblings('.order-product-count')
|
||||
val = parseInt(val_holder.text())
|
||||
val_holder.text(val - 1) if val > 1
|
||||
)
|
||||
order_count_plus = $('<span class="btn btn-info btn-mini">+</span>')
|
||||
order_count_plus.click(->
|
||||
val_holder = $(this).siblings('.order-product-count')
|
||||
val = parseInt(val_holder.text())
|
||||
val_holder.text(val + 1)
|
||||
)
|
||||
row.append($('<td class="order-count-cell"></td>').append(order_count_minus).append(' ').append(order_product_count).append(' ').append(order_count_plus))
|
||||
if include_order_buttons
|
||||
button = $('<button class="btn btn-mini btn-primary">Add</button>')
|
||||
callback = ((prod) ->
|
||||
->
|
||||
product_count_holder = $('#order-product-count-'+prod._id)
|
||||
count = parseInt(product_count_holder.text())
|
||||
product_count_holder.text(1)
|
||||
Quser.add_product(prod, count)
|
||||
)(product)
|
||||
button.click(callback)
|
||||
order_product_count = $('<span id="order-product-count-'+product._id+'" class="order-product-count">1</span>')
|
||||
order_count_minus = $('<span class="btn btn-info btn-mini">-</span>')
|
||||
order_count_minus.click(->
|
||||
val_holder = $(this).siblings('.order-product-count')
|
||||
val = parseInt(val_holder.text())
|
||||
val_holder.text(val - 1) if val > 1
|
||||
)
|
||||
order_count_plus = $('<span class="btn btn-info btn-mini">+</span>')
|
||||
order_count_plus.click(->
|
||||
val_holder = $(this).siblings('.order-product-count')
|
||||
val = parseInt(val_holder.text())
|
||||
val_holder.text(val + 1)
|
||||
)
|
||||
row.append($('<td class="order-count-cell"></td>').append(order_count_minus).append(' ').append(order_product_count).append(' ').append(order_count_plus))
|
||||
row.append('<td>'+Qrammer.currency(product.price)+'</td>')
|
||||
row.append($('<td></td>').append(button))
|
||||
row.append($('<td></td>').append(button)) if include_order_buttons
|
||||
body.append(row)
|
||||
)
|
||||
|
||||
actions_for_table: (table_id)->
|
||||
$.get('/user/table_info.json?table_id='+table_id, (res)->
|
||||
actions_for_table: (table)->
|
||||
table = JSON.parse(table) if typeof(table) == 'string'
|
||||
$.get('/user/table_info.json?table_id='+table.table_id, (res)->
|
||||
if res.occupied
|
||||
alert('Table is occupied')
|
||||
else
|
||||
$.post('/user/create_list.json', {table_id: table_id}, (res)-> Quser.handle_response(res))
|
||||
if res.other_supplier
|
||||
#TODO cannot do something with other supplier when list is active
|
||||
else if res.current_table_id && res.current_table_id == table.table_id
|
||||
#nothing has changed, show product list
|
||||
window.location = '/user/list_products'
|
||||
else if res.current_table_id && res.current_table_id != table.table_id
|
||||
#TODO Offer to move table
|
||||
$.post('/user/move_table', {table_id: table.table_id}, (res2)->
|
||||
if res2.occupied
|
||||
alert('Cannot move to occupied table')
|
||||
else
|
||||
window.location = '/user/list_products'
|
||||
)
|
||||
else
|
||||
#$.post('/user/create_list.json', {table_id: table.table_id}, (res)-> Quser.handle_response(res))
|
||||
window.location = '/user/list_products_for_table?table_id='+table.table_id
|
||||
, 'json')
|
||||
add_product: (product, count) ->
|
||||
count ||= 1
|
||||
|
||||
Reference in New Issue
Block a user