Skip to content

Commit

Permalink
Update: Allow overriding of all defaults for type:tooltip
Browse files Browse the repository at this point in the history
Set defaults for tooltips dynamically instead of implicitly so they can be overridden with custom options.
  • Loading branch information
vladimirsiljkovic committed Dec 10, 2018
1 parent 81139df commit ffe6521
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions jquery.popupoverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
document.body.style.OTransition !== undefined ||
document.body.style.transition !== undefined;

if (options.type == 'tooltip') {
options.background = false;
options.scrolllock = false;
}

if (options.scrolllock) {
// Calculate the browser's scrollbar width dynamically
var parent;
Expand Down Expand Up @@ -801,25 +796,31 @@
return this.each(function () {

var $el = $(this);
var newDefaults = $.extend(true, {}, $.fn.popup.defaults);

// Set defaults for tooltips dynamically instead of implicitly, so they can be overriden with custom options.
if (customoptions && customoptions.type === 'tooltip') {
newDefaults.background = false;
}

if (typeof customoptions === 'object') { // e.g. $('#popup').popup({'color':'blue'})
var opt = $.extend({}, $.fn.popup.defaults, $el.data('popupoptions'), customoptions);
var opt = $.extend({}, newDefaults, $el.data('popupoptions'), customoptions);
$el.data('popupoptions', opt);
options = $el.data('popupoptions');

methods._init(this);

} else if (typeof customoptions === 'string') { // e.g. $('#popup').popup('hide')
if (!($el.data('popupoptions'))) {
$el.data('popupoptions', $.fn.popup.defaults);
$el.data('popupoptions', newDefaults);
options = $el.data('popupoptions');
}

methods[customoptions].call(this, this);

} else { // e.g. $('#popup').popup()
if (!($el.data('popupoptions'))) {
$el.data('popupoptions', $.fn.popup.defaults);
$el.data('popupoptions', newDefaults);
options = $el.data('popupoptions');
}

Expand Down

0 comments on commit ffe6521

Please sign in to comment.