mirror of https://github.com/gorhill/uBlock.git
this fixes default tab selection for Firefox
This commit is contained in:
parent
580d3a81db
commit
5ec300602a
|
@ -36,22 +36,26 @@ var messager = vAPI.messaging.channel('stats.js');
|
||||||
|
|
||||||
var renderPageSelector = function(targetTabId) {
|
var renderPageSelector = function(targetTabId) {
|
||||||
var selectedTabId = targetTabId || uDom('#pageSelector').val();
|
var selectedTabId = targetTabId || uDom('#pageSelector').val();
|
||||||
var onTabReceived = function(tabId, tabTitle) {
|
var onDataReceived = function(pageTitles) {
|
||||||
uDom('#pageSelector').append('<option value="' + tabId + '">' + tabTitle);
|
if ( pageTitles.hasOwnProperty(selectedTabId) === false ) {
|
||||||
if ( tabId.toString() === selectedTabId ) {
|
selectedTabId = pageTitles[0];
|
||||||
uDom('#pageSelector').val(tabId);
|
|
||||||
}
|
}
|
||||||
};
|
var select = uDom('#pageSelector').empty();
|
||||||
var onDataReceived = function(pageDetails) {
|
var option;
|
||||||
uDom('#pageSelector option').remove();
|
for ( var tabId in pageTitles ) {
|
||||||
if ( pageDetails.hasOwnProperty(selectedTabId) === false ) {
|
if ( pageTitles.hasOwnProperty(tabId) === false ) {
|
||||||
selectedTabId = pageDetails[0];
|
continue;
|
||||||
}
|
}
|
||||||
for ( var tabId in pageDetails ) {
|
option = uDom('<option>').text(pageTitles[tabId])
|
||||||
if ( pageDetails.hasOwnProperty(tabId) ) {
|
.prop('value', tabId);
|
||||||
onTabReceived(tabId, pageDetails[tabId]);
|
if ( tabId === selectedTabId ) {
|
||||||
|
option.prop('selected', true);
|
||||||
}
|
}
|
||||||
|
select.append(option);
|
||||||
}
|
}
|
||||||
|
// This must be done after inserting all option tags, or else Firefox
|
||||||
|
// will refuse values which do not exist yet.
|
||||||
|
select.prop('value', selectedTabId);
|
||||||
selectPage();
|
selectPage();
|
||||||
};
|
};
|
||||||
messager.send({ what: 'getPageDetails' }, onDataReceived);
|
messager.send({ what: 'getPageDetails' }, onDataReceived);
|
||||||
|
|
Loading…
Reference in New Issue