Skip to content

Commit eedf6d5

Browse files
committed
Fix _is_one_column_mode -> _isOneColumnMode and add in obsolete unit checks for all gs, non-GSEngine code.
1 parent 51d7a20 commit eedf6d5

File tree

5 files changed

+305
-4
lines changed

5 files changed

+305
-4
lines changed

dist/gridstack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@
14661466
GridStack.prototype._update_container_height = obsolete(GridStack.prototype._updateContainerHeight,
14671467
'_update_container_height', '_updateContainerHeight');
14681468
GridStack.prototype._is_one_column_mode = obsolete(GridStack.prototype._isOneColumnMode,
1469-
'_is_one_column_mode',' _isOneColumnMode');
1469+
'_is_one_column_mode','_isOneColumnMode');
14701470
GridStack.prototype._prepare_element = obsolete(GridStack.prototype._prepareElement,
14711471
'_prepare_element', '_prepareElement');
14721472
GridStack.prototype.set_animation = obsolete(GridStack.prototype.setAnimation,

dist/gridstack.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gridstack.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/gridstack-spec.js

Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,305 @@ describe('gridstack', function() {
330330
}
331331
});
332332
});
333+
334+
describe('grid.isAreaEmpty', function() {
335+
beforeEach(function() {
336+
document.body.insertAdjacentHTML(
337+
'afterbegin', gridstackHTML);
338+
});
339+
afterEach(function() {
340+
document.body.removeChild(document.getElementsByClassName('grid-stack')[0]);
341+
});
342+
it('should set return false.', function() {
343+
var options = {
344+
cellHeight: 80,
345+
verticalMargin: 10
346+
};
347+
$('.grid-stack').gridstack(options);
348+
var grid = $('.grid-stack').data('gridstack');
349+
var shouldBeFalse = grid.isAreaEmpty(1, 1, 1, 1);
350+
expect(shouldBeFalse).toBe(false);
351+
});
352+
it('should set return true.', function() {
353+
var options = {
354+
cellHeight: 80,
355+
verticalMargin: 10
356+
};
357+
$('.grid-stack').gridstack(options);
358+
var grid = $('.grid-stack').data('gridstack');
359+
var shouldBeTrue = grid.isAreaEmpty(5, 5, 1, 1);
360+
expect(shouldBeTrue).toBe(true);
361+
});
362+
});
363+
364+
describe('grid obsolete warnings', function() {
365+
beforeEach(function() {
366+
document.body.insertAdjacentHTML(
367+
'afterbegin', gridstackHTML);
368+
});
369+
afterEach(function() {
370+
document.body.removeChild(document.getElementsByClassName('grid-stack')[0]);
371+
});
372+
it('should log a warning if set_static is called.', function() {
373+
console.warn = jasmine.createSpy('log');
374+
var options = {
375+
cellHeight: 80,
376+
verticalMargin: 10
377+
};
378+
$('.grid-stack').gridstack(options);
379+
var grid = $('.grid-stack').data('gridstack');
380+
grid.set_static(true);
381+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `set_static` is deprecated as of v0.2.5 and has been replaced with `setStatic`. It will be **completely** removed in v1.0.');
382+
});
383+
it('should log a warning if _set_static_class is called.', function() {
384+
console.warn = jasmine.createSpy('log');
385+
var options = {
386+
cellHeight: 80,
387+
verticalMargin: 10
388+
};
389+
$('.grid-stack').gridstack(options);
390+
var grid = $('.grid-stack').data('gridstack');
391+
grid._set_static_class();
392+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_set_static_class` is deprecated as of v0.2.5 and has been replaced with `_setStaticClass`. It will be **completely** removed in v1.0.');
393+
});
394+
it('should log a warning if is_area_empty is called.', function() {
395+
console.warn = jasmine.createSpy('log');
396+
var options = {
397+
cellHeight: 80,
398+
verticalMargin: 10
399+
};
400+
$('.grid-stack').gridstack(options);
401+
var grid = $('.grid-stack').data('gridstack');
402+
grid.is_area_empty(1, 1, 1, 1);
403+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `is_area_empty` is deprecated as of v0.2.5 and has been replaced with `isAreaEmpty`. It will be **completely** removed in v1.0.');
404+
});
405+
it('should log a warning if batch_update is called.', function() {
406+
console.warn = jasmine.createSpy('log');
407+
var options = {
408+
cellHeight: 80,
409+
verticalMargin: 10
410+
};
411+
$('.grid-stack').gridstack(options);
412+
var grid = $('.grid-stack').data('gridstack');
413+
grid.batch_update();
414+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `batch_update` is deprecated as of v0.2.5 and has been replaced with `batchUpdate`. It will be **completely** removed in v1.0.');
415+
});
416+
it('should log a warning if get_cell_from_pixel is called.', function() {
417+
console.warn = jasmine.createSpy('log');
418+
var options = {
419+
cellHeight: 80,
420+
verticalMargin: 10
421+
};
422+
$('.grid-stack').gridstack(options);
423+
var grid = $('.grid-stack').data('gridstack');
424+
var pixel = {top: 100, left: 72};
425+
grid.get_cell_from_pixel(pixel);
426+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `get_cell_from_pixel` is deprecated as of v0.2.5 and has been replaced with `getCellFromPixel`. It will be **completely** removed in v1.0.');
427+
});
428+
it('should log a warning if cell_width is called.', function() {
429+
console.warn = jasmine.createSpy('log');
430+
var options = {
431+
cellHeight: 80,
432+
verticalMargin: 10
433+
};
434+
$('.grid-stack').gridstack(options);
435+
var grid = $('.grid-stack').data('gridstack');
436+
grid.cell_width();
437+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `cell_width` is deprecated as of v0.2.5 and has been replaced with `cellWidth`. It will be **completely** removed in v1.0.');
438+
});
439+
it('should log a warning if cell_height is called.', function() {
440+
console.warn = jasmine.createSpy('log');
441+
var options = {
442+
cellHeight: 80,
443+
verticalMargin: 10
444+
};
445+
$('.grid-stack').gridstack(options);
446+
var grid = $('.grid-stack').data('gridstack');
447+
grid.cell_height();
448+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `cell_height` is deprecated as of v0.2.5 and has been replaced with `cellHeight`. It will be **completely** removed in v1.0.');
449+
});
450+
it('should log a warning if _update_element is called.', function() {
451+
console.warn = jasmine.createSpy('log');
452+
var options = {
453+
cellHeight: 80,
454+
verticalMargin: 10
455+
};
456+
$('.grid-stack').gridstack(options);
457+
var grid = $('.grid-stack').data('gridstack');
458+
grid._update_element();
459+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_update_element` is deprecated as of v0.2.5 and has been replaced with `_updateElement`. It will be **completely** removed in v1.0.');
460+
});
461+
it('should log a warning if min_width is called.', function() {
462+
console.warn = jasmine.createSpy('log');
463+
var options = {
464+
cellHeight: 80,
465+
verticalMargin: 10
466+
};
467+
$('.grid-stack').gridstack(options);
468+
var grid = $('.grid-stack').data('gridstack');
469+
var items = $('.grid-stack-item');
470+
for (var i = 0; i < items.length; i++) {
471+
grid.min_width(items[i], 2);
472+
}
473+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `min_width` is deprecated as of v0.2.5 and has been replaced with `minWidth`. It will be **completely** removed in v1.0.');
474+
});
475+
it('should log a warning if min_height is called.', function() {
476+
console.warn = jasmine.createSpy('log');
477+
var options = {
478+
cellHeight: 80,
479+
verticalMargin: 10
480+
};
481+
$('.grid-stack').gridstack(options);
482+
var grid = $('.grid-stack').data('gridstack');
483+
var items = $('.grid-stack-item');
484+
for (var i = 0; i < items.length; i++) {
485+
grid.min_height(items[i], 2);
486+
}
487+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `min_height` is deprecated as of v0.2.5 and has been replaced with `minHeight`. It will be **completely** removed in v1.0.');
488+
});
489+
it('should log a warning if remove_all is called.', function() {
490+
console.warn = jasmine.createSpy('log');
491+
var options = {
492+
cellHeight: 80,
493+
verticalMargin: 10
494+
};
495+
$('.grid-stack').gridstack(options);
496+
var grid = $('.grid-stack').data('gridstack');
497+
grid.remove_all();
498+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `remove_all` is deprecated as of v0.2.5 and has been replaced with `removeAll`. It will be **completely** removed in v1.0.');
499+
});
500+
it('should log a warning if remove_widget is called.', function() {
501+
console.warn = jasmine.createSpy('log');
502+
var options = {
503+
cellHeight: 80,
504+
verticalMargin: 10
505+
};
506+
$('.grid-stack').gridstack(options);
507+
var grid = $('.grid-stack').data('gridstack');
508+
var items = $('.grid-stack-item');
509+
for (var i = 0; i < items.length; i++) {
510+
grid.remove_widget(items[i]);
511+
}
512+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `remove_widget` is deprecated as of v0.2.5 and has been replaced with `removeWidget`. It will be **completely** removed in v1.0.');
513+
});
514+
it('should log a warning if will_it_fit is called.', function() {
515+
console.warn = jasmine.createSpy('log');
516+
var options = {
517+
cellHeight: 80,
518+
verticalMargin: 10
519+
};
520+
$('.grid-stack').gridstack(options);
521+
var grid = $('.grid-stack').data('gridstack');
522+
grid.will_it_fit(0, 0, 1, 1, false);
523+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `will_it_fit` is deprecated as of v0.2.5 and has been replaced with `willItFit`. It will be **completely** removed in v1.0.');
524+
});
525+
it('should log a warning if make_widget is called.', function() {
526+
console.warn = jasmine.createSpy('log');
527+
var options = {
528+
cellHeight: 80,
529+
verticalMargin: 10
530+
};
531+
$('.grid-stack').gridstack(options);
532+
var grid = $('.grid-stack').data('gridstack');
533+
var items = $('.grid-stack-item');
534+
for (var i = 0; i < items.length; i++) {
535+
grid.make_widget(items[i]);
536+
}
537+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `make_widget` is deprecated as of v0.2.5 and has been replaced with `makeWidget`. It will be **completely** removed in v1.0.');
538+
});
539+
it('should log a warning if add_widget is called.', function() {
540+
console.warn = jasmine.createSpy('log');
541+
var options = {
542+
cellHeight: 80,
543+
verticalMargin: 10
544+
};
545+
$('.grid-stack').gridstack(options);
546+
var grid = $('.grid-stack').data('gridstack');
547+
var items = $('.grid-stack-item');
548+
for (var i = 0; i < items.length; i++) {
549+
grid.add_widget(items[i]);
550+
}
551+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `add_widget` is deprecated as of v0.2.5 and has been replaced with `addWidget`. It will be **completely** removed in v1.0.');
552+
});
553+
it('should log a warning if set_animation is called.', function() {
554+
console.warn = jasmine.createSpy('log');
555+
var options = {
556+
cellHeight: 80,
557+
verticalMargin: 10
558+
};
559+
$('.grid-stack').gridstack(options);
560+
var grid = $('.grid-stack').data('gridstack');
561+
grid.set_animation(true);
562+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `set_animation` is deprecated as of v0.2.5 and has been replaced with `setAnimation`. It will be **completely** removed in v1.0.');
563+
});
564+
it('should log a warning if _prepare_element is called.', function() {
565+
console.warn = jasmine.createSpy('log');
566+
var options = {
567+
cellHeight: 80,
568+
verticalMargin: 10
569+
};
570+
$('.grid-stack').gridstack(options);
571+
var grid = $('.grid-stack').data('gridstack');
572+
var items = $('.grid-stack-item');
573+
for (var i = 0; i < items.length; i++) {
574+
grid._prepare_element(items[i]);
575+
}
576+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_prepare_element` is deprecated as of v0.2.5 and has been replaced with `_prepareElement`. It will be **completely** removed in v1.0.');
577+
});
578+
it('should log a warning if _is_one_column_mode is called.', function() {
579+
console.warn = jasmine.createSpy('log');
580+
var options = {
581+
cellHeight: 80,
582+
verticalMargin: 10
583+
};
584+
$('.grid-stack').gridstack(options);
585+
var grid = $('.grid-stack').data('gridstack');
586+
grid._is_one_column_mode();
587+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_is_one_column_mode` is deprecated as of v0.2.5 and has been replaced with `_isOneColumnMode`. It will be **completely** removed in v1.0.');
588+
});
589+
it('should log a warning if _update_container_height is called.', function() {
590+
console.warn = jasmine.createSpy('log');
591+
var options = {
592+
cellHeight: 80,
593+
verticalMargin: 10
594+
};
595+
$('.grid-stack').gridstack(options);
596+
var grid = $('.grid-stack').data('gridstack');
597+
grid._update_container_height();
598+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_update_container_height` is deprecated as of v0.2.5 and has been replaced with `_updateContainerHeight`. It will be **completely** removed in v1.0.');
599+
});
600+
it('should log a warning if _update_styles is called.', function() {
601+
console.warn = jasmine.createSpy('log');
602+
var options = {
603+
cellHeight: 80,
604+
verticalMargin: 10
605+
};
606+
$('.grid-stack').gridstack(options);
607+
var grid = $('.grid-stack').data('gridstack');
608+
grid._update_styles();
609+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_update_styles` is deprecated as of v0.2.5 and has been replaced with `_updateStyles`. It will be **completely** removed in v1.0.');
610+
});
611+
it('should log a warning if _init_styles is called.', function() {
612+
console.warn = jasmine.createSpy('log');
613+
var options = {
614+
cellHeight: 80,
615+
verticalMargin: 10
616+
};
617+
$('.grid-stack').gridstack(options);
618+
var grid = $('.grid-stack').data('gridstack');
619+
grid._init_styles();
620+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_init_styles` is deprecated as of v0.2.5 and has been replaced with `_initStyles`. It will be **completely** removed in v1.0.');
621+
});
622+
it('should log a warning if _trigger_change_event is called.', function() {
623+
console.warn = jasmine.createSpy('log');
624+
var options = {
625+
cellHeight: 80,
626+
verticalMargin: 10
627+
};
628+
$('.grid-stack').gridstack(options);
629+
var grid = $('.grid-stack').data('gridstack');
630+
grid._trigger_change_event();
631+
expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_trigger_change_event` is deprecated as of v0.2.5 and has been replaced with `_triggerChangeEvent`. It will be **completely** removed in v1.0.');
632+
});
633+
});
333634
});

src/gridstack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@
14661466
GridStack.prototype._update_container_height = obsolete(GridStack.prototype._updateContainerHeight,
14671467
'_update_container_height', '_updateContainerHeight');
14681468
GridStack.prototype._is_one_column_mode = obsolete(GridStack.prototype._isOneColumnMode,
1469-
'_is_one_column_mode',' _isOneColumnMode');
1469+
'_is_one_column_mode','_isOneColumnMode');
14701470
GridStack.prototype._prepare_element = obsolete(GridStack.prototype._prepareElement,
14711471
'_prepare_element', '_prepareElement');
14721472
GridStack.prototype.set_animation = obsolete(GridStack.prototype.setAnimation,

0 commit comments

Comments
 (0)