Click here to Skip to main content
15,881,898 members
Articles / Web Development / HTML

JSBalloon: Non Modal Feedback Mechanism for DHTML Applications

Rate me:
Please Sign up or sign in to vote.
4.83/5 (20 votes)
7 Sep 2005CPOL2 min read 133.3K   1.8K   57   41
A flexible, encapsulated way to implement a passive feedback mechanism

Sample Image - jsballoon.jpg

Introduction

While working on a large intranet application, I found that between validation errors, save confirmation messages, and other user feedback events, there were an awful lot of modal dialog boxes I had to pop and respond to. This DHTML object provides a balloon pop-up not unlike the Microsoft's tray balloon. While I agree that pop-ups are mostly a nuisance in the web environment, this form of rich tool tip may be very handy in streamlining user experience.

One of the features, in a form of an autoHide property, included in JSBalloon for example is the ability to hide the tool tip as soon as the user's mouse moves over it, thus swiftly allowing them to continue on with their work. Another advantage is the ability to place HTML code and form elements within a balloon, thus providing users with optional functionality that may either be easily dismissed or will hide on its own. The main purpose of this exercise, however, is to try and minimize the number of clicks and mouse moves the user needs to make.

Background

JSBalloon is not meant as a replacement for some other excellent DHTML (JavaScript) pop-up libraries, e.g., Jwin Popup Library or overLIB. Rather, it is meant as a very simple enhancement of tool tip functionality within the DHTML environment. Note that the code was tested and will run in Microsoft Internet Explorer 6 only. Also, it was created for a fixed screen.

Using the Code

The only thing you will need to do after copying the JSBalloon.js file to your web server is to update the JSBalloonPath variable with the full path where it is located. This is needed for locating the images and icons.

When instantiating new objects, make sure that your JSBalloon variables are globally scoped and instantiated only once per object:

JavaScript
<script language="JavaScript">

var b4=new JSBalloon({ width:150, 
                       autoAway:false, 
                       autoHide:false,
                       showCloseBox:true});

Once the object is created, you may use the Show method to display a balloon and Hide method to hide it.

The following example demonstrates how to show a balloon. Note that B3 is the ID of a button on a page. The anchor is optional and you may use top and left named arguments to place the balloon anywhere on a page instead.

JavaScript
b4.Show({title:'JavaScript Balloon Example',
    message:'This is an example of a JSBalloon object. '+
        'It\'s primary application is to provide ' +
        'a modeless feedback to DHTML applications.',
    anchor:B3});

You may also mix and match the arguments and properties:

JavaScript
var bl=new JSBalloon({ width:300});

function testBalloon()
{        
    bl.autoHide=false;
    bl.transShow=true;
    bl.autoAway=false;
    bl.showCloseBox=true;
    bl.transShowFilter="progid:DXImageTransform.Microsoft"+
        ".Stretch(stretchstyle=SPIN)";
    bl.transHideFilter="progid:DXImageTransform.Microsoft"+
        ".Slide(slidestyle=HIDE,Bands=1)";
    bl.Show({title:'JavaScript Balloon Example',
        message:'This is an example of a JSBalloon object. ' + 
                'It\'s primary application is to provide a '+
            'modeless feedback to DHTML applications.',
        anchor:B3, icon:'Info'});
}

and to hide:

JavaScript
b4.Hide();

Note that you don't have to call Hide if autoHide is true. Also, if autoAway is true, the Hide method is called when a user moves the mouse over the balloon.

Please review the included source documentation for all the methods and properties.

History

  • 7th September, 2005: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Canada Canada
Arkady Lesniara is a Senior System Analyst/Developer based in Toronto, Canada, specializing in .Net solutions that focus on ASP .Net, VB .Net, T-SQL, AJAX, and all related technologies.

