Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tools that change global behavior of website things, for not deal with a lot of changes for a little thing
/**
In example make all images of website content (maybe insterted trough editor)
openable trough gallery
[this work with Blueimp Gallery https://github.com/blueimp/Gallery]
*/
$(".auto-gallery-content").each(function(){
var data_gallery = $(this).data("autoGallery") ? $(this).data("autoGallery") : "gallery";
$("img", $(this)).each(function () {
if (!$(this).hasClass('no-auto-gallery')) {
// create` data-gallery
if (!$(this).parent().is('a')) {
$(this).wrap("<a href='" + $(this).attr('src') + "' data-gallery='"+ data_gallery +"'></a>");
} else {
// add data-gallery
if (typeof $(this).parent('a').attr('data-gallery') == "undefined") {
$(this).parent().attr('data-gallery', data_gallery);
}
}
}
});
});
/**
Or make all tag <a href="mailto:... that begining with "mailto" anchor to contact form
[used with a scroll effect begin a very nice thing. of course you need to have a contact form on any page of site]
https://arturmamedov.github.io/withFront/#target-block
*/
$('a[href^="mailto"]').each(function(){
var href_mailto = this.href.replace('mailto:', '');
$(this).attr('href', '#w-email').addClass('w-scroll');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.