PageSourceSearch

https://cannabis.net/assets/vendor/rateyo/jquery.rateyo.optimized.js

js cannabis.net collected 2026-09-24 08:53:18 UTC 10,475 bytes, 1 lines download raw bytes

1;(function($){"use strict";var BASICSTAR="<?xml version=\"1.0\" encoding=\"utf-8\"?>"+"<svg version=\"1.1\" id=\"Layer_1\""+"xmlns=\"http://www.w3.org/2000/svg\""+"viewBox=\"0 12.705 512 486.59\""+"x=\"0px\" y=\"0px\""+"xml:space=\"preserve\">"+"<polygon id=\"star-icon\""+"points=\"256.814,12.705 317.205,198.566"+" 512.631,198.566 354.529,313.435 "+"414.918,499.295 256.814,384.427 "+"98.713,499.295 159.102,313.435 "+"1,198.566 196.426,198.566 \"/>"+"</svg>";var DEFAULTS={starWidth:"32px",normalFill:"gray",ratedFill:"#f39c12",numStars:5,maxValue:5,precision:1,rating:0,fullStar:false,halfStar:false,readOnly:false,spacing:"0px",onChange:null,onSet:null};function checkPrecision(value,minValue,maxValue){if(value===minValue){value=minValue;}else if(value===maxValue){value=maxValue;}return value;}function checkBounds(value,minValue,maxValue){var isValid=value>=minValue&&value<=maxValue;if(!isValid){throw Error("Invalid Rating, expected value between "+minValue+" and "+maxValue);}return value;}function getInstance(node,collection){var instance;$.each(collection,function(){if(node===this.node){instance=this;return false;}});return instance;}function deleteInstance(node,collection){$.each(collection,function(index){if(node===this.node){var firstPart=collection.slice(0,index),secondPart=collection.slice(index+1,collection.length);collection=firstPart.concat(secondPart);return false;}});return collection;}function isDefined(value){return typeof value!=="undefined";}function RateYo($node,options){this.$node=$node;this.node=$node.get(0);var that=this;$node.addClass("jq-ry-container");var $groupWrapper=$("<div/>").addClass("jq-ry-group-wrapper").appendTo($node);var $normalGroup=$("<div/>").addClass("jq-ry-normal-group").addClass("jq-ry-group").appendTo($groupWrapper);var $ratedGroup=$("<div/>").addClass("jq-ry-rated-group").addClass("jq-ry-group").appendTo($groupWrapper);var step,starWidth,percentOfStar,spacing,percentOfSpacing,containerWidth,minValue=0;function showRating(ratingVal){if(!isDefined(ratingVal)){ratingVal=options.rating;}var numStarsToShow=ratingVal/step;var percent=numStarsToShow*percentOfStar;if(numStarsToShow>1){percent+=(Math.ceil(numStarsToShow)-1)*percentOfSpacing;}$ratedGroup.css("width",percent+"%");}function setContainerWidth(){containerWidth=starWidth*options.numStars;containerWidth+=spacing*(options.numStars-1);percentOfStar=(starWidth/containerWidth)*100;percentOfSpacing=(spacing/containerWidth)*100;$node.width(containerWidth);showRating();}function setStarWidth(newWidth){if(!isDefined(newWidth)){return options.starWidth;}options.starWidth=options.starHeight=newWidth;starWidth=parseFloat(options.starWidth.replace("px",""));$normalGroup.find("svg").attr({width:options.starWidth,height:options.starHeight});$ratedGroup.find("svg").attr({width:options.starWidth,height:options.starHeight});setContainerWidth();return $node;}function setSpacing(newSpacing){if(!isDefined(newSpacing)){return options.spacing;}options.spacing=newSpacing;spacing=parseFloat(options.spacing.replace("px",""));$normalGroup.find("svg:not(:first-child)").css({"margin-left":newSpacing});$ratedGroup.find("svg:not(:first-child)").css({"margin-left":newSpacing});setContainerWidth();return $node;}function setNormalFill(newFill){if(!isDefined(newFill)){return options.normalFill;}options.normalFill=newFill;$normalGroup.find("svg").attr({fill:options.normalFill});return $node;}function setRatedFill(newFill){if(!isDefined(newFill)){return options.ratedFill;}options.ratedFill=newFill;$ratedGroup.find("svg").attr({fill:options.ratedFill});return $node;}function setNumStars(newValue){if(!isDefined(newValue)){return options.numStars;}options.numStars=newValue;step=options.maxValue/options.numStars;$normalGroup.empty();$ratedGroup.empty();for(var i=0;i<options.numStars;i++){$normalGroup.append($(BASICSTAR));$ratedGroup.append($(BASICSTAR));}setStarWidth(options.starWidth);setRatedFill(options.ratedFill);setNormalFill(options.normalFill);setSpacing(options.spacing);showRating();return $node;}function setMaxValue(newValue){if(!isDefined(newValue)){return options.maxValue;}options.maxValue=newValue;step=options.maxValue/options.numStars;if(options.rating>newValue){setRating(newValue);}showRating();return $node;}function setPrecision(newValue){if(!isDefined(newValue)){return options.precision;}options.precision=newValue;showRating();return $node;}function setHalfStar(newValue){if(!isDefined(newValue)){return options.halfStar;}options.halfStar=newValue;return $node;}function setFullStar(newValue){if(!isDefined(newValue)){return options.fullStar;}options.fullStar=newValue;return $node;}function round(value){var remainder=value%step,halfStep=step/2,isHalfStar=options.halfStar,isFullStar=options.fullStar;if(!isFullStar&&!isHalfStar){return value;}if(isFullStar||(isHalfStar&&remainder>halfStep)){value+=step-remainder;}else{value=value-remainder;if(remainder>0){value+=halfStep;}}return value;}function calculateRating(e){var position=$normalGroup.offset(),nodeStartX=position.left,nodeEndX=nodeStartX+$normalGroup.width();var maxValue=options.maxValue;var pageX=e.pageX;var calculatedRating=0;if(pageX<nodeStartX){calculatedRating=minValue;}else if(pageX>nodeEndX){calculatedRating=maxValue;}else{var calcPrcnt=((pageX-nodeStartX)/(nodeEndX-nodeStartX));if(spacing>0){calcPrcnt*=100;var remPrcnt=calcPrcnt;while(remPrcnt>0){if(remPrcnt>percentOfStar){calculatedRating+=step;remPrcnt-=(percentOfStar+percentOfSpacing);}else{calculatedRating+=remPrcnt/percentOfStar*step;remPrcnt=0;}}}else{calculatedRating=calcPrcnt*(options.maxValue);}calculatedRating=round(calculatedRating);}return calculatedRating;}function onMouseEnter(e){var rating=calculateRating(e).toFixed(options.precision);var maxValue=options.maxValue;rating=checkPrecision(parseFloat(rating),minValue,maxValue);showRating(rating);$node.trigger("rateyo.change",{rating:rating});}function onMouseLeave(){showRating();$node.trigger("rateyo.change",{rating:options.rating});}function onMouseClick(e){var resultantRating=calculateRating(e).toFixed(options.precision);resultantRating=parseFloat(resultantRating);that.rating(resultantRating);}function onChange(e,data){if(options.onChange&&typeof options.onChange==="function"){options.onChange.apply(this,[data.rating,that]);}}function onSet(e,data){if(options.onSet&&typeof options.onSet==="function"){options.onSet.apply(this,[data.rating,that]);}}function bindEvents(){$node.on("mousemove",onMouseEnter).on("mouseenter",onMouseEnter).on("mouseleave",onMouseLeave).on("click",onMouseClick).on("rateyo.change",onCh
1ange).on("rateyo.set",onSet);}function unbindEvents(){$node.off("mousemove",onMouseEnter).off("mouseenter",onMouseEnter).off("mouseleave",onMouseLeave).off("click",onMouseClick).off("rateyo.change",onChange).off("rateyo.set",onSet);}function setReadOnly(newValue){if(!isDefined(newValue)){return options.readOnly;}options.readOnly=newValue;$node.attr("readonly",true);unbindEvents();if(!newValue){$node.removeAttr("readonly");bindEvents();}return $node;}function setRating(newValue){if(!isDefined(newValue)){return options.rating;}var rating=newValue;var maxValue=options.maxValue;if(typeof rating==="string"){if(rating[rating.length-1]==="%"){rating=rating.substr(0,rating.length-1);maxValue=100;setMaxValue(maxValue);}rating=parseFloat(rating);}checkBounds(rating,minValue,maxValue);rating=parseFloat(rating.toFixed(options.precision));checkPrecision(parseFloat(rating),minValue,maxValue);options.rating=rating;showRating();$node.trigger("rateyo.set",{rating:rating});return $node;}function setOnSet(method){if(!isDefined(method)){return options.onSet;}options.onSet=method;return $node;}function setOnChange(method){if(!isDefined(method)){return options.onChange;}options.onChange=method;return $node;}this.rating=function(newValue){if(!isDefined(newValue)){return options.rating;}setRating(newValue);return $node;};this.destroy=function(){if(!options.readOnly){unbindEvents();}RateYo.prototype.collection=deleteInstance($node.get(0),this.collection);$node.removeClass("jq-ry-container").children().remove();return $node;};this.method=function(methodName){if(!methodName){throw Error("Method name not specified!");}if(!isDefined(this[methodName])){throw Error("Method "+methodName+" doesn't exist!");}var args=Array.prototype.slice.apply(arguments,[]),params=args.slice(1),method=this[methodName];return method.apply(this,params);};this.option=function(optionName,param){if(!isDefined(optionName)){return options;}var method;switch(optionName){case"starWidth":method=setStarWidth;break;case"numStars":method=setNumStars;break;case"normalFill":method=setNormalFill;break;case"ratedFill":method=setRatedFill;break;case"maxValue":method=setMaxValue;break;case"precision":method=setPrecision;break;case"rating":method=setRating;break;case"halfStar":method=setHalfStar;break;case"fullStar":method=setFullStar;break;case"readOnly":method=setReadOnly;break;case"spacing":method=setSpacing;break;case"onSet":method=setOnSet;break;case"onChange":method=setOnChange;break;default:throw Error("No such option as "+optionName);}return method(param);};setNumStars(options.numStars);setReadOnly(options.readOnly);this.collection.push(this);this.rating(options.rating);}RateYo.prototype.collection=[];window.RateYo=RateYo;function _rateYo(options){var rateYoInstances=RateYo.prototype.collection;var $nodes=$(this);if($nodes.length===0){return $nodes;}var args=Array.prototype.slice.apply(arguments,[]);if(args.length===0){options=args[0]={};}else if(args.length===1&&typeof args[0]==="object"){options=args[0];}else if(args.length>=1&&typeof args[0]==="string"){var methodName=args[0],params=args.slice(1);var result=[];$.each($nodes,function(i,node){var existingInstance=getInstance(node,rateYoInstances);if(!existingInstance){throw Error("Trying to set options before even initialization");}var method=existingInstance[methodName];if(!method){throw Error("Method "+methodName+" does not exist!");}var returnVal=method.apply(existingInstance,params);result.push(returnVal);});result=result.length===1?result[0]:$(result);return result;}else{throw Error("Invalid Arguments");}options=$.extend(JSON.parse(JSON.stringify(DEFAULTS)),options);return $.each($nodes,function(){var existingInstance=getInstance(this,rateYoInstances);if(!existingInstance){return new RateYo($(this),$.extend({},options));}});}function rateYo(){return _rateYo.apply(this,Array.prototype.slice.apply(arguments,[]));}$.fn.rateYo=rateYo;}(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.