Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
fa938177 | 5 | | Copyright CiviCRM LLC (c) 2004-2016 | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
e203a505 | 25 | *}// http://civicrm.org/licensing |
3a8e94ac | 26 | {capture assign=menuMarkup}{strip} |
76fd69ba | 27 | <ul id="civicrm-menu"> |
3a8e94ac | 28 | {if call_user_func(array('CRM_Core_Permission','giveMeAllACLs'))} |
15a59011 | 29 | <li id="crm-qsearch" class="menumain"> |
3a8e94ac CW |
30 | <form action="{crmURL p='civicrm/contact/search/advanced' h=0 }" name="search_block" id="id_search_block" method="post"> |
31 | <div id="quickSearch"> | |
567b9207 | 32 | <input type="text" class="form-text" id="sort_name_navigation" placeholder="{ts}Contacts{/ts}" name="sort_name" style="width: 6em;" /> |
3a8e94ac CW |
33 | <input type="text" id="sort_contact_id" style="display: none" /> |
34 | <input type="hidden" name="hidden_location" value="1" /> | |
c3bcf6ba | 35 | <input type="hidden" name="qfKey" value="" /> |
97e557d7 | 36 | <div style="height:1px; overflow:hidden;"><input type="submit" value="{ts}Go{/ts}" name="_qf_Advanced_refresh" class="crm-form-submit default" /></div> |
3a8e94ac CW |
37 | </div> |
38 | </form> | |
39 | <ul> | |
7958c588 | 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> |
d79be26c | 41 | <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="contact_id" name="quickSearchField">{ts}Contact ID{/ts}</label></li> |
3a8e94ac CW |
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> | |
51b81901 | 56 | {/strip}{/capture}// <script> Generated {$smarty.now|date_format:'%d %b %Y %H:%M:%S'} |
e203a505 CW |
57 | {literal} |
58 | (function($) { | |
59 | var menuMarkup = {/literal}{$menuMarkup|@json_encode}; | |
60 | {if $config->userFramework neq 'Joomla'}{literal} | |
15a59011 | 61 | $('body').append(menuMarkup); |
6a488035 | 62 | |
e203a505 CW |
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 | }); | |
e0f7ceee | 69 | |
e203a505 CW |
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} | |
c3bcf6ba CW |
83 | // CRM-15493 get the current qfKey |
84 | $("input[name=qfKey]", "#quickSearch").val($('#civicrm-navigation-menu').data('qfkey')); | |
85 | ||
e203a505 CW |
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 | }); | |
6a488035 | 93 | |
7cb72342 | 94 | $('#sort_name_navigation') |
49e5c704 | 95 | .autocomplete({ |
7cb72342 CW |
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 = []; | |
106bb5da | 106 | if (result.values.length > 0) { |
15220e8f | 107 | $('#sort_name_navigation').autocomplete('widget').menu('option', 'disabled', false); |
7cb72342 CW |
108 | $.each(result.values, function(k, v) { |
109 | ret.push({value: v.id, label: v.data}); | |
106bb5da EE |
110 | }); |
111 | } else { | |
15220e8f | 112 | $('#sort_name_navigation').autocomplete('widget').menu('option', 'disabled', true); |
568eb71b | 113 | ret.push({value: '0', label: {/literal}'{ts escape='js'}None found.{/ts}'{literal}}); |
7cb72342 CW |
114 | } |
115 | response(ret); | |
116 | }) | |
e203a505 | 117 | }, |
567b9207 | 118 | focus: function (event, ui) { |
5e0a1798 | 119 | return false; |
31037a42 | 120 | }, |
7cb72342 | 121 | select: function (event, ui) { |
106bb5da EE |
122 | if (ui.item.value > 0) { |
123 | document.location = CRM.url('civicrm/contact/view', {reset: 1, cid: ui.item.value}); | |
124 | } | |
e203a505 | 125 | return false; |
3b4e4823 CW |
126 | }, |
127 | create: function() { | |
128 | // Place menu in front | |
15220e8f CW |
129 | $(this).autocomplete('widget') |
130 | .addClass('crm-quickSearch-results') | |
131 | .css('z-index', $('#civicrm-menu').css('z-index')); | |
7cb72342 CW |
132 | } |
133 | }) | |
134 | .keydown(function() { | |
135 | $.Menu.closeAll(); | |
567b9207 CW |
136 | }) |
137 | .on('focus', function() { | |
62bed82d | 138 | setQuickSearchValue(); |
567b9207 CW |
139 | if ($(this).attr('style').indexOf('14em') < 0) { |
140 | $(this).animate({width: '14em'}); | |
141 | } | |
142 | }) | |
143 | .on('blur', function() { | |
144 | // Shrink if no input and menu is not open | |
145 | if (!$(this).val().length && $(this).attr('style').indexOf('6em') < 0 && !$('.crm-quickSearchField:visible', '#root-menu-div').length) { | |
146 | $(this).animate({width: '6em'}); | |
147 | } | |
7cb72342 | 148 | }); |
877e5889 | 149 | $('.crm-hidemenu').click(function(e) { |
fb9daa75 | 150 | $('#civicrm-menu').slideUp(); |
3c7172b9 | 151 | if ($('#crm-notification-container').length) { |
877e5889 CW |
152 | 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}); |
153 | $('#crm-restore-menu') | |
f4b168fd | 154 | .button({icons: {primary: 'fa-undo'}}) |
877e5889 CW |
155 | .click(function(e) { |
156 | e.preventDefault(); | |
157 | alert.close(); | |
158 | $('#civicrm-menu').slideDown(); | |
159 | }) | |
160 | .parent().css('text-align', 'center').find('.ui-button-text').css({'padding-top': '4px', 'padding-bottom': '4px'}) | |
161 | ; | |
3c7172b9 | 162 | } |
877e5889 | 163 | e.preventDefault(); |
fb9daa75 | 164 | }); |
62bed82d CW |
165 | function setQuickSearchValue() { |
166 | var $selection = $('.crm-quickSearchField input:checked'), | |
167 | label = $selection.parent().text(), | |
168 | value = $selection.val(); | |
e203a505 | 169 | // These fields are not supported by advanced search |
d393c5fe | 170 | if (!value || value === 'first_name' || value === 'last_name') { |
e203a505 | 171 | value = 'sort_name'; |
3a8e94ac | 172 | } |
62bed82d CW |
173 | $('#sort_name_navigation').attr({name: value, placeholder: label}); |
174 | } | |
175 | $('.crm-quickSearchField').click(function() { | |
176 | setQuickSearchValue(); | |
177 | $('#sort_name_navigation').focus(); | |
e203a505 | 178 | }); |
62bed82d CW |
179 | // Set & retrieve default value |
180 | if (window.localStorage) { | |
181 | $('.crm-quickSearchField').click(function() { | |
182 | localStorage.quickSearchField = $('input', this).val(); | |
183 | }); | |
184 | if (localStorage.quickSearchField) { | |
185 | $('.crm-quickSearchField input[value=' + localStorage.quickSearchField + ']').prop('checked', true); | |
186 | } | |
187 | } | |
03c752c4 | 188 | // redirect to view page if there is only one contact |
e203a505 | 189 | $('#id_search_block').on('submit', function() { |
49e5c704 | 190 | var $menu = $('#sort_name_navigation').autocomplete('widget'); |
03c752c4 CW |
191 | if ($('li.ui-menu-item', $menu).length === 1) { |
192 | var cid = $('li.ui-menu-item', $menu).data('ui-autocomplete-item').value; | |
1a9a2abf SL |
193 | if (cid > 0) { |
194 | document.location = CRM.url('civicrm/contact/view', {reset: 1, cid: cid}); | |
195 | return false; | |
196 | } | |
3a8e94ac | 197 | } |
e203a505 | 198 | }); |
75f04e33 CW |
199 | // Close menu after selecting an item |
200 | $('#root-menu-div').on('click', 'a', $.Menu.closeAll); | |
e203a505 | 201 | }); |
fb9daa75 | 202 | $('#civicrm-menu').menuBar({arrowSrc: CRM.config.resourceBase + 'packages/jquery/css/images/arrow.png'}); |
3cc60a06 | 203 | })(CRM.$);{/literal} |