From 183f9a0ba19b6fcdf1475285af1bb1fcd45a9442 Mon Sep 17 00:00:00 2001 From: Lei Yan Date: Fri, 20 Sep 2013 17:20:52 -0500 Subject: Tissue correlation results work for sample r/rho correlation page and are written to the template --- misc/gn_installation_notes.txt | 14 +- wqflask/base/mrna_assay_tissue_data.py | 152 +++++++++++---------- .../wqflask/correlation/correlation_functions.py | 12 +- wqflask/wqflask/correlation/show_corr_results.py | 65 ++++++--- wqflask/wqflask/templates/correlation_page.html | 9 +- 5 files changed, 157 insertions(+), 95 deletions(-) diff --git a/misc/gn_installation_notes.txt b/misc/gn_installation_notes.txt index 6329586f..a73e7d4f 100644 --- a/misc/gn_installation_notes.txt +++ b/misc/gn_installation_notes.txt @@ -272,6 +272,12 @@ sudo apt-get install r-base-dev =========================================== +Installing rpy2 + +pip install rpy2 + +=========================================== + Install Parallel Python (pp) wget http://www.parallelpython.com/downloads/pp/pp-1.6.3.tar.gz @@ -303,7 +309,13 @@ To get server running: !If having seemingly inexplicable problems with imports, make sure I've started the environment! Start up virtual environment: -source ~/ve27/bin/activate +source ~/ve27/bin/activate============== + +Install requests + +pip install requests + +======================= To set WQFLASK_SETTINGS environment variable: export WQFLASK_SETTINGS=~/zach_settings.py (or wherever file is located) diff --git a/wqflask/base/mrna_assay_tissue_data.py b/wqflask/base/mrna_assay_tissue_data.py index 8ae71858..7eb07028 100644 --- a/wqflask/base/mrna_assay_tissue_data.py +++ b/wqflask/base/mrna_assay_tissue_data.py @@ -4,11 +4,13 @@ import collections from flask import g -from utility import dbtools -from uitility import Bunch +from utility import db_tools +from utility import Bunch from MySQLdb import escape_string as escape +from pprint import pformat as pf + class MrnaAssayTissueData(object): def __init__(self, gene_symbols=None): @@ -35,14 +37,15 @@ class MrnaAssayTissueData(object): # Note that inner join is necessary in this query to get distinct record in one symbol group # with highest mean value # Due to the limit size of TissueProbeSetFreezeId table in DB, - # performance of inner join is acceptable. + # performance of inner join is acceptable.MrnaAssayTissueData(gene_symbols=symbol_list) + print("len(gene_symbols): ", len(gene_symbols)) if len(gene_symbols) == 0: query += '''Symbol!='' and Symbol Is Not Null group by Symbol) as x inner join TissueProbeSetXRef as t on t.Symbol = x.Symbol and t.Mean = x.maxmean; ''' else: - in_clause = dbtools.create_in_clause(gene_symbols) + in_clause = db_tools.create_in_clause(gene_symbols) query += ''' Symbol in {} group by Symbol) as x inner join TissueProbeSetXRef as t on t.Symbol = x.Symbol @@ -51,17 +54,19 @@ class MrnaAssayTissueData(object): results = g.db.execute(query).fetchall() for result in results: - symbol = item[0] - gene_symbols.append(symbol) - symbol = symbol.lower() - - self.data[symbol].gene_id = result.GeneId - self.data[symbol].data_id = result.DataId - self.data[symbol].chr = result.Chr - self.data[symbol].mb = result.Mb - self.data[symbol].description = result.description - self.data[symbol].probe_target_description = result.Probe_Target_Description + symbol = result[0] + if symbol in gene_symbols: + #gene_symbols.append(symbol) + symbol = symbol.lower() + + self.data[symbol].gene_id = result.GeneId + self.data[symbol].data_id = result.DataId + self.data[symbol].chr = result.Chr + self.data[symbol].mb = result.Mb + self.data[symbol].description = result.description + self.data[symbol].probe_target_description = result.Probe_Target_Description + #print("self.data: ", pf(self.data)) ########################################################################### #Input: cursor, symbolList (list), dataIdDict(Dict) @@ -70,65 +75,72 @@ class MrnaAssayTissueData(object): #function: get one dictionary whose key is gene symbol and value is tissue expression data (list type). #Attention! All keys are lower case! ########################################################################### - def get_symbol_value_pairs(self): - - id_list = [self.tissue_data[symbol.lower()].data_id for item in self.tissue_data] - - symbol_value_pairs = {} - value_list=[] - query = """SELECT value, id - FROM TissueProbeSetData - WHERE Id IN {}""".format(create_in_clause(id_list)) - - try : - results = g.db.execute(query).fetchall() - for result in results: - value_list.append(result.value) - symbol_value_pairs[symbol] = value_list - except: - symbol_value_pairs[symbol] = None - - #for symbol in symbol_list: - # if tissue_data.has_key(symbol): - # data_id = tissue_data[symbol].data_id - # - # query = """select value, id - # from TissueProbeSetData - # where Id={}""".format(escape(data_id)) - # try : - # results = g.db.execute(query).fetchall() - # for item in results: - # item = item[0] - # value_list.append(item) - # symbol_value_pairs[symbol] = value_list - # value_list=[] - # except: - # symbol_value_pairs[symbol] = None + def get_symbol_values_pairs(self): + id_list = [self.data[symbol].data_id for symbol in self.data] + + symbol_values_dict = {} + + query = """SELECT TissueProbeSetXRef.Symbol, TissueProbeSetData.value + FROM TissueProbeSetXRef, TissueProbeSetData + WHERE TissueProbeSetData.Id IN {} and + TissueProbeSetXRef.DataId = TissueProbeSetData.Id""".format(db_tools.create_in_clause(id_list)) + + results = g.db.execute(query).fetchall() + for result in results: + if result.Symbol.lower() not in symbol_values_dict: + symbol_values_dict[result.Symbol.lower()] = [result.value] + else: + symbol_values_dict[result.Symbol.lower()].append(result.value) + + #for symbol in self.data: + # data_id = self.data[symbol].data_id + # symbol_values_dict[symbol] = self.get_tissue_values(data_id) + - return symbol_value_pairs + return symbol_values_dict - ######################################################################################################## - #input: cursor, symbolList (list), dataIdDict(Dict): key is symbol - #output: SymbolValuePairDict(dictionary):one dictionary of Symbol and Value Pair. - # key is symbol, value is one list of expression values of one probeSet. - #function: wrapper function for getSymbolValuePairDict function - # build gene symbol list if necessary, cut it into small lists if necessary, - # then call getSymbolValuePairDict function and merge the results. - ######################################################################################################## - def get_trait_symbol_and_tissue_values(symbol_list=None): - tissue_data = MrnaAssayTissueData(gene_symbols=symbol_list) + #def get_tissue_values(self, data_id): + # """Gets the tissue values for a particular gene""" + # + # tissue_values=[] + # + # query = """SELECT value, id + # FROM TissueProbeSetData + # WHERE Id IN {}""".format(db_tools.create_in_clause(data_id)) + # + # #try : + # results = g.db.execute(query).fetchall() + # for result in results: + # tissue_values.append(result.value) + # #symbol_values_dict[symbol] = value_list + # #except: + # # symbol_values_pairs[symbol] = None + # + # return tissue_values - #symbolList, - #geneIdDict, - #dataIdDict, - #ChrDict, - #MbDict, - #descDict, - #pTargetDescDict = getTissueProbeSetXRefInfo( - # GeneNameLst=GeneNameLst,TissueProbeSetFreezeId=TissueProbeSetFreezeId) - - if len(tissue_data.gene_symbols): - return get_symbol_value_pairs(tissue_data) +######################################################################################################## +#input: cursor, symbolList (list), dataIdDict(Dict): key is symbol +#output: SymbolValuePairDict(dictionary):one dictionary of Symbol and Value Pair. +# key is symbol, value is one list of expression values of one probeSet. +#function: wrapper function for getSymbolValuePairDict function +# build gene symbol list if necessary, cut it into small lists if necessary, +# then call getSymbolValuePairDict function and merge the results. +######################################################################################################## + +#def get_trait_symbol_and_tissue_values(symbol_list=None): +# tissue_data = MrnaAssayTissueData(gene_symbols=symbol_list) +# +# #symbolList, +# #geneIdDict, +# #dataIdDict, +# #ChrDict, +# #MbDict, +# #descDict, +# #pTargetDescDict = getTissueProbeSetXRefInfo( +# # GeneNameLst=GeneNameLst,TissueProbeSetFreezeId=TissueProbeSetFreezeId) +# +# if len(tissue_data.gene_symbols): +# return get_symbol_values_pairs(tissue_data) diff --git a/wqflask/wqflask/correlation/correlation_functions.py b/wqflask/wqflask/correlation/correlation_functions.py index 56f66810..84d47bb5 100644 --- a/wqflask/wqflask/correlation/correlation_functions.py +++ b/wqflask/wqflask/correlation/correlation_functions.py @@ -27,7 +27,7 @@ from __future__ import absolute_import, print_function, division import math -#import rpy2.robjects +import rpy2.robjects import pp import string @@ -494,7 +494,7 @@ pcor.rec <- function(x,y,z,method="p",na.rm=T){ #XZ, April 30, 2010: The input primaryTrait and targetTrait are instance of webqtlTrait #XZ: The primaryTrait and targetTrait should have executed retrieveData function -def calZeroOrderCorr (primaryTrait, targetTrait, method='pearson'): +def calZeroOrderCorr(primaryTrait, targetTrait, method='pearson'): #primaryTrait.retrieveData() @@ -560,7 +560,7 @@ def calZeroOrderCorr (primaryTrait, targetTrait, method='pearson'): #the same tissue order ##################################################################################### -def calZeroOrderCorrForTiss (primaryValue=[], targetValue=[], method='pearson'): +def cal_zero_order_corr_for_tiss (primaryValue=[], targetValue=[], method='pearson'): R_primary = rpy2.robjects.FloatVector(range(len(primaryValue))) N = len(primaryValue) @@ -809,6 +809,9 @@ def get_trait_symbol_and_tissue_values(symbol_list=None): tissue_data = MrnaAssayTissueData(gene_symbols=symbol_list) + if len(tissue_data.gene_symbols): + return tissue_data.get_symbol_values_pairs() + #symbolList, #geneIdDict, #dataIdDict, @@ -818,9 +821,6 @@ def get_trait_symbol_and_tissue_values(symbol_list=None): #pTargetDescDict = getTissueProbeSetXRefInfo( # GeneNameLst=GeneNameLst,TissueProbeSetFreezeId=TissueProbeSetFreezeId) - if len(tissue_data.gene_symbols): - return get_symbol_value_pairs(tissue_data) - #limit_num=1000 #count = len(symbol_list) # diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index b17e1db1..b9d009af 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -105,7 +105,7 @@ class CorrelationResults(object): self.sample_data = {} self.corr_method = start_vars['corr_sample_method'] - self.return_number = 500 + self.return_number = 50 #The two if statements below append samples to the sample list based upon whether the user #rselected Primary Samples Only, Other Samples Only, or All Samples @@ -158,15 +158,27 @@ class CorrelationResults(object): for trait_counter, trait in enumerate(self.correlation_data.keys()[:self.return_number]): trait_object = GeneralTrait(dataset=self.dataset, name=trait, get_qtl_info=True) + + print("gene symbol: ", trait_object.symbol) + trait_object.sample_r = self.correlation_data[trait][0] trait_object.sample_p = self.correlation_data[trait][1] trait_object.num_overlap = self.correlation_data[trait][2] + #Get symbol for trait and call function that gets each tissue value from the database (tables TissueProbeSetXRef, + #TissueProbeSetData, etc) and calculates the correlation (cal_zero_order_corr_for_tissue in correlation_functions) + + + # Set some sane defaults - trait_object.tissue_corr = None - trait_object.tissue_pvalue = None + trait_object.tissue_corr = 0 + trait_object.tissue_pvalue = 0 self.correlation_results.append(trait_object) + + self.do_tissue_correlation_by_list() + + print("self.correlation_results: ", pf(self.correlation_results)) @@ -183,7 +195,7 @@ class CorrelationResults(object): # mb = trait_object.mb # ) # if trait_object.mean: - # trait_info[mean] = trait_object.mean + #def do_tissue_correlation_by_list(self, tissue_dataset_id):t_object.alias, # trait_info[mean] = trait_object.mean # if hasattr(trait_object, 'mean'): # trait_info[mean] = trait_object.mean # if hasattr(trait_object, 'lrs'): @@ -197,7 +209,8 @@ class CorrelationResults(object): # correlation = float(self.correlation_data[trait][0]), # p_value = float(self.correlation_data[trait][1]), # symbol = trait_object.symbol, - # alias = trait_object.alias, + # alias = trai + #def do_tissue_correlation_by_list(self, tissue_dataset_id):t_object.alias, # description = trait_object.description, # chromosome = trait_object.chr, # mb = trait_object.mb @@ -637,7 +650,15 @@ class CorrelationResults(object): for entry in results: trait_name, tissue_corr, tissue_pvalue = entry tissue_corr_dict[trait_name] = (tissue_corr, tissue_pvalue) - + #symbolList, + #geneIdDict, + #dataIdDict, + #ChrDict, + #MbDict, + #descDict, + #pTargetDescDict = getTissueProbeSetXRefInfo( + # GeneNameLst=GeneNameLst,TissueProbeSetFreezeId=TissueProbeSetFreezeId) + g.db.execute('DROP TEMPORARY TABLE {}'.format(escape(temp_table))) return tissue_corr_dict @@ -944,13 +965,17 @@ class CorrelationResults(object): return (symbolCorrDict, symbolPvalueDict) - def do_tissue_correlation_by_list(self, tissue_dataset_id): + def do_tissue_correlation_by_list(self, tissue_dataset_id=1): + """Given a list of correlation results (self.correlation_results), gets the tissue correlation value for each""" - trait_symbol_and_values = correlation_functions.get_trait_symbol_and_tissue_values( - gene_name_list = [self.this_trait.symbol]) + #Gets tissue expression values for the primary trait + primary_trait_tissue_vals_dict = correlation_functions.get_trait_symbol_and_tissue_values( + symbol_list = [self.this_trait.symbol]) + + print("primary_trait_tissue_vals: ", pf(primary_trait_tissue_vals_dict)) - if self.this_trait.symbol.lower() in trait_symbol_and_values: - primary_trait_value = trait_symbol_and_values[self.this_trait_symbol.lower()] + if self.this_trait.symbol.lower() in primary_trait_tissue_vals_dict: + primary_trait_tissue_values = primary_trait_tissue_vals_dict[self.this_trait.symbol.lower()] #gene_symbol_list = [] # @@ -960,19 +985,25 @@ class CorrelationResults(object): gene_symbol_list = [trait.symbol for trait in self.correlation_results if trait.symbol] - symbol_value_dict = correlation_functions.get_trait_gene_symbol_and_tissue_values( - gene_symbol_list=gene_symbol_list) + corr_result_tissue_vals_dict= correlation_functions.get_trait_symbol_and_tissue_values( + symbol_list=gene_symbol_list) + + print("corr_result_tissue_vals: ", pf(corr_result_tissue_vals_dict)) for trait in self.correlation_results: - if trait.symbol and trait.symbol.lower() in symbol_value_dict: - this_trait_value = symbol_value_dict[trait.symbol.lower()] + if trait.symbol and trait.symbol.lower() in corr_result_tissue_vals_dict: + this_trait_tissue_values = corr_result_tissue_vals_dict[trait.symbol.lower()] - result = correlation_functions.calZeroOrderCorrForTiss(primary_trait_value, - this_trait_value, + result = correlation_functions.cal_zero_order_corr_for_tiss(primary_trait_tissue_values, + this_trait_tissue_values, self.corr_method) trait.tissue_corr = result[0] trait.tissue_pvalue = result[2] + + #print("trait.tissue_corr / pvalue: ", str(trait.tissue_corr) + " :: " + str(trait.tissue_pvalue)) + + # else: # trait.tissue_corr = None # trait.tissue_pvalue = None diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 53b12545..7082dbf2 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -28,10 +28,15 @@ Sample r N Cases Sample p(r) + Tissue r + Tissue p(r) {% else %} Sample rho Sample p(rho) + Tissue rho + Tissue p(rho) {% endif %} + @@ -41,13 +46,15 @@ {{ trait.symbol }} {{ trait.alias }} {{ trait.description }} - Chr{{ trait.chr }}:{{'%0.6f'|format(trait.mb)}} + Chr{{ trait.chr }}:{{trait.mb}} {{'%0.3f'|format(trait.mean)}} {{'%0.3f'|format(trait.lrs)}} Chr{{ trait.locus_chr }}:{{'%0.6f'|format(trait.locus_mb)}} {{'%0.3f'|format(trait.sample_r)}} {{ trait.num_overlap }} {{'%0.3e'|format(trait.sample_p)}} + {{'%0.3f'|format(trait.tissue_corr)}} + {{'%0.3e'|format(trait.tissue_pvalue)}} {% endfor %} -- cgit v1.2.3 From 081f4f222a261c0d84bfb266aa4a32d6d62cab85 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 24 Sep 2013 18:08:23 -0500 Subject: Did some work towards doing the tissue correlation for all traits in a dataset (in order to sort by tissue correlation instead of sample correlation). --- wqflask/base/data_set.py | 14 +- wqflask/maintenance/quick_search_table.py | 6 +- .../wqflask/correlation/correlation_functions.py | 2 - wqflask/wqflask/correlation/show_corr_results.py | 545 +++++++++++---------- .../show_trait_calculate_correlations.html | 2 +- 5 files changed, 309 insertions(+), 260 deletions(-) diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 96e04df0..5d21c901 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -1055,7 +1055,6 @@ class MrnaAssayDataSet(DataSet): """ % (escape(self.name), escape(self.dataset.name)) results = g.db.execute(query).fetchone() return results[0] - def retrieve_sample_data(self, trait): query = """ @@ -1077,6 +1076,19 @@ class MrnaAssayDataSet(DataSet): results = g.db.execute(query).fetchall() return results + def retrieve_gene_symbols(self): + query = """ + select ProbeSet.Name, ProbeSet.Symbol + from ProbeSet,ProbeSetXRef + where ProbeSetXRef.ProbeSetFreezeId = %s and + ProbeSetXRef.ProbeSetId=ProbeSet.Id; + """ % (self.id) + results = g.db.execute(query).fetchall() + symbol_dict = {} + for item in results: + symbol_dict[item[0]] = item[1] + return symbol_dict + class TempDataSet(DataSet): '''Temporary user-generated data set''' diff --git a/wqflask/maintenance/quick_search_table.py b/wqflask/maintenance/quick_search_table.py index 9cd792ef..eef61857 100644 --- a/wqflask/maintenance/quick_search_table.py +++ b/wqflask/maintenance/quick_search_table.py @@ -11,10 +11,10 @@ each trait, its dataset, and several columns determined by its trait type (pheno """ -from __future__ import print_function, division, absolute_import +from __future__ import absolute_import, division, print_function -import sys -sys.path.append("../../..") +#import sys +#sys.path.append("../../..") import simplejson as json diff --git a/wqflask/wqflask/correlation/correlation_functions.py b/wqflask/wqflask/correlation/correlation_functions.py index 84d47bb5..da5c3197 100644 --- a/wqflask/wqflask/correlation/correlation_functions.py +++ b/wqflask/wqflask/correlation/correlation_functions.py @@ -805,8 +805,6 @@ def get_symbol_value_pairs(tissue_data): ######################################################################################################## def get_trait_symbol_and_tissue_values(symbol_list=None): - SymbolValuePairDict={} - tissue_data = MrnaAssayTissueData(gene_symbols=symbol_list) if len(tissue_data.gene_symbols): diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index b9d009af..c6bc5b2a 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -95,8 +95,7 @@ class CorrelationResults(object): #self.this_trait = GeneralTrait(dataset=self.dataset.name, # name=start_vars['trait_id'], - # cellid=None) - #print("start_vars: ", pf(start_vars)) + # cellid=None) with Bench("Doing correlations"): helper_functions.get_species_dataset_trait(self, start_vars) self.dataset.group.read_genotype_file() @@ -104,6 +103,7 @@ class CorrelationResults(object): corr_samples_group = start_vars['corr_samples_group'] self.sample_data = {} + self.corr_type = start_vars['corr_type'] self.corr_method = start_vars['corr_sample_method'] self.return_number = 50 @@ -127,36 +127,61 @@ class CorrelationResults(object): self.target_dataset = data_set.create_dataset(start_vars['corr_dataset']) self.target_dataset.get_trait_data() + self.correlation_results = [] self.correlation_data = {} - for trait, values in self.target_dataset.trait_data.iteritems(): - this_trait_vals = [] - target_vals = [] - for index, sample in enumerate(self.target_dataset.samplelist): - if sample in self.sample_data: - sample_value = self.sample_data[sample] - target_sample_value = values[index] - this_trait_vals.append(sample_value) - target_vals.append(target_sample_value) - - this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values( - this_trait_vals, target_vals) - - if self.corr_method == 'pearson': - sample_r, sample_p = scipy.stats.pearsonr(this_trait_vals, target_vals) - else: - sample_r, sample_p = scipy.stats.spearmanr(this_trait_vals, target_vals) - - self.correlation_data[trait] = [sample_r, sample_p, num_overlap] - - self.correlation_data = collections.OrderedDict(sorted(self.correlation_data.items(), - key=lambda t: -abs(t[1][0]))) - self.correlation_results = [] - - #self.correlation_data_slice = collections.OrderedDict() + if self.corr_type == "tissue": + trait_symbol_dict = self.dataset.retrieve_gene_symbols() + trait_symbols = trait_symbol_dict.values + + tissue_corr_data = self.do_tissue_corr_for_all_traits(gene_symbol_list=trait_symbols) + + for trait in tissue_corr_data.keys()[:self.return_number]: + this_trait_vals = [] + target_vals = [] + for index, sample in enumerate(self.target_dataset.samplelist): + if sample in self.sample_data: + sample_value = self.sample_data[sample] + target_sample_value = self.target_dataset.trait_data[trait][index] + this_trait_vals.append(sample_value) + target_vals.append(target_sample_value) + + this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values( + this_trait_vals, target_vals) + + if self.corr_method == 'pearson': + sample_r, sample_p = scipy.stats.pearsonr(this_trait_vals, target_vals) + else: + sample_r, sample_p = scipy.stats.spearmanr(this_trait_vals, target_vals) + + self.correlation_data[trait] = [sample_r, sample_p, num_overlap] + + elif self.corr_type == "sample": + for trait, values in self.target_dataset.trait_data.iteritems(): + this_trait_vals = [] + target_vals = [] + for index, sample in enumerate(self.target_dataset.samplelist): + if sample in self.sample_data: + sample_value = self.sample_data[sample] + target_sample_value = values[index] + this_trait_vals.append(sample_value) + target_vals.append(target_sample_value) + + this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values( + this_trait_vals, target_vals) + + if self.corr_method == 'pearson': + sample_r, sample_p = scipy.stats.pearsonr(this_trait_vals, target_vals) + else: + sample_r, sample_p = scipy.stats.spearmanr(this_trait_vals, target_vals) + + self.correlation_data[trait] = [sample_r, sample_p, num_overlap] + + self.correlation_data = collections.OrderedDict(sorted(self.correlation_data.items(), + key=lambda t: -abs(t[1][0]))) - for trait_counter, trait in enumerate(self.correlation_data.keys()[:self.return_number]): + for _trait_counter, trait in enumerate(self.correlation_data.keys()[:self.return_number]): trait_object = GeneralTrait(dataset=self.dataset, name=trait, get_qtl_info=True) print("gene symbol: ", trait_object.symbol) @@ -168,63 +193,21 @@ class CorrelationResults(object): #Get symbol for trait and call function that gets each tissue value from the database (tables TissueProbeSetXRef, #TissueProbeSetData, etc) and calculates the correlation (cal_zero_order_corr_for_tissue in correlation_functions) - - - # Set some sane defaults - trait_object.tissue_corr = 0 - trait_object.tissue_pvalue = 0 - + if self.corr_method != "tissue": + # Set some sane defaults + trait_object.tissue_corr = 0 + trait_object.tissue_pvalue = 0 + else: + trait_object.tissue_corr = tissue_corr_data[trait][1] + trait_object.tissue_pvalue = tissue_corr_data[trait][2] + self.correlation_results.append(trait_object) - self.do_tissue_correlation_by_list() + if self.corr_method != "tissue": + self.do_tissue_correlation_for_trait_list() print("self.correlation_results: ", pf(self.correlation_results)) - - - #self.correlation_data_slice[trait] = self.correlation_data[trait] - #self.correlation_data_slice[trait].append(trait_object) - #if self.dataset.type == 'ProbeSet': - # trait_info = collections.OrderedDict( - # correlation = float(self.correlation_data[trait][0]), - # p_value = float(self.correlation_data[trait][1]), - # symbol = trait_object.symbol, - # alias = trait_object.alias, - # description = trait_object.description, - # chromosome = trait_object.chr, - # mb = trait_object.mb - # ) - # if trait_object.mean: - #def do_tissue_correlation_by_list(self, tissue_dataset_id):t_object.alias, # trait_info[mean] = trait_object.mean - # if hasattr(trait_object, 'mean'): - # trait_info[mean] = trait_object.mean - # if hasattr(trait_object, 'lrs'): - # trait_info[lrs] = trait_object.lrs - # if hasattr(trait_object, 'locus_chr'): - # trait_info[locus_chr] = trait_object.locus_chr - # if hasattr(trait_object, 'locus_mb'): - # trait_info[locus_mb] = trait_object.locus_mb - #elif self.dataset.type == 'Geno': - # trait_info = collections.OrderedDict( - # correlation = float(self.correlation_data[trait][0]), - # p_value = float(self.correlation_data[trait][1]), - # symbol = trait_object.symbol, - # alias = trai - #def do_tissue_correlation_by_list(self, tissue_dataset_id):t_object.alias, - # description = trait_object.description, - # chromosome = trait_object.chr, - # mb = trait_object.mb - # ) - #else: # 'Publish' - # trait_info = collections.OrderedDict( - # correlation = float(self.correlation_data[trait][0]), - # p_value = float(self.correlation_data[trait][1]), - # symbol = trait_object.symbol, - # alias = trait_object.alias, - # description = trait_object.description, - # chromosome = trait_object.chr, - # mb = trait_object.mb - # ) #XZ, 09/18/2008: get all information about the user selected database. #target_db_name = fd.corr_dataset @@ -278,6 +261,210 @@ class CorrelationResults(object): ############################################################################################################################################ + def do_tissue_correlation_for_trait_list(self, tissue_dataset_id=1): + """Given a list of correlation results (self.correlation_results), gets the tissue correlation value for each""" + + #Gets tissue expression values for the primary trait + primary_trait_tissue_vals_dict = correlation_functions.get_trait_symbol_and_tissue_values( + symbol_list = [self.this_trait.symbol]) + + print("primary_trait_tissue_vals: ", pf(primary_trait_tissue_vals_dict)) + + if self.this_trait.symbol.lower() in primary_trait_tissue_vals_dict: + primary_trait_tissue_values = primary_trait_tissue_vals_dict[self.this_trait.symbol.lower()] + + #gene_symbol_list = [] + # + #for trait in self.correlation_results: + # if hasattr(trait, 'symbol'): + # gene_symbol_list.append(trait.symbol) + + gene_symbol_list = [trait.symbol for trait in self.correlation_results if trait.symbol] + + corr_result_tissue_vals_dict= correlation_functions.get_trait_symbol_and_tissue_values( + symbol_list=gene_symbol_list) + + print("corr_result_tissue_vals: ", pf(corr_result_tissue_vals_dict)) + + for trait in self.correlation_results: + if trait.symbol and trait.symbol.lower() in corr_result_tissue_vals_dict: + this_trait_tissue_values = corr_result_tissue_vals_dict[trait.symbol.lower()] + + result = correlation_functions.cal_zero_order_corr_for_tiss(primary_trait_tissue_values, + this_trait_tissue_values, + self.corr_method) + + trait.tissue_corr = result[0] + trait.tissue_pvalue = result[2] + + # else: + # trait.tissue_corr = None + # trait.tissue_pvalue = None + #else: + # for trait in self.correlation_results: + # trait.tissue_corr = None + # trait.tissue_pvalue = None + + #return self.correlation_results + + + def do_tissue_corr_for_all_traits(self, trait_symbols, tissue_dataset_id=1): + #Gets tissue expression values for the primary trait + primary_trait_tissue_vals_dict = correlation_functions.get_trait_symbol_and_tissue_values( + symbol_list = [self.this_trait.symbol]) + + correlation_data = {} + if self.this_trait.symbol.lower() in primary_trait_tissue_vals_dict: + primary_trait_tissue_values = primary_trait_tissue_vals_dict[self.this_trait.symbol.lower()] + + corr_result_tissue_vals_dict= correlation_functions.get_trait_symbol_and_tissue_values( + symbol_list=trait_symbols.values) + + print("corr_result_tissue_vals: ", pf(corr_result_tissue_vals_dict)) + + for trait, symbol in trait_symbols.iteritems(): + if symbol.lower() in corr_result_tissue_vals_dict: + this_trait_tissue_values = corr_result_tissue_vals_dict[symbol.lower()] + + result = correlation_functions.cal_zero_order_corr_for_tiss(primary_trait_tissue_values, + this_trait_tissue_values, + self.corr_method) + + correlation_results[trait] = [symbol, result[0], result[2]] + + correlation_data = collections.OrderedDict(sorted(self.correlation_data.items(), + key=lambda t: -abs(t[1][1]))) + + return correlation_data + + + + def do_tissue_corr_for_all_traits_2(self): + """Comments Possibly Out of Date!!!!! + + Uses get_temp_tissue_corr_table to generate table of tissue correlations + + This function then gathers that data and pairs it with the TraitID string. + Takes as its arguments a formdata instance, and a dataset instance. + Returns a dictionary of 'TraitID':(tissueCorr, tissuePValue) + for the requested correlation + + Used when the user selects the tissue correlation method; i.e. not for the + column that is appended to all probeset trait correlation tables + + """ + + # table name string + temp_table = self.get_temp_tissue_corr_table(tissue_probesetfreeze_id=TISSUE_MOUSE_DB, + method=method) + + query = """SELECT ProbeSet.Name, {}.Correlation, {}.PValue + FROM (ProbeSet, ProbeSetXRef, ProbeSetFreeze) + LEFT JOIN {} ON {}.Symbol=ProbeSet.Symbol + WHERE ProbeSetFreeze.Name = '{}' + and ProbeSetFreeze.Id=ProbeSetXRef.ProbeSetFreezeId + and ProbeSet.Id = ProbeSetXRef.ProbeSetId + and ProbeSet.Symbol IS NOT NULL + and {}.Correlation IS NOT NULL""".format(dataset.mescape( + temp_table, temp_table, temp_table, temp_table, + self.dataset.name, temp_table)) + + results = g.db.execute(query).fetchall() + + tissue_corr_dict = {} + + for entry in results: + trait_name, tissue_corr, tissue_pvalue = entry + tissue_corr_dict[trait_name] = (tissue_corr, tissue_pvalue) + #symbolList, + #geneIdDict, + #dataIdDict, + #ChrDict, + #MbDict, + #descDict, + #pTargetDescDict = getTissueProbeSetXRefInfo( + # GeneNameLst=GeneNameLst,TissueProbeSetFreezeId=TissueProbeSetFreezeId) + + g.db.execute('DROP TEMPORARY TABLE {}'.format(escape(temp_table))) + + return tissue_corr_dict + + + #XZ, 09/23/2008: In tissue correlation tables, there is no record of GeneId1 == GeneId2 + #XZ, 09/24/2008: Note that the correlation value can be negative. + def get_temp_tissue_corr_table(self, + tissue_probesetfreeze_id=0, + method="", + return_number=0): + + + def cmp_tisscorr_absolute_value(A, B): + try: + if abs(A[1]) < abs(B[1]): return 1 + elif abs(A[1]) == abs(B[1]): + return 0 + else: return -1 + except: + return 0 + + symbol_corr_dict, symbol_pvalue_dict = self.calculate_corr_for_all_tissues( + tissue_dataset_id=TISSUE_MOUSE_DB) + + symbol_corr_list = symbol_corr_dict.items() + + symbol_corr_list.sort(cmp_tisscorr_absolute_value) + symbol_corr_list = symbol_corr_list[0 : 2*return_number] + + tmp_table_name = webqtlUtil.genRandStr(prefix="TOPTISSUE") + + q1 = 'CREATE TEMPORARY TABLE %s (Symbol varchar(100) PRIMARY KEY, Correlation float, PValue float)' % tmp_table_name + self.cursor.execute(q1) + + for one_pair in symbol_corr_list: + one_symbol = one_pair[0] + one_corr = one_pair[1] + one_p_value = symbol_pvalue_dict[one_symbol] + + self.cursor.execute( "INSERT INTO %s (Symbol, Correlation, PValue) VALUES ('%s',%f,%f)" % (tmpTableName, one_symbol, float(one_corr), float(one_p_value)) ) + + return tmp_table_name + + + def calculate_corr_for_all_tissues(self, tissue_dataset_id=None): + + symbol_corr_dict = {} + symbol_pvalue_dict = {} + + primary_trait_symbol_value_dict = correlation_functions.make_gene_tissue_value_dict( + GeneNameLst=[self.this_trait.symbol], + TissueProbeSetFreezeId=tissue_dataset_id) + primary_trait_value = primary_trait_symbol_value_dict.values()[0] + + symbol_value_dict = correlation_functions.make_gene_tissue_value_dict( + gene_name_list=[], + tissue_dataset_id=tissue_dataset_id) + + symbol_corr_dict, symbol_pvalue_dict = correlation_functions.batch_cal_tissue_corr( + primaryTraitValue, + SymbolValueDict, + method=self.corr_method) + #else: + # symbol_corr_dict, symbol_pvalue_dict = correlation_functions.batch_cal_tissue_corr( + # primaryTraitValue, + # SymbolValueDict) + + return (symbolCorrDict, symbolPvalueDict) + + ##XZ, 12/16/2008: the input geneid is of mouse type + #def checkSymbolForTissueCorr(self, tissueProbeSetFreezeId=0, symbol=""): + # q = "SELECT 1 FROM TissueProbeSetXRef WHERE TissueProbeSetFreezeId=%s and Symbol='%s' LIMIT 1" % (tissueProbeSetFreezeId,symbol) + # self.cursor.execute(q) + # try: + # x = self.cursor.fetchone() + # if x: return True + # else: raise + # except: return False + def get_all_dataset_data(self): @@ -353,6 +540,8 @@ class CorrelationResults(object): return mouse_geneid + + ##XZ, 12/16/2008: the input geneid is of mouse type #def checkForLitInfo(self,geneId): # q = 'SELECT 1 FROM LCorrRamin3 WHERE GeneId1=%s LIMIT 1' % geneId @@ -364,16 +553,6 @@ class CorrelationResults(object): # except: return False - ##XZ, 12/16/2008: the input geneid is of mouse type - #def checkSymbolForTissueCorr(self, tissueProbeSetFreezeId=0, symbol=""): - # q = "SELECT 1 FROM TissueProbeSetXRef WHERE TissueProbeSetFreezeId=%s and Symbol='%s' LIMIT 1" % (tissueProbeSetFreezeId,symbol) - # self.cursor.execute(q) - # try: - # x = self.cursor.fetchone() - # if x: return True - # else: raise - # except: return False - def fetchAllDatabaseData(self, species, GeneId, GeneSymbol, strains, db, method, returnNumber, tissueProbeSetFreezeId): @@ -545,46 +724,6 @@ class CorrelationResults(object): - #XZ, 09/23/2008: In tissue correlation tables, there is no record of GeneId1 == GeneId2 - #XZ, 09/24/2008: Note that the correlation value can be negative. - def get_temp_tissue_corr_table(self, - tissue_probesetfreeze_id=0, - method="", - return_number=0): - - - def cmp_tisscorr_absolute_value(A, B): - try: - if abs(A[1]) < abs(B[1]): return 1 - elif abs(A[1]) == abs(B[1]): - return 0 - else: return -1 - except: - return 0 - - symbol_corr_dict, symbol_pvalue_dict = self.calculate_corr_for_all_tissues( - tissue_dataset_id=TISSUE_MOUSE_DB) - - symbol_corr_list = symbol_corr_dict.items() - - symbol_corr_list.sort(cmp_tisscorr_absolute_value) - symbol_corr_list = symbol_corr_list[0 : 2*return_number] - - tmp_table_name = webqtlUtil.genRandStr(prefix="TOPTISSUE") - - q1 = 'CREATE TEMPORARY TABLE %s (Symbol varchar(100) PRIMARY KEY, Correlation float, PValue float)' % tmp_table_name - self.cursor.execute(q1) - - for one_pair in symbol_corr_list: - one_symbol = one_pair[0] - one_corr = one_pair[1] - one_p_value = symbol_pvalue_dict[one_symbol] - - self.cursor.execute( "INSERT INTO %s (Symbol, Correlation, PValue) VALUES ('%s',%f,%f)" % (tmpTableName, one_symbol, float(one_corr), float(one_p_value)) ) - - return tmp_table_name - - #XZ, 01/09/2009: This function was created by David Crowell. Xiaodong cleaned up and modified it. def fetchLitCorrelations(self, species, GeneId, db, returnNumber): ### Used to generate Lit Correlations when calculations are done from text file. dcrowell August 2008 """Uses getTempLiteratureTable to generate table of literatire correlations. This function then gathers that data and @@ -612,57 +751,6 @@ class CorrelationResults(object): return litCorrDict - def fetch_tissue_correlations(self): - """Comments Possibly Out of Date!!!!! - - - Uses getTempTissueCorrTable to generate table of tissue correlations - - This function then gathers that data and pairs it with the TraitID string. - Takes as its arguments a formdata instance, and a database instance. - Returns a dictionary of 'TraitID':(tissueCorr, tissuePValue) - for the requested correlation - - Used when the user selects the tissue correlation method; i.e. not for the - column that is appended to all probeset trait correlation tables - - """ - - # table name string - temp_table = self.get_temp_tissue_corr_table(tissue_probesetfreeze_id=TISSUE_MOUSE_DB, - method=method) - - query = """SELECT ProbeSet.Name, {}.Correlation, {}.PValue - FROM (ProbeSet, ProbeSetXRef, ProbeSetFreeze) - LEFT JOIN {} ON {}.Symbol=ProbeSet.Symbol - WHERE ProbeSetFreeze.Name = '{}' - and ProbeSetFreeze.Id=ProbeSetXRef.ProbeSetFreezeId - and ProbeSet.Id = ProbeSetXRef.ProbeSetId - and ProbeSet.Symbol IS NOT NULL - and {}.Correlation IS NOT NULL""".format(dataset.mescape( - temp_table, temp_table, temp_table, temp_table, - self.dataset.name, temp_table)) - - results = g.db.execute(query).fetchall() - - tissue_corr_dict = {} - - for entry in results: - trait_name, tissue_corr, tissue_pvalue = entry - tissue_corr_dict[trait_name] = (tissue_corr, tissue_pvalue) - #symbolList, - #geneIdDict, - #dataIdDict, - #ChrDict, - #MbDict, - #descDict, - #pTargetDescDict = getTissueProbeSetXRefInfo( - # GeneNameLst=GeneNameLst,TissueProbeSetFreezeId=TissueProbeSetFreezeId) - - g.db.execute('DROP TEMPORARY TABLE {}'.format(escape(temp_table))) - - return tissue_corr_dict - def getLiteratureCorrelationByList(self, input_trait_mouse_geneid=None, species=None, traitList=None): @@ -819,7 +907,30 @@ class CorrelationResults(object): allcorrelations.append( one_traitinfo ) _log.info("Appending the results") + def calculate_corr_for_all_tissues(self, tissue_dataset_id=None): + + symbol_corr_dict = {} + symbol_pvalue_dict = {} + primary_trait_symbol_value_dict = correlation_functions.make_gene_tissue_value_dict( + GeneNameLst=[self.this_trait.symbol], + TissueProbeSetFreezeId=tissue_dataset_id) + primary_trait_value = primary_trait_symbol_value_dict.values()[0] + + symbol_value_dict = correlation_functions.make_gene_tissue_value_dict( + gene_name_list=[], + tissue_dataset_id=tissue_dataset_id) + + symbol_corr_dict, symbol_pvalue_dict = correlation_functions.batch_cal_tissue_corr( + primaryTraitValue, + SymbolValueDict, + method=self.corr_method) + #else: + # symbol_corr_dict, symbol_pvalue_dict = correlation_functions.batch_cal_tissue_corr( + # primaryTraitValue, + # SymbolValueDict) + + return (symbolCorrDict, symbolPvalueDict) datasetFile.close() totalTraits = len(allcorrelations) _log.info("Done correlating using the fast method") @@ -939,78 +1050,6 @@ class CorrelationResults(object): return trait_list """ - def calculate_corr_for_all_tissues(self, tissue_dataset_id=None): - symbol_corr_dict = {} - symbol_pvalue_dict = {} - primary_trait_symbol_value_dict = correlation_functions.make_gene_tissue_value_dict( - GeneNameLst=[self.this_trait.symbol], - TissueProbeSetFreezeId=tissue_dataset_id) - primary_trait_value = primary_trait_symbol_value_dict.values()[0] - - symbol_value_dict = correlation_functions.make_gene_tissue_value_dict( - gene_name_list=[], - tissue_dataset_id=tissue_dataset_id) - - symbol_corr_dict, symbol_pvalue_dict = correlation_functions.batch_cal_tissue_corr( - primaryTraitValue, - SymbolValueDict, - method=self.corr_method) - #else: - # symbol_corr_dict, symbol_pvalue_dict = correlation_functions.batch_cal_tissue_corr( - # primaryTraitValue, - # SymbolValueDict) - - return (symbolCorrDict, symbolPvalueDict) - - - def do_tissue_correlation_by_list(self, tissue_dataset_id=1): - """Given a list of correlation results (self.correlation_results), gets the tissue correlation value for each""" - - #Gets tissue expression values for the primary trait - primary_trait_tissue_vals_dict = correlation_functions.get_trait_symbol_and_tissue_values( - symbol_list = [self.this_trait.symbol]) - - print("primary_trait_tissue_vals: ", pf(primary_trait_tissue_vals_dict)) - - if self.this_trait.symbol.lower() in primary_trait_tissue_vals_dict: - primary_trait_tissue_values = primary_trait_tissue_vals_dict[self.this_trait.symbol.lower()] - - #gene_symbol_list = [] - # - #for trait in self.correlation_results: - # if hasattr(trait, 'symbol'): - # gene_symbol_list.append(trait.symbol) - - gene_symbol_list = [trait.symbol for trait in self.correlation_results if trait.symbol] - - corr_result_tissue_vals_dict= correlation_functions.get_trait_symbol_and_tissue_values( - symbol_list=gene_symbol_list) - - print("corr_result_tissue_vals: ", pf(corr_result_tissue_vals_dict)) - - for trait in self.correlation_results: - if trait.symbol and trait.symbol.lower() in corr_result_tissue_vals_dict: - this_trait_tissue_values = corr_result_tissue_vals_dict[trait.symbol.lower()] - - result = correlation_functions.cal_zero_order_corr_for_tiss(primary_trait_tissue_values, - this_trait_tissue_values, - self.corr_method) - - trait.tissue_corr = result[0] - trait.tissue_pvalue = result[2] - - #print("trait.tissue_corr / pvalue: ", str(trait.tissue_corr) + " :: " + str(trait.tissue_pvalue)) - - - # else: - # trait.tissue_corr = None - # trait.tissue_pvalue = None - #else: - # for trait in self.correlation_results: - # trait.tissue_corr = None - # trait.tissue_pvalue = None - - #return self.correlation_results diff --git a/wqflask/wqflask/templates/show_trait_calculate_correlations.html b/wqflask/wqflask/templates/show_trait_calculate_correlations.html index 12a064c0..73502392 100644 --- a/wqflask/wqflask/templates/show_trait_calculate_correlations.html +++ b/wqflask/wqflask/templates/show_trait_calculate_correlations.html @@ -5,7 +5,7 @@
- -- cgit v1.2.3 From 46624ca0058dcf2014b7eadb8bd0a595b4041159 Mon Sep 17 00:00:00 2001 From: Lei Yan Date: Fri, 27 Sep 2013 16:25:48 -0500 Subject: Added trait links to correlation results Began adding the code that does the initial sort by literature correlation --- web/webqtl/correlation/CorrelationPage.py | 2 +- wqflask/base/mrna_assay_tissue_data.py | 2 +- wqflask/wqflask/correlation/show_corr_results.py | 278 ++++++++++++----------- wqflask/wqflask/templates/correlation_page.html | 5 +- 4 files changed, 156 insertions(+), 131 deletions(-) diff --git a/web/webqtl/correlation/CorrelationPage.py b/web/webqtl/correlation/CorrelationPage.py index 8c74ae0c..0c98f032 100755 --- a/web/webqtl/correlation/CorrelationPage.py +++ b/web/webqtl/correlation/CorrelationPage.py @@ -819,7 +819,7 @@ Resorting this table
#XZ, 12/12/2008: if the input geneid is 'None', return 0 #XZ, 12/12/2008: if the input geneid has no corresponding mouse geneid, return 0 def translateToMouseGeneID (self, species, geneid): - mouse_geneid = 0; + mouse_geneid = 0 #if input geneid is None, return 0. if not geneid: diff --git a/wqflask/base/mrna_assay_tissue_data.py b/wqflask/base/mrna_assay_tissue_data.py index 7eb07028..be5df657 100644 --- a/wqflask/base/mrna_assay_tissue_data.py +++ b/wqflask/base/mrna_assay_tissue_data.py @@ -38,7 +38,7 @@ class MrnaAssayTissueData(object): # with highest mean value # Due to the limit size of TissueProbeSetFreezeId table in DB, # performance of inner join is acceptable.MrnaAssayTissueData(gene_symbols=symbol_list) - print("len(gene_symbols): ", len(gene_symbols)) + #print("len(gene_symbols): ", len(gene_symbols)) if len(gene_symbols) == 0: query += '''Symbol!='' and Symbol Is Not Null group by Symbol) as x inner join TissueProbeSetXRef as t on t.Symbol = x.Symbol diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index c6bc5b2a..42d5acd6 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -133,58 +133,46 @@ class CorrelationResults(object): if self.corr_type == "tissue": trait_symbol_dict = self.dataset.retrieve_gene_symbols() - trait_symbols = trait_symbol_dict.values - - tissue_corr_data = self.do_tissue_corr_for_all_traits(gene_symbol_list=trait_symbols) + tissue_corr_data = self.do_tissue_corr_for_all_traits(trait_gene_symbols = trait_symbol_dict) + #print("tissue_corr_data: ", pf(tissue_corr_data)) for trait in tissue_corr_data.keys()[:self.return_number]: - this_trait_vals = [] - target_vals = [] - for index, sample in enumerate(self.target_dataset.samplelist): - if sample in self.sample_data: - sample_value = self.sample_data[sample] - target_sample_value = self.target_dataset.trait_data[trait][index] - this_trait_vals.append(sample_value) - target_vals.append(target_sample_value) - - this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values( - this_trait_vals, target_vals) - - if self.corr_method == 'pearson': - sample_r, sample_p = scipy.stats.pearsonr(this_trait_vals, target_vals) - else: - sample_r, sample_p = scipy.stats.spearmanr(this_trait_vals, target_vals) - - self.correlation_data[trait] = [sample_r, sample_p, num_overlap] + self.get_sample_r_and_p_values(trait = trait, target_samples = self.target_dataset.trait_data[trait]) + #this_trait_vals = [] + #target_vals = [] + #for index, sample in enumerate(self.target_dataset.samplelist): + # if sample in self.sample_data: + # sample_value = self.sample_data[sample] + # target_sample_value = self.target_dataset.trait_data[trait][index] + # this_trait_vals.append(sample_value) + # target_vals.append(target_sample_value) + # + #this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values( + # this_trait_vals, target_vals) + # + #if self.corr_method == 'pearson': + # sample_r, sample_p = scipy.stats.pearsonr(this_trait_vals, target_vals) + #else: + # sample_r, sample_p = scipy.stats.spearmanr(this_trait_vals, target_vals) + # + #self.correlation_data[trait] = [sample_r, sample_p, num_overlap] + elif self.corr_type == "lit": + trait_symbol_dict = self.dataset.retrieve_gene_symbols() + elif self.corr_type == "sample": for trait, values in self.target_dataset.trait_data.iteritems(): - this_trait_vals = [] - target_vals = [] - for index, sample in enumerate(self.target_dataset.samplelist): - if sample in self.sample_data: - sample_value = self.sample_data[sample] - target_sample_value = values[index] - this_trait_vals.append(sample_value) - target_vals.append(target_sample_value) - - this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values( - this_trait_vals, target_vals) - - if self.corr_method == 'pearson': - sample_r, sample_p = scipy.stats.pearsonr(this_trait_vals, target_vals) - else: - sample_r, sample_p = scipy.stats.spearmanr(this_trait_vals, target_vals) - - self.correlation_data[trait] = [sample_r, sample_p, num_overlap] - + self.get_sample_r_and_p_values(trait = trait, target_samples = values) + self.correlation_data = collections.OrderedDict(sorted(self.correlation_data.items(), key=lambda t: -abs(t[1][0]))) + #print("correlation_data: ", pf(self.correlation_data)) + for _trait_counter, trait in enumerate(self.correlation_data.keys()[:self.return_number]): trait_object = GeneralTrait(dataset=self.dataset, name=trait, get_qtl_info=True) - print("gene symbol: ", trait_object.symbol) + #print("gene symbol: ", trait_object.symbol) trait_object.sample_r = self.correlation_data[trait][0] trait_object.sample_p = self.correlation_data[trait][1] @@ -193,17 +181,20 @@ class CorrelationResults(object): #Get symbol for trait and call function that gets each tissue value from the database (tables TissueProbeSetXRef, #TissueProbeSetData, etc) and calculates the correlation (cal_zero_order_corr_for_tissue in correlation_functions) - if self.corr_method != "tissue": + if self.corr_type == "tissue": + trait_object.tissue_corr = tissue_corr_data[trait][1] + trait_object.tissue_pvalue = tissue_corr_data[trait][2] + else: # Set some sane defaults trait_object.tissue_corr = 0 trait_object.tissue_pvalue = 0 - else: - trait_object.tissue_corr = tissue_corr_data[trait][1] - trait_object.tissue_pvalue = tissue_corr_data[trait][2] self.correlation_results.append(trait_object) - if self.corr_method != "tissue": + if self.corr_type != "lit": + self.do_lit_correlation_for_trait_list() + + if self.corr_type != "tissue": self.do_tissue_correlation_for_trait_list() print("self.correlation_results: ", pf(self.correlation_results)) @@ -308,36 +299,138 @@ class CorrelationResults(object): #return self.correlation_results - def do_tissue_corr_for_all_traits(self, trait_symbols, tissue_dataset_id=1): + def do_tissue_corr_for_all_traits(self, trait_gene_symbols, tissue_dataset_id=1): #Gets tissue expression values for the primary trait primary_trait_tissue_vals_dict = correlation_functions.get_trait_symbol_and_tissue_values( symbol_list = [self.this_trait.symbol]) - correlation_data = {} if self.this_trait.symbol.lower() in primary_trait_tissue_vals_dict: primary_trait_tissue_values = primary_trait_tissue_vals_dict[self.this_trait.symbol.lower()] + #print("trait_gene_symbols: ", pf(trait_gene_symbols.values())) corr_result_tissue_vals_dict= correlation_functions.get_trait_symbol_and_tissue_values( - symbol_list=trait_symbols.values) - - print("corr_result_tissue_vals: ", pf(corr_result_tissue_vals_dict)) + symbol_list=trait_gene_symbols.values()) - for trait, symbol in trait_symbols.iteritems(): - if symbol.lower() in corr_result_tissue_vals_dict: + #print("corr_result_tissue_vals: ", pf(corr_result_tissue_vals_dict)) + + #print("trait_gene_symbols: ", pf(trait_gene_symbols)) + + tissue_corr_data = {} + for trait, symbol in trait_gene_symbols.iteritems(): + if symbol and symbol.lower() in corr_result_tissue_vals_dict: this_trait_tissue_values = corr_result_tissue_vals_dict[symbol.lower()] + #print("this_trait_tissue_values: ", pf(this_trait_tissue_values)) result = correlation_functions.cal_zero_order_corr_for_tiss(primary_trait_tissue_values, this_trait_tissue_values, self.corr_method) - correlation_results[trait] = [symbol, result[0], result[2]] + tissue_corr_data[trait] = [symbol, result[0], result[2]] - correlation_data = collections.OrderedDict(sorted(self.correlation_data.items(), - key=lambda t: -abs(t[1][1]))) + tissue_corr_data = collections.OrderedDict(sorted(tissue_corr_data.items(), + key=lambda t: -abs(t[1][1]))) + + return tissue_corr_data - return correlation_data + def do_lit_correlation_for_trait_list(self): + + input_trait_mouse_gene_id = self.convert_to_mouse_gene_id(self.dataset.group.species.lower(), self.this_trait.geneid) + + for trait in self.correlation_results: + + if trait.geneid: + trait.mouse_gene_id = self.convert_to_mouse_gene_id(self.dataset.group.species.lower(), trait.geneid) + else: + trait.mouse_gene_id = None + + if trait.mouse_gene_id and str(trait.mouse_gene_id).find(";") == -1: + result = g.db.execute( + """SELECT value + FROM LCorrRamin3 + WHERE GeneId1='%s' and + GeneId2='%s' + """ % (escape(trait.mouse_gene_id), escape(self.this_trait.geneid)) + ).fetchone() + if not result: + result = g.db.execute("""SELECT value + FROM LCorrRamin3 + WHERE GeneId2='%s' and + GeneId1='%s' + """ % (escape(trait.mouse_gene_id), escape(input_trait_mouse_gene_id)) + ).fetchone() + + if result: + lit_corr = result.value + + if lit_corr: + trait.lit_corr = lit_corr + else: + trait.lit_corr = 0 + else: + trait.lit_corr = 0 + + + def convert_to_mouse_gene_id(self, species=None, gene_id=None): + """If the species is rat or human, translate the gene_id to the mouse geneid + + If there is no input gene_id or there's no corresponding mouse gene_id, return None + + """ + if not gene_id: + return None + + mouse_gene_id = None + + if species == 'mouse': + mouse_gene_id = gene_id + + elif species == 'rat': + mouse_gene_id = g.db.execute( + """SELECT mouse + FROM GeneIDXRef + WHERE rat='%d' + """, escape(int(gene_id))).fetchone().mouse + elif species == 'human': + mouse_gene_id = g.db.execute( + """SELECT mouse + FROM GeneIDXRef + WHERE human='%d' + """, escape(int(gene_id))).fetchone().mouse + + #print("mouse_geneid:", mouse_geneid) + + return mouse_gene_id + + def get_sample_r_and_p_values(self, trait, target_samples): + """Calculates the sample r (or rho) and p-value + + Given a primary trait and a target trait's sample values, + calculates either the pearson r or spearman rho and the p-value + using the corresponding scipy functions. + + """ + + this_trait_vals = [] + target_vals = [] + for index, sample in enumerate(self.target_dataset.samplelist): + if sample in self.sample_data: + sample_value = self.sample_data[sample] + target_sample_value = target_samples[index] + this_trait_vals.append(sample_value) + target_vals.append(target_sample_value) + + this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values( + this_trait_vals, target_vals) + + if self.corr_method == 'pearson': + sample_r, sample_p = scipy.stats.pearsonr(this_trait_vals, target_vals) + else: + sample_r, sample_p = scipy.stats.spearmanr(this_trait_vals, target_vals) + + self.correlation_data[trait] = [sample_r, sample_p, num_overlap] + def do_tissue_corr_for_all_traits_2(self): """Comments Possibly Out of Date!!!!! @@ -508,39 +601,6 @@ class CorrelationResults(object): self.sample_data[str(sample)] = float(value) - #XZ, 12/12/2008: if the species is rat or human, translate the geneid to mouse geneid - #XZ, 12/12/2008: if the input geneid is 'None', return 0 - #XZ, 12/12/2008: if the input geneid has no corresponding mouse geneid, return 0 - def translateToMouseGeneID(self, species, geneid): - #mouse_geneid = 0 - - if not geneid: - return 0 - - #self.id, self.name, self.fullname, self.shortname = g.db.execute(""" - # SELECT Id, Name, FullName, ShortName - # FROM %s - # WHERE public > %s AND - # (Name = '%s' OR FullName = '%s' OR ShortName = '%s') - # """ % (query_args)).fetchone() - - if species == 'mouse': - mouse_geneid = geneid - elif species == 'rat': - mouse_geneid = g.db.execute( - """SELECT mouse FROM GeneIDXRef WHERE rat='%d'""", int(geneid)).fetchone().mouse - #if record: - # mouse_geneid = record[0] - elif species == 'human': - mouse_geneid = g.db.execute( - """SELECT mouse FROM GeneIDXRef WHERE human='%d'""", int(geneid)).fetchone().mouse - #if record: - # mouse_geneid = record[0] - print("mouse_geneid:", mouse_geneid) - return mouse_geneid - - - ##XZ, 12/16/2008: the input geneid is of mouse type #def checkForLitInfo(self,geneId): @@ -751,44 +811,6 @@ class CorrelationResults(object): return litCorrDict - - def getLiteratureCorrelationByList(self, input_trait_mouse_geneid=None, species=None, traitList=None): - - tmpTableName = webqtlUtil.genRandStr(prefix="LITERATURE") - - q1 = 'CREATE TEMPORARY TABLE %s (GeneId1 int(12) unsigned, GeneId2 int(12) unsigned PRIMARY KEY, value double)' % tmpTableName - q2 = 'INSERT INTO %s (GeneId1, GeneId2, value) SELECT GeneId1,GeneId2,value FROM LCorrRamin3 WHERE GeneId1=%s' % (tmpTableName, input_trait_mouse_geneid) - q3 = 'INSERT INTO %s (GeneId1, GeneId2, value) SELECT GeneId2,GeneId1,value FROM LCorrRamin3 WHERE GeneId2=%s AND GeneId1!=%s' % (tmpTableName, input_trait_mouse_geneid, input_trait_mouse_geneid) - - for x in [q1,q2,q3]: - self.cursor.execute(x) - - for thisTrait in traitList: - try: - if thisTrait.geneid: - thisTrait.mouse_geneid = self.translateToMouseGeneID(species, thisTrait.geneid) - else: - thisTrait.mouse_geneid = 0 - except: - thisTrait.mouse_geneid = 0 - - if thisTrait.mouse_geneid and str(thisTrait.mouse_geneid).find(";") == -1: - try: - self.cursor.execute("SELECT value FROM %s WHERE GeneId2 = %s" % (tmpTableName, thisTrait.mouse_geneid)) - result = self.cursor.fetchone() - if result: - thisTrait.LCorr = result[0] - else: - thisTrait.LCorr = None - except: - thisTrait.LCorr = None - else: - thisTrait.LCorr = None - - self.cursor.execute("DROP TEMPORARY TABLE %s" % tmpTableName) - - return traitList - def get_traits(self, vals): #Todo: Redo cached stuff using memcached diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 7082dbf2..4d09cf20 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -28,11 +28,13 @@ Sample r N Cases Sample p(r) + Lit Corr Tissue r Tissue p(r) {% else %} Sample rho Sample p(rho) + Lit Corr Tissue rho Tissue p(rho) {% endif %} @@ -42,7 +44,7 @@ {% for trait in correlation_results %} - {{ trait.name }} + {{ trait.name }} {{ trait.symbol }} {{ trait.alias }} {{ trait.description }} @@ -53,6 +55,7 @@ {{'%0.3f'|format(trait.sample_r)}} {{ trait.num_overlap }} {{'%0.3e'|format(trait.sample_p)}} + {{'%0.3f'|format(trait.lit_corr)}} {{'%0.3f'|format(trait.tissue_corr)}} {{'%0.3e'|format(trait.tissue_pvalue)}} -- cgit v1.2.3 From 58327f74caa0616b1f6401a1154c03e87ae5e7bf Mon Sep 17 00:00:00 2001 From: Lei Yan Date: Fri, 27 Sep 2013 16:58:05 -0500 Subject: Downloaded the TableTools library so tables can be exported/saved --- .../static/packages/TableTools/alt_init.html | 520 ++++ .../static/packages/TableTools/alter_buttons.html | 505 ++++ .../static/packages/TableTools/bootstrap.html | 551 +++++ .../static/packages/TableTools/button_text.html | 531 +++++ .../static/packages/TableTools/collection.html | 522 +++++ .../static/packages/TableTools/defaults.html | 503 ++++ .../wqflask/static/packages/TableTools/index.html | 499 ++++ .../packages/TableTools/media/as3/ZeroClipboard.as | 221 ++ .../TableTools/media/as3/ZeroClipboardPdf.as | 310 +++ .../packages/TableTools/media/as3/lib/AlivePDF.swc | Bin 0 -> 131230 bytes .../packages/TableTools/media/css/TableTools.css | 321 +++ .../TableTools/media/css/TableTools_JUI.css | 185 ++ .../TableTools/media/images/background.png | Bin 0 -> 944 bytes .../TableTools/media/images/collection.png | Bin 0 -> 1166 bytes .../TableTools/media/images/collection_hover.png | Bin 0 -> 1194 bytes .../packages/TableTools/media/images/copy.png | Bin 0 -> 2184 bytes .../TableTools/media/images/copy_hover.png | Bin 0 -> 2797 bytes .../packages/TableTools/media/images/csv.png | Bin 0 -> 1607 bytes .../packages/TableTools/media/images/csv_hover.png | Bin 0 -> 1854 bytes .../packages/TableTools/media/images/pdf.png | Bin 0 -> 4325 bytes .../packages/TableTools/media/images/pdf_hover.png | Bin 0 -> 2786 bytes .../packages/TableTools/media/images/print.png | Bin 0 -> 2123 bytes .../TableTools/media/images/print_hover.png | Bin 0 -> 2230 bytes .../TableTools/media/images/psd/collection.psd | Bin 0 -> 25792 bytes .../TableTools/media/images/psd/copy document.psd | Bin 0 -> 104729 bytes .../TableTools/media/images/psd/file_types.psd | Bin 0 -> 1090645 bytes .../TableTools/media/images/psd/printer.psd | Bin 0 -> 119952 bytes .../packages/TableTools/media/images/xls.png | Bin 0 -> 1641 bytes .../packages/TableTools/media/images/xls_hover.png | Bin 0 -> 2061 bytes .../packages/TableTools/media/js/TableTools.js | 2476 ++++++++++++++++++++ .../packages/TableTools/media/js/TableTools.min.js | 77 + .../TableTools/media/js/TableTools.min.js.gz | Bin 0 -> 8785 bytes .../packages/TableTools/media/js/ZeroClipboard.js | 367 +++ .../packages/TableTools/media/swf/copy_csv_xls.swf | Bin 0 -> 2165 bytes .../TableTools/media/swf/copy_csv_xls_pdf.swf | Bin 0 -> 58824 bytes .../static/packages/TableTools/multi_instance.html | 499 ++++ .../packages/TableTools/multiple_tables.html | 296 +++ .../static/packages/TableTools/pdf_message.html | 524 +++++ .../static/packages/TableTools/plug-in.html | 539 +++++ .../static/packages/TableTools/select_multi.html | 507 ++++ .../static/packages/TableTools/select_single.html | 505 ++++ .../static/packages/TableTools/swf_path.html | 505 ++++ .../wqflask/static/packages/TableTools/tabs.html | 348 +++ .../wqflask/static/packages/TableTools/theme.html | 524 +++++ 44 files changed, 11835 insertions(+) create mode 100755 wqflask/wqflask/static/packages/TableTools/alt_init.html create mode 100755 wqflask/wqflask/static/packages/TableTools/alter_buttons.html create mode 100755 wqflask/wqflask/static/packages/TableTools/bootstrap.html create mode 100755 wqflask/wqflask/static/packages/TableTools/button_text.html create mode 100755 wqflask/wqflask/static/packages/TableTools/collection.html create mode 100755 wqflask/wqflask/static/packages/TableTools/defaults.html create mode 100755 wqflask/wqflask/static/packages/TableTools/index.html create mode 100755 wqflask/wqflask/static/packages/TableTools/media/as3/ZeroClipboard.as create mode 100755 wqflask/wqflask/static/packages/TableTools/media/as3/ZeroClipboardPdf.as create mode 100644 wqflask/wqflask/static/packages/TableTools/media/as3/lib/AlivePDF.swc create mode 100755 wqflask/wqflask/static/packages/TableTools/media/css/TableTools.css create mode 100755 wqflask/wqflask/static/packages/TableTools/media/css/TableTools_JUI.css create mode 100644 wqflask/wqflask/static/packages/TableTools/media/images/background.png create mode 100644 wqflask/wqflask/static/packages/TableTools/media/images/collection.png create mode 100644 wqflask/wqflask/static/packages/TableTools/media/images/collection_hover.png create mode 100755 wqflask/wqflask/static/packages/TableTools/media/images/copy.png create mode 100755 wqflask/wqflask/static/packages/TableTools/media/images/copy_hover.png create mode 100755 wqflask/wqflask/static/packages/TableTools/media/images/csv.png create mode 100755 wqflask/wqflask/static/packages/TableTools/media/images/csv_hover.png create mode 100644 wqflask/wqflask/static/packages/TableTools/media/images/pdf.png create mode 100644 wqflask/wqflask/static/packages/TableTools/media/images/pdf_hover.png create mode 100755 wqflask/wqflask/static/packages/TableTools/media/images/print.png create mode 100755 wqflask/wqflask/static/packages/TableTools/media/images/print_hover.png create mode 100644 wqflask/wqflask/static/packages/TableTools/media/images/psd/collection.psd create mode 100755 wqflask/wqflask/static/packages/TableTools/media/images/psd/copy document.psd create mode 100755 wqflask/wqflask/static/packages/TableTools/media/images/psd/file_types.psd create mode 100755 wqflask/wqflask/static/packages/TableTools/media/images/psd/printer.psd create mode 100755 wqflask/wqflask/static/packages/TableTools/media/images/xls.png create mode 100755 wqflask/wqflask/static/packages/TableTools/media/images/xls_hover.png create mode 100755 wqflask/wqflask/static/packages/TableTools/media/js/TableTools.js create mode 100644 wqflask/wqflask/static/packages/TableTools/media/js/TableTools.min.js create mode 100644 wqflask/wqflask/static/packages/TableTools/media/js/TableTools.min.js.gz create mode 100755 wqflask/wqflask/static/packages/TableTools/media/js/ZeroClipboard.js create mode 100644 wqflask/wqflask/static/packages/TableTools/media/swf/copy_csv_xls.swf create mode 100644 wqflask/wqflask/static/packages/TableTools/media/swf/copy_csv_xls_pdf.swf create mode 100755 wqflask/wqflask/static/packages/TableTools/multi_instance.html create mode 100755 wqflask/wqflask/static/packages/TableTools/multiple_tables.html create mode 100755 wqflask/wqflask/static/packages/TableTools/pdf_message.html create mode 100755 wqflask/wqflask/static/packages/TableTools/plug-in.html create mode 100755 wqflask/wqflask/static/packages/TableTools/select_multi.html create mode 100755 wqflask/wqflask/static/packages/TableTools/select_single.html create mode 100755 wqflask/wqflask/static/packages/TableTools/swf_path.html create mode 100755 wqflask/wqflask/static/packages/TableTools/tabs.html create mode 100755 wqflask/wqflask/static/packages/TableTools/theme.html diff --git a/wqflask/wqflask/static/packages/TableTools/alt_init.html b/wqflask/wqflask/static/packages/TableTools/alt_init.html new file mode 100755 index 00000000..73853150 --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/alt_init.html @@ -0,0 +1,520 @@ + + + + + + + TableTools example + + + + + + + + +
+
+ TableTools example - initialisation with 'new TableTools()' +
+ +

