Updated site to scale better on small screens; Added clearfix css; Updated shadow feature to use css shadows instead of js/images.
Added code to the admin part of the site - still non-functional. Need to fix JSON streaming over HTTP such that native types (boolean, Date, int) are preserved for the DB; Need to finish the restore functionality & the hide/show of the edit, delete, and restore buttons on each editor page.
This commit is contained in:
@@ -11,6 +11,14 @@ var LinkedTable;
|
||||
this.selectionHandler = function(event) {
|
||||
$(this).addClass(_this.options.selectionCSS).siblings().removeClass(_this.options.selectionCSS);
|
||||
_this.$selectedRow = $(this);
|
||||
|
||||
//Create a selection event indicating the table has changed its selection.
|
||||
//var e = $.Event('selection.linkedtable', {relatedTarget: _this.$element[0]});
|
||||
//Fire the event.
|
||||
//_this.$element.trigger(e);
|
||||
if(_this.options.selectionChanged) {
|
||||
_this.options.selectionChanged(_this.$selectedRow, _this.$selectedRow.data("model"));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -19,6 +27,7 @@ var LinkedTable;
|
||||
attr: 'data-key-name',
|
||||
selectionCSS: 'selected',
|
||||
selection: 'row', //Currently only row is supported.
|
||||
selectionChanged: undefined, //An optional handler called when the selection changes, and passed the selected element (jquery wrapper for the table row 'tr' HTML element currently selected), and the model associated with the row.
|
||||
supportingData: [], //An array of objects, one for each collection of supporting data. Each object must have a 'name', 'url', and optional 'parameters'. The url and parameters are used the same as for the primary query. The name is used to store the results for use in rendering the data. Optional 'postProcess' attribute can be a function that takes the data and returns a modified set of data.
|
||||
cellDataHandlers: {}, //An object containing a function for each attribute, where the attribute is the table header object key, and the function is called to convert the primary data object into a cell value. The function will be passed the jquery table data wrapper object for the cell, the primary data object for the row, and the object containing the supporting data returned from running the supporting data queries.
|
||||
postAddRowHandler: null, //Optional function that is passed the jquery table row and the data object sent by the server for that row. Allows post processing of the row prior to display.
|
||||
@@ -74,7 +83,7 @@ var LinkedTable;
|
||||
else {params = {};}
|
||||
|
||||
//Load the primary set of data.
|
||||
deferreds.push($.getJSON(this.options.url, params));
|
||||
deferreds.push($.post(this.options.url, params, 'json'));
|
||||
|
||||
//Load all supporting data.
|
||||
for(var supportingDataIndex = 0; supportingDataIndex < this.options.supportingData.length; supportingDataIndex++) {
|
||||
@@ -95,24 +104,27 @@ var LinkedTable;
|
||||
else {params = {};}
|
||||
|
||||
//Load the supporting data.
|
||||
deferreds.push($.getJSON(nextSupportingData.url, params));
|
||||
deferreds.push($.post(nextSupportingData.url, params, 'json'));
|
||||
}
|
||||
|
||||
//Use apply to convert an array of parameters to individual parameters for the $.when(..) function. The success function will receive the results in order passed to when().
|
||||
$.when.apply($, deferreds).then(function() {
|
||||
var data = arguments[0][0]; //Note: The result of the first query returns an array of three values: the data (array in this case), the message, and XHR object. We only care about the data.
|
||||
//Note: If there is only one query, then the argument array contains the results for the one query, otherwise the argument array is an array of result arrays, one for each query.
|
||||
var data = (deferreds.length > 1 ? arguments[0][0] : arguments[0]); //Note: For multiple queries, the result of the first query returns an array of three values: the data (array in this case), the message, and XHR object. We only care about the data.
|
||||
var headers = thead.children();
|
||||
var attributes = [];
|
||||
|
||||
//Save each supporting set of data by name into the supportingData object.
|
||||
for(var argumentIndex = 1; argumentIndex < arguments.length; argumentIndex++) {
|
||||
var supportingResult = arguments[argumentIndex][0]; //We only care about the data. The other two array elements are the status and the XHR object.
|
||||
if(deferreds.length > 1) {
|
||||
//Save each supporting set of data by name into the supportingData object.
|
||||
for(var argumentIndex = 1; argumentIndex < arguments.length; argumentIndex++) {
|
||||
var supportingResult = arguments[argumentIndex][0]; //We only care about the data. The other two array elements are the status and the XHR object.
|
||||
|
||||
if(_this.options.supportingData[argumentIndex - 1].postProcess) {
|
||||
supportingResult = _this.options.supportingData[argumentIndex - 1].postProcess(supportingResult);
|
||||
if(_this.options.supportingData[argumentIndex - 1].postProcess) {
|
||||
supportingResult = _this.options.supportingData[argumentIndex - 1].postProcess(supportingResult);
|
||||
}
|
||||
|
||||
supportingData[_this.options.supportingData[argumentIndex - 1].name] = supportingResult;
|
||||
}
|
||||
|
||||
supportingData[_this.options.supportingData[argumentIndex - 1].name] = supportingResult;
|
||||
}
|
||||
|
||||
//Read the table headers to get the data object keys.
|
||||
|
||||
Reference in New Issue
Block a user