<commit_before><template>
	<div v-if="$attrs.disabled" class="vue-star-rating">
		<div class="rating-star" 
			v-for="star in stars"
			v-bind:class="['rating-star',star.highlight?'highlight':'',star.active?'active':'']" 
			>★</div>
	</div>
	<div 
		v-else
		class="vue-star-rating"
		v-bind:value="value"
	>
		<div class="rating-star" 
			v-for="star in stars"
			v-on:mouseover="over(star)"
			v-on:mouseout="out(star)"
			v-on:click="click(star)"
			v-bind:class="['rating-star',star.highlight?'highlight':'',star.active?'active':'']" 
			>★</div>
	</div>
</template>

<style lang="less">
.trans{
	-webkit-transition	:color 255ms ease-in-out;
	-moz-transition		:color 255ms ease-in-out;
	-ms-transition		:color 255ms ease-in-out;
	-o-transition		:color 255ms ease-in-out;
	transition			:color 255ms ease-in-out;
}
.vue-star-rating{
	.rating-star{
		.trans;
		float:left;
		color:#999;
		&.highlight{
			color:red;
		}
	}
	&:not([disabled='disabled']){
		.rating-star{
			cursor:pointer;
		}
	}
	&[disabled='disabled']{
		opacity:0.66;
	}
}
</style>

<script>
export default{
	data    :()=>({
		value:0,
		stars 	:[
			{
				id:0,
				highlight:false,
				active:false
			},{
				id:1,
				highlight:false,
				active:false
			},{
				id:2,
				highlight:false,
				active:false
			},{
				id:3,
				highlight:false,
				active:false
			},{
				id:4,
				highlight:false,
				active:false
			}
		]
	}),
	created(){
		if(typeof this.$attrs.value!='undefined'){
			this.init(this.$attrs.value);
		}
	},
	methods:{
		init:function(value){
			for(var i in this.stars){
				this.stars[i].active=(value>=i)?true:false;
				this.stars[i].highlight=(value>=i)?true:false;
			}
			this.value=value;
		},
		over:function(star){
			if(star.active){
				for(var i=star.id+1;this.stars[i];i++){
					this.stars[i].highlight=false;
				}
			}else{
				for(var i in this.stars){
					if(i<=star.id){
						this.stars[i].highlight=true;
					}else{
						break;
					}
				}
			}
		},
		out:function(star){
			for(var i in this.stars){
				this.stars[i].highlight=this.stars[i].active?true:false;
			}
		},
		click:function(star){
			this.value=star.id;
			for(var i in this.stars){
				this.stars[i].active=(i<=star.id)?true:false;
			}
			axios.get('/ajax/star_rating/add',{params:{
				source_id:this.$attrs.id,
				source:this.$attrs.source,
				rating:this.value
			}}).then(response=>{
				this.init(response.data.rating);
				this.$attrs.disabled=true;
			});
		}
	}
}
</script><commit_msg>Update vue2-star-rating.vue<commit_after><template>
	<div v-if="$attrs.disabled" class="vue-star-rating">
		<div v-if="disabledMessage" class="disabled-message">{{disabledMessageText}}</div>
		<div v-for="star in stars" @click="disabledMessageShow()" :class="['rating-star',star.highlight?'highlight':'',star.active?'active':'']">★</div>
	</div>
	<div v-else	class="vue-star-rating" :value="value">
		<div v-for="star in stars"	@mouseover="over(star)"	@mouseout="out(star)" @click="click(star)" :class="['rating-star',star.highlight?'highlight':'',star.active?'active':'']">★</div>
	</div>
</template>

<script>
export default{
	data    :()=>({
		disabledMessage:false,
		disabledMessageText:'Нельзя проголосовать пока вы не ознакомились с материалом.',
		value:0,
		stars 	:[
			{
				id:0,
				highlight:false,
				active:false
			},{
				id:1,
				highlight:false,
				active:false
			},{
				id:2,
				highlight:false,
				active:false
			},{
				id:3,
				highlight:false,
				active:false
			},{
				id:4,
				highlight:false,
				active:false
			}
		]
	}),
	created(){
		if(typeof this.$attrs.value!='undefined'){
			this.init(this.$attrs.value);
		}
	},
	methods:{
		disabledMessageShow :function(){
			this.disabledMessage=true;
			setTimeout(function(){
				this.disabledMessage=false;
			}.bind(this),3333);
		},
		init 		:function(value){
			for(var i in this.stars){
				this.stars[i].active=(value>=i)?true:false;
				this.stars[i].highlight=(value>=i)?true:false;
			}
			this.value=value;
		},
		over 		:function(star){
			if(star.active){
				for(var i=star.id+1;this.stars[i];i++){
					this.stars[i].highlight=false;
				}
			}else{
				for(var i in this.stars){
					if(i<=star.id){
						this.stars[i].highlight=true;
					}else{
						break;
					}
				}
			}
		},
		out 		:function(star){
			for(var i in this.stars){
				this.stars[i].highlight=this.stars[i].active?true:false;
			}
		},
		click 		:function(star){
			this.value=star.id;
			for(var i in this.stars){
				this.stars[i].active=(i<=star.id)?true:false;
			}
			axios.get('/ajax/star_rating/add',{params:{
				source_id:this.$attrs.id,
				source:this.$attrs.source,
				rating:this.value
			}}).then(response=>{
				this.init(response.data.rating);
				this.$attrs.disabled=true;
			});
		}
	}
}
</script>
{'fraction_non_alphanumeric': 0.20117228386016328, 'fraction_numerical': 0.008373456144023446, 'mean_word_length': 3.323981900452489, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2069111', 'n_tokens_mistral': 2309, 'n_tokens_neox': 1838, 'n_words': 249}