Apply document info (subject, title, comment, authors)

This commit is contained in:
Julia Radzhabova 2019-06-21 14:34:40 +03:00
parent fceec13206
commit aa9c0a2f5c
4 changed files with 91 additions and 25 deletions

View file

@ -760,6 +760,8 @@ define([
this.infoObj = {PageCount: 0, WordsCount: 0, ParagraphCount: 0, SymbolsCount: 0, SymbolsWSCount:0}; this.infoObj = {PageCount: 0, WordsCount: 0, ParagraphCount: 0, SymbolsCount: 0, SymbolsWSCount:0};
this.inProgress = false; this.inProgress = false;
this.menu = options.menu; this.menu = options.menu;
this.coreProps = null;
this.authors = [];
}, },
render: function() { render: function() {
@ -787,7 +789,10 @@ define([
placeHolder : this.txtAddText, placeHolder : this.txtAddText,
validateOnBlur: false validateOnBlur: false
}).on('changed:after', function() { }).on('changed:after', function() {
// me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); if (me.coreProps && me.api) {
me.coreProps.asc_putTitle(me.inputTitle.getValue());
me.api.asc_setCoreProps(me.coreProps);
}
}); });
this.inputSubject = new Common.UI.InputField({ this.inputSubject = new Common.UI.InputField({
el : $('#id-info-subject'), el : $('#id-info-subject'),
@ -795,7 +800,10 @@ define([
placeHolder : this.txtAddText, placeHolder : this.txtAddText,
validateOnBlur: false validateOnBlur: false
}).on('changed:after', function() { }).on('changed:after', function() {
// me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); if (me.coreProps && me.api) {
me.coreProps.asc_putSubject(me.inputSubject.getValue());
me.api.asc_setCoreProps(me.coreProps);
}
}); });
this.inputComment = new Common.UI.InputField({ this.inputComment = new Common.UI.InputField({
el : $('#id-info-comment'), el : $('#id-info-comment'),
@ -803,7 +811,10 @@ define([
placeHolder : this.txtAddText, placeHolder : this.txtAddText,
validateOnBlur: false validateOnBlur: false
}).on('changed:after', function() { }).on('changed:after', function() {
// me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); if (me.coreProps && me.api) {
me.coreProps.asc_putDescription(me.inputComment.getValue());
me.api.asc_setCoreProps(me.coreProps);
}
}); });
// modify info // modify info
@ -823,7 +834,11 @@ define([
var el = btn.closest('tr'), var el = btn.closest('tr'),
idx = me.tblAuthor.find('tr').index(el); idx = me.tblAuthor.find('tr').index(el);
el.remove(); el.remove();
// remove idx author from info me.authors.splice(idx, 1);
if (me.coreProps && me.api) {
me.coreProps.asc_putCreator(me.authors.join(';'));
me.api.asc_setCoreProps(me.coreProps);
}
} }
}); });
@ -840,10 +855,14 @@ define([
if (str) { if (str) {
var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str)));
me.trAuthor.before(div); me.trAuthor.before(div);
// add str author to info me.authors.push(item);
} }
}); });
me.inputAuthor.setValue(''); me.inputAuthor.setValue('');
if (me.coreProps && me.api) {
me.coreProps.asc_putCreator(me.authors.join(';'));
me.api.asc_setCoreProps(me.coreProps);
}
} }
}); });
@ -903,9 +922,9 @@ define([
} }
this._ShowHideInfoItem(this.lblApplication, !!appname); this._ShowHideInfoItem(this.lblApplication, !!appname);
var props = (this.api) ? this.api.asc_getCoreProps() : null; this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null;
if (props) { if (this.coreProps) {
var value = props.asc_getCreated(); var value = this.coreProps.asc_getCreated();
if (value) if (value)
this.lblDate.text(value.toLocaleString()); this.lblDate.text(value.toLocaleString());
this._ShowHideInfoItem(this.lblDate, !!value); this._ShowHideInfoItem(this.lblDate, !!value);
@ -920,6 +939,7 @@ define([
props = (this.api) ? this.api.asc_getCoreProps() : null, props = (this.api) ? this.api.asc_getCoreProps() : null,
value; value;
this.coreProps = props;
// var app = (this.api) ? this.api.asc_getAppProps() : null; // var app = (this.api) ? this.api.asc_getAppProps() : null;
// if (app) { // if (app) {
// value = app.asc_getTotalTime(); // value = app.asc_getTotalTime();
@ -948,10 +968,12 @@ define([
this.inputComment.setValue(value || ''); this.inputComment.setValue(value || '');
this.tblAuthor.find('tr:not(:last-of-type)').remove(); this.tblAuthor.find('tr:not(:last-of-type)').remove();
this.authors = [];
value = props.asc_getCreator();//"123\"\"\"\<\>,456"; value = props.asc_getCreator();//"123\"\"\"\<\>,456";
value && value.split(/\s*[,;]\s*/).forEach(function(item) { value && value.split(/\s*[,;]\s*/).forEach(function(item) {
var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item)));
me.trAuthor.before(div); me.trAuthor.before(div);
me.authors.push(item);
}); });
} }
}, },

View file

@ -658,6 +658,8 @@ define([
].join('')); ].join(''));
this.menu = options.menu; this.menu = options.menu;
this.coreProps = null;
this.authors = [];
}, },
render: function() { render: function() {
@ -677,7 +679,10 @@ define([
placeHolder : this.txtAddText, placeHolder : this.txtAddText,
validateOnBlur: false validateOnBlur: false
}).on('changed:after', function() { }).on('changed:after', function() {
// me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); if (me.coreProps && me.api) {
me.coreProps.asc_putTitle(me.inputTitle.getValue());
me.api.asc_setCoreProps(me.coreProps);
}
}); });
this.inputSubject = new Common.UI.InputField({ this.inputSubject = new Common.UI.InputField({
el : $('#id-info-subject'), el : $('#id-info-subject'),
@ -685,7 +690,10 @@ define([
placeHolder : this.txtAddText, placeHolder : this.txtAddText,
validateOnBlur: false validateOnBlur: false
}).on('changed:after', function() { }).on('changed:after', function() {
// me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); if (me.coreProps && me.api) {
me.coreProps.asc_putSubject(me.inputSubject.getValue());
me.api.asc_setCoreProps(me.coreProps);
}
}); });
this.inputComment = new Common.UI.InputField({ this.inputComment = new Common.UI.InputField({
el : $('#id-info-comment'), el : $('#id-info-comment'),
@ -693,7 +701,10 @@ define([
placeHolder : this.txtAddText, placeHolder : this.txtAddText,
validateOnBlur: false validateOnBlur: false
}).on('changed:after', function() { }).on('changed:after', function() {
// me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); if (me.coreProps && me.api) {
me.coreProps.asc_putDescription(me.inputComment.getValue());
me.api.asc_setCoreProps(me.coreProps);
}
}); });
// modify info // modify info
@ -713,7 +724,11 @@ define([
var el = btn.closest('tr'), var el = btn.closest('tr'),
idx = me.tblAuthor.find('tr').index(el); idx = me.tblAuthor.find('tr').index(el);
el.remove(); el.remove();
// remove idx author from info me.authors.splice(idx, 1);
if (me.coreProps && me.api) {
me.coreProps.asc_putCreator(me.authors.join(';'));
me.api.asc_setCoreProps(me.coreProps);
}
} }
}); });
@ -730,10 +745,14 @@ define([
if (str) { if (str) {
var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str)));
me.trAuthor.before(div); me.trAuthor.before(div);
// add str author to info me.authors.push(item);
} }
}); });
me.inputAuthor.setValue(''); me.inputAuthor.setValue('');
if (me.coreProps && me.api) {
me.coreProps.asc_putCreator(me.authors.join(';'));
me.api.asc_setCoreProps(me.coreProps);
}
} }
}); });
@ -790,9 +809,9 @@ define([
} }
this._ShowHideInfoItem(this.lblApplication, !!appname); this._ShowHideInfoItem(this.lblApplication, !!appname);
var props = (this.api) ? this.api.asc_getCoreProps() : null; this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null;
if (props) { if (this.coreProps) {
var value = props.asc_getCreated(); var value = this.coreProps.asc_getCreated();
if (value) if (value)
this.lblDate.text(value.toLocaleString()); this.lblDate.text(value.toLocaleString());
this._ShowHideInfoItem(this.lblDate, !!value); this._ShowHideInfoItem(this.lblDate, !!value);
@ -807,6 +826,7 @@ define([
props = (this.api) ? this.api.asc_getCoreProps() : null, props = (this.api) ? this.api.asc_getCoreProps() : null,
value; value;
this.coreProps = props;
// var app = (this.api) ? this.api.asc_getAppProps() : null; // var app = (this.api) ? this.api.asc_getAppProps() : null;
// if (app) { // if (app) {
// value = app.asc_getTotalTime(); // value = app.asc_getTotalTime();
@ -835,10 +855,12 @@ define([
this.inputComment.setValue(value || ''); this.inputComment.setValue(value || '');
this.tblAuthor.find('tr:not(:last-of-type)').remove(); this.tblAuthor.find('tr:not(:last-of-type)').remove();
this.authors = [];
value = props.asc_getCreator();//"123\"\"\"\<\>,456"; value = props.asc_getCreator();//"123\"\"\"\<\>,456";
value && value.split(/\s*[,;]\s*/).forEach(function(item) { value && value.split(/\s*[,;]\s*/).forEach(function(item) {
var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item)));
me.trAuthor.before(div); me.trAuthor.before(div);
me.authors.push(item);
}); });
} }
}, },

