upgraded yui to 2.2.2 and yui-ext to 1.0.1a
This commit is contained in:
parent
4d9af2c691
commit
547ced6500
1992 changed files with 645731 additions and 0 deletions
200
www/extras/yui/examples/datatable/customsort.html
Normal file
200
www/extras/yui/examples/datatable/customsort.html
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example: DataTable - Custom Sorting (YUI Library)</title>
|
||||
<link type="text/css" rel="stylesheet" href="../../build/reset/reset.css">
|
||||
<link type="text/css" rel="stylesheet" href="../../build/fonts/fonts.css">
|
||||
<link type="text/css" rel="stylesheet" href="../../build/logger/assets/logger.css">
|
||||
<link type="text/css" rel="stylesheet" href="../../build/datatable/assets/datatable.css">
|
||||
<link type="text/css" rel="stylesheet" href="./css/examples.css">
|
||||
<link type="text/css" rel="stylesheet" href="../assets/dpSyntaxHighlighter.css">
|
||||
<style type="text/css">
|
||||
/* custom css*/
|
||||
#sort {margin:1em;}
|
||||
#sort table {border-collapse:collapse;}
|
||||
#sort th, #sort td {border:1px solid #000;}
|
||||
#sort th {background-color:#696969;}/*dark gray*/
|
||||
#sort th a {color:#fff;}
|
||||
#sort th .yui-dt-headtext {margin-right:5px;padding-right:15px;} /*room for arrow*/
|
||||
#sort .yui-dt-sortedbyasc, #sort .yui-dt-sortedbydesc {background-color:#3F3F3F;}/*dark gray*/
|
||||
#sort .yui-dt-sortedbyasc .yui-dt-headtext {background-image: url('img/arrow_up.gif'); background-repeat:no-repeat; background-position:right;}/*arrow up*/
|
||||
#sort .yui-dt-sortedbydesc .yui-dt-headtext {background-image: url('img/arrow_dn.gif'); background-repeat:no-repeat; background-position:right;}/*arrow down*/
|
||||
#sort .yui-dt-odd {background-color:#eee;} /*light gray zebra stripe*/
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="hd">
|
||||
<h1><img src="./img/logo.gif" class="logo" alt="Y!"/><a href="./">DataTable Widget</a> :: Custom Sorting</h1>
|
||||
</div>
|
||||
<div id="bd">
|
||||
<div id="sort"></div>
|
||||
|
||||
<!-- Sample code begins -->
|
||||
<div id="code">
|
||||
<h3>Sample Code</h3>
|
||||
|
||||
<p>Data:</p>
|
||||
|
||||
<textarea name="code" class="JScript" cols="60" rows="1">
|
||||
YAHOO.example.Data.areacodes = [
|
||||
{areacode: "201", state: "New Jersey"},
|
||||
...,
|
||||
{areacode: "989", state: "Michigan"}
|
||||
];
|
||||
</textarea>
|
||||
|
||||
<p>CSS:</p>
|
||||
|
||||
<textarea name="code" class="HTML" cols="60" rows="1">
|
||||
/* custom css*/
|
||||
#sort {margin:1em;}
|
||||
#sort table {border-collapse:collapse;}
|
||||
#sort th, #sort td {border:1px solid #000;}
|
||||
#sort th {background-color:#696969;}/*dark gray*/
|
||||
#sort th a {color:#fff;}
|
||||
#sort th .yui-dt-headtext {margin-right:5px;padding-right:15px;} /*room for arrow*/
|
||||
#sort .yui-dt-sortedbyasc, #sort .yui-dt-sortedbydesc {background-color:#3F3F3F;}/*dark gray*/
|
||||
#sort .yui-dt-sortedbyasc .yui-dt-headtext {background-image: url('img/arrow_up.gif'); background-repeat:no-repeat; background-position:right;}/*arrow up*/
|
||||
#sort .yui-dt-sortedbydesc .yui-dt-headtext {background-image: url('img/arrow_dn.gif'); background-repeat:no-repeat; background-position:right;}/*arrow down*/
|
||||
#sort .yui-dt-odd {background-color:#eee;} /*light gray zebra stripe*/
|
||||
</textarea>
|
||||
|
||||
<p>Markup:</p>
|
||||
|
||||
<textarea name="code" class="HTML" cols="60" rows="1">
|
||||
<div id="sort"></div>
|
||||
</textarea>
|
||||
|
||||
<p>JavaScript:</p>
|
||||
|
||||
<textarea name="code" class="JScript" cols="60" rows="1">
|
||||
// Custom sort functionality to sort by areacode within states
|
||||
YAHOO.example.sortStatesAsc = function(a, b) {
|
||||
if((a === null) || (typeof a == "undefined")) {
|
||||
if((b === null) || (typeof b == "undefined")) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if((b === null) || (typeof b == "undefined")) {
|
||||
return -1;
|
||||
}
|
||||
var comp = YAHOO.util.Sort.compareAsc;
|
||||
var compState = comp(a.state, b.state);
|
||||
return (compState !== 0) ? compState : comp(a.areacode, b.areacode);
|
||||
};
|
||||
YAHOO.example.sortStatesDesc = function(a, b) {
|
||||
if((a === null) || (typeof a == "undefined")) {
|
||||
if((b === null) || (typeof b == "undefined")) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if((b === null) || (typeof b == "undefined")) {
|
||||
return 1;
|
||||
}
|
||||
var comp = YAHOO.util.Sort.compareDesc;
|
||||
var compState = comp(a.state, b.state);
|
||||
return (compState !== 0) ? compState : comp(a.areacode, b.areacode);
|
||||
};
|
||||
|
||||
var myColumnHeaders = [
|
||||
{key:"areacode",text:"Area Codes",sortable:true},
|
||||
{key:"state",text:"States",sortable:true,sortOptions:{ascFunction:YAHOO.example.sortStatesAsc,descFunction:YAHOO.example.sortStatesDesc}}
|
||||
];
|
||||
var myColumnSet = new YAHOO.widget.ColumnSet(myColumnHeaders);
|
||||
|
||||
var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.areacodes);
|
||||
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
|
||||
myDataSource.responseSchema = {
|
||||
fields: ["areacode","state"]
|
||||
};
|
||||
|
||||
var myDataTable = new YAHOO.widget.DataTable("sort",myColumnSet,myDataSource,{caption:"Example: Custom Sorting",sortedBy:{colKey:"areacode",dir:"asc"}});
|
||||
var onColumnSort = function(oArgs) {
|
||||
var column = oArgs.column;
|
||||
var dir = oArgs.dir;
|
||||
};
|
||||
myDataTable.subscribe("columnSortEvent",onColumnSort);
|
||||
</textarea>
|
||||
</div>
|
||||
<!-- Code sample ends -->
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="../../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../../build/logger/logger.js"></script>
|
||||
<script type="text/javascript" src="../../build/datasource/datasource-beta-debug.js"></script>
|
||||
<script type="text/javascript" src="../../build/datatable/datatable-beta-debug.js"></script>
|
||||
<script type="text/javascript" src="./js/data.js"></script>
|
||||
<script type="text/javascript">
|
||||
var myLogger = new YAHOO.widget.LogReader();
|
||||
|
||||
/****************************************************************************/
|
||||
/****************************************************************************/
|
||||
/****************************************************************************/
|
||||
|
||||
// Custom sort functionality to sort by areacode within states
|
||||
YAHOO.example.sortStatesAsc = function(a, b) {
|
||||
if((a === null) || (typeof a == "undefined")) {
|
||||
if((b === null) || (typeof b == "undefined")) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if((b === null) || (typeof b == "undefined")) {
|
||||
return -1;
|
||||
}
|
||||
var comp = YAHOO.util.Sort.compareAsc;
|
||||
var compState = comp(a.state, b.state);
|
||||
return (compState !== 0) ? compState : comp(a.areacode, b.areacode);
|
||||
};
|
||||
YAHOO.example.sortStatesDesc = function(a, b) {
|
||||
if((a === null) || (typeof a == "undefined")) {
|
||||
if((b === null) || (typeof b == "undefined")) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if((b === null) || (typeof b == "undefined")) {
|
||||
return 1;
|
||||
}
|
||||
var comp = YAHOO.util.Sort.compareDesc;
|
||||
var compState = comp(a.state, b.state);
|
||||
return (compState !== 0) ? compState : comp(a.areacode, b.areacode);
|
||||
};
|
||||
|
||||
var myColumnHeaders = [
|
||||
{key:"areacode",text:"Area Codes",sortable:true},
|
||||
{key:"state",text:"States",sortable:true,sortOptions:{ascFunction:YAHOO.example.sortStatesAsc,descFunction:YAHOO.example.sortStatesDesc}}
|
||||
];
|
||||
var myColumnSet = new YAHOO.widget.ColumnSet(myColumnHeaders);
|
||||
|
||||
var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.areacodes);
|
||||
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
|
||||
myDataSource.responseSchema = {
|
||||
fields: ["areacode","state"]
|
||||
};
|
||||
|
||||
var myDataTable = new YAHOO.widget.DataTable("sort",myColumnSet,myDataSource,{caption:"Example: Custom Sorting",sortedBy:{colKey:"areacode",dir:"asc"}});
|
||||
var onColumnSort = function(oArgs) {
|
||||
var column = oArgs.column;
|
||||
var dir = oArgs.dir;
|
||||
};
|
||||
myDataTable.subscribe("columnSortEvent",onColumnSort);
|
||||
</script>
|
||||
<script type="text/javascript" src="../assets/dpSyntaxHighlighter.js"></script>
|
||||
<script type="text/javascript">
|
||||
dp.SyntaxHighlighter.HighlightAll('code');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue