Loading ...
Sorry, an error occurred while loading the content.

Re: Calendar: Date-specific rendering carrying over into further cells

Expand Messages
  • ggextras
    Well, I ve come to a solution to this. As entering inline styles does not work, if you cannot style the table cells with a static stylesheet, you can do
    Message 1 of 7 , Dec 11, 2006
    • 0 Attachment
      Well, I've come to a solution to this.  As entering inline styles does not work, if you cannot style the table cells with a static stylesheet, you can do something like the following:

      var dates = {
          '#ccc' : ['2006-12-02','2006-12-04'],
          '#eee' : [
      '2006-12-03']
      }
             
      var rules = Array();
      for ( var x in dates) {
          rules.push(dates[x].join(', ') + " { background-color: " + x + "; }");
      }

      if ( document.all && !window.opera) {
          // Insert the stylesheet for IE6+
          if ( document.getElementsByTagName('style').length == 0 ) {
              document.getElementsByTagName('head').item(0).appendChild(document.createElement('style'));
          }
          /* Use some correct but unused ids to prevent from adding the css multiple times */
          var css =  "#__asdf{}" + rules.join('') + "#__fdsa{}";
          if ( document.styleSheets[0].cssText.match("#__asdf") ) {
              alert('here');
              document.styleSheets[0].cssText.replace(/#__asdf[\s\S]+#__fdsa\s*{[\s\n]*}/i,css);
          } else {
              document.styleSheets[0].cssText += css;
          }
      } else {
          // Insert the stylesheet for FF, Opera, Safari
          // Don't want to duplicate the styles
          if ( $('__keydate_style') ) { $('__keydate_style').parentNode.removeChild($('__keydate_style')) }
          var styleNode = document.createElement("style");
          styleNode.type = "text/css";
          styleNode.setAttribute('id','__keydate_style');
          styleNode.appendChild(document.createTextNode(rules.join('')));
          document.getElementsByTagName('head').item(0).appendChild(styleNode);
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.