/* * SimpleModal Confirm Modal Dialog * http://www.ericmmartin.com/projects/simplemodal/ * http://code.google.com/p/simplemodal/ * * Copyright (c) 2010 Eric Martin - http://ericmmartin.com * * Licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php * * Revision: $Id: confirm.js 238 2010-03-11 05:56:57Z emartin24 $ * */ jQuery(function ($) { $('#confirm-dialog input.confirm, #confirm-dialog a.confirm').click(function (e) { e.preventDefault(); // example of calling the confirm function // you must use a callback function to perform the "yes" action confirm($('#coupon_id').val(), function () { window.location.href = '#'; }); }); }); function confirm(message, callback) { $('#confirm').modal({ closeHTML: "x", position: ["20%",], overlayId: 'confirm-overlay', containerId: 'confirm-container', onShow: function (dialog) { // add padding to the buttons in firefox/mozilla if ($.browser.mozilla) { $('.buttons').css({ 'padding-bottom': '2px' }); } // input field font size if ($.browser.safari) { $('.buttons').css({ 'font-size': '.9em' }); } // if the user clicks "yes" $('.yes', dialog.data[0]).click(function () { // call the callback if ($.isFunction(callback)) { if($('#confirm #friend').val().length <=0){ alert('請輸入朋友的email'); return; } if($('#confirm #me').val().length <=0){ alert('請輸入您的email'); return; } if($('#confirm #name').val().length <=0){ alert('請輸入您的姓名'); return; } if($('#confirm #content').val().length <=0){ alert('請輸入留言'); return; } alert('轉寄成功!'); // do forward var localname = 'http://www.wicatch.com/'; $.post(localname + '/coupons/send_mail/'+ $('#confirm #id').val()+'/'+ (($('#confirm #send_me:checked').val() == undefined)?'0':'1') , { friend: '\"'+ $('#confirm #friend').val() + '\"', me: '\"' + $('#confirm #me').val() + '\"', name: '\"' + $('#confirm #name').val() + '\"', content: '\"' + $('#confirm #content').val() + '\"', id: '\"' + $('#confirm #id').val()+ '\"', send_me: '\"' + (($('#confirm #send_me:checked').val() == undefined)?'0':'1')+ '\"' }, function(data){ //alert(data); }); } $('.message', dialog.data['friend']).append(); // close the dialog $.modal.close(); }); } }); }