Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
3 | | CiviCRM version 4.3 | | |
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} | |
46 | <script type="text/javascript"> | |
47 | cj(function () { | |
48 | cj("#navigation-tree").jstree({ | |
49 | plugins : [ "themes", "json_data", "dnd","ui", "crrm","contextmenu" ], | |
50 | json_data : { | |
51 | ajax:{ | |
52 | dataType : "json", | |
53 | async : true, | |
54 | url : {/literal}"{crmURL p='civicrm/ajax/menu' h=0 q='key='}{crmKey name='civicrm/ajax/menu'}"{literal} | |
55 | } | |
56 | }, | |
57 | rules : { | |
58 | droppable : [ "tree-drop" ], | |
59 | multiple : true, | |
60 | deletable : "all", | |
61 | draggable : "all" | |
62 | }, | |
63 | crrm : { | |
64 | move: { | |
65 | check_move: function(m) { | |
66 | var homeMenuId = {/literal}"{$homeMenuId}"{literal}; | |
67 | ||
68 | if ( cj( m.r[0] ).attr('id').replace("node_","") == homeMenuId || | |
69 | cj( m.o[0] ).attr('id').replace("node_","") == homeMenuId ) { | |
70 | return false; | |
71 | } else { | |
72 | return true; | |
73 | } | |
74 | } | |
75 | } | |
76 | }, | |
77 | contextmenu : { | |
78 | items: { | |
79 | create : false, | |
80 | ccp : { | |
81 | label : "Edit", | |
82 | visible : function (node, obj) { if(node.length != 1) return false; | |
83 | return obj.check("renameable", node); }, | |
84 | action : function (node, obj) { | |
85 | var nid = cj(node).prop('id'); | |
86 | var nodeID = nid.substr( 5 ); | |
87 | var editURL = {/literal}"{crmURL p='civicrm/admin/menu' h=0 q='action=update&reset=1&id='}"{literal} + nodeID; | |
88 | location.href = editURL; | |
89 | }, | |
90 | submenu : false | |
91 | } | |
92 | } | |
93 | } | |
94 | ||
95 | }).bind("rename.jstree", function ( e,node ) { | |
96 | var nodeID = node.rslt.obj.attr('id').replace("node_",""); | |
97 | var newName = node.rslt.new_name; | |
98 | var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal}; | |
99 | cj.get( postURL + '&type=rename&id=' + nodeID + '&data=' + newName, | |
100 | function (data) { | |
101 | cj("#reset-menu").show( ); | |
102 | } | |
103 | ); | |
104 | ||
105 | }).bind("remove.jstree", function ( e,node ) { | |
106 | var menuName = node.rslt.obj.find('a').first( ).text( ); | |
107 | var nodeID = node.rslt.obj.attr('id').replace("node_",""); | |
108 | ||
109 | // don't allow deleting of home | |
110 | var homeMenuId = {/literal}"{$homeMenuId}"{literal}; | |
111 | if ( nodeID == homeMenuId ) { | |
112 | var cannotDeleteMsg = {/literal}"{ts escape='js'}You cannot delete this menu item:{/ts}" + " "{literal} + menuName; | |
113 | CRM.alert( cannotDeleteMsg, {/literal}"{ts escape='js'}Cannot Delete{/ts}"{literal} ); | |
114 | cj("#navigation-tree").jstree('refresh'); | |
115 | return false; | |
116 | } | |
117 | 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}; | |
118 | var isDelete = confirm( deleteMsg ); | |
119 | if ( isDelete ) { | |
120 | var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal}; | |
121 | cj.get( postURL + '&type=delete&id=' + nodeID, | |
122 | function (data) { | |
123 | cj("#reset-menu").show( ); | |
124 | } | |
125 | ); | |
126 | } else { | |
127 | cj("#navigation-tree").jstree('refresh'); | |
128 | } | |
129 | ||
130 | }).bind("move_node.jstree", function ( e,node ) { | |
131 | node.rslt.o.each(function (i) { | |
132 | var nodeID = node.rslt.o.attr('id').replace("node_",""); | |
133 | var refID = node.rslt.np.attr('id').replace("node_",""); | |
134 | if (isNaN( refID ) ){ refID =''; } | |
135 | var ps = node.rslt.cp+i; | |
136 | var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal}; | |
137 | cj.get( postURL + '&type=move&id=' + nodeID + '&ref_id=' + refID + '&ps='+ps, | |
138 | function (data) { | |
139 | cj("#reset-menu").show( ); | |
140 | }); | |
141 | }); | |
142 | }); | |
143 | }); | |
144 | </script> | |
145 | {/literal} | |
146 | {/if} |