Skip to content

Instantly share code, notes, and snippets.

View Haraldson's full-sized avatar

Hein Haraldson Berg Haraldson

View GitHub Profile
@Haraldson
Haraldson / tracking.js
Created November 16, 2012 11:14
Fjord Tours tracking hack
if(!Array.prototype.indexOf)
{
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
"use strict";
if (this == null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (len === 0) {
@Haraldson
Haraldson / ekornes-flip-rotation.js
Created February 24, 2013 18:31
Forsiderotasjon som sett på ekornes.no (nettstedet er senere flyttet, men utseende og funksjonalitet er bevart).
if(typeof jQuery !== 'undefined')
{
function FlipRotation(args)
{
if($(args.selector.wrap).length)
{
this.initialize(args);
}
}
@Haraldson
Haraldson / jQuery.genericContentFader.js
Created February 24, 2013 20:12
Generell innholdsfader.
var GenericFader = function(args)
{
if($(args.selector.wrap).length)
{
this.initialize(args);
}
};
GenericFader.prototype = {
initialize: function(args)
@Haraldson
Haraldson / jQuery.inputTextReplacer.js
Created February 24, 2013 20:16
Generelt script for hjelpetekster som verdier i skjemafelter, for nettlesere hvor HTML5s placeholder-attributt ikke støttes.
(function($)
{
var SemanticInputTextReplacer = function(args)
{
if($(args.inputs).length > 0)
this.init(args);
};
SemanticInputTextReplacer.prototype = {
placeholderSupport: false,
var Slider = function(args)
{
this.initialize(args);
}
Slider.prototype = {
initialize: function(args)
{
this.setSliderWidth(args);
@Haraldson
Haraldson / ekornes-tabs.js
Created February 24, 2013 22:40
Faner med AJAX-innlasting av innhold som sett på ekornes.no før nettstedet ble flyttet.
if(typeof jQuery !== 'undefined')
{
function Tabs(args)
{
if($(args.selector.wrap).length)
{
this.init(args);
}
}
@Haraldson
Haraldson / imagegallery.php
Created February 24, 2013 22:44
Bildegalleri som baserer seg på at bilder hentes fra DAM basert på tags som lagres av redaktør i CMS.
<?php
require_once(CLASSES_ROOT.'/mediabase/api/kmcontroller.php');
require_once(CLASSES_ROOT.'/mediabase/keymedia.php');
require_once(CLASSES_ROOT.'/system/mediabase/kpmediabase.php');
class CustomerImageGalleryGUI
{
protected $mb;
protected $tpl;
@Haraldson
Haraldson / product.html.twig
Created May 2, 2013 12:31
Failing product template
{% extends noLayout ? viewbaseLayout : 'KTQProductSitesBundle::pagelayout.html.twig' %}
{% block content %}
{% set pricesOrderContentId = content.getField('link_prices_order').value.destinationContentId %}
{% set freeTrialContentId = content.getField('link_free_trial').value.destinationContentId %}
<div class="product landing span12">
<div class="row">
<div class="header span12">
<div class="row">
<div class="span5">
<h1>{{ ez_render_field(content, 'name') }}</h1>
@Haraldson
Haraldson / gist:5501897
Created May 2, 2013 12:33
Stack trace: Twig_Error_Runtime
in kernel.root_dir/cache/dev/classes.php at line 6047
at Twig_Template ->displayWithErrorHandling (array('noLayout' => true, 'content' => object(Content), 'viewbaseLayout' => 'EzPublishCoreBundle::viewbase_layout.html.twig', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => true), 'ezpublish' => object(GlobalHelper), 'app' => object(GlobalVariables)), array())
in kernel.root_dir/cache/dev/classes.php at line 6017
at Twig_Template ->display (array('noLayout' => true, 'content' => object(Content), 'viewbaseLayout' => 'EzPublishCoreBundle::viewbase_layout.html.twig'))
in kernel.root_dir/cache/dev/classes.php at line 6024
at Twig_Template ->render (array('noLayout' => true, 'content' => object(Content), 'viewbaseLayout' => 'EzPublishCoreBundle::viewbase_layout.html.twig'))
in /Users/hhb/www/ez5-projects/product-sites/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php at line 53
at TwigEngine ->render ('KTQProductSitesBundle:particles:link.html.
protected $serviceContainer;
protected $pageService;
public function __construct($serviceContainer)
{
$this->serviceContainer = $serviceContainer;
$this->pageService = $this->serviceContainer->getPageService();
}