Skip to content

Instantly share code, notes, and snippets.

@lakenen
lakenen / CSSMatrix-example.js
Created March 27, 2013 19:23
CSSMatrix examples
// include https://github.com/camupod/CSSMatrix/blob/browserified/CSSMatrix.js
// create a matrix from a CSS matrix transform string
var matrix1 = new CSSMatrix('matrix(1, 2, 3, 4, 5, 6)');
var matrix2 = new CSSMatrix('matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)');
// create a matrix from matrix values
var matrix3 = new CSSMatrix(1, 2, 3, 4, 5, 6);
var matrix4 = new CSSMatrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
@lakenen
lakenen / page-svg.css
Created March 27, 2013 06:22
Crocodoc 3D Demo #4
/* ... */
.crocodoc-page-svg {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
@lakenen
lakenen / jquery.xdr.js
Created March 27, 2013 06:08
jQuery XDR for IE
(function ($) {
"use strict";
if (window.XDomainRequest) {
$.ajaxTransport(function(s) {
if (s.crossDomain && s.async) {
if (s.timeout) {
s.xdrTimeout = s.timeout;
delete s.timeout;
}
var xdr;
@lakenen
lakenen / page-affine.js
Created March 27, 2013 05:52
Crocodoc 3D Demo #3
function Page($el) {
// we need a new variable to determine if we should use
// 3d or 2d mode
var affine = !browserSupports3dTransforms();
/* ... */
// small changes to updateLayers and applyTransform
updateLayers = function () {
// detect if the page is flipped backwards
@lakenen
lakenen / page-transitions.css
Last active December 15, 2015 11:19
Crocodoc 3D Demo #2
/* ... */
.page-transitions .page-layer {
/* cheating a bit and adding a transition to "all" properties */
transition: all 0.3s;
}
.page-layer:first-child,
.page-exploded .page-layer {
background: rgba(255,255,255,0.03);
@lakenen
lakenen / demo1.html
Last active December 15, 2015 11:19
Crocodoc 3D Demo #1
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Demo</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="CSSMatrix.js"></script>
<style>
body {
background-color: #282828;
@lakenen
lakenen / importNode.js
Created March 14, 2013 21:55
document.importNode shim for IE <= 9. Started with http://stackoverflow.com/questions/1811116/ie-support-for-dom-importnode/9883539#9883539, modified to fix issues (http://stackoverflow.com/questions/14593520/ie9-importing-inline-svg-image-elements-broken) with importing image nodes and other nodes with namespaced:attributes
function importNode(node, allChildren, doc) {
var a, i, il;
doc = doc || document;
try {
return doc.importNode(node, allChildren);
} catch (e) {
switch (node.nodeType) {
case document.ELEMENT_NODE:
var newNode = doc.createElementNS(node.namespaceURI, node.nodeName);
if (node.attributes && node.attributes.length > 0) {
@lakenen
lakenen / crocodoc-node test results
Created February 1, 2013 18:20
mocha test results showing 460 passing for crocodoc-node (https://github.com/NetDevLtd/crocodoc-node)
$ make test
NODE_PATH="`pwd`:" ./node_modules/.bin/mocha test/specs | tee test/results/tests.log
path.existsSync is now called `fs.existsSync`.
mocha example (using framework)
Array
#indexOf()
✓ should return -1 when the value is not present
@lakenen
lakenen / getTextBoundingRect.js
Created December 3, 2012 02:26
Get cursor or text position in pixels for input element
// @author Rob W http://stackoverflow.com/users/938089/rob-w
// @name getTextBoundingRect
// @param input Required HTMLElement with `value` attribute
// @param selectionStart Optional number: Start offset. Default 0
// @param selectionEnd Optional number: End offset. Default selectionStart
// @param debug Optional boolean. If true, the created test layer
// will not be removed.
function getTextBoundingRect(input, selectionStart, selectionEnd, debug) {
// Basic parameter validation
if(!input || !('value' in input)) return input;
@lakenen
lakenen / script.coffeescript
Created September 28, 2012 00:20
Pulls posts from http://reddit.com/r/nocontext and shows them nicely.
TEXT_DISPLAY_TIME = 10000
delay = (ms, fn) -> setTimeout fn, ms
class NoContexts
constructor: ->
@next()
refreshData: (cb) ->
@noContexts = []