From 21759b79de82cfce744209df7a524b0151ff0709 Mon Sep 17 00:00:00 2001 From: Gabriela Navarro Date: Fri, 12 Jun 2015 16:03:37 +0000 Subject: [PATCH] Fix JS that was trying to return something null --- features/article_visualization.feature | 30 ++++++++++++++++++++++++++++++ public/javascripts/application.js | 6 ++++-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 features/article_visualization.feature diff --git a/features/article_visualization.feature b/features/article_visualization.feature new file mode 100644 index 0000000..a5d0ad6 --- /dev/null +++ b/features/article_visualization.feature @@ -0,0 +1,30 @@ +Feature: article visualization + As a user + I want to change view modes + In order to see articles in fullscreen or not in fullscreen + + Background: + Given the following users + | login | name | + | joaosilva | Joao Silva | + And "joaosilva" has no articles + And the following articles + | owner | name | body | + | joaosilva | Sample Article | This is an article | + And I am logged in as "joaosilva" + + @selenium + Scenario: viewing the article in fullscreen by default + Given I go to /joaosilva/sample-article?fullscreen=1 + Then I should see "Exit full screen" + + @selenium + Scenario: viewing the article not in fullscreen by default + Given I go to /joaosilva/sample-article + Then I should see "Full screen" + + @selenium + Scenario: changing the view mode from not in fullscreen to fullscreen + Given I go to /joaosilva/sample-article + And I follow "Full screen" + Then I should see "Exit full screen" diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 3206d8d..68067cb 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1178,7 +1178,10 @@ window.isHidden = function isHidden() { return (typeof(document.hidden) != 'unde function $_GET(id){ var a = new RegExp(id+"=([^&#=]*)"); - return decodeURIComponent(a.exec(window.location.search)[1]); + var result_of_search = a.exec(window.location.search) + if(result_of_search != null){ + return decodeURIComponent(result_of_search[1]); + } } var fullwidth=false; @@ -1206,4 +1209,3 @@ function fullscreenPageLoad(itemId){ } }); } - -- libgit2 0.21.2