| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 | /*问题:1、txt的问题变化 键盘处理流程*/Namespace.register("U.D.Txt"); //txt命名空间//#region 初始化命名空间//打开txtU.D.Txt.Txt = function (UDE, UGE) {    var i, _UDTD, _UDSD, _UDCD, _UDND, _UDKD,        _USN = UDE["UserallDirectoryName"],        _UIF = US.userInfo,        _UDOD = $("#UD_SYTX"),        _UDAD = _UDOD.childg(),         _UGE = US.Disk.Disks[_userid],         _UDID = UDE.UserDirectoryParentID || (UGE ? UGE[1][1] : ""),         _userid = UDE.UserId || (_UGE ? _UGE[1][0].UserId : _UIF.UserId),          _UIMG = UDE.UserThumbnailImageHead || (_UGE ? _UGE[1][0].UserThumbnailImageHead : _UIF.UserThumbnailImageHead);    if ((_UDCD = $("#UT_" + (UDE.UserDirectoryID || UDE.id)))[0]) { _UDCD.Center(); return _UDCD[0]; }    else { //生成值        _UDTD = $(_UDAD[0]).clone(true); _UDSD = $(_UDAD[1]).clone(true);        _UDCD = $("div", _UDTD);        _UDCD[2].innerHTML = UDE.UserName || UDE.UserNickName || "请登录";        _UDCD[3].innerHTML = _UGE ? "所有云文件" + _UGE[1][0]["FilesCount"] : "";        $($("img", _UDCD[1])[0] || $$("img", {}, _UDCD[1])).addAttrArray({ "onerror": U.M.ImgError, "src": U.M.GetImgU(_UIMG), "onclick": [[U.M.StopBubble], [U.D.DT.YYDK, ["Disk", { "userid": _userid, "directoryid": US.FG}]]] });        (_USN) && ($("input", _UDTD)[0].value = _USN.substr(0, (_UL = _USN.lastIndexOf(".")) > 0 ? _UL : _USN.length)); for (i = 0; i < 2; i++) { (_UDCD = $(i ? _UDSD : _UDTD).find(i ? "textarea" : "input")[0]).defaultValue = _UDCD.value; }        _UDCD = U.UI.Form({ id: "UT_" + (UDE.UserDirectoryID || UDE.id),            close: { onclick: U.M.apply(this, [[U.D.Txt.TxtClose, [UDE, _userid, _UDID]]]) },            resize: U.D.Txt.TxtSize, style: { width: "800px", height: "500px" },            content: _UDSD[0], title: _UDTD, bst: { style: { overflow: "hidden"} }        });        //加载数据        _UDND = U.D.Txt.TxtCreate(UDE, _userid, _UDID, _UDCD);        (_UDKD = _UDSD.find("select")).Aattr({ onchange: [[U.D.Txt.TxtZT, [_UDKD[0], _UDND[0]]]] }, 0);        U.OU.CreateWordSize(_UDKD[0]);        U.D.E.codeDetect({ cb: U.M.apply(null, [[U.D.Txt.CZJP, [_UDND[1]]]]),            el: [_UDSD[0], $("input", _UDTD)[0]]        });        return _UDCD.be;    }}//读取txtU.D.Txt.ReadTxt = function (UDE, UDOD) {    UDOD = $(UDOD);    var _UDID = UDOD.find("input")[0],    _UDTD = UDOD.find("textarea")[0];    _UDTD.focus();    if (UDE && UDE.UserDirectoryID) {        if (UDE.UsOffice != null) {            _UDTD.value = UDE.UsOffice;        }        else {            if (UDE.UserFilesServerName) {                U.A.Request(US.Auth, ["OpenTxtFile", UDE.UserFilesServerName], U.D.Txt.AsynReadTxt, [[_UDTD, true], _UDTD, UDE]);            }            else {                U.A.Request(US.Auth, ["GetFileContent", UDE.UserDirectoryID], U.D.Txt.AsynReadTxt, [[_UDTD, true], _UDTD, UDE]);            }        }    }}//读取文件异步U.D.Txt.AsynReadTxt = function (r) {    var context = r.context,    _UDOD = context[1],    _UDE = context[2];    _UDOD.value = _UDE.UsOffice = r = r.value.UsOffice || "";}//#endregion//#region 关闭窗体//关闭txtU.D.Txt.TxtClose = function (UDE, userid, UDID, UDOD) {    UDOD = $(UDOD);    var _UCB,    _userid = US.userInfo.userid,    _UDTD = UDOD.find("textarea")[0],    _UDID = UDOD.find("input")[0],    _UFN = _UDID.value,    _UTH = _UDTD.value,    _UTF = (!UDE || !UDE.UserDirectoryID),    _UDN = UDE.UserallDirectoryName.replace("." + UDE.UserDirectoryExtendType, "");    if (_userid && (!UDE || _userid == UDE.UserId)) {        if (UDE && UDE.UserDirectoryID && _UDN != _UFN && U.MS.ZWFileName.test(_UFN)) {            U.Dk.RE.MFN(UDE, _UFN, null, US.userInfo.userid);        } //保存文件同时修改文件名        else if ((_UFN != _UDID.defaultValue || _UTH != _UDTD.defaultValue) && (_UFN != _UDN || _UTH != UDE.UsOffice)) { //内容更变处理            _UCB = _UTF ? U.M.apply(null, [[U.D.Txt.TxtCloseCT, [UDOD[0], _UDTD, _UDID]]]) : U.M.apply(null, [[U.D.CloseWindow, [UDOD[0]]]]); //设置回调            U.UI.Confirm("是否保存内容", [U.M.apply(null, [[U.D.Txt.BCTxt, [UDE, userid, UDID, UDOD[0], _UCB, true]]])], [_UCB]); return false;        }    }    (_UTF) && (U.D.Txt.TxtCloseCT(UDOD[0], _UDTD, _UDID)); //关闭窗体使用}//关闭窗体U.D.Txt.TxtCloseCT = function (UDOD, UDTD, UDID) {    UDTD.value = "点击编辑内容..."; UDID.value = "未命名文档(点击编辑)..."; U.D.CloseWindow(UDOD);}//#endregion//#region 文件新建保存//保存异步U.D.Txt.AsynBCTxt = function (UTH, UDOD, UCE, URE) {    if (UCE && URE) {        U.Dk.LE.USOS(UCE[1].UserDirectoryID, UTH);        $(UDOD).find("input")[0].value = UCE[1].UserallDirectoryName;    }}//txt新建U.D.Txt.XJTxt = function (UDE, userid, UDID, UDOD) {    var _UDID, _UDTD, _UDID, _UDOD;    if (UDOD && (UDOD = $(UDOD)) && UDE.UserDirectoryID || ((_UDTD = _UDOD.find("textarea")[0]) && (_UDID = _UDOD.find("input")[0]) && _UDID.value && _UDTD.value && _UDID.defaultValue != _UDID.value && _UDTD.defaultValue != _UDTD.value)) { //提示保存文件        U.UI.Confirm("是否保存内容", [U.D.Txt.BCTxt, [UDE, userid, UDID, UDOD, U.M.apply(this, [[U.D.Txt.AsynXJTxt, [userid, UDID, UDOD, UDE]]]), true]]);    }    else {        _UDTD = $(UDOD).childg(0)[1];        _UDTD = $(_UDTD).childg(0, 0);        _UDID = Guid.newGuid(); $("#UT_" + (UDE.UserDirectoryID || UDE.id))[0].ID = "UT_" + _UDID; U.D.Txt.TxtCreate({ UserallDirectoryName: "", id: _UDID }, userid, UDID, { body: _UDTD[0], be: UDOD, content: UDOD.Child()[0] });    }}//新建异步U.D.Txt.AsynXJTxt = function (userid, UDID, UDOD, UDE, UTF) {    if (UTF !== false) {        var _UDOD = $(UDOD),        _UDID = _UDOD.find("input")[0],        _UDTD = _UDOD.find("textarea")[0];        _UDID.value = _UDID.defaultValue;        _UDTD.value = _UDTD.defaultValue;        U.D.Txt.XJTxt(UDE);    }}//txt保存U.D.Txt.BCTxt = function (UDE, userid, UDID, UDOD, UCB, UTF) {    var _UTF = (!UDE || !UDE.UserDirectoryID),    _UDOD = $(UDOD),     _UDTD = _UDOD.find("textarea")[0],     _UDID = _UDOD.find("input")[0],     _UHT = _UDTD.value,     _UIN = _UDID.value,     _userid = US.userInfo.userid;    if (!U.U.L.isLogin(3) && (_UTF || UDE.UserId == _userid)) { //登录保存使用        if (!U.MS.ZWFileName.test(_UIN) && _UDID.defaultValue != _UIN) {            U.Alert("文件名不符合");            _UDID.focus(); _UDID.select();        } //文件名输入区域        else if (!UTF || (_UHT && _UIN && (_UDID.defaultValue != _UIN || _UDTD.defaultValue != _UHT))) { //内容保存            (_UIN == _UDID.defaultValue) && (_UIN = "");            (_UHT == _UDID.defaultValue) && (_UHT = ""); //     (!_UTF) && (U.Dk.DiskOperatingSwitch(userid));            U.Ut.AddObj(UDE, U.Dk.LE.USOS(UDE.UserDirectoryID ? UDE : UDE.id, _UHT, "txt", [[U.D.Txt.AsynBCTxt, [_UHT, _UDOD]], [UCB]], null, UDID, _UIN)); UDOD.id = "UT_" + UDE.UserDirectoryID; return false;        }    }    else {        U.Alert("他人文件拒绝访问");    }    (UCB) && (UCB(false)); return true;}//#endregion//#region 附加功能处理//键盘特殊操作U.D.Txt.CZJP = function (UDOD, UDE, UDTD) {    if (UDE == "save") { UDOD[1].onclick(); } //保存设置}//txt字体变化U.D.Txt.TxtZT = function (UDOD, UDTD) {    var _UST = UDTD.value,    _UDND = document.createTextNode(" ");    $(UDTD).addAttrArray({ style: { fontSize: UDOD.value + "px"} }).append(_UDND);    $(_UDND).remove();}//txt创建处理U.D.Txt.TxtCreate = function (UDE, userid, UDID, UCE) {    var _USE = [U.D.Txt.TxtSize(null, null, UCE.body),    U.D.Txt.TxtEvent(UDE, userid, UDID, UCE.content)];    U.D.Txt.ReadTxt(UDE, UCE.be); return _USE;}//txt大小处理U.D.Txt.TxtSize = function (UDOD, UDTD, UDSD) {    var _UDOD = $(UDSD).childg(0)[0];    _UDOD = $(_UDOD).childg(0)[1];    $(_UDOD).css({ "height": UDSD.offsetHeight - 51 + "px", "width": UDSD.offsetWidth - 20 + "px" });    return _UDOD;}//txt事件赋值U.D.Txt.TxtEvent = function (UDE, userid, UDID, UDOD) {    var i, _UDMD, _UDAD = $(UDOD).Child(),    _UDCD = $(_UDAD[0]).childg();    $("&*", _UDCD).addAttrArray({ "unselectable": "on" });    for (i = 0; i < _UDCD.length - 1; i++) {//新建保存        _UDCD.addAttrArray({ "onmousedown": U.M.StopBubble, "onclick": [[i ? U.D.Txt.BCTxt : U.D.Txt.XJTxt, [UDE, userid, UDID, $(UDOD).Parent(3)]]] }, i);    }    return _UDCD;}
 |