Skip to content

Instantly share code, notes, and snippets.

@akoppela
Created April 24, 2011 12:47
Show Gist options
  • Save akoppela/939526 to your computer and use it in GitHub Desktop.
Save akoppela/939526 to your computer and use it in GitHub Desktop.
-------------------------------------------
var mergeOne = function(source, key, current){
if (current && typeof(current) == 'object' && current.indexOf != stringish && current.exec != regexpish && !(current.nodeName && current.nodeType) && (!current.$family || current.$family() == 'object')) {
console.info(current.clone);
if (current.indexOf != arrayish) {
var target = source[key];
if (target && typeof(target) == 'object' && current.indexOf != stringish && target.exec != regexpish && target.indexOf != arrayish) Object.merge(source[key], current)
else source[key] = Object.clone(current);
} else source[key] = current.clone();
} else source[key] = current;
return source;
};
String: "} else source[key] = current.clone();"
Error: "current.clone is undefined"
Fix: "} else if(current.clone) source[key] = current.clone();"
-------------------------------------------
Locale.Set = new Class({
sets: {},
inherits: {
locales: [],
sets: {}
},
initialize: function(name){
this.name = name || '';
},
define: function(set, key, value){
var defineData = this.sets[set];
if (!defineData) defineData = {};
if (key){
if (typeOf(key) == 'object') defineData = Object.merge(defineData, key);
else defineData[key] = value;
}
this.sets[set] = defineData;
return this;
},
String: "var defineData = this.sets[set];"
Error: "this.sets is null"
Fix:
if(!this.sets) this.sets = {};
var defineData = this.sets[set];
-------------------------------------------
this.Events = new Class({
$events: {},
addEvent: function(type, fn, internal){
type = removeOn(type);
/*<1.2compat>*/
if (fn == $empty) return this;
/*</1.2compat>*/
if(!this.$events) this.$events = {};
this.$events[type] = (this.$events[type] || []).include(fn);
if (internal) fn.internal = true;
return this;
},
String: "this.$events[type] = (this.$events[type] || []).include(fn);"
Error: "this.$events is null"
Fix:
if(!this.$events) this.$events = {};
this.$events[type] = (this.$events[type] || []).include(fn);
-------------------------------------------
Browser.Features.iOSTouch = (function(){
var name = 'cantouch', // Name does not matter
html = document.html,
hasTouch = false;
var handler = function(){
html.removeEventListener(name, handler, true);
hasTouch = true;
};
String: "html.removeEventListener(name, handler, true);"
Error: "html.removeEventListener is undefined"
Fix:
if(html.removeEventListener){
html.removeEventListener(name, handler, true);
hasTouch = true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment