1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
3 | typeof define === 'function' && define.amd ? define(factory) :
|
4 | (global.VRating = factory());
|
5 | }(this, (function () { 'use strict';
|
6 |
|
7 | var script = {
|
8 | name: 'VRating',
|
9 |
|
10 | props: {
|
11 | value: {
|
12 | type: Number,
|
13 | default: 0,
|
14 | required: true
|
15 | },
|
16 | type: {
|
17 | type: String,
|
18 | default: 'star',
|
19 | required: false
|
20 | },
|
21 | clearable: {
|
22 | type: Boolean,
|
23 | default: true,
|
24 | required: false
|
25 | },
|
26 | max: {
|
27 | type: Number,
|
28 | default: 5,
|
29 | required: false
|
30 | },
|
31 | initial: {
|
32 | type: Number,
|
33 | default: 0,
|
34 | required: false
|
35 | }
|
36 | },
|
37 |
|
38 | data: function data() {
|
39 | return {
|
40 | el: []
|
41 | };
|
42 | },
|
43 |
|
44 | watch: {
|
45 | value: function value(val, oldVal) {
|
46 | if (val === null) {
|
47 | $(this.el[0]).rating('clear rating');
|
48 | }
|
49 | }
|
50 | },
|
51 |
|
52 | mounted: function mounted() {
|
53 | var t = this;
|
54 | t.el = document.getElementsByClassName('ui rating');
|
55 | $(t.el[0]).rating({
|
56 | initialRating: t.initial,
|
57 | maxRating: t.max,
|
58 | clearable: t.clearable,
|
59 | onRate: function onRate(rating) {
|
60 | t.$emit('input', rating);
|
61 | }
|
62 | });
|
63 | }
|
64 | };
|
65 |
|
66 | function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
|
67 | if (typeof shadowMode !== 'boolean') {
|
68 | createInjectorSSR = createInjector;
|
69 | createInjector = shadowMode;
|
70 | shadowMode = false;
|
71 | }
|
72 |
|
73 | var options = typeof script === 'function' ? script.options : script;
|
74 |
|
75 | if (template && template.render) {
|
76 | options.render = template.render;
|
77 | options.staticRenderFns = template.staticRenderFns;
|
78 | options._compiled = true;
|
79 |
|
80 | if (isFunctionalTemplate) {
|
81 | options.functional = true;
|
82 | }
|
83 | }
|
84 |
|
85 | if (scopeId) {
|
86 | options._scopeId = scopeId;
|
87 | }
|
88 |
|
89 | var hook;
|
90 |
|
91 | if (moduleIdentifier) {
|
92 | hook = function hook(context) {
|
93 | context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
|
94 |
|
95 | if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
96 | context = __VUE_SSR_CONTEXT__;
|
97 | }
|
98 |
|
99 | if (style) {
|
100 | style.call(this, createInjectorSSR(context));
|
101 | }
|
102 |
|
103 | if (context && context._registeredComponents) {
|
104 | context._registeredComponents.add(moduleIdentifier);
|
105 | }
|
106 | };
|
107 |
|
108 | options._ssrRegister = hook;
|
109 | } else if (style) {
|
110 | hook = shadowMode ? function () {
|
111 | style.call(this, createInjectorShadow(this.$root.$options.shadowRoot));
|
112 | } : function (context) {
|
113 | style.call(this, createInjector(context));
|
114 | };
|
115 | }
|
116 |
|
117 | if (hook) {
|
118 | if (options.functional) {
|
119 | var originalRender = options.render;
|
120 |
|
121 | options.render = function renderWithStyleInjection(h, context) {
|
122 | hook.call(context);
|
123 | return originalRender(h, context);
|
124 | };
|
125 | } else {
|
126 | var existing = options.beforeCreate;
|
127 | options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
128 | }
|
129 | }
|
130 |
|
131 | return script;
|
132 | }
|
133 |
|
134 | var normalizeComponent_1 = normalizeComponent;
|
135 |
|
136 | var __vue_script__ = script;
|
137 |
|
138 | var __vue_render__ = function __vue_render__() {
|
139 | var _vm = this;
|
140 | var _h = _vm.$createElement;
|
141 | var _c = _vm._self._c || _h;
|
142 | return _c("div", { staticClass: "ui rating", class: [_vm.type] });
|
143 | };
|
144 | var __vue_staticRenderFns__ = [];
|
145 | __vue_render__._withStripped = true;
|
146 |
|
147 | var __vue_inject_styles__ = undefined;
|
148 |
|
149 | var __vue_scope_id__ = undefined;
|
150 |
|
151 | var __vue_module_identifier__ = undefined;
|
152 |
|
153 | var __vue_is_functional_template__ = false;
|
154 |
|
155 |
|
156 | 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);
|
157 |
|
158 | return VRating;
|
159 |
|
160 | })));
|