@@ -619,28 +619,18 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
619
619
fallback . parentNode . removeChild ( fallback ) ;
620
620
}
621
621
if ( this . options . previewsContainer ) {
622
- if ( typeof this . options . previewsContainer === "string" ) {
623
- this . previewsContainer = document . querySelector ( this . options . previewsContainer ) ;
624
- } else if ( this . options . previewsContainer . nodeType != null ) {
625
- this . previewsContainer = this . options . previewsContainer ;
626
- }
627
- if ( this . previewsContainer == null ) {
628
- throw new Error ( "Invalid `previewsContainer` option provided. Please provide a CSS selector or a plain HTML element." ) ;
629
- }
622
+ this . previewsContainer = Dropzone . getElement ( this . options . previewsContainer , "previewsContainer" ) ;
630
623
} else {
631
624
this . previewsContainer = this . element ;
632
625
}
633
626
if ( this . options . clickable ) {
634
627
if ( this . options . clickable === true ) {
635
- this . clickableElement = this . element ;
636
- } else if ( typeof this . options . clickable === "string" ) {
637
- this . clickableElement = document . querySelector ( this . options . clickable ) ;
638
- } else if ( this . options . clickable . nodeType != null ) {
639
- this . clickableElement = this . options . clickable ;
640
- }
641
- if ( ! this . clickableElement ) {
642
- throw new Error ( "Invalid `clickable` element provided. Please set it to `true`, a plain HTML element or a valid CSS selector." ) ;
628
+ this . clickableElements = [ this . element ] ;
629
+ } else {
630
+ this . clickableElements = Dropzone . getElements ( this . options . clickable , "clickable" ) ;
643
631
}
632
+ } else {
633
+ this . clickableElements = [ ] ;
644
634
}
645
635
this . init ( ) ;
646
636
}
@@ -655,7 +645,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
655
645
if ( this . element . classList . contains ( "dropzone" ) && ! this . element . querySelector ( "[data-dz-message]" ) ) {
656
646
this . element . appendChild ( Dropzone . createElement ( "<div class=\"dz-default dz-message\" data-dz-message><span>" + this . options . dictDefaultMessage + "</span></div>" ) ) ;
657
647
}
658
- if ( this . clickableElement ) {
648
+ if ( this . clickableElements . length ) {
659
649
setupHiddenFileInput = function ( ) {
660
650
if ( _this . hiddenFileInput ) {
661
651
document . body . removeChild ( _this . hiddenFileInput ) ;
@@ -750,18 +740,18 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
750
740
}
751
741
}
752
742
] ;
753
- if ( this . clickableElement ) {
754
- this . listeners . push ( {
755
- element : this . clickableElement ,
743
+ this . clickableElements . forEach ( function ( clickableElement ) {
744
+ return _this . listeners . push ( {
745
+ element : clickableElement ,
756
746
events : {
757
747
"click" : function ( evt ) {
758
- if ( ( _this . clickableElement !== _this . element ) || ( evt . target === _this . element || Dropzone . elementInside ( evt . target , _this . element . querySelector ( ".dz-message" ) ) ) ) {
748
+ if ( ( clickableElement !== _this . element ) || ( evt . target === _this . element || Dropzone . elementInside ( evt . target , _this . element . querySelector ( ".dz-message" ) ) ) ) {
759
749
return _this . hiddenFileInput . click ( ) ;
760
750
}
761
751
}
762
752
}
763
753
} ) ;
764
- }
754
+ } ) ;
765
755
this . enable ( ) ;
766
756
return this . options . init . call ( this ) ;
767
757
} ;
@@ -855,18 +845,18 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
855
845
} ;
856
846
857
847
Dropzone . prototype . disable = function ( ) {
858
- if ( this . clickableElement === this . element ) {
859
- this . element . classList . remove ( "dz-clickable" ) ;
860
- }
848
+ this . clickableElements . forEach ( function ( element ) {
849
+ return element . classList . remove ( "dz-clickable" ) ;
850
+ } ) ;
861
851
this . removeEventListeners ( ) ;
862
852
this . filesProcessing = [ ] ;
863
853
return this . filesQueue = [ ] ;
864
854
} ;
865
855
866
856
Dropzone . prototype . enable = function ( ) {
867
- if ( this . clickableElement === this . element ) {
868
- this . element . classList . add ( "dz-clickable" ) ;
869
- }
857
+ this . clickableElements . forEach ( function ( element ) {
858
+ return element . classList . add ( "dz-clickable" ) ;
859
+ } ) ;
870
860
return this . setupEventListeners ( ) ;
871
861
} ;
872
862
@@ -1255,6 +1245,50 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
1255
1245
return false ;
1256
1246
} ;
1257
1247
1248
+ Dropzone . getElement = function ( el , name ) {
1249
+ var element ;
1250
+
1251
+ if ( typeof el === "string" ) {
1252
+ element = document . querySelector ( el ) ;
1253
+ } else if ( el . nodeType != null ) {
1254
+ element = el ;
1255
+ }
1256
+ if ( element == null ) {
1257
+ throw new Error ( "Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element." ) ;
1258
+ }
1259
+ return element ;
1260
+ } ;
1261
+
1262
+ Dropzone . getElements = function ( els , name ) {
1263
+ var e , el , elements , _i , _j , _len , _len1 , _ref ;
1264
+
1265
+ if ( els instanceof Array ) {
1266
+ elements = [ ] ;
1267
+ try {
1268
+ for ( _i = 0 , _len = els . length ; _i < _len ; _i ++ ) {
1269
+ el = els [ _i ] ;
1270
+ elements . push ( this . getElement ( el , name ) ) ;
1271
+ }
1272
+ } catch ( _error ) {
1273
+ e = _error ;
1274
+ elements = null ;
1275
+ }
1276
+ } else if ( typeof els === "string" ) {
1277
+ elements = [ ] ;
1278
+ _ref = document . querySelectorAll ( els ) ;
1279
+ for ( _j = 0 , _len1 = _ref . length ; _j < _len1 ; _j ++ ) {
1280
+ el = _ref [ _j ] ;
1281
+ elements . push ( el ) ;
1282
+ }
1283
+ } else if ( els . nodeType != null ) {
1284
+ elements = [ els ] ;
1285
+ }
1286
+ if ( ! ( ( elements != null ) && elements . length ) ) {
1287
+ throw new Error ( "Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those." ) ;
1288
+ }
1289
+ return elements ;
1290
+ } ;
1291
+
1258
1292
Dropzone . isValidMimeType = function ( mimeType , acceptedMimeTypes ) {
1259
1293
var baseMimeType , validMimeType , _i , _len ;
1260
1294
0 commit comments