Skip to content
This repository was archived by the owner on Jul 3, 2024. It is now read-only.

Commit 45b9535

Browse files
bulk tabs/spaces conversion
testing out jcarnett's determinePath fix (http://github.com/jcarnett/eCSStender.js/commit/aa5b2700dc07ef101caeb0dccf6d48543ea461f9)
1 parent 8938977 commit 45b9535

File tree

1 file changed

+159
-152
lines changed

1 file changed

+159
-152
lines changed

src/eCSStender.js

Lines changed: 159 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ License: MIT License (see homepage)
190190
media = determineMedia( __stylesheets[s] );
191191
createMediaContainers( media );
192192
if ( __stylesheets[s].href )
193-
{
194-
determinePath( __stylesheets[s] );
195-
}
193+
{
194+
determinePath( __stylesheets[s] );
195+
}
196196
}
197197
getCSSFiles();
198198
}
@@ -497,26 +497,33 @@ License: MIT License (see homepage)
497497
parent = stylesheet.parentStyleSheet,
498498
parent_path = EMPTY,
499499
prefix = EMPTY,
500-
full_url = FALSE,
501-
curr_path, path_last_slash, file_name;
500+
full_url = FALSE,
501+
curr_path, path_last_slash, file_name;
502502
if ( ! css_path )
503-
{
504-
css_path = NULL;
505-
}
506-
else
507-
{
508-
full_url = css_path.match( REGEXP_URL );
509-
if ( is( full_url, ARRAY ) )
510-
{
511-
full_url = ( full_url.length > 0 );
512-
}
513-
}
514-
// we only want sheets
515-
if ( ! actual_path && // that don't already have a path
516-
! full_url ) // that don't have a full URL
517-
{
518-
if ( css_path.indexOf( SLASH ) === 0 ) { css_path = css_path.substring( 1 ); }
519-
curr_path = LOCATION.substring( 0, LOCATION.lastIndexOf( SLASH ) );
503+
{
504+
css_path = NULL;
505+
}
506+
else
507+
{
508+
full_url = css_path.match( REGEXP_URL );
509+
if ( is( full_url, ARRAY ) )
510+
{
511+
full_url = ( full_url.length > 0 );
512+
}
513+
}
514+
// we only want sheets
515+
if ( ! actual_path && // that don't already have a path
516+
! full_url ) // that don't have a full URL
517+
{
518+
if ( css_path.indexOf( SLASH ) === 0 )
519+
{
520+
css_path = css_path.substring( 1 );
521+
curr_path = LOCATION.substring( 0, LOCATION.lastIndexOf(WINDOW.location.pathname) );
522+
}
523+
else
524+
{
525+
curr_path = LOCATION.substring( 0, LOCATION.lastIndexOf( SLASH ) );
526+
}
520527
path_last_slash = css_path.lastIndexOf( SLASH );
521528
file_name = css_path.substring( path_last_slash + 1 );
522529
// check for an owner
@@ -1153,31 +1160,31 @@ License: MIT License (see homepage)
11531160
}
11541161
function camelize( str )
11551162
{
1156-
var
1157-
regex = /(-[a-z])/g,
1158-
func = function( bit ){
1159-
return bit.toUpperCase().replace( HYPHEN, EMPTY );
1160-
};
1161-
camelize = function( str )
1162-
{
1163-
return is( str, STRING ) ? low( str ).replace( regex, func )
1164-
: str;
1165-
};
1166-
return camelize( str );
1167-
}
1168-
function zero_out( str )
1169-
{
1170-
/* finds and removes any unit on a zero
1171-
http://www.w3.org/TR/2006/WD-css3-values-20060919/#numbers0
1172-
Relative values: em, ex, px, gd, rem, vw, vh, vm, ch
1173-
Absolute values: in, cm, mm, pt, pc
1174-
Percentages: %
1175-
Angles: deg, grad, rad, turn
1176-
Times: ms, s
1177-
Frequencies: Hz, kHz */
1178-
var regex = /(\s0)((c|m|r?e|v)m|ch|deg|ex|gd|g?rad|in|k?Hz|m?s|p[ctx]|turn|v[hw]|%)/g;
1179-
return is( str, STRING ) ? str.replace( regex, CAPTURE ) : str;
1180-
}
1163+
var
1164+
regex = /(-[a-z])/g,
1165+
func = function( bit ){
1166+
return bit.toUpperCase().replace( HYPHEN, EMPTY );
1167+
};
1168+
camelize = function( str )
1169+
{
1170+
return is( str, STRING ) ? low( str ).replace( regex, func )
1171+
: str;
1172+
};
1173+
return camelize( str );
1174+
}
1175+
function zero_out( str )
1176+
{
1177+
/* finds and removes any unit on a zero
1178+
http://www.w3.org/TR/2006/WD-css3-values-20060919/#numbers0
1179+
Relative values: em, ex, px, gd, rem, vw, vh, vm, ch
1180+
Absolute values: in, cm, mm, pt, pc
1181+
Percentages: %
1182+
Angles: deg, grad, rad, turn
1183+
Times: ms, s
1184+
Frequencies: Hz, kHz */
1185+
var regex = /(\s0)((c|m|r?e|v)m|ch|deg|ex|gd|g?rad|in|k?Hz|m?s|p[ctx]|turn|v[hw]|%)/g;
1186+
return is( str, STRING ) ? str.replace( regex, CAPTURE ) : str;
1187+
}
11811188
function addInlineStyle( el, property, value )
11821189
{
11831190
try {
@@ -1207,30 +1214,30 @@ License: MIT License (see homepage)
12071214
function XHR()
12081215
{
12091216
var
1210-
obj,
1211-
type = NULL;
1217+
obj,
1218+
type = NULL;
12121219
if ( WINDOW.XMLHttpRequest )
1213-
{
1214-
obj = WINDOW.XMLHttpRequest;
1215-
}
1216-
else
1217-
{
1220+
{
1221+
obj = WINDOW.XMLHttpRequest;
1222+
}
1223+
else
1224+
{
12181225
try {
1219-
obj = ActiveXObject;
1220-
type ='Microsoft.XMLHTTP';
1221-
connection = new obj(type);
1222-
}
1223-
catch ( e )
1224-
{
1225-
obj = function(){
1226-
return NULL;
1227-
};
1228-
}
1229-
}
1230-
XHR = function(){
1231-
return new obj(type);
1232-
};
1233-
return XHR();
1226+
obj = ActiveXObject;
1227+
type ='Microsoft.XMLHTTP';
1228+
connection = new obj(type);
1229+
}
1230+
catch ( e )
1231+
{
1232+
obj = function(){
1233+
return NULL;
1234+
};
1235+
}
1236+
}
1237+
XHR = function(){
1238+
return new obj(type);
1239+
};
1240+
return XHR();
12341241
}
12351242
function getCSSFiles()
12361243
{
@@ -1347,7 +1354,7 @@ License: MIT License (see homepage)
13471354
{
13481355
key = __cache_object.key(i);
13491356
if ( key &&
1350-
key.indexOf( ECSSTENDER ) === 0 )
1357+
key.indexOf( ECSSTENDER ) === 0 )
13511358
{
13521359
delete( __cache_object[key] );
13531360
}
@@ -1527,25 +1534,25 @@ License: MIT License (see homepage)
15271534
c1 = str.charCodeAt(i);
15281535
if ( c1 < 128 )
15291536
{
1530-
newstr += charAt( c1 );
1531-
}
1532-
else if ( (c1 > 127) && (c1 < 2048) )
1533-
{
1534-
newstr += charAt( (c1 >> 6) | 192 );
1535-
newstr += charAt( (c1 & 63) | 128 );
1536-
}
1537-
else
1538-
{
1539-
newstr += charAt( (c1 >> 12) | 224 );
1540-
newstr += charAt( ((c1 >> 6) & 63) | 128 );
1541-
newstr += charAt( (c1 & 63) | 128 );
1542-
}
1543-
}
1544-
str = newstr;
1545-
newstr = EMPTY;
1546-
// base64
1547-
i = 0;
1548-
iLen = str.length;
1537+
newstr += charAt( c1 );
1538+
}
1539+
else if ( (c1 > 127) && (c1 < 2048) )
1540+
{
1541+
newstr += charAt( (c1 >> 6) | 192 );
1542+
newstr += charAt( (c1 & 63) | 128 );
1543+
}
1544+
else
1545+
{
1546+
newstr += charAt( (c1 >> 12) | 224 );
1547+
newstr += charAt( ((c1 >> 6) & 63) | 128 );
1548+
newstr += charAt( (c1 & 63) | 128 );
1549+
}
1550+
}
1551+
str = newstr;
1552+
newstr = EMPTY;
1553+
// base64
1554+
i = 0;
1555+
iLen = str.length;
15491556
while ( i < iLen )
15501557
{
15511558
c1 = str.charCodeAt(i++);
@@ -1559,11 +1566,11 @@ License: MIT License (see homepage)
15591566

15601567
if ( isNaN(c2) )
15611568
{
1562-
e3 = e4 = 64;
1569+
e3 = e4 = 64;
15631570
}
15641571
else if ( isNaN(c3) )
15651572
{
1566-
e4 = 64;
1573+
e4 = 64;
15671574
}
15681575
newstr += keystr.charAt(e1) + keystr.charAt(e2) +
15691576
keystr.charAt(e3) + keystr.charAt(e4);
@@ -2084,36 +2091,36 @@ License: MIT License (see homepage)
20842091
{
20852092
// test element
20862093
el = newElement(DIV);
2087-
// are property and value flowing in separately?
2088-
if ( value )
2089-
{
2090-
property = what;
2091-
value = arrayify( value );
2092-
}
2093-
else
2094-
{
2095-
what = what.split(REGEXP_P_V);
2096-
property = what[0];
2097-
value = [ trim( what[1] ) ];
2098-
// reset what for the cache
2099-
what = arg[1];
2100-
}
2101-
// camel case
2102-
property = camelize( property );
2103-
if ( el.style[property] !== UNDEFINED )
2104-
{
2105-
// set it
2106-
el.style[property] = value[0];
2107-
// get it back
2108-
val = zero_out( el.style[property] );
2109-
// test
2110-
i = value.length;
2111-
while ( i-- &&
2112-
! result )
2113-
{
2114-
result = ( val === value[i] );
2115-
}
2116-
}
2094+
// are property and value flowing in separately?
2095+
if ( value )
2096+
{
2097+
property = what;
2098+
value = arrayify( value );
2099+
}
2100+
else
2101+
{
2102+
what = what.split(REGEXP_P_V);
2103+
property = what[0];
2104+
value = [ trim( what[1] ) ];
2105+
// reset what for the cache
2106+
what = arg[1];
2107+
}
2108+
// camel case
2109+
property = camelize( property );
2110+
if ( el.style[property] !== UNDEFINED )
2111+
{
2112+
// set it
2113+
el.style[property] = value[0];
2114+
// get it back
2115+
val = zero_out( el.style[property] );
2116+
// test
2117+
i = value.length;
2118+
while ( i-- &&
2119+
! result )
2120+
{
2121+
result = ( val === value[i] );
2122+
}
2123+
}
21172124
}
21182125
// selector test
21192126
else if ( type == SELECTOR )
@@ -2386,8 +2393,8 @@ License: MIT License (see homepage)
23862393
re = re || makeClassRegExp( the_class );
23872394
if ( hasClass( el, the_class, re ) )
23882395
{
2389-
el.className = trim( el.className.replace( re, SPACE ) );
2390-
}
2396+
el.className = trim( el.className.replace( re, SPACE ) );
2397+
}
23912398
};
23922399
eCSStender.removeClass = removeClass;
23932400
/**
@@ -2437,44 +2444,44 @@ License: MIT License (see homepage)
24372444
doScroll = DOCUMENT.documentElement.doScroll;
24382445

24392446
// for Mozilla/Safari/Opera9
2440-
if ( DOCUMENT.addEventListener )
2447+
if ( DOCUMENT.addEventListener )
24412448
{
24422449
DOCUMENT.addEventListener( DCL, function(){
24432450
DOCUMENT.removeEventListener( DCL, arguments.callee, FALSE );
24442451
initialize();
24452452
}, FALSE );
24462453
}
24472454
// If IE event model is used
2448-
else if ( DOCUMENT.attachEvent )
2449-
{
2450-
// ensure firing before onload, maybe late but safe also for iframes
2451-
DOCUMENT.attachEvent( ORC, function(){
2452-
if ( DOCUMENT.readyState === COMPLETE ) {
2453-
DOCUMENT.detachEvent( ORC, arguments.callee );
2454-
initialize();
2455-
}
2456-
});
2455+
else if ( DOCUMENT.attachEvent )
2456+
{
2457+
// ensure firing before onload, maybe late but safe also for iframes
2458+
DOCUMENT.attachEvent( ORC, function(){
2459+
if ( DOCUMENT.readyState === COMPLETE ) {
2460+
DOCUMENT.detachEvent( ORC, arguments.callee );
2461+
initialize();
2462+
}
2463+
});
24572464

2458-
// If IE and not an iframe, continually check to see if the document is ready
2459-
if ( doScroll &&
2460-
WINDOW == WINDOW.top )
2461-
{
2462-
(function(){
2463-
try {
2464-
// If IE is used, use the trick by Diego Perini
2465-
// http://javascript.nwbox.com/IEContentLoaded/
2466-
doScroll('left');
2467-
}
2468-
catch( error )
2469-
{
2470-
setTimeout( arguments.callee, 0 );
2471-
return;
2472-
}
2465+
// If IE and not an iframe, continually check to see if the document is ready
2466+
if ( doScroll &&
2467+
WINDOW == WINDOW.top )
2468+
{
2469+
(function(){
2470+
try {
2471+
// If IE is used, use the trick by Diego Perini
2472+
// http://javascript.nwbox.com/IEContentLoaded/
2473+
doScroll('left');
2474+
}
2475+
catch( error )
2476+
{
2477+
setTimeout( arguments.callee, 0 );
2478+
return;
2479+
}
24732480
// and execute any waiting functions
2474-
initialize();
2475-
})();
2476-
}
2477-
}
2481+
initialize();
2482+
})();
2483+
}
2484+
}
24782485
})();
24792486

24802487
})();

0 commit comments

Comments
 (0)