Added fileinput-filename support for fileinput.js

This commit is contained in:
Arnold Daniels
2013-10-27 22:14:24 +01:00
parent b6b74880d4
commit 33e7adf94d
6 changed files with 22 additions and 10 deletions

File diff suppressed because one or more lines are too long

View File

@@ -827,18 +827,22 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
var $img = $('<img>').attr('src', re.target.result)
e.target.files[0].result = re.target.result
this.$element.find('.fileinput-filename').text(file)
// if parent has max-height, using `(max-)height: 100%` on child doesn't take padding and border into account
if (preview.css('max-height') != 'none') $img.css('max-height', parseInt(preview.css('max-height'), 10) - parseInt(preview.css('padding-top'), 10) - parseInt(preview.css('padding-bottom'), 10) - parseInt(preview.css('border-top'), 10) - parseInt(preview.css('border-bottom'), 10))
preview.html($img)
element.addClass('fileinput-exists').removeClass('fileinput-new')
this.$element.trigger('change.bs.fileinput', e.target.files)
}
reader.readAsDataURL(file)
} else {
this.$element.find('.fileinput-filename').text(file)
this.$preview.text(file)
this.$element.addClass('fileinput-exists').removeClass('fileinput-new')
this.$element.trigger('change.bs.fileinput')
@@ -919,4 +923,4 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
}
})
}(window.jQuery)
}(window.jQuery);

File diff suppressed because one or more lines are too long

View File

@@ -2821,18 +2821,22 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
var $img = $('<img>').attr('src', re.target.result)
e.target.files[0].result = re.target.result
this.$element.find('.fileinput-filename').text(file)
// if parent has max-height, using `(max-)height: 100%` on child doesn't take padding and border into account
if (preview.css('max-height') != 'none') $img.css('max-height', parseInt(preview.css('max-height'), 10) - parseInt(preview.css('padding-top'), 10) - parseInt(preview.css('padding-bottom'), 10) - parseInt(preview.css('border-top'), 10) - parseInt(preview.css('border-bottom'), 10))
preview.html($img)
element.addClass('fileinput-exists').removeClass('fileinput-new')
this.$element.trigger('change.bs.fileinput', e.target.files)
}
reader.readAsDataURL(file)
} else {
this.$element.find('.fileinput-filename').text(file)
this.$preview.text(file)
this.$element.addClass('fileinput-exists').removeClass('fileinput-new')
this.$element.trigger('change.bs.fileinput')
@@ -2913,4 +2917,4 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
}
})
}(window.jQuery)
}(window.jQuery);

File diff suppressed because one or more lines are too long

View File

@@ -79,18 +79,22 @@
var $img = $('<img>').attr('src', re.target.result)
e.target.files[0].result = re.target.result
this.$element.find('.fileinput-filename').text(file)
// if parent has max-height, using `(max-)height: 100%` on child doesn't take padding and border into account
if (preview.css('max-height') != 'none') $img.css('max-height', parseInt(preview.css('max-height'), 10) - parseInt(preview.css('padding-top'), 10) - parseInt(preview.css('padding-bottom'), 10) - parseInt(preview.css('border-top'), 10) - parseInt(preview.css('border-bottom'), 10))
preview.html($img)
element.addClass('fileinput-exists').removeClass('fileinput-new')
this.$element.trigger('change.bs.fileinput', e.target.files)
}
reader.readAsDataURL(file)
} else {
this.$element.find('.fileinput-filename').text(file)
this.$preview.text(file)
this.$element.addClass('fileinput-exists').removeClass('fileinput-new')
this.$element.trigger('change.bs.fileinput')
@@ -171,4 +175,4 @@
}
})
}(window.jQuery)
}(window.jQuery);