From 56d499b1aa4a8ddc5f3240a86e82445eefb6d5af Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sun, 15 Jan 2012 14:23:47 +0000 Subject: [PATCH] Update ui to use bootstrap ui in more places --- public/scripts/main.js | 83 +++++++++++------ public/styles/normal.css | 62 +++---------- source/lib/RippingCluster/Job.class.php | 4 + source/webui/pages/ajax/admin/add-setting.php | 2 +- source/webui/pages/rips/setup.php | 9 +- source/webui/pages/sources/delete.php | 28 ------ source/webui/templates/admin/settings.tpl | 4 +- .../templates/ajax/admin/new-setting.tpl | 4 +- .../templates/ajax/admin/rename-setting.tpl | 4 +- source/webui/templates/ajax/delete-source.tpl | 6 +- .../webui/templates/ajax/update-settings.tpl | 6 +- .../templates/fragments/admin-setting-row.tpl | 8 +- .../fragments/admin-setting-value.tpl | 28 +++--- .../fragments/job-filename-popover.tpl | 9 ++ .../fragments/job-status-popover.tpl | 15 ++++ .../fragments/new-setting-dialog.tpl | 33 +++---- .../fragments/rename-setting-dialog.tpl | 2 +- .../webui/templates/fragments/source-list.tpl | 2 +- .../fragments/update-settings-dialog.tpl | 2 +- source/webui/templates/index.tpl | 48 +++++----- source/webui/templates/jobs.tpl | 39 ++++---- source/webui/templates/rips/setup.tpl | 88 +++++++------------ source/webui/templates/sources/delete.tpl | 7 -- 23 files changed, 221 insertions(+), 272 deletions(-) delete mode 100644 source/webui/pages/sources/delete.php create mode 100644 source/webui/templates/fragments/job-filename-popover.tpl create mode 100644 source/webui/templates/fragments/job-status-popover.tpl delete mode 100644 source/webui/templates/sources/delete.tpl diff --git a/public/scripts/main.js b/public/scripts/main.js index ce6fe82..717d1b0 100644 --- a/public/scripts/main.js +++ b/public/scripts/main.js @@ -48,7 +48,7 @@ var rc = { dialog: { init: function() { - $("#dialogheaderclose").click(rc.dialog.close); + $("#dialog-header-close").click(rc.dialog.close); }, prepare: function(d) { @@ -57,61 +57,67 @@ var rc = { if (d.dialog.buttons) { switch (d.dialog.buttons.type) { case 'ok': - $("#dialogfooterok").click( + $("#dialog-footer-ok-ok").click( function() { rc.trigger(d.dialog.buttons.actions.ok, d.dialog.buttons.params); } ); - $("#dialogfooterok").show(); + $("#dialog-footer-ok").show(); break; case 'okcancel': - $("#dialogfooterokcancel_ok").click(function() { + $("#dialog-footer-okcancel-ok").click(function() { rc.trigger(d.dialog.buttons.actions.ok, d.dialog.buttons.params); }); - $("#dialogfooterokcancel_cancel").click(function() { + $("#dialog-footer-okcancel-cancel").click(function() { rc.trigger(d.dialog.buttons.actions.cancel, d.dialog.buttons.params); }); - $("#dialogfooterokcancel").show(); + $("#dialog-footer-okcancel").show(); break; case 'yesno': - $("#dialogfooteryes").click( + $("#dialog-footer-yesno-yes").click( function() { rc.trigger(d.dialog.buttons.actions.yes, d.dialog.buttons.params); } ); - $("#dialogfooterno").click( + $("#dialog-footer-yesno-no").click( function() { rc.trigger(d.dialog.buttons.actions.no, d.dialog.buttons.params); } ); - $("#dialogfooteryesno").show(); + $("#dialog-footer-yesno").show(); break; } } if (d.dialog.title) { - $('#dialogheadertitle').html(d.dialog.title); + $('#dialog-header-title').html(d.dialog.title); } if (d.dialog.content) { - $('#dialogcontent').html(d.dialog.content); + $('#dialog-body').html(d.dialog.content); } - $("#dialog").show(); + $("#dialog").modal({ + show: true, + backdrop: true, + keyboard: true, + }); } }, close: function() { // Hide the dialog - $("#dialog").hide(); + $("#dialog").modal({ + show: false, + }); // Remove the dialog content - $("#dialogcontent").html(); + $("#dialog-body").html(); // Hide all buttons - $(".dialogfooterbuttonset").hide(); + $(".dialog-footer-buttonset").hide(); // Strip all event handlers - $(".dialogfooterbuttonset input[type='button']").unbind('click'); + $(".dialog-footer-buttonset input[type='button']").unbind('click'); }, error: function(title, content, messages) { @@ -145,7 +151,18 @@ var rc = { page: { init: function() { - $('.progressBar').each( + rc.page.updateEvents($('#page_content')); + }, + + update: function(d) { + for ( var f in d.page_replacements) { + $("#" + f).html(d.page_replacements[f].content); + rc.page.updateEvents('#' + f); + } + }, + + updateEvents: function(d) { + $(d).find('.progressBar').each( function() { $(this).progressBar({ steps: 100, @@ -161,12 +178,24 @@ var rc = { }); } ); - }, - - update: function(d) { - for ( var f in d.page_replacements) { - $("#" + f).html(d.page_replacements[f].content); - } + + $(d).find('.hover-highlight').hover( + function() { + $(this).addClass('highlight'); + }, + function() { + $(this).removeClass('highlight'); + } + ); + + $(d).find('a[rel=popover]').popover({ + offset: 10, + html: true, + }); + + $(d).find('input[type=checkbox].select_all').click(function() { + $('input[type=checkbox].'+$(this).attr('id')).attr('checked', $(this).attr('checked') == 'checked'); + }); } }, @@ -268,7 +297,7 @@ var rc = { rc.dialog.prepare({ dialog: { show: true, - title: 'Remove setting', + title: 'Remove this setting?', content: "Do you really want to remove setting '" + name + "'", buttons: { type: 'okcancel', @@ -322,11 +351,11 @@ var rc = { var line = $('
'); line.attr('id', 'settings_'+id+'_line'+next.val()); - var hash_key = $(''); - var hash_value = $(''); + var hash_key = $(''); + var hash_value = $(''); hash_key.change(function() { $('#setting_'+id+'_value'+next_value).attr('name', id+'['+$(this).val()+']'); - }) + }); line.append(hash_key).append(' ').append(hash_value).append(' '); var button = $(''); diff --git a/public/styles/normal.css b/public/styles/normal.css index 37c804e..ddf2894 100644 --- a/public/styles/normal.css +++ b/public/styles/normal.css @@ -32,53 +32,14 @@ text-align: center; } - /* Centred dialog taken from http://stackoverflow.com/questions/1205457/how-to-design-a-css-for-a-centered-floating-confirm-dialog */ - #centrepoint { - top: 50%; - left: 50%; - position: absolute; - } - #dialog { - position: relative; - width: 600px; - margin-left: -300px; - /*height: 20em;*/ - margin-top: -20em; - + .dialog-footer-buttonset { display: none; - background: #eeeeee; - border: 2px solid #a7a09a; } - #dialogheader { - height: 2em; - width: 100%; - margin: 0.3em; - } - #dialogheadertitle { - color: black; - font-weight: bold; - float: left; - } - #dialogheaderclose { - width: 1.2em; - height: 1.2em; - background-color: crimson; - color: white; - border: 1px solid fireBrick; - float: right; - margin-right: 1em; - text-align: center; - vertical-align: middle; - display: table-cell; - font-weight: bold; - cursor: pointer; - } - #dialogcontent { - padding: 0.5em; - } - .dialogfooterbuttonset { - display: none; - text-align: right; + + .dialog-footer-buttonset fieldset { + padding-top: 0; + padding-bottom: 0; + margin-bottom: 0; } .default { @@ -92,16 +53,13 @@ width: 16px; } - form#setup-rips input[type="text"] { - width: 30em; - } - #quantizer-slider { - width: 20em; + width: 10em; + margin: 0.5em; } - select.rip-streams { - width: 20em; + .highlight { + background: #dceaf4; } } diff --git a/source/lib/RippingCluster/Job.class.php b/source/lib/RippingCluster/Job.class.php index b4ed268..55b94ba 100644 --- a/source/lib/RippingCluster/Job.class.php +++ b/source/lib/RippingCluster/Job.class.php @@ -353,6 +353,10 @@ class RippingCluster_Job { public function destinationFilename() { return $this->destination_filename; } + + public function destinationFileBasename() { + return basename($this->destination_filename); + } public function title() { return $this->title; diff --git a/source/webui/pages/ajax/admin/add-setting.php b/source/webui/pages/ajax/admin/add-setting.php index 1cc591c..9e50b10 100644 --- a/source/webui/pages/ajax/admin/add-setting.php +++ b/source/webui/pages/ajax/admin/add-setting.php @@ -32,7 +32,7 @@ try { } break; case 'hash': { $type = Sihnon_Config::TYPE_HASH; - $value = array(); + $value = array('' => ''); } break; } diff --git a/source/webui/pages/rips/setup.php b/source/webui/pages/rips/setup.php index 0c11acb..70c89fe 100644 --- a/source/webui/pages/rips/setup.php +++ b/source/webui/pages/rips/setup.php @@ -11,7 +11,14 @@ if ($req->exists('submit')) { // Update the recently used list $recent_output_directories = $config->get('rips.output_directories.recent'); - if ( ! in_array($_POST['rip-options']['output-directory'], $recent_output_directories)) { + if (( $key = array_search($_POST['rip-options']['output-directory'], $recent_output_directories, true))) { + // Move the entry to the top of the recently used list if necessary + $recent_directory = array_splice($recent_output_directories, $key, 1); + if ($key > 0) { + array_unshift($recent_output_directories, $recent_directory[0]); + $config->set('rips.output_directories.recent', array_slice($recent_output_directories, 0, $config->get('rips.output_directories.recent_limit', 10))); + } + } else { array_unshift($recent_output_directories, $_POST['rip-options']['output-directory']); $config->set('rips.output_directories.recent', array_slice($recent_output_directories, 0, $config->get('rips.output_directories.recent_limit', 10))); } diff --git a/source/webui/pages/sources/delete.php b/source/webui/pages/sources/delete.php deleted file mode 100644 index 028b791..0000000 --- a/source/webui/pages/sources/delete.php +++ /dev/null @@ -1,28 +0,0 @@ -request(); -$config = $main->config(); - -// Grab the name of this source -$encoded_filename = null; -if ($req->exists('confirm')) { - $plugin = $req->get('plugin', 'RippingCluster_Exception_InvalidParameters'); - $encoded_filename = $req->get('id', 'RippingCluster_Exception_InvalidParameters'); - - $source = RippingCluster_Source_PluginFactory::loadEncoded($plugin, $encoded_filename, false); - $source->delete(); - - // Redirect back to the sources page - RippingCluster_Page::redirect('rips/sources'); - -} else { - $plugin = $req->get('plugin', 'RippingCluster_Exception_InvalidParameters'); - $encoded_filename = $req->get('id', 'RippingCluster_Exception_InvalidParameters'); - - $source = RippingCluster_Source_PluginFactory::loadEncoded($plugin, $encoded_filename, false); - - $this->smarty->assign('source', $source); -} - -?> \ No newline at end of file diff --git a/source/webui/templates/admin/settings.tpl b/source/webui/templates/admin/settings.tpl index 3640b03..807e62d 100644 --- a/source/webui/templates/admin/settings.tpl +++ b/source/webui/templates/admin/settings.tpl @@ -17,8 +17,8 @@ - - + + diff --git a/source/webui/templates/ajax/admin/new-setting.tpl b/source/webui/templates/ajax/admin/new-setting.tpl index 743a360..fa25298 100644 --- a/source/webui/templates/ajax/admin/new-setting.tpl +++ b/source/webui/templates/ajax/admin/new-setting.tpl @@ -1,10 +1,10 @@ "page_replacements": { - "dialogheadertitle": { + "dialog-header-title": { "content": "Add Setting" }, - "dialogcontent": { + "dialog-body": { {include file="fragments/new-setting-dialog.tpl" assign=new_setting_dialog_content} "content": {$new_setting_dialog_content|json_encode} } diff --git a/source/webui/templates/ajax/admin/rename-setting.tpl b/source/webui/templates/ajax/admin/rename-setting.tpl index eb744c9..2c73a70 100644 --- a/source/webui/templates/ajax/admin/rename-setting.tpl +++ b/source/webui/templates/ajax/admin/rename-setting.tpl @@ -14,11 +14,11 @@ "success": {$success|json_encode} {else} "page_replacements": { - "dialogheadertitle": { + "dialog-header-title": { "content": "Rename Setting" }, - "dialogcontent": { + "dialog-body": { {include file="fragments/rename-setting-dialog.tpl" assign="content"} "content": {$content|json_encode} } diff --git a/source/webui/templates/ajax/delete-source.tpl b/source/webui/templates/ajax/delete-source.tpl index 179d78d..e71ba75 100644 --- a/source/webui/templates/ajax/delete-source.tpl +++ b/source/webui/templates/ajax/delete-source.tpl @@ -6,11 +6,11 @@ "content": {$sources_html|json_encode} } {else} - "dialogheadertitle": { - "content": "Delete Source" + "dialog-header-title": { + "content": "Delete this source?" }, - "dialogcontent": { + "dialog-body": { {include file="fragments/delete-source.tpl" assign="delete_source_html"} "content": {$delete_source_html|json_encode} } diff --git a/source/webui/templates/ajax/update-settings.tpl b/source/webui/templates/ajax/update-settings.tpl index 3fa938f..6c5bf6d 100644 --- a/source/webui/templates/ajax/update-settings.tpl +++ b/source/webui/templates/ajax/update-settings.tpl @@ -1,10 +1,10 @@ "page_replacements": { - "dialogheadertitle": { - "content": "Update Settings" + "dialog-header-title": { + "content": "Settings updated" }, - "dialogcontent": { + "dialog-body": { {include file="fragments/update-settings-dialog.tpl" assign=dialog_content} "content": {$dialog_content|json_encode} } diff --git a/source/webui/templates/fragments/admin-setting-row.tpl b/source/webui/templates/fragments/admin-setting-row.tpl index f151e91..3329db5 100644 --- a/source/webui/templates/fragments/admin-setting-row.tpl +++ b/source/webui/templates/fragments/admin-setting-row.tpl @@ -1,9 +1,11 @@

- {$name}
- - + {$name} +

+

+ +

diff --git a/source/webui/templates/fragments/admin-setting-value.tpl b/source/webui/templates/fragments/admin-setting-value.tpl index 16a3dc1..409d9a5 100644 --- a/source/webui/templates/fragments/admin-setting-value.tpl +++ b/source/webui/templates/fragments/admin-setting-value.tpl @@ -3,38 +3,40 @@ {/case} {case Sihnon_Config::TYPE_INT} - + {/case} {case Sihnon_Config::TYPE_STRING} - + {/case} {case Sihnon_Config::TYPE_STRING_LIST}
{foreach from=$value item=line name=settings}
- - + +
{/foreach}
- +
{/case} {case Sihnon_Config::TYPE_HASH}
- {foreach from=$value item=hash_value key=hash_key name=settings} -
- - - -
- {/foreach} + {if $value} + {foreach from=$value item=hash_value key=hash_key name=settings} +
+ + + +
+ {/foreach} + {/if}
- +
{/case} diff --git a/source/webui/templates/fragments/job-filename-popover.tpl b/source/webui/templates/fragments/job-filename-popover.tpl new file mode 100644 index 0000000..abd64f1 --- /dev/null +++ b/source/webui/templates/fragments/job-filename-popover.tpl @@ -0,0 +1,9 @@ +
+
Destination Filename
+
{$job->destinationFilename()|escape:html}
+ + {if $job->isFinished()} +
File size
+
({$job->outputFilesize()|formatFilesize|escape:html})
+ {/if} +
\ No newline at end of file diff --git a/source/webui/templates/fragments/job-status-popover.tpl b/source/webui/templates/fragments/job-status-popover.tpl new file mode 100644 index 0000000..0530071 --- /dev/null +++ b/source/webui/templates/fragments/job-status-popover.tpl @@ -0,0 +1,15 @@ +
+ {if $current_status->hasProgressInfo()} +
Started
+
{$current_status->ctime()|date_format:"%D %T"}
+ +
Progress
+
{$current_status->ripProgress()}%
+ +
ETA
+
{$job->calculateETA()|formatDuration}
+ {/if} + +
Last update
+
{$current_status->mtime()|date_format:"%D %T"}
+
diff --git a/source/webui/templates/fragments/new-setting-dialog.tpl b/source/webui/templates/fragments/new-setting-dialog.tpl index fcea745..82772a4 100644 --- a/source/webui/templates/fragments/new-setting-dialog.tpl +++ b/source/webui/templates/fragments/new-setting-dialog.tpl @@ -1,22 +1,11 @@ - - - - - - - - - - - -
NameType
- - - -
+ + + + + diff --git a/source/webui/templates/fragments/rename-setting-dialog.tpl b/source/webui/templates/fragments/rename-setting-dialog.tpl index ed32c6d..f7b5859 100644 --- a/source/webui/templates/fragments/rename-setting-dialog.tpl +++ b/source/webui/templates/fragments/rename-setting-dialog.tpl @@ -2,5 +2,5 @@

Enter a new name for setting '{$name|escape}' below.

- +
\ No newline at end of file diff --git a/source/webui/templates/fragments/source-list.tpl b/source/webui/templates/fragments/source-list.tpl index 69491e1..1f62c3f 100644 --- a/source/webui/templates/fragments/source-list.tpl +++ b/source/webui/templates/fragments/source-list.tpl @@ -7,7 +7,7 @@ {assign var='source_filename' value=$source->filename()} {assign var='source_filename_encoded' value=$source->filenameEncoded()} {assign var='source_cached' value=$source->isCached()} -
  • +
  • [ Browse | Rip | Delete ] diff --git a/source/webui/templates/fragments/update-settings-dialog.tpl b/source/webui/templates/fragments/update-settings-dialog.tpl index d0c2214..463d169 100644 --- a/source/webui/templates/fragments/update-settings-dialog.tpl +++ b/source/webui/templates/fragments/update-settings-dialog.tpl @@ -1,5 +1,5 @@

    - Settings have been saved. + Your changes have been saved.

    {if $messages} diff --git a/source/webui/templates/index.tpl b/source/webui/templates/index.tpl index c19ea34..4c32289 100644 --- a/source/webui/templates/index.tpl +++ b/source/webui/templates/index.tpl @@ -4,7 +4,7 @@ {$title} - + @@ -99,31 +99,29 @@ -
    -
    -
    -
    Dialog
    -
    X
    + - -
    +
    - - - - - - - - - - - - -
    Selected subtitle tracks
    TrackLanguageFormat
    -
    - -
    +
    -
    +