Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-01-05-23-28-33
[civicrm-core.git] / templates / CRM / Admin / Page / Navigation.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
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>&nbsp;&nbsp;&nbsp;&nbsp;
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 <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>
54 <script type="text/javascript">
55 CRM.$(function($) {
56 $("#navigation-tree").jstree({
57 plugins: [ "themes", "json_data", "dnd","ui", "crrm","contextmenu" ],
58 json_data: {
59 ajax:{
60 dataType: "json",
61 url: {/literal}"{crmURL p='civicrm/ajax/menu' h=0 q='key='}{crmKey name='civicrm/ajax/menu'}"{literal}
62 },
63 progressive_render: true
64 },
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 },
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};
81 if ( $( m.r[0] ).attr('id').replace("node_","") == homeMenuId ||
82 $( 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 : "{/literal}{ts escape='js'}Edit{/ts}{literal}",
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 = $(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 CRM.loadForm(editURL).on('crmFormSuccess', function() {
102 $("#navigation-tree").jstree('refresh');
103 $("#reset-menu").show( );
104 });
105 },
106 submenu: false
107 }
108 }
109 }
110
111 }).bind("rename.jstree", function ( e,node ) {
112 var nodeID = node.rslt.obj.attr('id').replace("node_","");
113 var newName = node.rslt.new_name;
114 var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal};
115 $.get( postURL + '&type=rename&id=' + nodeID + '&data=' + newName,
116 function (data) {
117 $("#reset-menu").show( );
118 }
119 );
120
121 }).bind("remove.jstree", function( e,node ) {
122 var menuName = node.rslt.obj.find('a').first( ).text( );
123 var nodeID = node.rslt.obj.attr('id').replace("node_","");
124
125 // don't allow deleting of home
126 var homeMenuId = {/literal}"{$homeMenuId}"{literal};
127 if ( nodeID == homeMenuId ) {
128 var cannotDeleteMsg = {/literal}"{ts escape='js'}You cannot delete this menu item:{/ts}" + " "{literal} + menuName;
129 CRM.alert( cannotDeleteMsg, {/literal}"{ts escape='js'}Cannot Delete{/ts}"{literal} );
130 $("#navigation-tree").jstree('refresh');
131 return false;
132 }
133 var deleteMsg = {/literal}"{ts escape='js'}Are you sure you want to delete this menu item:{/ts}" + " "{literal} + menuName + {/literal}" ? {ts}This action cannot be undone.{/ts}"{literal};
134 var isDelete = confirm( deleteMsg );
135 if ( isDelete ) {
136 var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal};
137 $.get( postURL + '&type=delete&id=' + nodeID,
138 function (data) {
139 $("#reset-menu").show( );
140 }
141 );
142 } else {
143 $("#navigation-tree").jstree('refresh');
144 }
145
146 }).bind("move_node.jstree", function ( e,node ) {
147 node.rslt.o.each(function (i) {
148 var nodeID = node.rslt.o.attr('id').replace("node_","");
149 var refID = node.rslt.np.attr('id').replace("node_","");
150 if (isNaN( refID ) ){ refID =''; }
151 var ps = node.rslt.cp+i;
152 var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal};
153 $.get( postURL + '&type=move&id=' + nodeID + '&ref_id=' + refID + '&ps='+ps,
154 function (data) {
155 $("#reset-menu").show( );
156 });
157 });
158 });
159 $('#new-menu-item a.button')
160 .on('click', CRM.popup)
161 .on('crmPopupFormSuccess', function() {
162 $("#navigation-tree").jstree('refresh');
163 $("#reset-menu").show();
164 });
165 });
166 </script>
167 {/literal}
168 {/if}