resize.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. import luckysheetConfigsetting from './luckysheetConfigsetting';
  2. import luckysheetFreezen from './freezen';
  3. import { luckysheetrefreshgrid } from '../global/refresh';
  4. import Store from '../store';
  5. import locale from '../locale/locale';
  6. import sheetmanage from './sheetmanage';
  7. import tooltip from '../global/tooltip'
  8. import { $$, getObjType, camel2split } from "../utils/util";
  9. import { defaultToolbar, toolbarIdMap } from './toolbar';
  10. let gridW = 0,
  11. gridH = 0;
  12. export default function luckysheetsizeauto(isRefreshCanvas=true) {
  13. if (!luckysheetConfigsetting.showinfobar) {
  14. Store.infobarHeight = 0;
  15. $("#luckysheet_info_detail").hide();
  16. }
  17. else {
  18. $("#luckysheet_info_detail").show();
  19. // Store.infobarHeight = 56;
  20. Store.infobarHeight = document.querySelector('#luckysheet_info_detail').offsetHeight;
  21. }
  22. if (!!Store.toobarObject && !!Store.toobarObject.toobarElements && Store.toobarObject.toobarElements.length === 0) {
  23. $("#" + Store.container).find(".luckysheet-wa-editor").hide();
  24. Store.toolbarHeight = 0;
  25. }
  26. else {
  27. $("#" + Store.container).find(".luckysheet-wa-editor").show();
  28. // Store.toolbarHeight = 72;
  29. Store.toolbarHeight = document.querySelector('#' + Store.container +' .luckysheet-wa-editor')?.offsetHeight || 72;
  30. }
  31. // if (!luckysheetConfigsetting.showsheetbar) {
  32. // $("#" + Store.container).find("#luckysheet-sheet-area").hide();
  33. // Store.sheetBarHeight = 0;
  34. // }
  35. // else {
  36. // $("#" + Store.container).find("#luckysheet-sheet-area").show();
  37. // Store.sheetBarHeight = 31;
  38. // }
  39. customSheetbarConfig();
  40. // if (!luckysheetConfigsetting.showstatisticBar) {
  41. // $("#" + Store.container).find(".luckysheet-stat-area").hide();
  42. // Store.statisticBarHeight = 0;
  43. // }
  44. // else {
  45. // $("#" + Store.container).find(".luckysheet-stat-area").show();
  46. // Store.statisticBarHeight = 23;
  47. // }
  48. customStatisticBarConfig();
  49. // 公式栏
  50. const formulaEle = document.querySelector("#" + Store.container + ' .luckysheet-wa-calculate');
  51. if (!luckysheetConfigsetting.sheetFormulaBar) {
  52. formulaEle.style.display = 'none';
  53. Store.calculatebarHeight = 0;
  54. }
  55. else {
  56. formulaEle.style.display = 'block';
  57. Store.calculatebarHeight = formulaEle.offsetHeight;
  58. }
  59. $("#" + Store.container).find(".luckysheet-grid-container").css("top", Store.toolbarHeight + Store.infobarHeight + Store.calculatebarHeight);
  60. gridW = $("#" + Store.container).width();
  61. if(luckysheetConfigsetting.showConfigWindowResize){//数据透视表 图表 交替颜色 Protection
  62. if($("#luckysheet-modal-dialog-slider-pivot").is(":visible")){
  63. gridW -= $("#luckysheet-modal-dialog-slider-pivot").outerWidth();
  64. }
  65. else if($(".chartSetting").is(":visible")){
  66. gridW -= $(".chartSetting").outerWidth();
  67. }
  68. else if($("#luckysheet-modal-dialog-slider-alternateformat").is(":visible")){
  69. gridW -= $("#luckysheet-modal-dialog-slider-alternateformat").outerWidth();
  70. }
  71. if($("#luckysheet-modal-dialog-slider-protection").is(":visible")){
  72. gridW -= $("#luckysheet-modal-dialog-slider-protection").outerWidth();
  73. }
  74. }
  75. const _locale = locale();
  76. const locale_toolbar = _locale.toolbar;
  77. let ismore = false,
  78. toolbarW = 0,
  79. morebtn = `<div class="luckysheet-toolbar-button luckysheet-inline-block" data-tips="${locale_toolbar.toolMoreTip}" id="luckysheet-icon-morebtn" role="button" style="user-select: none;">
  80. <div class="luckysheet-toolbar-button-outer-box luckysheet-inline-block" style="user-select: none;">
  81. <div class="luckysheet-toolbar-button-inner-box luckysheet-inline-block" style="user-select: none;">
  82. <div class="luckysheet-toolbar-menu-button-caption luckysheet-inline-block" style="user-select: none;">
  83. ${locale_toolbar.toolMore}
  84. </div>
  85. <div class="luckysheet-toolbar-menu-button-dropdown luckysheet-inline-block iconfont luckysheet-iconfont-xiayige" style="user-select: none;font-size:12px;">
  86. </div>
  87. </div>
  88. </div>
  89. </div>`,
  90. // Add style left:$$('.luckysheet') left, when the worksheet does not fill the full screen
  91. morediv = '<div id="luckysheet-icon-morebtn-div" class="luckysheet-wa-editor" style="position:absolute;top:'+ (Store.infobarHeight + Store.toolbarHeight + $("#" + Store.container).offset().top + $("body").first().scrollTop()) +'px;right:0px;z-index:1003;padding:5.5px;visibility:hidden;height:auto;white-space:initial;"></div>';
  92. if($("#luckysheet-icon-morebtn-div").length == 0){
  93. $("body").first().append(morediv);
  94. }
  95. // $("#luckysheet-icon-morebtn-div").hide();
  96. $$("#luckysheet-icon-morebtn-div").style.visibility = 'hidden';
  97. // $("#luckysheet-icon-morebtn-div > div").appendTo($("#luckysheet-wa-editor"));
  98. $("#luckysheet-icon-morebtn-div > div").each(function(){
  99. const $t = $(this)[0];
  100. const $container = $("#luckysheet-wa-editor")[0];
  101. $container.appendChild(document.createTextNode(" "));
  102. $container.appendChild($t);
  103. });
  104. $("#luckysheet-icon-morebtn").remove();
  105. // 所有按钮宽度与元素定位
  106. const toobarWidths = Store.toobarObject.toobarWidths;
  107. const toobarElements = Store.toobarObject.toobarElements;
  108. let moreButtonIndex = 0;
  109. // When you resize the window during initialization, you will find that the dom has not been rendered yet
  110. if(toobarWidths == undefined){
  111. return;
  112. }
  113. // 找到应该隐藏的起始元素位置
  114. for (let index = toobarWidths.length - 1; index >= 0; index--) {
  115. // #luckysheet-icon-morebtn button width plus right is 83px
  116. if(toobarWidths[index] < gridW - 90){
  117. moreButtonIndex = index;
  118. if(moreButtonIndex < toobarWidths.length - 1){
  119. ismore = true;
  120. }
  121. break;
  122. }
  123. }
  124. // 从起始位置开始,后面的元素统一挪到下方隐藏DIV中
  125. for (let index = moreButtonIndex; index < toobarElements.length; index++) {
  126. const element = toobarElements[index];
  127. if(element instanceof Array){
  128. for(const ele of element){
  129. $("#luckysheet-icon-morebtn-div").append($(`${ele}`));
  130. }
  131. }else{
  132. $("#luckysheet-icon-morebtn-div").append($(`${element}`));
  133. }
  134. }
  135. if(ismore){
  136. $("#luckysheet-wa-editor").append(morebtn);
  137. $("#luckysheet-icon-morebtn").click(function(){
  138. //When resize, change the width of the more button container in real time
  139. $$('#luckysheet-icon-morebtn-div').style.left = '';//reset
  140. // *这里计算containerLeft的作用是:获得容器左侧的margin值,以让点击出现的“更多按钮”栏位置不会出错。
  141. const containerLeft = $$(`#${Store.container}`).getBoundingClientRect ? $$(`#${Store.container}`).getBoundingClientRect().left : 0;
  142. const morebtnLeft = $$('#luckysheet-icon-morebtn-div').getBoundingClientRect().left;//get real left info
  143. if(morebtnLeft < containerLeft){
  144. $$('#luckysheet-icon-morebtn-div').style.left = containerLeft + 'px';
  145. }
  146. let right = $(window).width() - $("#luckysheet-icon-morebtn").offset().left - $("#luckysheet-icon-morebtn").width()+ $("body").first().scrollLeft();
  147. // $("#luckysheet-icon-morebtn-div").toggle().css("right", right < 0 ? 0 : right);
  148. // use native js operation
  149. $$('#luckysheet-icon-morebtn-div').style.right = right < 0 ? 0 : right + 'px';
  150. // change to visibility,morebtnLeft will get the actual value
  151. if($$('#luckysheet-icon-morebtn-div').style.visibility === 'hidden'){
  152. $$('#luckysheet-icon-morebtn-div').style.visibility = 'visible';
  153. }else{
  154. $$('#luckysheet-icon-morebtn-div').style.visibility = 'hidden';
  155. }
  156. let $txt = $(this).find(".luckysheet-toolbar-menu-button-caption");
  157. if($txt.text().indexOf(locale_toolbar.toolMore) > -1){
  158. const toolCloseHTML = `
  159. <div class="luckysheet-toolbar-menu-button-caption luckysheet-inline-block" style="user-select: none;">
  160. ${locale_toolbar.toolClose}
  161. </div>
  162. <div class="luckysheet-toolbar-menu-button-dropdown luckysheet-inline-block iconfont luckysheet-iconfont-shangyige" style="user-select: none;font-size:12px;">
  163. </div>
  164. `
  165. $(this).find(".luckysheet-toolbar-button-inner-box").html(toolCloseHTML);
  166. }
  167. else{
  168. const toolMoreHTML = `
  169. <div class="luckysheet-toolbar-menu-button-caption luckysheet-inline-block" style="user-select: none;">
  170. ${locale_toolbar.toolMore}
  171. </div>
  172. <div class="luckysheet-toolbar-menu-button-dropdown luckysheet-inline-block iconfont luckysheet-iconfont-xiayige" style="user-select: none;font-size:12px;">
  173. </div>
  174. `
  175. $(this).find(".luckysheet-toolbar-button-inner-box").html(toolMoreHTML);
  176. }
  177. });
  178. //$("#luckysheet-wa-editor div").trigger("create");
  179. // $("#luckysheet-icon-morebtn-div .luckysheet-toolbar-menu-button").css("margin-right", -1);
  180. // $("#luckysheet-icon-morebtn-div .luckysheet-toolbar-button-split-left").css("margin-right", -3);
  181. // “更多”容器中,联动hover效果
  182. $("#luckysheet-icon-morebtn-div .luckysheet-toolbar-button-split-left").off("hover").hover(function(){
  183. $(this).next(".luckysheet-toolbar-button-split-right").addClass("luckysheet-toolbar-button-split-right-hover");
  184. }, function(){
  185. $(this).next(".luckysheet-toolbar-button-split-right").removeClass("luckysheet-toolbar-button-split-right-hover");
  186. });
  187. $("#luckysheet-icon-morebtn-div .luckysheet-toolbar-button-split-right").off("hover").hover(function(){
  188. $(this).prev(".luckysheet-toolbar-button-split-left").addClass("luckysheet-toolbar-button-hover");
  189. }, function(){
  190. $(this).prev(".luckysheet-toolbar-button-split-left").removeClass("luckysheet-toolbar-button-hover");
  191. });
  192. // tooltip
  193. tooltip.createHoverTip("#luckysheet-icon-morebtn-div" ,".luckysheet-toolbar-menu-button, .luckysheet-toolbar-button, .luckysheet-toolbar-combo-button");
  194. }
  195. $("#"+ Store.container + " .luckysheet-wa-editor .luckysheet-toolbar-button-split-left").off("hover").hover(function(){
  196. $(this).next(".luckysheet-toolbar-button-split-right").addClass("luckysheet-toolbar-button-split-right-hover");
  197. }, function(){
  198. $(this).next(".luckysheet-toolbar-button-split-right").removeClass("luckysheet-toolbar-button-split-right-hover");
  199. });
  200. $("#"+ Store.container + " .luckysheet-wa-editor .luckysheet-toolbar-button-split-right").off("hover").hover(function(){
  201. $(this).prev(".luckysheet-toolbar-button-split-left").addClass("luckysheet-toolbar-button-hover");
  202. }, function(){
  203. $(this).prev(".luckysheet-toolbar-button-split-left").removeClass("luckysheet-toolbar-button-hover");
  204. });
  205. // When adding elements to the luckysheet-icon-morebtn-div element of the toolbar, it will affect the height of the entire workbook area, so the height is obtained here
  206. gridH = $("#" + Store.container).height();
  207. $("#" + Store.container).find(".luckysheet").height(gridH - 2).width(gridW - 2);
  208. changeSheetContainerSize(gridW, gridH)
  209. if(isRefreshCanvas){
  210. luckysheetrefreshgrid($("#luckysheet-cell-main").scrollLeft(), $("#luckysheet-cell-main").scrollTop());
  211. }
  212. sheetmanage.sheetArrowShowAndHide();
  213. sheetmanage.sheetBarShowAndHide();
  214. }
  215. export function changeSheetContainerSize(gridW, gridH){
  216. if(gridW==null){
  217. gridW = $("#" + Store.container).width();
  218. }
  219. if(gridH==null){
  220. gridH = $("#" + Store.container).height();
  221. }
  222. Store.cellmainHeight = gridH - (Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight + Store.sheetBarHeight + Store.statisticBarHeight);
  223. Store.cellmainWidth = gridW - Store.rowHeaderWidth;
  224. $("#luckysheet-cols-h-c, #luckysheet-cell-main").width(Store.cellmainWidth);
  225. $("#luckysheet-cell-main").height(Store.cellmainHeight);
  226. $("#luckysheet-rows-h").height(Store.cellmainHeight - Store.cellMainSrollBarSize);
  227. $("#luckysheet-scrollbar-y").height(Store.cellmainHeight + Store.columnHeaderHeight - Store.cellMainSrollBarSize - 3);
  228. $("#luckysheet-scrollbar-x").height(Store.cellMainSrollBarSize);
  229. $("#luckysheet-scrollbar-y").width(Store.cellMainSrollBarSize);
  230. $("#luckysheet-scrollbar-x").width(Store.cellmainWidth).css("left", Store.rowHeaderWidth - 2);
  231. Store.luckysheetTableContentHW = [
  232. Store.cellmainWidth + Store.rowHeaderWidth - Store.cellMainSrollBarSize,
  233. Store.cellmainHeight + Store.columnHeaderHeight - Store.cellMainSrollBarSize
  234. ];
  235. $("#luckysheetTableContent, #luckysheetTableContentF").attr({
  236. width: Math.ceil(Store.luckysheetTableContentHW[0] * Store.devicePixelRatio),
  237. height: Math.ceil(Store.luckysheetTableContentHW[1] * Store.devicePixelRatio)
  238. })
  239. .css({ width: Store.luckysheetTableContentHW[0], height: Store.luckysheetTableContentHW[1] });
  240. $("#" + Store.container).find("#luckysheet-grid-window-1").css("bottom", Store.sheetBarHeight);
  241. $("#" + Store.container).find(".luckysheet-grid-window").css("bottom", Store.statisticBarHeight);
  242. let gridwidth = $("#luckysheet-grid-window-1").width();
  243. $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-handle")
  244. .css({ "width": gridwidth - 10 })
  245. .end()
  246. .find(".luckysheet-freezebar-horizontal-drop")
  247. .css({ "width": gridwidth - 10 });
  248. let gridheight = $("#luckysheet-grid-window-1").height();
  249. $("#luckysheet-freezebar-vertical")
  250. .find(".luckysheet-freezebar-vertical-handle")
  251. .css({ "height": gridheight - 10 })
  252. .end()
  253. .find(".luckysheet-freezebar-vertical-drop")
  254. .css({ "height": gridheight - 10 });
  255. luckysheetFreezen.createAssistCanvas();
  256. }
  257. /**
  258. *
  259. *
  260. * Toolbar judgment rules: First set the display and hide of all tool buttons according to showtoolbar, and then override the judgment of showtoolbar according to showtoolbarConfig rules
  261. *
  262. * The width value of each button in the statistics toolbar is used to calculate which needs to be placed in more buttons
  263. */
  264. export function menuToolBarWidth() {
  265. const showtoolbar = luckysheetConfigsetting.showtoolbar;
  266. const showtoolbarConfig = luckysheetConfigsetting.showtoolbarConfig;
  267. const toobarWidths = Store.toobarObject.toobarWidths = [];
  268. const toobarElements = Store.toobarObject.toobarElements = [];
  269. const toolbarConfig = Store.toobarObject.toolbarConfig = buildBoolBarConfig();
  270. /**
  271. * 基于 showtoolbarConfig 配置 动态生成 toolbarConfig
  272. * @returns {object}
  273. * @input showtoolbarConfig = ['undo', 'redo', '|' , 'font' , 'moreFormats', '|']
  274. * {
  275. * undo: {ele: '#luckysheet-icon-undo', index: 0},
  276. * redo: {ele: ['#luckysheet-icon-redo', '#luckysheet-separator-redo'], index: 1},
  277. * undo: {ele: '#luckysheet-icon-font', index: 2},
  278. * moreFormats: {ele: ['#luckysheet-icon-fmt-other', '#luckysheet-separator-more-formats'], index: 3},
  279. * }
  280. */
  281. function buildBoolBarConfig() {
  282. let obj = {};
  283. function array2Config(arr) {
  284. const obj = {};
  285. let current,next;
  286. let index = 0;
  287. for (let i = 0; i<arr.length; i++) {
  288. current = arr[i];
  289. next = arr[i + 1];
  290. if (current !== '|') {
  291. obj[current] = {
  292. ele: toolbarIdMap[current],
  293. index: index++
  294. }
  295. }
  296. if (next === '|') {
  297. if (getObjType(obj[current].ele) === 'array') {
  298. obj[current].ele.push(`#toolbar-separator-${camel2split(current)}`);
  299. } else {
  300. obj[current].ele = [obj[current].ele, `#toolbar-separator-${camel2split(current)}`];
  301. }
  302. }
  303. }
  304. return obj;
  305. }
  306. // 数组形式直接生成
  307. if (getObjType(showtoolbarConfig) === 'array') {
  308. // show 为 false
  309. if (!showtoolbar) {
  310. return obj;
  311. }
  312. return array2Config(showtoolbarConfig);
  313. }
  314. // 否则为全部中从记录中挑选显示或隐藏
  315. const config = defaultToolbar.reduce(function(total, curr) {
  316. if (curr !== '|') {
  317. total[curr] = true;
  318. }
  319. return total;
  320. }, {});
  321. if (!showtoolbar) {
  322. for (let s in config) {
  323. config[s] = false;
  324. }
  325. }
  326. if (JSON.stringify(showtoolbarConfig) !== '{}') {
  327. if(showtoolbarConfig.hasOwnProperty('undoRedo')){
  328. config.undo = config.redo = showtoolbarConfig.undoRedo;
  329. }
  330. Object.assign(config, showtoolbarConfig);
  331. let current,next;
  332. let index = 0;
  333. for (let i = 0; i<defaultToolbar.length; i++) {
  334. current = defaultToolbar[i];
  335. next = defaultToolbar[i + 1];
  336. if (config[current] === false) {
  337. continue;
  338. }
  339. if (current !== '|' && config[current]) {
  340. obj[current] = {
  341. ele: toolbarIdMap[current],
  342. index: index++
  343. }
  344. }
  345. if (next === '|') {
  346. if (getObjType(obj[current].ele) === 'array') {
  347. obj[current].ele.push(`#toolbar-separator-${camel2split(current)}`);
  348. } else {
  349. obj[current].ele = [obj[current].ele, `#toolbar-separator-${camel2split(current)}`];
  350. }
  351. }
  352. }
  353. } else {
  354. obj = showtoolbar ? array2Config(defaultToolbar) : {};
  355. }
  356. return obj;
  357. }
  358. for (let s in toolbarConfig){
  359. if (Object.prototype.hasOwnProperty.call(toolbarConfig, s)) {
  360. toobarElements.push($.extend(true,{},toolbarConfig[s]));
  361. }
  362. }
  363. toobarElements.sort(sortToolbar);
  364. function sortToolbar(a,b) {
  365. if(a.index > b.index){
  366. return 1;
  367. }else{
  368. return -1;
  369. }
  370. }
  371. toobarElements.forEach((curr,index,arr)=>{
  372. arr[index] = curr.ele;
  373. if(index !== toobarElements.length - 1){
  374. if(curr.ele instanceof Array){
  375. toobarWidths.push($(curr.ele[0]).offset().left);
  376. }else{
  377. toobarWidths.push($(curr.ele).offset().left);
  378. }
  379. }else{
  380. if(curr.ele instanceof Array){
  381. toobarWidths.push($(curr.ele[0]).offset().left);
  382. toobarWidths.push($(curr.ele[0]).offset().left + $(curr.ele[0]).outerWidth() + 5);
  383. }else{
  384. toobarWidths.push($(curr.ele).offset().left);
  385. toobarWidths.push($(curr.ele).offset().left + $(curr.ele).outerWidth() + 5);
  386. }
  387. }
  388. });
  389. //If the container does not occupy the full screen, we need to subtract the left margin
  390. const containerLeft = $('#' + Store.container).offset().left;
  391. toobarWidths.forEach((item,i)=>{
  392. toobarWidths[i] -= containerLeft;
  393. })
  394. }
  395. /**
  396. *Custom configuration bottom sheet button
  397. */
  398. function customSheetbarConfig() {
  399. if(!luckysheetConfigsetting.initShowsheetbarConfig){
  400. luckysheetConfigsetting.initShowsheetbarConfig = true;
  401. const config = {
  402. add: true, //Add worksheet
  403. menu: true, //Worksheet management menu
  404. sheet: true //Worksheet display
  405. }
  406. if(!luckysheetConfigsetting.showsheetbar){
  407. for(let s in config){
  408. config[s] = false;
  409. }
  410. }
  411. // showsheetbarConfig determines the final result
  412. if(JSON.stringify(luckysheetConfigsetting.showsheetbarConfig) !== '{}'){
  413. Object.assign(config,luckysheetConfigsetting.showsheetbarConfig);
  414. }
  415. luckysheetConfigsetting.showsheetbarConfig = config;
  416. }
  417. const config = luckysheetConfigsetting.showsheetbarConfig;
  418. let isHide = 0;
  419. for (let s in config) {
  420. if(!config[s]){
  421. switch (s) {
  422. case 'add':
  423. $('#luckysheet-sheets-add').hide();
  424. isHide++;
  425. break;
  426. case 'menu':
  427. $('#luckysheet-sheets-m').hide();
  428. isHide++;
  429. break;
  430. case 'sheet':
  431. $('#luckysheet-sheet-container').hide();
  432. $('#luckysheet-sheets-leftscroll').hide();
  433. $('#luckysheet-sheets-rightscroll').hide();
  434. isHide++;
  435. break;
  436. default:
  437. break;
  438. }
  439. }
  440. }
  441. if (isHide === 3) {
  442. $("#" + Store.container).find("#luckysheet-sheet-area").hide();
  443. Store.sheetBarHeight = 0;
  444. }
  445. else {
  446. $("#" + Store.container).find("#luckysheet-sheet-area").show();
  447. Store.sheetBarHeight = 31;
  448. }
  449. }
  450. /**
  451. * Customize the bottom count bar
  452. */
  453. function customStatisticBarConfig() {
  454. if(!luckysheetConfigsetting.initStatisticBarConfig){
  455. luckysheetConfigsetting.initStatisticBarConfig = true;
  456. const config = {
  457. count: true, // Count bar
  458. view: true, // print view
  459. zoom: true // Zoom
  460. }
  461. if(!luckysheetConfigsetting.showstatisticBar){
  462. for(let s in config){
  463. config[s] = false;
  464. }
  465. }
  466. // showstatisticBarConfig determines the final result
  467. if(JSON.stringify(luckysheetConfigsetting.showstatisticBarConfig) !== '{}'){
  468. Object.assign(config,luckysheetConfigsetting.showstatisticBarConfig);
  469. }
  470. luckysheetConfigsetting.showstatisticBarConfig = config;
  471. }
  472. const config = luckysheetConfigsetting.showstatisticBarConfig;
  473. let isHide = 0;
  474. for (let s in config) {
  475. if(!config[s]){
  476. switch (s) {
  477. case 'count':
  478. $('#luckysheet-sta-content').hide();
  479. isHide++;
  480. break;
  481. case 'view':
  482. $('.luckysheet-print-viewList').hide();
  483. isHide++;
  484. break;
  485. case 'zoom':
  486. $('#luckysheet-zoom-content').hide();
  487. isHide++;
  488. break;
  489. default:
  490. break;
  491. }
  492. }
  493. }
  494. if (isHide === 3) {
  495. $("#" + Store.container).find(".luckysheet-stat-area").hide();
  496. Store.statisticBarHeight = 0;
  497. }
  498. else {
  499. $("#" + Store.container).find(".luckysheet-stat-area").show();
  500. Store.statisticBarHeight = 23;
  501. }
  502. }