diff options
author | Ryan Seys <rsmseys@gmail.com> | 2012-10-30 18:59:58 -0400 |
---|---|---|
committer | Daniel Beauchamp <daniel.beauchamp@shopify.com> | 2012-11-05 22:38:22 -0500 |
commit | 77d859b096362a71306125d590156921e4f0a10d (patch) | |
tree | dd5795a12847f64d10ed7ff309d26fad7e6a20b4 /templates/project/assets/javascripts | |
parent | d87442ef06436dfef4c1cdb685c4d6bc9366e272 (diff) |
Save layout only suggested when layout changes. Closes #3
Diffstat (limited to 'templates/project/assets/javascripts')
-rw-r--r-- | templates/project/assets/javascripts/application.coffee | 1 | ||||
-rw-r--r-- | templates/project/assets/javascripts/dashing.gridster.coffee | 13 |
2 files changed, 10 insertions, 4 deletions
diff --git a/templates/project/assets/javascripts/application.coffee b/templates/project/assets/javascripts/application.coffee index be030e1..a1cbf3f 100644 --- a/templates/project/assets/javascripts/application.coffee +++ b/templates/project/assets/javascripts/application.coffee @@ -22,3 +22,4 @@ Dashing.on 'ready', -> avoid_overlapped_widgets: !Dashing.customGridsterLayout draggable: stop: Dashing.showGridsterInstructions + start: -> Dashing.currentWidgetPositions = Dashing.getWidgetPositions() diff --git a/templates/project/assets/javascripts/dashing.gridster.coffee b/templates/project/assets/javascripts/dashing.gridster.coffee index 0f6f9a1..e25c561 100644 --- a/templates/project/assets/javascripts/dashing.gridster.coffee +++ b/templates/project/assets/javascripts/dashing.gridster.coffee @@ -13,20 +13,25 @@ Dashing.gridsterLayout = (positions) -> $(widget).attr('data-row', positions[index].row) $(widget).attr('data-col', positions[index].col) +Dashing.getWidgetPositions = -> + $(".gridster ul:first").gridster().data('gridster').serialize() + Dashing.showGridsterInstructions = -> - data = $(".gridster ul:first").gridster().data('gridster').serialize() + newWidgetPositions = Dashing.getWidgetPositions() + + unless JSON.stringify(newWidgetPositions) == JSON.stringify(Dashing.currentWidgetPositions) + Dashing.currentWidgetPositions = newWidgetPositions $('#save-gridster').slideDown() $('#gridster-code').text(" <script type='text/javascript'>\n $(function() {\n - \ \ Dashing.gridsterLayout('#{JSON.stringify(data)}')\n + \ \ Dashing.gridsterLayout('#{JSON.stringify(Dashing.currentWidgetPositions)}')\n });\n </script> ") - $ -> $('#save-gridster').leanModal() $('#save-gridster').click -> - $('#save-gridster').slideUp()
\ No newline at end of file + $('#save-gridster').slideUp() |