Update library
This commit is contained in:
parent
d57cbdad49
commit
8d59f83188
@ -13,12 +13,9 @@
|
|||||||
|
|
||||||
original:
|
original:
|
||||||
http://github.com/piroor/fxaddonlib-tabs-drag-utils
|
http://github.com/piroor/fxaddonlib-tabs-drag-utils
|
||||||
|
|
||||||
depends on:
|
|
||||||
https://github.com/clear-code/js-extended-immutable
|
|
||||||
*/
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
const currentRevision = 40;
|
const currentRevision = 41;
|
||||||
|
|
||||||
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
||||||
|
|
||||||
@ -37,9 +34,6 @@
|
|||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
const TAB_DROP_TYPE = 'application/x-moz-tabbrowser-tab';
|
const TAB_DROP_TYPE = 'application/x-moz-tabbrowser-tab';
|
||||||
|
|
||||||
// fix path to extended-immutable.js
|
|
||||||
var { ExtendedImmutable } = Components.utils.import('resource://treestyletab-modules/lib/extended-immutable.js', {});
|
|
||||||
|
|
||||||
var tabsDragUtils = {
|
var tabsDragUtils = {
|
||||||
revision : currentRevision,
|
revision : currentRevision,
|
||||||
|
|
||||||
@ -149,28 +143,51 @@
|
|||||||
|
|
||||||
if (typeof aObserver._getDropEffectForTabDrag === 'function' &&
|
if (typeof aObserver._getDropEffectForTabDrag === 'function' &&
|
||||||
!aObserver.__tabsDragUtils__getDropEffectForTabDrag) {
|
!aObserver.__tabsDragUtils__getDropEffectForTabDrag) {
|
||||||
aObserver.__tabsDragUtils__getDropEffectForTabDrag = aObserver._getDropEffectForTabDrag;
|
aObserver.__tabsDragUtils_original__getDropEffectForTabDrag = aObserver._getDropEffectForTabDrag;
|
||||||
aObserver._getDropEffectForTabDrag = function(aEvent, ...aArgs) {
|
aObserver._getDropEffectForTabDrag = function(event) {
|
||||||
if (!window["piro.sakura.ne.jp"].tabsDragUtils.isTabsDragging(aEvent))
|
/**
|
||||||
return aEvent;
|
* Original:
|
||||||
|
* base version: Nightly 51.0a1
|
||||||
|
* date : 2016-09-04
|
||||||
|
* source : https://dxr.mozilla.org/mozilla-central/rev/1789229965bfc5e7b08dfcf1c054c366abe1267a/browser/base/content/tabbrowser.xml#5545
|
||||||
|
*/
|
||||||
|
//=====================================================================
|
||||||
|
var dt = event.dataTransfer;
|
||||||
|
// Disallow dropping multiple items
|
||||||
|
// if (dt.mozItemCount > 1)
|
||||||
|
if (dt.mozItemCount > 1 && !window['piro.sakura.ne.jp'].tabsDragUtils.isTabsDragging(event))
|
||||||
|
return "none";
|
||||||
|
|
||||||
var fakeItemCount = 1;
|
var types = dt.mozTypesAt(0);
|
||||||
var fakeDataTransfer = new ExtendedImmutable(aEvent.dataTransfer, {
|
// tabs are always added as the first type
|
||||||
get mozItemCount() {
|
if (types[0] == TAB_DROP_TYPE) {
|
||||||
if (fakeItemCount) {
|
let sourceNode = dt.mozGetDataAt(TAB_DROP_TYPE, 0);
|
||||||
fakeItemCount = null;
|
if (sourceNode instanceof XULElement &&
|
||||||
return fakeItemCount;
|
sourceNode.localName == "tab" &&
|
||||||
}
|
sourceNode.ownerDocument.defaultView instanceof ChromeWindow &&
|
||||||
return aEvent.dataTransfer.mozItemCount;
|
sourceNode.ownerDocument.documentElement.getAttribute("windowtype") == "navigator:browser" &&
|
||||||
}
|
sourceNode.ownerDocument.defaultView.gBrowser.tabContainer == sourceNode.parentNode) {
|
||||||
});
|
// Do not allow transfering a private tab to a non-private window
|
||||||
var fakeEvent = new ExtendedImmutable(aEvent, {
|
// and vice versa.
|
||||||
get dataTransfer() {
|
if (PrivateBrowsingUtils.isWindowPrivate(window) !=
|
||||||
return fakeDataTransfer;
|
PrivateBrowsingUtils.isWindowPrivate(sourceNode.ownerDocument.defaultView))
|
||||||
}
|
return "none";
|
||||||
});
|
|
||||||
return aObserver.__tabsDragUtils__getDropEffectForTabDrag(fakeEvent, ...aArgs);
|
if (window.gMultiProcessBrowser !=
|
||||||
|
sourceNode.ownerDocument.defaultView.gMultiProcessBrowser)
|
||||||
|
return "none";
|
||||||
|
|
||||||
|
return dt.dropEffect == "copy" ? "copy" : "move";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browserDragAndDrop.canDropLink(event)) {
|
||||||
|
return "link";
|
||||||
|
}
|
||||||
|
return "none";
|
||||||
|
//=====================================================================
|
||||||
};
|
};
|
||||||
|
aObserver.__TabsDragUtils_updated__getDropEffectForTabDrag = aObserver._getDropEffectForTabDrag;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('_animateTabMove' in aObserver &&
|
if ('_animateTabMove' in aObserver &&
|
||||||
@ -308,8 +325,6 @@ TDUContext.utils.updateDropIndex(newIndex, TDUContext);
|
|||||||
// Shift background tabs to leave a gap where the dragged tab
|
// Shift background tabs to leave a gap where the dragged tab
|
||||||
// would currently be dropped.
|
// would currently be dropped.
|
||||||
|
|
||||||
tabWidth = TDUContext.tabsSize;
|
|
||||||
|
|
||||||
for (let tab of tabs) {
|
for (let tab of tabs) {
|
||||||
if (tab != draggedTab) {
|
if (tab != draggedTab) {
|
||||||
let shift = getTabShift(tab, newIndex);
|
let shift = getTabShift(tab, newIndex);
|
||||||
@ -320,9 +335,11 @@ tabWidth = TDUContext.tabsSize;
|
|||||||
|
|
||||||
function getTabShift(tab, dropIndex) {
|
function getTabShift(tab, dropIndex) {
|
||||||
if (tab._tPos < draggedTab._tPos && tab._tPos >= dropIndex)
|
if (tab._tPos < draggedTab._tPos && tab._tPos >= dropIndex)
|
||||||
return rtl ? -tabWidth : tabWidth;
|
return rtl ? -TDUContext.tabsSize : TDUContext.tabsSize;
|
||||||
|
// return rtl ? -tabWidth : tabWidth;
|
||||||
if (tab._tPos > draggedTab._tPos && tab._tPos < dropIndex)
|
if (tab._tPos > draggedTab._tPos && tab._tPos < dropIndex)
|
||||||
return rtl ? tabWidth : -tabWidth;
|
return rtl ? TDUContext.tabsSize : -TDUContext.tabsSize;
|
||||||
|
// return rtl ? tabWidth : -tabWidth;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user