Skip to content

Instantly share code, notes, and snippets.

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

Markus Schober maxxscho

🏠
Working from home
View GitHub Profile
@maxxscho
maxxscho / _validateDateDACH.js
Last active August 29, 2015 14:07
jQuery Validate additional validation for dates in the format dd.mm.yyyy
/* Additional method for jquery validate
Valiate dates in the format dd.mm.yyyy
------------------------------------- */
jQuery.validator.addMethod(
"dateDECH",
function(value, element) {
var check = false;
var re = /^\d{1,2}\.\d{1,2}\.\d{4}$/;
if( re.test(value)){
var adata = value.split('.');
@maxxscho
maxxscho / _font-size.scss
Created December 5, 2014 07:52
Font size mixin for rem values with pixel fallback for old browsers
// REM output based on the $em-base variable with pixel fallback
@mixin font-size($pxVal) {
@if not unitless($pxVal) {
$pxVal: strip-unit($pxVal);
}
font-size: $pxVal * 1px;
font-size: rem($pxVal);
}
@maxxscho
maxxscho / _center-block.scss
Created December 5, 2014 09:15
Centers a block element
// Center a block element
@mixin center-block {
display: block;
margin-right: auto;
margin-left: auto;
}
@maxxscho
maxxscho / _center-vertical.scss
Last active January 7, 2016 14:58
Centering the unknown
// Center a block element width unknown
// height and width horizontally and vertically
// If it doesn't center vertically, play with the spacing.
// <div class="parent">
// <div class="child">....</div>
// </div>
//
// .parent {
// ... your styles here....
// text-align:center; // if you need horizontally spacing
@maxxscho
maxxscho / change-browser-name.js
Created December 11, 2014 13:25
Change browser tab name on blur
window.onblur = function () { document.title = 'you went?'; }
window.onfocus = function () { document.title = 'you came back'; }
@maxxscho
maxxscho / SubmenFirstWalker.php
Created January 5, 2015 09:13
Menu Walker for wordpress, that changes the order of items, which have a submenu. The submenu is first (standard is anchor first)
<?php
/**
* Class SubmenuFirstWalker
* This walker changes the order of elements, if they have a submenu
* Standard is anchor than the submenu. Wth this walker, the submenu gets rendered first.
* There is one new filter 'walker_nav_menu_end_el'
* @author Markus Schober
*/
class SubmenuFirstWalker extends Walker_Nav_Menu {
@maxxscho
maxxscho / passwordGenerator.php
Last active August 29, 2015 14:13
Password generator method
<?php
/**
* Generate Password with a given length and strength
*
* @param int $length
* @param int $strength
* @return string
*/
function generatePassword($length = 9, $strength = 4)
@maxxscho
maxxscho / the_field_if.php
Created January 22, 2015 13:45
Echo a field of Advanced Custom Fields, if it is present. You may prepend and append it with custom strings (HTML ;) )
<?php
/**
* Echo an ACF Field if it is present
* @param bool|int $field Name of the field
* @param string $before prepend the field with this string. HTML for example
* @param string $after append the field with this string. HTML for example
* @param bool|int $post_id
*
* @return bool|void
@maxxscho
maxxscho / script.js
Last active August 29, 2015 14:14
jQuery Autoscroll on hashed links
// Auto scroll
// -------------------------------------
$('a[href^=#]').on('click', function(e) {
e.preventDefault();
var $this = $(this),
target = $this.attr('href');
if(target && target !== "#") {
$('html, body').animate({
@maxxscho
maxxscho / _animated_underline.scss
Last active August 29, 2015 14:14
Animated underline on link hover mixin
/**
Adds an animated underline hover effect
a {
@include animated-underline(#000000);
// your styles here
}
*/
@mixin animated-underline($color: $color__link, $bottom: 3px, $height: 1px) {
position: relative;
display: inline-block;