[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;
};
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
String.prototype.strongMatch = function(regExp){
if (regExp && regExp instanceof RegExp) {

View file

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

View file

@ -526,7 +526,7 @@ define([
toolbarView = toolbarController.getView('Toolbar');
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)
this.api.StartAddShape('', false);
@ -865,7 +865,7 @@ define([
pluginsController.setApi(me.api);
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));
documentHolderController.setApi(me.api);
@ -1836,37 +1836,17 @@ define([
requestPlugins: function(pluginsPath) { // request plugins
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) {
if (!plugin) return '';
try {
var xhrObj = _createXMLHTTPObject();
if (xhrObj && plugin) {
xhrObj.open('GET', plugin, false);
xhrObj.send('');
var pluginJson = eval("(" + xhrObj.responseText + ")");
return pluginJson;
}
if ( plugin ) {
try {
var xhrObj = Common.Utils.createXhr();
if (xhrObj && plugin) {
xhrObj.open('GET', plugin, false);
xhrObj.send('');
return JSON.parse(xhrObj.responseText);
}
} catch (e) {}
}
catch (e) {}
return null;
};
@ -1881,37 +1861,17 @@ define([
var pluginsData = (uiCustomize) ? plugins.UIpluginsData : plugins.pluginsData;
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) {
if (!plugin) return '';
try {
var xhrObj = _createXMLHTTPObject();
if (xhrObj && plugin) {
xhrObj.open('GET', plugin, false);
xhrObj.send('');
var pluginJson = eval("(" + xhrObj.responseText + ")");
return pluginJson;
}
if ( plugin ) {
try {
var xhrObj = Common.Utils.createXhr();
if (xhrObj && plugin) {
xhrObj.open('GET', plugin, false);
xhrObj.send('');
return JSON.parse(xhrObj.responseText);
}
} catch (e) {}
}
catch (e) {}
return null;
};

View file

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

View file

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