[SPIP Zone] r4628 - in /_plugins_/_ze_laboratoire_/spiip: img_pack/layer.js img_pack/presentation.js inc/layer.php jquery-1.0a.js spiip_pipelines.php

Author: renatoformato@virgilio.it
Date: Thu Aug 17 18:20:03 2006
New Revision: 4628

Log:
no more inline js for "couche". Switch to jquery-1.0a that seems to fix most of the ready method problems. More performance improvement when showing menus

Added:
    _plugins_/_ze_laboratoire_/spiip/jquery-1.0a.js
Modified:
    _plugins_/_ze_laboratoire_/spiip/img_pack/layer.js
    _plugins_/_ze_laboratoire_/spiip/img_pack/presentation.js
    _plugins_/_ze_laboratoire_/spiip/inc/layer.php
    _plugins_/_ze_laboratoire_/spiip/spiip_pipelines.php

Modified: _plugins_/_ze_laboratoire_/spiip/img_pack/layer.js

--- _plugins_/_ze_laboratoire_/spiip/img_pack/layer.js (original)
+++ _plugins_/_ze_laboratoire_/spiip/img_pack/layer.js Thu Aug 17 18:20:03 2006
@@ -46,6 +46,7 @@
   }
}

+/*
function swap_couche(couche, rtl, dir, no_swap) {
   var layer;
   var triangle = findObj('triangle' + couche);
@@ -58,6 +59,15 @@
     layer.style.display = 'none';
   }
}
+*/
+function jquerySwapCouche() {
+ var m = this.id.match(/([-\d]+)(_rtl)?/);
+ var ids = m[1].split("-");
+ var dir = m[2] || '';
+ for(id in ids) $('#Layer'+ids[id]).toggle();
+ this.src = this.src.search(/bas\.gif$/)==-1 ? this.src.replace(/haut(_rtl)?\.gif$/,'bas.gif'): this.src.replace(/bas\.gif$/,'haut'+dir+'.gif');
+}
+
function ouvrir_couche(couche, rtl,dir) {
   var layer;
   var triangle = findObj('triangle' + couche);
@@ -212,7 +222,7 @@
     Field.innerHTML = url_chargee['mem_'+myUrl];
     Field.style.visibility = "visible";
     Field.style.display = "block";
- $('a.ajax',Field).click(exec_ajax_links).not('[@href]').css({'cursor':'pointer','visibility':'visible'});
+ $('a.ajax',Field).click(execAjaxLinks).not('[@href]').css({'cursor':'pointer','visibility':'visible'});
     if(jjscript) eval(jjscript);
   } else {
     image_search[myField] = findObj_forcer('img_'+myField);
@@ -227,7 +237,7 @@
         // si elle est non vide, l'afficher
         if (xmlhttp[myField].responseText != '') {
           Field.innerHTML = xmlhttp[myField].responseText;
- $('a.ajax',Field).click(exec_ajax_links).not('[@href]').css({'cursor':'pointer','visibility':'visible'});
+ $('a.ajax',Field).click(execAjaxLinks).not('[@href]').css({'cursor':'pointer','visibility':'visible'});
           url_chargee['mem_'+myUrl] = Field.innerHTML;
         
           Field.style.visibility = "visible";

Modified: _plugins_/_ze_laboratoire_/spiip/img_pack/presentation.js

--- _plugins_/_ze_laboratoire_/spiip/img_pack/presentation.js (original)
+++ _plugins_/_ze_laboratoire_/spiip/img_pack/presentation.js Thu Aug 17 18:20:03 2006
@@ -11,14 +11,18 @@
     $('map').mouseover(
       function(){active_menu.hide();active_menu=$('empty');}
     );
+ //init couche images
+ console.time("couche");
+ $('img.swapCouche').click(jquerySwapCouche).css('display','inline');
+ console.timeEnd("couche");
     //init ajax links
- $('a.ajax').click(exec_ajax_links).not('[@href]').css({'cursor':'pointer','visibility':'visible'});
+ $('a.ajax').click(execAjaxLinks).not('[@href]').css({'cursor':'pointer','visibility':'visible'});
   }
);

