23
23
' <param name="autoPlay" value="false" />\n' +
24
24
' <param name="autoStart" value="false" />\n' +
25
25
' <param name="quality" value="high" />\n' ;
26
+
26
27
var DEFAULT_PREVIEW = '<div class="file-preview-other" ' + STYLE_SETTING + '>\n' +
27
28
' <h2><i class="glyphicon glyphicon-file"></i></h2>\n' +
28
29
' </div>' ;
149
150
return Array . isArray ( a ) || Object . prototype . toString . call ( a ) === '[object Array]' ;
150
151
} ,
151
152
isSet = function ( needle , haystack ) {
152
- return ( typeof haystack == 'object' && typeof haystack [ needle ] !== 'undefined' ) ;
153
+ return ( typeof haystack == 'object' && needle in haystack ) ;
153
154
} ,
154
155
getValue = function ( options , param , value ) {
155
156
return ( isEmpty ( options ) || isEmpty ( options [ param ] ) ) ? value : options [ param ] ;
254
255
self . $element . removeClass ( 'file-loading' ) ;
255
256
} ,
256
257
getLayoutTemplate : function ( t ) {
258
+ var self = this ;
257
259
return isSet ( t , self . layoutTemplates ) ? self . layoutTemplates [ t ] : defaultLayoutTemplates [ t ] ;
258
260
} ,
259
261
getPreviewTemplate : function ( t ) {
262
+ var self = this ;
260
263
return isSet ( t , self . previewTemplates ) ? self . previewTemplates [ t ] : defaultPreviewTemplates [ t ] ;
261
264
} ,
262
265
listen : function ( ) {
672
675
}
673
676
}
674
677
678
+ $ . fn . fileinput = function ( options ) {
679
+ if ( ! hasFileAPISupport ( ) ) {
680
+ return ;
681
+ }
682
+
683
+ return this . each ( function ( ) {
684
+ var $this = $ ( this ) , data = $this . data ( 'fileinput' )
685
+ if ( ! data ) {
686
+ $this . data ( 'fileinput' , ( data = new FileInput ( this , options ) ) )
687
+ }
688
+ if ( typeof options == 'string' ) {
689
+ data [ options ] ( )
690
+ }
691
+ } )
692
+ } ;
693
+
675
694
//FileInput plugin definition
676
695
$ . fn . fileinput = function ( option ) {
677
696
if ( ! hasFileAPISupport ( ) ) {
761
780
}
762
781
} ) ;
763
782
764
- } ) ( window . jQuery ) ;
783
+ } ) ( window . jQuery ) ;
0 commit comments