summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/project/assets/javascripts/application.coffee1
-rw-r--r--templates/project/assets/javascripts/dashing.gridster.coffee13
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()