/*
Status: dont know where this will all live exactly
Need to pull in the implementation of the various helper methods
Some can be static method, others maybe methods of the ContentSetter (?)
Gut the ContentPane, replace its _setContent with our own call to dojox.html.set()
*/
dojo.provide("dojox.html._base");
dojo.require("dojo.html");
(function() {
if(dojo.isIE){
var alphaImageLoader = /(AlphaImageLoader\([^)]*?src=(['"]))(?![a-z]+:|\/)([^\r\n;}]+?)(\2[^)]*\)\s*[;}]?)/g;
}
// css at-rules must be set before any css declarations according to CSS spec
// match:
// @import 'http://dojotoolkit.org/dojo.css';
// @import 'you/never/thought/' print;
// @import url("it/would/work") tv, screen;
// @import url(/did/you/now.css);
// but not:
// @namespace dojo "http://dojotoolkit.org/dojo.css"; /* namespace URL should always be a absolute URI */
// @charset 'utf-8';
// @media print{ #menuRoot {display:none;} }
// we adjust all paths that dont start on '/' or contains ':'
//(?![a-z]+:|\/)
var cssPaths = /(?:(?:@import\s*(['"])(?![a-z]+:|\/)([^\r\n;{]+?)\1)|url\(\s*(['"]?)(?![a-z]+:|\/)([^\r\n;]+?)\3\s*\))([a-z, \s]*[;}]?)/g;
var adjustCssPaths = dojox.html._adjustCssPaths = function(cssUrl, cssText){
// summary:
// adjusts relative paths in cssText to be relative to cssUrl
// a path is considered relative if it doesn't start with '/' and not contains ':'
// description:
// Say we fetch a HTML page from level1/page.html
// It has some inline CSS:
// @import "css/page.css" tv, screen;
// ...
// background-image: url(images/aplhaimage.png);
//
// as we fetched this HTML and therefore this CSS
// from level1/page.html, these paths needs to be adjusted to:
// @import 'level1/css/page.css' tv, screen;
// ...
// background-image: url(level1/images/alphaimage.png);
//
// In IE it will also adjust relative paths in AlphaImageLoader()
// filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/alphaimage.png');
// will be adjusted to:
// filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='level1/images/alphaimage.png');
//
// Please note that any relative paths in AlphaImageLoader in external css files wont work, as
// the paths in AlphaImageLoader is MUST be declared relative to the HTML page,
// not relative to the CSS file that declares it
if(!cssText || !cssUrl){ return; }
// support the ImageAlphaFilter if it exists, most people use it in IE 6 for transparent PNGs
// We are NOT going to kill it in IE 7 just because the PNGs work there. Somebody might have
// other uses for it.
// If user want to disable css filter in IE6 he/she should
// unset filter in a declaration that just IE 6 doesn't understands
// like * > .myselector { filter:none; }
if(alphaImageLoader){
cssText = cssText.replace(alphaImageLoader, function(ignore, pre, delim, url, post){
return pre + (new dojo._Url(cssUrl, './'+url).toString()) + post;
});
}
return cssText.replace(cssPaths, function(ignore, delimStr, strUrl, delimUrl, urlUrl, media){
if(strUrl){
return '@import "' + (new dojo._Url(cssUrl, './'+strUrl).toString()) + '"' + media;
}else{
return 'url(' + (new dojo._Url(cssUrl, './'+urlUrl).toString()) + ')' + media;
}
});
};
// attributepaths one tag can have multiple paths, example:
// or
//
var htmlAttrPaths = /(<[a-z][a-z0-9]*\s[^>]*)(?:(href|src)=(['"]?)([^>]*?)\3|style=(['"]?)([^>]*?)\5)([^>]*>)/gi;
var adjustHtmlPaths = dojox.html._adjustHtmlPaths = function(htmlUrl, cont){
var url = htmlUrl || "./";
return cont.replace(htmlAttrPaths,
function(tag, start, name, delim, relUrl, delim2, cssText, end){
return start + (name ?
(name + '=' + delim + (new dojo._Url(url, relUrl).toString()) + delim)
: ('style=' + delim2 + adjustCssPaths(url, cssText) + delim2)
) + end;
}
);
};
var snarfStyles = dojox.html._snarfStyles = function (/*String*/cssUrl, /*String*/cont, /*Array*/styles){
/**************** cut out all