From 1527485f75ebe885fd7b65961db37820bf278a8e Mon Sep 17 00:00:00 2001 From: Pavel Reznikov Date: Wed, 17 Feb 2016 18:48:03 -0800 Subject: [PATCH] update demo --- demo/float.html | 7 ++++--- demo/knockout.html | 14 ++++++++------ demo/knockout2.html | 14 ++++++++------ demo/serialization.html | 31 +++++++++++++++++-------------- demo/two.html | 2 +- 5 files changed, 38 insertions(+), 30 deletions(-) diff --git a/demo/float.html b/demo/float.html index 638ec2a..fe5bc7c 100644 --- a/demo/float.html +++ b/demo/float.html @@ -68,18 +68,19 @@ this.grid = $('.grid-stack').data('gridstack'); - this.add_new_widget = function () { + this.addNewWidget = function () { var node = this.items.pop() || { x: 12 * Math.random(), y: 5 * Math.random(), width: 1 + 3 * Math.random(), height: 1 + 3 * Math.random() }; - this.grid.add_widget($('
'), + this.grid.addWidget($('
'), node.x, node.y, node.width, node.height); + return false; }.bind(this); - $('#add-new-widget').click(this.add_new_widget); + $('#add-new-widget').click(this.addNewWidget); }; }); diff --git a/demo/knockout.html b/demo/knockout.html index 2a7a360..dd16b3e 100644 --- a/demo/knockout.html +++ b/demo/knockout.html @@ -38,7 +38,7 @@

knockout.js Demo

- +

@@ -64,9 +64,9 @@ } var item = _.find(items, function (i) { return i.nodeType == 1 }); - grid.add_widget(item); + grid.addWidget(item); ko.utils.domNodeDisposal.addDisposeCallback(item, function () { - grid.remove_widget(item); + grid.removeWidget(item); }); }; }; @@ -78,7 +78,7 @@ [ '
', '
', - '
', + '
', '
', '
' ].join('') @@ -90,7 +90,7 @@ this.widgets = ko.observableArray(widgets); - this.add_new_widget = function () { + this.addNewWidget = function () { this.widgets.push({ x: 0, y: 0, @@ -98,10 +98,12 @@ height: Math.floor(1 + 3 * Math.random()), auto_position: true }); + return false; }; - this.delete_widget = function (item) { + this.deleteWidget = function (item) { self.widgets.remove(item); + return false; }; }; diff --git a/demo/knockout2.html b/demo/knockout2.html index af558ec..96d2819 100644 --- a/demo/knockout2.html +++ b/demo/knockout2.html @@ -38,7 +38,7 @@

knockout.js Demo

- +

@@ -64,9 +64,9 @@ } var item = _.find(items, function (i) { return i.nodeType == 1 }); - grid.add_widget(item); + grid.addWidget(item); ko.utils.domNodeDisposal.addDisposeCallback(item, function () { - grid.remove_widget(item); + grid.removeWidget(item); }); }; }; @@ -83,7 +83,7 @@ this.widgets = ko.observableArray(widgets); - this.add_new_widget = function () { + this.addNewWidget = function () { this.widgets.push({ x: 0, y: 0, @@ -91,10 +91,12 @@ height: Math.floor(1 + 3 * Math.random()), auto_position: true }); + return false; }; - this.delete_widget = function (item) { + this.deleteWidget = function (item) { self.widgets.remove(item); + return false; }; }; @@ -113,7 +115,7 @@ diff --git a/demo/serialization.html b/demo/serialization.html index aca9d32..b8484ea 100644 --- a/demo/serialization.html +++ b/demo/serialization.html @@ -60,7 +60,7 @@ $('.grid-stack').gridstack(options); new function () { - this.serialized_data = [ + this.serializedData = [ {x: 0, y: 0, width: 2, height: 2}, {x: 3, y: 1, width: 1, height: 2}, {x: 4, y: 1, width: 1, height: 1}, @@ -73,17 +73,18 @@ this.grid = $('.grid-stack').data('gridstack'); - this.load_grid = function () { - this.grid.remove_all(); - var items = GridStackUI.Utils.sort(this.serialized_data); + this.loadGrid = function () { + this.grid.removeAll(); + var items = GridStackUI.Utils.sort(this.serializedData); _.each(items, function (node) { - this.grid.add_widget($('
'), + this.grid.addWidget($('
'), node.x, node.y, node.width, node.height); }, this); + return false; }.bind(this); - this.save_grid = function () { - this.serialized_data = _.map($('.grid-stack > .grid-stack-item:visible'), function (el) { + this.saveGrid = function () { + this.serializedData = _.map($('.grid-stack > .grid-stack-item:visible'), function (el) { el = $(el); var node = el.data('_gridstack_node'); return { @@ -93,18 +94,20 @@ height: node.height }; }, this); - $('#saved-data').val(JSON.stringify(this.serialized_data, null, ' ')); + $('#saved-data').val(JSON.stringify(this.serializedData, null, ' ')); + return false; }.bind(this); - this.clear_grid = function () { - this.grid.remove_all(); + this.clearGrid = function () { + this.grid.removeAll(); + return false; }.bind(this); - $('#save-grid').click(this.save_grid); - $('#load-grid').click(this.load_grid); - $('#clear-grid').click(this.clear_grid); + $('#save-grid').click(this.saveGrid); + $('#load-grid').click(this.loadGrid); + $('#clear-grid').click(this.clearGrid); - this.load_grid(); + this.loadGrid(); }; }); diff --git a/demo/two.html b/demo/two.html index a9f64f7..7219455 100644 --- a/demo/two.html +++ b/demo/two.html @@ -75,7 +75,7 @@ var grid = $(this).data('gridstack'); _.each(items, function (node) { - grid.add_widget($('
'), + grid.addWidget($('
'), node.x, node.y, node.width, node.height); }, this); });