postal code search tool
Showing
15 changed files
with
453 additions
and
1 deletions
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Quotes Block Template. | ||
| 4 | * | ||
| 5 | * @param array $block The block settings and attributes. | ||
| 6 | * @param string $content The block inner HTML (empty). | ||
| 7 | * @param bool $is_preview True during AJAX preview. | ||
| 8 | * @param (int|string) $post_id The post ID this block is saved to. | ||
| 9 | */ | ||
| 10 | |||
| 11 | // Create id attribute allowing for custom "anchor" value. | ||
| 12 | $id = 'postal-search-' . $block['id']; | ||
| 13 | if( !empty($block['anchor']) ) { | ||
| 14 | $id = $block['anchor']; | ||
| 15 | } | ||
| 16 | |||
| 17 | // Create class attribute allowing for custom "className" and "align" values. | ||
| 18 | $className = 'postal-search'; | ||
| 19 | if( !empty($block['className']) ) { | ||
| 20 | $className .= ' ' . $block['className']; | ||
| 21 | } | ||
| 22 | if( !empty($block['align']) ) { | ||
| 23 | $className .= ' align' . $block['align']; | ||
| 24 | } | ||
| 25 | if( $is_preview ) { | ||
| 26 | $className .= ' is-admin'; | ||
| 27 | } | ||
| 28 | |||
| 29 | $postal_lookup = []; | ||
| 30 | $row = 0; | ||
| 31 | if (($handle = fopen(wp_get_upload_dir()['basedir']."/terriroties.csv", "r")) !== FALSE) { | ||
| 32 | while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { | ||
| 33 | |||
| 34 | $row++; | ||
| 35 | |||
| 36 | if($row == 1) { | ||
| 37 | continue; | ||
| 38 | } | ||
| 39 | |||
| 40 | $postal_lookup[] = ['GEOKEY'=>$data[0],'TERRITORY'=>$data[1],'1ST'=>$data[2],'PREFERRED'=>$data[3],'REGION'=>$data[4]]; | ||
| 41 | |||
| 42 | } | ||
| 43 | fclose($handle); | ||
| 44 | } | ||
| 45 | |||
| 46 | |||
| 47 | ?> | ||
| 48 | <div id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr($className); ?>"> | ||
| 49 | |||
| 50 | <h2>Preferred Property Risk Territory Lookup</h2> | ||
| 51 | |||
| 52 | <input type='hidden' class='postal-search-data' value='<?= json_encode($postal_lookup) ?>' /> | ||
| 53 | |||
| 54 | <table class='postal-search-results'> | ||
| 55 | <thead> | ||
| 56 | <tr class="header"><td>GEOKEY</td><td>TERRITORY</td><td>1ST</td><td>PREFERRED</td><td>REGION</td></tr> | ||
| 57 | </thead> | ||
| 58 | <tbody> | ||
| 59 | <?php foreach($postal_lookup as $pl) { ?> | ||
| 60 | <tr data-preferred="<?= $pl['PREFERRED'] ?>" class="header"><td><?= $pl['GEOKEY'] ?></td><td><?= $pl['TERRITORY'] ?></td><td><?= $pl['1ST'] ?></td><td><?= $pl['PREFERRED'] ?></td><td><?= $pl['REGION'] ?></td></tr> | ||
| 61 | <?php } ?> | ||
| 62 | </tbody> | ||
| 63 | </table> | ||
| 64 | |||
| 65 | </div> | ||
| 66 |
| ... | @@ -14522,6 +14522,146 @@ a.pdf:hover, a.extern:hover, a.xls:hover, a.mailto:hover { | ... | @@ -14522,6 +14522,146 @@ a.pdf:hover, a.extern:hover, a.xls:hover, a.mailto:hover { |
| 14522 | font-family: "Helvetica-Bold"; | 14522 | font-family: "Helvetica-Bold"; |
| 14523 | } | 14523 | } |
| 14524 | 14524 | ||
| 14525 | .dataTables_wrapper { | ||
| 14526 | display: flex; | ||
| 14527 | flex-wrap: wrap; | ||
| 14528 | } | ||
| 14529 | .dataTables_wrapper table { | ||
| 14530 | flex-basis: 100%; | ||
| 14531 | width: 100%; | ||
| 14532 | } | ||
| 14533 | .dataTables_wrapper table tr td { | ||
| 14534 | padding-left: 0; | ||
| 14535 | } | ||
| 14536 | .dataTables_wrapper .header td { | ||
| 14537 | cursor: pointer; | ||
| 14538 | } | ||
| 14539 | .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter { | ||
| 14540 | width: 300px; | ||
| 14541 | } | ||
| 14542 | .dataTables_wrapper .dataTables_filter label { | ||
| 14543 | font-family: HelveticaNeue, Helvetica, Arial, sans-serif; | ||
| 14544 | font-size: 20px; | ||
| 14545 | line-height: 25px; | ||
| 14546 | color: #68696d; | ||
| 14547 | text-transform: uppercase; | ||
| 14548 | font-weight: 800; | ||
| 14549 | padding-bottom: 1rem; | ||
| 14550 | margin-bottom: 0; | ||
| 14551 | display: flex; | ||
| 14552 | position: relative; | ||
| 14553 | } | ||
| 14554 | .dataTables_wrapper .dataTables_filter label:after { | ||
| 14555 | content: ""; | ||
| 14556 | background: url('data:image/svg+xml,<svg id="Component_13_1" data-name="Component 13 – 1" xmlns="http://www.w3.org/2000/svg" width="30.108" height="30.012" viewBox="0 0 30.108 30.012"><line id="Line_1" data-name="Line 1" x2="12.53" y2="12.53" transform="translate(16.517 16.421)" fill="none" stroke="%23949598" stroke-width="3"/><g id="Ellipse_1" data-name="Ellipse 1" fill="%23fff" stroke="%23949598" stroke-width="3"><circle cx="11.513" cy="11.513" r="11.513" stroke="none"/><circle cx="11.513" cy="11.513" r="10.013" fill="none"/></g></svg>'); | ||
| 14557 | width: 25px; | ||
| 14558 | height: 25px; | ||
| 14559 | display: block; | ||
| 14560 | background-size: 25px 25px; | ||
| 14561 | position: absolute; | ||
| 14562 | right: 0; | ||
| 14563 | bottom: 1.5rem; | ||
| 14564 | } | ||
| 14565 | .dataTables_wrapper input { | ||
| 14566 | flex: 1; | ||
| 14567 | padding-right: 1rem; | ||
| 14568 | border: 1px solid #fff; | ||
| 14569 | font-size: 1rem; | ||
| 14570 | border-bottom: 2px solid #54565a !important; | ||
| 14571 | font-family: Helvetica; | ||
| 14572 | padding: 0.5rem 0; | ||
| 14573 | } | ||
| 14574 | |||
| 14575 | .sorting_asc { | ||
| 14576 | position: relative; | ||
| 14577 | } | ||
| 14578 | .sorting_asc:after { | ||
| 14579 | content: ""; | ||
| 14580 | background: url(/wp-content/themes/commonwell-broker/images/arrow.png); | ||
| 14581 | display: inline-block; | ||
| 14582 | width: 20px; | ||
| 14583 | height: 20px; | ||
| 14584 | background-size: contain; | ||
| 14585 | transform: rotate(90deg); | ||
| 14586 | position: relative; | ||
| 14587 | top: 4px; | ||
| 14588 | left: 5px; | ||
| 14589 | } | ||
| 14590 | |||
| 14591 | .sorting:after { | ||
| 14592 | content: ""; | ||
| 14593 | display: inline-block; | ||
| 14594 | width: 20px; | ||
| 14595 | height: 20px; | ||
| 14596 | background-size: contain; | ||
| 14597 | position: relative; | ||
| 14598 | top: 4px; | ||
| 14599 | left: 5px; | ||
| 14600 | } | ||
| 14601 | |||
| 14602 | #DataTables_Table_0_length { | ||
| 14603 | display: none; | ||
| 14604 | } | ||
| 14605 | |||
| 14606 | .sorting_desc { | ||
| 14607 | position: relative; | ||
| 14608 | } | ||
| 14609 | .sorting_desc:after { | ||
| 14610 | content: ""; | ||
| 14611 | background: url(/wp-content/themes/commonwell-broker/images/arrow.png); | ||
| 14612 | display: inline-block; | ||
| 14613 | width: 20px; | ||
| 14614 | height: 20px; | ||
| 14615 | background-size: contain; | ||
| 14616 | transform: rotate(-90deg); | ||
| 14617 | position: relative; | ||
| 14618 | top: 4px; | ||
| 14619 | left: 5px; | ||
| 14620 | } | ||
| 14621 | |||
| 14622 | .postal-search-results tbody tr:first-of-type { | ||
| 14623 | background: rgba(84, 86, 90, 0.1490196078); | ||
| 14624 | } | ||
| 14625 | .postal-search-results tbody tr:first-of-type td { | ||
| 14626 | font-size: 12px !important; | ||
| 14627 | font-weight: 400 !important; | ||
| 14628 | padding: 9px 0 !important; | ||
| 14629 | color: #54565a !important; | ||
| 14630 | font-weight: normal !important; | ||
| 14631 | } | ||
| 14632 | |||
| 14633 | .postal-label { | ||
| 14634 | color: black; | ||
| 14635 | } | ||
| 14636 | |||
| 14637 | .search-postal-preferred tr.hidden { | ||
| 14638 | display: none; | ||
| 14639 | } | ||
| 14640 | |||
| 14641 | .postal-code-search, .search-postal-preferred { | ||
| 14642 | font-size: 18px; | ||
| 14643 | } | ||
| 14644 | |||
| 14645 | .postal-search { | ||
| 14646 | padding-top: 3rem; | ||
| 14647 | } | ||
| 14648 | |||
| 14649 | .postal-search label { | ||
| 14650 | display: flex; | ||
| 14651 | flex-direction: column; | ||
| 14652 | font-size: 18px; | ||
| 14653 | } | ||
| 14654 | |||
| 14655 | .postal-code-inputs { | ||
| 14656 | display: flex; | ||
| 14657 | } | ||
| 14658 | .postal-code-inputs > div { | ||
| 14659 | padding-right: 3rem; | ||
| 14660 | } | ||
| 14661 | .postal-code-inputs > input { | ||
| 14662 | font-size: 1rem; | ||
| 14663 | } | ||
| 14664 | |||
| 14525 | .strategic-child-page { | 14665 | .strategic-child-page { |
| 14526 | display: flex; | 14666 | display: flex; |
| 14527 | flex-direction: row; | 14667 | flex-direction: row; | ... | ... |
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed.
Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
| 1 | // import Fuse from 'fuse.js' | ||
| 2 | import DataTable from 'datatables.net-dt'; | ||
| 3 | |||
| 4 | (function( $ ) { | ||
| 5 | |||
| 6 | // var list = JSON.parse($('.postal-search-data').val()); | ||
| 7 | |||
| 8 | // const fuseOptions = { | ||
| 9 | // // isCaseSensitive: false, | ||
| 10 | // // includeScore: false, | ||
| 11 | // // shouldSort: true, | ||
| 12 | // // includeMatches: false, | ||
| 13 | // // findAllMatches: false, | ||
| 14 | // // minMatchCharLength: 1, | ||
| 15 | // // location: 0, | ||
| 16 | // threshold: 0.2, | ||
| 17 | // // distance: 100, | ||
| 18 | // // useExtendedSearch: false, | ||
| 19 | // // ignoreLocation: false, | ||
| 20 | // // ignoreFieldNorm: false, | ||
| 21 | // // fieldNormWeight: 1, | ||
| 22 | // keys: [ | ||
| 23 | // "GEOKEY", | ||
| 24 | // "TERRITORY" | ||
| 25 | // ] | ||
| 26 | // }; | ||
| 27 | |||
| 28 | // const fuse = new Fuse(list, fuseOptions); | ||
| 29 | |||
| 30 | var table = new DataTable('.postal-search-results', | ||
| 31 | { | ||
| 32 | responsive: true, | ||
| 33 | paging:true, | ||
| 34 | "lengthMenu":-1, | ||
| 35 | "oLanguage": { | ||
| 36 | "sSearch": "Enter Full Postal Code:" | ||
| 37 | } | ||
| 38 | } | ||
| 39 | ); | ||
| 40 | |||
| 41 | // function searchFuse(searchPattern) { | ||
| 42 | // return fuse.search(searchPattern); | ||
| 43 | // } | ||
| 44 | |||
| 45 | // $('.search-postal-preferred').on('change', function() { | ||
| 46 | // var preferred = $(this).find('option:selected').val(); | ||
| 47 | // $('.postal-search-results tr').removeClass('hidden'); | ||
| 48 | // if(preferred == 'YES' || preferred == 'NO') { | ||
| 49 | // $('.postal-search-results tr').each(function() { | ||
| 50 | // if(!$(this).hasClass('header')) { | ||
| 51 | // var _preferred = $(this).data('preferred'); | ||
| 52 | // console.log(_preferred); | ||
| 53 | // if(preferred != _preferred) { | ||
| 54 | // $(this).addClass('hidden'); | ||
| 55 | // } | ||
| 56 | // } | ||
| 57 | // }); | ||
| 58 | // } | ||
| 59 | // }); | ||
| 60 | |||
| 61 | // $('.postal-code-search').on('keyup', function() { | ||
| 62 | |||
| 63 | // var results = searchFuse($(this).val()); | ||
| 64 | |||
| 65 | // $('.postal-search-results tr').remove(); | ||
| 66 | // $('.postal-search-results').append( | ||
| 67 | // '<tr class="header"><td>GEOKEY</td><td>TERRITORY</td><td>1ST</td><td>PREFERRED</td><td>REGION</td></tr>' | ||
| 68 | // ); | ||
| 69 | |||
| 70 | // if(results.length > 200) { | ||
| 71 | // $('.postal-search-results').append("<tr><td>Result set to large</td><td></td><td></td><td></td><td></td></tr>"); | ||
| 72 | // } else { | ||
| 73 | // if(results.length == 0) { | ||
| 74 | // $('.postal-search-results').append("<tr><td>No Results Found</td><td></td><td></td><td></td><td></td></tr>"); | ||
| 75 | // } else { | ||
| 76 | // for(var i = 0;i < results.length;++i) { | ||
| 77 | // $('.postal-search-results').append( | ||
| 78 | // '<tr data-preferred="'+results[i].item['PREFERRED']+'"><td>'+results[i].item.GEOKEY+'</td><td>'+results[i].item.TERRITORY+'</td><td>'+results[i].item['1ST']+'</td><td>'+results[i].item['PREFERRED']+'</td><td>'+results[i].item['REGION']+'</td></tr>' | ||
| 79 | // ); | ||
| 80 | // } | ||
| 81 | // } | ||
| 82 | // } | ||
| 83 | |||
| 84 | // }); | ||
| 85 | |||
| 86 | }( jQuery )); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -14,6 +14,7 @@ import "./_resources_list"; | ... | @@ -14,6 +14,7 @@ import "./_resources_list"; |
| 14 | import "./_custom_select"; | 14 | import "./_custom_select"; |
| 15 | import "./_accordion"; | 15 | import "./_accordion"; |
| 16 | import "./_responsive"; | 16 | import "./_responsive"; |
| 17 | import "./_postal_search"; | ||
| 17 | 18 | ||
| 18 | function checkOffsetForTopper() { | 19 | function checkOffsetForTopper() { |
| 19 | if(jQuery('.the-toppe').length > 0) { | 20 | if(jQuery('.the-toppe').length > 0) { | ... | ... |
| ... | @@ -304,6 +304,153 @@ a.pdf, a.extern, a.xls, a.mailto { | ... | @@ -304,6 +304,153 @@ a.pdf, a.extern, a.xls, a.mailto { |
| 304 | } | 304 | } |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | .dataTables_wrapper { | ||
| 308 | display: flex; | ||
| 309 | flex-wrap: wrap; | ||
| 310 | table { | ||
| 311 | flex-basis: 100%; | ||
| 312 | width: 100%; | ||
| 313 | } | ||
| 314 | table tr td { | ||
| 315 | padding-left:0; | ||
| 316 | } | ||
| 317 | .header td { | ||
| 318 | cursor: pointer; | ||
| 319 | } | ||
| 320 | .dataTables_length, .dataTables_filter { | ||
| 321 | width: 300px; | ||
| 322 | } | ||
| 323 | .dataTables_filter { | ||
| 324 | label { | ||
| 325 | font-family: HelveticaNeue,Helvetica,Arial,sans-serif; | ||
| 326 | font-size: 20px; | ||
| 327 | line-height: 25px; | ||
| 328 | color: #68696d; | ||
| 329 | text-transform: uppercase; | ||
| 330 | font-weight: 800; | ||
| 331 | padding-bottom: 1rem; | ||
| 332 | margin-bottom: 0; | ||
| 333 | display: flex; | ||
| 334 | position: relative; | ||
| 335 | &:after { | ||
| 336 | content: ""; | ||
| 337 | background: url('data:image/svg+xml,<svg id="Component_13_1" data-name="Component 13 – 1" xmlns="http://www.w3.org/2000/svg" width="30.108" height="30.012" viewBox="0 0 30.108 30.012"><line id="Line_1" data-name="Line 1" x2="12.53" y2="12.53" transform="translate(16.517 16.421)" fill="none" stroke="%23949598" stroke-width="3"/><g id="Ellipse_1" data-name="Ellipse 1" fill="%23fff" stroke="%23949598" stroke-width="3"><circle cx="11.513" cy="11.513" r="11.513" stroke="none"/><circle cx="11.513" cy="11.513" r="10.013" fill="none"/></g></svg>'); | ||
| 338 | width: 25px; | ||
| 339 | height: 25px; | ||
| 340 | display: block; | ||
| 341 | background-size: 25px 25px; | ||
| 342 | position: absolute; | ||
| 343 | right:0; | ||
| 344 | bottom:1.5rem; | ||
| 345 | } | ||
| 346 | } | ||
| 347 | } | ||
| 348 | input { | ||
| 349 | flex: 1; | ||
| 350 | padding-right: 1rem; | ||
| 351 | border: 1px solid #fff; | ||
| 352 | font-size: 1rem; | ||
| 353 | border-bottom: 2px solid #54565a!important; | ||
| 354 | font-family: Helvetica; | ||
| 355 | padding: 0.5rem 0; | ||
| 356 | } | ||
| 357 | } | ||
| 358 | |||
| 359 | .sorting_asc { | ||
| 360 | position: relative; | ||
| 361 | &:after { | ||
| 362 | content: ""; | ||
| 363 | background: url(/wp-content/themes/commonwell-broker/images/arrow.png); | ||
| 364 | display: inline-block; | ||
| 365 | width: 20px; | ||
| 366 | height: 20px; | ||
| 367 | background-size: contain; | ||
| 368 | transform: rotate(90deg); | ||
| 369 | position: relative; | ||
| 370 | top: 4px; | ||
| 371 | left: 5px; | ||
| 372 | } | ||
| 373 | } | ||
| 374 | |||
| 375 | .sorting { | ||
| 376 | &:after { | ||
| 377 | content: ""; | ||
| 378 | display: inline-block; | ||
| 379 | width: 20px; | ||
| 380 | height: 20px; | ||
| 381 | background-size: contain; | ||
| 382 | position: relative; | ||
| 383 | top: 4px; | ||
| 384 | left: 5px; | ||
| 385 | } | ||
| 386 | } | ||
| 387 | |||
| 388 | #DataTables_Table_0_length { | ||
| 389 | display: none; | ||
| 390 | } | ||
| 391 | |||
| 392 | .sorting_desc { | ||
| 393 | position: relative; | ||
| 394 | &:after { | ||
| 395 | content: ""; | ||
| 396 | background: url(/wp-content/themes/commonwell-broker/images/arrow.png); | ||
| 397 | display: inline-block; | ||
| 398 | width: 20px; | ||
| 399 | height: 20px; | ||
| 400 | background-size: contain; | ||
| 401 | transform: rotate(-90deg); | ||
| 402 | position: relative; | ||
| 403 | top: 4px; | ||
| 404 | left: 5px; | ||
| 405 | } | ||
| 406 | } | ||
| 407 | |||
| 408 | .postal-search-results tbody tr:first-of-type { | ||
| 409 | background:rgba(84,86,90,.1490196078); | ||
| 410 | td { | ||
| 411 | font-size: 12px !important; | ||
| 412 | font-weight: 400 !important; | ||
| 413 | padding: 9px 0 !important; | ||
| 414 | color:#54565a !important; | ||
| 415 | font-weight: normal !important; | ||
| 416 | } | ||
| 417 | } | ||
| 418 | |||
| 419 | .postal-label { | ||
| 420 | color:black; | ||
| 421 | } | ||
| 422 | |||
| 423 | .search-postal-preferred { | ||
| 424 | tr.hidden { | ||
| 425 | display: none; | ||
| 426 | } | ||
| 427 | } | ||
| 428 | |||
| 429 | |||
| 430 | .postal-code-search, .search-postal-preferred { | ||
| 431 | font-size: 18px; | ||
| 432 | } | ||
| 433 | |||
| 434 | .postal-search { | ||
| 435 | padding-top:3rem; | ||
| 436 | } | ||
| 437 | |||
| 438 | .postal-search label { | ||
| 439 | display: flex; | ||
| 440 | flex-direction: column; | ||
| 441 | font-size: 18px; | ||
| 442 | } | ||
| 443 | |||
| 444 | .postal-code-inputs { | ||
| 445 | display: flex; | ||
| 446 | & > div { | ||
| 447 | padding-right:3rem; | ||
| 448 | } | ||
| 449 | & > input { | ||
| 450 | font-size: 1rem; | ||
| 451 | } | ||
| 452 | } | ||
| 453 | |||
| 307 | .strategic-child-page { | 454 | .strategic-child-page { |
| 308 | display: flex; | 455 | display: flex; |
| 309 | flex-direction: row; | 456 | flex-direction: row; | ... | ... |
| ... | @@ -18,5 +18,16 @@ function my_acf_init_block_types() { | ... | @@ -18,5 +18,16 @@ function my_acf_init_block_types() { |
| 18 | ] | 18 | ] |
| 19 | )); | 19 | )); |
| 20 | 20 | ||
| 21 | // register a portfolio item block | ||
| 22 | acf_register_block(array( | ||
| 23 | 'name' => 'postal', | ||
| 24 | 'title' => __('Postal Code Lookup'), | ||
| 25 | 'description' => __('A form for postal code lookup.'), | ||
| 26 | 'render_template' => 'blocks/postal-search-tool/postal-search-tool.php', | ||
| 27 | 'category' => 'layout', | ||
| 28 | 'icon' => 'excerpt-view', | ||
| 29 | 'keywords' => array( 'postal' ), | ||
| 30 | )); | ||
| 31 | |||
| 21 | } | 32 | } |
| 22 | } | 33 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment