Skip to content

Instantly share code, notes, and snippets.

View cheeaun's full-sized avatar
📬
Subscribe to my newsletter https://cheeaun.substack.com/

Chee Aun cheeaun

📬
Subscribe to my newsletter https://cheeaun.substack.com/
View GitHub Profile
@cheeaun
cheeaun / Element.getOffsets.1.2.2.js
Created July 30, 2009 11:24
Restoring the old getOffsets from 1.2.2
(function(){
Element.implement({
getOffsets: function(){
if (Browser.Engine.trident){
var bound = this.getBoundingClientRect(), html = this.getDocument().documentElement;
var isFixed = styleString(this, 'position') == 'fixed';
return {
x: bound.left + ((isFixed) ? 0 : html.scrollLeft) - html.clientLeft,
@cheeaun
cheeaun / Element.unsetStyle.js
Created August 17, 2009 02:38
MooTools Element.unsetStyle and unsetStyles (idea from @keeto)
Element.implement({
unsetStyle: function(property){
if (property == 'float') property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat';
property = property.camelCase();
delete this.style[property];
return this;
},
unsetStyles: function(properties){
Request.Twitter = new Class({
Extends: Request.JSONP,
options: {
linkify: true,
url: 'http://twitter.com/statuses/user_timeline/{term}.json',
data: {
count: 5
}
@cheeaun
cheeaun / chromeFrameIsAvailable.js
Created September 23, 2009 03:10
Javascript code to check if Chrome Frame is available.
var chromeFrameIsAvailable = (function(){
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('chromeframe') >= 0 || ua.indexOf('x-clock') >= 0) return true;
if (typeof window.ActiveXObject != 'undefined') try {
if (new ActiveXObject('ChromeTab.ChromeFrame')) return true;
} catch(e) {};
return false;
})();
@cheeaun
cheeaun / hide-hide-facebook.css
Created September 23, 2009 05:39
Hide 'Hide' button userstyle (Stylish)
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("facebook.com") {
.UIStory .UIStory_Hide{
display: none !important;
}
.UIStory[data-ft*=app_id] .UIStory_Hide{
display: block !important;
}
.UIStory[data-ft*=app_id] .UIActionMenu_Menu .UISelectList .UISelectList_Item:first-child{
.post pre{
overflow: auto; /* IE might not like this, but who cares? */
padding: 1em;
color: inherit;
background-color: #FAFAFA;
}
@cheeaun
cheeaun / color.php
Created October 2, 2009 08:30
Color class for Kohana
<?php defined('SYSPATH') or die('No direct script access.');
class Color {
public static function hex_to_rgb($hex){
$pattern = '/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/';
preg_match($pattern, $hex, $matches);
$matches = array_slice($matches, 1);
if (!function_exists('map')){
function map($value){
@cheeaun
cheeaun / String.limitChars.js
Created October 8, 2009 06:40
MooTools String.limitChars with 'preserve words' option, stolen from Kohana 3
// Port of Kohana3's Text::limit_chars helper
String.implement({
limitChars: function(limit, options){
var opts = {
endChar: null,
preserveWords: false
};
$extend(opts, options);
@cheeaun
cheeaun / Array.insensitiveSort.js
Created October 9, 2009 15:58
Array.insensitiveSort in MooTools
// http://pushingbuttons.net/?ArrayinsensitiveSort_in_MooTools
Array.implement({
insensitiveSort: function(){
return this.sort(function(a, b){
return a.toString().toLowerCase()>b.toString().toLowerCase();
});
}
@cheeaun
cheeaun / Element.disposeSelf.destroySelf.js
Created October 19, 2009 04:44
Element.disposeSelf and Element.destroySelf - removes an element without removing its content
(function(){
var moveContent = function(element){
var nodes = $A(element.childNodes);
var parent = element.parentNode;
for (var i=0, l=nodes.length; i<l; i++){
parent.insertBefore(nodes[i], element);
}
};