Skip to content

Instantly share code, notes, and snippets.

View Bellfalasch's full-sized avatar

Bobby Westberg Bellfalasch

View GitHub Profile
@Bellfalasch
Bellfalasch / page-template.xsl
Created June 9, 2015 10:34
page-template.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="#all" version="2.0" xmlns="http://www.w3.org/1999/xhtml"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:portal="http://www.enonic.com/cms/xslt/portal"
xmlns:stk="http://www.enonic.com/cms/xslt/stk">
<!-- HTML 5 doctype -->
<xsl:output doctype-system="about:legacy-compat" method="xhtml" encoding="utf-8" indent="no" omit-xml-declaration="yes" include-content-type="no"/>
@Bellfalasch
Bellfalasch / 3dbutton.css
Created March 13, 2015 10:52
Simple 3d button
/*
html:
<div class="test"></div>
*/
.test {
border: none;
border-bottom: 5px solid hsla(0,0%,0%,0.2);
/* border-left: 5px solid black;*/
border-radius: 50%;
@Bellfalasch
Bellfalasch / rotate-image.js
Created February 9, 2015 09:49
Rotate an image on click (nice "load" animation)
// Rotate image
// http://stackoverflow.com/questions/15191058/css-rotation-cross-browser-with-jquery-animate
// Call: $('#loadmore span').animateRotate( 360, 500, 'swing', null );
$.fn.animateRotate = function(angle, duration, easing, complete) {
var args = $.speed(duration, easing, complete);
var step = args.step;
return this.each(function(i, e) {
args.step = function(now) {
@Bellfalasch
Bellfalasch / equalHeight2.js
Created September 25, 2014 13:50
equalHeightAdjacents v2 - make objects in a two column list equal height horizontally OR a three column list equal height
// Divs (or whatever) floating side by side on rows of 2 or 3 each need to have equal height to float pretty. Majsonry-plugins doesn't make them equal height even though they handle the float-issues. This snippet makes all boxes on the same row equal height by finding the tallest box and setting the others to the same height.
// Disclaimer: should have been rewritten to arrays to support any amount of columns ... but yeah, "tomorrow" right? ;P
// If you toggle visibility on elements, re-call this function again like so:
// equalHeightAdjacents( $(".cards:visible") );
function equalHeightAdjacents( elems ) {
// Make Tema cards equal height per row so we don't get holes when using float
var cardleft, cardmid, cardright;
var cardleft_h = 0;
@Bellfalasch
Bellfalasch / datatables_export.js
Last active August 29, 2015 14:06
Take an entire DataTable object and create a CSV output from it, skipping filtered rows, but showing all the columns (except the ones you select specifically in the code to not show).
// Setup: Just send your DataTables object (oTable) into this function onclick on some button.
// Inspired by this source, but more or less completely re-written because we need to respect filters on tables
// http://datatables.net/forums/discussion/11984/simple-csv-export-with-jquery-php
function table2csv(oTable) {
var csv = '';
var text;
var headers = [];
var columns = [];
@Bellfalasch
Bellfalasch / arrowbuttons.css
Created August 26, 2014 12:05
Create arrow-buttons in a from-stepA-to-stepB-style. White with gray borders. Doesn't work in Chrome with the vertical alignment dislocating the ::before and ::after-things. Can use a lot of improvements overall.
/*
html:
<div class="button arrow active">
<span>Title</span>
</div>
*/
.button:focus {
outline: none;
}
.button.arrow.active {
@Bellfalasch
Bellfalasch / equalHeightAdjacents.js
Created August 26, 2014 11:58
equalHeightAdjacents - make objects in a two column list equal height horizontally
function equalHeightAdjacents( elems ) {
// Make Tema cards equal height per row so we don't get holes when using float
var odd = true;
var cardleft = 0;
var cardright = 0;
var cardleft_h = 0;
var cardright_h = 0;
$(elems).each( function() {
@Bellfalasch
Bellfalasch / placeholder.js
Created May 22, 2014 08:23
Enables you to use the placeholder attribute on input fields in IE9 and older without any semantic changes
// 1. Use the placeholder attribute just as normal on html5 elements, most browsers will understand
// 2. The code checks if placeholder is supported, if not it will mimic the behaviour
// 3. The class ".placeholder" is added to the mimiced text, so you can style it "color: gray" in your CSS to make it all be just like in modern browsers =D
// Source: http://www.cssnewbie.com/cross-browser-support-for-html5-placeholder-text-in-forms#.U3styFiSzck
jQuery(function() {
jQuery.support.placeholder = false;
test = document.createElement('input');
if('placeholder' in test) jQuery.support.placeholder = true;
@Bellfalasch
Bellfalasch / image-previewer.js
Last active August 29, 2015 13:57
Goes through every image in a page on certain html nodes and adds quick preview functionality to linked content. Centers image h and v onload, mouseout to close, or click body to close.
function createImagePreview() {
// Create one element to hold the popup image
var $popup = $("<div>");
$popup.attr("class","img-popup");
$popup.mouseover( function() {
$(this).mouseout( function() {
$(this).fadeOut();
});
@Bellfalasch
Bellfalasch / ingresspopup.js
Created February 17, 2014 12:03
A small preview snippet to hide/show some html on mouseover - with a timeout!
// Function that RutineBiblioteket uses to create small popups/previews for Rutine ingresser.
// Called when Ajax-request for menu filtered listing of Rutiner is done.
function ingresspopup() {
var timer;
var denna;
$("#rutine-list td > a.popup").hover( function() {
denna = $(this);