webfontloader 1.0.26 → 1.0.27

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v1.0.27 (April 20, 2012)
2
+ * Updated DomHelper to not require a UserAgent instance. Feature-detection is not used instead of UA detection for switching DOM methods.
3
+
1
4
  v1.0.26 (February 8, 2012)
2
5
  * Updated the included version of the Closure JS compiler jar to 1741, to handle newer annotation styles.
3
6
  * Added a missing param annotation for the new FontWatcher.watch argument.
data/lib/webfontloader.rb CHANGED
@@ -3,7 +3,7 @@ require 'yaml'
3
3
  require 'webfontloader/modules'
4
4
 
5
5
  module WebFontLoader
6
- VERSION = '1.0.26'
6
+ VERSION = '1.0.27'
7
7
 
8
8
  ProjectRoot = File.expand_path(File.dirname(__FILE__) + "/..")
9
9
 
@@ -1,8 +1,7 @@
1
1
  var DomHelperTest = TestCase('DomHelperTest');
2
2
 
3
3
  DomHelperTest.prototype.setUp = function() {
4
- this.domHelper_ = new webfont.DomHelper(document, new webfont.UserAgent("name", "version",
5
- "engine", "engineVersion", "platform", "platformVersion", true));
4
+ this.domHelper_ = new webfont.DomHelper(document);
6
5
  };
7
6
 
8
7
  DomHelperTest.prototype.testCreateElementNoAttr = function() {
@@ -90,4 +89,20 @@ DomHelperTest.prototype.testHasClassName = function() {
90
89
  assertTrue(this.domHelper_.hasClassName(div, 'moo-meuh'));
91
90
  assertFalse(this.domHelper_.hasClassName(div, 'meuh'));
92
91
  assertFalse(this.domHelper_.hasClassName(div, 'missingClassName'));
93
- }
92
+ };
93
+
94
+ DomHelperTest.prototype.testSetStyle = function() {
95
+ var e = this.domHelper_.createElement('span')
96
+ this.domHelper_.setStyle(e, 'left:3px;top:1px;');
97
+ assertEquals('3px', e.style.left)
98
+ assertEquals('1px', e.style.top);
99
+ };
100
+
101
+ DomHelperTest.prototype.testHasSupportForStyle = function() {
102
+ assertUndefined(this.domHelper_.supportForStyle_);
103
+ assertBoolean(this.domHelper_.hasSupportForStyle_());
104
+ this.domHelper_.supportForStyle_ = false;
105
+ assertFalse(this.domHelper_.hasSupportForStyle_());
106
+ this.domHelper_.supportForStyle_ = true;
107
+ assertTrue(this.domHelper_.hasSupportForStyle_());
108
+ };
@@ -79,8 +79,6 @@ webfont.AscenderScript.prototype.parseVariations = function(source){
79
79
  };
80
80
 
81
81
  window['WebFont'].addModule(webfont.AscenderScript.NAME, function(configuration) {
82
- var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
83
- var userAgent = userAgentParser.parse();
84
- var domHelper = new webfont.DomHelper(document, userAgent);
82
+ var domHelper = new webfont.DomHelper(document);
85
83
  return new webfont.AscenderScript(domHelper, configuration);
86
84
  });
@@ -2,12 +2,13 @@
2
2
  * Handles common DOM manipulation tasks. The aim of this library is to cover
3
3
  * the needs of typical font loading. Not more, not less.
4
4
  * @param {HTMLDocument} doc The HTML document we'll manipulate.
5
- * @param {webfont.UserAgent} userAgent The current user agent.
6
5
  * @constructor
7
6
  */
