Skip to content

Commit

Permalink
[JS] Adding onClose, afterLoad callback
Browse files Browse the repository at this point in the history
  • Loading branch information
dwaan committed Apr 3, 2017
1 parent 7b939c6 commit 6befc2f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tshirt-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
closeButton: true,
closeOutside: true,
disableTouchScroll: true,
onClick: function () {}
onClick: function () {},
onClose: function () {},
afterLoad: function () {}
},
popup = this,
settings = $.extend({}, defaults, options);

this.close = function () {
$("#" + settings.id).fadeOut(128);
$("#" + settings.id + " > div > div > div").removeClass("animated " + settings.animation).html("");

settings.onClose ();
};

return this.each(function () {
Expand All @@ -40,15 +44,11 @@
// See if it's a youtube link
youtube_id = url.match(/(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w\-_]+)\&?/);

console.log ("1", youtube_id);

// Just to make sure that the url have youtube's domains
if (url.indexOf("youtube.com") <= -1 && url.indexOf("youtu.be") <= -1) {
youtube_id = null;
}

console.log ("2", url.indexOf("youtube.com") <= -1, url.indexOf("youtu.be") <= -1, youtube_id);

if (youtube_id !== null) {
settings.type = "iframe";
}
Expand Down Expand Up @@ -125,10 +125,13 @@

$("#" + settings.id + " > div > div > div").addClass("animated " + settings.animation)
$("#" + settings.id + " > div > div > div > div").html("<p class='error'><i class='" + settings.iconPrefix +" " + settings.iconPrefix +"-rocket " + settings.iconPrefix +"-5x'></i><br />Error while loading your content<br />Please close this popup and try again</p>");

}
settings.afterLoad ();
});
} else if (settings.target !== "") {
$("#" + settings.id + " > div > div > div > div").html($(settings.target).html ());
settings.afterLoad ();
}


Expand All @@ -139,6 +142,8 @@
} else {
$("#" + settings.id + " > div > div > div > div").html ("<iframe src='" + url + "' width='100%' height='100%' frameborder='0' />");
}

settings.afterLoad ();
}

// Display or not close button
Expand Down

0 comments on commit 6befc2f

Please sign in to comment.