diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index e538406040..f4a3b6a643 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -2894,14 +2894,14 @@ define([ buttons: [{value: 'ok', caption: this.textInsert}, 'close'], handler: function(dlg, result, settings) { if (result == 'ok') { - me.api.asc_insertSymbol(settings.font ? settings.font : me.api.get_TextProps().get_TextPr().get_FontFamily().get_Name(), settings.code, settings.special); + me.insertSymbol(settings.font, settings.code, settings.special); } else Common.NotificationCenter.trigger('edit:complete', me.toolbar); } }); me.dlgSymbolTable.show(); me.dlgSymbolTable.on('symbol:dblclick', function(cmp, result, settings) { - me.api.asc_insertSymbol(settings.font ? settings.font : me.api.get_TextProps().get_TextPr().get_FontFamily().get_Name(), settings.code, settings.special); + me.insertSymbol(settings.font, settings.code, settings.special); }); me.dlgSymbolTable.on('close', function(obj){ Common.NotificationCenter.trigger('edit:complete', me.toolbar); @@ -2911,7 +2911,13 @@ define([ onInsertSymbolItemClick: function(picker, item, record, e) { if (this.api && record) - this.api.asc_insertSymbol(record.font ? record.get('font') : this.api.get_TextProps().get_TextPr().get_FontFamily().get_Name(), record.get('code'), record.get('special')); + this.insertSymbol(record.get('font'), record.get('symbol'), record.get('special')); + }, + + insertSymbol: function(fontRecord, symbol, special){ + var font = fontRecord ? fontRecord: this.api.get_TextProps().get_TextPr().get_FontFamily().get_Name(); + this.api.asc_insertSymbol(font, symbol, special); + this.toolbar.saveSymbol(symbol, font); }, onApiMathTypes: function(equation) { diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index 1c6c2ef341..e18e163ccf 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -2362,7 +2362,7 @@ define([ })); // set dataviews - + this.symbolsArr = this.loadRecentSymbolsFromStorage(); this.mnuInsertSymbolsPicker = new Common.UI.DataView({ el: $('#id-toolbar-menu-symbols'), parentMenu: this.btnInsertSymbol.menu, @@ -2370,34 +2370,8 @@ define([ restoreHeight: 290, delayRenderTips: true, scrollAlwaysVisible: true, - store: new Common.UI.DataViewStore([ - { symbol: '2022', code: 8226}, - { symbol: '20AC', code: 8364}, - { symbol: 'FF04', code: 65284}, - { symbol: '00A5', code: 165}, - { symbol: '00A9', code: 169}, - { symbol: '00AE', code: 174}, - { symbol: '00BD', code: 189}, - { symbol: '00BC', code: 188}, - { symbol: '2260', code: 8800}, - { symbol: '00B1', code: 177}, - { symbol: '00F7', code: 247}, - { symbol: '221A', code: 8730}, - { symbol: '2264', code: 8804}, - { symbol: '2265', code: 8805}, - { symbol: '2122', code: 8482}, - { symbol: '221E', code: 8734}, - { symbol: '007E', code: 126}, - { symbol: '00B0', code: 176}, - { symbol: '00A7', code: 167}, - { symbol: '03B1', code: 945}, - { symbol: '03B2', code: 946}, - { symbol: '03C0', code: 960}, - { symbol: '0394', code: 916}, - { symbol: '263A', code: 9786}, - { symbol: '2665', code: 9829} - ]), - itemTemplate: _.template('
&#<%= code %>') + store: new Common.UI.DataViewStore(this.symbolsArr), + itemTemplate: _.template('
style ="font-family: <%= font %>"<% } %>>&#<%= symbol %>
') }); this.btnInsertSymbol.menu.setInnerMenu([{menu: this.mnuInsertSymbolsPicker, index: 0}]); this.btnInsertSymbol.menu.on('show:before', _.bind(function() { @@ -2916,6 +2890,65 @@ define([ this.btnPageMargins.menu.items[0].setVisible(false); }, + loadRecentSymbolsFromStorage: function(){ + var recents = Common.localStorage.getItem('de-fastRecentSymbols'); + if(!!recents) + return JSON.parse(recents); + return [ + { symbol: 8226, font: 'Arial', tip: 'Symbol: 8226'}, + { symbol: 8364, font: 'Arial', tip: 'Symbol: 8364'}, + { symbol: 65284, font: 'Arial', tip: 'Symbol: 65284'}, + { symbol: 165, font: 'Arial', tip: 'Symbol: 165'}, + { symbol: 169, font: 'Arial', tip: 'Symbol: 169'}, + { symbol: 174, font: 'Arial', tip: 'Symbol: 174'}, + { symbol: 189, font: 'Arial', tip: 'Symbol: 189'}, + { symbol: 188, font: 'Arial', tip: 'Symbol: 188'}, + { symbol: 8800, font: 'Arial', tip: 'Symbol: 8800'}, + { symbol: 177, font: 'Arial', tip: 'Symbol: 177'}, + { symbol: 247, font: 'Arial', tip: 'Symbol: 247'}, + { symbol: 8730, font: 'Arial', tip: 'Symbol: 8730'}, + { symbol: 8804, font: 'Arial', tip: 'Symbol: 8804'}, + { symbol: 8805, font: 'Arial', tip: 'Symbol: 8805'}, + { symbol: 8482, font: 'Arial', tip: 'Symbol: 8482'}, + { symbol: 8734, font: 'Arial', tip: 'Symbol: 8734'}, + { symbol: 126, font: 'Arial', tip: 'Symbol: 126'}, + { symbol: 176, font: 'Arial', tip: 'Symbol: 176'}, + { symbol: 167, font: 'Arial', tip: 'Symbol: 167'}, + { symbol: 945, font: 'Arial', tip: 'Symbol: 945'}, + { symbol: 946, font: 'Arial', tip: 'Symbol: 946'}, + { symbol: 960, font: 'Arial', tip: 'Symbol: 960'}, + { symbol: 916, font: 'Arial', tip: 'Symbol: 916'}, + { symbol: 9786, font: 'Arial', tip: 'Symbol: 9786'}, + { symbol: 9829, font: 'Arial', tip: 'Symbol: 9829'} + ]; + }, + + saveSymbol: function(symbol, font) { + var maxLength =25; + if(this.symbolsArr.length === 0){ + this.symbolsArr.push({symbol: symbol, font: font, tip: 'Symbol: ' + symbol}); + this.saveRecentSymbolsToStorage(); + return; + } + for(var i = 0; i < this.symbolsArr.length; ++i){ + if(this.symbolsArr[i].symbol === symbol && this.symbolsArr[i].font === font){ + this.symbolsArr.splice(i, 1); + break; + } + } + this.symbolsArr.splice(0, 0, {symbol: symbol, font: font, tip: 'Symbol: ' + symbol}); + if(this.symbolsArr.length > maxLength){ + this.symbolsArr.splice(maxLength, this.symbolsArr.length - maxLength); + } + this.saveRecentSymbolsToStorage(); + }, + + saveRecentSymbolsToStorage: function(){ + var sJSON = JSON.stringify(this.symbolsArr); + Common.localStorage.setItem( 'de-fastRecentSymbols', sJSON); + this.mnuInsertSymbolsPicker.store.reset(this.symbolsArr); + }, + loadListPresetsFromStorage: function(path, groupId) { var recents = Common.localStorage.getItem(path), arr = []; diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 7079dbd4b2..5bd84063d6 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -2352,21 +2352,26 @@ define([ symbol: selected && selected.length>0 ? selected.charAt(0) : undefined, handler: function(dlg, result, settings) { if (result == 'ok') { - me.api.asc_insertSymbol(settings.font ? settings.font : me.api.get_TextProps().get_TextPr().get_FontFamily().get_Name(), settings.code, settings.special); + me.insertSymbol(settings.font, settings.code, settings.special); } else Common.NotificationCenter.trigger('edit:complete', me.toolbar); } }); win.show(); win.on('symbol:dblclick', function(cmp, result, settings) { - me.api.asc_insertSymbol(settings.font ? settings.font : me.api.get_TextProps().get_TextPr().get_FontFamily().get_Name(), settings.code, settings.special); - }); + me.insertSymbol(settings.font, settings.code, settings.special); }); } }, onInsertSymbolItemClick: function(picker, item, record, e) { if (this.api && record) - this.api.asc_insertSymbol(record.font ? record.get('font') : this.api.get_TextProps().get_TextPr().get_FontFamily().get_Name(), record.get('code'), record.get('special')); + this.insertSymbol(record.get('font') , record.get('symbol'), record.get('special')); + }, + + insertSymbol: function(fontRecord, symbol, special){ + var font = fontRecord ? fontRecord: this.api.get_TextProps().get_TextPr().get_FontFamily().get_Name(); + this.api.asc_insertSymbol(font, symbol, special); + this.toolbar.saveSymbol(symbol, font); }, onApiMathTypes: function(equation) { diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index a39331c40e..182953bf96 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -1631,7 +1631,7 @@ define([ this.btnInsertTextArt.menu.on('show:before', onShowBeforeTextArt); // set dataviews - + this.symbolsArr = this.loadRecentSymbolsFromStorage(); this.mnuInsertSymbolsPicker = new Common.UI.DataView({ el: $('#id-toolbar-menu-symbols'), parentMenu: this.btnInsertSymbol.menu, @@ -1639,34 +1639,8 @@ define([ restoreHeight: 290, delayRenderTips: true, scrollAlwaysVisible: true, - store: new Common.UI.DataViewStore([ - { symbol: '2022', code: 8226}, - { symbol: '20AC', code: 8364}, - { symbol: 'FF04', code: 65284}, - { symbol: '00A5', code: 165}, - { symbol: '00A9', code: 169}, - { symbol: '00AE', code: 174}, - { symbol: '00BD', code: 189}, - { symbol: '00BC', code: 188}, - { symbol: '2260', code: 8800}, - { symbol: '00B1', code: 177}, - { symbol: '00F7', code: 247}, - { symbol: '221A', code: 8730}, - { symbol: '2264', code: 8804}, - { symbol: '2265', code: 8805}, - { symbol: '2122', code: 8482}, - { symbol: '221E', code: 8734}, - { symbol: '007E', code: 126}, - { symbol: '00B0', code: 176}, - { symbol: '00A7', code: 167}, - { symbol: '03B1', code: 945}, - { symbol: '03B2', code: 946}, - { symbol: '03C0', code: 960}, - { symbol: '0394', code: 916}, - { symbol: '263A', code: 9786}, - { symbol: '2665', code: 9829} - ]), - itemTemplate: _.template('
&#<%= code %>') + store: new Common.UI.DataViewStore(this.symbolsArr), + itemTemplate: _.template('
style ="font-family: <%= font %>"<% } %>>&#<%= symbol %>
') }); this.btnInsertSymbol.menu.setInnerMenu([{menu: this.mnuInsertSymbolsPicker, index: 0}]); this.btnInsertSymbol.menu.on('show:before', _.bind(function() { @@ -2096,6 +2070,66 @@ define([ } }, + loadRecentSymbolsFromStorage: function(){ + var recents = Common.localStorage.getItem('pe-fastRecentSymbols'); + if(!!recents) + return JSON.parse(recents); + return [ + { symbol: 8226, font: 'Arial', tip: 'Symbol: 8226'}, + { symbol: 8364, font: 'Arial', tip: 'Symbol: 8364'}, + { symbol: 65284, font: 'Arial', tip: 'Symbol: 65284'}, + { symbol: 165, font: 'Arial', tip: 'Symbol: 165'}, + { symbol: 169, font: 'Arial', tip: 'Symbol: 169'}, + { symbol: 174, font: 'Arial', tip: 'Symbol: 174'}, + { symbol: 189, font: 'Arial', tip: 'Symbol: 189'}, + { symbol: 188, font: 'Arial', tip: 'Symbol: 188'}, + { symbol: 8800, font: 'Arial', tip: 'Symbol: 8800'}, + { symbol: 177, font: 'Arial', tip: 'Symbol: 177'}, + { symbol: 247, font: 'Arial', tip: 'Symbol: 247'}, + { symbol: 8730, font: 'Arial', tip: 'Symbol: 8730'}, + { symbol: 8804, font: 'Arial', tip: 'Symbol: 8804'}, + { symbol: 8805, font: 'Arial', tip: 'Symbol: 8805'}, + { symbol: 8482, font: 'Arial', tip: 'Symbol: 8482'}, + { symbol: 8734, font: 'Arial', tip: 'Symbol: 8734'}, + { symbol: 126, font: 'Arial', tip: 'Symbol: 126'}, + { symbol: 176, font: 'Arial', tip: 'Symbol: 176'}, + { symbol: 167, font: 'Arial', tip: 'Symbol: 167'}, + { symbol: 945, font: 'Arial', tip: 'Symbol: 945'}, + { symbol: 946, font: 'Arial', tip: 'Symbol: 946'}, + { symbol: 960, font: 'Arial', tip: 'Symbol: 960'}, + { symbol: 916, font: 'Arial', tip: 'Symbol: 916'}, + { symbol: 9786, font: 'Arial', tip: 'Symbol: 9786'}, + { symbol: 9829, font: 'Arial', tip: 'Symbol: 9829'} + ]; + + }, + + saveSymbol: function(symbol, font) { + var maxLength =25; + if(this.symbolsArr.length === 0){ + this.symbolsArr.push({symbol: symbol, font: font, tip: 'Symbol: ' + symbol}); + this.saveRecentSymbolsToStorage(); + return; + } + for(var i = 0; i < this.symbolsArr.length; ++i){ + if(this.symbolsArr[i].symbol === symbol && this.symbolsArr[i].font === font){ + this.symbolsArr.splice(i, 1); + break; + } + } + this.symbolsArr.splice(0, 0, {symbol: symbol, font: font, tip: 'Symbol: ' + symbol}); + if(this.symbolsArr.length > maxLength){ + this.symbolsArr.splice(maxLength, this.symbolsArr.length - maxLength); + } + this.saveRecentSymbolsToStorage(); + }, + + saveRecentSymbolsToStorage: function(){ + var sJSON = JSON.stringify(this.symbolsArr); + Common.localStorage.setItem( 'pe-fastRecentSymbols', sJSON); + this.mnuInsertSymbolsPicker.store.reset(this.symbolsArr); + }, + textBold: 'Bold', textItalic: 'Italic', textUnderline: 'Underline', diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index b23df7dc7f..c2d75a65f7 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -4081,21 +4081,27 @@ define([ symbol: selected && selected.length>0 ? selected.charAt(0) : undefined, handler: function(dlg, result, settings) { if (result == 'ok') { - me.api.asc_insertSymbol(settings.font ? settings.font : me.api.asc_getCellInfo().asc_getXfs().asc_getFontName(), settings.code, settings.special); + me.insertSymbol(settings.font, settings.code, settings.special); } else Common.NotificationCenter.trigger('edit:complete', me.toolbar); } }); win.show(); win.on('symbol:dblclick', function(cmp, result, settings) { - me.api.asc_insertSymbol(settings.font ? settings.font : me.api.asc_getCellInfo().asc_getXfs().asc_getFontName(), settings.code, settings.special); + me.insertSymbol(settings.font, settings.code, settings.special); }); } }, onInsertSymbolItemClick: function(picker, item, record, e) { if (this.api && record) - this.api.asc_insertSymbol(record.font ? record.get('font') : this.api.asc_getCellInfo().asc_getXfs().asc_getFontName(), record.get('code'), record.get('special')); + this.insertSymbol(record.get('font'), record.get('symbol'), record.get('special')); + }, + + insertSymbol: function(fontRecord, symbol, special){ + var font = fontRecord ? fontRecord: this.api.asc_getCellInfo().asc_getXfs().asc_getFontName(); + this.api.asc_insertSymbol(font, symbol, special); + this.toolbar.saveSymbol(symbol, font); }, onInsertSlicerClick: function() { diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index a3bc165925..9f800a1eaa 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -2759,6 +2759,8 @@ define([ this.btnInsertTextArt.menu.on('show:before', onShowBeforeTextArt); } + + this.symbolsArr = this.loadRecentSymbolsFromStorage(); this.mnuInsertSymbolsPicker = new Common.UI.DataView({ el: $('#id-toolbar-menu-symbols'), parentMenu: this.btnInsertSymbol.menu, @@ -2766,34 +2768,8 @@ define([ restoreHeight: 290, delayRenderTips: true, scrollAlwaysVisible: true, - store: new Common.UI.DataViewStore([ - { symbol: '2022', code: 8226}, - { symbol: '20AC', code: 8364}, - { symbol: 'FF04', code: 65284}, - { symbol: '00A5', code: 165}, - { symbol: '00A9', code: 169}, - { symbol: '00AE', code: 174}, - { symbol: '00BD', code: 189}, - { symbol: '00BC', code: 188}, - { symbol: '2260', code: 8800}, - { symbol: '00B1', code: 177}, - { symbol: '00F7', code: 247}, - { symbol: '221A', code: 8730}, - { symbol: '2264', code: 8804}, - { symbol: '2265', code: 8805}, - { symbol: '2122', code: 8482}, - { symbol: '221E', code: 8734}, - { symbol: '007E', code: 126}, - { symbol: '00B0', code: 176}, - { symbol: '00A7', code: 167}, - { symbol: '03B1', code: 945}, - { symbol: '03B2', code: 946}, - { symbol: '03C0', code: 960}, - { symbol: '0394', code: 916}, - { symbol: '263A', code: 9786}, - { symbol: '2665', code: 9829} - ]), - itemTemplate: _.template('
&#<%= code %>') + store: new Common.UI.DataViewStore(this.symbolsArr), + itemTemplate: _.template('
style ="font-family: <%= font %>"<% } %>>&#<%= symbol %>
') }); this.btnInsertSymbol.menu.setInnerMenu([{menu: this.mnuInsertSymbolsPicker, index: 0}]); this.btnInsertSymbol.menu.on('show:before', _.bind(function() { @@ -3283,6 +3259,66 @@ define([ }, + loadRecentSymbolsFromStorage: function(){ + var recents = Common.localStorage.getItem('sse-fastRecentSymbols'); + if(!!recents) + return JSON.parse(recents); + return [ + { symbol: 8226, font: 'Arial', tip: 'Symbol: 8226'}, + { symbol: 8364, font: 'Arial', tip: 'Symbol: 8364'}, + { symbol: 65284, font: 'Arial', tip: 'Symbol: 65284'}, + { symbol: 165, font: 'Arial', tip: 'Symbol: 165'}, + { symbol: 169, font: 'Arial', tip: 'Symbol: 169'}, + { symbol: 174, font: 'Arial', tip: 'Symbol: 174'}, + { symbol: 189, font: 'Arial', tip: 'Symbol: 189'}, + { symbol: 188, font: 'Arial', tip: 'Symbol: 188'}, + { symbol: 8800, font: 'Arial', tip: 'Symbol: 8800'}, + { symbol: 177, font: 'Arial', tip: 'Symbol: 177'}, + { symbol: 247, font: 'Arial', tip: 'Symbol: 247'}, + { symbol: 8730, font: 'Arial', tip: 'Symbol: 8730'}, + { symbol: 8804, font: 'Arial', tip: 'Symbol: 8804'}, + { symbol: 8805, font: 'Arial', tip: 'Symbol: 8805'}, + { symbol: 8482, font: 'Arial', tip: 'Symbol: 8482'}, + { symbol: 8734, font: 'Arial', tip: 'Symbol: 8734'}, + { symbol: 126, font: 'Arial', tip: 'Symbol: 126'}, + { symbol: 176, font: 'Arial', tip: 'Symbol: 176'}, + { symbol: 167, font: 'Arial', tip: 'Symbol: 167'}, + { symbol: 945, font: 'Arial', tip: 'Symbol: 945'}, + { symbol: 946, font: 'Arial', tip: 'Symbol: 946'}, + { symbol: 960, font: 'Arial', tip: 'Symbol: 960'}, + { symbol: 916, font: 'Arial', tip: 'Symbol: 916'}, + { symbol: 9786, font: 'Arial', tip: 'Symbol: 9786'}, + { symbol: 9829, font: 'Arial', tip: 'Symbol: 9829'} + ]; + + }, + + saveSymbol: function(symbol, font) { + var maxLength =25; + if(this.symbolsArr.length === 0){ + this.symbolsArr.push({symbol: symbol, font: font, tip: 'Symbol: ' + symbol}); + this.saveRecentSymbolsToStorage(); + return; + } + for(var i = 0; i < this.symbolsArr.length; ++i){ + if(this.symbolsArr[i].symbol === symbol && this.symbolsArr[i].font === font){ + this.symbolsArr.splice(i, 1); + break; + } + } + this.symbolsArr.splice(0, 0, {symbol: symbol, font: font, tip: 'Symbol: ' + symbol}); + if(this.symbolsArr.length > maxLength){ + this.symbolsArr.splice(maxLength, this.symbolsArr.length - maxLength); + } + this.saveRecentSymbolsToStorage(); + }, + + saveRecentSymbolsToStorage: function(){ + var sJSON = JSON.stringify(this.symbolsArr); + Common.localStorage.setItem( 'sse-fastRecentSymbols', sJSON); + this.mnuInsertSymbolsPicker.store.reset(this.symbolsArr); + }, + textBold: 'Bold', textItalic: 'Italic', textUnderline: 'Underline',