Merge in 5.11
[civicrm-core.git] / js / crm.wordpress.js
1 // http://civicrm.org/licensing
2 CRM.$(function($) {
3 $(document)
4 .on('dialogopen', function(e) {
5 // Make admin bar hide behind popup windows
6 $('#adminmenuwrap').css('z-index', '100');
7 })
8 .on('dialogclose', function(e) {
9 if ($('.ui-dialog-content:visible').not(e.target).length < 1) {
10 // Restore admin bar position
11 $('#adminmenuwrap').css('z-index', '');
12 }
13 })
14 .on('crmWysiwygCreate', function(e, type, editor) {
15 if (type === 'ckeditor') {
16 editor.on('maximize', function(e) {
17 $('#wpadminbar').toggle(e.data === 2);
18 });
19 }
20 });
21 // Prevent screen reader shortcuts from changing the document hash and breaking angular routes
22 $('a.screen-reader-shortcut').click(function() {
23 var href = $(this).attr('href');
24 // Show toolbar if hidden
25 if (href === '#wp-toolbar' && CRM.menubar.position === 'over-cms-menu') {
26 CRM.menubar.togglePosition(false);
27 }
28 $(href).focus();
29 return false;
30 });
31 $('<a href="#crm-qsearch-input" class="screen-reader-shortcut">' + ts("Open CiviCRM Menu") + '</a>')
32 .prependTo('#adminmenumain')
33 .click(function() {
34 CRM.menubar.open('Home');
35 return false;
36 });
37 });