@@ -43,13 +43,16 @@ export default {
4343 return ! this . disable && ! this . readonly
4444 }
4545 } ,
46- data : ( ) => ( { view : 'hex' } ) ,
46+ data : ( ) => ( {
47+ view : 'hex'
48+ } ) ,
4749 created ( ) {
4850 this . __saturationChange = throttle ( this . __saturationChange , 20 )
4951 } ,
5052 render ( h ) {
5153 return h ( 'div' , {
52- staticClass : 'q-color'
54+ staticClass : 'q-color' ,
55+ 'class' : { disabled : this . disable }
5356 } , [
5457 this . __getSaturation ( h ) ,
5558 this . __getSliders ( h ) ,
@@ -62,13 +65,16 @@ export default {
6265 ref : 'saturation' ,
6366 staticClass : 'q-color-saturation non-selectable relative-position overflow-hidden cursor-pointer' ,
6467 style : this . saturationStyle ,
65- on : {
66- click : this . __saturationClick
67- } ,
68- directives : [ {
69- name : 'touch-pan' ,
70- value : this . __saturationPan
71- } ]
68+ 'class' : { readonly : this . readonly } ,
69+ on : this . editable
70+ ? { click : this . __saturationClick }
71+ : null ,
72+ directives : this . editable
73+ ? [ {
74+ name : 'touch-pan' ,
75+ value : this . __saturationPan
76+ } ]
77+ : null
7278 } , [
7379 h ( 'div' , { staticClass : 'q-color-saturation-white absolute-full' } ) ,
7480 h ( 'div' , { staticClass : 'q-color-saturation-black absolute-full' } ) ,
@@ -96,7 +102,8 @@ export default {
96102 color : 'none' ,
97103 min : 0 ,
98104 max : 360 ,
99- fillHandleAlways : true
105+ fillHandleAlways : true ,
106+ readonly : ! this . editable
100107 } ,
101108 style : {
102109 color : this . value . hex
@@ -113,7 +120,8 @@ export default {
113120 color : 'none' ,
114121 min : 0 ,
115122 max : 100 ,
116- fillHandleAlways : true
123+ fillHandleAlways : true ,
124+ readonly : this . readonly
117125 } ,
118126 style : {
119127 color : this . value . hex
@@ -136,10 +144,13 @@ export default {
136144 attrs : {
137145 type : 'number' ,
138146 min : 0 ,
139- max
147+ max,
148+ readonly : ! this . editable
140149 } ,
141150 staticClass : 'full-width text-center' ,
142- domProps : { value : ( type === 'a' ? 100 : 1 ) * this . value [ type ] } ,
151+ domProps : {
152+ value : ( type === 'a' ? 100 : 1 ) * this . value [ type ]
153+ } ,
143154 on : {
144155 input : evt => {
145156 this . __onPropChange ( evt , type , max )
@@ -158,9 +169,8 @@ export default {
158169 h ( 'div' , { staticClass : 'col' } , [
159170 h ( 'input' , {
160171 domProps : { value : this . value . hex } ,
161- on : {
162- input : this . __onHexChange
163- } ,
172+ attrs : { readonly : this . readonly } ,
173+ on : { input : this . __onHexChange } ,
164174 staticClass : 'full-width text-center uppercase'
165175 } ) ,
166176 h ( 'div' , { staticClass : 'q-color-label text-center' } , [
@@ -246,10 +256,6 @@ export default {
246256 } ,
247257
248258 __saturationPan ( evt ) {
249- if ( ! this . editable ) {
250- return
251- }
252-
253259 if ( evt . isFinal ) {
254260 this . __dragStop ( evt )
255261 }
@@ -261,18 +267,14 @@ export default {
261267 }
262268 } ,
263269 __dragStart ( event ) {
264- if ( ! this . editable ) {
265- return
266- }
267-
268270 event . evt . stopPropagation ( )
269271 event . evt . preventDefault ( )
270272
271273 this . saturationDragging = true
272274 this . __saturationChange ( event )
273275 } ,
274276 __dragMove ( event ) {
275- if ( ! this . saturationDragging || ! this . editable ) {
277+ if ( ! this . saturationDragging ) {
276278 return
277279 }
278280 event . evt . stopPropagation ( )
@@ -281,10 +283,6 @@ export default {
281283 this . __saturationChange ( event )
282284 } ,
283285 __dragStop ( event ) {
284- if ( ! this . editable ) {
285- return
286- }
287-
288286 event . evt . stopPropagation ( )
289287 event . evt . preventDefault ( )
290288 this . saturationDragging = false
0 commit comments