Fixed position of extension buttons
This commit is contained in:
parent
c2055098a1
commit
81b37f3f1e
@ -198,6 +198,7 @@ define([
|
||||
// Operations on Layout
|
||||
addEventHook("onLayoutCreated");
|
||||
addEventHook("onLayoutResize");
|
||||
addEventHook("onExtensionButtonResize");
|
||||
|
||||
// Operations on editor
|
||||
addEventHook("onPagedownConfigure");
|
||||
|
@ -4,7 +4,7 @@ define([
|
||||
"utils",
|
||||
"classes/Extension",
|
||||
"text!html/buttonStat.html",
|
||||
"text!html/buttonStatSettingsBlock.html",
|
||||
"text!html/buttonStatSettingsBlock.html"
|
||||
], function($, _, utils, Extension, buttonStatHTML, buttonStatSettingsBlockHTML) {
|
||||
|
||||
var buttonStat = new Extension("buttonStat", 'Button "Statistics"', true, true);
|
||||
@ -15,7 +15,12 @@ define([
|
||||
name2: "Words",
|
||||
value2: "\\S+",
|
||||
name3: "Paragraphs",
|
||||
value3: "\\S.*",
|
||||
value3: "\\S.*"
|
||||
};
|
||||
|
||||
var eventMgr;
|
||||
buttonStat.onEventMgrCreated = function(eventMgrParam) {
|
||||
eventMgr = eventMgrParam;
|
||||
};
|
||||
|
||||
buttonStat.onLoadSettings = function() {
|
||||
@ -72,6 +77,7 @@ define([
|
||||
valueElt.textContent = value1Elt.textContent = (text.match(regex1) || []).length;
|
||||
value2Elt.textContent = (text.match(regex2) || []).length;
|
||||
value3Elt.textContent = (text.match(regex3) || []).length;
|
||||
eventMgr.onExtensionButtonResize();
|
||||
};
|
||||
|
||||
return buttonStat;
|
||||
|
@ -25,6 +25,7 @@ define([
|
||||
var menuPanelWidth = 280;
|
||||
var documentPanelWidth = 320;
|
||||
var titleMinWidth = 200;
|
||||
var previewButtonsClosedOffset = 18;
|
||||
var previewButtonsDropdownMargin = 130;
|
||||
var previewButtonsOffset = {
|
||||
x: -45,
|
||||
@ -606,10 +607,14 @@ define([
|
||||
previewButtons.x = previewButtonsOffset.x;
|
||||
previewButtons.y = previewButtonsOffset.y;
|
||||
previewButtons.applyCss();
|
||||
setTimeout(function() {
|
||||
previewButtons.$elt.addClass('animate');
|
||||
}, 0);
|
||||
|
||||
function openPreviewButtons() {
|
||||
clearTimeout(closeTimeoutId);
|
||||
if(!previewButtons.isDragged) {
|
||||
previewButtons.isOpen = true;
|
||||
previewButtons.x = previewButtonsOffset.x;
|
||||
previewButtons.applyCss();
|
||||
}
|
||||
@ -622,13 +627,14 @@ define([
|
||||
clearTimeout(closeTimeoutId);
|
||||
closeTimeoutId = setTimeout(function() {
|
||||
if(!previewButtons.isDragged && !dropdownOpen) {
|
||||
previewButtons.$elt.addClass('animate');
|
||||
previewButtons.x = previewButtonsOffset.x + previewButtons.elt.offsetWidth;
|
||||
previewButtons.isOpen = false;
|
||||
previewButtons.x = previewButtonsOffset.x + previewButtons.elt.offsetWidth + previewButtonsClosedOffset;
|
||||
previewButtons.applyCss();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
openPreviewButtons();
|
||||
closePreviewButtons();
|
||||
previewButtons.$elt.hover(openPreviewButtons, closePreviewButtons).on('show.bs.dropdown', function() {
|
||||
dropdownOpen = true;
|
||||
@ -656,6 +662,22 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
eventMgr.addListener('onExtensionButtonResize', function() {
|
||||
if(!previewButtons.isDragged) {
|
||||
if(!previewButtons.isOpen) {
|
||||
previewButtons.$elt.removeClass('animate');
|
||||
previewButtons.x = previewButtonsOffset.x + previewButtons.elt.offsetWidth + previewButtonsClosedOffset;
|
||||
previewButtons.applyCss();
|
||||
setTimeout(function() {
|
||||
previewButtons.$elt.addClass('animate');
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
previewButtons.adjustPosition();
|
||||
}
|
||||
});
|
||||
|
||||
eventMgr.onLayoutCreated(layout);
|
||||
return layout;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user