commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / templates / CRM / common / navigation.js.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
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 *}// http://civicrm.org/licensing
26 {capture assign=menuMarkup}{strip}
27 <ul id="civicrm-menu">
28 {if call_user_func(array('CRM_Core_Permission','giveMeAllACLs'))}
29 <li id="crm-qsearch" class="menumain">
30 <form action="{crmURL p='civicrm/contact/search/advanced' h=0 }" name="search_block" id="id_search_block" method="post">
31 <div id="quickSearch">
32 <input type="text" class="form-text" id="sort_name_navigation" placeholder="{ts}Contacts{/ts}" name="sort_name" style="width: 6em;" />
33 <input type="text" id="sort_contact_id" style="display: none" />
34 <input type="hidden" name="hidden_location" value="1" />
35 <input type="hidden" name="qfKey" value="" />
36 <div style="height:1px; overflow:hidden;"><input type="submit" value="{ts}Go{/ts}" name="_qf_Advanced_refresh" class="crm-form-submit default" /></div>
37 </div>
38 </form>
39 <ul>
40 <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" checked="checked" value="" name="quickSearchField"> {if $includeEmail}{ts}Name/Email{/ts}{else}{ts}Name{/ts}{/if}</label></li>
41 <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="contact_id" name="quickSearchField"> {ts}Contact ID{/ts}</label></li>
42 <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="external_identifier" name="quickSearchField"> {ts}External ID{/ts}</label></li>
43 <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="first_name" name="quickSearchField"> {ts}First Name{/ts}</label></li>
44 <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="last_name" name="quickSearchField"> {ts}Last Name{/ts}</label></li>
45 <li><label class="crm-quickSearchField"><input type="radio" data-tablename="eml" value="email" name="quickSearchField"> {ts}Email{/ts}</label></li>
46 <li><label class="crm-quickSearchField"><input type="radio" data-tablename="phe" value="phone_numeric" name="quickSearchField"> {ts}Phone{/ts}</label></li>
47 <li><label class="crm-quickSearchField"><input type="radio" data-tablename="sts" value="street_address" name="quickSearchField"> {ts}Street Address{/ts}</label></li>
48 <li><label class="crm-quickSearchField"><input type="radio" data-tablename="sts" value="city" name="quickSearchField"> {ts}City{/ts}</label></li>
49 <li><label class="crm-quickSearchField"><input type="radio" data-tablename="sts" value="postal_code" name="quickSearchField"> {ts}Postal Code{/ts}</label></li>
50 <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="job_title" name="quickSearchField"> {ts}Job Title{/ts}</label></li>
51 </ul>
52 </li>
53 {/if}
54 {$navigation}
55 </ul>
56 {/strip}{/capture}// <script> Generated {$smarty.now|date_format:'%d %b %Y %H:%M:%S'}
57 {literal}
58 (function($) {
59 var menuMarkup = {/literal}{$menuMarkup|@json_encode};
60 {if $config->userFramework neq 'Joomla'}{literal}
61 $('body').append(menuMarkup);
62
63 //Track Scrolling
64 $(window).scroll(function () {
65 var scroll = document.documentElement.scrollTop || document.body.scrollTop;
66 $('#civicrm-menu').css({top: "scroll", position: "fixed", top: "0px"});
67 $('div.sticky-header').css({top: "23px", position: "fixed"});
68 });
69
70 if ($('#edit-shortcuts').length > 0) {
71 $('#civicrm-menu').css({'width': '97%'});
72 }
73 {/literal}{else}{* Special menu hacks for Joomla *}{literal}
74 // below div is present in older version of joomla 2.5.x
75 var elementExists = $('div#toolbar-box div.m').length;
76 if (elementExists > 0) {
77 $('div#toolbar-box div.m').html(menuMarkup);
78 }
79 else {
80 $("#crm-nav-menu-container").html(menuMarkup).css({'padding-bottom': '10px'});
81 }
82 {/literal}{/if}{literal}
83 // CRM-15493 get the current qfKey
84 $("input[name=qfKey]", "#quickSearch").val($('#civicrm-navigation-menu').data('qfkey'));
85
86 $('#civicrm-menu').ready(function() {
87 $('#root-menu-div .outerbox').css({'margin-top': '6px'});
88 $('#root-menu-div .menu-ul li').css({'padding-bottom': '2px', 'margin-top': '2px'});
89 $('img.menu-item-arrow').css({top: '4px'});
90 $("#civicrm-menu >li").each(function(i){
91 $(this).attr("tabIndex",i+2);
92 });
93
94 $('#sort_name_navigation')
95 .autocomplete({
96 source: function(request, response) {
97 var
98 option = $('input[name=quickSearchField]:checked'),
99 params = {
100 name: request.term,
101 field_name: option.val(),
102 table_name: option.attr("data-tablename")
103 };
104 CRM.api3('contact', 'getquick', params).done(function(result) {
105 var ret = [];
106 if (result.values.length > 0) {
107 $('#sort_name_navigation').autocomplete('widget').menu('option', 'disabled', false);
108 $.each(result.values, function(k, v) {
109 ret.push({value: v.id, label: v.data});
110 });
111 } else {
112 $('#sort_name_navigation').autocomplete('widget').menu('option', 'disabled', true);
113 var label = option.closest('label').text();
114 var msg = ts('{/literal}{ts escape='js' 1='%1'}%1 not found.{/ts}'{literal}, {1: label});
115 // Remind user they are not searching by contact name (unless they enter a number)
116 if (params.field_name && !(/[\d].*/.test(params.name))) {
117 msg += {/literal}' {ts escape='js'}Did you mean to search by Name/Email instead?{/ts}'{literal};
118 }
119 ret.push({value: '0', label: msg});
120 }
121 response(ret);
122 })
123 },
124 focus: function (event, ui) {
125 return false;
126 },
127 select: function (event, ui) {
128 if (ui.item.value > 0) {
129 document.location = CRM.url('civicrm/contact/view', {reset: 1, cid: ui.item.value});
130 }
131 return false;
132 },
133 create: function() {
134 // Place menu in front
135 $(this).autocomplete('widget')
136 .addClass('crm-quickSearch-results')
137 .css('z-index', $('#civicrm-menu').css('z-index'));
138 }
139 })
140 .keydown(function() {
141 $.Menu.closeAll();
142 })
143 .on('focus', function() {
144 if ($(this).attr('style').indexOf('14em') < 0) {
145 $(this).animate({width: '14em'});
146 }
147 })
148 .on('blur', function() {
149 // Shrink if no input and menu is not open
150 if (!$(this).val().length && $(this).attr('style').indexOf('6em') < 0 && !$('.crm-quickSearchField:visible', '#root-menu-div').length) {
151 $(this).animate({width: '6em'});
152 }
153 });
154 $('.crm-hidemenu').click(function(e) {
155 $('#civicrm-menu').slideUp();
156 if ($('#crm-notification-container').length) {
157 var alert = CRM.alert({/literal}'<a href="#" id="crm-restore-menu" style="text-align: center; margin-top: -8px;">{ts escape='js'}Restore CiviCRM Menu{/ts}</a>'{literal}, '', 'none', {expires: 10000});
158 $('#crm-restore-menu')
159 .button({icons: {primary: 'ui-icon-arrowreturnthick-1-w'}})
160 .click(function(e) {
161 e.preventDefault();
162 alert.close();
163 $('#civicrm-menu').slideDown();
164 })
165 .parent().css('text-align', 'center').find('.ui-button-text').css({'padding-top': '4px', 'padding-bottom': '4px'})
166 ;
167 }
168 e.preventDefault();
169 });
170 $('.crm-quickSearchField').click(function() {
171 var label = $(this).text();
172 var value = $('input', this).val();
173 // These fields are not supported by advanced search
174 if (value === 'first_name' || value === 'last_name') {
175 value = 'sort_name';
176 }
177 $('#sort_name_navigation').attr({name: value, placeholder: label}).focus();
178 });
179 // redirect to view page if there is only one contact
180 $('#id_search_block').on('submit', function() {
181 var $menu = $('#sort_name_navigation').autocomplete('widget');
182 if ($('li.ui-menu-item', $menu).length === 1) {
183 var cid = $('li.ui-menu-item', $menu).data('ui-autocomplete-item').value;
184 if (cid > 0) {
185 document.location = CRM.url('civicrm/contact/view', {reset: 1, cid: cid});
186 return false;
187 }
188 }
189 });
190 // Close menu after selecting an item
191 $('#root-menu-div').on('click', 'a', $.Menu.closeAll);
192 });
193 $('#civicrm-menu').menuBar({arrowSrc: CRM.config.resourceBase + 'packages/jquery/css/images/arrow.png'});
194 })(CRM.$);{/literal}