webfontloader 1.0.29 → 1.0.30
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.
- data/CHANGELOG +4 -0
 - data/lib/webfontloader.rb +1 -1
 - data/src-test/core/useragenttest.js +32 -0
 - data/src/ascender/ascender_script.js +1 -1
 - data/src/async_load.js +1 -1
 - data/src/core/initialize.js +3 -3
 - data/src/core/useragentparser.js +21 -9
 - data/src/custom/customcss.js +1 -1
 - data/src/fontdeck/fontdeck_script.js +2 -2
 - data/src/google/googlefontapi.js +1 -1
 - data/src/monotype/monotype_script.js +1 -1
 - data/src/typekit/typekit_script.js +1 -1
 - data/webfontloader.gemspec +2 -2
 - metadata +4 -4
 
    
        data/CHANGELOG
    CHANGED
    
    | 
         @@ -1,3 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            v1.0.30 (August 17, 2012)
         
     | 
| 
      
 2 
     | 
    
         
            +
            * Added support for detecting the Windows Phone platform in UserAgentParser, which supports web fonts at version 8 and above.
         
     | 
| 
      
 3 
     | 
    
         
            +
            * Changes to make the global namespace of the library easier to configure when used in 3rd-party projects. (Thanks cbosco!)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       1 
5 
     | 
    
         
             
            v1.0.29 (July 26, 2012)
         
     | 
| 
       2 
6 
     | 
    
         
             
            * Added test to ensure Firefox for Android is properly detected as "Firefox" by UserAgentParser.
         
     | 
| 
       3 
7 
     | 
    
         
             
            * Added test to ensure Opera Mobile for Android is properly detected as "Opera" by UserAgentParser.
         
     | 
    
        data/lib/webfontloader.rb
    CHANGED
    
    
| 
         @@ -148,6 +148,38 @@ UserAgentTest.prototype.testBrowserIsIEMinimal = function() { 
     | 
|
| 
       148 
148 
     | 
    
         
             
              assertTrue(userAgent.isSupportingWebFont());
         
     | 
| 
       149 
149 
     | 
    
         
             
            };
         
     | 
| 
       150 
150 
     | 
    
         | 
| 
      
 151 
     | 
    
         
            +
            UserAgentTest.prototype.testBrowserIsIEOnWindowsPhone = function() {
         
     | 
| 
      
 152 
     | 
    
         
            +
              var userAgentParser = new webfont.UserAgentParser(
         
     | 
| 
      
 153 
     | 
    
         
            +
                  "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; ARM; Touch; IEMobile/10.0; <Manufacturer>; <Device>; <Operator>)",
         
     | 
| 
      
 154 
     | 
    
         
            +
                  this.defaultDocument_);
         
     | 
| 
      
 155 
     | 
    
         
            +
              var userAgent = userAgentParser.parse();
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
              assertEquals("MSIE", userAgent.getName());
         
     | 
| 
      
 158 
     | 
    
         
            +
              assertEquals("10.0", userAgent.getVersion());
         
     | 
| 
      
 159 
     | 
    
         
            +
              assertEquals("Windows Phone", userAgent.getPlatform());
         
     | 
| 
      
 160 
     | 
    
         
            +
              assertEquals("8.0", userAgent.getPlatformVersion());
         
     | 
| 
      
 161 
     | 
    
         
            +
              assertEquals("MSIE", userAgent.getEngine());
         
     | 
| 
      
 162 
     | 
    
         
            +
              assertEquals("10.0", userAgent.getEngineVersion());
         
     | 
| 
      
 163 
     | 
    
         
            +
              assertEquals(undefined, userAgent.getDocumentMode());
         
     | 
| 
      
 164 
     | 
    
         
            +
              assertTrue(userAgent.isSupportingWebFont());
         
     | 
| 
      
 165 
     | 
    
         
            +
            };
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
            UserAgentTest.prototype.testBrowserIsIEOnOldWindowsPhone = function() {
         
     | 
| 
      
 168 
     | 
    
         
            +
              var userAgentParser = new webfont.UserAgentParser(
         
     | 
| 
      
 169 
     | 
    
         
            +
                  "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; SGH-i917)",
         
     | 
| 
      
 170 
     | 
    
         
            +
                  this.defaultDocument_);
         
     | 
| 
      
 171 
     | 
    
         
            +
              var userAgent = userAgentParser.parse();
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
              assertEquals("MSIE", userAgent.getName());
         
     | 
| 
      
 174 
     | 
    
         
            +
              assertEquals("9.0", userAgent.getVersion());
         
     | 
| 
      
 175 
     | 
    
         
            +
              assertEquals("Windows Phone", userAgent.getPlatform());
         
     | 
| 
      
 176 
     | 
    
         
            +
              assertEquals("7.5", userAgent.getPlatformVersion());
         
     | 
| 
      
 177 
     | 
    
         
            +
              assertEquals("MSIE", userAgent.getEngine());
         
     | 
| 
      
 178 
     | 
    
         
            +
              assertEquals("9.0", userAgent.getEngineVersion());
         
     | 
| 
      
 179 
     | 
    
         
            +
              assertEquals(undefined, userAgent.getDocumentMode());
         
     | 
| 
      
 180 
     | 
    
         
            +
              assertFalse(userAgent.isSupportingWebFont());
         
     | 
| 
      
 181 
     | 
    
         
            +
            };
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
       151 
