Updated plugin nTooltip 2.0, popup tooltip is displayed when hovering over an element
We wrote a plugin that will display a pop-up message above an element, be it a button or a link. When you hover or click on an element, it will display a pop-up block with information. The block adapts when the device screen is resized. Below there is an example in gif animation and a code of how it works.
nTooltip is powered by jquery !!!
Download plugin 2.0 nTooltip archive:
Original html markup:
Javascript source code:
You can check it yourself:
- data-placement="left" - Block placement
- data-original-title=“test text“ - Content inside the tooltip block
Global options
1) Determines the alignment of the block, depending on its placement above the element, that is, if the property placement other values for placement will come.
align: left
align (type string)
There is a list that the property takes align:
1) In property placement specify how the block will be placed over the element
placement: left
placement (тип string)
There is a list that the property takes placement:
or in the attribute: data-placement="left"
1) specify the name of the element in which the "Tooltip" block will be created, by default the block is created inside the tag body
elem_global: .box
elem_global (тип string)
1) If we want to move the block both above or below when it appears, we will specify the properties top and left
top: 15
top (тип integer)
left: 15
left (тип integer)
1) When you hover or click on an element, a block is displayed at a certain speed. This counts as the base time for block animation.
time: 1000
time (type integer)
1)If the browser screen size has changed, the redrawing of the coordinates of the created block is triggered, only if the property resize takes true
resize: true
resize (type boolean)
1)There are two properties with which you can enable and disable the execution of the block appearance and disappearance event, these are properties start_elem and stop_elem
start_elem: true
start_elem (type boolean)
stop_elem: false
stop_elem (type boolean)
Cursor control
1)When performing various manipulations with an element, there is a property event, with which you can set the event executed by the cursor over the element.
cursor.event: click
cursor.event (тип string)
There is a list that the property takes cursor.event:
1)After the block appears, you can move the cursor to the created block, and the block will not disappear - this is a property is_over
cursor.is_over: false
cursor.is_over (type boolean)
Change the block that appears
1) When a block is created, the name is applied to it nTooltip to id and classes, if there is a conflict with the layout for this name, you can change it. The plugin itself works by this name.
elem.name: testTooltip
elem.name (type string)
1) I needed to change the block size there is a property width, the layout applies this size as max-width, for free adaptability.
elem.width: 250
elem.width (type integer)
1) We display something inside the block, for example, some html, title, text, there is a property html.
elem.html: ‘test text’
elem.html (type string, undefined)
or specify in the attribute data-original-title=“test text“. Js will have higher priority
2) There is an additional output for some icons, this is html_before.
elem.html_before: 'icon'
elem.html_before (type string)
3) There is an additional output for some icons, this is html_after.
elem.html_after: 'icon'
elem.html_after (type string)
1) Apply styles to the block that appears
elem.style: { 'background': 'red' }
elem.style (type json)
1) Element events are executed during the appearance and disappearance of the block, 2 functions work, eventStart, eventStop
elem.eventStart: function(self, self_elem, options){}
elem.eventStart (type function)
elem.eventStop: function(self, self_elem, options){}
elem.eventStop (type function)
Before element in block
1) Display or not display a before element inside a block
before.display: false
before.display (type boolean)
1) Specifying the dimensions of the before element inside the block
before.width: 10
before.width (type integer)
before.height: 10
before.height (type integer)
1) We display something inside a before element, for example, some kind html, title, text, there is a property html.
before.html: ''
before.html (type string)
1) Styling the befor element
before.style: { ‘background’: ‘red’ }
before.style (type json)
1) Element events are executed during the appearance and disappearance of the block, 2 functions work, eventStart, eventStop
before.eventStart: function(self, self_elem, options){}
before.eventStart (type function)
before.eventStop: function(self, self_elem, options){}
before.eventStop (type function)
Animation
1) Enable animation to work, respectively, you can disable if the property active will accept false
animation.active: false
animation.active (type boolean)
1) The effect of moving a block from the previous element on which it was previously displayed
animation.moving: true
animation.moving (type boolean)
1) When hovering or clicking on an element, a block is displayed with the effect of increasing or otherwise decreasing
animation.scale: true
animation.scale (type boolean)
2) Disable only block increase when
animation.scale_start: false
animation.scale_start (type boolean)
3) Disable only block reduction
animation.scale_stop: false
animation.scale_stop (type boolean)
4) We set the time to increase or decrease the block, Default time is taken as base if animation.time_scale takes on the meaning undefined
animation.time_scale: 1000
animation.time_scale (type integer, undefined)
1) to_1_css — the style is applied before the block is displayed
animation.to_1_css: {‘opacity’: ‘0’}
animation.to_1_css (type json)
2) to_2_css — the style is applied when the block is rendered
animation.to_2_css: {‘opacity’: ‘1’}
animation.to_2_css (type json)
3) end_1_css — the style is applied when the block starts to disappear
animation.end_1_css: {‘opacity’: ‘1’}
animation.end_1_css (type json)
4) end_2_css — the style is applied when the block is about to be destroyed
animation.end_2_css: {‘opacity’: ‘0’}
animation.end_2_css (type json)
1) Block events are executed in the process of block appearance and disappearance, 2 functions work, eventStart, eventStop
animation.eventStart: function(self, self_elem, options){}
animation.eventStart (type function)
animation.eventStop: function(self, self_elem, options){}
animation.eventStop (type function)