Skip to content

Instantly share code, notes, and snippets.

// Controls events for panel menu.
// We use context here on click events to compensate for a stupid bug in views ajax.
Drupal.behaviors.menuPanelBehavior = {
attach: function(context, settings) {
$(document).ready(function() {
$('body', context).click(function(e) {
// Ignore click on search box.
if (e.target.id == "edit-search-block-form--2") {
return;
}
@tracend
tracend / handlebars.localisation.js
Last active October 16, 2018 18:11
Handlebars Localisation Helper #cc
// Handlebars Localisation Helper
// Source: https://gist.github.com/tracend/3261055
Handlebars.registerHelper('l10n', function(keyword) {
var lang = (navigator.language) ? navigator.language : navigator.userLanguage;
// pick the right dictionary (if only one available assume it's the right one...)
var locale = window.locale[lang] || window.locale['en-US'] || window.locale || false;
// exit now if there's no data
if( !locale ) return target;
@runceel
runceel / gist:2437116
Created April 21, 2012 13:38
WinRT ICommand implementation
using System;
using System.Collections.Generic;
using System.Windows.Input;
namespace Application3.Common
{
class DelegateCommand : ICommand
{
private static readonly Action EmptyExecute = () => { };
private static readonly Func<bool> EmptyCanExecute = () => true;
@davidfowl
davidfowl / Examples
Created May 21, 2011 08:19
Powershell function that recursively walks all project items within a project and lets you execute an action on each one
# Print all project items
Recurse-Project -Action {param($item) "`"$($item.ProjectItem.Name)`" is a $($item.Type)" }
# Function to format all documents based on https://gist.github.com/984353
function Format-Document {
param(
[parameter(ValueFromPipelineByPropertyName = $true)]
[string[]]$ProjectName
)
Process {