Preamble

+

Typically when working with TableTools, the initialisation and insertion into the DOM will be done automatically by DataTables, through the use of the sDom parameter. However, it is also possible to initialise TableTools manually as shown in the example below. Once initialised you can insert the TableTools tool bar node anywhere you wish into the DOM using the instance.dom.container parameter.

+ + +

Live example

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Rendering engineBrowserPlatform(s)Engine versionCSS grade
Rendering engineBrowserPlatform(s)Engine versionCSS grade
TridentInternet Explorer 4.0Win 95+ (Entity: &)4X
TridentInternet Explorer 5.0Win 95+5C
TridentInternet Explorer 5.5Win 95+5.5A
TridentInternet Explorer 6Win 98+6A
TridentInternet Explorer 7Win XP SP2+7A
TridentAOL browser (AOL desktop)Win XP6A
Gecko (UTF-8: $¢€)Firefox 1.0Win 98+ / OSX.2+1.7A
GeckoFirefox 1.5Win 98+ / OSX.2+1.8A
GeckoFirefox 2.0Win 98+ / OSX.2+1.8A
GeckoFirefox 3.0Win 2k+ / OSX.3+1.9A
GeckoCamino 1.0OSX.2+1.8A
GeckoCamino 1.5OSX.3+1.8A
GeckoNetscape 7.2Win 95+ / Mac OS 8.6-9.21.7A
GeckoNetscape Browser 8Win 98SE+1.7A
GeckoNetscape Navigator 9Win 98+ / OSX.2+1.8A
GeckoMozilla 1.0Win 95+ / OSX.1+1A
GeckoMozilla 1.1Win 95+ / OSX.1+1.1A
GeckoMozilla 1.2Win 95+ / OSX.1+1.2A
GeckoMozilla 1.3Win 95+ / OSX.1+1.3A
GeckoMozilla 1.4Win 95+ / OSX.1+1.4A
GeckoMozilla 1.5Win 95+ / OSX.1+1.5A
GeckoMozilla 1.6Win 95+ / OSX.1+1.6A
GeckoMozilla 1.7Win 98+ / OSX.1+1.7A
GeckoMozilla 1.8Win 98+ / OSX.1+1.8A
GeckoSeamonkey 1.1Win 98+ / OSX.2+1.8A
GeckoEpiphany 2.20Gnome1.8A
WebkitSafari 1.2OSX.3125.5A
WebkitSafari 1.3OSX.3312.8A
WebkitSafari 2.0OSX.4+419.3A
WebkitSafari 3.0OSX.4+522.1A
WebkitOmniWeb 5.5OSX.4+420A
WebkitiPod Touch / iPhoneiPod420.1A
WebkitS60S60413A
PrestoOpera 7.0Win 95+ / OSX.1+-A
PrestoOpera 7.5Win 95+ / OSX.2+-A
PrestoOpera 8.0Win 95+ / OSX.2+-A
PrestoOpera 8.5Win 95+ / OSX.2+-A
PrestoOpera 9.0Win 95+ / OSX.3+-A
PrestoOpera 9.2Win 88+ / OSX.3+-A
PrestoOpera 9.5Win 88+ / OSX.3+-A
PrestoOpera for WiiWii-A
PrestoNokia N800N800-A
PrestoNintendo DS browserNintendo DS8.5C/A1
KHTMLKonqureror 3.1KDE 3.13.1C
KHTMLKonqureror 3.3KDE 3.33.3A
KHTMLKonqureror 3.5KDE 3.53.5A
TasmanInternet Explorer 4.5Mac OS 8-9-X
TasmanInternet Explorer 5.1Mac OS 7.6-91C
TasmanInternet Explorer 5.2Mac OS 8-X1C
MiscNetFront 3.1Embedded devices-C
MiscNetFront 3.4Embedded devices-A
MiscDillo 0.8Embedded devices-X
MiscLinksText only-X
MiscLynxText only-X
MiscIE MobileWindows Mobile 6-C
MiscPSP browserPSP-C
Other browsersAll others--U
+
+
+ + +

