jquery.fileupload-image-editor.js

 

jquery.fileupload-image-editor.js中

  _initEventHandlers: function () {
            this._super();

            var handlers = {};
            handlers[this.options.uploadImageEditorPreviewSelector] = this._previewHandler.bind(this);

            this._on(this.options.filesContainer, handlers);
        },

 

jquery.ui.widget.js

    _on: function( suppressDisabledCheck, element, handlers ) {
        var delegateElement,
            instance = this;

        // no suppressDisabledCheck flag, shuffle arguments
        if ( typeof suppressDisabledCheck !== "boolean" ) {
            handlers = element;
            element = suppressDisabledCheck;
            suppressDisabledCheck = false;
        }

        // no element argument, shuffle and use this.element
        if ( !handlers ) {
            handlers = element;
            element = this.element;
            delegateElement = this.widget();
        } else {
            element = delegateElement = $( element );
            this.bindings = this.bindings.add( element );
        }

 

遇到错误  

是因为找不到

uploadTemplateId: 'template-upload',

Uncaught TypeError: Cannot read property 'innerHTML' of null
at Function.tmpl.load (tmpl.js:38)

tmpl.load = function (id) {
return document.getElementById(id).innerHTML
}


at tmpl (tmpl.js:21)

var tmpl = function (str, data) {
var f = !/[^\w\-.:]/.test(str)
? (tmpl.cache[str] = tmpl.cache[str] || tmpl(tmpl.load(str)))
: new Function( // eslint-disable-line no-new-func
tmpl.arg + ',tmpl',
'var _e=tmpl.encode' +
tmpl.helper +
",_s='" +
str.replace(tmpl.regexp, tmpl.func) +
"';return _s;"
)
return data
? f(data, tmpl)
: function (data) {
return f(data, tmpl)
}
}


at $.<computed>.<computed>._initTemplates (jquery.fileupload-ui.js:657)

_initTemplates: function () {
var options = this.options;
options.templatesContainer = this.document[0].createElement(
options.filesContainer.prop('nodeName')
);
if (tmpl) {
if (options.uploadTemplateId) {
options.uploadTemplate = tmpl(options.uploadTemplateId);
}
if (options.downloadTemplateId) {
options.downloadTemplate = tmpl(options.downloadTemplateId);
}
}
}


at $.<computed>.<computed>._initTemplates (jquery.ui.widget.js:127)
at $.<computed>.<computed>._initSpecialOptions (jquery.fileupload-ui.js:677)

_initSpecialOptions: function () {
this._super();
this._initFilesContainer();
this._initTemplates();
},


at $.<computed>.<computed>._initSpecialOptions (jquery.ui.widget.js:127)
at $.<computed>.<computed>._create (jquery.fileupload.js:1381)

_create: function () {
this._initDataAttributes();
this._initSpecialOptions();
this._slots = [];
this._sequence = this._getXHRPromise(true);
this._sending = this._active = 0;
this._initProgressObject(this);
this._initEventHandlers();
},


at $.<computed>.<computed>._create (jquery.ui.widget.js:127)
at $.<computed>.<computed>._super (jquery.ui.widget.js:114)
at $.<computed>.<computed>._create (jquery.fileupload-process.js:167)

_create: function () {
this._super();
this._processing = 0;
this._processingQueue = $.Deferred().resolveWith(this)
.promise();
}

 

 

 

 

扩展阅读

https://api.jqueryui.com/jQuery.widget/#method-_on

_on( [suppressDisabledCheck ] [, element ], handlers )Returns: jQuery (plugin only)

Binds event handlers to the specified element(s). Delegation is supported via selectors inside the event names, e.g., " click .foo". The _on() method provides several benefits of direct event binding:
  • Maintains proper this context inside the handlers.
  • Automatically handles disabled widgets: If the widget is disabled or the event occurs on an element with the ui-state-disabled class, the event handler is not invoked. Can be overridden with the suppressDisabledCheck parameter.
  • Event handlers are automatically namespaced and cleaned up on destroy.
  • suppressDisabledCheck (default: false)
    Type: Boolean
    Whether or not to bypass the disabled check.
  • element
    Type: jQuery
    Which element(s) to bind the event handlers to. If no element is provided, this.element is used for non-delegated events and the widget element is used for delegated events.
  • handlers
    Type: Object
    An object in which the keys represent the event type and optional selector for delegation, and the values represent a handler function to be called for the event.
Code examples:

Prevent the default action of all links clicked within the widget's element.

this._on( this.element, {
  "click a": function( event ) {
    event.preventDefault();
  }
});

 

 

https://www.runoob.com/jquery/traversing-closest.html

定义和用法

closest() 方法返回被选元素的第一个祖先元素。

祖先是父、祖父、曾祖父,依此类推。

DOM 树:该方法从当前元素向上遍历,直至文档根元素的所有路径(<html>),来查找 DOM 元素的第一个祖先元素。

该方法与 parents() 类似,都是向上遍历 DOM 树,不同点是:

closest()

  • 从当前元素开始
  • 沿 DOM 树向上遍历,并返回匹配所传递的表达式的第一个单一祖先
  • 返回包含零个或一个元素的 jQuery 对象

parents()

  • 从父元素开始
  • 沿 DOM 树向上遍历,并返回匹配所传递的表达式的所有祖先
  • 返回包含零个、一个或多个元素的 jQuery 对象

 

转载于:https://www.cnblogs.com/chucklu/p/11102490.html

Pixie Image Editor 在线图片编辑器 中文版 功能 集成 - 轻松将pixie集成到任何现有项目或应用程序中。 可扩展 - Pixie接口和API可以使用新功能进行扩展。 移动 - Pixie拥有完整的移动支持,并可自动调整其界面以适应任何设备的大小。 可自定义的UI - 通过显示,隐藏或添加新菜单项,更改工具栏位置或使用不同的主题来自定义UI。 可翻译 - Pixie的界面可通过配置完全翻译。 水印 - 保存的照片可以使用指定的文本轻松加水印。 模式 - 在叠加(模态),内联或全屏模式之间进行选择。 工具API - 通过API使用所有精灵工具(调整大小,裁剪,框架等),而无需打开精灵界面。 可自定义的工具 - 所有工具都可完全自定义,您可以删除或修改和添加自定义贴纸,形状,字体,框架等。 状态 - 以json格式保存当前编辑器状态,允许使用预构建模板等功能。 照片处理 - 通过界面或API调整大小,裁剪,转换等。 滤镜 - Pixie配有许多内置滤镜,如灰度,模糊,黑白,复古等。可以通过API添加更多过滤器.. 框架 - 为任何大小的照片添加内置响应帧或添加自己的帧。 裁剪 - 将照片裁剪为指定宽高比之一,或让用户通过UI选择自定义裁剪区域。 绘图 - 功能强大的免费绘图工具支持鼠标和触摸,具有多种画笔类型,颜色等。 文本 - 完全支持向图像添加文本。可以使用数百种谷歌字体或仅使用自定义添加的字体。 形状 - 只需指定svg图像路径,即可轻松添加自定义形状。 贴纸 - 可以添加或删除自定义贴纸。任何类型的图像都可以用作贴纸。 角落 - 只需单击一下或API调用即可对图像角进行四舍五入。 空画布 - Pixie不必编辑现有照片,也可以从头开始轻松创建自定义图像。 历史记录 - 所有编辑器操作都是非破坏性的,可以通过历史记录工具轻松撤消和重做。 对象 - 所有对象(如贴纸,形状和文本)都在自己的图层上,可以通过更改颜色,添加阴影,背景等来轻松移动,调整大小,删除和修改。 图案和渐变 - 所有对象都可以使用许多内置或自定义图案和渐变填充。 保存 - 修改后的图像可以通过API或接口轻松保存在本地设备或服务器上。 缩放和平移 - 可以使用鼠标,鼠标滚轮或移动设备上的触摸和捏合手势来缩放和平移画布。 HTML5 - Pixie使用原生HTML5,这意味着它可以在每个设备上运行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值