annotate inkscape/firefox/content/css.js @ 936:a9abcdac0ae5

Fix issue of moving lightbar of testsvg.js. The lightbar does not move as expectation. It caused by compute trasnforming matrix that transform saved points from the space when saving points to current space. The transform matrix should not include matric of the owner of saved points.
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 12 Nov 2010 16:53:03 +0800
parents 4350aa369149
children
rev   line source
352
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
1 function get_css(rule_name, stylesheet, delete_flag) {
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
2 if (!document.styleSheets) return false;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
3 rule_name = rule_name.toLowerCase(); stylesheet = stylesheet || 0;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
4 for (var i = stylesheet; i < document.styleSheets.length; i++) {
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
5 var styleSheet = document.styleSheets[i]; css_rules = document.styleSheets[i].cssRules || document.styleSheets[i].rules;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
6 if(!css_rules) continue;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
7 var j = 0;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
8 do {
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
9 if(css_rules[j].selectorText.toLowerCase() == rule_name) {
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
10 if(delete_flag == true) {
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
11 if(document.styleSheets[i].removeRule) document.styleSheets[i].removeRule(j);
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
12 if(document.styleSheets[i].deleteRule) document.styleSheets[i].deleteRule(j);
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
13 return true;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
14 }
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
15 else return css_rules[j];
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
16 }
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
17 }
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
18 while (css_rules[++j]);
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
19 }
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
20 return false;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
21 }
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
22 function add_css(rule_name, stylesheet) {
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
23 rule_name = rule_name.toLowerCase(); stylesheet = stylesheet || 0;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
24 if (!document.styleSheets || get_css(rule_name, stylesheet)) return false;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
25 (document.styleSheets[stylesheet].addRule) ? document.styleSheets[stylesheet].addRule(rule_name, null, 0) : document.styleSheets[stylesheet].insertRule(rule_name+' { }', 0);
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
26 return get_css(rule_name);
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
27 }
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
28 function get_sheet_num (href_name) {
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
29 if (!document.styleSheets) return false;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
30 for (var i = 0; i < document.styleSheets.length; i++) { if(document.styleSheets[i].href && document.styleSheets[i].href.toString().match(href_name)) return i; }
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
31 return false;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
32 }
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
33 function remove_css(rule_name, stylesheet) { return get_css(rule_name, stylesheet, true); }
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
34
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
35 function add_sheet(url, media) {
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
36 if(document.createStyleSheet) {
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
37 document.createStyleSheet(url);
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
38 }
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
39 else {
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
40 var newSS = document.createElement('link');
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
41 newSS.rel = 'stylesheet';
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
42 newSS.type = 'text/css';
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
43 newSS.media = media || "all";
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
44
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
45 newSS.href = url;
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
46 // var styles = "@import url(' " + url + " ');";
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
47 // newSS.href ='data:text/css,'+escape(styles);
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
48 document.getElementsByTagName("head")[0].appendChild(newSS);
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
49 }
4350aa369149 Use jQuery UI components.
wycc
parents:
diff changeset
50 }