123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
-
- Namespace.register("U.UF.UI")
- U.UF.UI.form = function (title, content, formattr, formfun, headattr, contentattr, headbottomattr, parentel) {
- var _this = this;
-
- if (formattr && U.UF.UI.form.allForm[formattr.id]) {
- var _this = U.UF.UI.form.allForm[formattr.id];
- }
-
- else {
-
- this.id = formattr && formattr.id ? formattr.id : Guid.newGuid();
-
- U.UF.UI.form.allForm[this.id] = this;
- }
- _this.form;
- _this.header;
- _this.middle;
- _this.title = title;
- _this.content = content;
- _this.formattr = formattr;
- _this.headattr = headattr;
- _this.contentattr = contentattr;
- _this.headbottomattr = headbottomattr;
-
-
- if (formfun == null) {
- formfun = {};
- }
- _this.istop = null;
- if (formfun.istop != null) {
- _this.istop = formfun.istop;
- }
- _this.isdrag = true;
- if (formfun.isdrag != null) {
- _this.isdrag = formfun.isdrag;
- }
- _this.isstretching = true;
- if (formfun.isstretching != null) {
- _this.isstretching = formfun.isstretching;
- }
- _this.isenlarge = true;
- if (formfun.isenlarge != null) {
- _this.isenlarge = formfun.isenlarge;
- }
- _this.isnarrow = true;
- if (formfun.isnarrow != null) {
- _this.isnarrow = formfun.isnarrow;
- }
- _this.isclose = true;
- _this.closecallback = formfun.closecallback;
- if (formfun.isclose != null) {
- _this.isclose = formfun.isclose;
- }
- _this.parentel = parentel || document.body;
- _this.create();
- return _this;
- }
- U.UF.UI.form.allForm = {};
- U.UF.UI.form.prototype = {
-
- create: function () {
- var i,
- _resizefun,
- _formel,
- _headel,
- _contentel,
- _contentchildel,
- _stretchingel,
- _stretchinginfo,
- _headbottom,
- _enlargeel,
- _mousedown,
- _formattr = this.formattr || {},
- _headattr = this.headattr || {},
- _contentattr = this.contentattr || {},
- _replaceel = U.UF.UI.form.allForm[_formattr.id] ? U.UF.UI.form.allForm[_formattr.id].form : null
- ;
-
- if (_formattr.style) {
- _formattr.style.cssText = _formattr.style.cssText || "";
- _formattr.style.cssText = "width: 70%; position: fixed; border: 1px solid #444; background-color: #fff; z-index: 10; border-radius: 1px; overflow: hidden; -moz-box-shadow:0 0 30px 5px #555; -webkit-box-shadow:0 0 30px 5px #555; box-shadow:0 0 30px 5px #555; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius:5px;" + _formattr.style.cssText;
- } else {
- _formattr.style = {
- cssText: "width: 70%; position: fixed; border: 1px solid #444; background-color: #fff; z-index: 10; border-radius: 1px; overflow: hidden; -moz-box-shadow:0 0 30px 5px #555; -webkit-box-shadow:0 0 30px 5px #555; box-shadow:0 0 30px 5px #555; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius:5px;"
- };
- }
- _formattr.close = U.UF.C.apply(this, function () {
- U.UF.F.closeWindow(this.form);
- });
- _formattr.usform = "true";
- _formattr.id = _formattr.id || "";
- _formattr.style = _formattr.style || {};
- if (_formattr.onresize) {
- _resizefun = _formattr.onresize;
- _mousedown = _formattr.onmousedown;
- _formattr.onresize = U.UF.C.apply(this, function () {
- this.size();
- if (_resizefun) {
- _resizefun();
- }
- });
- _formattr.onmousedown = U.UF.C.apply(this, function () {
-
- if (this.istop !== false) {
- this.top();
- }
- if (_mousedown) {
- _mousedown();
- }
- });
- } else if (_formattr.onresize !== false) {
- _formattr.onresize = U.UF.C.apply(this, function () {
- this.size();
- });
- }
-
- var _formel = $$("div", this.formattr);
-
- if (this.istop === true) {
- _formel.style.zIndex = "9999";
- _formel["__top__"] = "false";
- } else if (this.istop === false) {
- _formel["__top__"] = "false";
- }
- this.form = _formel;
-
- if (this.title !== false) {
-
- if (_headattr.style) {
- _headattr.style.cssText = _headattr.style.cssText || "";
- _headattr.style.cssText = "text-indent: 10px; color: White; line-height: inherit; font-size: 14px; height: 30px; line-height: 30px; background-color: #2967A7; overflow: hidden; color: White; font-size: 14px; overflow: hidden; " + _headattr.style.cssText;
- } else {
- _headattr.style = {
- cssText: "text-indent: 10px; color: White; line-height: inherit; font-size: 14px; height: 30px; line-height: 30px; background-color: #2967A7; overflow: hidden; color: White; font-size: 14px; overflow: hidden; "
- }
- }
-
- if (this.isdrag) {
- _headattr.onmousedown = function () {
- U.UF.F.drag(_formel);
- };
- }
-
- _headel = $$("div", _headattr, _formel);
-
- if (U.UF.C.isString(this.title)) {
- _headel.innerHTML = this.title;
- }
-
- else if (U.UF.C.isElement(this.title)) {
- _headel.appendChild(this.title);
- }
- this.header = _headel;
- }
-
- _contentel = $$("div", { "style": { "cssText": "width: 100%; height:100%; position: relative;" } }, _formel);
-
- _contentattr.usbody = "true";
-
- if (_contentattr.style) {
- _contentattr.style.cssText = _contentattr.style.cssText || "";
-
- _contentattr.style.cssText = "text-align: left; overflow: hidden;" + _contentattr.style.cssText;
- } else {
- _contentattr.style = {
- cssText: "text-align: left; overflow: auto;"
- };
- }
-
- _contentchildel = $$("div", _contentattr, _contentel);
-
- if (U.UF.C.isString(this.content)) {
- _contentchildel.innerHTML = this.content;
- }
-
- else if (U.UF.C.isElement(this.content)) {
- _contentchildel.appendChild(this.content);
- }
- this.middle = _contentchildel;
-
- if (this.title === false && this.isdrag) {
- _contentel.onmousedown = function () {
- U.UF.F.drag(_formel);
- };
- }
-
- if (this.isstretching !== false) {
-
- _stretchingel = $$("div", { style: { "cssText": "display: block;" } }, _formel);
-
- _stretchinginfo = {
- "top": "cursor: n-resize; left: 0px; top: 0px; width: 100%; height: 5px;",
- "rightTop": "cursor: ne-resize; right: -2px; top: -2px; width: 12px; height: 12px;",
- "leftTop": "cursor: nw-resize; top: 0px; left: 0px; width: 12px; height: 12px;",
- "left": "cursor: w-resize; left: 0px; top: 0px; width: 5px; height: 100%;",
- "right": "cursor: e-resize; right: 0px; top: 0px; width: 5px; height: 100%;",
- "bottom": "cursor: s-resize; left: 0px; bottom: 0px; width: 100%; height: 5px;",
- "leftBottom": "cursor: sw-resize; left: -2px; bottom: -2px; width: 12px; height: 12px;",
- "rightBottom": "cursor: se-resize; right: -2px; bottom: -2px; width: 12px; height: 12px;"
- }
-
- for (i in _stretchinginfo) {
- $$("div", {
- "style": {
- "cssText": "position: absolute; overflow: hidden; display: block; z-index: 10;" + _stretchinginfo[i]
- },
- "onmousedown": U.UF.C.closure(function (scope, typename) {
-
- U.UF.F.stretching(_formel, typename, U.UF.C.apply(scope, scope.size));
- }, [this, i])
- }, _stretchingel);
- }
- }
-
- if (this.title !== false) {
- _headbottom = $$("div", {
- "style": { "cssText": "position: absolute; top: 3px; right: 0px; width: 80px; display: table-cell; vertical-align: middle;" }
- }, _formel);
- }
- if (this.isclose !== false) {
-
- $$("div", {
- "style": {
- "cssText": "background-image:url(../../../img/close.png); _background-image:url(/img/close.png);width: 14px; height: 14px; background-repeat: no-repeat; background-size: 100%; float: right; margin-right: 5px;margin-top:6px; cursor: pointer;"
- },
- "title": "点击关闭",
- "onmousedown": U.UF.EV.stopBubble,
- "onclick": U.UF.C.apply(this, function () {
- U.UF.F.closeWindow(this.form);
- try {
-
- if (U.MD.D.T.taskbar.close) {
- U.MD.D.T.taskbar.close({ "forms": _formel });
-
- }
- } catch (e) { }
-
- if (U.UF.C.isFunction(this.closecallback)) {
- this.closecallback();
- }
- })
- }, _headbottom);
- }
-
- if (this.isenlarge !== false) {
-
- _enlargeel = $$("div", {
- "style": {
- "cssText": "background-image:url(../../../img/max.png); _background-image:url(/img/max.png); background-size: 100%; float: right; margin-right: 10px; width: 17px; height: 17px; cursor: pointer;margin-top: 4px;"
- },
- "title": "最大化",
- "onmousedown": U.UF.EV.stopBubble,
-
- "onclick": function () {
- U.UF.F.windowZooming(_formel);
- }
- }, _headbottom);
-
- if (_headel) {
-
- _headel.ondblclick = U.UF.C.apply(_headel, function () {
-
- if (event.srcElement == this || U.UF.EL.isChild(this, event.srcElement)) {
- _enlargeel.onclick();
- }
- });
- }
- }
-
- if (this.isnarrow !== false) {
-
- $$("div", {
- "style": {
- "cssText": "background-image:url(../../../img/min.png); _background-image:url(/img/min.png);background-size: 100%; float: right; margin-right: 10px; margin-top: 3px; width: 20px; height: 20px; cursor: pointer;background-repeat: no-repeat;"
- },
- "title": "最小化",
- "onmousedown": U.UF.EV.stopBubble,
- "onclick": function () {
- U.UF.F.windowMinimize(_formel);
- }
- }, _headbottom);
- }
-
- if (_replaceel && _replaceel.parentNode != null) {
- _replaceel.parentNode.replaceChild(_formel, _replaceel);
- }
-
- else {
- this.parentel.appendChild(_formel);
- }
-
- if (_formel.style.top == "" && _formel.style.left == "" && _formel.style.right == "" && _formel.style.bottom == "") {
-
- U.UF.F.windowTopCenter(_formel);
- }
-
- else {
- U.UF.F.topWindow(_formel);
- }
-
- this.size();
- },
-
- top: function () {
- U.UF.F.topWindow(this.form);
- },
-
- size: function () {
- var _headheight = 0;
-
- if (this.header) {
- _headheight = this.header.clientHeight;
- }
-
- if (this.header) {
- this.middle.style.height = this.form.clientHeight - this.header.clientHeight + "px";
- } else {
- this.middle.style.height = this.form.clientHeight + "px";
- }
- }
- }
- U.UF.UI.form.windowResize = function () {
- var i,
- _style,
- _bodywidth = US.width,
- _bodyheight = US.height,
- _sizeinfo,
- _width,
- _height,
- _formel,
- _forms = U.UF.UI.form.allForm
- ;
-
- for (i in _forms) {
- _formel = _forms[i].form;
- if ($(_formel).css("display") != "none") {
- _style = {};
- _width = U.selectEl(_formel).css("width");
- _height = U.selectEl(_formel).css("height");
-
- _width = _width.indexOf("%") > -1 ? _width.toInt() / 100 : _formel.offsetWidth / _bodywidth;
- _height = _height.indexOf("%") > -1 ? _height.toInt() / 100 : _formel.offsetWidth / _bodyheight;
-
- if (_formel.style.right == "" || _formel.style.right == "auto") {
- _style.left = _formel.offsetLeft + (document.body.offsetWidth - _bodywidth) * ((1 - _width) / 2) + "px";
- }
-
- if (_formel.style.bottom == "" || _formel.style.bottom == "auto") {
- _style.top = _formel.offsetTop + (document.body.offsetHeight - _bodyheight) * ((1 - _height) / 2) + "px";
- }
-
- U.selectEl(_formel).addAttrArray({ "style": _style });
- }
- }
- }
- U.UF.UI.form.closeWindows = function () {
- var i;
- for (i in U.UF.UI.form.allForm) {
- if (U.UF.UI.form.allForm[i].isclose) {
- U.UF.UI.form.allForm[i].form.close();
- }
- }
- }
|