Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
232624b1 | 3 | | CiviCRM version 4.4 | |
6a488035 TO |
4 | +--------------------------------------------------------------------+ |
5 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
6 | +--------------------------------------------------------------------+ | |
7 | | This file is a part of CiviCRM. | | |
8 | | | | |
9 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
10 | | under the terms of the GNU Affero General Public License | | |
11 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
12 | | | | |
13 | | CiviCRM is distributed in the hope that it will be useful, but | | |
14 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
16 | | See the GNU Affero General Public License for more details. | | |
17 | | | | |
18 | | You should have received a copy of the GNU Affero General Public | | |
19 | | License and the CiviCRM Licensing Exception along | | |
20 | | with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | *} | |
26 | {if $action eq 1 or $action eq 2 or $action eq 8} | |
27 | {include file="CRM/Admin/Form/Navigation.tpl"} | |
28 | {else} | |
29 | <div id="help"> | |
30 | {ts}Customize the CiviCRM navigation menu bar for your users here.{/ts} {help id="id-navigation"} | |
31 | </div> | |
32 | ||
33 | <div class="crm-block crm-content-block"> | |
34 | <div id="new-menu-item"> | |
35 | <a href="{crmURL p="civicrm/admin/menu" q="action=add&reset=1"}" class="button" style="margin-left: 6px;"><span><div class="icon add-icon"></div>{ts}Add Menu Item{/ts}</span></a> | |
36 | <span id="reset-menu" class="success-status" style="display:none"> | |
37 | {capture assign=rebuildURL}{crmURL p='civicrm/admin/menu' q="reset=1"}{/capture} | |
38 | {ts 1=$rebuildURL}<a href='%1' title="Reload page"><strong>Click here</strong></a> to reload the page and see your changes in the menu bar above.{/ts} | |
39 | </span><br/><br/> | |
40 | </div> | |
41 | <div class="spacer"></div> | |
42 | <div id="navigation-tree" class="navigation-tree" style="height:auto; border-collapse:separate; background-color:#FFFFFF;"></div> | |
43 | <div class="spacer"></div> | |
44 | </div> | |
45 | {literal} | |
4441df69 CW |
46 | <style type="text/css"> |
47 | #navigation-tree li { | |
48 | font-weight: normal; | |
49 | } | |
50 | #navigation-tree > ul > li { | |
51 | font-weight: bold; | |
52 | } | |
53 | </style> | |
6a488035 TO |
54 | <script type="text/javascript"> |
55 | cj(function () { | |
56 | cj("#navigation-tree").jstree({ | |
57 | plugins : [ "themes", "json_data", "dnd","ui", "crrm","contextmenu" ], | |
58 | json_data : { | |
59 | ajax:{ | |
60 | dataType : "json", | |
61 | async : true, | |
62 | url : {/literal}"{crmURL p='civicrm/ajax/menu' h=0 q='key='}{crmKey name='civicrm/ajax/menu'}"{literal} | |
63 | } | |
64 | }, | |
4441df69 CW |
65 | themes: { |
66 | "theme": 'classic', | |
67 | "dots": true, | |
68 | "icons": false, | |
69 | "url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/classic/style.css' | |
70 | }, | |
6a488035 TO |
71 | rules : { |
72 | droppable : [ "tree-drop" ], | |
73 | multiple : true, | |
74 | deletable : "all", | |
75 | draggable : "all" | |
76 | }, | |
77 | crrm : { | |
78 | move: { | |
79 | check_move: function(m) { | |
80 | var homeMenuId = {/literal}"{$homeMenuId}"{literal}; | |
6a488035 TO |
81 | if ( cj( m.r[0] ).attr('id').replace("node_","") == homeMenuId || |
82 | cj( m.o[0] ).attr('id').replace("node_","") == homeMenuId ) { | |
83 | return false; | |
84 | } else { | |
85 | return true; | |
86 | } | |
87 | } | |
88 | } | |
89 | }, | |
90 | contextmenu : { | |
91 | items: { | |
92 | create : false, | |
93 | ccp : { | |
94 | label : "Edit", | |
95 | visible : function (node, obj) { if(node.length != 1) return false; | |
96 | return obj.check("renameable", node); }, | |
97 | action : function (node, obj) { | |
98 | var nid = cj(node).prop('id'); | |
99 | var nodeID = nid.substr( 5 ); | |
100 | var editURL = {/literal}"{crmURL p='civicrm/admin/menu' h=0 q='action=update&reset=1&id='}"{literal} + nodeID; | |
101 | location.href = editURL; | |
102 | }, | |
103 | submenu : false | |
104 | } | |
105 | } | |
106 | } | |
107 | ||
108 | }).bind("rename.jstree", function ( e,node ) { | |
109 | var nodeID = node.rslt.obj.attr('id').replace("node_",""); | |
110 | var newName = node.rslt.new_name; | |
111 | var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal}; | |
112 | cj.get( postURL + '&type=rename&id=' + nodeID + '&data=' + newName, | |
113 | function (data) { | |
114 | cj("#reset-menu").show( ); | |
115 | } | |
116 | ); | |
117 | ||
118 | }).bind("remove.jstree", function ( e,node ) { | |
119 | var menuName = node.rslt.obj.find('a').first( ).text( ); | |
120 | var nodeID = node.rslt.obj.attr('id').replace("node_",""); | |
121 | ||
122 | // don't allow deleting of home | |
123 | var homeMenuId = {/literal}"{$homeMenuId}"{literal}; | |
124 | if ( nodeID == homeMenuId ) { | |
125 | var cannotDeleteMsg = {/literal}"{ts escape='js'}You cannot delete this menu item:{/ts}" + " "{literal} + menuName; | |
126 | CRM.alert( cannotDeleteMsg, {/literal}"{ts escape='js'}Cannot Delete{/ts}"{literal} ); | |
127 | cj("#navigation-tree").jstree('refresh'); | |
128 | return false; | |
129 | } | |
130 | var deleteMsg = {/literal}"{ts escape='js'}Are you sure you want to delete this menu item:{/ts}" + " "{literal} + menuName + {/literal}" ? {ts}This action can not be undone.{/ts}"{literal}; | |
131 | var isDelete = confirm( deleteMsg ); | |
132 | if ( isDelete ) { | |
133 | var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal}; | |
134 | cj.get( postURL + '&type=delete&id=' + nodeID, | |
135 | function (data) { | |
136 | cj("#reset-menu").show( ); | |
137 | } | |
138 | ); | |
139 | } else { | |
140 | cj("#navigation-tree").jstree('refresh'); | |
141 | } | |
142 | ||
143 | }).bind("move_node.jstree", function ( e,node ) { | |
144 | node.rslt.o.each(function (i) { | |
145 | var nodeID = node.rslt.o.attr('id').replace("node_",""); | |
146 | var refID = node.rslt.np.attr('id').replace("node_",""); | |
147 | if (isNaN( refID ) ){ refID =''; } | |
148 | var ps = node.rslt.cp+i; | |
149 | var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal}; | |
150 | cj.get( postURL + '&type=move&id=' + nodeID + '&ref_id=' + refID + '&ps='+ps, | |
151 | function (data) { | |
152 | cj("#reset-menu").show( ); | |
153 | }); | |
154 | }); | |
155 | }); | |
156 | }); | |
157 | </script> | |
158 | {/literal} | |
159 | {/if} |