/** * classChanged event */ (function( func ) { $.fn.addClass = function() { // replace the existing function on $.fn func.apply( this, arguments ); // invoke the original function this.trigger('classChanged', 'added'); // trigger the custom event return this; // retain jQuery chainability } })($.fn.addClass); // pass the original function as an argument (function( func ) { $.fn.removeClass = function() { func.apply( this, arguments ); this.trigger('classChanged', 'removed'); return this; } })($.fn.removeClass); feedback_fillform = feedback_submitted = catalog_submitted = false; $(document).ready(function() { $(document).on("keypress", ".common-form input", function() { if (location.pathname == '/get-individually-priced/' || location.pathname == '/map-and-adress-and-contacts/' || location.pathname =='/get-business-grow/'){ $('.button').on('classChanged', function(e, type) { if ($(this).hasClass('submitted')){ if (!feedback_submitted){ console.log ('feedback_submitted'); yaCounter45503769.reachGoal("sendapplication"); feedback_submitted = true; } } }); if (!feedback_fillform){ console.log ('feedback_fillform'); yaCounter45503769.reachGoal("fillform"); feedback_fillform = true; } } if (location.pathname == '/'){ $('.button').on('classChanged', function(e, type) { if ($(this).hasClass('submitted')){ if (!catalog_submitted){ console.log ('catalog_submitted'); yaCounter45503769.reachGoal("downloadcatalog"); catalog_submitted = true; } } }); } }); });