Skip to content

Commit

Permalink
feat(toast,modal): support short notation $.
Browse files Browse the repository at this point in the history
This PR adds jquery short notation support ($.) to toast and modal which are made dynamically out of js properties and thus are not bound to an existing dom node.

Previously you always had to select body (which still works) when no existing domnode template exists. Infact the body selector was completely ignored.
  • Loading branch information
lubber-de authored Aug 31, 2022
1 parent df9b52b commit 86121ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/definitions/modules/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ window = (typeof window != 'undefined' && window.Math == Math)
: Function('return this')()
;

$.fn.modal = function(parameters) {
$.modal = $.fn.modal = function(parameters) {
var
$allModules = $(this),
$window = $(window),
Expand Down Expand Up @@ -75,8 +75,10 @@ $.fn.modal = function(parameters) {
$dimmable,
$dimmer,

isModalComponent = $module.hasClass('modal'),

element = this,
instance = $module.hasClass('modal') ? $module.data(moduleNamespace) : undefined,
instance = isModalComponent ? $module.data(moduleNamespace) : undefined,

ignoreRepeatedEvents = false,

Expand All @@ -94,7 +96,7 @@ $.fn.modal = function(parameters) {

initialize: function() {
module.create.id();
if(!$module.hasClass('modal')) {
if(!isModalComponent) {
module.create.modal();
if(!$.isFunction(settings.onHidden)) {
settings.onHidden = function () {
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ window = (typeof window != 'undefined' && window.Math == Math)
: Function('return this')()
;

$.fn.toast = function(parameters) {
$.toast = $.fn.toast = function(parameters) {
var
$allModules = $(this),
moduleSelector = $allModules.selector || '',
Expand Down

0 comments on commit 86121ef

Please sign in to comment.