From 363bc4eb8642d464cc0c099f7ab72a425b56b463 Mon Sep 17 00:00:00 2001 From: banux Date: Sun, 27 Oct 2013 07:37:05 +0100 Subject: [PATCH 1/2] Add a autoclose parameters. When we use sharing method in plugins like the tiny tiny rss one or the firefox plugins we can passe the autoclose=true parameters that close the popup. --- inc/poche/Poche.class.php | 8 ++++++-- themes/default/_head.twig | 1 + themes/default/js/autoClose.js | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 themes/default/js/autoClose.js diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 39d43761f..5d807268e 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -327,7 +327,7 @@ class Poche /** * Call action (mark as fav, archive, delete, etc.) */ - public function action($action, Url $url, $id = 0, $import = FALSE) + public function action($action, Url $url, $id = 0, $import = FALSE, $autoclose = FALSE) { switch ($action) { @@ -358,7 +358,11 @@ class Poche } if (!$import) { - Tools::redirect('?view=home'); + if ($autoclose == TRUE) { + Tools::redirect('?view=home'); + } else { + Tools::redirect('?view=home&autoclose=true'); + } } break; case 'delete': diff --git a/themes/default/_head.twig b/themes/default/_head.twig index d0cbd320b..577cc693c 100644 --- a/themes/default/_head.twig +++ b/themes/default/_head.twig @@ -8,3 +8,4 @@ + \ No newline at end of file diff --git a/themes/default/js/autoClose.js b/themes/default/js/autoClose.js new file mode 100644 index 000000000..3035d423f --- /dev/null +++ b/themes/default/js/autoClose.js @@ -0,0 +1,6 @@ +$(document).ready(function() { + current_url = window.location.href + if (current_url.match("&autoclose=true")) { + window.close(); + } +}); \ No newline at end of file From f616ab60efc502b919b9b72f81aee2975b2e8465 Mon Sep 17 00:00:00 2001 From: banux Date: Sun, 27 Oct 2013 07:47:14 +0100 Subject: [PATCH 2/2] use 2 seprate variable for autoclosing windows to avoid to quick closing when sharing, the popup can be close before the link is save --- inc/poche/Poche.class.php | 2 +- themes/default/js/autoClose.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 5d807268e..3ecaf084a 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -361,7 +361,7 @@ class Poche if ($autoclose == TRUE) { Tools::redirect('?view=home'); } else { - Tools::redirect('?view=home&autoclose=true'); + Tools::redirect('?view=home&closewin=true'); } } break; diff --git a/themes/default/js/autoClose.js b/themes/default/js/autoClose.js index 3035d423f..e9145b7e2 100644 --- a/themes/default/js/autoClose.js +++ b/themes/default/js/autoClose.js @@ -1,6 +1,6 @@ $(document).ready(function() { current_url = window.location.href - if (current_url.match("&autoclose=true")) { + if (current_url.match("&closewin=true")) { window.close(); } -}); \ No newline at end of file +});