Skip to content

Commit b0435ba

Browse files
author
Alain Dumesny
committed
added obsoleteAttr() check
1 parent 0fc6185 commit b0435ba

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/gridstack.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
factory(window.jQuery, window);
1919
}
2020
})(function($, scope) {
21+
22+
// checks for obsolete method names
2123
var obsolete = function(f, oldName, newName) {
2224
var wrapper = function() {
2325
console.warn('gridstack.js: Function `' + oldName + '` is deprecated as of v0.2.5 and has been replaced ' +
@@ -29,14 +31,25 @@
2931
return wrapper;
3032
};
3133

32-
var obsoleteOpts = function(opts, oldName, newName) {
34+
// checks for obsolete grid options 9can be used for any fields, but msg is about options)
35+
var obsoleteOpts = function(opts, oldName, newName) {
3336
if (opts[oldName] !== undefined) {
3437
opts[newName] = opts[oldName];
3538
console.warn('gridstack.js: Option `' + oldName + '` is deprecated as of v0.2.5 and has been replaced with `' +
3639
newName + '`. It will be **completely** removed in v1.0.');
3740
}
3841
};
3942

43+
// checks for obsolete Jquery element attributes
44+
var obsoleteAttr = function(el, oldName, newName) {
45+
var oldAttr = el.attr(oldName);
46+
if (oldAttr !== undefined) {
47+
el.attr(newName, oldAttr);
48+
console.warn('gridstack.js: attribute `' + oldName + '`=' + oldAttr + ' is deprecated on this object as of v0.5.2 and has been replaced with `' +
49+
newName + '`. It will be **completely** removed in v1.0.');
50+
}
51+
};
52+
4053
var Utils = {
4154

4255
isIntercepted: function(a, b) {
@@ -675,6 +688,10 @@
675688
obsoleteOpts(opts, 'always_show_resize_handle', 'alwaysShowResizeHandle');
676689
obsoleteOpts(opts, 'width', 'columns');
677690
obsoleteOpts(opts, 'height', 'maxRows');
691+
692+
// container attributes
693+
obsoleteAttr(this.container, 'data-gs-width', 'data-gs-columns');
694+
obsoleteAttr(this.container, 'data-gs-height', 'data-gs-max-rows');
678695
/*eslint-enable camelcase */
679696

680697
opts.itemClass = opts.itemClass || 'grid-stack-item';

0 commit comments

Comments
 (0)