Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Menu Popup

Sai Kiran 89Jan 18 2015 — edited Feb 1 2015

(function(){

  $.fn.popbox = function(options){

    var settings = $.extend({

      selector      : this.selector,

      open          : '.open',

      box           : '.box',

      arrow         : '.arrow',

      arrow_border  : '.arrow-border',

      close         : '.close'

    }, options);

    var methods = {

      open: function(event){

        event.preventDefault();

        var pop = $(this);

        var box = $(this).parent().find(settings['box']);

        box.find(settings['arrow']).css({'left': box.width()/2 - 10});

        box.find(settings['arrow_border']).css({'left': box.width()/2 - 10});

        if(box.css('display') == 'block'){

          methods.close();

        } else {

          box.css({'display': 'block', 'top': 10, 'left': ((pop.parent().width()/2) -box.width()/2 )});

        }

      },

      close: function(){

        $(settings['box']).fadeOut("fast");

      }

    };

    $(document).bind('keyup', function(event){

      if(event.keyCode == 27){

        methods.close();

      }

    });

    $(document).bind('click', function(event){

      if(!$(event.target).closest(settings['selector']).length){

        methods.close();

      }

    });

    return this.each(function(){

      $(this).css({'width': $(settings['box']).width()}); // Width needs to be set otherwise popbox will not move when window resized.

      $(settings['open'], this).bind('click', methods.open);

      $(settings['open'], this).parent().find(settings['close']).bind('click', function(event){

        event.preventDefault();

        methods.close();

      });

    });

  }

}).call(this);

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 1 2015
Added on Jan 18 2015
1 comment
822 views