x007xyz
x007xyz
  • 发布:2015-11-12 10:47
  • 更新:2015-11-12 15:21
  • 阅读:1778

帮忙看下代码,每行意思都懂,但是不知道他到底是干什么用。

分类:MUI
mui
/**  
 * mui target(action>popover>modal>tab>toggle)  
 */  
(function($, window, document) {  
    /**  
     * targets  
     */  
    $.targets = {};  
    /**  
     * target handles  
     */  
    $.targetHandles = [];  
    /**  
     * register target  
     * @param {type} target  
     * @returns {$.targets}  
     */  
    $.registerTarget = function(target) {  

        target.index = target.index || 1000;  

        $.targetHandles.push(target);  

        $.targetHandles.sort(function(a, b) {  
            return a.index - b.index;  
        });  

        return $.targetHandles;  
    };  
    window.addEventListener('touchstart', function(event) {  
        var target = event.target;  
        var founds = {};  
        for (; target && target !== document; target = target.parentNode) {  
            var isFound = false;  
            $.each($.targetHandles, function(index, targetHandle) {  
                var name = targetHandle.name;  
                if (!isFound && !founds[name] && targetHandle.hasOwnProperty('handle')) {  
                    $.targets[name] = targetHandle.handle(event, target);  
                    if ($.targets[name]) {  
                        founds[name] = true;  
                        if (targetHandle.isContinue !== true) {  
                            isFound = true;  
                        }  
                    }  
                } else {  
                    if (!founds[name]) {  
                        if (targetHandle.isReset !== false)  
                            $.targets[name] = false;  
                    }  
                }  
            });  
            if (isFound) {  
                break;  
            }  
        }  

    });  
})(mui, window, document);  
2015-11-12 10:47 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

这是内部使用的一个查找当前指定控件target。将来会废弃掉。

该问题目前已经被锁定, 无法添加新回复