1 Star 0 Fork 219

Ericoder/zui

forked from easysoft/zui 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
jquery.extensions.js 2.68 KB
一键复制 编辑 原始数据 按行查看 历史
/* ========================================================================
* ZUI: jquery.extensions.js
* http://zui.sexy
* ========================================================================
* Copyright (c) 2014 cnezsoft.com; Licensed MIT
* ======================================================================== */
(function($, window, Math)
{
'use strict';
/* Check jquery */
if(typeof($) === 'undefined')
{
throw new Error('ZUI requires jQuery');
}
$.extend(
{
uuid: function()
{
var d = (new Date()).getTime();
while (d < 10000000000000000)
{
d *= 10;
}
return d + Math.floor(Math.random() * 9999);
},
getPropertyCount: function(obj)
{
if (typeof(obj) !== 'object' || obj === null) return 0;
return Object.getOwnPropertyNames(obj).length;
},
callEvent: function(func, event, proxy)
{
if ($.isFunction(func))
{
if (typeof proxy != 'undefined')
{
func = $.proxy(func, proxy);
}
var result = func(event);
if(event) event.result = result;
return !(result !== undefined && (!result));
}
return 1;
},
clientLang: function()
{
var lang;
if (typeof(window.config) != 'undefined' && window.config.clientLang)
{
lang = window.config.clientLang;
}
else
{
var hl = $('html').attr('lang');
lang = hl ? hl : (navigator.userLanguage || navigator.userLanguage || 'zh_cn');
}
return lang.replace('-', '_').toLowerCase();
}
});
$.fn.callEvent = function(name, event, model)
{
var $this = $(this);
var dotIndex = name.indexOf('.zui.');
var shortName = name;
if (dotIndex < 0 && model && model.name)
{
name += '.' + model.name;
}
else
{
shortName = name.substring(0, dotIndex);
}
var e = $.Event(name, event);
// var result = $this.trigger(e);
if ((typeof model === 'undefined') && dotIndex > 0)
{
model = $this.data(name.substring(dotIndex + 1));
}
if (model && model.options)
{
var func = model.options[shortName];
if ($.isFunction(func))
{
$.callEvent(model.options[shortName], e, model);
}
}
return e;
};
}(jQuery, window, Math));
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ericoder/zui.git
git@gitee.com:ericoder/zui.git
ericoder
zui
zui
master

搜索帮助