codelation_ui 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +327 -0
  4. data/Rakefile +8 -0
  5. data/app/assets/javascripts/codelation_ui/_base_resources/app.js +91 -0
  6. data/app/assets/javascripts/codelation_ui/_base_resources/components/has_grid.js +24 -0
  7. data/app/assets/javascripts/codelation_ui/_base_resources/components/link.js +22 -0
  8. data/app/assets/javascripts/codelation_ui/_base_resources/progress_bar.js +5 -0
  9. data/app/assets/javascripts/codelation_ui/base.js +8 -0
  10. data/app/assets/javascripts/codelation_ui/extended/slider.js +654 -0
  11. data/app/assets/javascripts/codelation_ui/extended.js +1 -0
  12. data/app/assets/javascripts/codelation_ui/forms/components/input.js +497 -0
  13. data/app/assets/javascripts/codelation_ui/forms/index.js +2 -0
  14. data/app/assets/javascripts/codelation_ui/forms/interfaces/form.js +71 -0
  15. data/app/assets/javascripts/codelation_ui/forms/interfaces/form_validation.js +31 -0
  16. data/app/assets/javascripts/codelation_ui/forms.js +2 -0
  17. data/app/assets/javascripts/codelation_ui/std/index.js +2 -0
  18. data/app/assets/javascripts/codelation_ui/std/interfaces/content_formatters.js +27 -0
  19. data/app/assets/javascripts/codelation_ui/std/interfaces/content_validators.js +50 -0
  20. data/app/assets/javascripts/codelation_ui/std/interfaces/helpers.js +10 -0
  21. data/app/assets/javascripts/codelation_ui/std.js +1 -0
  22. data/app/assets/javascripts/codelation_ui/vue.js +12 -0
  23. data/app/assets/javascripts/codelation_ui/vue_pages.js +11 -0
  24. data/app/assets/javascripts/codelation_ui.js +6 -0
  25. data/app/assets/stylesheets/codelation_ui/_base_resources/_normalize.scss +427 -0
  26. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/_bourbon-deprecated-upcoming.scss +411 -0
  27. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/_bourbon.scss +87 -0
  28. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-color.scss +26 -0
  29. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-radius.scss +48 -0
  30. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-style.scss +25 -0
  31. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-width.scss +25 -0
  32. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_buttons.scss +64 -0
  33. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_clearfix.scss +25 -0
  34. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_ellipsis.scss +30 -0
  35. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_font-stacks.scss +31 -0
  36. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_hide-text.scss +27 -0
  37. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_margin.scss +26 -0
  38. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_padding.scss +26 -0
  39. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_position.scss +48 -0
  40. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_prefixer.scss +66 -0
  41. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_retina-image.scss +25 -0
  42. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_size.scss +51 -0
  43. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_text-inputs.scss +113 -0
  44. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_timing-functions.scss +34 -0
  45. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_triangle.scss +63 -0
  46. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_word-wrap.scss +29 -0
  47. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_animation.scss +43 -0
  48. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_appearance.scss +3 -0
  49. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_backface-visibility.scss +3 -0
  50. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_background-image.scss +42 -0
  51. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_background.scss +55 -0
  52. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_border-image.scss +59 -0
  53. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_calc.scss +4 -0
  54. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_columns.scss +47 -0
  55. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_filter.scss +4 -0
  56. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_flex-box.scss +287 -0
  57. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_font-face.scss +24 -0
  58. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_font-feature-settings.scss +4 -0
  59. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_hidpi-media-query.scss +10 -0
  60. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_hyphens.scss +4 -0
  61. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_image-rendering.scss +14 -0
  62. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_keyframes.scss +36 -0
  63. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_linear-gradient.scss +38 -0
  64. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_perspective.scss +8 -0
  65. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_placeholder.scss +8 -0
  66. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_radial-gradient.scss +39 -0
  67. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_selection.scss +42 -0
  68. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_text-decoration.scss +19 -0
  69. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_transform.scss +15 -0
  70. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_transition.scss +71 -0
  71. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_user-select.scss +3 -0
  72. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_assign-inputs.scss +11 -0
  73. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_contains-falsy.scss +20 -0
  74. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_contains.scss +26 -0
  75. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-length.scss +11 -0
  76. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-light.scss +21 -0
  77. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-number.scss +11 -0
  78. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-size.scss +13 -0
  79. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_modular-scale.scss +69 -0
  80. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_px-to-em.scss +13 -0
  81. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_px-to-rem.scss +15 -0
  82. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_shade.scss +24 -0
  83. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_strip-units.scss +17 -0
  84. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_tint.scss +24 -0
  85. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_transition-property-name.scss +22 -0
  86. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_unpack.scss +27 -0
  87. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_convert-units.scss +21 -0
  88. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_directional-values.scss +96 -0
  89. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_font-source-declaration.scss +43 -0
  90. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_gradient-positions-parser.scss +13 -0
  91. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-angle-parser.scss +25 -0
  92. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-gradient-parser.scss +41 -0
  93. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-positions-parser.scss +61 -0
  94. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-side-corner-parser.scss +31 -0
  95. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_radial-arg-parser.scss +69 -0
  96. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_radial-gradient-parser.scss +50 -0
  97. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_radial-positions-parser.scss +18 -0
  98. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_render-gradients.scss +26 -0
  99. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_shape-size-stripper.scss +10 -0
  100. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_str-to-num.scss +50 -0
  101. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/settings/_asset-pipeline.scss +7 -0
  102. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/settings/_prefixer.scss +9 -0
  103. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/settings/_px-to-em.scss +1 -0
  104. data/app/assets/stylesheets/codelation_ui/_base_resources/functions/color.scss +162 -0
  105. data/app/assets/stylesheets/codelation_ui/_base_resources/functions/text_color.scss +41 -0
  106. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/button.scss +47 -0
  107. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/center_children.scss +9 -0
  108. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/col_span.scss +16 -0
  109. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/has_cards.scss +43 -0
  110. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/has_columns.scss +66 -0
  111. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/has_grid.scss +80 -0
  112. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/outer_container.scss +10 -0
  113. data/app/assets/stylesheets/codelation_ui/base.scss +27 -0
  114. data/app/assets/stylesheets/codelation_ui/extended/slider.scss +222 -0
  115. data/app/assets/stylesheets/codelation_ui/extended.scss +1 -0
  116. data/app/assets/stylesheets/codelation_ui/forms/input.scss +72 -0
  117. data/app/assets/stylesheets/codelation_ui/forms.scss +1 -0
  118. data/app/assets/stylesheets/codelation_ui/std.scss +1 -0
  119. data/app/assets/stylesheets/codelation_ui.scss +4 -0
  120. data/lib/codelation_ui.rb +7 -0
  121. data/vendor/assets/javascripts/autonumeric/autoNumeric-1.9.39.js +1465 -0
  122. data/vendor/assets/javascripts/autonumeric/autonumeric_ujs.js +94 -0
  123. data/vendor/assets/javascripts/autonumeric.js +2 -0
  124. data/vendor/assets/javascripts/awesomplete.js +392 -0
  125. data/vendor/assets/javascripts/moment.js +4301 -0
  126. data/vendor/assets/javascripts/numeral.js +679 -0
  127. data/vendor/assets/javascripts/pikaday.js +1081 -0
  128. data/vendor/assets/javascripts/summernote.js +7300 -0
  129. data/vendor/assets/javascripts/vue.js +10237 -0
  130. metadata +242 -0
