Changeset 1031


Ignore:
Timestamp:
08/23/08 20:13:52 (11 years ago)
Author:
ray
Message:

#1227 @import rule & stylistLoadStylesheet

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/new-dialogs/plugins/Stylist/stylist.js

    r1008 r1031  
    453453Xinha.ripStylesFromCSSFile = function(URL) 
    454454{ 
    455   Xinha.setLoadingMessage('Loading Styles'); 
    456455  var css = Xinha._geturlcontent(URL); 
     456  var RE_atimport = '@import\\s*(url\\()?["\'](.*)["\'].*'; 
     457  var imports = css.match(new RegExp(RE_atimport,'ig')); 
     458  var m, file, re = new RegExp(RE_atimport,'i'); 
     459 
     460  if (imports) 
     461  { 
     462    var path = URL.replace(/\?.*$/,'').split("/"); 
     463    path.pop(); 
     464    path = path.join('/'); 
     465    for (var i=0;i<imports.length;i++) 
     466    { 
     467      m = imports[i].match(re); 
     468      file = m[2]; 
     469      if (!file.match(/^([^:]+\:)?\//)) 
     470      { 
     471        file = Xinha._resolveRelativeUrl(path,file); 
     472      } 
     473      css += Xinha._geturlcontent(file); 
     474    } 
     475  } 
     476 
    457477  return Xinha.ripStylesFromCSSString(css); 
    458478}; 
  • trunk/examples/XinhaConfig.js

    r1000 r1031  
    6868   // NOTE : YOU MUST GIVE AN ABSOLUTE URL 
    6969   
    70    xinha_config.pageStyleSheets = [ _editor_url + "examples/full_example.css" ]; 
     70   xinha_config.pageStyleSheets = [ _editor_url + "examples/files/full_example.css" ]; 
     71   //if you're using Stylist, import a stylesheet like this 
     72   xinha_config.stylistLoadStylesheet(_editor_url + "examples/files/stylist.css"); 
    7173 
    7274  /** STEP 4 *************************************************************** 
  • trunk/plugins/Stylist/stylist.js

    r1000 r1031  
    453453{ 
    454454  var css = Xinha._geturlcontent(URL); 
     455  var RE_atimport = '@import\\s*(url\\()?["\'](.*)["\'].*'; 
     456  var imports = css.match(new RegExp(RE_atimport,'ig')); 
     457  var m, file, re = new RegExp(RE_atimport,'i'); 
     458 
     459  if (imports) 
     460  { 
     461    var path = URL.replace(/\?.*$/,'').split("/"); 
     462    path.pop(); 
     463    path = path.join('/'); 
     464    for (var i=0;i<imports.length;i++) 
     465    { 
     466      m = imports[i].match(re); 
     467      file = m[2]; 
     468      if (!file.match(/^([^:]+\:)?\//)) 
     469      { 
     470        file = Xinha._resolveRelativeUrl(path,file); 
     471      } 
     472      css += Xinha._geturlcontent(file); 
     473    } 
     474  } 
     475 
    455476  return Xinha.ripStylesFromCSSString(css); 
    456477}; 
     
    462483  RE_comment = /\/\*(.|\r|\n)*?\*\//g; 
    463484  RE_rule    = /\{(.|\r|\n)*?\}/g; 
     485  css = css.replace(RE_comment, ''); 
    464486  css = css.replace(RE_comment, ''); 
    465487  css = css.replace(RE_rule, ','); 
Note: See TracChangeset for help on using the changeset viewer.