ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

jquery.dropdown.block.js
Go to the documentation of this file.
1 var dropdown_block_class = function( element , options )
2 {
3 this._element = jQuery( element );
4 this._block_name = 'block-' + ( ++dropdown_block_class.blockId );
5 this.init( options );
6 }
7
8 dropdown_block_class.blockId = 0;
9
10 dropdown_block_class.prototype.init = function( options )
11 {
12 var obj = this;
13
14 var ExtClass = '';
15 if( options.ext_class )
16 {
17 ExtClass = ' ' + options.ext_class;
18 }
19
20 jQuery( this._element ).after( '<div class="popup_block_panel' + ExtClass + '" style="position:absolute; display:none;" id="' + this._block_name + '">' + options.content + '</div>' );
21
22 jQuery( this._element ).mouseover(
23 function( evt )
24 {
25 var position = jQuery( obj._element ).position();
26 var height = jQuery( obj._element ).outerHeight( true );
27
28 jQuery( '#' + obj._block_name ).css( 'left' , position.left );
29 jQuery( '#' + obj._block_name ).css( 'top' , position.top + height - 1 );
30 jQuery( '#' + obj._block_name ).css( 'display' , 'block' );
31 }
32 );
33
34 jQuery( document ).mousemove(
35 function( evt )
36 {
37 var offset = jQuery( obj._element ).offset();
38 var height = jQuery( obj._element ).outerHeight( true );
39 var width = jQuery( obj._element ).outerWidth( true );
40
41 if( offset.left <= evt.pageX && evt.pageX <= offset.left + width && offset.top <= evt.pageY && evt.pageY <= offset.top + height )
42 {
43 return;
44 }
45
46 offset = jQuery( obj._element ).next().offset();
47 height = jQuery( obj._element ).next().outerHeight( true );
48 width = jQuery( obj._element ).next().outerWidth( true );
49
50 if( offset.left <= evt.pageX && evt.pageX <= offset.left + width && offset.top <= evt.pageY && evt.pageY <= offset.top + height )
51 {
52 return;
53 }
54
55 jQuery( obj._element ).next().css( 'display' , 'none' );
56 }
57 );
58 }
59
60 jQuery.fn.dropdown_block = function( options )
61 {
62 options = jQuery.extend(
63 {
64 content : 'empty'
65 } ,
66 options
67 );
68
69 if( this.length == 0 )
70 {
71 result = false;
72 }
73 else if( this.length == 1 )
74 {
75 result = new dropdown_block_class( jQuery( this ) , options );
76 }
77 else
78 {
79 result = [];
80
81 for( i = 0 ; i < this.length ; i++ )
82 {
83 result.push( new dropdown_block_class( jQuery( this[ i ] ) , options ) );
84 }
85 }
86
87 return( result );
88 }