eaa7ada6 by Jeff Balicki

qa

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent 2439b51a
...@@ -20663,6 +20663,197 @@ ...@@ -20663,6 +20663,197 @@
20663 $$1.fn.DataTable[prop] = val; 20663 $$1.fn.DataTable[prop] = val;
20664 }); 20664 });
20665 20665
20666 var mobile_article_list = [];
20667 function postItem(post_obj, size, sides, side_index, side_alternate, labels) {
20668 console.log(post_obj);
20669 var li = "";
20670 if (size == 2) {
20671 li += "<li class='article-card lg'><a href='" + post_obj['href'] + "'>";
20672 if (post_obj['img_src']) {
20673 li += "<div class='image large'><div class='scale-wrapper'><img src='" + post_obj['img_src'] + "' /></div></div>";
20674 }
20675 if (post_obj['title'].length > 100) {
20676 li += "<div class='content reduce'><span class='news-title'>" + post_obj['title'] + "</span></div>";
20677 } else {
20678 li += "<div class='content'><span class='news-title'>" + post_obj['title'] + "</span>";
20679 }
20680 if (post_obj['text']) {
20681 li += "<p>" + post_obj['text'] + "...</p>";
20682 }
20683 if (post_obj['date']) {
20684 li += "<span class='published'>" + window.POST_LIST_LABELS.published + " " + post_obj['date'] + "</span>";
20685 }
20686 li += "</div></a></li>";
20687 } else {
20688 li += "<li class='article-card sm'><a href='" + post_obj['href'] + "'>";
20689 if (post_obj['img_src']) {
20690 li += "<div class='image'><div class='scale-wrapper'><img src='" + post_obj['img_src'] + "' /></div></div>";
20691 }
20692 if (post_obj['title'].length > 100) {
20693 li += "<div class='content reduce'><span class='news-title'>" + post_obj['title'] + "</span>";
20694 } else {
20695 li += "<div class='content'><span class='news-title'>" + post_obj['title'] + "</span>";
20696 }
20697 if (post_obj['text']) {
20698 li += "<p>" + post_obj['text'] + "...</p>";
20699 }
20700 if (post_obj['article_author']) {
20701 li += "<span class='author-name'>" + post_obj['article_author'] + " | </span>";
20702 }
20703 if (post_obj['author_title']) {
20704 li += "<span class='author-title'>" + post_obj['author_title'] + "</span>";
20705 }
20706 if (post_obj['author_company']) {
20707 li += "<span class='author_company'>" + post_obj['author_company'] + "</span>";
20708 }
20709 if (post_obj['date']) {
20710 li += "<span class='published'>" + window.POST_LIST_LABELS.published + " " + post_obj['date'] + "</span>";
20711 }
20712 li += "";
20713 li += "</div></li>";
20714 }
20715 mobile_article_list.push(li);
20716 if (side_index % 2 == 0 || side_index == 0) {
20717 if (side_alternate == 0 || side_alternate % 2 == 0) {
20718 sides.left.push(li);
20719 } else {
20720 sides.right.push(li);
20721 }
20722 } else {
20723 if (side_alternate == 0 || side_alternate % 2 == 0) {
20724 sides.right.push(li);
20725 } else {
20726 sides.left.push(li);
20727 }
20728 }
20729 return li;
20730 }
20731 function loadPostSegment(block, segment, append, limit) {
20732 const categories = jQuery(block).data('categories');
20733 if (append) {
20734 jQuery('.post-list-load-more').addClass('loading');
20735 }
20736 var lang = document.documentElement.lang;
20737 if (lang == 'fr-FR') {
20738 lang = "&lang=fr";
20739 } else {
20740 lang = "&lang=en";
20741 }
20742 var limit_q = "";
20743 if (limit) {
20744 limit_q = "&limit=" + limit;
20745 }
20746 jQuery.get('/wp-json/v1/post_list?segment=' + segment + '&categories=' + categories + lang + limit_q, function (result) {
20747 var posts = result['posts'],
20748 last_index = result['last_index'];
20749 var pattern = jQuery(block).data('pattern');
20750 window.POST_LIST_LABELS = {};
20751 window.POST_LIST_LABELS.published = jQuery(block).data('published');
20752 var pattern_idx = 0,
20753 side_index = 0,
20754 reset_side_from_large = 0,
20755 side_alternate = 1;
20756 if (jQuery(block).data('pattern_idx')) {
20757 pattern_idx = jQuery(block).data('pattern_idx');
20758 }
20759 if (jQuery(block).data('side_index')) {
20760 side_index = jQuery(block).data('side_index');
20761 }
20762 if (jQuery(block).data('reset_side_from_large')) {
20763 reset_side_from_large = jQuery(block).data('reset_side_from_large');
20764 }
20765 if (jQuery(block).data('side_alternate')) {
20766 side_alternate = jQuery(block).data('side_alternate');
20767 }
20768 var sides = {
20769 left: [],
20770 right: []
20771 };
20772 posts.map(obj => {
20773 if (pattern == 3) {
20774 postItem(obj, 1, sides, side_index);
20775 } else if (pattern == 2) {
20776 if (pattern_idx == 0) {
20777 postItem(obj, 2, sides, 0, 0);
20778 reset_side_from_large = 3;
20779 } else {
20780 if (reset_side_from_large > 0) {
20781 postItem(obj, 1, sides, 1, 0);
20782 --reset_side_from_large;
20783 } else {
20784 postItem(obj, 1, sides, 1);
20785 ++reset_side_from_large;
20786 }
20787 }
20788 } else if (pattern == 1) {
20789 if (pattern_idx == 0 || pattern_idx % 4 == 0) {
20790 postItem(obj, 2, sides, 0, side_alternate);
20791 reset_side_from_large = 3;
20792 } else {
20793 if (reset_side_from_large > 0) {
20794 postItem(obj, 1, sides, 1, side_alternate);
20795 --reset_side_from_large;
20796 if (reset_side_from_large == 0) {
20797 ++side_alternate; //after completion of a 3rd small after a large flip to the alternate sides
20798 }
20799 } else {
20800 postItem(obj, 1, sides, side_index, side_alternate);
20801 }
20802 }
20803 }
20804 ++side_index;
20805 ++pattern_idx;
20806 });
20807 jQuery(block).data('pattern_idx', pattern_idx);
20808 jQuery(block).data('side_index', side_index);
20809 jQuery(block).data('reset_side_from_large', reset_side_from_large);
20810 jQuery(block).data('side_alternate', side_alternate);
20811 if (append) {
20812 jQuery(block).find('.post-list-left-col').append("<ul class='newslist'>" + sides.left.join('') + "</ul>");
20813 jQuery(block).find('.post-list-right-col').append("<ul class='newslist'>" + sides.right.join('') + "</ul>");
20814 } else {
20815 jQuery(block).find('.post-list-left-col').html("<ul class='newslist'>" + sides.left.join('') + "</ul>");
20816 jQuery(block).find('.post-list-right-col').html("<ul class='newslist'>" + sides.right.join('') + "</ul>");
20817 }
20818 jQuery('.mobile-article-list').html("<ul>" + mobile_article_list.join('') + "</ul>");
20819 if (last_index) {
20820 jQuery('.post-list-load-more').css('display', 'none');
20821 }
20822 }).always(function () {
20823 jQuery('.post-list-load-more').removeClass('loading');
20824 });
20825 }
20826 jQuery(function ($) {
20827 $('.related-load-more').on('click', function (e) {
20828 e.preventDefault();
20829 var segment = $(this).data('segment');
20830 var that = this;
20831 $(that).addClass('loading');
20832 setTimeout(function () {
20833 $(that).parents('.related').find('.related-block.hidden[data-related-segment="' + segment + '"]').removeClass('hidden');
20834 $(that).data('segment', segment + 1);
20835 $(that).removeClass('loading');
20836 if ($(that).parents('.related').find('.related-block.hidden[data-related-segment="' + (segment + 1) + '"]').length == 0) {
20837 $(that).remove();
20838 }
20839 }, 100);
20840 });
20841 $('.news-and-stories-block').each(function () {
20842 var no_load = $(this).data('no-load'),
20843 limit = $(this).data('static-limit');
20844 if (no_load) {
20845 loadPostSegment(this, "all", null, limit);
20846 } else {
20847 loadPostSegment(this, 0);
20848 }
20849 $(this).find('.post-list-load-more').on('click', function () {
20850 var segment = $(this).data('segment');
20851 loadPostSegment($(this).parents('.news-and-stories-block'), segment, true);
20852 $(this).data('segment', ++segment);
20853 });
20854 });
20855 });
20856
20666 // Search Filter 20857 // Search Filter
20667 var Search = function ($) { 20858 var Search = function ($) {
20668 function init() { 20859 function init() {
...@@ -26226,197 +26417,6 @@ ...@@ -26226,197 +26417,6 @@
26226 // }); 26417 // });
26227 }); 26418 });
26228 26419
26229 var mobile_article_list = [];
26230 function postItem(post_obj, size, sides, side_index, side_alternate, labels) {
26231 console.log(post_obj);
26232 var li = "";
26233 if (size == 2) {
26234 li += "<li class='article-card lg'><a href='" + post_obj['href'] + "'>";
26235 if (post_obj['img_src']) {
26236 li += "<div class='image large'><div class='scale-wrapper'><img src='" + post_obj['img_src'] + "' /></div></div>";
26237 }
26238 if (post_obj['title'].length > 100) {
26239 li += "<div class='content reduce'><span class='news-title'>" + post_obj['title'] + "</span></div>";
26240 } else {
26241 li += "<div class='content'><span class='news-title'>" + post_obj['title'] + "</span>";
26242 }
26243 if (post_obj['text']) {
26244 li += "<p>" + post_obj['text'] + "...</p>";
26245 }
26246 if (post_obj['date']) {
26247 li += "<span class='published'>" + window.POST_LIST_LABELS.published + " " + post_obj['date'] + "</span>";
26248 }
26249 li += "</div></a></li>";
26250 } else {
26251 li += "<li class='article-card sm'><a href='" + post_obj['href'] + "'>";
26252 if (post_obj['img_src']) {
26253 li += "<div class='image'><div class='scale-wrapper'><img src='" + post_obj['img_src'] + "' /></div></div>";
26254 }
26255 if (post_obj['title'].length > 100) {
26256 li += "<div class='content reduce'><span class='news-title'>" + post_obj['title'] + "</span>";
26257 } else {
26258 li += "<div class='content'><span class='news-title'>" + post_obj['title'] + "</span>";
26259 }
26260 if (post_obj['text']) {
26261 li += "<p>" + post_obj['text'] + "...</p>";
26262 }
26263 if (post_obj['article_author']) {
26264 li += "<span class='author-name'>" + post_obj['article_author'] + " | </span>";
26265 }
26266 if (post_obj['author_title']) {
26267 li += "<span class='author-title'>" + post_obj['author_title'] + "</span>";
26268 }
26269 if (post_obj['author_company']) {
26270 li += "<span class='author_company'>" + post_obj['author_company'] + "</span>";
26271 }
26272 if (post_obj['date']) {
26273 li += "<span class='published'>" + window.POST_LIST_LABELS.published + " " + post_obj['date'] + "</span>";
26274 }
26275 li += "";
26276 li += "</div></li>";
26277 }
26278 mobile_article_list.push(li);
26279 if (side_index % 2 == 0 || side_index == 0) {
26280 if (side_alternate == 0 || side_alternate % 2 == 0) {
26281 sides.left.push(li);
26282 } else {
26283 sides.right.push(li);
26284 }
26285 } else {
26286 if (side_alternate == 0 || side_alternate % 2 == 0) {
26287 sides.right.push(li);
26288 } else {
26289 sides.left.push(li);
26290 }
26291 }
26292 return li;
26293 }
26294 function loadPostSegment(block, segment, append, limit) {
26295 const categories = jQuery(block).data('categories');
26296 if (append) {
26297 jQuery('.post-list-load-more').addClass('loading');
26298 }
26299 var lang = document.documentElement.lang;
26300 if (lang == 'fr-FR') {
26301 lang = "&lang=fr";
26302 } else {
26303 lang = "&lang=en";
26304 }
26305 var limit_q = "";
26306 if (limit) {
26307 limit_q = "&limit=" + limit;
26308 }
26309 jQuery.get('/wp-json/v1/post_list?segment=' + segment + '&categories=' + categories + lang + limit_q, function (result) {
26310 var posts = result['posts'],
26311 last_index = result['last_index'];
26312 var pattern = jQuery(block).data('pattern');
26313 window.POST_LIST_LABELS = {};
26314 window.POST_LIST_LABELS.published = jQuery(block).data('published');
26315 var pattern_idx = 0,
26316 side_index = 0,
26317 reset_side_from_large = 0,
26318 side_alternate = 1;
26319 if (jQuery(block).data('pattern_idx')) {
26320 pattern_idx = jQuery(block).data('pattern_idx');
26321 }
26322 if (jQuery(block).data('side_index')) {
26323 side_index = jQuery(block).data('side_index');
26324 }
26325 if (jQuery(block).data('reset_side_from_large')) {
26326 reset_side_from_large = jQuery(block).data('reset_side_from_large');
26327 }
26328 if (jQuery(block).data('side_alternate')) {
26329 side_alternate = jQuery(block).data('side_alternate');
26330 }
26331 var sides = {
26332 left: [],
26333 right: []
26334 };
26335 posts.map(obj => {
26336 if (pattern == 3) {
26337 postItem(obj, 1, sides, side_index);
26338 } else if (pattern == 2) {
26339 if (pattern_idx == 0) {
26340 postItem(obj, 2, sides, 0, 0);
26341 reset_side_from_large = 3;
26342 } else {
26343 if (reset_side_from_large > 0) {
26344 postItem(obj, 1, sides, 1, 0);
26345 --reset_side_from_large;
26346 } else {
26347 postItem(obj, 1, sides, 1);
26348 ++reset_side_from_large;
26349 }
26350 }
26351 } else if (pattern == 1) {
26352 if (pattern_idx == 0 || pattern_idx % 4 == 0) {
26353 postItem(obj, 2, sides, 0, side_alternate);
26354 reset_side_from_large = 3;
26355 } else {
26356 if (reset_side_from_large > 0) {
26357 postItem(obj, 1, sides, 1, side_alternate);
26358 --reset_side_from_large;
26359 if (reset_side_from_large == 0) {
26360 ++side_alternate; //after completion of a 3rd small after a large flip to the alternate sides
26361 }
26362 } else {
26363 postItem(obj, 1, sides, side_index, side_alternate);
26364 }
26365 }
26366 }
26367 ++side_index;
26368 ++pattern_idx;
26369 });
26370 jQuery(block).data('pattern_idx', pattern_idx);
26371 jQuery(block).data('side_index', side_index);
26372 jQuery(block).data('reset_side_from_large', reset_side_from_large);
26373 jQuery(block).data('side_alternate', side_alternate);
26374 if (append) {
26375 jQuery(block).find('.post-list-left-col').append("<ul class='newslist'>" + sides.left.join('') + "</ul>");
26376 jQuery(block).find('.post-list-right-col').append("<ul class='newslist'>" + sides.right.join('') + "</ul>");
26377 } else {
26378 jQuery(block).find('.post-list-left-col').html("<ul class='newslist'>" + sides.left.join('') + "</ul>");
26379 jQuery(block).find('.post-list-right-col').html("<ul class='newslist'>" + sides.right.join('') + "</ul>");
26380 }
26381 jQuery('.mobile-article-list').html("<ul>" + mobile_article_list.join('') + "</ul>");
26382 if (last_index) {
26383 jQuery('.post-list-load-more').css('display', 'none');
26384 }
26385 }).always(function () {
26386 jQuery('.post-list-load-more').removeClass('loading');
26387 });
26388 }
26389 jQuery(function ($) {
26390 $('.related-load-more').on('click', function (e) {
26391 e.preventDefault();
26392 var segment = $(this).data('segment');
26393 var that = this;
26394 $(that).addClass('loading');
26395 setTimeout(function () {
26396 $(that).parents('.related').find('.related-block.hidden[data-related-segment="' + segment + '"]').removeClass('hidden');
26397 $(that).data('segment', segment + 1);
26398 $(that).removeClass('loading');
26399 if ($(that).parents('.related').find('.related-block.hidden[data-related-segment="' + (segment + 1) + '"]').length == 0) {
26400 $(that).remove();
26401 }
26402 }, 100);
26403 });
26404 $('.news-and-stories-block').each(function () {
26405 var no_load = $(this).data('no-load'),
26406 limit = $(this).data('static-limit');
26407 if (no_load) {
26408 loadPostSegment(this, "all", null, limit);
26409 } else {
26410 loadPostSegment(this, 0);
26411 }
26412 $(this).find('.post-list-load-more').on('click', function () {
26413 var segment = $(this).data('segment');
26414 loadPostSegment($(this).parents('.news-and-stories-block'), segment, true);
26415 $(this).data('segment', ++segment);
26416 });
26417 });
26418 });
26419
26420 // Add your custom JS here. 26420 // Add your custom JS here.
26421 var myLazyLoad = new LazyLoad(); 26421 var myLazyLoad = new LazyLoad();
26422 window.tz_checkVisible = function (elm, evalType, offset, heightBuffer) { 26422 window.tz_checkVisible = function (elm, evalType, offset, heightBuffer) {
...@@ -26434,16 +26434,6 @@ ...@@ -26434,16 +26434,6 @@
26434 if (evalType === "above") return y < vpH + st; 26434 if (evalType === "above") return y < vpH + st;
26435 }; 26435 };
26436 jQuery(document).ready(function ($) { 26436 jQuery(document).ready(function ($) {
26437 if ($('html:lang(fr-FR)').length && $('#search-wrapper:not(.news-search)').length) {
26438 $('.wpml-ls-link').attr('href', document.location.origin + '/search/');
26439 } else if ($('#search-wrapper:not(.news-search)').length) {
26440 $('.wpml-ls-link').attr('href', document.location.origin + '/search/?lang=fr');
26441 }
26442 if ($('html:lang(fr-FR)').length && $('.news-search').length) {
26443 $('.wpml-ls-link').attr('href', document.location.origin + '/news/');
26444 } else if ($('.news-search').length) {
26445 $('.wpml-ls-link').attr('href', document.location.origin + '/news/?lang=fr');
26446 }
26447 trim_text(); 26437 trim_text();
26448 $('#relevant-resources').dataTable({ 26438 $('#relevant-resources').dataTable({
26449 info: false, 26439 info: false,
......
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.
...@@ -97,7 +97,16 @@ get_header(); ...@@ -97,7 +97,16 @@ get_header();
97 </div> 97 </div>
98 98
99 <!-- The pagination component --> 99 <!-- The pagination component -->
100 100 <!-- The pagination component -->
101 <script>
102 jQuery(document).ready(function($) {
103 if ($('html:lang(fr-FR)').length && $('.news-search').length) {
104 $('.wpml-ls-link').attr('href', document.location.origin + '/news/');
105 }else if($('.news-search').length){
106 $('.wpml-ls-link').attr('href', document.location.origin + '/news/?lang=fr');
107 }
108 });
109 </script>
101 110
102 111
103 112
......
...@@ -83,8 +83,15 @@ get_header(); ...@@ -83,8 +83,15 @@ get_header();
83 </div> 83 </div>
84 84
85 <!-- The pagination component --> 85 <!-- The pagination component -->
86 86 <script>
87 87 jQuery(document).ready(function($) {
88 if ($('html:lang(fr-FR)').length && $('#search-wrapper:not(.news-search)').length) {
89 $('.wpml-ls-link').attr('href', document.location.origin + '/search/');
90 }else if($('#search-wrapper:not(.news-search)').length){
91 $('.wpml-ls-link').attr('href', document.location.origin + '/search/?lang=fr');
92 }
93 });
94 </script>
88 95
89 96
90 </div><!-- #content --> 97 </div><!-- #content -->
......
...@@ -3,13 +3,12 @@ import jquery from 'jquery'; ...@@ -3,13 +3,12 @@ import jquery from 'jquery';
3 import LazyLoad from "vanilla-lazyload"; 3 import LazyLoad from "vanilla-lazyload";
4 import DataTable from 'datatables.net-dt'; 4 import DataTable from 'datatables.net-dt';
5 5
6 6 import "./_post-list-load-more";
7 import "./_search"; 7 import "./_search";
8 import "./_header_menu"; 8 import "./_header_menu";
9 import "./_side_menu"; 9 import "./_side_menu";
10 import "./_image_captionation"; 10 import "./_image_captionation";
11 import "./_carousels"; 11 import "./_carousels";
12 import "./_post-list-load-more";
13 12
14 13
15 14
...@@ -36,17 +35,6 @@ window.tz_checkVisible = function(elm, evalType , offset, heightBuffer) { ...@@ -36,17 +35,6 @@ window.tz_checkVisible = function(elm, evalType , offset, heightBuffer) {
36 35
37 jQuery(document).ready(function($) { 36 jQuery(document).ready(function($) {
38 37
39 if ($('html:lang(fr-FR)').length && $('#search-wrapper:not(.news-search)').length) {
40 $('.wpml-ls-link').attr('href', document.location.origin + '/search/');
41 }else if($('#search-wrapper:not(.news-search)').length){
42 $('.wpml-ls-link').attr('href', document.location.origin + '/search/?lang=fr');
43 }
44
45 if ($('html:lang(fr-FR)').length && $('.news-search').length) {
46 $('.wpml-ls-link').attr('href', document.location.origin + '/news/');
47 }else if($('.news-search').length){
48 $('.wpml-ls-link').attr('href', document.location.origin + '/news/?lang=fr');
49 }
50 38
51 trim_text(); 39 trim_text();
52 $('#relevant-resources').dataTable( { 40 $('#relevant-resources').dataTable( {
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
2 Theme Name: MSF CA Child 2 Theme Name: MSF CA Child
3 Author: Tenzing Communications 3 Author: Tenzing Communications
4 Template: msf-ca 4 Template: msf-ca
5 Version: 1.0.57 5 Version: 1.0.58
6 */ 6 */
...\ No newline at end of file ...\ No newline at end of file
......