diff --git a/config/asset_packages.yml b/config/asset_packages.yml index e01160a8..dea6fd1d 100644 --- a/config/asset_packages.yml +++ b/config/asset_packages.yml @@ -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 diff --git a/public/javascripts/lowpro.js b/public/javascripts/lowpro.js index a119f20a..cd3bff8f 100644 --- a/public/javascripts/lowpro.js +++ b/public/javascripts/lowpro.js @@ -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>>>>>> 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 diff --git a/public/javascripts/selector-addon-v1.js b/public/javascripts/selector-addon-v1.js deleted file mode 100644 index e6cdf254..00000000 --- a/public/javascripts/selector-addon-v1.js +++ /dev/null @@ -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 - * - * 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(); -} diff --git a/public/stylesheets/standard.css b/public/stylesheets/standard.css index 9c326508..e754c456 100644 --- a/public/stylesheets/standard.css +++ b/public/stylesheets/standard.css @@ -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;