You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
6.5 KiB
21 lines
6.5 KiB
1 year ago
|
/* ===========================================================
|
||
|
* Bootstrap: fileinput.js v4.0.0
|
||
|
* https://www.jasny.net/bootstrap/
|
||
|
* ===========================================================
|
||
|
* Copyright 2012-2014 Arnold Daniels
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License")
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
* ========================================================== */
|
||
|
|
||
|
!function(u){"use strict";var i="Microsoft Internet Explorer"==window.navigator.appName,n=function(e,t){if(this.$element=u(e),this.options=u.extend({},n.DEFAULTS,t),this.$input=this.$element.find(":file"),0!==this.$input.length){this.name=this.$input.attr("name")||t.name,this.$hidden=this.$element.find('input[type=hidden][name="'+this.name+'"]'),0===this.$hidden.length&&(this.$hidden=u('<input type="hidden">').insertBefore(this.$input)),this.$preview=this.$element.find(".fileinput-preview");var i=this.$preview.css("height");"inline"!==this.$preview.css("display")&&"0px"!==i&&"none"!==i&&this.$preview.css("line-height",i),this.original={exists:this.$element.hasClass("fileinput-exists"),preview:this.$preview.html(),hiddenVal:this.$hidden.val()},this.listen(),this.reset()}};n.DEFAULTS={clearName:!0},n.prototype.listen=function(){this.$input.on("change.bs.fileinput",u.proxy(this.change,this)),u(this.$input[0].form).on("reset.bs.fileinput",u.proxy(this.reset,this)),this.$element.find('[data-trigger="fileinput"]').on("click.bs.fileinput",u.proxy(this.trigger,this)),this.$element.find('[data-dismiss="fileinput"]').on("click.bs.fileinput",u.proxy(this.clear,this))},n.prototype.verifySizes=function(e){if(void 0===this.options.maxSize)return!0;var t=parseFloat(this.options.maxSize);if(t!==this.options.maxSize)return!0;for(var i=0;i<e.length;i++){var n=void 0!==e[i].size?e[i].size:null;if(null!==n&&t<(n=n/1e3/1e3))return!1}return!0},n.prototype.change=function(e){var l=void 0===e.target.files?e.target&&e.target.value?[{name:e.target.value.replace(/^.+\\/,"")}]:[]:e.target.files;if(e.stopPropagation(),0===l.length)return this.clear(),void this.$element.trigger("clear.bs.fileinput");if(!this.verifySizes(l))return this.$element.trigger("max_size.bs.fileinput"),this.clear(),void this.$element.trigger("clear.bs.fileinput");this.$hidden.val(""),this.$hidden.attr("name",""),this.$input.attr("name",this.name);var h=l[0];if(0<this.$preview.length&&(void 0!==h.type?h.type.match(/^image\/(gif|png|jpeg|svg\+xml)$/):h.name.match(/\.(gif|png|jpe?g|svg)$/i))&&"undefined"!=typeof FileReader){var p=this,t=new FileReader,f=this.$preview,o=this.$element;t.onload=function(e){var t=u("<img>");if(t[0].src=e.target.result,l[0].result=e.target.result,o.find(".fileinput-filename").text(h.name),"none"!=f.css("max-height")){var i=parseInt(f.css("max-height"),10)||0,n=parseInt(f.css("padding-top"),10)||0,s=parseInt(f.css("padding-bottom"),10)||0,r=parseInt(f.css("border-top"),10)||0,a=parseInt(f.css("border-bottom"),10)||0;t.css("max-height",i-n-s-r-a)}f.html(t),p.options.exif&&p.setImageTransform(t,h),o.addClass("fileinput-exists").removeClass("fileinput-new"),o.trigger("change.bs.fileinput",l)},t.readAsDataURL(h)}else{var i=h.name,n=this.$element.find(".fileinput-filename");1<l.length&&(i=u.map(l,function(e){return e.name}).join(", ")),n.text(i),this.$preview.text(h.name),this.$element.addClass("fileinput-exists").removeClass("fileinput-new"),this.$element.trigger("change.bs.fileinput")}},n.prototype.setImageTransform=function(n,e){var s=this,r=new FileReader;r.onload=function(e){var t=new DataView(r.result),i=s.getImageExif(t);i&&s.resetOrientation(n,i)},r.readAsArrayBuffer(e)},n.prototype.getImageExif=function(e){if(65496!=e.getUint16(0,!1))return-2;for(var t=e.byteLength,i=2;i<t;){var n=e.getUint16(i,!1);if(i+=2,65505==n){if(1165519206!=e.getUint32(i+=2,!1))return-1;var s=18761==e.getUint16(i+=6,!1);i+=e.getUint32(i+4,s);var r=e.getUint16(i,s);i+=2;for(var a=0;a<r;a++)if(274==e.getUint16(i+12*a,s))return e.getUint16(i+12*a+8,s)}else{if(65280!=(65280&n))break;i+=e.getUint16(i,!1)}}return-1},n.prototype.resetOrientation=function(s,r){var a=new Image;a.onload=function(){var e=a.width,t=a.height,i=document.createElement("canvas"),n=i.getContext("2d");switch(-1<[5,6,7,8].indexOf(r)?(i.width=t,i.height=e):(i.width=e,i.height=t),r){case 2:n.transform(-1,0,0,1,e,0);break;case 3:n.transform(-1,0,0,-1,e,t);break;case 4:n.transform(1,0,0,-1,0,t);break;case 5:n.transform(0,1,1,0,0,0);break;case 6:n.transform(0,1,-1,0,t,0);break;case 7:n.transform(0,-1,-1,0,t,e);bre
|