Skip to content

Instantly share code, notes, and snippets.

View rafalborowski's full-sized avatar
🏠
Working from home

Rafal Borowski rafalborowski

🏠
Working from home
View GitHub Profile
@rafalborowski
rafalborowski / comment-fn.php
Created May 17, 2013 12:04
Comment display func
<?php
/**************************************************
* Function to Display Comments
***************************************************/
function display_all_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
if (get_comment_type() == 'pingback' || get_comment_type() == 'trackback') : ?>
<li id="comment-<?php comment_ID(); ?>" class="comment">
@rafalborowski
rafalborowski / new_gist_file
Created May 17, 2013 12:01
Add a template directory as a var that you can use in jQuery/JavaScript
<script type="text/javascript">
var wp_template_dir = "<?php echo get_stylesheet_directory_uri(); ?>";
</script>
/*
selectivizr v1.0.3b - (c) Keith Clark, freely distributable under the terms
of the MIT license.
selectivizr.com
*/
/*
Notes about this source
-----------------------
/*
HTML5 Shiv v3.6.2pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
Uncompressed source: https://github.com/aFarkas/html5shiv
*/
(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.
@rafalborowski
rafalborowski / html-template.html
Created May 16, 2013 16:45
Html start template for bootstrap (needs update)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Set latest rendering mode for IE -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Title</title>
<!-- Set viewport for mobile devices to zoom to 100% and turn off user privileges to scale -->
@rafalborowski
rafalborowski / retina-images.js
Created May 16, 2013 16:34
Image replacement for retina devices and other devices. Images should be placed in "normal" and "retina" folders.
jQuery(document).ready(function(){
if (window.devicePixelRatio > 1) {
var images = jQuery('img');
images.each(function(i) {
var lowres = jQuery(this).attr('src');
var highres = lowres.replace("normal", "retina");
jQuery(this).attr('src', highres);
});
}
@rafalborowski
rafalborowski / mobile-menu.js
Created May 16, 2013 16:23
Clones menu to a new container and adds show/hide to mobile nav button
/* Mobile menu toggle */
jQuery(document).ready(function(){
var mobileNavButton = jQuery('.mobile-nav-button'),
mobileNav = jQuery('.mobile-nav');
jQuery('header nav ul:first-child')
.clone().appendTo(mobileNav)
.removeClass('hidden-phone')
.addClass('visible-phone');
@rafalborowski
rafalborowski / scroll-to-top.js
Created May 16, 2013 16:14
Scroll to top button. Create an empty div in the footer with a "go-top" class.
/* Scroll to top */
jQuery(document).ready(function(){
jQuery('nav ul li a').click(function(){
var el = jQuery(this).attr('href');
var elWrapped = jQuery(el);
scrollToDiv(elWrapped,40);
return false;
});
@rafalborowski
rafalborowski / google-analytics.js
Created May 16, 2013 16:02
Google Analytics Code
/* Google Analytics Code */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
@rafalborowski
rafalborowski / fn.exists.js
Created May 16, 2013 15:59
Function for checking if container exists,
/* Function */
jQuery.fn.exists = function() {
return this.length>0;
}
/* Usage */
jQuery(document).ready(function(){
if (jQuery(".container").exists()) {
jQuery(".container").dosomething();
}