Initialisation code

+
$(document).ready( function () {
+	var oTable = $('#example').dataTable();
+	var oTableTools = new TableTools( oTable, {
+		"buttons": [
+			"copy",
+			"csv",
+			"xls",
+			"pdf",
+			{ "type": "print", "buttonText": "Print me!" }
+		]
+	} );
+	
+	$('#demo').before( oTableTools.dom.container );
+} );
+ + +

Other examples

+ + + + +
+ + \ No newline at end of file diff --git a/wqflask/wqflask/static/packages/TableTools/alter_buttons.html b/wqflask/wqflask/static/packages/TableTools/alter_buttons.html new file mode 100755 index 00000000..771b0b86 --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/alter_buttons.html @@ -0,0 +1,505 @@ + + + + + + + TableTools example + + + + + + + + +
+
+ TableTools example - button arrangement +
+ +

Preamble

+

TableTools makes it very simple to arrange the buttons in the toolbar as you see fit. Using the aButtons parameter you can use any of the predefined buttons or customised buttons. The example below shows how TableTools can be initialised to provide only the 'copy-to-clipboard' and 'print view' options (i.e. no save to local file option is available).

+ + +

Live example

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Rendering engineBrowserPlatform(s)Engine versionCSS grade
Rendering engineBrowserPlatform(s)Engine versionCSS grade
TridentInternet Explorer 4.0Win 95+ (Entity: &)4X
TridentInternet Explorer 5.0Win 95+5C
TridentInternet Explorer 5.5Win 95+5.5A
TridentInternet Explorer 6Win 98+6A
TridentInternet Explorer 7Win XP SP2+7A
TridentAOL browser (AOL desktop)Win XP6A
Gecko (UTF-8: $¢€)Firefox 1.0Win 98+ / OSX.2+1.7A
GeckoFirefox 1.5Win 98+ / OSX.2+1.8A
GeckoFirefox 2.0Win 98+ / OSX.2+1.8A
GeckoFirefox 3.0Win 2k+ / OSX.3+1.9A
GeckoCamino 1.0OSX.2+1.8A
GeckoCamino 1.5OSX.3+1.8A
GeckoNetscape 7.2Win 95+ / Mac OS 8.6-9.21.7A
GeckoNetscape Browser 8Win 98SE+1.7A
GeckoNetscape Navigator 9Win 98+ / OSX.2+1.8A
GeckoMozilla 1.0Win 95+ / OSX.1+1A
GeckoMozilla 1.1Win 95+ / OSX.1+1.1A
GeckoMozilla 1.2Win 95+ / OSX.1+1.2A
GeckoMozilla 1.3Win 95+ / OSX.1+1.3A
GeckoMozilla 1.4Win 95+ / OSX.1+1.4A
GeckoMozilla 1.5Win 95+ / OSX.1+1.5A
GeckoMozilla 1.6Win 95+ / OSX.1+1.6A
GeckoMozilla 1.7Win 98+ / OSX.1+1.7A
GeckoMozilla 1.8Win 98+ / OSX.1+1.8A
GeckoSeamonkey 1.1Win 98+ / OSX.2+1.8A
GeckoEpiphany 2.20Gnome1.8A
WebkitSafari 1.2OSX.3125.5A
WebkitSafari 1.3OSX.3312.8A
WebkitSafari 2.0OSX.4+419.3A
WebkitSafari 3.0OSX.4+522.1A
WebkitOmniWeb 5.5OSX.4+420A
WebkitiPod Touch / iPhoneiPod420.1A
WebkitS60S60413A
PrestoOpera 7.0Win 95+ / OSX.1+-A
PrestoOpera 7.5Win 95+ / OSX.2+-A
PrestoOpera 8.0Win 95+ / OSX.2+-A
PrestoOpera 8.5Win 95+ / OSX.2+-A
PrestoOpera 9.0Win 95+ / OSX.3+-A
PrestoOpera 9.2Win 88+ / OSX.3+-A
PrestoOpera 9.5Win 88+ / OSX.3+-A
PrestoOpera for WiiWii-A
PrestoNokia N800N800-A
PrestoNintendo DS browserNintendo DS8.5C/A1
KHTMLKonqureror 3.1KDE 3.13.1C
KHTMLKonqureror 3.3KDE 3.33.3A
KHTMLKonqureror 3.5KDE 3.53.5A
TasmanInternet Explorer 4.5Mac OS 8-9-X
TasmanInternet Explorer 5.1Mac OS 7.6-91C
TasmanInternet Explorer 5.2Mac OS 8-X1C
MiscNetFront 3.1Embedded devices-C
MiscNetFront 3.4Embedded devices-A
MiscDillo 0.8Embedded devices-X
MiscLinksText only-X
MiscLynxText only-X
MiscIE MobileWindows Mobile 6-C
MiscPSP browserPSP-C
Other browsersAll others--U
+
+
+ + +