function showMenu() {
   if(init_gauche) {
- $('.bandeau_sec').
+ $('#haut-page div.bandeau_sec').
     //before adjusting offset let the submenu have a layout
     css({'visible':'hidden','display':'block'}).each(decalerCouche).
     //reset visibility
@@ -42,16 +46,15 @@

     layer.style.left = gauche+"px";
   }
-
}

-function exec_ajax_links() {
       //call information is inside the link id
       //id='page-var1:val1:var2:val2-dest_el'
       //params are separated by --
       //param 0 = page to exec
       //param 1 = arguments of exec (pairs of name, value separated by :slight_smile:
       //param 3 = id of the receiving element
+function execAjaxLinks() {
       var params = this.id.split('--');
       var url = './?exec='+params[0]+'&var_ajax=1';
       var args = params[1].split(':');

Modified: _plugins_/_ze_laboratoire_/spiip/inc/layer.php

--- _plugins_/_ze_laboratoire_/spiip/inc/layer.php (original)
+++ _plugins_/_ze_laboratoire_/spiip/inc/layer.php Thu Aug 17 18:20:03 2006
@@ -68,12 +68,14 @@

     if (!$icone) {
       $icone = "deplierhaut$spip_lang_rtl.gif";
- $couches[] = array($numero_block[$nom_block],0);
+ //$couches[] = array($numero_block[$nom_block],0);
     }
- else
- $couches[] = array($numero_block[$nom_block],1);
+ //else
+ // $couches[] = array($numero_block[$nom_block],1);
+ $couches[] = $numero_block[$nom_block];
   }
- return produire_acceder_couche($couches, $numero_block[$nom_block], $icone);
+ //return produire_acceder_couche($couches, $numero_block[$nom_block], $icone);
+ return produire_acceder_couche($couches, $icone);
}

@@ -91,17 +93,21 @@
       $numero_block[$nom_block] = $compteur_block;
     }

- $couches[] = array($numero_block[$nom_block],0);
+ //$couches[] = array($numero_block[$nom_block],0);
+ $couches[] = $numero_block[$nom_block];

   }

- return produire_acceder_couche($couches, $numero_block[$nom_block], "deplierbas.gif");
+ //return produire_acceder_couche($couches, $numero_block[$nom_block], "deplierbas.gif");
+ return produire_acceder_couche($couches, "deplierbas.gif");
}

