diff options
| author | hukl <contact@smyck.org> | 2009-09-01 23:13:45 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-09-01 23:13:45 +0200 |
| commit | cae5b4accca2f880bbd4a5ffae265f78c689075c (patch) | |
| tree | 1688c0e655559999b4963846a80ba34b95b79c7f /public/javascripts/admin_interface.js | |
| parent | 656af6c97987e103c30946ec944cac433252fe75 (diff) | |
Added javascript goodness to add and sort and drag and drop images on pages
Diffstat (limited to 'public/javascripts/admin_interface.js')
| -rw-r--r-- | public/javascripts/admin_interface.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index ce971a4..977e42a 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js | |||
| @@ -4,6 +4,7 @@ $(document).ready(function () { | |||
| 4 | meta_data.initialize(); | 4 | meta_data.initialize(); |
| 5 | menu_item_sorter.initialize(); | 5 | menu_item_sorter.initialize(); |
| 6 | 6 | ||
| 7 | |||
| 7 | jQuery.ajaxSetup({ | 8 | jQuery.ajaxSetup({ |
| 8 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} | 9 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} |
| 9 | }) | 10 | }) |
| @@ -27,6 +28,7 @@ meta_data = { | |||
| 27 | 28 | ||
| 28 | if ($("#button").attr("class") == "unselected") { | 29 | if ($("#button").attr("class") == "unselected") { |
| 29 | $("#button").attr("class", "selected"); | 30 | $("#button").attr("class", "selected"); |
| 31 | image_interface.initialize(); | ||
| 30 | } | 32 | } |
| 31 | else { | 33 | else { |
| 32 | $("#button").attr("class", "unselected"); | 34 | $("#button").attr("class", "unselected"); |
| @@ -110,5 +112,39 @@ menu_item_sorter = { | |||
| 110 | $(".ui-state-highlight").html("<td colspan='100%'></td>"); | 112 | $(".ui-state-highlight").html("<td colspan='100%'></td>"); |
| 111 | } | 113 | } |
| 112 | } | 114 | } |
| 115 | |||
| 116 | image_interface = { | ||
| 117 | initialize : function() { | ||
| 118 | $("ul#image_box").sortable({ | ||
| 119 | revert : true, | ||
| 120 | stop : function(event, ui) { | ||
| 121 | $.ajax({ | ||
| 122 | type : "POST", | ||
| 123 | url : "/pages/" + $("ul#image_box").attr("rel") + "/sort_images", | ||
| 124 | dataType : "json", | ||
| 125 | data : $("ul#image_box").sortable("serialize", {attribute : "rel"}) + "&_method=put", | ||
| 126 | success : function() {} | ||
| 127 | }); | ||
| 128 | } | ||
| 129 | }); | ||
| 130 | |||
| 131 | $("ul#image_box").droppable({ | ||
| 132 | out : function(event, ui) { | ||
| 133 | $(ui.draggable).bind("mouseup", function() {$(this).remove()}) | ||
| 134 | } | ||
| 135 | }); | ||
| 136 | |||
| 137 | $("div#asset_toolbox ul li").draggable({ | ||
| 138 | connectToSortable : 'ul#image_box', | ||
| 139 | helper : 'clone', | ||
| 140 | revert : 'invalid', | ||
| 141 | stop : function() { | ||
| 142 | |||
| 143 | } | ||
| 144 | }); | ||
| 145 | |||
| 146 | $("ul, li").disableSelection(); | ||
| 147 | } | ||
| 148 | } | ||
| 113 | 149 | ||
| 114 | 150 | ||
