ajaxlibs 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -28,6 +28,8 @@ You can specify a specific version of each library to use, or the latest availab
28
28
  * prototype
29
29
  * scriptaculous
30
30
  * swfobject
31
+ * Google Chrome Frame
32
+ * Google Webfont
31
33
 
32
34
  == Examples
33
35
 
@@ -49,7 +51,7 @@ and in production :
49
51
 
50
52
  in development environment :
51
53
 
52
- <script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.min.js?1267013480" type="text/javascript"></script>
54
+ <script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.min.js?1267013480" type="text/javascript"></script>
53
55
  <script src="/javascripts/ajaxlibs/jqueryui/1.7.2/jqueryui.min.js?1267013480" type="text/javascript"></script>
54
56
 
55
57
  this time in production :
@@ -89,7 +91,7 @@ will produce
89
91
 
90
92
  will produce :
91
93
 
92
- <script src="/javascripts/ajaxlibs/prototype/1.6.1.0/prototype.js?1267013480" type="text/javascript"></script>
94
+ <script src="/javascripts/ajaxlibs/prototype/1.6.1.0/prototype.js?1267013480" type="text/javascript"></script>
93
95
  <script src="/javascripts/ajaxlibs/scriptaculous/1.8.3/scriptaculous.js?1267013481" type="text/javascript"></script>
94
96
 
95
97
  === define alternate production environments
@@ -120,7 +122,7 @@ Ajaxlibs prior to version 0.1.10 was copying all javascript libraries in all ava
120
122
  * support more javascript libraries : available though Google CDN (yui), not available through Google CDN, available only from google (google maps, ...).
121
123
 
122
124
  == Note on Patches/Pull Requests
123
-
125
+
124
126
  * Fork the project.
125
127
  * Make your feature addition or bug fix.
126
128
  * Add tests for it. This is important so I don't break it in a
@@ -129,6 +131,10 @@ Ajaxlibs prior to version 0.1.10 was copying all javascript libraries in all ava
129
131
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
130
132
  * Send me a pull request. Bonus points for topic branches.
131
133
 
134
+ == Contributors
135
+
136
+ * Jesse Cooke : Chrome Frame & Webfont support
137
+
132
138
  == Copyright
133
139
 
134
140
  Copyright (c) 2010 Fabien Jakimowicz. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.11
1
+ 0.1.12
data/lib/ajaxlibs.rb CHANGED
@@ -2,6 +2,7 @@ require 'ajaxlibs/constants'
2
2
  require 'ajaxlibs/exceptions'
3
3
  require 'ajaxlibs/versions_tools'
4
4
  require 'ajaxlibs/library'
5
+ require 'ajaxlibs/libraries/chrome_frame.rb'
5
6
  require 'ajaxlibs/libraries/dojo'
6
7
  require 'ajaxlibs/libraries/ext_core'
7
8
  require 'ajaxlibs/libraries/jquery'
@@ -11,6 +12,7 @@ require 'ajaxlibs/libraries/mootools'
11
12
  require 'ajaxlibs/libraries/prototype'
12
13
  require 'ajaxlibs/libraries/scriptaculous'
13
14
  require 'ajaxlibs/libraries/swfobject'
15
+ require 'ajaxlibs/libraries/webfont.rb'
14
16
  require 'ajaxlibs/includes_helper'
15
17
 
16
18
  ActionView::Base.send(:include, Ajaxlibs::IncludesHelper) if Object.const_defined?(:ActionView)
