v-rating
Version:
Rating component in Semantic-UI made with VueJS
153 lines (124 loc) • 3.66 kB
JavaScript
var script = {
name: 'VRating',
props: {
value: {
type: Number,
default: 0,
required: true
},
type: {
type: String,
default: 'star',
required: false
},
clearable: {
type: Boolean,
default: true,
required: false
},
max: {
type: Number,
default: 5,
required: false
},
initial: {
type: Number,
default: 0,
required: false
}
},
data: function data() {
return {
el: []
};
},
watch: {
value: function value(val, oldVal) {
if (val === null) {
$(this.el[0]).rating('clear rating');
}
}
},
mounted: function mounted() {
var t = this;
t.el = document.getElementsByClassName('ui rating');
$(t.el[0]).rating({
initialRating: t.initial,
maxRating: t.max,
clearable: t.clearable,
onRate: function onRate(rating) {
t.$emit('input', rating);
}
});
}
};
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
if (typeof shadowMode !== 'boolean') {
createInjectorSSR = createInjector;
createInjector = shadowMode;
shadowMode = false;
}
var options = typeof script === 'function' ? script.options : script;
if (template && template.render) {
options.render = template.render;
options.staticRenderFns = template.staticRenderFns;
options._compiled = true;
if (isFunctionalTemplate) {
options.functional = true;
}
}
if (scopeId) {
options._scopeId = scopeId;
}
var hook;
if (moduleIdentifier) {
hook = function hook(context) {
context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__;
}
if (style) {
style.call(this, createInjectorSSR(context));
}
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier);
}
};
options._ssrRegister = hook;
} else if (style) {
hook = shadowMode ? function () {
style.call(this, createInjectorShadow(this.$root.$options.shadowRoot));
} : function (context) {
style.call(this, createInjector(context));
};
}
if (hook) {
if (options.functional) {
var originalRender = options.render;
options.render = function renderWithStyleInjection(h, context) {
hook.call(context);
return originalRender(h, context);
};
} else {
var existing = options.beforeCreate;
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
}
}
return script;
}
var normalizeComponent_1 = normalizeComponent;
var __vue_script__ = script;
var __vue_render__ = function __vue_render__() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c("div", { staticClass: "ui rating", class: [_vm.type] });
};
var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
var __vue_inject_styles__ = undefined;
var __vue_scope_id__ = undefined;
var __vue_module_identifier__ = undefined;
var __vue_is_functional_template__ = false;
var VRating = normalizeComponent_1({ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);
export default VRating;