diff --git a/src/tipso.js b/src/tipso.js
index 83b9999..c1b322f 100644
--- a/src/tipso.js
+++ b/src/tipso.js
@@ -5,48 +5,48 @@
* Licensed under the MIT license
* http://object505.mit-license.org/
*/
- // CommonJS, AMD or browser globals
+// CommonJS, AMD or browser globals
(function (factory) {
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(['jquery'], factory);
- } else if (typeof exports === 'object') {
- // Node/CommonJS
- module.exports = factory(require('jquery'));
- } else {
- // Browser globals
- factory(jQuery);
- }
-}(function($) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['jquery'], factory);
+ } else if (typeof exports === 'object') {
+ // Node/CommonJS
+ module.exports = factory(require('jquery'));
+ } else {
+ // Browser globals
+ factory(jQuery);
+ }
+}(function ($) {
var pluginName = "tipso",
defaults = {
- speed : 400, //Animation speed
- background : '#55b555',
- titleBackground : '#333333',
- color : '#ffffff',
- titleColor : '#ffffff',
- titleContent : '', //Content of the title bar
- showArrow : true,
- position : 'top',
- width : 200,
- maxWidth : '',
- delay : 200,
- hideDelay : 0,
- animationIn : '',
- animationOut : '',
- offsetX : 0,
- offsetY : 0,
- arrowWidth : 8,
- tooltipHover : false,
- content : null,
- ajaxContentUrl : null,
- ajaxContentBuffer : 0,
- contentElementId : null, //Normally used for picking template scripts
- useTitle : false, //Use the title tag as tooptip or not
- templateEngineFunc: null, //A function that compiles and renders the content
- onBeforeShow : null,
- onShow : null,
- onHide : null
+ speed: 400, //Animation speed
+ background: '#55b555',
+ titleBackground: '#333333',
+ color: '#ffffff',
+ titleColor: '#ffffff',
+ titleContent: '', //Content of the title bar
+ showArrow: true,
+ position: 'top',
+ width: 200,
+ maxWidth: '',
+ delay: 200,
+ hideDelay: 0,
+ animationIn: '',
+ animationOut: '',
+ offsetX: 0,
+ offsetY: 0,
+ arrowWidth: 8,
+ tooltipHover: false,
+ content: null,
+ ajaxContentUrl: null,
+ ajaxContentBuffer: 0,
+ contentElementId: null, //Normally used for picking template scripts
+ useTitle: false, //Use the title tag as tooptip or not
+ templateEngineFunc: null, //A function that compiles and renders the content
+ onBeforeShow: null,
+ onShow: null,
+ onHide: null
};
function Plugin(element, options) {
@@ -61,18 +61,15 @@
* data-tipso is an object then use it as extra settings and if it's not
* then use it as a title.
*/
- if (typeof(this.$element.data("tipso")) === "object")
- {
+ if (typeof (this.$element.data("tipso")) === "object") {
$.extend(this.settings, this.$element.data("tipso"));
}
var data_keys = Object.keys(this.$element.data());
var data_attrs = {};
- for (var i = 0; i < data_keys.length; i++)
- {
+ for (var i = 0; i < data_keys.length; i++) {
var key = data_keys[i].replace(pluginName, "");
- if (key === "")
- {
+ if (key === "") {
continue;
}
//lowercase first letter
@@ -82,10 +79,8 @@
//We cannot use extend for data_attrs because they are automatically
//lowercased. We need to do this manually and extend this.settings with
//data_attrs
- for (var settings_key in this.settings)
- {
- if (settings_key.toLowerCase() == key)
- {
+ for (var settings_key in this.settings) {
+ if (settings_key.toLowerCase() == key) {
this.settings[settings_key] = data_attrs[key];
}
}
@@ -106,7 +101,7 @@
}
$.extend(Plugin.prototype, {
- init: function() {
+ init: function () {
var obj = this,
$e = this.$element,
$doc = this.doc;
@@ -114,48 +109,46 @@
if (obj.settings.tooltipHover) {
var waitForHover = null,
- hoverHelper = null;
- $e.on('mouseover' + '.' + pluginName, function() {
+ hoverHelper = null;
+ $e.on('mouseover' + '.' + pluginName, function () {
clearTimeout(waitForHover);
clearTimeout(hoverHelper);
- hoverHelper = setTimeout(function(){
+ hoverHelper = setTimeout(function () {
obj.show();
}, 150);
});
- $e.on('mouseout' + '.' + pluginName, function() {
+ $e.on('mouseout' + '.' + pluginName, function () {
clearTimeout(waitForHover);
clearTimeout(hoverHelper);
- waitForHover = setTimeout(function(){
+ waitForHover = setTimeout(function () {
obj.hide();
}, 200);
obj.tooltip()
- .on('mouseover' + '.' + pluginName, function() {
+ .on('mouseover' + '.' + pluginName, function () {
obj.mode = 'tooltipHover';
})
- .on('mouseout' + '.' + pluginName, function() {
+ .on('mouseout' + '.' + pluginName, function () {
obj.mode = 'show';
clearTimeout(waitForHover);
- waitForHover = setTimeout(function(){
+ waitForHover = setTimeout(function () {
obj.hide();
}, 200);
- })
- ;
+ });
});
} else {
- $e.on('mouseover' + '.' + pluginName, function() {
+ $e.on('mouseover' + '.' + pluginName, function () {
obj.show();
});
- $e.on('mouseout' + '.' + pluginName, function() {
+ $e.on('mouseout' + '.' + pluginName, function () {
obj.hide();
});
}
- if(obj.settings.ajaxContentUrl)
- {
- obj.ajaxContent = null;
- }
+ if (obj.settings.ajaxContentUrl) {
+ obj.ajaxContent = null;
+ }
},
- tooltip: function() {
+ tooltip: function () {
if (!this.tipso_bubble) {
this.tipso_bubble = $(
'
'
@@ -163,16 +156,15 @@
}
return this.tipso_bubble;
},
- show: function() {
+ show: function () {
var tipso_bubble = this.tooltip(),
obj = this,
$win = this.win;
if (obj.settings.showArrow === false) {
- tipso_bubble.find(".tipso_arrow").hide();
- }
- else {
- tipso_bubble.find(".tipso_arrow").show();
+ tipso_bubble.find(".tipso_arrow").hide();
+ } else {
+ tipso_bubble.find(".tipso_arrow").show();
}
if (obj.mode === 'hide') {
@@ -180,7 +172,7 @@
obj.settings.onBeforeShow(obj.$element, obj.element, obj);
}
if (obj.settings.size) {
- tipso_bubble.addClass(obj.settings.size);
+ tipso_bubble.addClass(obj.settings.size);
}
if (obj.settings.width) {
tipso_bubble.css({
@@ -188,7 +180,7 @@
color: obj.settings.color,
width: obj.settings.width
}).hide();
- } else if (obj.settings.maxWidth){
+ } else if (obj.settings.maxWidth) {
tipso_bubble.css({
background: obj.settings.background,
color: obj.settings.color,
@@ -202,50 +194,51 @@
}).hide();
}
tipso_bubble.find('.tipso_title').css({
- background: obj.settings.titleBackground,
- color: obj.settings.titleColor
+ background: obj.settings.titleBackground,
+ color: obj.settings.titleColor
});
tipso_bubble.find('.tipso_content').html(obj.content());
tipso_bubble.find('.tipso_title').html(obj.titleContent());
reposition(obj);
- $win.on('resize' + '.' + pluginName, function tipsoResizeHandler () {
- obj.settings.position = obj.settings.preferedPosition;
- reposition(obj);
+ $win.on('resize' + '.' + pluginName, function tipsoResizeHandler() {
+ obj.settings.position = obj.settings.preferedPosition;
+ reposition(obj);
});
window.clearTimeout(obj.timeout);
obj.timeout = null;
- obj.timeout = window.setTimeout(function() {
- if (obj.ieFade || obj.settings.animationIn === '' || obj.settings.animationOut === ''){
+ obj.timeout = window.setTimeout(function () {
+ if (obj.ieFade || obj.settings.animationIn === '' || obj.settings.animationOut === '') {
tipso_bubble.appendTo('body').stop(true, true).fadeIn(obj.settings
- .speed, function() {
- obj.mode = 'show';
- if ($.isFunction(obj.settings.onShow)) {
- obj.settings.onShow(obj.$element, obj.element, obj);
- }
- });
+ .speed,
+ function () {
+ obj.mode = 'show';
+ if ($.isFunction(obj.settings.onShow)) {
+ obj.settings.onShow(obj.$element, obj.element, obj);
+ }
+ });
} else {
tipso_bubble.remove().appendTo('body')
- .stop(true, true)
- .removeClass('animated ' + obj.settings.animationOut)
- .addClass('noAnimation')
- .removeClass('noAnimation')
- .addClass('animated ' + obj.settings.animationIn).fadeIn(obj.settings.speed, function() {
- $(this).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
- $(this).removeClass('animated ' + obj.settings.animationIn);
+ .stop(true, true)
+ .removeClass('animated ' + obj.settings.animationOut)
+ .addClass('noAnimation')
+ .removeClass('noAnimation')
+ .addClass('animated ' + obj.settings.animationIn).fadeIn(obj.settings.speed, function () {
+ $(this).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
+ $(this).removeClass('animated ' + obj.settings.animationIn);
+ });
+ obj.mode = 'show';
+ if ($.isFunction(obj.settings.onShow)) {
+ obj.settings.onShow(obj.$element, obj.element, obj);
+ }
+ $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler');
});
- obj.mode = 'show';
- if ($.isFunction(obj.settings.onShow)) {
- obj.settings.onShow(obj.$element, obj.element, obj);
- }
- $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler');
- });
}
}, obj.settings.delay);
}
},
- hide: function(force) {
+ hide: function (force) {
var obj = this,
$win = this.win,
tipso_bubble = this.tooltip(),
@@ -258,39 +251,39 @@
window.clearTimeout(obj.timeout);
obj.timeout = null;
- obj.timeout = window.setTimeout(function() {
+ obj.timeout = window.setTimeout(function () {
if (obj.mode !== 'tooltipHover') {
- if (obj.ieFade || obj.settings.animationIn === '' || obj.settings.animationOut === ''){
+ if (obj.ieFade || obj.settings.animationIn === '' || obj.settings.animationOut === '') {
tipso_bubble.stop(true, true).fadeOut(obj.settings.speed,
- function() {
- $(this).remove();
- if ($.isFunction(obj.settings.onHide) && obj.mode === 'show') {
- obj.settings.onHide(obj.$element, obj.element, obj);
- }
- obj.mode = 'hide';
- $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler');
- });
+ function () {
+ $(this).remove();
+ if ($.isFunction(obj.settings.onHide) && obj.mode === 'show') {
+ obj.settings.onHide(obj.$element, obj.element, obj);
+ }
+ obj.mode = 'hide';
+ $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler');
+ });
} else {
tipso_bubble.stop(true, true)
- .removeClass('animated ' + obj.settings.animationIn)
- .addClass('noAnimation').removeClass('noAnimation')
- .addClass('animated ' + obj.settings.animationOut)
- .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
- $(this).removeClass('animated ' + obj.settings.animationOut).remove();
- if ($.isFunction(obj.settings.onHide) && obj.mode === 'show') {
- obj.settings.onHide(obj.$element, obj.element, obj);
- }
- obj.mode = 'hide';
- $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler');
- });
+ .removeClass('animated ' + obj.settings.animationIn)
+ .addClass('noAnimation').removeClass('noAnimation')
+ .addClass('animated ' + obj.settings.animationOut)
+ .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
+ $(this).removeClass('animated ' + obj.settings.animationOut).remove();
+ if ($.isFunction(obj.settings.onHide) && obj.mode === 'show') {
+ obj.settings.onHide(obj.$element, obj.element, obj);
+ }
+ obj.mode = 'hide';
+ $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler');
+ });
}
}
}, hideDelay);
},
- close: function() {
+ close: function () {
this.hide(true);
},
- destroy: function() {
+ destroy: function () {
var $e = this.$element,
$win = this.win,
$doc = this.doc;
@@ -299,80 +292,59 @@
$e.removeData(pluginName);
$e.removeClass('tipso_style').attr('title', this._title);
},
- titleContent: function() {
- var content,
- $e = this.$element,
- obj = this;
- if (obj.settings.titleContent)
- {
- content = obj.settings.titleContent;
- }
- else
- {
- content = $e.data('tipso-title');
- }
- return content;
+ titleContent: function () {
+ var content,
+ $e = this.$element,
+ obj = this;
+ if (obj.settings.titleContent) {
+ content = obj.settings.titleContent;
+ } else {
+ content = $e.data('tipso-title');
+ }
+ return content;
},
- content: function() {
+ content: function () {
var content,
$e = this.$element,
obj = this,
title = this._title;
- if (obj.settings.ajaxContentUrl)
- {
- if(obj._ajaxContent)
- {
- content = obj._ajaxContent;
- }
- else
- {
- obj._ajaxContent = content = $.ajax({
- type: "GET",
- url: obj.settings.ajaxContentUrl,
- async: false
- }).responseText;
- if(obj.settings.ajaxContentBuffer > 0)
- {
- setTimeout(function(){
- obj._ajaxContent = null;
- }, obj.settings.ajaxContentBuffer);
- }
- else
- {
- obj._ajaxContent = null;
- }
- }
- }
- else if (obj.settings.contentElementId)
- {
- content = $("#" + obj.settings.contentElementId).text();
- }
- else if (obj.settings.content)
- {
+ if (obj.settings.ajaxContentUrl) {
+ if (obj._ajaxContent) {
+ content = obj._ajaxContent;
+ } else {
+ obj._ajaxContent = content = $.ajax({
+ type: "GET",
+ url: obj.settings.ajaxContentUrl,
+ async: false
+ }).responseText;
+ if (obj.settings.ajaxContentBuffer > 0) {
+ setTimeout(function () {
+ obj._ajaxContent = null;
+ }, obj.settings.ajaxContentBuffer);
+ } else {
+ obj._ajaxContent = null;
+ }
+ }
+ } else if (obj.settings.contentElementId) {
+ content = $("#" + obj.settings.contentElementId).html();
+ } else if (obj.settings.content) {
content = obj.settings.content;
- }
- else
- {
- if (obj.settings.useTitle === true)
- {
+ } else {
+ if (obj.settings.useTitle === true) {
content = title;
- }
- else
- {
+ } else {
// Only use data-tipso as content if it's not being used for settings
- if (typeof($e.data("tipso")) === "string")
- {
+ if (typeof ($e.data("tipso")) === "string") {
content = $e.data('tipso');
}
}
}
- if (obj.settings.templateEngineFunc !== null)
- {
- content = obj.settings.templateEngineFunc(content);
+ if (obj.settings.templateEngineFunc !== null) {
+ content = obj.settings.templateEngineFunc(content);
}
return content;
},
- update: function(key, value) {
+ update: function (key, value) {
var obj = this;
if (value) {
obj.settings[key] = value;
@@ -390,18 +362,18 @@
var width = clone.outerWidth();
clone.remove();
return {
- 'width' : width,
- 'height' : height
+ 'width': width,
+ 'height': height
};
}
- var supportsTransitions = (function() {
+ var supportsTransitions = (function () {
var s = document.createElement('p').style,
- v = ['ms','O','Moz','Webkit'];
- if( s['transition'] === '' ) return true;
- while( v.length )
- if( v.pop() + 'Transition' in s )
- return true;
+ v = ['ms', 'O', 'Moz', 'Webkit'];
+ if (s['transition'] === '') return true;
+ while (v.length)
+ if (v.pop() + 'Transition' in s)
+ return true;
return false;
})();
@@ -421,15 +393,14 @@
var arrow_color = obj.settings.background;
var title_content = obj.titleContent();
if (title_content !== undefined && title_content !== '') {
- arrow_color = obj.settings.titleBackground;
+ arrow_color = obj.settings.titleBackground;
}
if ($e.parent().outerWidth() > $win.outerWidth()) {
$win = $e.parent();
}
- switch (obj.settings.position)
- {
+ switch (obj.settings.position) {
case 'top-right':
pos_left = $e.offset().left + ($e.outerWidth());
pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow;
@@ -437,8 +408,7 @@
marginLeft: -obj.settings.arrowWidth,
marginTop: '',
});
- if (pos_top < $win.scrollTop())
- {
+ if (pos_top < $win.scrollTop()) {
pos_top = $e.offset().top + $e.outerHeight() + arrow;
tipso_bubble.find('.tipso_arrow').css({
@@ -460,9 +430,7 @@
tipso_bubble.removeClass('top-right top bottom left right');
tipso_bubble.addClass('bottom');
- }
- else
- {
+ } else {
tipso_bubble.find('.tipso_arrow').css({
'border-top-color': obj.settings.background,
'border-bottom-color': 'transparent ',
@@ -490,8 +458,7 @@
marginLeft: -obj.settings.arrowWidth,
marginTop: '',
});
- if (pos_top < $win.scrollTop())
- {
+ if (pos_top < $win.scrollTop()) {
pos_top = $e.offset().top + $e.outerHeight() + arrow;
tipso_bubble.find('.tipso_arrow').css({
@@ -513,9 +480,7 @@
tipso_bubble.removeClass('top-right top bottom left right');
tipso_bubble.addClass('bottom');
- }
- else
- {
+ } else {
tipso_bubble.find('.tipso_arrow').css({
'border-top-color': obj.settings.background,
'border-bottom-color': 'transparent ',
@@ -537,76 +502,72 @@
}
break;
- /*
- * Bottom right position
- */
+ /*
+ * Bottom right position
+ */
case 'bottom-right':
- pos_left = $e.offset().left + ($e.outerWidth());
- pos_top = $e.offset().top + $e.outerHeight() + arrow;
- tipso_bubble.find('.tipso_arrow').css({
- marginLeft: -obj.settings.arrowWidth,
- marginTop: '',
- });
- if (pos_top + realHeight(tipso_bubble).height > $win.scrollTop() + $win.outerHeight())
- {
- pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow;
-
- tipso_bubble.find('.tipso_arrow').css({
- 'border-bottom-color': 'transparent',
- 'border-top-color': obj.settings.background,
- 'border-left-color': 'transparent',
- 'border-right-color': 'transparent'
- });
-
- /*
- * Hide and show the appropriate rounded corners
- */
- removeCornerClasses(tipso_bubble);
- tipso_bubble.addClass("top_right_corner");
- tipso_bubble.find(".tipso_title").addClass("top_left_corner");
- tipso_bubble.find('.tipso_arrow').css({
- 'border-left-color': obj.settings.background,
- });
-
- tipso_bubble.removeClass('top-right top bottom left right');
- tipso_bubble.addClass('top');
- }
- else
- {
- tipso_bubble.find('.tipso_arrow').css({
- 'border-top-color': 'transparent',
- 'border-bottom-color': arrow_color,
- 'border-left-color': 'transparent',
- 'border-right-color': 'transparent'
- });
-
- /*
- * Hide and show the appropriate rounded corners
- */
- removeCornerClasses(tipso_bubble);
- tipso_bubble.addClass("bottom_right_corner");
- tipso_bubble.find(".tipso_title").addClass("bottom_right_corner");
- tipso_bubble.find('.tipso_arrow').css({
- 'border-left-color': arrow_color,
- });
-
- tipso_bubble.removeClass('top bottom left right');
- tipso_bubble.addClass('bottom');
- }
- break;
-
- /*
- * Bottom left position
- */
- case 'bottom-left':
+ pos_left = $e.offset().left + ($e.outerWidth());
+ pos_top = $e.offset().top + $e.outerHeight() + arrow;
+ tipso_bubble.find('.tipso_arrow').css({
+ marginLeft: -obj.settings.arrowWidth,
+ marginTop: '',
+ });
+ if (pos_top + realHeight(tipso_bubble).height > $win.scrollTop() + $win.outerHeight()) {
+ pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow;
+
+ tipso_bubble.find('.tipso_arrow').css({
+ 'border-bottom-color': 'transparent',
+ 'border-top-color': obj.settings.background,
+ 'border-left-color': 'transparent',
+ 'border-right-color': 'transparent'
+ });
+
+ /*
+ * Hide and show the appropriate rounded corners
+ */
+ removeCornerClasses(tipso_bubble);
+ tipso_bubble.addClass("top_right_corner");
+ tipso_bubble.find(".tipso_title").addClass("top_left_corner");
+ tipso_bubble.find('.tipso_arrow').css({
+ 'border-left-color': obj.settings.background,
+ });
+
+ tipso_bubble.removeClass('top-right top bottom left right');
+ tipso_bubble.addClass('top');
+ } else {
+ tipso_bubble.find('.tipso_arrow').css({
+ 'border-top-color': 'transparent',
+ 'border-bottom-color': arrow_color,
+ 'border-left-color': 'transparent',
+ 'border-right-color': 'transparent'
+ });
+
+ /*
+ * Hide and show the appropriate rounded corners
+ */
+ removeCornerClasses(tipso_bubble);
+ tipso_bubble.addClass("bottom_right_corner");
+ tipso_bubble.find(".tipso_title").addClass("bottom_right_corner");
+ tipso_bubble.find('.tipso_arrow').css({
+ 'border-left-color': arrow_color,
+ });
+
+ tipso_bubble.removeClass('top bottom left right');
+ tipso_bubble.addClass('bottom');
+ }
+ break;
+
+ /*
+ * Bottom left position
+ */
+ case 'bottom-left':
pos_left = $e.offset().left - (realHeight(tipso_bubble).width);
pos_top = $e.offset().top + $e.outerHeight() + arrow;
tipso_bubble.find('.tipso_arrow').css({
marginLeft: -obj.settings.arrowWidth,
marginTop: '',
});
- if (pos_top + realHeight(tipso_bubble).height > $win.scrollTop() + $win.outerHeight())
- {
+ if (pos_top + realHeight(tipso_bubble).height > $win.scrollTop() + $win.outerHeight()) {
pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow;
tipso_bubble.find('.tipso_arrow').css({
@@ -628,9 +589,7 @@
tipso_bubble.removeClass('top-right top bottom left right');
tipso_bubble.addClass('top');
- }
- else
- {
+ } else {
tipso_bubble.find('.tipso_arrow').css({
'border-top-color': 'transparent',
'border-bottom-color': arrow_color,
@@ -652,9 +611,9 @@
tipso_bubble.addClass('bottom');
}
break;
- /*
- * Top position
- */
+ /*
+ * Top position
+ */
case 'top':
pos_left = $e.offset().left + ($e.outerWidth() / 2) - (realHeight(tipso_bubble).width / 2);
pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow;
@@ -662,8 +621,7 @@
marginLeft: -obj.settings.arrowWidth,
marginTop: '',
});
- if (pos_top < $win.scrollTop())
- {
+ if (pos_top < $win.scrollTop()) {
pos_top = $e.offset().top + $e.outerHeight() + arrow;
tipso_bubble.find('.tipso_arrow').css({
@@ -675,9 +633,7 @@
tipso_bubble.removeClass('top bottom left right');
tipso_bubble.addClass('bottom');
- }
- else
- {
+ } else {
tipso_bubble.find('.tipso_arrow').css({
'border-top-color': obj.settings.background,
'border-bottom-color': 'transparent',
@@ -695,8 +651,7 @@
marginLeft: -obj.settings.arrowWidth,
marginTop: '',
});
- if (pos_top + realHeight(tipso_bubble).height > $win.scrollTop() + $win.outerHeight())
- {
+ if (pos_top + realHeight(tipso_bubble).height > $win.scrollTop() + $win.outerHeight()) {
pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow;
tipso_bubble.find('.tipso_arrow').css({
'border-top-color': obj.settings.background,
@@ -706,9 +661,7 @@
});
tipso_bubble.removeClass('top bottom left right');
tipso_bubble.addClass('top');
- }
- else
- {
+ } else {
tipso_bubble.find('.tipso_arrow').css({
'border-bottom-color': arrow_color,
'border-top-color': 'transparent',
@@ -726,8 +679,7 @@
marginTop: -obj.settings.arrowWidth,
marginLeft: ''
});
- if (pos_left < $win.scrollLeft())
- {
+ if (pos_left < $win.scrollLeft()) {
pos_left = $e.offset().left + $e.outerWidth() + arrow;
tipso_bubble.find('.tipso_arrow').css({
'border-right-color': obj.settings.background,
@@ -737,9 +689,7 @@
});
tipso_bubble.removeClass('top bottom left right');
tipso_bubble.addClass('right');
- }
- else
- {
+ } else {
tipso_bubble.find('.tipso_arrow').css({
'border-left-color': obj.settings.background,
'border-right-color': 'transparent',
@@ -757,8 +707,7 @@
marginTop: -obj.settings.arrowWidth,
marginLeft: ''
});
- if (pos_left + arrow + obj.settings.width > $win.scrollLeft() + $win.outerWidth())
- {
+ if (pos_left + arrow + obj.settings.width > $win.scrollLeft() + $win.outerWidth()) {
pos_left = $e.offset().left - realHeight(tipso_bubble).width - arrow;
tipso_bubble.find('.tipso_arrow').css({
'border-left-color': obj.settings.background,
@@ -768,9 +717,7 @@
});
tipso_bubble.removeClass('top bottom left right');
tipso_bubble.addClass('left');
- }
- else
- {
+ } else {
tipso_bubble.find('.tipso_arrow').css({
'border-right-color': obj.settings.background,
'border-left-color': 'transparent',
@@ -785,29 +732,25 @@
/*
* Set the position of the arrow for the corner positions
*/
- if (obj.settings.position === 'top-right')
- {
+ if (obj.settings.position === 'top-right') {
tipso_bubble.find('.tipso_arrow').css({
'margin-left': -obj.settings.width / 2
});
}
- if (obj.settings.position === 'top-left')
- {
+ if (obj.settings.position === 'top-left') {
var tipso_arrow = tipso_bubble.find(".tipso_arrow").eq(0);
tipso_arrow.css({
'margin-left': obj.settings.width / 2 - 2 * obj.settings.arrowWidth
});
}
- if (obj.settings.position === 'bottom-right')
- {
+ if (obj.settings.position === 'bottom-right') {
var tipso_arrow = tipso_bubble.find(".tipso_arrow").eq(0);
tipso_arrow.css({
'margin-left': -obj.settings.width / 2,
'margin-top': ''
});
}
- if (obj.settings.position === 'bottom-left')
- {
+ if (obj.settings.position === 'bottom-left') {
var tipso_arrow = tipso_bubble.find(".tipso_arrow").eq(0);
tipso_arrow.css({
'margin-left': obj.settings.width / 2 - 2 * obj.settings.arrowWidth,
@@ -818,15 +761,13 @@
/*
* Check out of boundness
*/
- if (pos_left < $win.scrollLeft() && (obj.settings.position === 'bottom' || obj.settings.position === 'top'))
- {
+ if (pos_left < $win.scrollLeft() && (obj.settings.position === 'bottom' || obj.settings.position === 'top')) {
tipso_bubble.find('.tipso_arrow').css({
marginLeft: pos_left - obj.settings.arrowWidth
});
pos_left = 0;
}
- if (pos_left + obj.settings.width > $win.outerWidth() && (obj.settings.position === 'bottom' || obj.settings.position === 'top'))
- {
+ if (pos_left + obj.settings.width > $win.outerWidth() && (obj.settings.position === 'bottom' || obj.settings.position === 'top')) {
diff = $win.outerWidth() - (pos_left + obj.settings.width);
tipso_bubble.find('.tipso_arrow').css({
marginLeft: -diff - obj.settings.arrowWidth,
@@ -835,21 +776,19 @@
pos_left = pos_left + diff;
}
if (pos_left < $win.scrollLeft() &&
- (obj.settings.position === 'left' ||
+ (obj.settings.position === 'left' ||
obj.settings.position === 'right' ||
obj.settings.position === 'top-right' ||
obj.settings.position === 'top-left' ||
obj.settings.position === 'bottom-right' ||
- obj.settings.position === 'bottom-left'))
- {
+ obj.settings.position === 'bottom-left')) {
pos_left = $e.offset().left + ($e.outerWidth() / 2) - (realHeight(tipso_bubble).width / 2);
tipso_bubble.find('.tipso_arrow').css({
marginLeft: -obj.settings.arrowWidth,
marginTop: ''
});
pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow;
- if (pos_top < $win.scrollTop())
- {
+ if (pos_top < $win.scrollTop()) {
pos_top = $e.offset().top + $e.outerHeight() + arrow;
tipso_bubble.find('.tipso_arrow').css({
'border-bottom-color': arrow_color,
@@ -860,9 +799,7 @@
tipso_bubble.removeClass('top bottom left right');
removeCornerClasses(tipso_bubble);
tipso_bubble.addClass('bottom');
- }
- else
- {
+ } else {
tipso_bubble.find('.tipso_arrow').css({
'border-top-color': obj.settings.background,
'border-bottom-color': 'transparent',
@@ -873,8 +810,7 @@
removeCornerClasses(tipso_bubble);
tipso_bubble.addClass('top');
}
- if (pos_left + obj.settings.width > $win.outerWidth())
- {
+ if (pos_left + obj.settings.width > $win.outerWidth()) {
diff = $win.outerWidth() - (pos_left + obj.settings.width);
tipso_bubble.find('.tipso_arrow').css({
marginLeft: -diff - obj.settings.arrowWidth,
@@ -882,8 +818,7 @@
});
pos_left = pos_left + diff;
}
- if (pos_left < $win.scrollLeft())
- {
+ if (pos_left < $win.scrollLeft()) {
tipso_bubble.find('.tipso_arrow').css({
marginLeft: pos_left - obj.settings.arrowWidth
});
@@ -895,21 +830,19 @@
* If out of bounds from the right hand side
*/
if (pos_left + obj.settings.width > $win.outerWidth() &&
- (obj.settings.position === 'left' ||
+ (obj.settings.position === 'left' ||
obj.settings.position === 'right' ||
obj.settings.position === 'top-right' ||
obj.settings.position === 'top-left' ||
obj.settings.position === 'bottom-right' ||
- obj.settings.position === 'bottom-right'))
- {
+ obj.settings.position === 'bottom-right')) {
pos_left = $e.offset().left + ($e.outerWidth() / 2) - (realHeight(tipso_bubble).width / 2);
tipso_bubble.find('.tipso_arrow').css({
marginLeft: -obj.settings.arrowWidth,
marginTop: ''
});
pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow;
- if (pos_top < $win.scrollTop())
- {
+ if (pos_top < $win.scrollTop()) {
pos_top = $e.offset().top + $e.outerHeight() + arrow;
tipso_bubble.find('.tipso_arrow').css({
'border-bottom-color': arrow_color,
@@ -921,9 +854,7 @@
removeCornerClasses(tipso_bubble);
tipso_bubble.removeClass('top bottom left right');
tipso_bubble.addClass('bottom');
- }
- else
- {
+ } else {
tipso_bubble.find('.tipso_arrow').css({
'border-top-color': obj.settings.background,
'border-bottom-color': 'transparent',
@@ -938,8 +869,7 @@
tipso_bubble.removeClass('top bottom left right');
tipso_bubble.addClass('top');
}
- if (pos_left + obj.settings.width > $win.outerWidth())
- {
+ if (pos_left + obj.settings.width > $win.outerWidth()) {
diff = $win.outerWidth() - (pos_left + obj.settings.width);
tipso_bubble.find('.tipso_arrow').css({
marginLeft: -diff - obj.settings.arrowWidth,
@@ -947,8 +877,7 @@
});
pos_left = pos_left + diff;
}
- if (pos_left < $win.scrollLeft())
- {
+ if (pos_left < $win.scrollLeft()) {
tipso_bubble.find('.tipso_arrow').css({
marginLeft: pos_left - obj.settings.arrowWidth
});
@@ -963,26 +892,24 @@
// If positioned right or left and tooltip is out of bounds change position
// This position change will be temporary, because preferedPosition is there
// to help!!
- if (pos_top < $win.scrollTop() && (obj.settings.position === 'right' || obj.settings.position === 'left'))
- {
+ if (pos_top < $win.scrollTop() && (obj.settings.position === 'right' || obj.settings.position === 'left')) {
$e.tipso('update', 'position', 'bottom');
reposition(obj);
}
if (pos_top + realHeight(tipso_bubble).height > $win.scrollTop() + $win.outerHeight() &&
- (obj.settings.position === 'right' || obj.settings.position === 'left'))
- {
+ (obj.settings.position === 'right' || obj.settings.position === 'left')) {
$e.tipso('update', 'position', 'top');
reposition(obj);
}
}
- $[pluginName] = $.fn[pluginName] = function(options) {
+ $[pluginName] = $.fn[pluginName] = function (options) {
var args = arguments;
if (options === undefined || typeof options === 'object') {
if (!(this instanceof $)) {
$.extend(defaults, options);
}
- return this.each(function() {
+ return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
}
@@ -990,7 +917,7 @@
} else if (typeof options === 'string' && options[0] !== '_' && options !==
'init') {
var returns;
- this.each(function() {
+ this.each(function () {
var instance = $.data(this, 'plugin_' + pluginName);
if (!instance) {
instance = $.data(this, 'plugin_' + pluginName, new Plugin(
@@ -1008,4 +935,4 @@
return returns !== undefined ? returns : this;
}
};
-}));
+}));
\ No newline at end of file