1 | {combine_script id='jquery.underscore' load='footer' path='themes/default/js/plugins/underscore.js'} |
---|
2 | |
---|
3 | {footer_script require='jquery.ui.sortable'} |
---|
4 | (function($){ |
---|
5 | $("#menuOrdering").submit(function() { |
---|
6 | $('.menuUl li').each(function(i) { |
---|
7 | $('.menuPos[name="position[' + $(this).data('id') + ']"]').val(i); |
---|
8 | }); |
---|
9 | }); |
---|
10 | |
---|
11 | $('.menuUl').on('click', 'a.deletePage', function() { |
---|
12 | var id = $(this).parents("li.menuLi").data('id'); |
---|
13 | $(this).parents("li.menuLi").remove(); |
---|
14 | $("select[name='add_page'] option[value='"+ id +"']").removeAttr("disabled"); |
---|
15 | }); |
---|
16 | |
---|
17 | function init_sortable() { |
---|
18 | $(".menuUl").sortable({ |
---|
19 | axis: "y", |
---|
20 | opacity: 0.8 |
---|
21 | }); |
---|
22 | } |
---|
23 | |
---|
24 | var template = _.template($('#lp_template').html()); |
---|
25 | |
---|
26 | $("select[name='add_page']").change(function() { |
---|
27 | if ($(this).val() != -1) { |
---|
28 | var $option = $(this).children("option:selected"); |
---|
29 | |
---|
30 | $("ul.menuUl").append(template({ |
---|
31 | id: $(this).val(), |
---|
32 | name: $option.html(), |
---|
33 | href: $option.data('href'), |
---|
34 | standalone: $option.data('standalone'), |
---|
35 | language: $option.data('language') |
---|
36 | })); |
---|
37 | |
---|
38 | $option.attr("disabled", "disabled"); |
---|
39 | $(this).val(-1); |
---|
40 | init_sortable(); |
---|
41 | } |
---|
42 | }); |
---|
43 | |
---|
44 | init_sortable(); |
---|
45 | |
---|
46 | {foreach from=$cat_pages item=page} |
---|
47 | $("ul.menuUl").append(template({ |
---|
48 | id: {$page.page_id}, |
---|
49 | name: '{$page.title}', |
---|
50 | href: '{$page.U_PAGE}', |
---|
51 | standalone: {$page.standalone}, |
---|
52 | language: '{$page.language}' |
---|
53 | })); |
---|
54 | {/foreach} |
---|
55 | }(jQuery)); |
---|
56 | {/footer_script} |
---|
57 | |
---|
58 | {html_style} |
---|
59 | #menuOrdering a:hover { border:none; } |
---|
60 | .menuPos { display:none; } |
---|
61 | .menuLi { cursor:move; } |
---|
62 | {/html_style} |
---|
63 | |
---|
64 | |
---|
65 | <div class="titrePage"> |
---|
66 | <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> › {'Edit album'|translate} {$TABSHEET_TITLE}</h2> |
---|
67 | </div> |
---|
68 | |
---|
69 | <form id="menuOrdering" action="{$F_ACTION}" method="post"> |
---|
70 | {if count($pages)} |
---|
71 | <p style="margin-bottom:15px;"> |
---|
72 | {'ap_add_page'|translate} |
---|
73 | <select name="add_page"> |
---|
74 | <option value="-1" selected="selected">------------</option> |
---|
75 | {foreach from=$pages item=page} |
---|
76 | <option value="{$page.id}" {$page.disabled} data-href="{$page.U_PAGE}" data-standalone="{$page.standalone}" data-language="{$page.language}"> |
---|
77 | {$page.title} |
---|
78 | </option> |
---|
79 | {/foreach} |
---|
80 | </select> |
---|
81 | </p> |
---|
82 | |
---|
83 | <ul class="menuUl"></ul> |
---|
84 | |
---|
85 | <p class="menuSubmit"> |
---|
86 | <input type="submit" name="save_pages" value="{'Submit'|translate}"> |
---|
87 | <input type="submit" name="reset" value="{'Reset'|translate}"> |
---|
88 | </p> |
---|
89 | {/if} |
---|
90 | |
---|
91 | <p style="text-align:left;"> |
---|
92 | <a href="{$AP_ADMIN}">{'ap_add_page'|translate}</a> |
---|
93 | </p> |
---|
94 | |
---|
95 | </form> |
---|
96 | |
---|
97 | <script type="text/template" id="lp_template"> |
---|
98 | <li class="menuLi" data-id=<%= id %>> |
---|
99 | <p> |
---|
100 | <span style="margin:2px 5px;"> |
---|
101 | <a href="#" class="deletePage"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/category_delete.png" alt="{'delete'|translate}" title="{'delete'|translate}"></a> |
---|
102 | </span> |
---|
103 | |
---|
104 | <img src="{$themeconf.admin_icon_dir}/cat_move.png" class="button drag_button" alt="{'Drag to re-order'|translate}" title="{'Drag to re-order'|translate}"> |
---|
105 | <b><a href="<%= href %>"><%= name %></a></b> |
---|
106 | <% if (standalone) { %> |
---|
107 | - {'ap_standalone_page'|translate} |
---|
108 | <% } %> |
---|
109 | <% if (language) { %> |
---|
110 | <i>(<%= language %>)</i> |
---|
111 | <% } %> |
---|
112 | </p> |
---|
113 | |
---|
114 | <input class="menuPos" type="text" size="4" name="position[<%= id %>]" maxlength="4" value="0"> |
---|
115 | </li> |
---|
116 | </script> |
---|