var shop = { message: null, open: function (dialog) { // add padding to the buttons in firefox/mozilla if ($.browser.mozilla) { $('#shop-container .shop-button').css({ 'padding-bottom': '2px' }); } // input field font size if ($.browser.safari) { $('#shop-container .shop-input').css({ 'font-size': '.9em' }); } // dynamically determine height var h = 405; var title = $('#shop-container .shop-title').html(); $('#shop-container .shop-title').html('Lade...'); dialog.overlay.fadeIn(200, function () { dialog.container.fadeIn(200, function () { dialog.data.fadeIn(200, function () { $('#shop-container .shop-content').animate({ height: h }, function () { $('#shop-container .shop-title').html(title); $('#shop-container form').fadeIn(200, function () { $('#shop-container #shop-name').focus(); $('#shop-container .shop-cc').click(function () { var cc = $('#shop-container #shop-cc'); cc.is(':checked') ? cc.attr('checked', '') : cc.attr('checked', 'checked'); }); // fix png's for IE 6 if ($.browser.msie && $.browser.version < 7) { $('#shop-container .shop-button').each(function () { if ($(this).css('backgroundImage').match(/^url[("']+(.*\.png)[)"']+$/i)) { var src = RegExp.$1; $(this).css({ backgroundImage: 'none', filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '", sizingMethod="crop")' }); } }); } }); }); }); }); }); }, show: function (dialog) { $('#shop-container .shop-send').click(function (e) { e.preventDefault(); // validate form if (shop.validate()) { $('#shop-container .shop-message').fadeOut(function () { $('#shop-container .shop-message').removeClass('shop-error').empty(); }); $('#shop-container .shop-title').html('Sende...'); $('#shop-container form').fadeOut(200); $('#shop-container .shop-content').animate({ height: '150px' }, function () { $('#shop-container .shop-loading').fadeIn(200, function () { $.ajax({ url: 'shop.php', data: $('#shop-container form').serialize() + '&action=add', type: 'post', cache: false, dataType: 'html', complete: function (xhr) { $('#shop-container .shop-loading').fadeOut(200, function () { $('#shop-container .shop-title').html('Vielen Dank!'); $('#shop-container .shop-message').html(xhr.responseText).fadeIn(200); }); }, error: shop.error }); }); }); } else { if ($('#shop-container .shop-message:visible').length > 0) { var msg = $('#shop-container .shop-message div'); msg.fadeOut(200, function () { msg.empty(); shop.showError(); msg.fadeIn(200); }); } else { $('#shop-container .shop-message').animate({ height: '30px' }, shop.showError); } } }); }, close: function (dialog) { $('#shop-container .shop-message').fadeOut(); $('#shop-container .shop-title').html('Und Tschüss...'); $('#shop-container form').fadeOut(200); $('#shop-container .shop-content').animate({ height: 40 }, function () { dialog.data.fadeOut(200, function () { dialog.container.fadeOut(200, function () { dialog.overlay.fadeOut(200, function () { $.modal.close(); }); }); }); }); }, error: function (xhr) { alert(xhr.statusText); }, validate: function () { shop.message = ''; // if (!$('#shop-container #shop-menge').val()) { // shop.message += 'Bitte geben Sie die gewüschte Menge an. '; // } if (shop.message.length > 0) { return false; } else { return true; } }, showError: function () { $('#shop-container .shop-message') .html($('
').append(shop.message)) .fadeIn(200); } };