Skip to content

Commit

Permalink
Merge pull request #149 from dixso/develop
Browse files Browse the repository at this point in the history
3.0.1
  • Loading branch information
dixso committed Sep 19, 2015
2 parents 549212d + fbfc7c7 commit 168ac9c
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 40 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"mobile",
"ui"
],
"version": "3.0.0",
"version": "3.0.1",
"author": {
"name": "Julio de la Calle",
"email": "juliodlcp@gmail.com"
Expand Down
2 changes: 1 addition & 1 deletion dist/custombox.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/custombox.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ <h3 class="popover-title">Example</h3>
Custombox.open({<br>
&nbsp;&nbsp;&nbsp;&nbsp;target: &nbsp;'#modal',<br>
&nbsp;&nbsp;&nbsp;&nbsp;loading: {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delay:&nbsp;&nbsp;2000,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent:&nbsp;['sk-wandering-cubes'],<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;childrens:&nbsp;&nbsp;&nbsp;&nbsp;[<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;['sk-cube', 'sk-cube1'],<br>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "custombox",
"description": "Modal Window Effects with transitions CSS3.",
"version": "3.0.0",
"version": "3.0.1",
"licenses": [
{
"type": "MIT",
Expand Down
102 changes: 68 additions & 34 deletions src/js/custombox.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,6 @@
// Listeners.
this.binds();
},
zIndex: function() {
for ( var zIndex = 0, x = 0, elements = document.getElementsByTagName('*'), xLen = elements.length; x < xLen; x += 1 ) {
var val = window.getComputedStyle(elements[x]).getPropertyValue('z-index');
if ( val ) {
val =+ val;
if ( val > zIndex ) {
zIndex = val;
}
}
}
return zIndex;
},
built: function( item ) {
var cb;
if ( typeof this.item !== 'undefined' ) {
Expand Down Expand Up @@ -397,6 +385,7 @@
},
open: function() {
var _this = this,
delay = 0,
cb = _this.cb[_this.item],
scrollbar = _this.scrollbar();

Expand All @@ -406,6 +395,15 @@

_this.main.classList.add('custombox-container-open');

// Loading delay.
if ( _this.cb[_this.item].settings.loading ) {
if ( _this.cb[_this.item].settings.loading.delay && !isNaN( _this.cb[_this.item].settings.loading.delay * 1 ) ) {
delay = _this.cb[_this.item].settings.loading.delay * 1;
} else {
delay = 1000;
}
}

if ( cb.settings.overlay ) {
if ( _config.overlay.perspective.indexOf(cb.settings.overlayEffect) > -1 || _config.overlay.together.indexOf( cb.settings.overlayEffect ) > -1 ) {
// Add class perspective.
Expand All @@ -414,32 +412,47 @@
cb.overlay.style.opacity = cb.settings.overlayOpacity;
}

if ( _config.overlay.together.indexOf( cb.settings.overlayEffect ) > -1 || _config.oldIE ) {
var open = function() {
cb.overlay.removeEventListener('transitionend', open);

// Load target.
_this.load();

if ( cb.inline) {
cb.wrapper.classList.add('custombox-modal-open');
}
} else {
var open = function() {
cb.overlay.removeEventListener('transitionend', open);
};

if ( _this.cb[_this.item].settings.loading ) {
setTimeout(function() {
open();
}, delay);
} else {
if ( _config.overlay.together.indexOf( cb.settings.overlayEffect ) > -1 || _config.oldIE ) {
if ( _this.cb[_this.item].settings.loading ) {
setTimeout(function() {
// Load target.
_this.load();

if ( cb.inline) {
cb.wrapper.classList.add('custombox-modal-open');
}
}, delay);
}
} else {
cb.overlay.addEventListener('transitionend', open, false);
}
}
} else {
if ( _this.cb[_this.item].settings.loading ) {
setTimeout(function() {
// Load target.
_this.load();

if ( cb.inline) {
cb.wrapper.classList.add('custombox-modal-open');
}
};
cb.overlay.addEventListener('transitionend', open, false);
}
} else {
// Load target.
_this.load();

if ( cb.inline) {
cb.wrapper.classList.add('custombox-modal-open');
}, delay);
}
}
return _this;
Expand Down Expand Up @@ -474,6 +487,10 @@
var _this = this,
cb = this.cb[item];

if ( !cb ) {
return;
}

// Remove classes from html tag.
if ( _this.cb.length === 1 ) {
document.documentElement.classList.remove('custombox-open', 'custombox-perspective');
Expand Down Expand Up @@ -516,11 +533,6 @@
cb.overlay.parentNode.removeChild(cb.overlay);
}

// Callback close.
if ( typeof cb.settings.close === 'function' ) {
cb.settings.close.call();
}

// Trigger close.
if ( document.createEvent ) {
var tclose = document.createEvent('Event');
Expand All @@ -541,8 +553,13 @@

// Remove items.
_this.cb.splice(item, 1);

// Callback close.
if ( typeof cb.settings.close === 'function' ) {
cb.settings.close.call();
}
},
close: function( target ) {
close: function( target, callback ) {
var _this = this,
item;

Expand All @@ -559,6 +576,10 @@

var cb = _this.cb[item];

if ( typeof callback === 'function' ) {
cb.settings.close = callback;
}

// Modal
if ( _config.modal.position.indexOf( cb.settings.effect ) > -1 && cb.settings.animation.length > 1 ) {
cb.modal.classList.remove('custombox-modal-' + cb.settings.effect + '-' + cb.settings.animation[0]);
Expand Down Expand Up @@ -595,6 +616,8 @@
if ( this.cb[i].settings.width !== 'full' ) {
this.cb[i].container.style.marginLeft = '5%';
this.cb[i].container.style.marginRight = '5%';
} else if ( this.cb[i].content.offsetWidth <= window.innerWidth ) {
this.cb[i].content.style.width = 'auto';
}
this.cb[i].container.style.width = 'auto';
this.cb[i].wrapper.style.width = window.innerWidth + 'px';
Expand All @@ -620,6 +643,12 @@
this.cb[i].container.style.marginTop = '5%';
this.cb[i].container.style.marginBottom = '5%';
} else {
if ( this.cb[i].settings.width === 'full' ) {
this.cb[i].settings.position[1] = 'top';
if ( this.cb[i].content.offsetHeight <= window.innerHeight ) {
this.cb[i].content.style.height = window.innerHeight + 'px';
}
}
switch ( this.cb[i].settings.position[1].trim() ) {
case 'top':
result = 0;
Expand Down Expand Up @@ -738,15 +767,20 @@
* @param {object} options - Options for the custombox.
*/
open: function( options ) {
_private.set(options);
_private.set( options );
_private.init();
},
/**
* @desc Close Custombox.
* @param {string} options - Target.
* @param {function} callback.
*/
close: function( target ) {
_private.close(target);
close: function( target, callback ) {
if ( typeof target === 'function' ) {
callback = target;
target = false;
}
_private.close( target, callback );
}
};
}));

0 comments on commit 168ac9c

Please sign in to comment.