jQuery file upload cropper的流程
https://tkvw.github.io/jQuery-File-Upload/basic-plus-editor.html
最开始初始化jquery.ui.widget.js中的factory( jQuery );
jquery.fileupload.js中
1. }(function ($) {
2. factory(window.jQuery);
3.$.widget('blueimp.fileupload', {
// The fileupload widget listens for change events on file input fields defined
// via fileInput setting and paste or drop events of the given dropZone.
// In addition to the default jQuery Widget methods, the fileupload widget
// exposes the "add" and "send" methods, to add or directly send files using
// the fileupload API.
// By default, files added via file input selection, paste, drag & drop or
// "add" method are uploaded immediately, but it is possible to override
// the "add" callback option to queue file uploads.
初始化file upload
$.widget('blueimp.fileupload', {
然后是jquery.ui.widget.js
4. $.widget = function( name, base, prototype ) {
var fullName, existingConstructor, constructor, basePrototype,
// proxiedPrototype allows the provided prototype to remain unmodified
// so that it can be used as a mixin for multiple widgets (#8876)
proxiedPrototype = {},
namespace = name.split( "." )[ 0 ];
base._childConstructors.push( constructor );
5.$.widget.bridge( name, constructor ); //这里的name是file upload,constructor对应到79行
6.回到上面的 }(function ($) {
初始化jquery.fileupload-process.js中,也是
factory(
window.jQuery
);
var originalAdd = $.blueimp.fileupload.prototype.options.add;
// The File Upload Processing plugin extends the fileupload widget
// with file processing functionality:
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
在constructor = $[ namespace ][ name ] = function( options, element ) {设置断点
初始化顺序
jquery.fileupload.js
jquery.fileupload-process.js
jquery.fileupload-image.js
jquery.fileupload-image-editor.js
jquery.fileupload-ui.js
然后再是main.js开始触发
https://github.com/tkvw/jQuery-File-Upload/blob/master/js/main.js
程序的入口在main.js中,
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: 'http://localhost:81/jquery-file-upload-server/php/'
});
然后,jquery.ui.widget.js 第79行
$[ namespace ] = $[ namespace ] || {};
existingConstructor = $[ namespace ][ name ];
constructor = $[ namespace ][ name ] = function( options, element ) {
// allow instantiation without "new" keyword
if ( !this._createWidget ) {
return new constructor( options, element );
}
$.widget.bridge = function( name, object ) {
var fullName = object.prototype.widgetFullName || name;
$.fn[ name ] = function( options ) {
然后是jquery.fileupload-ui.js里面的_create方法
jquery.fileupload-process.js里面的_create方法
jquery.fileupload.js里面的_create方法
jquery.fileupload-ui.js里面的_initEventHandlers方法中的this._super();,触发下面的
jquery.fileupload-image-editor.js里面的_initEventHandlers方法
继续执行jquery.fileupload-ui.js中的_initButtonBarEventHandlers方法,此方法在上面的_initEventHandlers里面
this._on(fileUploadButtonBar.find('.start'), {
click: function (e) {
e.preventDefault();
filesList.find('.start').click();
}
});
this._on(fileUploadButtonBar.find('.cancel'), {
click: function (e) {
e.preventDefault();
filesList.find('.cancel').click();
}
});
this._on(fileUploadButtonBar.find('.delete'), {
click: function (e) {
e.preventDefault();
filesList.find('.toggle:checked')
.closest('.template-download')
.find('.delete').click();
fileUploadButtonBar.find('.toggle')
.prop('checked', false);
}
});
this._on(fileUploadButtonBar.find('.toggle'), {
change: function (e) {
filesList.find('.toggle').prop(
'checked',
$(e.currentTarget).is(':checked')
);
}
});
jquery.fileupload-process.js的_create方法,
_create: function () {
this._super();
this._processing = 0;
this._processingQueue = $.Deferred().resolveWith(this)
.promise();
}
jquery.fileupload-ui.js
_create: function () {
this._super();
this._resetFinishedDeferreds();
if (!$.support.fileInput) {
this._disableFileInputButton();
}
},
_resetFinishedDeferreds: function () {
this._finishedUploads = [];
},
发现这些create方法,都是jquery.ui.widget.js中_createWidget方法后面的代码触发
_createWidget: function( options, element ) {
this._create();
this._trigger( "create", null, this._getCreateEventData() );
this._init();
然后是main.js中最后一部分
$.ajax({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: $('#fileupload').fileupload('option', 'url'),
dataType: 'json',
context: $('#fileupload')[0]
}).always(function () {
$(this).removeClass('fileupload-processing');
}).done(function (result) {
$(this).fileupload('option', 'done')
.call(this, $.Event('done'), {result: result});
});
jQuery file upload cropper的流程的更多相关文章
- jQuery file upload cropper的 click .preview事件没有绑定成功
测试 修改https://github.com/tkvw/jQuery-File-Upload/blob/master/basic-plus.html var node = $('<p id=& ...
- jQuery file upload上传图片的流程
先触发_onChange[jquery.fileupload.js] _onChange: function (e) { var that = this, data = { fileInput: $( ...
- 定制jQuery File Upload为微博式单文件上传
日志未经声明,均为AlloVince原创.版权采用『 知识共享署名-非商业性使用 2.5 许可协议』进行许可. jQuery File Upload是一个非常优秀的上传组件,主要使用了XHR作为上传方 ...
- jQuery File Upload 单页面多实例的实现
jQuery File Upload 的 GitHub 地址:https://github.com/blueimp/jQuery-File-Upload 插件描述:jQuery File Upload ...
- jQuery File Upload done函数没有返回
最近在使用jQuery File Upload 上传图片时发现一个问题,发现done函数没有callback,经过一番折腾,找到问题原因,是由于dataType: ‘json’造成的,改为autoUp ...
- 用jQuery File Upload做的上传控件demo,支持同页面多个上传按钮
需求 有这么一个需求,一个form有多个文件要上传,但又不是传统的图片批量上传那种,是类似下图这种需求,一开始是用的swfupload做的上传,但是问题是如果有多个按钮的话,就要写很多重复的代码,于为 ...
- jquery file upload 文件上传插件
1. jquery file upload 下载 jquery file upload Demo 地址:https://blueimp.github.io/jQuery-File-Upload/ jq ...
- jQuery File Upload跨域上传
最近在做一个一手粮互联网项目,方案为前后端分离,自己负责前端框架,采用了Requirejs+avalonjs+jquery三个框架完成. 前后端通过跨域实现接口调用,中间也发现了不少问题,尤其是在富文 ...
- jquery ajax发送delete(use in jquery file upload delete file)
环境: jQuery file upload HTML example code <div class="pic-preview"> <div class=&qu ...
随机推荐
- homebrew学习(四)之取消homebrew自动更新
homebrew自动更新 使用brew install /brew cask install安装软件总是先updating HomeBrew…,速度很慢 取消homebrew自动更新 方法一:使用命令 ...
- npm学习(七)之如何发布包、更新发布包、删除发布包
前言 我们经常使用npm来下载别人的模块或者说包,那么我们如何将自己写的模块上传到npm呢? 了解npm政策 在开始之前,最好回顾一下npm的政策,以防您对站点礼仪.命名.许可或其他指导原则有疑问. ...
- The authenticity of host 'github.com (52.74.223.119)' can't be established.
出现这种错误的问题应考虑是否配置ssh,若没有配置,则进行相关配置 若配置后还出现这种问题,这是由于本地缺少一个文化夹.直接yes而不是y或是回车
- NSUserDefaults的用法
NSUserDefaults适合存储轻量级的本地数据,比如要保存一个登陆界面的数据,用户名.密码之类的,个人觉得使用NSUserDefaults是首选.下次再登陆的时候就可以直接从NSUserDefa ...
- git上传文件夹报错: ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/taminachen/rjxm.git' hint: Updates were rejected because the remote contains work
使用git上传本地文件夹到远程仓库,使用如下命令:git push -u origin master时报错 原因是在GitHub创建仓库时创建了readme文件,但是本地没有这个文件,造成本地目录与远 ...
- [转载]克服FPGA I/O引脚分配挑战--xilinx系列
转载走,放到自己的分类中好了 原文地址:I/O引脚分配挑战--xilinx系列">克服FPGA I/O引脚分配挑战--xilinx系列作者:方槍槍 http://www.eefocus ...
- hive模拟数据
人员表 id,姓名,爱好,住址 1,小明1,lol-book-movie,beijing:mashibing-shanghai:pudong 2,小明2,lol-book-movie,beijing: ...
- Spring配置搭建——Spring学习 day1
对象准备 1.导包 Spring core ,context ,beans ,expression ,aop Apache commons logging 2.写入一个对象 这边写入User对象 3. ...
- 为什么 Android 开发者都应该尝试一下 Anko?
简评: 这里介绍的仅仅是 Anko 中很小的一部分,Kotlin + Anko 真的让 Android 开发简化了不少,用了 Anko 基本就可以告别那些什么 Android 不得不知的代码收集贴了. ...
- 通过lua扩展nginx
1. 安装 准备主要的三个安装包,分别是 nginx-1.15.9.tar.gz LuaJIT-2.0.5.tar.gz lua-nginx-module-0.10.14.tar.gz 相关版本可以去 ...