Commit af7f2254 authored by Julia Radzhabova's avatar Julia Radzhabova Committed by GitHub

Merge pull request #15 from ONLYOFFICE/refactor

Refactor
parents de773f86 d38c8714
...@@ -218,7 +218,7 @@ define([ ...@@ -218,7 +218,7 @@ define([
style : me.style style : me.style
})); }));
if (me.menu && _.isFunction(me.menu.render)) if (me.menu && _.isObject(me.menu) && _.isFunction(me.menu.render))
me.menu.render(me.cmpEl); me.menu.render(me.cmpEl);
parentEl.html(me.cmpEl); parentEl.html(me.cmpEl);
...@@ -379,7 +379,7 @@ define([ ...@@ -379,7 +379,7 @@ define([
} }
if (me.disabled) { if (me.disabled) {
me.setDisabled(me.disabled); me.setDisabled(!(me.disabled=false));
} }
me.trigger('render:after', me); me.trigger('render:after', me);
...@@ -414,7 +414,7 @@ define([ ...@@ -414,7 +414,7 @@ define([
}, },
setDisabled: function(disabled) { setDisabled: function(disabled) {
if (this.rendered) { if (this.rendered && this.disabled != disabled) {
var el = this.cmpEl, var el = this.cmpEl,
isGroup = el.hasClass('btn-group'); isGroup = el.hasClass('btn-group');
...@@ -489,6 +489,13 @@ define([ ...@@ -489,6 +489,13 @@ define([
} }
} }
} }
},
setMenu: function (m) {
if (m && _.isObject(m) && _.isFunction(m.render)){
this.menu = m;
this.menu.render(this.cmpEl);
}
} }
}); });
}); });
......
...@@ -188,13 +188,6 @@ define([ ...@@ -188,13 +188,6 @@ define([
Common.NotificationCenter.on('menumanager:hideall', _.bind(me.closeMenu, me)); Common.NotificationCenter.on('menumanager:hideall', _.bind(me.closeMenu, me));
this.scroller = new Common.UI.Scroller({
el: $('.dropdown-menu', me.cmpEl),
minScrollbarLength : 40,
scrollYMarginOffset: 30,
includePadding : true
});
// set default selection // set default selection
this.setDefaultSelection(); this.setDefaultSelection();
...@@ -232,6 +225,15 @@ define([ ...@@ -232,6 +225,15 @@ define([
}, },
onBeforeShowMenu: function(e) { onBeforeShowMenu: function(e) {
if ( !this.scroller ) {
this.scroller = new Common.UI.Scroller(_.extend({
el: $('.dropdown-menu', this.cmpEl),
minScrollbarLength: 40,
scrollYMarginOffset: 30,
includePadding: true
}, this.options.scroller));
}
Common.NotificationCenter.trigger('menu:show'); Common.NotificationCenter.trigger('menu:show');
this.trigger('show:before', this, e); this.trigger('show:before', this, e);
if (this.options.hint) { if (this.options.hint) {
...@@ -525,12 +527,12 @@ define([ ...@@ -525,12 +527,12 @@ define([
this.scroller.destroy(); this.scroller.destroy();
delete this.scroller; delete this.scroller;
} }
this.scroller = new Common.UI.Scroller({ this.scroller = new Common.UI.Scroller(_.extend({
el: $('.dropdown-menu', this.cmpEl), el: $('.dropdown-menu', this.cmpEl),
minScrollbarLength : 40, minScrollbarLength : 40,
scrollYMarginOffset: 30, scrollYMarginOffset: 30,
includePadding : true includePadding : true
}); }, this.options.scroller));
} }
} }
})()); })());
......
...@@ -85,11 +85,14 @@ define([ ...@@ -85,11 +85,14 @@ define([
initialize : function(options) { initialize : function(options) {
Common.UI.ComboBox.prototype.initialize.call(this, _.extend(options, { Common.UI.ComboBox.prototype.initialize.call(this, _.extend(options, {
displayField: 'name' displayField: 'name',
scroller: {
alwaysVisibleY: true,
onChange: this.updateVisibleFontsTiles.bind(this)
}
})); }));
this.recent = _.isNumber(options.recent) ? options.recent : 3; this.recent = _.isNumber(options.recent) ? options.recent : 3;
this.bindUpdateVisibleFontsTiles = _.bind(this.updateVisibleFontsTiles, this);
Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this)); Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this));
Common.NotificationCenter.on('fonts:load', _.bind(this.fillFonts, this)); Common.NotificationCenter.on('fonts:load', _.bind(this.fillFonts, this));
...@@ -109,8 +112,6 @@ define([ ...@@ -109,8 +112,6 @@ define([
this._input.on('keyup', _.bind(this.onInputKeyUp, this)); this._input.on('keyup', _.bind(this.onInputKeyUp, this));
this._input.on('keydown', _.bind(this.onInputKeyDown, this)); this._input.on('keydown', _.bind(this.onInputKeyDown, this));
this.scroller.update({alwaysVisibleY: true, onChange:this.bindUpdateVisibleFontsTiles});
return this; return this;
}, },
......
...@@ -851,7 +851,7 @@ define([ ...@@ -851,7 +851,7 @@ define([
if (window.styles_loaded) { if (window.styles_loaded) {
clearInterval(timer_sl); clearInterval(timer_sl);
toolbarController.getView('Toolbar').createDelayedElements(); toolbarController.createDelayedElements();
documentHolderController.getView('DocumentHolder').createDelayedElements(); documentHolderController.getView('DocumentHolder').createDelayedElements();
me.loadLanguages(); me.loadLanguages();
......
...@@ -166,7 +166,7 @@ define([ ...@@ -166,7 +166,7 @@ define([
// Create toolbar view // Create toolbar view
this.toolbar = this.createView('Toolbar'); this.toolbar = this.createView('Toolbar');
this.toolbar.on('render:after', _.bind(this.onToolbarAfterRender, this)); // this.toolbar.on('render:after', _.bind(this.onToolbarAfterRender, this));
}, },
onToolbarAfterRender: function(toolbar) { onToolbarAfterRender: function(toolbar) {
...@@ -2627,6 +2627,11 @@ define([ ...@@ -2627,6 +2627,11 @@ define([
me._mailMergeDlg.show(); me._mailMergeDlg.show();
}, },
createDelayedElements: function() {
this.toolbar.createDelayedElements();
this.onToolbarAfterRender(this.toolbar);
},
textEmptyImgUrl : 'You need to specify image URL.', textEmptyImgUrl : 'You need to specify image URL.',
textWarning : 'Warning', textWarning : 'Warning',
textFontSizeErr : 'The entered value is incorrect.<br>Please enter a numeric value between 1 and 100', textFontSizeErr : 'The entered value is incorrect.<br>Please enter a numeric value between 1 and 100',
......
...@@ -64,7 +64,6 @@ define([ ...@@ -64,7 +64,6 @@ define([
}, },
initialize: function () { initialize: function () {
var me = this;
this._initSettings = true; this._initSettings = true;
this._state = { this._state = {
...@@ -80,67 +79,6 @@ define([ ...@@ -80,67 +79,6 @@ define([
this._locked = false; this._locked = false;
this.render(); this.render();
var _arrPosition = [
[c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_LEFT, 'icon-right-panel btn-colontitul-tl', 'headerfooter-button-top-left', this.textTopLeft],
[c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_CENTER, 'icon-right-panel btn-colontitul-tc', 'headerfooter-button-top-center', this.textTopCenter],
[c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_RIGHT, 'icon-right-panel btn-colontitul-tr', 'headerfooter-button-top-right', this.textTopRight],
[c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_LEFT, 'icon-right-panel btn-colontitul-bl', 'headerfooter-button-bottom-left', this.textBottomLeft],
[c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_CENTER, 'icon-right-panel btn-colontitul-bc', 'headerfooter-button-bottom-center', this.textBottomCenter],
[c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_RIGHT, 'icon-right-panel btn-colontitul-br', 'headerfooter-button-bottom-right', this.textBottomRight]
];
this._btnsPosition = [];
_.each(_arrPosition, function(item, index, list){
var _btn = new Common.UI.Button({
cls: 'btn-options huge',
iconCls: item[2],
posWhere:item[0],
posAlign:item[1],
hint: item[4]
});
_btn.render( $('#'+item[3])) ;
_btn.on('click', _.bind(this.onBtnPositionClick, this));
this._btnsPosition.push( _btn );
this.lockedControls.push(_btn);
}, this);
this.numPosition = new Common.UI.MetricSpinner({
el: $('#headerfooter-spin-position'),
step: .1,
width: 85,
value: '1.25 cm',
defaultUnit : "cm",
maxValue: 55.88,
minValue: 0
});
this.spinners.push(this.numPosition);
this.lockedControls.push(this.numPosition);
this.lblPosition = $(this.el).find('#headerfooter-label-position');
this.chDiffFirst = new Common.UI.CheckBox({
el: $('#headerfooter-check-diff-first'),
labelText: this.textDiffFirst
});
this.lockedControls.push(this.chDiffFirst);
this.chDiffOdd = new Common.UI.CheckBox({
el: $('#headerfooter-check-diff-odd'),
labelText: this.textDiffOdd
});
this.lockedControls.push(this.chDiffOdd);
this.chSameAs = new Common.UI.CheckBox({
el: $('#headerfooter-check-same-as'),
labelText: this.textSameAs
});
this.lockedControls.push(this.chSameAs);
this.numPosition.on('change', _.bind(this.onNumPositionChange, this));
this.chDiffFirst.on('change', _.bind(this.onDiffFirstChange, this));
this.chDiffOdd.on('change', _.bind(this.onDiffOddChange, this));
this.chSameAs.on('change', _.bind(this.onSameAsChange, this));
}, },
render: function () { render: function () {
...@@ -240,7 +178,71 @@ define([ ...@@ -240,7 +178,71 @@ define([
} }
}, },
createDelayedControls: function() {
var _arrPosition = [
[c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_LEFT, 'icon-right-panel btn-colontitul-tl', 'headerfooter-button-top-left', this.textTopLeft],
[c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_CENTER, 'icon-right-panel btn-colontitul-tc', 'headerfooter-button-top-center', this.textTopCenter],
[c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_RIGHT, 'icon-right-panel btn-colontitul-tr', 'headerfooter-button-top-right', this.textTopRight],
[c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_LEFT, 'icon-right-panel btn-colontitul-bl', 'headerfooter-button-bottom-left', this.textBottomLeft],
[c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_CENTER, 'icon-right-panel btn-colontitul-bc', 'headerfooter-button-bottom-center', this.textBottomCenter],
[c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_RIGHT, 'icon-right-panel btn-colontitul-br', 'headerfooter-button-bottom-right', this.textBottomRight]
];
this._btnsPosition = [];
_.each(_arrPosition, function(item, index, list){
var _btn = new Common.UI.Button({
cls: 'btn-options huge',
iconCls: item[2],
posWhere:item[0],
posAlign:item[1],
hint: item[4]
});
_btn.render( $('#'+item[3])) ;
_btn.on('click', _.bind(this.onBtnPositionClick, this));
this._btnsPosition.push( _btn );
this.lockedControls.push(_btn);
}, this);
this.numPosition = new Common.UI.MetricSpinner({
el: $('#headerfooter-spin-position'),
step: .1,
width: 85,
value: '1.25 cm',
defaultUnit : "cm",
maxValue: 55.88,
minValue: 0
});
this.spinners.push(this.numPosition);
this.lockedControls.push(this.numPosition);
this.lblPosition = $(this.el).find('#headerfooter-label-position');
this.chDiffFirst = new Common.UI.CheckBox({
el: $('#headerfooter-check-diff-first'),
labelText: this.textDiffFirst
});
this.lockedControls.push(this.chDiffFirst);
this.chDiffOdd = new Common.UI.CheckBox({
el: $('#headerfooter-check-diff-odd'),
labelText: this.textDiffOdd
});
this.lockedControls.push(this.chDiffOdd);
this.chSameAs = new Common.UI.CheckBox({
el: $('#headerfooter-check-same-as'),
labelText: this.textSameAs
});
this.lockedControls.push(this.chSameAs);
this.numPosition.on('change', _.bind(this.onNumPositionChange, this));
this.chDiffFirst.on('change', _.bind(this.onDiffFirstChange, this));
this.chDiffOdd.on('change', _.bind(this.onDiffOddChange, this));
this.chSameAs.on('change', _.bind(this.onSameAsChange, this));
},
createDelayedElements: function() { createDelayedElements: function() {
this.createDelayedControls();
this.updateMetricUnit(); this.updateMetricUnit();
}, },
...@@ -249,6 +251,8 @@ define([ ...@@ -249,6 +251,8 @@ define([
}, },
disableControls: function(disable) { disableControls: function(disable) {
if (this._initSettings) return;
if (this._state.DisabledControls!==disable) { if (this._state.DisabledControls!==disable) {
this._state.DisabledControls = disable; this._state.DisabledControls = disable;
_.each(this.lockedControls, function(item) { _.each(this.lockedControls, function(item) {
......
...@@ -64,7 +64,6 @@ define([ ...@@ -64,7 +64,6 @@ define([
}, },
initialize: function () { initialize: function () {
var me = this;
this._initSettings = true; this._initSettings = true;
this._state = { this._state = {
...@@ -84,7 +83,35 @@ define([ ...@@ -84,7 +83,35 @@ define([
this.render(); this.render();
var viewData = [ this.labelWidth = $(this.el).find('#image-label-width');
this.labelHeight = $(this.el).find('#image-label-height');
},
render: function () {
var el = $(this.el);
el.html(this.template({
scope: this
}));
},
setApi: function(api) {
this.api = api;
if (this.api)
this.api.asc_registerCallback('asc_onImgWrapStyleChanged', _.bind(this._ImgWrapStyleChanged, this));
return this;
},
updateMetricUnit: function() {
var value = Common.Utils.Metric.fnRecalcFromMM(this._state.Width);
this.labelWidth[0].innerHTML = this.textWidth + ': ' + value.toFixed(1) + ' ' + Common.Utils.Metric.getCurrentMetricName();
value = Common.Utils.Metric.fnRecalcFromMM(this._state.Height);
this.labelHeight[0].innerHTML = this.textHeight + ': ' + value.toFixed(1) + ' ' + Common.Utils.Metric.getCurrentMetricName();
},
createDelayedControls: function() {
var me = this,
viewData = [
{ offsetx: 0, data: Asc.c_oAscWrapStyle2.Inline, iconcls:'wrap-inline', tip: this.txtInline, selected: true }, { offsetx: 0, data: Asc.c_oAscWrapStyle2.Inline, iconcls:'wrap-inline', tip: this.txtInline, selected: true },
{ offsetx: 50, data: Asc.c_oAscWrapStyle2.Square, iconcls:'wrap-square', tip: this.txtSquare }, { offsetx: 50, data: Asc.c_oAscWrapStyle2.Square, iconcls:'wrap-square', tip: this.txtSquare },
{ offsetx: 100, data: Asc.c_oAscWrapStyle2.Tight, iconcls:'wrap-tight', tip: this.txtTight }, { offsetx: 100, data: Asc.c_oAscWrapStyle2.Tight, iconcls:'wrap-tight', tip: this.txtTight },
...@@ -116,9 +143,6 @@ define([ ...@@ -116,9 +143,6 @@ define([
this.mnuWrapPicker.on('item:click', _.bind(this.onSelectWrap, this, this.btnWrapType)); this.mnuWrapPicker.on('item:click', _.bind(this.onSelectWrap, this, this.btnWrapType));
this.lockedControls.push(this.btnWrapType); this.lockedControls.push(this.btnWrapType);
this.labelWidth = $(this.el).find('#image-label-width');
this.labelHeight = $(this.el).find('#image-label-height');
this.btnOriginalSize = new Common.UI.Button({ this.btnOriginalSize = new Common.UI.Button({
el: $('#image-button-original-size') el: $('#image-button-original-size')
}); });
...@@ -149,35 +173,14 @@ define([ ...@@ -149,35 +173,14 @@ define([
if (this.api) this.api.asc_pluginRun(this._originalProps.asc_getPluginGuid(), 0, this._originalProps.asc_getPluginData()); if (this.api) this.api.asc_pluginRun(this._originalProps.asc_getPluginGuid(), 0, this._originalProps.asc_getPluginData());
this.fireEvent('editcomplete', this); this.fireEvent('editcomplete', this);
}, this)); }, this));
$(this.el).on('click', '#image-advanced-link', _.bind(this.openAdvancedSettings, this));
},
render: function () {
var el = $(this.el);
el.html(this.template({
scope: this
}));
this.linkAdvanced = $('#image-advanced-link'); this.linkAdvanced = $('#image-advanced-link');
this.lblReplace = $('#image-lbl-replace'); this.lblReplace = $('#image-lbl-replace');
$(this.el).on('click', '#image-advanced-link', _.bind(this.openAdvancedSettings, this));
}, },
setApi: function(api) {
this.api = api;
if (this.api)
this.api.asc_registerCallback('asc_onImgWrapStyleChanged', _.bind(this._ImgWrapStyleChanged, this));
return this;
},
updateMetricUnit: function() {
var value = Common.Utils.Metric.fnRecalcFromMM(this._state.Width);
this.labelWidth[0].innerHTML = this.textWidth + ': ' + value.toFixed(1) + ' ' + Common.Utils.Metric.getCurrentMetricName();
value = Common.Utils.Metric.fnRecalcFromMM(this._state.Height);
this.labelHeight[0].innerHTML = this.textHeight + ': ' + value.toFixed(1) + ' ' + Common.Utils.Metric.getCurrentMetricName();
},
createDelayedElements: function() { createDelayedElements: function() {
this.createDelayedControls();
this.updateMetricUnit(); this.updateMetricUnit();
}, },
...@@ -248,6 +251,7 @@ define([ ...@@ -248,6 +251,7 @@ define([
}, },
_ImgWrapStyleChanged: function(style) { _ImgWrapStyleChanged: function(style) {
if (!this.mnuWrapPicker) return;
if (this._state.WrappingStyle!==style) { if (this._state.WrappingStyle!==style) {
this._noApply = true; this._noApply = true;
var record = this.mnuWrapPicker.store.findWhere({data: style}); var record = this.mnuWrapPicker.store.findWhere({data: style});
...@@ -387,6 +391,8 @@ define([ ...@@ -387,6 +391,8 @@ define([
}, },
disableControls: function(disable) { disableControls: function(disable) {
if (this._initSettings) return;
if (this._state.DisabledControls!==disable) { if (this._state.DisabledControls!==disable) {
this._state.DisabledControls = disable; this._state.DisabledControls = disable;
_.each(this.lockedControls, function(item) { _.each(this.lockedControls, function(item) {
......
...@@ -72,7 +72,9 @@ define([ ...@@ -72,7 +72,9 @@ define([
}, },
initialize: function () { initialize: function () {
var me = this; var me = this,
_set = DE.enumLockMM;
this._initSettings = true; this._initSettings = true;
this._state = { this._state = {
...@@ -88,18 +90,8 @@ define([ ...@@ -88,18 +90,8 @@ define([
this.emailAddresses = undefined; this.emailAddresses = undefined;
this.mergeMailData = undefined; this.mergeMailData = undefined;
var _set = DE.enumLockMM;
this.render(); this.render();
this.btnEditData = new Common.UI.Button({
el: me.$el.find('#mmerge-button-edit-data'),
lock: [_set.preview, _set.lostConnect]
});
this.btnEditData.on('click', _.bind(this.onEditData, this));
this.lblAddRecipients = $('#mmerge-lbl-add-recipients');
this.btnInsField = new Common.UI.Button({ this.btnInsField = new Common.UI.Button({
cls: 'btn-text-menu-default', cls: 'btn-text-menu-default',
caption: this.textInsertField, caption: this.textInsertField,
...@@ -120,19 +112,6 @@ define([ ...@@ -120,19 +112,6 @@ define([
}); });
this.btnInsField.render( $('#mmerge-btn-ins-field',me.$el)) ; this.btnInsField.render( $('#mmerge-btn-ins-field',me.$el)) ;
this.chHighlight = new Common.UI.Switcher({
el: me.$el.find('#mmerge-switcher-highlight'),
lock: [_set.noFields, _set.lostConnect]
});
this.chHighlight.on('change', _.bind(this.onCheckHighlightChange, this));
this.chPreview = new Common.UI.Switcher({
el: me.$el.find('#mmerge-switcher-preview'),
lock: [_set.noRecipients, _set.lostConnect]
});
this.chPreview.on('change', _.bind(this.onCheckPreviewChange, this));
this.emptyDBControls.push(this.chPreview);
this.txtFieldNum = new Common.UI.InputField({ this.txtFieldNum = new Common.UI.InputField({
el : $('#mmerge-field-num', me.$el), el : $('#mmerge-field-num', me.$el),
allowBlank : true, allowBlank : true,
...@@ -161,6 +140,52 @@ define([ ...@@ -161,6 +140,52 @@ define([
} }
}); });
this.emptyDBControls.push(this.txtFieldNum); this.emptyDBControls.push(this.txtFieldNum);
},
render: function () {
this.$el.html(this.template({
scope: this
}));
},
setApi: function(api) {
this.api = api;
if (this.api) {
this.api.asc_registerCallback('asc_onPreviewMailMergeResult', _.bind(this.onPreviewMailMergeResult, this));
this.api.asc_registerCallback('asc_onEndPreviewMailMergeResult', _.bind(this.onEndPreviewMailMergeResult, this));
this.api.asc_registerCallback('asc_onStartMailMerge', _.bind(this.onStartMailMerge, this));
this.api.asc_registerCallback('asc_onSaveMailMerge', _.bind(this.onSaveMailMerge, this));
this.api.asc_registerCallback('asc_onEndAction', _.bind(this.onLongActionEnd, this));
Common.Gateway.on('setemailaddresses', _.bind(this.onSetEmailAddresses, this));
Common.Gateway.on('processmailmerge', _.bind(this.onProcessMailMerge, this));
}
return this;
},
createDelayedControls: function() {
var me = this,
_set = DE.enumLockMM;
this.btnEditData = new Common.UI.Button({
el: me.$el.find('#mmerge-button-edit-data'),
lock: [_set.preview, _set.lostConnect]
});
this.btnEditData.on('click', _.bind(this.onEditData, this));
this.lblAddRecipients = $('#mmerge-lbl-add-recipients');
this.chHighlight = new Common.UI.Switcher({
el: me.$el.find('#mmerge-switcher-highlight'),
lock: [_set.noFields, _set.lostConnect]
});
this.chHighlight.on('change', _.bind(this.onCheckHighlightChange, this));
this.chPreview = new Common.UI.Switcher({
el: me.$el.find('#mmerge-switcher-preview'),
lock: [_set.noRecipients, _set.lostConnect]
});
this.chPreview.on('change', _.bind(this.onCheckPreviewChange, this));
this.emptyDBControls.push(this.chPreview);
this.btnFirst = new Common.UI.Button({ this.btnFirst = new Common.UI.Button({
cls: 'btn-toolbar', cls: 'btn-toolbar',
...@@ -343,32 +368,26 @@ define([ ...@@ -343,32 +368,26 @@ define([
}).on('click', _.bind(this.onMergeClick, this, false)); }).on('click', _.bind(this.onMergeClick, this, false));
this.emptyDBControls.push(this.btnMerge); this.emptyDBControls.push(this.btnMerge);
this.$el.on('click', '#mmerge-readmore-link', _.bind(this.openHelp, this));
},
render: function () {
this.$el.html(this.template({
scope: this
}));
this.linkReadMore = $('#mmerge-readmore-link', this.$el); this.linkReadMore = $('#mmerge-readmore-link', this.$el);
}, this.$el.on('click', '#mmerge-readmore-link', _.bind(this.openHelp, this));
setApi: function(api) { if (this.mode) {
this.api = api; if (!this.mode.mergeFolderUrl)
if (this.api) { this.btnPortal.setVisible(false);
this.api.asc_registerCallback('asc_onPreviewMailMergeResult', _.bind(this.onPreviewMailMergeResult, this)); if (!this.mode.canSendEmailAddresses) {
this.api.asc_registerCallback('asc_onEndPreviewMailMergeResult', _.bind(this.onEndPreviewMailMergeResult, this)); this._arrMergeSrc.pop();
this.api.asc_registerCallback('asc_onStartMailMerge', _.bind(this.onStartMailMerge, this)); this.cmbMergeTo.setData(this._arrMergeSrc);
this.api.asc_registerCallback('asc_onSaveMailMerge', _.bind(this.onSaveMailMerge, this)); this.cmbMergeTo.setValue(this._arrMergeSrc[0].value);
this.api.asc_registerCallback('asc_onEndAction', _.bind(this.onLongActionEnd, this)); }
Common.Gateway.on('setemailaddresses', _.bind(this.onSetEmailAddresses, this));
Common.Gateway.on('processmailmerge', _.bind(this.onProcessMailMerge, this));
} }
return this;
}, },
ChangeSettings: function(props) { ChangeSettings: function(props) {
if (this._initSettings) {
this.createDelayedControls();
this._initSettings = false;
}
this.disableInsertControls(this._locked); this.disableInsertControls(this._locked);
if (props) { if (props) {
...@@ -763,6 +782,8 @@ define([ ...@@ -763,6 +782,8 @@ define([
}, },
disableControls: function(disable) { disableControls: function(disable) {
if (this._initSettings) return;
this.lockControls(DE.enumLockMM.lostConnect, disable, { this.lockControls(DE.enumLockMM.lostConnect, disable, {
array: _.union([this.btnEditData, this.btnInsField, this.chHighlight], (this.mode.mergeFolderUrl) ? [this.btnPortal] : []), array: _.union([this.btnEditData, this.btnInsField, this.chHighlight], (this.mode.mergeFolderUrl) ? [this.btnPortal] : []),
merge: true merge: true
...@@ -775,13 +796,6 @@ define([ ...@@ -775,13 +796,6 @@ define([
setMode: function(mode) { setMode: function(mode) {
this.mode = mode; this.mode = mode;
if (!this.mode.mergeFolderUrl)
this.btnPortal.setVisible(false);
if (!this.mode.canSendEmailAddresses) {
this._arrMergeSrc.pop();
this.cmbMergeTo.setData(this._arrMergeSrc);
this.cmbMergeTo.setValue(this._arrMergeSrc[0].value);
}
}, },
disableEditing: function(disable) { disableEditing: function(disable) {
...@@ -807,7 +821,7 @@ define([ ...@@ -807,7 +821,7 @@ define([
}, },
disablePreviewMode: function() { disablePreviewMode: function() {
if (this.api && this.chPreview.getValue()) { if (this.api && this.chPreview && this.chPreview.getValue()) {
this.api.asc_EndPreviewMailMergeResult(); this.api.asc_EndPreviewMailMergeResult();
} }
}, },
......
...@@ -67,7 +67,6 @@ define([ ...@@ -67,7 +67,6 @@ define([
}, },
initialize: function () { initialize: function () {
var me = this;
this._initSettings = true; this._initSettings = true;
this._state = { this._state = {
...@@ -157,22 +156,8 @@ define([ ...@@ -157,22 +156,8 @@ define([
this.btnColor = new Common.UI.ColorButton({ this.btnColor = new Common.UI.ColorButton({
style: "width:45px;", style: "width:45px;",
disabled: this._locked, disabled: this._locked,
menu : new Common.UI.Menu({ menu : true
items: [
{ template: _.template('<div id="paragraph-color-menu" style="width: 165px; height: 220px; margin: 10px;"></div>') },
{ template: _.template('<a id="paragraph-color-new" style="padding-left:12px;">' + me.textNewColor + '</a>') }
]
})
});
this.btnColor.on('render:after', function(btn) {
me.mnuColorPicker = new Common.UI.ThemeColorPalette({
el: $('#paragraph-color-menu'),
transparent: true
});
me.mnuColorPicker.on('select', _.bind(me.onColorPickerSelect, me));
}); });
this.btnColor.render( $('#paragraph-color-btn')); this.btnColor.render( $('#paragraph-color-btn'));
this.lockedControls.push(this.btnColor); this.lockedControls.push(this.btnColor);
...@@ -456,8 +441,20 @@ define([ ...@@ -456,8 +441,20 @@ define([
}, },
UpdateThemeColors: function() { UpdateThemeColors: function() {
if (this.mnuColorPicker) if (!this.mnuColorPicker) {
this.mnuColorPicker.updateColors(Common.Utils.ThemeColor.getEffectColors(), Common.Utils.ThemeColor.getStandartColors()); this.btnColor.setMenu( new Common.UI.Menu({
items: [
{ template: _.template('<div id="paragraph-color-menu" style="width: 165px; height: 220px; margin: 10px;"></div>') },
{ template: _.template('<a id="paragraph-color-new" style="padding-left:12px;">' + this.textNewColor + '</a>') }
]
}));
this.mnuColorPicker = new Common.UI.ThemeColorPalette({
el: $('#paragraph-color-menu'),
transparent: true
});
this.mnuColorPicker.on('select', _.bind(this.onColorPickerSelect, this));
}
this.mnuColorPicker.updateColors(Common.Utils.ThemeColor.getEffectColors(), Common.Utils.ThemeColor.getStandartColors());
}, },
onHideMenus: function(e){ onHideMenus: function(e){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment