FileDocumentViewer

0
I am using FileDocumentViewer widget. When I hit the popout button , it displays the pdf in a new tab with an url /file?guid=xxxxxxxxxxxxx2&changedDate=xxxxxxxxxxxx&target=window&csrfToken=f2ba6ec9-a6e9-4d81-8c13-00a2f7b9b  The title of the window says file . Is it possible to change the window title to the name of the file that was opened or one of the attibutes of the FileDocument entity 
asked
1 answers
0

The popout window will by default take the name of the file, which is “file”. If you would be able to change the source code of the FileDocumentViewer widget you could implement something like this, to set the window title to the document name after the window was opened.

I made this change in the file: FileDocumentViewer.js

_eventPopout: function () {
  logger.debug(this.id + "._eventPopout");
  //window.open(this._getFileUrl());

  //Add by Jeroen
  var w = window.open(this._getFileUrl());
  var title = 'File';
  if (this._contextObj && this._contextObj.get("HasContents")) {
    if (this.escapeTitle) {
      title = dom.escapeString((this._contextObj.get(this.headertitle) || "").replace(/\n/g, " "));
    } else {
      title = this._contextObj.get(this.headertitle);
	}			
  }
  setTimeout(() => w.document.title = title, 0);
  //End added by Jeroen            
},

 

answered