var App = function(){ this.currency = "€" $(document).ready(function(){ $('.js-confirm-dialog').modal({ 'show': false }); $('.js-confirm-dialog .js-confirm-cancel').click(function(){ $('.js-confirm-dialog').modal('hide'); }); $('.js-alert-dialog').modal({ 'show' : false }); $('.js-alert-dialog .js-alert-ok').click(function(){ $('.js-alert-dialog').modal('hide'); }); $('.alert .close').click(function(){ $(this).parent().addClass('hidden'); }); $('.js-phone').keyup(function(e) { val = this.value.replace(/[^0-9\+\(\)\-\ ]/g,''); this.value = val; }); }); } App.prototype.confirm = function(message, handler, width ,height) { $('.js-confirm-dialog .js-confirm-content').html(message); $('.js-confirm-dialog .js-confirm-ok').unbind('click').click(handler); $('.js-confirm-dialog').modal('show'); } App.prototype.alert = function(message, width, height, handler) { $('.js-alert-dialog .js-alert-content').html(message); if(handler != null) $('.js-alert-dialog .js-alert-ok').unbind('click').click(handler); $('.js-alert-dialog').modal('show'); } App.prototype.bindNumericEvents = function() { $('.js-numeric').unbind('keyup').keyup(function(e){ val = this.value.replace(/[^0-9\.]/g,''); if(val.split('.').length>2) val =val.replace(/\.+$/,""); this.value = val; }); } App.prototype.showEmailDialog = function(to, subject, message, additionalContent){ $(".js-send-email-alert").addClass("hidden"); $(".js-send-email-alert .js-message").html(''); $(".js-email-to").val((to != null) ? to : ''); $(".js-email-subject").val((subject != null) ? subject : ''); tinymce.get('emailContent').setContent((message != null) ? message : ''); $(".js-email-additionalContent").val((additionalContent != null) ? additionalContent : ''); $('.js-email-dialog').modal('show'); } App.prototype.formatPrice = function(price,currency){ if(currency == null) currency = App.currency; if($.trim(price) == '') price = 0; price = parseFloat(Math.round(price * 100) / 100).toFixed(2); str = price.toString().replace('.00',',-').replace(".",","); return currency + str.toLocaleString().split(",")[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".") + "," + str.toLocaleString().split(",")[1]; } var App = new App(); $(document).ready(function(){ $('.js-numeric').keyup(function(e){ val = this.value.replace(/[^0-9\.]/g,''); if(val.split('.').length>2) val =val.replace(/\.+$/,""); this.value = val; }); /*email dialog*/ $('.js-email-dialog').modal({ 'show': false }); $('.js-email-cancel').click(function(){ $('.js-email-dialog').modal('hide'); }); $('.js-email-ok').click(function(){ tinymce.get("emailContent").save(); $(".js-send-email-form").submit(); }); $(".js-send-email-form").ajaxForm({ beforeSubmit : function(){ $(".js-send-email-loading").show('fade'); }, success : function(response){ var res = eval(response); $(".js-send-email-loading").hide(); if (res.error == 0) { $('.js-email-dialog').modal('hide'); App.alert('De email is verzonden.', 350, 150); } else { $(".js-send-email-alert .js-message").html(''); for (var i=0;i"); } $(".js-send-email-alert").removeClass("hidden"); } } }); tinymce.init({ selector: "textarea#emailContent", theme: "modern", // width: 300, height: 200, toolbar: "bold italic underline | bullist numlist", menubar: false, theme_advanced_path : false }); });