feat(gridster): add config to set custom show/hide widget methods

by default jQuery’s `hide` and `show` methods are used. You could also
use fadeIn/fadeOut or write your own kind of jQuery plugin like
`$.fn.showInAFancyWay` and use `showInAFancyWay` as the value in the
show_method config option.

If you want to keep the previos behaviour, you need to set
`hide_method` option to `’fadeOut’`

Breaking Changes

`remove_widget` and `remove_all_widgets` methods not return a promise
instead of the gridster instance
This commit is contained in:
Javi Sánchez-Marín
2015-04-16 17:45:11 +02:00
parent e258d595b0
commit 7de5bbabc0
2 changed files with 43 additions and 31 deletions

View File

@ -349,15 +349,16 @@ describe('gridster.js', function() {
expect($el).to.have.length(1);
});
it('should be positioned in the top/leftmost available space', function() {
this.gridster.remove_widget('[data-col=1][data-row=1]');
it('should be positioned in the top/leftmost available space', function(done) {
this.gridster.remove_widget('[data-col=1][data-row=1]').done(function() {
this.gridster.add_widget('<li class="new">new</li>', 1, 1);
this.gridster.add_widget('<li class="new">new</li>', 1, 1);
var $el = this.gridster.$el.find('.new');
expect($el.attr('data-col')).to.equal('1');
expect($el.attr('data-row')).to.equal('1');
expect(this.gridster.gridmap[1][1][0]).to.equal($el[0]);
var $el = this.gridster.$el.find('.new');
expect($el.attr('data-col')).to.equal('1');
expect($el.attr('data-row')).to.equal('1');
expect(this.gridster.gridmap[1][1][0]).to.equal($el[0]);
done();
}.bind(this));
});
it('should respect the specified dimensions and coords', function() {
@ -384,7 +385,7 @@ describe('gridster.js', function() {
it('should be removed from the grid', function(done) {
var $el = this.gridster.$el.find('[data-col=1][data-row=1]');
this.gridster.remove_widget($el, false, function() {
this.gridster.remove_widget($el, false).done(function() {
expect(this.gridmap[1][1]).to.be.false;
expect(document.contains($el[0])).to.be.false;
done();
@ -396,8 +397,8 @@ describe('gridster.js', function() {
var $el2 = this.gridster.$el.find('[data-col=2][data-row=1]');
var $el3 = this.gridster.$el.find('[data-col=1][data-row=3]');
var silent = false;
this.gridster.remove_widget($el1, silent, function() {
this.remove_widget($el2, silent, function() {
this.gridster.remove_widget($el1, silent).done(function() {
this.remove_widget($el2, silent).done(function() {
expect($el3.attr('data-col')).to.equal('1');
expect($el3.attr('data-row')).to.equal('1');
done();
@ -410,8 +411,8 @@ describe('gridster.js', function() {
var $el2 = this.gridster.$el.find('[data-col=2][data-row=1]');
var $el3 = this.gridster.$el.find('[data-col=1][data-row=3]');
var silent = true;
this.gridster.remove_widget($el1, silent, function() {
this.remove_widget($el2, silent, function() {
this.gridster.remove_widget($el1, silent).done(function() {
this.remove_widget($el2, silent).done(function() {
expect($el3.attr('data-col')).to.equal('1');
expect($el3.attr('data-row')).to.equal('3');
done();