37 lines
1.3 KiB
Plaintext
37 lines
1.3 KiB
Plaintext
<div class="widget-link widget1">
|
||
|
||
<h3 class="widget-title">
|
||
<span>{{widget-title}}</span>
|
||
</h3>
|
||
<ul class="list-unstyled" data-level="0" data-list="web_link">
|
||
<li class="widget-content">
|
||
<a href="{{link_to_show}}" target="{{target}}" class="widget1-a">
|
||
<div class="link-img-wrap{{display_image}}">
|
||
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
|
||
</div>
|
||
<span data-list="statuses" data-level="1">
|
||
<span class="label status {{status-class}}">{{status}}</span>
|
||
</span>
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
|
||
</div>
|
||
<script>
|
||
$('.widget1').each(function() {
|
||
const $widget = $(this);
|
||
|
||
// 1. 抓取該 widget 下方清單中第一個連結的屬性
|
||
const $firstLink = $widget.find('.widget1-a').first();
|
||
const href = $firstLink.attr('href');
|
||
const target = $firstLink.attr('target') || '_self';
|
||
const ariaLabel = $widget.find('.widget-title').text().trim();
|
||
|
||
// 2. 如果有找到 href,就幫 .widget-title 內容包上一層 <a>
|
||
if (href) {
|
||
$widget.find('.widget-title').wrapInner(function() {
|
||
return `<a href="${href}" target="${target}" aria-label="${ariaLabel}" style="text-decoration: none; color: inherit;"></a>`;
|
||
});
|
||
}
|
||
});
|
||
</script> |