Skip to content

Commit

Permalink
- do onBeforeClose a onAfterClose callbacků se předává objekt, ob…
Browse files Browse the repository at this point in the history
…sahující element, který pdbox otevřel; stejně jako do ostatních callbacků, viz příklad
  • Loading branch information
zipper committed May 28, 2019
1 parent d541349 commit 88c9177
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 20 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ $ cat bower.json

## Changelog

### v1.3.6
- do `onBeforeClose` a `onAfterClose` callbacků se předává objekt, obsahující element, který pdbox otevřel; stejně jako do ostatních callbacků, viz příklad

### v1.3.5
- oprava smazaného modifikátoru `pdbox--inner` při použití option `isInner` u pdboxu

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery.pdbox",
"version": "1.3.5",
"version": "1.3.6",
"homepage": "https://github.com/peckadesign/jquery.pdbox",
"authors": [
"PeckaDesign, s.r.o <support@peckadesign.cz>"
Expand Down
8 changes: 5 additions & 3 deletions dist/js/jquery.pdbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright Copyright (c) 2014-2019 PeckaDesign, s.r.o
* @license MIT
*
* @version 1.3.5
* @version 1.3.6
*/
$.pdBox = (function () {

Expand Down Expand Up @@ -188,13 +188,15 @@ $.pdBox = (function () {

PdBox.prototype.close = function () {
if (this.isOpen) {
var $el = this.$el;

this.isOpen = false;
this.$el = null;

this.removeEventListener('load', this.setOptions);

this.rootElem.addClass('pdbox--closing');
this.dispatchEvent('beforeClose');
this.dispatchEvent('beforeClose', {element: $el});

this.window.elem.off();

Expand All @@ -208,7 +210,7 @@ $.pdBox = (function () {
that.$body.removeClass('pdbox-open pdbox-open--scrollbar-offset');
}

that.dispatchEvent('afterClose');
that.dispatchEvent('afterClose', {element: $el});
}, closingDuration);
}
};
Expand Down
4 changes: 2 additions & 2 deletions dist/js/jquery.pdbox.min.js

Large diffs are not rendered by default.

30 changes: 20 additions & 10 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,33 @@
$(function () {

var pdBox = window.pdBox || {};
pdBox.foo = function (e) {
pdBox.foo = function (context) {
console.log(context);
console.log('onAfterOpen, callback from element');
};
pdBox.elLoad = function (e) {
pdBox.elLoad = function (context) {
console.log(context);
console.log('onLoad, callback from element');
};
pdBox.elBeforeClose = function (e) {
pdBox.elBeforeClose = function (context) {
console.log(context);
console.log('onBeforeClose, callback from element');
};
pdBox.elAfterClose = function (e) {
pdBox.elAfterClose = function (context) {
console.log(context);
console.log('onAfterClose, callback from element');
};
window.pdBox = pdBox;


// these callbacks cannot be set using data attributes, since beforeOpen callback is called before opening element is processed!
onBeforeOpenCallbacks = [
function () {
function (context) {
console.log(context);
console.log('onBeforeOpen, callback 1');
},
function () {
function (context) {
console.log(context);
console.log('onBeforeOpen, callback 2');
}
];
Expand All @@ -53,16 +59,20 @@
"(min-width: 590px) calc(100vw - (2 * 5px) - (2 * 10px))," +
"calc(100vw - (2 * 10px))",
onBeforeOpen: onBeforeOpenCallbacks, // array or object
onAfterOpen: function () {
onAfterOpen: function (context) {
console.log(context);
console.log('onAfterOpen')
},
onLoad: function () {
onLoad: function (context) {
console.log(context);
console.log('onLoad');
},
onBeforeClose: function () {
onBeforeClose: function (context) {
console.log(context);
console.log('onBeforeClose');
},
onAfterClose: function () {
onAfterClose: function (context) {
console.log(context);
console.log('onAfterClose');
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jquery.pdbox",
"title": "jQuery pdBox",
"description": "pdBox is thickbox-like jQeruy plugin developed in PeckaDesign",
"version": "1.3.5",
"version": "1.3.6",
"author": {
"name":"PeckaDesign, s.r.o",
"email": "support@peckadesign.cz"
Expand Down
8 changes: 5 additions & 3 deletions src/js/jquery.pdbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright Copyright (c) 2014-2018 PeckaDesign, s.r.o
* @license MIT
*
* @version 1.3.1
* @version 1.3.6
*/
$.pdBox = (function () {

Expand Down Expand Up @@ -188,13 +188,15 @@ $.pdBox = (function () {

PdBox.prototype.close = function () {
if (this.isOpen) {
var $el = this.$el;

this.isOpen = false;
this.$el = null;

this.removeEventListener('load', this.setOptions);

this.rootElem.addClass('pdbox--closing');
this.dispatchEvent('beforeClose');
this.dispatchEvent('beforeClose', {element: $el});

this.window.elem.off();

Expand All @@ -208,7 +210,7 @@ $.pdBox = (function () {
that.$body.removeClass('pdbox-open pdbox-open--scrollbar-offset');
}

that.dispatchEvent('afterClose');
that.dispatchEvent('afterClose', {element: $el});
}, closingDuration);
}
};
Expand Down

0 comments on commit 88c9177

Please sign in to comment.