1/** 2 * @file 3 * Custom theme behaviors: selectâpicker styling and siteâwide enhancements. 4 */ 5(function (Drupal, once, $) { 6 'use strict'; 7 8 /** 9 * Applies bootstrap-select styling to specific Views forms. 10 */ 11 Drupal.behaviors.akSelectStyles = { 12 attach: function (context, settings) { 13 // 1) Reports form. 14 once('ak-select-reports', '#views-exposed-form-ak-reports-reports', context) 15 .forEach(function (formEl) { 16 $('select', formEl).addClass('selectpicker'); 17 }); 18 19 // 2) Latestâhome articles form. 20 once('ak-select-articles', '#views-exposed-form-ak-articles-latest-home', context) 21 .forEach(function (formEl) { 22 $('select', formEl).addClass('selectpicker'); 23 }); 24 } 25 }; 26 27 /** 28 * All the rest of your siteâwide jQuery tweaks run once per page load. 29 */ 30 Drupal.behaviors.akSiteEnhancements = { 31 attach: function (context, settings) { 32 once('ak-site-enhancements', 'body', context).forEach(function () { 33 // â Language switcher URLs 34 var currentURL = window.location.href; 35 var arLink, enLink; 36 if (currentURL.includes('/en/')) { 37 arLink = currentURL.replace('/en/', '/ar/'); 38 enLink = currentURL; 39 } else { 40 arLink = currentURL; 41 enLink = currentURL.replace('/ar/', '/en/'); 42 } 43 44 // â Reports form conditional fields 45 function reportsForm(val) { 46 var $form = $('#views-exposed-form-ak-reports-reports'); 47 switch (val) { 48 case '7': 49 $form.find('.form-item-body, .form-item-country').show(); 50 break; 51 case '40': 52 $form.find('.form-item-body select').val('All').end() 53 .find('.form-item-body').hide() 54 .end().find('.form-item-country').show(); 55 break; 56 case '39': 57 $form.find('.form-item-body select').val('All').end() 58 .find('.form-item-body').hide() 59 .end().find('.form-item-country select').val('All').end() 60 .find('.form-item-country').hide(); 61 break; 62 default: 63 if ($form.find('.form-item-body select').val() === 'All') { 64 $form.find('.form-item-body').hide(); 65 } 66 if ($form.find('.form-item-country select').val() === 'All') { 67 $form.find('.form-item-country').hide(); 68 } 69 break; 70 } 71 } 72 73 // Initialize on load 74 var initVal = $('#views-exposed-form-ak-reports-reports .form-item-type select').val(); 75 reportsForm(initVal); 76 77 // Attach change handler once 78 once('ak-select-doc-type', '#views-exposed-form-ak-reports-reports .form-item-type select', context) 79 .forEach(function (el) { 80 $(el).on('change', function (e) { 81 reportsForm(e.target.value); 82 }); 83 }); 84 85 // â Gallery thumbnail logic 86 var gallercount = $('.field-gallery-thumbs > a').length; 87 if (gallercount === 1) { 88 $('.case-slider .field-gallery .field-gallery-thumbs') 89 .css('display', 'none') 90 .find('a:first').css('display', 'none'); 91 } 92 93 // â Hide empty âmore countryâ block 94 if (!$.trim($('.view-more-country-for-article-landing-page').html())) { 95 $('.block-views-blockmore-country-for-article-landing-page-block-1').hide(); 96 } 97 98 // â Append âLatest Updateâ to region headings 99 ['.latest_gulf', '.latest_Mashreq', '.latest_Maghreb'].forEach(function (sel) { 100 var $h3 = $(sel + ' .view-content .item-list h3'); 101 $h3.text($h3.text() + ' Latest Update'); 102 }); 103 104 // â Reposition home cases view 105 $('.view-latest-home-cases') 106 .insertBefore('.field--name-dynamic-block-fieldtaxonomy-term-articles-per-country'); 107 108 // â Page header & inserts 109 $('.path-reports .region-header .page-header').text('Latest reports'); 110 $('.taxonomy-term--type-ak-country .view-latest-home-cases') 111 .before('<div class="countreport">Latest Cases</div>'); 112 $('.view-id-ak_reports .view-filters') 113 .before('<div class="searchreport">Search reports</div>'); 114 $('#views-exposed-form-ak-reports-reports .form-item-type .filter-option.pull-left') 115 .text('Type of Report'); 116 117 // â Show report menu on /reports or /contact 118 if ($('body').hasClass('path-reports') || $('body').hasClass('path-contact')) { 119 $('.report_menu').show(); 120 } 121 122 // â Hide AK Events & Campaigns content regions 123 if ($('#block-views-block-ak-events-block-1').length || 124 $('#block-views-block-campaigns-block-1').length) { 125 $('.region-content .page, .middle_cntent').hide(); 126 } 127 128 // â Always hide French switcher 129 $('#block-languageswitcher-3 .fr').hide(); 130 131 // â Country blockâtitle replacement 132 var countryText = $('.field--name-field-ak-countries .field--item').text(); 133 $('.block-views-blockmore-country-for-article-landing-page-block-1 h2.block-title') 134 .text(function () { 135 return $(this).text().replace('Country', countryText); 136 }); 137 $('html[lang=ar] .block-views-blockmore-country-for-article-landing-page-block-1 h2.block-title') 138 .text(function () { 139 return $(this).text() 140 .replace('Country', countryText) 141 .replace('More on', 'اÙÙ Ø²ÙØ¯ عÙ'); 142 }); 143 144 // â Arabicâspecific tweaks 145 if ($('.logo.pull-left').attr('href') === '/ar') { 146 $('.block-views-blockhome-page-report-block-1 .block-title').css('margin-right', '96px'); 147 $('.region-sidebar-report .block-twitter-block .block-title').css('padding-right', '35px'); 148 $('.report_section').addClass('arbic'); 149 $('body').addClass('arbic'); 150 $('.path-reports .region-header .page-header').replaceWith('آخر Ø§ÙØªÙØ§Ø±ÙØ±'); 151 $('.countreport').replaceWith("<div class='countreport'>Ø£ØØ¯Ø« Ø§ÙØØ§ÙØ§Øª</div>"); 152 $(".field--name-dynamic-block-fieldtaxonomy-term-articles-per-country .field--label") 153 .replaceWith("<div class='field--label'>Ø£ØØ¯Ø« Ø§ÙØ£Ø®Ø¨Ø§Ø±</div>"); 154 $("#main-menu-link-contentab9f3aa1-87b8-4543-9208-56a59ca71335 a").text("Ø§ÙØØ§ÙØ§Øª"); 155 $(".contact-message-need-help-form #group-applicant-information .panel-title") 156 .text("Ø¨ÙØ§Ùات Ù ÙØ¯Ù Ø§ÙØ·Ùب"); 157 $(".contact-message-need-help-form .panel-body .help-block") 158 .text("إذا تعرضت Ø£ÙØª Ø£Ù Ø£ØØ¯ ٠عارÙÙ ÙØ§ÙØªÙØ§Ù ØÙÙÙÙ Ø§ÙØ¥ÙساÙÙØ©Ø أ٠إذا ÙÙØª Ù ØØ§Ù ÙØ§ ÙØ£ØØ¯ Ø¶ØØ§Ùا Ø§ÙØªÙا٠ØÙÙÙ Ø§ÙØ¥ÙØ³Ø§ÙØ Ø§ÙØ±Ø¬Ø§Ø¡ Ø§ÙØ¥Ø¬Ø§Ø¨Ø© عÙÙ Ø§ÙØ£Ø³Ø¦ÙØ© Ø§ÙØªØ§ÙÙØ© ÙÙ Ø³Ø§Ø¹Ø¯ØªÙØ§ عÙ٠تÙÙÙ٠٠ا إذا ÙØ§Ù ÙÙ ÙØ³Ø¹Ùا ٠ساعدتÙ"); 159 $(".contact-message-need-help-form #bootstrap-panel--2 .panel-title").text("ÙÙÙØ© Ø§ÙØ¶ØÙØ©"); 160 $(".contact-message-need-help-form #bootstrap-panel--3 .panel-title").text("Ø·Ø¨ÙØ¹Ø© Ø§ÙØ§ÙØªÙØ§Ù"); 161 $(".contact-message-need-help-form .field--type-string .form-item-field-i-0-value .control-label") 162 .text("إذا ÙØ§Ù آخر Ø ÙØ±Ø¬Ù ØªÙØ¯ÙÙ Ø§ÙØªÙاصÙÙ"); 163 $('.maintop.en').hide(); 164 $('.maintop.ar').show(); 165 setTimeout(function () { 166 $(".form-search.form-control") 167 .attr("placeholder", "Ø£Ø¯Ø®Ù Ø§ÙØ¹Ø¨Ø§Ø±Ø§Øª Ø§ÙØªÙ ØªØ±ÙØ¯ Ø§ÙØ¨ØØ« عÙÙØ§."); 168 $('#views-exposed-form-ak-reports-reports .form-type-select .dropdown-menu li:first') 169 .text('- Ø£Ù -'); 170 }, 2000); 171 $('#edit-field-country-target-id option[value="All"]').text('- Ø£Ù -'); 172 $('.path-reports .view-ak-reports .searchreport') 173 .replaceWith("<div class='searchreport'>
173ØªÙØ§Ø±Ùر Ø§ÙØ¨ØØ«</div>"); 174 $('.path-reports #block-mainnavigationarabic').hide(); 175 176 // â Month name translation 177 var month = $('.article-main .date .month').html().trim(); 178 var monthMap = { 179 'January': 'ÙØ§ÙÙÙ Ø§ÙØ«Ø§ÙÙ', 'February': 'Ø´ÙØ± ÙØ¨Ø±Ø§Ùر', 180 'March': '٠ارس', 'April': 'أبرÙÙ', 181 'May': 'ÙØ¯', 'June': 'ÙÙÙÙÙ', 182 'July': 'ÙÙÙÙÙ', 'August': 'أغسطس', 183 'September':'سبت٠بر', 'October': 'Ø´ÙØ± Ø§ÙØªÙبر', 184 'November':'ÙÙÙ٠بر', 'December':'Ø¯ÙØ³Ù بر' 185 }; 186 var monthval = monthMap[month] || 'Ø¯ÙØ³Ù بر'; 187 var day = $('.article-main .date .dat').html(); 188 var year = $('.article-main .date .year').html(); 189 $(".article-main .date.arbic") 190 .html("<span class='month'>" + monthval + "</span> <span class='dat'>" + day + "</span> <span class='year'>" + year + "</span>"); 191 $('.article-main .date.eng').hide(); 192 } 193 194 // â Donation button text 195 $('.comment-comment-form .form-submit').text('Click to Donate'); 196 197 // â Add class for latest news view 198 if ($('.view-latest-news').hasClass('view-id-latest_news')) { 199 $('body').addClass('case_body'); 200 } 201 202 // â Ensure Font Awesome is loaded 203 if (!$('head link[href*="font-awesome"]').length) { 204 $('head').append( 205 '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" type="text/css" />' 206 ); 207 } 208 209 // â Social & date wraps on document pages 210 $('.page-node-type-ak-document .se-block, .page-node-type-ak-document .field--name-field-ak-file') 211 .wrapAll('<div class="document_social"></div>'); 212 $('.page-node-type-ak-document .field--name-field-ak-pub-date, .page-node-type-ak-document .page-header') 213 .wrapAll('<div class="date_title"></div>'); 214 $('.date_title').detach().appendTo('.page-node-type-ak-document .field--name-field-image'); 215 $('.page-node-type-ak-document .date_title .field--name-field-ak-pub-date') 216 .detach().insertBefore('.page-node-type-ak-document .date_title .page-header'); 217 218 // â Wrap taxonomy term regions 219 $('.taxonomy-term--type-ak-country .bs-region--middle, .taxonomy-term--type-ak-country .bs-region--bottom') 220 .wrapAll('<div class="child_merge"></div>'); 221 $('.taxonomy-term--type-ak-country .bs-region--top-left, .taxonomy-term--type-ak-country .bs-region--top-right') 222 .wrapAll('<div class="child_merge_top"></div>'); 223 $('.taxonomy-term--type-ak-topics .field--name-description') 224 .wrapAll('<div class="topic_child"></div>'); 225 $('.taxonomy-term--type-ak-topics .field--name-dynamic-block-fieldtaxonomy-term-by-region-by-topic') 226 .wrapAll('<div class="topic_child_top"></div>'); 227 228 // â Newsletter + map side by side 229 $('#block-newsletter,#block-ak-map').wrapAll('<div class="newsletter-half"></div>'); 230 231 // â Wrap bootstrap panels 232 $('#bootstrap-panel .panel-heading, #bootstrap-panel .panel-body').wrapAll('<div class="human-inner"></div>'); 233 $('#bootstrap-panel--2 .panel-heading, #bootstrap-panel--2 .panel-body').wrapAll('<div class="human-inner"></div>'); 234 $('#bootstrap-panel--3 .panel-heading, #bootstrap-panel--3 .panel-body').wrapAll('<div class="human-inner"></div>'); 235 $('#bootstrap-panel--4 .panel-heading, #bootstrap-panel--4 .panel-body').wrapAll('<div class="human-inner"></div>'); 236 $('#bootstrap-panel--5 .panel-heading, #bootstrap-panel--5 .panel-body').wrapAll('<div class="human-inner"></div>'); 237 238 // â Wrap country email block 239 $('.col-sm-3.bs-region.bs-region--top-right .field--type-email') 240 .wrapAll('<div class="country_right_inner_b"></div>'); 241 242 // â Move footer logo before newsletter block 243 $('#block-footerlogo').detach().insertBefore('#block-newsletter'); 244 245 // â Sort country dropdowns alphabetically 246 $('#edit-field-country-target-id').append( 247 $('#edit-field-country-target-id option').remove().sort(function (a, b) { 248 return $(a).text() > $(b).text() ? 1 : -1; 249 }) 250 ); 251 $('#edit-field-country-target-id option[value="All"]').prop('selected', true); 252 253 $('#edit-field-ak-country-target-id').append( 254 $('#edit-field-ak-country-target-id option').remove().sort(function (a, b) { 255 return $(a).text() > $(b).text() ? 1 : -1; 256 }) 257 ); 258 $('#edit-field-ak-country-target-id option[value="All"]').prop('selected', true); 259 260 // â Translate âAllâ in Arabic 261 $('html[lang=ar] option[value="All"]').html('- Ø£Ù -'); 262 263 // â Translate contact/need_help form panels 264 $('html[lang="ar"] #trans-applicant-information .panel-title') 265 .text('٠عÙÙ٠ات Ù ÙØ¯Ù Ø§ÙØ·Ùب'); 266 $('html[lang="ar"] #trans-applicant-information--description') 267 .text('إذا ÙÙØª Ø£ÙØª Ø£Ù ÙØ±Ùب٠ضØÙØ© ÙØ§ÙØªÙØ§Ù ØÙÙÙ Ø§ÙØ¥ÙØ³Ø§Ù Ø Ø£Ù Ø¥Ø°Ø§ ÙÙØª Ù ØØ§Ù ÙÙØ§ ÙØ¶ØÙØ© Ø§ÙØªÙا٠ØÙÙÙ Ø§ÙØ¥ÙØ³Ø§Ù Ø ÙÙØ±Ø¬Ù Ø§ÙØ¥Ø¬Ø§Ø¨Ø© عÙÙ Ø§ÙØ£Ø³Ø¦ÙØ© Ø§ÙØªØ§ÙÙØ© ÙÙ Ø³Ø§Ø¹Ø¯ØªÙØ§ Ù٠تÙÙÙ٠٠ا إذا ÙØ§Ù Ø¨Ø¥Ù ÙØ§ÙÙØ§ ØªÙØ¯Ù٠اÙ٠ساعدة ÙÙ.'); 268 $('html[lang="ar"] #trans-identity-of-the-victim .panel-title').text('ÙÙÙØ© Ø§ÙØ¶ØÙØ©'); 269 $('html[lang="ar"] #trans-nature-of-the-violation .panel-title').text('Ø·Ø¨ÙØ¹Ø© Ø§ÙØ¥ÙØªÙØ§Ù'); 270 }); 271 } 272 }; 273 274})(Drupal, once, jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.