fassets_core 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/MIT-LICENSE +21 -0
  2. data/README.md +22 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/images/fassets_core/add.png +0 -0
  5. data/app/assets/images/fassets_core/archive.png +0 -0
  6. data/app/assets/images/fassets_core/classify.png +0 -0
  7. data/app/assets/images/fassets_core/clipboard.png +0 -0
  8. data/app/assets/images/fassets_core/collapse.png +0 -0
  9. data/app/assets/images/fassets_core/collapsed.png +0 -0
  10. data/app/assets/images/fassets_core/delete.png +0 -0
  11. data/app/assets/images/fassets_core/drag.png +0 -0
  12. data/app/assets/images/fassets_core/edit.png +0 -0
  13. data/app/assets/images/fassets_core/link.png +0 -0
  14. data/app/assets/images/fassets_core/markup_preview.png +0 -0
  15. data/app/assets/images/fassets_core/remove.png +0 -0
  16. data/app/assets/images/fassets_core/sort.png +0 -0
  17. data/app/assets/images/fassets_core/warning.png +0 -0
  18. data/app/assets/javascripts/fassets_core/add_asset_box.js +102 -0
  19. data/app/assets/javascripts/fassets_core/application.js.erb +14 -0
  20. data/app/assets/javascripts/fassets_core/assets.js +31 -0
  21. data/app/assets/javascripts/fassets_core/catalog_box.js +73 -0
  22. data/app/assets/javascripts/fassets_core/catalogs.js +46 -0
  23. data/app/assets/javascripts/fassets_core/classification.js +37 -0
  24. data/app/assets/javascripts/fassets_core/edit_box.js +63 -0
  25. data/app/assets/javascripts/fassets_core/facets.js.erb +32 -0
  26. data/app/assets/javascripts/fassets_core/tray.js +30 -0
  27. data/app/assets/stylesheets/fassets_core/add_asset_box.css.scss +77 -0
  28. data/app/assets/stylesheets/fassets_core/application.css +16 -0
  29. data/app/assets/stylesheets/fassets_core/assets.css.scss +74 -0
  30. data/app/assets/stylesheets/fassets_core/catalog_box.css.scss +45 -0
  31. data/app/assets/stylesheets/fassets_core/collapsible.css.scss +54 -0
  32. data/app/assets/stylesheets/fassets_core/edit_box.css.scss +58 -0
  33. data/app/assets/stylesheets/fassets_core/facet.css.scss +56 -0
  34. data/app/assets/stylesheets/fassets_core/filter.css.scss +20 -0
  35. data/app/assets/stylesheets/fassets_core/forms.css.scss +12 -0
  36. data/app/assets/stylesheets/fassets_core/labels.css.scss +13 -0
  37. data/app/assets/stylesheets/fassets_core/master.css.scss +127 -0
  38. data/app/assets/stylesheets/fassets_core/sidebar.css.scss +84 -0
  39. data/app/assets/stylesheets/fassets_core/tray.css.scss +106 -0
  40. data/app/controllers/assets_controller.rb +115 -0
  41. data/app/controllers/catalogs_controller.rb +99 -0
  42. data/app/controllers/classifications_controller.rb +56 -0
  43. data/app/controllers/facets_controller.rb +57 -0
  44. data/app/controllers/fassets_core/application_controller.rb +5 -0
  45. data/app/controllers/labels_controller.rb +54 -0
  46. data/app/controllers/tray_positions_controller.rb +81 -0
  47. data/app/helpers/assets_helper.rb +20 -0
  48. data/app/helpers/catalogs_helper.rb +3 -0
  49. data/app/helpers/classifications_helper.rb +8 -0
  50. data/app/helpers/fassets_core/application_helper.rb +48 -0
  51. data/app/helpers/labels_helper.rb +3 -0
  52. data/app/helpers/tray_positions_helper.rb +3 -0
  53. data/app/models/asset.rb +52 -0
  54. data/app/models/catalog.rb +16 -0
  55. data/app/models/classification.rb +8 -0
  56. data/app/models/facet.rb +19 -0
  57. data/app/models/label.rb +11 -0
  58. data/app/models/label_filter.rb +16 -0
  59. data/app/models/labeling.rb +5 -0
  60. data/app/models/tray_position.rb +9 -0
  61. data/app/views/assets/_add_asset_sidebar.html.haml +8 -0
  62. data/app/views/assets/_classification.html.haml +33 -0
  63. data/app/views/assets/_form.html.haml +30 -0
  64. data/app/views/assets/_put_on_tray.html.haml +7 -0
  65. data/app/views/assets/edit.html.haml +15 -0
  66. data/app/views/assets/new.html.haml +25 -0
  67. data/app/views/assets/show.html.haml +13 -0
  68. data/app/views/catalogs/_box_catalog_list.html.haml +6 -0
  69. data/app/views/catalogs/_box_content.html.haml +13 -0
  70. data/app/views/catalogs/_catalog.html.haml +2 -0
  71. data/app/views/catalogs/_facet.html.haml +13 -0
  72. data/app/views/catalogs/_filter_item.html.haml +3 -0
  73. data/app/views/catalogs/_form.html.haml +6 -0
  74. data/app/views/catalogs/box.html.haml +6 -0
  75. data/app/views/catalogs/edit.html.haml +8 -0
  76. data/app/views/catalogs/index.html.haml +17 -0
  77. data/app/views/catalogs/new.html.haml +8 -0
  78. data/app/views/catalogs/show.html.haml +30 -0
  79. data/app/views/classifications/update.js.erb +4 -0
  80. data/app/views/facets/_form.html.haml +9 -0
  81. data/app/views/facets/edit.html.haml +15 -0
  82. data/app/views/labels/_form.haml +3 -0
  83. data/app/views/labels/_sidebar.html.haml +22 -0
  84. data/app/views/labels/destroy.js.erb +13 -0
  85. data/app/views/layouts/fassets_core/application.html.haml +16 -0
  86. data/app/views/shared/_asset.html.haml +22 -0
  87. data/app/views/shared/_asset_form.html.haml +7 -0
  88. data/app/views/shared/_classification.html.haml +23 -0
  89. data/app/views/shared/_clipboard.html.haml +10 -0
  90. data/app/views/shared/_error.html.haml +6 -0
  91. data/app/views/shared/_tray.html.haml +13 -0
  92. data/app/views/shared/_tray_position.html.haml +8 -0
  93. data/app/views/tray_positions/create.js.rjs +10 -0
  94. data/app/views/tray_positions/destroy.js.rjs +1 -0
  95. data/app/views/tray_positions/sort.js.rjs +15 -0
  96. data/config/initializers/mime_types.rb +2 -0
  97. data/config/initializers/uploader.rb +2 -0
  98. data/config/initializers/users.rb +7 -0
  99. data/config/routes.rb +34 -0
  100. data/db/migrate/001_create_catalogs.rb +13 -0
  101. data/db/migrate/002_create_facets.rb +14 -0
  102. data/db/migrate/003_create_labels.rb +12 -0
  103. data/db/migrate/005_create_classifications.rb +12 -0
  104. data/db/migrate/006_create_labelings.rb +12 -0
  105. data/db/migrate/007_create_tray_positions.rb +13 -0
  106. data/db/migrate/008_create_assets.rb +16 -0
  107. data/db/migrate/010_add_label_ordering.rb +10 -0
  108. data/db/migrate/017_add_clipboard.rb +11 -0
  109. data/db/migrate/20120803150826_add_position_to_facet.rb +5 -0
  110. data/db/schema.rb +141 -0
  111. data/db/seeds.rb +7 -0
  112. data/lib/acts_as_asset.rb +36 -0
  113. data/lib/authenticated_system.rb +187 -0
  114. data/lib/authenticated_test_helper.rb +20 -0
  115. data/lib/fassets_core.rb +6 -0
  116. data/lib/fassets_core/engine.rb +7 -0
  117. data/lib/fassets_core/plugins.rb +13 -0
  118. data/lib/fassets_core/test_helper.rb +3 -0
  119. data/lib/fassets_core/test_helper/every_assets_controller.rb +161 -0
  120. data/lib/fassets_core/test_helper/every_authenticated_controller.rb +10 -0
  121. data/lib/fassets_core/version.rb +3 -0
  122. data/lib/tasks/cucumber.rake +57 -0
  123. data/lib/tasks/fassets-core_tasks.rake +4 -0
  124. data/lib/template_manager.rb +27 -0
  125. data/test/fassets-core_test.rb +7 -0
  126. data/test/fixtures/asset_contents.yml +7 -0
  127. data/test/fixtures/assets.yml +7 -0
  128. data/test/fixtures/catalogs.yml +9 -0
  129. data/test/fixtures/classifications.yml +7 -0
  130. data/test/fixtures/facets.yml +9 -0
  131. data/test/fixtures/frames.yml +11 -0
  132. data/test/fixtures/image_assets.yml +7 -0
  133. data/test/fixtures/labellings.yml +7 -0
  134. data/test/fixtures/labels.yml +9 -0
  135. data/test/fixtures/presentations.yml +7 -0
  136. data/test/fixtures/slides.yml +11 -0
  137. data/test/fixtures/slots.yml +0 -0
  138. data/test/fixtures/topics.yml +11 -0
  139. data/test/fixtures/tray_positions.yml +7 -0
  140. data/test/fixtures/users.yml +31 -0
  141. data/test/functional/assets_controller_test.rb +8 -0
  142. data/test/functional/catalogs_controller_test.rb +8 -0
  143. data/test/functional/classifications_controller_test.rb +8 -0
  144. data/test/functional/content_controller_test.rb +8 -0
  145. data/test/functional/facets_controller_test.rb +8 -0
  146. data/test/functional/file_assets_controller_test.rb +8 -0
  147. data/test/functional/files_controller_test.rb +8 -0
  148. data/test/functional/labellings_controller_test.rb +8 -0
  149. data/test/functional/labels_controller_test.rb +8 -0
  150. data/test/functional/presentations_controller_test.rb +8 -0
  151. data/test/functional/sessions_controller_test.rb +82 -0
  152. data/test/functional/slides_controller_test.rb +8 -0
  153. data/test/functional/slots_controller_test.rb +8 -0
  154. data/test/functional/tray_positions_controller_test.rb +8 -0
  155. data/test/functional/urls_controller_test.rb +8 -0
  156. data/test/functional/users_controller_test.rb +58 -0
  157. data/test/integration/navigation_test.rb +10 -0
  158. data/test/performance/browsing_test.rb +9 -0
  159. data/test/test_helper.rb +10 -0
  160. data/test/unit/asset_content_test.rb +8 -0
  161. data/test/unit/asset_test.rb +8 -0
  162. data/test/unit/catalog_test.rb +8 -0
  163. data/test/unit/classification_test.rb +8 -0
  164. data/test/unit/facet_test.rb +8 -0
  165. data/test/unit/frame_test.rb +8 -0
  166. data/test/unit/image_asset_test.rb +8 -0
  167. data/test/unit/label_test.rb +8 -0
  168. data/test/unit/labelling_test.rb +8 -0
  169. data/test/unit/presentation_test.rb +8 -0
  170. data/test/unit/slide_test.rb +8 -0
  171. data/test/unit/slot_test.rb +8 -0
  172. data/test/unit/topic_test.rb +8 -0
  173. data/test/unit/tray_position_test.rb +8 -0
  174. data/test/unit/user_test.rb +103 -0
  175. metadata +453 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2008-2009 Jan Krüger
