Skip to content

Loading…

Way simplify vAPI closePopup for Safari #492

Merged
merged 1 commit into from

2 participants

@chrisaljoudi

From Apple's documentation:

Your extension can have multiple popovers. Each popover is an element in the safari.extension.popovers array. There is a single instance of each popover, regardless of the number of open windows. Only the active window can display the popover.

Use that to hugely simplify vAPI.closePopup.

@gorhill gorhill merged commit 08f4644 into chrisaljoudi:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 13, 2015
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 15 deletions.
  1. +3 −15 platform/safari/vapi-common.js
View
18 platform/safari/vapi-common.js
@@ -114,22 +114,10 @@ vAPI.i18n = function(s) {
/******************************************************************************/
vAPI.closePopup = function() {
- var safr = safari.extension.globalPage.contentWindow.safari;
- var items = safr.extension.toolbarItems;
-
- for ( var i = 0; i < items.length; i++ ) {
- if ( items[i].browserWindow !== safr.application.activeBrowserWindow ) {
- continue;
- }
-
- if ( items[i].popover && items[i].popover.visible ) {
- items[i].popover.hide();
- }
+ var popover = safari.extension.popovers[0];
+ if ( popover ) {
+ popover.hide();
}
};
-/******************************************************************************/
-
})();
-
-/******************************************************************************/
Something went wrong with that request. Please try again.