From 84cc99cedd96c196ae44242388d0749f66ff11a7 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Thu, 26 Mar 2009 15:58:26 +0000 Subject: [PATCH] require 'linger' over menublock openers before triggering. These are the little gray arrows beside the item-names that trigger the 'about/edit' menus to pop up. Previously, if you sailed your mouse over one of them while moving across the screen, they would pop open. Aggravating. Now a moment of linger-time (currently 200ms) over the arrows is needed to trigger the menu. Much nicer. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@230 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/static/menublocks.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/conifer/static/menublocks.js b/conifer/static/menublocks.js index 0d62111..7d4de56 100644 --- a/conifer/static/menublocks.js +++ b/conifer/static/menublocks.js @@ -3,12 +3,13 @@ function init_blocks() { $('div').click(hideblocks); } +var LINGER = 200; // # milliseconds linger-time required to trigger menu var blocknum = 0; function make_opener() { var menublock = $(this); var blockid = 'menublock' + (blocknum++); menublock.attr('id', blockid); - var opener = '»'; + var opener = '»'; menublock.before(opener); menublock.hide(); } @@ -17,10 +18,30 @@ function hideblocks() { $('span.menublock').hide(); } +// the block we are scheduling to open (due to a mouseover). +var block_to_open = null; + +function maybe_cancelblock(bid) { + // if it is not open yet, this will stop it from opening. + block_to_open = null; +} + +function maybe_openblock(bid) { + // it's 'maybe' because it's cancellable. You have to linger for + // LINGER milliseconds for the open to happen; otherwise + // maybe_cancelblock() will prevent it. + block_to_open = bid; + var cmd = 'openblock("' + bid + '")'; + setTimeout(cmd, LINGER); +} + function openblock(bid) { - if (!resequencing) { - hideblocks(); - $('#' + bid).fadeIn('fast'); + if (!resequencing) { // it's annoying during reseq. + if (block_to_open == bid) { + hideblocks(); + $('#' + bid).fadeIn('fast'); + block_to_open = null; + } } } -- 2.11.0