FloatHelper
- 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的更多相关文章
随机推荐
- ORA-21561: OID generation failed
ORA-21561: OID generation failed 从AIX机器上连Linux上的Oracle数据库时报ORA-21561: OID generation failed错误.不是因为AI ...
- P2463 [SDOI2008]Sandy的卡片[差分+串拼接后缀数组]
P2463 [SDOI2008]Sandy的卡片 套路都差不多,都是差分后二分答案找lcp.只是这题要把多个串拼接起来成为一个大串,中间用某些值域中没有的数字相隔(最好间隔符都不一样想想为什么),排序 ...
- 设置可见GPU方式
只可见第一块GPU os.environ["CUDA_VISIBLE_DEVICES"] = "0"
- BZOJ1018:[SHOI2008]堵塞的交通
浅谈树状数组与线段树:https://www.cnblogs.com/AKMer/p/9946944.html 题目传送门:https://www.lydsy.com/JudgeOnline/prob ...
- bzoj 3714 [PA2014]Kuglarz——思路+最小生成树
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3714 如果用s[ i ]表示前 i 个的奇偶性,那么c(i_j)表示s[ i-1 ]^s[ ...
- linux历史及基本知识
1. Linux的历史: 1973年,Ken Thompson以C语言写出第一个正式版的UNIX内核, 1977年:重要的UNIX分支——BSD(Berkeley Sofeware Distribut ...
- java注解总结(1)
1.什么是注解 注解,主要提供一种机制,这种机制允许程序员在编写代码的同时可以直接编写元数据. 2.介绍 何为注解?--->元数据:描述数据自身的数据. 注解就是代码的元数据,他们包含了代码自身 ...
- openstack 创建镜像生成虚拟机不知道密码如何解决
背景: openstack juno版本,使用glance创建centos7镜像,然后生成虚拟机. 操作步骤: 首先获取镜像http://cloud.centos.org/centos/7/image ...
- Oracle 11g R2安装手册(…
1.Oracle 11g R2安装手册(图文教程)For Windows 1.下载Oracle 11g R2 for Windows版本,下载地址如下官方网站:http://download.orac ...
- LeetCode: 389 Find the Difference(easy)
题目: Given two strings s and t which consist of only lowercase letters. String t is generated by rand ...