From 463189158132427f916370e1b1a88e15692b3217 Mon Sep 17 00:00:00 2001 From: Cerdic <cedric@yterium.com> Date: Fri, 15 Dec 2006 17:38:07 +0000 Subject: [PATCH] Les descriptifs des plugins en jTip, pour alleger le chargement de la page. Mais comment on fait pour cliquer sur les liens maintenant ? --- .gitattributes | 6 +++ dist/images/arrow_left.gif | Bin 0 -> 102 bytes dist/images/arrow_right.gif | Bin 0 -> 102 bytes dist/images/loader.gif | Bin 0 -> 958 bytes dist/javascript/jtip.js | 97 ++++++++++++++++++++++++++++++++++ dist/jtip.css | 98 +++++++++++++++++++++++++++++++++++ ecrire/exec/admin_plugin.php | 46 +++++----------- ecrire/exec/info_plugin.php | 13 +++++ ecrire/inc/plugin.php | 43 +++++++++++++++ 9 files changed, 271 insertions(+), 32 deletions(-) create mode 100644 dist/images/arrow_left.gif create mode 100644 dist/images/arrow_right.gif create mode 100644 dist/images/loader.gif create mode 100644 dist/javascript/jtip.js create mode 100644 dist/jtip.css create mode 100644 ecrire/exec/info_plugin.php diff --git a/.gitattributes b/.gitattributes index aade0b366e..9d131a3a9c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -32,6 +32,8 @@ dist/images/aide-48_rtl.png -text dist/images/aide.gif -text dist/images/aide_rtl.gif -text dist/images/annonce.gif -text +dist/images/arrow_left.gif -text +dist/images/arrow_right.gif -text dist/images/article-24.gif -text dist/images/asuivre-24.gif -text dist/images/asuivre-48.png -text @@ -100,6 +102,7 @@ dist/images/langues-12.gif -text dist/images/langues-24.gif -text dist/images/langues-modif-12.gif -text dist/images/langues-off-12.gif -text +dist/images/loader.gif -text dist/images/logo-spip.gif -text dist/images/logo_spip.jpg -text dist/images/loupe-moins.gif -text @@ -222,8 +225,10 @@ dist/javascript/async_upload.js -text dist/javascript/dragdrop_interface.js -text dist/javascript/form.js -text dist/javascript/jquery-1.0.3.js -text +dist/javascript/jtip.js -text dist/javascript/pause.js -text dist/jquery.js.html -text +dist/jtip.css -text dist/modeles/article_mots.html -text dist/modeles/article_traductions.html -text dist/modeles/doc.html -text @@ -407,6 +412,7 @@ ecrire/exec/gadgets.php -text ecrire/exec/grouper_mots.php -text ecrire/exec/iconifier.php -text ecrire/exec/import_all.php -text +ecrire/exec/info_plugin.php -text ecrire/exec/informer.php -text ecrire/exec/informer_auteur.php -text ecrire/exec/install.php -text diff --git a/dist/images/arrow_left.gif b/dist/images/arrow_left.gif new file mode 100644 index 0000000000000000000000000000000000000000..4c9e5c66bda8fa0b1e78bd144ba5349c7c26131f GIT binary patch literal 102 zcmZ?wbhEHb<Yo|OSj50^=FFM*@85s_{{24~Fu;J~PZm}Y1{MY#kN`+61GBcrE}1`! vdqkg#DBNEo`Rp1~*(r}%va43+SPSK@?9vFn{eJT6J1XtMllUhvFjxZsvt1@n literal 0 HcmV?d00001 diff --git a/dist/images/arrow_right.gif b/dist/images/arrow_right.gif new file mode 100644 index 0000000000000000000000000000000000000000..3252c359e276df642fa30a804284645dc1aeac72 GIT binary patch literal 102 zcmZ?wbhEHb<Yo|OSj50^=FFM*@85s_{{24~Fu;J~PZm}Y1{MY#kN`+61G6^AmOBg1 v?mcmD$+uH7oA1UwtvzyLW=7XEZR;*YpHmGNBEQ83=Ny>6PyWet1_o;YKk+K% literal 0 HcmV?d00001 diff --git a/dist/images/loader.gif b/dist/images/loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..32af9875a41d87a018252b23b87c2c985db35c9e GIT binary patch literal 958 zcmZ?wbhEHbv}539n8?6z=FFLyGiUz)|DS<@LGeGgpKD04vtxj(k)8oFBS`2c3o91` z6N3%|0|Ns{3j<SpkAC|B-M0$WlbocN8f8A#WSlS2m$rj-Zc*6N*T({O=@pe7{CW1m zmOk#L3YFgH?m2I#IW?STmN8m-_TpqwUB9iNR|IFB(V888yUfS8xH>-PNA0&w6ACM? zTd-gMUhcujponaz2m>zz1Cv^d{z}QW?bC|*nJhCmh;#3aytlkiIiqUDifKCAoR({E z58=8T=qHNM%Fe*RK&Dnc^0kVRuT_S8t;*zU)uM{l9{rV^;K*UK)FdWykQ_{^R-|Ae zRVz~Dkg63aNf57<6D{AkOwnK1&A~r=&X#jW)q1v7cWGYvR`X1fO}TPg?5@0bHLZs3 q&pX#{tm1opvTn<Q78V7uO85DjQgamMuUm20^KS(I<u^+h7_0%;K{fIK literal 0 HcmV?d00001 diff --git a/dist/javascript/jtip.js b/dist/javascript/jtip.js new file mode 100644 index 0000000000..2903f3f6a3 --- /dev/null +++ b/dist/javascript/jtip.js @@ -0,0 +1,97 @@ +/* + * JTip + * By Cody Lindley (http://www.codylindley.com) + * Under an Attribution, Share Alike License + * JTip is built on top of the very light weight jquery library. + */ + +//on page load (as soon as its ready) call JT_init +$(document).ready(JT_init); + +function JT_init(){ + $("a.jTip") + .hover(function(){JT_show(this.href,this.id,this.name)},function(){$('#JT').remove()}) + .click(function(){return false}); +} + +function JT_show(url,linkId,title){ + if(title == false)title=" "; + var de = document.documentElement; + var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; + var hasArea = w - getAbsoluteLeft(linkId); + var clickElementy = getAbsoluteTop(linkId) - 3; //set y position + + var queryString = url.replace(/^[^\?]+\??/,''); + var params = parseQuery( queryString ); + if(params['width'] === undefined){params['width'] = 250}; + if(params['link'] !== undefined){ + $('#' + linkId).bind('click',function(){window.location = params['link']}); + $('#' + linkId).css('cursor','pointer'); + } + + if(hasArea>((params['width']*1)+75)){ + $("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_arrow_left'></div><div id='JT_close_left'>"+title+"</div><div id='JT_copy'><div class='JT_loader'><div></div></div>");//right side + var arrowOffset = getElementWidth(linkId) + 11; + var clickElementx = getAbsoluteLeft(linkId) + arrowOffset; //set x position + }else{ + $("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_arrow_right' style='left:"+((params['width']*1)+1)+"px'></div><div id='JT_close_right'>"+title+"</div><div id='JT_copy'><div class='JT_loader'><div></div></div>");//left side + var clickElementx = getAbsoluteLeft(linkId) - ((params['width']*1) + 15); //set x position + } + + $('#JT').css({left: clickElementx+"px", top: clickElementy+"px"}); + $('#JT').show(); + $('#JT_copy').load(url); + +} + +function getElementWidth(objectId) { + x = document.getElementById(objectId); + return x.offsetWidth; +} + +function getAbsoluteLeft(objectId) { + // Get an object left position from the upper left viewport corner + o = document.getElementById(objectId) + oLeft = o.offsetLeft // Get left position from the parent object + while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element + oParent = o.offsetParent // Get parent object reference + oLeft += oParent.offsetLeft // Add parent left position + o = oParent + } + return oLeft +} + +function getAbsoluteTop(objectId) { + // Get an object top position from the upper left viewport corner + o = document.getElementById(objectId) + oTop = o.offsetTop // Get top position from the parent object + while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element + oParent = o.offsetParent // Get parent object reference + oTop += oParent.offsetTop // Add parent top position + o = oParent + } + return oTop +} + +function parseQuery ( query ) { + var Params = new Object (); + if ( ! query ) return Params; // return empty object + var Pairs = query.split(/[;&]/); + for ( var i = 0; i < Pairs.length; i++ ) { + var KeyVal = Pairs[i].split('='); + if ( ! KeyVal || KeyVal.length != 2 ) continue; + var key = unescape( KeyVal[0] ); + var val = unescape( KeyVal[1] ); + val = val.replace(/\+/g, ' '); + Params[key] = val; + } + return Params; +} + +function blockEvents(evt) { + if(evt.target){ + evt.preventDefault(); + }else{ + evt.returnValue = false; + } +} \ No newline at end of file diff --git a/dist/jtip.css b/dist/jtip.css new file mode 100644 index 0000000000..d793c85c8a --- /dev/null +++ b/dist/jtip.css @@ -0,0 +1,98 @@ +/* - - - - - - CSS Document - - - - - - - - - + +Title : Global style sheet for client-side web development +Author : Cody Lindley + +- - - - - - - - - - - - - - - - - - - - - */ + +.formInfo a, .formInfo a:active, formInfo a:visited{ + background-color: #f66; + font-size: 1.3em; + font-weight:bold; + padding:1px 2px; + margin-left:5px; + color:#FFFFFF; + text-decoration: none; + float: right; +} + +.formInfo a:hover{ + color:#660000; + text-decoration: none; +} + +/* ---------->>> jtip <<<---------------------------------------------------------------*/ + +#JT_arrow_left{ + background-image: url(images/arrow_left.gif); + background-repeat: no-repeat; + background-position: left top; + position: absolute; + z-index:101; + left:-12px; + height:23px; + width:10px; + top:-3px; +} + +#JT_arrow_right{ + background-image: url(images/arrow_right.gif); + background-repeat: no-repeat; + background-position: left top; + position: absolute; + z-index:101; + height:23px; + width:11px; + top:-2px; +} + +#JT { + position: absolute; + z-index:100; + border: 2px solid #CCCCCC; + background-color: #fff; +} + +#JT_copy{ + padding:10px 10px 10px 10px; + color:#333333; +} + +.JT_loader{ + background-image: url(images/loader.gif); + background-repeat: no-repeat; + background-position: center center; + width:100%; + height:12px; +} + +#JT_close_left{ + background-color: #CCCCCC; + text-align: left; + padding-left: 8px; + padding-bottom: 5px; + padding-top: 2px; + font-weight:bold; +} + +#JT_close_right{ + background-color: #CCCCCC; + text-align: left; + padding-left: 8px; + padding-bottom: 5px; + padding-top: 2px; + font-weight:bold; +} + +#JT_copy p{ +margin:3px 0; +} + +#JT_copy img{ + padding: 1px; + border: 1px solid #CCCCCC; +} + +.jTip{ +cursor:help; +} diff --git a/ecrire/exec/admin_plugin.php b/ecrire/exec/admin_plugin.php index 2a4879d6e9..2088b3cce6 100644 --- a/ecrire/exec/admin_plugin.php +++ b/ecrire/exec/admin_plugin.php @@ -40,8 +40,10 @@ function exec_admin_plugin() { global $couleur_claire; $commencer_page = charger_fonction('commencer_page', 'inc'); echo $commencer_page(_T('icone_admin_plugin'), "configuration", "plugin"); - echo "<style type='text/css'>\n"; $dir_img_pack = _DIR_IMG_PACK; + echo "<link rel='stylesheet' href='".find_in_path('jtip.css')."' type='text/css' media='screen' />"; + echo "<script src='"._DIR_JAVASCRIPT."jtip.js' type='text/javascript'></script>"; + echo "<style type='text/css'>\n"; echo <<<EOF div.cadre-padding ul li { list-style:none ; @@ -232,11 +234,9 @@ function affiche_arbre_plugins($liste_plugins,$liste_plugins_actifs){ $maxiter=1000; echo http_script(" $(document).ready( - function() - { + function(){ $('input.check').click(function(){\$(this).parent().toggleClass('nomplugin_on');}); - } - );"); + });"); while (count($liste_plugins) && $maxiter--){ // le rep suivant $dir = dirname(reset($liste_plugins)); @@ -274,8 +274,13 @@ function ligne_plug($plug_file, $actif, $id){ $s .= "</div>"; } + $etat = 'dev'; + if (isset($info['etat'])) + $etat = $info['etat']; + $nom = typo($info['nom']); // puce d'etat du plugin // <etat>dev|experimental|test|stable</etat> + $s .= "<span class='formInfo'><a href='".generer_url_ecrire('info_plugin',"plug=$plug_file&width=500")."' class='jTip' name=\"".attribut_html($nom)."\" id='aide_$plug_file'>?</a></span>"; $s .= "<span class='$etat'> </span>"; if (!$erreur){ $s .= "<input type='checkbox' name='statusplug_$plug_file' value='O' id='label_$id_input'"; @@ -284,38 +289,15 @@ function ligne_plug($plug_file, $actif, $id){ } $id_input++; - $s .= bouton_block_invisible("$plug_file"); + //$s .= bouton_block_invisible("$plug_file"); - $s .= ($actif?"":"").typo($info['nom']).($actif?"":""); + $s .= $nom; $s .= "</div>"; - // TODO : n'afficher que les actifs, les autres en AHAH - if (true - OR $actif - OR _SPIP_AJAX!=1) # va-t-on afficher le bloc ? + // afficher les details d'un plug en secours + if (_request('plug')==$plug_file) $s .= affiche_bloc_plugin($plug_file, $info); return $s; } - -// http://doc.spip.org/@affiche_bloc_plugin -function affiche_bloc_plugin($plug_file, $info) { - $s .= debut_block_invisible("$plug_file"); - $s .= "<div class='detailplugin'>"; - $s .= _T('version') .' '. $info['version'] . " | <strong>$titre_etat</strong><br/>"; - $s .= _T('repertoire_plugins') .' '. $plug_file . "<br/>"; - - if (isset($info['description'])) - $s .= "<hr/>" . propre($info['description']) . "<br/>"; - - if (isset($info['auteur'])) - $s .= "<hr/>" . _T('auteur') .' '. propre($info['auteur']) . "<br/>"; - if (isset($info['lien'])) - $s .= "<hr/>" . _T('info_url') .' '. propre($info['lien']) . "<br/>"; - $s .= "</div>"; - $s .= fin_block(); - - return $s; -} - ?> diff --git a/ecrire/exec/info_plugin.php b/ecrire/exec/info_plugin.php new file mode 100644 index 0000000000..4c5621020b --- /dev/null +++ b/ecrire/exec/info_plugin.php @@ -0,0 +1,13 @@ +<?php + +if (!defined("_ECRIRE_INC_VERSION")) return; + +include_spip('inc/plugin'); + +function exec_info_plugin() { + $plug = _request('plug'); + $info = plugin_get_infos($plug); + ajax_retour(affiche_bloc_plugin($plug_file, $info)); +} + +?> \ No newline at end of file diff --git a/ecrire/inc/plugin.php b/ecrire/inc/plugin.php index b835539725..8fc6c6c227 100644 --- a/ecrire/inc/plugin.php +++ b/ecrire/inc/plugin.php @@ -441,4 +441,47 @@ function verifie_include_plugins() { spip_log("desactivation des plugins suite a suppression du repertoire"); } } + +// http://doc.spip.org/@affiche_bloc_plugin +function affiche_bloc_plugin($plug_file, $info) { + // puce d'etat du plugin + // <etat>dev|experimental|test|stable</etat> + $etat = 'dev'; + if (isset($info['etat'])) + $etat = $info['etat']; + switch ($etat) { + case 'experimental': + $puce = 'puce-rouge.gif'; + $titre_etat = _T('plugin_etat_experimental'); + break; + case 'test': + $puce = 'puce-orange.gif'; + $titre_etat = _T('plugin_etat_test'); + break; + case 'stable': + $puce = 'puce-verte.gif'; + $titre_etat = _T('plugin_etat_stable'); + break; + default: + $puce = 'puce-poubelle.gif'; + $titre_etat = _T('plugin_etat_developpement'); + break; + } + + $s .= "<div class='detailplugin verdana2'>"; + $s .= _T('version') .' '. $info['version'] . " | <strong>$titre_etat</strong><br/>"; + $s .= _T('repertoire_plugins') .' '. $plug_file . "<br/>"; + + if (isset($info['description'])) + $s .= "<hr/>" . propre($info['description']) . "<br/>"; + + if (isset($info['auteur'])) + $s .= "<hr/>" . _T('auteur') .' '. propre($info['auteur']) . "<br/>"; + if (isset($info['lien'])) + $s .= "<hr/>" . _T('info_url') .' '. propre($info['lien']) . "<br/>"; + $s .= "</div>"; + + return $s; +} + ?> -- GitLab