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. 关于Tensorflow 加载和使用多个模型的方式

    在Tensorflow中,所有操作对象都包装到相应的Session中的,所以想要使用不同的模型就需要将这些模型加载到不同的Session中并在使用的时候申明是哪个Session,从而避免由于Sessi ...

  2. "The object cannot be deleted because it was not found in the ObjectStateManager."

    最近优化EF的性能时遇到一个问题, 当在EF生成的Entityes的构造里加上: this.protocolnodes.MergeOption = MergeOption.NoTracking;thi ...

  3. Http协议-URI和资源

    所有东西都有一个标准化的名字,以帮助人们寻找城市中的各种资源.书籍有ISBN号,公交车有线路号,银行账户有账户编码,人有身份证,街道有街道名称.人们告诉图书馆管理员书籍的ISBN号,他即可找出该书籍的 ...

  4. day1 java基础回顾-Junit单元测试

    Junit单元测试框架的基本使用 一.搭建环境: 导入junit.jar包(junit4) 二.写测试类: 0,一般一个类对应一个测试类. 1,测试类与被测试类最好是放到同一个包中(可以是不同的源文件 ...

  5. WP之样式

    1.定义资源 <Window.Resources> <!--下面用样式--> <Style x:Key="BigFontButtonStyle"> ...

  6. 网站特效离不开脚本,javascript是最常用的脚本语言,我们归纳一下常用的基础函数和语法:

    转载自网络,非原创 1.输出语句:document.write(""); 2.JS中的注释为//3.传统的HTML文档顺序是:document->html->(head ...

  7. 《剑指offer》面试题22—栈的压入、弹出序列

    <程序员面试宝典>上也有经典的火车进站问题,类似. 如果12345是压栈顺序,序列45321可能是出栈顺序,但序列43512不可能. 规律:对序列中任意元素n,排在n后且比n小的元素一定是 ...

  8. 交叉编译调试qemu_guest_agent

    Winodws版本 编译环境Fedora23 下载VSS SDK的setup.exe 下载地址 提取VSS SDK头文件 将下面的代码保存成extract-vsssdk-headers.sh脚本,然后 ...

  9. 洛谷P2867 [USACO06NOV]大广场Big Square

    P2867 [USACO06NOV]大广场Big Square 题目描述 Farmer John's cows have entered into a competition with Farmer ...

  10. [Xcode 实际操作]六、媒体与动画-(5)使用CoreImage框架给图片添加马赛克效果

    目录:[Swift]Xcode实际操作 本文将演示如何使用CoreImage图像处理框架,给图片添加像素化的滤镜效果. 在项目导航区,打开视图控制器的代码文件[ViewController.swift ...