Skip to content

Instantly share code, notes, and snippets.

View jbutko's full-sized avatar

Jozef Butko jbutko

View GitHub Profile
@jbutko
jbutko / scripts.js
Created March 29, 2014 13:13
jQuery: jQuery add and remove class on a menu/nav
$(function(){
$(".navtab>li").click(function(){
$(this).addClass('selected').siblings().removeClass('selected');
});
});
// From http://stackoverflow.com/questions/12606784/jquery-add-and-remove-class-on-a-menu
@jbutko
jbutko / index.php
Created March 29, 2014 19:41
WP: Get pount position in total post count
$numposts = wp_count_posts('post');
echo $numposts->publish;
// From http://wordpress.org/support/topic/get-pount-position-in-total-post-count?replies=5
@jbutko
jbutko / index.php
Created March 29, 2014 19:45
WP, single.php: Post X of Y in single.php / Post Counter
class MY_Post_Numbers {
private $count = 0;
private $posts = array();
public function display_count() {
$this->init(); // prevent unnecessary queries
$id = get_the_ID();
echo sprintf( '<div class="post-counter">Post number<span class="num">%s</span><span class="slash">/</span><span class="total">%s</span></div>', $this->posts[$id], $this->count );
}
@jbutko
jbutko / scripts.js
Created April 5, 2014 20:58
javaScript: Get position in viewport coordinates
element.getBoundingClientRect(); // Get position in viewport coordinates
// From http://stackoverflow.com/questions/1567327/using-jquery-to-get-elements-position-relative-to-viewport
@jbutko
jbutko / index.php
Created April 6, 2014 10:32
WP, wp-admin: Add admin favicon
function pa_admin_area_favicon() {
echo '<link rel="shortcut icon" href="http://cdn.alex.leonard.ie/favicon.ico" />';
}
add_action('admin_head', 'pa_admin_area_favicon');
// From http://alex.leonard.ie/2012/05/24/wordpress-admin-area-favicon/
@jbutko
jbutko / styles.scss
Created April 10, 2014 17:35
SASS, SCSS, CSS: Select all elements on the same node level
.second {
.first ~ & {
/* styles to be applied to .second if a .first exists at the same node level */
}
}
// From http://stackoverflow.com/questions/15246387/css-and-or-sass-sibling-selector-upwards
@jbutko
jbutko / new_gist_file.ps1
Created April 13, 2014 11:51
Git, GitHub: Remove the directory only from the repository
$ git rm -r --cached .idea
#From https://coderwall.com/p/qaiaog
@jbutko
jbutko / scripts.js
Created April 14, 2014 16:29
jQuery: Get index of hovered element
$(document).ready(function () {
$('.around li').hover(function () {
var index = $('.around li').index(this);
console.log(index);
}, function () { });
});
// From http://stackoverflow.com/questions/11294012/jquery-get-index-of-hovered-li
@jbutko
jbutko / scripts.js
Created April 15, 2014 14:06
jQuery, JS: Detect Safari using jQuery/JS
var is_safari = navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1 && navigator.userAgent.indexOf('Android') == -1;
if (is_safari) {
// /* On folder hover lower featured image z-index and almost hide all folder icons */
$('.folder-image').hover(function() {
}, function() {
});
}
@jbutko
jbutko / style.css
Created April 20, 2014 16:24
CSS: Overflow-x value ignored in mobile Safari FIX
html {
/* This has to be added to html CSS */
overflow: hidden;
}
body {
overflow-x: hidden;
}
/* From http://stackoverflow.com/questions/17767176/overflow-x-value-ignored-in-mobile-safari */