183 
     | 
    
         
             
            UserAgentTest.prototype.testBrowserIsIPhone = function() {
         
     | 
| 
       152 
184 
     | 
    
         
             
              var userAgentParser = new webfont.UserAgentParser(
         
     | 
| 
       153 
185 
     | 
    
         
             
                  "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16",
         
     | 
| 
         @@ -78,7 +78,7 @@ webfont.AscenderScript.prototype.parseVariations = function(source){ 
     | 
|
| 
       78 
78 
     | 
    
         
             
              return variations;
         
     | 
| 
       79 
79 
     | 
    
         
             
            };
         
     | 
| 
       80 
80 
     | 
    
         | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
      
 81 
     | 
    
         
            +
            globalNamespaceObject.addModule(webfont.AscenderScript.NAME, function(configuration) {
         
     | 
| 
       82 
82 
     | 
    
         
             
              var domHelper = new webfont.DomHelper(document);
         
     | 
| 
       83 
83 
     | 
    
         
             
              return new webfont.AscenderScript(domHelper, configuration);
         
     | 
| 
       84 
84 
     | 
    
         
             
            });
         
     | 
    
        data/src/async_load.js
    CHANGED
    
    
    
        data/src/core/initialize.js
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            var globalName = 'WebFont';
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            // Provide an instance of WebFont in the global namespace.
         
     | 
| 
       5 
     | 
    
         
            -
            window[globalName] = (function() {
         
     | 
| 
      
 5 
     | 
    
         
            +
            var globalNamespaceObject = window[globalName] = (function() {
         
     | 
| 
       6 
6 
     | 
    
         
             
              var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
         
     | 
| 
       7 
7 
     | 
    
         
             
              var userAgent = userAgentParser.parse();
         
     | 
| 
       8 
8 
     | 
    
         
             
              var domHelper = new webfont.DomHelper(document);
         
     | 
| 
         @@ -13,8 +13,8 @@ window[globalName] = (function() { 
     | 
|
| 
       13 
13 
     | 
    
         
             
            })();
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
            // Export the public API.
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
            globalNamespaceObject['load'] = globalNamespaceObject.load;
         
     | 
| 
      
 17 
     | 
    
         
            +
            globalNamespaceObject['addModule'] = globalNamespaceObject.addModule;
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            // Export the UserAgent API because we pass this object to external modules.
         
     | 
| 
       20 
20 
     | 
    
         
             
            webfont.UserAgent.prototype['getName'] = webfont.UserAgent.prototype.getName;
         
     | 
    
        data/src/core/useragentparser.js
    CHANGED
    
    | 
         @@ -50,7 +50,7 @@ webfont.UserAgentParser.prototype.parse = function() { 
     | 
|
| 
       50 
50 
     | 
    
         
             
             */
         
     | 
| 
       51 
51 
     | 
    
         
             
            webfont.UserAgentParser.prototype.getPlatform_ = function() {
         
     | 
| 
       52 
52 
     | 
    
         
             
              var mobileOs = this.getMatchingGroup_(this.userAgent_,
         
     | 
| 
       53 
     | 
    
         
            -
                  /(iPod|iPad|iPhone|Android)/, 1);
         
     | 
| 
      
 53 
     | 
    
         
            +
                  /(iPod|iPad|iPhone|Android|Windows Phone)/, 1);
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
55 
     | 
    
         
             
              if (mobileOs != "") {
         
     | 
| 
       56 
56 
     | 
    
         
             
                return mobileOs;
         
     | 
| 
         @@ -76,6 +76,11 @@ webfont.UserAgentParser.prototype.getPlatformVersion_ = function() { 
     | 
|
| 
       76 
76 
     | 
    
         
             
              if (genericVersion) {
         
     | 
| 
       77 
77 
     | 
    
         
             
                return genericVersion;
         
     | 
| 
       78 
78 
     | 
    
         
             
              }
         
     | 
| 
      
 79 
     | 
    
         
            +
              var winPhoneVersion = this.getMatchingGroup_(this.userAgent_,
         
     | 
| 
      
 80 
     | 
    
         
            +
                  /Windows Phone( OS)? ([^;)]+)/, 2);
         
     | 
| 
      
 81 
     | 
    
         
            +
              if (winPhoneVersion) {
         
     | 
| 
      
 82 
     | 
    
         
            +
                return winPhoneVersion;
         
     | 
| 
      
 83 
     | 
    
         
            +
              }
         
     | 
| 
       79 
84 
     | 
    
         
             
              var iVersion = this.getMatchingGroup_(this.userAgent_,
         
     | 
| 
       80 
85 
     | 
    
         
             
                  /(iPhone )?OS ([\d_]+)/, 2);
         
     | 
| 
       81 
86 
     | 
    
         
             
              if (iVersion) {
         
     | 
| 
         @@ -101,25 +106,32 @@ webfont.UserAgentParser.prototype.isIe_ = function() { 
     | 
|
| 
       101 
106 
     | 
    
         
             
             * @private
         
     | 
| 
       102 
107 
     | 
    
         
             
             */
         
     | 
| 
       103 
108 
     | 
    
         
             
            webfont.UserAgentParser.prototype.parseIeUserAgentString_ = function() {
         
     | 
| 
      
 109 
     | 
    
         
            +
              // For IE we give MSIE as the engine name and the version of IE
         
     | 
| 
      
 110 
     | 
    
         
            +
              // instead of the specific Trident engine name and version
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
              var platform = this.getPlatform_();
         
     | 
| 
      
 113 
     | 
    
         
            +
              var platformVersion = this.getPlatformVersion_();
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
       104 
115 
     | 
    
         
             
              var browser = this.getMatchingGroup_(this.userAgent_, /(MSIE [\d\w\.]+)/, 1);
         
     | 
| 
       105 
     | 
    
         
            -
              var engineName = webfont.UserAgentParser.UNKNOWN;
         
     | 
| 
       106 
     | 
    
         
            -
              var engineVersion = webfont.UserAgentParser.UNKNOWN;
         
     | 
| 
       107 
116 
     | 
    
         | 
| 
       108 
117 
     | 
    
         
             
              if (browser != "") {
         
     | 
| 
       109 
118 
     | 
    
         
             
                var pair = browser.split(' ');
         
     | 
| 
       110 
119 
     | 
    
         
             
                var name = pair[0];
         
     | 
| 
       111 
120 
     | 
    
         
             
                var version = pair[1];
         
     | 
| 
      
 121 
     | 
    
         
            +
                var majorVersion = this.getMajorVersion_(version);
         
     | 
| 
      
 122 
     | 
    
         
            +
                var majorPlatformVersion = this.getMajorVersion_(platformVersion);
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                var supportWebFont = (platform == "Windows" && majorVersion >= 6) ||
         
     | 
| 
      
 125 
     | 
    
         
            +
                    (platform == "Windows Phone" && majorPlatformVersion >= 8);
         
     | 
| 
       112 
126 
     | 
    
         | 
| 
       113 
     | 
    
         
            -
                // For IE we give MSIE as the engine name and the version of IE
         
     | 
| 
       114 
     | 
    
         
            -
                // instead of the specific Trident engine name and version
         
     | 
| 
       115 
127 
     | 
    
         
             
                return new webfont.UserAgent(name, version, name, version,
         
     | 
| 
       116 
     | 
    
         
            -
                    this. 
     | 
| 
       117 
     | 
    
         
            -
                     
     | 
| 
      
 128 
     | 
    
         
            +
                    platform, platformVersion, this.getDocumentMode_(this.doc_),
         
     | 
| 
      
 129 
     | 
    
         
            +
                    supportWebFont);
         
     | 
| 
       118 
130 
     | 
    
         
             
              }
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
       119 
132 
     | 
    
         
             
              return new webfont.UserAgent("MSIE", webfont.UserAgentParser.UNKNOWN,
         
     | 
| 
       120 
133 
     | 
    
         
             
                  "MSIE", webfont.UserAgentParser.UNKNOWN,
         
     | 
| 
       121 
     | 
    
         
            -
                  this. 
     | 
| 
       122 
     | 
    
         
            -
                  this.getDocumentMode_(this.doc_), false);
         
     | 
| 
      
 134 
     | 
    
         
            +
                  platform, platformVersion, this.getDocumentMode_(this.doc_), false);
         
     | 
| 
       123 
135 
     | 
    
         
             
            };
         
     | 
| 
       124 
136 
     | 
    
         | 
| 
       125 
137 
     | 
    
         
             
            /**
         
     | 
    
        data/src/custom/customcss.js
    CHANGED
    
    | 
         @@ -31,7 +31,7 @@ webfont.CustomCss.prototype.supportUserAgent = function(userAgent, support) { 
     | 
|
| 
       31 
31 
     | 
    
         
             
              return support(userAgent.isSupportingWebFont());
         
     | 
| 
       32 
32 
     | 
    
         
             
            };
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
            globalNamespaceObject.addModule(webfont.CustomCss.NAME, function(configuration) {
         
     | 
| 
       35 
35 
     | 
    
         
             
              var domHelper = new webfont.DomHelper(document);
         
     | 
| 
       36 
36 
     | 
    
         
             
              return new webfont.CustomCss(domHelper, configuration);
         
     | 
| 
       37 
37 
     | 
    
         
             
            });
         
     | 
| 
         @@ -55,7 +55,7 @@ webfont.FontdeckScript.prototype.load = function(onReady) { 
     | 
|
| 
       55 
55 
     | 
    
         
             
              onReady(this.fontFamilies_, this.fontVariations_);
         
     | 
| 
       56 
56 
     | 
    
         
             
            };
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
            globalNamespaceObject.addModule(webfont.FontdeckScript.NAME, function(configuration) {
         
     | 
| 
       59 
59 
     | 
    
         
             
              var domHelper = new webfont.DomHelper(document);
         
     | 
| 
       60 
60 
     | 
    
         
             
              return new webfont.FontdeckScript(window, domHelper, configuration);
         
     | 
| 
       61 
     | 
    
         
            -
            });
         
     | 
| 
      
 61 
     | 
    
         
            +
            });
         
     | 
    
        data/src/google/googlefontapi.js
    CHANGED
    
    | 
         @@ -48,7 +48,7 @@ webfont.GoogleFontApi.prototype.insertLink_ = function(onReady) { 
     | 
|
| 
       48 
48 
     | 
    
         
             
                  fontApiParser.getFontTestStrings());
         
     | 
| 
       49 
49 
     | 
    
         
             
            };
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
      
 51 
     | 
    
         
            +
            globalNamespaceObject.addModule(webfont.GoogleFontApi.NAME, function(configuration) {
         
     | 
| 
       52 
52 
     | 
    
         
             
              var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
         
     | 
| 
       53 
53 
     | 
    
         
             
              var userAgent = userAgentParser.parse();
         
     | 
| 
       54 
54 
     | 
    
         
             
              return new webfont.GoogleFontApi(userAgent, new webfont.DomHelper(document),
         
     | 
| 
         @@ -97,7 +97,7 @@ webfont.MonotypeScript.prototype.protocol = function () { 
     | 
|
| 
       97 
97 
     | 
    
         
             
              return defaultProtocol;
         
     | 
| 
       98 
98 
     | 
    
         
             
            };
         
     | 
| 
       99 
99 
     | 
    
         | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
      
 100 
     | 
    
         
            +
            globalNamespaceObject.addModule(webfont.MonotypeScript.NAME, function (configuration) {
         
     | 
| 
       101 
101 
     | 
    
         
             
              var userAgentParser = new webfont.UserAgentParser(navigator.userAgent, document);
         
     | 
| 
       102 
102 
     | 
    
         
             
              var userAgent = userAgentParser.parse();
         
     | 
| 
       103 
103 
     | 
    
         
             
              var domHelper = new webfont.DomHelper(document);
         
     | 
| 
         @@ -53,7 +53,7 @@ webfont.TypekitScript.prototype.load = function(onReady) { 
     | 
|
| 
       53 
53 
     | 
    
         
             
              onReady(this.fontFamilies_, this.fontVariations_);
         
     | 
| 
       54 
54 
     | 
    
         
             
            };
         
     | 
| 
       55 
55 
     | 
    
         | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
      
 56 
     | 
    
         
            +
            globalNamespaceObject.addModule(webfont.TypekitScript.NAME, function(configuration) {
         
     | 
| 
       57 
57 
     | 
    
         
             
              var domHelper = new webfont.DomHelper(document);
         
     | 
| 
       58 
58 
     | 
    
         
             
              return new webfont.TypekitScript(window, domHelper, configuration);
         
     | 
| 
       59 
59 
     | 
    
         
             
            });
         
     | 
    
        data/webfontloader.gemspec
    CHANGED
    
    | 
         @@ -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. 
     | 
| 
       17 
     | 
    
         
            -
              s.date              = '2012- 
     | 
| 
      
 16 
     | 
    
         
            +
              s.version           = '1.0.30'
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.date              = '2012-08-17'
         
     | 
| 
       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:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 43
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 1
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 0
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 30
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 1.0.30
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Ryan Carver
         
     | 
| 
         @@ -16,7 +16,7 @@ autorequire: 
     | 
|
| 
       16 
16 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       17 
17 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
            date: 2012- 
     | 
| 
      
 19 
     | 
    
         
            +
            date: 2012-08-17 00:00:00 Z
         
     | 
| 
       20 
20 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       21 
21 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       22 
22 
     | 
    
         
             
              prerelease: false
         
     |