Initialisation code

+
$(document).ready( function () {
+	$('#example').dataTable( {
+		"sDom": 'T<"clear">lfrtip',
+		"oTableTools": {
+			"aButtons": [ "copy", "print" ]
+		}
+	} );
+} );
+ + +

Other examples

+ + + + +
+ + \ No newline at end of file diff --git a/wqflask/wqflask/static/packages/TableTools/bootstrap.html b/wqflask/wqflask/static/packages/TableTools/bootstrap.html new file mode 100755 index 00000000..664bde3d --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/bootstrap.html @@ -0,0 +1,551 @@ + + + + + + + TableTools example + + + + + + + + + + + +
+
+ TableTools with Twitter Bootstrap +
+ +

Preamble

+

Twitter Bootstrap is a very powerful design framework for allowing you to very quickly create applications with a unified look and feel. DataTables integrates well with Bootstrap, and so does TableTools.

+

This example shows the default Bootstrap theme being used with a Bootstrap styled DataTable. sDom is supplied to the DataTable with a setup suitable for Bootstrap styling, and a TableTools collection is used to show how it can be used in this environment.

+ +

Live example

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Rendering engineBrowserPlatform(s)Engine versionCSS grade
Rendering engineBrowserPlatform(s)Engine versionCSS grade
TridentInternet Explorer 4.0Win 95+ (Entity: &)4X
TridentInternet Explorer 5.0Win 95+5C
TridentInternet Explorer 5.5Win 95+5.5A
TridentInternet Explorer 6Win 98+6A
TridentInternet Explorer 7Win XP SP2+7A
TridentAOL browser (AOL desktop)Win XP6A
Gecko (UTF-8: $¢€ היצוא)Firefox 1.0Win 98+ / OSX.2+1.7A
GeckoFirefox 1.5Win 98+ / OSX.2+1.8A
GeckoFirefox 2.0Win 98+ / OSX.2+1.8A
GeckoFirefox 3.0Win 2k+ / OSX.3+1.9A
GeckoCamino 1.0OSX.2+1.8A
GeckoCamino 1.5OSX.3+1.8A
GeckoNetscape 7.2Win 95+ / Mac OS 8.6-9.21.7A
GeckoNetscape Browser 8Win 98SE+1.7A
GeckoNetscape Navigator 9Win 98+ / OSX.2+1.8A
GeckoMozilla 1.0Win 95+ / OSX.1+1A
GeckoMozilla 1.1Win 95+ / OSX.1+1.1A
GeckoMozilla 1.2Win 95+ / OSX.1+1.2A
GeckoMozilla 1.3Win 95+ / OSX.1+1.3A
GeckoMozilla 1.4Win 95+ / OSX.1+1.4A
GeckoMozilla 1.5Win 95+ / OSX.1+1.5A
GeckoMozilla 1.6Win 95+ / OSX.1+1.6A
GeckoMozilla 1.7Win 98+ / OSX.1+1.7A
GeckoMozilla 1.8Win 98+ / OSX.1+1.8A
GeckoSeamonkey 1.1Win 98+ / OSX.2+1.8A
GeckoEpiphany 2.20Gnome1.8A
WebkitSafari 1.2OSX.3125.5A
WebkitSafari 1.3OSX.3312.8A
WebkitSafari 2.0OSX.4+419.3A
WebkitSafari 3.0OSX.4+522.1A
WebkitOmniWeb 5.5OSX.4+420A
WebkitiPod Touch / iPhoneiPod420.1A
WebkitS60S60413A
PrestoOpera 7.0Win 95+ / OSX.1+-A
PrestoOpera 7.5Win 95+ / OSX.2+-A
PrestoOpera 8.0Win 95+ / OSX.2+-A
PrestoOpera 8.5Win 95+ / OSX.2+-A
PrestoOpera 9.0Win 95+ / OSX.3+-A
PrestoOpera 9.2Win 88+ / OSX.3+-A
PrestoOpera 9.5Win 88+ / OSX.3+-A
PrestoOpera for WiiWii-A
PrestoNokia N800N800-A
PrestoNintendo DS browserNintendo DS8.5C/A1
KHTMLKonqureror 3.1KDE 3.13.1C
KHTMLKonqureror 3.3KDE 3.33.3A
KHTMLKonqureror 3.5KDE 3.53.5A
TasmanInternet Explorer 4.5Mac OS 8-9-X
TasmanInternet Explorer 5.1Mac OS 7.6-91C
TasmanInternet Explorer 5.2Mac OS 8-X1C
MiscNetFront 3.1Embedded devices-C
MiscNetFront 3.4Embedded devices-A
MiscDillo 0.8Embedded devices-X
MiscLinksText only-X
MiscLynxText only-X
MiscIE MobileWindows Mobile 6-C
MiscPSP browserPSP-C
Other browsersAll others--U
+
+
+ + +

