vue-material/dist/components/mdRatingBar/index.js
2017-06-20 10:46:21 +02:00

6 lines
No EOL
6.2 KiB
JavaScript

/*!
* Vue Material v0.7.2
* Made with love by Marcos Moura
* Released under the MIT License.
*/
!(function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.VueMaterial=n():t.VueMaterial=n()})(this,(function(){return (function(t){function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var e={};return n.m=t,n.c=e,n.i=function(t){return t},n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="/",n(n.s=466)})({0:function(t,n){t.exports=function(t,n,e,o,i){var r,c=t=t||{},s=typeof t.default;"object"!==s&&"function"!==s||(r=t,c=t.default);var u="function"==typeof c?c.options:c;n&&(u.render=n.render,u.staticRenderFns=n.staticRenderFns),o&&(u._scopeId=o);var a;if(i?(a=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},u._ssrRegister=a):e&&(a=e),a){var l=u.functional,d=l?u.render:u.beforeCreate;l?u.render=function(t,n){return a.call(n),d(t,n)}:u.beforeCreate=d?[].concat(d,a):[a]}return{esModule:r,exports:c,options:u}}},1:function(t,n,e){"use strict";function o(t){if(!t)return null;var n=t.mdTheme;return n||"md-theme"!==t.$options._componentTag||(n=t.mdName),n||o(t.$parent)}Object.defineProperty(n,"__esModule",{value:!0}),n.default={props:{mdTheme:String},computed:{mdEffectiveTheme:function(){return o(this)||this.$material.currentTheme},themeClass:function(){return this.$material.prefix+this.mdEffectiveTheme}},watch:{mdTheme:function(t){this.$material.useTheme(t)}},beforeMount:function(){var t=this.mdTheme;this.$material.useTheme(t||"default")}},t.exports=n.default},100:function(t,n,e){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function i(t){t.component("md-rating-bar",c.default),t.material.styles.push(u.default)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=i;var r=e(344),c=o(r),s=e(282),u=o(s);t.exports=n.default},175:function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=e(1),i=(function(t){return t&&t.__esModule?t:{default:t}})(o);n.default={props:{mdMaxRating:{type:Number,default:5},disabled:Boolean,value:{type:Number,default:0},mdIconSize:{type:Number,default:1},mdFullIconset:String,mdEmptyIconset:String,mdFullIcon:{type:String,default:"star"},mdEmptyIcon:{type:String,default:"star"}},mixins:[i.default],data:function(){return{srcFullIcon:null,srcEmptyIcon:null,rating:this.value}},mounted:function(){this.srcFullIcon=this.checkSrc(this.mdFullIcon),this.srcEmptyIcon=this.checkSrc(this.mdEmptyIcon)},computed:{emptyIcon:function(){return this.mdEmptyIconset?"":this.mdEmptyIcon},fullIcon:function(){return this.mdFullIconset?"":this.mdFullIcon},iconClasses:function(){var t={};return this.mdIconSize&&(t["md-size-"+this.mdIconSize+"x"]=!0),t},fullIconStyle:function(){return{width:100/this.mdMaxRating*this.rating+"%","margin-left":-24*this.mdIconSize*this.mdMaxRating+"px"}}},watch:{mdFullIcon:function(){this.srcFullIcon=this.checkSrc(this.mdFullIcon)},mdEmptyIcon:function(){this.srcEmptyIcon=this.checkSrc(this.mdEmptyIcon)},value:function(){this.rating=this.value}},methods:{hoverStars:function(t){this.disabled||(this.rating=this.getIconIndex(t.currentTarget),this.$emit("hover",this.rating))},clickStars:function(t){if(!this.disabled){var n=this.getIconIndex(t.currentTarget);this.$emit("input",n),this.$emit("change",n)}},getIconIndex:function(t){var n=this,e=this.$el.querySelectorAll(".md-empty-icon > .md-icon, .md-full-icon > .md-icon"),o=-1;return e=Array.prototype.slice.call(e),e.some((function(e,i){if(e===t)return o=(i+1)%n.mdMaxRating,o=o||n.mdMaxRating,!0})),o},checkSrc:function(t){return t&&/.+\.(svg|png)/.test(t)?t:null},onMouseOut:function(){this.rating=this.value}}},t.exports=n.default},245:function(t,n){},282:function(t,n){t.exports=".THEME_NAME.md-rating-bar>.md-empty-icon .md-icon{color:BACKGROUND-CONTRAST-0.26}.THEME_NAME.md-rating-bar>.md-full-icon .md-icon{color:BACKGROUND-CONTRAST-0.38}.THEME_NAME.md-rating-bar.md-primary>.md-full-icon .md-icon{color:PRIMARY-COLOR}.THEME_NAME.md-rating-bar.md-accent>.md-full-icon .md-icon{color:ACCENT-COLOR}.THEME_NAME.md-rating-bar.md-warn>.md-full-icon .md-icon{color:WARN-COLOR}\n"},344:function(t,n,e){function o(t){e(245)}var i=e(0)(e(175),e(409),o,null,null);t.exports=i.exports},409:function(t,n){t.exports={render:function(){var t=this,n=t.$createElement,e=t._self._c||n;return e("div",{staticClass:"md-rating-bar",class:[t.themeClass],attrs:{disabled:t.disabled}},[t.srcEmptyIcon?e("div",{staticClass:"md-empty-icon"},t._l(t.mdMaxRating,(function(n){return t.srcEmptyIcon?e("md-icon",{key:n,class:[t.iconClasses],attrs:{"md-src":t.srcEmptyIcon},nativeOn:{mouseover:function(n){t.hoverStars(n)},click:function(n){t.clickStars(n)},mouseout:function(n){t.onMouseOut(n)}}}):t._e()}))):e("div",{staticClass:"md-empty-icon"},t._l(t.mdMaxRating,(function(n){return e("md-icon",{key:n,class:[t.iconClasses],attrs:{"md-iconset":t.mdEmptyIconset},domProps:{innerHTML:t._s(t.emptyIcon)},nativeOn:{mouseover:function(n){t.hoverStars(n)},click:function(n){t.clickStars(n)},mouseout:function(n){t.onMouseOut(n)}}})}))),t._v(" "),t.srcFullIcon?e("div",{staticClass:"md-full-icon",style:t.fullIconStyle},t._l(t.mdMaxRating,(function(n){return t.srcFullIcon?e("md-icon",{key:n,class:[t.iconClasses],attrs:{"md-src":t.srcFullIcon},nativeOn:{mouseover:function(n){t.hoverStars(n)},click:function(n){t.clickStars(n)},mouseout:function(n){t.onMouseOut(n)}}}):t._e()}))):e("div",{staticClass:"md-full-icon",style:t.fullIconStyle},t._l(t.mdMaxRating,(function(n){return e("md-icon",{key:n,class:[t.iconClasses],attrs:{"md-iconset":t.mdFullIconset},domProps:{innerHTML:t._s(t.fullIcon)},nativeOn:{mouseover:function(n){t.hoverStars(n)},click:function(n){t.clickStars(n)},mouseout:function(n){t.onMouseOut(n)}}})})))])},staticRenderFns:[]}},466:function(t,n,e){t.exports=e(100)}})}));