cable 0.8.6 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/views/layouts/_breadcrumb.html.erb +1 -0
- data/app/views/layouts/_messages.html.erb +3 -3
- data/app/views/layouts/admin.html.erb +21 -26
- data/lib/generators/cable/menu/templates/erb/menus/_menu_children_table.html.erb +1 -1
- data/lib/generators/cable/menu/templates/erb/menus/move.html.erb +0 -16
- data/lib/generators/cable/menu/templates/migration.rb +1 -0
- data/lib/generators/cable/resource/templates/erb/scaffold/_form.html.erb +18 -25
- data/lib/generators/cable/resource/templates/erb/scaffold/index.html.erb +47 -45
- data/lib/generators/cable/resource/templates/erb/scaffold/show.html.erb +1 -2
- data/public/images/cable/add.png +0 -0
- data/public/images/cable/children.png +0 -0
- data/public/images/cable/empty-menu.png +0 -0
- data/public/images/cable/header-background.jpg +0 -0
- data/public/images/cable/help.png +0 -0
- data/public/images/cable/loader.gif +0 -0
- data/public/javascripts/cable_menu.js +316 -0
- data/public/stylesheets/cable/base.css +25 -0
- data/public/stylesheets/cable/buttons.css +55 -0
- data/public/stylesheets/cable/formtastic_changes.css +51 -0
- data/public/stylesheets/cable/menu.css +120 -0
- data/public/stylesheets/cable/pagination.css +10 -0
- data/public/stylesheets/cable/regions.css +247 -0
- data/public/stylesheets/cable/search.css +45 -0
- data/public/stylesheets/cable/tables.css +34 -0
- data/public/stylesheets/cable/tags.css +61 -0
- data/public/stylesheets/cable.css +9 -859
- data/public/stylesheets/{ui/aristo/images/button_bg.png → jquery/ui/images/bg_fallback.png} +0 -0
- data/public/stylesheets/jquery/ui/images/icon_sprite.png +0 -0
- data/public/stylesheets/jquery/ui/images/progress_bar.gif +0 -0
- data/public/stylesheets/{ui/aristo/images/ui-icons_ffffff_256x240.png → jquery/ui/images/ui-icons_454545_256x240.png} +0 -0
- data/public/stylesheets/{ui/aristo/aristo.css → jquery/ui/jquery-ui-1.8.7.custom.css} +345 -166
- metadata +27 -66
- data/public/images/iphone-style-checkboxes/off.png +0 -0
- data/public/images/iphone-style-checkboxes/on.png +0 -0
- data/public/images/iphone-style-checkboxes/slider.png +0 -0
- data/public/images/iphone-style-checkboxes/slider_center.png +0 -0
- data/public/images/iphone-style-checkboxes/slider_left.png +0 -0
- data/public/images/iphone-style-checkboxes/slider_right.png +0 -0
- data/public/javascripts/iphone-style-checkboxes.js +0 -224
- data/public/javascripts/jquery.columnview.js +0 -84
- data/public/javascripts/jstree/_lib/jquery.cookie.js +0 -96
- data/public/javascripts/jstree/_lib/jquery.hotkeys.js +0 -99
- data/public/javascripts/jstree/_lib/jquery.js +0 -6240
- data/public/javascripts/jstree/jquery.jstree.js +0 -4526
- data/public/javascripts/jstree/themes/apple/bg.jpg +0 -0
- data/public/javascripts/jstree/themes/apple/d.png +0 -0
- data/public/javascripts/jstree/themes/apple/dot_for_ie.gif +0 -0
- data/public/javascripts/jstree/themes/apple/style.css +0 -61
- data/public/javascripts/jstree/themes/apple/throbber.gif +0 -0
- data/public/javascripts/jstree/themes/classic/d.png +0 -0
- data/public/javascripts/jstree/themes/classic/dot_for_ie.gif +0 -0
- data/public/javascripts/jstree/themes/classic/style.css +0 -59
- data/public/javascripts/jstree/themes/classic/throbber.gif +0 -0
- data/public/javascripts/jstree/themes/default/d.gif +0 -0
- data/public/javascripts/jstree/themes/default/d.png +0 -0
- data/public/javascripts/jstree/themes/default/style.css +0 -73
- data/public/javascripts/jstree/themes/default/throbber.gif +0 -0
- data/public/javascripts/jstree/themes/default-rtl/d.gif +0 -0
- data/public/javascripts/jstree/themes/default-rtl/d.png +0 -0
- data/public/javascripts/jstree/themes/default-rtl/dots.gif +0 -0
- data/public/javascripts/jstree/themes/default-rtl/style.css +0 -83
- data/public/javascripts/jstree/themes/default-rtl/throbber.gif +0 -0
- data/public/stylesheets/columnview.css +0 -61
- data/public/stylesheets/formtastic_changes.css +0 -66
- data/public/stylesheets/iphone_checkboxes.css +0 -76
- data/public/stylesheets/ui/aristo/icons.psd +0 -0
- data/public/stylesheets/ui/aristo/images/datepicker.gif +0 -0
- data/public/stylesheets/ui/aristo/images/icon_sprite.png +0 -0
- data/public/stylesheets/ui/aristo/images/progress_bar.gif +0 -0
- data/public/stylesheets/ui/aristo/images/right-arrow.png +0 -0
- data/public/stylesheets/ui/aristo/images/slider_h_bg.gif +0 -0
- data/public/stylesheets/ui/aristo/images/slider_v_bg.gif +0 -0
- data/public/stylesheets/ui/aristo/images/tab_bg.gif +0 -0
- data/public/stylesheets/ui/aristo/images/the_gradient.gif +0 -0
- data/public/stylesheets/ui/aristo/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/public/stylesheets/ui/aristo/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/public/stylesheets/ui/aristo/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/public/stylesheets/ui/aristo/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/public/stylesheets/ui/aristo/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/public/stylesheets/ui/aristo/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/stylesheets/ui/aristo/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/public/stylesheets/ui/aristo/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/public/stylesheets/ui/aristo/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/public/stylesheets/ui/aristo/images/ui-icons_228ef1_256x240.png +0 -0
- data/public/stylesheets/ui/aristo/images/ui-icons_ef8c08_256x240.png +0 -0
- data/public/stylesheets/ui/aristo/images/ui-icons_ffd27a_256x240.png +0 -0
- data/public/stylesheets/ui/images/sprite-aristo.png +0 -0
- data/public/stylesheets/ui/images/uniform/sprite.png +0 -0
- data/public/stylesheets/ui/uniform/uniform.aristo.css +0 -470
- data/public/stylesheets/ui/uniform/uniform.default.css +0 -477
- /data/public/stylesheets/{formtastic.css → cable/formtastic.css} +0 -0
- /data/public/stylesheets/{ui/aristo → jquery/ui}/images/slider_handles.png +0 -0
- /data/public/stylesheets/{ui/aristo → jquery/ui}/images/ui-icons_222222_256x240.png +0 -0
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
@@ -0,0 +1 @@
|
|
1
|
+
<div id="breadcrumb"><%= render_navigation :renderer => :breadcrumbs, :join_with => " » " %></div>
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<% flash.each do |key, message| %>
|
2
|
-
<div
|
2
|
+
<div class="messages box flash">
|
3
3
|
<div class="flash-<%= key %>">
|
4
4
|
<%= message %>
|
5
5
|
</div>
|
6
6
|
</div>
|
7
7
|
<% end %>
|
8
8
|
<% unless @content_for_form_errors.blank? %>
|
9
|
-
<div
|
9
|
+
<div class="messages box error">
|
10
10
|
<%= yield :form_errors %>
|
11
11
|
</div>
|
12
|
-
<% end %>
|
12
|
+
<% end %>
|
@@ -1,51 +1,46 @@
|
|
1
1
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2
2
|
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
|
3
3
|
|
4
|
-
<head>
|
5
|
-
|
6
|
-
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
+
<title><%= @page_title || Cable::Setting.last.site_title %> | Administration Portal </title>
|
7
7
|
|
8
8
|
<%= csrf_meta_tag %>
|
9
9
|
<%= stylesheet_link_tag 'cable/blueprint/screen' %>
|
10
|
-
<%=
|
11
|
-
<%= stylesheet_link_tag 'cable'
|
12
|
-
<%= stylesheet_link_tag '
|
13
|
-
|
14
|
-
<%= javascript_include_tag 'jquery' , 'jquery-ui', 'rails' %>
|
15
|
-
<%= javascript_include_tag 'tinymce/jquery.tinymce.js' %>
|
16
|
-
<%= javascript_include_tag 'jquery.tablesorter.min.js' %>
|
17
|
-
<%= javascript_include_tag 'admin.js' %>
|
18
|
-
|
10
|
+
<%= stylesheet_link_tag 'cable' %>
|
11
|
+
<%= stylesheet_link_tag 'cable/formtastic' %>
|
12
|
+
<%= stylesheet_link_tag 'cable/formtastic_changes' %>
|
13
|
+
<%= stylesheet_link_tag 'jquery/ui/jquery-ui-1.8.7.custom.css' %>
|
14
|
+
<%= javascript_include_tag 'jquery' , 'jquery-ui', 'rails','tinymce/jquery.tinymce.js', 'jquery.tablesorter.min.js', 'admin.js' %>
|
19
15
|
<%= yield :scripts %>
|
20
16
|
</head>
|
21
|
-
<body
|
22
|
-
<div
|
17
|
+
<body>
|
18
|
+
<div id="header">
|
23
19
|
<div class="container">
|
24
|
-
<div
|
25
|
-
|
26
|
-
<div class="span-12 last"><%= yield(:admin_login , admin_user_login) %></div>
|
27
|
-
</div>
|
20
|
+
<div class="span-16"><h1><%= Cable::Setting.last.site_title %></h1></div>
|
21
|
+
<div class="span-8 last"><%= yield(:admin_login , admin_user_login) %></div>
|
28
22
|
<div id="main-navigation" class="span-24"><%= render_navigation(:level => 1, :context => :admin) %></div>
|
29
23
|
</div>
|
30
24
|
</div>
|
31
|
-
<div id="
|
25
|
+
<div id="main-wrapper">
|
32
26
|
<div class="container">
|
33
27
|
<div id="right-col" class="span-4">
|
34
|
-
<div id="secondary-navigation"><%= render_navigation(:level => 2..5, :context => :admin) %></div>
|
28
|
+
<div id="secondary-navigation" class="box shadow"><%= render_navigation(:level => 2..5, :context => :admin) %></div>
|
35
29
|
<%= yield :sidebar %>
|
36
30
|
</div>
|
37
31
|
<div id="main" class="span-20 last">
|
38
|
-
<div
|
39
|
-
<h2><%= @page_title %></h2>
|
40
|
-
<div id="
|
32
|
+
<div class="box shadow">
|
33
|
+
<h2 id="title"><%= @page_title %></h2>
|
34
|
+
<div id="help"><%= yield :help %><a class="button">Help</a></div>
|
35
|
+
<%= render :partial => 'layouts/breadcrumb' %>
|
41
36
|
<%= yield :page_menu %>
|
42
|
-
|
37
|
+
<%= render :partial => 'layouts/messages' %>
|
43
38
|
<%= yield %>
|
44
|
-
</div>
|
39
|
+
</div>
|
45
40
|
</div>
|
46
41
|
</div>
|
47
42
|
</div>
|
48
|
-
<div class="footer
|
43
|
+
<div class="footer">
|
49
44
|
<div class="container">
|
50
45
|
<div id="powered-by-cable">Powered by: Cable | V.<%= Cable::Base.version %></div>
|
51
46
|
</div>
|
@@ -1,19 +1,3 @@
|
|
1
|
-
<%% content_for :scripts do %>
|
2
|
-
<%%= javascript_include_tag 'jquery.clickmenu' %>
|
3
|
-
<script>
|
4
|
-
$(document).ready(function(){
|
5
|
-
$('#menu-tree-list').clickMenu({arrowSrc:'/images/arrow-head.png', onClick:function(){
|
6
|
-
var id = $(this).attr("id").replace("menu_", "");
|
7
|
-
$("#parent").html("Moving to: "+$(this).attr("title"));
|
8
|
-
$("#menu_parent_id").val(id);
|
9
|
-
$('#menu-tree-list').trigger('closemenu');
|
10
|
-
|
11
|
-
return false;
|
12
|
-
}});
|
13
|
-
});
|
14
|
-
</script>
|
15
|
-
<%% end %>
|
16
|
-
|
17
1
|
<h2>Move Menu</h2>
|
18
2
|
<div id="parent">Select a parent</div><br />
|
19
3
|
<%%= semantic_form_for [:admin, @<%= singular_table_name %>] do |f| %>
|
@@ -14,6 +14,7 @@ class Create<%= table_name.camelize %> < ActiveRecord::Migration
|
|
14
14
|
# add_index :<%= table_name %>, :rgt
|
15
15
|
# add_index :<%= table_name %>, :parent_id
|
16
16
|
add_index :<%= table_name %>, :url
|
17
|
+
add_index :<%= table_name %>, :marketable_url
|
17
18
|
# add_index :<%= table_name %>, :cable_menuable_id
|
18
19
|
|
19
20
|
end
|
@@ -1,30 +1,23 @@
|
|
1
1
|
<%%= semantic_form_for([:admin,@<%= singular_table_name %>], :html => {:multipart => true}) do |f| %>
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
<%% if @<%= singular_table_name %>.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
<ul>
|
7
|
+
<%%= @<%= singular_table_name %>.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%%= msg %></li>
|
9
|
+
<%% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<%% end %>
|
13
|
+
<%%= f.inputs do %>
|
14
|
+
<% for attribute in attributes -%>
|
15
|
+
<% unless attribute.type == :text %>
|
16
16
|
<%%= f.input :<%= attribute.name %>, :label => '<%= attribute.name %>' %>
|
17
|
-
|
17
|
+
<% else %>
|
18
18
|
<%%= f.input :<%= attribute.name %>, :label => '<%= attribute.name %>', :input_html => {:class => 'html_editor'} %>
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
<hr />
|
24
|
-
<div class="submit">
|
25
|
-
<%%= f.buttons do %>
|
26
|
-
<%%= f.commit_button 'Submit', :button_html => {:class => 'submit_button'} %>
|
27
|
-
<%% end %>
|
28
|
-
</div>
|
29
|
-
|
19
|
+
<% end -%>
|
20
|
+
<% end %>
|
21
|
+
<%% end %>
|
22
|
+
<%%= f.buttons %>
|
30
23
|
<%% end %>
|
@@ -1,43 +1,48 @@
|
|
1
1
|
<table>
|
2
|
-
<
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
<
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Page</th>
|
5
|
+
<th>Template</th>
|
6
|
+
<th class="actions">Actions</th>
|
7
|
+
</tr>
|
8
|
+
</thead>
|
9
|
+
<tbody>
|
10
|
+
|
11
|
+
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
12
|
+
<tr>
|
13
|
+
<td><strong><%%= link_to <%= singular_table_name %>.title, [:admin, <%= singular_table_name %>], :target => "_blank" %></strong></td>
|
14
|
+
<td style="text-align:right;"><%%= link_to 'Edit', edit_admin_<%= singular_table_name %>_path(<%= singular_table_name %>) %> <%%= link_to 'Destroy', [:admin, <%= singular_table_name %>], :confirm => 'Are you sure?', :method => :delete %></td>
|
15
|
+
</tr>
|
16
|
+
<%% unless <%= singular_table_name %>.menu.blank? %>
|
17
|
+
<tr>
|
18
|
+
<td><strong>Template:</strong>
|
19
|
+
<td><%%= <%= singular_table_name %>.menu.template.titleize unless <%= singular_table_name %>.menu.blank? %></td>
|
20
|
+
</tr>
|
21
|
+
<%% end %>
|
22
|
+
|
23
|
+
<%% if <%= singular_table_name %>.respond_to?(:blocks) %>
|
24
|
+
<tr>
|
25
|
+
<td colspan=1>
|
26
|
+
<strong>Blocks:</strong>
|
27
|
+
</td>
|
28
|
+
<td>
|
29
|
+
<%% unless <%= singular_table_name %>.blocks.empty? %>
|
30
|
+
<%%= <%= singular_table_name %>.blocks.each do |block| %>
|
31
|
+
<strong><%%= link_to block.title, [:admin, block] %></strong> => <%%= block.region.titleize %><br />
|
32
|
+
<%% end %>
|
33
|
+
<%% end %>
|
34
|
+
</td>
|
35
|
+
</tr>
|
36
|
+
<%% end %>
|
37
|
+
|
38
|
+
<%% if <%= singular_table_name %>.respond_to?(:teaser) %>
|
39
|
+
<tr>
|
40
|
+
<td><strong>Teaser:</strong></td>
|
41
|
+
<td><%%= <%= singular_table_name %>.teaser unless <%= singular_table_name %>.teaser.blank? %></td>
|
42
|
+
</tr>
|
43
|
+
<%% end %>
|
44
|
+
|
45
|
+
<%% unless <%= singular_table_name %>.menu.blank? %>
|
41
46
|
<tr>
|
42
47
|
<td style="border-bottom:2px solid #333;">
|
43
48
|
<strong>URL:</strong>
|
@@ -46,9 +51,6 @@
|
|
46
51
|
<%%= <%= singular_table_name %>.menu.url unless <%= singular_table_name %>.menu.blank? %></td>
|
47
52
|
</td>
|
48
53
|
</tr>
|
49
|
-
|
50
|
-
|
51
|
-
</table>
|
52
|
-
<script>
|
53
|
-
$('.button').button();
|
54
|
-
</script>
|
54
|
+
<%% end %>
|
55
|
+
</tbody>
|
56
|
+
</table>
|
@@ -8,5 +8,4 @@
|
|
8
8
|
|
9
9
|
<% end %>
|
10
10
|
|
11
|
-
<%%= link_to 'Edit', edit_admin_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
|
12
|
-
<%%= link_to 'Back', admin_<%= index_helper %>_path %>
|
11
|
+
<%%= link_to 'Edit', edit_admin_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> | <%%= link_to 'Back', admin_<%= index_helper %>_path %>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,316 @@
|
|
1
|
+
(function($){
|
2
|
+
|
3
|
+
var xhr;
|
4
|
+
|
5
|
+
var sortable_options = {
|
6
|
+
items: "li:not(#add-menu)",
|
7
|
+
connectWith: '.cable_menu_wrapper ul',
|
8
|
+
appendTo: '.cable_menu_wrapper',
|
9
|
+
helper: 'clone',
|
10
|
+
placeholder: "ui-state-highlight",
|
11
|
+
delay: 100,
|
12
|
+
stop: function(event, ui){
|
13
|
+
$tree = $(".cable_menu_wrapper > ul");
|
14
|
+
update_tree($tree);
|
15
|
+
select_item(ui.item[0]);
|
16
|
+
},
|
17
|
+
update: function(event, ui) {
|
18
|
+
|
19
|
+
},
|
20
|
+
receive: function(event, ui) {
|
21
|
+
$target = $(event.target);
|
22
|
+
$item = $(ui.item[0]);
|
23
|
+
$children_of_item = $item.data("children");
|
24
|
+
$id_of_item = $item.attr("menu");
|
25
|
+
$id_of_target = $target.attr("menu");
|
26
|
+
var $test_for_children = $children_of_item.indexOf(parseInt($id_of_target));
|
27
|
+
if($test_for_children < 0){
|
28
|
+
|
29
|
+
}else{
|
30
|
+
$(ui.sender).sortable('cancel');
|
31
|
+
}
|
32
|
+
if($id_of_item == $id_of_target){
|
33
|
+
$(ui.sender).sortable('cancel');
|
34
|
+
}
|
35
|
+
}
|
36
|
+
};
|
37
|
+
|
38
|
+
function save_tree(){
|
39
|
+
$(".cable_menu_wrapper li").each(function() {
|
40
|
+
$li = $(this);
|
41
|
+
$ul = $("ul[menu="+$li.attr("menu")+"]");
|
42
|
+
$ul.removeAttr("id");
|
43
|
+
$li.append($ul);
|
44
|
+
$li.attr("id", "menu_"+$li.attr("menu"));
|
45
|
+
});
|
46
|
+
$(".cable_menu_wrapper").find("ul").unbind("mouseenter");
|
47
|
+
$(".cable_menu_wrapper").find("ul").unbind("mouseleave");
|
48
|
+
$('.cable_menu_wrapper > ul').removeAttr("id");
|
49
|
+
|
50
|
+
var the_menu = $('.cable_menu_wrapper > ul').serialize_list();
|
51
|
+
$(".cable_menu_wrapper").removeClass();
|
52
|
+
|
53
|
+
$.post("/admin/menus/sort", the_menu);
|
54
|
+
}
|
55
|
+
|
56
|
+
function show_add_menu(item){
|
57
|
+
$("#add-menu").remove();
|
58
|
+
|
59
|
+
var $add = $("<li id='add-menu'>Add Menu Item</li>").appendTo($(item));
|
60
|
+
// $add.css({"position":"absolute","bottom":"-40px"});
|
61
|
+
// $item.css({"padding-bottom":"40px","height":"300px"});
|
62
|
+
|
63
|
+
$add.click(function(){
|
64
|
+
var id = $(item).attr("menu");
|
65
|
+
$("#add-menu-form").html("<img src='/images/cable/loader.gif' />");
|
66
|
+
$("#add-menu-form").load("/admin/menus/new?parent_id="+id, function(){
|
67
|
+
$("#save-tree").hide();
|
68
|
+
$("#menu-details").hide();
|
69
|
+
$("<li class='commit'><input class='cancel' id='menu_cancel' name='cancel' type='button' value='Cancel' /></li>").insertBefore("ol li.commit").click(function(){
|
70
|
+
$("#add-menu-form").html("");
|
71
|
+
$("#save-tree").show();
|
72
|
+
});
|
73
|
+
|
74
|
+
});
|
75
|
+
})
|
76
|
+
}
|
77
|
+
|
78
|
+
function hide_add_menu(item){
|
79
|
+
// $item = $(item);
|
80
|
+
// $item.css({"padding-bottom":"0px","height":"340px"});
|
81
|
+
$("#add-menu").remove();
|
82
|
+
}
|
83
|
+
|
84
|
+
function update_parents(item){
|
85
|
+
var $li = $(item);
|
86
|
+
var $id = $li.attr("menu");
|
87
|
+
var $pli = $("li[menu="+$id+"]");
|
88
|
+
|
89
|
+
var $parents = [];
|
90
|
+
|
91
|
+
var $pid = $pli.parent().attr("menu");
|
92
|
+
$parents.push(parseInt($pid));
|
93
|
+
if($pid != 0){
|
94
|
+
var $arr = update_parents($pli.parent())
|
95
|
+
var len= $arr.length;
|
96
|
+
for(var i=0; i<len; i++) {
|
97
|
+
$parents.push(parseInt($arr[i]));
|
98
|
+
}
|
99
|
+
}
|
100
|
+
$li.data("parents",$parents);
|
101
|
+
return $parents;
|
102
|
+
}
|
103
|
+
|
104
|
+
function update_children(item){
|
105
|
+
var $li = $(item);
|
106
|
+
var $id = $li.attr("menu");
|
107
|
+
var $ul = $("ul[menu="+$id+"]");
|
108
|
+
|
109
|
+
if($ul.children().size() == 0){
|
110
|
+
$li.removeClass("has-children").addClass("empty");
|
111
|
+
}else{
|
112
|
+
$li.addClass("has-children");
|
113
|
+
}
|
114
|
+
|
115
|
+
var $children = [];
|
116
|
+
$ul.children().each(function(){
|
117
|
+
$cid = $(this).attr("menu");
|
118
|
+
$cul = $("ul[menu="+$cid+"]");
|
119
|
+
$children.push(parseInt($cid));
|
120
|
+
var $arr = update_children(this);
|
121
|
+
var len= $arr.length;
|
122
|
+
for(var i=0; i<len; i++) {
|
123
|
+
$children.push(parseInt($arr[i]));
|
124
|
+
}
|
125
|
+
})
|
126
|
+
|
127
|
+
$li.data("children",$children);
|
128
|
+
|
129
|
+
return $children;
|
130
|
+
}
|
131
|
+
|
132
|
+
function update_breadcrumb(){
|
133
|
+
var items = new Array();
|
134
|
+
$(".cable_menu_wrapper .selected").removeClass("last");
|
135
|
+
$(".cable_menu_wrapper .selected").each(function(){
|
136
|
+
items.push($(this).text());
|
137
|
+
});
|
138
|
+
|
139
|
+
$("#selection p").html(items.join(" » "));
|
140
|
+
$(".cable_menu_wrapper .selected").last().addClass("last");
|
141
|
+
}
|
142
|
+
|
143
|
+
function select_item(item,wrapper){
|
144
|
+
$item = $(item);
|
145
|
+
$id = $(item).attr("menu");
|
146
|
+
$wrapper = $(wrapper);
|
147
|
+
$child = $("ul[menu="+$id+"]");
|
148
|
+
|
149
|
+
if($child.children().size() > 0){
|
150
|
+
$child.css({ left: $item.parent().position().left + $item.parent().width()+3+$(".cable_menu_wrapper").scrollLeft(), top: 0}).show();
|
151
|
+
}else{
|
152
|
+
$("<ul class='cable_menu empty' menu="+$id+"/>").css({ left: $item.parent().position().left + $item.parent().width()+3+$(".cable_menu_wrapper").scrollLeft(), top: 0}).sortable(sortable_options).appendTo($wrapper).mouseenter(function() {
|
153
|
+
show_add_menu(this);
|
154
|
+
}).mouseleave(function(){
|
155
|
+
hide_add_menu(this);
|
156
|
+
});;
|
157
|
+
}
|
158
|
+
|
159
|
+
$item.addClass("selected");
|
160
|
+
|
161
|
+
$item.siblings('.selected').each(function(){
|
162
|
+
deselect(this);
|
163
|
+
});
|
164
|
+
|
165
|
+
$child.children().each(function(){
|
166
|
+
deselect(this);
|
167
|
+
});
|
168
|
+
|
169
|
+
$wrapper.append($item.parent());
|
170
|
+
last_width = $wrapper.attr("scrollWidth");
|
171
|
+
$wrapper.stop();
|
172
|
+
$wrapper.animate({ 'scrollLeft': $wrapper.attr("scrollWidth") }, 2000);
|
173
|
+
$("#add-menu-form").html("");
|
174
|
+
$("#save-tree").show();
|
175
|
+
$("#menu-details").html("<img src='/images/cable/loader.gif' />").show();
|
176
|
+
|
177
|
+
if(xhr != undefined) {
|
178
|
+
xhr.abort();
|
179
|
+
}
|
180
|
+
xhr = $.ajax({
|
181
|
+
url: "/admin/menus/"+$item.attr("menu"),
|
182
|
+
success: function(data) {
|
183
|
+
$("#menu-details").html(data);
|
184
|
+
}
|
185
|
+
});
|
186
|
+
update_breadcrumb();
|
187
|
+
}
|
188
|
+
|
189
|
+
function deselect(item) {
|
190
|
+
var $item = $(item);
|
191
|
+
$item.removeClass('selected');
|
192
|
+
$id = $item.attr("menu");
|
193
|
+
$child = $("ul[menu="+$id+"]");
|
194
|
+
$child.hide().find("li").each(function(){
|
195
|
+
deselect(this);
|
196
|
+
});
|
197
|
+
|
198
|
+
}
|
199
|
+
|
200
|
+
function update_tree(tree){
|
201
|
+
$tree = $(tree);
|
202
|
+
$tree.find("li").each(function(){
|
203
|
+
update_children(this);
|
204
|
+
update_parents(this);
|
205
|
+
});
|
206
|
+
}
|
207
|
+
|
208
|
+
function build_menu(ul, wrapper, id){
|
209
|
+
var $wrapper = $(wrapper);
|
210
|
+
var $ul = $(ul);
|
211
|
+
var $id = id;
|
212
|
+
var $new_menu = $("<ul class='cable_menu' menu="+$id+"/>").appendTo($wrapper);
|
213
|
+
if($id >= 1){
|
214
|
+
$new_menu.hide();
|
215
|
+
}
|
216
|
+
$ul.children().each(function(){
|
217
|
+
var $li = $(this);
|
218
|
+
var $cloned_li = $(this).clone();
|
219
|
+
if($cloned_li.children().size() > 0){
|
220
|
+
$cloned_li.addClass("has-children");
|
221
|
+
$cloned_li.children().each(function(){
|
222
|
+
var $id = $cloned_li.attr("id").replace("menu_","");
|
223
|
+
build_menu(this,$wrapper,$id);
|
224
|
+
});
|
225
|
+
}
|
226
|
+
$cloned_li.appendTo($new_menu);
|
227
|
+
$cloned_li.attr("menu",$cloned_li.attr("id").replace("menu_",""));
|
228
|
+
$cloned_li.removeAttr("id");
|
229
|
+
|
230
|
+
$cloned_li.find("ul").remove();
|
231
|
+
});
|
232
|
+
}
|
233
|
+
|
234
|
+
$.fn.serialize_list = function(options) {
|
235
|
+
var defaults = {
|
236
|
+
attributes: ['id'],
|
237
|
+
allow_nesting: true,
|
238
|
+
prepend: 'ul',
|
239
|
+
att_regex: false,
|
240
|
+
is_child: false
|
241
|
+
};
|
242
|
+
|
243
|
+
var opts = $.extend(defaults, options);
|
244
|
+
var serialized_string = '';
|
245
|
+
|
246
|
+
if(!opts.is_child){
|
247
|
+
opts.prepend = '&'+opts.prepend;
|
248
|
+
}
|
249
|
+
|
250
|
+
this.each(function() {
|
251
|
+
var li_count = 0;
|
252
|
+
$(this).children().each(function(){
|
253
|
+
if(opts.allow_nesting || opts.attributes.length > 1){
|
254
|
+
for(att in opts.attributes){
|
255
|
+
val = att_rep(opts.attributes[att], $(this).attr(opts.attributes[att]));
|
256
|
+
serialized_string += opts.prepend+'['+li_count+']['+opts.attributes[att]+']='+val;
|
257
|
+
}
|
258
|
+
} else {
|
259
|
+
val = att_rep(opts.attributes[0], $(this).attr(opts.attributes[0]));
|
260
|
+
serialized_string += opts.prepend+'['+li_count+']='+val;
|
261
|
+
}
|
262
|
+
|
263
|
+
if(opts.allow_nesting){
|
264
|
+
var child_base = opts.prepend+'['+li_count+'][children]';
|
265
|
+
$(this).children().each(function(){
|
266
|
+
if(this.tagName == 'UL' || this.tagName == 'OL'){
|
267
|
+
serialized_string += $(this).serialize_list({'prepend': child_base, 'is_child': true});
|
268
|
+
}
|
269
|
+
});
|
270
|
+
}
|
271
|
+
li_count++;
|
272
|
+
});
|
273
|
+
function att_rep (att, val){
|
274
|
+
if(opts.att_regex){
|
275
|
+
for(x in opts.att_regex){
|
276
|
+
if(opts.att_regex[x].att == att){
|
277
|
+
return val.replace(opts.att_regex[x].regex, '');
|
278
|
+
}
|
279
|
+
}
|
280
|
+
} else {
|
281
|
+
return val;
|
282
|
+
}
|
283
|
+
}
|
284
|
+
});
|
285
|
+
return(serialized_string);
|
286
|
+
};
|
287
|
+
|
288
|
+
$.fn.cable_menu = function(options){
|
289
|
+
var $tree = $(this);
|
290
|
+
var $wrapper = $("<div class='cable_menu_wrapper'></div>").insertAfter($tree);
|
291
|
+
|
292
|
+
build_menu($tree, $wrapper, 0);
|
293
|
+
|
294
|
+
$wrapper.find("li").click(function(){
|
295
|
+
select_item(this, $wrapper);
|
296
|
+
});
|
297
|
+
|
298
|
+
update_tree($wrapper);
|
299
|
+
$tree.remove();
|
300
|
+
|
301
|
+
$wrapper.find("ul").sortable(sortable_options);
|
302
|
+
$wrapper.find("ul").mouseenter(function() {
|
303
|
+
show_add_menu(this);
|
304
|
+
}).mouseleave(function(){
|
305
|
+
hide_add_menu(this);
|
306
|
+
});
|
307
|
+
var $current_selection = $("<div id='selection'><strong>Current Selection:</strong><p> </p></div>").insertBefore($wrapper);
|
308
|
+
var $save = $("<div id='save-tree' class='actions'><a>Save Tree</a></div>").insertAfter($wrapper);
|
309
|
+
var $form = $("<div id='add-menu-form' />").insertAfter($save);
|
310
|
+
var $menu_details = $("<div id='menu-details' />").insertAfter($save);
|
311
|
+
$save.click(function(){save_tree();});
|
312
|
+
$("<hr />").insertAfter($wrapper);
|
313
|
+
|
314
|
+
}
|
315
|
+
|
316
|
+
})(jQuery);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/* @override http://localhost:3000/stylesheets/cable/base.css */
|
2
|
+
|
3
|
+
body{
|
4
|
+
padding-bottom:5em;
|
5
|
+
background: #f2f2f2;
|
6
|
+
}
|
7
|
+
a{
|
8
|
+
text-decoration:none;
|
9
|
+
color: #2494fa;
|
10
|
+
}
|
11
|
+
a:hover{
|
12
|
+
text-decoration:underline;
|
13
|
+
}
|
14
|
+
|
15
|
+
.box{
|
16
|
+
background: white;
|
17
|
+
padding: 10px;
|
18
|
+
}
|
19
|
+
|
20
|
+
.box.shadow{
|
21
|
+
-moz-box-shadow: 0px 2px 2px #ccc;
|
22
|
+
-webkit-box-shadow: 0px 2px 2px #ccc;
|
23
|
+
box-shadow: 0px 2px 2px #ccc;
|
24
|
+
}
|
25
|
+
|