Initialisation code

+
$(document).ready( function () {
+	$('#example').dataTable( {
+		"sDom": "<'row-fluid'<'span6'T><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
+		"oTableTools": {
+			"aButtons": [
+				"copy",
+				"print",
+				{
+					"sExtends":    "collection",
+					"sButtonText": 'Save <span class="caret" />',
+					"aButtons":    [ "csv", "xls", "pdf" ]
+				}
+			]
+		}
+	} );
+} );
+ +

The following code is included from the DataTables bootstrap integration file:

+ +
// Set the classes that TableTools uses to something suitable for Bootstrap
+$.extend( true, $.fn.DataTable.TableTools.classes, {
+	"container": "btn-group",
+	"buttons": {
+		"normal": "btn",
+		"disabled": "btn disabled"
+	},
+	"collection": {
+		"container": "DTTT_dropdown dropdown-menu",
+		"buttons": {
+			"normal": "",
+			"disabled": "disabled"
+		}
+	}
+} );
+
+// Have the collection use a bootstrap compatible dropdown
+$.extend( true, $.fn.DataTable.TableTools.DEFAULTS.oTags, {
+	"collection": {
+		"container": "ul",
+		"button": "li",
+		"liner": "a"
+	}
+} );
+ + +

Other examples

+ + + + +
+ + \ No newline at end of file diff --git a/wqflask/wqflask/static/packages/TableTools/button_text.html b/wqflask/wqflask/static/packages/TableTools/button_text.html new file mode 100755 index 00000000..6828eb94 --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/button_text.html @@ -0,0 +1,531 @@ + + + + + + + TableTools example + + + + + + + + +
+
+ TableTools example - customised button text +
+ +

Preamble

+

You may wish to set your own text for the buttons in the TableTools toolbar, rather than relying on the default built-in text. This is done by overriding the sButtonText parameter of whatever button you wish to alter. The way TableTools allows you to alter a predefined button is by 'extending' it (using the sExtends parameter) and then setting the overriding parameter. A full list of the parameters which can be used is available on the DataTables.net web-site. This example shows how to set the button text as required.

+ + +

