Skip to content

Instantly share code, notes, and snippets.

View fenda's full-sized avatar

Fernanda Sampaio fenda

View GitHub Profile
@fenda
fenda / equalHeight
Last active December 18, 2015 09:59
Equal height to elements.
//author csa
jQuery.fn.equalHeight = function(tab){
try{
var elemHeight = new Array();
$(this).each(function() {
altura = $(this).outerHeight(true);
elemHeight.push(altura);
});
var maior = elemHeight.sort(function(a,b){return a - b}).slice(-1);
$(this).css({height: maior + "px"});
@fenda
fenda / Query URL parameter
Last active December 21, 2015 00:49
function to get a query string parameter
$.getQuerystring = function(key, default_) {
if (default_ == null) default_ = "";
key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
var qs = regex.exec(decodeURIComponent(window.location.href));
if (qs == null)
return default_;
else
return qs[1];
};
@fenda
fenda / youtube video id from URL
Created August 13, 2013 20:05
get youtube video id from URL
// from http://lasnv.net/
<script type="text/javascript">
function youtube_parser(url){
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var match = url.match(regExp);
if (match&&match[7].length==11){
return match[7];
}else{
alert("Url incorrecta");
@fenda
fenda / Detect zoom and hide element
Created October 7, 2013 14:02
Hide elements when page is zoomed
var zoomOri = document.documentElement.clientWidth / window.innerWidth;
var zoomCurrent = zoomOri;
$(window).resize(function() {
var zoomNew = document.documentElement.clientWidth / window.innerWidth;
if (zoomOri != zoomNew && zoomNew != zoomCurrent) {
$('.yourclass').hide();
} else if (zoomOri == zoomNew && zoomNew != zoomCurrent) {
$('.yourclass').show();
}
zoomCurrent = zoomNew
@fenda
fenda / .htaccess (file extension)
Last active June 6, 2023 13:27
remove file extension from url
# The following will allow you to use URLs such as the following:
#
# example.com/link
# example.com/link/
#
# Which will actually serve files such as the following:
#
# example.com/link.html
# example.com/link.php
#
@fenda
fenda / normalize.min.css
Created October 27, 2014 14:52
Normalize minified
/*! normalize.css 2012-02-07T12:37 UTC - http://github.com/necolas/normalize.css */article,aside,details,figcaption,figure,footer,header,hgroup,nav,section,summary{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}[hidden]{display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}html,button,input,select,textarea{font-family:sans-serif}body{margin:0}a:focus{outline:thin dotted}a:hover,a:active{outline:0}h1{font-size:2em;margin:.67em 0}h2{font-size:1.5em;margin:.83em 0}h3{font-size:1.17em;margin:1em 0}h4{font-size:1em;margin:1.33em 0}h5{font-size:.83em;margin:1.67em 0}h6{font-size:.75em;margin:2.33em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}blockquote{margin:1em 40px}dfn{font-style:italic}mark{background:#ff0;color:#000}p,pre{margin:1em 0}pre,code,kbd,samp{font-family:monospace,serif;_font-family:'courier new',monospace;font-size:1em}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word
@fenda
fenda / comma.js
Created October 25, 2015 15:09
add space after comma
$('.el').each(function() {
var string = $(this).html();
$(this).html(string.replace(/,/g , ', '));
});
@fenda
fenda / ftimage_title.php
Created October 28, 2015 01:56
Add title to Featured Images (Wordpress)
//add_filter( 'media_send_to_editor', 'inserted_image_titles', 15, 2 );
function featured_image_titles($attr, $attachment = null){
$attr['title'] = get_post($attachment->ID)->post_title;
return $attr;
}
add_filter('wp_get_attachment_image_attributes', 'featured_image_titles', 10, 2);
@fenda
fenda / one_page.php
Last active August 5, 2016 16:24
One page Wordpress theme
<?php get_header(); ?>
<?php
query_posts('post_type=page');
while(have_posts() ) : the_post();
endwhile;
?>
<?php
$className = 'section1';
@fenda
fenda / Click outside el to hide el
Created December 28, 2015 21:37
Hide element when clicking outside itself
$(document).click(function(e){
if ($(e.target).parents('.el').length === 0) {
$('.el').fadeOut();
}
});