first commit
This commit is contained in:
45
wp-content/themes/calla/assets/js/modules/like.js
Normal file
45
wp-content/themes/calla/assets/js/modules/like.js
Normal file
@@ -0,0 +1,45 @@
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
var like = {};
|
||||
|
||||
like.eltdfOnDocumentReady = eltdfOnDocumentReady;
|
||||
|
||||
$(document).ready(eltdfOnDocumentReady);
|
||||
|
||||
/**
|
||||
* All functions to be called on $(document).ready() should be in this function
|
||||
**/
|
||||
function eltdfOnDocumentReady() {
|
||||
eltdfLikes();
|
||||
}
|
||||
|
||||
function eltdfLikes() {
|
||||
$(document).on('click','.eltdf-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: 'calla_elated_like',
|
||||
likes_id: id,
|
||||
type: type
|
||||
};
|
||||
|
||||
var like = $.post(eltdfGlobalVars.vars.eltdfAjaxUrl, dataToPass, function( data ) {
|
||||
likeLink.html(data).addClass('liked').attr('title', 'You already like this!');
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user