1(function ($, undefined) { 2 'use strict'; 3 4 var OFFSET = 5; 5 6 function Rating(element, options) { 7 this.$input = $(element); 8 this.$rating = $('<span></span>').insertBefore(this.$input); 9 // Merge data and parameter options. 10 // Those provided as parameter prevail over the data ones. 11 this.options = (function (opts) { 12 // Sanitize start, stop, step, and fractions. 13 // All of them start, stop, and step must be integers. 14 opts.start = parseInt(opts.start, 10); 15 opts.start = isNaN(opts.start) ? undefined : opts.start; 16 // In case we don't have a valid stop rate try to get a reasonable 17 // one based on the existence of a valid start rate. 18 opts.stop = parseInt(opts.stop, 10); 19 opts.stop = isNaN(opts.stop) ? 20 opts.start + OFFSET || undefined : opts.stop; 21 // 0 step is ignored. 22 opts.step = parseInt(opts.step, 10) || undefined; 23 // Symbol fractions and scale (number of significant digits). 24 // 0 is ignored and negative numbers are turned to positive. 25 opts.fractions = Math.abs(parseInt(opts.fractions, 10)) || undefined; 26 opts.scale = Math.abs(parseInt(opts.scale, 10)) || undefined; 27 28 // Extend/Override the default options with those provided either as 29 // data attributes or function parameters. 30 opts = $.extend({}, $.fn.rating.defaults, opts); 31 // Inherit default filled if none is defined for the selected symbol. 32 opts.filledSelected = opts.filledSelected || opts.filled; 33 return opts; 34 }($.extend({}, this.$input.data(), options))); 35 36 this._init(); 37 }; 38 39 Rating.prototype = { 40 _init: function () { 41 var rating = this, 42 $input = this.$input, 43 $rating = this.$rating; 44 45 var ifEnabled = function (f) { 46 return function (e) { 47 // According to the W3C attribute readonly is not allowed on input 48 // elements with type hidden. 49 // Keep readonly prop for legacy but its use should be deprecated. 50 if (!$input.prop('disabled') && !$input.prop('readonly') && 51 $input.data('readonly') === undefined) { 52 f.call(this, e); 53 } 54 } 55 }; 56 57 // Build the rating control. 58 for (var i = 1; i <= this._rateToIndex(this.options.stop); i++) { 59 // Create the rating symbol container. 60 var $symbol = $('<div class="rating-symbol"></div>').css({ 61 display: 'inline-block', 62 position: 'relative' 63 }); 64 // Add background symbol to the symbol container. 65 $('<div class="rating-symbol-background ' + this.options.empty + '"></div>') 66 .appendTo($symbol); 67 // Add foreground symbol to the symbol container. 68 // The filled icon is wrapped with a div to allow fractional selection. 69 $('<div class="rating-symbol-foreground"></div>') 70 .append('<span></span>') 71 .css({ 72 display: 'inline-block', 73 position: 'absolute', 74 overflow: 'hidden', 75 left: 0, 76 // Overspecify right and left to 0 and let the container direction 77 // decide which one is going to take precedence according to the 78 // ltr/rtl direction. 79 // (https://developer.mozilla.org/en-US/docs/Web/CSS/right) 80 // When both the right CSS property and the left CSS property are 81 // defined, the position of the element is overspecified. In that 82 // case, the left value has precedence when the container is 83 // left-to-right (that is that the right computed value is set to 84 // -left), and the right value has precedence when the container is 85 // right-to-left (that is that the left computed value is set to 86 // -right). 87 right: 0, 88 width: 0 89 }).appendTo($symbol); 90 $rating.append($symbol); 91 this.options.extendSymbol.call($symbol, this._indexToRate(i)); 92 } 93 // Initialize the rating control with the associated input value rate. 94 this._updateRate($input.val()); 95 96 // Keep rating control and its associated input in sync. 97 $input 98 .on('change', function () { 99 rating._updateRate($(this).val()); 100 }); 101 102 var fractionalIndex = function (e) { 103 var $symbol = $(e.currentTarget); 104 // Calculate the distance from the mouse pointer to the origin of the 105 // symbol. We need to be careful with the CSS direction. If we are 106 // right-to-left then the symbol starts at the right. So we have to add 107 // the symbol width to the left offset to get the CSS rigth position. 108 var x = Math.abs((e.pageX || e.originalEvent.touches[0].pageX) - 109 (($symbol.css('direction') === 'rtl' && $symbol.width()) + 110 $symbol.offset().left)); 111 112 // NOTE: When the mouse pointer is close to the left side of the symbol 113 // a negative x is returned. Probably some precision error in the 114 // calculation. 115 // x should never be less than 0 because this would mean that we are in 116 // the previous symbol. 117 x = x > 0 ? x : rating.options.scale * 0.1; 118 return $symbol.index() + x / $symbol.width(); 119 }; 120 // Keep the current highlighted index (fractional or not). 121 var index; 122 $rating 123 .on('mousedown touchstart', '.rating-symbol', ifEnabled(function (e) { 124 // Set input 'trigger' the change event. 125 $input.val(rating._indexToRate(fractionalIndex(e))).change(); 126 })) 127 .on('mousemove touchmove', '.rating-symbol', ifEnabled(function (e) { 128 var current = rating._roundToFraction(fractionalIndex(e)); 129 if (current !== index) { 130 // Trigger pseudo rate leave event if the mouse pointer is not 131 // leaving from another symbol (mouseleave). 132 if (index !== undefined) $(this).trigger('rating.rateleave'); 133 // Update index and trigger rate enter event. 134 index = current; 135 $(this).trigger('rating.rateenter', [rating._indexToRate(index)]); 136 } 137 // Fill the symbols as fractions chunks. 138 rating._fillUntil(current); 139 })) 140 .on('mouseleave touchend', '.rating-symbol', ifEnabled(function () { 141 // When a symbol is left, reset index and trigger rate leave event. 142 index = undefined; 143 $(this).trigger('rating.rateleave'); 144 // Restore on hover out. 145 rating._fillUntil(rating._rateToIndex(parseFloat($input.val()))); 146 })); 147 148 }, 149 // Fill rating symbols until index. 150 _fillUntil: function (index) { 151 var $rating = this.$rating; 152 // Get the index of the last whole symbol. 153 var i = Math.floor(index); 154 // Hide completely hidden symbols background. 155 $rating.find('.rating-symbol-background') 156 .css('visibility', 'visible') 157 .slice(0, i).css('visibility', 'hidden'); 158 var $rates = $rating.find('.rating-symbol-foreground'); 159 // Reset foreground 160 $rates.width(0); 161 // Fill all the foreground symbols up to the selected one. 162 $rates.slice(0, i).width('auto') 163 .find('span').attr('class', this.options.filled); 164 // Amend selected symbol.
165 $rates.eq(index % 1 ? i : i - 1) 166 .find('span').attr('class', this.options.filledSelected); 167 // Partially fill the fractional one. 168 $rates.eq(i).width(index % 1 * 100 + '%'); 169 }, 170 // Calculate the rate of an index according the the start and step. 171 _indexToRate: function (index) { 172 return this.options.start + Math.floor(index) * this.options.step + 173 this.options.step * this._roundToFraction(index % 1); 174 }, 175 // Calculate the corresponding index for a rate. 176 _rateToIndex: function (rate) { 177 return (rate - this.options.start) / this.options.step; 178 }, 179 // Round index to the configured opts.fractions. 180 _roundToFraction: function (index) { 181 // Get the closest top fraction. 182 var fraction = Math.ceil(index % 1 * this.options.fractions) / this.options.fractions; 183 // Truncate decimal trying to avoid float precission issues. 184 var p = Math.pow(10, this.options.scale); 185 return Math.floor(index) + Math.floor(fraction * p) / p; 186 }, 187 // Check the rate is in the proper range [start..stop]. 188 _contains: function (rate) { 189 var start = this.options.step > 0 ? this.options.start : this.options.stop; 190 var stop = this.options.step > 0 ? this.options.stop : this.options.start; 191 return start <= rate && rate <= stop; 192 }, 193 // Update empty and filled rating symbols according to a rate. 194 _updateRate: function (rate) { 195 var value = parseFloat(rate); 196 if (this._contains(value)) { 197 this._fillUntil(this._rateToIndex(value)); 198 this.$input.val(value); 199 } 200 }, 201 rate: function (value) { 202 if (value === undefined) { 203 return this.$input.val(); 204 } 205 this._updateRate(value); 206 } 207 }; 208 209 $.fn.rating = function (options) { 210 var args = Array.prototype.slice.call(arguments, 1), 211 result; 212 this.each(function () { 213 var $input = $(this); 214 var rating = $input.data('rating'); 215 if (!rating) { 216 $input.data('rating', (rating = new Rating(this, options))); 217 } 218 // Underscore are used for private methods. 219 if (typeof options === 'string' && options[0] !== '_') { 220 result = rating[options].apply(rating, args); 221 } 222 }); 223 return result || this; 224 }; 225 226 // Plugin defaults. 227 $.fn.rating.defaults = { 228 filled: 'glyphicon glyphicon-star', 229 filledSelected: undefined, 230 empty: 'glyphicon glyphicon-star-empty', 231 start: 0, 232 stop: OFFSET, 233 step: 1, 234 fractions: 1, 235 scale: 3, 236 extendSymbol: function (rate) {}, 237 }; 238 239 $(function () { 240 $('input.rating').rating(); 241 }); 242}(jQuery)); 243 244function countLikes(obj) { 245 var con_id = $(obj).attr("data-id"); 246 var user = $(obj).attr("data-user"); 247 var like_status = $(obj).attr("data-value"); 248 //ER-81117 Start 249 var content_type=0; 250 if(typeof $(obj).attr("data-content_type") !== 'undefined'){ 251 var content_type = $(obj).attr("data-content_type"); 252 } 253 //ER-81117 End 254 if (con_id != '') { 255 $.ajax({
256 url: HTTP_ROOT + "/movie/checkcontentlikes", 257 data: {con_id: con_id, like_status: like_status, user: user,content_type:content_type}, //ER-81117 (Add content_type) 258 method: 'post', 259 success: function (result) { 260 result = JSON.parse(result); 261 if(result.result=='login'){ 262 if ($("#loginModal").length > 0) { 263 $("#loginModal").modal('show'); 264 $('#loader').hide(); 265 $("#loginModal .modal-header h4").html('Please login to Like this Content'); 266 }else{ 267 location.reload(); 268 } 269 }else{ 270 //ER-62081 Start 271 var total_dislikes = parseInt(result.total_dislikes); 272 var total_likes = parseInt(result.total_likes); 273 $('#total_dislikes').html(total_dislikes); 274 $('#total_likes').html(total_likes); 275 276 var likesCount = parseInt(result.get_likes); 277 let likeColour = (likesCount === 1)?"#32c5d2":"#444c53"; 278 $("#likes_chk").attr("data-value", likesCount); 279 $("#likes_chk > span").css('color',likeColour); 280 281 var dislikesCount = parseInt(result.get_dislikes); 282 let dislikeColour = (dislikesCount === 1)?"#32c5d2":"#444c53"; 283 $("#dislikes_chk").attr("data-value", dislikesCount); 284 return $("#dislikes_chk > span").css('color',dislikeColour); 285 //ER-62081 End 286 } 287 } 288 }); 289 } else { 290 return false; 291 } 292} 293//ER-62081 Start 294function countDislikes(obj) { 295 var con_id = $(obj).attr("data-id"); 296 var user = $(obj).attr("data-user"); 297 var dislike_status = $(obj).attr("data-value"); 298 //ER-81117 Start 299 var content_type=0; 300 if(typeof $(obj).attr("data-content_type") !== 'undefined'){ 301 var content_type = $(obj).attr("data-content_type"); 302 } 303 //ER-81117 End 304 if (con_id != '') { 305 $.ajax({
306 url: HTTP_ROOT + "/movie/checkcontentdislikes", 307 data: {con_id: con_id, dislike_status: dislike_status, user: user,content_type:content_type}, //ER-81117 (Add content_type) 308 method: 'post', 309 success: function (result) { 310 result = JSON.parse(result); 311 if(result.result=='login'){ 312 if ($("#loginModal").length > 0) { 313 $("#loginModal").modal('show'); 314 $('#loader').hide(); 315 $("#loginModal .modal-header h4").html('Please login to Dislike this Content'); 316 }else{ 317 location.reload(); 318 } 319 }else{ 320 321 var total_dislikes = parseInt(result.total_dislikes); 322 var total_likes = parseInt(result.total_likes); 323 $('#total_dislikes').html(total_dislikes); 324 $('#total_likes').html(total_likes); 325 326 var likesCount = parseInt(result.get_likes); 327 let likeColour = (likesCount === 1)?"#32c5d2":"#444c53"; 328 $("#likes_chk").attr("data-value", likesCount); 329 $("#likes_chk > span").css('color',likeColour); 330 331 var dislikesCount = parseInt(result.get_dislikes); 332 let dislikeColour = (dislikesCount === 1)?"#32c5d2":"#444c53"; 333 $("#dislikes_chk").attr("data-value", dislikesCount); 334 return $("#dislikes_chk > span").css('color',dislikeColour); 335 } 336 } 337 }); 338 } else { 339 return false; 340 } 341} 342//ER-62081 End
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.