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 | <div id="menu-container" style="display:none;"> | |
27 | <ul id="civicrm-menu"> | |
28 | {if call_user_func(array('CRM_Core_Permission','giveMeAllACLs'))} | |
29 | <li id="crm-qsearch" class="menumain crm-link-home"> | |
81aa6678 | 30 | <form action="{crmURL p='civicrm/contact/search/advanced' h=0 }" name="search_block" id="id_search_block" method="post" onsubmit="getSearchURLValue( );"> |
6a488035 TO |
31 | <div id="quickSearch"> |
32 | <input type="text" class="form-text" id="sort_name_navigation" placeholder="{ts}Find Contacts{/ts}" name="sort_name" style="width: 12em;" /> | |
81aa6678 CW |
33 | <input type="text" id="sort_contact_id" style="display: none" /> |
34 | <input type="hidden" name="hidden_location" value="1" /> | |
6a488035 | 35 | <input type="hidden" name="qfKey" value="{crmKey name='CRM_Contact_Controller_Search' addSequence=1}" /> |
81aa6678 | 36 | <div style="height:1px; overflow:hidden;"><input type="submit" value="{ts}Go{/ts}" name="_qf_Advanced_refresh" class="form-submit default" /></div> |
6a488035 TO |
37 | </div> |
38 | </form> | |
39 | <ul> | |
40 | <li><label class="crm-quickSearchField"><input type="radio" checked="" data-tablename="cc" checked="checked" value="" name="quickSearchField">{ts}Name/Email{/ts}</label></li> | |
41 | <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="id" name="quickSearchField">{ts}CiviCRM 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 | ||
54 | {/if} | |
55 | {$navigation} | |
56 | </ul> | |
57 | </div> | |
58 | ||
59 | {literal} | |
60 | <script type="text/javascript"> | |
81aa6678 | 61 | cj(function( ) { |
6a488035 TO |
62 | cj("#civicrm-menu >li").each(function(i){ |
63 | cj(this).attr("tabIndex",i+2); | |
64 | }); | |
6a488035 TO |
65 | |
66 | var contactUrl = {/literal}"{crmURL p='civicrm/ajax/rest' q='className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=navigation' h=0 }"{literal}; | |
67 | ||
68 | cj( '#sort_name_navigation' ).autocomplete( contactUrl, { | |
69 | width: 200, | |
70 | selectFirst: false, | |
71 | minChars: 1, | |
72 | matchContains: true, | |
73 | delay: 400, | |
74 | max: CRM.config.search_autocomplete_count, | |
75 | extraParams:{ | |
76 | limit: CRM.config.search_autocomplete_count, | |
77 | fieldName:function () { | |
78 | return cj('input[name=quickSearchField]:checked').val(); | |
79 | }, | |
80 | tableName:function () { | |
81 | return cj('input[name=quickSearchField]:checked').attr("data-tablename"); | |
82 | } | |
83 | } | |
84 | }).result(function(event, data, formatted) { | |
81aa6678 | 85 | document.location = CRM.url('civicrm/contact/view', {reset: 1, cid: data[1]}); |
6a488035 TO |
86 | return false; |
87 | }); | |
88 | cj('#sort_name_navigation').keydown(function() { | |
89 | cj.Menu.closeAll(); | |
90 | }); | |
91 | cj('.crm-quickSearchField').click(function() { | |
92 | var label = cj(this).text(); | |
81aa6678 CW |
93 | var value = cj('input', this).val(); |
94 | // These fields are not supported by advanced search | |
95 | if (value === 'first_name' || value === 'last_name') { | |
96 | value = 'sort_name'; | |
97 | } | |
98 | cj('#sort_name_navigation').attr({name: value, placeholder: label}).flushCache().focus(); | |
6a488035 TO |
99 | }); |
100 | }); | |
101 | function getSearchURLValue( ) | |
102 | { | |
103 | var input = cj('#sort_name_navigation').val(); | |
104 | var contactId = cj( '#sort_contact_id' ).val(); | |
105 | if ( ! contactId || isNaN( contactId ) ) { | |
106 | var sortValue = cj( '#sort_name_navigation' ).val(); | |
107 | if ( sortValue ) { | |
108 | //using xmlhttprequest check if there is only one contact and redirect to view page | |
109 | var dataUrl = {/literal}"{crmURL p='civicrm/ajax/contact' h=0 q='name='}"{literal} + sortValue; | |
110 | ||
111 | var response = cj.ajax({ | |
112 | url: dataUrl, | |
113 | async: false | |
114 | }).responseText; | |
115 | ||
116 | contactId = response; | |
117 | } | |
118 | } | |
119 | ||
120 | if ( contactId && !isNaN(parseInt(contactId)) ) { | |
121 | var url = {/literal}"{crmURL p='civicrm/contact/view' h=0 q='reset=1&cid='}"{literal} + contactId; | |
122 | document.getElementById('id_search_block').action = url; | |
123 | } | |
124 | } | |
735c0c34 | 125 | {/literal}{if $config->userFramework neq 'Joomla'}{literal} |
6a488035 TO |
126 | cj('body').prepend( cj("#menu-container").html() ); |
127 | ||
128 | //Track Scrolling | |
129 | cj(window).scroll( function () { | |
130 | var scroll = document.documentElement.scrollTop || document.body.scrollTop; | |
131 | cj('#civicrm-menu').css({top: "scroll", position: "fixed", top: "0px"}); | |
132 | cj('div.sticky-header').css({ 'top' : "23px", position: "fixed" }); | |
133 | }); | |
134 | ||
135 | if ( cj('#edit-shortcuts').length > 0 ) { | |
136 | cj('#civicrm-menu').css({ 'width': '97%' }); | |
137 | } | |
735c0c34 CW |
138 | {/literal}{else}{* Special menu hacks for Joomla *}{literal} |
139 | cj('div#toolbar-box div.m').html(cj("#menu-container").html()); | |
140 | cj('#civicrm-menu').ready(function() { | |
141 | cj('#root-menu-div .outerbox').css({ 'margin-top': '6px'}); | |
142 | cj('#root-menu-div .outerbox').first().css({ 'margin-top': '20px'}); | |
143 | cj('#root-menu-div .menu-ul li').css({ 'padding-bottom' : '2px', 'margin-top' : '2px' }); | |
144 | cj('img.menu-item-arrow').css({ 'top' : '4px' }); | |
145 | }); | |
146 | {/literal}{/if}{literal} | |
6a488035 TO |
147 | cj('#civicrm-menu').menu( {arrowSrc: CRM.config.resourceBase + 'packages/jquery/css/images/arrow.png'} ); |
148 | </script> | |
149 | {/literal} |