Live example

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Rendering engineBrowserPlatform(s)Engine versionCSS grade
Rendering engineBrowserPlatform(s)Engine versionCSS grade
TridentInternet Explorer 4.0Win 95+ (Entity: &)4X
TridentInternet Explorer 5.0Win 95+5C
TridentInternet Explorer 5.5Win 95+5.5A
TridentInternet Explorer 6Win 98+6A
TridentInternet Explorer 7Win XP SP2+7A
TridentAOL browser (AOL desktop)Win XP6A
Gecko (UTF-8: $¢€)Firefox 1.0Win 98+ / OSX.2+1.7A
GeckoFirefox 1.5Win 98+ / OSX.2+1.8A
GeckoFirefox 2.0Win 98+ / OSX.2+1.8A
GeckoFirefox 3.0Win 2k+ / OSX.3+1.9A
GeckoCamino 1.0OSX.2+1.8A
GeckoCamino 1.5OSX.3+1.8A
GeckoNetscape 7.2Win 95+ / Mac OS 8.6-9.21.7A
GeckoNetscape Browser 8Win 98SE+1.7A
GeckoNetscape Navigator 9Win 98+ / OSX.2+1.8A
GeckoMozilla 1.0Win 95+ / OSX.1+1A
GeckoMozilla 1.1Win 95+ / OSX.1+1.1A
GeckoMozilla 1.2Win 95+ / OSX.1+1.2A
GeckoMozilla 1.3Win 95+ / OSX.1+1.3A
GeckoMozilla 1.4Win 95+ / OSX.1+1.4A
GeckoMozilla 1.5Win 95+ / OSX.1+1.5A
GeckoMozilla 1.6Win 95+ / OSX.1+1.6A
GeckoMozilla 1.7Win 98+ / OSX.1+1.7A
GeckoMozilla 1.8Win 98+ / OSX.1+1.8A
GeckoSeamonkey 1.1Win 98+ / OSX.2+1.8A
GeckoEpiphany 2.20Gnome1.8A
WebkitSafari 1.2OSX.3125.5A
WebkitSafari 1.3OSX.3312.8A
WebkitSafari 2.0OSX.4+419.3A
WebkitSafari 3.0OSX.4+522.1A
WebkitOmniWeb 5.5OSX.4+420A
WebkitiPod Touch / iPhoneiPod420.1A
WebkitS60S60413A
PrestoOpera 7.0Win 95+ / OSX.1+-A
PrestoOpera 7.5Win 95+ / OSX.2+-A
PrestoOpera 8.0Win 95+ / OSX.2+-A
PrestoOpera 8.5Win 95+ / OSX.2+-A
PrestoOpera 9.0Win 95+ / OSX.3+-A
PrestoOpera 9.2Win 88+ / OSX.3+-A
PrestoOpera 9.5Win 88+ / OSX.3+-A
PrestoOpera for WiiWii-A
PrestoNokia N800N800-A
PrestoNintendo DS browserNintendo DS8.5C/A1
KHTMLKonqureror 3.1KDE 3.13.1C
KHTMLKonqureror 3.3KDE 3.33.3A
KHTMLKonqureror 3.5KDE 3.53.5A
TasmanInternet Explorer 4.5Mac OS 8-9-X
TasmanInternet Explorer 5.1Mac OS 7.6-91C
TasmanInternet Explorer 5.2Mac OS 8-X1C
MiscNetFront 3.1Embedded devices-C
MiscNetFront 3.4Embedded devices-A
MiscDillo 0.8Embedded devices-X
MiscLinksText only-X
MiscLynxText only-X
MiscIE MobileWindows Mobile 6-C
MiscPSP browserPSP-C
Other browsersAll others--U
+
+
+ + +

Initialisation code

+
$(document).ready( function () {
+	$('#example').dataTable( {
+		"sDom": 'T<"clear">lfrtip',
+		"oTableTools": {
+			"aButtons": [
+				{
+					"sExtends": "copy",
+					"sButtonText": "Copy to clipboard"
+				},
+				{
+					"sExtends": "csv",
+					"sButtonText": "Save to CSV"
+				},
+				{
+					"sExtends": "xls",
+					"sButtonText": "Save for Excel"
+				}
+			]
+		}
+	} );
+} );
+ + +

Other examples

+ + + + +
+ + \ No newline at end of file diff --git a/wqflask/wqflask/static/packages/TableTools/collection.html b/wqflask/wqflask/static/packages/TableTools/collection.html new file mode 100755 index 00000000..4eb3141b --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/collection.html @@ -0,0 +1,522 @@ + + + + + + + TableTools example + + + + + + + + +
+
+ TableTools example - button collections +
+ +

Preamble

+

TableTools provides the ability to group buttons into a hidden drop down list, which is activated by clicking on a top-level button. This is achieved by extending the 'collection' predefined button type and setting it's aButtons parameter with the same options as the top level buttons (note that you cannot currently use a collection within a collection).

+

The example below shows the file save buttons grouped into a collection, while the copy and print buttons are left on the top level.

+ + +

Live example

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Rendering engineBrowserPlatform(s)Engine versionCSS grade
Rendering engineBrowserPlatform(s)Engine versionCSS grade
TridentInternet Explorer 4.0Win 95+ (Entity: &)4X
TridentInternet Explorer 5.0Win 95+5C
TridentInternet Explorer 5.5Win 95+5.5A
TridentInternet Explorer 6Win 98+6A
TridentInternet Explorer 7Win XP SP2+7A
TridentAOL browser (AOL desktop)Win XP6A
Gecko (UTF-8: $¢€)Firefox 1.0Win 98+ / OSX.2+1.7A
GeckoFirefox 1.5Win 98+ / OSX.2+1.8A
GeckoFirefox 2.0Win 98+ / OSX.2+1.8A
GeckoFirefox 3.0Win 2k+ / OSX.3+1.9A
GeckoCamino 1.0OSX.2+1.8A
GeckoCamino 1.5OSX.3+1.8A
GeckoNetscape 7.2Win 95+ / Mac OS 8.6-9.21.7A
GeckoNetscape Browser 8Win 98SE+1.7A
GeckoNetscape Navigator 9Win 98+ / OSX.2+1.8A
GeckoMozilla 1.0Win 95+ / OSX.1+1A
GeckoMozilla 1.1Win 95+ / OSX.1+1.1A
GeckoMozilla 1.2Win 95+ / OSX.1+1.2A
GeckoMozilla 1.3Win 95+ / OSX.1+1.3A
GeckoMozilla 1.4Win 95+ / OSX.1+1.4A
GeckoMozilla 1.5Win 95+ / OSX.1+1.5A
GeckoMozilla 1.6Win 95+ / OSX.1+1.6A
GeckoMozilla 1.7Win 98+ / OSX.1+1.7A
GeckoMozilla 1.8Win 98+ / OSX.1+1.8A
GeckoSeamonkey 1.1Win 98+ / OSX.2+1.8A
GeckoEpiphany 2.20Gnome1.8A
WebkitSafari 1.2OSX.3125.5A
WebkitSafari 1.3OSX.3312.8A
WebkitSafari 2.0OSX.4+419.3A
WebkitSafari 3.0OSX.4+522.1A
WebkitOmniWeb 5.5OSX.4+420A
WebkitiPod Touch / iPhoneiPod420.1A
WebkitS60S60413A
PrestoOpera 7.0Win 95+ / OSX.1+-A
PrestoOpera 7.5Win 95+ / OSX.2+-A
PrestoOpera 8.0Win 95+ / OSX.2+-A
PrestoOpera 8.5Win 95+ / OSX.2+-A
PrestoOpera 9.0Win 95+ / OSX.3+-A
PrestoOpera 9.2Win 88+ / OSX.3+-A
PrestoOpera 9.5Win 88+ / OSX.3+-A
PrestoOpera for WiiWii-A
PrestoNokia N800N800-A
PrestoNintendo DS browserNintendo DS8.5C/A1
KHTMLKonqureror 3.1KDE 3.13.1C
KHTMLKonqureror 3.3KDE 3.33.3A
KHTMLKonqureror 3.5KDE 3.53.5A
TasmanInternet Explorer 4.5Mac OS 8-9-X
TasmanInternet Explorer 5.1Mac OS 7.6-91C
TasmanInternet Explorer 5.2Mac OS 8-X1C
MiscNetFront 3.1Embedded devices-C
MiscNetFront 3.4Embedded devices-A
MiscDillo 0.8Embedded devices-X
MiscLinksText only-X
MiscLynxText only-X
MiscIE MobileWindows Mobile 6-C
MiscPSP browserPSP-C
Other browsersAll others--U
+
+
+ + +

Initialisation code

+
$(document).ready( function () {
+	$('#example').dataTable( {
+		"sDom": 'T<"clear">lfrtip',
+		"oTableTools": {
+			"aButtons": [
+				"copy",
+				"print",
+				{
+					"sExtends":    "collection",
+					"sButtonText": "Save",
+					"aButtons":    [ "csv", "xls", "pdf" ]
+				}
+			]
+		}
+	} );
+} );
+ + +

Other examples

+ + + + +
+ + \ No newline at end of file diff --git a/wqflask/wqflask/static/packages/TableTools/defaults.html b/wqflask/wqflask/static/packages/TableTools/defaults.html new file mode 100755 index 00000000..5ef74a68 --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/defaults.html @@ -0,0 +1,503 @@ + + + + + + + TableTools example + + + + + + + + +
+
+ TableTools example - changing the initialisation defaults +
+ +

Preamble

+

TableTools provides the ability to override the default initialisation parameters that are used when creating a new instance. This this particularly useful if you have multiple tables which you want to have the same TableTools behaviour - rather than declaring the structure multiple times, you can just set the defaults once. This example shows how to alter the default buttons.

+ + +

Live example

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Rendering engineBrowserPlatform(s)Engine versionCSS grade
Rendering engineBrowserPlatform(s)Engine versionCSS grade
TridentInternet Explorer 4.0Win 95+ (Entity: &)4X
TridentInternet Explorer 5.0Win 95+5C
TridentInternet Explorer 5.5Win 95+5.5A
TridentInternet Explorer 6Win 98+6A
TridentInternet Explorer 7Win XP SP2+7A
TridentAOL browser (AOL desktop)Win XP6A
Gecko (UTF-8: $¢€)Firefox 1.0Win 98+ / OSX.2+1.7A
GeckoFirefox 1.5Win 98+ / OSX.2+1.8A
GeckoFirefox 2.0Win 98+ / OSX.2+1.8A
GeckoFirefox 3.0Win 2k+ / OSX.3+1.9A
GeckoCamino 1.0OSX.2+1.8A
GeckoCamino 1.5OSX.3+1.8A
GeckoNetscape 7.2Win 95+ / Mac OS 8.6-9.21.7A
GeckoNetscape Browser 8Win 98SE+1.7A
GeckoNetscape Navigator 9Win 98+ / OSX.2+1.8A
GeckoMozilla 1.0Win 95+ / OSX.1+1A
GeckoMozilla 1.1Win 95+ / OSX.1+1.1A
GeckoMozilla 1.2Win 95+ / OSX.1+1.2A
GeckoMozilla 1.3Win 95+ / OSX.1+1.3A
GeckoMozilla 1.4Win 95+ / OSX.1+1.4A
GeckoMozilla 1.5Win 95+ / OSX.1+1.5A
GeckoMozilla 1.6Win 95+ / OSX.1+1.6A
GeckoMozilla 1.7Win 98+ / OSX.1+1.7A
GeckoMozilla 1.8Win 98+ / OSX.1+1.8A
GeckoSeamonkey 1.1Win 98+ / OSX.2+1.8A
GeckoEpiphany 2.20Gnome1.8A
WebkitSafari 1.2OSX.3125.5A
WebkitSafari 1.3OSX.3312.8A
WebkitSafari 2.0OSX.4+419.3A
WebkitSafari 3.0OSX.4+522.1A
WebkitOmniWeb 5.5OSX.4+420A
WebkitiPod Touch / iPhoneiPod420.1A
WebkitS60S60413A
PrestoOpera 7.0Win 95+ / OSX.1+-A
PrestoOpera 7.5Win 95+ / OSX.2+-A
PrestoOpera 8.0Win 95+ / OSX.2+-A
PrestoOpera 8.5Win 95+ / OSX.2+-A
PrestoOpera 9.0Win 95+ / OSX.3+-A
PrestoOpera 9.2Win 88+ / OSX.3+-A
PrestoOpera 9.5Win 88+ / OSX.3+-A
PrestoOpera for WiiWii-A
PrestoNokia N800N800-A
PrestoNintendo DS browserNintendo DS8.5C/A1
KHTMLKonqureror 3.1KDE 3.13.1C
KHTMLKonqureror 3.3KDE 3.33.3A
KHTMLKonqureror 3.5KDE 3.53.5A
TasmanInternet Explorer 4.5Mac OS 8-9-X
TasmanInternet Explorer 5.1Mac OS 7.6-91C
TasmanInternet Explorer 5.2Mac OS 8-X1C
MiscNetFront 3.1Embedded devices-C
MiscNetFront 3.4Embedded devices-A
MiscDillo 0.8Embedded devices-X
MiscLinksText only-X
MiscLynxText only-X
MiscIE MobileWindows Mobile 6-C
MiscPSP browserPSP-C
Other browsersAll others--U
+
+
+ + +

Initialisation code

+
$(document).ready( function () {
+	TableTools.DEFAULTS.aButtons = [ "copy", "csv", "xls" ];
+	
+	$('#example').dataTable( {
+		"sDom": 'T<"clear">lfrtip'
+	} );
+} );
+ + +

Other examples

+ + + + +
+ + \ No newline at end of file diff --git a/wqflask/wqflask/static/packages/TableTools/index.html b/wqflask/wqflask/static/packages/TableTools/index.html new file mode 100755 index 00000000..06a2442d --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/index.html @@ -0,0 +1,499 @@ + + + + + + + TableTools example + + + + + + + + +
+
+ TableTools example +
+ +

Preamble

+

This example shows the basic initialisation of TableTools by simply including the 'T' marker in DataTables' sDom parameter. This tell DataTables to insert the TableTools toolbar in that location. Remember to include the Javascript and CSS source files as well!

+

It is worth noting that you might need to set the sSwfPath parameter to tell TableTools where to find the SWF file for copy and file save.

+ +

Live example

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Rendering engineBrowserPlatform(s)Engine versionCSS grade
Rendering engineBrowserPlatform(s)Engine versionCSS grade
TridentInternet Explorer 4.0Win 95+ (Entity: &)4X
TridentInternet Explorer 5.0Win 95+5C
TridentInternet Explorer 5.5Win 95+5.5A
TridentInternet Explorer 6Win 98+6A
TridentInternet Explorer 7Win XP SP2+7A
TridentAOL browser (AOL desktop)Win XP6A
Gecko (UTF-8: $¢€ היצוא)Firefox 1.0Win 98+ / OSX.2+1.7A
GeckoFirefox 1.5Win 98+ / OSX.2+1.8A
GeckoFirefox 2.0Win 98+ / OSX.2+1.8A
GeckoFirefox 3.0Win 2k+ / OSX.3+1.9A
GeckoCamino 1.0OSX.2+1.8A
GeckoCamino 1.5OSX.3+1.8A
GeckoNetscape 7.2Win 95+ / Mac OS 8.6-9.21.7A
GeckoNetscape Browser 8Win 98SE+1.7A
GeckoNetscape Navigator 9Win 98+ / OSX.2+1.8A
GeckoMozilla 1.0Win 95+ / OSX.1+1A
GeckoMozilla 1.1Win 95+ / OSX.1+1.1A
GeckoMozilla 1.2Win 95+ / OSX.1+1.2A
GeckoMozilla 1.3Win 95+ / OSX.1+1.3A
GeckoMozilla 1.4Win 95+ / OSX.1+1.4A
GeckoMozilla 1.5Win 95+ / OSX.1+1.5A
GeckoMozilla 1.6Win 95+ / OSX.1+1.6A
GeckoMozilla 1.7Win 98+ / OSX.1+1.7A
GeckoMozilla 1.8Win 98+ / OSX.1+1.8A
GeckoSeamonkey 1.1Win 98+ / OSX.2+1.8A
GeckoEpiphany 2.20Gnome1.8A
WebkitSafari 1.2OSX.3125.5A
WebkitSafari 1.3OSX.3312.8A
WebkitSafari 2.0OSX.4+419.3A
WebkitSafari 3.0OSX.4+522.1A
WebkitOmniWeb 5.5OSX.4+420A
WebkitiPod Touch / iPhoneiPod420.1A
WebkitS60S60413A
PrestoOpera 7.0Win 95+ / OSX.1+-A
PrestoOpera 7.5Win 95+ / OSX.2+-A
PrestoOpera 8.0Win 95+ / OSX.2+-A
PrestoOpera 8.5Win 95+ / OSX.2+-A
PrestoOpera 9.0Win 95+ / OSX.3+-A
PrestoOpera 9.2Win 88+ / OSX.3+-A
PrestoOpera 9.5Win 88+ / OSX.3+-A
PrestoOpera for WiiWii-A
PrestoNokia N800N800-A
PrestoNintendo DS browserNintendo DS8.5C/A1
KHTMLKonqureror 3.1KDE 3.13.1C
KHTMLKonqureror 3.3KDE 3.33.3A
KHTMLKonqureror 3.5KDE 3.53.5A
TasmanInternet Explorer 4.5Mac OS 8-9-X
TasmanInternet Explorer 5.1Mac OS 7.6-91C
TasmanInternet Explorer 5.2Mac OS 8-X1C
MiscNetFront 3.1Embedded devices-C
MiscNetFront 3.4Embedded devices-A
MiscDillo 0.8Embedded devices-X
MiscLinksText only-X
MiscLynxText only-X
MiscIE MobileWindows Mobile 6-C
MiscPSP browserPSP-C
Other browsersAll others--U
+
+
+ + +

Initialisation code

+
$(document).ready( function () {
+	$('#example').dataTable( {
+		"sDom": 'T<"clear">lfrtip'
+	} );
+} );
+ + +

Other examples