2
+ Copyright (c) 2011 Christopher Sharp, Julian Bäume
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # FassetsCore
2
+
3
+ This project rocks and uses MIT-LICENSE.
4
+
5
+ # Install
6
+
7
+ To use this plugin in your rails project, you need to add the gem to your applications `Gemfile`:
8
+
9
+ ```
10
+ # for now the git version of fassets core should be used, since it’s under heavy development
11
+ gem 'fassets_core', :git => "git://github.com/fassets/fassets_core.git"
12
+ ```
13
+
14
+ After that, run the `bundle` command to install all new dependencies.
15
+
16
+ Then you need to install and run the migrations:
17
+
18
+ ```
19
+ bundle exec rake fassets_core_engine:install:migrations
20
+ bundle exec rake db:migrate
21
+ ```
22
+
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'FassetsCore'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
29
+ require 'rake/testtask'
30
+
31
+ Rake::TestTask.new(:test) do |t|
32
+ t.libs << 'lib'
33
+ t.libs << 'test'
34
+ t.pattern = 'test/**/*_test.rb'
35
+ t.verbose = false
36
+ end
37
+
38
+
39
+ task :default => :test
@@ -0,0 +1,102 @@
1
+ //$(document).ajaxSend(function(event, request, settings) {
2
+ // if (typeof(AUTH_TOKEN) == "undefined") return;
3
+ // // settings.data is a serialized string like "foo=bar&baz=boink" (or null)
4
+ // settings.data = settings.data || "";
5
+ // settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
6
+ //});
7
+
8
+
9
+ $(document).ready(function(){
10
+ var show_asset_box = function() {
11
+ $.fancybox.showActivity();
12
+ var f_width = $(window).width()*0.8;
13
+ var f_height = $(window).height()*0.8;
14
+ $("#add_asset_content").css("left",$("#catalog_list").width()+10);
15
+ $("#add_asset_content").css("width",$("#fancybox-content").width()-$("#catalog_list").width()-30-$("#facets").width());
16
+ $.ajaxSetup({cache: false});
17
+ $.get('/assets/new', { content_only: true }, function(data) {
18
+ $.fancybox({
19
+ content: data,
20
+ padding: 0,
21
+ autoDimensions: false,
22
+ width: f_width,
23
+ height: f_height,
24
+ onComplete: function(){
25
+ $("#fancybox-content").data("box-type","add_asset");
26
+ adjust_links();
27
+ $.fancybox.resize();
28
+ }
29
+ });
30
+ });
31
+ };
32
+ $(window).keydown(function(event){
33
+ switch(event.keyCode) {
34
+ case 65: // a
35
+ activeObj = document.activeElement;
36
+ if (activeObj.type == "textarea") break;
37
+ if (activeObj.type == "text") break;
38
+ if ($(activeObj).attr("class") != undefined && $(activeObj).attr("class").indexOf("slot") != -1) break;
39
+ if ($("#fancybox-wrap").is(":visible")) {
40
+ $.fancybox.close();
41
+ } else {
42
+ show_asset_box();
43
+ }
44
+ break;
45
+ }
46
+ });
47
+ var adjust_links = function(){
48
+ $("#fancybox-content li.asset_type").click(function(event){
49
+ event.preventDefault();
50
+ $.fancybox.showActivity();
51
+ asset_type = $(event.target).data("asset-type");
52
+ $("#fancybox-content").load("/assets/new", {type: asset_type, content_only: true }, function() {
53
+ adjust_links();
54
+ });
55
+ $.fancybox.resize();
56
+ $.fancybox.hideActivity();
57
+ });
58
+ $("#fancybox-content .asset_create_button").click(function(event){
59
+ event.preventDefault();
60
+ $.fancybox.showActivity();
61
+ var action = $("#add_asset_content form").attr("action");
62
+ $.post(action, $("#add_asset_content form").serialize(), function(data){
63
+ $("#fancybox-content #add_asset_content").load(data[0].edit_box_url+"?type="+data[0].content_type);
64
+ });
65
+ reload_tray();
66
+ $.fancybox.resize();;
67
+ $.fancybox.hideActivity();
68
+ });
69
+ $("#fancybox-content .asset_submit_button").click(function(event){
70
+ event.preventDefault();
71
+ $.fancybox.showActivity();
72
+ //var token = encodeURIComponent(AUTH_TOKEN)
73
+ var asset_type = $(event.target).data("asset-type");
74
+ reload_tray();
75
+ $.fancybox.hideActivity();
76
+ });
77
+ $("form.edit_classification input[type=submit][value=Save]").hide();
78
+ };
79
+
80
+ $("#new_asset_link").click(function(event){
81
+ event.preventDefault();
82
+ show_asset_box();
83
+ });
84
+ var reload_tray = function() {
85
+ var user_id = $("#tray").data("user-id");
86
+ $("#tray").load("/users/"+user_id+"/tray_positions/", function() {
87
+ $('#tray .drop_button').click(function(event){
88
+ event.preventDefault();
89
+ var user_id = $(event.target).data("user-id");
90
+ var tp_id = $(event.target).data("tp-id");
91
+ $.ajax({
92
+ type: 'DELETE',
93
+ cache : false,
94
+ url : "/users/"+user_id+"/tray_positions/"+tp_id,
95
+ success: function(data) {
96
+ $("#tray").load("/users/"+user_id+"/tray_positions/");
97
+ }
98
+ });
99
+ });
100
+ });
101
+ };
102
+ });
@@ -0,0 +1,14 @@
1
+ // Place your application-specific JavaScript functions and classes here
2
+ //
3
+ //= require jquery
4
+ //= require jquery_ujs
5
+ //= require jquery-ui
6
+ //= require jquery.iframe-transport
7
+ //= require jquery.collapsiblePanel-0.2.0
8
+ //= require fancybox
9
+ //= require_tree .
10
+ //= require_self
11
+
12
+ $.ajaxSetup({ 'beforeSend': function(xhr) {
13
+ xhr.setRequestHeader("Accept", "text/javascript,text/html");
14
+ }});
@@ -0,0 +1,31 @@
1
+ $(document).ready(function(){
2
+ $(".asset").live("mouseenter",function(event){
3
+ $(this).find(".asset_actions").fadeIn(150);
4
+ });
5
+ $(".asset").live("mouseleave",function(event){
6
+ $(this).find(".asset_actions").fadeOut(100);
7
+ });
8
+ $(".put_on_tray_button").live("click", function(event){
9
+ event.preventDefault();
10
+ var user_id = $(event.target).data("user-id");
11
+ var asset_id = $(event.target).data("asset-id");
12
+ data = {tray_position: {asset_id: asset_id, user_id: user_id}};
13
+ $.post("/users/"+user_id+"/tray_positions",data, function(){
14
+ $("#tray").load("/users/"+user_id+"/tray_positions/", function() {
15
+ $('#tray .drop_button').click(function(event){
16
+ event.preventDefault();
17
+ var user_id = $(event.target).data("user-id");
18
+ var tp_id = $(event.target).data("tp-id");
19
+ $.ajax({
20
+ type: 'DELETE',
21
+ cache : false,
22
+ url : "/users/"+user_id+"/tray_positions/"+tp_id,
23
+ success: function(data) {
24
+ $("#tray").load("/users/"+user_id+"/tray_positions/");
25
+ }
26
+ });
27
+ });
28
+ });
29
+ });
30
+ });
31
+ });
@@ -0,0 +1,73 @@
1
+ $(document).ready(function(){
2
+ var show_catalog = function() {
3
+ $.fancybox.showActivity();
4
+ var f_width = $(window).width()*0.8;
5
+ var f_height = $(window).height()*0.8;
6
+ $("#box_content").css("left",$("#catalog_list").width()+10);
7
+ $("#box_content").css("width",$("#fancybox-content").width()-$("#catalog_list").width()-30-$("#facets").width());
8
+ $.ajax({
9
+ type : "GET",
10
+ cache : false,
11
+ url : "/catalog_box",
12
+ success: function(data) {
13
+ $.fancybox({
14
+ content: data,
15
+ padding: 0,
16
+ autoDimensions: false,
17
+ width: f_width,
18
+ height: f_height,
19
+ onComplete: function(){$("#fancybox-content").attr("box_type","catalog");}
20
+ });
21
+ $("#box_content").css("left",$("#catalog_list").width()+10);
22
+ $("#box_content").css("width",$("#fancybox-content").width()-$("#catalog_list").width()-30-$("#fancybox-content #sidebar").width());
23
+ fancybox_links();
24
+ $.fancybox.resize();
25
+ }
26
+ });
27
+ };
28
+ $(window).keydown(function(event){
29
+ switch(event.keyCode) {
30
+ case 67: // c
31
+ activeObj = document.activeElement;
32
+ if (activeObj.type == "textarea") break;
33
+ if (activeObj.type == "text") break;
34
+ if ($(activeObj).attr("class") != undefined && $(activeObj).attr("class").indexOf("slot") != -1) break;
35
+ if ($("#fancybox-wrap").is(":visible")) {
36
+ $.fancybox.close();
37
+ } else {
38
+ show_catalog();
39
+ }
40
+ break;
41
+ }
42
+ });
43
+ var fancybox_links = function(){
44
+ $("#fancybox-content li.label, .clear_filter, .facet_drop_link").click(function(event){
45
+ event.preventDefault();
46
+ $.fancybox.showActivity();
47
+ var catalog = $("#fancybox-content #selected").attr("catalog_id");
48
+ var filter = event.target.href.split("?")[1];
49
+ $("#fancybox-content #facets").load("/box_facet?id="+catalog+"&"+filter);
50
+ $("#fancybox-content #box_content").load("/box_content?id="+catalog+"&"+filter, function(){
51
+ $("#box_content").css("width",$("#fancybox-content").width()-$("#catalog_list").width()-30-$("#fancybox-content #sidebar").width());
52
+ });
53
+ $.fancybox.resize();
54
+ $.fancybox.hideActivity();
55
+ });
56
+ $("#fancybox-content .catalog_list_item").click(function(event){
57
+ event.preventDefault();
58
+ $.fancybox.showActivity();
59
+ var catalog = event.target.href.split("=")[1];
60
+ $("#fancybox-content").load("/catalog_box?id="+catalog, function(){
61
+ $("#box_content").css("width",$("#fancybox-content").width()-$("#catalog_list").width()-30-$("#fancybox-content #sidebar").width());
62
+ });
63
+ $.fancybox.resize();;
64
+ $.fancybox.hideActivity();
65
+ });
66
+ };
67
+ $(document).ajaxStop(function() {
68
+ if($("#fancybox-content").attr("box_type") == "catalog"){
69
+ fancybox_links();
70
+ $.fancybox.resize();
71
+ }
72
+ });
73
+ });
@@ -0,0 +1,46 @@
1
+ $(function(){
2
+ $( "#facets" ).sortable({
3
+ axis: "y",
4
+ handle: ".handle",
5
+ update: function (e, ui){
6
+ $.post($(this).data('update-url'), $(this).sortable('serialize')+"&catalog_id="+$(this).data('catalog_id'))
7
+ }
8
+ });
9
+
10
+ $("#assets li.asset").draggable({
11
+ handle: ".handle",
12
+ helper: "clone",
13
+ connectToSortable: "#tray ol",
14
+ start:function(e, ui) {
15
+ $('#tray ol').addClass("active");
16
+ },
17
+ stop:function(e, ui) {
18
+ $('#tray ol').removeClass("active");
19
+ }
20
+ });
21
+
22
+ $("#catalog_main").droppable({
23
+ accept:'.asset',
24
+ activeClass:'active',
25
+ hoverClass:'hover',
26
+ drop:function(ev,ui){
27
+ var id;
28
+ var asset = $(ui.draggable).clone();
29
+ if ($(ui.draggable).is("[id^='tp']")) {
30
+ id = $(ui.draggable).attr("rel");
31
+ asset.find("input").remove();
32
+ asset.attr("id", "asset_" + id);
33
+ } else {
34
+ id = $(ui.draggable).attr("asset_id");
35
+ }
36
+ $.ajax({
37
+ type: 'put',
38
+ url: window.location.href + "/add_asset",
39
+ data: "&asset_id="+id,
40
+ success: function(){
41
+ window.location.reload();
42
+ }
43
+ });
44
+ }
45
+ });
46
+ });
@@ -0,0 +1,37 @@
1
+ $(document).ready(function(){
2
+ $("#sidebar .classification_create").live("click",function(event){
3
+ event.preventDefault();
4
+ $.fancybox.showActivity();
5
+ var catalog_id = $("#fancybox-content #classification_catalog_id :selected").val();
6
+ var asset_id = $("#fancybox-content #classification_asset_id").val();
7
+ $.ajax({
8
+ type : "POST",
9
+ cache : false,
10
+ url : "/classifications?asset_id="+asset_id+"&catalog_id="+catalog_id,
11
+ success: function(data) {
12
+ $("#fancybox-content #sidebar").load("/asset/"+asset_id+"/classifications");
13
+ }
14
+ });
15
+ $.fancybox.resize();;
16
+ $.fancybox.hideActivity();
17
+ });
18
+ $("#sidebar .classification_drop").live("click",function(event){
19
+ event.preventDefault();
20
+ if (confirm("Are you sure?") == false){
21
+ return;
22
+ };
23
+ $.fancybox.showActivity();
24
+ var classification_id = $(event.target).attr("classification_id");
25
+ var asset_id = $("#fancybox-content #classification_asset_id").val();
26
+ $.ajax({
27
+ type : "DELETE",
28
+ cache : false,
29
+ url : "/classifications/"+classification_id,
30
+ success: function(data) {
31
+ $("#fancybox-content #sidebar").load("/asset/"+asset_id+"/classifications");
32
+ }
33
+ });
34
+ $.fancybox.resize();
35
+ $.fancybox.hideActivity();
36
+ });
37
+ });
@@ -0,0 +1,63 @@
1
+ $(document).ready(function(){
2
+ var show_edit_box = function(event) {
3
+ var asset_id = $(event.target).data("asset-id");
4
+ $.fancybox.showActivity();
5
+ var f_width = $(window).width()*0.8;
6
+ var f_height = $(window).height()*0.8;
7
+ $.ajax({
8
+ type : "GET",
9
+ cache : false,
10
+ url : "/asset/"+asset_id+"/edit",
11
+ success: function(data) {
12
+ $.fancybox({
13
+ content: data,
14
+ padding: 0,
15
+ autoDimensions: false,
16
+ width: f_width,
17
+ height: f_height,
18
+ onComplete: function(){$("#fancybox-content").data("box-type","edit_asset");}
19
+ });
20
+ adjust_links();
21
+ $.fancybox.resize();
22
+ }
23
+ });
24
+ };
25
+ $("body .edit_button").live("click",function(event){
26
+ event.preventDefault();
27
+ show_edit_box(event);
28
+ });
29
+ var adjust_links = function(){
30
+ $("#fancybox-content li.asset_type").click(function(event){
31
+ event.preventDefault();
32
+ $.fancybox.showActivity();
33
+ var type = event.target.href.split("=")[1];
34
+ $("#fancybox-content").load("/add_asset_box?type="+type);
35
+ $.fancybox.resize();
36
+ $.fancybox.hideActivity();
37
+ });
38
+ $("form.edit_classification input[type=submit][value=Save]").hide();
39
+ };
40
+ $(document).ajaxStop(function() {
41
+ if($("#fancybox-content").data("box-type") == "edit_asset"){
42
+ adjust_links();
43
+ }
44
+ });
45
+ var reload_tray = function() {
46
+ var user_id = $("#tray").data("user-id");
47
+ $("#tray").load("/users/"+user_id+"/tray_positions/", function() {
48
+ $('#tray .drop_button').click(function(event){
49
+ event.preventDefault();
50
+ var user_id = $(event.target).data("user-id");
51
+ var tp_id = $(event.target).data("tp-id");
52
+ $.ajax({
53
+ type: 'DELETE',
54
+ cache : false,
55
+ url : "/users/"+user_id+"/tray_positions/"+tp_id,
56
+ success: function(data) {
57
+ $("#tray").load("/users/"+user_id+"/tray_positions/");
58
+ }
59
+ });
60
+ });
61
+ });
62
+ };
63
+ });