Skip to content

Instantly share code, notes, and snippets.

View louisremi's full-sized avatar

Louis-Rémi Babé louisremi

View GitHub Profile
// -----------------------------------------------------------------
// To be added to CmdUtils API
// -----------------------------------------------------------------
// ** {{{ CmdUtils.getUbiquity( ) }}} **
//
// Get a reference to Ubiquity. This is used by
// {{{ CmdUtils.closeUbiquity() }}} and {{{ CmdUtils.getCommandByName() }}}, but
// probably doesn't need to be used directly by command feeds.
(function(jQuery){
// This shortTermMemory will contain the last parsed simple selector.
// To be usefull it needs to be accessed faster than it would take to re-parse the selector.
// Selectors are to complex to serve as keys of a hash, and a bi-dimensional array would be too slow.
// I'm wondering if .data() would be fast enough for that purpose.
var shortTermMemory = [];
jQuery.fn.extend({
closest: function( selector, context ) {
(function(jQuery){
var parsedCache = [],
_filter = jQuery.filter;
jQuery.filter = jQuery.multiFilter = function( expr, elems, not ) {
var parsed = [], split, re, matches = [], match, l, i;
// We are looking for simple selectors of the form "div", ".class" or "div.class"
// We'll try to minimize the extra-processing for complex selectors
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Over and Out test page</title>
<link rel="stylesheet" type="text/css" media="all" href="shCore.css" />
<link rel="stylesheet" type="text/css" media="all" href="shThemeFadeToGrey.css" />
<style>
.deco {
padding: 5px;
Index: event.js
===================================================================
--- event.js (revision 6582)
+++ event.js (working copy)
@@ -7,7 +7,7 @@
// Bind an event to an element
// Original by Dean Edwards
- add: function( elem, types, handler, data ) {
+ add: function( elem, types, handler, data, noSpecial ) {
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Bubbling test</title>
<style>
.test li {
margin-left: 3em;
width: 200px;
}
var
abs = Math.abs,
sqrt = Math.sqrt,
floor = Math.floor,
min = Math.min,
V3 = function(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
// Minimalist class (className) manipulation library
var klass = {
has: function(elem, name) {
return (' '+elem.className+' ').indexOf(' '+name+' ') != -1;
},
add: function(elem, name) {
if(!klass.has(elem, name)) {
elem.className += ' '+name;
}
},
(function($) {
var div = document.createElement('div'),
divStyle = div.style,
support = $.support,
rmatrixFilter = /M\d{2}=([\d+.\-]+)/g;
support.transform =
divStyle.MozTransform === ''? 'MozTransform' :
(divStyle.WebkitTransform === ''? 'WebkitTransform' :
@louisremi
louisremi / which form.js
Created February 23, 2011 07:39
Why is IE9 Another Thorn in our Side?
/*
* margin-top or marginTop?
* When to use lower-case and camel-case property names in JavaScript.
*/
// Setting style: camel-case
elem.style.marginTop = '10px';
// Getting style: camel-case
var value = elem.style.marginTop;