Skip to content

Instantly share code, notes, and snippets.

View sebmarkbage's full-sized avatar

Sebastian Markbåge sebmarkbage

View GitHub Profile
// Array shuffle for MooTools
Array.implement({
shuffle: function(){
for (var i = this.length; i && --i;){
var temp = this[i], r = Math.floor(Math.random() * ( i + 1 ));
this[i] = this[r];
this[r] = temp;
}
@sebmarkbage
sebmarkbage / cat.js
Last active December 14, 2015 14:58 — forked from dherman/cat.js
// EXAMPLE: a compound iterator with sequencing
// Python style
function cat() {
let is = arguments;
return {
next: {
let length;
while ((length = is.length) > 0) {
try {
<html>
<head>
<script src="mootools.js"></script>
<script src="mootools-1.2.4.4-more.js"></script>
<script src="rx.js"></script>
<script src="rx.mootools.js"></script>
<script>
window.addEvent('domready', function() {
PRELOADING REQUIRED:
Sheer({
original: 'urn:Sheer:Lang:Array',
require: {
'urn:Sheer:Lang': ['Type', 'Object', 'Function']
}
}, function(Type, Object, Function) {
/*=
name: Animation
description: Simple animations implementation that work with standard-sized browsers (using Fx) and use webkit css animations where available.
license: MooTools MIT-Style License (http://mootools.net/license.txt)
copyright: Valerio Proietti (http://mad4milk.net)
authors: Valerio Proietti (http://mad4milk.net)
requires: MooTools 1.2.3+ (Core) (http://mootools.net/download)
=*/
var Animation = new Class({
Element.implement({
/**
truncates element text to fit in element width.
end (bool) defaults false. True = cuts string at end, False = cuts string in middle
str (string) truncation string default : '...'
**/
truncate : function(end,str){
str = str || '...';
var style = this.style;
var originalStyles = { overflow: style.overflow, 'white-space': style.whiteSpace, padding: style.padding };