1$(function() { 2 3 var like = 'ÐÑавиÑÑÑ'; 4 var cancelLike = 'Ðе нÑавиÑÑÑ'; 5 6 if (typeof Yii != 'undefined') { 7 8 like = Yii.t( "common", "Like" ); 9 cancelLike = Yii.t( "common", "Cancel like" ); 10 } 11 12 var INACTIVE_TEXT = like; 13 var ACTIVE_TEXT = cancelLike; 14 15 var channel = window.accountUserWebSocketConnection 16 ? 'likes' + window.accountUserWebSocketConnection.pageKey + window.accountId 17 : undefined; 18 19 $('body').delegate('.b-like .button', 'click', function(){ 20 var $el = $(this); 21 if ($el.hasClass('auth-link')) { 22 var active = window.gcModalActive(); 23 active && active.hide(); 24 window.gcGetDefaultModalAuth().show(); 25 26 return false; 27 } 28 var inProgress = $el.data('in-progress') === true; 29 if (inProgress) { 30 return false; 31 } 32 else { 33 $el.data('in-progress', true); 34 } 35 var isReset = $el.hasClass('like'); 36 var isPositive = $el.hasClass('positive'); 37 var data = { 38 object_id: $el.data('object-id') 39 , object_type_id: $el.data('object-type-id') 40 , is_reset: isReset ? 1 : 0 41 , is_positive: isPositive ? 1 : 0 42 }; 43 if (channel) { 44 data.channel = channel; 45 } 46 var $parent = $el.parent(); 47 var count = $parent.find('.positive-count .value').html(); 48 count = count ? parseInt(count) : 0; 49 applyCount($parent, '.positive-count', isReset ? (count ? count - 1 : 0) : count + 1 ); 50 var likes = { 51 values: {} 52 }; 53 likes.values[window.accountUserId] = !isReset; 54 applyText($el, likes); 55 ajaxCall('/cms/like/like', data, {}, function() { 56 var positiveCount = response.likes.positive_count; 57 applyCount($parent, '.positive-count', positiveCount); 58 var negativeCount = response.likes.negative_count; 59 //applyCount($parent, '.negative-count', negativeCount); // todo 60 applyText($el, response.likes); 61 }, function() { 62 $el.data('in-progress', false); 63 }); 64 }); 65 66 var applyCount = function ($parent, classSelector, count) { 67 if (count > 0) { 68 $parent.find(classSelector).removeClass('hide').find('.value').text(count); 69 } 70 else { 71 $parent.find(classSelector).addClass('hide').find('.value').text(count); 72 } 73 }; 74 75 var applyText = function ($el, likes) { 76 var text; 77 if (likes.values[window.accountUserId] === true) { 78 text = ACTIVE_TEXT; 79 $el.addClass('like'); 80 } 81 else { 82 text = INACTIVE_TEXT; 83 $el.removeClass('like'); 84 } 85 $el.find('.html').html(text); 86 }; 87 88 if (channel) { 89 window.accountUserWebSocketConnection.subscribeChannel(channel, function(message, json){ 90 var $el = $('.'+json.class); 91 if (!($el.length > 0)) { 92 return; 93 } 94 var $parent = $el.parent(); 95 96 applyCount($parent, '.positive-count', json.likes.positive_count); 97 applyCount($parent, '.negative-count', json.likes.negative_count); 98 99 applyText($el.find('.positive'), json.likes); 100 }); 101 } 102 103 $('.positive-count:not(.disable-like-list)').on('click', function (e) { 104 url = '/pl/cms/control/like/users-list?object_id=' + $(this).data('object-id') + '&object_type_id=' + $(this).data('object-type-id'); 105 ajaxCall(url, {}, {}, function (response) { 106 var modal = window.gcModalFactory.create({show: false}); 107 108 modal.getModalEl().find('.modal-dialog').css('max-width', '600px'); 109 modal.getModalEl().find('.modal-dialog').css('margin-top', '50px'); 110 modal.getContentEl().addClass("row-container"); 111 modal.setTitle(response.title); 112 modal.setContent(response.content); 113 modal.show(); 114 115 }); 116 117 return false; 118 }); 119 120 121});
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.