(function($) { 'use strict'; var like = {}; mkd.modules.like = like; like.mkdLikes = mkdLikes; like.mkdOnDocumentReady = mkdOnDocumentReady; like.mkdOnWindowLoad = mkdOnWindowLoad; like.mkdOnWindowResize = mkdOnWindowResize; like.mkdOnWindowScroll = mkdOnWindowScroll; $(document).ready(mkdOnDocumentReady); $(window).load(mkdOnWindowLoad); $(window).resize(mkdOnWindowResize); $(window).scroll(mkdOnWindowScroll); /* All functions to be called on $(document).ready() should be in this function */ function mkdOnDocumentReady() { mkdLikes(); } /* All functions to be called on $(window).load() should be in this function */ function mkdOnWindowLoad() { } /* All functions to be called on $(window).resize() should be in this function */ function mkdOnWindowResize() { } /* All functions to be called on $(window).scroll() should be in this function */ function mkdOnWindowScroll() { } function mkdLikes() { $(document).on('click','.mkd-like', function() { var likeLink = $(this), id = likeLink.attr('id'), type; if ( likeLink.hasClass('liked') ) { return false; } if(typeof likeLink.data('type') !== 'undefined') { type = likeLink.data('type'); } var dataToPass = { action: 'topfit_mikado_like', likes_id: id, type: type }; var like = $.post(mkdLike.ajaxurl, dataToPass, function( data ) { likeLink.html(data).addClass('liked').attr('title','You already like this!'); if(type !== 'portfolio_list') { likeLink.children('span').css('opacity',1); } }); return false; }); } })(jQuery);