<commit_before>// Javascript Document
// Javascript Document
var $tree,
    treeDS = new kendo.data.HierarchicalDataSource({
      filterable: true,
      transport: {
        read: function(e){
          appui.fn.post(data.root + "tree/" + (e.data.id ? e.data.id : data.cat), function(d){
            $.each(d.data, function(i, v){
              d.data[i].text = v.text.toString();
              d.data[i].is_parent = v.num_children > 0 ? true : false;
            });
            e.success(d);
          });
        }
      },
      schema: {
        data: "data",
        model: {
          id: "id",
          hasChildren: "is_parent",
          fields: {
            type: {type: "string"},
            text: {type: "string"},
            code: {type: "string"},
            is_parent: {type: "bool"}
          }
        }
      }
    }),
    treeCfg = {
      dataSource: treeDS,
      template: function (e) {
        var st = '<i class="fa fa-' + (e.item.icon ? e.item.icon : 'cog') + '"></i> ' + e.item.text;
        return st;
      }
    };
if ( data.is_admin ){
  $.extend(treeCfg, {
    dragAndDrop: true,
    drag: function(e){
      var dd = false,
          ds = this.dataItem(e.sourceNode),
          ok = 1;
      if ( e.dropTarget === undefined ){
        ok = false;
      }
      dd = this.dataItem(e.dropTarget);
      if ( ok ){
        if ( (dd.id_parent !== 0) && !dd.cfg.allow_children ){
          ok = false;
        }
        else if ( ds.id === dd.id ){
          ok = false;
        }
        else if ( !dd.cfg.orderable && (ds.id_parent === dd.id) ){
          ok = false;
        }
      }
      if ( !ok ){
        if ( e.setStatusClass !== undefined ){
          e.setStatusClass("k-denied");
        }
        if ( e.setValid !== undefined ){
          e.setValid(false);
        }
      }
    },
    drop: function(e){
      if ( e.valid && confirm(data.lng.confirm_move) ){
        var tree = this,
            dd = this.dataItem(e.destinationNode),
            ds = this.dataItem(e.sourceNode),
            prev = $(e.sourceNode).prev(),
            parent = $(e.sourceNode).parent();
        appui.fn.log(e);
        appui.fn.post(data.root + 'actions/move', {
          dest: dd.id,
          src: ds.id
        }, function(d){<commit_msg>options' orderable becomes sortable<commit_after>// Javascript Document
// Javascript Document
var $tree,
    treeDS = new kendo.data.HierarchicalDataSource({
      filterable: true,
      transport: {
        read: function(e){
          appui.fn.post(data.root + "tree/" + (e.data.id ? e.data.id : data.cat), function(d){
            $.each(d.data, function(i, v){
              d.data[i].text = v.text.toString();
              d.data[i].is_parent = v.num_children > 0 ? true : false;
            });
            e.success(d);
          });
        }
      },
      schema: {
        data: "data",
        model: {
          id: "id",
          hasChildren: "is_parent",
          fields: {
            type: {type: "string"},
            text: {type: "string"},
            code: {type: "string"},
            is_parent: {type: "bool"}
          }
        }
      }
    }),
    treeCfg = {
      dataSource: treeDS,
      template: function (e) {
        var st = '<i class="fa fa-' + (e.item.icon ? e.item.icon : 'cog') + '"></i> ' + e.item.text;
        return st;
      }
    };
if ( data.is_admin ){
  $.extend(treeCfg, {
    dragAndDrop: true,
    drag: function(e){
      var dd = false,
          ds = this.dataItem(e.sourceNode),
          ok = 1;
      if ( e.dropTarget === undefined ){
        ok = false;
      }
      dd = this.dataItem(e.dropTarget);
      if ( ok ){
        if ( (dd.id_parent !== 0) && !dd.cfg.allow_children ){
          ok = false;
        }
        else if ( ds.id === dd.id ){
          ok = false;
        }
        else if ( !dd.cfg.sortable && (ds.id_parent === dd.id) ){
          ok = false;
        }
      }
      if ( !ok ){
        if ( e.setStatusClass !== undefined ){
          e.setStatusClass("k-denied");
        }
        if ( e.setValid !== undefined ){
          e.setValid(false);
        }
      }
    },
    drop: function(e){
      if ( e.valid && confirm(data.lng.confirm_move) ){
        var tree = this,
            dd = this.dataItem(e.destinationNode),
            ds = this.dataItem(e.sourceNode),
            prev = $(e.sourceNode).prev(),
            parent = $(e.sourceNode).parent();
        appui.fn.log(e);
        appui.fn.post(data.root + 'actions/move', {
          dest: dd.id,
          src: ds.id
        }, function(d){
{'fraction_non_alphanumeric': 0.1639380048024449, 'fraction_numerical': 0.0013097576948264572, 'mean_word_length': 1.4555198285101822, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4592521', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1476, 'n_words': 296}