xooie 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/vendor/assets/javascripts/xooie/stylesheet.js +78 -85
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ab70009822697252412831035528f1eb7020952
|
4
|
+
data.tar.gz: 02654c802201da330d75241b49253816418fbccf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e72367be7bff8679fee12a3f5a2878a7606328dda0bbed569e36d02c86a2c534051d8a804f4a42e9071a6bbbab4adfc410d042f36a4c39890a43e3fbeb1ba7a
|
7
|
+
data.tar.gz: 324165490b07d3ab0e6590bd945874c8ab64018f0f8e863dfead8ebd54e0cce1b0656582e4fb69f40d7bbad38e8fec98455e7e7bf5a0c1f9a510307b6b838206
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright
|
2
|
+
* Copyright 2013 Comcast
|
3
3
|
*
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
* you may not use this file except in compliance with the License.
|
@@ -14,109 +14,102 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
define('xooie/stylesheet', ['jquery'], function($) {
|
18
|
-
|
19
|
-
var i, title;
|
17
|
+
define('xooie/stylesheet', ['jquery'], function ($) {
|
18
|
+
'use strict';
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
var Stylesheet = function (name) {
|
21
|
+
//check to see if a stylesheet already exists with this name
|
22
|
+
this.element = $('style[id=' + name + ']');
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
if (this.element.length <= 0) {
|
25
|
+
//if it does, use it, else create a new one
|
26
|
+
this.element = $(['<style id="' + name + '">',
|
27
|
+
'/* This is a dynamically generated stylesheet: ' + name + ' */',
|
28
|
+
'</style>'].join(''));
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
this.element.appendTo($('head'));
|
31
|
+
}
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
if (document.styleSheets[i].ownerNode && document.styleSheets[i].ownerNode.getAttribute('id') === name) {
|
36
|
-
this._index = i;
|
37
|
-
}
|
38
|
-
}
|
39
|
-
}
|
33
|
+
this._name = name;
|
34
|
+
};
|
40
35
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
this._index = i;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
}
|
48
|
-
};
|
36
|
+
Stylesheet.prototype.get = function () {
|
37
|
+
return this.element[0].sheet || this.element[0].styleSheet;
|
38
|
+
};
|
49
39
|
|
50
|
-
|
51
|
-
|
52
|
-
};
|
40
|
+
Stylesheet.prototype.getRule = function (ruleName) {
|
41
|
+
var i, rules;
|
53
42
|
|
54
|
-
|
55
|
-
ruleName = ruleName.toLowerCase();
|
43
|
+
ruleName = ruleName.toLowerCase();
|
56
44
|
|
57
|
-
|
45
|
+
//Check if this uses the IE format (styleSheet.rules) or the Mozilla/Webkit format
|
46
|
+
rules = this.get().cssRules || this.get().rules;
|
58
47
|
|
59
|
-
|
60
|
-
|
48
|
+
for (i = 0; i < rules.length; i += 1) {
|
49
|
+
if (rules[i].selectorText.toLowerCase() === ruleName) {
|
50
|
+
return rules[i];
|
51
|
+
}
|
52
|
+
}
|
61
53
|
|
62
|
-
|
63
|
-
|
64
|
-
return rules[i];
|
65
|
-
}
|
66
|
-
}
|
54
|
+
return false;
|
55
|
+
};
|
67
56
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
57
|
+
Stylesheet.prototype.addRule = function (ruleName, properties) {
|
58
|
+
var rule = this.getRule(ruleName), index, prop, propString = '', ruleNameArray, i;
|
59
|
+
|
60
|
+
if (!rule) {
|
61
|
+
for (prop in properties) {
|
62
|
+
if (properties.hasOwnProperty(prop)) {
|
63
|
+
propString += prop + ': ' + properties[prop] + ';';
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
if (this.get().insertRule) {
|
68
|
+
//This is the W3C-preferred method
|
69
|
+
index = this.get().cssRules.length;
|
70
|
+
this.get().insertRule(ruleName + ' {' + propString + '}', index);
|
71
|
+
rule = this.get().cssRules[index];
|
72
|
+
} else {
|
73
|
+
//support for IE < 9
|
74
|
+
index = this.get().rules.length;
|
75
|
+
ruleNameArray = ruleName.split(',');
|
76
|
+
// READ: http://msdn.microsoft.com/en-us/library/ie/aa358796%28v=vs.85%29.aspx
|
77
|
+
for (i = 0; i < ruleNameArray.length; i += 1) {
|
78
|
+
this.get().addRule(ruleNameArray[i], propString, index + i);
|
90
79
|
}
|
91
80
|
|
92
|
-
|
93
|
-
|
81
|
+
rule = this.get().rules[index];
|
82
|
+
}
|
83
|
+
}
|
94
84
|
|
95
|
-
|
96
|
-
|
85
|
+
return rule;
|
86
|
+
};
|
97
87
|
|
98
|
-
|
88
|
+
Stylesheet.prototype.deleteRule = function (ruleName) {
|
89
|
+
var i, rules;
|
99
90
|
|
100
|
-
|
101
|
-
rules = this.get().cssRules || this.get().rules;
|
91
|
+
ruleName = ruleName.toLowerCase();
|
102
92
|
|
103
|
-
|
104
|
-
|
105
|
-
if (this.get().deleteRule) {
|
106
|
-
//this is the W3C-preferred method
|
107
|
-
this.get().deleteRule(i);
|
108
|
-
} else {
|
109
|
-
//support for IE < 9
|
110
|
-
this.get().removeRule(i);
|
111
|
-
}
|
93
|
+
//Check if this uses the IE format (styleSheet.rules) or the Mozilla/Webkit format
|
94
|
+
rules = this.get().cssRules || this.get().rules;
|
112
95
|
|
113
|
-
|
114
|
-
|
96
|
+
for (i = 0; i < rules.length; i += 1) {
|
97
|
+
if (rules[i].selectorText.toLowerCase() === ruleName) {
|
98
|
+
if (this.get().deleteRule) {
|
99
|
+
//this is the W3C-preferred method
|
100
|
+
this.get().deleteRule(i);
|
101
|
+
} else {
|
102
|
+
//support for IE < 9
|
103
|
+
this.get().removeRule(i);
|
115
104
|
}
|
116
105
|
|
117
|
-
return
|
118
|
-
|
106
|
+
return true;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
return false;
|
111
|
+
};
|
119
112
|
|
120
|
-
|
113
|
+
return Stylesheet;
|
121
114
|
|
122
|
-
});
|
115
|
+
});
|