Add simple Chrome detection and updates for Gears dialog, fixes #7684

git-svn-id: https://develop.svn.wordpress.org/trunk@8815 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2008-09-05 16:29:03 +00:00
parent 6d94c5cfcc
commit 414eae6719
5 changed files with 43 additions and 23 deletions

View File

@ -100,14 +100,7 @@ if ( ! $is_opera ) {
<div id="gears-msg2" style="display:none;">
<h3 class="info-box-title"><?php _e('Gears Status'); ?></h3>
<p><?php _e('Gears is installed on this computer, but is not enabled for use with WordPress.'); ?></p>
<p><?php
if ( $is_safari )
_e('To enable it, ensure this web site is not on the denied list in Gears Settings under the Safari menu, then click the button below.');
else
_e('To enable it, ensure this web site is not on the denied list in Gears Settings under your browser&#8217;s Tools menu, then click the button below.');
?></p>
<p><?php _e('To enable it click the button below.'); ?></p>
<p><strong><?php _e('However, Gears should not be enabled if this is a public or shared computer.'); ?></strong></p>
<div class="submit"><button class="button" onclick="wpGears.getPermission();"><?php _e('Enable Gears'); ?></button>
<button class="button" style="margin-left:10px;" onclick="document.getElementById('gears-info-box').style.display='none';"><?php _e('Cancel'); ?></button></div>
@ -117,16 +110,36 @@ if ( ! $is_opera ) {
<h3 class="info-box-title"><?php _e('Gears Status'); ?></h3>
<p><?php
if ( $is_safari )
if ( $is_chrome )
_e('Gears is installed and enabled on this computer. You can disable it from your browser&#8217;s Options, Under the Hood menu.');
elseif ( $is_safari )
_e('Gears is installed and enabled on this computer. You can disable it from the Safari menu.');
else
_e('Gears is installed and enabled on this computer. You can disable it from your browser&#8217;s Tools menu.');
?></p>
<p><?php _e('If there are any errors try disabling Gears, reloading the page, and re-enabling Gears.'); ?></p>
<p><?php _e('Local storage status:'); ?> <span id="gears-wait"><span style="color:#f00;"><?php _e('Please wait! Updating files:'); ?></span> <span id="gears-upd-number"></span></span></p>
<p><?php _e('Local storage status:'); ?> <span id="gears-wait"><span style="color:#f00;"><?php _e('Updating files:'); ?></span> <span id="gears-upd-number"></span></span></p>
<div class="submit"><button class="button" onclick="document.getElementById('gears-info-box').style.display='none';"><?php _e('Close'); ?></button></div>
</div>
<div id="gears-msg4" style="display:none;">
<h3 class="info-box-title"><?php _e('Gears Status'); ?></h3>
<p><?php _e('This web site is denied to use Gears.'); ?></p>
<p><?php
if ( $is_chrome )
_e('To allow it, change the Gears settings from your browser&#8217;s Options, Under the Hood menu and reload this page.');
elseif ( $is_safari )
_e('To allow it, change the Gears settings from the Safari menu and reload this page.');
else
_e('To allow it, change the Gears settings from your browser&#8217;s Tools menu and reload this page.');
?></p>
<p><strong><?php _e('However, Gears should not be enabled if this is a public or shared computer.'); ?></strong></p>
<div class="submit"><button class="button" onclick="document.getElementById('gears-info-box').style.display='none';"><?php _e('Cancel'); ?></button></div>
</div>
</div>
<?php } ?>

View File

@ -208,7 +208,6 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
{ "url" : "../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm?ver=311b" },
{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/template.htm?ver=311b" },
{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html?ver=311f" },
{ "url" : "../wp-includes/js/tinymce/wp-mce-help.php?ver=311b" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css?ver=311b" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css?ver=311b" },
@ -276,6 +275,5 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
{ "url" : "../wp-includes/images/crystal/spreadsheet.png" },
{ "url" : "../wp-includes/images/rss.png" },
{ "url" : "../wp-includes/js/thickbox/loadingAnimation.gif" },
{ "url" : "../wp-includes/js/thickbox/tb-close.png" },
{ "url" : "../wp-includes/js/swfupload/swfupload_f9.swf" }
{ "url" : "../wp-includes/js/thickbox/tb-close.png" }
]}

View File

@ -10,17 +10,20 @@ wpGears = {
store = localServer.createManagedStore(this.storeName());
store.manifestUrl = "gears-manifest.php";
store.checkForUpdate();
this.message();
this.message(3);
},
getPermission : function() {
var perm = true;
if ( 'undefined' != typeof google && google.gears ) {
if ( ! google.gears.factory.hasPermission )
google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
perm = google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
try {
this.createStore();
} catch(e) {} // silence if canceled
if ( perm )
try { this.createStore(); } catch(e) { this.message(); } // silence if canceled
else
this.message(4);
}
},
@ -34,13 +37,16 @@ wpGears = {
},
message : function(show) {
var t = this, msg1 = t.I('gears-msg1'), msg2 = t.I('gears-msg2'), msg3 = t.I('gears-msg3'), num = t.I('gears-upd-number'), wait = t.I('gears-wait');
var t = this, msg1 = t.I('gears-msg1'), msg2 = t.I('gears-msg2'), msg3 = t.I('gears-msg3'), msg4 = t.I('gears-msg4'), num = t.I('gears-upd-number'), wait = t.I('gears-wait');
if ( ! msg1 ) return;
if ( 'undefined' != typeof google && google.gears ) {
if ( google.gears.factory.hasPermission ) {
msg1.style.display = msg2.style.display = 'none';
if ( show && show == 4 ) {
msg1.style.display = msg2.style.display = msg3.style.display = 'none';
msg4.style.display = 'block';
} else if ( google.gears.factory.hasPermission ) {
msg1.style.display = msg2.style.display = msg4.style.display = 'none';
msg3.style.display = 'block';
if ( 'undefined' == typeof store )
@ -50,12 +56,13 @@ wpGears = {
store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);};
store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);};
} else {
msg1.style.display = msg3.style.display = 'none';
msg1.style.display = msg3.style.display = msg4.style.display = 'none';
msg2.style.display = 'block';
}
}
if ( show ) t.I('gears-info-box').style.display = 'block';
else t.I('gears-info-box').style.display = 'none';
},
I : function(id) {

View File

@ -234,7 +234,7 @@ function wp_default_scripts( &$scripts ) {
'count' => __('Word count: %d')
));
$scripts->add( 'wp-gears', '/wp-admin/js/wp-gears.js', false, '20080721' );
$scripts->add( 'wp-gears', '/wp-admin/js/wp-gears.js', false, '20080905' );
$scripts->localize( 'wp-gears', 'wpGearsL10n', array(
'updateCompleted' => __('Update completed.'),
'error' => __('Error:')

View File

@ -38,6 +38,8 @@ $is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false) {
$is_lynx = true;
} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chrome') !== false ) {
$is_chrome = true;
} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') !== false ) {
$is_safari = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false) {