Skip to content

Instantly share code, notes, and snippets.

View MartijnR's full-sized avatar

Martijn van de Rijdt MartijnR

View GitHub Profile
@MartijnR
MartijnR / jq_plugin_template
Last active December 10, 2015 07:08
jQuery plugin
(function($) {
"use strict";
var MyWidget = function(element, options) {
this.init();
};
GeopointWidget.prototype = {
constructor: GeopointWidget,
@MartijnR
MartijnR / resize_stop_event
Last active December 10, 2015 07:18
resizestop event
$(window).on('resize', function(){
var resizeCount = $(window).data('resizecount') || 0;
resizeCount++;
$(window).data('resizecount', resizeCount);
window.setTimeout(function(){
if (resizeCount == $(window).data('resizecount')){
$(window).data('resizecount', 0);
//do the things
console.debug('resizing stopped');
.........;
@MartijnR
MartijnR / table_widget_alt
Created December 28, 2012 23:28
table widget alternative
// var $row,
// $table = $('<table></table>'),
// $thead = $('<thead></thead>'),
// $tbody = $('<tbody></tbody>'),
// $header = $(this).find('.jr-appearance-label'),
// $content = $(this).find('.jr-appearance-list-nolabel');
//
// $row = createRow($header, 'th');
// $row.appendTo($thead);
// $thead.appendTo($table);//
@MartijnR
MartijnR / jquery.getXPath.js
Created March 8, 2013 19:00
Get XPath from jQuery element
/**
* Creates an XPath from a node (currently not used inside this Class (instead FormHTML.prototype.generateName is used) but will be in future);
* @param {string=} rootNodeName if absent the root is #document
* @return {string} XPath
*/
$.fn.getXPath = function(rootNodeName){
//other nodes may have the same XPath but because this function is used to determine the corresponding input name of a data node, index is not included
var position,
$node = this.first(),
nodeName = $node.prop('nodeName'),
(function($){
$.fn.takeOut = function($nodes){
return this.filter(function(){
for (var i = 0 ; i<$nodes.length ; i++){
if ($(this).is($nodes.eq(i))){
console.log('took out node: ', $(this));
return false;
}
}
return true;
@MartijnR
MartijnR / mardownToHtml.jquery.js
Last active December 17, 2015 17:19
mardownToHtml JQuery plugin
$.fn.markdownToHtml = function () {
return this.each(function () {
var html,
$childStore = $('<div/>');
$(this).children().each(function (index) {
var name = '$$$' + index;
$(this).clone().markdownToHtml().appendTo($childStore);
$(this).replaceWith(name);
});
html = $(this).html();
@MartijnR
MartijnR / hey-myf
Created September 13, 2013 18:05
Run this in browser console
[][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]][([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]]]+([][[]]+[])[+[[+!+[]]]]+(![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[+!+[]]]]+([][[]]+[])[+[[+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[
@MartijnR
MartijnR / hey-alex
Created September 13, 2013 18:11
Paste this in your browser console
[][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]][([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]]]+([][[]]+[])[+[[+!+[]]]]+(![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[+!+[]]]]+([][[]]+[])[+[[+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[
@MartijnR
MartijnR / enketo-compliant-widget-template
Last active September 5, 2017 16:12
Enketo-compliant Widget Template
'use strict';
/**
* My Fancy Widget
*
* A jQuery plugin form widget that is compatible with Enketo Smart Paper
* and extends a base Enketo Widget class (see https://github.com/enketo/enketo-core)
*/
var Widget = require('../../js/Widget');
@MartijnR
MartijnR / enketo-hints-tooltip
Created November 1, 2013 17:40
enketo-hints-tooltip
//add 'hint' icon, could be moved to XSLT, but is very fast even on super large forms - 31 msecs on bench6 form
if (!modernizr.touch){
$hint = '<span class="hint" ><i class="icon-question-sign"></i></span>';
$form.find('.jr-hint ~ input, .jr-hint ~ select, .jr-hint ~ textarea').before($hint);
$form.find('legend > .jr-hint').parent().find('span:last-child').after($hint);
$form.find('.trigger > .jr-hint').parent().find('span:last').after($hint);
}
/**
* setHints updates the hints. It is called whenever the language or output value is changed.