Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
feat(config): sheetbar
Browse files Browse the repository at this point in the history
Support config:showsheetbarConfig
  • Loading branch information
mengshukeji committed Oct 29, 2020
1 parent 0909f5e commit 3555746
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 33 deletions.
32 changes: 27 additions & 5 deletions docs/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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,
Expand All @@ -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
{
Expand All @@ -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
Expand Down
28 changes: 25 additions & 3 deletions docs/zh/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,9 @@ Luckysheet开放了更细致的自定义配置选项,分别有
------------
### showsheetbarConfig

[todo]

- 类型:Object
- 默认值:{}
- 作用:自定义配置底部sheet页按钮
- 作用:自定义配置底部sheet页按钮,可以与showsheetbar配合使用,`showsheetbarConfig`拥有更高的优先级。
- 格式:
```json
{
Expand All @@ -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
Expand Down
97 changes: 77 additions & 20 deletions src/controllers/resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
}
14 changes: 10 additions & 4 deletions src/controllers/sheetmanage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,6 @@
"scrollTop": 0
}]*/
})

})
</script>

Expand Down

0 comments on commit 3555746

Please sign in to comment.