// http://doc.spip.org/@produire_acceder_couche
-function produire_acceder_couche($couches, $nom, $icone) {
-
+//function produire_acceder_couche($couches, $nom, $icone) {
+function produire_acceder_couche($couches, $icone) {
+ global $spip_lang_rtl;
   // ne rien afficher si js desactive
+ /*
   if ($_COOKIE['spip_accepte_ajax'] == -1)
     return '';

@@ -112,9 +118,11 @@
       . _DIR_IMG_PACK."',"
       . $couche[1].');';

- return
+ /*return
   '<img name="triangle'.$nom.'" src="'._DIR_IMG_PACK.$icone.'" alt="" title="'._T('info_deplier').'" border="0" height="10" width="10"
-onclick="'.join(' ',$onclick).'" />';
+onclick="'.join(' ',$onclick).'" />';*/
+ return
+ '<img class="swapCouche" id="triangle'.join($couches,'-').$spip_lang_rtl.'" src="'._DIR_IMG_PACK.$icone.'" alt="" title="'._T('info_deplier').'" style="display:none;border:none" height="10" width="10" />';

}

Added: _plugins_/_ze_laboratoire_/spiip/jquery-1.0a.js

--- _plugins_/_ze_laboratoire_/spiip/jquery-1.0a.js (added)
+++ _plugins_/_ze_laboratoire_/spiip/jquery-1.0a.js Thu Aug 17 18:20:03 2006
@@ -0,0 +1,1518 @@
+/*
+ * jQuery - New Wave Javascript
+ *
+ * Copyright (c) 2006 John Resig (jquery.com)
+ * Licensed under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * $Date: 2006-07-01 10:05:50 -0400 (Sat, 01 Jul 2006) $
+ * $Rev: 110 $
+ */
+
+// Global undefined variable
+window.undefined = window.undefined;
+
+/**
+ * Create a new jQuery Object
+ * @constructor
+ */
+function jQuery(a,c) {
+ // Watch for when a jQuery object is passed in as an arg
+ if ( a && a.jquery )
+ return a;
+
+ // If the context is global, return a new object
+ if ( window == this )
+ return new jQuery(a,c);
+
+ // Find the matching elements and save them for later
+ this.cur = jQuery.Select(
+ a || jQuery.context || document,
+ c && c.jquery && c.get(0) || c
+ );
+}
+
+/**
+ * The jQuery query object.
+ */
+if ( !window.$ )
+ var $ = jQuery;
+
+/*
+ * Handle support for overriding other $() functions. Way too many libraries
+ * provide this function to simply ignore it and overwrite it.
+ */
+else
+ var $ = function(a,c) {
+ // Check to see if this is a possible collision case
+ if ( !c && a.constructor == String &&
+
+ // Make sure that the expression is a colliding one
+ !/[^a-zA-Z0-9_-]/.test(a) &&
+
+ // and that there are no elements that match it
+ // (this is the one truly ambiguous case)
+ !document.getElementsByTagName(a).length ) {
+
+ // Only return the element if it's found
+ var obj = document.getElementById(a);
+ if ( obj ) return obj;
+
+ }
+
+ return jQuery(a,c);
+ };
+
+jQuery.fn = jQuery.prototype = {
+ /**
+ * The current SVN version of jQuery.
+ *
+ * @private
+ * @type String
+ */
+ jquery: "$Rev: 110 $",
+
+ /**
+ * The number of elements currently matched.
+ *
+ * @type Number
+ */
+ size: function() {
+ return this.get().length;
+ },
+
+ /**
+ * Access the elements matched. If a number is provided,
+ * the Nth element is returned, otherwise, an array of all
+ * matched items is returned.
+ *
+ * @type Array,DOMElement
+ */
+ get: function(num) {
+ return num == undefined ? this.cur : this.cur[num];
+ },
+
+ each: function(f) {
+ for ( var i = 0; i < this.size(); i++ )
+ f.apply( this.get(i), [i] );
+ return this;
+ },
+ set: function(a,b) {
+ return this.each(function(){
+ if ( b === undefined )
+ for ( var j in a )
+ jQuery.attr(this,j,a[j]);
+ else
+ jQuery.attr(this,a,b);
+ });
+ },
+ html: function(h) {
+ return h == undefined && this.size() ?
+ this.get(0).innerHTML : this.set( "innerHTML", h );
+ },
+ val: function(h) {
+ return h == undefined && this.size() ?
+ this.get(0).value : this.set( "value", h );
+ },
+ text: function(e) {
+ e = e || this.get();
+ var t = "";
+ for ( var j = 0; j < e.length; j++ )
+ for ( var i = 0; i < e[j].childNodes.length; i++ )
+ t += e[j].childNodes[i].nodeType != 1 ?
+ e[j].childNodes[i].nodeValue :
+ jQuery.fn.text(e[j].childNodes[i].childNodes);
+ return t;
+ },
+
+ css: function(a,b) {
+ return a.constructor != String || b ?
+ this.each(function(){
+ if ( b === undefined )
+ for ( var j in a )
+ jQuery.attr(this.style,j,a[j]);
+ else
+ jQuery.attr(this.style,a,b);
+ }) : jQuery.css( this.get(0), a );
+ },
+ toggle: function() {

[... 1395 lines stripped ...]