1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
| <!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0">
<meta name="author" content="Daniel Hagnoul">
<title>Forum jQuery</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/headjs/1.0.3/head.min.js"></script>
<link href='http://fonts.googleapis.com/css?family=Sofia|Ubuntu:400|Kreon'>
<script>
"use strict";
var debugBool = true;
/*
* On utilise head.js pour charger JS et CSS de manière asynchrone
* et parallèle, mais on les exécute dans l'ordre.
* Voir la documentation et l'API : http://headjs.com/
* Les polices de caractères et le fichier head.js doivent être
* inclus manuellement.
*/
head.load(
"http://danielhagnoul.developpez.com/styles/dvjhRemBase.css",
"http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/sunny/jquery-ui.min.css",
"http://code.jquery.com/qunit/qunit-1.13.0.css",
{ "d3" : "http://d3js.org/d3.v3.min.js" },
"http://danielhagnoul.developpez.com/lib/dvjh/d3HeadBase.js",
{ "jquery" : "http://code.jquery.com/jquery-2.0.3.min.js" },
{ "jqueryui" : "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js" },
"http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/i18n/jquery-ui-i18n.min.js",
{ "qunit" : "http://code.jquery.com/qunit/qunit-1.13.0.js" }
);
</script>
<style>
/* Nota bene : ici 1 rem est égal à 10 px, voir dvjhRemBase.css */
.qunit { margin-top: 2.4rem; }
/*-- Début code du test --*/
#tableID {
display: none;
}
td, th {
width:5rem;
height:5rem;
text-align:center;
border:1px solid grey;
}
td.rowspan2 {
background-color: yellow;
}
td.colspan2 {
background-color: green;
}
td.rowspan2.colspan2 {
background-color: #FFEBCD;
}
td.colspan3 {
background-color: #ccffcc;
}
td.rowspan5 {
background-color: red;
}
/*-- Fin code du test --*/
</style>
</head>
<body>
<header>
<hgroup>
<h1>Forum jQuery</h1>
<h2>
<a href="">Lien</a>
</h2>
</hgroup>
</header>
<section class="conteneur">
<nav>
<!-- Début code du test -->
<!-- Fin code du test -->
</nav>
<article>
<!-- Début code du test -->
<table id="tableID">
<tbody>
<tr>
<td name="1_1">1_1</td>
<td name="1_2">1_2</td>
<td name="1_3">1_3</td>
<td name="1_4">1_4;</td>
<td name="1_5">1_5</td>
<td name="1_6">1_6</td>
<td name="1_7">1_7</td>
</tr>
<tr>
<td name="2_1">2_1</td>
<td class="rowspan5" name="2_2">2_2 3_2 4_2 5_2 6_2</td>
<td class="red" name="2_3">2_3</td>
<td class="rowspan5" name="2_4">2_4 3_4 4_4 5_4 6_4</td>
<td class="rowspan2 colspan2" name="2_5">2_5 2_6 <br> 3_5 3_6</td>
<td name="2_7">2_7</td>
</tr>
<tr>
<td name="3_1">3_1</td>
<td class="rowspan2" name="3_3">3_3 4_3</td>
<td name="3_7">3_7</td>
</tr>
<tr>
<td name="4_1">4_1</td>
<td class="rowspan2 colspan2" name="4_5">4_5 4_6 <br> 5_5 5_6</td>
<td name="4_7">4_7</td>
</tr>
<tr>
<td name="5_1">5_1</td>
<td class="rowspan2" name="5_3">5_3 6_3</td>
<td name="5_7">5_7</td>
</tr>
<tr>
<td name="6_1">6_1</td>
<td class="colspan2" name="6_5">6_5 6_6</td>
<td name="6_7">6_7</td>
</tr>
<tr>
<td name="7_1">7_1</td>
<td name="7_2">7_2</td>
<td name="7_3">7_3</td>
<td name="7_4">7_4</td>
<td name="7_5">7_5</td>
<td name="7_6">7_6</td>
<td name="7_7">7_7</td>
</tr>
</tbody>
</table>
<!-- Fin code du test -->
</article>
<article class="qunit">
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</article>
</section>
<footer itemscope itemtype="http://danielhagnoul.developpez.com/">
<time datetime="2014-01-09T00:34:22.698+0100" pubdate>2014-01-09T00:34:22.698+0100</time>
<span itemprop="name">Daniel Hagnoul</span>
<a href="http://www.developpez.net/forums/u285162/danielhagnoul/" itemprop="url">@danielhagnoul</a>
<a href="http://danielhagnoul.developpez.com/" itemprop="url">Mon cahier dexercices</a>
<a href="http://javascript.developpez.com/faq/jquery/" itemprop="url">FAQ</a>
<a href="http://javascript.developpez.com/cours/?page=frameworks#jquery" itemprop="url">Tutoriels</a>
</footer>
<script>
"use strict";
/*
* Chargeur de code head.js, document ready et fichiers chargés.
*/
head.ready( [ "d3", "jquery", "jqueryui", "qunit" ], function(){
var ISOformat = d3.time.format( "%Y-%m-%dT%H:%M:%S.%L%Z" );
/* Début code du test */
(function($){
$.fn.spacefrogRule = function(options){
var opts = $.extend({}, $.fn.spacefrogRule.defaults, options);
var rowExp = new RegExp("(" + opts.rowClass + ")(\\d+)", "i");
var colExp = new RegExp("(" + opts.colClass + ")(\\d+)", "i");
return this.each(function(i, item){
$("th", item).each(function(j, jtem){
var str = jtem.className;
var rowrule = rowExp.exec(str);
var colrule = colExp.exec(str);
if (rowrule != null){
jtem.rowSpan = rowrule[2];
}
if (colrule != null){
jtem.colSpan = colrule[2];
}
});
$("td", item).each(function(k, ktem){
var str = ktem.className;
var rowrule = rowExp.exec(str);
var colrule = colExp.exec(str);
if (rowrule != null){
ktem.rowSpan = rowrule[2];
}
if (colrule != null){
ktem.colSpan = colrule[2];
}
});
});
};
$.fn.spacefrogRule.defaults = {
rowClass: "rowspan",
colClass: "colspan"
};
})(jQuery);
$( "#tableID" )
.show()
.spacefrogRule();
/* Fin code du test */
});
</script>
</body>
</html> |
Partager