xooie 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bba9ef5b7fd47812ebd8bcf300e546a972f6e6d3
4
- data.tar.gz: 6ff0ba21b6c701a1d749169faa5c33283c727da8
3
+ metadata.gz: 9ab70009822697252412831035528f1eb7020952
4
+ data.tar.gz: 02654c802201da330d75241b49253816418fbccf
5
5
  SHA512:
6
- metadata.gz: 0bb54e98a604cac3f43d8771837ce9b1f746ae53b113d9328dd6bbc361768b3493d0bf9eea5cd9ee48f5f0dc631f7b40fe150d8c66ac01c63279fa5cf8b3e928
7
- data.tar.gz: d828d26641b76aba41f47a11c8ff04a02f797cd45d44fc4595a4a2ea82c0675eeef181d291ab0e52a6e2c42171f249f5d11eda76ce35ace1b53894490b12d65f
6
+ metadata.gz: 7e72367be7bff8679fee12a3f5a2878a7606328dda0bbed569e36d02c86a2c534051d8a804f4a42e9071a6bbbab4adfc410d042f36a4c39890a43e3fbeb1ba7a
7
+ data.tar.gz: 324165490b07d3ab0e6590bd945874c8ab64018f0f8e863dfead8ebd54e0cce1b0656582e4fb69f40d7bbad38e8fec98455e7e7bf5a0c1f9a510307b6b838206
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2012 Comcast
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
- var Stylesheet = function(name){
19
- var i, title;
17
+ define('xooie/stylesheet', ['jquery'], function ($) {
18
+ 'use strict';
20
19
 
21
- //check to see if a stylesheet already exists with this name
22
- this.element = $('style[id=' + name + ']');
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
- 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(''));
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
- this.element.appendTo($('head'));
31
- }
30
+ this.element.appendTo($('head'));
31
+ }
32
32
 
33
- if (document.styleSheets) {
34
- for (i = 0; i < document.styleSheets.length; i += 1){
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
- if (typeof this._index === 'undefined') {
42
- for (i = 0; i < document.styleSheets.length; i += 1){
43
- if (document.styleSheets[i].id === name) {
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
- Stylesheet.prototype.get = function(){
51
- return document.styleSheets[this._index];
52
- };
40
+ Stylesheet.prototype.getRule = function (ruleName) {
41
+ var i, rules;
53
42
 
54
- Stylesheet.prototype.getRule = function(ruleName){
55
- ruleName = ruleName.toLowerCase();
43
+ ruleName = ruleName.toLowerCase();
56
44
 
57
- var i, rules;
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
- //Check if this uses the IE format (styleSheet.rules) or the Mozilla/Webkit format
60
- rules = this.get().cssRules || this.get().rules;
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
- for (i = 0; i < rules.length; i += 1){
63
- if (rules[i].selectorText.toLowerCase() === ruleName) {
64
- return rules[i];
65
- }
66
- }
54
+ return false;
55
+ };
67
56
 
68
- return false;
69
- };
70
-
71
- Stylesheet.prototype.addRule = function(ruleName, properties){
72
- var rule = this.getRule(ruleName), index, prop, propString = '';
73
-
74
- if (!rule){
75
- for (prop in properties) {
76
- propString += prop + ': ' + properties[prop] + ';';
77
- }
78
-
79
- if (this.get().insertRule) {
80
- //This is the W3C-preferred method
81
- index = this.get().cssRules.length;
82
- this.get().insertRule(ruleName + ' {' + propString + '}', index);
83
- rule = this.get().cssRules[index];
84
- } else {
85
- //support for IE < 9
86
- index = this.get().rules.length;
87
- this.get().addRule(ruleName, propString, index);
88
- rule = this.get().rules[index];
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
- return rule;
93
- };
81
+ rule = this.get().rules[index];
82
+ }
83
+ }
94
84
 
95
- Stylesheet.prototype.deleteRule = function(ruleName){
96
- ruleName = ruleName.toLowerCase();
85
+ return rule;
86
+ };
97
87
 
98
- var i, rules;
88
+ Stylesheet.prototype.deleteRule = function (ruleName) {
89
+ var i, rules;
99
90
 
100
- //Check if this uses the IE format (styleSheet.rules) or the Mozilla/Webkit format
101
- rules = this.get().cssRules || this.get().rules;
91
+ ruleName = ruleName.toLowerCase();
102
92
 
103
- for (i = 0; i < rules.length; i += 1){
104
- if (rules[i].selectorText.toLowerCase() === ruleName) {
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
- return true;
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 false;
118
- };
106
+ return true;
107
+ }
108
+ }
109
+
110
+ return false;
111
+ };
119
112
 
120
- return Stylesheet;
113
+ return Stylesheet;
121
114
 
122
- });
115
+ });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xooie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Larkin