jquery Display similar reminder box

Source: Internet
Author: User
Tags bind config

  (function ($) {   $.fn.tooltip = function (settings) {    //Configuration setup& nbsp;    config = {       ' dialog_content_selector ': ' Div.tooltip_ Description ',       ' animation_distance ': 50,       ' Opacity ': 0.85,       ' arrow_left_offset ': 70,       ' Arrow_top_offset ': 50,       ' arrow_height ': 20,        ' arrow_width ': 20,       ' Animation_duration_ms ': 300,        ' event_in ': ' mouseover ',       ' event_out ': ' Mouseout '      };     if (settings) $.extend (config, settings);    /**       * Apply interaction to the matching elements      **/     This.each (function () {       $ (this). Bind ( Config.event_in,function () {         _show (this);       })        bind (Config.event_out,function () {          _hide (This);      })     });     /**      * Positions the dialog box based on the target  & nbsp;   * element ' s location      **/     function _show ( Target_elm) {       var dialog_content = $ (Target_elm). Find (Config.dialog_content_ selector);       var dialog_box = _create (dialog_content);        var is_top_right = $ (Target_elm). Hasclass ("Tooltiptopright");      &nbsP var is_bottom_right = $ (Target_elm). Hasclass ("Tooltipbottomright");       var is_top = $ (Target_elm). Hasclass ("Tooltiptop");       var is_bottom = $ (Target_elm). HasClass (" Tooltipbottom ");       var has_position = Is_top_right | | Is_bottom_right | | Is_top | | is_bottom;       var position;       var target_elm_ Position = $ (Target_elm). Offset ();      //coming from the top right   & nbsp;   if (is_top_right | |!has_position && (Target_elm_position.top < $ (dialog_box). outerHeight () && target_elm_position.top >= config.arrow_top_offset)) {          Position = {           Start: {              left:target_elm_position. Left + $ (target_elm). Outerwidth () + config.animation_distance,              top : Target_elm_position.top + ($ (Target_elm). Outerheight ()/2)-Config.arrow_top_ offset          },            End: {             Left:target_elm _position.left + $ (target_elm). Outerwidth (),              top : Target_elm_position.top + ($ (Target_elm). Outerheight ()/2)-config.arrow_top_offset  & nbsp;       },           Arrow_class: "Div.left_arrow"         }       }      //coming from the bottom Right       else if (is_bottom_right | |!has_position && (Target_elm_position.left < Config.arrow_left_ Offset + $ (target_elm). Outerwidth () && target_elm_position.top > $ (dialog_box). Outerheight ()) {          position = {            Start: {             left:target_elm_ Position.left + $ (target_elm). Outerwidth () + config.animation_distance,              top : Target_elm_position.top + ($ (Target_elm). Outerheight ()/2) + Config.arrow_ Top_offset-$ (Dialog_box). Outerheight () + config.arrow_height           },           End: {              Left:target_elm_position.left + $ (target_elm). OuterwidtH (),             top : Target_elm_position.top + ($ (Target_elm). Outerheight ()/2) + Config.arrow_top_offset-$ (Dialog_box). Outerheight () + config.arrow_height & nbsp;        },            Arrow_class: "Div.left_arrow"         }          $ (Dialog_box). Find ("Div.left_arrow"). CSS ({top: $ (Dialog_box). Outerheight ()-( Config.arrow_top_offset * 2) + "px"});      }      // Coming from the top       else if (is_top | |!has_position && (target_elm_ Position.top + config.animation_distance > $ (dialog_box). Outerheight () && target_elm_position.left >= Config.arrow_left_offset)) {         position = { &NBsp;         Start: {              Left:target_elm_position.left + ($ (Target_elm). Outerwidth ()/2)-Config.arrow_left_offset,              top : Target_elm_position.top- Config.animation_distance-$ (Dialog_box). Outerheight ()            },           End: {              Left:target_elm_position.left + ($ (Target_elm). Outerwidth ()/2)-Config.arrow_ left_offset,             top : Target_elm_ Position.top-$ (Dialog_box). Outerheight () + config.arrow_height           },           arrow_class: "Div.down_Arrow "        }      }              //coming from the bottom        Else if (Is_bottom | |!has_position && (target_elm_position.top + config.animation_distance < $ (dialog_ box). Outerheight ()) {         position = {            Start: {             Left:target_elm_position.left + ($ (Target_elm). Outerwidth ()/2)-config.arrow_left_offset,              top : Target_elm_position.top + $ (target_elm). Outerheight () + config.animation_distance          },            End: {             Left:target_elm_position.left + ($ (Target_elm). Outerwidth ()/2)-Config.arrow_left _offset,             top : Target_elm_ Position.top + $ (target_elm). Outerheight ()           },            arrow_class: "Div.up_arrow"          }      }      //position and show The box       $ (dialog_box). CSS ({         Top:position.start.top + "px",         left:position.start.left + "px",          opacity:config.opacity      });               $ (dialog_box). Find ("div. Arrow "). Hide ();       $ (dialog_box). Find (Position.arrow_class). Show ();       //Begin animation       $ (dialog_box). Animate ({          top:position.end.top,          left:position.end.left,         opacity: "Toggle"        }, Config.animation_duration_ms);            }; --End _show function    /**      * Stop the animation (if any) and Remov E from dialog box from the dom      */     function _hide (Target_elm) {& nbsp;      $ (' body '). Find ("Div.jquery-gdakram-tooltip"). Stop (). Remove ();     };    /**      * creates the DIalog Box element      * and appends it to the body      **/ & nbsp;   function _create (content_elm) {       var header = ($ (content_elm). attr ("title"))? "<h1>" + $ (Content_elm). attr ("title") + "</h1>": ';       return $ (' < Div class= ' jquery-gdakram-tooltip ' >         <div class= ' Up_arrow Arrow ' ></div>         <div class= ' Left_arrow Arrow ' ></ div>         <div class= ' content ' > ' + header + $ (content_elm). HTML ( ) + "</div>         <div style= ' Clear:both ' ></div>          <div class= ' Down_arrow Arrow ' ></div>        </div> "). Appendto (' body ');    &nbsP };     return this;  };&nbsp}) (JQuery);

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.