Changeset 28938


Ignore:
Timestamp:
Jul 4, 2014, 12:30:26 PM (10 years ago)
Author:
mistic100
Message:

selectize/localcache : remove overkill categories sorting (already done in WS) + remove some data (comments, uppercets, etc...)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/themes/default/js/LocalStorageCache.js

    r28937 r28938  
    203203    options.loader = function(callback) {
    204204      $.getJSON(options.rootUrl + 'ws.php?format=json&method=pwg.categories.getAdminList', function(data) {
    205         callback(data.result.categories);
     205        var cats = data.result.categories.map(function(c, i) {
     206          c.pos = i;
     207          delete c['comment'];
     208          delete c['uppercats'];
     209          return c;
     210        });
     211
     212        callback(cats);
    206213      });
    207214    };
     
    218225  CategoriesCache.prototype.selectize = function($target, options) {
    219226    options = options || {};
    220 
    221     options.filter = function(cats) {
    222       cats.map(function(c) {
    223         c.pos = c.global_rank.split('.');
    224       });
    225 
    226       cats.sort(function(a, b) {
    227         var i = 0;
    228         while (a.pos[i] && b.pos[i]) {
    229           if (a.pos[i] != b.pos[i]) {
    230             return a.pos[i] - b.pos[i];
    231           }
    232           i++;
    233         }
    234         return (!a.pos[i] && b.pos[i]) ? -1 : 1;
    235       });
    236 
    237       cats.map(function(c, i) {
    238         c.pos = i;
    239       });
    240 
    241       return cats;
    242     };
    243227
    244228    $target.selectize({
     
    268252    options.loader = function(callback) {
    269253      $.getJSON(options.rootUrl + 'ws.php?format=json&method=pwg.tags.getAdminList', function(data) {
    270         var tags = data.result.tags;
    271        
    272         for (var i=0, l=tags.length; i<l; i++) {
    273           tags[i].id = '~~' + tags[i].id + '~~';
    274         }
    275        
     254        var tags = data.result.tags.map(function(t) {
     255          t.id = '~~' + t.id + '~~';
     256          delete t['url_name'];
     257          delete t['lastmodified'];
     258          return t;
     259        });
     260
    276261        callback(tags);
    277262      });
     
    316301    options.loader = function(callback) {
    317302      $.getJSON(options.rootUrl + 'ws.php?format=json&method=pwg.groups.getList&per_page=9999', function(data) {
    318         callback(data.result.groups);
     303        var groups = data.result.groups.map(function(g) {
     304          delete g['lastmodified'];
     305          return g;
     306        });
     307
     308        callback(groups);
    319309      });
    320310    };
Note: See TracChangeset for help on using the changeset viewer.