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
function isScrolledIntoView(elem){ | |
var docViewTop = $(window).scrollTop(); | |
var docViewBottom = docViewTop + $(window).height(); | |
var elemTop = $(elem).offset().top; | |
var elemBottom = elemTop + $(elem).height(); | |
return Math.min(elemBottom, docViewBottom) >= Math.max(elemTop, docViewTop); | |
} |
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
document.addEventListener('DOMContentLoaded', function() { | |
function throttle(fn, threshhold, scope) { | |
threshhold || (threshhold = 250); | |
var last, | |
deferTimer; | |
return function () { | |
var context = scope || this; | |
var now = +new Date, | |
args = arguments; |
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
/* put code below in 404.php */ | |
<?php | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: ".get_bloginfo('url')); | |
exit(); | |
?> |
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
<h1>The long long text with icon before that should be vertically aligned to first line of text<h1> | |
h1{ | |
font-size: 40px; | |
line-height: 1.444; | |
} | |
h1:before{ | |
content: 'A'; // here is the first trick: pseudoelement with some text gives us the height of the 1st line of main-element`s text | |
display: inline-block; | |
background: url(youricon.png) no-repeat; |
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
When trying to catch event that fires on rendering the v-html you should be aware of that its actually renders html ONLY AFTER ANIMATION/TRANSTION is finished. So, thats why you need to create setTimeout. Just try to omit <transition> and see that it catch rendering correctly |
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
function current_url() | |
{ | |
$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
$validURL = str_replace("&", "&", $url); | |
return $validURL; | |
} |
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
<form method="GET" action="/url-of-your-current-page/"> | |
<input type="text" name="search" class="search-string" placeholder=""> | |
<a class="search-clear"><i class="fa fa-times-circle" aria-hidden="true"></i> | |
</a> | |
<button type="submit">Search</button> | |
</form> | |
//search block js | |
function getUrlParameter(name) { | |
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); |
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
$search_str = get_query_var('search') ? get_query_var('search') : ''; // get string from url ?search=search_string (e.g. that what is submitted by ordinary form) | |
$args = array( | |
's' => $search_str //add parameter to query args | |
); | |
$the_query = new WP_Query($args); // standart WP query call |
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
window.location.href = window.location.href.split('?')[0] |
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
uniqueValuesArray = inputArray.filter(function(item, pos) { | |
return inputArray.indexOf(item) == pos; | |
}) | |
//slightly different | |
uniqueValuesArray = inputArray.filter(function(item, pos, self) { | |
return self.indexOf(item) == pos; | |
}) |