| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655 | Namespace.register("U.MD.O.E.TL");/*excel 的 工具栏功能*/U.MD.O.E.setStyle = false;U.MD.O.E.clearStyle = false;/*为选中单元格添加样式*attr 格式:{样式名:样式值}* cellArr 单元格数组 可选可不选*  req 如果存在 则不发送send请求*/U.MD.O.E.TL.setStyle = function (attr, cellArr, req) {    var _attr = attr, //需添加的样式名和值,以json形式        _sname, //添加的样式名字        _scontent, //添加样式的内容        _eiditorBox = $("#U_MD_O_E_editorBox")[0],           //获取对象并命名        _cellCheckd = cellArr || $(".U_MD_O_E_cellCheckd"),  //获取对象并命名        _dataArr = [],                                       //添加空的数组        _firstAttr = "";                                     //添加空的变量    for (var key in _attr) {        _sname = key;                //键名        _scontent = _attr[key];      //键值    }    for (var i = 0; i < _cellCheckd.length; i++) {          //处理字体的循环        _cellCheckd[i].setAttribute("name", "seted");       //给指定的元素添加属性        if (_cellCheckd[i].style.fontWeight == "" && _sname == "fontWeight") { //判断字体是否加粗            _eiditorBox.style[_sname] = _scontent;                                         _cellCheckd[i].style[_sname] = _eiditorBox.style[_sname];          //设置属性字体加粗        }        else if (_cellCheckd[i].style.fontStyle == "" && _sname == "fontStyle") {//判断字体是否斜体            _eiditorBox.style[_sname] = _scontent;            _cellCheckd[i].style[_sname] = _eiditorBox.style[_sname];          //设置属性字体斜体        }        else if (_cellCheckd[i].style.textDecoration == "" && _sname == "textDecoration") {//判断字体是否下划线            _eiditorBox.style[_sname] = _scontent;            _cellCheckd[i].style[_sname] = _eiditorBox.style[_sname];           //设置属性字体下划线        }        else if (_cellCheckd[i].style.textDecoration == "underline" && _sname == "textDecoration" && _scontent == "line-through") {//删除线            _eiditorBox.style[_sname] = _scontent;            _cellCheckd[i].style[_sname] = _eiditorBox.style[_sname];        }        else if (_cellCheckd[i].style.textDecoration == "line-through" && _sname == "textDecoration" && _scontent == "underline") {//删除线切换到下划线            _eiditorBox.style[_sname] = _scontent;            _cellCheckd[i].style[_sname] = _eiditorBox.style[_sname];        }        else if ((_cellCheckd[i].style.textAlign == "" || _cellCheckd[i].style.textAlign == "left" || _cellCheckd[i].style.textAlign == "center" || _cellCheckd[i].style.textAlign == "right") && _sname == "textAlign") {//内容水平定位            _eiditorBox.style[_sname] = _scontent;            _cellCheckd[i].style[_sname] = _eiditorBox.style[_sname];        }        else if (_sname == "textAlign" && _cellCheckd[i].style.textAlign == _scontent) {//重复添加同一个水平定位样式时的清除            _eiditorBox.style[_sname] = "";            _cellCheckd[i].style[_sname] = "";        }        else if (_sname == "backgroundColor") {//背景色            _cellCheckd[i].style[_sname] = _scontent;        }        else if (_sname == "color") {//字体色            _cellCheckd[i].style[_sname] = _scontent;        }        else if (_sname == "fontFamily") {//字体系列            _eiditorBox.style[_sname] = _scontent;            _cellCheckd[i].style[_sname] = _eiditorBox.style[_sname];        }        else if (_sname == "fontSize") {//字体大小            _eiditorBox.style[_sname] = _scontent;            _cellCheckd[i].style[_sname] = _eiditorBox.style[_sname];        }        else {                      //重复选中时的清除            _eiditorBox.style[_sname] = "";     //设置为空清除            _cellCheckd[i].style[_sname] = _eiditorBox.style[_sname];            attr = "";            _scontent = "";        }        if (i == 0) {            _firstAttr = attr;        }        var _info = {                               //设定数组并且赋值            col: _cellCheckd[i].col,                               row: _cellCheckd[i].row,            innerText: _cellCheckd[i].innerText,    //为文本的内容            attr: _sname, //属性            value: _scontent        };        _dataArr.push(_info);    }    U.MD.O.E.dataChange(U.MD.O.E.excelInfo("blur", _dataArr), req);    //合并时 保存数据}/** 清除所有样式*  req 如果存在 则不发送send请求*/U.MD.O.E.TL.clearStyle = function (cellArr, req) {                  //传入参数    var _eiditorBox = $("#U_MD_O_E_editorBox")[0],                  //选择对象命名        _cellCheckd = cellArr || $(".U_MD_O_E_cellCheckd"),         //选择对象命名        _dataArr = [];                                              //设置空的数组    for (var i = 0; i < _cellCheckd.length; i++) {                  //for循环指定对象长度        U.MD.O.E.TL.cellClearStyle(_cellCheckd[i]);                         var _info = {                                               //设定数组并且赋值            col: _cellCheckd[i].col,                                //为指定为col 的参数            row: _cellCheckd[i].row,                                //为指定为row 的参数            innerText: _cellCheckd[i].innerText,                    //为指定为innerText 的文本内容            clearStyle: true        };        _dataArr.push(_info);                                       //调用函数传入数组    }    U.MD.O.E.dataChange(U.MD.O.E.excelInfo("blur", _dataArr), req);    //合并时 保存数据    _eiditorBox.style.fontWeight = "";                              //合并时保存数据重置属性fontWeight    _eiditorBox.style.fontStyle = "";                               //合并时保存数据重置属性fontStyle    _eiditorBox.style.textDecoration = "";                          //合并时保存数据重置属性textDecoration    _eiditorBox.style.textAlign = "";                               //合并时保存数据重置属性textAlign    _eiditorBox.style.verticalAlign = "";                           //合并时保存数据重置属性verticalAlign    _eiditorBox.style.color = "";                                   //合并时保存数据重置属性color    _eiditorBox.style.fontFamily = "";                              //合并时保存数据重置属性fontFamily    _eiditorBox.style.fontSize = "";                                //合并时保存数据重置属性fontSize}/** 单元格清除所有样式*/U.MD.O.E.TL.cellClearStyle = function (cell) {    cell.style.fontWeight = "";                           //清除cell的样式fontWeight    cell.style.fontStyle = "";                            //清除cell的样式fontStyle    cell.style.textDecoration = "";                       //清除cell的样式textDecoration    cell.style.textAlign = "";                            //清除cell的样式textAlign    cell.style.verticalAlign = "";                        //清除cell的样式verticalAlign    cell.endRow ? _cellCheckd[i].style.display = "" : ''; //如果不是合并单元格元素的话 则将display清除    if (cell.children[0])        cell.children[0].style.verticalAlign = "";    cell.style.color = "";                                  //清除cell的样式color    cell.style.backgroundColor = "";                        //清除cell的样式backgroundColor    cell.style.fontFamily = "";                             //清除cell的样式fontFamily    cell.style.fontSize = "";                               //清除cell的样式fontSize}       /*修改文本垂直定位*attr 格式:{样式名:样式值}*/U.MD.O.E.TL.setTextStyle = function (attr, cellArr) {    var _attr = attr, //需添加的样式名和值,以json形式        _sname, //添加的样式名字        _scontent, //添加样式的内容        _eiditorBox = $("#U_MD_O_E_editorBox")[0], //声明变量        _cellCheckd = cellArr||$(".U_MD_O_E_cellCheckd"),//声明变量        _cellArr = [];                                  //声明数组并为空    for (var key in _attr) {                            //for循环json数组        _sname = key;        //键名        _scontent = _attr[key];   //键值        for (var i = 0; i < _cellCheckd.length; i++) { //for循环遍历            _eiditorBox.style[_sname] = _scontent;            _cellCheckd[i].style.display = 'table';     //更改样式            if (_cellCheckd[i].children[0])             //文本子节点                _cellCheckd[i].children[0].style[_sname] = _scontent;            _cellArr.push(_cellCheckd[i].id);           //调用函数        }    }    console.log(_cellArr);    console.log(attr);}/** * Excel颜色选择器* @param el 绑定了事件的元素* @param event 鼠标事件*/U.MD.O.E.TL.colorPicker = function (el, event) {    U.MD.O.E.TL.colorPicker.clickEl = el; /*button*/    /*判断是否创建色板*/    if (!U.MD.O.E.TL.colorPicker.ColorPickerEl) {           //判断有没有创建色板        U.MD.O.E.TL.colorPicker.ColorPickerEl = U.MD.UI.ColorPicker(U.MD.O.E.TL.colorPicker.ColorPickerEl, U.MD.O.E.TL.changeColor); /*生成色板*/        document.body.appendChild(U.MD.O.E.TL.colorPicker.ColorPickerEl) /*将色板添加到body里面*/        U.MD.O.E.TL.colorPicker.ColorPickerEl.style.position = 'absolute'; /*将绝对定位赋值给色板*/        U.MD.O.E.TL.colorPicker.ColorPickerEl.style.zIndex = '9999' /*层级为2*/    }    if (el.parentNode.className == "BD_BorderPicker") {        U.MD.O.E.TL.colorPicker.ColorPickerEl.style.left = el.parentNode.offsetLeft + 'px'; /*定位色板x位置*/    } else {        U.MD.O.E.TL.colorPicker.ColorPickerEl.style.left = event.target.getBoundingClientRect().left + 'px'; /*定位色板x位置*/    }    U.MD.O.E.TL.colorPicker.ColorPickerEl.style.top = event.target.getBoundingClientRect().top + 30 + (document.documentElement.scrollTop || document.body.scrollTop) + 'px'; /*定位色板y位置*/    U.MD.O.E.TL.colorPicker.ColorPickerEl.style.display = "block"; /*让色板显示出来*/    U.UF.EV.stopBubble(event);      //调用停止函数}U.MD.O.E.TL.colorPicker.clickEl = null; /*点击按钮*/U.MD.O.E.TL.colorPicker.ColorPickerEl = null; /*当前颜色div*//** * 改变两个小块的颜色* @param r 返回颜色值*/U.MD.O.E.TL.changeColor = function (r) {    var _changeEl = U.MD.O.E.TL.colorPicker.clickEl.querySelector('div[changecolor]'); /*获取自定义属性的元素*/    _changeEl.style.background = r; /*改变小块的颜色*/    console.log(_changeEl);    if (_changeEl && _changeEl.getAttribute('changecolor') == 'font') /*判断自定义属性的内容*/        U.MD.O.E.TL.setStyle({ 'color': U.UF.C.getColorByRGB(r) }); /*设置光标选中的样式*/    else if (_changeEl && _changeEl.getAttribute('changecolor') == 'bdcolor')        ;    else        U.MD.O.E.TL.setStyle({ 'backgroundColor': U.UF.C.getColorByRGB(r) }); /*设置光标选中的样式*/    U.MD.O.E.TL.colorPicker.ColorPickerEl.style.display = "none"; /*选择完后隐藏起来*/}/** * 设置多样式json 的样式* @param cell 单元格* @param attr 为{attr:value,attr:value,attr:value}多样式json*/U.MD.O.E.TL.jsonSetStyle = function (cell, attr) {    for (var i in attr) {         cell.style[i] = attr[i]    }}/**改变单元格边框样式*el 边框改变的效果*attr 格式:{样式名:样式值}* cellArr 单元格数组 可选可不选*/U.MD.O.E.TL.setBorderStyle = function (el, attr, cellArr, req) {    $(".BD_BorderPicker")[0].style.display = "none";        //声明对象的元素    var _el = el,                                           //声明变量        _type;    if (typeof (_el) == "string") {                         //判断变量        _type = _el;    } else {        _type = _el.title;    }    var _color = U.UF.C.getColorByRGB($("#bdcolor")[0].style.background), //声明对象元素        _attr = attr, //需添加的样式名和值,以json形式        _sname, //添加的样式名字        _scontent, //添加样式的内容        _eiditorBox = $("#U_MD_O_E_editorBox")[0],        _cellCheckd = cellArr || $(".U_MD_O_E_cellCheckd"),        _cellLeft, //左边框        _cellTop,        _cellRight,        _cellBottom,        _row = $(".U_MD_O_E_row"),        _col = $(".U_MD_O_E_column"),        _left, //起始x        _top, //起始y        _right, //结束x        _bottom, //结束y        _data    _dataArr = [];//创建数组为空    console.log(_cellCheckd.length);    console.log(_cellCheckd);    for (var key in _attr) {        _sname = key;        //键名        _scontent = _attr[key];   //键值    }    if (_type != "无框线" && typeof (_el) == "string") {   //判断单元格有无框线    } else if (_type != "无框线") {                        //判断单元格有无框线        _scontent = _scontent + " " + _color;    }    for (var i = 0; i < _cellCheckd.length; i++) {          //for循环遍历        if (i == 0) {            _left = _cellCheckd[i].col;                     //给予for循环里面的第一个元素赋值            _top = _cellCheckd[i].row;        }        if (i == _cellCheckd.length - 1) {                  //给予for循环里面的最后一个元素赋值            _right = _cellCheckd[i].col;            _bottom = _cellCheckd[i].row;        }    }    if (_type == "所有边框" || _type == "无框线") {//边框        for (var i = 0; i < _cellCheckd.length; i++) {//for循环遍历            _cellCheckd[i].setAttribute("name", "seted");   //给每一个元素添加属性元素            _cellCheckd[i].style.borderRight = _scontent;   //右边框            _cellCheckd[i].style.borderBottom = _scontent;  //底部边框            if (_cellCheckd[i].col == 1) {                if (_type == "无框线")                    _cellCheckd[i].style.borderLeft = "none"; //左边框                else                    _cellCheckd[i].style.borderLeft = _scontent;                _data = {                                      //数组赋值                    col: _cellCheckd[i].col,                   //指定对象的col参数                     row: _cellCheckd[i].row,                   //指定对象的row参数                     innerText: _cellCheckd[i].innerText,       //指定对象的文本内容                    attr: _sname, //属性                    br: "border-left",                         //指定元素的br参数                    value: _type == "无框线" ? "none" : _scontent, //指定为type内容的value参数                    bordertype: _type                          //指定变量的bordertype参数                };                _dataArr.push(_data);                          //传入数组调用函数            } else if (_cellCheckd[i].col == _left) {                _cellLeft = $("#POS_" + (_cellCheckd[i].col - 1) + "_" + (_cellCheckd[i].row) + "")[0];                _cellLeft.style.borderRight = _scontent;                _data = {                    col: _cellCheckd[i].col - 1,                //指定对象的col参数                     row: _cellCheckd[i].row,                    //指定对象的row参数                    innerText: _cellCheckd[i].innerText,        //指定对象的文本内容                    attr: _sname, //属性                    br: "border-right",                         //指定元素的br参数                    value: _scontent,                           //指定为_scontent内容的value参数                    bordertype: _type                };                _dataArr.push(_data);                           //传入数组调用函数            }            if (_cellCheckd[i].row == 1) {                if (_type == "无框线")                          //判断有无框线                    _cellCheckd[i].style.borderTop = "none";    //添加对象的样式                else                    _cellCheckd[i].style.borderTop = _scontent; //添加对象的样式                _data = {                                       //声明数组                    col: _cellCheckd[i].col,                    //指定对象的col参数                    row: _cellCheckd[i].row,                    //指定对象的row参数                    innerText: _cellCheckd[i].innerText,        //指定对象的文本内容                    attr: _sname, //属性                    bb: "border-top",                              //指定元素的br参数                    value: _type == "无框线" ? "none" : _scontent, //指定为type内容的value参数                    bordertype: _type                };                _dataArr.push(_data);            } else if (_cellCheckd[i].row == _top) {                _cellTop = $("#POS_" + (_cellCheckd[i].col) + "_" + (_cellCheckd[i].row - 1) + "")[0];  //声明变量的内容                _cellTop.style.borderBottom = _scontent;                                                //添加样式                _data = {                    col: _cellCheckd[i].col,                    //指定对象的col参数                    row: _cellCheckd[i].row - 1,                //指定对象的row参数                    innerText: _cellCheckd[i].innerText,        //指定对象的文本内容                    attr: _sname, //属性                    bb: "border-bottom",                        //指定元素的br参数                    value: _scontent,                           //指定为_scontent内容的value参数                    bordertype: _type                           //指定为_type内容的bordertype参数                };                _dataArr.push(_data);                           //传入数组调用函数            }            _data = {                col: _cellCheckd[i].col,                        //指定对象的col参数                row: _cellCheckd[i].row,                        //指定对象的row参数                innerText: _cellCheckd[i].innerText,            //指定对象的文本内容                attr: _sname, //属性                br: "border-right",                             //指定元素的br参数                bb: "border-bottom",                            //指定元素的br参数                value: _scontent,                               //指定为_scontent内容的value参数                bordertype: _type                               //指定为_type内容的bordertype参数            };            _dataArr.push(_data);                               //传入数组调用函数        }    }    else if (_type == "外侧框线") {                             //判断参数_type是否为外侧框线        for (var i = 0; i < _cellCheckd.length; i++) {          //for循环遍历            if (_cellCheckd[i].col == 1) {                      //变量等于1的时候                _cellCheckd[i].style.borderLeft = _scontent;                _data = {                                       //声明数组                    col: _cellCheckd[i].col,                    //指定对象的col参数                    row: _cellCheckd[i].row,                    //指定对象的row参数                    innerText: _cellCheckd[i].innerText,        //指定对象的文本内容                    attr: _sname,                               //属性                    br: "border-left",                          //指定元素的br参数                    value: _scontent,                           //指定为_scontent内容的value参数                    bordertype: _type                           //指定为_type内容的bordertype参数                };                _dataArr.push(_data);                           //传入数组调用函数            } else if (_cellCheckd[i].col == _left) {                _cellLeft = $("#POS_" + (_cellCheckd[i].col - 1) + "_" + (_cellCheckd[i].row) + "")[0];                _cellLeft.style.borderRight = _scontent;                _data = {                                       //声明数组                    col: _cellCheckd[i].col - 1,                //指定对象的col参数                    row: _cellCheckd[i].row,                    //指定对象的row参数                    innerText: _cellCheckd[i].innerText,        //指定对象的文本内容                    attr: _sname, //属性                    br: "border-right",                         //指定元素的br参数                    value: _scontent,                           //指定为_scontent内容的value参数                    bordertype: _type                           //指定为_type内容的bordertype参数                };                _dataArr.push(_data);                           //传入数组调用函数            }            if (_cellCheckd[i].row == 1) {                _cellCheckd[i].style.borderTop = _scontent;                _data = {                                       //声明数组                    col: _cellCheckd[i].col,                    //指定对象的col参数                    row: _cellCheckd[i].row,                    //指定对象的row参数                    innerText: _cellCheckd[i].innerText,        //指定对象的文本内容                    attr: _sname, //属性                    bb: "border-top",                           //指定元素的bb参数                    value: _scontent,                           //指定为_scontent内容的value参数                    bordertype: _type                           //指定为_type内容的bordertype参数                };                _dataArr.push(_data);                            //传入数组调用函数            } else if (_cellCheckd[i].row == _top) {                _cellTop = $("#POS_" + (_cellCheckd[i].col) + "_" + (_cellCheckd[i].row - 1) + "")[0];                _cellTop.style.borderBottom = _scontent;                _data = {                                       //声明数组                    col: _cellCheckd[i].col,                    //指定对象的col参数                    row: _cellCheckd[i].row - 1,                //指定对象的row参数                    innerText: _cellCheckd[i].innerText,        //指定对象的文本内容                    attr: _sname, //属性                    bb: "border-bottom",                        //指定元素的bb参数                    value: _scontent,                           //指定为_scontent内容的value参数                    bordertype: _type                           //指定为_type内容的bordertype参数                };                _dataArr.push(_data);                            //传入数组调用函数            }            if (_cellCheckd[i].col == _right) {                 //判断框线的右框线                _cellRight = $("#POS_" + (_cellCheckd[i].col) + "_" + (_cellCheckd[i].row) + "")[0];                _cellRight.style.borderRight = _scontent;       //添加变量的样式                _data = { col: _cellRight.col, row: _cellRight.row, innerText: _cellRight.innerText, attr: _sname, br: "border-right", value: _scontent, bordertype: _type };                _dataArr.push(_data);                           //传入数组调用函数            }            if (_cellCheckd[i].row == _bottom) {                //判断框线的底部框线                _cellBottom = $("#POS_" + (_cellCheckd[i].col) + "_" + (_cellCheckd[i].row) + "")[0];                _cellBottom.style.borderBottom = _scontent;     //添加变量的样式                _data = { col: _cellBottom.col, row: _cellBottom.row, innerText: _cellBottom.innerText, attr: _sname, bb: "border-bottom", value: _scontent, bordertype: _type };                _dataArr.push(_data);                            //传入数组调用函数            }        }    }    else if (_type == "上框线") {                              //判断框线为上框线        for (var i = 0; i < _cellCheckd.length; i++) {            if (_cellCheckd[i].row == 1) {                _cellCheckd[i].style.borderTop = _scontent;                _data = {                    col: _cellCheckd[i].col,                //指定对象的col参数                    row: _cellCheckd[i].row,                //指定对象的row参数                    innerText: _cellCheckd[i].innerText,    //指定对象的文本内容                    attr: _sname, //属性                    bb: "border-top",                       //指定元素的bb参数                    value: _scontent,                       //指定为_scontent内容的value参数                    bordertype: _type                       //指定为_type内容的bordertype参数                };                _dataArr.push(_data);            } else if (_cellCheckd[i].row == _top) {                _cellTop = $("#POS_" + (_cellCheckd[i].col) + "_" + (_cellCheckd[i].row - 1) + "")[0];                _cellTop.style.borderBottom = _scontent;                _data = {                    col: _cellCheckd[i].col,                //指定对象的col参数                    row: _cellCheckd[i].row - 1,            //指定对象的row参数                    innerText: _cellCheckd[i].innerText,    //指定对象的文本内容                    attr: _sname, //属性                    bb: "border-bottom",                    //指定元素的bb参数                    value: _scontent,                       //指定为_scontent内容的value参数                    bordertype: _type                       //指定为_type内容的bordertype参数                };                _dataArr.push(_data);            }        }    }    else if (_type == "下框线" || _type == "双底框线") {           //判断为双底框线        for (var i = 0; i < _cellCheckd.length; i++) {            if (_cellCheckd[i].row == _bottom) {                _cellBottom = $("#POS_" + (_cellCheckd[i].col) + "_" + (_cellCheckd[i].row) + "")[0];                _cellBottom.style.borderBottom = _scontent;         //指定数组的参数                _data = { col: _cellBottom.col, row: _cellBottom.row, innerText: _cellBottom.innerText, attr: _sname, bb: "border-bottom", value: _scontent, bordertype: _type };                _dataArr.push(_data);            }        }    }    else if (_type == "左框线") {                               //判断指定为左框线        for (var i = 0; i < _cellCheckd.length; i++) {            if (_cellCheckd[i].col == 1) {                _cellCheckd[i].style.borderLeft = _scontent;    //添加元素                _data = {                    col: _cellCheckd[i].col,                    //指定对象的col参数                    row: _cellCheckd[i].row,                    //指定对象的row参数                    innerText: _cellCheckd[i].innerText,        //指定对象的文本内容                    attr: _sname, //属性                    br: "border-left",                          //指定元素的br参数                    value: _scontent,                           //指定为_scontent内容的value参数                    bordertype: _type                           //指定为_type内容的bordertype参数                };                _dataArr.push(_data);            } else if (_cellCheckd[i].col == _left) {                       _cellLeft = $("#POS_" + (_cellCheckd[i].col - 1) + "_" + (_cellCheckd[i].row) + "")[0];                _cellLeft.style.borderRight = _scontent;                _data = {                    col: _cellCheckd[i].col - 1,                //指定对象的col参数                    row: _cellCheckd[i].row,                    //指定对象的row参数                    innerText: _cellCheckd[i].innerText,        //指定对象的文本内容                    attr: _sname, //属性                    br: "border-right",                         //指定元素的br参数                    value: _scontent,                           //指定为_scontent内容的value参数                    bordertype: _type                           //指定为_type内容的bordertype参数                };                _dataArr.push(_data);            }        }    }    else if (_type == "右框线") {                              //判断为有边框        for (var i = 0; i < _cellCheckd.length; i++) {            if (_cellCheckd[i].col == _right) {                _cellRight = $("#POS_" + (_cellCheckd[i].col) + "_" + (_cellCheckd[i].row) + "")[0];                _cellRight.style.borderRight = _scontent;      //指定数组的参数调用函数                _data = { col: _cellRight.col, row: _cellRight.row, innerText: _cellRight.innerText, attr: _sname, br: "border-right", value: _scontent, bordertype: _type };                _dataArr.push(_data);            }        }    }    else if (_type == "上下框线") {                         //判断为上下框线        for (var i = 0; i < _cellCheckd.length; i++) {            if (_cellCheckd[i].row == 1) {                _cellCheckd[i].style.borderTop = _scontent;                _data = {                    col: _cellCheckd[i].col,                    //指定对象的col参数                    row: _cellCheckd[i].row,                    //指定对象的row参数                    innerText: _cellCheckd[i].innerText,        //指定对象的文本内容                    attr: _sname, //属性                    bb: "border-top",                           //指定元素的br参数                    value: _scontent,                            //指定为_scontent内容的value参数                    bordertype: _type                            //指定为_type内容的bordertype参数                };                _dataArr.push(_data);            } else if (_cellCheckd[i].row == _top) {                _cellTop = $("#POS_" + (_cellCheckd[i].col) + "_" + (_cellCheckd[i].row - 1) + "")[0];                _cellTop.style.borderBottom = _scontent;                _data = {                    col: _cellCheckd[i].col,                     //指定为_type内容的bordertype参数                    row: _cellCheckd[i].row - 1,                //指定对象的row参数                    innerText: _cellCheckd[i].innerText,                    attr: _sname, //属性                    bb: "border-bottom",                    //指定元素的br参数                    value: _scontent,                       //指定为_scontent内容的value参数                    bordertype: _type                       //指定为_type内容的bordertype参数                };                _dataArr.push(_data);            }            if (_cellCheckd[i].row == _bottom) {    //判断为下边框                _cellBottom = $("#POS_" + (_cellCheckd[i].col) + "_" + (_cellCheckd[i].row) + "")[0];                _cellBottom.style.borderBottom = _scontent; //传入数组赋值,调用函数                _data = { col: _cellBottom.col, row: _cellBottom.row, innerText: _cellBottom.innerText, attr: _sname, bb: "border-bottom", value: _scontent, bordertype: _type };                _dataArr.push(_data);            }        }    }    console.log(_dataArr);    U.MD.O.E.dataChange(U.MD.O.E.excelInfo("setBorder", _dataArr), req);    //合并时 保存数据    U.UF.EV.stopBubble(window.event);}/*** 创建边框选区* 在U.MD.O.E.initExcel里调用*/U.MD.O.E.TL.borderPicker = function () {    var barelement = $("#bd_Pick")[0];    var div = $$("div", {                   //创建div赋属性元素的值        datacontent: '',        style: {            width: "120px",            height: "80px",            border: "1px solid #CDCDCD",            backgroundColor: " #FFF",            padding: "10px 10px 10px 5px",            position: "absolute",            left: $(".U_MD_O_E_Editor_head_features_ul_ibtmore")[0].offsetLeft + "px",            display: "none",            zIndex: 1        }        , "className": "BD_BorderPicker"    //赋值属性名    }, barelement); //创建外部div对象    $(barelement).bind('click', function (e) { /*绑定事件*/        U.UF.EV.stopBubble(e);        //阻止事件冒泡    });    div.innerHTML = "<div class='U_MD_O_E_Editor_head_features_ul_ibt' style='background-position: 5px 1px;width: 24px; height: 18px' title='所有边框' onmousedown='U.MD.O.E.TL.setBorderStyle(this,{ \"border\": \"1px solid\" });'></div><div class='U_MD_O_E_Editor_head_features_ul_ibt' style='background-position: 5px -28px;width: 24px; height: 18px' title='外侧框线' onmousedown='U.MD.O.E.TL.setBorderStyle(this,{ \"border\": \"1px solid\" });'></div><div class='U_MD_O_E_Editor_head_features_ul_ibt' style='background-position: 5px -57px;width: 24px; height: 18px' title='无框线' onmousedown='U.MD.O.E.TL.setBorderStyle(this,{ \"border\": \"1px solid #bebebe\" });'></div><div class='U_MD_O_E_Editor_head_features_ul_ibt' style='background-position: 5px -85px;width: 24px; height: 18px' title='上框线' onmousedown='U.MD.O.E.TL.setBorderStyle(this,{ \"border\": \"1px solid\" });'></div><div class='U_MD_O_E_Editor_head_features_ul_ibt' style='background-position: 5px -113px;width: 24px; height: 18px' title='下框线' onmousedown='U.MD.O.E.TL.setBorderStyle(this,{ \"border\": \"1px solid\" });'></div><div class='U_MD_O_E_Editor_head_features_ul_ibt' style='background-position: 5px -143px;width: 24px; height: 18px' title='左框线' onmousedown='U.MD.O.E.TL.setBorderStyle(this,{ \"border\": \"1px solid\" });'></div><div class='U_MD_O_E_Editor_head_features_ul_ibt' style='background-position: 5px -171px;width: 24px; height: 18px' title='右框线' onmousedown='U.MD.O.E.TL.setBorderStyle(this,{ \"border\": \"1px solid\" });'></div><div class='U_MD_O_E_Editor_head_features_ul_ibt' style='background-position: 5px -199px;width: 24px; height: 18px' title='上下框线' onmousedown='U.MD.O.E.TL.setBorderStyle(this,{ \"border\": \"1px solid\" });'></div><div class='U_MD_O_E_Editor_head_features_ul_ibt' style='background-position: 5px -228px;width: 24px; height: 18px' title='双底框线' onmousedown='U.MD.O.E.TL.setBorderStyle(this,{ \"border\": \"3px double\" });'></div><div class='U_MD_O_E_Editor_head_features_ul_ibtcolor' title='边框颜色' onclick = 'U.MD.O.E.TL.colorPicker(this, event)'><div style='float:left;padding-top: 5px;margin-left:6px'><div class='' style='background: url(/img/bordercolor.png) no-repeat;width: 14px; height: 14px;float: none;margin: 2px'></div><div style='width:18px;height: 4px; background: #000;' changecolor='bdcolor' id='bdcolor'></div></div><div class='U_MD_O_E_Editor_head_features_ul_bctext' style='padding-top: 7px;width:96px;height:22px;text-align:left;line-height:22px;float:right'>边框颜色</div>";}/**边框选择框的显示与隐藏*/U.MD.O.E.TL.borderPickerShow = function () {    var _el = $(".BD_BorderPicker")[0]; //声明变量    if (_el.style.display == "none")    //触发函数时改变display的状态        _el.style.display = "block";}U.MD.O.E.TL.hideChange = function (el) {    if (!el.children.length) /*判断是否有子元素*/        return;    el.style.display === 'table-row' ? el.style.display = 'none' : el.style.display = 'table-row'; /*显示隐藏*/}/** * 给工具栏绑定onresize事件* @param moreareael 存放超出内容的div*/U.MD.O.E.TL.toolsbind = function (moreareael) {    var _toolsEl = $('#tools')[0];    _toolsEl.onresize = function () { /*给工具栏绑定onresize事件*/        U.MD.O.E.TL.toolbarCheck(_toolsEl, moreareael);    };    U.MD.O.E.TL.toolbarCheck(_toolsEl, moreareael);}/** * 工具栏检测内容区域大小* @param forms 工具栏div* @param moreareael 存放超出内容的div*/U.MD.O.E.TL.toolbarCheck = function (forms, moreareael) {    var _winW = forms.clientWidth; /*获取工具栏可视长*/    var _morealattice = $(".U_MD_O_H_head_mo")[0];  //获取对象    var _partition1 = $('div[partition="1"]')[0];    console.log(_winW);    if (_winW > 1189) {             //当大于1189xp将隐藏,当小于时显示        $('#moreButton')[0].style.display = 'none'    } else {        $('#moreButton')[0].style.display = 'block'     }    if (!(_winW > 750)) {            //当大于780xp将局左,小于时不居左        moreareael.querySelector('div[partition="1"]').style.float = "";    } else if (_winW > 750) {        _partition1.style.float = "left";    }    if (!(_winW > 849) && !moreareael.querySelector('div[partition="4"]')) { /*当小于732px将第四组工具转移*/        moreareael.insertBefore($('div[partition="4"]')[0], moreareael.firstElementChild) /*将第四组转移*/    } else {        if (_winW > 849 && moreareael.querySelector('div[partition="4"]'))            moreareael.parentNode.insertBefore($('div[partition="4"]')[0], moreareael.previousElementSibling) /*将第四组重新添加到工具栏里*/    }    if (!(_winW > 922) && !moreareael.querySelector('div[partition="3"]')) { /*当小于873px将第三组工具转移*/        moreareael.insertBefore($('div[partition="3"]')[0], moreareael.firstElementChild)/*将第三组转移*/        _morealattice.style.right = "";        _morealattice.style.left = "0px";    } else {        if (_winW > 922 && moreareael.querySelector('div[partition="3"]'))            moreareael.parentNode.insertBefore($('div[partition="3"]')[0], moreareael.previousElementSibling)/*将第三组重新添加到工具栏里*/        if (_winW > 922) {/*当大于922px左右居清空*/            _morealattice.style.right = "0px";            _morealattice.style.left = "";        }    }    if (!(_winW > 1186) && !moreareael.querySelector('div[partition="2"]')) { /*当小于1012px将第二组工具转移*/        moreareael.insertBefore($('div[partition="2"]')[0], moreareael.firstElementChild)/*将第二组转移*/    } else {        if (_winW > 1186 && moreareael.querySelector('div[partition="2"]'))            moreareael.parentNode.insertBefore($('div[partition="2"]')[0], moreareael.previousElementSibling)/*将第二组重新添加到工具栏里*/    }    if (!(_winW > 1189) && !moreareael.querySelector('div[partition="1"]')) { /*当小于1153px将第一组工具转移*/        moreareael.appendChild($('div[partition="1"]')[0]); /*将第一组转移*/    } else {        if (_winW > 1189 && moreareael.querySelector('div[partition="1"]'))            moreareael.parentNode.insertBefore($('div[partition="1"]')[0], moreareael.previousElementSibling)/*将第一组重新添加到工具栏里*/        if (_winW > 1189) {/*当大于1153px将隐藏更多工具栏*/            _morealattice.style.display = "none";        }    }}
 |