Comments and Discussions

 
QuestionLicense to use the code Pin
neildux12-Oct-12 5:22
neildux12-Oct-12 5:22 
AnswerRe: License to use the code Pin
Arkady Lesniara12-Oct-12 5:31
Arkady Lesniara12-Oct-12 5:31 
GeneralThanks for this post Pin
deepak_rai24-Jan-08 23:18
deepak_rai24-Jan-08 23:18 
Questionhow I can show a balloon Pin
Tom_MJU11-Sep-07 22:20
Tom_MJU11-Sep-07 22:20 
QuestionHow to pass .aspx page in this function Pin
er.miteshpatel11-Aug-07 16:48
er.miteshpatel11-Aug-07 16:48 
QuestionHow can i implement it in ASPX ? Pin
amitsm1432-Apr-07 21:14
amitsm1432-Apr-07 21:14 
AnswerRe: How can i implement it in ASPX ? Pin
Arkady Lesniara3-Apr-07 15:14
Arkady Lesniara3-Apr-07 15:14 
GeneralPrinting page with balloons Pin
dlbjr17-Mar-07 9:26
dlbjr17-Mar-07 9:26 
GeneralUpdates to JSBalloon [modified] Pin
Niraj Sharma8-Dec-06 5:50
Niraj Sharma8-Dec-06 5:50 
QuestionUnable to Immplement the JsBallon in my aspx file VS 2005 Pin
sew new4-Aug-06 9:13
sew new4-Aug-06 9:13 
QuestionDid anyone get it working in firefox? Pin
zquad15-May-06 17:09
zquad15-May-06 17:09 
AnswerRe: Did anyone get it working in firefox? Pin
SemXYZ19-May-06 11:42
SemXYZ19-May-06 11:42 
QuestionIs this JSBalloon licensed or Free for use? Pin
Wayne G. L12-May-06 8:16
Wayne G. L12-May-06 8:16 
AnswerRe: Is this JSBalloon licensed or Free for use? Pin
Arkady Lesniara12-May-06 8:29
Arkady Lesniara12-May-06 8:29 
GeneralFirefox 1.5.0.2 Pin
poinciana20-Apr-06 4:25
poinciana20-Apr-06 4:25 
GeneralYou are delayed 1 year Pin
Anonymous9-Sep-05 8:42
Anonymous9-Sep-05 8:42 
GeneralRe: You are delayed 1 year Pin
OugalNevets21-Sep-05 9:20
OugalNevets21-Sep-05 9:20 
GeneralFirefox version Pin
Andy Krafft8-Sep-05 7:31
Andy Krafft8-Sep-05 7:31 
GeneralObjectOverlap Pin
DeKale5-Sep-05 11:43
DeKale5-Sep-05 11:43 
One of your functions is more complex then necessarily and didn't function as it should. Here is an alternative, that is simpler, shorter and might work.

<br />
function ObjectOverlap(obj1, obj2)<br />
{<br />
	var obj1TopX = getLeft(obj1);<br />
	var obj1TopY = getTop(obj1);<br />
	var obj1BottomX = getLeft(obj1)+obj1.offsetWidth;<br />
	var obj1BottomY = getTop(obj1)+obj1.offsetHeight;<br />
	<br />
	var obj2TopX = getLeft(obj2);<br />
	var obj2TopY = getTop(obj2);<br />
	var obj2BottomX = getLeft(obj2)+obj2.offsetWidth;<br />
	var obj2BottomY = getTop(obj2)+obj2.offsetHeight;<br />
	<br />
	var overlapOnX = (obj1TopX < obj2BottomX && obj2TopX < obj1BottomX);<br />
	var overlapOnY = (obj1TopY < obj2BottomY && obj2TopY < obj1BottomY);<br />
	<br />
	return (overlapOnX && overlapOnY);<br />
}<br />


The function now checks simply if the objects overlab horizontally (overlapOnX) and vertically (overlapOnY).
GeneralRe: ObjectOverlap Pin
Arkady Lesniara6-Sep-05 5:02
Arkady Lesniara6-Sep-05 5:02 
GeneralBalloon positioning upon scrolling Pin
Andy Krafft7-Aug-05 9:54
Andy Krafft7-Aug-05 9:54 
GeneralRe: Balloon positioning upon scrolling Pin
Arkady Lesniara8-Aug-05 3:52
Arkady Lesniara8-Aug-05 3:52 
GeneralRe: Balloon positioning upon scrolling Pin
albans7-Apr-08 21:40
albans7-Apr-08 21:40 
General.Show Delay Pin
leyet28-Jul-05 14:26
leyet28-Jul-05 14:26 
GeneralRe: .Show Delay Pin
Arkady Lesniara29-Jul-05 4:46
Arkady Lesniara29-Jul-05 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.