diff options
author | NastuzziSamy <samy@nastuzzi.fr> | 2018-05-06 23:26:46 +0300 |
---|---|---|
committer | NastuzziSamy <samy@nastuzzi.fr> | 2018-05-06 23:26:46 +0300 |
commit | e28855b772c3f2f8a469f55196a968f12323bba4 (patch) | |
tree | 0fde1e027148b0461cd504170ea6ca44a4a0e63b /js/script.js | |
parent | bb8a0494edf2d1bf366710f62f6b4a21a4d1263e (diff) |
Bugs fixedv0.8.4
Bad delimiter selection
Submenus went out of the screen
Submenus was not deleted (at the end, unnecessary use of memory)
Diffstat (limited to 'js/script.js')
-rw-r--r-- | js/script.js | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/js/script.js b/js/script.js index d28bb3e..14d256f 100644 --- a/js/script.js +++ b/js/script.js @@ -232,10 +232,20 @@ var RightClick = RightClick || {}; div.appendTo(context); if (menu.isSubMenu) { + var top = context.position().top + Math.abs(div.css("marginTop").replace('px', '')); + var left = context.parents('.rightClick').first().innerWidth() - (Math.abs(div.css("marginLeft").replace('px', '')) / 2); + var right = 'auto'; + var positionAndWidth = div.offset().left + context.parents('.rightClick').first().outerWidth() + div.outerWidth() + (Math.abs(div.css("marginLeft").replace('px', '')) * 4); + + if (positionAndWidth > $(window).width()) { + right = left; + left = 'auto'; + } + div.css({ - 'left': context.parents('.rightClick').first().innerWidth() - (Math.abs(div.css("marginLeft").replace('px', '')) / 2), - 'right': 'auto', - 'top': context.position().top + Math.abs(div.css("marginTop").replace('px', '')) + 'left': left, + 'right': right, + 'top': top }); } else { @@ -349,6 +359,9 @@ var RightClick = RightClick || {}; if (exports.menus.hasOwnProperty(i)) { if (exports.menus[i].close() === false) return false; + + if (exports.menus[i].isSubMenu) + exports.menus.splice(i, 1); } } @@ -358,8 +371,10 @@ var RightClick = RightClick || {}; exports.closeAllSubMenus = function () { for (var i in exports.menus) { if (exports.menus.hasOwnProperty(i)) { - if (exports.menus[i].isSubMenu && exports.menus[i].close() === false) - return false; + if (exports.menus[i].isSubMenu) { + if (exports.menus[i].close() === false) + return false; + } } } |