Last active
July 28, 2020 07:16
-
-
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
This file contains hidden or 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
/** | |
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