diff --git a/docs/guide/config.md b/docs/guide/config.md index b3eaed789..9c27ec4e1 100644 --- a/docs/guide/config.md +++ b/docs/guide/config.md @@ -188,7 +188,7 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect - Type: Object - Default: {} -- Usage: Custom configuration toolbar,can be used in conjunction with showtoolbar, `showtoolbarConfig` has a higher priority. +- Usage: Custom configuration toolbar,can be used in conjunction with `showtoolbar`, `showtoolbarConfig` has a higher priority. - Format: ```json { @@ -247,7 +247,7 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect ```js //options { - showtoolbar: true, // 默认就是true,可以不设置 + showtoolbar: true, // The default is true, you can leave it unset showtoolbarConfig:{ image: false, print: false, @@ -270,11 +270,9 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect ------------ ### showsheetbarConfig -[todo] - - Type: Object - Default: {} -- Usage: Custom configuration bottom sheet button +- Usage: Custom configuration bottom sheet button, can be used in conjunction with `showsheetbar`, `showsheetbarConfig` has a higher priority. - Format: ```json { @@ -283,6 +281,30 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect sheet: false //Worksheet display } ``` +- Example: + - Only display the `Add worksheet` button: + + ```js + //options + { + showsheetbar: false, + showsheetbarConfig:{ + add: true, + } + } + ``` + - Only hide the `Add worksheet` and `Worksheet management menu` buttons: + + ```js + //options + { + showsheetbar: true, // The default is true, you can leave it unset + showsheetbarConfig:{ + add: false, + menu: false, + } + } + ``` ------------ ### showstatisticBar diff --git a/docs/zh/guide/config.md b/docs/zh/guide/config.md index f7fb59d6c..1f0161ea7 100644 --- a/docs/zh/guide/config.md +++ b/docs/zh/guide/config.md @@ -358,11 +358,9 @@ Luckysheet开放了更细致的自定义配置选项,分别有 ------------ ### showsheetbarConfig -[todo] - - 类型:Object - 默认值:{} -- 作用:自定义配置底部sheet页按钮 +- 作用:自定义配置底部sheet页按钮,可以与showsheetbar配合使用,`showsheetbarConfig`拥有更高的优先级。 - 格式: ```json { @@ -371,6 +369,30 @@ Luckysheet开放了更细致的自定义配置选项,分别有 sheet: false //sheet页显示 } ``` +- 示例: + - 仅显示新增sheet按钮: + + ```js + //options + { + showsheetbar: false, + showsheetbarConfig:{ + add: true, + } + } + ``` + - 仅隐藏新增sheet和管理按钮: + + ```js + //options + { + showsheetbar: true, // 默认就是true,可以不设置 + showsheetbarConfig:{ + add: false, + menu: false, + } + } + ``` ------------ ### showstatisticBar diff --git a/src/controllers/resize.js b/src/controllers/resize.js index c96e2fb20..ca616d329 100644 --- a/src/controllers/resize.js +++ b/src/controllers/resize.js @@ -20,16 +20,6 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) { Store.infobarHeight = document.querySelector('#luckysheet_info_detail').offsetHeight; } - // - // if (!luckysheetConfigsetting.showtoolbar) { - // $("#" + Store.container).find(".luckysheet-wa-editor, .luckysheet-share-logo").hide(); - // Store.toolbarHeight = 0; - // } - // else { - // $("#" + Store.container).find(".luckysheet-wa-editor, .luckysheet-share-logo").show(); - // // Store.toolbarHeight = 72; - // Store.toolbarHeight = document.querySelector('#' + Store.container +' .luckysheet-wa-editor').offsetHeight; - // } if (Store.toobarObject.toobarElements.length === 0) { $("#" + Store.container).find(".luckysheet-wa-editor").hide(); Store.toolbarHeight = 0; @@ -40,17 +30,17 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) { Store.toolbarHeight = document.querySelector('#' + Store.container +' .luckysheet-wa-editor').offsetHeight; } - // customToolbarConfig(luckysheetConfigsetting.showtoolbar,luckysheetConfigsetting.showtoolbarConfig); - + // if (!luckysheetConfigsetting.showsheetbar) { + // $("#" + Store.container).find("#luckysheet-sheet-area").hide(); + // Store.sheetBarHeight = 0; + // } + // else { + // $("#" + Store.container).find("#luckysheet-sheet-area").show(); + // Store.sheetBarHeight = 31; + // } - if (!luckysheetConfigsetting.showsheetbar) { - $("#" + Store.container).find("#luckysheet-sheet-area").hide(); - Store.sheetBarHeight = 0; - } - else { - $("#" + Store.container).find("#luckysheet-sheet-area").show(); - Store.sheetBarHeight = 31; - } + + customSheetbarConfig(); if (!luckysheetConfigsetting.showstatisticBar) { $("#" + Store.container).find(".luckysheet-stat-area").hide(); @@ -565,4 +555,71 @@ export function menuToolBarWidth() { }); +} + +function customSheetbarConfig() { + + if(!luckysheetConfigsetting.initShowsheetbarConfig){ + + luckysheetConfigsetting.initShowsheetbarConfig = true; + + const config = { + add: true, //新增sheet + menu: true, //sheet管理菜单 + sheet: true //sheet页显示 + } + + if(!luckysheetConfigsetting.showsheetbar){ + for(let s in config){ + config[s] = false; + } + } + + // showsheetbarConfig determines the final result + if(JSON.stringify(luckysheetConfigsetting.showsheetbarConfig) !== '{}'){ + Object.assign(config,luckysheetConfigsetting.showsheetbarConfig); + } + + luckysheetConfigsetting.showsheetbarConfig = config; + + } + + const config = luckysheetConfigsetting.showsheetbarConfig; + + let isHide = 0; + + for (let s in config) { + if(!config[s]){ + switch (s) { + case 'add': + $('#luckysheet-sheets-add').hide(); + isHide++; + break; + + case 'menu': + $('#luckysheet-sheets-m').hide(); + isHide++; + break; + + case 'sheet': + $('#luckysheet-sheet-container').hide(); + $('#luckysheet-sheets-leftscroll').hide(); + $('#luckysheet-sheets-rightscroll').hide(); + isHide++; + break; + + default: + break; + } + } + } + + if (isHide === 3) { + $("#" + Store.container).find("#luckysheet-sheet-area").hide(); + Store.sheetBarHeight = 0; + } + else { + $("#" + Store.container).find("#luckysheet-sheet-area").show(); + Store.sheetBarHeight = 31; + } } \ No newline at end of file diff --git a/src/controllers/sheetmanage.js b/src/controllers/sheetmanage.js index 36cd089a7..0cb4e0b4d 100644 --- a/src/controllers/sheetmanage.js +++ b/src/controllers/sheetmanage.js @@ -391,8 +391,11 @@ const sheetmanage = { $c.scrollLeft(scrollLeftpx - 10); if (c_width >= winW * 0.7) { - $("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block"); - $("#luckysheet-sheet-container .docs-sheet-fade-left").show(); + if(luckysheetConfigsetting.showsheetbarConfig.sheet){ + $("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block"); + $("#luckysheet-sheet-container .docs-sheet-fade-left").show(); + } + } }, 1) }, @@ -1414,8 +1417,11 @@ const sheetmanage = { }); if (c_width >= containerW) { - $("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block"); - $("#luckysheet-sheet-container .docs-sheet-fade-left").show(); + if(luckysheetConfigsetting.showsheetbarConfig.sheet){ + $("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block"); + $("#luckysheet-sheet-container .docs-sheet-fade-left").show(); + } + } else{ $("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "none"); diff --git a/src/core.js b/src/core.js index c98d563cd..36883afa8 100644 --- a/src/core.js +++ b/src/core.js @@ -89,6 +89,7 @@ luckysheet.create = function (setting) { luckysheetConfigsetting.showtoolbarConfig = extendsetting.showtoolbarConfig; luckysheetConfigsetting.showinfobar = extendsetting.showinfobar; luckysheetConfigsetting.showsheetbar = extendsetting.showsheetbar; + luckysheetConfigsetting.showsheetbarConfig = extendsetting.showsheetbarConfig; luckysheetConfigsetting.showstatisticBar = extendsetting.showstatisticBar; luckysheetConfigsetting.pointEdit = extendsetting.pointEdit; luckysheetConfigsetting.pointEditUpdate = extendsetting.pointEditUpdate; diff --git a/src/index.html b/src/index.html index eda4e4883..369b00c8a 100644 --- a/src/index.html +++ b/src/index.html @@ -1793,7 +1793,6 @@ "scrollTop": 0 }]*/ }) - }) </script>