this._calculateYpos = function() { var currentWindowPos = editor.getCursorWindowPosition(true), defaultTextHeight = (ko.views.manager.currentView.scimoz.textHeight(0) - 10), adjustY =+ prefs.getIntPref('tooltipY'); defaultTextHeight = defaultTextHeight + adjustY; return (currentWindowPos.y + defaultTextHeight); }
this._calculateXpos = function() { var currentWindowPos = editor.getCursorWindowPosition(true); return currentWindowPos.x; }
this._calculatePosition = (from, panel) => { var pos, scintilla = _ko.views.manager.currentView ? _ko.views.manager.currentView.scintilla : false; var normalize = function(pos) { pos.x = Math.round(pos.x); pos.y = Math.round(pos.y); return pos; } // Check if pos is already in the correct format if (from && (typeof from) == 'object' && ("x" in from) && ("y" in from)) { pos = from; if ( ! pos.center) { return normalize(pos); } } // Use editor cursor position else if (from == "editor" && editor.available()) { pos = editor.getCursorWindowPosition(true); pos.y -= editor.defaultTextHeight(); var computed = _window.getComputedStyle(panel.element()); pos.y -= parseInt(computed.paddingBottom.replace(/px$/,'')); pos.y -= parseInt(computed.paddingTop.replace(/px$/,'')); // Editor preset cant (shouldnt) be centered return normalize(pos); } // Use editor cursor position else if (from == "bottom-right") // There is no statusbar if the editor isnt available { var wrapper = $("#editorviewbox", _window); var bo = wrapper.element().boxObject; var pos = {x: bo.screenX + bo.width, y: bo.screenY + bo.height}; var computed = _window.getComputedStyle(panel.element()); pos.y -= parseInt(computed.paddingBottom.replace(/px$/,'')); pos.y -= parseInt(computed.paddingTop.replace(/px$/,'')); pos.y -= parseInt(computed.height.replace(/px$/,'')); pos.x -= parseInt(computed.width.replace(/px$/,'')); pos.x -= 5; // padding return normalize(pos); } else { // Center horizontally on the window var bo = document.getElementById('komodo-editor-vbox'); bo = bo ? bo.boxObject : document.documentElement.boxObject; var wx = bo.screenX, wy = bo.screenY, ww = bo.width, wh = bo.height; pos = {x: (ww / 2) + wx, y: (wy + wh) - 100}; } // Center the panel var box = panel.element().boxObject; pos.x = pos.x - ((box.width || 400) / 2); // placeholder width if it is not yet available pos.y = pos.y - box.height; return normalize(pos); }