window.Qwaiter= alert: (msg) -> $('.modal').modal('hide') template = @mustache('#alert-template', {title: 'Alert', message: msg, close: 'OK'}) $(template).modal() false confirm: (options) -> options ||= {} content = options.content || 'Are you sure?' title = options.title || 'Confirm' wrapper = $('') if typeof(options.ok) == 'function' callback_wrapper = -> wrapper.modal('hide') options.ok() callback_cancel_wrapper = -> wrapper.modal('hide') options.cancel() if options.cancel header = $('') .append('') .append('

'+title+'

').appendTo(wrapper) body = $('').append('

'+content+'

').appendTo(wrapper) ok_button = $('Yes') if typeof(options.ok) == 'function' ok_button.click(callback_wrapper) else ok_button.click -> eval(options.ok) wrapper.modal('hide') footer = $('') .append($('Close').click(callback_cancel_wrapper)) .append(ok_button) .appendTo(wrapper) wrapper.modal() currency: (num) -> num = 0.0 if isNaN(num) || num == '' || num == null '€ ' + parseFloat(num).toFixed(2) mustache: (selector, locals)-> locs = $.extend(locals, currency: -> (val)-> currency(Mustache.render(val, this)) ) Mustache.to_html($(selector).html(), locs) jQuery.ajaxSetup 'beforeSend': (xhr) -> xhr.setRequestHeader("Accept", "text/javascript")