1(function($){ 2 3 'use strict'; 4 5 window.jnews.like = window.jnews.like || {}; 6 7 window.jnews.like = 8 { 9 init: function($container) 10 { 11 var base = this; 12 13 if ( $container === undefined ) 14 { 15 base.container = $('body'); 16 } else { 17 base.container = $container; 18 } 19 20 base.container.find('.jeg_meta_like > a').unbind('click').bind('click', function(e) 21 { 22 e.preventDefault(); 23 24 if ( $(this).hasClass('clicked') ) return; 25 26 base.element = $(this); 27 base.parent = base.element.parent(); 28 base.like = base.parent.find('.like'); 29 base.dislike = base.parent.find('.dislike'); 30 31 base.ajax_request(); 32 }); 33 }, 34 35 ajax_request: function() 36 { 37 var base = this; 38 39 base.parent.addClass('clicked').find('.fa').addClass('fa-pulse'); 40 41 $.ajax({ 42 url : jnews_ajax_url, 43 type: 'post', 44 dataType: "json", 45 data: { 46 'post_id' : base.element.attr('data-id'), 47 'type' : base.element.attr('data-type'), 48 'action' : 'like_handler' 49 }, 50 }).done(function(data) 51 { 52 if ( data.response === -1 ) 53 { 54 $('#jeg_loginform form').find('h3').html(data.message); 55 window.jnews.loginregister.hook_form(); 56 $.magnificPopup.open({ 57 items: { 58 removalDelay: 500, //delay removal by X to allow out-animation 59 midClick: true, 60 src: "#jeg_loginform", 61 type: 'inline' 62 } 63 }); 64 } else 65 { 66 if ( data.value === 1 ) 67 { 68 base.like.html("<i class='fa fa-thumbs-up'></i> <span>" + data.like + "</span>"); 69 base.dislike.html("<i class='fa fa-thumbs-o-down fa-flip-horizontal'></i> <span>" + data.dislike + "</span>"); 70 } 71 72 if ( data.value === -1 ) 73 { 74 base.like.html("<i class='fa fa-thumbs-o-up'></i> <span>" + data.like + "</span>"); 75 base.dislike.html("<i class='fa fa-thumbs-down fa-flip-horizontal'></i> <span>" + data.dislike + "</span>"); 76 } 77 78 if ( data.value === 0 ) 79 { 80 base.like.html("<i class='fa fa-thumbs-o-up'></i> <span>" + data.like + "</span>"); 81 base.dislike.html("<i class='fa fa-thumbs-o-down fa-flip-horizontal'></i> <span>" + data.dislike + "</span>"); 82 } 83 } 84 }).fail(function(data, textStatus, errorThrown) 85 { 86 if(textStatus === 'error') 87 { 88 alert(errorThrown.toString()); 89 } else if (textStatus === 'timeout') 90 { 91 alert('Execution Timeout'); 92 } 93 }).always(function(data, textStatus, errorThrown) 94 { 95 base.element.attr('data-message', data.message); 96 base.parent.removeClass('clicked').find('.fa').removeClass('fa-pulse');; 97 }); 98 } 99 }; 100 101 $(document).bind('ready jnews-ajax-load', function(e, data) 102 { 103 jnews.like.init(); 104 }); 105 106})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.