Ignore:
Timestamp:
May 24, 2014, 6:24:52 PM (10 years ago)
Author:
mistic100
Message:

feature 3077 : use selectize on batch_manager_global, cat_modify and photos_add_direct
+ rewrite "add album" popup (more flexible and working with selectize)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/themes/default/template/cat_modify.tpl

    r25748 r28533  
     1{combine_script id='LocalStorageCache' load='footer' path='admin/themes/default/js/LocalStorageCache.js'}
     2
     3{combine_script id='jquery.selectize' load='footer' path='themes/default/js/plugins/selectize.min.js'}
     4{combine_css id='jquery.selectize' path="themes/default/js/plugins/selectize.default.css"}
     5
     6{footer_script}
     7{* <!-- CATEGORIES --> *}
     8var categoriesCache = new LocalStorageCache({
     9  key: 'categoriesAdminList',
     10  serverKey: '{$CACHE_KEYS.categories}',
     11  serverId: '{$CACHE_KEYS._hash}',
     12
     13  loader: function(callback) {
     14    jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.categories.getAdminList', function(data) {
     15      callback(data.result.categories);
     16    });
     17  }
     18});
     19
     20jQuery('[data-selectize=categories]').selectize({
     21  valueField: 'id',
     22  labelField: 'fullname',
     23  sortField: 'fullname',
     24  searchField: ['fullname'],
     25  plugins: ['remove_button']
     26});
     27
     28categoriesCache.get(function(categories) {
     29  categories.push({
     30    id: 0,
     31    fullname: '------------'
     32  });
     33 
     34  // remove itself and children
     35  categories = jQuery.grep(categories, function(cat) {
     36    return !(/\b{$CAT_ID}\b/.test(cat.uppercats));
     37  });
     38 
     39  categories.sort(function(a, b) {
     40    return a.fullname.localeCompare(b.fullname);
     41  });
     42 
     43  jQuery('[data-selectize=categories]').each(function() {
     44    this.selectize.load(function(callback) {
     45      callback(categories);
     46    });
     47
     48    if (jQuery(this).data('value')) {
     49      this.selectize.setValue(jQuery(this).data('value')[0]);
     50    }
     51   
     52    // prevent empty value
     53    if (this.selectize.getValue() == '') {
     54      this.selectize.setValue(categories[0].id);
     55    }
     56    this.selectize.on('dropdown_close', function() {
     57      if (this.getValue() == '') {
     58        this.setValue(categories[0].id);
     59      }
     60    });
     61  });
     62});
     63{/footer_script}
     64
     65
    166<div class="titrePage">
    267  <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> &#8250; {'Edit album'|@translate} {$TABSHEET_TITLE}</h2>
     
    72137  </p>
    73138
    74 {if isset($move_cat_options) }
     139{if isset($parent_category) }
    75140  <p>
    76141    <strong>{'Parent album'|@translate}</strong>
    77142    <br>
    78     <select class="categoryDropDown" name="parent">
    79       <option value="0">------------</option>
    80       {html_options options=$move_cat_options selected=$move_cat_options_selected }
    81     </select>
     143    <select data-selectize="categories" data-value="{$parent_category|@json_encode|escape:html}"
     144        name="parent" style="width:400px"></select>
    82145  </p>
    83146{/if}
Note: See TracChangeset for help on using the changeset viewer.