Advertisement
Guest User

Untitled

a guest
May 4th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. $( document ).ready( function() {
  2.  
  3. var cookie_name = 'dbrains-coupon';
  4. var cookie_name_error = 'dbrains-coupon-error';
  5.  
  6. if ( 'undefined' === typeof $.cookie( cookie_name ) ) {
  7. return;
  8. }
  9.  
  10. var message = 'The coupon code ' + $.cookie( cookie_name ).toUpperCase() + ' has been successfully applied.';
  11. var notice_class = 'dbrains-wc-coupons-notice';
  12.  
  13. if ( 'undefined' !== typeof $.cookie( cookie_name_error ) ) {
  14. message = $.cookie( cookie_name_error );
  15. notice_class += ' error';
  16. }
  17.  
  18. var $coupon_notice = $( '<div></div>', {
  19. 'class': notice_class
  20. } );
  21.  
  22. var $coupon_message = $( '<p></p>', {
  23. 'class': 'dbrains-wc-coupons-notice-message'
  24. } );
  25.  
  26. $coupon_message.html( message );
  27. $coupon_notice.prepend( $coupon_message )
  28. $( 'body' ).prepend( $coupon_notice );
  29.  
  30. var coupon_height = $coupon_notice.outerHeight();
  31. $coupon_notice
  32. .css( 'margin-top', -1 * coupon_height )
  33. .show()
  34. .animate( { 'margin-top' : 0 }, 800 );
  35.  
  36. setTimeout( function() {
  37. $coupon_notice
  38. .animate( { 'margin-top' : -1 * coupon_height }, 800, function() {
  39. $( this ).remove();
  40. } );
  41. }, 4000 );
  42.  
  43. // clear the cookies
  44. $.removeCookie( cookie_name, { path: '/' } );
  45. $.removeCookie( cookie_name_error, { path: '/' } );
  46.  
  47. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement