[DE] Added methods for table of content.
This commit is contained in:
parent
851bd976fe
commit
909e73270a
|
@ -50,6 +50,7 @@ define([
|
||||||
return {
|
return {
|
||||||
id: Common.UI.getId(),
|
id: Common.UI.getId(),
|
||||||
name: '',
|
name: '',
|
||||||
|
isNotHeader: false,
|
||||||
hasSubItems: false,
|
hasSubItems: false,
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
.tree-item {
|
.tree-item {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-height: 32px;
|
||||||
padding: 0px 0 0 26px;
|
padding: 0px 0 0 26px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ define([
|
||||||
setApi: function(api) {
|
setApi: function(api) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.api.asc_registerCallback('asc_onDocumentOutlineUpdate', _.bind(this.updateNavigation, this));
|
this.api.asc_registerCallback('asc_onDocumentOutlineUpdate', _.bind(this.updateNavigation, this));
|
||||||
|
this.api.asc_registerCallback('asc_onDocumentOutlineCurrentPosition', _.bind(this.onChangeOutlinePosition, this));
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -111,11 +112,19 @@ define([
|
||||||
index: i
|
index: i
|
||||||
}));
|
}));
|
||||||
prev_level = level;
|
prev_level = level;
|
||||||
|
}
|
||||||
|
if (count>0 && this._navigationObject.isFirstItemNotHeader()) {
|
||||||
|
arr[0].set('hasSubItems', false);
|
||||||
|
arr[0].set('isNotHeader', true);
|
||||||
|
arr[0].set('tip', this.txtGotoBeginning);
|
||||||
}
|
}
|
||||||
this.getApplication().getCollection('Navigation').reset(arr);
|
this.getApplication().getCollection('Navigation').reset(arr);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onChangeOutlinePosition: function(index) {
|
||||||
|
this.panelNavigation.viewNavigationList.selectByIndex(index);
|
||||||
|
},
|
||||||
|
|
||||||
onItemContextMenu: function(picker, item, record, e){
|
onItemContextMenu: function(picker, item, record, e){
|
||||||
var showPoint;
|
var showPoint;
|
||||||
var menu = this.panelNavigation.navigationMenu;
|
var menu = this.panelNavigation.navigationMenu;
|
||||||
|
@ -127,11 +136,11 @@ define([
|
||||||
top = e.clientY*Common.Utils.zoom();
|
top = e.clientY*Common.Utils.zoom();
|
||||||
showPoint = [e.clientX*Common.Utils.zoom() + 5, top - parentOffset.top + 5];
|
showPoint = [e.clientX*Common.Utils.zoom() + 5, top - parentOffset.top + 5];
|
||||||
|
|
||||||
if (record != undefined) {
|
var isNotHeader = record.get('isNotHeader');
|
||||||
//itemMenu
|
menu.items[0].setDisabled(isNotHeader);
|
||||||
// menu.items[0].setVisible(true);
|
menu.items[1].setDisabled(isNotHeader);
|
||||||
} else {
|
menu.items[3].setDisabled(isNotHeader);
|
||||||
}
|
menu.items[7].setDisabled(isNotHeader);
|
||||||
|
|
||||||
if (showPoint != undefined) {
|
if (showPoint != undefined) {
|
||||||
var menuContainer = this.panelNavigation.$el.find('#menu-navigation-container');
|
var menuContainer = this.panelNavigation.$el.find('#menu-navigation-container');
|
||||||
|
@ -143,7 +152,7 @@ define([
|
||||||
menu.render(menuContainer);
|
menu.render(menuContainer);
|
||||||
menu.cmpEl.attr({tabindex: "-1"});
|
menu.cmpEl.attr({tabindex: "-1"});
|
||||||
}
|
}
|
||||||
|
menu.cmpEl.attr('data-value', record.get('index'));
|
||||||
menuContainer.css({
|
menuContainer.css({
|
||||||
left: showPoint[0],
|
left: showPoint[0],
|
||||||
top: showPoint[1]
|
top: showPoint[1]
|
||||||
|
@ -154,24 +163,26 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onSelectItem: function(picker, item, record, e){
|
onSelectItem: function(picker, item, record, e){
|
||||||
// this.api.asc_gotoHeader();
|
if (!this._navigationObject) return;
|
||||||
|
this._navigationObject.goto(record.get('index'));
|
||||||
},
|
},
|
||||||
|
|
||||||
onMenuItemClick: function (menu, item) {
|
onMenuItemClick: function (menu, item) {
|
||||||
|
if (!this._navigationObject) return;
|
||||||
|
|
||||||
|
var index = parseInt(menu.cmpEl.attr('data-value'));
|
||||||
if (item.value == 'promote') {
|
if (item.value == 'promote') {
|
||||||
|
this._navigationObject.promote(index);
|
||||||
} else if (item.value == 'promote') {
|
|
||||||
|
|
||||||
} else if (item.value == 'indent') {
|
} else if (item.value == 'indent') {
|
||||||
|
this._navigationObject.demote(index);
|
||||||
} else if (item.value == 'before') {
|
} else if (item.value == 'before') {
|
||||||
|
this._navigationObject.insertHeader(index, true);
|
||||||
} else if (item.value == 'after') {
|
} else if (item.value == 'after') {
|
||||||
|
this._navigationObject.insertHeader(index, false);
|
||||||
} else if (item.value == 'new') {
|
} else if (item.value == 'new') {
|
||||||
|
this._navigationObject.insertSubHeader(index);
|
||||||
} else if (item.value == 'select') {
|
} else if (item.value == 'select') {
|
||||||
|
this._navigationObject.selectContent(index);
|
||||||
} else if (item.value == 'expand') {
|
} else if (item.value == 'expand') {
|
||||||
this.panelNavigation.viewNavigationList.expandAll();
|
this.panelNavigation.viewNavigationList.expandAll();
|
||||||
} else if (item.value == 'collapse') {
|
} else if (item.value == 'collapse') {
|
||||||
|
@ -181,7 +192,9 @@ define([
|
||||||
|
|
||||||
onMenuLevelsItemClick: function (menu, item) {
|
onMenuLevelsItemClick: function (menu, item) {
|
||||||
this.panelNavigation.viewNavigationList.expandToLevel(item.value-1);
|
this.panelNavigation.viewNavigationList.expandToLevel(item.value-1);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
txtGotoBeginning: 'Go to the beginning of the document'
|
||||||
|
|
||||||
}, DE.Controllers.Navigation || {}));
|
}, DE.Controllers.Navigation || {}));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue