blog/themes/typing/source/js/cloudinary-jquery-file-uplo...

4 lines
71 KiB
JavaScript
Raw Normal View History

2018-10-01 02:24:11 +00:00
var slice=[].slice,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;!function(root,factory){var name,ref,results,value;if("function"==typeof define&&define.amd)return define(["jquery"],factory);if("object"==typeof exports)return module.exports=factory(require("jquery"));root.cloudinary||(root.cloudinary={}),ref=factory(jQuery),results=[];for(name in ref)value=ref[name],results.push(root.cloudinary[name]=value)}(this,function(jQuery){var ArrayParam,BaseUtil,ClientHintsMetaTag,Cloudinary,CloudinaryJQuery,Condition,Configuration,Expression,ExpressionParam,FetchLayer,HtmlTag,ImageTag,Layer,LayerParam,Param,RangeParam,RawParam,SubtitlesLayer,TextLayer,Transformation,TransformationBase,TransformationParam,Util,VideoTag,addClass,allStrings,base64Encode,base64EncodeURL,camelCase,cloneDeep,cloudinary,compact,contains,convertKeys,crc32,defaults,difference,funcTag,functions,getAttribute,getData,hasClass,identity,isEmpty,isFunction,isNumberLike,isObject,isString,m,merge,objToString,objectProto,parameters,reWords,removeAttribute,setAttribute,setAttributes,setData,smartEscape,snakeCase,utf8_encode,webp,width,withCamelCaseKeys,withSnakeCaseKeys,without;return allStrings=function(list){var item,j,len;for(j=0,len=list.length;j<len;j++)if(item=list[j],!Util.isString(item))return!1;return!0},without=function(array,item){var i,length,newArray;for(newArray=[],i=-1,length=array.length;++i<length;)array[i]!==item&&newArray.push(array[i]);return newArray},isNumberLike=function(value){return null!=value&&!isNaN(parseFloat(value))},smartEscape=function(string,unsafe){return null==unsafe&&(unsafe=/([^a-zA-Z0-9_.\-\/:]+)/g),string.replace(unsafe,function(match){return match.split("").map(function(c){return"%"+c.charCodeAt(0).toString(16).toUpperCase()}).join("")})},defaults=function(){var destination,sources;return destination=arguments[0],sources=2<=arguments.length?slice.call(arguments,1):[],sources.reduce(function(dest,source){var key,value;for(key in source)value=source[key],void 0===dest[key]&&(dest[key]=value);return dest},destination)},objectProto=Object.prototype,objToString=objectProto.toString,isObject=function(value){var type;return type=typeof value,!!value&&("object"===type||"function"===type)},funcTag="[object Function]",isFunction=function(value){return isObject(value)&&objToString.call(value)===funcTag},reWords=function(){var lower,upper;return upper="[A-Z]",lower="[a-z]+",RegExp(upper+"+(?="+upper+lower+")|"+upper+"?"+lower+"|"+upper+"+|[0-9]+","g")}(),camelCase=function(source){var i,word,words;return words=source.match(reWords),words=function(){var j,len,results;for(results=[],i=j=0,len=words.length;j<len;i=++j)word=words[i],word=word.toLocaleLowerCase(),i?results.push(word.charAt(0).toLocaleUpperCase()+word.slice(1)):results.push(word);return results}(),words.join("")},snakeCase=function(source){var i,word,words;return words=source.match(reWords),words=function(){var j,len,results;for(results=[],i=j=0,len=words.length;j<len;i=++j)word=words[i],results.push(word.toLocaleLowerCase());return results}(),words.join("_")},convertKeys=function(source,converter){var key,result,value;null==converter&&(converter=Util.identity),result={};for(key in source)value=source[key],key=converter(key),Util.isEmpty(key)||(result[key]=value);return result},withCamelCaseKeys=function(source){return convertKeys(source,Util.camelCase)},withSnakeCaseKeys=function(source){return convertKeys(source,Util.snakeCase)},base64Encode="undefined"!=typeof btoa&&isFunction(btoa)?btoa:"undefined"!=typeof Buffer&&isFunction(Buffer)?function(input){return input instanceof Buffer||(input=new Buffer.from(String(input),"binary")),input.toString("base64")}:function(input){throw new Error("No base64 encoding function found")},base64EncodeURL=function(input){try{input=decodeURI(input)}catch(error1){error1}return input=encodeURI(input),base64Encode(input)}
;return names=Object.getOwnPropertyNames(trans),0!==names.length&&(tr=new this.constructor(this.toOptions(!1)),this.resetTransformations(),this.chained.push(tr)),this}),this.resetTransformations||(this.resetTransformations=function(){return trans={},this}),this.otherOptions||(this.otherOptions={}),this.chained=[],Util.isEmpty(options)||this.fromOptions(options)}var VAR_NAME_RE,lastArgCallback,processVar;return VAR_NAME_RE=/^\$[a-zA-Z0-9]+$/,TransformationBase.prototype.trans_separator="/",TransformationBase.prototype.param_separator=",",lastArgCallback=function(args){var callback;return callback=null!=args?args[args.length-1]:void 0,Util.isFunction(callback)?callback:void 0},TransformationBase.prototype.fromOptions=function(options){var key,opt;if(options instanceof TransformationBase)this.fromTransformation(options);else{options||(options={}),(Util.isString(options)||Util.isArray(options))&&(options={transformation:options}),options=Util.cloneDeep(options,function(value){if(value instanceof TransformationBase)return new value.constructor(value.toOptions())}),options.if&&(this.set("if",options.if),delete options.if);for(key in options)opt=options[key],key.match(VAR_NAME_RE)?"$attr"!==key&&this.set("variable",key,opt):this.set(key,opt)}return this},TransformationBase.prototype.fromTransformation=function(other){var j,key,len,ref;if(other instanceof TransformationBase)for(ref=other.keys(),j=0,len=ref.length;j<len;j++)key=ref[j],this.set(key,other.get(key).origValue);return this},TransformationBase.prototype.set=function(){var camelKey,key,values;return key=arguments[0],values=2<=arguments.length?slice.call(arguments,1):[],camelKey=Util.camelCase(key),Util.contains(Transformation.methods,camelKey)?this[camelKey].apply(this,values):this.otherOptions[key]=values[0],this},TransformationBase.prototype.hasLayer=function(){return this.getValue("overlay")||this.getValue("underlay")},TransformationBase.prototype.serialize=function(){var ifParam,j,len,paramList,ref,ref1,ref2,ref3,ref4,resultArray,t,tr,transformationList,transformationString,transformations,value,variables,vars;for(resultArray=function(){var j,len,ref,results;for(ref=this.chained,results=[],j=0,len=ref.length;j<len;j++)tr=ref[j],results.push(tr.serialize());return results}.call(this),paramList=this.keys(),transformations=null!=(ref=this.get("transformation"))?ref.serialize():void 0,ifParam=null!=(ref1=this.get("if"))?ref1.serialize():void 0,variables=processVar(null!=(ref2=this.get("variables"))?ref2.value():void 0),paramList=Util.difference(paramList,["transformation","if","variables"]),vars=[],transformationList=[],j=0,len=paramList.length;j<len;j++)t=paramList[j],t.match(VAR_NAME_RE)?vars.push(t+"_"+Expression.normalize(null!=(ref3=this.get(t))?ref3.value():void 0)):transformationList.push(null!=(ref4=this.get(t))?ref4.serialize():void 0);switch(!1){case!Util.isString(transformations):transformationList.push(transformations);break;case!Util.isArray(transformations):resultArray=resultArray.concat(transformations)}return transformationList=function(){var l,len1,results;for(results=[],l=0,len1=transformationList.length;l<len1;l++)value=transformationList[l],(Util.isArray(value)&&!Util.isEmpty(value)||!Util.isArray(value)&&value)&&results.push(value);return results}(),transformationList=vars.sort().concat(variables).concat(transformationList.sort()),"if_end"===ifParam?transformationList.push(ifParam):Util.isEmpty(ifParam)||transformationList.unshift(ifParam),transformationString=Util.compact(transformationList).join(this.param_separator),Util.isEmpty(transformationString)||resultArray.push(transformationString),Util.compact(resultArray).join(this.trans_separator)},TransformationBase.prototype.listNames=function(){return Transformation.methods},TransformationBase.prototype.toHtmlAttributes=function(){var attrName,height,j,key,len,options,ref,ref1,ref2,ref3,value;options={},ref=this.otherOptions;for(key in ref)value=ref[key],Util.contains(Transformation.PARAM_NAMES,Util.snakeCase(key))||(attrName=/^html_/.test(key)?key.slice(5):key,options[attrName]=value);for(ref1=thi
dataSrc=dataSrc.replace(/w_auto[^,\/]*/g,"w_"+requiredWidth)}Util.removeAttribute(tag,"width"),options.responsive_preserve_height||Util.removeAttribute(tag,"height")}else setUrl=!1;setUrl&&Util.setAttribute(tag,"src",dataSrc)}return this},Cloudinary.prototype.transformation=function(options){return Transformation.new(this.config()).fromOptions(options).setParent(this)},Cloudinary}(),CloudinaryJQuery=function(superClass){function CloudinaryJQuery(options){CloudinaryJQuery.__super__.constructor.call(this,options)}return extend(CloudinaryJQuery,superClass),CloudinaryJQuery.prototype.image=function(publicId,options){var client_hints,img,ref,ref1;return null==options&&(options={}),img=this.imageTag(publicId,options),client_hints=null!=(ref=null!=(ref1=options.client_hints)?ref1:this.config("client_hints"))&&ref,null!=options.src||client_hints||img.setAttr("src",""),img=jQuery(img.toHtml()),client_hints||img.data("src-cache",this.url(publicId,options)).cloudinary_update(options),img},CloudinaryJQuery.prototype.responsive=function(options){var ref,ref1,ref2,responsiveClass,responsiveConfig,responsiveResizeInitialized,timeout;if(responsiveConfig=jQuery.extend(responsiveConfig||{},options),responsiveClass=null!=(ref=this.responsiveConfig.responsive_class)?ref:this.config("responsive_class"),jQuery("img."+responsiveClass+", img.cld-hidpi").cloudinary_update(responsiveConfig),(null==(ref1=null!=(ref2=responsiveConfig.responsive_resize)?ref2:this.config("responsive_resize"))||ref1)&&!responsiveResizeInitialized)return responsiveConfig.resizing=responsiveResizeInitialized=!0,timeout=null,jQuery(window).on("resize",function(_this){return function(){var debounce,ref3,ref4,reset,run,wait;return debounce=null!=(ref3=null!=(ref4=responsiveConfig.responsive_debounce)?ref4:_this.config("responsive_debounce"))?ref3:100,reset=function(){if(timeout)return clearTimeout(timeout),timeout=null},run=function(){return jQuery("img."+responsiveClass).cloudinary_update(responsiveConfig)},wait=function(){return reset(),setTimeout(function(){return reset(),run()},debounce)},debounce?wait():run()}}(this))},CloudinaryJQuery}(Cloudinary),jQuery.fn.cloudinary=function(options){return this.filter("img").each(function(){var img_options,public_id,url;return img_options=jQuery.extend({width:jQuery(this).attr("width"),height:jQuery(this).attr("height"),src:jQuery(this).attr("src")},jQuery(this).data(),options),public_id=img_options.source||img_options.src,delete img_options.source,delete img_options.src,url=jQuery.cloudinary.url(public_id,img_options),img_options=new Transformation(img_options).toHtmlAttributes(),jQuery(this).data("src-cache",url).attr({width:img_options.width,height:img_options.height})}).cloudinary_update(options),this},jQuery.fn.cloudinary_update=function(options){return null==options&&(options={}),jQuery.cloudinary.cloudinary_update(this.filter("img").toArray(),options),this},webp=null,jQuery.fn.webpify=function(options,webp_options){var that,webp_canary;return null==options&&(options={}),that=this,webp_options=null!=webp_options?webp_options:options,webp||(webp=jQuery.Deferred(),webp_canary=new Image,webp_canary.onerror=webp.reject,webp_canary.onload=webp.resolve,webp_canary.src="data:image/webp;base64,UklGRi4AAABXRUJQVlA4TCEAAAAvAUAAEB8wAiMwAgSSNtse/cXjxyCCmrYNWPwmHRH9jwMA"),jQuery(function(){return webp.done(function(){return jQuery(that).cloudinary(jQuery.extend({},webp_options,{format:"webp"}))}).fail(function(){return jQuery(that).cloudinary(options)})}),this},jQuery.fn.fetchify=function(options){return this.cloudinary(jQuery.extend(options,{type:"fetch"}))},jQuery.cloudinary=new CloudinaryJQuery,jQuery.cloudinary.fromDocument(),CloudinaryJQuery.prototype.delete_by_token=function(delete_token,options){var cloud_name,dataType,url;return options=options||{},url=options.url,url||(cloud_name=options.cloud_name||jQuery.cloudinary.config().cloud_name,url="https://api.cloudinary.com/v1_1/"+cloud_name+"/delete_by_token"),dataType=jQuery.support.xhrFileUpload?"json":"iframe json",jQuery.ajax({url:url,method:"POST",data:{token:delete_token},head
//# sourceMappingURL=cloudinary-jquery-file-upload.min.js.map