-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assets : load Swiper JS.
- Loading branch information
Showing
7 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
document.addEventListener("DOMContentLoaded", function() { | ||
'use strict'; | ||
var $swipes = document.querySelectorAll('.wputheme-swiper'); | ||
Array.prototype.forEach.call($swipes, function($swipe) { | ||
wputheme_swiper_init($swipe, { | ||
navigation: { | ||
nextEl: '.swiper-button-next', | ||
prevEl: '.swiper-button-prev', | ||
}, | ||
pagination: { | ||
el: '.swiper-pagination' | ||
}, | ||
scrollbar: { | ||
el: '.swiper-scrollbar', | ||
}, | ||
keyboard: { | ||
enabled: true, | ||
}, | ||
watchSlidesProgress: true, | ||
loop: true | ||
}); | ||
}); | ||
}); | ||
|
||
function wputheme_swiper_init($element, _settings) { | ||
'use strict'; | ||
/* Build wrapper */ | ||
var $swiper = document.createElement('div'); | ||
$swiper.classList.add('swiper', 'wputheme-swiper-wrapper'); | ||
$element.parentNode.insertBefore($swiper, $element.nextSibling); | ||
$swiper.appendChild($element); | ||
|
||
/* Add element class */ | ||
$element.classList.add('swiper-wrapper'); | ||
|
||
/* Add slides classes */ | ||
Array.prototype.forEach.call($element.children, function($slide) { | ||
$slide.classList.add('swiper-slide'); | ||
}); | ||
|
||
/* Add utilities */ | ||
var _utilsHTML = ''; | ||
if (_settings.pagination) { | ||
_utilsHTML += '<div class="swiper-pagination"></div>'; | ||
} | ||
if (_settings.navigation) { | ||
_settings.pagination.clickable = true; | ||
_utilsHTML += '<div class="swiper-button-prev"></div>'; | ||
_utilsHTML += '<div class="swiper-button-next"></div>'; | ||
} | ||
if (_settings.scrollbar) { | ||
_utilsHTML += '<div class="swiper-scrollbar"></div>'; | ||
} | ||
var $utils = document.createElement('div'); | ||
$utils.innerHTML = _utilsHTML; | ||
$swiper.appendChild($utils); | ||
|
||
/* Init swiper */ | ||
new Swiper($swiper, _settings); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters