Changeset 9598 for trunk/admin


Ignore:
Timestamp:
Mar 10, 2011, 12:36:14 PM (14 years ago)
Author:
patdenice
Message:

feature:2219
Sort available plugins without reloading the whole page

Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/plugins_new.php

    r8728 r9598  
    3131$template->set_filenames(array('plugins' => 'plugins_new.tpl'));
    3232
    33 $order = isset($_GET['order']) ? $_GET['order'] : 'date';
    34 $base_url = get_root_url().'admin.php?page='.$page['page'].'&order='.$order;
     33$base_url = get_root_url().'admin.php?page='.$page['page'];
    3534
    3635$plugins = new plugins();
     
    8786
    8887//---------------------------------------------------------------Order options
    89 $link = get_root_url().'admin.php?page='.$page['page'].'&order=';
    9088$template->assign('order_options',
    9189  array(
    92     $link.'date' => l10n('Post date'),
    93     $link.'revision' => l10n('Last revisions'),
    94     $link.'name' => l10n('Name'),
    95     $link.'author' => l10n('Author'),
    96     $link.'downloads' => l10n('Number of downloads')));
    97 $template->assign('order_selected', $link.$order);
     90    'date' => l10n('Post date'),
     91    'revision' => l10n('Last revisions'),
     92    'name' => l10n('Name'),
     93    'author' => l10n('Author'),
     94    'downloads' => l10n('Number of downloads')));
    9895
    9996// +-----------------------------------------------------------------------+
     
    10299if ($plugins->get_server_plugins(true))
    103100{
    104   $plugins->sort_server_plugins($order);
     101  $plugins->sort_server_plugins('date');
    105102
    106103  foreach($plugins->server_plugins as $plugin)
     
    122119      'BIG_DESC' => $ext_desc,
    123120      'VERSION' => $plugin['revision_name'],
     121      'REVISION_DATE' => preg_replace('/[^0-9]/', '', $plugin['revision_date']),
    124122      'AUTHOR' => $plugin['author_name'],
    125123      'DOWNLOADS' => $plugin['extension_nb_downloads'],
  • trunk/admin/themes/default/template/plugins_new.tpl

    r9586 r9598  
    1 {footer_script require='jquery.effects.blind'}{literal}
     1{combine_script id='jquery.sort' path='themes/default/js/plugins/jquery.sort.js'}
     2
     3{footer_script require='jquery.effects.blind,jquery.sort'}{literal}
     4var sortOrder = 'date';
     5var sortPlugins = (function(a, b) {
     6  if (sortOrder == 'downloads' || sortOrder == 'revision' || sortOrder == 'date')
     7    return parseInt($(a).find('input[name="'+sortOrder+'"]').val())
     8      < parseInt($(b).find('input[name="'+sortOrder+'"]').val()) ? 1 : -1;
     9  else
     10    return $(a).find('input[name="'+sortOrder+'"]').val().toLowerCase()
     11      > $(b).find('input[name="'+sortOrder+'"]').val().toLowerCase()  ? 1 : -1;
     12});
     13
    214jQuery(document).ready(function(){
    315        jQuery("td[id^='desc_']").click(function() {
     
    1426                return false;
    1527        });
     28
     29  jQuery('select[name="selectOrder"]').change(function() {
     30    sortOrder = this.value;
     31    $('.pluginBox').sortElements(sortPlugins);
     32  });
    1633});
    1734{/literal}{/footer_script}
     
    2037<span class="sort">
    2138{'Sort order'|@translate} :
    22   <select onchange="document.location = this.options[this.selectedIndex].value;">
    23         {html_options options=$order_options selected=$order_selected}
    24   </select>
     39{html_options name="selectOrder" options=$order_options selected=$order_selected}
    2540</span>
    2641  <h2>{'Plugins'|@translate}</h2>
     
    3348{foreach from=$plugins item=plugin name=plugins_loop}
    3449<div class="pluginBox" id="plugin_{$plugin.ID}">
     50<input type="hidden" name="date" value="{$plugin.ID}">
     51<input type="hidden" name="name" value="{$plugin.EXT_NAME}">
     52<input type="hidden" name="revision" value="{$plugin.REVISION_DATE}">
     53<input type="hidden" name="downloads" value="{$plugin.DOWNLOADS}">
     54<input type="hidden" name="author" value="{$plugin.AUTHOR}">
    3555  <table>
    3656    <tr>
Note: See TracChangeset for help on using the changeset viewer.