Skip to content

Commit

Permalink
fix(server): support server side rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Jun 27, 2016
1 parent 06a2d41 commit bc62163
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/main/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,16 @@ class Modal {
// Static variable that keeps track of all open modals
Modal._modalInstances = [];

if(global.addEventListener) {
// Global keydown listener for modal
global.addEventListener('keydown', (e) => {
if (e.keyCode === KEY_ESC) {
const lastModal = Modal._modalInstances[Modal._modalInstances.length - 1];
if (lastModal) {
Widget.findWidget(lastModal).close(e);
global.addEventListener('keydown', (e) => {
if (e.keyCode === KEY_ESC) {
const lastModal = Modal._modalInstances[Modal._modalInstances.length - 1];
if (lastModal) {
Widget.findWidget(lastModal).close(e);
}
}
}
});
});
}

export default Modal;
2 changes: 1 addition & 1 deletion src/main/util/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// polyfill for custom events to make thinks work in IE
// The needed polyfill is so small that I embedded it here
(function poly() {
if (!global.CustomEvent || typeof global.CustomEvent !== 'function') {
if (global.document && (!global.CustomEvent || typeof global.CustomEvent !== 'function')) {
const CustomEvent = function CustomEvent(event, params) {
const thisParams = params ||
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/util/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Util from './Util';

// we attach global settings to global once because settings might be shared a lot of times trough the application
// Maybe find a better way to handle that scenario
if (!global.FLEXCSS_GLOBAL_SETTINGS) {
if (global.document && !global.FLEXCSS_GLOBAL_SETTINGS) {
global.FLEXCSS_GLOBAL_SETTINGS = {
// defined breakpoint for small devices < n
smallBreakpoint: 768,
Expand Down

0 comments on commit bc62163

Please sign in to comment.