@@ -0,0 +1,13 @@
1
+ class Ajaxlibs::Library::ChromeFrame < Ajaxlibs::Library
2
+ Versions = ['1.0.0',
3
+ '1.0.1',
4
+ '1.0.2']
5
+
6
+ def self.library_name #:nodoc:
7
+ "chrome-frame"
8
+ end
9
+
10
+ def file_name #:nodoc:
11
+ @minified ? 'CFInstall.min' : 'CFInstall'
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ class Ajaxlibs::Library::Webfont < Ajaxlibs::Library
2
+ Versions = ["1"]
3
+
4
+ def file_name #:nodoc:
5
+ @minified ? 'webfont' : 'webfont_debug'
6
+ end
7
+ end
@@ -0,0 +1,224 @@
1
+ // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ /**
6
+ * @fileoverview CFInstall.js provides a set of utilities for managing
7
+ * the Chrome Frame detection and installation process.
8
+ * @author slightlyoff@google.com (Alex Russell)
9
+ */
10
+
11
+ (function(scope) {
12
+ // bail if we'd be over-writing an existing CFInstall object
13
+ if (scope['CFInstall']) {
14
+ return;
15
+ }
16
+
17
+ /**
18
+ * returns an item based on DOM ID. Optionally a document may be provided to
19
+ * specify the scope to search in. If a node is passed, it's returned as-is.
20
+ * @param {string|Node} id The ID of the node to be located or a node
21
+ * @param {Node} doc Optional A document to search for id.
22
+ * @return {Node}
23
+ */
24
+ var byId = function(id, doc) {
25
+ return (typeof id == 'string') ? (doc || document).getElementById(id) : id;
26
+ };
27
+
28
+ /////////////////////////////////////////////////////////////////////////////
29
+ // Plugin Detection
30
+ /////////////////////////////////////////////////////////////////////////////
31
+
32
+ var cachedAvailable;
33
+
34
+ /**
35
+ * Checks to find out if ChromeFrame is available as a plugin
36
+ * @return {Boolean}
37
+ */
38
+ var isAvailable = function() {
39
+ if (typeof cachedAvailable != 'undefined') {
40
+ return cachedAvailable;
41
+ }
42
+
43
+ cachedAvailable = false;
44
+
45
+ // Look for CF in the User Agent before trying more expensive checks
46
+ var ua = navigator.userAgent.toLowerCase();
47
+ if (ua.indexOf("chromeframe") >= 0 || ua.indexOf("x-clock") >= 0) {
48
+ cachedAvailable = true;
49
+ return cachedAvailable;
50
+ }
51
+
52
+ if (typeof window['ActiveXObject'] != 'undefined') {
53
+ try {
54
+ var obj = new ActiveXObject('ChromeTab.ChromeFrame');
55
+ if (obj) {
56
+ cachedAvailable = true;
57
+ }
58
+ } catch(e) {
59
+ // squelch
60
+ }
61
+ }
62
+ return cachedAvailable;
63
+ };
64
+
65
+
66
+ /** @type {boolean} */
67
+ var cfStyleTagInjected = false;
68
+
69
+ /**
70
+ * Creates a style sheet in the document which provides default styling for
71
+ * ChromeFrame instances. Successive calls should have no additive effect.
72
+ */
73
+ var injectCFStyleTag = function() {
74
+ if (cfStyleTagInjected) {
75
+ // Once and only once
76
+ return;
77
+ }
78
+ try {
79
+ var rule = '.chromeFrameInstallDefaultStyle {' +
80
+ 'width: 800px;' +
81
+ 'height: 600px;' +
82
+ 'position: absolute;' +
83
+ 'left: 50%;' +
84
+ 'top: 50%;' +
85
+ 'margin-left: -400px;' +
86
+ 'margin-top: -300px;' +
87
+ '}';
88
+ var ss = document.createElement('style');
89
+ ss.setAttribute('type', 'text/css');
90
+ if (ss.styleSheet) {
91
+ ss.styleSheet.cssText = rule;
92
+ } else {
93
+ ss.appendChild(document.createTextNode(rule));
94
+ }
95
+ var h = document.getElementsByTagName('head')[0];
96
+ var firstChild = h.firstChild;
97
+ h.insertBefore(ss, firstChild);
98
+ cfStyleTagInjected = true;
99
+ } catch (e) {
100
+ // squelch
101
+ }
102
+ };
103
+
104
+
105
+ /**
106
+ * Plucks properties from the passed arguments and sets them on the passed
107
+ * DOM node
108
+ * @param {Node} node The node to set properties on
109
+ * @param {Object} args A map of user-specified properties to set
110
+ */
111
+ var setProperties = function(node, args) {
112
+ injectCFStyleTag();
113
+
114
+ var srcNode = byId(args['node']);
115
+
116
+ node.id = args['id'] || (srcNode ? srcNode['id'] || getUid(srcNode) : '');
117
+
118
+ // TODO(slightlyoff): Opera compat? need to test there
119
+ var cssText = args['cssText'] || '';
120
+ node.style.cssText = ' ' + cssText;
121
+
122
+ var classText = args['className'] || '';
123
+ node.className = 'chromeFrameInstallDefaultStyle ' + classText;
124
+
125
+ // default if the browser doesn't so we don't show sad-tab
126
+ var src = args['src'] || 'about:blank';
127
+
128
+ node.src = src;
129
+
130
+ if (srcNode) {
131
+ srcNode.parentNode.replaceChild(node, srcNode);
132
+ }
133
+ };
134
+
135
+ /**
136
+ * Creates an iframe.
137
+ * @param {Object} args A bag of configuration properties, including values
138
+ * like 'node', 'cssText', 'className', 'id', 'src', etc.
139
+ * @return {Node}
140
+ */
141
+ var makeIframe = function(args) {
142
+ var el = document.createElement('iframe');
143
+ setProperties(el, args);
144
+ return el;
145
+ };
146
+
147
+ var CFInstall = {};
148
+ /**
149
+ * Checks to see if Chrome Frame is available, if not, prompts the user to
150
+ * install. Once installation is begun, a background timer starts,
151
+ * checkinging for a successful install every 2 seconds. Upon detection of
152
+ * successful installation, the current page is reloaded, or if a
153
+ * 'destination' parameter is passed, the page navigates there instead.
154
+ * @param {Object} args A bag of configuration properties. Respected
155
+ * properties are: 'mode', 'url', 'destination', 'node', 'onmissing',
156
+ * 'preventPrompt', 'oninstall', 'preventInstallDetection', 'cssText', and
157
+ * 'className'.
158
+ * @public
159
+ */
160
+ CFInstall.check = function(args) {
161
+ args = args || {};
162
+
163
+ // We currently only support CF in IE
164
+ // TODO(slightlyoff): Update this should we support other browsers!
165
+ var ieRe = /MSIE (\S+)/;
166
+ if (!ieRe.test(navigator.userAgent)) {
167
+ return;
168
+ }
169
+
170
+
171
+ // TODO(slightlyoff): Update this URL when a mini-installer page is
172
+ // available.
173
+ var installUrl = '//www.google.com/chromeframe';
174
+ if (!isAvailable()) {
175
+ if (args.onmissing) {
176
+ args.onmissing();
177
+ }
178
+
179
+ args.src = args.url || installUrl;
180
+ var mode = args.mode || 'inline';
181
+ var preventPrompt = args.preventPrompt || false;
182
+
183
+ if (!preventPrompt) {
184
+ if (mode == 'inline') {
185
+ var ifr = makeIframe(args);
186
+ // TODO(slightlyoff): handle placement more elegantly!
187
+ if (!ifr.parentNode) {
188
+ var firstChild = document.body.firstChild;
189
+ document.body.insertBefore(ifr, firstChild);
190
+ }
191
+ } else {
192
+ window.open(args.src);
193
+ }
194
+ }
195
+
196
+ if (args.preventInstallDetection) {
197
+ return;
198
+ }
199
+
200
+ // Begin polling for install success.
201
+ var installTimer = setInterval(function() {
202
+ // every 2 seconds, look to see if CF is available, if so, proceed on
203
+ // to our destination
204
+ if (isAvailable()) {
205
+ if (args.oninstall) {
206
+ args.oninstall();
207
+ }
208
+
209
+ clearInterval(installTimer);
210
+ // TODO(slightlyoff): add a way to prevent navigation or make it
211
+ // contingent on oninstall?
212
+ window.location = args.destination || window.location;
213
+ }
214
+ }, 2000);
215
+ }
216
+ };
217
+
218
+ CFInstall.isAvailable = isAvailable;
219
+
220
+ // expose CFInstall to the external scope. We've already checked to make
221
+ // sure we're not going to blow existing objects away.
222
+ scope.CFInstall = CFInstall;
223
+
224
+ })(this['ChromeFrameInstallScope'] || this);
@@ -0,0 +1,224 @@
1
+ // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ /**
6
+ * @fileoverview CFInstall.js provides a set of utilities for managing
7
+ * the Chrome Frame detection and installation process.
8
+ * @author slightlyoff@google.com (Alex Russell)
9
+ */
10
+
11
+ (function(scope) {
12
+ // bail if we'd be over-writing an existing CFInstall object
13
+ if (scope['CFInstall']) {
14
+ return;
15
+ }
16
+
17
+ /**
18
+ * returns an item based on DOM ID. Optionally a document may be provided to
19
+ * specify the scope to search in. If a node is passed, it's returned as-is.
20
+ * @param {string|Node} id The ID of the node to be located or a node
21
+ * @param {Node} doc Optional A document to search for id.
22
+ * @return {Node}
23
+ */
24
+ var byId = function(id, doc) {
25
+ return (typeof id == 'string') ? (doc || document).getElementById(id) : id;
26
+ };
27
+
28
+ /////////////////////////////////////////////////////////////////////////////
29
+ // Plugin Detection
30
+ /////////////////////////////////////////////////////////////////////////////
31
+
32
+ var cachedAvailable;
33
+
34
+ /**
35
+ * Checks to find out if ChromeFrame is available as a plugin
36
+ * @return {Boolean}
37
+ */
38
+ var isAvailable = function() {
39
+ if (typeof cachedAvailable != 'undefined') {
40
+ return cachedAvailable;
41
+ }
42
+
43
+ cachedAvailable = false;
44
+
45
+ // Look for CF in the User Agent before trying more expensive checks
46
+ var ua = navigator.userAgent.toLowerCase();
47
+ if (ua.indexOf("chromeframe") >= 0 || ua.indexOf("x-clock") >= 0) {
48
+ cachedAvailable = true;
49
+ return cachedAvailable;
50
+ }
51
+
52
+ if (typeof window['ActiveXObject'] != 'undefined') {
53
+ try {
54
+ var obj = new ActiveXObject('ChromeTab.ChromeFrame');
55
+ if (obj) {
56
+ cachedAvailable = true;
57
+ }
58
+ } catch(e) {
59
+ // squelch
60
+ }
61
+ }
62
+ return cachedAvailable;
63
+ };
64
+
65
+
66
+ /** @type {boolean} */
67
+ var cfStyleTagInjected = false;
68
+
69
+ /**
70
+ * Creates a style sheet in the document which provides default styling for
71
+ * ChromeFrame instances. Successive calls should have no additive effect.
72
+ */
73
+ var injectCFStyleTag = function() {
74
+ if (cfStyleTagInjected) {
75
+ // Once and only once
76
+ return;
77
+ }
78
+ try {
79
+ var rule = '.chromeFrameInstallDefaultStyle {' +
80
+ 'width: 800px;' +
81
+ 'height: 600px;' +
82
+ 'position: absolute;' +
83
+ 'left: 50%;' +
84
+ 'top: 50%;' +
85
+ 'margin-left: -400px;' +
86
+ 'margin-top: -300px;' +
87
+ '}';
88
+ var ss = document.createElement('style');
89
+ ss.setAttribute('type', 'text/css');
90
+ if (ss.styleSheet) {
91
+ ss.styleSheet.cssText = rule;
92
+ } else {
93
+ ss.appendChild(document.createTextNode(rule));
94
+ }
95
+ var h = document.getElementsByTagName('head')[0];
96
+ var firstChild = h.firstChild;
97
+ h.insertBefore(ss, firstChild);
98
+ cfStyleTagInjected = true;
99
+ } catch (e) {
100
+ // squelch
101
+ }
102
+ };
103
+
104
+
105
+ /**
106
+ * Plucks properties from the passed arguments and sets them on the passed
107
+ * DOM node
108
+ * @param {Node} node The node to set properties on
109
+ * @param {Object} args A map of user-specified properties to set
110
+ */
111
+ var setProperties = function(node, args) {
112
+ injectCFStyleTag();
113
+
114
+ var srcNode = byId(args['node']);
115
+
116
+ node.id = args['id'] || (srcNode ? srcNode['id'] || getUid(srcNode) : '');
117
+
118
+ // TODO(slightlyoff): Opera compat? need to test there
119
+ var cssText = args['cssText'] || '';
120
+ node.style.cssText = ' ' + cssText;
121
+
122
+ var classText = args['className'] || '';
123
+ node.className = 'chromeFrameInstallDefaultStyle ' + classText;
124
+
125
+ // default if the browser doesn't so we don't show sad-tab
126
+ var src = args['src'] || 'about:blank';
127
+
128
+ node.src = src;
129
+
130
+ if (srcNode) {
131
+ srcNode.parentNode.replaceChild(node, srcNode);
132
+ }
133
+ };
134
+
135
+ /**
136
+ * Creates an iframe.
137
+ * @param {Object} args A bag of configuration properties, including values
138
+ * like 'node', 'cssText', 'className', 'id', 'src', etc.
139
+ * @return {Node}
140
+ */
141
+ var makeIframe = function(args) {
142
+ var el = document.createElement('iframe');
143
+ setProperties(el, args);
144
+ return el;
145
+ };
146
+
147
+ var CFInstall = {};
148
+ /**
149
+ * Checks to see if Chrome Frame is available, if not, prompts the user to
150
+ * install. Once installation is begun, a background timer starts,
151
+ * checkinging for a successful install every 2 seconds. Upon detection of
152
+ * successful installation, the current page is reloaded, or if a
153
+ * 'destination' parameter is passed, the page navigates there instead.
154
+ * @param {Object} args A bag of configuration properties. Respected
155
+ * properties are: 'mode', 'url', 'destination', 'node', 'onmissing',
156
+ * 'preventPrompt', 'oninstall', 'preventInstallDetection', 'cssText', and
157
+ * 'className'.
158
+ * @public
159
+ */
160
+ CFInstall.check = function(args) {
161
+ args = args || {};
162
+
163
+ // We currently only support CF in IE
164
+ // TODO(slightlyoff): Update this should we support other browsers!
165
+ var ieRe = /MSIE (\S+)/;
166
+ if (!ieRe.test(navigator.userAgent)) {
167
+ return;
168
+ }
169
+
170
+
171
+ // TODO(slightlyoff): Update this URL when a mini-installer page is
172
+ // available.
173
+ var installUrl = '//www.google.com/chromeframe';
174
+ if (!isAvailable()) {
175
+ if (args.onmissing) {
176
+ args.onmissing();
177
+ }
178
+
179
+ args.src = args.url || installUrl;
180
+ var mode = args.mode || 'inline';
181
+ var preventPrompt = args.preventPrompt || false;
182
+
183
+ if (!preventPrompt) {
184
+ if (mode == 'inline') {
185
+ var ifr = makeIframe(args);
186
+ // TODO(slightlyoff): handle placement more elegantly!
187
+ if (!ifr.parentNode) {
188
+ var firstChild = document.body.firstChild;
189
+ document.body.insertBefore(ifr, firstChild);
190
+ }
191
+ } else {
192
+ window.open(args.src);
193
+ }
194
+ }
195
+
196
+ if (args.preventInstallDetection) {
197
+ return;
198
+ }
199
+
200
+ // Begin polling for install success.
201
+ var installTimer = setInterval(function() {
202
+ // every 2 seconds, look to see if CF is available, if so, proceed on
203
+ // to our destination
204
+ if (isAvailable()) {
205
+ if (args.oninstall) {
206
+ args.oninstall();
207
+ }
208
+
209
+ clearInterval(installTimer);
210
+ // TODO(slightlyoff): add a way to prevent navigation or make it
211
+ // contingent on oninstall?
212
+ window.location = args.destination || window.location;
213
+ }
214
+ }, 2000);
215
+ }
216
+ };
217
+
218
+ CFInstall.isAvailable = isAvailable;
219
+
220
+ // expose CFInstall to the external scope. We've already checked to make
221
+ // sure we're not going to blow existing objects away.
222
+ scope.CFInstall = CFInstall;
223
+
224
+ })(this['ChromeFrameInstallScope'] || this);