1(function ($) { 2 3 Drupal.behaviors.manage_society = { 4 attach: function (context,settings) { 5 6 // Check Facebook iFrame loads and show fallback if not 7 /* if ($('#fb_if').length) { 8 var iframe = document.getElementById('fb_if'); 9 var fbFallback = '<span class="fa fa-facebook" style="margin-right:2rem"></span><a href="https://www.facebook.com/TheArtsSociety/">Follow The Arts Society on Facebook</a>'; 10 if (!iframe.contentDocument) { 11 $('#fb_if').replaceWith(fbFallback); 12 } else if (iframe.contentDocument.location.href == "about:blank") { 13 $('#fb_if').replaceWith(fbFallback); 14 } 15 } */ 16 17 // Updating Manage My Society block links. 18 $('.view-display-id-manage_my_society_block .views-row .society-webpage').each(function(index) { 19 id = $(this).attr('id'); 20 var relationship_found = false; 21 var member_found = false; 22 // Comparing links with desired society contact ids. 23 if (typeof Drupal.settings.nadfas_manage_society != 'undefined') { 24 $.each(Drupal.settings.nadfas_manage_society, function(index, value){ 25 // Society relationships check. 26 if (index == 'society-relationship-' + value && id == value) { 27 relationship_found = true; 28 } 29 // Society Member relationship check. 30 if (index == 'society-member-' + value && id == value) { 31 member_found = true; 32 } 33 }); 34 } 35 // Hide Society Webpage, Events and News. 36 if (relationship_found == false) { 37 $('.society-webpage-' + id).hide(); 38 $('.society-webpage-events-' + id).hide(); 39 $('.society-webpage-news-' + id).hide(); 40 } 41 // Member Relationship not found hide Society Members, Details and Activities links. 42 if (member_found == false) { 43 $('.society-members-' + id).hide(); 44 $('.society-details-' + id).hide(); 45 $('.society-activities-' + id).hide(); 46 } 47 }); 48 49 // Makes category search block sticky. 50 var blockChooseCategory = $('.block-choose-another-category', context); 51 blockChooseCategory.addClass('categories-fly-fixed'); 52 53 // Set a min height to the region to prevent choppy scrolling. 54 var $blockRegionBottom = $('.page-search-category .region-bottom-region, .node-type-resource .region-bottom-region, .page-search-resources .region-bottom-region', context); 55 $blockRegionBottom.css({'min-height' : blockChooseCategory.outerHeight() }); 56 57 // Fix left margin on position fixed for wide screens. 58 var windowWidth = $(window, context).width(); 59 if(windowWidth > 1920){ 60 blockChooseCategory.css({ 61 'left': (windowWidth - 1920) / 2, 62 }) 63 } 64 65 // Scroll function implementation. 66 $(window, context).scroll(function() { 67 if($(window, context).scrollTop() + $(window, context).height() > $(document, context).height() - 200) { 68 blockChooseCategory.removeClass('categories-fly-fixed'); 69 } else { 70 blockChooseCategory.addClass('categories-fly-fixed'); 71 } 72 }); 73 74 // Add accordion functionality. 75 var chevronArrow = $('.choose-another-category-title i', context); 76 $('.choose-another-category-accordion', context).click(function() { 77 $('.choose-another-category', context).slideToggle("slow", function() { 78 $blockRegionBottom.css({'min-height' : blockChooseCategory.outerHeight() }); 79 }); 80 if(chevronArrow.hasClass('fa-chevron-left')){ 81 chevronArrow.removeClass('fa-chevron-left'); 82 chevronArrow.addClass('fa-chevron-down'); 83 }else{ 84 chevronArrow.removeClass('fa-chevron-down'); 85 chevronArrow.addClass('fa-chevron-left'); 86 } 87 return false; 88 }); 89 } 90 }; 91})(jQuery); 92 93/* Civi stuff */ 94CRM.$(function($) { 95 96 $('div.member_search_wrapper #member_search_button').click(function() { 97 let searchText = $('div.member_search_wrapper input[name="member_search"]').val(); 98 if (searchText) { 99 window.location = '/' + CRM.vars.buttonSearch.buttonSearchlink + '?search=' + searchText; 100 } 101 }); 102 103 // Date in YYYY-MM-DD format 104 var d = new Date(); 105 var today = d.getFullYear() + "-" + (d.getMonth() + 1 ) + "-" + d.getDate(); 106 var yestrDate = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + (d.getDate() - 1); 107 // Datatable stuff 108 $('#society-activities-table').DataTable({ 109 retrieve: true, 110 "order": [[ 3, 'desc' ]], 111 }); 112 113 $('#society-arts-volunteering-project-table').DataTable({ 114 retrieve: true, 115 "order": [[ 3, 'desc' ]], 116 'columns': [ 117 null, 118 null, 119 null, 120 null, 121 ], 122 }); 123 124 $('#society-waiting-members-table').DataTable({ 125 retrieve: true, 126 stateSave: true, 127 'columns': [ 128 null, 129 null, 130 {className: "nowrap"} 131 ], 132 "order": [[ 1, 'asc' ], [ 0, 'asc' ]], 133 "drawCallback": function( settings ) { 134 135 if (CRM.vars) { 136 $.each(CRM.vars.relChange.relChange, function (key, value) { 137 // Convert to member 138 139 $("#addmember-" + value.rcontA + "-" + value.relID).on('click', function (e) { 140 e.preventDefault(); 141 CRM.confirm({ 142 width: 400, 143 title: ts('Are you sure?'),
144 message: ts('You are about to move a contact from Waiting List to Member. Please click' + 145 ' "Continue" to proceed.') 146 }) 147 .on('crmConfirm:yes', function () { 148 // Removing current Waiting Member relationship 149 CRM.api3('Relationship', 'create', { 150 "id": value.relID, 151 "contact_id_a": value.rcontA, 152 "contact_id_b": value.rcontB, 153 "relationship_type_id": value.rtypeID, 154 "end_date": yestrDate, 155 "is_permission_b_a": 0, 156 "is_permission_a_b": 0, 157 "is_active": 0 158 }), 159 // Add new Relationship 160 CRM.api3('Relationship', 'create', { 161 // "id": value.relID, 162 "contact_id_a": value.rcontA, 163 "contact_id_b": value.rcontB, 164 "relationship_type_id": 4, 165 "start_date": today, 166 "is_permission_b_a": 1, 167 "is_permission_a_b": 0, 168 "is_active": 1 169 }).done(function (result) { 170 //console.log(result); 171 var rid = result['id']; 172 if (result['is_error'] == 0) { 173 CRM.status(result.values[rid]['display_name'] + ' was successfully added as a Member!\n Refreshing page .. ', 'Success', 'success'); 174 //CRM.refreshParent; 175 location.reload(); 176 } 177 if (result['is_error'] == 1) { 178 CRM.status(result['error_message'], 'error', 'error'); 179 // console.log(result); 180 } 181 }); 182 }) 183 .on('crmConfirm:no', function () { 184 CRM.status('Cancelled', 'info'); 185 }) 186 // e.off(); 187 }); 188 189 190 // Remove from a Waiting List 191 $("#removefromwaiting-" + value.rcontA + "-" + value.relID).on('click', function (e) { 192 e.preventDefault(); 193 CRM.confirm({ 194 width: 400, 195 title: ts('Are you sure?'), 196 message: ts('You are about to remove a contact from Waiting List. Please click "Continue"' + 197 ' to proceed.') 198 }) 199 .on('crmConfirm:yes', function () { 200 // Removing current Waiting Member relationship 201 CRM.api3('Relationship', 'create', { 202 "id": value.relID, 203 "contact_id_a": value.rcontA, 204 "contact_id_b": value.rcontB, 205 "relationship_type_id": value.rtypeID, 206 "end_date": yestrDate, 207 "is_permission_b_a": 0, 208 "is_permission_a_b": 0, 209 "is_active": 0 210 }).done(function (result) { 211 //console.log(result); 212 //return;
213 var rid = result['id']; 214 if (result['is_error'] == 0) { 215 CRM.status(result.values[rid]['display_name'] + ' was successfully removed from a Waiting List.\n Refreshing page .. ', 'Success', 'success'); 216 //CRM.refreshParent; 217 location.reload(); 218 } 219 if (result['is_error'] == 1) { 220 CRM.status(result['error_message'], 'error', 'error'); 221 // console.log(result); 222 } 223 }); 224 }) 225 .on('crmConfirm:no', function () { 226 CRM.status('Cancelled', 'info'); 227 }) 228 e.off(); 229 }); 230 }); 231 } 232 //}); 233 } 234 }); 235 236// Separate Committee table 237 $('#society-committee-members-table').DataTable({ 238 retrieve: true, 239 stateSave: true, 240 'columns': [ 241 null, 242 null, 243 {className: "nowrap"} 244 ], 245 "drawCallback": function( settings ) { 246 // Check if variables came from php module aren't empty 247 if (CRM.vars) { 248 $.each(CRM.vars.relChange.relChange, function (key, value) { 249 $("#resign-committee-" + value.rcontA + "-" + value.relID).on('click', function (e) { 250 e.preventDefault(); 251 CRM.api3('Relationship', 'getcount', { 252 "contact_id_a": value.rcontA, 253 "is_active": 1, 254 }).done(function (result) { 255 if (result.result > 1) { 256 rc1 = 1; 257 } 258 if (result.result <= 1) { 259 rc1 = 0; 260 } 261 }); 262 CRM.confirm({ 263 width: 400, 264 title: ts('Are you sure?'), 265 message: ts('You are about to remove a ' 266 + value.rname + ' relation between ' 267 + value.iname + ' member and ' + value.oname + '.' 268 + 'Please click "OK" to proceed.') 269 }) 270 .on('crmConfirm:yes', function () { 271 CRM.api3('Contact', 'create', { 272 "contact_type": "Individual", 273 "id": value.rcontA, 274 "custom_197": rc1, 275 // Relationships part 276 'api.Relationship.create': { 277 "id": value.relID, 278 "contact_id_a": value.rcontA, 279 "contact_id_b": value.rcontB, 280 "relationship_type_id": value.rtypeID, 281 "end_date": today, 282 "is_permission_b_a": 0, 283 "is_permission_a_b": 0, 284 "is_active": 0 285 }, 286 }).done(function (result) { 287 //console.log(result); 288 var rid = result['id']; 289 if (result['is_error'] == 0) { 290 CRM.status(result.values[rid]['display_name'] + ' was successfully resigned!<br>Refreshing page..', 'Success', 'success'); 291 location.reload(); 292 } 293 if (result['is_error'] == 1) { 294 CRM.status(result['error_message'], 'error', 'error'); 295 } 296 } 297 ); 298 }) 299 .on('crmConfirm:no', function () { 300 CRM.status('Cancelled', 'info'); 301 }); 302 }); 303 }) 304 } 305 } 306 }); 307 308 309 $('table.society-display').DataTable({ 310 retrieve: true, 311 stateSave: true, 312 'columns': [ 313 null, 314 null, 315 {className: "nowrap"} 316 ], 317 "drawCallback": function( settings ) { 318 // Check if variables came from php module aren't empty 319 if (CRM.vars) { 320 $.each(CRM.vars.relChange.relChange, function (key, value) { 321 $("#resign-" + value.rcontA + "-" + value.relID).off('click').on('click', function (e) { 322 e.preventDefault(); 323 CRM.api3('Relationship', 'getcount', { 324 "contact_id_a": value.rcontA, 325 "is_active": 1, 326 }).done(function (result) { 327 if (result.result > 1) { 328 rc1 = 1; 329 } 330 if (result.result <= 1) { 331 rc1 = 0; 332 } 333 }); 334 335// Get Resignation Reason custom field values list 336 CRM.api3('Contact', 'getoptions', { 337 "field": "custom_1141" 338 }).done(function (result) { 339 str = ''; 340 $.each (result['values'], function (key, value) { 341 str = str + '<input type="radio" id="' + value.replace(/\s/g, '-') + '" name="resignationReason" value="' 342 + key + '">' + '<label for="' + value.replace(/\s/g, '-') + '">'+ value 343 + '</label><br>' 344 }); 345 resReason(str); 346 }); 347 348 function resReason(d) { 349 CRM.confirm({ 350 width: 400, 351 title: ts('Are you sure?'),
352 message: ts('You are about to remove a ' 353 + value.rname + ' relation between ' 354 + value.iname + ' member and ' + value.oname + '.' 355 + '<br><br><u>Please select a reason below:</u>' 356 + '<form id="resReason" style="margin: 1rem 2rem;">' 357 + d 358 + '</form>' 359 + 'Please click "OK" to proceed.') 360 }) 361 .on('crmConfirm:yes', function () { 362 CRM.api3('Contact', 'create', { 363 "contact_type": "Individual", 364 "id": value.rcontA, 365 "custom_197": rc1, 366 "custom_1141": $("#resReason input[type='radio']:checked").val(), 367 // Relationships part 368 'api.Relationship.create': { 369 "id": value.relID, 370 "contact_id_a": value.rcontA, 371 "contact_id_b": value.rcontB, 372 "relationship_type_id": value.rtypeID, 373 "end_date": today, 374 "is_permission_b_a": 0, 375 "is_permission_a_b": 0, 376 "is_active": 0 377 }, 378 }).done(function (result) { 379 //console.log(result); 380 var rid = result['id']; 381 if (result['is_error'] == 0) { 382 CRM.status(result.values[rid]['display_name'] + ' was successfully resigned!<br>Refreshing page..', 'Success', 'success'); 383 //CRM.refreshParent; 384 location.reload(); 385 } 386 if (result['is_error'] == 1) { 387 CRM.status(result['error_message'], 'error', 'error'); 388 } 389 } 390 ); 391 }) 392 .on('crmConfirm:no', function () { 393 CRM.status('Cancelled', 'info'); 394 // location.reload(); 395 }); 396 //e.off(); 397 } //resReason close 398 }); 399 // Decease 400 $("#decease-" + value.rcontA + "-" + value.relID).on('click', function (e) { 401 e.preventDefault(); 402 CRM.confirm({ 403 width: 400, 404 title: ts('Are you sure?'), 405 message: ts('You are about to remove a member from your list who has died. ' + 406 'Please click "Continue" to proceed.') 407 }) 408 .on('crmConfirm:yes', function () { 409 CRM.api3('Contact', 'create', { 410 "contact_type": "Individual", 411 "id": value.rcontA, 412 "is_deceased": 1, 413 "deceased_date": yestrDate, 414 "custom_197": 0, 415 // Relationships part 416 'api.Relationship.create': { 417 "id": value.relID, 418 "contact_id_a": value.rcontA, 419 "contact_id_b": value.rcontB, 420 "relationship_type_id": value.rtypeID, 421 "end_date": yestrDate, 422 "is_permission_b_a": 0, 423 "is_permission_a_b": 0, 424 "is_active": 0 425 }, 426 }).done(function (result) { 427 var rid = result['id']; 428 if (result['is_error'] == 0) { 429 CRM.status(result.values[rid]['display_name'] + ' was sucessfully deceised!\n Refreshing page .. ', 'Success', 'success' ); 430 //CRM.refreshParent; 431 location.reload(); 432 } 433 if (result['is_error'] == 1) { 434 CRM.status(result['error_message'], 'error', 'error'); 435 } 436 }); 437 }) 438 .on('crmConfirm:no', function () { 439 CRM.status('Cancelled', 'info'); 440 }) 441 }); 442 // the end 443 }) 444 } 445 } 446 }); 447 448 $('.page-manage-my-society #block-system-main').on('click', 'a.societymemberedit', CRM.popup); 449 $('.page-manage-my-society #block-system-main').on('click', 'a.viewmember', CRM.popup); 450 $('.page-manage-my-society #block-system-main').on('click', 'a.waitinglist-member-edit', CRM.popup); 451 $('.page-manage-my-society #block-system-main').on('click', 'a.viewwaiting', CRM.popup); 452 $('.page-user-manage-my-society .view-manage-my-society').on('click', 'a.mms-society-details', CRM.popup); 453 $('.page-manage-my-society #block-system-main') 454 .on('click', 'a.add_new_member', CRM.popup) 455 .on('crmPopupFormSuccess', 'a.add_new_member', function() { 456 CRM.alert= function() {}; 457 CRM.status('Success! Please wait a second, refreshing a corresponded table', 'Success', 'info' ); 458 location.reload(true); 459 }); 460 461 $('.page-manage-my-society #block-system-main') 462 .on('click', 'a.add_waiting_member', CRM.popup) 463 .on('crmPopupFormSuccess', 'a.add_waiting_member', function() { 464 CRM.alert= function() {}; 465 CRM.status('Success! Please wait a second, refreshing a corresponded table', 'Success', 'success' ); 466 location.reload(true); 467 }); 468 469 $('.page-manage-my-society #block-system-main') 470 .on('click', 'a.addcommiteemember', CRM.popup) 471 .on('crmPopupFormSuccess', 'a.addcommiteemember', function() { 472 CRM.alert= function() {}; 473 CRM.status('Success! Please wait a second, refreshing a corresponded table', 'Success', 'success' ); 474 location.reload(true); 475 }); 476 477});
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.