Skip to content

Instantly share code, notes, and snippets.

@arturmamedov
Last active July 28, 2020 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arturmamedov/61ac3e77e8a2458f54a8c4267ae9982a to your computer and use it in GitHub Desktop.
Save arturmamedov/61ac3e77e8a2458f54a8c4267ae9982a to your computer and use it in GitHub Desktop.
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