[PE] Refactoring loading slide layouts
This commit is contained in:
parent
abe915fca3
commit
c022b065a0
|
@ -125,6 +125,7 @@ define([
|
||||||
'insert:textart' : this.onInsertTextart.bind(this),
|
'insert:textart' : this.onInsertTextart.bind(this),
|
||||||
'insert:shape' : this.onInsertShape.bind(this),
|
'insert:shape' : this.onInsertShape.bind(this),
|
||||||
'add:slide' : this.onAddSlide.bind(this),
|
'add:slide' : this.onAddSlide.bind(this),
|
||||||
|
'change:slide' : this.onChangeSlide.bind(this),
|
||||||
'change:compact' : this.onClickChangeCompact
|
'change:compact' : this.onClickChangeCompact
|
||||||
},
|
},
|
||||||
'FileMenu': {
|
'FileMenu': {
|
||||||
|
@ -255,8 +256,6 @@ define([
|
||||||
* UI Events
|
* UI Events
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (toolbar.mnuChangeSlidePicker)
|
|
||||||
toolbar.mnuChangeSlidePicker.on('item:click', _.bind(this.onChangeSlide, this));
|
|
||||||
toolbar.btnPreview.on('click', _.bind(this.onPreviewBtnClick, this));
|
toolbar.btnPreview.on('click', _.bind(this.onPreviewBtnClick, this));
|
||||||
toolbar.btnPreview.menu.on('item:click', _.bind(this.onPreviewItemClick, this));
|
toolbar.btnPreview.menu.on('item:click', _.bind(this.onPreviewItemClick, this));
|
||||||
toolbar.btnPrint.on('click', _.bind(this.onPrint, this));
|
toolbar.btnPrint.on('click', _.bind(this.onPrint, this));
|
||||||
|
@ -722,8 +721,12 @@ define([
|
||||||
this.toolbar.lockToolbar(PE.enumLock.inEquation, in_equation, {array: [me.toolbar.btnSuperscript, me.toolbar.btnSubscript]});
|
this.toolbar.lockToolbar(PE.enumLock.inEquation, in_equation, {array: [me.toolbar.btnSuperscript, me.toolbar.btnSubscript]});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.toolbar.mnuChangeSlidePicker)
|
if (this.toolbar.btnChangeSlide) {
|
||||||
this.toolbar.mnuChangeSlidePicker.options.layout_index = layout_index;
|
if (this.toolbar.btnChangeSlide.mnuSlidePicker)
|
||||||
|
this.toolbar.btnChangeSlide.mnuSlidePicker.options.layout_index = layout_index;
|
||||||
|
else
|
||||||
|
this.toolbar.btnChangeSlide.mnuSlidePicker = {options: {layout_index: layout_index}};
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onApiStyleChange: function(v) {
|
onApiStyleChange: function(v) {
|
||||||
|
@ -816,19 +819,17 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddSlide: function(type) {
|
onAddSlide: function(type) {
|
||||||
var me = this;
|
|
||||||
if ( this.api) {
|
if ( this.api) {
|
||||||
this.api.AddSlide(type);
|
this.api.AddSlide(type);
|
||||||
|
|
||||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
||||||
Common.component.Analytics.trackEvent('ToolBar', 'Add Slide');
|
Common.component.Analytics.trackEvent('ToolBar', 'Add Slide');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onChangeSlide: function(picker, item, record) {
|
onChangeSlide: function(type) {
|
||||||
if (this.api) {
|
if (this.api) {
|
||||||
if (record)
|
this.api.ChangeLayout(type);
|
||||||
this.api.ChangeLayout(record.get('data').idx);
|
|
||||||
|
|
||||||
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
||||||
Common.component.Analytics.trackEvent('ToolBar', 'Change Layout');
|
Common.component.Analytics.trackEvent('ToolBar', 'Change Layout');
|
||||||
|
|
|
@ -1188,46 +1188,6 @@ define([
|
||||||
maxColumns: 10
|
maxColumns: 10
|
||||||
});
|
});
|
||||||
|
|
||||||
var createDataPicker = function (btn) {
|
|
||||||
me.mnuChangeSlidePicker = new Common.UI.DataView({
|
|
||||||
el: $('#id-toolbar-menu-changeslide'),
|
|
||||||
parentMenu: me.btnChangeSlide.menu,
|
|
||||||
restoreHeight: 300,
|
|
||||||
restoreWidth: 302,
|
|
||||||
style: 'max-height: 300px;',
|
|
||||||
store: PE.getCollection('SlideLayouts'),
|
|
||||||
itemTemplate: _.template([
|
|
||||||
'<div class="layout" id="<%= id %>" style="width: <%= itemWidth %>px;">',
|
|
||||||
'<div style="background-image: url(<%= imageUrl %>); width: <%= itemWidth %>px; height: <%= itemHeight %>px;"/>',
|
|
||||||
'<div class="title"><%= title %></div> ',
|
|
||||||
'</div>'
|
|
||||||
].join(''))
|
|
||||||
});
|
|
||||||
if (me.btnChangeSlide.menu) {
|
|
||||||
me.btnChangeSlide.menu.on('show:after', function () {
|
|
||||||
me.onSlidePickerShowAfter(me.mnuChangeSlidePicker);
|
|
||||||
me.mnuChangeSlidePicker.scroller.update({alwaysVisibleY: true});
|
|
||||||
|
|
||||||
var record = me.mnuChangeSlidePicker.store.findLayoutByIndex(me.mnuChangeSlidePicker.options.layout_index);
|
|
||||||
if (record) {
|
|
||||||
me.mnuChangeSlidePicker.selectRecord(record, true);
|
|
||||||
me.mnuChangeSlidePicker.scrollToRecord(record);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
me.mnuChangeSlidePicker._needRecalcSlideLayout = true;
|
|
||||||
};
|
|
||||||
// btnChangeSlide isn't in compact toolbar mode -> may be rendered after createDelayedElements
|
|
||||||
if (this.btnChangeSlide.rendered)
|
|
||||||
createDataPicker(this.btnChangeSlide);
|
|
||||||
else
|
|
||||||
this.btnChangeSlide.on('render:after', createDataPicker);
|
|
||||||
|
|
||||||
this.listenTo(PE.getCollection('SlideLayouts'), 'reset', function () {
|
|
||||||
if (me.mnuChangeSlidePicker)
|
|
||||||
me.mnuChangeSlidePicker._needRecalcSlideLayout = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
/** coauthoring begin **/
|
/** coauthoring begin **/
|
||||||
this.showSynchTip = !Common.localStorage.getBool('pe-hide-synch');
|
this.showSynchTip = !Common.localStorage.getBool('pe-hide-synch');
|
||||||
|
|
||||||
|
@ -1421,7 +1381,6 @@ define([
|
||||||
|
|
||||||
onSlidePickerShowAfter: function (picker) {
|
onSlidePickerShowAfter: function (picker) {
|
||||||
if (!picker._needRecalcSlideLayout) return;
|
if (!picker._needRecalcSlideLayout) return;
|
||||||
|
|
||||||
if (picker.cmpEl && picker.dataViewItems.length > 0) {
|
if (picker.cmpEl && picker.dataViewItems.length > 0) {
|
||||||
var dataViewItems = picker.dataViewItems,
|
var dataViewItems = picker.dataViewItems,
|
||||||
el = $(dataViewItems[0].el),
|
el = $(dataViewItems[0].el),
|
||||||
|
@ -1522,14 +1481,14 @@ define([
|
||||||
|
|
||||||
updateAddSlideMenu: function(collection) {
|
updateAddSlideMenu: function(collection) {
|
||||||
if (collection.size()<1) return;
|
if (collection.size()<1) return;
|
||||||
|
|
||||||
var me = this;
|
var me = this;
|
||||||
me.btnsAddSlide.forEach(function (btn, index) {
|
if (!me.binding.onShowBeforeAddSlide) {
|
||||||
if ( !btn.mnuAddSlidePicker ) {
|
me.binding.onShowBeforeAddSlide = function(menu) {
|
||||||
btn.mnuAddSlidePicker = new Common.UI.DataView({
|
var change = (this.iconCls == 'btn-changeslide');
|
||||||
el: $('#id-toolbar-menu-addslide-' + index),
|
var picker = new Common.UI.DataView({
|
||||||
parentMenu: btn.menu,
|
el: $('.menu-layouts', menu.$el),
|
||||||
showLast: false,
|
parentMenu: menu,
|
||||||
|
showLast: change,
|
||||||
restoreHeight: 300,
|
restoreHeight: 300,
|
||||||
restoreWidth: 302,
|
restoreWidth: 302,
|
||||||
style: 'max-height: 300px;',
|
style: 'max-height: 300px;',
|
||||||
|
@ -1541,21 +1500,38 @@ define([
|
||||||
'</div>'
|
'</div>'
|
||||||
].join(''))
|
].join(''))
|
||||||
});
|
});
|
||||||
btn.mnuAddSlidePicker.on('item:click', function (picker, item, record, e) {
|
picker.on('item:click', function (picker, item, record, e) {
|
||||||
if (e.type !== 'click') Common.UI.Menu.Manager.hideAll();
|
if (e.type !== 'click') Common.UI.Menu.Manager.hideAll();
|
||||||
if (record)
|
if (record)
|
||||||
me.fireEvent('add:slide', [record.get('data').idx]);
|
me.fireEvent(change ? 'change:slide' : 'add:slide', [record.get('data').idx]);
|
||||||
});
|
});
|
||||||
if (btn.menu) {
|
if (menu) {
|
||||||
btn.menu.on('show:after', function () {
|
menu.on('show:after', function () {
|
||||||
me.onSlidePickerShowAfter(btn.mnuAddSlidePicker);
|
me.onSlidePickerShowAfter(picker);
|
||||||
btn.mnuAddSlidePicker.scroller.update({alwaysVisibleY: true});
|
picker.scroller.update({alwaysVisibleY: true});
|
||||||
btn.mnuAddSlidePicker.scroller.scrollTop(0);
|
if (change) {
|
||||||
|
var record = picker.store.findLayoutByIndex(picker.options.layout_index);
|
||||||
|
if (record) {
|
||||||
|
picker.selectRecord(record, true);
|
||||||
|
picker.scrollToRecord(record);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
picker.scroller.scrollTop(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
menu.off('show:before', me.binding.onShowBeforeAddSlide);
|
||||||
btn.mnuAddSlidePicker._needRecalcSlideLayout = true;
|
if (change && this.mnuSlidePicker)
|
||||||
});
|
picker.options.layout_index = this.mnuSlidePicker.options.layout_index;
|
||||||
|
this.mnuSlidePicker = picker;
|
||||||
|
};
|
||||||
|
me.btnsAddSlide.concat(me.btnChangeSlide).forEach(function (btn, index) {
|
||||||
|
btn.menu.on('show:before', me.binding.onShowBeforeAddSlide, btn);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
me.btnsAddSlide.concat(me.btnChangeSlide).forEach(function (btn, index) {
|
||||||
|
btn.mnuSlidePicker && (btn.mnuSlidePicker._needRecalcSlideLayout = true);
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
textBold: 'Bold',
|
textBold: 'Bold',
|
||||||
|
|
Loading…
Reference in a new issue