Skip to content

Commit

Permalink
Fix balloons position
Browse files Browse the repository at this point in the history
  • Loading branch information
kezsulap committed Nov 23, 2024
1 parent f8ffd14 commit 115d75c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
29 changes: 25 additions & 4 deletions resources/jquery-balloon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
* @author: Hayato Takenaka (http://urin.take-uma.net)
* @version: 0.3.0 - 2012/02/25
**/

function isInViewport(el) {
let left = parseFloat(el.style.left);
return left >= 0;
}

;(function($) {
//-----------------------------------------------------------------------------
// Private
Expand Down Expand Up @@ -99,7 +105,22 @@
})();

// Adjust position of balloon body
function makeupBalloon($target, $balloon, options) {
function makeupBalloonWrapper($target, $balloon, options) {
let positions = options.position.split('-');
console.log('Will try', positions)
for (let position of positions) {
let my_options = {}
Object.assign(my_options, options);
my_options.position = position;
makeupBalloonOriginalImpl($target, $balloon, my_options);
if (isInViewport($balloon[0])) {
console.log('break');
break;
}
}
}
function makeupBalloonOriginalImpl($target, $balloon, options) {
console.log('try', options)
$balloon.stop(true, true);
var outerTip, innerTip,
initTipStyle = {position: "absolute", height: "0", width: "0", border: "solid 0 transparent"},
Expand Down Expand Up @@ -206,7 +227,7 @@
if(options.url) {
$balloon.load($.isFunction(options.url) ? options.url(this) : options.url, function(res, sts, xhr) {
if(options.ajaxComplete) options.ajaxComplete(res, sts, xhr);
makeupBalloon($target, $balloon, options);
makeupBalloonWrapper($target, $balloon, options);
});
}
if(isNew) {
Expand All @@ -216,10 +237,10 @@
.css({visibility: "hidden", position: "absolute"})
.appendTo("body");
$target.data("balloon", $balloon);
makeupBalloon($target, $balloon, options);
makeupBalloonWrapper($target, $balloon, options);
$balloon.hide().css("visibility", "visible");
} else {
makeupBalloon($target, $balloon, options);
makeupBalloonWrapper($target, $balloon, options);
}
$target.data("onTimer", setTimeout(function() {
if(options.showAnimation) {
Expand Down
2 changes: 1 addition & 1 deletion resources/parse-v13.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ function display(node, HTML_title=true, do_topmenu=true) {
no++;
}
if (!is_comment) {
$(a).balloon({position: depth <= 1 ? "bottom" : "left", contents: format_str(node.current_auction.to_table())});
$(a).balloon({position: 'left-top', contents: format_str(node.current_auction.to_table())});
}
content.appendChild(a);
}
Expand Down

0 comments on commit 115d75c

Please sign in to comment.