Déplacement des fichiers statiques

Les CSS, JS et Images sont désormais dans des dossiers
`$app/static/{css/js/images}` où `$app` désigne l'application qui les utilise,
en l'occurrence `gestioncof`, `bda`, `bda2` et `bda3`.
This commit is contained in:
Martin Pépin 2016-05-26 00:57:22 +02:00
parent 35d46d449d
commit af6f56e250
17 changed files with 20 additions and 0 deletions

View file

@ -0,0 +1,635 @@
html,body {
}
@font-face {
font-family: 'Droid Serif';
font-style: normal;
font-weight: bold;
src: local('Droid Serif Bold'), local('DroidSerif-Bold'), url('droidserif.woff') format('woff');
}
.spacer {
clear: both;
}
a:link, a:active, a:visited {
color: #111;
background: transparent;
}
a:hover {
color: #444;
background: transparent;
}
form#profile table {
border-collapse: collapse;
}
table#bda_formset {
width: 100%;
}
.bda-field-spectacle select {
width: 96%;
margin: 0 2%;
}
.bda-field-double_choice select {
width: 94%;
margin: 0 3%;
}
.bda-field-double, .bda-field-autoquit, .bda-field-priority {
text-align: center;
}
.bda-field-double {
width: 15%;
}
.bda-field-autoquit {
width: 15%;
}
.tools-cell {
width: 32px;
}
.tools {
width: 32px;
}
.tools a.icon.drag-handler, .tools a.icon.delete-handler {
float: left;
}
.tools a.icon.drag-handler {
margin-right: 5px;
}
form#bda_form p {
font-size: 0.8em;
}
table#bda_formset {
border-spacing: 0px 5px;
}
tbody.bda_formset_content {
}
tr.dynamic-form td {
border-width: 1px 1px 1px 0px;
border-style: solid;
border-color: #888;
background: #EEE;
}
tr.dynamic-form td:first-child {
border-left-width: 1px;
}
tr.dynamic-form.predelete td {
background-color: #FFECEC;
border-width: 1px 1px 1px 0px;
border-style: solid;
border-color: #CCC;
}
tr.dynamic-form.predelete td:first-child {
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
border: 1px solid #CCC;
}
tr.dynamic-form.predelete td:last-child {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
.ui-sortable-helper {
}
tr.ui-sortable-placeholder td, .placeholder-cell {
background: transparent;
border-width: 1px 1px 1px 0px;
border-style: solid;
border-color: #CCC;
}
tr.ui-sortable-placeholder td:first-child {
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
border: 1px solid #CCC;
}
tr.ui-sortable-placeholder td:last-child {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
form {
padding: 0;
}
#form-placeholder {
margin-top: 15px;
}
#form-placeholder form#profile {
margin-top: 10px;
}
form#profile table td, form#profile table th {
width: 400px;
}
form#profile table th {
text-align: right;
}
fieldset {
border: 0;
margin: 0;
padding: 0;
float: left;
clear: none;
width: auto;
}
fieldset legend {
display: none;
}
#main-login-container {
width: 500px;
margin: 7em auto;
}
#main-login {
width: 500px;
border: 15px solid #333;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}
#main-container {
max-width: 95%;
width: 1000px;
margin: 7em auto;
display: block;
}
#main {
border: 15px solid #333;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
padding: 2em;
box-shadow: 0 0 100px #AAA inset;
}
#main #main-content {
font-size: 1.25em;
margin-top: 10px;
}
#main #main-content ul {
line-height: 1.3em;
}
#main h1 {
font-size: 3em;
}
#main h1 a {
color: #333;
text-decoration: none;
}
#main h2 {
font-size: 1.5em;
margin-bottom: 10px;
}
#main h3 {
font-size: 1.3em;
margin-top: 5px;
}
#main h4 {
margin-top: 10px;
font-weight: bold;
}
#main p {
margin-top: 8px;
margin-bottom: 8px;
}
#main form li {
list-style: none;
}
.success {
font-weight: bold;
color: #00B000;
background-color: transparent;
}
.error {
font-weight: bold;
color: #B00000;
background-color: transparent;
}
#main form ul.errorlist li {
font-weight: bold;
color: #B00000;
background-color: transparent;
list-style: disc;
}
form#bda_form ul.errorlist li {
padding-left: 0px;
list-style: none;
}
#main-login.login_block {
padding: 2em;
box-shadow: 0 0 100px #AAA inset;
}
a#login_clipper, a#login_outsider {
float: left;
display: block;
width: 250px;
height: 200px;
text-align: center;
font-family: 'Droid Serif', serif;
font-size: 2em;
font-weight: bold;
line-height: 190px;
text-decoration: none;
color: #FFF;
}
a#login_clipper {
background-color: #123E96;
box-shadow: 0 0 100px #040C78 inset;
}
a#login_clipper:hover {
background-color: #164BB6;
}
a#login_outsider {
background-color: #961221;
box-shadow: 0 0 100px #780411 inset;
}
a#login_outsider:hover {
background-color: #B31729;
}
#main-login label {
font-size: 11px;
}
#main-login label span.accesskey {
text-decoration: underline;
}
#main-login input {
letter-spacing: 1px;
}
#main-login .btn-row {
float: right;
}
.btn-submit, .btn-addmore {
float: none;
clear: none;
display: inline;
letter-spacing: 0;
color: #333;
padding: 5px;
text-transform: uppercofe;
font-variant: small-caps;
border: 1px solid #ccc;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EEE), to(#CCC));
background: -moz-linear-gradient(19% 75% 90deg,#EEE, #CCC);
background: linear-gradient(center top, #EEE, #CCC);
}
#main-login .btn-reset {
float: none;
clear: none;
margin-left: 5px;
border: 0;
border-left: 1px solid #ddd;
background: transparent;
color: #777;
text-transform: lowercase;
letter-spacing: 0;
}
/* RESET --------------------------------- */
/* reset some properties for elements since defaults are not crossbrowser - http: //meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ */
html,body,div,span,h1,h2,h3,h4,p,a,img,ul,li,fieldset,form,label,legend {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
font-family: inherit;
vertical-align: baseline;
}
:focus {
outline: 0;
}
ul {
font-size: 1.1em;
padding: 6px 0 6px 12px;
}
body {
font: normal 400 62.5%/1.0 Verdana, sans-serif;
background-color: #eee;
color: #333;
}
/* HEADER --------------------------------- */
#header h1 {
font-family: 'Droid Serif', serif;
font-weight: bold;
font-size: 18px;
margin-bottom: 5px;
float: left;
}
#main-login #header h1 {
float: none;
}
#header #homelink {
float: right;
}
tt {
font-weight: bold;
}
.error {
color: #BB0000;
background-color: transparent;
}
/* FORMS --------------------------------- */
#main-login input {
border-width: 1px;
font-family: Verdana,sans-serif;
font-size: 1.1em;
color: #000;
padding: 3px;
min-height: 1.5em;
}
#main-login input[type="text"], #main-login input[type=password] {
border: 2px solid #888;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
box-shadow: 0 0 12px #AAA inset;
min-height: 2em;
}
input[disabled], input[readonly] {
color: #BBB;
}
input[type="text"], input[type=password] {
border: 1px solid #888;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
box-shadow: 0 0 3px #AAA inset;
padding: 0px 2px 0px 2px;
}
input#search_autocomplete {
width: 600px;
font-size: 14px;
height: 20px;
padding: 10px 8px;
margin: 0 auto;
display: block;
color: #aaa;
}
input#search_autocomplete:focus {
font-size: 18px;
color: #343a4a;
}
.autocomplete {margin-bottom:5px;}
.yourlabs-autocomplete ul {list-style-type: none; padding: 0; margin: 0; font-size: 1.5em;}
.yourlabs-autocomplete li {padding: 6px 5px; display: block;}
.yourlabs-autocomplete li a {text-decoration: none;}
.yourlabs-autocomplete li a span.highlight {text-decoration: underline; font-weight: bold;}
.yourlabs-autocomplete li.autocomplete-header {background-color: #FFEF9E; padding: 3px 5px; color: #000;}
.yourlabs-autocomplete li.autocomplete-value {cursor: pointer;}
.yourlabs-autocomplete li.hilight {background-color: #EA4839; color: #FFF; }
.yourlabs-autocomplete li.hilight a {color: #FFF; }
.yourlabs-autocomplete { border: none; background: none; }
.yourlabs-autocomplete.outer-container { position: relative; }
.yourlabs-autocomplete.inner-container { position: absolute; left: -1px; top: 2px; border: 1px solid #B7B7B7; width: 618px; background: #fff; }
.yourlabs-autocomplete.inner-container { margin: 0; padding: 0; overflow-x: hidden; overflow-y: auto; position: relative; list-style-type: none; }
hr {
border: 0;
height: 1px;
background: #333;
background: -webkit-gradient(linear, left top, right top, color-stop(0%,hsla(0,0%,70%,0)), color-stop(50%,hsla(0,0%,70%,.75)), color-stop(100%,hsla(0,0%,70%,0)));
background: -webkit-linear-gradient(left, hsla(0,0%,70%,0) 0%, hsla(0,0%,70%,.75) 50%, hsla(0,0%,70%,0) 100%);
background: -moz-linear-gradient(left, hsla(0,0%,70%,0) 0%, hsla(0,0%,70%,.75) 50%, hsla(0,0%,70%,0) 100%);
background: -ms-linear-gradient(left, hsla(0,0%,70%,0) 0%, hsla(0,0%,70%,.75) 50%, hsla(0,0%,70%,0) 100%);
background: -o-linear-gradient(left, hsla(0,0%,70%,0) 0%, hsla(0,0%,70%,.75) 50%, hsla(0,0%,70%,0) 100%);
background: linear-gradient(left, hsla(0,0%,70%,0) 0%, hsla(0,0%,70%,.75) 50%, hsla(0,0%,70%,0) 100%);
}
.tristate:hover {
cursor: pointer;
}
abbr[title] {
cursor: help;
border-bottom: 1px dotted #999999;
}
abbr.initialism {
font-size: 90%;
text-transform: uppercase;
}
blockquote {
padding: 0 0 0 15px;
margin: 0 0 20px;
border-left: 5px solid #eeeeee;
}
blockquote p {
margin-bottom: 0;
font-size: 16px;
font-weight: 300;
line-height: 25px;
}
blockquote small {
display: block;
line-height: 20px;
color: #999999;
}
blockquote small:before {
content: '\2014 \00A0';
}
blockquote.pull-right {
float: right;
padding-right: 15px;
padding-left: 0;
border-right: 5px solid #eeeeee;
border-left: 0;
}
blockquote.pull-right p,
blockquote.pull-right small {
text-align: right;
}
blockquote.pull-right small:before {
content: '';
}
blockquote.pull-right small:after {
content: '\00A0 \2014';
}
q:before,
q:after,
blockquote:before,
blockquote:after {
content: "";
}
address {
display: block;
margin-bottom: 20px;
font-style: normal;
line-height: 20px;
}
code,
pre {
padding: 0 3px 2px;
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
font-size: 12px;
color: #333333;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
code {
padding: 2px 4px;
color: #d14;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
}
pre {
display: block;
padding: 9.5px;
margin: 0 0 10px;
font-size: 13px;
line-height: 20px;
word-break: break-all;
word-wrap: break-word;
white-space: pre;
white-space: pre-wrap;
background-color: #f5f5f5;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.15);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
pre.prettyprint {
margin-bottom: 20px;
}
pre code {
padding: 0;
color: inherit;
background-color: transparent;
border: 0;
}
.pre-scrollable {
max-height: 340px;
overflow-y: scroll;
}
/* Louis pour etat places*/
.etat-bda td {
border:1px solid #666;
padding:4px;
}
.etat-bda tr:nth-child(even) {background: #CCC}
.greenratio {
background-color: #3F3;
border: 5px solid #ccc;
border: 5px solid rgba(0, 0, 0, 0.15);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.orangeratio {
background-color: #FF3;
border: 5px solid #ccc;
border: 5px solid rgba(0, 0, 0, 0.15);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.redratio {
background-color: #F33;
border: 5px solid #ccc;
border: 5px solid rgba(0, 0, 0, 0.15);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
th[data-sort]{
cursor:pointer;
}
tr.awesome{
color: red;
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

View file

@ -0,0 +1,19 @@
Copyright (c) 2012 Joseph McCullough
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,166 @@
Stupid jQuery Table Sort
========================
This is a stupid jQuery table sorting plugin. Nothing fancy, nothing really
impressive. Overall, stupidly simple.
[View the demo here][0]
See the example.html document to see how to implement it.
Example Usage
-------------
The JS:
$("table").stupidtable();
The HTML:
<table>
<thead>
<tr>
<th data-sort="int">int</th>
<th data-sort="float">float</th>
<th data-sort="string">string</th>
</tr>
</thead>
<tbody>
<tr>
<td>15</td>
<td>-.18</td>
<td>banana</td>
</tr>
...
...
...
The thead and tbody tags must be used.
Add a `data-sort` attribute of "DATATYPE" to the th elements to make them sortable
by that data type. If you don't want that column to be sortable, just omit the
`data-sort` attribute.
Predefined data types
---------------------
Our aim is to keep this plugin as lightweight as possible. Consequently, the
only predefined datatypes that you can pass to the th elements are
* `int`
* `float`
* `string` (case-sensitive)
* `string-ins` (case-insensitive)
These data types will be sufficient for many simple tables. However, if you need
different data types for sorting, you can easily create your own!
Creating your own data types
----------------------------
Creating your own data type for sorting purposes is easy as long as you are
comfortable using custom functions for sorting. Consult [Mozilla's Docs][1]
if you're not.
Let's create an alphanum datatype for a User ID that takes strings in the
form "D10", "A40", and sorts them based on the number.
<thead>
<tr>
<th data-sort="string">Name</th>
<th data-sort="int">Age</th>
<th data-sort="alphanum">UserID</th>
</tr>
</thead>
<tbody>
<tr>
<td>Joseph McCullough</td>
<td>20</td>
<td>D10</td>
</tr>
<tr>
<td>Justin Edwards</td>
<td>29</td>
<td>A40</td>
</tr>
...
...
...
Now we need to specify how the **alphanum** type will be sorted. To do that,
we do the following:
$("table").stupidtable({
"alphanum":function(a,b){
var pattern = "^[A-Z](\\d+)$";
var re = new RegExp(pattern);
var aNum = re.exec(a).slice(1);
var bNum = re.exec(b).slice(1);
return parseInt(aNum,10) - parseInt(bNum,10);
}
});
This extracts the integers from the cell and compares them in the style
that sort functions use.
Callbacks
---------
To execute a callback function after a table column has been sorted, you can
bind on `aftertablesort`.
var table = $("table").stupidtable();
table.bind('aftertablesort', function (event, data) {
// data.column - the index of the column sorted after a click
// data.direction - the sorting direction (either asc or desc)
// $(this) - this table object
console.log("The sorting direction: " + data.direction);
console.log("The column index: " + data.column);
});
Similarly, to execute a callback before a table column has been sorted, you can
bind on `beforetablesort`.
See the complex_example.html file.
Data with multiple representations/predefined order
---------------------------------------------------
Often we find two distinct ways of offering data: In a machine friendly way,
and a Human-friendly way. A clear example is a Timestamp. Additionally,
arbitrary data values may already have a predefined sort order. In either case,
it's to our advantage to have a way to store the "sortable data" while letting
the viewer see the Human-friendly representation of that data. While the
purpose of the custom sort methods is to take data and make it sortable
(machine friendly), sometimes this is too hard or too expensive, computationally
speaking.
To solve this problem, you can specify a `data-sort-value` attribute to
table cells, and the attribute value will be the basis of the sort as opposed
to the text value of the table cell. See the complex_example.html file, where
we sort a column of letters based not on their alphabetical order, but by their
frequency in the English language. You'll still need to specify a sort type
or come up with your own custom sort function, but the presence of the
`data-sort-value` attribute tells the plugin to use the value of the
attribute as the basis of the sort.
License
-------
The Stupid jQuery Plugin is licensed under the MIT license. See the LICENSE
file for full details.
[0]: http://joequery.github.com/Stupid-Table-Plugin/
[1]: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/sort

View file

@ -0,0 +1,77 @@
<!DOCTYPE html>
<html>
<head>
<title>Stupid jQuery table sort</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../stupidtable.js?dev"></script>
<script>
$(function(){
$("table").stupidtable();
});
</script>
<style type="text/css">
table {
border-collapse: collapse;
}
th, td {
padding: 5px 10px;
border: 1px solid #999;
}
th {
background-color: #eee;
}
th[data-sort]{
cursor:pointer;
}
tr.awesome{
color: red;
}
</style>
</style>
</head>
<body>
<h1>Stupid jQuery table sort!</h1>
<p>This example shows how a sortable table can be implemented with very little configuration. Simply specify the data type on a <code>&lt;th&gt;</code> element using the <code>data-sort</code> attribute, and the plugin handles the rest.</p>
<table>
<thead>
<tr>
<th data-sort="int">int</th>
<th data-sort="float">float</th>
<th data-sort="string">string</th>
</tr>
</thead>
<tbody>
<tr>
<td>15</td>
<td>-.18</td>
<td>banana</td>
</tr>
<tr class="awesome">
<td>95</td>
<td>36</td>
<td>coke</td>
</tr>
<tr>
<td>2</td>
<td>-152.5</td>
<td>apple</td>
</tr>
<tr>
<td>-53</td>
<td>88.5</td>
<td>zebra</td>
</tr>
<tr>
<td>195</td>
<td>-858</td>
<td>orange</td>
</tr>
</tbody>
</table>
</body>
</html>

View file

@ -0,0 +1,70 @@
<!DOCTYPE html>
<html>
<head>
<title>Stupid jQuery table sort (colspan test)</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../stupidtable.js?dev"></script>
<script>
$(function(){
$("table").stupidtable();
});
</script>
<style type="text/css">
table {
border-collapse: collapse;
}
th, td {
padding: 5px 10px;
border: 1px solid #999;
}
th {
background-color: #eee;
}
th[data-sort]{
cursor:pointer;
}
tr.awesome{
color: red;
}
</style>
</style>
</head>
<body>
<h1>Stupid jQuery table sort! (colspan test)</h1>
<p>Tables using colspans are handled just fine.</p>
<table id="stupid">
<thead>
<tr>
<th data-sort="string">Letter</td>
<th colspan="2" data-sort="string">colspan=2</th>
<th data-sort="int">Number</td>
</tr>
</thead>
<tbody>
<tr>
<td>def</td>
<td>X</td>
<td>9</td>
<td>1</td>
</tr>
<tr>
<td>abc</td>
<td>Z</td>
<td>8</td>
<td>2</td>
</tr>
<tr>
<td>bcd</td>
<td>Y</td>
<td>7</td>
<td>0</td>
</tr>
</tbody>
</table>
</body>
</html>

View file

@ -0,0 +1,183 @@
<!DOCTYPE html>
<html>
<head>
<title>Stupid jQuery table sort (complex example)</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../stupidtable.js?dev"></script>
<script>
$(function(){
// Helper function to convert a string of the form "Mar 15, 1987" into
// a Date object.
var date_from_string = function(str){
var months = ["jan","feb","mar","apr","may","jun","jul",
"aug","sep","oct","nov","dec"];
var pattern = "^([a-zA-Z]{3})\\s*(\\d{2}),\\s*(\\d{4})$";
var re = new RegExp(pattern);
var DateParts = re.exec(str).slice(1);
var Year = DateParts[2];
var Month = $.inArray(DateParts[0].toLowerCase(), months);
var Day = DateParts[1];
return new Date(Year, Month, Day);
}
var moveBlanks = function(a, b) {
if ( a < b ){
if (a == "")
return 1;
else
return -1;
}
if ( a > b ){
if (b == "")
return -1;
else
return 1;
}
return 0;
};
var moveBlanksDesc = function(a, b) {
// Blanks are by definition the smallest value, so we don't have to
// worry about them here
if ( a < b )
return 1;
if ( a > b )
return -1;
return 0;
};
var table = $("table").stupidtable({
"date":function(a,b){
// Get these into date objects for comparison.
aDate = date_from_string(a);
bDate = date_from_string(b);
return aDate - bDate;
},
"moveBlanks": moveBlanks,
"moveBlanksDesc": moveBlanksDesc,
});
table.on("beforetablesort", function (event, data) {
// data.column - the index of the column sorted after a click
// data.direction - the sorting direction (either asc or desc)
$("#msg").text("Sorting index " + data.column)
});
table.on("aftertablesort", function (event, data) {
var th = $(this).find("th");
th.find(".arrow").remove();
var dir = $.fn.stupidtable.dir;
var arrow = data.direction === dir.ASC ? "&uarr;" : "&darr;";
th.eq(data.column).append('<span class="arrow">' + arrow +'</span>');
});
$("tr").slice(1).click(function(){
$(".awesome").removeClass("awesome");
$(this).addClass("awesome");
});
});
</script>
<style type="text/css">
table {
border-collapse: collapse;
}
th, td {
padding: 5px 10px;
border: 1px solid #999;
}
th {
background-color: #eee;
}
th[data-sort]{
cursor:pointer;
}
tr.awesome{
color: red;
}
#msg {
color: green;
}
</style>
</head>
<body>
<h1>Stupid jQuery table sort! (complex example)</h1>
<p>This example showcases several of the more advanced features, including specifying sort values, custom data types and callbacks. View the source of this file or see the <a href="http://joequery.github.com/Stupid-Table-Plugin/">documentation</a> for more details on how to implement them.</p>
<p id="msg">&nbsp;</p>
<table>
<thead>
<tr>
<th data-sort="int">int</th>
<th data-sort="int">int</th>
<th data-sort="float">float</th>
<th data-sort="moveBlanks" data-sort-desc="moveBlanksDesc">string</th>
<th data-sort="string-ins">case</th>
<th>Can't sort me!</th>
<th data-sort="date">date</th>
<th data-sort="int">Letter frequency</th>
</tr>
</thead>
<tbody>
<tr>
<td>15</td>
<td>15</td>
<td>-.18</td>
<td>banana</td>
<td>Homer</td>
<td>arbitrary</td>
<td>Sep 15, 2002</td>
<td data-sort-value="0">E</td>
</tr>
<tr class="awesome">
<td>95</td>
<td>95</td>
<td>36</td>
<td></td>
<td>purple</td>
<td>pointless</td>
<td>Aug 07, 2004</td>
<td data-sort-value="1">T</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>-152.5</td>
<td></td>
<td>is</td>
<td>silly</td>
<td>Mar 15, 1986</td>
<td data-sort-value="2">A</td>
</tr>
<tr>
<td>-53</td>
<td>-53</td>
<td>88.5</td>
<td>hello</td>
<td>a</td>
<td>eccentric</td>
<td>Feb 27, 2086</td>
<td data-sort-value="3">O</td>
</tr>
<tr>
<td>195</td>
<td>195</td>
<td>-858</td>
<td>orange</td>
<td>fruit</td>
<td>garbage</td>
<td>Mar 15, 1986</td>
<td data-sort-value="4">I</td>
</tr>
</tbody>
</table>
</body>
</html>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,158 @@
// Stupid jQuery table plugin.
// Call on a table
// sortFns: Sort functions for your datatypes.
(function($) {
$.fn.stupidtable = function(sortFns) {
return this.each(function() {
var $table = $(this);
sortFns = sortFns || {};
// ==================================================== //
// Utility functions //
// ==================================================== //
// Merge sort functions with some default sort functions.
sortFns = $.extend({}, $.fn.stupidtable.default_sort_fns, sortFns);
// Return the resulting indexes of a sort so we can apply
// this result elsewhere. This returns an array of index numbers.
// return[0] = x means "arr's 0th element is now at x"
var sort_map = function(arr, sort_function, reverse_column) {
var map = [];
var index = 0;
if (reverse_column) {
for (var i = arr.length-1; i >= 0; i--) {
map.push(i);
}
}
else {
var sorted = arr.slice(0).sort(sort_function);
for (var i=0; i<arr.length; i++) {
index = $.inArray(arr[i], sorted);
// If this index is already in the map, look for the next index.
// This handles the case of duplicate entries.
while ($.inArray(index, map) != -1) {
index++;
}
map.push(index);
}
}
return map;
};
// Apply a sort map to the array.
var apply_sort_map = function(arr, map) {
var clone = arr.slice(0),
newIndex = 0;
for (var i=0; i<map.length; i++) {
newIndex = map[i];
clone[newIndex] = arr[i];
}
return clone;
};
// ==================================================== //
// Begin execution! //
// ==================================================== //
// Do sorting when THs are clicked
$table.on("click", "th", function() {
var trs = $table.children("tbody").children("tr");
var $this = $(this);
var th_index = 0;
var dir = $.fn.stupidtable.dir;
$table.find("th").slice(0, $this.index()).each(function() {
var cols = $(this).attr("colspan") || 1;
th_index += parseInt(cols,10);
});
// Determine (and/or reverse) sorting direction, default `asc`
var sort_dir = $this.data("sort-dir") === dir.ASC ? dir.DESC : dir.ASC;
// Choose appropriate sorting function. If we're sorting descending, check
// for a `data-sort-desc` attribute.
if ( sort_dir == dir.DESC )
var type = $this.data("sort-desc") || $this.data("sort") || null;
else
var type = $this.data("sort") || null;
// Prevent sorting if no type defined
if (type === null) {
return;
}
// Trigger `beforetablesort` event that calling scripts can hook into;
// pass parameters for sorted column index and sorting direction
$table.trigger("beforetablesort", {column: th_index, direction: sort_dir});
// More reliable method of forcing a redraw
$table.css("display");
// Run sorting asynchronously on a timout to force browser redraw after
// `beforetablesort` callback. Also avoids locking up the browser too much.
setTimeout(function() {
// Gather the elements for this column
var column = [];
var sortMethod = sortFns[type];
// Push either the value of the `data-order-by` attribute if specified
// or just the text() value in this column to column[] for comparison.
trs.each(function(index,tr) {
var $e = $(tr).children().eq(th_index);
var sort_val = $e.data("sort-value");
var order_by = typeof(sort_val) !== "undefined" ? sort_val : $e.text();
column.push(order_by);
});
// Create the sort map. This column having a sort-dir implies it was
// the last column sorted. As long as no data-sort-desc is specified,
// we're free to just reverse the column.
var reverse_column = !!$this.data("sort-dir") && !$this.data("sort-desc");
var theMap = sort_map(column, sortMethod, reverse_column);
// Reset siblings
$table.find("th").data("sort-dir", null).removeClass("sorting-desc sorting-asc");
$this.data("sort-dir", sort_dir).addClass("sorting-"+sort_dir);
// Replace the content of tbody with the sortedTRs. Strangely (and
// conveniently!) enough, .append accomplishes this for us.
var sortedTRs = $(apply_sort_map(trs, theMap));
$table.children("tbody").append(sortedTRs);
// Trigger `aftertablesort` event. Similar to `beforetablesort`
$table.trigger("aftertablesort", {column: th_index, direction: sort_dir});
// More reliable method of forcing a redraw
$table.css("display");
}, 10);
});
});
};
// Enum containing sorting directions
$.fn.stupidtable.dir = {ASC: "asc", DESC: "desc"};
$.fn.stupidtable.default_sort_fns = {
"int": function(a, b) {
return parseInt(a, 10) - parseInt(b, 10);
},
"float": function(a, b) {
return parseFloat(a) - parseFloat(b);
},
"string": function(a, b) {
if (a < b) return -1;
if (a > b) return +1;
return 0;
},
"string-ins": function(a, b) {
a = a.toLowerCase();
b = b.toLowerCase();
if (a < b) return -1;
if (a > b) return +1;
return 0;
}
};
})(jQuery);

View file

@ -0,0 +1,3 @@
(function(d){d.fn.stupidtable=function(b){return this.each(function(){var a=d(this);b=b||{};b=d.extend({},d.fn.stupidtable.default_sort_fns,b);a.on("click","th",function(){var n=a.children("tbody").children("tr"),e=d(this),j=0,m=d.fn.stupidtable.dir;a.find("th").slice(0,e.index()).each(function(){var a=d(this).attr("colspan")||1;j+=parseInt(a,10)});var l=e.data("sort-dir")===m.ASC?m.DESC:m.ASC,p=l==m.DESC?e.data("sort-desc")||e.data("sort")||null:e.data("sort")||null;null!==p&&(a.trigger("beforetablesort",
{column:j,direction:l}),a.css("display"),setTimeout(function(){var k=[],c=b[p];n.each(function(a,b){var c=d(b).children().eq(j),e=c.data("sort-value"),c="undefined"!==typeof e?e:c.text();k.push(c)});var f=[],g=0;if(e.data("sort-dir")&&!e.data("sort-desc"))for(c=k.length-1;0<=c;c--)f.push(c);else for(var h=k.slice(0).sort(c),c=0;c<k.length;c++){for(g=d.inArray(k[c],h);-1!=d.inArray(g,f);)g++;f.push(g)}a.find("th").data("sort-dir",null).removeClass("sorting-desc sorting-asc");e.data("sort-dir",l).addClass("sorting-"+
l);g=n.slice(0);for(h=c=0;h<f.length;h++)c=f[h],g[c]=n[h];f=d(g);a.children("tbody").append(f);a.trigger("aftertablesort",{column:j,direction:l});a.css("display")},10))})})};d.fn.stupidtable.dir={ASC:"asc",DESC:"desc"};d.fn.stupidtable.default_sort_fns={"int":function(b,a){return parseInt(b,10)-parseInt(a,10)},"float":function(b,a){return parseFloat(b)-parseFloat(a)},string:function(b,a){return b<a?-1:b>a?1:0},"string-ins":function(b,a){b=b.toLowerCase();a=a.toLowerCase();return b<a?-1:b>a?1:0}}})(jQuery);

4
gestioncof/static/js/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long