Build menulist items for sibling bookmarks in the folder progressively.
I think this can become a workaround for #398.
This commit is contained in:
parent
63114ca99f
commit
c10e126000
@ -159,15 +159,11 @@ var TreeStyleTabBookmarksServiceEditable = {
|
|||||||
if (PlacesUtils.bookmarks.getFolderIdForItem(id) == PlacesUtils.unfiledBookmarksFolderId)
|
if (PlacesUtils.bookmarks.getFolderIdForItem(id) == PlacesUtils.unfiledBookmarksFolderId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._createSiblingsFragment(id, (function(aFragment) {
|
this._createSiblingsFragment(id, (function(aSiblingsFragment) {
|
||||||
var siblings = Array.slice(aFragment.childNodes)
|
|
||||||
.map(function(aItem) {
|
|
||||||
return parseInt(aItem.getAttribute('value'));
|
|
||||||
});
|
|
||||||
var range = document.createRange();
|
var range = document.createRange();
|
||||||
range.selectNodeContents(popup);
|
range.selectNodeContents(popup);
|
||||||
range.setEndBefore(this.separator);
|
range.setEndBefore(this.separator);
|
||||||
range.insertNode(aFragment);
|
range.insertNode(aSiblingsFragment);
|
||||||
range.detach();
|
range.detach();
|
||||||
|
|
||||||
var selected = popup.getElementsByAttribute('selected', 'true')[0];
|
var selected = popup.getElementsByAttribute('selected', 'true')[0];
|
||||||
@ -194,8 +190,9 @@ var TreeStyleTabBookmarksServiceEditable = {
|
|||||||
this._createSiblingsFragmentTimer = window.setTimeout(progressiveIteration, interval);
|
this._createSiblingsFragmentTimer = window.setTimeout(progressiveIteration, interval);
|
||||||
}
|
}
|
||||||
catch(e if e instanceof StopIteration) {
|
catch(e if e instanceof StopIteration) {
|
||||||
var fragment = this._createSiblingsFragmentInternal(aCurrentItem, items);
|
this._createSiblingsFragmentInternal(aCurrentItem, items, function(aSiblingsFragment) {
|
||||||
aCallback(fragment);
|
aCallback(aSiblingsFragment);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
}
|
}
|
||||||
@ -206,7 +203,7 @@ var TreeStyleTabBookmarksServiceEditable = {
|
|||||||
this._createSiblingsFragmentTimer = window.setTimeout(progressiveIteration, interval);
|
this._createSiblingsFragmentTimer = window.setTimeout(progressiveIteration, interval);
|
||||||
},
|
},
|
||||||
_createSiblingsFragmentTimer : null,
|
_createSiblingsFragmentTimer : null,
|
||||||
_createSiblingsFragmentInternal : function TSTBMEditable_createSiblingsFragmentInternal(aCurrentItem, aItems)
|
_createSiblingsFragmentInternal : function TSTBMEditable_createSiblingsFragmentInternal(aCurrentItem, aItems, aCallback)
|
||||||
{
|
{
|
||||||
var treeStructure = this.getTreeStructureFromItems(aItems);
|
var treeStructure = this.getTreeStructureFromItems(aItems);
|
||||||
|
|
||||||
@ -219,11 +216,24 @@ var TreeStyleTabBookmarksServiceEditable = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fragment = document.createDocumentFragment();
|
var fragment = document.createDocumentFragment();
|
||||||
for (let [i, id] in Iterator(aItems))
|
|
||||||
|
if (this._createSiblingsFragmentInternalTimer)
|
||||||
|
window.clearTimeout(this._createSiblingsFragmentInternalTimer);
|
||||||
|
|
||||||
|
var interval = 100;
|
||||||
|
var step = 10;
|
||||||
|
var current = 0;
|
||||||
|
var progressiveIteration = (function() {
|
||||||
|
let id;
|
||||||
|
for (let i = 0; i < step; i++)
|
||||||
{
|
{
|
||||||
|
id = aItems[current++];
|
||||||
|
if (!id)
|
||||||
|
break;
|
||||||
|
|
||||||
let label = PlacesUtils.bookmarks.getItemTitle(id);
|
let label = PlacesUtils.bookmarks.getItemTitle(id);
|
||||||
let item = document.createElement('menuitem');
|
let menuitem = document.createElement('menuitem');
|
||||||
item.setAttribute('value', id);
|
menuitem.setAttribute('value', id);
|
||||||
|
|
||||||
let parent = i;
|
let parent = i;
|
||||||
let nest = 0;
|
let nest = 0;
|
||||||
@ -233,21 +243,31 @@ var TreeStyleTabBookmarksServiceEditable = {
|
|||||||
nest++;
|
nest++;
|
||||||
if (parent == currentIndex) disabled = true;
|
if (parent == currentIndex) disabled = true;
|
||||||
}
|
}
|
||||||
if (nest) item.setAttribute('style', 'padding-left:'+nest+'em');
|
if (nest)
|
||||||
|
menuitem.setAttribute('style', 'padding-left:'+nest+'em');
|
||||||
|
|
||||||
if (disabled || id == aCurrentItem) {
|
if (disabled || id == aCurrentItem) {
|
||||||
item.setAttribute('disabled', true);
|
menuitem.setAttribute('disabled', true);
|
||||||
if (id == aCurrentItem)
|
if (id == aCurrentItem)
|
||||||
label = TreeStyleTabUtils.treeBundle.getFormattedString('bookmarkProperty.parent.current.label', [label]);
|
label = TreeStyleTabUtils.treeBundle.getFormattedString('bookmarkProperty.parent.current.label', [label]);
|
||||||
}
|
}
|
||||||
if (id == selected) item.setAttribute('selected', true);
|
if (id == selected)
|
||||||
|
menuitem.setAttribute('selected', true);
|
||||||
|
|
||||||
item.setAttribute('label', label);
|
menuitem.setAttribute('label', label);
|
||||||
|
|
||||||
fragment.appendChild(item);
|
fragment.appendChild(menuitem);
|
||||||
}
|
}
|
||||||
return fragment;
|
if (id) {
|
||||||
|
this._createSiblingsFragmentInternalTimer = window.setTimeout(progressiveIteration, interval);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._createSiblingsFragmentInternalTimer = null;
|
||||||
|
aCallback(fragment);
|
||||||
|
}).bind(this);
|
||||||
|
this._createSiblingsFragmentInternalTimer = window.setTimeout(progressiveIteration, interval);
|
||||||
},
|
},
|
||||||
|
_createSiblingsFragmentInternalTimer : null,
|
||||||
_getItemsInFolderIterator : function TSTBMEditable_getItemsInFolderIterator(aId)
|
_getItemsInFolderIterator : function TSTBMEditable_getItemsInFolderIterator(aId)
|
||||||
{
|
{
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user