diff --git a/demo/column.html b/demo/column.html index f0f543d07..0fe00de9a 100644 --- a/demo/column.html +++ b/demo/column.html @@ -11,6 +11,7 @@ + @@ -36,9 +37,9 @@

setColumn() grid demo

$grid.gridstack({float: true}); grid = $grid.data('gridstack'); - $grid.on('added', (e, items) => log(' added ', items)); - $grid.on('removed', (e, items) => log(' removed ', items)); - $grid.on('change', (e, items) => log(' change ', items)); + $grid.on('added', function(e, items) {log(' added ', items)}); + $grid.on('removed', function(e, items) {log(' removed ', items)}); + $grid.on('change', function(e, items) {log(' change ', items)}); function log(type, items) { if (!items) { return; } var str = ''; @@ -63,7 +64,7 @@

setColumn() grid demo

}; grid.commit(); - $('#add-widget').click(() => { + $('#add-widget').click(function() { var node = items.pop() || { x: Math.round(12 * Math.random()), y: Math.round(5 * Math.random()), @@ -73,15 +74,15 @@

setColumn() grid demo

grid.addWidget($('
' + count++ + '
'), node); }); - $('#1column').click(() => { grid.setColumn(1); }); - $('#2column').click(() => { grid.setColumn(2); }); - $('#3column').click(() => { grid.setColumn(3); }); - $('#4column').click(() => { grid.setColumn(4); }); - $('#6column').click(() => { grid.setColumn(6); }); - $('#6column').click(() => { grid.setColumn(6); }); - $('#8column').click(() => { grid.setColumn(8); }); - $('#10column').click(() => { grid.setColumn(10); }); - $('#12column').click(() => { grid.setColumn(12); }); + $('#1column').click(function() { grid.setColumn(1); }); + $('#2column').click(function() { grid.setColumn(2); }); + $('#3column').click(function() { grid.setColumn(3); }); + $('#4column').click(function() { grid.setColumn(4); }); + $('#6column').click(function() { grid.setColumn(6); }); + $('#6column').click(function() { grid.setColumn(6); }); + $('#8column').click(function() { grid.setColumn(8); }); + $('#10column').click(function() { grid.setColumn(10); }); + $('#12column').click(function() { grid.setColumn(12); }); }); diff --git a/src/gridstack-poly.js b/src/gridstack-poly.js index 51d680450..9cda393e8 100644 --- a/src/gridstack-poly.js +++ b/src/gridstack-poly.js @@ -10,7 +10,7 @@ Number.isNaN = Number.isNaN || function isNaN(input) { return typeof input === 'number' && input !== input; } -// https://tc39.github.io/ecma262/#sec-array.prototype.find +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find if (!Array.prototype.find) { Object.defineProperty(Array.prototype, 'find', { value: function (predicate) { @@ -55,4 +55,51 @@ if (!Array.prototype.find) { configurable: true, writable: true }); +} + +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex +if (!Array.prototype.findIndex) { + Object.defineProperty(Array.prototype, 'findIndex', { + value: function(predicate) { + // 1. Let O be ? ToObject(this value). + if (this == null) { + throw new TypeError('"this" is null or not defined'); + } + + var o = Object(this); + + // 2. Let len be ? ToLength(? Get(O, "length")). + var len = o.length >>> 0; + + // 3. If IsCallable(predicate) is false, throw a TypeError exception. + if (typeof predicate !== 'function') { + throw new TypeError('predicate must be a function'); + } + + // 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + var thisArg = arguments[1]; + + // 5. Let k be 0. + var k = 0; + + // 6. Repeat, while k < len + while (k < len) { + // a. Let Pk be ! ToString(k). + // b. Let kValue be ? Get(O, Pk). + // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + // d. If testResult is true, return k. + var kValue = o[k]; + if (predicate.call(thisArg, kValue, k, o)) { + return k; + } + // e. Increase k by 1. + k++; + } + + // 7. Return -1. + return -1; + }, + configurable: true, + writable: true + }); } \ No newline at end of file diff --git a/src/jquery-ui.js b/src/jquery-ui.js index 911c02292..d6e1192f6 100644 --- a/src/jquery-ui.js +++ b/src/jquery-ui.js @@ -399,7 +399,7 @@ $.Widget.prototype = { if ( typeof key === "string" ) { - // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } + // Handle nested keys, e.g., "foo.bar" = { foo: { bar: ___ } } options = {}; parts = key.split( "." ); key = parts.shift();