[ Index ]
 

Code source de SPIP 1.9.2c

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/dist/javascript/ -> articles_tous_edite.js (source)

   1  function deplie_arbre(){
   2      tree = jQuery('#articles_tous');
   3      jQuery('ul:hidden',tree).siblings('img.expandImage').each(function(){jQuery(this).bascule()});
   4  }
   5  function plie_arbre(){
   6      tree = jQuery('#articles_tous');
   7      jQuery('#articles_tous ul').hide();
   8      jQuery('img.expandImage', tree).attr('src',img_deplierhaut);
   9  }
  10  function annuler_deplacement(){
  11      liste = jQuery("#deplacements").text();
  12      tableau = liste.split("\n");
  13      if (tableau.length>0){
  14          action = tableau[tableau.length-1];
  15          tab = action.split(":");
  16          jQuery("#"+tab[2]).insertion(tab[0],jQuery("#"+tab[0]).parent().attr('id'));
  17          tableau.pop();
  18          jQuery("#deplacements").html(tableau.join("\n"));
  19          if (tableau.length==0) jQuery("#cancel").hide();
  20          if (tableau.length==0) jQuery("#apply").hide();
  21      }
  22  }
  23  
  24  jQuery.fn.set_expandImage = function(){
  25      jQuery('ul:hidden',jQuery(this)).parent().prepend('<img src="'+img_deplierhaut+'" class="expandImage" />');
  26      jQuery('ul:visible',jQuery(this)).parent().prepend('<img src="'+img_deplierbas+'" class="expandImage" />');
  27      jQuery('img.expandImage', jQuery(this)).click(function (){jQuery(this).bascule();});
  28      return jQuery(this);
  29  }
  30  
  31  var recall;
  32  jQuery.fn.deplie = function(){
  33      jQuery(this).show();
  34      jQuery(this).siblings('img.expandImage').eq(0).attr('src',img_deplierbas);
  35      jQuery(this).children('li').children('a.ajax').each(function(){
  36          jQuery(this).before("<div>"+ajax_image_searching+"</div>");
  37          var id = jQuery(this).parent().parent().attr('id');
  38          jQuery(this).parent().parent().load(jQuery(this).attr('href')+"&var_ajaxcharset=utf-8",function(){jQuery("#"+id).set_expandImage().set_droppables();jQuery.recallDroppables();});
  39      });
  40      recall = true;
  41      jQuery.recallDroppables();
  42      return jQuery(this);
  43  }
  44  
  45  jQuery.fn.bascule = function() {
  46      subbranch = jQuery(this).siblings('ul').eq(0);
  47      if (subbranch.is(':hidden')) {
  48          subbranch.show();
  49          jQuery(this).attr('src',img_deplierbas);
  50          subbranch.children('li').children('a.ajax').each(function(){
  51              jQuery(this).before("<div>"+ajax_image_searching+"</div>");
  52              var id = jQuery(this).parent().parent().attr('id');
  53              jQuery(this).parent().parent().load(jQuery(this).attr('href')+"&var_ajaxcharset=utf-8",function(){jQuery("#"+id).set_expandImage().set_droppables();});
  54          });
  55      } else {
  56          subbranch.hide();
  57          jQuery(this).attr('src',img_deplierhaut);
  58      }
  59      return jQuery(this);
  60  }
  61  jQuery.fn.insertion = function(dropped_id,origine_id){
  62      dropped = jQuery('#'+dropped_id);
  63      subbranch = jQuery(this).children('ul').eq(0);
  64      if (subbranch.size() == 0) {
  65          jQuery(this).prepend('<img src="'+img_deplierbas+'" width="16" height="16" class="expandImage" />');
  66          id = jQuery(this).attr('id');
  67          id = id.split("-"); id=id[1]
  68          jQuery(this).append("<ul id='ul"+id+"' ></ul>");
  69          jQuery(this).children('img.expandImage').click(function (){jQuery(this).bascule();});
  70          subbranch = jQuery(this).children('ul').eq(0);
  71      }
  72      if((dropped.is('li.art')) && (subbranch.children('li.rub').length>0)){
  73          subbranch.end().children('li.rub').eq(0).before(dropped);
  74      }
  75      else
  76          subbranch.end().append(dropped);
  77  
  78      if (subbranch.is(':hidden')){
  79          subbranch.deplie();
  80      }
  81  
  82      oldParent = jQuery('#'+origine_id);
  83      oldBranches = jQuery('li', oldParent);
  84      if (oldBranches.size() == 0) {
  85          oldParent.siblings('img.expandImage').remove();
  86          oldParent.end().remove();
  87      }
  88  }
  89  
  90  jQuery.fn.set_droppables = function(){
  91      jQuery('span.holder',jQuery(this)).Droppable(
  92          {
  93              accept            : 'treeItem',
  94              hoverclass        : 'none',
  95              activeclass        : 'fakeClass',
  96              tollerance        : 'intersect',
  97              onhover            : function(dragged)
  98              {
  99                  jQuery(this).parent().addClass('selected');
 100                  if (!this.expanded) {
 101                      subbranch = jQuery(this).siblings('ul').eq(0);
 102                      if (subbranch.is(':hidden')){
 103                          subbranch.pause(1000).deplie();
 104                          this.expanded = true;
 105                      }
 106                  }
 107              },
 108              onout            : function()
 109              {
 110                  jQuery(this).parent().removeClass('selected');
 111                  if (this.expanded){
 112                      subbranch = jQuery(this).siblings('ul').eq(0);
 113                      subbranch.unpause();
 114                      if (recall){
 115                          recall=false;
 116                      }
 117                  }
 118                  this.expanded = false;
 119              },
 120              ondrop            : function(dropped)
 121              {
 122                  jQuery(this).parent().removeClass('selected');
 123                  subbranch = jQuery(this).siblings('ul').eq(0);
 124                  if (this.expanded)
 125                      subbranch.unpause();
 126                  var target=jQuery(this).parent().attr('id');
 127                  var quoi=jQuery(dropped).attr('id');
 128                  var source=jQuery(dropped).parent().parent().attr('id'); // il faut stocker l'id du li car le ul peut avoir disparu au moment du cancel
 129                  action=quoi+":"+target+":"+source;
 130                  var dep = jQuery("#deplacements");
 131                  dep.html(dep.text()+"\n"+action);
 132                  jQuery("#apply").show();
 133                  jQuery("#cancel").show();
 134                  jQuery(this).parent().insertion(quoi,jQuery(dropped).parent().attr('id'));
 135              }
 136          }
 137      );
 138      jQuery('li.treeItem',jQuery(this)).Draggable(
 139          {
 140              revert        : true,
 141              ghosting : true,
 142              autoSize : true
 143          }
 144      );
 145  }
 146  
 147  jQuery(
 148      function()
 149      {
 150          jQuery('#articles_tous').set_expandImage();
 151          jQuery('#articles_tous').set_droppables();
 152      }
 153  );


Généré le : Wed Nov 21 10:20:27 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics