Hiding controls with custom config.js

326 views
Skip to first unread message

Chris Hine

unread,
Jan 19, 2015, 2:47:00 PM1/19/15
to pdfnet-w...@googlegroups.com
Hi,

I'm attempting to hide some of the default UI via ReaderControl.config.ui.

I've found that I cannot set the text search to false without encountering an error.

This:
ReaderControl.config.ui = {
    // main UI elements
    hideAnnotationPanel: false,
    hideControlBar: false,
    hideSidePanel: false,
    // UI subelements
    hideDisplayModes: false,
    hideZoom: false,
    hideTextSearch: true,
    hidePrint: false
};

Yields:
"Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. ReaderControl.js:767"

Might this be a bug?

Additionally, the above is accomplished simply by modifying the default ReaderControlConfig.js under the html5 folder. If I attempt to supply my own config.js to the constructor of WebViewer (overriding that default file as I understand it) I find that the default still executes and errors on this part:
$(function () {
    readerControl.toolModeMap['AnnotationCreateTextHighlight']
        .bind('textSelected', function (quads, text) {
                console.log('textSelected');
                console.log(quads);
                console.log(text);
            });
});

Yielding:
"Uncaught ReferenceError: readerControl is not defined ReaderControlConfig.js:69"

Should I not expect my own custom config.js to prevent that default one from executing? Mine contains only the following:
ReaderControl.config.ui = {
    // main UI elements
    hideAnnotationPanel: true,
    hideControlBar: false,
    hideSidePanel: true,
    // UI subelements
    hideDisplayModes: false,
    hideZoom: false,
    hideTextSearch: false,
    hidePrint: true
};

I know it is being applied because I can observe those elements hidden.

Thanks,
Chris

Matt Parizeau

unread,
Jan 20, 2015, 1:43:56 PM1/20/15
to pdfnet-w...@googlegroups.com
Hi Chris,

It looks like the error when trying to hide text search is a bug. You can fix it by making a small fix to ReaderControl.js. Find the line in ReaderControl.js that has if (ReaderControl.config.ui.hideTextSearch) and inside the if statement replace everything with $('#searchControl').parent().hide().

ReaderControlConfig.js will still execute even if you supply your own config file, so that part is expected. One other thing to remember is that the text annotation tools will not emit textSelected events so I'm not sure what the error is with it, but the code shouldn't be necessary.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Chris Hine

unread,
Jan 22, 2015, 3:17:58 PM1/22/15
to pdfnet-w...@googlegroups.com
Got it, thanks Matt.

Chris
Reply all
Reply to author
Forward
0 new messages