source: trunk/spip/esqueleto-redcta/plugins/magusine/ie7/ie7-css2-selectors.js @ 359

Last change on this file since 359 was 80, checked in by guille, 16 years ago

el plugin completo

File size: 8.9 KB
Line 
1/*
2        IE7, version 0.9 (alpha) (2005-08-19)
3        Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
4        License: http://creativecommons.org/licenses/LGPL/2.1/
5*/
6IE7.addModule("ie7-css2-selectors",function(){cssQuery.addModule("css-level2",function(){selectors[">"]=function(r,f,t,n){var e,i,j;for(i=0;i<f.length;i++){var s=childElements(f[i]);for(j=0;(e=s[j]);j++)if(compareTagName(e,t,n))r.push(e)}};selectors["+"]=function(r,f,t,n){for(var i=0;i<f.length;i++){var e=nextElementSibling(f[i]);if(e&&compareTagName(e,t,n))r.push(e)}};selectors["@"]=function(r,f,a){var t=attributeSelectors[a].test;var e,i;for(i=0;(e=f[i]);i++)if(t(e))r.push(e)};pseudoClasses["first-child"]=function(e){return!previousElementSibling(e)};pseudoClasses["lang"]=function(e,c){c=new RegExp("^"+c,"i");while(e&&!e.getAttribute("lang"))e=e.parentNode;return e&&c.test(e.getAttribute("lang"))};AttributeSelector.NS_IE=/\\:/g;AttributeSelector.PREFIX="@";AttributeSelector.tests={};AttributeSelector.replace=function(m,a,n,c,v){var k=this.PREFIX+m;if(!attributeSelectors[k]){a=this.create(a,c||"",v||"");attributeSelectors[k]=a;attributeSelectors.push(a)}return attributeSelectors[k].id};AttributeSelector.parse=function(s){s=s.replace(this.NS_IE,"|");var m;while(m=s.match(this.match)){var r=this.replace(m[0],m[1],m[2],m[3],m[4]);s=s.replace(this.match,r)}return s};AttributeSelector.create=function(p,t,v){var a={};a.id=this.PREFIX+attributeSelectors.length;a.name=p;t=this.tests[t];t=t?t(this.getAttribute(p),getText(v)):false;a.test=new Function("e","return "+t);return a};AttributeSelector.getAttribute=function(n){switch(n.toLowerCase()){case"id":return"e.id";case"class":return"e.className";case"for":return"e.htmlFor";case"href":if(isMSIE){return"String((e.outerHTML.match(/href=\\x22?([^\\s\\x22]*)\\x22?/)||[])[1]||'')"}}return"e.getAttribute('"+n.replace(N,":")+"')"};AttributeSelector.tests[""]=function(a){return a};AttributeSelector.tests["="]=function(a,v){return a+"=="+Quote.add(v)};AttributeSelector.tests["~="]=function(a,v){return"/(^| )"+regEscape(v)+"( |$)/.test("+a+")"};AttributeSelector.tests["|="]=function(a,v){return"/^"+regEscape(v)+"(-|$)/.test("+a+")"};var _6=parseSelector;parseSelector=function(s){return _6(AttributeSelector.parse(s))}});var AttributeSelector=cssQuery.valueOf("AttributeSelector");var H=/a(#[\w-]+)?(\.[\w-]+)?:(hover|active)/i;var B1=/\s*\{\s*/,B2=/\s*\}\s*/,C=/\s*\,\s*/;var F=/(.*)(:first-(line|letter))/;StyleSheet.prototype.specialize({parse:function(){this.inherit();var o=ie7CSS.rules.length;var ru=this.cssText.split(B2),r;var se,c,i,j;for(i=0;i<ru.length;i++){r=ru[i].split(B1);se=r[0].split(C);c=r[1];for(j=0;j<se.length;j++){se[j]=c?this.createRule(se[j],c):""}ru[i]=se.join("\n")}this.cssText=ru.join("\n");this.rules=ie7CSS.rules.slice(o)},recalc:function(){var r,i;for(i=0;(r=this.rules[i]);i++)r.recalc()},createRule:function(s,c){if(ie7CSS.UNKNOWN.test(s)){var m;if(m=s.match(PseudoElement.MATCH)){return new PseudoElement(m[1],m[2],c)}else if(m=s.match(DynamicRule.MATCH)){if(!isHTML||!H.test(m)||DynamicRule.COMPLEX.test(m)){return new DynamicRule(s,m[1],m[2],m[3],c)}}else return new Rule(s,c)}return s+" {"+c+"}"}});ie7CSS.specialize({rules:[],pseudoClasses:cssQuery.valueOf("pseudoClasses"),dynamicPseudoClasses:{},cache:cssQuery.valueOf("cache"),Rule:Rule,DynamicRule:DynamicRule,PseudoElement:PseudoElement,DynamicPseudoClass:DynamicPseudoClass,apply:function(){var p=this.pseudoClasses+"|before|after|"+this.dynamicPseudoClasses;p=p.replace(/(link|visited)\|/g,"");this.UNKNOWN=new RegExp("[>+~\[]|([:.])[\\w-()]+\\1|:("+p+")");var c="[^\\s(]+\\s*[+~]|@\\d+|:(";Rule.COMPLEX=new RegExp(c+p+")","g");DynamicRule.COMPLEX=new RegExp(c+this.pseudoClasses+")","g");DynamicRule.MATCH=new RegExp("(.*):("+this.dynamicPseudoClasses+")(.*)");PseudoElement.MATCH=/(.*):(before|after).*/;this.inherit()},recalc:function(){this.screen.recalc();this.inherit()},getText:function(s,p){return httpRequest?(loadFile(s.href,p)||s.cssText):this.inherit(s)},addEventHandler:function(e,t,h){addEventHandler(e,t,h)}});function Rule(s,c){this.id=ie7CSS.rules.length;this.className=Rule.PREFIX+this.id;s=(s).match(F)||s||"*";this.selector=s[1]||s;this.selectorText=Rule.simple(this.selector)+"."+this.className+(s[2]||"");this.cssText=c;this.MATCH=new RegExp("\\s"+this.className+"(\\s|$)","g");ie7CSS.rules.push(this);this.init()};Common.specialize({constructor:Rule,toString:function(){return this.selectorText+" {"+this.cssText+"}"},init:DUMMY,add:function(e){e.className+=" "+this.className},remove:function(e){e.className=e.className.replace(this.MATCH,"$1")},recalc:function(){var m=ie7CSS.cache[" *."+this.className]=cssQuery(this.selector);for(i=0;i<m.length;i++)this.add(m[i])}});Rule.PREFIX="ie7_class";Rule.CHILD=/>/g;Rule.simple=function(s){s=AttributeSelector.parse(s);return s.replace(this.COMPLEX,"").replace(this.CHILD," ")};function DynamicRule(s,a,d,t,c){this.attach=a||"*";this.dynamicPseudoClass=ie7CSS.dynamicPseudoClasses[d];this.target=t;this.inherit(s,c)};Rule.specialize({constructor:DynamicRule,recalc:function(){var m=cssQuery(this.attach);for(var i=0;i<m.length;i++){var t=(this.target)?cssQuery(this.target,m[i]):[m[i]];if(t.length)this.dynamicPseudoClass.apply(m[i],t,this)}}});var A=/^attr/;var U=/^url\s*\(\s*([^)]*)\)$/;var M={before0:"beforeBegin",before1:"afterBegin",after0:"afterEnd",after1:"beforeEnd"};var _5=makePath("ie7-content.htc",path)+"?";HEADER+=".ie7_anon{display:none}";function PseudoElement(s,p,c){this.position=p;var co=c.match(PseudoElement.CONTENT),m,e;if(co){co=co[1];m=co.split(/\s+/);for(var i=0;(e=m[i]);i++){m[i]=A.test(e)?{attr:e.slice(5,-1)}:(e.charAt(0)=="'")?getString(e):decode(e)}co=m}this.content=co;this.inherit(s,decode(c))};Rule.specialize({constructor:PseudoElement,toString:function(){return"."+this.className+"{display:inline}"},init:function(){this.match=cssQuery(this.selector);for(var i=0;i<this.match.length;i++){var r=this.match[i].runtimeStyle;if(!r[this.position])r[this.position]={cssText:""};r[this.position].cssText+=";"+this.cssText;if(this.content!=null)r[this.position].content=this.content}},recalc:function(){if(this.content==null)return;for(var i=0;i<this.match.length;i++){this.create(this.match[i])}},create:function(t){var g=t.runtimeStyle[this.position];if(g){var c=[].concat(g.content||"");for(var j=0;j<c.length;j++){if(typeof c[j]=="object"){c[j]=t.getAttribute(c[j].attr)}}c=c.join("");var u=c.match(U);var h=PseudoElement[u?"OBJECT":"ANON"].replace(/%1/,this.className);var cs=g.cssText.replace(/'/g,'"');var po=M[this.position+Number(t.canHaveChildren)];if(u){var p=document.createElement(h);t.insertAdjacentElement(po,p);p.data=_5;addTimer(p,cs,Quote.remove(u[1]))}else{h=h.replace(/%2/,cs).replace(/%3/,c);t.insertAdjacentHTML(po,h)}t.runtimeStyle[this.position]=null}}});PseudoElement.CONTENT=/content\s*:\s*([^;]*)(;|$)/;PseudoElement.OBJECT="<object class='ie7_anon %1' ie7_anon width=100% height=0 type=text/x-scriptlet>";PseudoElement.ANON="<ie7:! class='ie7_anon %1' ie7_anon style='%2'>%3</ie7:!>";function DynamicPseudoClass(n,a){this.name=n;this.apply=a;this.instances={};ie7CSS.dynamicPseudoClasses[n]=this};Common.specialize({constructor:DynamicPseudoClass,register:function(i){var c=i[2];i.id=c.id+i[0].uniqueID;if(!this.instances[i.id]){var t=i[1],j;for(j=0;j<t.length;j++)c.add(t[j]);this.instances[i.id]=i}},unregister:function(i){if(this.instances[i.id]){var c=i[2];var t=i[1],j;for(j=0;j<t.length;j++)c.remove(t[j]);delete this.instances[i.id]}}});ie7CSS.pseudoClasses.toString=function(){var t=[],p;for(p in this){if(this[p].length>1)p+="\\([^)]*\\)";t.push(p)}return t.join("|")};ie7CSS.pseudoClasses["link"]=function(e){return e.currentStyle["ie7-link"]=="link"};ie7CSS.pseudoClasses["visited"]=function(e){return e.currentStyle["ie7-link"]=="visited"};var _4=(appVersion<5.5)?"onmouseover":"onmouseenter";var _3=(appVersion<5.5)?"onmouseout":"onmouseleave";ie7CSS.dynamicPseudoClasses.toString=ie7CSS.pseudoClasses.toString;var _0=new DynamicPseudoClass("hover",function(e){var i=arguments;ie7CSS.addEventHandler(e,_4,function(){_0.register(i)});ie7CSS.addEventHandler(e,_3,function(){_0.unregister(i)})});var _1=new DynamicPseudoClass("focus",function(e){var i=arguments;ie7CSS.addEventHandler(e,"onfocus",function(){_1.unregister(i);_1.register(i)});ie7CSS.addEventHandler(e,"onblur",function(){_1.unregister(i)});if(e==document.activeElement){_1.register(i)}});var _2=new DynamicPseudoClass("active",function(e){var i=arguments;ie7CSS.addEventHandler(e,"onmousedown",function(){_2.register(i)})});addEventHandler(document,"onmouseup",function(){var i=_2.instances,j;for(j in i)_2.unregister(i[j]);i=_0.instances;for(j in i)if(!i[j][0].contains(event.srcElement))_0.unregister(i[j])});ICommon(AttributeSelector);AttributeSelector.specialize({getAttribute:function(n){switch(n.toLowerCase()){case"class":return"e.className.replace(/\\b\\s*ie7_class\\d+/g,'')";case"src":return"(e.pngSrc||e.src)"}return this.inherit(n)}});encoder.add(/::/,":");safeString.add(/\\([\da-fA-F]{1,4})/,function(m,o){m=m[o+1];return"\\u"+"0000".slice(m.length)+m})});
Note: See TracBrowser for help on using the repository browser.