Skip to content

Instantly share code, notes, and snippets.

/*!
* Simple jQuery Equal Heights
*
* Copyright (c) 2013 Matt Banks
* Dual licensed under the MIT and GPL licenses.
* Uses the same license as jQuery, see:
* http://docs.jquery.com/License
*
* @version 1.5.1
*/
document.querySelectorAll('a[href^="#"]').forEach(function (el) {
el.onclick = function (e) {
e.preventDefault();
var hash = this.getAttribute('href');
var target = document.querySelector(hash);
var headerOffset = 100;
var elementPosition = target.offsetTop;
var offsetPosition = elementPosition - headerOffset;
window.scrollTo({
top: offsetPosition,
$(function() {
$('.hover').bind('touchstart touchend', function(e) {
e.preventDefault();
$(this).toggleClass('hover-effect');
});
});
In english:
when you start or end a touch, turn the class hover-effect on or off.
Then, in your HTML, add a class hover to anything you want this to work with. In your CSS, replace any instance of:
//span around last word
$('.sentence').each(function(){
var self = $(this);
self.html(self.html().replace(/(\S+)\s*$/, '<span>$1</span>'));
});
//span around first word
$('.sentence').each(function(){
var self = $(this);
self.html(self.html().replace(/^(\S+)/, '<span>$1</span>'));
//Active menu, absolute url
$('.menu a').each(function() {
if (this.href == window.location.href) {
$(this).addClass('active');
}
});
//Active menu, relative url
var url = window.location.pathname,
urlRegExp = new RegExp(url.replace(/\/$/,'') + '$');
//add to SVG images class
<img src="img/logo.svg" alt="alt" class="img-svg">
//Replace all SVG images with inline SVG
$('img.img-svg').each(function(){
var $img = $(this);
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
$.get(imgURL, function(data) {
//In Template
<?php
$options = get_option('sample_theme_options');
echo $options['phone1'];
?>
//in functions.php
require_once ( get_stylesheet_directory() . '/theme-options.php' );
//theme-options.php file:
@AntonLitvin
AntonLitvin / gulpfile.js
Last active May 22, 2018 08:56
by html academy
//My gulpfile based on htmlacademy
package.json
{
"name": "project",
"version": "1.0.0",
"private": true,
"description": "",
"author": "Anton Litvinenko",
"devDependencies": {
//Добавление глобального класса для переопределения стилей
function dowidth(){
var width = $('body').width();
if(width >= 1200) {
$('body').removeClass('large medium small x-small mobile');
$('body').addClass('large');
}
if(width < 1200 & width >= 992) {
$('body').removeClass('large medium small x-small mobile');
//There is negative bottom margins on wrappers
<body>
<div class="wrapper">
content
<div class="push"></div>
</div>
<footer class="footer"></footer>
</body>