Keep the button position when it's placed right before space, flexible space or separator
Este commit está contenido en:
27
bootstrap.js
vendido
27
bootstrap.js
vendido
@@ -55,9 +55,17 @@ let button = {
|
|||||||
toolbox.palette.appendChild(b);
|
toolbox.palette.appendChild(b);
|
||||||
|
|
||||||
let {toolbarId, nextItemId} = this.getPrefs(),
|
let {toolbarId, nextItemId} = this.getPrefs(),
|
||||||
toolbar = toolbarId && $(doc, toolbarId),
|
toolbar = toolbarId && $(doc, toolbarId);
|
||||||
nextItem = toolbar && $(doc, nextItemId);
|
|
||||||
if (toolbar) {
|
if (toolbar) {
|
||||||
|
// Handle special items with dynamic ids
|
||||||
|
let match = /^(separator|spacer|spring)\[(\d+)\]$/.exec(nextItemId);
|
||||||
|
if (match !== null) {
|
||||||
|
let dynItems = toolbar.querySelectorAll("toolbar" + match[1]);
|
||||||
|
if (match[2] < dynItems.length) {
|
||||||
|
nextItemId = dynItems[match[2]].id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let nextItem = nextItemId && $(doc, nextItemId);
|
||||||
if (nextItem && nextItem.parentNode && nextItem.parentNode.id.replace("-customization-target", "") == toolbarId) {
|
if (nextItem && nextItem.parentNode && nextItem.parentNode.id.replace("-customization-target", "") == toolbarId) {
|
||||||
toolbar.insertItem(this.meta.id, nextItem);
|
toolbar.insertItem(this.meta.id, nextItem);
|
||||||
} else {
|
} else {
|
||||||
@@ -90,15 +98,26 @@ let button = {
|
|||||||
afterCustomize : function (e) {
|
afterCustomize : function (e) {
|
||||||
let toolbox = e.target,
|
let toolbox = e.target,
|
||||||
b = $(toolbox.parentNode, button.meta.id),
|
b = $(toolbox.parentNode, button.meta.id),
|
||||||
toolbarId, nextItemId;
|
toolbarId, nextItem, nextItemId;
|
||||||
if (b) {
|
if (b) {
|
||||||
let parent = b.parentNode,
|
let parent = b.parentNode;
|
||||||
nextItem = b.nextSibling;
|
nextItem = b.nextSibling;
|
||||||
if (parent && (parent.localName == "toolbar" || parent.classList.contains("customization-target"))) {
|
if (parent && (parent.localName == "toolbar" || parent.classList.contains("customization-target"))) {
|
||||||
toolbarId = parent.id;
|
toolbarId = parent.id;
|
||||||
nextItemId = nextItem && nextItem.id;
|
nextItemId = nextItem && nextItem.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Handle special items with dynamic ids
|
||||||
|
let match = /^(separator|spacer|spring)\d+$/.exec(nextItemId);
|
||||||
|
if (match !== null) {
|
||||||
|
let dynItems = nextItem.parentNode.querySelectorAll("toolbar" + match[1]);
|
||||||
|
for (let i = 0; i < dynItems.length; i++) {
|
||||||
|
if (dynItems[i].id == nextItemId) {
|
||||||
|
nextItemId = match[1] + "[" + i + "]";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
button.setPrefs(toolbarId, nextItemId);
|
button.setPrefs(toolbarId, nextItemId);
|
||||||
},
|
},
|
||||||
getPrefs : function () {
|
getPrefs : function () {
|
||||||
|
|||||||
Referencia en una nueva incidencia
Block a user