Page 1 of 1

Javascript error css.cssText 'Member not found'

Posted: Wed Aug 20, 2014 11:46 am
by sbd_jeff
Hi Stimulsoft,
I'm looking for clarification on what this block of code from Viewer.js in Stimulsoft.Reports.MvcMobile is responsible for:

Code: Select all

StiMvcViewer.prototype.prepareStyles = function (images) {
    var head = this.options.head;
    var cssForRemoving = [];
    for (i = 0; i < head.childNodes.length; i++) {
        var node = head.childNodes[i];
        if (node.type == "text/css") {
            if (node.sheet && node.sheet.rules) {
                var flag = false;
                for (j = 0; j < node.sheet.cssRules.length; j++) {
                    css = node.sheet.cssRules[j];
                    if (css.cssText.indexOf("stimulsoftTheme") != -1 && css.cssText.indexOf("stimulsoftTheme" + this.options.theme) == -1) { flag = true; }
                    if (css.style && css.style.backgroundimage && (css.style.backgroundImage.indexOf(".gif]") > 0 || css.style.backgroundImage.indexOf(".png]") > 0)) {
                        backgroundImage = css.style.backgroundImage;
                        backgroundImage = backgroundImage.substr(backgroundImage.indexOf("["), backgroundImage.indexOf("]") - backgroundImage.indexOf("[") + 1);
                        if (images[backgroundImage]) css.style.backgroundImage = "url('" + images[backgroundImage] + "')";
                    }
                }
                if (flag) cssForRemoving.push(node);
            }
            else {
                if (node.styleSheet) {
                    cssText = node.styleSheet.cssText;
                    if (cssText.indexOf("stimulsoftTheme") != -1 && cssText.indexOf("stimulsoftTheme" + this.options.theme) == -1) cssForRemoving.push(node);
                    else
                        while (param = this.getCssParameter(cssText)) cssText = cssText.replace(param, images[param]);
                    node.styleSheet.cssText = cssText;
                }
            }
        }
    }
    for (var index in cssForRemoving) head.removeChild(cssForRemoving[index]);
}
I think it is responsible for overriding your default theme by declaring "stimulsoftTheme" somewhere in our stylesheet, but I just wanted to be sure of its purpose.
The reason I ask is we have been having trouble lately with this issue http://forum.stimulsoft.com/viewtopic.php?f=13&t=37602.

After getting around that, we have been encountering a "Member not found" exception when an attempt is made to access "cssText" in the line:

Code: Select all

if (css.cssText.indexOf("stimulsoftTheme") != -1 && css.cssText.indexOf("stimulsoftTheme" + this.options.theme) == -1) { flag = true; }
I've worked around it by testing the entire document for the id "stimulsoftTheme" and skipping if it isn't found. This essentially skips that entire css searching block, but I wanted to know what its purpose is if you could please provide that info.

Thanks,

Re: Javascript error css.cssText 'Member not found'

Posted: Wed Aug 20, 2014 12:34 pm
by HighAley
Hello.

We have made an improvement.
Please, check our next prerelease build that will be available on August 22.

Thank you.