87,919
社区成员
发帖
与我相关
我的任务
分享
大体上如下:
var editor = function(){
var ajaxRequestUrl = "";
function Fields(id, title) {
this.fields = [];
}
Fields.prototype = {
save : function() { },
redirect : function(result) {},
}
return {
init : function() { this.allowFields = new allowEditFields();}
}
}();
//调用
$(document).ready(function(){
editor.init();
});
var g = function(){
function Test() {
this.age = 24;
}
return {
init:function(){
this.name = "jeechang";
},
test:Test
};
}();
g.init();
alert(g.name);//jeechang
g.test();
alert(g.age);//24
alert(g.Test());//error
希望你能明白~
///////////////////////////////////
//指定 jquery.ui.dialog打开时的位置
///////////////////////////////////
(function($) {
var originOpen = $.ui.dialog.prototype.open
$.ui.dialog.prototype.open = function() {
//var event= window.event || arguments.callee.caller.arguments[0];
//var event = event || window.event;
var event = getEvent();
//alert(event) // ie 和 ff下,都显示 "[object]"
var PosX = 0;
var PosY = 0;
if (event.pageX || event.pageY) {
PosX = event.pageX;
PosY = event.pageY;
}
else {
PosX = event.clientX + document.body.scrollLeft - document.body.clientLeft;
PosY = event.clientY + document.body.scrollTop - document.body.clientTop;
};
this.options.position = [PosX, PosY];
//alert(this.options.position);
originOpen.apply(this, arguments);
};
function getEvent() { //同时兼容ie和ff的写法
if (document.all) return window.event;
func = getEvent.caller;
while (func != null) {
var arg0 = func.arguments[0];
if (arg0) {
if ((arg0.constructor == Event || arg0.constructor == MouseEvent)
|| (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
return arg0;
}
}
func = func.caller;
}
return null;
}
})(jQuery);