@@ -0,0 +1,654 @@
1
+ // From: https://www.npmjs.com/package/vue-slider-component
2
+ // Converted to support Vue 1.x on Rails asset pipeline
3
+
4
+ (function() {
5
+ "use strict";
6
+
7
+ App.register('component').enter(function() {
8
+
9
+ var template = '<div v-el:wrap :class="[\'vue-slider-wrap\', flowDirection, disabledClass, { \'vue-slider-has-label\': piecewiseLabel }]" v-show="show" :style="wrapStyles" @click="wrapClick">\
10
+ <div v-el:elem class="vue-slider" :style="styleMerge(elemStyles, bgStyle)">\
11
+ <template v-if="isMoblie">\
12
+ <template v-if="isRange">\
13
+ <div v-el:dot0 :class="[tooltipStatus, \'vue-slider-dot\']" :style="styleMerge(sliderStyles[0], dotStyles)" @touchstart="moveStart(0)">\
14
+ <span :class="[\'vue-slider-tooltip-\' + tooltipDirection[0], \'vue-slider-tooltip\']" :style="tooltipStyles[0]">{{ formatter ? formatting(val[0]) : val[0] }}</span>\
15
+ </div>\
16
+ <div v-el:dot1 :class="[tooltipStatus, \'vue-slider-dot\']" :style="styleMerge(sliderStyles[1], dotStyles)" @touchstart="moveStart(1)">\
17
+ <span :class="[\'vue-slider-tooltip-\' + tooltipDirection[1], \'vue-slider-tooltip\']" :style="tooltipStyles[1]">{{ formatter ? formatting(val[1]) : val[1] }}</span>\
18
+ </div>\
19
+ </template>\
20
+ <template v-else>\
21
+ <div v-el:dot :class="[tooltipStatus, \'vue-slider-dot\']" :style="styleMerge(sliderStyles, dotStyles)" @touchstart="moveStart">\
22
+ <span :class="[\'vue-slider-tooltip-\' + tooltipDirection, \'vue-slider-tooltip\']" :style="tooltipStyles">{{ formatter ? formatting(val) : val}}</span>\
23
+ </div>\
24
+ </template>\
25
+ </template>\
26
+ <template v-else>\
27
+ <template v-if="isRange">\
28
+ <div v-el:dot0 :class="[tooltipStatus, \'vue-slider-dot\']" :style="styleMerge(sliderStyles[0], dotStyles)" @mousedown="moveStart(0)">\
29
+ <span :class="[\'vue-slider-tooltip-\' + tooltipDirection[0], \'vue-slider-tooltip\']" :style="tooltipStyles[0]">{{ formatter ? formatting(val[0]) : val[0] }}</span>\
30
+ </div>\
31
+ <div v-el:dot1 :class="[tooltipStatus, \'vue-slider-dot\']" :style="styleMerge(sliderStyles[1], dotStyles)" @mousedown="moveStart(1)">\
32
+ <span :class="[\'vue-slider-tooltip-\' + tooltipDirection[1], \'vue-slider-tooltip\']" :style="tooltipStyles[1]">{{ formatter ? formatting(val[1]) : val[1] }}</span>\
33
+ </div>\
34
+ </template>\
35
+ <template v-else>\
36
+ <div v-el:dot :class="[tooltipStatus, \'vue-slider-dot\']" :style="styleMerge(sliderStyles, dotStyles)" @mousedown="moveStart">\
37
+ <span :class="[\'vue-slider-tooltip-\' + tooltipDirection, \'vue-slider-tooltip\']" :style="tooltipStyles">{{ formatter ? formatting(val) : val }}</span>\
38
+ </div>\
39
+ </template>\
40
+ </template>\
41
+ <template v-if="piecewise">\
42
+ <ul class="vue-slider-piecewise">\
43
+ <li v-for="piecewiseObj in piecewiseDotWrap" :style="styleMerge(piecewiseDotStyle, piecewiseObj.style)">\
44
+ <span class="vue-slider-piecewise-dot" :style="styleMerge(piecewiseStyle, piecewiseObj.inRange ? piecewiseActiveStyle : null)"></span>\
45
+ <span v-if="piecewiseLabel" class="vue-slider-piecewise-label" :style="styleMerge(labelStyle, piecewiseObj.inRange ? labelActiveStyle : null)">{{ piecewiseObj.label }}</span>\
46
+ </li>\
47
+ </ul>\
48
+ </template>\
49
+ <div v-el:process class="vue-slider-process" :style="processStyle"></div>\
50
+ </div>\
51
+ </div>';
52
+
53
+ Vue.component('vue-slider', {
54
+ template: template,
55
+ data: function() {
56
+ return {
57
+ flag: false,
58
+ size: 0,
59
+ currentValue: 0,
60
+ currentSlider: 0
61
+ }
62
+ },
63
+ props: {
64
+ width: {
65
+ type: [Number, String],
66
+ default: 'auto'
67
+ },
68
+ height: {
69
+ type: [Number, String],
70
+ default: 6
71
+ },
72
+ data: {
73
+ type: Array,
74
+ default: null
75
+ },
76
+ dotSize: {
77
+ type: Number,
78
+ default: 16
79
+ },
80
+ min: {
81
+ type: Number,
82
+ default: 0
83
+ },
84
+ max: {
85
+ type: Number,
86
+ default: 100
87
+ },
88
+ interval: {
89
+ type: Number,
90
+ default: 1
91
+ },
92
+ show: {
93
+ type: Boolean,
94
+ default: true
95
+ },
96
+ disabled: {
97
+ type: Boolean,
98
+ default: false
99
+ },
100
+ piecewise: {
101
+ type: Boolean,
102
+ default: false
103
+ },
104
+ tooltip: {
105
+ type: [String, Boolean],
106
+ default: 'always'
107
+ },
108
+ eventType: {
109
+ type: String,
110
+ default: 'auto'
111
+ },
112
+ direction: {
113
+ type: String,
114
+ default: 'horizontal'
115
+ },
116
+ reverse: {
117
+ type: Boolean,
118
+ default: false
119
+ },
120
+ lazy: {
121
+ type: Boolean,
122
+ default: false
123
+ },
124
+ clickable: {
125
+ type: Boolean,
126
+ default: true
127
+ },
128
+ speed: {
129
+ type: Number,
130
+ default: 0.5
131
+ },
132
+ realTime: {
133
+ type: Boolean,
134
+ default: false
135
+ },
136
+ value: {
137
+ type: [String, Number, Array],
138
+ default: 0
139
+ },
140
+ piecewiseLabel: {
141
+ type: Boolean,
142
+ default: false
143
+ },
144
+ sliderStyle: [Array, Object],
145
+ tooltipDir: [Array, String],
146
+ formatter: [String, Function],
147
+ piecewiseStyle: Object,
148
+ piecewiseActiveStyle: Object,
149
+ processStyle: Object,
150
+ bgStyle: Object,
151
+ tooltipStyle: [Array, Object],
152
+ labelStyle: Object,
153
+ labelActiveStyle: Object
154
+ },
155
+ computed: {
156
+ flowDirection() {
157
+ return `vue-slider-${this.direction + (this.reverse ? '-reverse' : '')}`
158
+ },
159
+ tooltipDirection() {
160
+ let dir = this.tooltipDir || (this.direction === 'vertical' ? 'left' : 'top')
161
+ if (Array.isArray(dir)) {
162
+ return this.isRange ? dir : dir[1]
163
+ }
164
+ else {
165
+ return this.isRange ? [dir, dir] : dir
166
+ }
167
+ },
168
+ tooltipStatus() {
169
+ return this.tooltip === 'hover' && this.flag ? 'vue-slider-always' : this.tooltip ? `vue-slider-${this.tooltip}` : ''
170
+ },
171
+ tooltipClass() {
172
+ return [`vue-slider-tooltip-${this.tooltipDirection}`, 'vue-slider-tooltip']
173
+ },
174
+ isMoblie() {
175
+ return this.eventType === 'touch' || this.eventType !== 'mouse' && /(iPhone|iPad|iPod|iOS|Android|SymbianOS|Windows Phone|Mobile)/i.test(navigator.userAgent)
176
+ },
177
+ isDisabled() {
178
+ return this.eventType === 'none' ? true : this.disabled
179
+ },
180
+ disabledClass() {
181
+ return this.disabled ? 'vue-slider-disabled' : ''
182
+ },
183
+ isRange() {
184
+ return Array.isArray(this.value)
185
+ },
186
+ slider() {
187
+ return this.isRange ? [this.$els.dot0, this.$els.dot1] : this.$els.dot
188
+ },
189
+ minimum() {
190
+ return this.data ? 0 : this.min
191
+ },
192
+ val: {
193
+ get() {
194
+ return this.data ? (this.isRange ? [this.data[this.currentValue[0]], this.data[this.currentValue[1]]] : this.data[this.currentValue]) : this.currentValue
195
+ },
196
+ set(val) {
197
+ if (this.data) {
198
+ if (this.isRange) {
199
+ let index0 = this.data.indexOf(val[0])
200
+ let index1 = this.data.indexOf(val[1])
201
+ if (index0 > -1 && index1 > -1) {
202
+ this.currentValue = [index0, index1]
203
+ }
204
+ }
205
+ else {
206
+ let index = this.data.indexOf(val)
207
+ if (index > -1) {
208
+ this.currentValue = index
209
+ }
210
+ }
211
+ }
212
+ else {
213
+ this.currentValue = val
214
+ }
215
+ }
216
+ },
217
+ currentIndex() {
218
+ if (this.isRange) {
219
+ return this.data ? this.currentValue : [(this.currentValue[0] - this.minimum) / this.spacing, (this.currentValue[1] - this.minimum) / this.spacing]
220
+ }
221
+ else {
222
+ return (this.currentValue - this.minimum) / this.spacing
223
+ }
224
+ },
225
+ indexRange() {
226
+ if (this.isRange) {
227
+ return this.currentIndex
228
+ }
229
+ else {
230
+ return [0, this.currentIndex]
231
+ }
232
+ },
233
+ maximum() {
234
+ return this.data ? (this.data.length - 1) : this.max
235
+ },
236
+ multiple() {
237
+ let decimals = `${this.interval}`.split('.')[1]
238
+ return decimals ? Math.pow(10, decimals.length) : 1
239
+ },
240
+ spacing() {
241
+ return this.data ? 1 : this.interval
242
+ },
243
+ total() {
244
+ if (this.data) {
245
+ return this.data.length - 1
246
+ }
247
+ else if (~~((this.maximum - this.minimum) * this.multiple) % (this.interval * this.multiple) !== 0) {
248
+ console.error('[Vue-slider warn]: Prop[interval] is illegal, Please make sure that the interval can be divisible')
249
+ }
250
+ return (this.maximum - this.minimum) / this.interval
251
+ },
252
+ gap() {
253
+ return this.size / this.total
254
+ },
255
+ position() {
256
+ return this.isRange ? [(this.currentValue[0] - this.minimum) / this.spacing * this.gap, (this.currentValue[1] - this.minimum) / this.spacing * this.gap] : ((this.currentValue - this.minimum) / this.spacing * this.gap)
257
+ },
258
+ limit() {
259
+ return this.isRange ? [[0, this.position[1]], [this.position[0], this.size]] : [0, this.size]
260
+ },
261
+ valueLimit() {
262
+ return this.isRange ? [[this.minimum, this.currentValue[1]], [this.currentValue[0], this.maximum]] : [this.minimum, this.maximum]
263
+ },
264
+ wrapStyles() {
265
+ return this.direction === 'vertical' ? {
266
+ height: typeof this.height === 'number' ? `${this.height}px` : this.height,
267
+ padding: `${this.dotSize / 2}px`
268
+ } : {
269
+ width: typeof this.width === 'number' ? `${this.width}px` : this.width,
270
+ padding: `${this.dotSize / 2}px`
271
+ }
272
+ },
273
+ sliderStyles() {
274
+ if (Array.isArray(this.sliderStyle)) {
275
+ return this.isRange ? this.sliderStyle : this.sliderStyle[1]
276
+ }
277
+ else {
278
+ return this.isRange ? [this.sliderStyle, this.sliderStyle] : this.sliderStyle
279
+ }
280
+ },
281
+ tooltipStyles() {
282
+ if (Array.isArray(this.tooltipStyle)) {
283
+ return this.isRange ? this.tooltipStyle : this.tooltipStyle[1]
284
+ }
285
+ else {
286
+ return this.isRange ? [this.tooltipStyle, this.tooltipStyle] : this.tooltipStyle
287
+ }
288
+ },
289
+ elemStyles() {
290
+ return this.direction === 'vertical' ? {
291
+ width: `${this.width}px`,
292
+ height: '100%'
293
+ } : {
294
+ height: `${this.height}px`
295
+ }
296
+ },
297
+ dotStyles() {
298
+ return this.direction === 'vertical' ? {
299
+ width: `${this.dotSize}px`,
300
+ height: `${this.dotSize}px`,
301
+ left: `${(-(this.dotSize - this.width) / 2)}px`
302
+ } : {
303
+ width: `${this.dotSize}px`,
304
+ height: `${this.dotSize}px`,
305
+ top: `${(-(this.dotSize - this.height) / 2)}px`
306
+ }
307
+ },
308
+ piecewiseDotStyle() {
309
+ return this.direction === 'vertical' ? {
310
+ width: `${this.width}px`,
311
+ height: `${this.width}px`
312
+ } : {
313
+ width: `${this.height}px`,
314
+ height: `${this.height}px`
315
+ }
316
+ },
317
+ piecewiseDotWrap() {
318
+ if (!this.piecewise) {
319
+ return false
320
+ }
321
+
322
+ let arr = []
323
+ let gap = (this.size - (this.direction === 'vertical' ? this.width : this.height)) / this.total
324
+ for (let i = 0; i <= this.total; i++) {
325
+ let style = this.direction === 'vertical' ? {
326
+ bottom: `${this.gap * i - this.width / 2}px`,
327
+ left: '200px'
328
+ } : {
329
+ left: `${this.gap * i - this.height / 2}px`,
330
+ top: '0'
331
+ }
332
+ let index = this.reverse ? (this.total - i) : i
333
+ let label = this.data ? this.data[index] : (this.spacing * index) + this.min
334
+ arr.push({
335
+ style,
336
+ label: this.formatter ? this.formatting(label) : label,
337
+ inRange: index >= this.indexRange[0] && index <= this.indexRange[1]
338
+ })
339
+ }
340
+ return arr
341
+ }
342
+ },
343
+ watch: {
344
+ value(val) {
345
+ this.flag || this.setValue(val)
346
+ },
347
+ currentValue: function(val) {
348
+ this.value = this.val
349
+ },
350
+ max(val) {
351
+ if (this.flag || this.data) {
352
+ this.refresh()
353
+ }
354
+ else if (this.isRange) {
355
+ let bool
356
+ val = this.val.map((v) => {
357
+ if (v > val) {
358
+ bool = true
359
+ return val
360
+ }
361
+ return v
362
+ })
363
+ bool && this.setValue(val)
364
+ this.refresh()
365
+ }
366
+ else {
367
+ this.val > val && this.setValue(val)
368
+ this.refresh()
369
+ }
370
+ },
371
+ min(val) {
372
+ if (this.flag || this.data) {
373
+ this.refresh()
374
+ }
375
+ else if (this.isRange) {
376
+ let bool
377
+ val = this.val.map((v) => {
378
+ if (v < val) {
379
+ bool = true
380
+ return val
381
+ }
382
+ return v
383
+ })
384
+ bool && this.setValue(val)
385
+ this.refresh()
386
+ }
387
+ else {
388
+ this.val < val && this.setValue(val)
389
+ this.refresh()
390
+ }
391
+ },
392
+ show(bool) {
393
+ if (bool && !this.size) {
394
+ this.$nextTick(() => {
395
+ this.refresh()
396
+ })
397
+ }
398
+ }
399
+ },
400
+ methods: {
401
+ styleMerge(one, two) {
402
+ if (one === undefined) {
403
+ return two;
404
+ }
405
+ if (two === undefined) {
406
+ return one;
407
+ }
408
+ for (var attrname in two) { one[attrname] = two[attrname]; }
409
+ return one;
410
+ },
411
+ bindEvents() {
412
+ if (this.isMoblie) {
413
+ this.$els.wrap.addEventListener('touchmove', this.moving)
414
+ this.$els.wrap.addEventListener('touchend', this.moveEnd)
415
+ }
416
+ else {
417
+ document.addEventListener('mousemove', this.moving)
418
+ document.addEventListener('mouseup', this.moveEnd)
419
+ document.addEventListener('mouseleave', this.moveEnd)
420
+ }
421
+ },
422
+ unbindEvents() {
423
+ window.removeEventListener('resize', this.refresh)
424
+
425
+ if (this.isMoblie) {
426
+ this.$els.wrap.removeEventListener('touchmove', this.moving)
427
+ this.$els.wrap.removeEventListener('touchend', this.moveEnd)
428
+ }
429
+ else {
430
+ document.removeEventListener('mousemove', this.moving)
431
+ document.removeEventListener('mouseup', this.moveEnd)
432
+ document.removeEventListener('mouseleave', this.moveEnd)
433
+ }
434
+ },
435
+ formatting(value) {
436
+ return typeof this.formatter === 'string' ? this.formatter.replace(/\{value\}/, value) : this.formatter(value)
437
+ },
438
+ getPos(e) {
439
+ this.realTime && this.getStaticData()
440
+ return this.direction === 'vertical' ? (this.reverse ? (e.pageY - this.offset) : (this.size - (e.pageY - this.offset))) : (this.reverse ? (this.size - (e.clientX - this.offset)) : (e.clientX - this.offset))
441
+ },
442
+ wrapClick(e) {
443
+ if (this.isDisabled || !this.clickable) return false
444
+ let pos = this.getPos(e)
445
+ if (this.isRange) {
446
+ this.currentSlider = pos > ((this.position[1] - this.position[0]) / 2 + this.position[0]) ? 1 : 0
447
+ }
448
+ this.setValueOnPos(pos)
449
+ },
450
+ moveStart(index) {
451
+ if (this.isDisabled) return false
452
+ else if (this.isRange) {
453
+ this.currentSlider = index
454
+ }
455
+ this.flag = true
456
+ this.$emit('drag-start', this)
457
+ },
458
+ moving(e) {
459
+ if (!this.flag) return false
460
+ e.preventDefault()
461
+
462
+ if (this.isMoblie) e = e.targetTouches[0]
463
+ this.setValueOnPos(this.getPos(e), true)
464
+ },
465
+ moveEnd(e) {
466
+ if (this.flag) {
467
+ this.$emit('drag-end', this)
468
+ if (this.lazy && this.isDiff(this.val, this.value)) {
469
+ this.syncValue()
470
+ }
471
+ }
472
+ else {
473
+ return false
474
+ }
475
+ this.flag = false
476
+ this.setPosition()
477
+ },
478
+ setValueOnPos(pos, isDrag) {
479
+ let range = this.isRange ? this.limit[this.currentSlider] : this.limit
480
+ let valueRange = this.isRange ? this.valueLimit[this.currentSlider] : this.valueLimit
481
+ if (pos >= range[0] && pos <= range[1]) {
482
+ this.setTransform(pos)
483
+ let v = (Math.round(pos / this.gap) * (this.spacing * this.multiple) + (this.minimum * this.multiple)) / this.multiple
484
+ this.setCurrentValue(v, isDrag)
485
+ }
486
+ else if (pos < range[0]) {
487
+ this.setTransform(range[0])
488
+ this.setCurrentValue(valueRange[0])
489
+ if (this.currentSlider === 1) this.currentSlider = 0
490
+ }
491
+ else {
492
+ this.setTransform(range[1])
493
+ this.setCurrentValue(valueRange[1])
494
+ if (this.currentSlider === 0) this.currentSlider = 1
495
+ }
496
+ },
497
+ isDiff(a, b) {
498
+ if (Object.prototype.toString.call(a) !== Object.prototype.toString.call(b)) {
499
+ return true
500
+ }
501
+ else if (Array.isArray(a) && a.length === b.length) {
502
+ return a.some((v, i) => v !== b[i])
503
+ }
504
+ return a !== b
505
+ },
506
+ setCurrentValue(val, bool) {
507
+ if (val < this.minimum || val > this.maximum) return false
508
+ if (this.isRange) {
509
+ if (this.isDiff(this.currentValue[this.currentSlider], val)) {
510
+ this.currentValue.splice(this.currentSlider, 1, val)
511
+ if (!this.lazy || !this.flag) {
512
+ this.syncValue()
513
+ }
514
+ }
515
+ }
516
+ else if (this.isDiff(this.currentValue, val)) {
517
+ this.currentValue = val
518
+ if (!this.lazy || !this.flag) {
519
+ this.syncValue()
520
+ }
521
+ }
522
+ bool || this.setPosition()
523
+ },
524
+ setIndex(val) {
525
+ if (Array.isArray(val) && this.isRange) {
526
+ let value
527
+ if (this.data) {
528
+ value = [this.data[val[0]], this.data[val[1]]]
529
+ }
530
+ else {
531
+ value = [this.spacing * val[0] + this.minimum, this.spacing * val[1] + this.minimum]
532
+ }
533
+ this.setValue(value)
534
+ }
535
+ else {
536
+ val = this.spacing * val + this.minimum
537
+ if (this.isRange) {
538
+ this.currentSlider = val > ((this.currentValue[1] - this.currentValue[0]) / 2 + this.currentValue[0]) ? 1 : 0
539
+ }
540
+ this.setCurrentValue(val)
541
+ }
542
+ },
543
+ setValue(val, speed, isInit) {
544
+ if (this.isDiff(this.val, val)) {
545
+ this.val = val
546
+ !isInit && this.syncValue()
547
+ }
548
+
549
+ this.$nextTick(() => {
550
+ this.setPosition(speed)
551
+ })
552
+ },
553
+ setPosition(speed) {
554
+ this.flag || this.setTransitionTime(speed === undefined ? this.speed : speed)
555
+ if (this.isRange) {
556
+ this.currentSlider = 0
557
+ this.setTransform(this.position[this.currentSlider])
558
+ this.currentSlider = 1
559
+ this.setTransform(this.position[this.currentSlider])
560
+ }
561
+ else {
562
+ this.setTransform(this.position)
563
+ }
564
+ this.flag || this.setTransitionTime(0)
565
+ },
566
+ setTransform(val) {
567
+ let value = (this.direction === 'vertical' ? ((this.dotSize / 2) - val) : (val - (this.dotSize / 2))) * (this.reverse ? -1 : 1)
568
+ let translateValue = this.direction === 'vertical' ? `translateY(${value}px)` : `translateX(${value}px)`
569
+ let processSize = `${this.currentSlider === 0 ? this.position[1] - val : val - this.position[0]}px`
570
+ let processPos = `${this.currentSlider === 0 ? val : this.position[0]}px`
571
+ if (this.isRange) {
572
+ this.slider[this.currentSlider].style.transform = translateValue
573
+ this.slider[this.currentSlider].style.WebkitTransform = translateValue
574
+ this.slider[this.currentSlider].style.msTransform = translateValue
575
+ if (this.direction === 'vertical') {
576
+ this.$els.process.style.height = processSize
577
+ this.$els.process.style[this.reverse ? 'top' : 'bottom'] = processPos
578
+ }
579
+ else {
580
+ this.$els.process.style.width = processSize
581
+ this.$els.process.style[this.reverse ? 'right' : 'left'] = processPos
582
+ }
583
+ }
584
+ else {
585
+ this.slider.style.transform = translateValue
586
+ this.slider.style.WebkitTransform = translateValue
587
+ this.slider.style.msTransform = translateValue
588
+ if (this.direction === 'vertical') {
589
+ this.$els.process.style.height = `${val}px`
590
+ this.$els.process.style[this.reverse ? 'top' : 'bottom'] = 0
591
+ }
592
+ else {
593
+ this.$els.process.style.width = `${val}px`
594
+ this.$els.process.style[this.reverse ? 'right' : 'left'] = 0
595
+ }
596
+ }
597
+ },
598
+ setTransitionTime(time) {
599
+ time || this.$els.process.offsetWidth
600
+ if (this.isRange) {
601
+ for (let i = 0; i < this.slider.length; i++) {
602
+ this.slider[i].style.transitionDuration = `${time}s`
603
+ this.slider[i].style.WebkitTransitionDuration = `${time}s`
604
+ }
605
+ this.$els.process.style.transitionDuration = `${time}s`
606
+ this.$els.process.style.WebkitTransitionDuration = `${time}s`
607
+ }
608
+ else {
609
+ this.slider.style.transitionDuration = `${time}s`
610
+ this.slider.style.WebkitTransitionDuration = `${time}s`
611
+ this.$els.process.style.transitionDuration = `${time}s`
612
+ this.$els.process.style.WebkitTransitionDuration = `${time}s`
613
+ }
614
+ },
615
+ syncValue() {
616
+ this.$emit('callback', this.val)
617
+ this.$emit('input', this.isRange ? this.val.slice() : this.val)
618
+ },
619
+ getValue() {
620
+ return this.val
621
+ },
622
+ getIndex() {
623
+ return this.currentIndex
624
+ },
625
+ getStaticData() {
626
+ if (this.$els.elem) {
627
+ this.size = this.direction === 'vertical' ? this.$els.elem.offsetHeight : this.$els.elem.offsetWidth
628
+ this.offset = this.direction === 'vertical' ? (this.$els.elem.getBoundingClientRect().top + window.pageYOffset || document.documentElement.scrollTop) : this.$els.elem.getBoundingClientRect().left
629
+ }
630
+ },
631
+ refresh() {
632
+ if (this.$els.elem) {
633
+ this.getStaticData()
634
+ this.setPosition()
635
+ }
636
+ }
637
+ },
638
+ created() {
639
+ window.addEventListener('resize', this.refresh)
640
+ },
641
+ ready() {
642
+ var self = this;
643
+ this.$nextTick(function(){
644
+ self.getStaticData()
645
+ self.setValue(self.value, 0, true)
646
+ self.bindEvents()
647
+ })
648
+ },
649
+ destroyed() {
650
+ this.unbindEvents()
651
+ }
652
+ });
653
+ });
654
+ })();
@@ -0,0 +1 @@
1
+ //= require_tree ./extended