diff --git a/apps/common/main/lib/component/DataView.js b/apps/common/main/lib/component/DataView.js index 380adb99e..859df45c4 100644 --- a/apps/common/main/lib/component/DataView.js +++ b/apps/common/main/lib/component/DataView.js @@ -476,12 +476,12 @@ define([ var me = this, view_el = $(view.el), tip = record.get('tip'); - if (tip) { + if (tip!==undefined && tip!==null) { if (this.delayRenderTips) view_el.one('mouseenter', function(){ // hide tooltip when mouse is over menu view_el.attr('data-toggle', 'tooltip'); view_el.tooltip({ - title : tip, + title : record.get('tip'), // use actual tip, because it can be changed placement : 'cursor', zIndex : me.tipZIndex }); @@ -490,7 +490,7 @@ define([ else { view_el.attr('data-toggle', 'tooltip'); view_el.tooltip({ - title : tip, + title : record.get('tip'), // use actual tip, because it can be changed placement : 'cursor', zIndex : me.tipZIndex }); diff --git a/apps/common/main/lib/view/ListSettingsDialog.js b/apps/common/main/lib/view/ListSettingsDialog.js index 96afdac6a..4df5c4906 100644 --- a/apps/common/main/lib/view/ListSettingsDialog.js +++ b/apps/common/main/lib/view/ListSettingsDialog.js @@ -50,6 +50,13 @@ define([ 'common/main/lib/view/SymbolTableDialog' ], function () { 'use strict'; + var _BulletTypes = {}; + _BulletTypes.none = -1; + _BulletTypes.symbol = 0; + _BulletTypes.image = 2; + _BulletTypes.newSymbol = 1; + _BulletTypes.newImage = -2; + Common.Views.ListSettingsDialog = Common.UI.Window.extend(_.extend({ options: { type: 0, // 0 - markers, 1 - numbers @@ -86,6 +93,15 @@ define([ '', '', '', + '', + '', + '', + '', + '', + '
', + '', + '', + '', '', '', '', @@ -106,7 +122,7 @@ define([ '', '', '', - '', + '', '', '', '', @@ -123,6 +139,8 @@ define([ this.props = options.props; this.options.tpl = _.template(this.template)(this.options); this.color = '000000'; + this.storage = !!options.storage; + this.api = options.api; Common.UI.Window.prototype.initialize.call(this, this.options); }, @@ -179,7 +197,9 @@ define([ [ '<% _.each(items, function(item) { %>', '
  • ', - '<%= item.displayValue %><% if (item.value === 0) { %><%=item.symbol%><% } %>', + '<%= item.displayValue %>', + '<% if (item.value === 0) { %><%=item.symbol%>', + '<% } else if (item.value === 2) { %><% } %>', '
  • ', '<% }); %>' ]; @@ -201,22 +221,30 @@ define([ template : _.template(template.join('')), itemsTemplate: _.template(itemsTemplate.join('')), data : [ - { displayValue: this.txtNone, value: -1 }, - { displayValue: this.txtSymbol + ': ', value: 0, symbol: "•", font: 'Arial' }, - { displayValue: this.txtSymbol + ': ', value: 0, symbol: "o", font: 'Courier New' }, - { displayValue: this.txtSymbol + ': ', value: 0, symbol: "§", font: 'Wingdings' }, - { displayValue: this.txtSymbol + ': ', value: 0, symbol: "v", font: 'Wingdings' }, - { displayValue: this.txtSymbol + ': ', value: 0, symbol: "Ø", font: 'Wingdings' }, - { displayValue: this.txtSymbol + ': ', value: 0, symbol: "ü", font: 'Wingdings' }, - { displayValue: this.txtSymbol + ': ', value: 0, symbol: "w", font: 'Wingdings' }, - { displayValue: this.txtSymbol + ': ', value: 0, symbol: "–", font: 'Arial' }, - { displayValue: this.txtNewBullet, value: 1 } + { displayValue: this.txtNone, value: _BulletTypes.none }, + { displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "•", font: 'Arial' }, + { displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "o", font: 'Courier New' }, + { displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "§", font: 'Wingdings' }, + { displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "v", font: 'Wingdings' }, + { displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "Ø", font: 'Wingdings' }, + { displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "ü", font: 'Wingdings' }, + { displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "w", font: 'Wingdings' }, + { displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "–", font: 'Arial' }, + { displayValue: this.txtNewBullet, value: _BulletTypes.newSymbol }, + { displayValue: this.txtNewImage, value: _BulletTypes.newImage } ], updateFormControl: function(record) { var formcontrol = $(this.el).find('.form-control'); if (record) { - if (record.get('value')==0) + if (record.get('value')===_BulletTypes.symbol) formcontrol[0].innerHTML = record.get('displayValue') + '' + record.get('symbol') + ''; + else if (record.get('value')===_BulletTypes.image) { + formcontrol[0].innerHTML = record.get('displayValue') + ''; + var bullet = new Asc.asc_CBullet(); + bullet.asc_fillBulletImage(me.imageProps.id); + bullet.drawSquareImage('id-dlg-list-bullet-combo-preview'); + } else if (record.get('value')===_BulletTypes.newImage) + formcontrol[0].innerHTML = me.txtImage; else formcontrol[0].innerHTML = record.get('displayValue'); } else @@ -227,7 +255,9 @@ define([ this.cmbBulletFormat.selectRecord(rec); this.bulletProps = {symbol: rec.get('symbol'), font: rec.get('font')}; this.cmbBulletFormat.on('selected', _.bind(function (combo, record) { - if (record.value === 1) { + this.imageControls.toggleClass('hidden', !(record.value === _BulletTypes.image || record.value === _BulletTypes.newImage)); + this.colorControls.toggleClass('hidden', record.value === _BulletTypes.image || record.value === _BulletTypes.newImage); + if (record.value === _BulletTypes.newSymbol) { var me = this, props = me.bulletProps, handler = function(dlg, result, settings) { @@ -242,10 +272,14 @@ define([ } } var store = combo.store; - if (!store.findWhere({value: 0, symbol: props.symbol, font: props.font})) - store.add({ displayValue: me.txtSymbol + ': ', value: 0, symbol: props.symbol, font: props.font }, {at: store.length-1}); + if (!store.findWhere({value: _BulletTypes.symbol, symbol: props.symbol, font: props.font})) { + var idx = store.indexOf(store.findWhere({value: _BulletTypes.image})); + if (idx<0) + idx = store.indexOf(store.findWhere({value: _BulletTypes.newSymbol})); + store.add({ displayValue: me.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: props.symbol, font: props.font }, {at: idx}); + } combo.setData(store.models); - combo.selectRecord(combo.store.findWhere({value: 0, symbol: props.symbol, font: props.font})); + combo.selectRecord(combo.store.findWhere({value: _BulletTypes.symbol, symbol: props.symbol, font: props.font})); }, win = new Common.Views.SymbolTableDialog({ api: me.options.api, @@ -258,7 +292,11 @@ define([ }); win.show(); win.on('symbol:dblclick', handler); - } else if (record.value == -1) { + } else if (record.value == _BulletTypes.newImage) { // new image + } else if (record.value == _BulletTypes.image) { // image + if (this._changedProps) + this._changedProps.asc_fillBulletImage(this.imageProps.id); + } else if (record.value == _BulletTypes.none) { if (this._changedProps) this._changedProps.asc_putListType(0, record.value); } else { @@ -271,7 +309,9 @@ define([ this._changedProps.asc_putSymbol(this.bulletProps.symbol); } } + this.btnOk.setDisabled(record.value === _BulletTypes.newImage); }, this)); + this.cmbBulletFormat.on('show:after', _.bind(this.onBulletFormatOpen, this)); this.spnSize = new Common.UI.MetricSpinner({ el : $window.find('#id-dlg-list-size'), @@ -314,7 +354,32 @@ define([ } }); - me.numberingControls = $window.find('.numbering'); + this.btnSelectImage = new Common.UI.Button({ + parentEl: $('#id-dlg-list-image'), + cls: 'btn-text-menu-default', + caption: this.textSelect, + style: 'width: 100%;', + menu: new Common.UI.Menu({ + style: 'min-width: 100px;', + maxHeight: 200, + additionalAlign: this.menuAddAlign, + items: [ + {caption: this.textFromFile, value: 0}, + {caption: this.textFromUrl, value: 1}, + {caption: this.textFromStorage, value: 2} + ] + }) + }); + this.btnSelectImage.menu.on('item:click', _.bind(this.onImageSelect, this)); + this.btnSelectImage.menu.items[2].setVisible(this.storage); + + this.btnOk = new Common.UI.Button({ + el: $window.find('.primary') + }); + + me.numberingControls = $window.find('tr.numbering'); + me.imageControls = $window.find('tr.image'); + me.colorControls = $window.find('tr.color'); var el = $window.find('table tr:first() td:first()'); el.width(Math.max($window.find('.numbering .text').width(), el.width())); @@ -323,12 +388,52 @@ define([ }, getFocusedComponents: function() { - return [this.cmbNumFormat, this.cmbBulletFormat, this.spnSize, this.spnStart, this.btnColor]; + return [this.cmbNumFormat, this.cmbBulletFormat, this.btnSelectImage, this.spnSize, this.spnStart, this.btnColor]; }, afterRender: function() { this.updateThemeColors(); this._setDefaults(this.props); + + var me = this; + var onApiImageLoaded = function(bullet) { + me.imageProps = {id: bullet.asc_getImageId(), redraw: true}; + if (me._changedProps) + me._changedProps.asc_fillBulletImage(me.imageProps.id); + // add or update record for image to btnBulletFormat and select it + var store = me.cmbBulletFormat.store; + if (!store.findWhere({value: _BulletTypes.image})) { + var idx = store.indexOf(store.findWhere({value: _BulletTypes.newSymbol})); + store.add({ displayValue: me.txtImage + ':', value: _BulletTypes.image }, {at: idx}); + } + me.cmbBulletFormat.setData(store.models); + me.cmbBulletFormat.selectRecord(me.cmbBulletFormat.store.findWhere({value: _BulletTypes.image})); + me.btnOk.setDisabled(false); + }; + this.api.asc_registerCallback('asc_onBulletImageLoaded', onApiImageLoaded); + + var insertImageFromStorage = function(data) { + if (data && data._urls && data.c=='bullet') { + (new Asc.asc_CBullet()).asc_putImageUrl(data._urls[0], data.token); + } + }; + Common.NotificationCenter.on('storage:image-insert', insertImageFromStorage); + + this.on('close', function(obj){ + me.api.asc_unregisterCallback('asc_onBulletImageLoaded', onApiImageLoaded); + Common.NotificationCenter.off('storage:image-insert', insertImageFromStorage); + }); + }, + + onBulletFormatOpen: function(combo) { + var store = combo.store, + rec = store.findWhere({value: _BulletTypes.image}); + if (rec && this.imageProps.redraw) { + var bullet = new Asc.asc_CBullet(); + bullet.asc_fillBulletImage(this.imageProps.id); + bullet.drawSquareImage('id-dlg-list-bullet-image-preview'); + this.imageProps.redraw = false; + } }, updateThemeColors: function() { @@ -347,9 +452,14 @@ define([ }, ShowHideElem: function(value) { + var isImage = value==0 && (this.cmbBulletFormat.getValue()===_BulletTypes.image || this.cmbBulletFormat.getValue()===_BulletTypes.newImage || + (this.cmbBulletFormat.getValue()===undefined || this.cmbBulletFormat.getValue()==='') && this.originalType === AscFormat.BULLET_TYPE_BULLET_BLIP); this.numberingControls.toggleClass('hidden', value==0); + this.imageControls.toggleClass('hidden', !isImage); + this.colorControls.toggleClass('hidden', isImage); this.cmbNumFormat.setVisible(value==1); this.cmbBulletFormat.setVisible(value==0); + this.btnOk.setDisabled(isImage && (this.cmbBulletFormat.getValue()===_BulletTypes.newImage)); var me = this; _.delay(function(){ if (value) @@ -362,18 +472,28 @@ define([ _handleInput: function(state) { if (this.options.handler) { + if (state == 'ok' && this.btnOk.isDisabled()) { + return; + } var type = this.btnBullet.pressed ? 0 : 1; if (this.originalType == AscFormat.BULLET_TYPE_BULLET_NONE) { this._changedProps = new Asc.asc_CBullet(); - this._changedProps.asc_putColor(Common.Utils.ThemeColor.getRgbColor(this.color)); this._changedProps.asc_putSize(this.spnSize.getNumberValue()); + if (type==0 && this.cmbBulletFormat.getValue()===_BulletTypes.image && this.imageProps) {//image + this._changedProps.asc_fillBulletImage(this.imageProps.id); + } else { + this._changedProps.asc_putColor(Common.Utils.ThemeColor.getRgbColor(this.color)); + } } if (this.originalType == AscFormat.BULLET_TYPE_BULLET_NONE || - this.originalType == AscFormat.BULLET_TYPE_BULLET_CHAR && type==1 || this.originalType == AscFormat.BULLET_TYPE_BULLET_AUTONUM && type==0) { // changed list type + (this.originalType == AscFormat.BULLET_TYPE_BULLET_CHAR || this.originalType == AscFormat.BULLET_TYPE_BULLET_BLIP) && type==1 || + this.originalType == AscFormat.BULLET_TYPE_BULLET_AUTONUM && type==0) { // changed list type if (type==0) {//markers - if (this.cmbBulletFormat.getValue()==-1) { + if (this.cmbBulletFormat.getValue()==_BulletTypes.none) { this._changedProps.asc_putListType(0, -1); + } else if (this.cmbBulletFormat.getValue()==_BulletTypes.image) { + } else { this._changedProps.asc_putFont(this.bulletProps.font); this._changedProps.asc_putSymbol(this.bulletProps.symbol); @@ -432,16 +552,28 @@ define([ if (this.originalType == AscFormat.BULLET_TYPE_BULLET_NONE) { this.cmbNumFormat.setValue(-1); - this.cmbBulletFormat.setValue(-1); + this.cmbBulletFormat.setValue(_BulletTypes.none); type = this.type; } else if (this.originalType == AscFormat.BULLET_TYPE_BULLET_CHAR) { var symbol = bullet.asc_getSymbol(); if (symbol) { this.bulletProps = {symbol: symbol, font: bullet.asc_getFont()}; - if (!this.cmbBulletFormat.store.findWhere({value: 0, symbol: this.bulletProps.symbol, font: this.bulletProps.font})) - this.cmbBulletFormat.store.add({ displayValue: this.txtSymbol + ': ', value: 0, symbol: this.bulletProps.symbol, font: this.bulletProps.font }, {at: this.cmbBulletFormat.store.length-1}); + if (!this.cmbBulletFormat.store.findWhere({value: _BulletTypes.symbol, symbol: this.bulletProps.symbol, font: this.bulletProps.font})) + this.cmbBulletFormat.store.add({ displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: this.bulletProps.symbol, font: this.bulletProps.font }, {at: this.cmbBulletFormat.store.length-2}); this.cmbBulletFormat.setData(this.cmbBulletFormat.store.models); - this.cmbBulletFormat.selectRecord(this.cmbBulletFormat.store.findWhere({value: 0, symbol: this.bulletProps.symbol, font: this.bulletProps.font})); + this.cmbBulletFormat.selectRecord(this.cmbBulletFormat.store.findWhere({value: _BulletTypes.symbol, symbol: this.bulletProps.symbol, font: this.bulletProps.font})); + } else + this.cmbBulletFormat.setValue(''); + this._changedProps = bullet; + type = 0; + } else if (this.originalType == AscFormat.BULLET_TYPE_BULLET_BLIP) { + var id = bullet.asc_getImageId(); + if (id) { + this.imageProps = {id: id, redraw: true}; + if (!this.cmbBulletFormat.store.findWhere({value: _BulletTypes.image})) + this.cmbBulletFormat.store.add({ displayValue: this.txtImage + ':', value: _BulletTypes.image}, {at: this.cmbBulletFormat.store.length-2}); + this.cmbBulletFormat.setData(this.cmbBulletFormat.store.models); + this.cmbBulletFormat.selectRecord(this.cmbBulletFormat.store.findWhere({value: _BulletTypes.image})); } else this.cmbBulletFormat.setValue(''); this._changedProps = bullet; @@ -458,7 +590,7 @@ define([ } } else {// different bullet types this.cmbNumFormat.setValue(-1); - this.cmbBulletFormat.setValue(-1); + this.cmbBulletFormat.setValue(_BulletTypes.none); this._changedProps = new Asc.asc_CBullet(); type = this.type; } @@ -468,6 +600,26 @@ define([ this.ShowHideElem(type); }, + onImageSelect: function(menu, item) { + if (item.value==1) { + var me = this; + (new Common.Views.ImageFromUrlDialog({ + handler: function(result, value) { + if (result == 'ok') { + var checkUrl = value.replace(/ /g, ''); + if (!_.isEmpty(checkUrl)) { + (new Asc.asc_CBullet()).asc_putImageUrl(checkUrl); + } + } + } + })).show(); + } else if (item.value==2) { + Common.NotificationCenter.trigger('storage:image-load', 'bullet'); + } else { + (new Asc.asc_CBullet()).asc_showFileDialog(); + } + }, + txtTitle: 'List Settings', txtSize: 'Size', txtColor: 'Color', @@ -478,6 +630,13 @@ define([ txtType: 'Type', txtNone: 'None', txtNewBullet: 'New bullet', - txtSymbol: 'Symbol' + txtSymbol: 'Symbol', + txtNewImage: 'New image', + txtImage: 'Image', + txtImport: 'Import', + textSelect: 'Select From', + textFromUrl: 'From URL', + textFromFile: 'From File', + textFromStorage: 'From Storage' }, Common.Views.ListSettingsDialog || {})) }); \ No newline at end of file diff --git a/apps/common/main/resources/less/combobox.less b/apps/common/main/resources/less/combobox.less index d561e6ee7..4b8615ed6 100644 --- a/apps/common/main/resources/less/combobox.less +++ b/apps/common/main/resources/less/combobox.less @@ -144,7 +144,7 @@ -webkit-filter: @img-border-type-filter; filter: @img-border-type-filter; } - canvas { + .font-item canvas { -webkit-filter: @img-border-type-filter; filter: @img-border-type-filter; } @@ -154,7 +154,7 @@ -webkit-filter: @img-border-type-filter-selected; filter: @img-border-type-filter-selected; } - canvas { + .font-item canvas { -webkit-filter: @img-border-type-filter-selected; filter: @img-border-type-filter-selected; } diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index cdf03f8c8..a869ff4fb 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -503,20 +503,63 @@ define([ } }, + updateBulletTip: function(view, title) { + if (view) { + var tip = $(view.el).data('bs.tooltip'); + if (tip) { + tip.options.title = title; + tip.$tip.find('.tooltip-inner').text(title); + } + } + }, + onApiBullets: function(v) { - if (this._state.bullets.type != v.get_ListType() || this._state.bullets.subtype != v.get_ListSubType()) { + if (this._state.bullets.type !== v.get_ListType() || this._state.bullets.subtype !== v.get_ListSubType() || v.get_ListType()===0 && v.get_ListSubType()===0x1000) { this._state.bullets.type = v.get_ListType(); this._state.bullets.subtype = v.get_ListSubType(); + var rec = this.toolbar.mnuMarkersPicker.store.at(8), + drawDefBullet = (rec.get('data').subtype===0x1000) && (this._state.bullets.type===1 || this._state.bullets.subtype!==0x1000); + this._clearBullets(); switch(this._state.bullets.type) { case 0: + var idx; + if (this._state.bullets.subtype!==0x1000) + idx = this._state.bullets.subtype; + else { // custom + var bullet = v.asc_getListCustom(); + if (bullet) { + var type = bullet.asc_getType(); + if (type == Asc.asc_PreviewBulletType.char) { + var symbol = bullet.asc_getChar(); + if (symbol) { + rec.get('data').subtype = 0x1000; + rec.set('drawdata', {type: type, char: symbol, specialFont: bullet.asc_getSpecialFont()}); + rec.set('tip', ''); + this.toolbar.mnuMarkersPicker.dataViewItems && this.updateBulletTip(this.toolbar.mnuMarkersPicker.dataViewItems[8], ''); + drawDefBullet = false; + idx = 8; + } + } else if (type == Asc.asc_PreviewBulletType.image) { + var id = bullet.asc_getImageId(); + if (id) { + rec.get('data').subtype = 0x1000; + rec.set('drawdata', {type: type, imageId: id}); + rec.set('tip', ''); + this.toolbar.mnuMarkersPicker.dataViewItems && this.updateBulletTip(this.toolbar.mnuMarkersPicker.dataViewItems[8], ''); + drawDefBullet = false; + idx = 8; + } + } + } + } + (idx!==undefined) ? this.toolbar.mnuMarkersPicker.selectByIndex(idx, true) : + this.toolbar.mnuMarkersPicker.deselectAll(true); + this.toolbar.btnMarkers.toggle(true, true); - if (this._state.bullets.subtype!==undefined) - this.toolbar.mnuMarkersPicker.selectByIndex(this._state.bullets.subtype, true); - else - this.toolbar.mnuMarkersPicker.deselectAll(true); + this.toolbar.mnuNumbersPicker.deselectAll(true); break; case 1: var idx = 0; @@ -545,8 +588,15 @@ define([ } this.toolbar.btnNumbers.toggle(true, true); this.toolbar.mnuNumbersPicker.selectByIndex(idx, true); + this.toolbar.mnuMarkersPicker.deselectAll(true); break; } + if (drawDefBullet) { + rec.get('data').subtype = 8; + rec.set('drawdata', this.toolbar._markersArr[8]); + rec.set('tip', this.toolbar.tipMarkersDash); + this.toolbar.mnuMarkersPicker.dataViewItems && this.updateBulletTip(this.toolbar.mnuMarkersPicker.dataViewItems[8], this.toolbar.tipMarkersDash); + } } }, @@ -1247,6 +1297,7 @@ define([ api: me.api, props: props, type: type, + storage: me.mode.canRequestInsertImage || me.mode.fileChoiceUrl && me.mode.fileChoiceUrl.indexOf("{documentType}")>-1, interfaceLang: me.toolbar.mode.lang, handler: function(result, value) { if (result == 'ok') { @@ -1358,7 +1409,9 @@ define([ var store = picker.store; var arr = []; store.each(function(item){ - arr.push(item.get('id')); + var data = item.get('drawdata'); + data['divId'] = item.get('id'); + arr.push(data); }); if (this.api && this.api.SetDrawImagePreviewBulletForMenu) { this.api.SetDrawImagePreviewBulletForMenu(arr, type); @@ -1381,11 +1434,31 @@ define([ } if (btn) { - btn.toggle(rawData.data.subtype > -1, true); + btn.toggle(rawData.data.subtype !== -1, true); } - if (this.api) - this.api.put_ListType(rawData.data.type, rawData.data.subtype); + if (this.api){ + if (rawData.data.type===0 && rawData.data.subtype===0x1000) {// custom bullet + var bullet = new Asc.asc_CBullet(); + if (rawData.drawdata.type===Asc.asc_PreviewBulletType.char) { + bullet.asc_putSymbol(rawData.drawdata.char); + bullet.asc_putFont(rawData.drawdata.specialFont); + } else if (rawData.drawdata.type===Asc.asc_PreviewBulletType.image) + bullet.asc_fillBulletImage(rawData.drawdata.imageId); + var selectedElements = this.api.getSelectedElements(); + if (selectedElements && _.isArray(selectedElements)) { + for (var i = 0; i< selectedElements.length; i++) { + if (Asc.c_oAscTypeSelectElement.Paragraph == selectedElements[i].get_ObjectType()) { + var props = selectedElements[i].get_ObjectValue(); + props.asc_putBullet(bullet); + this.api.paraApply(props); + break; + } + } + } + } else + this.api.put_ListType(rawData.data.type, rawData.data.subtype); + } Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.component.Analytics.trackEvent('ToolBar', 'List Type'); diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index b3c0b48d6..42006a9c2 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -1458,6 +1458,17 @@ define([ // set dataviews + this._markersArr = [ + {type: Asc.asc_PreviewBulletType.text, text: 'None'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00B7), specialFont: 'Symbol'}, + {type: Asc.asc_PreviewBulletType.char, char: 'o', specialFont: 'Courier New'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00A7), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x0076), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00D8), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00FC), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00A8), specialFont: 'Symbol'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x2013), specialFont: 'Arial'} + ]; var _conf = this.mnuMarkersPicker.conf; this.mnuMarkersPicker = new Common.UI.DataView({ el: $('#id-toolbar-menu-markers'), @@ -1467,15 +1478,15 @@ define([ allowScrollbar: false, delayRenderTips: true, store: new Common.UI.DataViewStore([ - {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: -1}, skipRenderOnChange: true, tip: this.tipNone}, - {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 1}, skipRenderOnChange: true, tip: this.tipMarkersFRound}, - {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 2}, skipRenderOnChange: true, tip: this.tipMarkersHRound}, - {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 3}, skipRenderOnChange: true, tip: this.tipMarkersFSquare}, - {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 4}, skipRenderOnChange: true, tip: this.tipMarkersStar}, - {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 5}, skipRenderOnChange: true, tip: this.tipMarkersArrow}, - {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 6}, skipRenderOnChange: true, tip: this.tipMarkersCheckmark}, - {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 7}, skipRenderOnChange: true, tip: this.tipMarkersFRhombus}, - {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 8}, skipRenderOnChange: true, tip: this.tipMarkersDash} + {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: -1},drawdata: this._markersArr[0], skipRenderOnChange: true, tip: this.tipNone}, + {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 1}, drawdata: this._markersArr[1], skipRenderOnChange: true, tip: this.tipMarkersFRound}, + {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 2}, drawdata: this._markersArr[2], skipRenderOnChange: true, tip: this.tipMarkersHRound}, + {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 3}, drawdata: this._markersArr[3], skipRenderOnChange: true, tip: this.tipMarkersFSquare}, + {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 4}, drawdata: this._markersArr[4], skipRenderOnChange: true, tip: this.tipMarkersStar}, + {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 5}, drawdata: this._markersArr[5], skipRenderOnChange: true, tip: this.tipMarkersArrow}, + {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 6}, drawdata: this._markersArr[6], skipRenderOnChange: true, tip: this.tipMarkersCheckmark}, + {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 7}, drawdata: this._markersArr[7], skipRenderOnChange: true, tip: this.tipMarkersFRhombus}, + {id: 'id-markers-' + Common.UI.getId(), data: {type: 0, subtype: 8}, drawdata: this._markersArr[8], skipRenderOnChange: true, tip: this.tipMarkersDash} ]), itemTemplate: _.template('
    ') }); @@ -1491,14 +1502,14 @@ define([ allowScrollbar: false, delayRenderTips: true, store: new Common.UI.DataViewStore([ - {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: -1}, skipRenderOnChange: true, tip: this.tipNone}, - {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 4}, skipRenderOnChange: true, tip: this.tipNumCapitalLetters}, - {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 5}, skipRenderOnChange: true, tip: this.tipNumLettersParentheses}, - {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 6}, skipRenderOnChange: true, tip: this.tipNumLettersPoints}, - {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 1}, skipRenderOnChange: true, tip: this.tipNumNumbersPoint}, - {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 2}, skipRenderOnChange: true, tip: this.tipNumNumbersParentheses}, - {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 3}, skipRenderOnChange: true, tip: this.tipNumRoman}, - {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 7}, skipRenderOnChange: true, tip: this.tipNumRomanSmall} + {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: -1},drawdata: {type: Asc.asc_PreviewBulletType.text, text: 'None'}, skipRenderOnChange: true, tip: this.tipNone}, + {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 4}, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.UpperLetterDot_Left}, skipRenderOnChange: true, tip: this.tipNumCapitalLetters}, + {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 5}, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.LowerLetterBracket_Left}, skipRenderOnChange: true, tip: this.tipNumLettersParentheses}, + {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 6}, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.LowerLetterDot_Left}, skipRenderOnChange: true, tip: this.tipNumLettersPoints}, + {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 1}, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.DecimalDot_Right}, skipRenderOnChange: true, tip: this.tipNumNumbersPoint}, + {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 2}, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.DecimalBracket_Right}, skipRenderOnChange: true, tip: this.tipNumNumbersParentheses}, + {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 3}, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.UpperRomanDot_Right}, skipRenderOnChange: true, tip: this.tipNumRoman}, + {id: 'id-numbers-' + Common.UI.getId(), data: {type: 1, subtype: 7}, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.LowerRomanDot_Right}, skipRenderOnChange: true, tip: this.tipNumRomanSmall} ]), itemTemplate: _.template('
    ') }); diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index c78329dfd..5137cafa3 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -236,7 +236,7 @@ define([ view.menuParagraphVAlign.menu.on('item:click', _.bind(me.onParagraphVAlign, me)); view.menuParagraphDirection.menu.on('item:click', _.bind(me.onParagraphDirection, me)); view.menuParagraphBullets.menu.on('item:click', _.bind(me.onSelectBulletMenu, me)); - view.menuParagraphBullets.menu.on('render:after', _.bind(me.onBulletMenuShowAfter, me)); + // view.menuParagraphBullets.menu.on('render:after', _.bind(me.onBulletMenuShowAfter, me)); view.menuParagraphBullets.menu.on('show:after', _.bind(me.onBulletMenuShowAfter, me)); view.menuAddHyperlinkShape.on('click', _.bind(me.onInsHyperlink, me)); view.menuEditHyperlinkShape.on('click', _.bind(me.onInsHyperlink, me)); @@ -918,6 +918,7 @@ define([ api: me.api, props: props, type: 0, + storage: me.permissions.canRequestInsertImage || me.permissions.fileChoiceUrl && me.permissions.fileChoiceUrl.indexOf("{documentType}")>-1, interfaceLang: me.permissions.lang, handler: function(result, value) { if (result == 'ok') { @@ -949,7 +950,25 @@ define([ rawData = record; } - if (this.api) + if (rawData.type===0 && rawData.subtype===0x1000) {// custom bullet + var bullet = new Asc.asc_CBullet(); + if (rawData.drawdata.type===Asc.asc_PreviewBulletType.char) { + bullet.asc_putSymbol(rawData.drawdata.char); + bullet.asc_putFont(rawData.drawdata.specialFont); + } else if (rawData.drawdata.type===Asc.asc_PreviewBulletType.image) + bullet.asc_fillBulletImage(rawData.drawdata.imageId); + + var props; + var selectedObjects = this.api.asc_getGraphicObjectProps(); + for (var i = 0; i < selectedObjects.length; i++) { + if (selectedObjects[i].asc_getObjectType() == Asc.c_oAscTypeSelectElement.Paragraph) { + props = selectedObjects[i].asc_getObjectValue(); + props.asc_putBullet(bullet); + this.api.asc_setGraphicObjectProps(props); + break; + } + } + } else this.api.asc_setListType(rawData.type, rawData.subtype); if (e.type !== 'click') @@ -2111,9 +2130,48 @@ define([ documentHolder.menuParagraphDirect270.setChecked(direct == Asc.c_oAscVertDrawingText.vert270); documentHolder.menuParagraphBulletNone.setChecked(listtype.get_ListType() == -1); - // documentHolder.mnuListSettings.setDisabled(listtype.get_ListType() == -1); - var rec = documentHolder.paraBulletsPicker.store.findWhere({ type: listtype.get_ListType(), subtype: listtype.get_ListSubType() }); + var type = listtype.get_ListType(), + subtype = listtype.get_ListSubType(), + rec, + defrec = documentHolder.paraBulletsPicker.store.at(7), + drawDefBullet = (defrec.get('subtype')===0x1000) && (type===1 || subtype!==0x1000); + if (type===1 || subtype!==0x1000) { + rec = documentHolder.paraBulletsPicker.store.findWhere({ type: type, subtype: subtype }); + } else { + var bullet = listtype.asc_getListCustom(); + if (bullet) { + var bullettype = bullet.asc_getType(); + if (bullettype === Asc.asc_PreviewBulletType.char) { + var symbol = bullet.asc_getChar(); + if (symbol) { + rec = defrec; + rec.set('subtype', 0x1000); + rec.set('drawdata', {type: bullettype, char: symbol, specialFont: bullet.asc_getSpecialFont()}); + rec.set('tip', ''); + documentHolder.paraBulletsPicker.dataViewItems && this.updateBulletTip(documentHolder.paraBulletsPicker.dataViewItems[7], ''); + drawDefBullet = false; + + } + } else if (bullettype === Asc.asc_PreviewBulletType.image) { + var id = bullet.asc_getImageId(); + if (id) { + rec = defrec; + rec.set('subtype', 0x1000); + rec.set('drawdata', {type: bullettype, imageId: id}); + rec.set('tip', ''); + documentHolder.paraBulletsPicker.dataViewItems && this.updateBulletTip(documentHolder.paraBulletsPicker.dataViewItems[7], ''); + drawDefBullet = false; + } + } + } + } documentHolder.paraBulletsPicker.selectRecord(rec, true); + if (drawDefBullet) { + defrec.set('subtype', 8); + defrec.set('drawdata', documentHolder._markersArr[7]); + defrec.set('tip', documentHolder.tipMarkersDash); + documentHolder.paraBulletsPicker.dataViewItems && this.updateBulletTip(documentHolder.paraBulletsPicker.dataViewItems[7], documentHolder.tipMarkersDash); + } } else if (elType == Asc.c_oAscTypeSelectElement.Paragraph) { documentHolder.pmiTextAdvanced.textInfo = selectedObjects[i].asc_getObjectValue(); isObjLocked = isObjLocked || documentHolder.pmiTextAdvanced.textInfo.asc_getLocked(); @@ -3764,6 +3822,7 @@ define([ outerMenu: {menu: view.menuParagraphBullets.menu, index: 0}, groups : view.paraBulletsPicker.groups, store : view.paraBulletsPicker.store, + delayRenderTips: true, itemTemplate: _.template('<% if (type==0) { %>' + '
    ' + '<% } else if (type==1) { %>' + @@ -3779,17 +3838,30 @@ define([ var store = this.documentHolder.paraBulletsPicker.store; var arrNum = [], arrMarker = []; store.each(function(item){ - if (item.get('group')=='menu-list-bullet-group') - arrMarker.push(item.get('id')); + var data = item.get('drawdata'); + data['divId'] = item.get('id'); + if (item.get('group')==='menu-list-bullet-group') + arrMarker.push(data); else - arrNum.push(item.get('id')); + arrNum.push(data); }); + if (this.api && this.api.SetDrawImagePreviewBulletForMenu) { this.api.SetDrawImagePreviewBulletForMenu(arrMarker, 0); this.api.SetDrawImagePreviewBulletForMenu(arrNum, 1); } }, + updateBulletTip: function(view, title) { + if (view) { + var tip = $(view.el).data('bs.tooltip'); + if (tip) { + tip.options.title = title; + tip.$tip.find('.tooltip-inner').text(title); + } + } + }, + onSignatureClick: function(item) { var datavalue = item.cmpEl.attr('data-value'); switch (item.value) { diff --git a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js index 159f2d452..bcf77715e 100644 --- a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js @@ -966,25 +966,35 @@ define([ }) }); + me._markersArr = [ + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00B7), specialFont: 'Symbol'}, + {type: Asc.asc_PreviewBulletType.char, char: 'o', specialFont: 'Courier New'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00A7), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x0076), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00D8), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00FC), specialFont: 'Wingdings'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x00A8), specialFont: 'Symbol'}, + {type: Asc.asc_PreviewBulletType.char, char: String.fromCharCode(0x2013), specialFont: 'Arial'} + ]; me.paraBulletsPicker = { conf: {rec: null}, delayRenderTips: true, store : new Common.UI.DataViewStore([ - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 1, skipRenderOnChange: true, tip: this.tipMarkersFRound}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 2, skipRenderOnChange: true, tip: this.tipMarkersHRound}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 3, skipRenderOnChange: true, tip: this.tipMarkersFSquare}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 4, skipRenderOnChange: true, tip: this.tipMarkersStar}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 5, skipRenderOnChange: true, tip: this.tipMarkersArrow}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 6, skipRenderOnChange: true, tip: this.tipMarkersCheckmark}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 7, skipRenderOnChange: true, tip: this.tipMarkersFRhombus}, - {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 8, skipRenderOnChange: true, tip: this.tipMarkersDash}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 4, skipRenderOnChange: true, tip: this.tipNumCapitalLetters}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 5, skipRenderOnChange: true, tip: this.tipNumLettersParentheses}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 6, skipRenderOnChange: true, tip: this.tipNumLettersPoints}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 1, skipRenderOnChange: true, tip: this.tipNumNumbersPoint}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 2, skipRenderOnChange: true, tip: this.tipNumNumbersParentheses}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 3, skipRenderOnChange: true, tip: this.tipNumRoman}, - {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 7, skipRenderOnChange: true, tip: this.tipNumRomanSmall} + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 1, drawdata: me._markersArr[0], skipRenderOnChange: true, tip: this.tipMarkersFRound}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 2, drawdata: me._markersArr[1], skipRenderOnChange: true, tip: this.tipMarkersHRound}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 3, drawdata: me._markersArr[2], skipRenderOnChange: true, tip: this.tipMarkersFSquare}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 4, drawdata: me._markersArr[3], skipRenderOnChange: true, tip: this.tipMarkersStar}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 5, drawdata: me._markersArr[4], skipRenderOnChange: true, tip: this.tipMarkersArrow}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 6, drawdata: me._markersArr[5], skipRenderOnChange: true, tip: this.tipMarkersCheckmark}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 7, drawdata: me._markersArr[6], skipRenderOnChange: true, tip: this.tipMarkersFRhombus}, + {group: 'menu-list-bullet-group', id: 'id-markers-' + Common.UI.getId(), type: 0, subtype: 8, drawdata: me._markersArr[7], skipRenderOnChange: true, tip: this.tipMarkersDash}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 4, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.UpperLetterDot_Left}, skipRenderOnChange: true, tip: this.tipNumCapitalLetters}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 5, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.LowerLetterBracket_Left}, skipRenderOnChange: true, tip: this.tipNumLettersParentheses}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 6, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.LowerLetterDot_Left}, skipRenderOnChange: true, tip: this.tipNumLettersPoints}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 1, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.DecimalDot_Right}, skipRenderOnChange: true, tip: this.tipNumNumbersPoint}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 2, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.DecimalBracket_Right}, skipRenderOnChange: true, tip: this.tipNumNumbersParentheses}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 3, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.UpperRomanDot_Right}, skipRenderOnChange: true, tip: this.tipNumRoman}, + {group: 'menu-list-number-group', id: 'id-numbers-' + Common.UI.getId(), type: 1, subtype: 7, drawdata: {type: Asc.asc_PreviewBulletType.number, numberingType: Asc.asc_oAscNumberingLevel.LowerRomanDot_Right}, skipRenderOnChange: true, tip: this.tipNumRomanSmall} ]), groups: new Common.UI.DataViewGroupStore([ {id: 'menu-list-bullet-group', caption: this.textBullets},