PageSourceSearch

https://ruwest.ru/bitrix/templates/westruss/components/bitrix/iblock.vote/stars/script.js?15526762933018

js ruwest.ru collected 2026-10-02 07:49:47 UTC 3,018 bytes, 127 lines download raw bytes

1;(function(window) {
2	if (window.JCIblockVoteStars)
3		return;
4
5	JCIblockVoteStars = function (params)
6	{
7		this.progressId = params.progressId;
8		this.ratingId = params.ratingId;
9		this.starsId = params.starsId;
10		this.ajaxUrl = params.ajaxUrl;
11		this.voteId = params.voteId;
12		this.starsObj = null;
13		this.votedValue = null;
14		this.preVotedValue = null;
15	};
16
17	JCIblockVoteStars.prototype.setValue = function(value)
18	{
19		value = parseInt(value);
20		if (isNaN(value))
21			value = 0;
22		else if(value > 100)
23			value = 100;
24		else if(value < 0)
25			value = 0;
26
27		var progressObj = BX(this.progressId);
28
29		if(!!progressObj)
30		{
31			progressObj.style.width = parseInt(value)+"%";
32			this.votedValue = value;
33		}
34	};
35
36	JCIblockVoteStars.prototype.setVotes = function(value)
37	{
38		var ratingObj = BX(this.ratingId);
39
40		if(!!ratingObj)
41			ratingObj.innerHTML = "( "+value+" )";
42	};
43
44	JCIblockVoteStars.prototype.getStarsObj = function()
45	{
46		if(!this.starsObj)
47			this.starsObj = BX(this.starsId);
48
49		return this.starsObj;
50	};
51
52	//todo: IE 8 has no pageX, pageY.
53	JCIblockVoteStars.prototype.onMouseMove = function(event)
54	{
55		var starsPos = BX.pos(this.getStarsObj());
56
57		var voteValue = (event.pageX - starsPos.left)/starsPos.width*5;
58
59		for (var i = 1; i <= 5; i++)
60		{
61			if(voteValue < i)
62			{
63				voteValue = i;
64				break;
65			}
66		}
67
68		this.setValue(voteValue*20);
69	};
70
71	JCIblockVoteStars.prototype.onMouseOver = function(event)
72	{
73		BX.bind(this.getStarsObj(), 'click', BX.proxy(this.onVote, this));
74		this.preVotedValue = this.votedValue;
75	};
76
77	JCIblockVoteStars.prototype.onMouseOut = function(event)
78	{
79		BX.unbind(this.getStarsObj(), 'click', BX.proxy(this.onVote, this));
80		this.votedValue = this.preVotedValue;
81		this.setValue(this.votedValue);
82	};
83
84	JCIblockVoteStars.prototype.onVote = function(event)
85	{
86		this.unBindEvents();
87
88		this.ajaxParams.rating = parseInt(this.votedValue/20)-1;
89		this.ajaxParams.vote = "Y";
90		this.ajaxParams.vote_id = this.voteId;
91
92		BX.ajax({
93			timeout:   30,
94			method:   'POST',
95			dataType: 'json',
96			url:       this.ajaxUrl,
97			data:      this.ajaxParams,
98			onsuccess: BX.delegate(this.SetResult, this)
99		});
100	};
101
102	JCIblockVoteStars.prototype.SetResult = function(result)
103	{
104		if (!!result && !result.ERROR)
105		{
106			this.setValue((result.value+1)*20);
107			this.setVotes(result.votes);
108		}
109	};
110
111	JCIblockVoteStars.prototype.bindEvents = function()
112	{
113		var starsObj = this.getStarsObj();
114		BX.bind(starsObj, 'mousemove', BX.proxy(this.onMouseMove, this));
115		BX.bind(starsObj, 'mouseover', BX.proxy(this.onMouseOver, this));
116		BX.bind(starsObj, 'mouseout', BX.proxy(this.onMouseOut, this));
117	};
118
119	JCIblockVoteStars.prototype.unBindEvents = function()
120	{
121		var starsObj = this.getStarsObj();
122		BX.unbind(starsObj, 'mousemove', BX.proxy(this.onMouseMove, this));
123		BX.unbind(starsObj, 'mouseover', BX.proxy(this.onMouseOver, this));
124		BX.unbind(starsObj, 'mouseout', BX.proxy(this.onMouseOut, this));
125		BX.unbind(this.getStarsObj(), 'click', BX.proxy(this.onVote, this));
126	};
127})(window);

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.