the_sortable_tree 1.9.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/MIT-LICENSE +4 -2
  2. data/README.md +237 -438
  3. data/app/assets/images/iconza/{gray → icons}/add.png +0 -0
  4. data/app/assets/images/iconza/{gray → icons}/delete.png +0 -0
  5. data/app/assets/images/iconza/{gray → icons}/edit.png +0 -0
  6. data/app/assets/images/iconza/icons/move.png +0 -0
  7. data/app/assets/images/iconza/{red/add.png → icons/red_add.png} +0 -0
  8. data/app/assets/images/iconza/{red/delete.png → icons/red_delete.png} +0 -0
  9. data/app/assets/images/iconza/{red/edit.png → icons/red_edit.png} +0 -0
  10. data/app/assets/images/iconza/icons/red_move.png +0 -0
  11. data/app/assets/javascripts/render_tree_helper.js.coffee +82 -0
  12. data/app/assets/javascripts/sortable_tree/initializer.js.coffee +54 -0
  13. data/app/assets/stylesheets/sortable_tree.css.scss +106 -0
  14. data/app/assets/stylesheets/tree.css.scss +26 -29
  15. data/app/controllers/the_sortable_tree_controller.rb +3 -2
  16. data/app/helpers/render_sortable_tree_helper.rb +62 -0
  17. data/app/helpers/render_tree_helper.rb +45 -0
  18. data/app/helpers/the_sortable_tree_helper.rb +67 -52
  19. data/app/views/sortable/client/_tree.html.erb +9 -0
  20. data/app/views/tree/client/_tree.html.erb +23 -0
  21. data/lib/fake.example +44 -0
  22. data/lib/generators/the_sortable_tree/views_generator.rb +29 -18
  23. data/lib/the_sortable_tree.rb +4 -8
  24. data/lib/the_sortable_tree/engine.rb +1 -1
  25. data/lib/the_sortable_tree/version.rb +1 -1
  26. metadata +31 -60
  27. data/app/assets/images/iconza/blue/add.png +0 -0
  28. data/app/assets/images/iconza/blue/delete.png +0 -0
  29. data/app/assets/images/iconza/blue/down.png +0 -0
  30. data/app/assets/images/iconza/blue/downloads_folder.png +0 -0
  31. data/app/assets/images/iconza/blue/edit.png +0 -0
  32. data/app/assets/images/iconza/blue/move.png +0 -0
  33. data/app/assets/images/iconza/blue/up.png +0 -0
  34. data/app/assets/images/iconza/gray/down.png +0 -0
  35. data/app/assets/images/iconza/gray/lock.png +0 -0
  36. data/app/assets/images/iconza/gray/mail.png +0 -0
  37. data/app/assets/images/iconza/gray/push_pin.png +0 -0
  38. data/app/assets/images/iconza/gray/up.png +0 -0
  39. data/app/assets/images/iconza/red/down.png +0 -0
  40. data/app/assets/images/iconza/red/newspaper.png +0 -0
  41. data/app/assets/images/iconza/red/trash.png +0 -0
  42. data/app/assets/images/iconza/red/up.png +0 -0
  43. data/app/assets/images/iconza/red/zoom.png +0 -0
  44. data/app/assets/javascripts/comments/base.js.coffee +0 -46
  45. data/app/assets/javascripts/sortable/base.js.coffee +0 -47
  46. data/app/assets/stylesheets/comments_tree.css.scss +0 -84
  47. data/app/assets/stylesheets/sortable.css.scss +0 -106
  48. data/app/views/comments/base/_children.html.haml +0 -1
  49. data/app/views/comments/base/_comment.html.haml +0 -8
  50. data/app/views/comments/base/_new_comment_form.html.haml +0 -18
  51. data/app/views/comments/base/_node.html.haml +0 -3
  52. data/app/views/comments/base/_tree.html.haml +0 -5
  53. data/app/views/sortable/base/_children.html.haml +0 -1
  54. data/app/views/sortable/base/_controls.html.haml +0 -16
  55. data/app/views/sortable/base/_link.html.haml +0 -7
  56. data/app/views/sortable/base/_new.html.haml +0 -3
  57. data/app/views/sortable/base/_node.html.haml +0 -3
  58. data/app/views/sortable/base/_tree.html.haml +0 -12
  59. data/app/views/tree/base/_children.html.haml +0 -1
  60. data/app/views/tree/base/_link.html.haml +0 -1
  61. data/app/views/tree/base/_node.html.haml +0 -3
  62. data/app/views/tree/base/_tree.html.haml +0 -3
  63. data/config/locales/en.yml +0 -31
  64. data/config/locales/ru.yml +0 -31
  65. data/lib/tasks/the_sortable_tree.rake +0 -4
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,46 +0,0 @@
1
- $ ->
2
- class @CommentsTreeInit
3
- # SELECTORS
4
- reply_links: $('.comments_tree .comment .reply')
5
- skip_link: $('.comments_tree .new_comment .skip')
6
- new_comment_form: $('.comments_tree form.new_comment')
7
- parent_input: $(".comments_tree form.new_comment input[name='comment[parent_id]']")
8
-
9
- constructor: ->
10
-
11
- @reply_links.click (event) =>
12
- # GET DATA
13
- link = $ event.target
14
- comment = link.parents('.comment')
15
- title = comment.find('.title .main')
16
- hidden_field = comment.find('input:hidden')
17
- parent_id = hidden_field.val()
18
-
19
- form = @new_comment_form
20
- for_block = form.find('.for')
21
- name_field = for_block.find('i')
22
-
23
- # SET DATA
24
- name_field.html title.html()
25
- @parent_input.val parent_id
26
-
27
- # SHOW and JUMP
28
- for_block.show()
29
- window.location.hash = '#new_comment'
30
-
31
- false
32
-
33
- @skip_link.click (event) =>
34
- link = $ event.target
35
- form = @new_comment_form
36
- for_block = form.find('.for')
37
- name_field = for_block.find('i')
38
-
39
- name_field.html ''
40
- @parent_input.val ''
41
-
42
- for_block.hide()
43
-
44
- false
45
-
46
- new @CommentsTreeInit
@@ -1,47 +0,0 @@
1
- class @TheSortableTree
2
- max_levels = 3
3
- rebuild_url = '/'
4
-
5
- init: ->
6
- $('ol.sortable').nestedSortable
7
- disableNesting: 'no-nest'
8
- forcePlaceholderSize: true
9
- handle: 'i.handle'
10
- helper: 'clone'
11
- items: 'li'
12
- maxLevels: @max_levels
13
- opacity: .6
14
- placeholder: 'placeholder'
15
- revert: 250
16
- tabSize: 25
17
- tolerance: 'pointer'
18
- toleranceElement: '> div'
19
-
20
- $('ol.sortable').sortable
21
- update: (event, ui) =>
22
- parent_id = ui.item.parent().parent().attr('id')
23
- item_id = ui.item.attr('id')
24
- prev_id = ui.item.prev().attr('id')
25
- next_id = ui.item.next().attr('id')
26
-
27
- @rebuild item_id, parent_id, prev_id, next_id
28
-
29
- rebuild: (item_id, parent_id, prev_id, next_id) =>
30
- $.ajax
31
- type: 'POST'
32
- dataType: 'script'
33
- url: @rebuild_url
34
- data:
35
- id: item_id
36
- parent_id: parent_id
37
- prev_id: prev_id
38
- next_id: next_id
39
-
40
- beforeSend: (xhr) ->
41
- $('.nested_set i.handle').hide()
42
-
43
- success: (data, status, xhr) ->
44
- $('.nested_set i.handle').show()
45
-
46
- error: (xhr, status, error) ->
47
- alert error
@@ -1,84 +0,0 @@
1
- .comments_tree{
2
- * {
3
- margin: 0; padding: 0;
4
- list-style:none;
5
- }
6
-
7
- .new_comment{
8
- padding: 10px;
9
- margin-bottom: 10px;
10
- border: 1px solid Blue;
11
- border-radius: 5px;
12
- p{
13
- margin-bottom: 10px;
14
- }
15
- input[type=text], textarea{
16
- border: 1px solid Grey;
17
- border-left: 2px solid Grey;
18
- width: 90%;
19
- }
20
- }
21
-
22
- .nested_set{
23
- margin-bottom: 25px;
24
- }
25
-
26
- ol{
27
-
28
- margin: 0;
29
- padding: 0;
30
- list-style:none;
31
-
32
- &.nested_set {
33
- list-style:none;
34
- font-size: 16px;
35
-
36
- li{
37
- font-size: 0.95em;
38
- line-height: 130%;
39
- margin-bottom: 5px;
40
- list-style:none;
41
- list-style-position: outside;
42
-
43
- .comment{
44
- border: 1px solid LightGray;
45
- border-radius: 4px;
46
- padding: 10px;
47
-
48
- .title, .contacts{
49
- margin-bottom: 5px;
50
- }
51
-
52
- .title{
53
- color: blue;
54
- .reply a{
55
- font-size: 0.9em;
56
- font-family: Arial;
57
- color: green;
58
- text-decoration: none;
59
- &:hover{ text-decoration: underline; }
60
- }
61
- }
62
- .contacts{
63
- font-style: italic;
64
- }
65
- .content{
66
- background: LightGray;
67
- border-radius: 2px;
68
- font-family: Arial;
69
- padding: 5px;
70
- }
71
- }
72
- }
73
-
74
- ol{
75
- border-left: 1px dashed LightGreen;
76
- padding-left: 10px;
77
- margin-left: 15px;
78
- margin-top: 5px;
79
-
80
- li{ font-weight: normal; }
81
- }
82
- }
83
- }
84
- }
@@ -1,106 +0,0 @@
1
- .sortable{
2
- * {
3
- margin: 0; padding: 0;
4
- list-style: none;
5
- }
6
-
7
- .nested_set_new_image{
8
- vertical-align: middle;
9
- border: none;
10
- }
11
-
12
- .nested_set_new{
13
- margin: 25px 0;
14
- a{ font-size: 14pt }
15
- }
16
-
17
- .nested_set{
18
- margin: 0; padding: 0;
19
- list-style: none;
20
- font-size: 16px;
21
-
22
- a{
23
- color: #000;
24
- font-size: 10pt;
25
- font-weight: normal;
26
- text-decoration: none;
27
- line-height: 150%;
28
- margin-left: 30px;
29
- margin-right: 120px;
30
- display: block;
31
-
32
- &:hover{
33
- color: #2476FF;
34
- text-decoration: none;
35
- }
36
-
37
- img{
38
- float: left
39
- }
40
- }
41
-
42
- ol{
43
- margin: 0 0 0 25px;
44
- border-left: 1px dashed gray;
45
- li{ margin-bottom: 5px; }
46
- }
47
-
48
- .root{
49
- a{ font-weight: bold; }
50
- }
51
- .handle{
52
- width: 16px;
53
- height: 16px;
54
- float: left;
55
- cursor: move;
56
- background: transparent url(/assets/iconza/blue/move.png) no-repeat scroll center center;
57
- }
58
- .link{
59
- position: relative;
60
- overflow: hidden;
61
- zoom: 1;
62
- padding: 5px;
63
- margin: 0 0 5px 5px;
64
- background: #EFEFEF;
65
- border-radius: 5px;
66
- &:hover{
67
- background: #FEE;
68
- }
69
- }
70
- .controls{
71
- position: absolute;
72
- top: 5px; right: 10px;
73
- }
74
- .button{
75
- width: 20px;
76
- height: 20px;
77
- display: block;
78
- float: left;
79
- margin: 0 0 0 3px;
80
- cursor: pointer;
81
-
82
- &.new{
83
- background: transparent url(/assets/iconza/blue/add.png) no-repeat scroll center center;
84
- &:hover{ background: transparent url(/assets/iconza/red/add.png) no-repeat scroll center center }
85
- }
86
- &.edit{
87
- background: transparent url(/assets/iconza/blue/edit.png) no-repeat scroll center center;
88
- &:hover{ background: transparent url(/assets/iconza/red/edit.png) no-repeat scroll center center }
89
- }
90
- &.delete{
91
- background: transparent url(/assets/iconza/blue/delete.png) no-repeat scroll center center;
92
- &:hover{ background: transparent url(/assets/iconza/red/delete.png) no-repeat scroll center center }
93
- }
94
- &.undeleted{ background: transparent url(/assets/iconza/gray/delete.png) no-repeat scroll center center }
95
- }
96
-
97
- .placeholder {
98
- background-color: #EEF;
99
- border: 1px dashed blue;
100
- }
101
- .ui-nestedSortable-error {
102
- background: #FAA;
103
- color: #8a1f11;
104
- }
105
- }
106
- }
@@ -1 +0,0 @@
1
- = content_tag :ol, raw(children)
@@ -1,8 +0,0 @@
1
- .comment
2
- = hidden_field :comment, :id, :value => node.send(opts[:node_id]), :id => nil
3
- .title
4
- %span.main= node.send opts[:title]
5
- - if opts[:level] <= opts[:max_levels]
6
- %span.reply= link_to t('.reply'), '#'
7
- .contacts= node.send opts[:contacts_field]
8
- .content= raw node.send opts[:content_field]
@@ -1,18 +0,0 @@
1
- = form_for Comment.new, :class => :new_comment do |f|
2
- = f.hidden_field :parent_id
3
-
4
- %label= t('.title')
5
- %p= f.text_field opts[:title]
6
-
7
- %label= t('.contacts')
8
- %p= f.text_field opts[:contacts_field]
9
-
10
- %label
11
- = t('.content')
12
- %span.for{ :style => 'display:none' }
13
- = t('.for')
14
- %i Undefined
15
- = link_to t('.skip'), '#', :class => :skip
16
- %p= f.text_area opts[:raw_content_field]
17
-
18
- %div= f.submit t('.submit')
@@ -1,3 +0,0 @@
1
- %li
2
- = raw render(:partial => "#{opts[:path]}/comment", :locals => {:opts => opts, :root => root, :node => node})
3
- = render(:partial => "#{opts[:path]}/children", :locals => {:opts => opts, :parent => node, :children => children}) unless children.blank?
@@ -1,5 +0,0 @@
1
- .comments_tree
2
- - unless tree.empty?
3
- %ol.nested_set= raw tree
4
-
5
- = raw render(:partial => "#{opts[:path]}/new_comment_form", :locals => {:opts => opts})
@@ -1 +0,0 @@
1
- = content_tag :ol, raw(children)
@@ -1,16 +0,0 @@
1
- -# EDIT
2
- - edit = link_to '', polymorphic_url(opts[:namespace] + [node], :action => :edit), :title => t('.edit_this'), :class => 'button edit'
3
- -# DELETE
4
- - if opts[:has_children]
5
- - delete = link_to('', url_for(opts[:namespace] + [node]),
6
- :title => t('.delete'),
7
- :method => :delete,
8
- :data => { :confirm => t('.delete_confirm') },
9
- :class => 'button delete')
10
- - else
11
- - delete = link_to('', '#',
12
- :title => t('.cant_be_deleted'),
13
- :onclick => "alert('#{t('.delete_nested_elements')}')",
14
- :class => 'button undeleted')
15
- -# OUTPUT
16
- = edit + delete
@@ -1,7 +0,0 @@
1
- - title = node.send opts[:title]
2
- - handle = content_tag :i, '', :class => :handle
3
- - link = link_to(title, url_for(opts[:namespace] + [node]), :title => title)
4
- - controls = render(:partial => "#{opts[:path]}/controls", :locals => { :node => node, :opts => opts })
5
- - controls = content_tag(:b, controls, :class => :controls)
6
- - element = handle + controls + link
7
- %div{ :class => "link#{' root' if root}" }= element
@@ -1,3 +0,0 @@
1
- - image = image_tag('iconza/blue/add.png', :class => :nested_set_new_image) + ' '
2
- - link = link_to(image + t('.create'), opts[:new_url])
3
- .nested_set_new= link
@@ -1,3 +0,0 @@
1
- %li{ :id => "#{node.send(opts[:id])}_#{opts[:klass]}" }
2
- = raw render(:partial => "#{opts[:path]}/link", :locals => {:opts => opts, :root => root, :node => node})
3
- = render(:partial => "#{opts[:path]}/children", :locals => {:opts => opts, :parent => node, :children => children}) unless children.blank?
@@ -1,12 +0,0 @@
1
- .sortable
2
- = render :partial => "#{opts[:path]}/new", :locals => { :opts => opts }
3
- - unless tree.empty?
4
- :javascript
5
- $(function() {
6
- sortable = new TheSortableTree;
7
- sortable.max_levels = #{opts[:max_levels]};
8
- sortable.rebuild_url = "#{url_for(:controller => opts[:klass].pluralize, :action => :rebuild)}";
9
- sortable.init()
10
- })
11
-
12
- %ol.ui-sortable.sortable.nested_set{ :id => "#{opts[:klass]}_nested_set" }= raw tree
@@ -1 +0,0 @@
1
- = content_tag :ol, raw(children)
@@ -1 +0,0 @@
1
- = link_to node.send(opts[:title]), url_for(opts[:namespace] + [node]), :title => node.send(opts[:title])
@@ -1,3 +0,0 @@
1
- %li
2
- = raw render(:partial => "#{opts[:path]}/link", :locals => {:opts => opts, :root => root, :node => node})
3
- = render(:partial => "#{opts[:path]}/children", :locals => {:opts => opts, :parent => node, :children => children}) unless children.blank?
@@ -1,3 +0,0 @@
1
- .tree
2
- - unless tree.empty?
3
- %ol.nested_set= raw tree