From 1c04963f3f9d48046a38961660f1e554cf117f9c Mon Sep 17 00:00:00 2001 From: Cerdic <cedric@yterium.com> Date: Sun, 30 Jan 2011 14:27:23 +0000 Subject: [PATCH] nettoyage du head de l'espace prive : ordonner les composants js-inline puis css puis js externe (chargement sans blocage) corrolairement, eviter les appels a jquery dans le js-inline poser les classes no-js, langue et direction sur <html>, un javascript en debut de head remplace no-js par js (nhoizey, selon http://paulirish.com/2009/avoiding-the-fouc-v3/ & modernizr & htmlboilerplate) definir les jeu de classes (tetue) : none, none-js, none-nojs : masque un element (respectivement toujours, en presence de js,en absence de js) hidden, hidden-js, hidden-nojs : passe un element en visibility hidden (respectivement toujours, en presence de js, en absence de js) over, over-js, over-nojs : envoie hors champ un element (respectivement toujours, en presence de js, en absence de js) --- ecrire/inc/commencer_page.php | 21 ++++++++------------- ecrire/inc/lang.php | 8 +++----- ecrire/inc/pipelines_ecrire.php | 8 +++++++- ecrire/inc/presentation_mini.php | 31 ++++++++++++------------------- ecrire/inc/utils.php | 4 ++-- prive/javascript/gadgets.js | 7 +++++-- prive/style_prive.html | 15 +++++++++++++-- 7 files changed, 50 insertions(+), 44 deletions(-) diff --git a/ecrire/inc/commencer_page.php b/ecrire/inc/commencer_page.php index 910782f660..542d746406 100644 --- a/ecrire/inc/commencer_page.php +++ b/ecrire/inc/commencer_page.php @@ -58,19 +58,14 @@ function init_head($titre='', $dummy=0, $minipres=false) { . "<meta http-equiv='Content-Type' content='text/html" . (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') - . "' />\n" - . envoi_link($nom_site_spip,$minipres); - - $head .= " - <script type='text/javascript'><!-- - jQuery(document).ready(function(){ - " . repercuter_gadgets() . ' - }); - var style = document.createElement("style"); - style.innerHTML = ".jsnone {display:none;}"; - document.getElementsByTagName("head")[0].appendChild(style); - // --></script> - '; + . "' />\n"; + + $head .= "<script type='text/javascript'>/*<![CDATA[*/\n" + ."var url_menu_rubrique='./?exec=menu_rubriques\\x26date=" . $GLOBALS['meta']['date_calcul_rubriques']."';\n" + ."(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement);\n" + ."/*]]>*/</script>\n"; + $head .= envoi_link($nom_site_spip,$minipres); + return pipeline('header_prive', $head); } diff --git a/ecrire/inc/lang.php b/ecrire/inc/lang.php index bb2c120182..f74490c876 100644 --- a/ecrire/inc/lang.php +++ b/ecrire/inc/lang.php @@ -349,11 +349,9 @@ function init_langues() { // http://doc.spip.org/@html_lang_attributes function html_lang_attributes() { - return "<html xmlns='http://www.w3.org/1999/xhtml' lang='" - . $GLOBALS['spip_lang'] - . "' dir='" - . ($GLOBALS['spip_lang_rtl'] ? 'rtl' : 'ltr') - . "'>\n" ; + $lang = $GLOBALS['spip_lang']; + $dir = ($GLOBALS['spip_lang_rtl'] ? 'rtl' : 'ltr'); + return "<html class='$dir $lang no-js' xmlns='http://www.w3.org/1999/xhtml' lang='$lang' dir='$dir'>\n" ; } init_langues(); utiliser_langue_site(); diff --git a/ecrire/inc/pipelines_ecrire.php b/ecrire/inc/pipelines_ecrire.php index 8e7fe77903..6df0d09b40 100644 --- a/ecrire/inc/pipelines_ecrire.php +++ b/ecrire/inc/pipelines_ecrire.php @@ -28,7 +28,13 @@ function f_jQuery_prive ($texte) { ))) as $script) if ($script = find_in_path($script)) $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; - $texte = $x.$texte; + // inserer avant le premier script externe ou a la fin + if (preg_match(",<script[^><]*src=,",$texte,$match) + AND $p = strpos($texte,$match[0])){ + $texte = substr_replace($texte,$x,$p,0); + } + else + $texte .= $x; return $texte; } diff --git a/ecrire/inc/presentation_mini.php b/ecrire/inc/presentation_mini.php index 4bb91c81aa..6fd772ff89 100644 --- a/ecrire/inc/presentation_mini.php +++ b/ecrire/inc/presentation_mini.php @@ -87,10 +87,6 @@ function envoi_link($nom_site_spip, $minipres=false) { // CSS espace prive : la vraie . '<link rel="stylesheet" type="text/css" href="' . generer_url_public('style_prive', $paramcss) .'" />' . "\n" - . "<!--[if lt IE 8]>\n" - . '<link rel="stylesheet" type="text/css" href="' - . generer_url_public('style_prive_ie', $paramcss) .'" />' . "\n" - . "<![endif]-->\n" // CSS optionelle minipres . ($minipres?'<link rel="stylesheet" type="text/css" href="' @@ -103,9 +99,7 @@ function envoi_link($nom_site_spip, $minipres=false) { . url_absolue($favicon) . "\" type='image/x-icon' />\n"; - $js = debut_javascript(); - - if ($spip_display == 4) return $res . $js; + list($inlinejs,$js) = debut_javascript(); $nom = entites_html($nom_site_spip); @@ -121,7 +115,7 @@ function envoi_link($nom_site_spip, $minipres=false) { . " ("._T("info_breves_03") . ")\" href='" . generer_url_public('backend-breves') . "' />\n"; - return $res . $js; + return $inlinejs . $res . $js; } // http://doc.spip.org/@debut_javascript @@ -148,13 +142,11 @@ function debut_javascript() if (!defined('_LARGEUR_ICONES_BANDEAU')) include_spip('inc/bandeau'); - return - // envoi le fichier JS de config si browser ok. - $GLOBALS['browser_layer'] . - http_script( - ((isset($_COOKIE['spip_accepte_ajax']) && $_COOKIE['spip_accepte_ajax'] >= 1) + return array( + "<script type='text/javascript'>/*<![CDATA[*/" + .((isset($_COOKIE['spip_accepte_ajax']) && $_COOKIE['spip_accepte_ajax'] >= 1) ? '' - : "jQuery.ajax({'url':'$testeur'});") . + : "\nfunction test_accepte_ajax(){jQuery.ajax({'url':'$testeur'});}") . (_OUTILS_DEVELOPPEURS ?"var _OUTILS_DEVELOPPEURS=true;":"") . "\nvar ajax_image_searching = \n'<img src=\"".url_absolue(chemin_image("searching.gif"))."\" alt=\"\" />';" . "\nvar stat = " . (($GLOBALS['meta']["activer_statistiques"] != 'non') ? 1 : 0) . @@ -167,11 +159,12 @@ function debut_javascript() ($browser_version >= 6))) ? 1 : 0) . "\nvar confirm_changer_statut = '" . unicode_to_javascript(addslashes(html2unicode(_T("confirm_changer_statut")))) . - "';\n") . - //plugin needed to fix the select showing through the submenus o IE6 - (($browser_name == "MSIE" && $browser_version <= 6) ? http_script('', 'bgiframe.js'):'' ) . - http_script('', 'presentation.js') . - http_script('', 'gadgets.js'); + "';\n/*]]>*/</script>\n", + // envoi le fichier JS de config si browser ok. + $GLOBALS['browser_layer'] . + http_script('', 'presentation.js') . + http_script('', 'gadgets.js') + ); } // diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index c901a4de5c..52b5c350f5 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -605,9 +605,9 @@ function http_script($script, $src='', $noscript='') { } else $src = ''; if ($script) - $script = ("<!--\n" . + $script = ("/*<![CDATA[*/\n" . preg_replace(',</([^>]*)>,','<\/\1>', $script) . - "\n//-->\n"); + "/*]]>*/"); if ($noscript) $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; diff --git a/prive/javascript/gadgets.js b/prive/javascript/gadgets.js index c95d9e1e16..b5271424ed 100644 --- a/prive/javascript/gadgets.js +++ b/prive/javascript/gadgets.js @@ -1,8 +1,8 @@ -function init_gadgets(url_toutsite,url_navrapide,url_agenda,html_messagerie){ +function init_gadgets(){ jQuery('#boutonbandeautoutsite').one('mouseover',function(){ jQuery(this).siblings('ul').animeajax(); jQuery.ajax({ - url: url_toutsite, + url: url_menu_rubrique, success: function(c){ jQuery('#boutonbandeautoutsite').siblings('ul').remove(); jQuery('#boutonbandeautoutsite') @@ -17,6 +17,7 @@ function focus_zone(selecteur){ return false; } jQuery(document).ready(function(){ + init_gadgets(); var is_open = 0; jQuery.fn.menuItemOpen = function(){ jQuery(this) @@ -103,4 +104,6 @@ jQuery(document).ready(function(){ .blur(function(){ jQuery('#bando_liens_rapides').removeClass('actif'); }); + if (typeof window.test_accepte_ajax != "undefined") + test_accepte_ajax(); }); diff --git a/prive/style_prive.html b/prive/style_prive.html index ca1a05760a..bfb0a5367c 100644 --- a/prive/style_prive.html +++ b/prive/style_prive.html @@ -37,8 +37,10 @@ body { font-size:0.625em; font-family: Verdana, Geneva, Sans, sans-serif; } .nettoyeur { clear: both; height: 0; margin: 0; padding: 0; border: 0; line-height: 1px; font-size: 1px; } /* Non visible a l'ecran */ -.invisible { position: absolute; top: -3000em; height: 1%; } -.none { display: none; } +.none,.js .none-js,.no-js .none-nojs { display: none; } +.hidden,.js .hidden-js,.no-js .hidden-nojs {visibility:hidden;} +.invisible, /* compat */ +.over,.js .over-js,.no-js .over-nojs { position: absolute; left: -3000em; height: 1%; } /* ajax */ .image_loading {float:#GET{right};} @@ -76,6 +78,15 @@ body.edition .large #extra, .breves_edit .large #extra, .rubriques_edit .large #extra {width:140px;} +/*fix all layout problems of IE6 and IE7*/ +.lte7 .cadre, +.lte7 .fiche_objet, /*title not visible*/ +.lte7 .ajax-action, /*containers of expandible boxes go mad*/ +.lte7 .tabs-container, /*containers of expandible boxes go mad*/ +.lte7 #portfolio, +.lte7 #documents {zoom:1} + + /* style par defaut sur les tables. selecteur generique pour avoir une faible priorite */ table { border-collapse: collapse; /* equivalent a cellspacing=0 */ -- GitLab