2015-01-12 03:18:24 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
|
2015-03-18 02:08:48 +01:00
|
|
|
uBlock - a browser extension to block requests.
|
|
|
|
Copyright (C) 2015 The uBlock authors
|
2015-01-12 03:18:24 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
|
|
|
|
2015-04-09 00:36:14 +02:00
|
|
|
Home: https://github.com/chrisaljoudi/uBlock
|
2015-01-12 03:18:24 +01:00
|
|
|
*/
|
2015-02-10 06:47:45 +01:00
|
|
|
(function() {
|
2015-04-07 08:34:36 +02:00
|
|
|
"use strict";
|
2015-01-12 03:18:24 +01:00
|
|
|
|
2015-05-01 18:05:11 +02:00
|
|
|
if(typeof safari.self === "undefined" || window.top !== window) {
|
2015-04-07 08:34:36 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-03-17 00:40:17 +01:00
|
|
|
|
2015-01-12 03:07:25 +01:00
|
|
|
var onLoaded = function() {
|
2015-03-17 00:08:28 +01:00
|
|
|
var _toggle = DOMTokenList.prototype.toggle;
|
2015-05-01 18:25:48 +02:00
|
|
|
var unchainPane2Timeout = false;
|
|
|
|
var unchainPane2 = function() {
|
2015-06-01 02:14:39 +02:00
|
|
|
scopeIcons.style.removeProperty("display");
|
2015-05-01 18:25:48 +02:00
|
|
|
pane2.style.removeProperty("display");
|
|
|
|
};
|
2015-04-07 08:34:36 +02:00
|
|
|
DOMTokenList.prototype.toggle = function(className, enabled) {
|
|
|
|
if(className === "dfEnabled") {
|
2015-05-01 18:25:48 +02:00
|
|
|
if(unchainPane2Timeout !== false) {
|
|
|
|
clearTimeout(unchainPane2Timeout);
|
|
|
|
unchainPane2Timeout = false;
|
|
|
|
}
|
|
|
|
_toggle.apply(this, arguments);
|
2015-06-01 02:14:39 +02:00
|
|
|
scopeIcons.style.setProperty("display", "none", "important");
|
2015-05-01 18:25:48 +02:00
|
|
|
pane2.style.setProperty("display", "inline-block", "important");
|
2015-06-01 02:14:39 +02:00
|
|
|
unchainPane2Timeout = setTimeout(unchainPane2, 400);
|
2015-04-07 08:34:36 +02:00
|
|
|
updateSize(enabled);
|
|
|
|
}
|
2015-05-01 18:25:48 +02:00
|
|
|
else {
|
|
|
|
_toggle.apply(this, arguments);
|
2015-03-17 00:08:28 +01:00
|
|
|
}
|
|
|
|
};
|
2015-04-07 08:34:36 +02:00
|
|
|
var body = document.body,
|
|
|
|
popover = safari.self,
|
|
|
|
panes = document.getElementById("panes"),
|
2015-06-01 02:14:39 +02:00
|
|
|
scopeIcons = document.getElementById("scopeIcons"),
|
2015-04-07 08:34:36 +02:00
|
|
|
pane1 = panes.children[0],
|
|
|
|
pane2 = panes.children[1];
|
2015-03-17 00:40:17 +01:00
|
|
|
|
2015-04-07 08:34:36 +02:00
|
|
|
body.style.width = "100%";
|
|
|
|
panes.style.width = "100%";
|
|
|
|
|
|
|
|
var updateSize = function(isOpen) {
|
|
|
|
var w = pane2.clientWidth;
|
|
|
|
if(typeof isOpen === "undefined") {
|
|
|
|
isOpen = (w !== 0);
|
|
|
|
}
|
|
|
|
popover.width = (isOpen ? w : 0) + pane1.clientWidth;
|
2015-01-12 03:37:10 +01:00
|
|
|
popover.height = body.clientHeight;
|
2015-01-12 03:07:25 +01:00
|
|
|
};
|
2015-03-21 21:11:42 +01:00
|
|
|
|
|
|
|
setTimeout(updateSize, 0);
|
2015-01-12 03:07:25 +01:00
|
|
|
};
|
2015-04-07 08:34:36 +02:00
|
|
|
|
2015-03-16 19:02:54 +01:00
|
|
|
window.addEventListener("load", onLoaded);
|
2015-02-10 06:47:45 +01:00
|
|
|
})();
|