2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.3 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
26 {if $action eq 1 or $action eq 2 or $action eq 8}
27 {include file="CRM/Admin/Form/Navigation.tpl"}
30 {ts}Customize the CiviCRM navigation menu bar for your users here.{/ts} {help id="id-navigation"}
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}
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>
46 <script type="text/javascript">
48 cj("#navigation-tree").jstree({
49 plugins : [ "themes", "json_data", "dnd","ui", "crrm","contextmenu" ],
54 url : {/literal}"{crmURL p='civicrm/ajax/menu' h=0 q='key='}{crmKey name='civicrm/ajax/menu'}"{literal}
58 droppable : [ "tree-drop" ],
65 check_move: function(m) {
66 var homeMenuId = {/literal}"{$homeMenuId}"{literal};
68 if ( cj( m.r[0] ).attr('id').replace("node_","") == homeMenuId ||
69 cj( m.o[0] ).attr('id').replace("node_","") == homeMenuId ) {
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;
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,
101 cj("#reset-menu").show( );
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_","");
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');
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 );
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,
123 cj("#reset-menu").show( );
127 cj("#navigation-tree").jstree('refresh');
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,
139 cj("#reset-menu").show( );