@@ -76,6 +76,7 @@ function Dropify(element, options) {
7676 this . imgFileExtensions = [ 'png' , 'jpg' , 'jpeg' , 'gif' , 'bmp' ] ;
7777 this . errorsEvent = $ . Event ( 'dropify.errors' ) ;
7878 this . isDisabled = false ;
79+ this . isInit = false ;
7980 this . file = {
8081 object : null ,
8182 name : null ,
@@ -94,7 +95,6 @@ function Dropify(element, options) {
9495 this . onFileReady = this . onFileReady . bind ( this ) ;
9596
9697 this . translateMessages ( ) ;
97- this . translateErrors ( ) ;
9898 this . createElements ( ) ;
9999 this . setContainerSize ( ) ;
100100
@@ -117,6 +117,7 @@ Dropify.prototype.onChange = function()
117117 */
118118Dropify . prototype . createElements = function ( )
119119{
120+ this . isInit = true ;
120121 this . input . wrap ( $ ( this . settings . tpl . wrap ) ) ;
121122 this . wrapper = this . input . parent ( ) ;
122123
@@ -228,7 +229,7 @@ Dropify.prototype.onFileReady = function(event, src)
228229 var errorNamespace = this . errorsEvent . errors [ i ] . namespace ;
229230 var errorKey = errorNamespace . split ( '.' ) . pop ( ) ;
230231 this . showError ( errorKey ) ;
231- } ;
232+ }
232233
233234 if ( typeof this . errorsContainer !== "undefined" ) {
234235 this . errorsContainer . addClass ( 'visible' ) ;
@@ -284,7 +285,13 @@ Dropify.prototype.setPreview = function(src)
284285 this . hideLoader ( ) ;
285286
286287 if ( this . isImage ( ) === true ) {
287- $ ( '<img />' ) . attr ( 'src' , src ) . appendTo ( render ) ;
288+ var imgTag = $ ( '<img />' ) . attr ( 'src' , src ) ;
289+
290+ if ( this . settings . height ) {
291+ imgTag . css ( "max-height" , this . settings . height ) ;
292+ }
293+
294+ imgTag . appendTo ( render ) ;
288295 } else {
289296 $ ( '<i />' ) . attr ( 'class' , 'dropify-font-file' ) . appendTo ( render ) ;
290297 $ ( '<span class="dropify-extension" />' ) . html ( this . getFileType ( ) ) . appendTo ( render ) ;
@@ -417,18 +424,6 @@ Dropify.prototype.translateMessages = function()
417424 }
418425} ;
419426
420- /**
421- * Translate errors if needed.
422- */
423- Dropify . prototype . translateErrors = function ( )
424- {
425- // for (var name in this.settings.tpl) {
426- // for (var key in this.settings.messages) {
427- // this.settings.tpl[name] = this.settings.tpl[name].replace('{{ ' + key + ' }}', this.settings.messages[key]);
428- // }
429- // }
430- } ;
431-
432427/**
433428 * Check the limit filesize.
434429 */
@@ -576,8 +571,6 @@ Dropify.prototype.getError = function(errorKey)
576571 return error ;
577572} ;
578573
579-
580-
581574/**
582575 * Show the loader
583576 */
@@ -598,20 +591,30 @@ Dropify.prototype.hideLoader = function()
598591 }
599592} ;
600593
594+ /**
595+ * Destroy dropify
596+ */
601597Dropify . prototype . destroy = function ( )
602598{
603599 this . input . siblings ( ) . remove ( ) ;
604600 this . input . unwrap ( ) ;
601+ this . isInit = false ;
605602} ;
606603
604+ /**
605+ * Init dropify
606+ */
607607Dropify . prototype . init = function ( )
608608{
609609 this . createElements ( ) ;
610610} ;
611611
612+ /**
613+ * Test if element is init
614+ */
612615Dropify . prototype . isDropified = function ( )
613616{
614- return this . input . parent ( ) . hasClass ( 'dropify-wrapper' ) ;
617+ return this . isInit ;
615618} ;
616619
617620$ . fn [ pluginName ] = function ( options ) {
0 commit comments