+ + + + +
+ + \ No newline at end of file diff --git a/wqflask/wqflask/static/packages/TableTools/media/as3/ZeroClipboard.as b/wqflask/wqflask/static/packages/TableTools/media/as3/ZeroClipboard.as new file mode 100755 index 00000000..d6b9c072 --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/media/as3/ZeroClipboard.as @@ -0,0 +1,221 @@ +/* Compile using: mxmlc --target-player=10.0.0 ZeroClipboard.as */ +package { + import flash.display.Stage; + import flash.display.Sprite; + import flash.display.LoaderInfo; + import flash.display.StageScaleMode; + import flash.events.*; + import flash.display.StageAlign; + import flash.display.StageScaleMode; + import flash.external.ExternalInterface; + import flash.system.Security; + import flash.utils.*; + import flash.system.System; + import flash.net.FileReference; + import flash.net.FileFilter; + + public class ZeroClipboard extends Sprite { + + private var domId:String = ''; + private var button:Sprite; + private var clipText:String = 'blank'; + private var fileName:String = ''; + private var action:String = 'copy'; + private var incBom:Boolean = true; + private var charSet:String = 'utf8'; + + + public function ZeroClipboard() { + // constructor, setup event listeners and external interfaces + stage.scaleMode = StageScaleMode.EXACT_FIT; + flash.system.Security.allowDomain("*"); + + // import flashvars + var flashvars:Object = LoaderInfo( this.root.loaderInfo ).parameters; + domId = flashvars.id.split("\\").join("\\\\"); + + // invisible button covers entire stage + button = new Sprite(); + button.buttonMode = true; + button.useHandCursor = true; + button.graphics.beginFill(0x00FF00); + button.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); + button.alpha = 0.0; + addChild(button); + + button.addEventListener(MouseEvent.CLICK, clickHandler); + button.addEventListener(MouseEvent.MOUSE_OVER, function(event:Event):void { + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseOver', null ); + } ); + button.addEventListener(MouseEvent.MOUSE_OUT, function(event:Event):void { + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseOut', null ); + } ); + button.addEventListener(MouseEvent.MOUSE_DOWN, function(event:Event):void { + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseDown', null ); + } ); + button.addEventListener(MouseEvent.MOUSE_UP, function(event:Event):void { + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseUp', null ); + } ); + + // External functions - readd whenever the stage is made active for IE + addCallbacks(); + stage.addEventListener(Event.ACTIVATE, addCallbacks); + + // signal to the browser that we are ready + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'load', null ); + } + + public function addCallbacks (evt:Event = null):void { + ExternalInterface.addCallback("setHandCursor", setHandCursor); + ExternalInterface.addCallback("clearText", clearText); + ExternalInterface.addCallback("setText", setText); + ExternalInterface.addCallback("appendText", appendText); + ExternalInterface.addCallback("setFileName", setFileName); + ExternalInterface.addCallback("setAction", setAction); + ExternalInterface.addCallback("setCharSet", setCharSet); + ExternalInterface.addCallback("setBomInc", setBomInc); + } + + + public function setCharSet(newCharSet:String):void { + if ( newCharSet == 'UTF16LE' ) { + charSet = newCharSet; + } else { + charSet = 'UTF8'; + } + } + + public function setBomInc(newBomInc:Boolean):void { + incBom = newBomInc; + } + + public function clearText():void { + clipText = ''; + } + + public function appendText(newText:String):void { + clipText += newText; + } + + public function setText(newText:String):void { + clipText = newText; + } + + public function setFileName(newFileName:String):void { + fileName = newFileName; + } + + public function setAction(newAction:String):void { + action = newAction; + } + + public function setHandCursor(enabled:Boolean):void { + // control whether the hand cursor is shown on rollover (true) + // or the default arrow cursor (false) + button.useHandCursor = enabled; + } + + + private function clickHandler(event:Event):void { + var fileRef:FileReference = new FileReference(); + fileRef.addEventListener(Event.COMPLETE, saveComplete); + + if ( action == "save" ) { + /* Save as a file */ + if ( charSet == 'UTF16LE' ) { + fileRef.save( strToUTF16LE(clipText), fileName ); + } else { + fileRef.save( strToUTF8(clipText), fileName ); + } + } else if ( action == "pdf" ) { + fileRef.save( "This instance of ZeroClipboard is not configured for PDF export. "+ + "Please use the PDF export version.", fileName+".txt" ); + } else { + /* Copy the text to the clipboard. Note charset and BOM have no effect here */ + System.setClipboard( clipText ); + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'complete', clipText ); + } + } + + + private function saveComplete(event:Event):void { + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'complete', clipText ); + } + + + private function getProp( prop:String, opts:Array ):String + { + var i:int, iLen:int; + for ( i=0, iLen=opts.length ; i> 8 ); + } + + i++; + } + + return utf16; + } + } +} diff --git a/wqflask/wqflask/static/packages/TableTools/media/as3/ZeroClipboardPdf.as b/wqflask/wqflask/static/packages/TableTools/media/as3/ZeroClipboardPdf.as new file mode 100755 index 00000000..158d5f18 --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/media/as3/ZeroClipboardPdf.as @@ -0,0 +1,310 @@ +/* Compile using: mxmlc --target-player=10.0.0 -static-link-runtime-shared-libraries=true -library-path+=lib ZeroClipboardPdf.as */ +package { + import flash.display.Stage; + import flash.display.Sprite; + import flash.display.LoaderInfo; + import flash.display.StageScaleMode; + import flash.events.*; + import flash.display.StageAlign; + import flash.display.StageScaleMode; + import flash.external.ExternalInterface; + import flash.system.Security; + import flash.utils.*; + import flash.system.System; + import flash.net.FileReference; + import flash.net.FileFilter; + + /* PDF imports */ + import org.alivepdf.pdf.PDF; + import org.alivepdf.data.Grid; + import org.alivepdf.data.GridColumn; + import org.alivepdf.layout.Orientation; + import org.alivepdf.layout.Size; + import org.alivepdf.layout.Unit; + import org.alivepdf.display.Display; + import org.alivepdf.saving.Method; + import org.alivepdf.fonts.FontFamily; + import org.alivepdf.fonts.Style; + import org.alivepdf.fonts.CoreFont; + import org.alivepdf.colors.RGBColor; + + public class ZeroClipboard extends Sprite { + + private var domId:String = ''; + private var button:Sprite; + private var clipText:String = 'blank'; + private var fileName:String = ''; + private var action:String = 'copy'; + private var incBom:Boolean = true; + private var charSet:String = 'utf8'; + + + public function ZeroClipboard() { + // constructor, setup event listeners and external interfaces + stage.scaleMode = StageScaleMode.EXACT_FIT; + flash.system.Security.allowDomain("*"); + + // import flashvars + var flashvars:Object = LoaderInfo( this.root.loaderInfo ).parameters; + domId = flashvars.id.split("\\").join("\\\\"); + + // invisible button covers entire stage + button = new Sprite(); + button.buttonMode = true; + button.useHandCursor = true; + button.graphics.beginFill(0x00FF00); + button.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); + button.alpha = 0.0; + addChild(button); + + button.addEventListener(MouseEvent.CLICK, function(event:Event):void { + clickHandler(event); + } ); + button.addEventListener(MouseEvent.MOUSE_OVER, function(event:Event):void { + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseOver', null ); + } ); + button.addEventListener(MouseEvent.MOUSE_OUT, function(event:Event):void { + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseOut', null ); + } ); + button.addEventListener(MouseEvent.MOUSE_DOWN, function(event:Event):void { + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseDown', null ); + } ); + button.addEventListener(MouseEvent.MOUSE_UP, function(event:Event):void { + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseUp', null ); + } ); + + // External functions - readd whenever the stage is made active for IE + addCallbacks(); + stage.addEventListener(Event.ACTIVATE, addCallbacks); + + // signal to the browser that we are ready + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'load', null ); + } + + public function addCallbacks (evt:Event = null):void { + ExternalInterface.addCallback("setHandCursor", setHandCursor); + ExternalInterface.addCallback("clearText", clearText); + ExternalInterface.addCallback("setText", setText); + ExternalInterface.addCallback("appendText", appendText); + ExternalInterface.addCallback("setFileName", setFileName); + ExternalInterface.addCallback("setAction", setAction); + ExternalInterface.addCallback("setCharSet", setCharSet); + ExternalInterface.addCallback("setBomInc", setBomInc); + } + + + public function setCharSet(newCharSet:String):void { + if ( newCharSet == 'UTF16LE' ) { + charSet = newCharSet; + } else { + charSet = 'UTF8'; + } + } + + public function setBomInc(newBomInc:Boolean):void { + incBom = newBomInc; + } + + public function clearText():void { + clipText = ''; + } + + public function appendText(newText:String):void { + clipText += newText; + } + + public function setText(newText:String):void { + clipText = newText; + } + + public function setFileName(newFileName:String):void { + fileName = newFileName; + } + + public function setAction(newAction:String):void { + action = newAction; + } + + public function setHandCursor(enabled:Boolean):void { + // control whether the hand cursor is shown on rollover (true) + // or the default arrow cursor (false) + button.useHandCursor = enabled; + } + + + private function clickHandler(event:Event):void { + var fileRef:FileReference = new FileReference(); + fileRef.addEventListener(Event.COMPLETE, saveComplete); + + if ( action == "save" ) { + /* Save as a file */ + if ( charSet == 'UTF16LE' ) { + fileRef.save( strToUTF16LE(clipText), fileName ); + } else { + fileRef.save( strToUTF8(clipText), fileName ); + } + } else if ( action == "pdf" ) { + /* Save as a PDF */ + var pdf:PDF = configPdf(); + fileRef.save( pdf.save( Method.LOCAL ), fileName ); + } else { + /* Copy the text to the clipboard. Note charset and BOM have no effect here */ + System.setClipboard( clipText ); + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'complete', clipText ); + } + } + + + private function saveComplete(event:Event):void { + ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'complete', clipText ); + } + + + private function getProp( prop:String, opts:Array ):String + { + var i:int, iLen:int; + for ( i=0, iLen=opts.length ; i> 8 ); + } + + i++; + } + + return utf16; + } + } +} diff --git a/wqflask/wqflask/static/packages/TableTools/media/as3/lib/AlivePDF.swc b/wqflask/wqflask/static/packages/TableTools/media/as3/lib/AlivePDF.swc new file mode 100644 index 00000000..ee0f3f8f Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/as3/lib/AlivePDF.swc differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/css/TableTools.css b/wqflask/wqflask/static/packages/TableTools/media/css/TableTools.css new file mode 100755 index 00000000..705008b0 --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/media/css/TableTools.css @@ -0,0 +1,321 @@ +/* + * File: TableTools.css + * Description: Styles for TableTools 2 + * Author: Allan Jardine (www.sprymedia.co.uk) + * Language: Javascript + * License: GPL v2 / 3 point BSD + * Project: DataTables + * + * Copyright 2009-2012 Allan Jardine, all rights reserved. + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * CSS name space: + * DTTT DataTables TableTools + * + * Style sheet provides: + * CONTAINER TableTools container element and styles applying to all components + * BUTTON_STYLES Action specific button styles + * SELECTING Row selection styles + * COLLECTIONS Drop down list (collection) styles + * PRINTING Print display styles + */ + + +/* + * CONTAINER + * TableTools container element and styles applying to all components + */ +div.DTTT_container { + position: relative; + float: right; + margin-bottom: 1em; +} + +button.DTTT_button, +div.DTTT_button, +a.DTTT_button { + position: relative; + float: left; + margin-right: 3px; + padding: 5px 8px; + border: 1px solid #999; + cursor: pointer; + *cursor: hand; + font-size: 0.88em; + color: black !important; + + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + -ms-border-radius: 2px; + -o-border-radius: 2px; + border-radius: 2px; + + -webkit-box-shadow: 1px 1px 3px #ccc; + -moz-box-shadow: 1px 1px 3px #ccc; + -ms-box-shadow: 1px 1px 3px #ccc; + -o-box-shadow: 1px 1px 3px #ccc; + box-shadow: 1px 1px 3px #ccc; + + /* Generated by http://www.colorzilla.com/gradient-editor/ */ + background: #ffffff; /* Old browsers */ + background: -webkit-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* Chrome10+,Safari5.1+ */ + background: -moz-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* FF3.6+ */ + background: -ms-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* IE10+ */ + background: -o-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* Opera 11.10+ */ + background: linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f9f9f9',GradientType=0 ); /* IE6-9 */ +} + + +/* Buttons are cunning border-box sizing - we can't just use that for A and DIV due to IE6/7 */ +button.DTTT_button { + height: 30px; + padding: 3px 8px; +} + +.DTTT_button embed { + outline: none; +} + +button.DTTT_button:hover, +div.DTTT_button:hover, +a.DTTT_button:hover { + border: 1px solid #666; + text-decoration: none !important; + + -webkit-box-shadow: 1px 1px 3px #999; + -moz-box-shadow: 1px 1px 3px #999; + -ms-box-shadow: 1px 1px 3px #999; + -o-box-shadow: 1px 1px 3px #999; + box-shadow: 1px 1px 3px #999; + + background: #f3f3f3; /* Old browsers */ + background: -webkit-linear-gradient(top, #f3f3f3 0%,#e2e2e2 89%,#f4f4f4 100%); /* Chrome10+,Safari5.1+ */ + background: -moz-linear-gradient(top, #f3f3f3 0%,#e2e2e2 89%,#f4f4f4 100%); /* FF3.6+ */ + background: -ms-linear-gradient(top, #f3f3f3 0%,#e2e2e2 89%,#f4f4f4 100%); /* IE10+ */ + background: -o-linear-gradient(top, #f3f3f3 0%,#e2e2e2 89%,#f4f4f4 100%); /* Opera 11.10+ */ + background: linear-gradient(top, #f3f3f3 0%,#e2e2e2 89%,#f4f4f4 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f3f3f3', endColorstr='#f4f4f4',GradientType=0 ); /* IE6-9 */ +} + +button.DTTT_disabled, +div.DTTT_disabled, +a.DTTT_disabled { + color: #999; + border: 1px solid #d0d0d0; + + background: #ffffff; /* Old browsers */ + background: -webkit-linear-gradient(top, #ffffff 0%,#f9f9f9 89%,#fafafa 100%); /* Chrome10+,Safari5.1+ */ + background: -moz-linear-gradient(top, #ffffff 0%,#f9f9f9 89%,#fafafa 100%); /* FF3.6+ */ + background: -ms-linear-gradient(top, #ffffff 0%,#f9f9f9 89%,#fafafa 100%); /* IE10+ */ + background: -o-linear-gradient(top, #ffffff 0%,#f9f9f9 89%,#fafafa 100%); /* Opera 11.10+ */ + background: linear-gradient(top, #ffffff 0%,#f9f9f9 89%,#fafafa 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#fafafa',GradientType=0 ); /* IE6-9 */ +} + + + +/* + * BUTTON_STYLES + * Action specific button styles + * If you want images - comment this back in + +a.DTTT_button_csv, +a.DTTT_button_xls, +a.DTTT_button_copy, +a.DTTT_button_pdf, +a.DTTT_button_print { + padding-right: 0px; +} + +a.DTTT_button_csv span, +a.DTTT_button_xls span, +a.DTTT_button_copy span, +a.DTTT_button_pdf span, +a.DTTT_button_print span { + display: inline-block; + height: 24px; + line-height: 24px; + padding-right: 30px; +} + + +a.DTTT_button_csv span { background: url(../images/csv.png) no-repeat bottom right; } +a.DTTT_button_csv:hover span { background: url(../images/csv_hover.png) no-repeat center right; } + +a.DTTT_button_xls span { background: url(../images/xls.png) no-repeat center right; } +a.DTTT_button_xls:hover span { background: #f0f0f0 url(../images/xls_hover.png) no-repeat center right; } + +a.DTTT_button_copy span { background: url(../images/copy.png) no-repeat center right; } +a.DTTT_button_copy:hover span { background: #f0f0f0 url(../images/copy_hover.png) no-repeat center right; } + +a.DTTT_button_pdf span { background: url(../images/pdf.png) no-repeat center right; } +a.DTTT_button_pdf:hover span { background: #f0f0f0 url(../images/pdf_hover.png) no-repeat center right; } + +a.DTTT_button_print span { background: url(../images/print.png) no-repeat center right; } +a.DTTT_button_print:hover span { background: #f0f0f0 url(../images/print_hover.png) no-repeat center right; } + + */ + +button.DTTT_button_collection span { + padding-right: 17px; + background: url(../images/collection.png) no-repeat center right; +} + +button.DTTT_button_collection:hover span { + padding-right: 17px; + background: #f0f0f0 url(../images/collection_hover.png) no-repeat center right; +} + + +/* + * SELECTING + * Row selection styles + */ +table.DTTT_selectable tbody tr { + cursor: pointer; + *cursor: hand; +} + +table.dataTable tr.DTTT_selected.odd { + background-color: #9FAFD1; +} + +table.dataTable tr.DTTT_selected.odd td.sorting_1 { + background-color: #9FAFD1; +} + +table.dataTable tr.DTTT_selected.odd td.sorting_2 { + background-color: #9FAFD1; +} + +table.dataTable tr.DTTT_selected.odd td.sorting_3 { + background-color: #9FAFD1; +} + + +table.dataTable tr.DTTT_selected.even { + background-color: #B0BED9; +} + +table.dataTable tr.DTTT_selected.even td.sorting_1 { + background-color: #B0BED9; +} + +table.dataTable tr.DTTT_selected.even td.sorting_2 { + background-color: #B0BED9; +} + +table.dataTable tr.DTTT_selected.even td.sorting_3 { + background-color: #B0BED9; +} + + +/* + * COLLECTIONS + * Drop down list (collection) styles + */ + +div.DTTT_collection { + width: 150px; + padding: 8px 8px 4px 8px; + border: 1px solid #ccc; + border: 1px solid rgba( 0, 0, 0, 0.4 ); + background-color: #f3f3f3; + background-color: rgba( 255, 255, 255, 0.3 ); + overflow: hidden; + z-index: 2002; + + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + -ms-border-radius: 5px; + -o-border-radius: 5px; + border-radius: 5px; + + -webkit-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3); + -moz-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3); + -ms-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3); + -o-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3); + box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3); +} + +div.DTTT_collection_background { + background: transparent url(../images/background.png) repeat top left; + z-index: 2001; +} + +div.DTTT_collection button.DTTT_button, +div.DTTT_collection div.DTTT_button, +div.DTTT_collection a.DTTT_button { + position: relative; + left: 0; + right: 0; + + display: block; + float: none; + margin-bottom: 4px; + + -webkit-box-shadow: 1px 1px 3px #999; + -moz-box-shadow: 1px 1px 3px #999; + -ms-box-shadow: 1px 1px 3px #999; + -o-box-shadow: 1px 1px 3px #999; + box-shadow: 1px 1px 3px #999; +} + + +/* + * PRINTING + * Print display styles + */ + +.DTTT_print_info { + position: fixed; + top: 50%; + left: 50%; + width: 400px; + height: 150px; + margin-left: -200px; + margin-top: -75px; + text-align: center; + color: #333; + padding: 10px 30px; + + background: #ffffff; /* Old browsers */ + background: -webkit-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* Chrome10+,Safari5.1+ */ + background: -moz-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* FF3.6+ */ + background: -ms-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* IE10+ */ + background: -o-linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* Opera 11.10+ */ + background: linear-gradient(top, #ffffff 0%,#f3f3f3 89%,#f9f9f9 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f9f9f9',GradientType=0 ); /* IE6-9 */ + + opacity: 0.95; + + border: 1px solid black; + border: 1px solid rgba(0, 0, 0, 0.5); + + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + -ms-border-radius: 6px; + -o-border-radius: 6px; + border-radius: 6px; + + -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.5); + -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.5); + -ms-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.5); + -o-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.5); + box-shadow: 0 3px 7px rgba(0, 0, 0, 0.5); +} + +.DTTT_print_info h6 { + font-weight: normal; + font-size: 28px; + line-height: 28px; + margin: 1em; +} + +.DTTT_print_info p { + font-size: 14px; + line-height: 20px; +} + diff --git a/wqflask/wqflask/static/packages/TableTools/media/css/TableTools_JUI.css b/wqflask/wqflask/static/packages/TableTools/media/css/TableTools_JUI.css new file mode 100755 index 00000000..4c41138e --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/media/css/TableTools_JUI.css @@ -0,0 +1,185 @@ +/* + * File: TableTools.css + * Description: Styles for TableTools 2 with JUI theming + * Author: Allan Jardine (www.sprymedia.co.uk) + * Language: Javascript + * License: LGPL / 3 point BSD + * Project: DataTables + * + * Copyright 2010 Allan Jardine, all rights reserved. + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Notes: + * Generally speaking, please refer to the TableTools.css file - this file contains basic + * modifications to that 'master' stylesheet for ThemeRoller. + * + * CSS name space: + * DTTT DataTables TableTools + * + * Colour dictionary: + * Button border #d0d0d0 + * Button border hover #999999 + * Hover background #f0f0f0 + * Action blue #4b66d9 + * + * Style sheet provides: + * CONTAINER TableTools container element and styles applying to all components + * SELECTING Row selection styles + * COLLECTIONS Drop down list (collection) styles + * PRINTING Print display styles + * MISC Minor misc styles + */ + + +/* + * CONTAINER + * TableTools container element and styles applying to all components + */ +div.DTTT_container { + position: relative; + float: left; +} + +.DTTT_button { + position: relative; + float: left; + margin-right: 3px; + padding: 3px 10px; + border: 1px solid #d0d0d0; + background-color: #fff; + color: #333 !important; + cursor: pointer; + *cursor: hand; +} + +.DTTT_button::-moz-focus-inner { + border: none !important; + padding: 0; +} + + + +/* + * SELECTING + * Row selection styles + */ +table.DTTT_selectable tbody tr { + cursor: pointer; + *cursor: hand; +} + +table.dataTable tr.DTTT_selected.odd { + background-color: #9FAFD1; +} + +table.dataTable tr.DTTT_selected.odd td.sorting_1 { + background-color: #9FAFD1; +} + +table.dataTable tr.DTTT_selected.odd td.sorting_2 { + background-color: #9FAFD1; +} + +table.dataTable tr.DTTT_selected.odd td.sorting_3 { + background-color: #9FAFD1; +} + + +table.dataTable tr.DTTT_selected.even { + background-color: #B0BED9; +} + +table.dataTable tr.DTTT_selected.even td.sorting_1 { + background-color: #B0BED9; +} + +table.dataTable tr.DTTT_selected.even td.sorting_2 { + background-color: #B0BED9; +} + +table.dataTable tr.DTTT_selected.even td.sorting_3 { + background-color: #B0BED9; +} + + +/* + * COLLECTIONS + * Drop down list (collection) styles + */ + +div.DTTT_collection { + width: 150px; + background-color: #f3f3f3; + overflow: hidden; + z-index: 2002; + + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5); + -moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5); + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5); +} + +div.DTTT_collection_background { + background: url(../images/background.png) repeat top left; + z-index: 2001; +} + +div.DTTT_collection button.DTTT_button, +div.DTTT_collection div.DTTT_button, +div.DTTT_collection a.DTTT_button { + float: none; + width: 100%; + margin-bottom: -0.1em; +} + + +/* + * PRINTING + * Print display styles + */ + +.DTTT_print_info { + position: fixed; + top: 50%; + left: 50%; + width: 400px; + height: 150px; + margin-left: -200px; + margin-top: -75px; + text-align: center; + background-color: #3f3f3f; + color: white; + padding: 10px 30px; + + opacity: 0.9; + + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5); + -moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5); + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5); +} + +.DTTT_print_info h6 { + font-weight: normal; + font-size: 28px; + line-height: 28px; + margin: 1em; +} + +.DTTT_print_info p { + font-size: 14px; + line-height: 20px; +} + + +/* + * MISC + * Minor misc styles + */ + +.DTTT_disabled { + color: #999; +} diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/background.png b/wqflask/wqflask/static/packages/TableTools/media/images/background.png new file mode 100644 index 00000000..915efba6 Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/background.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/collection.png b/wqflask/wqflask/static/packages/TableTools/media/images/collection.png new file mode 100644 index 00000000..5dd4dfdf Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/collection.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/collection_hover.png b/wqflask/wqflask/static/packages/TableTools/media/images/collection_hover.png new file mode 100644 index 00000000..7b37b1e9 Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/collection_hover.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/copy.png b/wqflask/wqflask/static/packages/TableTools/media/images/copy.png new file mode 100755 index 00000000..5b01ab16 Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/copy.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/copy_hover.png b/wqflask/wqflask/static/packages/TableTools/media/images/copy_hover.png new file mode 100755 index 00000000..039a7fc3 Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/copy_hover.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/csv.png b/wqflask/wqflask/static/packages/TableTools/media/images/csv.png new file mode 100755 index 00000000..43df1559 Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/csv.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/csv_hover.png b/wqflask/wqflask/static/packages/TableTools/media/images/csv_hover.png new file mode 100755 index 00000000..10b34d3b Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/csv_hover.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/pdf.png b/wqflask/wqflask/static/packages/TableTools/media/images/pdf.png new file mode 100644 index 00000000..1b038d08 Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/pdf.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/pdf_hover.png b/wqflask/wqflask/static/packages/TableTools/media/images/pdf_hover.png new file mode 100644 index 00000000..eb06855f Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/pdf_hover.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/print.png b/wqflask/wqflask/static/packages/TableTools/media/images/print.png new file mode 100755 index 00000000..2db08242 Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/print.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/print_hover.png b/wqflask/wqflask/static/packages/TableTools/media/images/print_hover.png new file mode 100755 index 00000000..9808a9cc Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/print_hover.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/psd/collection.psd b/wqflask/wqflask/static/packages/TableTools/media/images/psd/collection.psd new file mode 100644 index 00000000..7eb7caf2 Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/psd/collection.psd differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/psd/copy document.psd b/wqflask/wqflask/static/packages/TableTools/media/images/psd/copy document.psd new file mode 100755 index 00000000..ca207adc Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/psd/copy document.psd differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/psd/file_types.psd b/wqflask/wqflask/static/packages/TableTools/media/images/psd/file_types.psd new file mode 100755 index 00000000..0f280ad5 Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/psd/file_types.psd differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/psd/printer.psd b/wqflask/wqflask/static/packages/TableTools/media/images/psd/printer.psd new file mode 100755 index 00000000..8c33f7aa Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/psd/printer.psd differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/xls.png b/wqflask/wqflask/static/packages/TableTools/media/images/xls.png new file mode 100755 index 00000000..5aaf40d0 Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/xls.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/images/xls_hover.png b/wqflask/wqflask/static/packages/TableTools/media/images/xls_hover.png new file mode 100755 index 00000000..5b1930af Binary files /dev/null and b/wqflask/wqflask/static/packages/TableTools/media/images/xls_hover.png differ diff --git a/wqflask/wqflask/static/packages/TableTools/media/js/TableTools.js b/wqflask/wqflask/static/packages/TableTools/media/js/TableTools.js new file mode 100755 index 00000000..3c3ae911 --- /dev/null +++ b/wqflask/wqflask/static/packages/TableTools/media/js/TableTools.js @@ -0,0 +1,2476 @@ +/* + * File: TableTools.js + * Version: 2.1.5 + * Description: Tools and buttons for DataTables + * Author: Allan Jardine (www.sprymedia.co.uk) + * Language: Javascript + * License: GPL v2 or BSD 3 point style + * Project: DataTables + * + * Copyright 2009-2013 Allan Jardine, all rights reserved. + * + * This source file is free software, under either the GPL v2 license or a + * BSD style license, available at: + * http://datatables.net/license_gpl2 + * http://datatables.net/license_bsd + */ + +/* Global scope for TableTools */ +var TableTools; + +(function($, window, document) { + +/** + * TableTools provides flexible buttons and other tools for a DataTables enhanced table + * @class TableTools + * @constructor + * @param {Object} oDT DataTables instance + * @param {Object} oOpts TableTools options + * @param {String} oOpts.sSwfPath ZeroClipboard SWF path + * @param {String} oOpts.sRowSelect Row selection options - 'none', 'single' or 'multi' + * @param {Function} oOpts.fnPreRowSelect Callback function just prior to row selection + * @param {Function} oOpts.fnRowSelected Callback function just after row selection + * @param {Function} oOpts.fnRowDeselected Callback function when row is deselected + * @param {Array} oOpts.aButtons List of buttons to be used + */ +TableTools = function( oDT, oOpts ) +{ + /* Santiy check that we are a new instance */ + if ( ! this instanceof TableTools ) + { + alert( "Warning: TableTools must be initialised with the keyword 'new'" ); + } + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Public class variables + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + /** + * @namespace Settings object which contains customisable information for TableTools instance + */ + this.s = { + /** + * Store 'this' so the instance can be retrieved from the settings object + * @property that + * @type object + * @default this + */ + "that": this, + + /** + * DataTables settings objects + * @property dt + * @type object + * @default From the oDT init option + */ + "dt": oDT.fnSettings(), + + /** + * @namespace Print specific information + */ + "print": { + /** + * DataTables draw 'start' point before the printing display was shown + * @property saveStart + * @type int + * @default -1 + */ + "saveStart": -1, + + /** + * DataTables draw 'length' point before the printing display was shown + * @property saveLength + * @type int + * @default -1 + */ + "saveLength": -1, + + /** + * Page scrolling point before the printing display was shown so it can be restored + * @property saveScroll + * @type int + * @default -1 + */ + "saveScroll": -1, + + /** + * Wrapped function to end the print display (to maintain scope) + * @property funcEnd + * @type Function + * @default function () {} + */ + "funcEnd": function () {} + }, + + /** + * A unique ID is assigned to each button in each instance + * @property buttonCounter + * @type int + * @default 0 + */ + "buttonCounter": 0, + + /** + * @namespace Select rows specific information + */ + "select": { + /** + * Select type - can be 'none', 'single' or 'multi' + * @property type + * @type string + * @default "" + */ + "type": "", + + /** + * Array of nodes which are currently selected + * @property selected + * @type array + * @default [] + */ + "selected": [], + + /** + * Function to run before the selection can take place. Will cancel the select if the + * function returns false + * @property preRowSelect + * @type Function + * @default null + */ + "preRowSelect": null, + + /** + * Function to run when a row is selected + * @property postSelected + * @type Function + * @default null + */ + "postSelected": null, + + /** + * Function to run when a row is deselected + * @property postDeselected + * @type Function + * @default null + */ + "postDeselected": null, + + /** + * Indicate if all rows are selected (needed for server-side processing) + * @property all + * @type boolean + * @default false + */ + "all": false, + + /** + * Class name to add to selected TR nodes + * @property selectedClass + * @type String + * @default "" + */ + "selectedClass": "" + }, + + /** + * Store of the user input customisation object + * @property custom + * @type object + * @default {} + */ + "custom": {}, + + /** + * SWF movie path + * @property swfPath + * @type string + * @default "" + */ + "swfPath": "", + + /** + * Default button set + * @property buttonSet + * @type array + * @default [] + */ + "buttonSet": [], + + /** + * When there is more than one TableTools instance for a DataTable, there must be a + * master which controls events (row selection etc) + * @property master + * @type boolean + * @default false + */ + "master": false, + + /** + * Tag names that are used for creating collections and buttons + * @namesapce + */ + "tags": {} + }; + + + /** + * @namespace Common and useful DOM elements for the class instance + */ + this.dom = { + /** + * DIV element that is create and all TableTools buttons (and their children) put into + * @property container + * @type node + * @default null + */ + "container": null, + + /** + * The table node to which TableTools will be applied + * @property table + * @type node + * @default null + */ + "table": null, + + /** + * @namespace Nodes used for the print display + */ + "print": { + /** + * Nodes which have been removed from the display by setting them to display none + * @property hidden + * @type array + * @default [] + */ + "hidden": [], + + /** + * The information display saying telling the user about the print display + * @property message + * @type node + * @default null + */ + "message": null + }, + + /** + * @namespace Nodes used for a collection display. This contains the currently used collection + */ + "collection": { + /** + * The div wrapper containing the buttons in the collection (i.e. the menu) + * @property collection + * @type node + * @default null + */ + "collection": null, + + /** + * Background display to provide focus and capture events + * @property background + * @type node + * @default null + */ + "background": null + } + }; + + /** + * @namespace Name space for the classes that this TableTools instance will use + * @extends TableTools.classes + */ + this.classes = $.extend( true, {}, TableTools.classes ); + if ( this.s.dt.bJUI ) + { + $.extend( true, this.classes, TableTools.classes_themeroller ); + } + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Public class methods + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + /** + * Retreieve the settings object from an instance + * @method fnSettings + * @returns {object} TableTools settings object + */ + this.fnSettings = function () { + return this.s; + }; + + + /* Constructor logic */ + if ( typeof oOpts == 'undefined' ) + { + oOpts = {}; + } + + this._fnConstruct( oOpts ); + + return this; +}; + + + +TableTools.prototype = { + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Public methods + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + /** + * Retreieve the settings object from an instance + * @returns {array} List of TR nodes which are currently selected + * @param {boolean} [filtered=false] Get only selected rows which are + * available given the filtering applied to the table. By default + * this is false - i.e. all rows, regardless of filtering are + selected. + */ + "fnGetSelected": function ( filtered ) + { + var + out = [], + data = this.s.dt.aoData, + displayed = this.s.dt.aiDisplay, + i, iLen; + + if ( filtered ) + { + // Only consider filtered rows + for ( i=0, iLen=displayed.length ; i 0 ) + { + sTitle = anTitle[0].innerHTML; + } + } + + /* Strip characters which the OS will object to - checking for UTF8 support in the scripting + * engine + */ + if ( "\u00A1".toString().length < 4 ) { + return sTitle.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g, ""); + } else { + return sTitle.replace(/[^a-zA-Z0-9_\.,\-_ !\(\)]/g, ""); + } + }, + + + /** + * Calculate a unity array with the column width by proportion for a set of columns to be + * included for a button. This is particularly useful for PDF creation, where we can use the + * column widths calculated by the browser to size the columns in the PDF. + * @param {Object} oConfig Button configuration object + * @returns {Array} Unity array of column ratios + */ + "fnCalcColRatios": function ( oConfig ) + { + var + aoCols = this.s.dt.aoColumns, + aColumnsInc = this._fnColumnTargets( oConfig.mColumns ), + aColWidths = [], + iWidth = 0, iTotal = 0, i, iLen; + + for ( i=0, iLen=aColumnsInc.length ; i