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A,EAAIK,MAEJ,OADAL,EAAIC,kBACG,CAEf,IAEAlE,OAAO,QAAQgE,GAAG,SAAU,8BAA8B,SAASC,GAC/DjE,OAAOmE,MAAMvC,IAAK5B,OAAOmE,MAAMvC,MAAMmB,QAAQ,YAAa,IAC9D,IAEA/C,OAAO,QAAQgE,GAAG,QAAS,wBAAwB,SAASC,GACxDA,EAAIC,iBACJ9D,EAAYG,SAAUP,OAAOmE,MACjC,IAEAnE,OAAO,QAAQgE,GAAG,SAAU,sBAAsB,SAASC,GACvDA,EAAIC,iBACJ9D,EAAYG,SAAUP,OAAOmE,MACjC,IAEAnE,OAAO,QAAQgE,GAAG,QAAS,yBAAyB,SAASC,GACzDA,EAAIC,iBACJ9D,EAAYqD,WAChB,GAEJ,GAEH,CApLD,CAoLGzD,O","sources":["webpack://order-tip-woo/external var \"jQuery\"","webpack://order-tip-woo/./assets/src/js/front/front.js"],"sourcesContent":["const __WEBPACK_NAMESPACE_OBJECT__ = jQuery;","import $ from 'jquery';\n\n(function($) {\n\n const orderTipPlacedEvent = new CustomEvent('wootipplaced');\n const orderTipRemove = new CustomEvent('wootipremove');\n\n const WooOrderTip = {\n\n selectTip: trigger => {\n\n const applyTip = trigger.parent().find('button.woo_order_tip_apply');\n \n jQuery('.woo_order_tip').removeClass('active');\n \n trigger.addClass('active');\n \n const tip = trigger.data('tip');\n \n if( tip == 'custom' ) {\n applyTip.toggle();\n trigger.parent().find('.woo_order_tip_custom_text').toggle().focus();\n } else {\n WooOrderTip.applyTip( trigger );\n }\n \n },\n\n applyTip: trigger => {\n\n const container = trigger.parents('#wooot_order_tip_form'),\n tip_type = container.find('.woo_order_tip.active').data('tip-type'),\n tip_type_symbol = tip_type == '1' ? '%' : wootip.cs,\n tip_custom = container.find('.woo_order_tip.active').data('tip-custom'),\n tip_cash = container.find('.woo_order_tip.active').data('tip-cash'),\n tip_recurring = container.find('#woo_recurring_tip').is(':checked');\n \n let errors = 0,\n tip = container.find('.woo_order_tip.active').data('tip');\n\n const tip_label = tip + tip_type_symbol\n \n if( tip == 'custom' ) {\n\n tip = container.find('.woo_order_tip_custom_text').val();\n\n if( ! tip || parseInt( tip ) == 0 ) {\n container.find('.woo_order_tip_custom_text').css('border', '1px solid red').focus();\n errors = 1;\n return false;\n } else {\n container.find('.woo_order_tip_custom_text').css('border', 'initial');\n errors = 0;\n }\n\n }\n\n if( ! errors ) {\n\n jQuery('.woocommerce').block({message: ''});\n\n jQuery.ajax({\n type: \"POST\",\n url: wootip.au,\n dataType: 'json',\n data: ({\n action: 'apply_tip', \n tip: tip, \n tip_type: tip_type, \n tip_label: tip_label, \n tip_custom: tip_custom, \n tip_cash: tip_cash, \n tip_recurring: tip_recurring, \n security: wootip.n\n }),\n success: function (tipApplied) {\n\n if( tipApplied.status && 'success' === tipApplied.status ) {\n if( tip_custom ) {\n jQuery('.woo_order_tip[data-tip=\"custom\"]').text( wootip.s.cut + ' (' + wootip.cs + tip.replace( ',', wootip.ds ).replace( '.', wootip.ds ) + ')' );\n }\n jQuery('body').trigger( 'update_checkout' );\n if( jQuery( 'button[name=\"update_cart\"]' ).length ) {\n jQuery( 'button[name=\"update_cart\"]' ).attr('aria-disabled', false).removeAttr('disabled').trigger('click');\n }\n \n jQuery('.woo_order_tip_remove').show();\n jQuery('.woo_order_tip_apply').hide();\n jQuery('.woo_order_tip_custom_text').hide();\n\n document.dispatchEvent(orderTipPlacedEvent);\n\n jQuery('.woocommerce').unblock();\n \n }\n\n }\n });\n\n }\n\n },\n\n removeTip: () => {\n\n if( wootip.eart == '1' ) {\n\n if( confirm( wootip.s.rtc ) === true ) {\n WooOrderTip.doRemoveTip();\n }\n \n } else {\n WooOrderTip.doRemoveTip();\n }\n\n },\n\n doRemoveTip: () => {\n\n jQuery('.woocommerce').block({message: ''});\n\n jQuery.ajax({\n type: \"POST\",\n url: wootip.au,\n dataType: 'html',\n data: ({action: 'remove_tip', security: wootip.n2}),\n success: function (tipRemoved) {\n\n if( tipRemoved == 'success' ) {\n document.dispatchEvent(orderTipRemove);\n jQuery('.woo_order_tip[data-tip=\"custom\"]').text( wootip.s.cut );\n jQuery('body').trigger( 'update_checkout' );\n jQuery('[name=\"update_cart\"]').attr('aria-disabled', false).removeAttr('disabled').trigger('click');\n jQuery('.woocommerce').unblock();\n jQuery('.woo_order_tip_remove').hide();\n jQuery('.woo_order_tip').removeClass('active');\n }\n\n }\n\n });\n\n }\n\n }\n\n jQuery(function() {\n\n jQuery('body').on('click', '.woo_order_tip', function(evt){\n evt.preventDefault();\n WooOrderTip.selectTip( jQuery(this) );\n });\n\n jQuery('.woo_order_tip_custom_text').on('keypress', function(evt){\n console.log(evt);\n if( evt.which == 13 ) {\n evt.preventDefault();\n return false;\n }\n });\n \n jQuery('body').on('change', '.woo_order_tip_custom_text', function(evt){\n jQuery(this).val( jQuery(this).val().replace(/[^0-9.,]/g, '') );\n });\n \n jQuery('body').on('click', '.woo_order_tip_apply', function(evt){\n evt.preventDefault();\n WooOrderTip.applyTip( jQuery(this) );\n });\n \n jQuery('body').on('change', '#woo_recurring_tip', function(evt){\n evt.preventDefault();\n WooOrderTip.applyTip( jQuery(this) );\n });\n \n jQuery('body').on('click', '.woo_order_tip_remove', function(evt){\n evt.preventDefault();\n WooOrderTip.removeTip();\n });\n \n });\n\n})(jQuery);"],"names":["jQuery","orderTipPlacedEvent","CustomEvent","orderTipRemove","WooOrderTip","selectTip","trigger","applyTip","parent","find","removeClass","addClass","data","toggle","focus","container","parents","tip_type","tip_type_symbol","wootip","cs","tip_custom","tip_cash","tip_recurring","is","errors","tip","tip_label","val","parseInt","css","block","message","ajax","type","url","au","dataType","action","security","n","success","tipApplied","status","text","s","cut","replace","ds","length","attr","removeAttr","show","hide","document","dispatchEvent","unblock","removeTip","eart","confirm","rtc","doRemoveTip","n2","tipRemoved","on","evt","preventDefault","this","console","log","which"],"sourceRoot":""}