seaofclouds (owner)

Revisions

gist: 7334 Download_button fork
public
Public Clone URL: git://gist.github.com/7334.git
Embed All Files: show embed
jquery.pop.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// pop! for jQuery
// v0.3 requires jQuery v1.2 or later
// WATCH OUT, THIS IS IN DEVELOPMENT AND DOES NOT WORK!
//
// Licensed under the MIT:
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright 2007,2008 SEAOFCLOUDS [http://seaofclouds.com]
//
 
(function($) {
  
  $.fn.pop = function(options) {
 
    var settings = $.extend({}, $.fn.pop.defaults, options);
 
    var pops = [];
    
    var zIndex = 1000;
 
    $(this).each(function() {
    
      var content = $(this).find(settings.content);
      pops.push(content);
      var trigger = $(this).find(settings.trigger);
 
      content.hide();
      
      $(content).css({ zIndex: zIndex-- });
 
      $(trigger).click(function(e){
        $(content).show();
        $(content).addClass('active');
      });
 
      activePop = null;
      $(document.body).click(function(){
        $(pops).each(function(i) {
          if ($(this)!=activePop) {
            $(this).removeClass('active');
            $(this).hide();
          }
        });
        return false;
      });
 
      $([content, trigger]).mouseover(function() {
        activePop = $(content);
      });
      $([content, trigger]).mouseout(function() {
        activePop = null;
      });
 
    });
 
  }
 
  $.fn.pop.defaults = {
   content : '.pop_content',
   trigger : '.pop_trigger'
  }
    
 
})(jQuery);
Text only #
1
2
3
4
5
6
7
8
// structure
//
// <div class="pop">
// <div class="pop_toggle"></div>
// <div class="pop_content">
// content_here
// </div>
// </div>