View file

@ -1109,6 +1109,8 @@ define([
].join('')); ].join(''));
this.menu = options.menu; this.menu = options.menu;
this.coreProps = null;
this.authors = [];
}, },
render: function() { render: function() {
@ -1128,7 +1130,10 @@ define([
placeHolder : this.txtAddText, placeHolder : this.txtAddText,
validateOnBlur: false validateOnBlur: false
}).on('changed:after', function() { }).on('changed:after', function() {
// me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); if (me.coreProps && me.api) {
me.coreProps.asc_putTitle(me.inputTitle.getValue());
me.api.asc_setCoreProps(me.coreProps);
}
}); });
this.inputSubject = new Common.UI.InputField({ this.inputSubject = new Common.UI.InputField({
el : $('#id-info-subject'), el : $('#id-info-subject'),
@ -1136,7 +1141,10 @@ define([
placeHolder : this.txtAddText, placeHolder : this.txtAddText,
validateOnBlur: false validateOnBlur: false
}).on('changed:after', function() { }).on('changed:after', function() {
// me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); if (me.coreProps && me.api) {
me.coreProps.asc_putSubject(me.inputSubject.getValue());
me.api.asc_setCoreProps(me.coreProps);
}
}); });
this.inputComment = new Common.UI.InputField({ this.inputComment = new Common.UI.InputField({
el : $('#id-info-comment'), el : $('#id-info-comment'),
@ -1144,7 +1152,10 @@ define([
placeHolder : this.txtAddText, placeHolder : this.txtAddText,
validateOnBlur: false validateOnBlur: false
}).on('changed:after', function() { }).on('changed:after', function() {
// me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); if (me.coreProps && me.api) {
me.coreProps.asc_putDescription(me.inputComment.getValue());
me.api.asc_setCoreProps(me.coreProps);
}
}); });
// modify info // modify info
@ -1164,7 +1175,11 @@ define([
var el = btn.closest('tr'), var el = btn.closest('tr'),
idx = me.tblAuthor.find('tr').index(el); idx = me.tblAuthor.find('tr').index(el);
el.remove(); el.remove();
// remove idx author from info me.authors.splice(idx, 1);
if (me.coreProps && me.api) {
me.coreProps.asc_putCreator(me.authors.join(';'));
me.api.asc_setCoreProps(me.coreProps);
}
} }
}); });
@ -1181,10 +1196,14 @@ define([
if (str) { if (str) {
var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str)));
me.trAuthor.before(div); me.trAuthor.before(div);
// add str author to info me.authors.push(item);
} }
}); });
me.inputAuthor.setValue(''); me.inputAuthor.setValue('');
if (me.coreProps && me.api) {
me.coreProps.asc_putCreator(me.authors.join(';'));
me.api.asc_setCoreProps(me.coreProps);
}
} }
}); });
@ -1241,9 +1260,9 @@ define([
} }
this._ShowHideInfoItem(this.lblApplication, !!appname); this._ShowHideInfoItem(this.lblApplication, !!appname);
var props = (this.api) ? this.api.asc_getCoreProps() : null; this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null;
if (props) { if (this.coreProps) {
var value = props.asc_getCreated(); var value = this.coreProps.asc_getCreated();
if (value) if (value)
this.lblDate.text(value.toLocaleString()); this.lblDate.text(value.toLocaleString());
this._ShowHideInfoItem(this.lblDate, !!value); this._ShowHideInfoItem(this.lblDate, !!value);
@ -1258,6 +1277,7 @@ define([
props = (this.api) ? this.api.asc_getCoreProps() : null, props = (this.api) ? this.api.asc_getCoreProps() : null,
value; value;
this.coreProps = props;
// var app = (this.api) ? this.api.asc_getAppProps() : null; // var app = (this.api) ? this.api.asc_getAppProps() : null;
// if (app) { // if (app) {
// value = app.asc_getTotalTime(); // value = app.asc_getTotalTime();
@ -1286,10 +1306,12 @@ define([
this.inputComment.setValue(value || ''); this.inputComment.setValue(value || '');
this.tblAuthor.find('tr:not(:last-of-type)').remove(); this.tblAuthor.find('tr:not(:last-of-type)').remove();
this.authors = [];
value = props.asc_getCreator();//"123\"\"\"\<\>,456"; value = props.asc_getCreator();//"123\"\"\"\<\>,456";
value && value.split(/\s*[,;]\s*/).forEach(function(item) { value && value.split(/\s*[,;]\s*/).forEach(function(item) {
var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item)));
me.trAuthor.before(div); me.trAuthor.before(div);
me.authors.push(item);
}); });
} }
}, },

View file

@ -754,8 +754,8 @@
"SSE.Controllers.Toolbar.textOperator": "Operators", "SSE.Controllers.Toolbar.textOperator": "Operators",
"SSE.Controllers.Toolbar.textPivot": "Pivot Table", "SSE.Controllers.Toolbar.textPivot": "Pivot Table",
"SSE.Controllers.Toolbar.textRadical": "Radicals", "SSE.Controllers.Toolbar.textRadical": "Radicals",
"SSE.Controllers.Toolbar.textScript": "Scripts",
"SSE.Controllers.Toolbar.textSymbols": "Symbols", "SSE.Controllers.Toolbar.textSymbols": "Symbols",
"SSE.Controllers.Toolbar.textScript": "Scripts",
"SSE.Controllers.Toolbar.textWarning": "Warning", "SSE.Controllers.Toolbar.textWarning": "Warning",
"SSE.Controllers.Toolbar.txtAccent_Accent": "Acute", "SSE.Controllers.Toolbar.txtAccent_Accent": "Acute",
"SSE.Controllers.Toolbar.txtAccent_ArrowD": "Right-left arrow above", "SSE.Controllers.Toolbar.txtAccent_ArrowD": "Right-left arrow above",