function FloatHelper() {
} FloatHelper.prototype.showFloater = function (Target, Title, Action, ActionCallback, Callback, IsNeedTemplete) {
this.hideFloater();
var FloaterID = "Float_" + Title;
var Floater = $("#" + FloaterID);
if (Floater.length == 0) {
var newFloater = $("<div>");
newFloater.addClass("Absolute FloatDiv");
newFloater.attr("id", FloaterID);
Floater = newFloater; if (IsNeedTemplete == undefined || IsNeedTemplete == null || IsNeedTemplete) {
var newDiv = $("<div>");
newDiv.addClass("Template_HoverHead");
var newSpan = $("<span>");
newSpan.addClass("title");
newSpan.html(Title);
newDiv.append(newSpan); var newActionDiv = $("<div>");
newActionDiv.addClass("HoverHead_Buttons Right");
var newInput = $("<input>");
newInput.attr({
"type": "button",
"value": Action
}); if (ActionCallback != undefined && ActionCallback != null) {
newActionDiv.on("click", ActionCallback);
newFloater.css("cursor", "pointer").click(ActionCallback);
$("[data-name=" + Title + "]").css("cursor", "pointer").click(function (event) {
event.preventDefault ? event.preventDefault() : event.returnvalue = false;
ActionCallback();
});
} newInput.addClass("Action");
newActionDiv.append(newInput);
newDiv.append(newActionDiv);
newFloater.append(newDiv);
}
$(doc.body).append(newFloater);
} else {
Floater.show();
} var top, left, TargetTop, width; if (Target != null) {
width = Target.width();
TargetTop = Target.offset().top;
top = Math.ceil(TargetTop - Floater.height());
left = Target.offset().left;
Floater.css({
"top": top + "px",
"left": left + "px",
"width": width + "px"
});
this.showOutLine(Title);
if (Callback != undefined && Callback != null) {
Callback();
}
}
}; FloatHelper.prototype.hideFloater = function (Callback) {
var FloatDiv = $(".FloatDiv");
if (FloatDiv.is(":visible")) {
FloatDiv.remove();
this.hideOutline();
if (Callback != undefined && Callback != null) {
Callback();
}
}
}; FloatHelper.prototype.resize = function (Callback) {
var FloatDiv = $(".FloatDiv:visible");
if (FloatDiv.length > 0) {
var name = FloatDiv.attr("id").replace("Float_", "");
var Target = $("[data-name = " + name + "]");
var width, top, left;
if (FloatDiv.is(":visible")) {
top = Target.offset().top;
left = Target.offset().left;
width = Target.width();
if (width < 180) {
width = 180;
}
FloatDiv.css({
"width": width,
"top": top,
"left": left
});
if (Callback != undefined && Callback != null) {
Callback();
}
}
}
}; FloatHelper.prototype.showOutLine = function (name) {
var target = $(".FloatDiv:visible");
var Floater;
if (target.length > 0) {
name = name || target.attr("id").replace("Float_", "");
var editableDiv = $("[data-name =" + name + " ]");
try {
this.hideOutline();
} catch (e) { }
editableDiv.css("outline", "solid 6px #fdc666");
Floater = $("#Float_" + name);
var w = editableDiv.width() + 12 + Math.round(editableDiv.css("padding-left").match(/^[0-9]*/g)[0]) + Math.round(editableDiv.css("padding-right").match(/^[0-9]*/g)[0]);
if (w <= 180) {
w = 180;
editableDiv.css("width", w - 12);
editableDiv.find("ul").addClass("Right Less180");
} else {
editableDiv.find("ul.Right.Less180").removeClass("Right");
}
Floater.css({
"width": w,
"left": editableDiv.offset().left - 6,
"top": Math.ceil(editableDiv.offset().top - Floater.height())
});
if (name == "Background") {
Floater.css("top", editableDiv.offset().top);
}
}
}; FloatHelper.prototype.hideOutline = function () {
_.each($("[data-editable = True]"), function (item) {
if (item) {
$(item).css("outline", "none");
}
});
};

可视化建站这个项目中的Js,除了DialogHelper,其他的都是自己完成的,感觉自己真厉害啊,虽然写的不是那么完善,可能还会有各种bug,但是很高兴,自己终于完成了,赞自己一次。

下班回家喽!

FloatHelper的更多相关文章

随机推荐

  1. oracle Instant Client install

    Installation See the Instant Client Home Page for more information. Installation of ZIP files: 1. Do ...

  2. k8s 部署kube-dns

    [root@k8s-master src]# kubectl create -f kube-dns.yaml service "kube-dns" createdserviceac ...

  3. 【Lintcode】106.Convert Sorted List to Balanced BST

    题目: Given a singly linked list where elements are sorted in ascending order, convert it to a height ...

  4. BZOJ1798:[AHOI2009]维护序列

    浅谈树状数组与线段树:https://www.cnblogs.com/AKMer/p/9946944.html 题目传送门:https://www.lydsy.com/JudgeOnline/prob ...

  5. POJ3259(ford判环)

    Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 39078   Accepted: 14369 Descr ...

  6. HDU4391(线段树+剪枝)

    Paint The Wall Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  7. python set集合的用法

    python的set和其他语言类似, 是一个无序不重复元素集, 基本功能包括关系测试和消除重复元素. 集合对象还支持union(联合), intersection(交), difference(差)和 ...

  8. 创建oracle数据库图示(一步一步教你安装oracle)

    123456 密码 版权声明:本文为博主原创文章,未经博主允许不得转载.

  9. 25.ProfileService实现(调试)

    上一节课拿到的AccessToken和IdToken 实现ProfileService类 在服务端 添加ProfileService类 需要继承IProfileServiuce 用到的画图工具 Ipr ...

  10. POJ 1845-Sumdiv(快速幂取模+整数唯一分解定理+约数和公式+同余模公式)

    Sumdiv Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Statu ...