mirror of
https://github.com/transmission/transmission
synced 2025-03-04 02:28:03 +00:00
(trunk web) rename "iphone" variables and css files as "mobile", since they also work on iPods and Android phones.
This commit is contained in:
parent
6d4a7a2f10
commit
2faba73c5b
6 changed files with 58 additions and 149 deletions
|
@ -12,9 +12,9 @@
|
|||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
|
||||
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" type="text/css" media="all" />
|
||||
<!--
|
||||
<link media="screen" href="./stylesheets/iphone.css" type= "text/css" rel="stylesheet" />
|
||||
<link media="screen" href="./stylesheets/mobile.css" type= "text/css" rel="stylesheet" />
|
||||
-->
|
||||
<link media="only screen and (max-device-width: 480px)" href="./stylesheets/iphone.css" type= "text/css" rel="stylesheet" />
|
||||
<link media="only screen and (max-device-width: 480px)" href="./stylesheets/mobile.css" type= "text/css" rel="stylesheet" />
|
||||
<link media="screen and (min-device-width: 481px)" href="./stylesheets/common.css" type="text/css" rel="stylesheet" />
|
||||
<!--[if IE]>
|
||||
<link media="screen" href="./stylesheets/common.css" type="text/css" rel="stylesheet" />
|
||||
|
|
|
@ -6,14 +6,10 @@
|
|||
* Common javascript
|
||||
*/
|
||||
|
||||
var transmission;
|
||||
var dialog;
|
||||
// Test for a Webkit build that supports box-shadow: 521+ (release Safari 3 is
|
||||
// actually 523.10.3). We need 3.1 for CSS animation (dialog sheets) but as it
|
||||
// degrades gracefully let's not worry too much.
|
||||
var Safari3 = testSafari3();
|
||||
var iPhone = RegExp("(iPhone|iPod|Android)").test(navigator.userAgent);
|
||||
if (iPhone) var scroll_timeout;
|
||||
var transmission,
|
||||
dialog,
|
||||
isMobileDevice = RegExp("(isMobileDevice|iPod|Android)").test(navigator.userAgent),
|
||||
scroll_timeout;
|
||||
|
||||
if (!Array.indexOf){
|
||||
Array.prototype.indexOf = function(obj){
|
||||
|
@ -25,23 +21,6 @@ if (!Array.indexOf){
|
|||
}
|
||||
}
|
||||
|
||||
function testSafari3()
|
||||
{
|
||||
var minimum = new Array(521,0);
|
||||
var webKitFields = RegExp("(AppleWebKit/)([^ ]+)").exec(navigator.userAgent);
|
||||
if (!webKitFields || webKitFields.length < 3) return false;
|
||||
var version = webKitFields[2].split(".");
|
||||
for (var i = 0; i < minimum.length; i++) {
|
||||
var toInt = parseInt(version[i]);
|
||||
var versionField = isNaN(toInt) ? 0 : toInt;
|
||||
var minimumField = minimum[i];
|
||||
|
||||
if (versionField > minimumField) return true;
|
||||
if (versionField < minimumField) return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
// Initialise the dialog controller
|
||||
dialog = new Dialog();
|
||||
|
@ -61,33 +40,21 @@ $(document).ready(function() {
|
|||
// Move search field's margin down for the styled input
|
||||
$('#torrent_search').css('margin-top', 3);
|
||||
}
|
||||
if (!Safari3 && !iPhone) {
|
||||
if (isMobileDevice){
|
||||
window.onload = function(){ setTimeout(function() { window.scrollTo(0,1); },500); };
|
||||
window.onorientationchange = function(){ setTimeout(function() { window.scrollTo(0,1); },100); };
|
||||
if (window.navigator.standalone)
|
||||
// Fix min height for isMobileDevice when run in full screen mode from home screen
|
||||
// so the footer appears in the right place
|
||||
$('body div#torrent_container').css('min-height', '338px');
|
||||
$("label[for=torrent_upload_url]").text("URL: ");
|
||||
} else {
|
||||
// Fix for non-Safari-3 browsers: dark borders to replace shadows.
|
||||
// Opera messes up the menu if we use a border on .trans_menu
|
||||
// div.outerbox so use ul instead
|
||||
$('.trans_menu ul, div#jqContextMenu, div.dialog_container div.dialog_window').css('border', '1px solid #777');
|
||||
// and this kills the border we used to have
|
||||
$('.trans_menu div.outerbox').css('border', 'none');
|
||||
} else if (!iPhone) {
|
||||
// Used for Safari 3.1 CSS animation. Degrades gracefully (so Safari 3
|
||||
// test is good enough) but we delay our hide/unhide to wait for the
|
||||
// scrolling - no point making other browsers wait.
|
||||
$('div#upload_container div.dialog_window').css('top', '-205px');
|
||||
$('div#prefs_container div.dialog_window').css('top', '-425px');
|
||||
$('div#dialog_container div.dialog_window').css('top', '-425px');
|
||||
$('div.dialog_container div.dialog_window').css('-webkit-transition', 'top 0.3s');
|
||||
// -webkit-appearance makes some links into buttons, but needs
|
||||
// different padding.
|
||||
$('div.dialog_container div.dialog_window a').css('padding', '2px 10px 3px');
|
||||
}
|
||||
if (iPhone){
|
||||
window.onload = function(){ setTimeout(function() { window.scrollTo(0,1); },500); };
|
||||
window.onorientationchange = function(){ setTimeout(function() { window.scrollTo(0,1); },100); };
|
||||
if (window.navigator.standalone)
|
||||
// Fix min height for iPhone when run in full screen mode from home screen
|
||||
// so the footer appears in the right place
|
||||
$('body div#torrent_container').css('min-height', '338px');
|
||||
$("label[for=torrent_upload_url]").text("URL: ");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -46,13 +46,8 @@ Dialog.prototype = {
|
|||
hideDialog: function()
|
||||
{
|
||||
$('body.dialog_showing').removeClass('dialog_showing');
|
||||
if (Safari3) {
|
||||
$('div#dialog_container div.dialog_window').css('top', '-150px');
|
||||
setTimeout("dialog._container.hide();",500);
|
||||
} else {
|
||||
this._container.hide();
|
||||
transmission.hideiPhoneAddressbar();
|
||||
}
|
||||
this._container.hide();
|
||||
transmission.hideMobileAddressbar();
|
||||
transmission.updateButtonStates();
|
||||
},
|
||||
|
||||
|
@ -80,14 +75,8 @@ Dialog.prototype = {
|
|||
confirm: function(dialog_heading, dialog_message, confirm_button_label,
|
||||
callback_function, callback_data, cancel_button_label)
|
||||
{
|
||||
if (!iPhone && Safari3) {
|
||||
$('div#upload_container div.dialog_window').css('top', '-205px');
|
||||
$('div#prefs_container div.dialog_window').css('top', '-425px');
|
||||
setTimeout("$('#upload_container').hide();",500);
|
||||
setTimeout("$('#prefs_container').hide();",500);
|
||||
} else if (!iPhone) {
|
||||
if (!isMobileDevice)
|
||||
$('.dialog_container').hide();
|
||||
}
|
||||
setInnerHTML(this._heading[0], dialog_heading);
|
||||
setInnerHTML(this._message[0], dialog_message);
|
||||
setInnerHTML(this._cancel_button[0], (cancel_button_label == null) ? 'Cancel' : cancel_button_label);
|
||||
|
@ -98,51 +87,28 @@ Dialog.prototype = {
|
|||
$('body').addClass('dialog_showing');
|
||||
this._container.show();
|
||||
transmission.updateButtonStates();
|
||||
if (iPhone) {
|
||||
transmission.hideiPhoneAddressbar();
|
||||
} else if (Safari3) {
|
||||
setTimeout("$('div#dialog_container div.dialog_window').css('top', '0px');",10);
|
||||
}
|
||||
if (isMobileDevice)
|
||||
transmission.hideMobileAddressbar();
|
||||
},
|
||||
|
||||
/*
|
||||
* Display an alert dialog
|
||||
*/
|
||||
alert: function(dialog_heading, dialog_message, cancel_button_label) {
|
||||
if (!iPhone && Safari3) {
|
||||
$('div#upload_container div.dialog_window').css('top', '-205px');
|
||||
$('div#prefs_container div.dialog_window').css('top', '-425px');
|
||||
setTimeout("$('#upload_container').hide();",500);
|
||||
setTimeout("$('#prefs_container').hide();",500);
|
||||
} else if (!iPhone) {
|
||||
if (!isMobileDevice)
|
||||
$('.dialog_container').hide();
|
||||
}
|
||||
setInnerHTML(this._heading[0], dialog_heading);
|
||||
setInnerHTML(this._message[0], dialog_message);
|
||||
// jquery::hide() doesn't work here in Safari for some odd reason
|
||||
this._confirm_button.css('display', 'none');
|
||||
setInnerHTML(this._cancel_button[0], cancel_button_label);
|
||||
// Just in case
|
||||
if (!iPhone && Safari3) {
|
||||
$('div#upload_container div.dialog_window').css('top', '-205px');
|
||||
setTimeout("$('#upload_container').hide();",500);
|
||||
} else {
|
||||
$('#upload_container').hide();
|
||||
}
|
||||
$('#upload_container').hide();
|
||||
$('body').addClass('dialog_showing');
|
||||
transmission.updateButtonStates();
|
||||
if (iPhone) {
|
||||
transmission.hideiPhoneAddressbar();
|
||||
this._container.show();
|
||||
} else if (Safari3) {
|
||||
// long pause as we just hid all the dialogs on a timeout - we'll get the error
|
||||
// scrolling in and immediately disappearing if we're not careful!
|
||||
//dialogTimeout = null;
|
||||
this._container.show();
|
||||
setTimeout("$('div#dialog_container div.dialog_window').css('top', '0px');",500);
|
||||
} else {
|
||||
this._container.show();
|
||||
}
|
||||
if (isMobileDevice)
|
||||
transmission.hideMobileAddressbar();
|
||||
this._container.show();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ FileRow.prototype =
|
|||
x -= e.offsetLeft;
|
||||
e = e.offsetParent;
|
||||
}
|
||||
if (iPhone) {
|
||||
if (isMobileDevice) {
|
||||
if (x < 8) prio = -1;
|
||||
else if (x < 27) prio = 0;
|
||||
else prio = 1;
|
||||
|
|
|
@ -71,7 +71,7 @@ Transmission.prototype =
|
|||
|
||||
$('#torrent_upload_form').submit(function() { $('#upload_confirm_button').click(); return false; });
|
||||
|
||||
if (iPhone) {
|
||||
if (isMobileDevice) {
|
||||
$('#inspector_close').bind('click', function() { tr.setInspectorVisible(false); });
|
||||
$('#preferences_link').bind('click', function(e) { tr.releaseClutchPreferencesButton(e); });
|
||||
} else {
|
||||
|
@ -169,7 +169,7 @@ Transmission.prototype =
|
|||
},
|
||||
|
||||
preloadImages: function() {
|
||||
if (iPhone) {
|
||||
if (isMobileDevice) {
|
||||
this.loadImages(
|
||||
'images/buttons/info_general.png',
|
||||
'images/buttons/info_activity.png',
|
||||
|
@ -211,9 +211,9 @@ Transmission.prototype =
|
|||
|
||||
// iPhone conditions in the section allow us to not
|
||||
// include transmenu js to save some bandwidth; if we
|
||||
// start using prefs on iPhone we need to weed
|
||||
// start using prefs on mobile devices we need to weed
|
||||
// transmenu refs out of that too.
|
||||
if (!iPhone)
|
||||
if (!isMobileDevice)
|
||||
{
|
||||
$('#sort_by_' + this[Prefs._SortMethod]).selectMenuItem();
|
||||
|
||||
|
@ -350,7 +350,7 @@ Transmission.prototype =
|
|||
|
||||
scrollToRow: function(row)
|
||||
{
|
||||
if (iPhone) // FIXME: why?
|
||||
if (isMobileDevice) // FIXME: why?
|
||||
return;
|
||||
|
||||
var list = $('#torrent_container'),
|
||||
|
@ -547,28 +547,28 @@ Transmission.prototype =
|
|||
stopAllClicked: function(ev) {
|
||||
if (this.isButtonEnabled(ev)) {
|
||||
this.stopAllTorrents();
|
||||
this.hideiPhoneAddressbar();
|
||||
this.hideMobileAddressbar();
|
||||
}
|
||||
},
|
||||
|
||||
stopSelectedClicked: function(ev) {
|
||||
if (this.isButtonEnabled(ev)) {
|
||||
this.stopSelectedTorrents();
|
||||
this.hideiPhoneAddressbar();
|
||||
this.hideMobileAddressbar();
|
||||
}
|
||||
},
|
||||
|
||||
startAllClicked: function(ev) {
|
||||
if (this.isButtonEnabled(ev)) {
|
||||
this.startAllTorrents();
|
||||
this.hideiPhoneAddressbar();
|
||||
this.hideMobileAddressbar();
|
||||
}
|
||||
},
|
||||
|
||||
startSelectedClicked: function(ev) {
|
||||
if (this.isButtonEnabled(ev)) {
|
||||
this.startSelectedTorrents(false);
|
||||
this.hideiPhoneAddressbar();
|
||||
this.hideMobileAddressbar();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -630,12 +630,7 @@ Transmission.prototype =
|
|||
|
||||
hideUploadDialog: function() {
|
||||
$('body.open_showing').removeClass('open_showing');
|
||||
if (!iPhone && Safari3) {
|
||||
$('div#upload_container div.dialog_window').css('top', '-205px');
|
||||
setTimeout("$('#upload_container').hide();",500);
|
||||
} else {
|
||||
$('#upload_container').hide();
|
||||
}
|
||||
$('#upload_container').hide();
|
||||
this.updateButtonStates();
|
||||
},
|
||||
|
||||
|
@ -696,12 +691,12 @@ Transmission.prototype =
|
|||
removeClicked: function(ev) {
|
||||
if (this.isButtonEnabled(ev)) {
|
||||
this.removeSelectedTorrents();
|
||||
this.hideiPhoneAddressbar();
|
||||
this.hideMobileAddressbar();
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* 'Clutch Preferences' was clicked (iPhone only)
|
||||
* 'Clutch Preferences' was clicked (isMobileDevice only)
|
||||
*/
|
||||
releaseClutchPreferencesButton: function() {
|
||||
$('div#prefs_container div#pref_error').hide();
|
||||
|
@ -778,9 +773,7 @@ Transmission.prototype =
|
|||
this.checkPort(true);
|
||||
$('body').addClass('prefs_showing');
|
||||
$('#prefs_container').show();
|
||||
this.hideiPhoneAddressbar();
|
||||
if (Safari3)
|
||||
setTimeout("$('div#prefs_container div.dialog_window').css('top', '0px');",10);
|
||||
this.hideMobileAddressbar();
|
||||
this.updateButtonStates();
|
||||
this.togglePeriodicSessionRefresh(false);
|
||||
},
|
||||
|
@ -788,15 +781,9 @@ Transmission.prototype =
|
|||
hidePrefsDialog: function()
|
||||
{
|
||||
$('body.prefs_showing').removeClass('prefs_showing');
|
||||
if (iPhone) {
|
||||
this.hideiPhoneAddressbar();
|
||||
$('#prefs_container').hide();
|
||||
} else if (Safari3) {
|
||||
$('div#prefs_container div.dialog_window').css('top', '-425px');
|
||||
setTimeout("$('#prefs_container').hide();",500);
|
||||
} else {
|
||||
$('#prefs_container').hide();
|
||||
}
|
||||
if (isMobileDevice)
|
||||
this.hideMobileAddressbar();
|
||||
$('#prefs_container').hide();
|
||||
this.updateButtonStates();
|
||||
this.togglePeriodicSessionRefresh(true);
|
||||
},
|
||||
|
@ -847,7 +834,7 @@ Transmission.prototype =
|
|||
$('#port_rand').prop('checked', p[RPC._PeerPortRandom]);
|
||||
$('#port_forward').prop('checked', p[RPC._PortForwardingEnabled]);
|
||||
|
||||
if (!iPhone)
|
||||
if (!isMobileDevice)
|
||||
{
|
||||
setInnerHTML($('#limited_download_rate')[0], [ 'Limit (', Transmission.fmt.speed(dn_limit_k), ')' ].join(''));
|
||||
var key = dn_limited ? '#limited_download_rate'
|
||||
|
@ -876,24 +863,16 @@ Transmission.prototype =
|
|||
this.loadDaemonStats();
|
||||
$('body').addClass('stats_showing');
|
||||
$('#stats_container').show();
|
||||
this.hideiPhoneAddressbar();
|
||||
if (Safari3)
|
||||
setTimeout("$('div#stats_container div.dialog_window').css('top', '0px');",10);
|
||||
this.hideMobileAddressbar();
|
||||
this.updateButtonStates();
|
||||
this.togglePeriodicStatsRefresh(true);
|
||||
},
|
||||
|
||||
hideStatsDialog: function() {
|
||||
$('body.stats_showing').removeClass('stats_showing');
|
||||
if (iPhone) {
|
||||
this.hideiPhoneAddressbar();
|
||||
$('#stats_container').hide();
|
||||
} else if (Safari3) {
|
||||
$('div#stats_container div.dialog_window').css('top', '-425px');
|
||||
setTimeout("$('#stats_container').hide();",500);
|
||||
} else {
|
||||
$('#stats_container').hide();
|
||||
}
|
||||
if (isMobileDevice)
|
||||
this.hideMobileAddressbar();
|
||||
$('#stats_container').hide();
|
||||
this.updateButtonStates();
|
||||
this.togglePeriodicStatsRefresh(false);
|
||||
},
|
||||
|
@ -1138,7 +1117,7 @@ Transmission.prototype =
|
|||
meta_key = true;
|
||||
|
||||
// Shift-Click - selects a range from the last-clicked row to this one
|
||||
if (iPhone) {
|
||||
if (isMobileDevice) {
|
||||
if (row.isSelected())
|
||||
this.setInspectorVisible(true);
|
||||
this.setSelectedRow(row);
|
||||
|
@ -1208,9 +1187,6 @@ Transmission.prototype =
|
|||
$('input#torrent_auto_start').attr('checked', $('#prefs_form #auto_start')[0].checked);
|
||||
$('#upload_container').show();
|
||||
$('#torrent_upload_url').focus();
|
||||
if (!iPhone && Safari3) {
|
||||
setTimeout("$('div#upload_container div.dialog_window').css('top', '0px');",10);
|
||||
}
|
||||
|
||||
// Submit the upload form
|
||||
} else {
|
||||
|
@ -1339,10 +1315,10 @@ Transmission.prototype =
|
|||
this.remote.changeFileCommand(command, rows);
|
||||
},
|
||||
|
||||
hideiPhoneAddressbar: function(timeInSeconds) {
|
||||
if (iPhone) {
|
||||
hideMobileAddressbar: function(timeInSeconds) {
|
||||
if (isMobileDevice) {
|
||||
var delayLength = timeInSeconds ? timeInSeconds*1000 : 150;
|
||||
// not currently supported on iPhone
|
||||
// not currently supported on isMobileDevice
|
||||
if (/*document.body.scrollTop!=1 && */scroll_timeout==null) {
|
||||
var tr = this;
|
||||
scroll_timeout = setTimeout(function() {tr.doToolbarHide();}, delayLength);
|
||||
|
@ -1470,7 +1446,7 @@ Transmission.prototype =
|
|||
|
||||
inspectorTabClicked: function(ev, tab)
|
||||
{
|
||||
if (iPhone) ev.stopPropagation();
|
||||
if (isMobileDevice) ev.stopPropagation();
|
||||
|
||||
// select this tab and deselect the others
|
||||
$(tab).addClass('selected').siblings().removeClass('selected');
|
||||
|
@ -1478,7 +1454,7 @@ Transmission.prototype =
|
|||
// show this tab and hide the others
|
||||
$('#'+tab.id+'_container').show().siblings('.inspector_container').hide();
|
||||
|
||||
this.hideiPhoneAddressbar();
|
||||
this.hideMobileAddressbar();
|
||||
this.updatePeersLists();
|
||||
this.updateTrackersLists();
|
||||
this.updateFileList();
|
||||
|
@ -1492,7 +1468,7 @@ Transmission.prototype =
|
|||
return;
|
||||
|
||||
var torrents = this.getSelectedTorrents();
|
||||
if (!torrents.length && iPhone) {
|
||||
if (!torrents.length && isMobileDevice) {
|
||||
this.setInspectorVisible(false);
|
||||
return;
|
||||
}
|
||||
|
@ -1870,10 +1846,10 @@ Transmission.prototype =
|
|||
|
||||
// update the ui widgetry
|
||||
$('#torrent_inspector').toggle(visible);
|
||||
if (iPhone) {
|
||||
if (isMobileDevice) {
|
||||
$('body').toggleClass('inspector_showing',visible);
|
||||
$('#inspector_close').toggle(visible);
|
||||
this.hideiPhoneAddressbar();
|
||||
this.hideMobileAddressbar();
|
||||
} else {
|
||||
var w = visible ? $('#torrent_inspector').width() + 1 + 'px' : '0px';
|
||||
$('#torrent_container')[0].style.right = w;
|
||||
|
@ -1896,7 +1872,7 @@ Transmission.prototype =
|
|||
var popup = $('#filter-popup');
|
||||
popup.dialog({
|
||||
autoOpen: false,
|
||||
position: iPhone ? [0,0] : [40,80],
|
||||
position: isMobileDevice ? [0,0] : [40,80],
|
||||
show: 'blind',
|
||||
hide: 'blind',
|
||||
title: 'Show',
|
||||
|
@ -2277,7 +2253,7 @@ Transmission.prototype =
|
|||
|
||||
// update the ui: context menu
|
||||
// (disabled in iphone mode...)
|
||||
if (!iPhone) {
|
||||
if (!isMobileDevice) {
|
||||
var e = $('#settings_menu #compact_view');
|
||||
if (compact)
|
||||
e.selectMenuItem();
|
||||
|
|
Loading…
Add table
Reference in a new issue