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的流程的更多相关文章

  1. jQuery file upload cropper的 click .preview事件没有绑定成功

    测试 修改https://github.com/tkvw/jQuery-File-Upload/blob/master/basic-plus.html var node = $('<p id=& ...

  2. jQuery file upload上传图片的流程

    先触发_onChange[jquery.fileupload.js] _onChange: function (e) { var that = this, data = { fileInput: $( ...

  3. 定制jQuery File Upload为微博式单文件上传

    日志未经声明,均为AlloVince原创.版权采用『 知识共享署名-非商业性使用 2.5 许可协议』进行许可. jQuery File Upload是一个非常优秀的上传组件,主要使用了XHR作为上传方 ...

  4. jQuery File Upload 单页面多实例的实现

    jQuery File Upload 的 GitHub 地址:https://github.com/blueimp/jQuery-File-Upload 插件描述:jQuery File Upload ...

  5. jQuery File Upload done函数没有返回

    最近在使用jQuery File Upload 上传图片时发现一个问题,发现done函数没有callback,经过一番折腾,找到问题原因,是由于dataType: ‘json’造成的,改为autoUp ...

  6. 用jQuery File Upload做的上传控件demo,支持同页面多个上传按钮

    需求 有这么一个需求,一个form有多个文件要上传,但又不是传统的图片批量上传那种,是类似下图这种需求,一开始是用的swfupload做的上传,但是问题是如果有多个按钮的话,就要写很多重复的代码,于为 ...

  7. jquery file upload 文件上传插件

    1. jquery file upload 下载 jquery file upload Demo 地址:https://blueimp.github.io/jQuery-File-Upload/ jq ...

  8. jQuery File Upload跨域上传

    最近在做一个一手粮互联网项目,方案为前后端分离,自己负责前端框架,采用了Requirejs+avalonjs+jquery三个框架完成. 前后端通过跨域实现接口调用,中间也发现了不少问题,尤其是在富文 ...

  9. jquery ajax发送delete(use in jquery file upload delete file)

    环境: jQuery file upload HTML example code <div class="pic-preview"> <div class=&qu ...

随机推荐

  1. 详解vue全局组件与局部组件使用方法

    这篇文章主要为大家详细介绍了vue全局组件与局部组件的使用方法,具有一定的参考价值,对此有需要的朋友可以参考学习下.如有不足之处,欢迎批评指正. vue全局/局部注册,以及一些混淆的组件main.js ...

  2. CS起源:实现狙击子弹加速

    在前面的课程 FPS 游戏实现方框透视 中我们实现了对CS中游戏人物的透视效果,今天我们就来研究下狙击枪如何变成机关枪!原理很简单,直接去掉枪的上膛动画,配合无线子弹就完事了,这里只提供一种分析思路. ...

  3. css3弹性伸缩布局(一)—————flex布局

    CSS3弹性伸缩布局简介 2009年,W3C提出了一种崭新的方案—-Flex布局(即弹性伸缩布局),它可以简便.完整.响应式地实现各种页面布局,包括一直让人很头疼的垂直水平居中也变得很简单地就迎刃而解 ...

  4. Linux日常操作整理

    1. Linux下建立ssh互信 需要在两台机器上保证安装ssh步骤:cd ~/.sshssh-keygen(每台机器执行此操作)ssh root@192.168.2.100 cat ~/.ssh/i ...

  5. 生产服务器上安装Python

    2018-05-17 生产环境的服务器(以下简称内网服务器)由于安全限制,可能无法连接外网.这种情况下将无法直接使用pip命令安装python的包 一.更改pip源 - 默认pip是使用Python官 ...

  6. 别再误解MySQL和「幻读」了

    The so-called phantom problem occurs within a transaction when the same query produces different set ...

  7. 用java写一个死锁

    什么是死锁? 多个线程同时被阻塞,它们中的一个或者全部都在等待某个资源被释放.由于线程被无限期地阻塞,因此程序不可能正常终止. 不适当的使用“synchronized”关键词来管理线程对特定对象的访问 ...

  8. mysql笔记——索引

    什么是索引? 数据库中的一个对象. 在数据库中用来加速表的查询. 通过使用快速路径访问方法定位数据,减少了磁盘的i/o. 与表分别独立存放,但不能独立存在,必须属于某个表. 由数据库自动维护,表被删除 ...

  9. hive中对子查询如in,exists等支持

    案例情况:同事使用公司数据探查跑一段代码,部分代码如下,报错,显示不支持in内的子查询.但是直接用虚拟机去跑的话代码没有任何报错,也出结果,很奇怪. SELECT t1.SIGN_CODE AS bu ...

  10. JAVA笔记19-容器之三 Set接口、List接口、Collections类、Comparable接口(重要)

    一.Set接口 //HashSet综合举例 import java.util.*; public class Test{ public static void main(String[] args){ ...