8
- webfont.DomHelper = function(doc, userAgent) {
7
+ webfont.DomHelper = function(doc) {
9
8
  this.document_ = doc;
10
- this.userAgent_ = userAgent;
9
+
10
+ /** @type {boolean|undefined} */
11
+ this.supportForStyle_ = undefined;
11
12
  };
12
13
 
13
14
  /**
@@ -171,9 +172,25 @@ webfont.DomHelper.prototype.hasClassName = function(e, name) {
171
172
  * @param {string} styleString The style string.
172
173
  */
173
174
  webfont.DomHelper.prototype.setStyle = function(e, styleString) {
174
- if (this.userAgent_.getName() == "MSIE") {
175
- e.style.cssText = styleString;
176
- } else {
175
+ if (this.hasSupportForStyle_()) {
177
176
  e.setAttribute("style", styleString);
177
+ } else {
178
+ e.style.cssText = styleString;
179
+ }
180
+ };
181
+
182
+ /**
183
+ * Check if getting and setting the style attribute on an element with
184
+ * getAttribute/setAttribute is supported. In old IE, you must use style.cssText
185
+ * instead. Feature detection is only done the first time this is called.
186
+ * @private
187
+ * @return {boolean} Whether or not the feature is supported.
188
+ */
189
+ webfont.DomHelper.prototype.hasSupportForStyle_ = function() {
190
+ if (this.supportForStyle_ === undefined) {
191
+ var e = this.document_.createElement('p');
192
+ e.innerHTML = '<a style="top:1px;">w</a>';
193
+ this.supportForStyle_ = /top/.test(e.getElementsByTagName('a')[0].getAttribute('style'));
178
194
  }
195
+ return this.supportForStyle_
179
196
  };
@@ -5,7 +5,7 @@ var globalName = 'WebFont';
5
5
  window[globalName] = (function() {
6
6
  var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
7
7
  var userAgent = userAgentParser.parse();
8
- var domHelper = new webfont.DomHelper(document, userAgent);
8
+ var domHelper = new webfont.DomHelper(document);
9
9
  var asyncCall = function(func, timeout) { setTimeout(func, timeout); };
10
10
 
11
11
  return new webfont.WebFont(domHelper, new webfont.FontModuleLoader(),
@@ -32,8 +32,6 @@ webfont.CustomCss.prototype.supportUserAgent = function(userAgent, support) {
32
32
  };
33
33
 
34
34
  window['WebFont'].addModule(webfont.CustomCss.NAME, function(configuration) {
35
- var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
36
- var userAgent = userAgentParser.parse();
37
- var domHelper = new webfont.DomHelper(document, userAgent);
35
+ var domHelper = new webfont.DomHelper(document);
38
36
  return new webfont.CustomCss(domHelper, configuration);
39
37
  });
@@ -56,8 +56,6 @@ webfont.FontdeckScript.prototype.load = function(onReady) {
56
56
  };
57
57
 
58
58
  window['WebFont'].addModule(webfont.FontdeckScript.NAME, function(configuration) {
59
- var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
60
- var userAgent = userAgentParser.parse();
61
- var domHelper = new webfont.DomHelper(document, userAgent);
59
+ var domHelper = new webfont.DomHelper(document);
62
60
  return new webfont.FontdeckScript(window, domHelper, configuration);
63
61
  });
@@ -51,6 +51,6 @@ webfont.GoogleFontApi.prototype.insertLink_ = function(onReady) {
51
51
  window['WebFont'].addModule(webfont.GoogleFontApi.NAME, function(configuration) {
52
52
  var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
53
53
  var userAgent = userAgentParser.parse();
54
- return new webfont.GoogleFontApi(userAgent,
55
- new webfont.DomHelper(document, userAgent), configuration);
54
+ return new webfont.GoogleFontApi(userAgent, new webfont.DomHelper(document),
55
+ configuration);
56
56
  });
@@ -100,6 +100,6 @@ webfont.MonotypeScript.prototype.protocol = function () {
100
100
  window['WebFont'].addModule(webfont.MonotypeScript.NAME, function (configuration) {
101
101
  var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
102
102
  var userAgent = userAgentParser.parse();
103
- var domHelper = new webfont.DomHelper(document, userAgent);
103
+ var domHelper = new webfont.DomHelper(document);
104
104
  return new webfont.MonotypeScript(window, userAgent, domHelper, document, configuration);
105
105
  });
@@ -54,9 +54,7 @@ webfont.TypekitScript.prototype.load = function(onReady) {
54
54
  };
55
55
 
56
56
  window['WebFont'].addModule(webfont.TypekitScript.NAME, function(configuration) {
57
- var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
58
- var userAgent = userAgentParser.parse();
59
- var domHelper = new webfont.DomHelper(document, userAgent);
57
+ var domHelper = new webfont.DomHelper(document);
60
58
  return new webfont.TypekitScript(window, domHelper, configuration);
61
59
  });
62
60
 
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'webfontloader'
16
- s.version = '1.0.26'
17
- s.date = '2012-02-15'
16
+ s.version = '1.0.27'
17
+ s.date = '2012-04-20'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webfontloader
3
3
  version: !ruby/object:Gem::Version
4
- hash: 35
4
+ hash: 33
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 26
10
- version: 1.0.26
9
+ - 27
10
+ version: 1.0.27
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Carver
@@ -16,10 +16,10 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-02-15 00:00:00 -08:00
20
- default_executable:
19
+ date: 2012-04-20 00:00:00 Z
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
@@ -31,11 +31,11 @@ dependencies:
31
31
  - 2
32
32
  - 1
33
33
  version: 1.2.1
34
- prerelease: false
35
34
  requirement: *id001
36
35
  name: rack
37
36
  type: :development
38
37
  - !ruby/object:Gem::Dependency
38
+ prerelease: false
39
39
  version_requirements: &id002 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
@@ -46,11 +46,11 @@ dependencies:
46
46
  - 1
47
47
  - 0
48
48
  version: "1.0"
49
- prerelease: false
50
49
  requirement: *id002
51
50
  name: sinatra
52
51
  type: :development
53
52
  - !ruby/object:Gem::Dependency
53
+ prerelease: false
54
54
  version_requirements: &id003 !ruby/object:Gem::Requirement
55
55
  none: false
56
56
  requirements:
@@ -62,7 +62,6 @@ dependencies:
62
62
  - 1
63
63
  - 6
64
64
  version: 0.1.6
65
- prerelease: false
66
65
  requirement: *id003
67
66
  name: vegas
68
67
  type: :development
@@ -166,7 +165,6 @@ files:
166
165
  - tools/compiler/compiler.jar
167
166
  - tools/jstestdriver/JsTestDriver-1.2.1.jar
168
167
  - webfontloader.gemspec
169
- has_rdoc: true
170
168
  homepage: http://github.com/typekit/webfontloader
171
169
  licenses: []
172
170
 
@@ -196,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
194
  requirements: []
197
195
 
198
196
  rubyforge_project:
199
- rubygems_version: 1.5.2
197
+ rubygems_version: 1.8.15
200
198
  signing_key:
201
199
  specification_version: 2
202
200
  summary: WebFont Loader gives you added control when using linked fonts via @font-face.