1jQuery(document).ready(function ($) { 2 if (!$('.divi-100-article-card').length) { 3 return false; 4 } else { 5 $('.et_pb_blog_grid').find('.et_pb_post').each(function() { 6 var $this = $(this); 7 8 /** 9 * Adds article-card class to div 10 */ 11 $this 12 .addClass('article-card'); 13 14 /** 15 * Creates content div and appends to post 16 */ 17 $this 18 .append('<div class="article-card__content" />'); 19 20 /** 21 * Post variables 22 */ 23 var postContent = $this.find('.article-card__content'); 24 var postMeta = $this.children('.post-meta'); 25 26 /** 27 * Excerpt variables 28 */ 29 var excerpt = $this.clone().children().remove().end().text().trim(); 30 var excerptWrap = $('<div class="article-card__excerpt" />'); 31 32 if ($this.children('p').not('p.post-meta').length > 0) { 33 excerpt = $this.children('p').not('p.post-meta').text(); 34 $this.children('p').not('p.post-meta').remove(); 35 } 36 37 /** 38 * Check if excerpt is over 100 characters 39 */ 40 if (excerpt.length > 80) { 41 excerpt = excerpt.substring(0, 80).split(" ").slice(0, -1).join(" ") + "..." 42 } 43 44 /** 45 * Creates category div based off post-meta children 46 */ 47 postMeta 48 .children('a') 49 .addClass('article-card__category') 50 .appendTo(postContent); 51 52 /** 53 * Appends excerpt to content div 54 */ 55 excerptWrap 56 .text(excerpt) 57 .appendTo(postContent); 58 59 /** 60 * Creates meta div and appends to content 61 */ 62 postContent 63 .append('<div class="article-card__meta" />'); 64 65 /** 66 * Removes old text from post 67 */ 68 $this 69 .contents() 70 .filter(function () { 71 return (this.nodeType == 3); 72 }) 73 .remove(); 74 75 /** 76 * Creates date div based off .published 77 */ 78 $(this).find('.published').text(function() { 79 return $(this).text().slice(0, -6); 80 }); 81 82 $this 83 .find('.published') 84 .appendTo(this) 85 .replaceWith(function (i, text) { 86 return ( 87 text 88 .replace(/([a-zA-Z]+)([\d\D]*)/g, 89 '<div class="article-card__date">\ 90 <span class="article-card__day">
90$2</span>\ 91 <span class="article-card__month">$1</span>\ 92 </div>' 93 ) 94 ); 95 }); 96 97 /** 98 * Removes comma, spaces from day 99 */ 100 $this 101 .find('.article-card__day') 102 .text(function() { 103 return $(this) 104 .text() 105 .replace(/\,/g, '') 106 .trim(); 107 }); 108 109 /** 110 * Add article-card__title class to title 111 */ 112 $this 113 .find('.entry-title') 114 .addClass('article-card__title') 115 .prependTo(postContent); 116 117 /** 118 * Appends author to content div 119 */ 120 $this 121 .find('.author') 122 .addClass('article-card__author') 123 .appendTo($this.find('.article-card__meta')); 124 125 126 /** 127 * Get existing comment and appends it to post comment 128 */ 129 var comments = postMeta.text().replace(/[^a-zA-Z0-9 ]/g, "").replace("by", "").trim(); 130 131 if (comments) { 132 $('<span class="article-card__comments">' + comments + '</span>') 133 .appendTo($this.find('.article-card__meta')); 134 } 135 136 /** 137 * Remove old post-meta div 138 */ 139 postMeta.remove(); 140 141 /** 142 * If .post-content exist, then append contents to excerpt 143 */ 144 if ($(this).find('.post-content').length > 0) { 145 $(this) 146 .find('.post-content p') 147 .appendTo($(this) 148 .find('.article-card__excerpt')); 149 } 150 151 /** 152 * Hide excerpt by default on desktop 153 */ 154 if ($(window).width() > 768) { 155 $this 156 .children() 157 .children('.article-card__excerpt') 158 .hide(); 159 } 160 161 /** 162 * Get outer height of content div and applies a padding to card 163 */ 164 function postModuleSize() { 165 var postContentHeight = postContent.outerHeight(); 166 167 $this.css({ 168 'padding-bottom': postContentHeight 169 }); 170 } 171 172 setTimeout(postModuleSize, 100); 173 174 /** 175 * Recall getPostContentSize() on window resize 176 */ 177 $(window).resize(function() { 178 postModuleSize(); 179 }); 180 181 /** 182 * Handle animations on desktop 183 */ 184 if ($(window).width() > 768) { 185 186 /** 187 * Prevents loading incorrect state 188 */ 189 setTimeout(function() { 190 $this.on('hover', function () { 191 $this.find('.article-card__excerpt').stop().animate({ 192 height: "toggle", 193 opacity: "toggle" 194 }, 200); 195 }); 196 }); 197 } 198 }); 199 } 200});
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.