[DE] refactoring

This commit is contained in:
Maxim Kadushkin 2017-03-06 12:30:18 +03:00
parent 63da5b2483
commit eed89a5c5b
5 changed files with 55 additions and 78 deletions

View file

@ -682,6 +682,25 @@ Common.Utils.fillUserInfo = function(info, lang, defname) {
return _user; return _user;
}; };
Common.Utils.createXhr = function () {
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
// Extend javascript String type // Extend javascript String type
String.prototype.strongMatch = function(regExp){ String.prototype.strongMatch = function(regExp){
if (regExp && regExp instanceof RegExp) { if (regExp && regExp instanceof RegExp) {

View file

@ -527,8 +527,8 @@ define([
(new Promise(function (resolve) { (new Promise(function (resolve) {
Common.NotificationCenter.on('app:ready', function () { resolve(); }); Common.NotificationCenter.on('app:ready', function () { resolve(); });
})).then(function(){ })).then(function(){
me.btnPrev.updateHint(me.txtPrev); me.btnPrev.updateHint(me.hintPrev);
me.btnNext.updateHint(me.txtNext); me.btnNext.updateHint(me.hintNext);
me.btnTurnOn.updateHint(me.textChangesOn); me.btnTurnOn.updateHint(me.textChangesOn);
setEvents.call(me); setEvents.call(me);
} }
@ -575,8 +575,6 @@ define([
return Common.Utils.String.htmlEncode(username); return Common.Utils.String.htmlEncode(username);
}, },
txtPrev: 'To previous change',
txtNext: 'To next change',
textChangesOn: 'Preview changes', textChangesOn: 'Preview changes',
txtAccept: 'Accept', txtAccept: 'Accept',
txtAcceptCurrent: 'Accept current Changes', txtAcceptCurrent: 'Accept current Changes',

View file

@ -526,7 +526,7 @@ define([
toolbarView = toolbarController.getView('Toolbar'); toolbarView = toolbarController.getView('Toolbar');
if (this.appOptions.isEdit && toolbarView && (toolbarView.btnInsertShape.pressed || toolbarView.btnInsertText.pressed) && if (this.appOptions.isEdit && toolbarView && (toolbarView.btnInsertShape.pressed || toolbarView.btnInsertText.pressed) &&
( !_.isObject(arguments[1]) || arguments[1].id !== 'id-toolbar-btn-insertshape')) { // TODO: Event from api is needed to clear btnInsertShape state ( !_.isObject(arguments[1]) || arguments[1].id !== 'tlb-btn-insshape')) { // TODO: Event from api is needed to clear btnInsertShape state
if (this.api) if (this.api)
this.api.StartAddShape('', false); this.api.StartAddShape('', false);
@ -865,7 +865,7 @@ define([
pluginsController.setApi(me.api); pluginsController.setApi(me.api);
me.updatePlugins(me.plugins, false); me.updatePlugins(me.plugins, false);
me.requestPlugins('../../../../sdkjs-plugins/config.json'); me.requestPlugins('../../../../plugins.json');
me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me)); me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me));
documentHolderController.setApi(me.api); documentHolderController.setApi(me.api);
@ -1836,37 +1836,17 @@ define([
requestPlugins: function(pluginsPath) { // request plugins requestPlugins: function(pluginsPath) { // request plugins
if (!pluginsPath) return; if (!pluginsPath) return;
var _createXMLHTTPObject = function() {
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
};
var _getPluginJson = function(plugin) { var _getPluginJson = function(plugin) {
if (!plugin) return ''; if ( plugin ) {
try { try {
var xhrObj = _createXMLHTTPObject(); var xhrObj = Common.Utils.createXhr();
if (xhrObj && plugin) { if (xhrObj && plugin) {
xhrObj.open('GET', plugin, false); xhrObj.open('GET', plugin, false);
xhrObj.send(''); xhrObj.send('');
var pluginJson = eval("(" + xhrObj.responseText + ")"); return JSON.parse(xhrObj.responseText);
return pluginJson;
} }
} catch (e) {}
} }
catch (e) {}
return null; return null;
}; };
@ -1881,37 +1861,17 @@ define([
var pluginsData = (uiCustomize) ? plugins.UIpluginsData : plugins.pluginsData; var pluginsData = (uiCustomize) ? plugins.UIpluginsData : plugins.pluginsData;
if (!pluginsData || pluginsData.length<1) return; if (!pluginsData || pluginsData.length<1) return;
var _createXMLHTTPObject = function() {
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
};
var _getPluginJson = function(plugin) { var _getPluginJson = function(plugin) {
if (!plugin) return ''; if ( plugin ) {
try { try {
var xhrObj = _createXMLHTTPObject(); var xhrObj = Common.Utils.createXhr();
if (xhrObj && plugin) { if (xhrObj && plugin) {
xhrObj.open('GET', plugin, false); xhrObj.open('GET', plugin, false);
xhrObj.send(''); xhrObj.send('');
var pluginJson = eval("(" + xhrObj.responseText + ")"); return JSON.parse(xhrObj.responseText);
return pluginJson;
} }
} catch (e) {}
} }
catch (e) {}
return null; return null;
}; };

View file

@ -578,7 +578,7 @@ define([
this.mnuMultilevelPicker = clone(this.mnuMarkersPicker); this.mnuMultilevelPicker = clone(this.mnuMarkersPicker);
this.btnInsertTable = new Common.UI.Button({ this.btnInsertTable = new Common.UI.Button({
id: 'id-toolbar-btn-inserttable', id: 'tlb-btn-instable',
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'btn-inserttable', iconCls: 'btn-inserttable',
caption: me.capBtnInsTable, caption: me.capBtnInsTable,
@ -592,7 +592,7 @@ define([
this.paragraphControls.push(this.btnInsertTable); this.paragraphControls.push(this.btnInsertTable);
this.btnInsertImage = new Common.UI.Button({ this.btnInsertImage = new Common.UI.Button({
id: 'id-toolbar-btn-insertimage', id: 'tlb-btn-insimage',
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'btn-insertimage', iconCls: 'btn-insertimage',
caption: me.capBtnInsImage, caption: me.capBtnInsImage,
@ -606,7 +606,7 @@ define([
this.paragraphControls.push(this.btnInsertImage); this.paragraphControls.push(this.btnInsertImage);
this.btnInsertChart = new Common.UI.Button({ this.btnInsertChart = new Common.UI.Button({
id: 'id-toolbar-btn-insertchart', id: 'tlb-btn-inschart',
cls: 'btn-toolbar', cls: 'btn-toolbar',
caption: me.capBtnInsChart, caption: me.capBtnInsChart,
iconCls: 'btn-insertchart', iconCls: 'btn-insertchart',
@ -620,7 +620,7 @@ define([
this.paragraphControls.push(this.btnInsertChart); this.paragraphControls.push(this.btnInsertChart);
this.btnInsertText = new Common.UI.Button({ this.btnInsertText = new Common.UI.Button({
id: 'id-toolbar-btn-inserttext', id: 'tlb-btn-inserttext',
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'btn-text', iconCls: 'btn-text',
caption: me.capBtnInsTextbox, caption: me.capBtnInsTextbox,
@ -646,7 +646,7 @@ define([
this.paragraphControls.push(this.btnInsertText); this.paragraphControls.push(this.btnInsertText);
this.btnInsertPageBreak = new Common.UI.Button({ this.btnInsertPageBreak = new Common.UI.Button({
id: 'id-toolbar-btn-pagebreak', id: 'tlb-btn-pagebreak',
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'btn-pagebreak', iconCls: 'btn-pagebreak',
split: true, split: true,
@ -656,7 +656,7 @@ define([
this.paragraphControls.push(this.btnInsertPageBreak); this.paragraphControls.push(this.btnInsertPageBreak);
this.btnInsertHyperlink = new Common.UI.Button({ this.btnInsertHyperlink = new Common.UI.Button({
id: 'id-toolbar-btn-inserthyperlink', id: 'tlb-btn-inshyperlink',
cls: 'btn-toolbar', cls: 'btn-toolbar',
caption: me.capBtnInsLink, caption: me.capBtnInsLink,
iconCls: 'btn-inserthyperlink' iconCls: 'btn-inserthyperlink'
@ -687,7 +687,7 @@ define([
this.toolbarControls.push(this.btnEditHeader); this.toolbarControls.push(this.btnEditHeader);
this.btnInsertShape = new Common.UI.Button({ this.btnInsertShape = new Common.UI.Button({
id: 'id-toolbar-btn-insertshape', id: 'tlb-btn-insshape',
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'btn-insertshape', iconCls: 'btn-insertshape',
caption: me.capBtnInsShape, caption: me.capBtnInsShape,
@ -697,7 +697,7 @@ define([
this.paragraphControls.push(this.btnInsertShape); this.paragraphControls.push(this.btnInsertShape);
this.btnInsertEquation = new Common.UI.Button({ this.btnInsertEquation = new Common.UI.Button({
id: 'id-toolbar-btn-insertequation', id: 'tlb-btn-insequation',
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'btn-insertequation', iconCls: 'btn-insertequation',
caption: me.capBtnInsEquation, caption: me.capBtnInsEquation,
@ -707,7 +707,7 @@ define([
this.paragraphControls.push(this.btnInsertEquation); this.paragraphControls.push(this.btnInsertEquation);
this.btnDropCap = new Common.UI.Button({ this.btnDropCap = new Common.UI.Button({
id: 'id-toolbar-btn-dropcap', id: 'tlb-btn-dropcap',
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'btn-dropcap', iconCls: 'btn-dropcap',
caption: me.capBtnInsDropcap, caption: me.capBtnInsDropcap,
@ -744,7 +744,7 @@ define([
this.paragraphControls.push(this.btnDropCap); this.paragraphControls.push(this.btnDropCap);
this.btnColumns = new Common.UI.Button({ this.btnColumns = new Common.UI.Button({
id: 'id-toolbar-btn-columns', id: 'tlb-btn-columns',
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'btn-columns', iconCls: 'btn-columns',
caption: me.capBtnColumns, caption: me.capBtnColumns,
@ -792,7 +792,7 @@ define([
this.paragraphControls.push(this.btnColumns); this.paragraphControls.push(this.btnColumns);
this.btnPageOrient = new Common.UI.Button({ this.btnPageOrient = new Common.UI.Button({
id: 'id-toolbar-btn-pageorient', id: 'tlb-btn-pageorient',
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'btn-pageorient', iconCls: 'btn-pageorient',
caption: me.capBtnPageOrient, caption: me.capBtnPageOrient,
@ -828,7 +828,7 @@ define([
'<% } %></a>'); '<% } %></a>');
this.btnPageMargins = new Common.UI.Button({ this.btnPageMargins = new Common.UI.Button({
id: 'id-toolbar-btn-pagemargins', id: 'tlb-btn-pagemargins',
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'btn-pagemargins', iconCls: 'btn-pagemargins',
caption: me.capBtnMargins, caption: me.capBtnMargins,
@ -887,7 +887,7 @@ define([
'<%= parseFloat(Common.Utils.Metric.fnRecalcFromMM(options.value[1]).toFixed(2)) %> <%= Common.Utils.Metric.getCurrentMetricName() %></div></a>'); '<%= parseFloat(Common.Utils.Metric.fnRecalcFromMM(options.value[1]).toFixed(2)) %> <%= Common.Utils.Metric.getCurrentMetricName() %></div></a>');
this.btnPageSize = new Common.UI.Button({ this.btnPageSize = new Common.UI.Button({
id: 'id-toolbar-btn-pagesize', id: 'tlb-btn-pagesize',
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'btn-pagesize', iconCls: 'btn-pagesize',
caption: me.capBtnPageSize, caption: me.capBtnPageSize,
@ -2550,7 +2550,6 @@ define([
mniNoteSettings: 'Notes Settings', mniNoteSettings: 'Notes Settings',
textGotoFootnote: 'Go to Footnotes', textGotoFootnote: 'Go to Footnotes',
tipChangeChart: 'Change Chart Type' tipChangeChart: 'Change Chart Type'
} }
})(), DE.Views.Toolbar || {})); })(), DE.Views.Toolbar || {}));
}); });

View file

@ -64,6 +64,7 @@ button.notify .btn-menu-comments {background-position: -0*@toolbar-icon-size -60
} }
#file-menu-panel { #file-menu-panel {
height: -webkit-calc(~"100% + @{height-controls}");
height: calc(~"100% + @{height-controls}"); height: calc(~"100% + @{height-controls}");
top: -@height-controls; top: -@height-controls;
border-top: 1px solid @gray-dark; border-top: 1px solid @gray-dark;