Changeset 28502


Ignore:
Timestamp:
05/18/14 17:15:25 (5 years ago)
Author:
mistic100
Message:

feature 3077 : use Selectize on batch_manager_global

Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager_global.php

    r28500 r28502  
    555555{ 
    556556  // remove tags 
    557   $tags = get_common_tags($page['cat_elements_id'], -1); 
    558  
    559   $template->assign( 
    560     array( 
    561       'DEL_TAG_SELECTION' => get_html_tag_selection($tags, 'del_tags'), 
    562       ) 
    563     ); 
     557  $template->assign('associated_tags', get_common_tags($page['cat_elements_id'], -1)); 
    564558} 
    565559 
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r28500 r28502  
    55 
    66{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'} 
     7 
    78{combine_script id='jquery.ui.slider' require='jquery.ui' load='footer' path='themes/default/js/ui/minified/jquery.ui.slider.min.js'} 
    89{combine_css path="themes/default/js/ui/theme/jquery.ui.slider.css"} 
     10 
     11{combine_script id='LocalStorageCache' load='footer' path='admin/themes/default/js/LocalStorageCache.js'} 
     12 
     13{combine_script id='jquery.selectize' load='footer' path='themes/default/js/plugins/selectize.min.js'} 
     14{combine_css id='jquery.selectize' path="themes/default/js/plugins/selectize.default.css"} 
     15 
     16{combine_script id='jquery.progressBar' load='footer' path='themes/default/js/plugins/jquery.progressbar.min.js'} 
     17{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} 
    918 
    1019{footer_script}{literal} 
     
    5261        $('ul.thumbnails').enableShiftClick(); 
    5362}); 
    54 {/literal}{/footer_script} 
    55  
    56 {combine_css path='themes/default/js/plugins/jquery.tokeninput.css'} 
    57 {combine_script id='jquery.tokeninput' load='footer' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'} 
    58 {combine_script id='jquery.progressBar' load='footer' path='themes/default/js/plugins/jquery.progressbar.min.js'} 
    59 {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} 
    60  
    61 {footer_script require='jquery.tokeninput'} 
     63{/literal} 
     64 
    6265jQuery(document).ready(function() {ldelim} 
    6366  jQuery('[data-datepicker]').pwgDatepicker({ showTimepicker: true }); 
     
    6568  jQuery("a.preview-box").colorbox(); 
    6669   
    67         var tag_src = [{foreach from=$tags item=tag name=tags}{ldelim}name:"{$tag.name|@escape:'javascript'}",id:"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}]; 
    68   jQuery("#tags").tokenInput( 
    69     tag_src, 
    70     {ldelim} 
    71       hintText: '{'Type in a search term'|@translate}', 
    72       noResultsText: '{'No results'|@translate}', 
    73       searchingText: '{'Searching...'|@translate}', 
    74       newText: ' ({'new'|@translate})', 
    75       animateDropdown: false, 
    76       preventDuplicates: true, 
    77       allowFreeTagging: true 
    78     } 
    79   ); 
    80          
    81   jQuery("#tagsFilter").tokenInput( 
    82     tag_src, 
    83     {ldelim} 
    84       hintText: '{'Type in a search term'|@translate}', 
    85       noResultsText: '{'No results'|@translate}', 
    86       searchingText: '{'Searching...'|@translate}', 
    87       animateDropdown: false, 
    88       preventDuplicates: true, 
    89       allowFreeTagging: false 
    90     } 
    91   ); 
    92  
     70  {* <!-- TAGS --> *} 
     71  var tagsCache = new LocalStorageCache('tagsAdminList', 5*60, function(callback) { 
     72    jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.tags.getAdminList', function(data) { 
     73      var tags = data.result.tags; 
     74       
     75      for (var i=0, l=tags.length; i<l; i++) { 
     76        tags[i].id = '~~' + tags[i].id + '~~'; 
     77      } 
     78       
     79      callback(tags); 
     80    }); 
     81  }); 
     82   
     83  jQuery('[data-selectize=tags]').selectize({ 
     84    valueField: 'id', 
     85    labelField: 'name', 
     86    searchField: ['name'], 
     87    plugins: ['remove_button'] 
     88  }); 
     89   
     90  jQuery('[data-selectize=tags-create]').selectize({ 
     91    valueField: 'id', 
     92    labelField: 'name', 
     93    searchField: ['name'], 
     94    plugins: ['remove_button'], 
     95    create: function(input, callback) { 
     96      tagsCache.clear(); 
     97       
     98      callback({ 
     99        id: input, 
     100        name: input 
     101      }); 
     102    } 
     103  }); 
     104   
     105  tagsCache.get(function(tags) { 
     106    jQuery('[data-selectize^=tags]').each(function() { 
     107      this.selectize.load(function(callback) { 
     108        // one select is populated with <option> 
     109        if (jQuery.isEmptyObject(this.options)) { 
     110          callback(tags); 
     111        } 
     112      }); 
     113 
     114      if (jQuery(this).data('value')) { 
     115        jQuery.each(jQuery(this).data('value'), jQuery.proxy(function(i, tag) { 
     116          this.selectize.addItem(tag.id); 
     117        }, this)); 
     118      } 
     119    }); 
     120  }); 
    93121}); 
    94 {/footer_script} 
    95  
    96 {footer_script} 
     122 
    97123var nb_thumbs_page = {$nb_thumbs_page}; 
    98124var nb_thumbs_set = {$nb_thumbs_set}; 
     
    607633        <input type="checkbox" name="filter_tags_use" class="useFilterCheckbox" {if isset($filter.tags)}checked="checked"{/if}> 
    608634        {'Tags'|@translate} 
    609         <select id="tagsFilter" name="filter_tags"> 
    610           {if isset($filter_tags)}{foreach from=$filter_tags item=tag} 
    611           <option value="{$tag.id}">{$tag.name}</option> 
    612           {/foreach}{/if} 
    613         </select> 
     635        <select data-selectize="tags" data-value="{if isset($filter_tags)}{$filter_tags|@json_encode|escape:html}{else}[]{/if}" 
     636          name="filter_tags[]" multiple style="width:400px;" ></select> 
    614637        <label><span><input type="radio" name="tag_mode" value="AND" {if !isset($filter.tag_mode) or $filter.tag_mode eq 'AND'}checked="checked"{/if}> {'All tags'|@translate}</span></label> 
    615638        <label><span><input type="radio" name="tag_mode" value="OR" {if isset($filter.tag_mode) and $filter.tag_mode eq 'OR'}checked="checked"{/if}> {'Any tag'|@translate}</span></label> 
     
    671694                                <input name="q" size=40 value="{$filter.search.q|stripslashes|htmlspecialchars}"> 
    672695                                {combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'} 
    673                                 <a href="admin/popuphelp.php?page=quick_search"onclick="popuphelp(this.href);return false;" title="{'Help'|@translate}"><span class="icon-help-circled"></span></a> 
     696                                <a href="admin/popuphelp.php?page=quick_search" onclick="popuphelp(this.href);return false;" title="{'Help'|@translate}"><span class="icon-help-circled"></span></a> 
    674697                        </li> 
    675698    </ul> 
     
    783806  {/if} 
    784807      <option value="add_tags">{'Add tags'|@translate}</option> 
    785   {if !empty($DEL_TAG_SELECTION)} 
     808  {if !empty($associated_tags)} 
    786809      <option value="del_tags">{'remove tags'|@translate}</option> 
    787810  {/if} 
     
    837860    <!-- add_tags --> 
    838861    <div id="action_add_tags" class="bulkAction"> 
    839 <select id="tags" name="add_tags"> 
    840 </select> 
     862      <select data-selectize="tags-create" name="add_tags[]" multiple style="width:400px;"></select> 
    841863    </div> 
    842864 
    843865    <!-- del_tags --> 
    844866    <div id="action_del_tags" class="bulkAction"> 
    845 {if !empty($DEL_TAG_SELECTION)}{$DEL_TAG_SELECTION}{/if} 
     867{if !empty($associated_tags)} 
     868      <select data-selectize="tags" name="del_tags[]" multiple style="width:400px;"> 
     869      {foreach from=$associated_tags item=tag} 
     870        <option value="{$tag.id}">{$tag.name}</option> 
     871      {/foreach} 
     872      </select> 
     873{/if} 
    846874    </div> 
    847875 
Note: See TracChangeset for help on using the changeset viewer.