some name changes to camelcase and a few fixes for IE7

This commit is contained in:
Damien Churchill 2008-09-22 14:07:32 +00:00
commit 71bc34be0d
4 changed files with 29 additions and 26 deletions

View file

@ -34,15 +34,15 @@ Deluge.Widgets.TorrentGrid = new Class({
'Checking': '/pixmaps/inactive16.png' 'Checking': '/pixmaps/inactive16.png'
}, },
get_selected_torrents: function() { getSelectedTorrents: function() {
var torrentIds = []; var torrentIds = [];
this.get_selected().each(function(row) { this.getSelected().each(function(row) {
torrentIds.include(row.id); torrentIds.include(row.id);
}); });
return torrentIds; return torrentIds;
}, },
set_torrent_filter: function(state) { setTorrentFilter: function(state) {
state = state.replace(' ', ''); state = state.replace(' ', '');
this.filterer = function (r) { this.filterer = function (r) {
if (r.torrent.state == state) { return true } else { return false }; if (r.torrent.state == state) { return true } else { return false };
@ -50,7 +50,7 @@ Deluge.Widgets.TorrentGrid = new Class({
this.render(); this.render();
}, },
update_torrents: function(torrents) { updateTorrents: function(torrents) {
torrents.getKeys().each(function(torrentId) { torrents.getKeys().each(function(torrentId) {
var torrent = torrents[torrentId] var torrent = torrents[torrentId]
var torrentIds = torrents.getKeys() var torrentIds = torrents.getKeys()

View file

@ -23,7 +23,7 @@ Deluge.UI = {
filePriorities: this.filePriorities.bindWithEvent(this), filePriorities: this.filePriorities.bindWithEvent(this),
labelsChanged: this.labelsChanged.bindWithEvent(this) labelsChanged: this.labelsChanged.bindWithEvent(this)
}; };
this.loadUi.delay(100, this); this.loadUi.delay(250, this);
}, },
loadUi: function() { loadUi: function() {
@ -31,27 +31,29 @@ Deluge.UI = {
this.toolbar = new Deluge.Widgets.Toolbar(); this.toolbar = new Deluge.Widgets.Toolbar();
this.addWindow = new Deluge.Widgets.AddWindow(); this.addWindow = new Deluge.Widgets.AddWindow();
if (Browser.Engine.name != 'trident') {
this.prefsWindow = new Deluge.Widgets.PreferencesWindow(); this.prefsWindow = new Deluge.Widgets.PreferencesWindow();
}
this.statusbar = new Deluge.Widgets.StatusBar(); this.statusbar = new Deluge.Widgets.StatusBar();
this.labels = new Deluge.Widgets.Labels() this.labels = new Deluge.Widgets.Labels()
this.details = new Deluge.Widgets.Details() this.details = new Deluge.Widgets.Details()
this.initialize_grid() this.initializeGrid()
this.split_horz = new Widgets.SplitPane('top', this.labels, this.grid, { this.split_horz = new Widgets.SplitPane('top', this.labels, this.grid, {
pane1: {min: 150}, pane1: {min: 150},
pane2: {min: 100, expand: true} pane2: {min: 100, expand: true}
}); });
var details = $W('details') var details = $W('details')
this.split_vert = new Widgets.SplitPane('main', this.split_horz, details, { this.splitVert = new Widgets.SplitPane('main', this.split_horz, details, {
direction: 'vertical', direction: 'vertical',
pane1: {min: 100, expand: true}, pane1: {min: 100, expand: true},
pane2: {min: 200} pane2: {min: 200}
}); });
this.vbox.addBox(this.toolbar, {fixed: true}); this.vbox.addBox(this.toolbar, {fixed: true});
this.vbox.addBox(this.split_vert); this.vbox.addBox(this.splitVert);
this.vbox.addBox(this.statusbar, {fixed: true}); this.vbox.addBox(this.statusbar, {fixed: true});
this.vbox.calculatePositions(); this.vbox.calculatePositions();
this.details.expand() this.details.expand()
@ -68,7 +70,7 @@ Deluge.UI = {
this.overlay = $('overlay').dispose(); this.overlay = $('overlay').dispose();
}, },
initialize_grid: function() { initializeGrid: function() {
this.grid = new Deluge.Widgets.TorrentGrid('torrents') this.grid = new Deluge.Widgets.TorrentGrid('torrents')
var menu = new Widgets.PopupMenu() var menu = new Widgets.PopupMenu()
@ -146,7 +148,7 @@ Deluge.UI = {
this.torrents.each(function(torrent, torrent_id) { this.torrents.each(function(torrent, torrent_id) {
torrent.id = torrent_id; torrent.id = torrent_id;
}) })
this.grid.update_torrents(this.torrents); this.grid.updateTorrents(this.torrents);
this.statusbar.update(this.stats); this.statusbar.update(this.stats);
if ($chk(this.grid.selectedRow)) if ($chk(this.grid.selectedRow))
@ -180,15 +182,15 @@ Deluge.UI = {
}, },
toolbarClick: function(event) { toolbarClick: function(event) {
this.torrent_action(event.action); this.torrentAction(event.action);
}, },
labelsChanged: function(event) { labelsChanged: function(event) {
this.update() this.update()
}, },
torrent_action: function(action, value) { torrentAction: function(action, value) {
var torrentIds = this.grid.get_selected_torrents(); var torrentIds = this.grid.getSelectedTorrents();
var client = Deluge.Client; var client = Deluge.Client;
switch (action) { switch (action) {
case 'resume': case 'resume':

View file

@ -36,7 +36,6 @@ Deluge.Keys = {
'max_upload_slots','is_auto_managed', 'stop_at_ratio', 'stop_ratio', 'max_upload_slots','is_auto_managed', 'stop_at_ratio', 'stop_ratio',
'remove_at_ratio', 'private', 'prioritize_first_last' 'remove_at_ratio', 'private', 'prioritize_first_last'
] ]
} };
Deluge.Keys.Statistics.extend(Deluge.Keys.Grid) Deluge.Keys.Statistics.extend(Deluge.Keys.Grid);
Deluge.Widgets = $empty; Deluge.Widgets = $empty;

View file

@ -118,6 +118,7 @@ Array.implement({
var total = 0 var total = 0
this.each(function(item) { this.each(function(item) {
var value = item var value = item
if (!$defined(value)) return;
if ($defined(key)) { value = item[key] } if ($defined(key)) { value = item[key] }
if ($type(value) == 'number') { total += value } if ($type(value) == 'number') { total += value }
}, this) }, this)
@ -128,7 +129,7 @@ Array.implement({
Element.implement({ Element.implement({
getInnerSize: function() { getInnerSize: function() {
this.getPadding() this.getPadding()
if ((/^(?:body|html)$/i).test(this.tagName)) return window.getSize(); if ((/^(?:body|html)$/i).test(this.tagName)) return this.getWindow().getSize();
return {x: this.clientWidth - this.padding.x, y: this.clientHeight - this.padding.y}; return {x: this.clientWidth - this.padding.x, y: this.clientHeight - this.padding.y};
}, },
@ -1268,7 +1269,7 @@ Widgets.DataGrid = new Class({
this.columns[0].order = -1 this.columns[0].order = -1
if ($chk(this.element)) { this.scanElement() } else { this.createElement } if ($chk(this.element)) { this.scanElement() } else { this.createElement }
this.element.setStyle('MozUserSelect', 'none') this.element.setStyle('MozUserSelect', 'none')
this.resize_columns() this.resizeColumns()
this.addEvent('resize', this.resized.bindWithEvent(this)) this.addEvent('resize', this.resized.bindWithEvent(this))
}, },
@ -1371,7 +1372,7 @@ Widgets.DataGrid = new Class({
return row return row
}, },
get_selected: function() { getSelected: function() {
selected = [] selected = []
this.rows.each(function(row) { this.rows.each(function(row) {
if (row.selected) { selected.include(row) } if (row.selected) { selected.include(row) }
@ -1413,13 +1414,14 @@ Widgets.DataGrid = new Class({
if (selected) { this.selected = $A(this.body.rows).indexOf(selected) } if (selected) { this.selected = $A(this.body.rows).indexOf(selected) }
}, },
resize_columns: function() { resizeColumns: function() {
var totalWidth = this.options.columns.sum('width')
var total_width = this.options.columns.sum('width') this.table.setStyle('width', totalWidth)
this.table.setStyle('width', total_width)
var cols = this.header.getElements('th') var cols = this.header.getElements('th')
cols.each(function(col, index) { cols.each(function(col, index) {
if (this.options.columns[index]) {
col.setStyle('width', this.options.columns[index].width) col.setStyle('width', this.options.columns[index].width)
}
}, this) }, this)
}, },