@@ -5,6 +5,7 @@ const SetupSpellChecker = require('./spellchecker');
55
66const ConfigUtil = require ( __dirname + '/utils/config-util.js' ) ;
77const LinkUtil = require ( __dirname + '/utils/link-util.js' ) ;
8+ const params = require ( __dirname + '/utils/params-util.js' ) ;
89
910// eslint-disable-next-line import/no-unassigned-import
1011require ( './notification' ) ;
@@ -42,46 +43,44 @@ process.once('loaded', () => {
4243
4344// To prevent failing this script on linux we need to load it after the document loaded
4445document . addEventListener ( 'DOMContentLoaded' , ( ) => {
46+ if ( params . isPageParams ( ) ) {
4547 // Get the default language of the server
46- const serverLanguage = page_params . default_language ; // eslint-disable-line no-undef, camelcase
47-
48- if ( serverLanguage ) {
49- // Set spellcheker language
50- ConfigUtil . setConfigItem ( 'spellcheckerLanguage' , serverLanguage ) ;
51- // Init spellchecker
52- SetupSpellChecker . init ( ) ;
53- }
54-
55- // redirect users to network troubleshooting page
56- const getRestartButton = document . querySelector ( '.restart_get_events_button' ) ;
57- if ( getRestartButton ) {
58- getRestartButton . addEventListener ( 'click' , ( ) => {
59- ipcRenderer . send ( 'forward-message' , 'reload-viewer' ) ;
48+ const serverLanguage = page_params . default_language ; // eslint-disable-line no-undef, camelcase
49+ if ( serverLanguage ) {
50+ // Set spellcheker language
51+ ConfigUtil . setConfigItem ( 'spellcheckerLanguage' , serverLanguage ) ;
52+ // Init spellchecker
53+ SetupSpellChecker . init ( ) ;
54+ }
55+ // redirect users to network troubleshooting page
56+ const getRestartButton = document . querySelector ( '.restart_get_events_button' ) ;
57+ if ( getRestartButton ) {
58+ getRestartButton . addEventListener ( 'click' , ( ) => {
59+ ipcRenderer . send ( 'forward-message' , 'reload-viewer' ) ;
60+ } ) ;
61+ }
62+ // Open image attachment link in the lightbox instead of opening in the default browser
63+ const { $, lightbox } = window ;
64+ $ ( '#main_div' ) . on ( 'click' , '.message_content p a' , function ( e ) {
65+ const url = $ ( this ) . attr ( 'href' ) ;
66+
67+ if ( LinkUtil . isImage ( url ) ) {
68+ const $img = $ ( this ) . parent ( ) . siblings ( '.message_inline_image' ) . find ( 'img' ) ;
69+
70+ // prevent the image link from opening in a new page.
71+ e . preventDefault ( ) ;
72+ // prevent the message compose dialog from happening.
73+ e . stopPropagation ( ) ;
74+
75+ // Open image in the default browser if image preview is unavailable
76+ if ( ! $img [ 0 ] ) {
77+ shell . openExternal ( window . location . origin + url ) ;
78+ }
79+ // Open image in lightbox
80+ lightbox . open ( $img ) ;
81+ }
6082 } ) ;
6183 }
62-
63- // Open image attachment link in the lightbox instead of opening in the default browser
64- const { $, lightbox } = window ;
65-
66- $ ( '#main_div' ) . on ( 'click' , '.message_content p a' , function ( e ) {
67- const url = $ ( this ) . attr ( 'href' ) ;
68-
69- if ( LinkUtil . isImage ( url ) ) {
70- const $img = $ ( this ) . parent ( ) . siblings ( '.message_inline_image' ) . find ( 'img' ) ;
71-
72- // prevent the image link from opening in a new page.
73- e . preventDefault ( ) ;
74- // prevent the message compose dialog from happening.
75- e . stopPropagation ( ) ;
76-
77- // Open image in the default browser if image preview is unavailable
78- if ( ! $img [ 0 ] ) {
79- shell . openExternal ( window . location . origin + url ) ;
80- }
81- // Open image in lightbox
82- lightbox . open ( $img ) ;
83- }
84- } ) ;
8584} ) ;
8685
8786// Clean up spellchecker events after you navigate away from this page;
0 commit comments