@@ -31,11 +31,19 @@ require([
3131 hideDownload : false ,
3232 hidePrint : false ,
3333 hideOpenFile : false ,
34+ usePDFjsAttribute : "" ,
35+ hideDownloadAttribute : "" ,
36+ hidePrintAttribute : "" ,
37+ hideOpenFileAttribute : "" ,
3438
3539 // Internal variables.
3640 _handle : null ,
3741 _contextObj : null ,
3842 _objProperty : null ,
43+ _usePDFjs : null ,
44+ _hideDownload : null ,
45+ _hidePrint : null ,
46+ _hideOpenFile : null ,
3947 iframeNode : null ,
4048
4149 postCreate : function ( ) {
@@ -50,6 +58,11 @@ require([
5058 "width" : this . width === 0 ? "auto" : this . width + "px"
5159 } ) ;
5260
61+ this . _usePDFjs = this . usePDFjs ;
62+ this . _hideDownload = this . hideDownload ;
63+ this . _hideOpenFile = this . hideOpenFile ;
64+ this . _hidePrint = this . hidePrint ;
65+
5366 this . _setupEvents ( ) ;
5467 } ,
5568
@@ -71,29 +84,50 @@ require([
7184
7285 if ( obj ) {
7386 this . _contextObj = obj ;
87+ this . _getSettings ( ) ;
7488 this . _resetSubscriptions ( ) ;
7589 this . _updateRendering ( callback ) ;
7690 } else {
7791 this . _executeCallback ( callback , "update" ) ;
7892 }
7993 } ,
8094
95+ _getSettings : function ( ) {
96+ logger . debug ( this . id + "._getSettings" ) ;
97+
98+ if ( this . usePDFjsAttribute && this . usePDFjsAttribute . length ) {
99+ this . _usePDFjs = this . _contextObj . get ( this . usePDFjsAttribute ) ;
100+ }
101+
102+ if ( this . hideDownloadAttribute && this . hideDownloadAttribute . length ) {
103+ this . _hideDownload = this . _contextObj . get ( this . hideDownloadAttribute ) ;
104+ }
105+
106+ if ( this . hidePrintAttribute && this . hidePrintAttribute . length ) {
107+ this . _hidePrint = this . _contextObj . get ( this . hidePrintAttribute ) ;
108+ }
109+
110+ if ( this . hideOpenFileAttribute && this . hideOpenFileAttribute . length ) {
111+ this . _hideOpenFile = this . _contextObj . get ( this . hideOpenFileAttribute ) ;
112+ }
113+ } ,
114+
81115 _updateRendering : function ( callback ) {
82116 logger . debug ( this . id + "._updateRendering" ) ;
83117 domConstruct . destroy ( this . iframeNode ) ;
84118 this . iframeNode = null ;
85119 this . _iframeNodeCreate ( ) ;
86120
87121 if ( this . _contextObj && this . _contextObj . get ( "HasContents" ) ) {
88- if ( this . usePDFjs /* && this._contextObj.get("Name").indexOf(".pdf") !== -1*/ ) {
122+ if ( this . _usePDFjs /* && this._contextObj.get("Name").indexOf(".pdf") !== -1*/ ) {
89123 var pdfJSViewer = require . toUrl ( "FileDocumentViewer/lib/pdfjs/web/viewer.html" ) . split ( "?" ) [ 0 ] ,
90124 encoded = pdfJSViewer + "?file=" + encodeURIComponent ( this . _getFileUrl ( ) ) ;
91125
92126 domAttr . set ( this . iframeNode , "src" , encoded ) ;
93127
94- if ( this . hideDownload || this . hidePrint || this . hideOpenFile ) {
128+ if ( this . _hideDownload || this . _hidePrint || this . _hideOpenFile ) {
95129 this . iframeNode . onload = lang . hitch ( this , function ( ) {
96- dojoWindow . withDoc ( this . iframeNode . contentWindow . document , lang . hitch ( this , this . _hideButtons ) )
130+ dojoWindow . withDoc ( this . iframeNode . contentWindow . document , lang . hitch ( this , this . _hideButtonsFromUI ) )
97131 } )
98132 }
99133 } else {
@@ -162,16 +196,16 @@ require([
162196 }
163197 } ,
164198
165- _hideButtons : function ( ) {
199+ _hideButtonsFromUI : function ( ) {
166200 logger . debug ( this . id + "._hideButtons" ) ;
167201
168- if ( this . hideDownload ) {
202+ if ( this . _hideDownload ) {
169203 domQuery ( 'button.download' ) . style ( 'display' , 'none' ) ;
170204 }
171- if ( this . hidePrint ) {
205+ if ( this . _hidePrint ) {
172206 domQuery ( 'button.print' ) . style ( 'display' , 'none' ) ;
173207 }
174- if ( this . hideOpenFile ) {
208+ if ( this . _hideOpenFile ) {
175209 domQuery ( 'button.openFile' ) . style ( 'display' , 'none' ) ;
176210 }
177211
0 commit comments