Register font events in controllers (not in the component ComboBoxFonts)
This commit is contained in:
		
							parent
							
								
									47f508b0b2
								
							
						
					
					
						commit
						d52a2c6774
					
				| 
						 | 
				
			
			@ -95,7 +95,7 @@ define([
 | 
			
		|||
 | 
			
		||||
                this.recent = _.isNumber(options.recent) ? options.recent : 3;
 | 
			
		||||
 | 
			
		||||
                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));
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -115,8 +115,6 @@ define([
 | 
			
		|||
                this._input.on('focus',     _.bind(function() {this.inFormControl = true;}, this));
 | 
			
		||||
                this._input.on('blur',      _.bind(function() {this.inFormControl = false;}, this));
 | 
			
		||||
 | 
			
		||||
                this._modalParents = this.cmpEl.closest('.asc-window');
 | 
			
		||||
 | 
			
		||||
                return this;
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -334,8 +332,6 @@ define([
 | 
			
		|||
                var name = (_.isFunction(font.get_Name) ?  font.get_Name() : font.asc_getName());
 | 
			
		||||
 | 
			
		||||
                if (this.getRawValue() !== name) {
 | 
			
		||||
                    if (this._modalParents.length > 0) return;
 | 
			
		||||
 | 
			
		||||
                    var record = this.store.findWhere({
 | 
			
		||||
                        name: name
 | 
			
		||||
                    });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -368,6 +368,7 @@ define([
 | 
			
		|||
            this.api.asc_registerCallback('asc_onContextMenu',          _.bind(this.onContextMenu, this));
 | 
			
		||||
            this.api.asc_registerCallback('asc_onShowParaMarks',        _.bind(this.onShowParaMarks, this));
 | 
			
		||||
            this.api.asc_registerCallback('asc_onChangeSdtGlobalSettings',_.bind(this.onChangeSdtGlobalSettings, this));
 | 
			
		||||
            Common.NotificationCenter.on('fonts:change',                _.bind(this.onApiChangeFont, this));
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onChangeCompactView: function(view, compact) {
 | 
			
		||||
| 
						 | 
				
			
			@ -392,6 +393,10 @@ define([
 | 
			
		|||
            this.toolbar.collapse();
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onApiChangeFont: function(font) {
 | 
			
		||||
            !this.getApplication().getController('Main').isModalShowed && this.toolbar.cmbFontName.onApiChangeFont(font);
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onApiFontSize: function(size) {
 | 
			
		||||
            if (this._state.fontsize !== size) {
 | 
			
		||||
                this.toolbar.cmbFontSize.setValue(size);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -319,6 +319,7 @@ define([
 | 
			
		|||
            this.api.asc_registerCallback('asc_onUnderline',            _.bind(this.onApiUnderline, this));
 | 
			
		||||
            this.api.asc_registerCallback('asc_onStrikeout',            _.bind(this.onApiStrikeout, this));
 | 
			
		||||
            this.api.asc_registerCallback('asc_onVerticalAlign',        _.bind(this.onApiVerticalAlign, this));
 | 
			
		||||
            Common.NotificationCenter.on('fonts:change',                _.bind(this.onApiChangeFont, this));
 | 
			
		||||
 | 
			
		||||
            this.api.asc_registerCallback('asc_onCanUndo',              _.bind(this.onApiCanRevert, this, 'undo'));
 | 
			
		||||
            this.api.asc_registerCallback('asc_onCanRedo',              _.bind(this.onApiCanRevert, this, 'redo'));
 | 
			
		||||
| 
						 | 
				
			
			@ -377,6 +378,10 @@ define([
 | 
			
		|||
            this.toolbar.collapse();
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onApiChangeFont: function(font) {
 | 
			
		||||
            !this.getApplication().getController('Main').isModalShowed && this.toolbar.cmbFontName.onApiChangeFont(font);
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onApiFontSize: function(size) {
 | 
			
		||||
            if (this._state.fontsize !== size) {
 | 
			
		||||
                this.toolbar.cmbFontSize.setValue(size);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -387,6 +387,7 @@ define([
 | 
			
		|||
            Common.NotificationCenter.on('api:disconnect',              _.bind(this.onApiCoAuthoringDisconnect, this));
 | 
			
		||||
            this.api.asc_registerCallback('asc_onLockDefNameManager',   _.bind(this.onLockDefNameManager, this));
 | 
			
		||||
            this.api.asc_registerCallback('asc_onZoomChanged',          _.bind(this.onApiZoomChange, this));
 | 
			
		||||
            Common.NotificationCenter.on('fonts:change',                _.bind(this.onApiChangeFont, this));
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        // onNewDocument: function(btn, e) {
 | 
			
		||||
| 
						 | 
				
			
			@ -403,6 +404,10 @@ define([
 | 
			
		|||
        //     Common.component.Analytics.trackEvent('ToolBar', 'Open Document');
 | 
			
		||||
        // },
 | 
			
		||||
 | 
			
		||||
        onApiChangeFont: function(font) {
 | 
			
		||||
            !this.getApplication().getController('Main').isModalShowed && this.toolbar.cmbFontName.onApiChangeFont(font);
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onContextMenu: function() {
 | 
			
		||||
            this.toolbar.collapse();
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -341,6 +341,7 @@ define([
 | 
			
		|||
            }));
 | 
			
		||||
            this.cmbFonts[1].on('selected', _.bind(this.onFontSelect, this));
 | 
			
		||||
            this.footerControls.push(this.cmbFonts[1]);
 | 
			
		||||
            Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this));
 | 
			
		||||
 | 
			
		||||
            data = [
 | 
			
		||||
                { value: 8, displayValue: "8" },
 | 
			
		||||
| 
						 | 
				
			
			@ -537,6 +538,7 @@ define([
 | 
			
		|||
                cls         : 'btn-toolbar',
 | 
			
		||||
                iconCls     : 'btn-fontcolor',
 | 
			
		||||
                hint        : this.textColor,
 | 
			
		||||
                split       : true,
 | 
			
		||||
                menu        : new Common.UI.Menu({
 | 
			
		||||
                    items: [
 | 
			
		||||
                        { template: _.template('<div id="id-dlg-h-menu-fontcolor" style="width: 169px; height: 220px; margin: 10px;"></div>') },
 | 
			
		||||
| 
						 | 
				
			
			@ -545,6 +547,7 @@ define([
 | 
			
		|||
                })
 | 
			
		||||
            }));
 | 
			
		||||
            this.btnTextColor[0].render($('#id-dlg-h-textcolor'));
 | 
			
		||||
            this.btnTextColor[0].on('click', _.bind(this.onTextColor, this));
 | 
			
		||||
            this.mnuTextColorPicker = [];
 | 
			
		||||
            this.mnuTextColorPicker.push(initNewColor(this.btnTextColor[0], "#id-dlg-h-menu-fontcolor"));
 | 
			
		||||
            this.headerControls.push(this.btnTextColor[0]);
 | 
			
		||||
| 
						 | 
				
			
			@ -553,6 +556,7 @@ define([
 | 
			
		|||
                cls         : 'btn-toolbar',
 | 
			
		||||
                iconCls     : 'btn-fontcolor',
 | 
			
		||||
                hint        : this.textColor,
 | 
			
		||||
                split       : true,
 | 
			
		||||
                menu        : new Common.UI.Menu({
 | 
			
		||||
                    items: [
 | 
			
		||||
                        { template: _.template('<div id="id-dlg-f-menu-fontcolor" style="width: 169px; height: 220px; margin: 10px;"></div>') },
 | 
			
		||||
| 
						 | 
				
			
			@ -561,6 +565,7 @@ define([
 | 
			
		|||
                })
 | 
			
		||||
            }));
 | 
			
		||||
            this.btnTextColor[1].render($('#id-dlg-f-textcolor'));
 | 
			
		||||
            this.btnTextColor[1].on('click', _.bind(this.onTextColor, this));
 | 
			
		||||
            this.mnuTextColorPicker.push(initNewColor(this.btnTextColor[1], "#id-dlg-f-menu-fontcolor"));
 | 
			
		||||
            this.footerControls.push(this.btnTextColor[1]);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -725,17 +730,15 @@ define([
 | 
			
		|||
        },
 | 
			
		||||
 | 
			
		||||
        onFontSelect: function(combo, record) {
 | 
			
		||||
            if (this.HFObject) {
 | 
			
		||||
            if (this.HFObject)
 | 
			
		||||
                this.HFObject.setFontName(record.name);
 | 
			
		||||
                this.scrollerUpdate();
 | 
			
		||||
            }
 | 
			
		||||
            this.onCanvasClick(this.currentCanvas);
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onFontSizeSelect: function(combo, record) {
 | 
			
		||||
            if (this.HFObject) {
 | 
			
		||||
            if (this.HFObject)
 | 
			
		||||
                this.HFObject.setFontSize(record.value);
 | 
			
		||||
                this.scrollerUpdate();
 | 
			
		||||
            }
 | 
			
		||||
            this.onCanvasClick(this.currentCanvas);
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onBoldClick: function(btn, e) {
 | 
			
		||||
| 
						 | 
				
			
			@ -780,6 +783,12 @@ define([
 | 
			
		|||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        onTextColor: function() {
 | 
			
		||||
            var mnuTextColorPicker = this.mnuTextColorPicker[this.isFooter ? 1 : 0];
 | 
			
		||||
            mnuTextColorPicker.trigger('select', mnuTextColorPicker, mnuTextColorPicker.currentColor, true);
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onColorSelect: function(btn, picker, color) {
 | 
			
		||||
            var clr = (typeof(color) == 'object') ? color.color : color;
 | 
			
		||||
            btn.currentColor = color;
 | 
			
		||||
| 
						 | 
				
			
			@ -787,6 +796,7 @@ define([
 | 
			
		|||
            picker.currentColor = color;
 | 
			
		||||
            if (this.HFObject)
 | 
			
		||||
                this.HFObject.setTextColor(Common.Utils.ThemeColor.getRgbColor(color));
 | 
			
		||||
            this.onCanvasClick(this.currentCanvas);
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onPageTypeToggle: function(type, btn, state) {
 | 
			
		||||
| 
						 | 
				
			
			@ -796,6 +806,10 @@ define([
 | 
			
		|||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onApiChangeFont: function(font) {
 | 
			
		||||
            this.cmbFonts[this.isFooter ? 1 : 0].onApiChangeFont(font);
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onApiEditorSelectionChanged: function(fontobj) {
 | 
			
		||||
            var idx = this.isFooter ? 1 : 0,
 | 
			
		||||
                val;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue