From 6befc2f58d8a59d4ce2174242a6ca5a077f7ca65 Mon Sep 17 00:00:00 2001 From: Dwan Date: Mon, 3 Apr 2017 14:22:08 +0700 Subject: [PATCH] [JS] Adding onClose, afterLoad callback --- tshirt-popup.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tshirt-popup.js b/tshirt-popup.js index a8dd365..2bb6747 100644 --- a/tshirt-popup.js +++ b/tshirt-popup.js @@ -16,7 +16,9 @@ closeButton: true, closeOutside: true, disableTouchScroll: true, - onClick: function () {} + onClick: function () {}, + onClose: function () {}, + afterLoad: function () {} }, popup = this, settings = $.extend({}, defaults, options); @@ -24,6 +26,8 @@ this.close = function () { $("#" + settings.id).fadeOut(128); $("#" + settings.id + " > div > div > div").removeClass("animated " + settings.animation).html(""); + + settings.onClose (); }; return this.each(function () { @@ -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"; } @@ -125,10 +125,13 @@ $("#" + settings.id + " > div > div > div").addClass("animated " + settings.animation) $("#" + settings.id + " > div > div > div > div").html("


Error while loading your content
Please close this popup and try again

"); + } + settings.afterLoad (); }); } else if (settings.target !== "") { $("#" + settings.id + " > div > div > div > div").html($(settings.target).html ()); + settings.afterLoad (); } @@ -139,6 +142,8 @@ } else { $("#" + settings.id + " > div > div > div > div").html ("