浏览代码

Fix #187: New property `previewFileIcon` to configure file icon shown in preview for unreadable file types

Kartik Visweswaran 10 年之前
父节点
当前提交
c70df9dbfb
共有 5 个文件被更改,包括 16 次插入7 次删除
  1. 2 0
      CHANGE.md
  2. 4 1
      README.md
  3. 6 4
      examples/index.html
  4. 4 2
      js/fileinput.js
  5. 0 0
      js/fileinput.min.js

+ 2 - 0
CHANGE.md

@@ -12,6 +12,8 @@ version 4.1.8
 8. (enh #179): Validate and cast `maxFileSize`, `maxFileCount`, and `initialPreviewCount` to numeric - even if they have been setup as a string.
 9. (enh #181): Fix change event triggered for IE 11 when file input is set to empty.
 10. (enh #183): Delete extra data enhancements.
+11. (enh #184): Fix documentation for filedeleted event.
+12. (enh #187): New property `previewFileIcon` to configure file icon shown in preview for unreadable file types.
 
 version 4.1.7
 =============

+ 4 - 1
README.md

@@ -631,6 +631,9 @@ This is by default setup as following:
 }
 ```
 
+#### previewFileIcon
+_string_ the icon to be shown in each preview file thumbnail when an unreadable file type for preview is detected. Defaults to `<i class="glyphicon glyphicon-file"></i>`.
+
 #### browseLabel
 _string_ the label to display for the file picker/browse button. Defaults to `Browse &hellip;`.
 
@@ -1107,7 +1110,7 @@ This event is triggered after deletion of each thumbnail file in the `initialPre
 - `data`: the output of `deleteExtraData` object.
 
 ```js
-$('#input-id').on('filedelete', function(event, key) {
+$('#input-id').on('filedeleted', function(event, key) {
     console.log('Key = ' + key);
 });
 ```

+ 6 - 4
examples/index.html

@@ -4,11 +4,11 @@
     <head>
         <meta charset="UTF-8"/>
         <title>Krajee JQuery Plugins - &copy; Kartik</title>
-        <link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
+        <link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
         <link href="../css/fileinput.css" media="all" rel="stylesheet" type="text/css" />
         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
         <script src="../js/fileinput.js" type="text/javascript"></script>
-        <script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js" type="text/javascript"></script>
+        <script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js" type="text/javascript"></script>
     </head>
     <body>
         <div class="container kv-main">
@@ -26,6 +26,7 @@
                     <input id="file-2" type="file" class="file" readonly=true data-show-upload="false">
                 </div> 
                 <div class="form-group">
+                    <label>Preview File Icon</label>
                     <input id="file-3" type="file" multiple=true>
                 </div>
                 <div class="form-group">
@@ -42,7 +43,7 @@
                     <div id="errorBlock" class="help-block"></div>
                 </div>
                 <div class="form-group">
-                    <input id="file-5" class="file" type="file" multiple=true data-preview-file-type="any" data-upload-url="#">
+                    <input id="file-5" class="file" type="file" multiple=true data-preview-file-type="any" data-upload-url="#" data-preview-file-icon="">
                 </div>
             </form>
         </div>
@@ -71,7 +72,8 @@
 		showUpload: false,
 		showCaption: false,
 		browseClass: "btn btn-primary btn-lg",
-		fileType: "any"
+		fileType: "any",
+        previewFileIcon: "<i class='glyphicon glyphicon-king'></i>"
 	});
 	$("#file-4").fileinput({
 		uploadExtraData: [

+ 4 - 2
js/fileinput.js

@@ -59,7 +59,7 @@
             '      <param name="autoStart" value="false" />\n' +
             '      <param name="quality" value="high" />\n',
         DEFAULT_PREVIEW = '<div class="file-preview-other">\n' +
-            '       <i class="glyphicon glyphicon-file"></i>\n' +
+            '       {previewFileIcon}\n' +
             '   </div>',
         defaultFileActionSettings = {
             removeIcon: '<i class="glyphicon glyphicon-trash text-danger"></i>',
@@ -387,6 +387,7 @@
         getPreviewTemplate: function (t) {
             var self = this,
                 template = isSet(t, self.previewTemplates) ? self.previewTemplates[t] : defaultPreviewTemplates[t];
+            template = template.repl('{previewFileIcon}', self.previewFileIcon);
             if (isEmpty(self.customPreviewTags)) {
                 return template;
             }
@@ -1350,7 +1351,7 @@
             }
             var self = this, cat = self.parseFileType(file), caption = self.slug(file.name), content, strText,
                 types = self.allowedPreviewTypes, mimes = self.allowedPreviewMimeTypes,
-                tmplt = isSet(cat, self.previewTemplates) ? self.previewTemplates[cat] : defaultPreviewTemplates[cat],
+                tmplt = self.getPreviewTemplate(cat),
                 config = isSet(cat, self.previewSettings) ? self.previewSettings[cat] : defaultPreviewSettings[cat],
                 wrapLen = parseInt(self.wrapTextLength, 10), wrapInd = self.wrapIndicator,
                 chkTypes = types.indexOf(cat) >= 0, id, height,
@@ -1771,6 +1772,7 @@
         customPreviewTags: {},
         previewSettings: defaultPreviewSettings,
         fileTypeSettings: defaultFileTypeSettings,
+        previewFileIcon: '<i class="glyphicon glyphicon-file"></i>',
         browseLabel: 'Browse &hellip;',
         browseIcon: '<i class="glyphicon glyphicon-folder-open"></i> &nbsp;',
         browseClass: 'btn btn-primary',

文件差异内容过多而无法显示
+ 0 - 0
js/fileinput.min.js


部分文件因为文件数量过多而无法显示