Browse Source

feat(config): sheetbar

Support config:showsheetbarConfig
master
mengshukeji 5 years ago
parent
commit
3555746f4c
  1. 32
      docs/guide/config.md
  2. 28
      docs/zh/guide/config.md
  3. 95
      src/controllers/resize.js
  4. 6
      src/controllers/sheetmanage.js
  5. 1
      src/core.js
  6. 1
      src/index.html

32
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

28
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

95
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();
@ -566,3 +556,70 @@ 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;
}
}

6
src/controllers/sheetmanage.js

@ -391,9 +391,12 @@ const sheetmanage = {
$c.scrollLeft(scrollLeftpx - 10);
if (c_width >= winW * 0.7) {
if(luckysheetConfigsetting.showsheetbarConfig.sheet){
$("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block");
$("#luckysheet-sheet-container .docs-sheet-fade-left").show();
}
}
}, 1)
},
copySheet: function(copyindex, e) {
@ -1414,9 +1417,12 @@ const sheetmanage = {
});
if (c_width >= containerW) {
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");
$("#luckysheet-sheet-container .docs-sheet-fade-left").hide();

1
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;

1
src/index.html

@ -1793,7 +1793,6 @@
"scrollTop": 0
}]*/
})
})
</script>

Loading…
Cancel
Save