mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
fixes bugs where IE7 bailed out on an error resulting from the use of an optimized $$ function of lowpro
upgraded to lowpro 0.2. Version 0.4 did not work and caused behaviours to not work disabled optimized $$ since it still caused errors in ie7
This commit is contained in:
parent
3dc6b02c17
commit
feb6699a33
4 changed files with 134 additions and 178 deletions
|
|
@ -6,7 +6,6 @@ javascripts:
|
|||
- dragdrop
|
||||
- controls
|
||||
- application
|
||||
- selector-addon-v1
|
||||
- calendar
|
||||
- calendar-en
|
||||
- calendar-setup
|
||||
|
|
@ -14,8 +13,8 @@ javascripts:
|
|||
- todo-items
|
||||
- niftycube
|
||||
- protoload
|
||||
- lowpro
|
||||
- flashobject
|
||||
- lowpro
|
||||
stylesheets:
|
||||
- tracks:
|
||||
- standard
|
||||
|
|
|
|||
|
|
@ -1,5 +1,91 @@
|
|||
LowPro = {};
|
||||
LowPro.Version = '0.1';
|
||||
LowPro.Version = '0.2';
|
||||
|
||||
if (!Element.addMethods)
|
||||
Element.addMethods = function(o) { Object.extend(Element.Methods, o) };
|
||||
|
||||
// Simple utility methods for working with the DOM
|
||||
DOM = {
|
||||
nextElement : function(element) {
|
||||
element = $(element);
|
||||
while (element = element.nextSibling)
|
||||
if (element.nodeType == 1) return $(element);
|
||||
return null;
|
||||
},
|
||||
previousElement : function(element) {
|
||||
element = $(element);
|
||||
while (element = element.previousSibling)
|
||||
if (element.nodeType == 1) return $(element);
|
||||
return null;
|
||||
},
|
||||
remove : function(element) {
|
||||
return $(element).parentNode.removeChild(element);
|
||||
},
|
||||
insertAfter : function(element, node) {
|
||||
return $(element).previousSibling.inserBefore(node);
|
||||
},
|
||||
replaceElement : function(element, node) {
|
||||
$(element).parentNode.replaceChild(node, element);
|
||||
return node;
|
||||
}
|
||||
};
|
||||
|
||||
// Add them to the element mixin
|
||||
Element.addMethods(DOM);
|
||||
|
||||
// DOMBuilder for prototype
|
||||
DOM.Builder = {
|
||||
IE_TRANSLATIONS : {
|
||||
'class' : 'className',
|
||||
'for' : 'htmlFor'
|
||||
},
|
||||
ieAttrSet : function(attrs, attr, el) {
|
||||
var trans;
|
||||
if (trans = this.IE_TRANSLATIONS[attr]) el[trans] = attrs[attr];
|
||||
else if (attr == 'style') el.style.cssText = attrs[attr];
|
||||
else if (attr.match(/^on/)) el[attr] = new Function(attrs[attr]);
|
||||
else el.setAttribute(attr, attrs[attr]);
|
||||
},
|
||||
tagFunc : function(tag) {
|
||||
return function() {
|
||||
var attrs, children;
|
||||
if (arguments.length>0) {
|
||||
if (arguments[0].nodeName || typeof arguments[0] == "string") children = arguments;
|
||||
else { attrs = arguments[0]; children = [].slice.call(arguments, 1); };
|
||||
}
|
||||
return DOM.Builder.create(tag, attrs, children);
|
||||
};
|
||||
},
|
||||
create : function(tag, attrs, children) {
|
||||
attrs = attrs || {}; children = children || [];
|
||||
var isIE = navigator.userAgent.match(/MSIE/);
|
||||
var el = document.createElement((isIE && attrs.name) ? "<" + tag + " name=" + attrs.name + ">" : tag);
|
||||
for (var attr in attrs) {
|
||||
if (typeof attrs[attr] != 'function') {
|
||||
if (isIE) this.ieAttrSet(attrs, attrs, el);
|
||||
else el.setAttribute(attr, attrs[attr]);
|
||||
};
|
||||
}
|
||||
for (var i=0; i<children.length; i++) {
|
||||
if (typeof children[i] == 'string') children[i] = document.createTextNode(children[i]);
|
||||
el.appendChild(children[i]);
|
||||
}
|
||||
return $(el);
|
||||
}
|
||||
};
|
||||
|
||||
// Automatically create node builders as $tagName.
|
||||
(function() {
|
||||
var els = ("p|div|span|strong|em|img|table|tr|td|th|thead|tbody|tfoot|pre|code|" +
|
||||
"h1|h2|h3|h4|h5|h6|ul|ol|li|form|input|textarea|legend|fieldset|" +
|
||||
"select|option|blockquote|cite|br|hr|dd|dl|dt|address|a|button|abbr|acronym|" +
|
||||
"script|link|style|bdo|ins|del|object|param|col|colgroup|optgroup|caption|" +
|
||||
"label|dfn|kbd|samp|var").split("|");
|
||||
var el, i=0;
|
||||
while (el = els[i++]) window['$' + el] = DOM.Builder.tagFunc(el);
|
||||
})();
|
||||
|
||||
|
||||
|
||||
// Adapted from DOM Ready extension by Dan Webb
|
||||
// http://www.vivabit.com/bollocks/2006/06/21/a-dom-ready-extension-for-prototype
|
||||
|
|
@ -49,9 +135,6 @@ Object.extend(Event, {
|
|||
}
|
||||
});
|
||||
|
||||
if (!Element.addMethods)
|
||||
Element.addMethods = function(o) { Object.extend(Element.Methods, o) };
|
||||
|
||||
// Extend Element with observe and stopObserving.
|
||||
Element.addMethods({
|
||||
observe : function(el, event, callback) {
|
||||
|
|
@ -200,7 +283,7 @@ Event.observe(window, 'unload', Event.addBehavior.unload.bind(Event.addBehavior)
|
|||
// Event.addBehavior({ 'a.rollover' : MyBehavior });
|
||||
Behavior = {
|
||||
create : function(members) {
|
||||
var behavior = Class.create();
|
||||
var behavior = function(element) { this.element = $(element) };
|
||||
behavior.prototype.initialize = Prototype.K;
|
||||
Object.extend(behavior.prototype, members);
|
||||
Object.extend(behavior, Behavior.ClassMethods);
|
||||
|
|
@ -208,8 +291,8 @@ Behavior = {
|
|||
},
|
||||
ClassMethods : {
|
||||
attach : function(element) {
|
||||
var bound = new this;
|
||||
bound.element = $(element);
|
||||
var bound = new this(element);
|
||||
bound.initialize.apply(bound);
|
||||
this._bindEvents(bound);
|
||||
return bound;
|
||||
},
|
||||
|
|
@ -245,11 +328,19 @@ LowPro.SelectorLite.prototype = {
|
|||
var cursor = Math.max(id, klass);
|
||||
|
||||
if(cursor == -1) params.tag = selector.toUpperCase();
|
||||
<<<<<<< HEAD:public/javascripts/lowpro.js
|
||||
else if(id == -1 || klass == cursor) params.classes.push(selector.substring(klass + 1))
|
||||
=======
|
||||
else if(id == -1 || klass == cursor) params.classes.push(selector.substring(klass + 1));
|
||||
>>>>>>> recurring_work:public/javascripts/lowpro.js
|
||||
else if(!params.id) params.id = selector.substring(id + 1);
|
||||
|
||||
selector = selector.substring(0, cursor);
|
||||
} while(cursor > 0);
|
||||
<<<<<<< HEAD:public/javascripts/lowpro.js
|
||||
=======
|
||||
|
||||
>>>>>>> recurring_work:public/javascripts/lowpro.js
|
||||
this.selectors[i] = params;
|
||||
}
|
||||
|
||||
|
|
@ -262,21 +353,36 @@ LowPro.SelectorLite.prototype = {
|
|||
|
||||
findElements: function(parent, descendant) {
|
||||
var selector = this.selectors[this.index], results = [], element;
|
||||
<<<<<<< HEAD:public/javascripts/lowpro.js
|
||||
if(selector.id) {
|
||||
element = $(selector.id);
|
||||
if(element && (selector.tag == '*' || element.tagName == selector.tag) &&
|
||||
(element.childOf(parent))) {
|
||||
results = [element];
|
||||
=======
|
||||
if (selector.id) {
|
||||
element = $(selector.id);
|
||||
if (element && (selector.tag == '*' || element.tagName == selector.tag) && (element.childOf(parent))) {
|
||||
results = [element];
|
||||
>>>>>>> recurring_work:public/javascripts/lowpro.js
|
||||
}
|
||||
} else {
|
||||
results = $A(parent.getElementsByTagName(selector.tag));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD:public/javascripts/lowpro.js
|
||||
if(selector.classes.length == 1) {
|
||||
results = results.select(function(target) {
|
||||
return $(target).hasClassName(selector.classes[0]);
|
||||
});
|
||||
} else if(selector.classes.length > 1) {
|
||||
=======
|
||||
if (selector.classes.length == 1) {
|
||||
results = results.select(function(target) {
|
||||
return $(target).hasClassName(selector.classes[0]);
|
||||
});
|
||||
} else if (selector.classes.length > 1) {
|
||||
>>>>>>> recurring_work:public/javascripts/lowpro.js
|
||||
results = results.select(function(target) {
|
||||
var klasses = $(target).classNames();
|
||||
return selector.classes.all(function(klass) {
|
||||
|
|
@ -285,7 +391,11 @@ LowPro.SelectorLite.prototype = {
|
|||
});
|
||||
}
|
||||
|
||||
<<<<<<< HEAD:public/javascripts/lowpro.js
|
||||
if(descendant) {
|
||||
=======
|
||||
if (descendant) {
|
||||
>>>>>>> recurring_work:public/javascripts/lowpro.js
|
||||
this.results = this.results.concat(results);
|
||||
} else {
|
||||
++this.index;
|
||||
|
|
@ -294,6 +404,7 @@ LowPro.SelectorLite.prototype = {
|
|||
}.bind(this));
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD:public/javascripts/lowpro.js
|
||||
}
|
||||
|
||||
LowPro.$$old=$$;
|
||||
|
|
@ -304,4 +415,16 @@ function $$(a,b) {
|
|||
return LowPro.$$old.apply(this, arguments);
|
||||
return new LowPro.SelectorLite(a.split(/\s+/)).get();
|
||||
}
|
||||
=======
|
||||
};
|
||||
|
||||
LowPro.$$old=$$;
|
||||
LowPro.optimize$$ = false;
|
||||
|
||||
$$ = function(a,b) {
|
||||
if (LowPro.optimize$$ == false || b || a.indexOf("[")>=0)
|
||||
return LowPro.$$old(a, b);
|
||||
return new LowPro.SelectorLite(a.split(/\s+/)).get();
|
||||
};
|
||||
>>>>>>> recurring_work:public/javascripts/lowpro.js
|
||||
|
||||
|
|
|
|||
|
|
@ -1,163 +0,0 @@
|
|||
/************************************
|
||||
*
|
||||
* An add-on to Prototype 1.5 to speed up the $$ function in usual cases.
|
||||
*
|
||||
* http://www.sylvainzimmer.com/index.php/archives/2006/06/25/speeding-up-prototypes-selector/
|
||||
*
|
||||
* Authors:
|
||||
* - Sylvain ZIMMER <sylvain _at_ jamendo.com>
|
||||
*
|
||||
* Changelog:
|
||||
* v1 (2006/06/25)
|
||||
* - Initial release
|
||||
*
|
||||
* License: AS-IS
|
||||
*
|
||||
* Trivia: Check out www.jamendo.com for some great Creative Commons music ;-)
|
||||
*
|
||||
************************************/
|
||||
|
||||
|
||||
|
||||
// We don't extend the Selector class because we want
|
||||
// to be able to use it if the expression is too complicated.
|
||||
var SelectorLiteAddon=Class.create();
|
||||
|
||||
|
||||
SelectorLiteAddon.prototype = {
|
||||
|
||||
// This is the constructor. It parses the stack of selectors.
|
||||
initialize: function(stack) {
|
||||
|
||||
this.r=[]; //results
|
||||
this.s=[]; //stack of selectors
|
||||
this.i=0; //stack pointer
|
||||
|
||||
//Parse the selectors
|
||||
for (var i=stack.length-1;i>=0;i--) {
|
||||
|
||||
//This is the parsed selector. Format is : [tagname, id, classnames]
|
||||
var s=["*","",[]];
|
||||
|
||||
//The unparsed current selector
|
||||
var t=stack[i];
|
||||
|
||||
//Parse the selector backwards
|
||||
var cursor=t.length-1;
|
||||
do {
|
||||
|
||||
var d=t.lastIndexOf("#");
|
||||
var p=t.lastIndexOf(".");
|
||||
cursor=Math.max(d,p);
|
||||
|
||||
//Found a tagName
|
||||
if (cursor==-1) {
|
||||
s[0]=t.toUpperCase();
|
||||
|
||||
//Found a className
|
||||
} else if (d==-1 || p==cursor) {
|
||||
s[2].push(t.substring(p+1));
|
||||
|
||||
//Found an ID
|
||||
} else if (!s[1]) {
|
||||
s[1]=t.substring(d+1);
|
||||
}
|
||||
t=t.substring(0,cursor);
|
||||
} while (cursor>0);
|
||||
this.s[i]=s;
|
||||
}
|
||||
},
|
||||
|
||||
//Returns a list of matched elements below a given root.
|
||||
get:function(root) {
|
||||
this.explore(root || document,this.i==(this.s.length-1));
|
||||
return this.r;
|
||||
},
|
||||
|
||||
//Recursive function where the actual search is being done.
|
||||
// elt: current root element
|
||||
// leaf: boolean, are we in a leaf of the search tree?
|
||||
explore:function(elt,leaf) {
|
||||
|
||||
//Parsed selector
|
||||
var s=this.s[this.i];
|
||||
|
||||
//Results
|
||||
var r=[];
|
||||
|
||||
//Selector has an ID, use it!
|
||||
if (s[1]) {
|
||||
|
||||
e=$(s[1]);
|
||||
if (e && (s[0]=="*" || e.tagName==s[0]) && e.childOf(elt)) {
|
||||
r=[e];
|
||||
}
|
||||
|
||||
//Selector has no ID, search by tagname.
|
||||
} else {
|
||||
r=$A(elt.getElementsByTagName(s[0]));
|
||||
}
|
||||
|
||||
|
||||
//Filter the results by classnames.
|
||||
//Todo: by attributes too?
|
||||
//Sidenote: The performance hit is often here.
|
||||
|
||||
//Single className : that's fast!
|
||||
if (s[2].length==1) { //single classname
|
||||
r=r.findAll(function(o) {
|
||||
|
||||
//If the element has only one classname too, the test is simple!
|
||||
if (o.className.indexOf(" ")==-1) {
|
||||
return o.className==s[2][0];
|
||||
} else {
|
||||
return o.className.split(/\s+/).include(s[2][0]);
|
||||
}
|
||||
});
|
||||
|
||||
//Multipe classNames, a bit slower.
|
||||
} else if (s[2].length>0) {
|
||||
r=r.findAll(function(o) {
|
||||
|
||||
//If the elemtn has only one classname, we can drop it.
|
||||
if (o.className.indexOf(" ")==-1) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
//Check that all required classnames are present.
|
||||
var q=o.className.split(/\s+/);
|
||||
return s[2].all(function(c) {
|
||||
return q.include(c);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//Append the results if we're in a leaf
|
||||
if (leaf) {
|
||||
this.r=this.r.concat(r);
|
||||
|
||||
//Continue exploring the tree otherwise
|
||||
} else {
|
||||
++this.i;
|
||||
r.each(function(o) {
|
||||
this.explore(o,this.i==(this.s.length-1));
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Overwrite the $$ function.
|
||||
var $$old=$$;
|
||||
|
||||
var $$=function(a,b) {
|
||||
|
||||
//expression is too complicated, forward the call to prototype's function!
|
||||
if (b || a.indexOf("[")>=0) return $$old.apply(this,arguments);
|
||||
|
||||
//Otherwise use our addon!
|
||||
return new SelectorLiteAddon(a.split(/\s+/)).get();
|
||||
}
|
||||
|
|
@ -305,8 +305,7 @@ body.stats #topbar {
|
|||
margin-right: -5px;
|
||||
margin-bottom: 0px;
|
||||
color: #666;
|
||||
position:left; /* changed from relative to left in order to show 'add note' */
|
||||
/* text-shadow: rgba(0,0,0,.4) 0px 2px 5px; */
|
||||
position:static;
|
||||
}
|
||||
|
||||
.container_toggle img {
|
||||
|
|
@ -629,9 +628,7 @@ li {
|
|||
font-size: 1.1em;
|
||||
padding: 3px 0px;
|
||||
}
|
||||
#sidebar li {
|
||||
padding: auto;
|
||||
}
|
||||
|
||||
#sidebar .integrations-link {
|
||||
margin-top:10px;
|
||||
padding-top:10px;
|
||||
|
|
@ -639,7 +636,7 @@ li {
|
|||
}
|
||||
.sortable_row {
|
||||
background: #fff;
|
||||
_background: transparent;
|
||||
_background: transparent; /* the underscore is only used by ie6 and below */
|
||||
padding: 4px 4px 4px 8px;
|
||||
margin: 2px 2px;
|
||||
border: 1px solid #ccc;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue