From cd0972c759924b2a4ab33b4f54f61e8ec1cc9afa Mon Sep 17 00:00:00 2001 From: Max Guglielmi Date: Mon, 6 Apr 2015 18:45:46 +1000 Subject: [PATCH] Started ezEditTable integration --- Gruntfile.js | 5 + dist/extensions/ezEditTable/docs/doc.html | 2049 ++++ .../ezEditTable/docs/doc_class.html | 154 + .../ezEditTable/docs/doc_methods.html | 599 ++ .../ezEditTable/docs/doc_properties.html | 515 + .../ezEditTable/docs/doc_utilities.html | 207 + dist/extensions/ezEditTable/docs/index.html | 473 + dist/extensions/ezEditTable/docs/samples.html | 1082 ++ dist/extensions/ezEditTable/docs/starter.html | 195 + .../ezEditTable/ezEditTable-uncompressed.css | 86 + .../ezEditTable/ezEditTable-uncompressed.js | 2081 ++++ dist/extensions/ezEditTable/ezEditTable.css | 7 + dist/extensions/ezEditTable/ezEditTable.js | 9 + .../ezEditTable/themes/bg_mod_cell.png | Bin 0 -> 234 bytes .../ezEditTable/themes/default/ezDefault.css | 23 + .../themes/default/img/bg_col_header.gif | Bin 0 -> 875 bytes .../extensions/ezEditTable/themes/icn_add.gif | Bin 0 -> 398 bytes .../ezEditTable/themes/icn_cross.png | Bin 0 -> 655 bytes .../extensions/ezEditTable/themes/icn_del.gif | Bin 0 -> 330 bytes .../ezEditTable/themes/icn_edit.gif | Bin 0 -> 342 bytes .../ezEditTable/themes/icn_save.gif | Bin 0 -> 375 bytes .../ezEditTable/themes/icn_tick.png | Bin 0 -> 537 bytes .../ezEditTable/themes/skyblue/ezSkyBlue.css | 68 + .../themes/skyblue/img/sky_blue_grid.gif | Bin 0 -> 554 bytes dist/filtergrid.css | 2 +- dist/tablefilter.js | 9509 +---------------- libs/ezEditTable/docs/doc.html | 2049 ++++ libs/ezEditTable/docs/doc_class.html | 154 + libs/ezEditTable/docs/doc_methods.html | 599 ++ libs/ezEditTable/docs/doc_properties.html | 515 + libs/ezEditTable/docs/doc_utilities.html | 207 + libs/ezEditTable/docs/index.html | 473 + libs/ezEditTable/docs/samples.html | 1082 ++ libs/ezEditTable/docs/starter.html | 195 + libs/ezEditTable/ezEditTable-uncompressed.css | 86 + libs/ezEditTable/ezEditTable-uncompressed.js | 2081 ++++ libs/ezEditTable/ezEditTable.css | 7 + libs/ezEditTable/ezEditTable.js | 9 + libs/ezEditTable/themes/bg_mod_cell.png | Bin 0 -> 234 bytes libs/ezEditTable/themes/default/ezDefault.css | 23 + .../themes/default/img/bg_col_header.gif | Bin 0 -> 875 bytes libs/ezEditTable/themes/icn_add.gif | Bin 0 -> 398 bytes libs/ezEditTable/themes/icn_cross.png | Bin 0 -> 655 bytes libs/ezEditTable/themes/icn_del.gif | Bin 0 -> 330 bytes libs/ezEditTable/themes/icn_edit.gif | Bin 0 -> 342 bytes libs/ezEditTable/themes/icn_save.gif | Bin 0 -> 375 bytes libs/ezEditTable/themes/icn_tick.png | Bin 0 -> 537 bytes libs/ezEditTable/themes/skyblue/ezSkyBlue.css | 68 + .../themes/skyblue/img/sky_blue_grid.gif | Bin 0 -> 554 bytes src-es6/modules/paging.js | 2 +- src-es6/tablefilter.js | 147 +- src/array.js | 4 +- src/cookie.js | 4 +- src/date.js | 4 +- src/dom.js | 4 +- src/event.js | 4 +- src/extensions/ezEditTable/docs/doc.html | 2049 ++++ .../ezEditTable/docs/doc_class.html | 154 + .../ezEditTable/docs/doc_methods.html | 599 ++ .../ezEditTable/docs/doc_properties.html | 515 + .../ezEditTable/docs/doc_utilities.html | 207 + src/extensions/ezEditTable/docs/index.html | 473 + src/extensions/ezEditTable/docs/samples.html | 1082 ++ src/extensions/ezEditTable/docs/starter.html | 195 + .../ezEditTable/ezEditTable-uncompressed.css | 86 + .../ezEditTable/ezEditTable-uncompressed.js | 2081 ++++ src/extensions/ezEditTable/ezEditTable.css | 7 + src/extensions/ezEditTable/ezEditTable.js | 9 + .../ezEditTable/themes/bg_mod_cell.png | Bin 0 -> 234 bytes .../ezEditTable/themes/default/ezDefault.css | 23 + .../themes/default/img/bg_col_header.gif | Bin 0 -> 875 bytes src/extensions/ezEditTable/themes/icn_add.gif | Bin 0 -> 398 bytes .../ezEditTable/themes/icn_cross.png | Bin 0 -> 655 bytes src/extensions/ezEditTable/themes/icn_del.gif | Bin 0 -> 330 bytes .../ezEditTable/themes/icn_edit.gif | Bin 0 -> 342 bytes .../ezEditTable/themes/icn_save.gif | Bin 0 -> 375 bytes .../ezEditTable/themes/icn_tick.png | Bin 0 -> 537 bytes .../ezEditTable/themes/skyblue/ezSkyBlue.css | 68 + .../themes/skyblue/img/sky_blue_grid.gif | Bin 0 -> 554 bytes .../sortabletable/adapterSortabletable.js | 34 +- src/helpers.js | 4 +- src/index.html | 6 + src/modules/alternateRows.js | 35 +- src/modules/checkList.js | 39 +- src/modules/clearButton.js | 23 +- src/modules/colOps.js | 15 +- src/modules/dropdown.js | 27 +- src/modules/gridLayout.js | 19 +- src/modules/help.js | 23 +- src/modules/highlightKeywords.js | 23 +- src/modules/loader.js | 19 +- src/modules/paging.js | 77 +- src/modules/popupFilter.js | 47 +- src/modules/rowsCounter.js | 23 +- src/modules/statusBar.js | 23 +- src/modules/store.js | 35 +- src/sort.js | 4 +- src/string.js | 4 +- src/tablefilter.js | 391 +- src/types.js | 4 +- test/test-sort-custom-sorter.js | 16 +- 101 files changed, 23056 insertions(+), 10164 deletions(-) create mode 100644 dist/extensions/ezEditTable/docs/doc.html create mode 100644 dist/extensions/ezEditTable/docs/doc_class.html create mode 100644 dist/extensions/ezEditTable/docs/doc_methods.html create mode 100644 dist/extensions/ezEditTable/docs/doc_properties.html create mode 100644 dist/extensions/ezEditTable/docs/doc_utilities.html create mode 100644 dist/extensions/ezEditTable/docs/index.html create mode 100644 dist/extensions/ezEditTable/docs/samples.html create mode 100644 dist/extensions/ezEditTable/docs/starter.html create mode 100644 dist/extensions/ezEditTable/ezEditTable-uncompressed.css create mode 100644 dist/extensions/ezEditTable/ezEditTable-uncompressed.js create mode 100644 dist/extensions/ezEditTable/ezEditTable.css create mode 100644 dist/extensions/ezEditTable/ezEditTable.js create mode 100644 dist/extensions/ezEditTable/themes/bg_mod_cell.png create mode 100644 dist/extensions/ezEditTable/themes/default/ezDefault.css create mode 100644 dist/extensions/ezEditTable/themes/default/img/bg_col_header.gif create mode 100644 dist/extensions/ezEditTable/themes/icn_add.gif create mode 100644 dist/extensions/ezEditTable/themes/icn_cross.png create mode 100644 dist/extensions/ezEditTable/themes/icn_del.gif create mode 100644 dist/extensions/ezEditTable/themes/icn_edit.gif create mode 100644 dist/extensions/ezEditTable/themes/icn_save.gif create mode 100644 dist/extensions/ezEditTable/themes/icn_tick.png create mode 100644 dist/extensions/ezEditTable/themes/skyblue/ezSkyBlue.css create mode 100644 dist/extensions/ezEditTable/themes/skyblue/img/sky_blue_grid.gif create mode 100644 libs/ezEditTable/docs/doc.html create mode 100644 libs/ezEditTable/docs/doc_class.html create mode 100644 libs/ezEditTable/docs/doc_methods.html create mode 100644 libs/ezEditTable/docs/doc_properties.html create mode 100644 libs/ezEditTable/docs/doc_utilities.html create mode 100644 libs/ezEditTable/docs/index.html create mode 100644 libs/ezEditTable/docs/samples.html create mode 100644 libs/ezEditTable/docs/starter.html create mode 100644 libs/ezEditTable/ezEditTable-uncompressed.css create mode 100644 libs/ezEditTable/ezEditTable-uncompressed.js create mode 100644 libs/ezEditTable/ezEditTable.css create mode 100644 libs/ezEditTable/ezEditTable.js create mode 100644 libs/ezEditTable/themes/bg_mod_cell.png create mode 100644 libs/ezEditTable/themes/default/ezDefault.css create mode 100644 libs/ezEditTable/themes/default/img/bg_col_header.gif create mode 100644 libs/ezEditTable/themes/icn_add.gif create mode 100644 libs/ezEditTable/themes/icn_cross.png create mode 100644 libs/ezEditTable/themes/icn_del.gif create mode 100644 libs/ezEditTable/themes/icn_edit.gif create mode 100644 libs/ezEditTable/themes/icn_save.gif create mode 100644 libs/ezEditTable/themes/icn_tick.png create mode 100644 libs/ezEditTable/themes/skyblue/ezSkyBlue.css create mode 100644 libs/ezEditTable/themes/skyblue/img/sky_blue_grid.gif create mode 100644 src/extensions/ezEditTable/docs/doc.html create mode 100644 src/extensions/ezEditTable/docs/doc_class.html create mode 100644 src/extensions/ezEditTable/docs/doc_methods.html create mode 100644 src/extensions/ezEditTable/docs/doc_properties.html create mode 100644 src/extensions/ezEditTable/docs/doc_utilities.html create mode 100644 src/extensions/ezEditTable/docs/index.html create mode 100644 src/extensions/ezEditTable/docs/samples.html create mode 100644 src/extensions/ezEditTable/docs/starter.html create mode 100644 src/extensions/ezEditTable/ezEditTable-uncompressed.css create mode 100644 src/extensions/ezEditTable/ezEditTable-uncompressed.js create mode 100644 src/extensions/ezEditTable/ezEditTable.css create mode 100644 src/extensions/ezEditTable/ezEditTable.js create mode 100644 src/extensions/ezEditTable/themes/bg_mod_cell.png create mode 100644 src/extensions/ezEditTable/themes/default/ezDefault.css create mode 100644 src/extensions/ezEditTable/themes/default/img/bg_col_header.gif create mode 100644 src/extensions/ezEditTable/themes/icn_add.gif create mode 100644 src/extensions/ezEditTable/themes/icn_cross.png create mode 100644 src/extensions/ezEditTable/themes/icn_del.gif create mode 100644 src/extensions/ezEditTable/themes/icn_edit.gif create mode 100644 src/extensions/ezEditTable/themes/icn_save.gif create mode 100644 src/extensions/ezEditTable/themes/icn_tick.png create mode 100644 src/extensions/ezEditTable/themes/skyblue/ezSkyBlue.css create mode 100644 src/extensions/ezEditTable/themes/skyblue/img/sky_blue_grid.gif diff --git a/Gruntfile.js b/Gruntfile.js index 170f94a5..55c6fb82 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -204,6 +204,11 @@ module.exports = function (grunt) { { src: 'libs/sortabletable.js', dest: '<%= source_folder %>extensions/sortabletable/sortabletable.js' }, // { src: 'libs/requirejs/require.js', dest: '<%= dist_folder %>require.js' }, // { src: ['**'], cwd: '<%= source_folder %>TF_Modules/', dest: '<%= dist_folder %>TF_Modules/', expand: true }, + + // TODO: remove ezEditTable + { src: ['**'], cwd: 'libs/ezEditTable/', dest: '<%= source_folder %>extensions/ezEditTable/', expand: true }, + { src: ['**'], cwd: 'libs/ezEditTable/', dest: '<%= dist_folder %>extensions/ezEditTable/', expand: true }, + // { src: ['**'], cwd: '<%= source_folder %>TF_Themes/', dest: '<%= dist_folder %>TF_Themes/', expand: true } ] } diff --git a/dist/extensions/ezEditTable/docs/doc.html b/dist/extensions/ezEditTable/docs/doc.html new file mode 100644 index 00000000..51c58484 --- /dev/null +++ b/dist/extensions/ezEditTable/docs/doc.html @@ -0,0 +1,2049 @@ + + + + ezEditTable, enhance HTML tables easily, advanced inline editing, selection and keyboard navigation - script by Max Guglielmi + + + + + + + + + + + + + + + +
+ + + + + +
+ + + +

Documentation

+ + + +

Configuration Object

+ + +

You will find here all the properties of the configuration object ( var + etConfig = { property: value }) needed to configure the EditTable object:

+ + + + + +

General

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
selectionbooleanenables / disables selection model (default - true)  var etConfig = { selection: false }
editablebooleanenables / disables inline cell editing(default - false)  var etConfig = { editable: true }
key_navigationbooleanenables / disables keyboard navigation (default - true) var etConfig = { key_navigation: false }
table_cssstringdefines the css class of the table element (default - 'ezEditableTable')Check out the ezEditTable.css stylesheet and edit the css classes + for your project's needs var etConfig = { table_css: "myclass" }
unselectable_css string defines the css class that makes the table text unselectable (default + - 'ezUnselectable')Older versions of IE do not support this css class, as an alternative + use unselectable="on" to expect same result var etConfig = { unselectable_css: "myclass" }
activity_indicator_css string defines the css class to be applied to the table in order to indicate + server activity   var etConfig = { activity_indicator_css: "myclass" }
on_server_activity_start function callback event function called before server activity starts (default: + null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • row is the current row to be processed server-side
  • +
var etConfig = { on_server_activity_start: function(o, row){ + alert('Row data to be processed: ' + o.Selection.GetRowValues(row)); } }
on_server_activity_stop function callback event function called when server activity stopped (default: + null)

2 parameters are passed to the function:

+ + +
    +
  • o is the current EditTable object
  • +
  • row is the current row to be processed server-side
  • +
var etConfig = { on_server_activity_stop: function(o, row){ + alert('Row data processed server-side: ' + o.Selection.GetRowValues(row)); + } }
base_pathstring defines the path to the script's directory (default: 'ezEditTable/')This is used for the command editor icons' path var etConfig = { base_path: "myDir/" }
+ Top of page +
+ + + +

Selection

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
selection_modelstring defines the selection model: "single" or "multiple" + (default: 'single') 2 possible values: 'single' or 'multiple'var etConfig = { selection_model: 'multiple' }
default_selectionstringdefines the selection type (default: 'row')3 possible values: 'row', 'cell' or 'both'var etConfig = { default_selection: 'both' }
key_selectionbooleanenables / disable multiple selection by using Ctrl and Shift keys + (default: true)select multiple rows by holding Ctrl or Shift key down, only if + selection model is 'multiple'var etConfig = { key_selection: false }
select_row_at_startbooleanfirst row is selected at start if set true (default: false) var etConfig = { select_row_at_start: true }
row_index_at_startnumberdefines which row has to be selected at start (default: this.startRow)this.startRow = numeric parameter passed to constructor:
+ var et = new EditTable('myTableId', 3, etConfig);
var etConfig = { row_index_at_start: 3 }
scroll_into_viewbooleanIf set true selected row scrolls into view; useful when row is selected + by using keyboard (default: false) var etConfig = { scroll_into_view: true }
active_row_cssstringdefines css class for active row (default: 'ezActiveRow') var etConfig = { active_row_css: 'myClass' }
selected_row_cssstringdefines css class for selected rows (default: 'ezSelectedRow')

only if 'multiple' selection model is enabled

+
var etConfig = { selected_row_css: 'myClass' }
active_cell_cssstring defines css class for active cell (default: 'ezActiveCell')only if 'cell' or 'both' selection type is enabledvar etConfig = { active_cell_css: 'myClass' };
nb_rows_per_pagenumber defines number of rows to jump when PgDown or PgUp keys are pressed + (default: 10)

specify a huge number to jump straight to 1st or last row (1000)

+
var etConfig = { nb_rows_per_page: 1000 }
+ Top of page +
+ + +

Selection callback events

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
on_selection_initializedfunctioncallback event function called when Selection object is initialised + (default: null)

1 parameter is passed to the function:

+
    +
  • o is the current EditTable object
  • + +
var etConfig = { on_selection_initialized: function(o){ alert(o.id+' + Selection object is initialised!'); } }
on_before_selected_rowfunctioncallback event function called before a row is selected (default: + null) )

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • row is the current row to be selected
  • +
var etConfig = { on_before_selected_row: function(o, row){ + alert('Row index: ' + row.rowIndex); } }
on_after_selected_rowfunctioncallback event function called after a row is selected (default: + null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • + +
  • row is the current selected row
  • +
var etConfig = { on_after_selected_row: function(o, row){ + alert('Row index: ' + row.rowIndex); } }
on_before_selected_cellfunctioncallback event function called before a cell is selected (default: + null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • cell is the current cell to be selected
  • +
var etConfig = { on_before_selected_cell: function(o, cell){ + alert('Cell index: ' + cell.cellIndex); } }
on_after_selected_cellfunctioncallback event function called (default: null)

2 parameters are passed to the function:

+
    + +
  • o is the current EditTable object
  • +
  • cell is the current selected cell
  • +
var etConfig = { on_after_selected_cell: function(o, cell){ + alert('Cell index: ' + cell.cellIndex); } }
on_before_deselected_rowfunctioncallback event function called before a row is deselected (default: + null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • row is the current row to be deselected
  • + +
var etConfig = { on_before_deselected_row: function(o, row){ + alert('Row index: ' + row.rowIndex); } }
on_after_deselected_rowfunctioncallback event function called after a row is deselected (default: + null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • row is the current deselected row
  • +
var etConfig = { on_after_deselected_row: function(o, row){ + alert('Row index: ' + row.rowIndex); } }
on_before_deselected_cellfunctioncallback event function called before a cell is deselected (default: + null)

2 parameters are passed to the function:

+
    + +
  • o is the current EditTable object
  • +
  • cell is the current cell to be deselected
  • +
var etConfig = { on_before_deselected_cell: function(o, cell){ + alert('Cell index: ' + cell.cellIndex); } }
on_after_deselected_cellfunctioncallback event function called after a cell is deselected (default: + null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • cell is the current deselected cell
  • + +
var etConfig = { on_after_deselected_cell: function(o, cell){ + alert('Cell index: ' + cell.cellIndex); } }
on_validate_rowfunctioncallback event function called after a row is validated by pressing enter key or on double-click (default: + null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • row is the current validated row
  • +
+

Note the editable property needs to be set to false

+ +
var etConfig = { on_validate_row: function(o, row){ + alert('Row index: ' + row.rowIndex); } }
on_validate_cellfunctioncallback event function called after a cell is validated by pressing enter key or on double-click (default: + null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • cell is the current validated cell
  • +
+

Note the editable property needs to be set to false

+ +
var etConfig = { on_validate_cell: function(o, cell){ + alert('Cell index: ' + cell.cellIndex); } }
+ Top of page +
+ + + +

Editable

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
editor_modelstringdefines the editor model (default: 'cell')2 possible values: 'cell' or 'row'var etConfig = { editor_model: 'row' }
open_editor_actionstringdefines which mouse action opens the inline editing feature (default: + 'dblclick') 2 possible values: 'dblclick', 'click'var etConfig = { open_editor_action: 'click' }
ajax newbooleanenables AJAX requests (default: true if jQuery is detected)it is enabled if jQuery is detected and the ajax property is + not explicitly set falsevar etConfig = { editable: true, ajax: false }
cell_editorsarrayarray defining the editor configuration for each column (default: + []) the number of editors must be equal to the number of columns. Refer + to Cell editors properties for details + about editors' configuration

var etConfig = { cell_editors: [
+ { type: 'select' },
+ { type: 'textarea' },
+ { type: 'input' },
+ { type: 'uploader' },
+ { type: 'none' },
+ { type: 'command' }
+ ] }

input_editor_cssstringdefines the css class for 'input' type editors (default: 'ezInputEditor') var etConfig = { input_editor_css: 'myClass' };
textarea_editor_cssstringdefines the css class for 'textarea' type editors (default: 'ezTextAreaEditor') var etConfig = { textarea_editor_css: 'myClass' };
select_editor_cssstringdefines the css class for 'input' type editors (default: 'ezSelectEditor') var etConfig = { select_editor_css: 'myClass' };
command_editor_cssstringcss class applied to command editor buttons container (default: + 'ezCommandEditor') var etConfig = { command_editor_css: 'myClass' };
modified_cell_cssstringcss class applied to modified cells (default: 'ezModifiedCell')this css class shows the green small triangle in the left-upper + corner of the cellvar etConfig = { modified_cell_css: 'myClass' };
auto_savebooleansaves automatically pending changes upon selection changeeditable property needs to be activated (default: true if editable is on)var etConfig = { auto_save: false };
auto_save_modelstringdetermines when modified and/or added data is saved, upon row or cell selection change (default: 'row')2 possible values 'row' or 'cell'var etConfig = { auto_save_model: 'cell' };
auto_save_typestringdefines if only insertions or updates, or both are saved automatically (default: 'both')3 possible values 'insert', 'update' or 'both'var etConfig = { auto_save_type: 'update' };
editable_on_keystroke newbooleanmakes the inline cell editor appear upon keystroke (default: false)only if edition is enabled and editorModel is set to 'cell' and + selectionModel to 'single'var etConfig = { editable: true, editable_on_keystroke: true };
new_row_prefixstringdefines the prefix for new added row ids (default: 'tr')prefix should match the prefix assigned to already existing rowsvar etConfig = { new_row_prefix: 'row' };
form_submit_intervalnumberdefines the interval in ms separating rows data submissions (default: 50)by default the script submits a single form for each modified row. Depending on ISPs / network + security policies, multiple submissions to same page are blocked by the server. + This interval can be useful to fine tune the form submissions when those server restrictions apply.var etConfig = { form_submit_interval: 750 };
new_row_pos newstring or numberdefines the row position of a newly created row (default: 'top')2 possible values as a string: 'top' or 'bottom', and as an integer: + any number >= 0 and <= total number of rows. If the supplied numeric + value exceeds the total number of rows then the script fallback to default + value 'top'var etConfig = { new_row_pos: 'bottom' };
+ + Top of page +
+ + +

Cell editors

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
typestringsets the editor type (default: 'input')these are the editor types: 'none', 'input', 'textarea', 'select', + 'multiple', 'boolean', 'command', 'custom', 'uploader' var etConfig = { cell_editors: [
+ { type: 'select' },
+ { type: 'textarea' },
+ { type: 'input' },
+ { type: 'uploader' },
+ { type: 'none' },
+ { type: 'command' }
+ ]}
cssstringdefines a css class for the editor (default: null)  var etConfig = { cell_editors: [
+ { type: 'select', css:'myClass' },...
+ ]}
attributesarray defines the additional attributes for the editor's DOM element + (default: null)useful for specifying the max length of characters for input and + textarea typesvar etConfig = { cell_editors: [
+ + { type: 'input', attributes:[['maxLength',5],['title','5 chars max']] + },...
+ ]}
stylestringsets the inline style for the editor's DOM element (default: null) var etConfig = { cell_editors: [
+ { type: 'textarea', style: 'background-color:#fff;' },...
+ ]}
custom_slc_optionsarraydefines the options of a 'select' editor type (default: null)this property applies only to 'select' and 'multiple' editors { + type: 'multiple', custom_slc_options:['a','b','c'], sort_slc_options: + 'string', values_separator: ', ' },var etConfig = { cell_editors: [
+ { type: 'select', custom_slc_options:['a','b','c'] },...
+ ]}
custom_slc_valuesarraydefines the options values of a 'select' editor type (default: null)this property applies only to 'select' and 'multiple' editors { + type: 'multiple', custom_slc_options:['a','b','c'], custom_slc_values:['1','2','3'], sort_slc_options: + 'string', values_separator: ', ' },var etConfig = { cell_editors: [
+ { type: 'select', custom_slc_options:['a','b','c'], custom_slc_values:['1','2','3'] },...
+ ]}
sort_slc_optionsstringsorts the custom options (default: null)

this property applies only to 'select' and 'multiple' editors. + 3 possible values:

+
    + +
  • 'string': sorts string values
  • +
  • 'numasc': sorts numeric values in ascending manner
  • +
  • 'numdesc': sorts numeric values in descending manner
  • +
var etConfig = { cell_editors: [
+ { type: 'select', custom_slc_options:['a','b','c'], sort_slc_options: + 'string' },...
+ ]}
values_separatorstringdefines the value separator for 'multiple' type editors (default: + ', ') this property applies only to 'multiple' editorsvar etConfig = { cell_editors: [
+ { type: 'multiple', custom_slc_options:['a','b','c'], sort_slc_options: + 'string', values_separator: '; ' },...
+ ]}
allow_empty_valuebooleandefines the columns accepting empty values (default: false)var etConfig = { cell_editors: [
+ { type: 'input', allow_empty_value:true },...
+ ]}
targetstringdefines the custom editor target element id (default: 'null')this property applies only to 'custom' editorsvar etConfig = { cell_editors: [
+ { type: 'custom', target: 'datePick' },...
+ ]}
command_column_indexnumbertells the script in which column command buttons have to be generated + (default: this.nbCells-1)this property applies only to 'command' editors. Default value is + the last column of the tablevar etConfig = { cell_editors: [
+ { type: 'command', command_column_index: 4 },...
+ ]}
buttonsobject

this literal object is the configuration object of the command + buttons generated in column (default: {})

this property applies only to 'command' editors. Refer to Command + buttons properties for details about 'command' editor buttons + configuration

var etConfig = { cell_editors: [
+ { type: 'command', command_column_index: 4,
+ buttons:{
+ enable: ['update', 'insert', 'delete', 'submit', 'cancel'],
+ 'update': { title:'Edit row' },
+ 'insert': { title:'Add row', scrollIntoView: false },
+ 'delete': { title:'Delete row' },
+ 'submit': { text:'Save', title:'Save' },
+ 'cancel': { text:'Cancel', title:'Cancel' } }
+ },...
+ + ]}

+ Top of page +
+ + +

Command buttons

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
enablearrayenables the command buttons to be generated (default: ['update', + 'insert', 'delete', 'submit', 'cancel'])command buttons types: 'update', 'insert', 'delete', 'submit', 'cancel'. + To disable a particular button remove it from the arrayvar etConfig = { cell_editors: [
+ { type: 'command', command_column_index: 4,
+ buttons:{
+ enable: ['update', 'submit', 'cancel'],
+ 'update': { title:'Edit row' },
+ + 'submit': { text:'Save', title:'Save' },
+ 'cancel': { text:'Cancel', title:'Cancel' } }
},...
+ ]}
updateobjectconfiguration object of the 'update' button (default: {})

Below a list of the properties for the 'update' button:

+
    +
  • 'text': text of the button (default: '')
  • +
  • 'icon': icon image html (default: '<img src="'+this.basePath+'themes/icn_edit.gif" + alt="" />')
  • + +
  • 'title': tooltip for the button (default: 'Edit record')
  • +
  • 'css': additional css class (default: null)
  • +
  • 'style': inline style element (default: null)
  • +
var etConfig = { cell_editors: [
+ { type: 'command', command_column_index: 4,
+ + buttons:{
+ enable: ['update'],
+ 'update': { text:'Edit', title:'Edit row', css:'myClass'}
},...
+ ]}
insertobject configuration object of the 'insert' button (default: {})

Below a list of the properties for the 'insert' button:

+
    +
  • 'text': text of the button (default: '')
  • +
  • 'icon': icon image html (default: '<img src="'+this.basePath+'themes/icn_edit.gif" + alt="" />')
  • + +
  • 'title': tooltip for the button (default: 'Create record')
  • +
  • 'css': additional css class (default: null)
  • +
  • 'style': inline style element (default: null)
  • +
  • 'scrollIntoView': scrolls into view inserted row (default: false)
  • +
var etConfig = { cell_editors: [
+ { type: 'command', command_column_index: 4,
+ buttons:{
+ enable: ['insert'],
+ 'insert': { text:'Add', title:'Add row', css:'myClass'}
},...
+ ]}
deleteobjectconfiguration object of the 'delete' button (default: {})

Below a list of the properties for the 'delete' button:

+
    +
  • 'text': text of the button (default: '')
  • + +
  • 'icon': icon image html (default: '<img src="'+this.basePath+'themes/icn_edit.gif" + alt="" />')
  • +
  • 'title': tooltip for the button (default: 'Delete record')
  • +
  • 'css': additional css class (default: null)
  • +
  • 'style': inline style element (default: null)
  • + +
var etConfig = { cell_editors: [
+ { type: 'command', command_column_index: 4,
+ buttons:{
+ enable: ['delete'],
+ 'delete': { text:'Remove', title:'Remove row', css:'myClass'}
},...
+ + ]}
submitobjectconfiguration object of the 'submit' button (default: {})

Below a list of the properties for the 'submit' button:

+
    +
  • 'text': text of the button (default: 'Submit')
  • +
  • 'icon': icon image html (default: '<img src="'+this.basePath+'themes/icn_edit.gif" + alt="" />')
  • +
  • 'title': tooltip for the button (default: 'Submit record')
  • + +
  • 'css': additional css class (default: null)
  • +
  • 'style': inline style element (default: null)
  • +
var etConfig = { cell_editors: [
+ { type: 'command', command_column_index: 4,
+ buttons:{
+ + enable: ['submit'],
+ 'submit': { text:'Save', title:'Save row', css:'myClass'}
},...
+ ]}
cancelobjectconfiguration object of the 'cancel' button (default: {})

Below a list of the properties for the 'cancel' button:

+
    +
  • 'text': text of the button (default: 'Cancel')
  • +
  • 'icon': icon image html (default: '<img src="'+this.basePath+'themes/icn_edit.gif" + alt="" />')
  • + +
  • 'title': tooltip for the button (default: 'Cancel')
  • +
  • 'css': additional css class (default: null)
  • +
  • 'style': inline style element (default: null)
  • +
var etConfig = { cell_editors: [
+ { type: 'command', command_column_index: 4,
+ + buttons:{
+ enable: ['cancel'],
+ 'cancel': { css:'myClass'}
},...
+ ]}
+ Top of page +
+ + +

Uploader editor

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
uploaderobjectdefines the uploader editor settings (default: {}) ...cell_editors:[ + { + type: 'uploader', + uploader: { uri: 'php/uploadFile.php', path: 'images/uploads/', max_file_size: '51200', show_link: false } + },... + ] +
uristringdefines the URL of the resource performing the upload operation (default: null) ...cell_editors:[ + { + type: 'uploader', + uploader: { uri: 'php/uploadFile.php' } + },... + ] +
pathstringdefines the path to the uploads folder repository (default: null) ...cell_editors:[ + { + type: 'uploader', + uploader: { path: 'images/uploads/' } + },... + ] +
show_uploadbooleanshows or hides uploaded file (default: true) ...cell_editors:[ + { + type: 'uploader', + uploader: { show_upload: false } + },... + ] +
sql_fieldstringdefines the name of the SQL field name storing upload filename (default: 'IMAGENAME')optional depending on how the upload server-side operation is implemented. + On the script's website, the name of the SQL field storing the filename is rerquired by the PHP resource. + This does not mean that it is a good practice, it is just for demoing purposes....cell_editors:[ + { + type: 'uploader', + uploader: { sql_field: 'FILENAME' } + },... + ] +
record_id_column_indexnumbertells the script which is the index of the column containing the record id (default: null)optional depending on how the id of a record is used in the HTML table. + If this property is defined, the script will use it in order to retrieve the + record id of working row. Otherwise, it will extract it from the id of the + working row, by default 'tr'+Id. + ...cell_editors:[ + { + type: 'uploader', + uploader: { record_id_column_index: 0 } + },... + ] +
show_linkbooleanUploaded file appears as a link in the uploader box and in the cell if set true (default: true) ...cell_editors:[ + { + type: 'uploader', + uploader: { show_link: false } + },... + ] +
link_cssstringdefines the css class for the upload link (default: '') ...cell_editors:[ + { + type: 'uploader', + uploader: { show_link: true, link_css: 'myClass' } + },... + ] +
loader_imagestringdefines the path of the loader image displayed during the upload operation (default: this.basePath + 'themes/img_loader.gif') ...cell_editors:[ + { + type: 'uploader', + uploader: { loader_image: 'myFolder/loader.gif' } + },... + ] +
ok_imagestringsets the path of the image used to notify users that cell contains an uploaded file (default: this.basePath + 'themes/img_loader.gif')If show_upload is active and show_link property is set false this property applies....cell_editors:[ + { + type: 'uploader', + uploader: { ok_image: 'myFolder/ok.gif' } + },... + ] +
max_file_sizenumbersets the maximum file size allowed, default value is 100Kb (default: 102400)Optional depending on the server-side implementation. This value is passed to the server in the online script's demos....cell_editors:[ + { + type: 'uploader', + uploader: { max_file_size: 51200 } + },... + ] +
valid_extensionsstringsets a list of comma separated file extensions to pass to the server logic (default: 'jpg, jpeg, gif, png')Optional depending on the server-side implementation. This value is passed to the server in the online script's demos....cell_editors:[ + { + type: 'uploader', + uploader: { valid_extensions: 'doc,docx,pdf,rtf' } + },... + ] +
cssstringdefines the css class applied to the uploader container element (default: 'ezUploaderEditor')...cell_editors:[ + { + type: 'uploader', + uploader: { css: 'myClass' } + },... + ] +
output_cssstringdefines the css class applied to the uploader output messages container (default: 'ezUploaderEditorOutput')...cell_editors:[ + { + type: 'uploader', + uploader: { output_css: 'myClass' } + },... + ] +
display_cssstringdefines the css class applied to the image displayer container (default: 'ezUploaderEditorOutput')...cell_editors:[ + { + type: 'uploader', + uploader: { output_css: 'myClass' } + },... + ] +
javascript_code_successstringdefines javascript code to be injected by the server after a successfull upload operation + (default: '<script>window.parent["{1}"].SetUploadSuccess(true); window.parent["{1}"].SetUploadName("{0}");' + + 'window.parent["{1}"].ShowUpload();</script>')Optional depending on server-side implementation. This value is passed to the server in the online script's demos....cell_editors:[ + { + type: 'uploader', + uploader: { javascript_code_success: '<script>alert('Upload name: {0}');</script>' } + },... + ] +
+ + Top of page +
+ + +

Editable and cell editors callback events and delegates

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
on_editable_initializedfunctioncallback event function called when Editable object is initialised + (default: null)

1 parameter is passed to the function:

+
    +
  • o is the current EditTable object
  • + +
var etConfig = { on_editable_initialized: function(o){ alert(o.id+ + ' Editable object is initialised!'); } }
on_before_open_editorfunctioncallback event function called before a cell editor is opened + (default: null) +

3 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • cell is the current cell
  • +
  • editor is the current opened editor
  • +
var etConfig = { on_before_open_editor: function(o, cell, + editor){ cell.style.backgroundColor = 'pink'; } }
on_after_open_editorfunction callback event function called after a cell editor is opened (default: + null)

3 parameters are passed to the function:

+
    + +
  • o is the current EditTable object
  • +
  • cell is the current cell
  • +
  • editor is the current opened editor
  • +
var etConfig = { on_after_open_editor: function(o, cell, editor){ + cell.style.backgroundColor = 'transparent'; } }
on_before_close_editorfunctioncallback event function called before a cell editor is closed (default: + null)

3 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • + +
  • cell is the current cell
  • +
  • editor is the current opened editor
  • +
var etConfig = { on_before_close_editor: function(o, cell, + editor){ cell.style.backgroundColor = 'pink'; } }
on_after_close_editorfunctioncallback event function called after a cell editor is closed (default: + null)

3 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • cell is the current cell
  • + +
  • editor is the current opened editor
  • +
var etConfig = { on_after_close_editor: function(o, cell, + editor){ cell.style.backgroundColor = 'transparent'; } }
set_custom_editor_valuefunctiondelegate function called to set 'custom' editor value (default: + null)

4 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • editor is the current opened editor
  • +
  • colIndex is the column index
  • + +
  • val is the value to set in the custom editor
  • +
var etConfig = { set_custom_editor_value: function(o, editor, + colIndex, val){ alert('Value to set in custom editor:' + val); } }
get_custom_editor_valuefunctiondelegate function called to get 'custom' editor value (default: + null)

3 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • editor is the current opened editor
  • +
  • colIndex is the column index
  • + +
var etConfig = { get_custom_editor_value: function(o, editor, + colIndex){ alert('Call function to retrieve custom editor value for + column '+colIndex); } }
set_cell_modified_valuefunctiondelegate function called to write modified value in cell (default: + null)

3 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • cell is the current cell
  • +
  • val is the value to write in the cell
  • +
var etConfig = { set_cell_modified_value: function(o, cell, + val){ alert('This value has to be written in the cell: ' + val); } + }
validate_modified_valuefunctiondelegate function called to validate modified value to be written + in cell (default: null)

3 parameters are passed to the function:

+
    + +
  • o is the current EditTable object
  • +
  • colIndex is the column index
  • +
  • cellVal is the cell value
  • +
  • edtVal is the editor value
  • +
  • cell is the current cell
  • + +
  • editor is the current editor
  • +
+

The validation delegate must return a boolean

var etConfig = { validate_modified_value: function(o, colIndex, + cellVal, edtVal, cell, editor){ alert('Validation function returns + a boolean'); } }
open_custom_editorfunctiondelegate function called to open 'custom' editor (default: null)

3 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • cell is the current cell
  • + +
  • editor is the current opened editor
  • +
var etConfig = { open_custom_editor: function(o, cell, editor){ + alert('Custom editor for column '+cell.cellIndex+' is being opened!'); + } }
close_custom_editorfunctiondelegate function called to close 'custom' editor (default: null)

3 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • cell is the current cell
  • +
  • editor is the current opened editor
  • + +
var etConfig = { close_custom_editor: function(o, cell, editor){ + alert('Custom editor for column '+cell.cellIndex+' is closed!'); } + }
show_uploadfunctiondelegate function called by uploader editor to display uploaded file (default: null)

4 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • divUplDisplay is the container element containing the upload
  • +
  • uploadName is the filename of the uploaded file
  • +
  • path is the upload path
  • +
var etConfig = { + cell_editors:[ + { + type: 'uploader', + uploader: { + show_upload: function(o, divUplDisplay, uploadName, path){ + divUplDisplay.style.display = ''; + divUplDisplay.innerHTML = uploadName; + } + } + }] + }
on_before_openfunctioncallback called before uploader editor is opened (default: null)

3 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • editor is the current opened uploader editor
  • +
  • cell is the current cell
  • +
var etConfig = { + cell_editors:[ + { + type: 'uploader', + uploader: { + on_before_open: function(o, editor, cell){ + alert('uploader is going to be opened'); + } + } + }] + }
on_after_openfunctioncallback called after uploader editor is opened (default: null)

3 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • editor is the current opened uploader editor
  • +
  • cell is the current cell
  • +
var etConfig = { + cell_editors:[ + { + type: 'uploader', + uploader: { + on_after_open: function(o, editor, cell){ + alert('uploader is opened now'); + } + } + }] + }
on_before_closefunctioncallback called before uploader editor is closed (default: null)

3 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • editor is the current opened uploader editor
  • +
  • cell is the current cell
  • +
var etConfig = { + cell_editors:[ + { + type: 'uploader', + uploader: { + on_before_close: function(o, editor, cell){ + alert('uploader is going to be closed'); + } + } + }] + }
on_after_closefunctioncallback called after uploader editor is closed (default: null)

3 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • editor is the current opened uploader editor
  • +
  • cell is the current cell
  • +
var etConfig = { + cell_editors:[ + { + type: 'uploader', + uploader: { + on_after_close: function(o, editor, cell){ + alert('uploader is closed now'); + } + } + }] + }
+ Top of page +
+ + +

Actions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
actionsobjectserver actions configuration object (default: {})   

var etConfig = {
+ actions:{
+ 'update': {
+ uri: 'updateRow.php', submit_method: 'form', form_method: 'POST', +
+ param_names: ['iso', 'name', 'printablename', 'iso3', 'code'] },
+ + 'insert': {
+ uri: 'insertRow.php', submit_method: 'form', form_method: 'POST', +
+ param_names: ['iso', 'name', 'printablename', 'iso3', 'code'] },
+ 'delete': {
+ uri: 'script.delete.php', submit_method: 'script', bulk_delete: + true }
+ }
+ +
}

+
update object'update' action configuration object (default: {})

Below the list of properties for the 'update' actions:

+
    +
  • uri: server-side page
  • +
  • form_method: 2 possible values 'form' or 'script'
  • +
  • submit_method: 'POST' or 'GET' requests, if form_method is script + only GET requests
  • +
  • param_names: collection of parameters expected by the server-side + page (uri property)
  • + +
var etConfig = {
+ actions:{
+ 'update': {
+ uri: 'updateRow.php', submit_method: 'form', form_method: 'POST', +
+ param_names: ['iso', 'name', 'printablename', 'iso3', 'code'] } }
+ +
}
insertobject 'insert' action configuration object (default: {})

Below the list of properties for the 'insert' actions:

+ +
    +
  • uri: server-side page
  • +
  • form_method: 2 possible values 'form' or 'script'
  • +
  • submit_method: 'POST' or 'GET' requests, if form_method is script + only GET requests
  • +
  • param_names: collection of parameters expected by the server-side + page (uri property)
  • +
  • default_record: collection of values to add when a row is added + to table (insert command button)
  • + +

var etConfig = {
+ actions:{
+ 'insert': {
+ uri: 'insertRow.php', submit_method: 'form', form_method: 'POST', +
+ param_names: ['iso', 'name', 'printablename', 'iso3', 'code'],
+ + default_record: ['', 'New country', 'New country', 'XXX', '0']
} + }
+
}

+
deleteobject'delete' action configuration object  (default: {})

Below the list of properties for the 'update' actions:

+
    +
  • uri: server-side page
  • +
  • form_method: 2 possible values 'form' or 'script'
  • +
  • submit_method: 'POST' or 'GET' requests, if form_method is script + only GET requests
  • + +
  • param_names: collection of parameters expected by the server-side + page (uri property)
  • +
  • bulk_delete: enables multiple rows deletion operations
  • +
var etConfig = {
+ actions:{
+ 'delete': {
+ + uri: 'script.delete.php', submit_method: 'script', bulk_delete: true + } }
}
+ + +

Actions callback events

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
on_update_submitfunctiondelegate function called for submitting modified data to server + (default: null)

2 parameters are passed to the function:

+ +
    +
  • o is the current EditTable object
  • +
  • treated rows: array of modified rows objects
  • +


+ var etConfig = {
+
actions:{
+ + 'update': {
+ uri: 'updateRow.php', submit_method: 'form', form_method: 'POST', +
+ on_update_submit: function(o, treatedRows){ alert(treatedRows); + }
+ } } } }

+
on_insert_submit function delegate function called for submitting inserted data to server + (default: null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • treated rows: array of inserted rows objects
  • + +
var etConfig = {
+ actions:{
+ 'insert': {
+ uri: 'insertRow.php', submit_method: 'form', form_method: 'POST', +
+ on_insert_submit: function(o, treatedRows){ alert(treatedRows); }
+ + } } } }
on_delete_submitfunction delegate function called for submitting deleted data to server + (default: null)

2 parameters are passed to the function:

+ +
    +
  • o is the current EditTable object
  • +
  • treated rows: array of deleted rows objects
  • +

+ var etConfig = {
+ actions:{
+ + 'delete': {
+ uri: 'script.delete.php', submit_method: 'script', bulk_delete: false,
+ on_delete_submit: function(o, treatedRows){ alert(treatedRows); }
+ } } } }
on_before_submit function callback function called before data is sent to server (default: + null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • treated rows: array of modified rows objects
  • + +

var etConfig = {
+ actions:{
+ 'update': {
+ uri: 'updateRow.php', submit_method: 'form', form_method: 'POST',
+ on_before_submit: function(o, modifiedRows){ alert('before update'); + }
+ + },
+ 'insert': {
+ uri: 'insertRow.php', submit_method: 'form', form_method: 'POST', +
+ on_before_submit: function(o, modifiedRows){ alert('before insert'); + }
+ },
+ 'delete': {
+ + uri: 'script.delete.php', submit_method: 'script', bulk_delete: + false,
+ on_before_submit: function(o, modifiedRows){ alert('before delete'); + } }
} }

+
on_after_submit function callback function called after data is sent to server (default: + null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • treated rows: array of modified rows objects
  • +
var etConfig = {
+ actions:{
+ 'update': {
+ uri: 'updateRow.php', submit_method: 'form', form_method: 'POST',
+ on_after_submit: function(o, modifiedRows){ alert('before update'); + }
+ },
+ + 'insert': {
+ uri: 'insertRow.php', submit_method: 'form', form_method: 'POST', +
+ on_after_submit: function(o, modifiedRows){ alert('before insert'); + }
+ },
+ 'delete': {
+ uri: 'script.delete.php', submit_method: 'script', bulk_delete: false,
+ + on_after_submit: function(o, modifiedRows){ alert('before delete'); + } }
}
on_submit_error function callback function called when error occurs when data is sent to + server (default: null)

2 parameters are passed to the function:

+
    +
  • o is the current EditTable object
  • +
  • e is the error object
  • +
  • desc is the error object description
  • +
+
+var etConfig = {
+        actions: {
+            'update': {
+                uri: 'updateRow.php',
+                submit_method: 'form',
+                form_method: 'POST',
+                on_submit_error: function (o, e, desc) {
+                    alert('An error occured');
+                }
+            },
+            'insert': {
+
+                uri: 'insertRow.php',
+                submit_method: 'form',
+                form_method: 'POST',
+
+                on_submit_error: function (o, e, desc) {
+                    alert('An error occured');
+                }
+            },
+            'delete': {
+                uri: 'script.delete.php',
+                submit_method: 'script',
+                bulk_delete: false,
+                on_submit_error: function (o, e, desc) {
+                    alert('An error occured');
+                }
+            }
+        }
+          	
+
check_response_sanity newfunctioncallback function called when the AJAX request returns a response object + usually in JSON format. This delegate checks the sanity of the response object and + returns a boolean (default: null) +

This callback is invoked only when ajax is on.

+

1 parameter is passed to the function:

+
    +
  • data: response object, usually in JSON format
  • +
+
+
+actions: {
+    'update': {
+        uri: 'php/json.update.record.php',
+        form_method: 'POST',
+        param_names: [
+        	'id', 'name', 'email', 'startdate', 'salary'
+        ],
+        check_response_sanity: function (data) {
+            return (data && data.hasOwnProperty('result') &&
+                data.result.hasOwnProperty('success'));
+        }
+    },
+    'insert': {
+        uri: 'php/json.insert.record.php',
+        form_method: 'POST',
+        param_names: [
+        	'id', 'name', 'email', 'startdate', 'salary'
+        ],
+        default_record: [
+        	'', 'Employee name...', 
+        	'employee@email.com', '2011-01-01', 
+        	'0.00'
+        ],
+        check_response_sanity: function (data) {
+            return (data && data.hasOwnProperty('result') &&
+                data.result.hasOwnProperty('success'));
+        }
+    },
+    'delete': {
+        uri: 'php/json.delete.record.php',
+        form_method: 'POST',
+        bulk_delete: false,
+        param_names: ['id'],
+        check_response_sanity: function (data) {
+            return (data && data.hasOwnProperty('result') &&
+                data.result.hasOwnProperty('success'));
+        }
+    }
+};
+          	
+
process_response newfunctioncallback function called when the AJAX request returns a response object + usually in JSON format. This delegate gives the possibility to add custom + processing of the response object (default: null) +

This callback is invoked only when ajax is on.

+

1 parameter is passed to the function:

+
    +
  • data: response object, usually in JSON format
  • +
+
+
+actions: {
+    'update': {
+        uri: 'php/json.update.record.php',
+        form_method: 'POST',
+        param_names: [
+        	'id', 'name', 'email', 'startdate', 'salary'
+        ],
+        process_response: function (data) {
+        	alert(data.result.description);
+        }
+    },
+    'insert': {
+        uri: 'php/json.insert.record.php',
+        form_method: 'POST',
+        param_names: [
+        	'id', 'name', 'email', 'startdate', 'salary'
+        ],
+        default_record: [
+        	'', 'Employee name...', 
+        	'employee@email.com', '2011-01-01', 
+        	'0.00'
+        ],
+        process_response: function (data) {
+            alert(data.result.description + 
+            	' ('+ data.result.id +')');
+        }
+    },
+    'delete': {
+        uri: 'php/json.delete.record.php',
+        form_method: 'POST',
+        bulk_delete: false,
+        param_names: ['id'],
+        process_response: function (data) {
+            alert(data.result.description + 
+            	' ('+ data.result.id +')');
+        }
+    }
+};
+          	
+
+ + +

Messages

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
msg_submit_okstringtext displayed when data was successfully sent to the server (default: + 'Modified rows were successfully submitted to server!') 

 

var etConfig = { msg_submit_ok: 'Data saved successfully!'}
msg_confirm_delete_selected_rowsstringtext displayed to ask confirmation for deleting operation (default: + ''Do you want to delete the selected row(s)?'')  var etConfig = { msg_confirm_delete_selected_rows: 'Are you + sure you want to delete selected rows?' }
msg_error_occuredstringtext displayed when an error occurs in general (default: 'An error + occured!')  var etConfig = { msg_error_occured: 'Error!' }
msg_submit_unsuccessfulstringtext displayed when an error occurs when data is sent to server + (default: 'Modified rows could not be saved correctly!')  var etConfig = { msg_submit_unsuccessful: 'Data could not + be saved correctly!' }
undefined_submit_urlstringtext displayed when data cannot be sent to server because URI is + missing (default: 'Modified rows could not be saved! Submit URL is + not defined')  var etConfig = { msg_filter: 'Please provide a URL to which + submit data!' }
+ + Top of page +
+ + +
+ + + + +
+ + + + diff --git a/dist/extensions/ezEditTable/docs/doc_class.html b/dist/extensions/ezEditTable/docs/doc_class.html new file mode 100644 index 00000000..38dab65f --- /dev/null +++ b/dist/extensions/ezEditTable/docs/doc_class.html @@ -0,0 +1,154 @@ + + + + + ezEditTable, enhance HTML tables easily, advanced inline editing, selection and keyboard navigation - script by Max Guglielmi + + + + + + + + + + + + + + + +
+ + + + + +
+ + +

Documentation

+ + +

EditTable Class

+ + + + +

Constructor

+

EditTable(id, startRow, config);

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterTypeDescriptionRemarksExample
idstringid of the table element var myEditTable = new EditTable("myTableId");
startRow numberindex of the first row from which row selection can startoptional parametervar myEditTable = new EditTable("myTableId", 2);
configobject configuration objectoptional parametervar myEditTable = new EditTable("myTableId", 2, { editable: true });
+ + + +
+ +
+ + + + +
+ + + + diff --git a/dist/extensions/ezEditTable/docs/doc_methods.html b/dist/extensions/ezEditTable/docs/doc_methods.html new file mode 100644 index 00000000..f69723e9 --- /dev/null +++ b/dist/extensions/ezEditTable/docs/doc_methods.html @@ -0,0 +1,599 @@ + + + + ezEditTable, enhance HTML tables easily, advanced inline editing, selection and keyboard navigation - script by Max Guglielmi + + + + + + + + + + + + + + + +
+ + + + + +
+ + + +

Documentation

+ + + + +

EditTable Class

+ + + + +

General Public Methods

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MethodDescriptionRemarksExample
Init()EditTable object initialisation  var myET = new EditTable('myTableId');
+ myET.editable = true;
+ ...
+ myET.Init();
GetCellsNb( rowIndex )returns number of cells of a specified row  myET.GetCellsNb(4);
GetRowsNb()returns total number of rows myET.GetRowsNb();
GetRow(e)returns the DOM row element for a given event function myFunction(e){ var clickedRow = myET.GetRow(e); }
GetRowByIndex( rowIndex )returns the DOM row element for a given row index  myET.GetRowByIndex(5);
GetCell(e)returns the DOM cell element for a given event  function myFunction(e){ var clickedCell = myET.GetCell(e); + }
IsSelectable()checks if table rows are selectable and returns a boolean  myET.IsSelectable();
IsEditable()checks if table is editable and returns a boolean  myET.IsEditable();
ClearSelections()clears current row(s) and/or cell selection  myET.ClearSelections();
+ + Top of page +
+ + +

Selection Public Methods

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MethodDescriptionRemarksExample
Init()Selection object initialisation  var myET = new EditTable('myTableId');
+ ...
+ myET.Selection.Init();
Set()enables selection feature  myET.Selection.Set();
Remove() disables selection feature myET.Selection.Remove();
SetEvents()sets click and keyboard events to table element myET.Selection.SetEvents();
RemoveEvents()removes click and keyboard events to table element myET.Selection.RemoveEvents();
GetActiveRow()returns the active row element, that is, the row currently selected  var activeRow = myET.Selection.GetActiveRow();
+ if(activeRow){ ... }
GetActiveCell()returns the active cell element, that is, the cell currently selected var activeCell = myET.Selection.GetActiveCell();
+ if(activeCell){ ... }
GetSelectedRows()returns an array of the row elements currently selected, if selection + model is multiplereturns:
+ [rowobject, rowobject, rowobject, ... rowobject]
var selRows = myET.Selection.GetSelectedRows();
+ if(selRows.length > 0){ ... }
GetSelectedValues()returns an array containing a collection of selected rows values + returns: [
+ ['value 0', 'value 1', 'value 2', ... 'value 3'],
+ ['value 0', 'value 1', 'value 2', ... 'value 3'],
+ + ['value 0', 'value 1', 'value 2', ... 'value 3'],
+ ...
+ ['value 0', 'value 1', 'value 2', ... 'value 3']
+ ]
var selValues = myET.Selection.GetSelectedValues();
+ if(selValues.length > 0){
+ + var firstValueOfFirstSelectedRow = selValues[0][0];
+ }
GetActiveRowValues()returns an array containing the cell values of active rowreturns ['value 0', 'value 1', 'value 2', ... 'value 3']var activeValues = myET.Selection.GetActiveRowValues();
+ if(activeValues.length > 0){ ... }
GetRowValues( row )returns an array containing the cell values of a given row, it accepts + only a row DOM elementreturns ['value 0', 'value 1', 'value 2', ... 'value 3']

var myRow = myET.GetRowByIndex(7);
+ if(myRow){
+ myRowValues = myET.Selection.GetRowValues(myRow);
+
}

SelectRowByIndex( rowIndex )selects a row for a given row index  myET.Selection.SelectRowByIndex(9);
SelectRowsByIndexes( rowIndexes ) newselects rows for a given array of row indexesMultiple selection needs to be active (selection_model: 'multiple') myET.Selection.SelectRowsByIndexes([2, 7, 9, 12]);
SelectRow( row )selects given row element var myRow = myET.GetRowByIndex(6);
+ if(myRow){
+ myET.Selection.SelectRow(myRow);
+ }
DeselectRow( row )deselects given row element var myRow = myET.GetRowByIndex(6);
+ if(myET.Selection.IsRowSelected(myRow)){
+ + myET.Selection.DeselectRow(myRow);
+ }
SelectCell( cell )selects given cell element var myCell = myET.GetRowByIndex(3).cells[2];
+ if(myCell) myET.Selection.SelectCell(myCell);
DeselectCell( cell )deselects given cell element var myCell = myET.GetRowByIndex(3).cells[2];
+ if(myCell) myET.Selection.DeselectCell(myCell);
ClearSelections()clears current row(s) and/or cell selectionThe general ClearSelections() invokes this method ( + myET.ClearSelections() )myET.Selection.ClearSelections();
IsRowSelected( row )determines if given row is selected and returns a boolean var myRow = myET.GetRowByIndex(6);
+ + if(myET.Selection.IsRowSelected(myRow)){ ... }
IsCellSelected( cell )determines if given cell is selected and returns a boolean var myCell = myET.GetRowByIndex(3).cells[2];
+ + if(myET.Selection.IsCellSelected( myCell )){ ... }
+ + Top of page +
+ + +

Editable Public Methods

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MethodDescriptionRemarksExample
Init()Editable object initialisation  var myET = new EditTable('myTableId');
+ + ...
+ myET.Editable.Init();
Set()enables inline editing feature  myET.Editable.Set();
Remove() disables inline editing feature myET.Editable.Remove();
SetEvents()sets click and keyboard events to table element myET.Editable.SetEvents();
RemoveEvents()removes click and keyboard events to table element myET.Editable.RemoveEvents();
GetModifiedRows()returns an array containing the modified rows objectsreturns:
+ [
+ [rowIndex,
+ { values: [val0, val1, ...valn],
+ urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
+ + modified: [true, false, ...]
+ }],
+ ...
+ [rowIndex,
+ { values: [val0, val1, ...valn],
+ urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
+ + modified: [true, false, ...]
+ }]
+ ]
+ urlParams are the paramaters names that are expected server-side. + If the parameters' names are not defined by the property param_names + in the actions object (configuration object actions), + the param name by default equals to 'col_n' where + n is the column index (col_0, col_1, ... col_n)

var modRowObjs = myET.Editable.GetModifiedRows();
+ for(var i=0; i<modRowObjs.length; i++){
+ var rowIndex = modRowObjs[i][0]; //int
+ var obj = modRowObjs[i][1]; //object
+ var objValues = obj.values; //array
+ + var objModValues = obj.modified; //array of booleans
+ var objUrlParams = obj.urlParams //string
+ }

GetAddedRows()returns an array containing the added rows objectsreturns:
+ [
+ [rowIndex,
+ { values: [val0, val1, ...valn],
+ urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
+ + modified: [true, true, ...]
+ }],
+ ...
+ [rowIndex,
+ { values: [val0, val1, ...valn],
+ urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
+ + modified: [true, true, ...]
+ }]
+ ]
+ urlParams are the paramaters names that are expected server-side. + If the parameters' names are not defined by the property param_names + in the actions object (configuration object actions), + the param name by default equals to 'col_n' where + n is the column index (col_0, col_1, ... col_n)
var addRowObjs = myET.Editable.GetAddedRows();
+ for(var i=0; i<addRowObjs.length; i++){
+ var rowIndex = addRowObjs[i][0]; //int
+ var obj = addRowObjs[i][1]; //object
+ var objValues = obj.values; //array
+ var objModValues = obj.modified; //array of booleans
+ + var objUrlParams = obj.urlParams //string
+ }
GetDeletedRows()returns an array containing the deleted rows objectsreturns:
+ + [
+ [rowIndex,
+ { values: [val0, val1, ...valn],
+ urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
+ modified: [false, false, ...]
+ + }],
+ ...
+ [rowIndex,
+ { values: [val0, val1, ...valn],
+ urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
+ + modified: [false, false, ...]
+ }]
+ ]
+ urlParams are the paramaters names that are expected server-side. + If the parameters' names are not defined by the property param_names + in the actions object (configuration object actions), + the param name by default equals to 'col_n' where + n is the column index (col_0, col_1, ... col_n)
var delRowObjs = myET.Editable.GetDeletedRows();
+ for(var i=0; i<delRowObjs.length; i++){
+ var rowIndex = delRowObjs[i][0]; //int
+ var obj = delRowObjs[i][1]; //object
+ var objValues = obj.values; //array
+ + var objModValues = obj.modified; //array of booleans
+ var objUrlParams = obj.urlParams //string
+ }
SubmitEditedRows()submits edited rows to server according to actions configuration + options modified rows objects are sent to server (uri property in 'update' + actions configuration options)

function SaveEditedRows(){
+ myET.Editable.SubmitEditedRows();
+ }

+
SubmitAddedRows()submits added rows to server according to actions configuration + options added rows objects are sent to server (uri property in 'insert' + actions configuration options)function SaveAddedRows(){ + myET.Editable.SubmitAddeddRows(); + }
SubmitDeletedRows()submits deleted rows to server according to actions configuration + options deleted rows objects are sent to server (uri property in 'delete' + actions configuration options). A + confirmation prompt appears before sending data to server

function DeleteSelectedRows(){ + myET.Editable.SubmitDeletedRows(); + }

SubmitAll() newsubmits added and edited rows to server according to actions configuration + options function SubmitAll(){ myET.Editable.SubmitAll(); }
AddNewRow()adds a row to the tablemyET.Editable.AddNewRow();
+ +
+ + + + +
+ + + + diff --git a/dist/extensions/ezEditTable/docs/doc_properties.html b/dist/extensions/ezEditTable/docs/doc_properties.html new file mode 100644 index 00000000..1c295cf3 --- /dev/null +++ b/dist/extensions/ezEditTable/docs/doc_properties.html @@ -0,0 +1,515 @@ + + + + + ezEditTable, enhance HTML tables easily, advanced inline editing, selection and keyboard navigation - script by Max Guglielmi + + + + + + + + + + + + + + + +
+ + + + + +
+ + + +

Documentation

+ + + +

EditTable Class

+ + + + +

General Public Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
idstringreturns the HTML table's id used by the EditTable objectuse it as getter onlyalert( myET.id );
tableHTMLTableElementreturns the HTML table element used by the EditTable objectuse it as getter onlyalert( myET.table );
configobjectreturns the EditTable configuration object (literal object)use it as getter or setteralert( myET.config );
startRownumberindex of the first row from which row selection can startuse it as getter onlyalert( myET.startRow );
nbCellsnumberreturns the number of table columnsuse it as getter onlyalert( myET.nbCells );
selectionbooleanenables / disables selection modeluse it as getter or settermyET.selection = false;
keyNavbooleanenables / disables keyboard navigationuse it as getter or settermyET.keyNav = false;
editablebooleanenables / disables inline editinguse it as getter or settermyET.editable = true;
tableCssstringdefines the css class of the table elementuse it as getter or settermyET.tableCss = 'myClass';
unselectableCssstringdefines the css class that makes the table text unselectableuse it as getter or setteralert( myET.unselectableCss );
activityIndicatorCssstringdefines the css class to be applied to the table in order to indicate + server activity use it as getter or setteralert( myET.activityIndicatorCss );
basePathstringdefines the path to the script's directoryuse it as getter or setteralert( myET.basePath );
+
+ Top of page + + +

Selection Public Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
selectionModelstringdefines the selection model: "single" or "multiple"use it as getter or setter - 2 possible values: 'single' or 'multiple'myET.selectionModel = 'multiple';
defaultSelectionstringdefines the selection typeuse it as getter or setter - 3 possible values: 'row', 'cell' or + 'both'myET.defaultSelection = 'both';
keySelectionbooleanenables / disable multiple selection by using Ctrl and Shift keys + use it as getter or setter - select multiple rows by holding Ctrl + or Shift key down, only if selection model is 'multiple'myET.keySelection = false;
selectRowAtStartbooleanfirst row is selected at start if set trueuse it as getter or settermyET.selectRowAtStart = true;
rowIndexAtStartnumberdefines which row has to be selected at startuse it as getter or settermyET.rowIndexAtStart = 5;
scrollIntoViewbooleanIf set true selected row scrolls into view; useful when row is selected + by using keyboarduse it as getter or settermyET.scrollIntoView = true;
activeRowCssstringdefines css class for active rowuse it as getter or settermyET.activeRowCss = 'myClass';
selectedRowCssstringdefines css class for selected rowsuse it as getter or setter - only if 'multiple' selection model + is enabledmyET.selectedRowCss = 'myClass';
activeCellCssstringdefines css class for active celluse it as getter or setter - only if 'cell' or 'both' selection + type is enabledmyET.activeCellCss = 'myClass';
nbRowsPerPagenumberdefines number of rows to jump when PgDown or PgUp keys are presseduse it as getter or setter - specify a huge number to jump straight + to 1st or last row (1000)myET.nbRowsPerPage = 1000;
+
+ Top of page + + +

Editable Public Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescriptionRemarksExample
editorModelstringdefines the editor modeluse it as getter or setter - 2 possible values: 'cell' or 'row'myET.editorModel = 'row';
openEditorActionstringdefines which mouse action opens the inline editing featureuse it as getter or setter - 2 possible values: 'dblclick', 'click'myET.openEditorAction = 'click';
ajax newbooleanenables AJAX requests (default: true if jQuery is detected)it is enabled if jQuery is detected and the ajax property is + not explicitly set falsemyET.ajax = false;
inputEditorCssbooleandefines the css class for 'input' type editorsuse it as getter or setter - select multiple rows by holding Ctrl + or Shift key down, only if selection model is 'multiple'myET.inputEditorCss = 'myClass';
textareaEditorCssbooleandefines the css class for 'textarea' type editorsuse it as getter or settermyET.textareaEditorCss = 'myClass';
selectEditorCssnumberdefines the css class for 'input' type editorsuse it as getter or settermyET.selectEditorCss = 'myClass';
commandEditorCssbooleancss class applied to command editor buttons containeruse it as getter or settermyET.commandEditorCss = 'myClass';
modifiedCellCssstringcss class applied to modified cellsuse it as getter or setter - this css class shows the green small + triangle in the left-upper corner of the cellmyET.modifiedCellCss = 'myClass';
cellEditorsarrayarray defining the editor configuration for each columnuse it as getter or setter - the number of editors must be equal + to the number of columns. Refer to Cell + editors properties for details about editors' configurationmyET.cellEditors = [
+ { type: 'select' },
+ { type: 'textarea' },
+ { type: 'input' },
+ { type: 'uploader' },
+ { type: 'none' },
+ { type: 'command' }
+ ];
actionsobjectserver actions configuration object use it as getter or setter - Refer to actions + properties for details about server actions configurationmyET.actions = {
+ 'update': {
+ uri: 'updateRow.php', submit_method: 'form', form_method: 'POST', +
+ param_names: ['iso', 'name', 'printablename', 'iso3', 'code'] },
+ 'insert': {
+ uri: 'insertRow.php', submit_method: 'form', form_method: 'POST', +
+ + param_names: ['iso', 'name', 'printablename', 'iso3', 'code'] },
+ 'delete': {
+ uri: 'script.delete.php', submit_method: 'script', bulk_delete: true + }
+ }
autoSavebooleansaves automatically pending changes upon selection changeeditable property needs to be activated (default: true if editable is on)myET.autoSave = false;
autoSaveModelstringdetermines when modified and/or added data is saved, upon row or cell selection change (default: 'row')2 possible values 'row' or 'cell'myET.autoSaveModel = 'cell';
autoSaveTypestringdefines if only insertions or updates, or both are saved automatically (default: 'both')3 possible values 'insert', 'update' or 'both'myET.autoSaveType = 'update';
editableOnKeystroke newbooleanmakes the inline cell editor appear upon keystroke (default: false)only if edition is enabled and editorModel is set to 'cell' and + selectionModel to 'single'myET.editableOnKeystroke = true;
newRowPrefixstringdefines the prefix for new added row ids (default: 'tr')prefix should match the prefix assigned to already existing rowsmyET.newRowPrefix = 'row';
formSubmitIntervalnumberdefines the interval in ms separating rows data submissions (default: 50)by default the script submits a single form for each modified row. Depending on ISPs + security policies, multiple submissions to same page are simply blocked by the server. + This interval can be useful to fine tune the form submissions when those server restrictions apply.myET.formSubmitInterval = 750;
newRowPos newstring or numberdefines the row position of a newly created row (default: 'top')2 possible values as a string: 'top' or 'bottom', and as an integer: + any number >= 0 and <= total number of rows. If the supplied numeric + value exceeds the total number of rows then the script fallback to default + value 'top'myET.newRowPos = 'bottom';
+
+ + Top of page + + +
+ + + + +
+ + + + diff --git a/dist/extensions/ezEditTable/docs/doc_utilities.html b/dist/extensions/ezEditTable/docs/doc_utilities.html new file mode 100644 index 00000000..2f362404 --- /dev/null +++ b/dist/extensions/ezEditTable/docs/doc_utilities.html @@ -0,0 +1,207 @@ + + + + + ezEditTable, enhance HTML tables easily, advanced inline editing, selection and keyboard navigation - script by Max Guglielmi + + + + + + + + + + + + + + + +
+ + + + + +
+ + + +

Documentation

+ + + +

Utility Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MethodDescriptionRemarksExample
setEditTable( id, startRow, config )

Calls EditTable constructor and returns the EditTable object:

+ +
    +
  • id: table id (string)
  • +
  • startRow (optional): index of the first row from which row selection + can start (number)
  • +
  • config (optional): configuration object (literal object)
  • +
  var et = setEditTable('myTableId', 2, { editable: true });
Get(id)

this is a document.getElementById() shortcut:

+
    +
  • id: id of the element (string)
  • + +
  var myElm = et.Get('myId');
Tag(o, tagname)

this is just a getElementsByTagName() shortcut:

+ +
    +
  • o: target element (DOM element)
  • +
  • tagname: tag to search for (string)
  • +
+

It returns an array

 var myTables = et.Tag(document, 'table');
GetText(n)

returns the text of given a node and its child nodes:

+
    +
  • n: node (DOM element)
  • +
 var tableText = et.GetText( et.Tag(document,'table' )[0]);
CreateElm(tag)

creates an html element with defined attributes:

+
    +
  • the html tag to create (string)
  • + +
  • an unlimited # of arrays defining the attributes values ('attribute + name','value' ['id','myId'])
  • +
 var myInput = et.CreateElm( 'input', ['id','myId'], ['value','Hello + world'] );
CreateText(t)

this is just a document.createTextNode shortcut:

+ +
    +
  • t: text to generate (string)
  • +
 var myText = et.CreateText( 'Hello world' );
IsArray(obj)

checks if passed param is an array. It returns a boolean

 alert(et.IsArray([1,2,3]));
IsObj(obj)

checks if passed param is an object. It returns a boolean

 alert(et.IsObj({ text: 'hello'}));
IsFn(fn)

checks if passed param is a function. It returns a boolean

 alert(et.IsFn(function(){ var a=0; }));
+ +
+ + + +
+ + + + +
+ + + + diff --git a/dist/extensions/ezEditTable/docs/index.html b/dist/extensions/ezEditTable/docs/index.html new file mode 100644 index 00000000..8d1da9ef --- /dev/null +++ b/dist/extensions/ezEditTable/docs/index.html @@ -0,0 +1,473 @@ + + + + + ezEditTable, enhance HTML tables easily, advanced inline editing, selection and keyboard navigation - script by Max Guglielmi + + + + + + + + + + + + + + + +
+ + + + + +
+

ezEditTable

+

Description

+

+ ezEditTable is a javascript code aimed at enhancing regular + HTML tables by adding features such as inline editing components, advanced + selection and keyboard navigation. With just a line of code you can easily + convert a regular HTML table in an advanced editable and selectable grid control. +

+

Main features

+
    +
  • Attach to an existing HTML table
  • +
  • Advanced selection model
  • +
  • Extended keyboard navigation
  • +
  • Inline cell or row editing
  • +
  • Insert and remove rows
  • +
  • Send changes to server via GET or POST form submission, AJAX requests or + by script injection in the head section of the document (only GETs)
  • +
  • Integration with any server-side technology as this is a pure client-side solution
  • +
  • Callbacks for all events, and delegates for most actions
  • +
  • Based on plain javascript and dependent on jQuery only for performing AJAX requests
  • +
  • Exhaustive documentation and API
  • +
  • Easy setup and easy customisable themes
  • +
+ +

Installation + + Starter + +

+

To install ezEditTable unzip the download package and then include the following + scripts and stylesheet files in the head section of your page:

+ +
+	<link href="ezEditTable/ezEditTable.css" rel="stylesheet" type="text/css"/>
+	<script src="ezEditTable/ezEditTable.js"></script>
+	
+ +

Make sure the table you'd like to make editable or selectable + has an unique id and a thead and tbody + sections.

+

Here you have an example of a regular html table:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FromDestinationRoad Distance (km)By Air (hrs)By Rail (hrs)
SydneyAdelaide14121.425.3
SydneyBrisbane9821.516
SydneyCanberra286.64.3
SydneyMelbourne8721.110.5
AdelaidePerth27813.138
AdelaideAlice Springs1533220.25
AdelaideBrisbane20452.1540
+ +

Below the same table enhanced by the script (id="table1"), + click to select a row or use keys to move the selection:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FromDestinationRoad Distance (km)By Air (hrs)By Rail (hrs)
SydneyAdelaide14121.425.3
SydneyBrisbane9821.516
SydneyCanberra286.64.3
SydneyMelbourne8721.110.5
AdelaidePerth27813.138
AdelaideAlice Springs1533220.25
AdelaideBrisbane20452.1540
+ + +

There are 2 different ways to call the script:

+
    + + +
  • invoke the setEditTable function, which returns a EditTable object:
  • +
+ +
<script language="javascript" type="text/javascript">
+	var et = setEditTable("table1");
+</script> 
+ +
    +
  • instanciate the EditTable object:
  • +
+ +
<script language="javascript" type="text/javascript">
+	var et = new EditTable('table1');
+	et.Init();
+</script> 
+

If your document contains several tables (like this page), it is important + to define unique ids, otherwise the script will not work properly.

+ +

The setEditTable() function or the EditTable + class accepts 2 additional parameters that will be explained in the next + tables. In the example below, by specifing a row number as a "start" + row, we tell the script from which row can start the selection, this is + helpful when the tbody and thead sections are not defined:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
This is the table caption
FromDestinationRoad Distance (km)By Air (hrs)By Rail (hrs)
SydneyAdelaide14121.425.3
SydneyBrisbane9821.516
SydneyCanberra286.64.3
SydneyMelbourne8721.110.5
AdelaidePerth27813.138
AdelaideAlice Springs1533220.25
AdelaideBrisbane20452.1540
+ + +
var et02 = setEditTable("table2", 2);
+ +

or

+ +
var et02 = new EditTable("table2", 2);
+et02.Init();
+

By default, the script adds a single row selection feature to the table. + You could decide to also add a cell selection feature and make the cells + editable, double-click on a cell to see:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
This is the table caption
FromDestinationRoad Distance (km)By Air (hrs)By Rail (hrs)
SydneyAdelaide14121.425.3
SydneyBrisbane9821.516
SydneyCanberra286.64.3
SydneyMelbourne8721.110.5
AdelaidePerth27813.138
AdelaideAlice Springs1533220.25
AdelaideBrisbane20452.1540
+ +

To do that you just need to declare a literal object (configuration + object) in which you specify the features you would like to enable:

+ +
<script language="javascript" type="text/javascript">
+	var table3Config = {
+		default_selection: 'both',
+		editable: true,
+		auto_save: false
+	}
+ 	var et03 = setTableEdit("table3", 2, table3Config);
+</script>
+

or

+
<script language="javascript" type="text/javascript">
+	var table3Config = {
+		default_selection: 'both',
+		editable: true,
+		auto_save: false
+	}
+	var et03 = new EditTable("table3", 2 ,table3Config);
+	et03.Init();
+</script>
+ +

You can name the configuration object as you want, but don't forget + to add it to the parameters of the setEditTable() function + or EditTable class. It is important to respect the syntax and + naming convention as shown above. You will find an exhaustive list of properties + in the documentation section.

+

Documentation

+ + +

For more information about the script's configuration and API check out + the documentation and the + available online demos.

+ +
+ +
+ + + + +
+ + + + diff --git a/dist/extensions/ezEditTable/docs/samples.html b/dist/extensions/ezEditTable/docs/samples.html new file mode 100644 index 00000000..233ed4fe --- /dev/null +++ b/dist/extensions/ezEditTable/docs/samples.html @@ -0,0 +1,1082 @@ + + + + ezEditTable, enhance HTML tables easily, advanced inline editing, selection and keyboard navigation - script by Max Guglielmi | Samples, Examples + + + + + + + + + + + + + + + +
+ + + + + +
+ +

Samples + + Starter + +

+ +

In this page you will find a collection of samples showing how to configure + the ezEditTable script.

+
+
    +
  • Table 1: call the script
  • +
  • Table 2: enable cell selection only
  • + +
  • Table 3: enable multiple rows selection (click + + ctrl or shift key) and define selection's starting row
  • +
  • Table 4: disable key navigation and key selection + (ctrl and shift key for multiple selection), enable multiple selection + (click selection)
  • +
  • Table 5: select a row at start and use callback + event functions before and after a row is selected
  • +
  • Table 6: enable default inline cell editing, double-click + on a cell to display cell editor
  • +
  • Table 7: define editor type by column, double-click + or use F2, enter or spacebar keys to display editor
  • + +
  • Table 8: use the script's public methods and properties + to change features programmatically or to retrieve information
  • +
  • Table 9: enable a command type column editor
  • +
+
+ +
+

Here you have a regular HTML table:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ WORLD INTERNET USAGE AND POPULATION STATISTICS +
World RegionsPopulation ( 2007 Est.)Population % of World% Population ( Penetration )Usage % of World
Africa933,448,29214.2 %3.5 %3.0 %
Asia3,712,527,62456.5 %10.5 %35.6 %
Europe809,624,68612.3 %38.6 %28.6 %
Middle East193,452,7272.9 %10.0 %1.8 %
North America334,538,0185.1 %69.4 %21.2 %
Latin America / Caribbean556,606,6278.5 %16.0 %8.1 %
Oceania / Australia34,468,4430.5 %53.5 %1.7 %
+ +

Below the same table enhanced by the ezEditTable script:

+ +

TABLE 1

+

Call the script

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
World RegionsPopulation ( 2007 Est.)Population % of World% Population ( Penetration )Usage % of World
Africa933,448,29214.2 %3.5 %3.0 %
Asia3,712,527,62456.5 %10.5 %35.6 %
Europe809,624,68612.3 %38.6 %28.6 %
Middle East193,452,7272.9 %10.0 %1.8 %
North America334,538,0185.1 %69.4 %21.2 %
Latin America / Caribbean556,606,6278.5 %16.0 %8.1 %
Oceania / Australia34,468,4430.5 %53.5 %1.7 %
+ +
<script language="javascript" type="text/javascript">
+	var et1 = setEditTable("table1");
+</script>
+
+ + Top of page +
+ +

TABLE 2

+

Enable cell selection only

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
World RegionsPopulation ( 2007 Est.)Population % of World% Population ( Penetration )Usage % of World
Africa933,448,29214.2 %3.5 %3.0 %
Asia3,712,527,62456.5 %10.5 %35.6 %
Europe809,624,68612.3 %38.6 %28.6 %
Middle East193,452,7272.9 %10.0 %1.8 %
North America334,538,0185.1 %69.4 %21.2 %
Latin America / Caribbean556,606,6278.5 %16.0 %8.1 %
Oceania / Australia34,468,4430.5 %53.5 %1.7 %
+ +
<script language="javascript" type="text/javascript">
+	var table2_Config = { default_selection:'cell' };
+	var et2 = setEditTable("table2", table2_Config);
+</script>
+ + Top of page +
+ +

TABLE 3

+ +

Enable multiple rows selection (click + ctrl or shift key) and define selection's + starting row

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Group 1Group 2Group 3
World RegionsPopulation ( 2007 Est.)Population % of World% Population ( Penetration )Usage % of World
Africa933,448,29214.2 %3.5 %3.0 %
Asia3,712,527,62456.5 %10.5 %35.6 %
Europe809,624,68612.3 %38.6 %28.6 %
Middle East193,452,7272.9 %10.0 %1.8 %
North America334,538,0185.1 %69.4 %21.2 %
Latin America / Caribbean556,606,6278.5 %16.0 %8.1 %
Oceania / Australia34,468,4430.5 %53.5 %1.7 %
+
<script language="javascript" type="text/javascript">
+	var table3_Config = { selection_model: 'multiple' };
+	var et3 = setEditTable("table3", table3_Config, 2);
+</script>
+ + Top of page +
+ +

TABLE 4

+

Disable key navigation and key selection, enable multiple selection (click + selection)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
World RegionsPopulation ( 2007 Est.)Population % of World% Population ( Penetration )Usage % of World
Africa933,448,29214.2 %3.5 %3.0 %
Asia3,712,527,62456.5 %10.5 %35.6 %
Europe809,624,68612.3 %38.6 %28.6 %
Middle East193,452,7272.9 %10.0 %1.8 %
North America334,538,0185.1 %69.4 %21.2 %
Latin America / Caribbean556,606,6278.5 %16.0 %8.1 %
Oceania / Australia34,468,4430.5 %53.5 %1.7 %
+
<script language="javascript" type="text/javascript">
+	table4_Config = { key_navigation: false, key_selection: false, selection_model: 'multiple' };
+	var et4 = setEditTable("table4", table4_Config);
+</script>
+ + Top of page +
+ +

TABLE 5

+ +

Select a row at start and use callback event functions before (on_before_selected_row) + and after (on_after_selected_row) a row is selected

+ +   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
World RegionsPopulation ( 2007 Est.)Population % of World% Population ( Penetration )Usage % of World
Africa933,448,29214.2 %3.5 %3.0 %
Asia3,712,527,62456.5 %10.5 %35.6 %
Europe809,624,68612.3 %38.6 %28.6 %
Middle East193,452,7272.9 %10.0 %1.8 %
North America334,538,0185.1 %69.4 %21.2 %
Latin America / Caribbean556,606,6278.5 %16.0 %8.1 %
Oceania / Australia34,468,4430.5 %53.5 %1.7 %
+ +
+<script language="javascript" type="text/javascript">
+	var table5_Config = {
+		select_row_at_start: true,
+		row_index_at_start: 1,
+		on_before_selected_row: function(o, row){ o.Get('output1').innerHTML = 'Active row: '+row.rowIndex.toString() +' '; },
+		on_after_selected_row: function(o, row){ o.Get('output2').innerHTML = 'Active row data:' + o.Selection.GetRowValues(row); },
+	};
+	var et5 = setEditTable("table5", table5_Config);
+</script>
+ + Top of page +
+

TABLE 6

+ +

Enable default inline cell editing, double-click on a cell to display cell + editor

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
World RegionsPopulation ( 2007 Est.)Population % of World% Population ( Penetration )Usage % of World
Africa933,448,29214.2 %3.5 %3.0 %
Asia3,712,527,62456.5 %10.5 %35.6 %
Europe809,624,68612.3 %38.6 %28.6 %
Middle East193,452,7272.9 %10.0 %1.8 %
North America334,538,0185.1 %69.4 %21.2 %
Latin America / Caribbean556,606,6278.5 %16.0 %8.1 %
Oceania / Australia34,468,4430.5 %53.5 %1.7 %
+
+<script language="javascript" type="text/javascript">
+	var table6_Config = { editable: true, auto_save: false, default_selection: 'both' };
+	var et6 = setEditTable("table6", table6_Config);
+</script>
+ + Top of page +
+ +

TABLE 7

+ +

Define editor type by column, double-click or use F2, enter or spacebar + keys to display editor

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
World RegionsPopulation ( 2007 Est.)Population % of World% Population ( Penetration )Usage % of World
Africa933,448,29214.2 %3.5 %3.0 %
Asia3,712,527,62456.5 %10.5 %35.6 %
Europe809,624,68612.3 %38.6 %28.6 %
Middle East193,452,7272.9 %10.0 %1.8 %
North America334,538,0185.1 %69.4 %21.2 %
Latin America / Caribbean556,606,6278.5 %16.0 %8.1 %
Oceania / Australia34,468,4430.5 %53.5 %1.7 %
+
+<script language="javascript" type="text/javascript">
+	var table7_Config = {
+		editable: true,
+		auto_save: false,
+		default_selection: 'both',
+		cell_editors:[
+			{ type: 'select', attributes:[['title','Choose a continent']] },
+			{ type: 'input', css:'alignRight' },
+			{ type: 'textarea', style:'background-color: yellow;' },
+			{ type: 'input', attributes:[['maxLength',5],['title','5 chars max']] },
+			{ type: 'none' }
+		]
+	};
+var et7 = setEditTable('table7', table7_Config);
+</script>
+ + Top of page +
+ +

TABLE 8

+ +

Use the script's public methods and properties to change features programmatically + or to retrieve information

+
+ + + + + + +
+ + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
World RegionsPopulation ( 2007 Est.)Population % of World% Population ( Penetration )Usage % of World
Africa933,448,29214.2 %3.5 %3.0 %
Asia3,712,527,62456.5 %10.5 %35.6 %
Europe809,624,68612.3 %38.6 %28.6 %
Middle East193,452,7272.9 %10.0 %1.8 %
North America334,538,0185.1 %69.4 %21.2 %
Latin America / Caribbean556,606,6278.5 %16.0 %8.1 %
Oceania / Australia34,468,4430.5 %53.5 %1.7 %
+ + +
+<script language="javascript" type="text/javascript">
+	var table8_Config = { editable: true, auto_save: false };
+	var et8 = setEditTable("table8", table8_Config);
+</script>
+
+<!-- buttons code below -->
+
+<input type="button" value="Is selectable?" onClick="alert( et8.IsSelectable() );" />
+<input type="button" value="Is editable?" onClick="alert( et8.IsEditable() );" />
+
+<input type="button" value="Clear selections" onClick="et8.ClearSelections();" />
+<input type="button" value="Disable edition" onClick="et8.Editable.Remove();" />
+
+<input type="button" value="Enable edition" onClick="et8.Editable.Set();" />
+<input type="button" value="Disable selection" onClick="et8.Selection.Remove();" />
+
+<input type="button" value="Enable selection" onClick="et8.Selection.Set();" />
+<input type="button" value="Enable multiple selection" onClick="et8.selectionModel = 'multiple';" />
+
+<input type="button" value="Disable multiple selection" onClick="et8.selectionModel = 'single';" />
+<input type="button" value="Enable cell selection" onClick="et8.ClearSelections(); et8.defaultSelection = 'cell';" />
+
+<input type="button" value="Disable cell selection" onClick="et8.ClearSelections(); et8.defaultSelection = 'row';" />
+<input type="button" value="Enable row editor" onClick="et8.editorModel = 'row';" />
+
+<input type="button" value="Disable row editor" onClick="et8.Editable.CloseRowEditor(); et8.editorModel = 'cell';" />
+<input type="button" value="Get active row values" onClick="alert(et8.Selection.GetActiveRowValues());" />
+
+<input type="button" value="Get selected rows values" onClick="alert(et8.Selection.GetSelectedValues());" />
+
+ + Top of page +
+ + +

TABLE 9

+

Enable a command type column editor

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
World RegionsPopulation ( 2007 Est.)Population % of World% Population ( Penetration )Usage % of WorldAction
Africa933,448,29214.2 %3.5 %3.0 % 
Asia3,712,527,62456.5 %10.5 %35.6 % 
Europe809,624,68612.3 %38.6 %28.6 % 
Middle East193,452,7272.9 %10.0 %1.8 % 
North America334,538,0185.1 %69.4 %21.2 % 
Latin America / Caribbean556,606,6278.5 %16.0 %8.1 % 
Oceania / Australia34,468,4430.5 %53.5 %1.7 % 
+
+<script language="javascript" type="text/javascript">
+//<![CDATA[
+	var table9_Config = {
+		base_path: '../',
+		editable: true,
+		auto_save: false,
+		cell_editors:[
+			{ type: 'select', attributes:[['title','Choose a continent']] },
+			{ type: 'input', css:'alignRight' },
+			{ type: 'textarea', style:'background-color: yellow;' },
+			{ type: 'input', attributes:[['maxLength',5],['title','5 chars max']] },
+			{ type: 'input' },
+			{ type: 'command',
+				buttons:{
+					enable: ['update', 'insert', 'delete', 'submit', 'cancel'],
+					'update': { title:'Edit row' },
+					'insert': { title:'Add row'  },
+					'delete': { title:'Delete row' },
+					'submit': { text:'Save', title:'Save'  },
+					'cancel': { text:'Cancel', title:'Cancel' }
+				}
+			}
+		]
+	};
+	var et9 = setEditTable("table9", table9_Config);
+//]]>
+</script>
+ + + Top of page +
+ +
+ + + + +
+ + + + diff --git a/dist/extensions/ezEditTable/docs/starter.html b/dist/extensions/ezEditTable/docs/starter.html new file mode 100644 index 00000000..1f306b87 --- /dev/null +++ b/dist/extensions/ezEditTable/docs/starter.html @@ -0,0 +1,195 @@ + + + + ezEditTable, enhance HTML tables easily - Starter page - by Max Guglielmi + + + + + + + + + + +

Starter

+

+ ← Documentation +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FromDestinationRoad Distance (km)By Air (hrs)By Rail (hrs)
SydneyAdelaide14121.425.3
SydneyBrisbane9821.516
SydneyCanberra286.64.3
SydneyMelbourne8721.110.5
AdelaidePerth27813.138
AdelaideAlice Springs1533220.25
AdelaideBrisbane20452.1540
+ + + +
+ +
+

Source code of the page:

+
+<!DOCTYPE HTML>
+<html>
+<head>
+    <title>ezEditTable, enhance HTML tables easily - Starter page - by Max Guglielmi</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+
+    <link href="../ezEditTable.css" rel="stylesheet" type="text/css">
+    <script src="../ezEditTable.js"></script>
+</head>
+<body>
+    <h1>ezEditTable Starter</h1>
+
+    <table id="demo" cellspacing="0" cellpadding="0">
+        <thead>
+                    <tr>
+                        <th>From</th>
+                        <th>Destination</th>
+                        <th>Road Distance (km)</th>
+                        <th>By Air (hrs)</th>
+                        <th width="15%">By Rail (hrs)</th>
+
+                    </tr>
+                </thead>
+                <tbody>
+                    <tr>
+                        <td><strong>Sydney</strong></td>
+                        <td>Adelaide</td>
+                        <td>1412</td>
+                        <td>1.4</td>
+                        <td>25.3</td>
+                    </tr>
+                    <tr>
+                        <td><strong>Sydney</strong></td>
+                        <td>Brisbane</td>
+                        <td>982</td>
+                        <td>1.5</td>
+                        <td>16</td>
+                    </tr>
+                    <tr>
+                        <td><strong>Sydney</strong></td>
+                        <td>Canberra</td>
+                        <td>286</td>
+                        <td>.6</td>
+                        <td>4.3</td>
+                    </tr>
+                    <tr>
+                        <td><strong>Sydney</strong></td>
+                        <td>Melbourne</td>
+                        <td>872</td>
+                        <td>1.1</td>
+                        <td>10.5</td>
+                    </tr>
+                    <tr>
+                        <td><strong>Adelaide</strong></td>
+                        <td>Perth</td>
+                        <td>2781</td>
+                        <td>3.1</td>
+                        <td>38</td>
+                    </tr>
+                    <tr>
+                        <td><strong>Adelaide</strong></td>
+                        <td>Alice Springs</td>
+                        <td>1533</td>
+                        <td>2</td>
+                        <td>20.25</td>
+                    </tr>
+                     <tr>
+                        <td><strong>Adelaide</strong></td>
+                        <td>Brisbane</td>
+                        <td>2045</td>
+                        <td>2.15</td>
+                        <td>40</td>
+                    </tr>
+        </tbody>
+    </table>
+
+    <script language="javascript" type="text/javascript">
+        var config = {
+            selection: true,
+            default_selection: 'both'
+        };
+        var et = new EditTable('demo', config);
+        et.Init();
+    </script>
+
+</body>
+</html>
+	  		
+
+ + diff --git a/dist/extensions/ezEditTable/ezEditTable-uncompressed.css b/dist/extensions/ezEditTable/ezEditTable-uncompressed.css new file mode 100644 index 00000000..50fa7fc9 --- /dev/null +++ b/dist/extensions/ezEditTable/ezEditTable-uncompressed.css @@ -0,0 +1,86 @@ +/*==================================================== + - ezEditTable global stylesheet + - Edit classes below for your projects' needs +=====================================================*/ + +.ezEditableTable{ + padding:0; color:#000; + border-collapse:collapse; + font:12px/13px arial, tahoma, helvetica, sans-serif !important; +} +.ezEditableTable th, .ezEditableTable td{ + margin:0; padding:5px; + color:inherit; + border:1px solid #ccc !important; +} +.ezEditableTable th{ + background:#EBECEE !important; +} + +/* Selection */ +.ezActiveRow{ background-color:#2852A8 !important; color:#fff; } +.ezSelectedRow{ background-color:#316AC5; color:#fff; } +.ezActiveCell{ + background-color:#D9E8FB !important; + color:#000 !important; font-weight:bold; +} +.ezUnselectable{ + -moz-user-select: -moz-none; + -khtml-user-select: none; + -webkit-user-select: none; + -o-user-select: none; + user-select: none; +} + +/* Cell editors */ +.ezInputEditor{ width:95%; height:auto; font-size:inherit; border:1px solid #AACCF6; } +.ezTextareaEditor{ width:95%; height:35px; font-size:inherit; border:1px solid #AACCF6; } +.ezSelectEditor{ width:100%; font-size:inherit; border:1px solid #AACCF6; } +.ezModifiedCell{ background:transparent url(themes/bg_mod_cell.png) 0 0 no-repeat; } +select[multiple="multiple"].ezSelectEditor{ height:35px; } +/* Command type editor */ +.ezCommandEditor{ margin:2px; } +.ezCommandEditor button{ + font-size:10px; + border:1px solid #ccc; + background:#fff; margin:1px; + border-radius:4px 4px 4px 4px; + -moz-border-radius:4px 4px 4px 4px; +} +/* Uploader editor */ +.ezUploaderEditor{ + position:absolute; display:inline; + margin:15px 0 0 0px; + border:1px solid #ccc; padding:5px; + background:#fff; color:#000; z-index:10000; + border-radius:4px; + -moz-border-radius:4px; + -webkit-border-radius:4px; + box-shadow:3px 3px 2px #888; + -moz-box-shadow:3px 3px 2px #888; + -webkit-box-shadow:3px 3px 2px #888; +} +.ezUploaderEditor button{ + font-size:10px; + border:1px solid #ccc; + background:#fff; margin:1px; + border-radius:4px 4px 4px 4px; + -moz-border-radius:4px 4px 4px 4px; +} +.ezUploaderEditorOutput{ } +.ezUploaderEditorDisplay{ + display:none; position:relative; + max-width:800px; max-height:600px; + overflow:auto; border:0; + background:#fff; padding:5px; margin:5px; +} + +/* Utils */ +.ezOpacity{ + filter:alpha(opacity=60); /* for IE */ + opacity:0.6; /* CSS3 standard */ +} +.alignLeft{ text-align:left; } +.alignCenter{ text-align:center; } +.alignRight{ text-align:right; } +.icnImg{ border:0; } \ No newline at end of file diff --git a/dist/extensions/ezEditTable/ezEditTable-uncompressed.js b/dist/extensions/ezEditTable/ezEditTable-uncompressed.js new file mode 100644 index 00000000..ee66e659 --- /dev/null +++ b/dist/extensions/ezEditTable/ezEditTable-uncompressed.js @@ -0,0 +1,2081 @@ +/*------------------------------------------------------------------------ + - ezEditTable v2.3 (edittable.free.fr) + - Copyright (c) 2012 Max Guglielmi + - License required for use +------------------------------------------------------------------------*/ + +var EditTable = function(id){ +/*======================================================================== + - EditTable object constructor + - Params: + - id: table id (string) + - startRow (optional): start row index (number) + - config (optional): configuration object (literal object) +========================================================================*/ + if(arguments.length === 0){ return; } + this.id = id; + this.version = '2.3'; + this.table = this.Get(id); + this.tBody = this.table.tBodies[0]; + this.startRow = 0; + this.config = null; + this.nbCells = null; + if(!window['et_activeGrid']){ window.et_activeGrid = ''; }//global var for active grid in page + + if(this.table === null || this.table.nodeName.LCase() !== 'table'){ return; } + var tBodyRows = this.Tag(this.tBody, 'tr'); + if(tBodyRows.length > 0){ this.startRow = tBodyRows[0].rowIndex; } + + if(arguments.length > 1){ + for(var i=0; iwindow.parent["{1}"].SetUploadSuccess(true); window.parent["{1}"].SetUploadName("{0}");' + + 'window.parent["{1}"].ShowUpload();'; //js code invoked from server-side when file successfully uploaded + + //Uploader callbacks and delegates + this.showUpload[i] = upl.hasOwnProperty('show_upload') && this.IsFn(upl['show_upload']) ? upl['show_upload'] : null; //delegate function for showing uploaded file + this.onBeforeOpenUploader[i] = upl.hasOwnProperty('on_before_open') && this.IsFn(upl['on_before_open']) ? upl['on_before_open'] : null; + this.onAfterOpenUploader[i] = upl.hasOwnProperty('on_after_open') && this.IsFn(upl['on_after_open']) ? upl['on_after_open'] : null; + this.onBeforeCloseUploader[i] = upl.hasOwnProperty('on_before_close') && this.IsFn(upl['on_before_close']) ? upl['on_before_close'] : null; + this.onAfterCloseUploader[i] = upl.hasOwnProperty('on_after_close') && this.IsFn(upl['on_after_close']) ? upl['on_after_close'] : null; + break; + } + } + if(this.editorTypes.indexOf(this.edtTypes.command) != -1){ this.editorModel = 'row'; } + this.inputEditorCss = f.input_editor_css!==undefined ? f.input_editor_css : 'ezInputEditor'; //default css class applied to input editor + this.textareaEditorCss = f.textarea_editor_css!==undefined ? f.textarea_editor_css : 'ezTextareaEditor'; //default css class applied to textarea editor + this.selectEditorCss = f.select_editor_css!==undefined ? f.select_editor_css : 'ezSelectEditor'; //default css class applied to select editor + this.commandEditorCss = f.command_editor_css!==undefined ? f.command_editor_css : 'ezCommandEditor'; //default css class applied to command editor + this.modifiedCellCss = f.modified_cell_css!==undefined ? f.modified_cell_css : 'ezModifiedCell'; //default css class applied to modified cell + + //Command type editor config + this.cmdEnabledBtns = this.editorCmdBtns.hasOwnProperty('enable') ? this.editorCmdBtns.enable : ['update', 'insert', 'delete', 'submit', 'cancel']; //command buttons to be enabled + this.cmdUpdateBtn = this.editorCmdBtns.hasOwnProperty('update') ? this.editorCmdBtns.update : {}; //update command button + this.cmdInsertBtn = this.editorCmdBtns.hasOwnProperty('insert') ? this.editorCmdBtns.insert : {}; //insert command button + this.cmdDeleteBtn = this.editorCmdBtns.hasOwnProperty('delete') ? this.editorCmdBtns['delete'] : {}; //delete command button + this.cmdSubmitBtn = this.editorCmdBtns.hasOwnProperty('submit') ? this.editorCmdBtns['submit'] : {}; //submit command button + this.cmdCancelBtn = this.editorCmdBtns.hasOwnProperty('cancel') ? this.editorCmdBtns.cancel : {}; //cancel command button + + this.cmdUpdateBtnText = this.cmdUpdateBtn.hasOwnProperty('text') ? this.cmdUpdateBtn.text : ''; //Default text is empty because icon is set by default + this.cmdInsertBtnText = this.cmdInsertBtn.hasOwnProperty('text') ? this.cmdInsertBtn.text : ''; //Default text is empty because icon is set by default + this.cmdDeleteBtnText = this.cmdDeleteBtn.hasOwnProperty('text') ? this.cmdDeleteBtn.text : ''; //Default text is empty because icon is set by default + this.cmdSubmitBtnText = this.cmdSubmitBtn.hasOwnProperty('text') ? this.cmdSubmitBtn.text : 'Submit'; + this.cmdCancelBtnText = this.cmdCancelBtn.hasOwnProperty('text') ? this.cmdCancelBtn.text : 'Cancel'; + + this.cmdUpdateBtnTitle = this.cmdUpdateBtn.hasOwnProperty('title') ? this.cmdUpdateBtn.title : 'Edit record'; + this.cmdInsertBtnTitle = this.cmdInsertBtn.hasOwnProperty('title') ? this.cmdInsertBtn.title : 'Create record'; + this.cmdDeleteBtnTitle = this.cmdDeleteBtn.hasOwnProperty('title') ? this.cmdDeleteBtn.title : 'Delete record'; + this.cmdSubmitBtnTitle = this.cmdSubmitBtn.hasOwnProperty('title') ? this.cmdSubmitBtn.title : 'Submit record'; + this.cmdCancelBtnTitle = this.cmdCancelBtn.hasOwnProperty('title') ? this.cmdCancelBtn.title : 'Cancel'; + + this.cmdUpdateBtnIcon = this.cmdUpdateBtn.hasOwnProperty('icon') ? this.cmdUpdateBtn.icon : ''; + this.cmdInsertBtnIcon = this.cmdInsertBtn.hasOwnProperty('icon') ? this.cmdInsertBtn.icon : ''; + this.cmdDeleteBtnIcon = this.cmdDeleteBtn.hasOwnProperty('icon') ? this.cmdDeleteBtn.icon : ''; + this.cmdSubmitBtnIcon = this.cmdSubmitBtn.hasOwnProperty('icon') ? this.cmdSubmitBtn.icon : ''; + this.cmdCancelBtnIcon = this.cmdCancelBtn.hasOwnProperty('icon') ? this.cmdCancelBtn.icon : ''; + + this.cmdUpdateBtnCss = this.cmdUpdateBtn.hasOwnProperty('css') ? this.cmdUpdateBtn.css : null; + this.cmdInsertBtnCss = this.cmdInsertBtn.hasOwnProperty('css') ? this.cmdInsertBtn.css : null; + this.cmdDeleteBtnCss = this.cmdDeleteBtn.hasOwnProperty('css') ? this.cmdDeleteBtn.css : null; + this.cmdSubmitBtnCss = this.cmdSubmitBtn.hasOwnProperty('css') ? this.cmdSubmitBtn.css : null; + this.cmdCancelBtnCss = this.cmdCancelBtn.hasOwnProperty('css') ? this.cmdCancelBtn.css : null; + + this.cmdUpdateBtnStyle = this.cmdUpdateBtn.hasOwnProperty('style') ? this.cmdUpdateBtn.style : null; + this.cmdInsertBtnStyle = this.cmdInsertBtn.hasOwnProperty('style') ? this.cmdInsertBtn.style : null; + this.cmdDeleteBtnStyle = this.cmdDeleteBtn.hasOwnProperty('style') ? this.cmdDeleteBtn.style : null; + this.cmdSubmitBtnStyle = this.cmdSubmitBtn.hasOwnProperty('style') ? this.cmdSubmitBtn.style : null; + this.cmdCancelBtnStyle = this.cmdCancelBtn.hasOwnProperty('style') ? this.cmdCancelBtn.style : null; + + this.cmdInsertBtnScroll = this.cmdInsertBtn.hasOwnProperty('scrollIntoView') ? this.cmdInsertBtn.scrollIntoView : false; //scroll new added row into view + + //Editor callbacks, delegates + this.onEditableInit = this.IsFn(f.on_editable_initialized) ? f.on_editable_initialized : null; + this.onBeforeOpenEditor = this.IsFn(f.on_before_open_editor) ? f.on_before_open_editor : null; + this.onAfterOpenEditor = this.IsFn(f.on_after_open_editor) ? f.on_after_open_editor : null; + this.onBeforeCloseEditor = this.IsFn(f.on_before_close_editor) ? f.on_before_close_editor : null; + this.onAfterCloseEditor = this.IsFn(f.on_after_close_editor) ? f.on_after_close_editor : null; + this.setCustomEditorValue = this.IsFn(f.set_custom_editor_value) ? f.set_custom_editor_value : null; + this.getCustomEditorValue = this.IsFn(f.get_custom_editor_value) ? f.get_custom_editor_value : null; + this.setCellModifiedValue = this.IsFn(f.set_cell_modified_value) ? f.set_cell_modified_value : null; + this.validateModifiedValue = this.IsFn(f.validate_modified_value) ? f.validate_modified_value : null; + this.openCustomEditor = this.IsFn(f.open_custom_editor) ? f.open_custom_editor : null; + this.closeCustomEditor = this.IsFn(f.close_custom_editor) ? f.close_custom_editor : null; + this.onAddedDomRow = this.IsFn(f.on_added_dom_row) ? f.on_added_dom_row : null; + + //Server actions config + this.actions = this.IsObj(f.actions) ? f.actions : {}; + this.updateConfig = this.actions['update']!==undefined ? this.actions['update'] : {}; + this.insertConfig = this.actions['insert']!==undefined ? this.actions['insert'] : {}; + this.deleteConfig = this.actions['delete']!==undefined ? this.actions['delete'] : {}; + this.updateURI = this.updateConfig.hasOwnProperty('uri') ? this.updateConfig['uri'] : null; + this.insertURI = this.insertConfig.hasOwnProperty('uri') ? this.insertConfig['uri'] : null; + this.deleteURI = this.deleteConfig.hasOwnProperty('uri') ? this.deleteConfig['uri'] : null; + this.updateFormMethod = this.updateConfig.hasOwnProperty('form_method') ? this.updateConfig['form_method'].LCase() : 'post'; + this.insertFormMethod = this.insertConfig.hasOwnProperty('form_method') ? this.insertConfig['form_method'].LCase() : 'post'; + this.deleteFormMethod = this.deleteConfig.hasOwnProperty('form_method') ? this.deleteConfig['form_method'].LCase() : 'post'; + this.updateSubmitMethod = this.updateConfig.hasOwnProperty('submit_method') ? this.updateConfig['submit_method'].LCase() : this.ajax ? 'ajax': 'form'; + this.insertSubmitMethod = this.insertConfig.hasOwnProperty('submit_method') ? this.insertConfig['submit_method'].LCase() : this.ajax ? 'ajax': 'form'; + this.deleteSubmitMethod = this.deleteConfig.hasOwnProperty('submit_method') ? this.deleteConfig['submit_method'].LCase() : this.ajax ? 'ajax': 'form'; + this.bulkDelete = this.deleteConfig.hasOwnProperty('bulk_delete') ? this.deleteConfig['bulk_delete'] : false; //enables delete of selected rows + this.defaultRecord = this.insertConfig.hasOwnProperty('default_record') + && this.IsArray(this.insertConfig['default_record']) ? this.insertConfig['default_record'] : null; + this.updateParams = this.updateConfig.hasOwnProperty('param_names') + && this.IsArray(this.updateConfig['param_names']) ? this.updateConfig['param_names'] : null; + this.insertParams = this.insertConfig.hasOwnProperty('param_names') + && this.IsArray(this.insertConfig['param_names']) ? this.insertConfig['param_names'] : null; + this.deleteParams = this.deleteConfig.hasOwnProperty('param_names') + && this.IsArray(this.deleteConfig['param_names']) ? this.deleteConfig['param_names'] : null; + + //Server actions delegates and callbacks + this.onUpdateSubmit = this.updateConfig.hasOwnProperty('on_update_submit') + && this.IsFn(this.updateConfig['on_update_submit']) ? this.updateConfig['on_update_submit'] : null; + this.onInsertSubmit = this.insertConfig.hasOwnProperty('on_insert_submit') + && this.IsFn(this.insertConfig['on_insert_submit']) ? this.insertConfig['on_insert_submit'] : null; + this.onDeleteSubmit = this.deleteConfig.hasOwnProperty('on_delete_submit') + && this.IsFn(this.deleteConfig['on_delete_submit']) ? this.deleteConfig['on_delete_submit'] : null; + this.onBeforeUpdateSubmit = this.updateConfig.hasOwnProperty('on_before_submit') + && this.IsFn(this.updateConfig['on_before_submit']) ? this.updateConfig['on_before_submit'] : null; + this.onBeforeInsertSubmit = this.insertConfig.hasOwnProperty('on_before_submit') + && this.IsFn(this.insertConfig['on_before_submit']) ? this.insertConfig['on_before_submit'] : null; + this.onBeforeDeleteSubmit = this.deleteConfig.hasOwnProperty('on_before_submit') + && this.IsFn(this.deleteConfig['on_before_submit']) ? this.deleteConfig['on_before_submit'] : null; + this.onAfterUpdateSubmit = this.updateConfig.hasOwnProperty('on_after_submit') + && this.IsFn(this.updateConfig['on_after_submit']) ? this.updateConfig['on_after_submit'] : null; + this.onAfterInsertSubmit = this.insertConfig.hasOwnProperty('on_after_submit') + && this.IsFn(this.insertConfig['on_after_submit']) ? this.insertConfig['on_after_submit'] : null; + this.onAfterDeleteSubmit = this.deleteConfig.hasOwnProperty('on_after_submit') + && this.IsFn(this.deleteConfig['on_after_submit']) ? this.deleteConfig['on_after_submit'] : null; + this.onUpdateError = this.updateConfig.hasOwnProperty('on_submit_error') + && this.IsFn(this.updateConfig['on_submit_error']) ? this.updateConfig['on_submit_error'] : null; + this.onInsertError = this.insertConfig.hasOwnProperty('on_submit_error') + && this.IsFn(this.insertConfig['on_submit_error']) ? this.insertConfig['on_submit_error'] : null; + this.onDeleteError = this.deleteConfig.hasOwnProperty('on_submit_error') + && this.IsFn(this.deleteConfig['on_submit_error']) ? this.deleteConfig['on_submit_error'] : null; + this.checkUpdateResponseSanity = this.updateConfig.hasOwnProperty('check_response_sanity') + && this.IsFn(this.updateConfig['check_response_sanity']) ? this.updateConfig['check_response_sanity'] : null; + this.checkInsertResponseSanity = this.insertConfig.hasOwnProperty('check_response_sanity') + && this.IsFn(this.insertConfig['check_response_sanity']) ? this.insertConfig['check_response_sanity'] : null; + this.checkDeleteResponseSanity = this.deleteConfig.hasOwnProperty('check_response_sanity') + && this.IsFn(this.deleteConfig['check_response_sanity']) ? this.deleteConfig['check_response_sanity'] : null; + this.processUpdateResponse = this.updateConfig.hasOwnProperty('process_response') + && this.IsFn(this.updateConfig['process_response']) ? this.updateConfig['process_response'] : null; + this.processInsertResponse = this.insertConfig.hasOwnProperty('process_response') + && this.IsFn(this.insertConfig['process_response']) ? this.insertConfig['process_response'] : null; + this.processDeleteResponse = this.deleteConfig.hasOwnProperty('process_response') + && this.IsFn(this.deleteConfig['process_response']) ? this.deleteConfig['process_response'] : null; + + //Messages + this.msgSubmitOK = f.msg_submit_ok!==undefined ? f.msg_submit_ok : 'Changes were successfully submitted to server!'; + this.msgConfirmDelSelectedRows = f.msg_confirm_delete_selected_rows!==undefined ? f.msg_confirm_delete_selected_rows : 'Do you want to delete the selected row(s)?'; + this.msgErrOccur = f.msg_error_occured!==undefined ? f.msg_error_occured : 'An error occured!'; + this.msgSaveUnsuccess = f.msg_submit_unsuccessful!==undefined ? f.msg_submit_unsuccessful : 'Changes could not be saved!'; + this.msgUndefinedSubmitUrl = f.undefined_submit_url!==undefined ? f.undefined_submit_url : 'Changes could not be saved! Endpoint URL is not defined'; + this.msgNewRowNoUploader = f.msg_new_row_no_uploader!==undefined ? f.msg_new_row_no_uploader : 'Please save the newly added rows before using the Uploader.'; + this.msgInvalidData = f.msg_invalid_data!==undefined ? f.msg_invalid_data : 'Returned data is invalid.'; + + //Containers + this.ifrmContainer = {}; //submit forms container + + //Values + this.valuesSeparator = ', '; + this.defaultRecordUndefinedValue = '...'; + this.newRowClass = 'ezNewRow'; + this.recordKeyValue = 'new'; + + //Attributes + this.attrValue = 'data-ez-slc-value'; + this.attrText = 'data-ez-slc-text'; + this.attrCont = 'data-ez-html'; + this.attrData = 'data-ez-data'; + this.attrUplname = 'data-ez-uplname'; + this.attrColIndex = 'data-ez-col-index'; + this.attrRowIndex = 'data-ez-row-index'; + + //Counters + this.savedRowsNb = { 'insert': 0, 'update': 0, 'delete': 0 }; + + //prefixes + this.prfxEdt = 'edt_'; + this.prfxIFrm = 'iframe_'; + this.prfxFrm = 'form_'; + this.prfxScr = 'scr_'; + this.prfxParam = 'col_'; + //upload editor + this.prfxUplCont = 'upl_'; + this.prfxUplForm = 'upl_form_'; + this.prfxUplIframe = 'upl_ifrm_'; + this.prfxUplInfo = 'upl_info_'; + this.prfxUplOutput = 'upl_output_'; + this.prfxUplBtn = 'upl_btn_'; + this.prfxUplBtnClose = 'upl_btn_close_'; + this.prfxUplImgDisplay = 'upl_img_display_'; + this.prfxUplWinRef = 'et_upl_'; + + //Upload form + this.uplFileInp = 'UPL_FILE'; + this.uplKeyInput = 'RECORD_KEY'; + this.uplFldPath = 'IMAGES_FOLDER_PATH'; + this.uplSqlFieldName = 'SQL_FIELD'; + this.uplFileSize = 'MAX_FILE_SIZE'; + this.uplValidExts = 'VALID_EXTENSIONS'; + this.uplJsCode = 'JS_CODE'; + + this.Editable = new Editable(this); + this.Selection = new Selection(this); +}; + +var Editable = function(editTable){ + this.o = editTable; +}; + +var Selection = function(editTable){ + this.o = editTable; +}; + +var Uploader = function(editTable, colIndex){ + this.o = editTable; + this.colIndex = colIndex; + window[this.o.prfxUplWinRef + colIndex + this.o.id] = this; //global reference for server-side purposes +}; + +Uploader.prototype = { + divUpl: null, formUpl: null, fileUpl: null, hiddenFileSize: null, hiddenFolderPath: null, hiddenValidExt: null, hiddenKey: null, + ifrmUpl: null, divUplInfo: null, divUplOutput: null, divUplBtnsCont: null, divUplBtn: null, divUplBtnClose: null, divUplDisplay: null, + initialValue: null, isUploadSuccessful: false, + Init: function(){ + if(!this.o.hasUploader){ return; } + this.SetUploader(); + }, + SetUploader: function(){ + this.divUpl = this.o.CreateElm('div', + ['id', this.o.prfxUplCont + this.colIndex + this.o.id], ['style', 'display:none; z-index:10001;'], ['class', this.o.uplCss[this.colIndex]] + ); + this.formUpl = this.o.CreateElm('form', + ['id', this.o.prfxUplForm + this.colIndex + this.o.id], ['name', this.o.prfxUplForm + this.colIndex + this.o.id], ['method', 'POST'], + ['action', this.o.uplURI[this.colIndex]], ['target', this.o.prfxUplIframe + this.colIndex + this.o.id], ['enctype', 'multipart/form-data'] + ); + this.fileUpl = this.o.CreateElm('input',['id', this.o.uplFileInp], ['name', this.o.uplFileInp], ['type', 'file']); + this.hiddenFileSize = this.o.CreateElm('input', ['name', this.o.uplFileSize], ['type', 'hidden'], ['value', this.o.uplMaxFileSize[this.colIndex]]); //server-side info: max file size + this.hiddenFolderPath = this.o.CreateElm('input', ['name', this.o.uplFldPath], ['type', 'hidden'], ['value', this.o.uplPath[this.colIndex]]); //server-side info: images folder path + this.hiddenValidExt = this.o.CreateElm('input', ['name', this.o.uplValidExts], ['type', 'hidden'], ['value', this.o.uplValidExt[this.colIndex]]); //server-side info: allowed file extensions + this.hiddenKey = this.o.CreateElm('input', ['name', this.o.uplKeyInput], ['type', 'hidden'], ['value', this.o.recordKeyValue]); //server-side info: record key + this.hiddenSqlField = this.o.CreateElm('input', ['name', this.o.uplSqlFieldName], ['type', 'hidden'], ['value', this.o.uplSqlField[this.colIndex]]); //server-side info: SQL field name storing upload filename + this.hiddenUplWinRef = this.o.CreateElm('input', ['name', this.o.uplJsCode], ['type', 'hidden'], ['value', this.o.uplJsSuccess[this.colIndex]]); //server-side info: js code invoked from server when upload successful + this.ifrmUpl = this.o.CreateElm('iframe', ['id', this.o.prfxUplIframe + this.colIndex + this.o.id], ['name', this.o.prfxUplIframe + this.colIndex + this.o.id], ['style', 'display:none; left:-10001;']); + this.divUplInfo = this.o.CreateElm('div',['id', this.o.prfxUplInfo + this.colIndex + this.o.id]); + this.divUplOutput = this.o.CreateElm('div',['id', this.o.prfxUplOutput + this.colIndex + this.o.id], ['class', this.o.uplOutputCss[this.colIndex]]); + this.divUplBtnsCont = this.o.CreateElm('div',['style', 'text-align:right']); + this.divUplBtn = this.o.CreateElm('button',['id', this.o.prfxUplBtn + this.colIndex + this.o.id], ['style', 'display:none;']); + this.divUplBtnClose = this.o.CreateElm('button',['id', this.o.prfxUplBtnClose + this.colIndex + this.o.id]); + this.divUplDisplay = this.o.CreateElm('div',['id', this.o.prfxUplImgDisplay + this.colIndex + this.o.id], ['class', this.o.uplDisplayCss[this.colIndex]]); + + //IE<8 class, name, style attributes are not set correctly... + if(!this.o.Css.Has(this.divUpl, this.o.uplCss[this.colIndex])){ + this.o.Css.Add(this.divUpl, this.o.uplCss[this.colIndex]); + this.o.Css.Add(this.divUplOutput, this.o.uplOutputCss[this.colIndex]); + this.o.Css.Add(this.divUplDisplay, this.o.uplDisplayCss[this.colIndex]); + this.divUpl.style.cssText = 'display:none; z-index:10001;'; + this.divUplBtnsCont.style.cssText = 'text-align:right'; + this.divUplBtn.style.cssText = 'display:none;'; + this.formUpl = document.createElement( + '
' + ); + this.ifrmUpl = document.createElement( + '' + ); + } + + this.divUplInfo.innerHTML = parseInt(this.o.uplMaxFileSize[this.colIndex]/1024, 10) + 'Kb max (' + this.o.uplValidExt[this.colIndex].toString() + ')'; + this.divUplBtn.appendChild(this.o.CreateText('Upload')); + this.divUplBtnClose.appendChild(this.o.CreateText('Close')); + this.divUplBtnsCont.appendChild(this.divUplBtn); + this.divUplBtnsCont.appendChild(this.divUplBtnClose); + + this.formUpl.appendChild(this.fileUpl); + this.formUpl.appendChild(this.hiddenFileSize); + this.formUpl.appendChild(this.hiddenFolderPath); + this.formUpl.appendChild(this.hiddenUplWinRef); + this.formUpl.appendChild(this.hiddenValidExt); + this.formUpl.appendChild(this.hiddenKey); + this.formUpl.appendChild(this.hiddenSqlField); + + this.divUpl.appendChild(this.formUpl); + this.divUpl.appendChild(this.ifrmUpl); + this.divUpl.appendChild(this.divUplInfo); + this.divUpl.appendChild(this.divUplOutput); + this.divUpl.appendChild(this.divUplBtnsCont); + this.divUpl.appendChild(this.divUplDisplay); + this.o.table.parentNode.insertBefore(this.divUpl, this.o.table); + + //Events + var x = this; + this.ifrmUpl.onload = this.ifrmUpl.onreadystatechange = function(){ //Iframe onload event + if(!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete'){ + try{ + var iframeDoc = this.contentDocument || this.contentWindow.document; + if(iframeDoc.location.href != 'about:blank'){ + x.Output(iframeDoc.body.innerHTML); + x.iframe.src = 'about:blank'; + x.HideUploadButton(); + } + } catch(ex){} + } + }; + + this.o.Event.Add(this.fileUpl, 'click', function(e){ x.OnUplClick(); }); + this.o.Event.Add(this.divUplBtn, 'click', function(e){ x.Upload(); }); + this.o.Event.Add(this.divUplBtnClose, 'click', function(e){ x.Close(x.o.Selection.GetActiveRow().cells[x.colIndex]); }); + + //Js code passed to server + var js = this.o.uplJsSuccess[this.colIndex].replace(/\{1\}/g, this.o.prfxUplWinRef + this.colIndex + this.o.id); + this.hiddenUplWinRef.value = js; + }, + GetValue: function(){ return this.fileUpl.value; }, + HasValueChanged: function(){ return this.initialValue != this.GetValue(); }, + OnUplClick: function(){ this.ShowUploadButton(); }, + Upload: function(){ this.ShowLoader(); this.formUpl.submit(); }, + SetRecordKey: function(key){ this.hiddenKey.value = key; }, + GetRecordKey: function(){ return this.hiddenKey.value; }, + ShowUploadButton: function(){ this.divUplBtn.style.display = 'inline'; }, + HideUploadButton: function(){ this.divUplBtn.style.display = 'none'; }, + ShowUploadContainer: function(){ this.divUplDisplay.style.display = 'block'; }, + HideUploadContainer: function(){ this.divUplDisplay.style.display = 'none'; }, + ShowUpload: function(){ + if(!this.o.uplShowUpload[this.colIndex]){ return; } + var row = this.o.Selection.GetActiveRow(); + if(this.o.showUpload[this.colIndex]){ + this.ShowUploadContainer(); + this.o.showUpload[this.colIndex].call(this, this.o, this.divUplDisplay, this.GetUploadName(), this.o.uplPath[this.colIndex]); + return; + } + if(row){ + var uplname = this.GetUploadName(); + if(uplname){ + if(this.o.uplShowLink[this.colIndex]){ + this.divUplDisplay.innerHTML = this.GetUploadLinkHtml(); + } else { + this.divUplDisplay.innerHTML = ''+uplname+''; + } + this.ShowUploadContainer(); + this.divUpl.scrollIntoView(false); + } else { this.ClearUpload(); } + } + }, + ClearUpload: function(){ + this.divUplDisplay.innerHTML = ''; + this.HideUploadContainer(); + }, + GetUploadName: function(){ + var cell = this.o.Selection.GetActiveRow().cells[this.colIndex]; + if(cell){ return cell.getAttribute(this.o.attrUplname); } + return null; + }, + SetUploadName: function(name){ + var cell = this.o.Selection.GetActiveRow().cells[this.colIndex]; + if(cell){ cell.setAttribute(this.o.attrUplname, name); } + }, + GetUploadLinkHtml: function(){ + var uplname = this.GetUploadName(); + return ''+ + uplname.replace(this.GetRecordKey()+'_', '') + ''; + }, + Open: function(cell){ + if(!cell){ return; } + if(this.o.Css.Has(cell.parentNode, this.o.newRowClass) || !cell.parentNode.getAttribute('id')){ alert(this.o.msgNewRowNoUploader); return; } + cell.appendChild(this.divUpl); + if(this.o.onBeforeOpenUploader[this.colIndex]){ + this.o.onBeforeOpenUploader[this.colIndex].call(this, this.o, this.divUpl, cell); + } + var key = this.o.uplRecordIdColIndex[this.colIndex] + ? this.o.Selection.GetActiveRow()[this.o.uplRecordIdColIndex[this.colIndex]] + : this.o.Selection.GetActiveRow().getAttribute('id').replace(this.o.newRowPrefix, ''); + if(key !== ''){ + this.divUpl.style.display = ''; + this.SetRecordKey(key); + this.initialValue = this.GetValue(); + this.SetUploadSuccess(false); + this.ShowUpload(); + } + if(this.o.onAfterOpenUploader[this.colIndex]){ + this.o.onAfterOpenUploader[this.colIndex].call(this, this.o, this.divUpl, cell); + } + }, + Close: function(cell){ + if(this.divUpl.style.display == 'none'){ return; } + if(this.o.onBeforeCloseUploader[this.colIndex]){ + this.o.onBeforeCloseUploader[this.colIndex].call(this, this.o, this.divUpl, cell); + } + if(cell && this.IsUploadSuccessful()){ + if(this.o.uplShowLink[this.colIndex]){ + var div = this.o.CreateElm('div'); + div.innerHTML = this.divUplDisplay.innerHTML; + cell.appendChild(div); + } else { + var img = this.o.Tag(cell, 'img')[0]; + if(img){ img.src = this.o.uplOkImg[this.colIndex]; } + } + } + this.Output(''); + this.SetRecordKey(''); + this.ClearUpload(); + this.HideUploadButton(); + this.divUpl.style.display = 'none'; + this.o.StandardBody().appendChild(this.divUpl); + if(this.o.onAfterCloseUploader[this.colIndex]){ + this.o.onAfterCloseUploader[this.colIndex].call(this, this.o, this.divUpl, cell); + } + }, + Output: function(msg){ this.divUplOutput.innerHTML = msg; }, + SetUploadSuccess: function(val){ this.isUploadSuccessful = val; }, + IsUploadSuccessful: function(val){ return this.isUploadSuccessful; }, + ShowLoader: function(){ this.Output('Please wait...'); }, + HideLoader: function(){ this.Output(''); } +}; + +Editable.prototype = { + onEditAdded: false, activeCellEditor: null, openCellEditor: null, activeRow: null, + modifiedRows: [], newRows: [], addedRows: [], deletedRows: [], + Init: function(){ + if(!this.o.editable){ return; } + this.SetEvents(); + this.SetCellsEditor(); + if(this.o.onEditableInit){ this.o.onEditableInit.call(null, this.o); } + }, + Set: function(){ this.o.editable = true; this.SetEvents(); }, + Remove: function(){ this.o.editable = false; this.RemoveEvents(); }, + SetEvents: function(){ + if(!this.onEditAdded){ + var x = this; + this.o.Event.Bind(this.o.table, this.o.openEditorAction, function(e){ x.Edit.call(x, e); }); + this.onEditAdded = true; + } + }, + RemoveEvents: function(){ + if(this.onEditAdded){ + var x = this; + this.o.Event.Unbind(this.o.table, this.o.openEditorAction, function(e){ x.Edit.call(x, e); }); + this.onEditAdded = false; + } + }, + SetCellsEditor: function(){ + for (var i = 0; i < this.o.nbCells; i++){ + if(this.o.editorTypes.length == this.o.nbCells){ + switch (this.o.editorTypes[i]){ + case this.o.edtTypes.none: + this.o.editors[i] = null; + break; + case this.o.edtTypes.input: + this.o.editors[i] = this.CreateInputEditor(i); + break; + case this.o.edtTypes.textarea: + this.o.editors[i] = this.CreateMultilineEditor(i); + break; + case this.o.edtTypes.select: + case this.o.edtTypes.multiple: + this.o.editors[i] = this.CreateSelectEditor(i); + break; + case this.o.edtTypes.bool: + this.o.editors[i] = {}; + break; + case this.o.edtTypes.uploader: + this.o.editors[i] = this.CreateUploaderEditor(i); + break; + case this.o.edtTypes.command: + this.SetCommandEditor(i); + this.o.editors[i] = null; + break; + case this.o.edtTypes.custom: + this.o.editors[i] = this.o.Get(this.o.customEditor[i]); + break; + default: + this.o.editors[i] = null; + break; + } + } else { + //If editor type not set, default type is input + this.o.editorTypes[i] = this.o.edtTypes.input; + this.o.editors[i] = this.CreateInputEditor(i); + } + } + }, + CreateInputEditor: function(colIndex){ + if(colIndex === undefined) return null; + var inp = this.o.CreateElm(this.o.edtTypes.input, ['id', this.o.prfxEdt + colIndex + '_' + this.o.id], ['type', 'text'], + ['class', this.o.inputEditorCss], [this.o.attrColIndex, colIndex]); + var attr = this.o.editorAttributes[colIndex]; + if(attr) for (var i = 0; i < attr.length; i++){ inp.setAttribute(attr[i][0], attr[i][1]); } //additional attributes + if(inp.className === '') inp.className = this.o.inputEditorCss; //for older IE versions... + if(this.o.editorCss[colIndex]) this.o.Css.Add(inp, this.o.editorCss[colIndex]); //additional css + if(this.o.editorStyles[colIndex]) inp.style.cssText = this.o.editorStyles[colIndex]; //inline style + var x = this; + this.o.Event.Add(inp, 'focus', function(e){ x.Event.OnInputFocus.call(x, e); }); + this.o.Event.Add(inp, 'blur', function(e){ x.Event.OnBlur.call(x, e); }); + return inp; + }, + CreateMultilineEditor: function(colIndex){ + if(colIndex === undefined) return null; + var txa = this.o.CreateElm(this.o.edtTypes.textarea, ['id', this.o.prfxEdt + colIndex + '_' + this.o.id], + ['class', this.o.textareaEditorCss], [this.o.attrColIndex, colIndex]); + var attr = this.o.editorAttributes[colIndex]; + if(attr) for (var i = 0; i < attr.length; i++){ txa.setAttribute(attr[i][0], attr[i][1]); } //additional attributes + if(txa.className === '') txa.className = this.o.textareaEditorCss; //for older IE versions... + if(this.o.editorCss[colIndex]) this.o.Css.Add(txa, this.o.editorCss[colIndex]); //additional css + if(this.o.editorStyles[colIndex]) txa.style.cssText = this.o.editorStyles[colIndex]; //inline style + var x = this; + this.o.Event.Add(txa, 'focus', function(e){ x.Event.OnInputFocus.call(x, e); }); + this.o.Event.Add(txa, 'blur', function(e){ x.Event.OnBlur.call(x, e); }); + this.o.Event.Add(txa, 'keypress', function(e){ x.Event.OnKeyPress.call(x, e); }); + return txa; + }, + CreateSelectEditor: function(colIndex){ + if(colIndex === undefined) return null; + var slc = this.o.CreateElm(this.o.edtTypes.select, ['id', this.o.prfxEdt + colIndex + '_' + this.o.id], + ['class', this.o.selectEditorCss], [this.o.attrColIndex, colIndex]); + if(this.o.IsEditorType(colIndex, this.o.edtTypes.multiple)){ slc.setAttribute('multiple', 'multiple'); } + var attr = this.o.editorAttributes[colIndex]; + if(attr) for (var i = 0; i < attr.length; i++){ slc.setAttribute(attr[i][0], attr[i][1]); } //additional attributes + if(slc.className === '') slc.className = this.o.selectEditorCss; //for older IE versions... + if(this.o.editorCss[colIndex]) this.o.Css.Add(slc, this.o.editorCss[colIndex]); //additional css + if(this.o.editorStyles[colIndex]) slc.style.cssText = this.o.editorStyles[colIndex]; //inline style + var optArray = [], valArray = []; //options arrays + if(this.o.editorCustomSlcOptions[colIndex]){//custom values + for (var i = 0; i < this.o.editorCustomSlcOptions[colIndex].length; i++){ + var data = this.o.editorCustomSlcOptions[colIndex][i]; + if(this.o.editorCustomSlcValues[colIndex]){ + var val = this.o.editorCustomSlcValues[colIndex][i]; + if(valArray.indexOf(val) == -1) valArray.push(val); + } + if(optArray.indexOf(data) == -1) optArray.push(data); + } + } else {//automatic column values + for (var i = this.o.startRow; i < this.o.GetRowsNb(); i++){ + var row = this.o.table.rows[i]; + var cell = row.cells[colIndex]; + if(!row || !cell) continue; + var data = this.o.GetText(cell); + if(optArray.indexOf(data) == -1) optArray.push(data); + } + } + if(this.o.editorSortSlcOptions[colIndex]){ + var sortType = this.o.editorSortSlcOptions[colIndex].LCase(); + if(sortType == 'numdesc'){ + try { optArray.sort(this.o.Sort.NumDesc); } catch (e){ } + } else if(sortType == 'numasc'){ + try { optArray.sort(this.o.Sort.NumAsc); } catch (e){ } + } else { + try { optArray.sort(this.o.Sort.IgnoreCase); } catch (e){ } + } + } + for (var j = 0; j < optArray.length; j++){ + var opt = this.o.CreateElm('option', ['value', valArray[j] || optArray[j]]); + opt.appendChild(this.o.CreateText(optArray[j])); + slc.appendChild(opt); + } + var x = this; + this.o.Event.Add(slc, 'change', function(e){ + var cell = x.o.GetCell(e); + if(cell){ + cell.setAttribute(x.o.attrText, slc.options[slc.selectedIndex].text); //for inserts + cell.setAttribute(x.o.attrValue, slc.options[slc.selectedIndex].value); //for inserts + slc.setAttribute(x.o.attrText, slc.options[slc.selectedIndex].text); + slc.setAttribute(x.o.attrValue, slc.options[slc.selectedIndex].value); + } + }); + this.o.Event.Add(slc, 'blur', function(e){ x.Event.OnBlur.call(x, e); }); + this.o.Event.Add(slc, 'keypress', function(e){ x.Event.OnKeyPress.call(x, e); }); + return slc; + }, + SetCommandEditor: function(colIndex){ + if(colIndex === undefined || !this.o.IsEditorType(colIndex, this.o.edtTypes.command)){ return; } + this.edtBtns = []; this.addBtns = []; this.delBtns = []; this.submitBtns = []; this.cancelBtns = []; + var x = this.o.Editable, + o = this.o; + for (var i = this.o.startRow; i < this.o.GetRowsNb(); i++){ + var row = this.o.table.rows[i]; + var cell = row.cells[colIndex]; + if(!row || !cell) continue; + + var div = this.o.CreateElm('div', ['class', this.o.commandEditorCss]); + if(this.o.cmdEnabledBtns.indexOf('update') != -1){ + var editBtn = this.o.CreateElm('button', ['id', 'editBtn_' + i + '_' + this.o.id], ['title', this.o.cmdUpdateBtnTitle], + ['css', this.o.cmdUpdateBtnCss], [this.o.attrColIndex, i]); + if(this.o.cmdUpdateBtnStyle) editBtn.style.cssText = this.o.cmdUpdateBtnStyle; //inline style + editBtn.innerHTML = this.o.cmdUpdateBtnIcon + this.o.cmdUpdateBtnText; + div.appendChild(editBtn); + this.o.Event.Add(editBtn, 'click', function(e){ x.Edit.call(x, e); }); + if(this.edtBtns.indexOf(editBtn) == -1) this.edtBtns[i] = editBtn; + } + if(this.o.cmdEnabledBtns.indexOf('insert') != -1){ + var createBtn = this.o.CreateElm('button', ['id', 'createBtn_' + i + '_' + this.o.id], ['title', this.o.cmdInsertBtnTitle], + ['css', this.o.cmdInsertBtnCss], [this.o.attrColIndex, i]); + if(this.o.cmdInsertBtnStyle) createBtn.style.cssText = this.o.cmdInsertBtnStyle; //inline style + createBtn.innerHTML = this.o.cmdInsertBtnIcon + this.o.cmdInsertBtnText; + div.appendChild(createBtn); + this.o.Event.Add(createBtn, 'click', function(e){ x.AddNewRow(); x.SetCommandEditor(x.o.editorCmdColIndex); }); + if(this.addBtns.indexOf(createBtn) == -1) this.addBtns[i] = createBtn; + } + if(this.o.cmdEnabledBtns.indexOf('delete') != -1){ + var delBtn = this.o.CreateElm('button', ['id', 'delBtn_' + i + '_' + this.o.id], ['title', this.o.cmdDeleteBtnTitle], + ['css', this.o.cmdDeleteBtnCss], [this.o.attrColIndex, i]); + if(this.o.cmdDeleteBtnStyle) delBtn.style.cssText = this.o.cmdDeleteBtnStyle; //inline style + delBtn.innerHTML = this.o.cmdDeleteBtnIcon + this.o.cmdDeleteBtnText; + div.appendChild(delBtn); + this.o.Event.Add(delBtn, 'click', function(e){ x.SubmitDeletedRows(); }); + if(this.delBtns.indexOf(delBtn) == -1) this.delBtns[i] = delBtn; + } + if(this.o.cmdEnabledBtns.indexOf('submit') != -1){ + var postBtn = this.o.CreateElm('button', ['id', 'postBtn_' + i + '_' + this.o.id], ['title', this.o.cmdSubmitBtnTitle], + ['style', 'display:none;'], ['css', this.o.cmdSubmitBtnCss], [this.o.attrColIndex, i]); + postBtn.style.display = 'none'; //older versions of IE + if(this.o.cmdSubmitBtnStyle) postBtn.style.cssText += this.o.cmdSubmitBtnStyle; //inline style + postBtn.innerHTML = this.o.cmdSubmitBtnIcon + this.o.cmdSubmitBtnText; + div.appendChild(postBtn); + this.o.Event.Add(postBtn, 'click', function(e){ + o.Event.Stop(e); + x.CloseRowEditor(); + x.SubmitAll(); + }); + if(this.submitBtns.indexOf(postBtn) == -1) this.submitBtns[i] = postBtn; + } + if(this.o.cmdEnabledBtns.indexOf('cancel') != -1){ + var cancelBtn = this.o.CreateElm('button', ['id', 'cancelBtn_' + i + '_' + this.o.id], ['title', this.o.cmdCancelBtnTitle], + ['style', 'display:none;'], ['css', this.o.cmdCancelBtnCss], [this.o.attrColIndex, i]); + cancelBtn.style.display = 'none'; //older versions of IE + if(this.o.cmdCancelBtnStyle) cancelBtn.style.cssText += this.o.cmdCancelBtnStyle; //inline style + cancelBtn.innerHTML = this.o.cmdCancelBtnIcon + this.o.cmdCancelBtnText; + div.appendChild(cancelBtn); + this.o.Event.Add(cancelBtn, 'click', function(e){ o.Event.Stop(e); x.CloseRowEditor(); }); + if(this.cancelBtns.indexOf(cancelBtn) == -1) this.cancelBtns[i] = cancelBtn; + } + cell.innerHTML = ''; + cell.appendChild(div); + } + }, + CreateUploaderEditor: function(colIndex){ + var uploader = new Uploader(this.o, colIndex); + uploader.Init(); + return uploader; + }, + OpenCellEditor: function(cell){ + if(!cell){ return; } + var cellIndex = cell.cellIndex; + var editor = this.o.editors[cellIndex]; + if(this.o.onBeforeOpenEditor){ this.o.onBeforeOpenEditor.call(null, this.o, cell, editor); } + this.activeCellEditor = cell; + this.openCellEditor = cellIndex; + if(!this.o.IsEditorType(cellIndex, this.o.edtTypes.uploader)){ + var data = this.o.GetText(cell); + this.SetCellCache(cell, data); + this.SetEditorValue(cellIndex, data); + if(!this.o.IsEditorType(cellIndex, this.o.edtTypes.custom)){ + cell.innerHTML = ''; + cell.appendChild(editor); + if(this.o.editorModel == 'cell'){ this.SetEditorFocus(cellIndex); } + } else { + if(this.o.openCustomEditor){ this.o.openCustomEditor.call(null, this.o, cell, editor); } + } + } else { editor.Open(cell); } + if(this.o.onAfterOpenEditor){ this.o.onAfterOpenEditor.call(null, this.o, cell, editor); } + }, + OpenRowEditor: function(row){ + if(!row) return; + this.activeRow = row; + for (var i = 0; i < this.o.nbCells; i++){ + if(!this.o.editors[i] || this.o.IsEditorType(i, this.o.edtTypes.bool) + || this.o.IsEditorType(i, this.o.edtTypes.command)){ continue; } + var c = row.cells[i]; + this.OpenCellEditor(c); + if(this.o.Selection.activeCell && this.o.Selection.activeCell.cellIndex === i){ + this.SetEditorFocus(i); + } + } + this.ShowCommandBtns(row.rowIndex, false); + }, + CloseRowEditor: function(){ + if(!this.activeRow) return; + var row = this.activeRow; + for (var i = 0; i < this.o.nbCells; i++){ + if(!this.o.editors[i] || this.o.IsEditorType(i, this.o.edtTypes.bool)) continue; + this.activeCellEditor = row.cells[i]; + this.CloseCellEditor(i); + } + this.ShowCommandBtns(row.rowIndex, true); + if(this.o.autoSave){ this.AutoSubmit(); } + this.activeRow = null; + }, + ShowCommandBtns: function(rowIndex, showIcons){ + if(rowIndex === undefined || showIcons === undefined || this.o.editorModel != 'row') return; + if(!this.edtBtns || !this.addBtns || !this.delBtns || !this.submitBtns || !this.cancelBtns) return; + if(showIcons){ + if(this.edtBtns[rowIndex]) this.edtBtns[rowIndex].style.display = 'inline'; + if(this.addBtns[rowIndex]) this.addBtns[rowIndex].style.display = 'inline'; + if(this.delBtns[rowIndex]) this.delBtns[rowIndex].style.display = 'inline'; + if(this.submitBtns[rowIndex]) this.submitBtns[rowIndex].style.display = 'none'; + if(this.cancelBtns[rowIndex]) this.cancelBtns[rowIndex].style.display = 'none'; + } else { + if(this.edtBtns[rowIndex]) this.edtBtns[rowIndex].style.display = 'none'; + if(this.addBtns[rowIndex]) this.addBtns[rowIndex].style.display = 'none'; + if(this.delBtns[rowIndex]) this.delBtns[rowIndex].style.display = 'none'; + if(this.submitBtns[rowIndex]) this.submitBtns[rowIndex].style.display = 'inline'; + if(this.cancelBtns[rowIndex]) this.cancelBtns[rowIndex].style.display = 'inline'; + } + }, + CloseCellEditor: function(colIndex){ + if(colIndex === undefined || !this.activeCellEditor){ return; } + if(this.o.onBeforeCloseEditor){ this.o.onBeforeCloseEditor.call(null, this.o, this.activeCellEditor, this.o.editors[colIndex]); } + var edtVal = this.GetEditorValue(colIndex), + cache = this.GetCellCache(this.activeCellEditor), + cellVal = cache[1], cellHtml = cache[0], + editor = this.o.editors[colIndex], + val; + if(this.o.IsEditorType(colIndex, this.o.edtTypes.uploader)){ + editor.Close(this.activeCellEditor); + } else { + if(this.o.IsEditorType(colIndex, this.o.edtTypes.multiple)){//multiple selections need to be cleared + for (var j = 0; j < editor.options.length; j++){ + if(editor.options[j].selected){ editor.options[j].selected = false; } + } + } + if(edtVal != cellVal){ + var reg = new RegExp(cellVal.RegexpEscape(), 'g'); + if(reg.test(cellHtml) && cellVal !== ''){ val = cellHtml.replace(reg, edtVal); } //value to be written + else { val = edtVal; } + } + if(this.o.setCellModifiedValue){ this.o.setCellModifiedValue.call(null, this.o, this.activeCellEditor, val); } + else { + try { this.activeCellEditor.removeChild(editor); } catch (e){ if(this.activeCellEditor) this.activeCellEditor.innerHTML = ''; } //for older versions of IE + try { + if(!this.o.validateModifiedValue || + this.o.validateModifiedValue.call(null, this.o, colIndex, cellVal, edtVal, this.activeCellEditor, editor)){ //validation ok + if(this.o.editorAllowEmptyValue[colIndex]){ //empty value is allowed + this.activeCellEditor.innerHTML = (val !== undefined ? val : cellHtml); + } else { this.activeCellEditor.innerHTML = (val !== undefined && val.Trim() !== '' ? val : cellHtml); } + if(edtVal != cellVal){ + //select editor with option value different from option text + if(this.o.IsEditorType(colIndex, this.o.edtTypes.select)){ val = editor.getAttribute(this.o.attrValue); } + if(this.o.editorModel == 'row'){ this.SetModifiedCell(this.activeCellEditor, this.activeCellEditor.innerHTML, cellVal); } + else { this.SetModifiedCell(this.activeCellEditor, val, cellVal); } + } + } else { this.activeCellEditor.innerHTML = cellVal || cellHtml; } //resets cached value + } catch (e){ } //Temp solution for mysterious Chrome bug + } + if(this.o.onAfterCloseEditor){ this.o.onAfterCloseEditor.call(null, this.o, this.activeCellEditor, editor); } + this.RemoveCellCache(this.activeCellEditor); + if(this.o.IsEditorType(colIndex, this.o.edtTypes.custom)){ + if(this.o.closeCustomEditor){ this.o.closeCustomEditor.call(null, this.o, this.activeCellEditor, editor); } + } + } + if(this.o.autoSave && this.o.editorModel === 'cell' && this.o.autoSaveModel === 'cell'){ this.AutoSubmit(); } + this.activeCellEditor = null; + this.openCellEditor = null; + }, + IsEditorOpen: function(colIndex){ return this.openCellEditor == colIndex; }, + IsRowEditorOpen: function(){ return this.activeRow !== null; }, + SetEditorFocus: function(colIndex){ + if(this.o.editors[colIndex] && (this.IsEditorOpen(colIndex) || this.activeRow) && + (!this.o.IsEditorType(colIndex, this.o.edtTypes.custom) && !this.o.IsEditorType(colIndex, this.o.edtTypes.command) + && !this.o.IsEditorType(colIndex, this.o.edtTypes.bool))){ this.o.editors[colIndex].focus(); } + }, + BlurEditor: function(colIndex){ if(this.o.editors[colIndex] && (this.IsEditorOpen(colIndex) || this.activeRow)) this.o.editors[colIndex].blur(); }, + SetModifiedCell: function(cell, val, oldVal){ + if(!cell) return; + var row = cell.parentNode; + if(this.o.Css.Has(row, this.o.newRowClass)){ return; } //modified values of added rows don't need to be treated + var r = {}; r.values = []; r.urlParams = ''; r.modified = []; + var modRow = this.GetModifiedRow(row.rowIndex); + if(!modRow){ + for (var i = 0; i < row.cells.length; i++){ + if(cell.cellIndex == i){ this.o.Css.Add(cell, this.o.modifiedCellCss); } + var cache = this.GetCellCache(row.cells[i]); + var t = cell.cellIndex == i ? val : (this.o.editorModel == 'row' && !this.o.IsEditorType(i, this.o.edtTypes.none) ? cache[1] || this.o.GetText(row.cells[i]) : this.o.GetText(row.cells[i])); + if(this.o.IsEditorType(i, this.o.edtTypes.bool) && this.o.Tag(row.cells[i], 'input').length > 0) + t = this.o.Tag(row.cells[i], 'input')[0].checked; + var paramName = this.o.prfxParam + i; //param name for server-side purposes + r.values.push(t); + r.modified.push(cell.cellIndex == i ? true : false); + r.urlParams += '&' + paramName + '=' + encodeURIComponent(t); //params for submission + } + this.modifiedRows.push([row.rowIndex, r]); + } else { + var obj = modRow[1]; + obj.values[cell.cellIndex] = val; + obj.modified[cell.cellIndex] = true; + var paramName = this.o.prfxParam + cell.cellIndex; + var oldParam = paramName + '=' + encodeURIComponent(oldVal); + var newParam = paramName + '=' + encodeURIComponent(val); + obj.urlParams = obj.urlParams.replace(oldParam, newParam); + } + }, + GetModifiedRow: function(rowIndex){ + if(rowIndex === undefined){ return null; } + for (var i = 0; i < this.modifiedRows.length; i++){ + if(this.modifiedRows[i][0] == rowIndex){ + return this.modifiedRows[i]; + } + } return null; + }, + GetModifiedRows: function(){ return this.modifiedRows; }, + GetAddedRows: function(){ return this.addedRows; }, + SetRowsObject: function(rows, cmd){ + if(!rows) return; + for (var i = 0; i < rows.length; i++){ + var row = rows[i]; + if(!row) continue; + var r = {}; r.values = []; r.urlParams = ''; r.modified = []; + for (var j = 0; j < row.cells.length; j++){ + var cell = row.cells[j]; + var t = this.o.GetText(row.cells[j]); + if(this.o.IsEditorType(j, this.o.edtTypes.bool) && this.o.Tag(cell, 'input').length > 0){ + t = this.o.Tag(cell, 'input')[0].checked; + } else if(this.o.IsEditorType(j, this.o.edtTypes.select)){ t = cell.getAttribute(this.o.attrValue); } + var paramName = this.o.prfxParam + j; //param name for server-side purposes + r.values.push(t); + r.modified.push((cmd == 'delete' ? false : true)); + r.urlParams += '&' + paramName + '=' + encodeURIComponent(t); //params for submission + } + if(cmd == 'delete') this.deletedRows.push([row.rowIndex, r]); + else if(cmd == 'insert') this.addedRows.push([row.rowIndex, r]); + else this.modifiedRows.push([row.rowIndex, r]); + } + }, + GetDeletedRows: function(){ return this.deletedRows; }, + RemoveModifiedRow: function(rowIndex){ + if(rowIndex === undefined) return; + for (var i = 0; i < this.GetModifiedRows().length; i++){ + if(this.GetModifiedRows()[i][0] == rowIndex){ + this.modifiedRows.splice(i, 1); break; + } + } + }, + RemoveModifiedCellMark: function(rowIndex, cellIndexes){ + if(rowIndex === undefined) return; + var row = this.o.table.rows[rowIndex], cells = row.cells; + for (var i = 0; i < cells.length; i++){ + var cell = cells[i]; + if(!cellIndexes || cellIndexes.indexOf(i) != -1) + this.o.Css.Remove(cell, this.o.modifiedCellCss); + } + }, + SetCellCache: function(cell, data, htmlCont){ + if(!cell || data === undefined) return; + var html = htmlCont || htmlCont === '' ? htmlCont : cell.innerHTML; + cell.setAttribute(this.o.attrCont, escape(html)); + cell.setAttribute(this.o.attrData, escape(data)); + }, + GetCellCache: function(cell){ + if(!cell) return []; + var a, b; + if(cell.attributes[this.o.attrCont] !== undefined) a = unescape(cell.getAttribute(this.o.attrCont)); + if(cell.attributes[this.o.attrData] !== undefined) b = unescape(cell.getAttribute(this.o.attrData)); + return [a, b]; + }, + RemoveCellCache: function(cell){ + if(!cell) return; + if(cell.attributes[this.o.attrCont] !== undefined) cell.removeAttribute(this.o.attrCont); + if(cell.attributes[this.o.attrData] !== undefined) cell.removeAttribute(this.o.attrData); + }, + GetEditorValue: function(colIndex){ + var editor = this.o.editors[colIndex]; + var editorType = this.o.editorTypes[colIndex]; + var val = ''; + if(!editor || !editorType) return val; + switch (editorType.LCase()){ + case this.o.edtTypes.input: + case this.o.edtTypes.textarea: + val = editor.value; + break; + case this.o.edtTypes.select: + val = editor.getAttribute(this.o.attrText) || editor.value; + break; + case this.o.edtTypes.multiple: + var sep = !this.o.editorValuesSeparator[colIndex] ? this.o.valuesSeparator : this.o.editorValuesSeparator[colIndex]; + for (var j = 0; j < editor.options.length; j++) + if(editor.options[j].selected) + val = val.concat(editor.options[j].value, sep); + val = val.substring(0, val.length - sep.length); + break; + case this.o.edtTypes.custom: + if(this.o.getCustomEditorValue) val = this.o.getCustomEditorValue.call(null, this.o, editor, colIndex); + break; + } + return val; + }, + SetEditorValue: function(colIndex, val){ + var editor = this.o.editors[colIndex]; + var editorType = this.o.editorTypes[colIndex]; + switch (editorType.LCase()){ + case this.o.edtTypes.input: + case this.o.edtTypes.textarea: + case this.o.edtTypes.select: + editor.value = val; + break; + case this.o.edtTypes.multiple: + for (var j = 0; j < editor.options.length; j++) + if(editor.options[j].value == val) editor.options[j].selected = true; + break; + case this.o.edtTypes.custom: + if(this.o.setCustomEditorValue) this.o.setCustomEditorValue.call(null, this.o, editor, colIndex, val); + break; + } + }, + GetCheckBox: function(cell){ + if(!cell) return null; + var chk = this.o.Tag(cell, 'input')[0]; + if(chk.getAttribute('type').LCase() == 'checkbox') return chk; + else return null; + }, + SetCheckBoxValue: function(e, cell){ + if(!cell) return; + var x = this.o.Editable; + var checkbox = x.GetCheckBox(cell); + if(!checkbox || checkbox.type.LCase() != 'checkbox') return; + if(this.o.Event.GetElement(e) != checkbox){//in case user clicks on cell instead of checkbox + if(checkbox.checked) checkbox.checked = false; + else checkbox.checked = true; + } + var data = !checkbox.checked; + x.SetCellCache(cell, data, ''); + x.SetModifiedCell(cell); + if(x.o.autoSave){ x.SubmitAll(); } //checkbox value set straightaway, prevents treatedRows inconsistency + }, + AddNewRow: function(){ + var row, + rowIdx = this.o.startRow; + + if(this.o.newRowPos === 'bottom'){ + rowIdx = -1; + } + else if(typeof this.o.newRowPos === 'number' && + this.o.newRowPos >= -1){ + rowIdx = this.o.newRowPos; + } + + try{ + row = this.o.table.insertRow(rowIdx); + } catch(e) { + row = this.o.table.insertRow(this.o.startRow); + console.log(e); + } + row.setAttribute('id', this.o.CreateId()); //temp id for new row + this.o.Css.Add(row, this.o.newRowClass); + for (var i = 0; i < this.o.nbCells; i++){ + var cell = row.insertCell(i); + if(this.o.defaultRecord){ cell.innerHTML = this.o.defaultRecord[i]; } + else { cell.innerHTML = this.o.defaultRecordUndefinedValue; } + } + if(this.o.cmdInsertBtnScroll){ row.scrollIntoView(false); } + this.newRows.push(row); + if(this.o.onAddedDomRow){ this.o.onAddedDomRow.call(null, this.o, this.newRows, row); } + }, + SubmitEditedRows: function(){ this.Submit('update'); }, + SubmitAddedRows: function(){ this.SetRowsObject(this.newRows, 'insert'); this.Submit('insert'); }, + SubmitDeletedRows: function(){ + if(this.o.selection){ + if(!this.o.Selection.activeRow && this.o.Selection.selectedRows.length === 0) return; + var rows = (this.o.bulkDelete) ? this.o.Selection.selectedRows : [this.o.Selection.activeRow]; + if(rows.length === 0){ return; } + this.SetRowsObject(rows, 'delete'); + if(confirm(this.o.msgConfirmDelSelectedRows)){ this.Submit('delete'); } + else { this.deletedRows = []; } + } + }, + SubmitAll: function(){ this.submitAll = true; this.SubmitAddedRows(); this.SubmitEditedRows(); }, + AutoSubmit: function(){ + switch(this.o.autoSaveType){ + case 'both': this.SubmitAll(); break; + case 'insert': this.SubmitAddedRows(); break; + case 'update': default: this.SubmitEditedRows(); break; + } + }, + Submit: function(cmd){ + cmd = cmd.LCase(); + var x = this; + var treatedRows, uri, submitMethod, formMethod, params; + var beforeSubmitCallBack, afterSubmitCallBack, onSubmit, onSubmitError; + var checkResponseSanity, processResponse; + switch ((cmd || '')){ + case 'insert': + treatedRows = this.GetAddedRows(); + uri = this.o.insertURI; + submitMethod = this.o.insertSubmitMethod; + formMethod = this.o.insertFormMethod; + params = this.o.insertParams; + beforeSubmitCallBack = this.o.onBeforeInsertSubmit; + afterSubmitCallBack = this.o.onAfterInsertSubmit; + onSubmit = this.o.onInsertSubmit; + onSubmitError = this.o.onInsertError; + checkResponseSanity = this.o.checkInsertResponseSanity; + processResponse = this.o.processInsertResponse; + break; + case 'delete': + treatedRows = this.GetDeletedRows(); + uri = this.o.deleteURI; + submitMethod = this.o.deleteSubmitMethod; + formMethod = this.o.deleteFormMethod; + params = this.o.deleteParams; + beforeSubmitCallBack = this.o.onBeforeDeleteSubmit; + afterSubmitCallBack = this.o.onAfterDeleteSubmit; + onSubmit = this.o.onDeleteSubmit; + onSubmitError = this.o.onDeleteError; + checkResponseSanity = this.o.checkDeleteResponseSanity; + processResponse = this.o.processDeleteResponse; + break; + case 'update': + default: + treatedRows = this.GetModifiedRows(); + uri = this.o.updateURI; + submitMethod = this.o.updateSubmitMethod; + formMethod = this.o.updateFormMethod; + params = this.o.updateParams; + beforeSubmitCallBack = this.o.onBeforeUpdateSubmit; + afterSubmitCallBack = this.o.onAfterUpdateSubmit; + onSubmit = this.o.onUpdateSubmit; + onSubmitError = this.o.onUpdateError; + checkResponseSanity = this.o.checkUpdateResponseSanity; + processResponse = this.o.processUpdateResponse; + break; + } + if(beforeSubmitCallBack){ beforeSubmitCallBack.call(null, this.o, treatedRows); } + if(onSubmit){ onSubmit.call(null, this.o, treatedRows); } + else { + if((!uri || uri === '') && treatedRows.length > 0){ + alert(cmd.toUpperCase() + ': ' + this.o.msgUndefinedSubmitUrl); + treatedRows = []; x.o.savedRowsNb[cmd] = 0; + SubmitComplete(false); + } else { + for (var i = 0; i < treatedRows.length; i++){ + var modArr = treatedRows[i], rowIndex = modArr[0], row = modArr[1]; + if(rowIndex < 0) continue; + var rowValues = row.values; + var urlParams = row.urlParams, paramParts = urlParams.split('&'); + var rowId = this.o.table.rows[rowIndex].getAttribute('id'); + if(params && this.o.IsArray(params)){//params are replaced if defined + for (var j = 0; j < params.length; j++){ + if(params[j] === ''){ continue; } + urlParams = urlParams.replace(paramParts[j + 1].split('=')[0], params[j]); + } + paramParts = urlParams.split('&'); + } + this.o.Css.Add(this.o.table, this.o.activityIndicatorCss); + if(this.o.onServerActivityStart) this.o.onServerActivityStart.call(null, this.o, this.o.table.rows[rowIndex]); + + if(submitMethod === 'script'){//GET method by using script tag inclusion + var prm = (uri.indexOf('?') === -1 ? '?rowId=' : '&rowId=') + rowId + urlParams; + try {//window.open(uri+prm); + this.o.IncludeFile(this.o.prfxScr + rowIndex + '_' + this.o.id, uri + prm, + function(eg, scriptElm){ + eg.savedRowsNb[cmd]++; var rIndex = scriptElm.id.replace(eg.prfxScr, '').replace('_' + eg.id, ''); + eg.Editable.RemoveModifiedCellMark(parseInt(rIndex, 10)); + SubmitComplete(true); + }); + } catch (e){ + this.o.Css.Remove(this.o.table, this.o.activityIndicatorCss); + if(this.o.onServerActivityStop) this.o.onServerActivityStop.call(null, this.o, this.o.table.rows[rowIndex]); + if(this.o.onSubmitError) this.o.onSubmitError.call(null, this.o, e, e.description); + else alert(this.o.msgErrOccur + '\n' + e.description + '\n' + this.o.msgSaveUnsuccess); + } + } + else if(submitMethod !== 'script' && this.o.ajax){ + var xhr = (function(rowIndex, arrIndex, rowId, urlParams) { + var _self = this, + div; + // Submit data with intervals + if(arrIndex===0){ + submitData(rowId, urlParams, rowIndex, arrIndex); + } else { + setTimeout(function() { + submitData(rowId, urlParams, rowIndex, arrIndex); }, + (arrIndex*x.o.formSubmitInterval) + ); + } + + function submitData(rowId, urlParams, rowIndex, arrIndex){ + var prm = 'rowId=' + rowId + '&rIndex=' + rowIndex + urlParams; + + $.ajax({ + url: uri, + type: formMethod, + data: prm + }).done(function(data, status, xhr){ + // Determine response content-type + var dataType = xhr.getResponseHeader('content-type') || 'application/json'; + + if(dataType.indexOf('application/json') !== -1){ + var sane = sanityCheck(data); + if(sane){ + // Process the response if needed + if(processResponse){ + processResponse.call(_self.o, data); + } + + // Ensure id attribute is set for newly created rows, so they can be updated immediately + if(data.result && data.result.id && cmd === 'insert'){ + if(_self.o.table.rows[rowIndex]){ + _self.o.table.rows[rowIndex].setAttribute('id', _self.o.newRowPrefix + data.result.id); + } + } + + release(); + } else { + fail(null, 'Invalid Data', _self.o.msgInvalidData); + } + } else { + div = _self.o.CreateElm('div', ['id', 'xhr_' + rowIndex + '_' + _self.o.id]); + document.body.appendChild(div); + $(div).html(data); + release(); + } + }).always(function(data){ + if(div){ document.body.removeChild(div); } + }).fail(fail); + } + + function sanityCheck(data) { + if(checkResponseSanity){ + return checkResponseSanity.call(_self.o, data); + } + return (data && data.hasOwnProperty('result') && + data.result.hasOwnProperty('success') && + data.result.hasOwnProperty('id')); + } + + function fail(jqXHR, textStatus, errDesc) { + // remove reference from collection of rows to be treated + if(cmd === 'insert'){ + _self.o.Editable.addedRows.splice(arrIndex, 1); + _self.o.Editable.newRows.splice(arrIndex, 1); + } + treatedRows.splice(arrIndex, 1); + _self.o.Css.Remove(_self.o.table, _self.o.activityIndicatorCss); + if(_self.o.onServerActivityStop) _self.o.onServerActivityStop.call(null, _self.o, _self.o.table.rows[rowIndex]); + if(_self.o.onSubmitError) _self.o.onSubmitError.call(null, _self.o, e, e.description); + else alert(_self.o.msgErrOccur + '\n' + errDesc + '\n' + _self.o.msgSaveUnsuccess); + } + + function release(){ + _self.o.savedRowsNb[cmd]++; + _self.o.Editable.RemoveModifiedCellMark(rowIndex); + _self.o.Css.Remove(_self.o.table.rows[rowIndex], _self.o.newRowClass); + SubmitComplete(true); + } + }).call(this, rowIndex, i, rowId, urlParams); + } else {//GET or POST method by using form and iframe elements + if(!this.o.ifrmContainer[cmd]) this.o.ifrmContainer[cmd] = this.o.CreateElm('div', ['id', 'cont_' + this.o.id + cmd], ['style', 'display:none;']); + var iframeId = this.o.prfxIFrm + rowIndex + '_' + this.o.id + cmd; + var iframe; //below for older versions of IE, name attribute dynamically created problem, very ugly solution... + try { var iframe = document.createElement(''); } + catch (e){ var iframe = this.o.CreateElm('iframe', ['id', iframeId], ['name', iframeId], ['src', 'about:blank'], [this.o.attrRowIndex, rowIndex]); } + iframe.style.cssText = 'display:none; width:0; height:0;'; + + var form = this.o.CreateElm( 'form', + ['id', this.o.prfxFrm + rowIndex + '_' + this.o.id + cmd], ['method', formMethod], ['action', uri], + ['target', iframeId], ['accept-charset', 'utf-8'] ); + for (var j = 1; j < paramParts.length; j++){ + var paramName = paramParts[j].split('=')[0]; + var paramValue = paramParts[j].split('=')[1]; + var hiddenField = this.o.CreateElm('input', ['type', 'hidden'], ['name', paramName], ['value', paramValue]); + form.appendChild(hiddenField); + } + var hiddenField = this.o.CreateElm('input', ['type', 'hidden'], ['name', 'rowId'], ['value', rowId]); + form.appendChild(hiddenField); + + document.body.appendChild(this.o.ifrmContainer[cmd]); + this.o.ifrmContainer[cmd].appendChild(iframe); + this.o.ifrmContainer[cmd].appendChild(form); + } + } //for i + + if(treatedRows.length > 0 && this.o.ifrmContainer[cmd]){ + var ifrms = this.o.Tag(this.o.ifrmContainer[cmd], 'iframe'), + frms = this.o.Tag(this.o.ifrmContainer[cmd], 'form'); + for(var j=0; j= x.o.startRow) { + slcRowIndex = curSlcRowIndex-1; + } else { + slcRowIndex = x.o.startRow; + } + } + if(selectedCell){ + curSlcCellIndex = selectedCell.cellIndex; + } + x.o.Selection.ClearSelections(); + var a = []; + for (var k = 0; k < x.o.Editable.deletedRows.length; k++){ + a.push(x.o.Editable.deletedRows[k][0]); + } + a.sort(x.o.Sort.NumDesc); //rows indexes need to be sorted in desc manner for rows deleting operation + for (var k = 0; k < a.length; k++){ + x.o.table.deleteRow(a[k]); + } + if(slcRowIndex !== null){ + x.o.Selection.SelectRowByIndex(slcRowIndex); + } + if(curSlcCellIndex !== null){ + if(selectedRow){ + var cell = selectedRow.cells[curSlcCellIndex]; + x.o.Selection.SelectCell(cell); + } + } + } + x.o.Editable.deletedRows = []; + x.o.Editable.SetCommandEditor(x.o.editorCmdColIndex); + } + else x.o.Editable.modifiedRows = []; + if(x.o.savedRowsNb.update === 0 && x.o.savedRowsNb.insert === 0 && x.o.savedRowsNb['delete'] === 0){ + if(afterSubmitCallBack){ afterSubmitCallBack.call(null, x.o, treatedRows); } + else { // message displayed if autosave false + if(verbose && !x.o.autoSave && (!x.o.Editable.submitAll || + (x.o.Editable.submitAll && cmd === 'update'))){ + alert(x.o.msgSubmitOK); + } + } + x.o.Editable.submitAll = false; + } + if(x.o.onServerActivityStop) x.o.onServerActivityStop.call(null, x.o, x.o.table.rows[rowIndex]); + if(submitMethod === 'form' && !x.o.ajax && x.o.ifrmContainer[cmd]){ + x.o.ifrmContainer[cmd].innerHTML = ''; + } + x.o.Css.Remove(x.o.table, x.o.activityIndicatorCss); + } + } + }, + Edit: function(e){ + var row, cell; + if(e && e.type && e.type.LCase().indexOf('click') !== -1){ + row = this.o.GetRow(e); + cell = this.o.GetCell(e); + } else { + if(!this.o.selection) return; + if(!this.o.Selection.activeRow && !this.o.Selection.activeCell) return; + row = this.o.Selection.activeRow; + cell = this.o.Selection.activeCell; + } + if(!row || row.rowIndex < this.o.startRow) return; + + if(this.o.editorModel === 'cell' && cell){ + var cellIndex = cell.cellIndex; + if(!this.activeCellEditor && this.o.editors[cellIndex]){ + if(this.o.IsEditorType(cellIndex, this.o.edtTypes.bool)){ + this.SetCheckBoxValue(e, cell); + } else { this.OpenCellEditor(cell); } + } + } + if(this.o.editorModel === 'row' && !this.IsRowEditorOpen()){ this.OpenRowEditor(row); } + }, + Event: { + OnInputFocus: function(e){ + var elm = this.o.Event.GetElement(e); + elm.select(); + }, + OnBlur: function(e){ + var elm = this.o.Event.GetElement(e); + var colIndex = elm.getAttribute(this.o.attrColIndex); + if(colIndex === null){ + var cell = this.o.GetElement(e, 'td'); + colIndex = cell.cellIndex; + } + if(this.o.editorModel == 'cell'){ this.CloseCellEditor(colIndex); } + } + } +}; + +Selection.prototype = { + onClickAdded: false, activeRow: null, activeCell: null, selectedRows: [], + Init: function(){ + if(!this.o.selection) return; + this.SetEvents(); + if(this.o.selectRowAtStart){ + this.SelectRowByIndex(this.o.rowIndexAtStart); + if(this.activeRow) this.SelectCell(this.activeRow.cells[0]); + } + if(this.o.onSelectionInit) this.o.onSelectionInit.call(null, this.o); + }, + Set: function(){ + this.o.selection = true; + this.o.keyNav = true; + this.SetEvents(); + }, + Remove: function(){ + this.o.selection = false; + this.o.keyNav = false; + this.RemoveEvents(); + }, + SetEvents: function(){ + if(!this.onClickAdded){ + var x = this; + this.o.Event.Bind(this.o.table, 'click', function(e){ x.OnClick.call(x, e); }); + if(this.o.onValidateRow || this.o.onValidateCell) this.o.Event.Bind(this.o.table, 'dblclick', function(e){ x.OnDblClick.call(x, e); }); + this.onClickAdded = true; + } + if(this.o.keyNav){ this.o.Event.Bind(this.o.StandardBody(), 'keydown', function(e){ x.OnKeyDown.call(x, e); }); } + }, + RemoveEvents: function(){ + if(this.onClickAdded){ + var x = this; + this.o.Event.Unbind(this.o.table, 'click', function(e){ x.OnClick.call(x, e); }); + if(this.o.onValidateRow || this.o.onValidateCell) this.o.Event.Unbind(this.o.table, 'dblclick', function(e){ x.OnDblClick.call(x, e); }); + this.o.Event.Unbind(this.o.StandardBody(), 'keydown', function(e){ x.OnKeyDown.call(x, e); }); + this.onClickAdded = false; + } + }, + GetActiveRow: function(){ return this.activeRow; }, + GetActiveCell: function(){ return this.activeCell; }, + GetSelectedRows: function(){ return this.selectedRows; }, + GetSelectedValues: function(){ + var values = []; + for(var i=0; i 0){ + if(!this.IsRowSelected(row)) this.SelectRow(row); + else this.DeselectRow(row); + } else this.SelectRow(row); + } + else if(this.o.keySelection && (!e.ctrlKey && !e.shiftKey)){ + this.ClearSelections(); + this.SelectRow(row); + } + else if(this.o.keySelection && e.ctrlKey && this.selectedRows.length > 0) + this.SelectRow(row); + else if(this.o.keySelection && e.shiftKey && this.selectedRows.length > 0){ + if(!this.activeRow) return; + var prevRowIndex = this.activeRow.rowIndex; + this.SelectRow(row); + var curRowIndex = this.activeRow.rowIndex; + if(prevRowIndex < curRowIndex){ + for(var i=prevRowIndex+1; icurRowIndex; i--){ + var r = this.o.table.rows[i]; + if(r){ + if(!this.IsRowSelected(r)) this.SelectRow(r); + else this.DeselectRow(r); + } + } + if(!this.IsRowSelected(this.o.table.rows[prevRowIndex-1])) + this.DeselectRow(this.o.table.rows[prevRowIndex]); + } + this.SelectRow(row); + } + else{ this.SelectRow(row); } + this.DeselectCell(this.activeCell); + if(this.IsRowSelected(row)){ this.SelectCell(cell); } + } + + if(this.o.editable){ + if(this.o.editorModel=='cell'){ + var activeCellEditor = this.o.Editable.activeCellEditor; + if(!activeCellEditor && cell && this.o.editors[cell.cellIndex]){ + //Boolean is set if cell clicked even if editor action is dblclick + if(this.o.IsEditorType(cell.cellIndex, this.o.edtTypes.bool) && this.o.openEditorAction==='dblclick'){ + this.o.Editable.SetCheckBoxValue(e, cell); + } + } + //Custom or uploader editor is closed if cell selection changes + if(activeCellEditor && (this.o.IsEditorType(activeCellEditor.cellIndex, this.o.edtTypes.custom) || + this.o.IsEditorType(activeCellEditor.cellIndex, this.o.edtTypes.uploader)) + && (cell && cell.cellIndex!=activeCellEditor.cellIndex || row.rowIndex!=activeCellEditor.parentNode.rowIndex)){ + this.o.Editable.CloseCellEditor(activeCellEditor.cellIndex); + } + } + if(this.o.editorModel=='row'){ + if(row != this.o.Editable.activeRow) this.o.Editable.CloseRowEditor(); + } + } + }, + OnKeyDown: function(e){ + if(!this.activeRow) return; + var t = this.o.GetTableFromElement(this.activeRow); + if(!t || t.nodeName.LCase() != 'table' || t['id'] != et_activeGrid) return; + var keyCode = this.o.Event.GetKey(e); + var maxRowIndex = (this.o.table.rows.length - 1); + var nbCells = (this.o.GetCellsNb() - 1); + var curRowIndex = this.activeRow.rowIndex; + var rowIndex, cellIndex; + + var x = this; + var navigate = function(cmd){ + if(!x.activeRow){ + rowIndex = x.o.startRow; cellIndex = 0; + } else { + var curCellIndex = (x.activeCell ? x.activeCell.cellIndex : 0); + if(x.o.selectionModel == 'single' || (x.o.selectionModel == 'multiple' && !e.shiftKey) || !x.o.keySelection) x.ClearSelections(); + else if(x.o.selectionModel == 'multiple' && e.shiftKey) x.DeselectCell(x.activeCell, e); + cellIndex = curCellIndex; + if(cmd === 'down') rowIndex = (curRowIndex < maxRowIndex) ? curRowIndex + 1 : maxRowIndex; + else if(cmd === 'up') rowIndex = (curRowIndex == x.o.startRow) ? x.o.startRow : curRowIndex - 1; + else if(cmd === 'pgdown') rowIndex = (curRowIndex+x.o.nbRowsPerPage < maxRowIndex) ? curRowIndex + x.o.nbRowsPerPage : maxRowIndex; + else if(cmd === 'pgup') rowIndex = (curRowIndex-x.o.nbRowsPerPage <= x.o.startRow) ? x.o.startRow : curRowIndex - x.o.nbRowsPerPage; + else if(cmd === 'home') rowIndex = x.o.startRow; + else if(cmd === 'end') rowIndex = maxRowIndex; + else if(cmd === 'right'){ + if(x.o.defaultSelection != 'row'){ + rowIndex = curRowIndex; + cellIndex = (curCellIndex+1 > nbCells) ? 0 : curCellIndex+1; + if((curCellIndex+1) > nbCells) rowIndex = (curRowIndex < maxRowIndex) ? curRowIndex + 1 : maxRowIndex; + } else rowIndex = (curRowIndex < maxRowIndex) ? curRowIndex + 1 : maxRowIndex; + } + else if(cmd === 'left'){ + if(x.o.defaultSelection != 'row'){ + rowIndex = curRowIndex; + cellIndex = (curCellIndex-1 < 0) ? nbCells : curCellIndex-1; + if(curCellIndex-1 < 0) rowIndex = (curRowIndex == x.o.startRow) ? x.o.startRow : curRowIndex - 1; + } else rowIndex = (curRowIndex == x.o.startRow) ? x.o.startRow : curRowIndex - 1; + } + } + var row = x.o.table.rows[rowIndex]; + if(x.o.keySelection && e.shiftKey && x.selectedRows.length > 0 && (cmd=='pgdown' || cmd=='pgup' || cmd=='home' || cmd=='end')){ + if(!x.activeRow) return; + if(curRowIndex < rowIndex){ + for(var i=curRowIndex+1; irowIndex; i--){ + var r = x.o.table.rows[i]; + if(r){ + if(!x.IsRowSelected(r)) x.SelectRow(r, e); + else x.DeselectRow(r, e); + } + } + if(!x.IsRowSelected(x.o.table.rows[curRowIndex-1])) + x.DeselectRow(x.o.table.rows[curRowIndex], e); + } + x.SelectRow(row, e); + } else { + if(x.o.keySelection && e.shiftKey && x.IsRowSelected(row)) x.DeselectRow(x.o.table.rows[curRowIndex], e); + x.SelectRow(row, e); + } + + if(x.o.defaultSelection != 'row'){ + var cell = row.cells[cellIndex]; + x.SelectCell(cell, e); + if(x.o.scrollIntoView) cell.scrollIntoView(false); + } + if(x.o.scrollIntoView && x.o.defaultSelection=='row') row.scrollIntoView(false); + if(x.o.autoSave && x.o.autoSaveModel === 'row'){ + if(rowIndex !== curRowIndex){ x.o.Editable.AutoSubmit(); } + } + x.o.Event.Cancel(e); + }; + + var ed = this.o.Editable; + function closeEditor(){ + if(x.o.editable && ed.activeCellEditor && x.o.editorModel=='cell') + ed.CloseCellEditor(ed.activeCellEditor.cellIndex); + + if(x.o.editable && ed.activeRow && x.o.editorModel=='row') + if(ed.activeRow != x.activeRow) ed.CloseRowEditor(); + } + + switch(keyCode){ + case 40: //arrow down + if(!x.o.editable || (x.o.editable && !ed.activeCellEditor && !ed.activeRow)) navigate('down'); + break; + case 38: //arrow up + if(!x.o.editable || (x.o.editable && !ed.activeCellEditor && !ed.activeRow)) navigate('up'); + break; + case 37: //arrow left + if(!x.o.editable || (x.o.editable && !ed.activeCellEditor && !ed.activeRow)) navigate('left'); + break; + case 39: //arrow right + if(!x.o.editable || (x.o.editable && !ed.activeCellEditor) && !ed.activeRow) navigate('right'); + break; + case 34: //pagedown + navigate('pgdown'); closeEditor(); + break; + case 33: //pageup + navigate('pgup'); closeEditor(); + break; + case 36: //home + navigate('home'); closeEditor(); + break; + case 35: //end + navigate('end'); closeEditor(); + break; + case 9: //tab + if(e.shiftKey) navigate('left'); + else navigate('right'); + if(x.o.editorModel == 'row'){ + if(x.activeCell && x.selectionModel!='row') ed.SetEditorFocus(x.activeCell.cellIndex); + if(x.activeRow && ed.activeRow && x.activeRow.rowIndex != ed.activeRow.rowIndex) closeEditor(); + } else{ closeEditor(); } + break; + case 13: //enter + if(!x.o.editable){ + if(!x.o.onValidateRow && !x.o.onValidateCell) navigate('down'); + else{ + if(x.o.onValidateRow && x.o.defaultSelection != 'cell') x.o.onValidateRow.call(null, x.o, x.activeRow); + if(x.o.onValidateCell && x.o.defaultSelection != 'row') x.o.onValidateCell.call(null, x.o, x.activeCell); + } + } else { + if(!ed.activeCellEditor){ ed.Edit.call(ed, e); x.o.Event.Cancel(e); } + else + if(x.o.IsEditorType(ed.activeCellEditor.cellIndex, x.o.edtTypes.input)){ closeEditor(); } + } + break; + case 113: //F2 + case 32: //space bar + if(x.o.editable && (!ed.activeCellEditor)){ ed.Edit.call(ed, e); x.o.Event.Cancel(e); } + break; + case 45: //insert + if(x.o.editable && (!ed.activeCellEditor)){ + ed.AddNewRow(); + ed.SetCommandEditor(x.o.editorCmdColIndex); + x.o.Event.Cancel(e); + } + break; + case 46: //delete + if(x.o.editable && (!ed.activeCellEditor)){ ed.SubmitDeletedRows(); x.o.Event.Cancel(e); } + break; + case 27: //escape + if(x.o.editable && x.o.editorModel == 'cell'){ if(ed.activeCellEditor) closeEditor(); } + if(x.o.editable && x.o.editorModel == 'row') closeEditor(); + break; + default: //key stroke opens editor if edition is enabled + if((x.o.editable && x.o.editableOnKeystroke && + x.o.editorModel == 'cell' && x.o.selectionModel == 'single' && + !ed.activeCellEditor && !ed.activeRow)){ + ed.Edit.call(ed, e); + x.o.Event.Cancel(e); + } + break; + } + if(x.o.editable && x.o.openEditorAction=='click'){ ed.Edit.call(ed, e); } + } +};//Selection + +EditTable.prototype = { + Init: function(){ + this.Css.Add(this.table, this.tableCss+' '+this.unselectableCss); + this.Selection.Init(); + this.Editable.Init(); + }, + GetCellsNb: function(rowIndex){ + var tr = (rowIndex === undefined) ? this.table.rows[this.startRow] : this.table.rows[rowIndex]; + return tr.cells.length; + }, + GetRowsNb: function(){ return this.table.rows.length; }, + GetRow: function(e){ return this.GetElement(e, 'tr'); }, + GetRowByIndex: function(rowIndex){ return this.table.rows[rowIndex]; }, + GetCell: function(e){ return this.GetElement(e, 'td') || this.GetElement(e, 'th'); }, + GetTableFromElement: function(elm){ + if(!elm) return null; + while(elm.parentNode){ + if(elm.nodeName.UCase() === 'TABLE'){ return elm; } + elm = elm.parentNode; + } + return null; + }, + GetElement: function(e, tagName){ + var elm, target = this.Event.GetElement(e); + while(target.parentNode){ + if(target.nodeName.UCase() === tagName.UCase() + && this.IsParentValid(target)){ + elm = target; break; + } + target = target.parentNode; + } + return elm; + }, + IsParentValid: function(elm){ + while(elm.parentNode){ + if(elm.nodeName.UCase() === 'TABLE'){ + if(elm.id == this.id) return true; + else return false; + } + elm = elm.parentNode; + } + return false; + }, + IsSelectable: function(){ return this.selection; }, + IsEditable: function(){ return this.editable; }, + ClearSelections: function(){ this.Selection.ClearSelections(); }, + IsEditorType: function(colIndex, type){ return this.editorTypes[colIndex] === type; }, + IsObj: function(o){ return (o && o.constructor == Object); }, + IsFn: function(fn){ return (fn && fn.constructor == Function); }, + IsArray: function(a){ return (a && a.constructor == Array); }, + Get: function(id){ return document.getElementById(id); }, + Tag: function(o, tagname){ if(!o){ return null; } else { return o.getElementsByTagName(tagname); } }, + GetText: function(n){ + if(!n){ return ''; } + var s = n.textContent || n.innerText || n.innerHTML.replace(/\<[^<>]+>/g, ''); + return s.replace(/^\s+/, '').replace(/\s+$/, '').Trim(); + }, + CreateElm: function(tag){ + if(tag===undefined || tag===null || tag==='') return; + var el = document.createElement(tag); + if(arguments.length>1){ + for(var i=0; i IE onload event works only for scripts, not for stylesheets + if(!isLoaded && + (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')){ + isLoaded = true; + if(typeof callback === 'function'){ + head.removeChild(file); + callback.call(null, x, this); + } + } + }; + head.appendChild(file); + }, + Sort:{ + NumAsc: function(a, b){ return (a-b); }, + NumDesc: function(a, b){ return (b-a); }, + IgnoreCase: function(a, b){ + var x = a.LCase(); + var y = b.LCase(); + return ((x < y) ? -1 : ((x > y) ? 1 : 0)); + } + } +}; + +if(typeof String.prototype.LCase === 'undefined'){ + String.prototype.LCase = function(){ return this.toLowerCase(); }; +} +if(typeof String.prototype.UCase === 'undefined'){ + String.prototype.UCase = function(){ return this.toUpperCase(); }; +} +if(typeof String.prototype.Trim === 'undefined'){ + String.prototype.Trim = function(){//optimised by Anthony Maes + return this.replace(/(^[\s\xA0]*)|([\s\xA0]*$)/g,''); + }; +} +if(typeof String.prototype.RegexpEscape === 'undefined'){ + String.prototype.RegexpEscape = function(){ + var s = this; + function escape(e){ + a = new RegExp('\\'+e,'g'); + s = s.replace(a,'\\'+e); + } + chars = new Array('\\','[','^','$','.','|','?','*','+','(',')','�'); + for(var e=0; e0&&(this.startRow=b[0].rowIndex),arguments.length>1)for(var c=0;cwindow.parent["{1}"].SetUploadSuccess(true); window.parent["{1}"].SetUploadName("{0}");window.parent["{1}"].ShowUpload();',this.showUpload[c]=g.hasOwnProperty("show_upload")&&this.IsFn(g.show_upload)?g.show_upload:null,this.onBeforeOpenUploader[c]=g.hasOwnProperty("on_before_open")&&this.IsFn(g.on_before_open)?g.on_before_open:null,this.onAfterOpenUploader[c]=g.hasOwnProperty("on_after_open")&&this.IsFn(g.on_after_open)?g.on_after_open:null,this.onBeforeCloseUploader[c]=g.hasOwnProperty("on_before_close")&&this.IsFn(g.on_before_close)?g.on_before_close:null,this.onAfterCloseUploader[c]=g.hasOwnProperty("on_after_close")&&this.IsFn(g.on_after_close)?g.on_after_close:null}}-1!=this.editorTypes.indexOf(this.edtTypes.command)&&(this.editorModel="row"),this.inputEditorCss=void 0!==e.input_editor_css?e.input_editor_css:"ezInputEditor",this.textareaEditorCss=void 0!==e.textarea_editor_css?e.textarea_editor_css:"ezTextareaEditor",this.selectEditorCss=void 0!==e.select_editor_css?e.select_editor_css:"ezSelectEditor",this.commandEditorCss=void 0!==e.command_editor_css?e.command_editor_css:"ezCommandEditor",this.modifiedCellCss=void 0!==e.modified_cell_css?e.modified_cell_css:"ezModifiedCell",this.cmdEnabledBtns=this.editorCmdBtns.hasOwnProperty("enable")?this.editorCmdBtns.enable:["update","insert","delete","submit","cancel"],this.cmdUpdateBtn=this.editorCmdBtns.hasOwnProperty("update")?this.editorCmdBtns.update:{},this.cmdInsertBtn=this.editorCmdBtns.hasOwnProperty("insert")?this.editorCmdBtns.insert:{},this.cmdDeleteBtn=this.editorCmdBtns.hasOwnProperty("delete")?this.editorCmdBtns["delete"]:{},this.cmdSubmitBtn=this.editorCmdBtns.hasOwnProperty("submit")?this.editorCmdBtns.submit:{},this.cmdCancelBtn=this.editorCmdBtns.hasOwnProperty("cancel")?this.editorCmdBtns.cancel:{},this.cmdUpdateBtnText=this.cmdUpdateBtn.hasOwnProperty("text")?this.cmdUpdateBtn.text:"",this.cmdInsertBtnText=this.cmdInsertBtn.hasOwnProperty("text")?this.cmdInsertBtn.text:"",this.cmdDeleteBtnText=this.cmdDeleteBtn.hasOwnProperty("text")?this.cmdDeleteBtn.text:"",this.cmdSubmitBtnText=this.cmdSubmitBtn.hasOwnProperty("text")?this.cmdSubmitBtn.text:"Submit",this.cmdCancelBtnText=this.cmdCancelBtn.hasOwnProperty("text")?this.cmdCancelBtn.text:"Cancel",this.cmdUpdateBtnTitle=this.cmdUpdateBtn.hasOwnProperty("title")?this.cmdUpdateBtn.title:"Edit record",this.cmdInsertBtnTitle=this.cmdInsertBtn.hasOwnProperty("title")?this.cmdInsertBtn.title:"Create record",this.cmdDeleteBtnTitle=this.cmdDeleteBtn.hasOwnProperty("title")?this.cmdDeleteBtn.title:"Delete record",this.cmdSubmitBtnTitle=this.cmdSubmitBtn.hasOwnProperty("title")?this.cmdSubmitBtn.title:"Submit record",this.cmdCancelBtnTitle=this.cmdCancelBtn.hasOwnProperty("title")?this.cmdCancelBtn.title:"Cancel",this.cmdUpdateBtnIcon=this.cmdUpdateBtn.hasOwnProperty("icon")?this.cmdUpdateBtn.icon:'',this.cmdInsertBtnIcon=this.cmdInsertBtn.hasOwnProperty("icon")?this.cmdInsertBtn.icon:'',this.cmdDeleteBtnIcon=this.cmdDeleteBtn.hasOwnProperty("icon")?this.cmdDeleteBtn.icon:'',this.cmdSubmitBtnIcon=this.cmdSubmitBtn.hasOwnProperty("icon")?this.cmdSubmitBtn.icon:"",this.cmdCancelBtnIcon=this.cmdCancelBtn.hasOwnProperty("icon")?this.cmdCancelBtn.icon:"",this.cmdUpdateBtnCss=this.cmdUpdateBtn.hasOwnProperty("css")?this.cmdUpdateBtn.css:null,this.cmdInsertBtnCss=this.cmdInsertBtn.hasOwnProperty("css")?this.cmdInsertBtn.css:null,this.cmdDeleteBtnCss=this.cmdDeleteBtn.hasOwnProperty("css")?this.cmdDeleteBtn.css:null,this.cmdSubmitBtnCss=this.cmdSubmitBtn.hasOwnProperty("css")?this.cmdSubmitBtn.css:null,this.cmdCancelBtnCss=this.cmdCancelBtn.hasOwnProperty("css")?this.cmdCancelBtn.css:null,this.cmdUpdateBtnStyle=this.cmdUpdateBtn.hasOwnProperty("style")?this.cmdUpdateBtn.style:null,this.cmdInsertBtnStyle=this.cmdInsertBtn.hasOwnProperty("style")?this.cmdInsertBtn.style:null,this.cmdDeleteBtnStyle=this.cmdDeleteBtn.hasOwnProperty("style")?this.cmdDeleteBtn.style:null,this.cmdSubmitBtnStyle=this.cmdSubmitBtn.hasOwnProperty("style")?this.cmdSubmitBtn.style:null,this.cmdCancelBtnStyle=this.cmdCancelBtn.hasOwnProperty("style")?this.cmdCancelBtn.style:null,this.cmdInsertBtnScroll=this.cmdInsertBtn.hasOwnProperty("scrollIntoView")?this.cmdInsertBtn.scrollIntoView:!1,this.onEditableInit=this.IsFn(e.on_editable_initialized)?e.on_editable_initialized:null,this.onBeforeOpenEditor=this.IsFn(e.on_before_open_editor)?e.on_before_open_editor:null,this.onAfterOpenEditor=this.IsFn(e.on_after_open_editor)?e.on_after_open_editor:null,this.onBeforeCloseEditor=this.IsFn(e.on_before_close_editor)?e.on_before_close_editor:null,this.onAfterCloseEditor=this.IsFn(e.on_after_close_editor)?e.on_after_close_editor:null,this.setCustomEditorValue=this.IsFn(e.set_custom_editor_value)?e.set_custom_editor_value:null,this.getCustomEditorValue=this.IsFn(e.get_custom_editor_value)?e.get_custom_editor_value:null,this.setCellModifiedValue=this.IsFn(e.set_cell_modified_value)?e.set_cell_modified_value:null,this.validateModifiedValue=this.IsFn(e.validate_modified_value)?e.validate_modified_value:null,this.openCustomEditor=this.IsFn(e.open_custom_editor)?e.open_custom_editor:null,this.closeCustomEditor=this.IsFn(e.close_custom_editor)?e.close_custom_editor:null,this.onAddedDomRow=this.IsFn(e.on_added_dom_row)?e.on_added_dom_row:null,this.actions=this.IsObj(e.actions)?e.actions:{},this.updateConfig=void 0!==this.actions.update?this.actions.update:{},this.insertConfig=void 0!==this.actions.insert?this.actions.insert:{},this.deleteConfig=void 0!==this.actions["delete"]?this.actions["delete"]:{},this.updateURI=this.updateConfig.hasOwnProperty("uri")?this.updateConfig.uri:null,this.insertURI=this.insertConfig.hasOwnProperty("uri")?this.insertConfig.uri:null,this.deleteURI=this.deleteConfig.hasOwnProperty("uri")?this.deleteConfig.uri:null,this.updateFormMethod=this.updateConfig.hasOwnProperty("form_method")?this.updateConfig.form_method.LCase():"post",this.insertFormMethod=this.insertConfig.hasOwnProperty("form_method")?this.insertConfig.form_method.LCase():"post",this.deleteFormMethod=this.deleteConfig.hasOwnProperty("form_method")?this.deleteConfig.form_method.LCase():"post",this.updateSubmitMethod=this.updateConfig.hasOwnProperty("submit_method")?this.updateConfig.submit_method.LCase():this.ajax?"ajax":"form",this.insertSubmitMethod=this.insertConfig.hasOwnProperty("submit_method")?this.insertConfig.submit_method.LCase():this.ajax?"ajax":"form",this.deleteSubmitMethod=this.deleteConfig.hasOwnProperty("submit_method")?this.deleteConfig.submit_method.LCase():this.ajax?"ajax":"form",this.bulkDelete=this.deleteConfig.hasOwnProperty("bulk_delete")?this.deleteConfig.bulk_delete:!1,this.defaultRecord=this.insertConfig.hasOwnProperty("default_record")&&this.IsArray(this.insertConfig.default_record)?this.insertConfig.default_record:null,this.updateParams=this.updateConfig.hasOwnProperty("param_names")&&this.IsArray(this.updateConfig.param_names)?this.updateConfig.param_names:null,this.insertParams=this.insertConfig.hasOwnProperty("param_names")&&this.IsArray(this.insertConfig.param_names)?this.insertConfig.param_names:null,this.deleteParams=this.deleteConfig.hasOwnProperty("param_names")&&this.IsArray(this.deleteConfig.param_names)?this.deleteConfig.param_names:null,this.onUpdateSubmit=this.updateConfig.hasOwnProperty("on_update_submit")&&this.IsFn(this.updateConfig.on_update_submit)?this.updateConfig.on_update_submit:null,this.onInsertSubmit=this.insertConfig.hasOwnProperty("on_insert_submit")&&this.IsFn(this.insertConfig.on_insert_submit)?this.insertConfig.on_insert_submit:null,this.onDeleteSubmit=this.deleteConfig.hasOwnProperty("on_delete_submit")&&this.IsFn(this.deleteConfig.on_delete_submit)?this.deleteConfig.on_delete_submit:null,this.onBeforeUpdateSubmit=this.updateConfig.hasOwnProperty("on_before_submit")&&this.IsFn(this.updateConfig.on_before_submit)?this.updateConfig.on_before_submit:null,this.onBeforeInsertSubmit=this.insertConfig.hasOwnProperty("on_before_submit")&&this.IsFn(this.insertConfig.on_before_submit)?this.insertConfig.on_before_submit:null,this.onBeforeDeleteSubmit=this.deleteConfig.hasOwnProperty("on_before_submit")&&this.IsFn(this.deleteConfig.on_before_submit)?this.deleteConfig.on_before_submit:null,this.onAfterUpdateSubmit=this.updateConfig.hasOwnProperty("on_after_submit")&&this.IsFn(this.updateConfig.on_after_submit)?this.updateConfig.on_after_submit:null,this.onAfterInsertSubmit=this.insertConfig.hasOwnProperty("on_after_submit")&&this.IsFn(this.insertConfig.on_after_submit)?this.insertConfig.on_after_submit:null,this.onAfterDeleteSubmit=this.deleteConfig.hasOwnProperty("on_after_submit")&&this.IsFn(this.deleteConfig.on_after_submit)?this.deleteConfig.on_after_submit:null,this.onUpdateError=this.updateConfig.hasOwnProperty("on_submit_error")&&this.IsFn(this.updateConfig.on_submit_error)?this.updateConfig.on_submit_error:null,this.onInsertError=this.insertConfig.hasOwnProperty("on_submit_error")&&this.IsFn(this.insertConfig.on_submit_error)?this.insertConfig.on_submit_error:null,this.onDeleteError=this.deleteConfig.hasOwnProperty("on_submit_error")&&this.IsFn(this.deleteConfig.on_submit_error)?this.deleteConfig.on_submit_error:null,this.checkUpdateResponseSanity=this.updateConfig.hasOwnProperty("check_response_sanity")&&this.IsFn(this.updateConfig.check_response_sanity)?this.updateConfig.check_response_sanity:null,this.checkInsertResponseSanity=this.insertConfig.hasOwnProperty("check_response_sanity")&&this.IsFn(this.insertConfig.check_response_sanity)?this.insertConfig.check_response_sanity:null,this.checkDeleteResponseSanity=this.deleteConfig.hasOwnProperty("check_response_sanity")&&this.IsFn(this.deleteConfig.check_response_sanity)?this.deleteConfig.check_response_sanity:null,this.processUpdateResponse=this.updateConfig.hasOwnProperty("process_response")&&this.IsFn(this.updateConfig.process_response)?this.updateConfig.process_response:null,this.processInsertResponse=this.insertConfig.hasOwnProperty("process_response")&&this.IsFn(this.insertConfig.process_response)?this.insertConfig.process_response:null,this.processDeleteResponse=this.deleteConfig.hasOwnProperty("process_response")&&this.IsFn(this.deleteConfig.process_response)?this.deleteConfig.process_response:null,this.msgSubmitOK=void 0!==e.msg_submit_ok?e.msg_submit_ok:"Changes were successfully submitted to server!",this.msgConfirmDelSelectedRows=void 0!==e.msg_confirm_delete_selected_rows?e.msg_confirm_delete_selected_rows:"Do you want to delete the selected row(s)?",this.msgErrOccur=void 0!==e.msg_error_occured?e.msg_error_occured:"An error occured!",this.msgSaveUnsuccess=void 0!==e.msg_submit_unsuccessful?e.msg_submit_unsuccessful:"Changes could not be saved!",this.msgUndefinedSubmitUrl=void 0!==e.undefined_submit_url?e.undefined_submit_url:"Changes could not be saved! Endpoint URL is not defined",this.msgNewRowNoUploader=void 0!==e.msg_new_row_no_uploader?e.msg_new_row_no_uploader:"Please save the newly added rows before using the Uploader.",this.msgInvalidData=void 0!==e.msg_invalid_data?e.msg_invalid_data:"Returned data is invalid.",this.ifrmContainer={},this.valuesSeparator=", ",this.defaultRecordUndefinedValue="...",this.newRowClass="ezNewRow",this.recordKeyValue="new",this.attrValue="data-ez-slc-value",this.attrText="data-ez-slc-text",this.attrCont="data-ez-html",this.attrData="data-ez-data",this.attrUplname="data-ez-uplname",this.attrColIndex="data-ez-col-index",this.attrRowIndex="data-ez-row-index",this.savedRowsNb={insert:0,update:0,"delete":0},this.prfxEdt="edt_",this.prfxIFrm="iframe_",this.prfxFrm="form_",this.prfxScr="scr_",this.prfxParam="col_",this.prfxUplCont="upl_",this.prfxUplForm="upl_form_",this.prfxUplIframe="upl_ifrm_",this.prfxUplInfo="upl_info_",this.prfxUplOutput="upl_output_",this.prfxUplBtn="upl_btn_",this.prfxUplBtnClose="upl_btn_close_",this.prfxUplImgDisplay="upl_img_display_",this.prfxUplWinRef="et_upl_",this.uplFileInp="UPL_FILE",this.uplKeyInput="RECORD_KEY",this.uplFldPath="IMAGES_FOLDER_PATH",this.uplSqlFieldName="SQL_FIELD",this.uplFileSize="MAX_FILE_SIZE",this.uplValidExts="VALID_EXTENSIONS",this.uplJsCode="JS_CODE",this.Editable=new Editable(this),this.Selection=new Selection(this)}},Editable=function(a){this.o=a},Selection=function(a){this.o=a},Uploader=function(a,b){this.o=a,this.colIndex=b,window[this.o.prfxUplWinRef+b+this.o.id]=this};Uploader.prototype={divUpl:null,formUpl:null,fileUpl:null,hiddenFileSize:null,hiddenFolderPath:null,hiddenValidExt:null,hiddenKey:null,ifrmUpl:null,divUplInfo:null,divUplOutput:null,divUplBtnsCont:null,divUplBtn:null,divUplBtnClose:null,divUplDisplay:null,initialValue:null,isUploadSuccessful:!1,Init:function(){this.o.hasUploader&&this.SetUploader()},SetUploader:function(){this.divUpl=this.o.CreateElm("div",["id",this.o.prfxUplCont+this.colIndex+this.o.id],["style","display:none; z-index:10001;"],["class",this.o.uplCss[this.colIndex]]),this.formUpl=this.o.CreateElm("form",["id",this.o.prfxUplForm+this.colIndex+this.o.id],["name",this.o.prfxUplForm+this.colIndex+this.o.id],["method","POST"],["action",this.o.uplURI[this.colIndex]],["target",this.o.prfxUplIframe+this.colIndex+this.o.id],["enctype","multipart/form-data"]),this.fileUpl=this.o.CreateElm("input",["id",this.o.uplFileInp],["name",this.o.uplFileInp],["type","file"]),this.hiddenFileSize=this.o.CreateElm("input",["name",this.o.uplFileSize],["type","hidden"],["value",this.o.uplMaxFileSize[this.colIndex]]),this.hiddenFolderPath=this.o.CreateElm("input",["name",this.o.uplFldPath],["type","hidden"],["value",this.o.uplPath[this.colIndex]]),this.hiddenValidExt=this.o.CreateElm("input",["name",this.o.uplValidExts],["type","hidden"],["value",this.o.uplValidExt[this.colIndex]]),this.hiddenKey=this.o.CreateElm("input",["name",this.o.uplKeyInput],["type","hidden"],["value",this.o.recordKeyValue]),this.hiddenSqlField=this.o.CreateElm("input",["name",this.o.uplSqlFieldName],["type","hidden"],["value",this.o.uplSqlField[this.colIndex]]),this.hiddenUplWinRef=this.o.CreateElm("input",["name",this.o.uplJsCode],["type","hidden"],["value",this.o.uplJsSuccess[this.colIndex]]),this.ifrmUpl=this.o.CreateElm("iframe",["id",this.o.prfxUplIframe+this.colIndex+this.o.id],["name",this.o.prfxUplIframe+this.colIndex+this.o.id],["style","display:none; left:-10001;"]),this.divUplInfo=this.o.CreateElm("div",["id",this.o.prfxUplInfo+this.colIndex+this.o.id]),this.divUplOutput=this.o.CreateElm("div",["id",this.o.prfxUplOutput+this.colIndex+this.o.id],["class",this.o.uplOutputCss[this.colIndex]]),this.divUplBtnsCont=this.o.CreateElm("div",["style","text-align:right"]),this.divUplBtn=this.o.CreateElm("button",["id",this.o.prfxUplBtn+this.colIndex+this.o.id],["style","display:none;"]),this.divUplBtnClose=this.o.CreateElm("button",["id",this.o.prfxUplBtnClose+this.colIndex+this.o.id]),this.divUplDisplay=this.o.CreateElm("div",["id",this.o.prfxUplImgDisplay+this.colIndex+this.o.id],["class",this.o.uplDisplayCss[this.colIndex]]),this.o.Css.Has(this.divUpl,this.o.uplCss[this.colIndex])||(this.o.Css.Add(this.divUpl,this.o.uplCss[this.colIndex]),this.o.Css.Add(this.divUplOutput,this.o.uplOutputCss[this.colIndex]),this.o.Css.Add(this.divUplDisplay,this.o.uplDisplayCss[this.colIndex]),this.divUpl.style.cssText="display:none; z-index:10001;",this.divUplBtnsCont.style.cssText="text-align:right",this.divUplBtn.style.cssText="display:none;",this.formUpl=document.createElement('
'),this.ifrmUpl=document.createElement('')),this.divUplInfo.innerHTML=parseInt(this.o.uplMaxFileSize[this.colIndex]/1024,10)+"Kb max ("+this.o.uplValidExt[this.colIndex].toString()+")",this.divUplBtn.appendChild(this.o.CreateText("Upload")),this.divUplBtnClose.appendChild(this.o.CreateText("Close")),this.divUplBtnsCont.appendChild(this.divUplBtn),this.divUplBtnsCont.appendChild(this.divUplBtnClose),this.formUpl.appendChild(this.fileUpl),this.formUpl.appendChild(this.hiddenFileSize),this.formUpl.appendChild(this.hiddenFolderPath),this.formUpl.appendChild(this.hiddenUplWinRef),this.formUpl.appendChild(this.hiddenValidExt),this.formUpl.appendChild(this.hiddenKey),this.formUpl.appendChild(this.hiddenSqlField),this.divUpl.appendChild(this.formUpl),this.divUpl.appendChild(this.ifrmUpl),this.divUpl.appendChild(this.divUplInfo),this.divUpl.appendChild(this.divUplOutput),this.divUpl.appendChild(this.divUplBtnsCont),this.divUpl.appendChild(this.divUplDisplay),this.o.table.parentNode.insertBefore(this.divUpl,this.o.table);var a=this;this.ifrmUpl.onload=this.ifrmUpl.onreadystatechange=function(){if(!this.readyState||"loaded"==this.readyState||"complete"==this.readyState)try{var b=this.contentDocument||this.contentWindow.document;"about:blank"!=b.location.href&&(a.Output(b.body.innerHTML),a.iframe.src="about:blank",a.HideUploadButton())}catch(c){}},this.o.Event.Add(this.fileUpl,"click",function(){a.OnUplClick()}),this.o.Event.Add(this.divUplBtn,"click",function(){a.Upload()}),this.o.Event.Add(this.divUplBtnClose,"click",function(){a.Close(a.o.Selection.GetActiveRow().cells[a.colIndex])});var b=this.o.uplJsSuccess[this.colIndex].replace(/\{1\}/g,this.o.prfxUplWinRef+this.colIndex+this.o.id);this.hiddenUplWinRef.value=b},GetValue:function(){return this.fileUpl.value},HasValueChanged:function(){return this.initialValue!=this.GetValue()},OnUplClick:function(){this.ShowUploadButton()},Upload:function(){this.ShowLoader(),this.formUpl.submit()},SetRecordKey:function(a){this.hiddenKey.value=a},GetRecordKey:function(){return this.hiddenKey.value},ShowUploadButton:function(){this.divUplBtn.style.display="inline"},HideUploadButton:function(){this.divUplBtn.style.display="none"},ShowUploadContainer:function(){this.divUplDisplay.style.display="block"},HideUploadContainer:function(){this.divUplDisplay.style.display="none"},ShowUpload:function(){if(this.o.uplShowUpload[this.colIndex]){var a=this.o.Selection.GetActiveRow();if(this.o.showUpload[this.colIndex])return this.ShowUploadContainer(),void this.o.showUpload[this.colIndex].call(this,this.o,this.divUplDisplay,this.GetUploadName(),this.o.uplPath[this.colIndex]);if(a){var b=this.GetUploadName();b?(this.divUplDisplay.innerHTML=this.o.uplShowLink[this.colIndex]?this.GetUploadLinkHtml():''+b+'',this.ShowUploadContainer(),this.divUpl.scrollIntoView(!1)):this.ClearUpload()}}},ClearUpload:function(){this.divUplDisplay.innerHTML="",this.HideUploadContainer()},GetUploadName:function(){var a=this.o.Selection.GetActiveRow().cells[this.colIndex];return a?a.getAttribute(this.o.attrUplname):null},SetUploadName:function(a){var b=this.o.Selection.GetActiveRow().cells[this.colIndex];b&&b.setAttribute(this.o.attrUplname,a)},GetUploadLinkHtml:function(){var a=this.GetUploadName();return''+a.replace(this.GetRecordKey()+"_","")+""},Open:function(a){if(a){if(this.o.Css.Has(a.parentNode,this.o.newRowClass)||!a.parentNode.getAttribute("id"))return void alert(this.o.msgNewRowNoUploader);a.appendChild(this.divUpl),this.o.onBeforeOpenUploader[this.colIndex]&&this.o.onBeforeOpenUploader[this.colIndex].call(this,this.o,this.divUpl,a);var b=this.o.uplRecordIdColIndex[this.colIndex]?this.o.Selection.GetActiveRow()[this.o.uplRecordIdColIndex[this.colIndex]]:this.o.Selection.GetActiveRow().getAttribute("id").replace(this.o.newRowPrefix,"");""!==b&&(this.divUpl.style.display="",this.SetRecordKey(b),this.initialValue=this.GetValue(),this.SetUploadSuccess(!1),this.ShowUpload()),this.o.onAfterOpenUploader[this.colIndex]&&this.o.onAfterOpenUploader[this.colIndex].call(this,this.o,this.divUpl,a)}},Close:function(a){if("none"!=this.divUpl.style.display){if(this.o.onBeforeCloseUploader[this.colIndex]&&this.o.onBeforeCloseUploader[this.colIndex].call(this,this.o,this.divUpl,a),a&&this.IsUploadSuccessful())if(this.o.uplShowLink[this.colIndex]){var b=this.o.CreateElm("div");b.innerHTML=this.divUplDisplay.innerHTML,a.appendChild(b)}else{var c=this.o.Tag(a,"img")[0];c&&(c.src=this.o.uplOkImg[this.colIndex])}this.Output(""),this.SetRecordKey(""),this.ClearUpload(),this.HideUploadButton(),this.divUpl.style.display="none",this.o.StandardBody().appendChild(this.divUpl),this.o.onAfterCloseUploader[this.colIndex]&&this.o.onAfterCloseUploader[this.colIndex].call(this,this.o,this.divUpl,a)}},Output:function(a){this.divUplOutput.innerHTML=a},SetUploadSuccess:function(a){this.isUploadSuccessful=a},IsUploadSuccessful:function(){return this.isUploadSuccessful},ShowLoader:function(){this.Output('Please wait...')},HideLoader:function(){this.Output("")}},Editable.prototype={onEditAdded:!1,activeCellEditor:null,openCellEditor:null,activeRow:null,modifiedRows:[],newRows:[],addedRows:[],deletedRows:[],Init:function(){this.o.editable&&(this.SetEvents(),this.SetCellsEditor(),this.o.onEditableInit&&this.o.onEditableInit.call(null,this.o))},Set:function(){this.o.editable=!0,this.SetEvents()},Remove:function(){this.o.editable=!1,this.RemoveEvents()},SetEvents:function(){if(!this.onEditAdded){var a=this;this.o.Event.Bind(this.o.table,this.o.openEditorAction,function(b){a.Edit.call(a,b)}),this.onEditAdded=!0}},RemoveEvents:function(){if(this.onEditAdded){var a=this;this.o.Event.Unbind(this.o.table,this.o.openEditorAction,function(b){a.Edit.call(a,b)}),this.onEditAdded=!1}},SetCellsEditor:function(){for(var a=0;a0&&(m=this.o.Tag(d.cells[k],"input")[0].checked);var h=this.o.prfxParam+k;e.values.push(m),e.modified.push(a.cellIndex==k?!0:!1),e.urlParams+="&"+h+"="+encodeURIComponent(m)}this.modifiedRows.push([d.rowIndex,e])}}}},GetModifiedRow:function(a){if(void 0===a)return null;for(var b=0;b0?h=this.o.Tag(g,"input")[0].checked:this.o.IsEditorType(f,this.o.edtTypes.select)&&(h=g.getAttribute(this.o.attrValue));var i=this.o.prfxParam+f;e.values.push(h),e.modified.push("delete"==b?!1:!0),e.urlParams+="&"+i+"="+encodeURIComponent(h)}"delete"==b?this.deletedRows.push([d.rowIndex,e]):"insert"==b?this.addedRows.push([d.rowIndex,e]):this.modifiedRows.push([d.rowIndex,e])}}},GetDeletedRows:function(){return this.deletedRows},RemoveModifiedRow:function(a){if(void 0!==a)for(var b=0;b=-1&&(b=this.o.newRowPos);try{a=this.o.table.insertRow(b)}catch(c){a=this.o.table.insertRow(this.o.startRow),console.log(c)}a.setAttribute("id",this.o.CreateId()),this.o.Css.Add(a,this.o.newRowClass);for(var d=0;d=n.o.startRow?h-1:n.o.startRow),g&&(j=g.cellIndex),n.o.Selection.ClearSelections();for(var l=[],m=0;m0)alert(a.toUpperCase()+": "+this.o.msgUndefinedSubmitUrl),c=[],n.o.savedRowsNb[a]=0,b(!1);else{for(var o=0;oq)){var s=(r.values,r.urlParams),t=s.split("&"),u=this.o.table.rows[q].getAttribute("id");if(g&&this.o.IsArray(g)){for(var v=0;v')}catch(x){var y=this.o.CreateElm("iframe",["id",z],["name",z],["src","about:blank"],[this.o.attrRowIndex,q])}y.style.cssText="display:none; width:0; height:0;";for(var A=this.o.CreateElm("form",["id",this.o.prfxFrm+q+"_"+this.o.id+a],["method",f],["action",d],["target",z],["accept-charset","utf-8"]),v=1;v0&&this.o.ifrmContainer[a])for(var E=this.o.Tag(this.o.ifrmContainer[a],"iframe"),F=this.o.Tag(this.o.ifrmContainer[a],"form"),v=0;v0)this.SelectRow(b);else if(this.o.keySelection&&a.shiftKey&&this.selectedRows.length>0){if(!this.activeRow)return;var d=this.activeRow.rowIndex;this.SelectRow(b);var e=this.activeRow.rowIndex;if(e>d){for(var f=d+1;e>f;f++){var g=this.o.table.rows[f];g&&(this.IsRowSelected(g)?this.DeselectRow(g):this.SelectRow(g))}this.IsRowSelected(this.o.table.rows[d+1])||this.DeselectRow(this.o.table.rows[d])}else{for(var f=d-1;f>e;f--){var g=this.o.table.rows[f];g&&(this.IsRowSelected(g)?this.DeselectRow(g):this.SelectRow(g))}this.IsRowSelected(this.o.table.rows[d-1])||this.DeselectRow(this.o.table.rows[d])}this.SelectRow(b)}else this.SelectRow(b);else this.ClearSelections(),this.SelectRow(b);else this.selectedRows.length>0?this.IsRowSelected(b)?this.DeselectRow(b):this.SelectRow(b):this.SelectRow(b);this.DeselectCell(this.activeCell),this.IsRowSelected(b)&&this.SelectCell(c)}if(this.o.editable){if("cell"==this.o.editorModel){var h=this.o.Editable.activeCellEditor;!h&&c&&this.o.editors[c.cellIndex]&&this.o.IsEditorType(c.cellIndex,this.o.edtTypes.bool)&&"dblclick"===this.o.openEditorAction&&this.o.Editable.SetCheckBoxValue(a,c),h&&(this.o.IsEditorType(h.cellIndex,this.o.edtTypes.custom)||this.o.IsEditorType(h.cellIndex,this.o.edtTypes.uploader))&&(c&&c.cellIndex!=h.cellIndex||b.rowIndex!=h.parentNode.rowIndex)&&this.o.Editable.CloseCellEditor(h.cellIndex)}"row"==this.o.editorModel&&b!=this.o.Editable.activeRow&&this.o.Editable.CloseRowEditor()}}},OnKeyDown:function(a){function b(){j.o.editable&&l.activeCellEditor&&"cell"==j.o.editorModel&&l.CloseCellEditor(l.activeCellEditor.cellIndex),j.o.editable&&l.activeRow&&"row"==j.o.editorModel&&l.activeRow!=j.activeRow&&l.CloseRowEditor()}if(this.activeRow){var c=this.o.GetTableFromElement(this.activeRow);if(c&&"table"==c.nodeName.LCase()&&c.id==et_activeGrid){var d,e,f=this.o.Event.GetKey(a),g=this.o.table.rows.length-1,h=this.o.GetCellsNb()-1,i=this.activeRow.rowIndex,j=this,k=function(b){if(j.activeRow){var c=j.activeCell?j.activeCell.cellIndex:0;"single"==j.o.selectionModel||"multiple"==j.o.selectionModel&&!a.shiftKey||!j.o.keySelection?j.ClearSelections():"multiple"==j.o.selectionModel&&a.shiftKey&&j.DeselectCell(j.activeCell,a),e=c,"down"===b?d=g>i?i+1:g:"up"===b?d=i==j.o.startRow?j.o.startRow:i-1:"pgdown"===b?d=i+j.o.nbRowsPerPageh?0:c+1,c+1>h&&(d=g>i?i+1:g)):d=g>i?i+1:g:"left"===b&&("row"!=j.o.defaultSelection?(d=i,e=0>c-1?h:c-1,0>c-1&&(d=i==j.o.startRow?j.o.startRow:i-1)):d=i==j.o.startRow?j.o.startRow:i-1)}else d=j.o.startRow,e=0;var f=j.o.table.rows[d];if(j.o.keySelection&&a.shiftKey&&j.selectedRows.length>0&&("pgdown"==b||"pgup"==b||"home"==b||"end"==b)){if(!j.activeRow)return;if(d>i){for(var k=i+1;d>k;k++){var l=j.o.table.rows[k];l&&(j.IsRowSelected(l)?j.DeselectRow(l,a):j.SelectRow(l,a))}j.IsRowSelected(j.o.table.rows[i+1])||j.DeselectRow(j.o.table.rows[i],a)}else{for(var k=i-1;k>d;k--){var l=j.o.table.rows[k];l&&(j.IsRowSelected(l)?j.DeselectRow(l,a):j.SelectRow(l,a))}j.IsRowSelected(j.o.table.rows[i-1])||j.DeselectRow(j.o.table.rows[i],a)}j.SelectRow(f,a)}else j.o.keySelection&&a.shiftKey&&j.IsRowSelected(f)&&j.DeselectRow(j.o.table.rows[i],a),j.SelectRow(f,a);if("row"!=j.o.defaultSelection){var m=f.cells[e];j.SelectCell(m,a),j.o.scrollIntoView&&m.scrollIntoView(!1)}j.o.scrollIntoView&&"row"==j.o.defaultSelection&&f.scrollIntoView(!1),j.o.autoSave&&"row"===j.o.autoSaveModel&&d!==i&&j.o.Editable.AutoSubmit(),j.o.Event.Cancel(a)},l=this.o.Editable;switch(f){case 40:(!j.o.editable||j.o.editable&&!l.activeCellEditor&&!l.activeRow)&&k("down");break;case 38:(!j.o.editable||j.o.editable&&!l.activeCellEditor&&!l.activeRow)&&k("up");break;case 37:(!j.o.editable||j.o.editable&&!l.activeCellEditor&&!l.activeRow)&&k("left");break;case 39:(!j.o.editable||j.o.editable&&!l.activeCellEditor&&!l.activeRow)&&k("right");break;case 34:k("pgdown"),b();break;case 33:k("pgup"),b();break;case 36:k("home"),b();break;case 35:k("end"),b();break;case 9:k(a.shiftKey?"left":"right"),"row"==j.o.editorModel?(j.activeCell&&"row"!=j.selectionModel&&l.SetEditorFocus(j.activeCell.cellIndex),j.activeRow&&l.activeRow&&j.activeRow.rowIndex!=l.activeRow.rowIndex&&b()):b();break;case 13:j.o.editable?l.activeCellEditor?j.o.IsEditorType(l.activeCellEditor.cellIndex,j.o.edtTypes.input)&&b():(l.Edit.call(l,a),j.o.Event.Cancel(a)):j.o.onValidateRow||j.o.onValidateCell?(j.o.onValidateRow&&"cell"!=j.o.defaultSelection&&j.o.onValidateRow.call(null,j.o,j.activeRow),j.o.onValidateCell&&"row"!=j.o.defaultSelection&&j.o.onValidateCell.call(null,j.o,j.activeCell)):k("down");break;case 113:case 32:j.o.editable&&!l.activeCellEditor&&(l.Edit.call(l,a),j.o.Event.Cancel(a));break;case 45:j.o.editable&&!l.activeCellEditor&&(l.AddNewRow(),l.SetCommandEditor(j.o.editorCmdColIndex),j.o.Event.Cancel(a));break;case 46:j.o.editable&&!l.activeCellEditor&&(l.SubmitDeletedRows(),j.o.Event.Cancel(a));break;case 27:j.o.editable&&"cell"==j.o.editorModel&&l.activeCellEditor&&b(),j.o.editable&&"row"==j.o.editorModel&&b();break;default:j.o.editable&&j.o.editableOnKeystroke&&"cell"==j.o.editorModel&&"single"==j.o.selectionModel&&!l.activeCellEditor&&!l.activeRow&&(l.Edit.call(l,a),j.o.Event.Cancel(a)) +}j.o.editable&&"click"==j.o.openEditorAction&&l.Edit.call(l,a)}}}},EditTable.prototype={Init:function(){this.Css.Add(this.table,this.tableCss+" "+this.unselectableCss),this.Selection.Init(),this.Editable.Init()},GetCellsNb:function(a){var b=void 0===a?this.table.rows[this.startRow]:this.table.rows[a];return b.cells.length},GetRowsNb:function(){return this.table.rows.length},GetRow:function(a){return this.GetElement(a,"tr")},GetRowByIndex:function(a){return this.table.rows[a]},GetCell:function(a){return this.GetElement(a,"td")||this.GetElement(a,"th")},GetTableFromElement:function(a){if(!a)return null;for(;a.parentNode;){if("TABLE"===a.nodeName.UCase())return a;a=a.parentNode}return null},GetElement:function(a,b){for(var c,d=this.Event.GetElement(a);d.parentNode;){if(d.nodeName.UCase()===b.UCase()&&this.IsParentValid(d)){c=d;break}d=d.parentNode}return c},IsParentValid:function(a){for(;a.parentNode;){if("TABLE"===a.nodeName.UCase())return a.id==this.id?!0:!1;a=a.parentNode}return!1},IsSelectable:function(){return this.selection},IsEditable:function(){return this.editable},ClearSelections:function(){this.Selection.ClearSelections()},IsEditorType:function(a,b){return this.editorTypes[a]===b},IsObj:function(a){return a&&a.constructor==Object},IsFn:function(a){return a&&a.constructor==Function},IsArray:function(a){return a&&a.constructor==Array},Get:function(a){return document.getElementById(a)},Tag:function(a,b){return a?a.getElementsByTagName(b):null},GetText:function(a){if(!a)return"";var b=a.textContent||a.innerText||a.innerHTML.replace(/\<[^<>]+>/g,"");return b.replace(/^\s+/,"").replace(/\s+$/,"").Trim()},CreateElm:function(a){if(void 0!==a&&null!==a&&""!==a){var b=document.createElement(a);if(arguments.length>1)for(var c=0;cc?-1:c>d?1:0}}},"undefined"==typeof String.prototype.LCase&&(String.prototype.LCase=function(){return this.toLowerCase()}),"undefined"==typeof String.prototype.UCase&&(String.prototype.UCase=function(){return this.toUpperCase()}),"undefined"==typeof String.prototype.Trim&&(String.prototype.Trim=function(){return this.replace(/(^[\s\xA0]*)|([\s\xA0]*$)/g,"")}),"undefined"==typeof String.prototype.RegexpEscape&&(String.prototype.RegexpEscape=function(){function b(b){a=new RegExp("\\"+b,"g"),c=c.replace(a,"\\"+b)}var c=this;chars=new Array("\\","[","^","$",".","|","?","*","+","(",")","�");for(var d=0;dc;c++)if(this[c]===a)return c;return-1}); \ No newline at end of file diff --git a/dist/extensions/ezEditTable/themes/bg_mod_cell.png b/dist/extensions/ezEditTable/themes/bg_mod_cell.png new file mode 100644 index 0000000000000000000000000000000000000000..6ab2c15fcb42d9aa420da8079443e359d293f0dc GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^tRT$93?x4=o+|@V%*9TgAsieWw;%dH0CIT(d_r9R z|Nn11lL3O*S8`VX#aT*%{DK+I-2HE~DK-(v=PdAuEM{Qf76M_$OLy!300qTLTq8=H zi&7IyGV}8kLNaqx84OJI4b1fo4Nhntv+Q|j42xu7BaPR3Mn~MJWyz8U}WKvuxLVPkM-ButH#9I< F0{~gSY2E+; literal 0 HcmV?d00001 diff --git a/dist/extensions/ezEditTable/themes/icn_add.gif b/dist/extensions/ezEditTable/themes/icn_add.gif new file mode 100644 index 0000000000000000000000000000000000000000..77f6dcd425f52153439de6f23cf27ab1736b2569 GIT binary patch literal 398 zcmV;90df9ENk%w1VGsZi0M!5h|NsB}|NZ;^`uG3#@ci!c`||Gk?(p>T>GA2~@#E$0 z=i2Vt-|OJg>(bWc*xKXW*5cR8+0MSyzQ51IvB$Hl!n35srJ%W~mAIB`#ANDDlreB2Nblpc!oh zph{68!O#RMpNw$&Oddky3dRA9crC+a_GuEoyT++I zn$b9r%cFfhHe2K68PkBu*@^<$y+7xQ$wJ~;c5aBx$R=xq*41Wo zhwQus_VOgm0hughj}MhOvs#{>Vg09Y8WxjWUJY5YW zJ?&8eG!59Cz=|E%Ns@013KLWOLV)CObIIj_5{>{#k%TEAMs_GbdDV`x-iYsGH z#=Z{USAQA>NY(}X7=3{K8#zt08!*rEJmgVy&Y5^okTyr0PUxu5+_tIy*$hUYat4{I6T78~EIV0c!@ z@F9=+VLrqARL1L>3{T^YUnel$OJcYX&u}1#;Y>8clVFBBAqOeC|MxQ7+?ugt`>y|+7`ATN@qgyb z%d2BgFI{nR$+FX{qgSt9dveLNT`TI&E{*y>li|pGznL>L7U;PFa0Bc$|- zPfJu-Eih#;%??%<5t5Xf7ObJJE-xj@zR}5%!5RQXpKC|} literal 0 HcmV?d00001 diff --git a/dist/extensions/ezEditTable/themes/icn_save.gif b/dist/extensions/ezEditTable/themes/icn_save.gif new file mode 100644 index 0000000000000000000000000000000000000000..44dcc1df9f866f5c3b1a7c9f2547919655e7f1d2 GIT binary patch literal 375 zcmV--0f_!bNk%w1VGjTg0M!5h{QdsT%+=@T>eSciM0(ru_5X{DxI>@+KV;Q$!~dAj z{`LI-{`&6I(%QP#_&SOGP+z?5^8Z+v_+zR3smJUzZ{R>~(m9v^X1f1XXv0vH_>7w4 zSBBeZoAL4U^~THOQFzgGv+*-q$gRuo>hJ$vm+mEG)#vX2veERl!RNZZ*i?e@^ZNH& zea;;~=5dVIAye~gc`Dv$psm;e9& z|NsC0A^8LW002J#EC2ui01p5U000J*z@KnPEdDa0jB=@jh#*2ljO7C?t^l8BXA)Xu zI$y33Aw>!TTKD($h{>lDNf4@dWp2PY5~thQcs^Bob9G({4h|@bBO??P6MrBH6B3pZ z8X7nk2LwWs9RmV00|PTD51pSF9ReF43_1)04;P+4Agm288#*%rAGNoWB{c!Z0Sz?= VJ+}}XEe6ul1{?%XM%h9^06SH8y|(}W literal 0 HcmV?d00001 diff --git a/dist/extensions/ezEditTable/themes/icn_tick.png b/dist/extensions/ezEditTable/themes/icn_tick.png new file mode 100644 index 0000000000000000000000000000000000000000..a9925a06ab02db30c1e7ead9c701c15bc63145cb GIT binary patch literal 537 zcmV+!0_OdRP)Hs{AQG2a)rMyf zFQK~pm1x3+7!nu%-M`k}``c>^00{o_1pjWJUTfl8mg=3qGEl8H@}^@w`VUx0_$uy4 z2FhRqKX}xI*?Tv1DJd8z#F#0c%*~rM30HE1@2o5m~}ZyoWhqv>ql{V z1ZGE0lgcoK^lx+eqc*rAX1Ky;Xx3U%u#zG!m-;eD1Qsn@kf3|F9qz~|95=&g3(7!X zB}JAT>RU;a%vaNOGnJ%e1=K6eAh43c(QN8RQ6~GP%O}Jju$~Ld*%`mO1p*}t0i%SbLv(Fo(*ODSht1{LUkSqtR)>sFlI%{G5+8D_QDgx~`GRLofMiNu21{DE+@l z1Wo_Kr?&U@Po(CTFB%^{j@_JjdiunvV^_~jUzoeUwC~mI;=Ps@>CIcIVR^Zy=lK42 z{ryvW-X9(u?C5yZ+B!0lNQ{myjE!BoGdX#yv$L&jV&dYFSnT|jYlqH0Ij}Y~G(O(f z_u%^Q@ZB@<_$)g9Y8_$~D+r7PetIgrA=<-hPZu}6RpN>m&e*tT0 B8SMZ7 literal 0 HcmV?d00001 diff --git a/dist/filtergrid.css b/dist/filtergrid.css index 15bef554..b2e0025d 100644 --- a/dist/filtergrid.css +++ b/dist/filtergrid.css @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------ - TableFilter stylesheet by Max Guglielmi - - (build date: Sat Apr 04 2015 19:09:58) + - (build date: Mon Apr 06 2015 18:41:27) - Edit below for your projects' needs ------------------------------------------------------------------------*/ diff --git a/dist/tablefilter.js b/dist/tablefilter.js index da87345d..62400419 100644 --- a/dist/tablefilter.js +++ b/dist/tablefilter.js @@ -1,9499 +1,10 @@ - -(function (root, factory) { - if (typeof define === 'function' && define.amd) { - define(factory); - } else if (typeof exports === 'object') { - module.exports = factory; - } else { - root.TableFilter = factory(); - } -})(this, function() {/** - * @license almond 0.3.0 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved. - * Available via the MIT or new BSD license. - * see: http://github.com/jrburke/almond for details - */ -//Going sloppy to avoid 'use strict' string cost, but strict practices should -//be followed. -/*jslint sloppy: true */ -/*global setTimeout: false */ - -var requirejs, require, define; -(function (undef) { - var main, req, makeMap, handlers, - defined = {}, - waiting = {}, - config = {}, - defining = {}, - hasOwn = Object.prototype.hasOwnProperty, - aps = [].slice, - jsSuffixRegExp = /\.js$/; - - function hasProp(obj, prop) { - return hasOwn.call(obj, prop); - } - - /** - * Given a relative module name, like ./something, normalize it to - * a real name that can be mapped to a path. - * @param {String} name the relative name - * @param {String} baseName a real name that the name arg is relative - * to. - * @returns {String} normalized name - */ - function normalize(name, baseName) { - var nameParts, nameSegment, mapValue, foundMap, lastIndex, - foundI, foundStarMap, starI, i, j, part, - baseParts = baseName && baseName.split("/"), - map = config.map, - starMap = (map && map['*']) || {}; - - //Adjust any relative paths. - if (name && name.charAt(0) === ".") { - //If have a base name, try to normalize against it, - //otherwise, assume it is a top-level require that will - //be relative to baseUrl in the end. - if (baseName) { - //Convert baseName to array, and lop off the last part, - //so that . matches that "directory" and not name of the baseName's - //module. For instance, baseName of "one/two/three", maps to - //"one/two/three.js", but we want the directory, "one/two" for - //this normalization. - baseParts = baseParts.slice(0, baseParts.length - 1); - name = name.split('/'); - lastIndex = name.length - 1; - - // Node .js allowance: - if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) { - name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, ''); - } - - name = baseParts.concat(name); - - //start trimDots - for (i = 0; i < name.length; i += 1) { - part = name[i]; - if (part === ".") { - name.splice(i, 1); - i -= 1; - } else if (part === "..") { - if (i === 1 && (name[2] === '..' || name[0] === '..')) { - //End of the line. Keep at least one non-dot - //path segment at the front so it can be mapped - //correctly to disk. Otherwise, there is likely - //no path mapping for a path starting with '..'. - //This can still fail, but catches the most reasonable - //uses of .. - break; - } else if (i > 0) { - name.splice(i - 1, 2); - i -= 2; - } - } - } - //end trimDots - - name = name.join("/"); - } else if (name.indexOf('./') === 0) { - // No baseName, so this is ID is resolved relative - // to baseUrl, pull off the leading dot. - name = name.substring(2); - } - } - - //Apply map config if available. - if ((baseParts || starMap) && map) { - nameParts = name.split('/'); - - for (i = nameParts.length; i > 0; i -= 1) { - nameSegment = nameParts.slice(0, i).join("/"); - - if (baseParts) { - //Find the longest baseName segment match in the config. - //So, do joins on the biggest to smallest lengths of baseParts. - for (j = baseParts.length; j > 0; j -= 1) { - mapValue = map[baseParts.slice(0, j).join('/')]; - - //baseName segment has config, find if it has one for - //this name. - if (mapValue) { - mapValue = mapValue[nameSegment]; - if (mapValue) { - //Match, update name to the new value. - foundMap = mapValue; - foundI = i; - break; - } - } - } - } - - if (foundMap) { - break; - } - - //Check for a star map match, but just hold on to it, - //if there is a shorter segment match later in a matching - //config, then favor over this star map. - if (!foundStarMap && starMap && starMap[nameSegment]) { - foundStarMap = starMap[nameSegment]; - starI = i; - } - } - - if (!foundMap && foundStarMap) { - foundMap = foundStarMap; - foundI = starI; - } - - if (foundMap) { - nameParts.splice(0, foundI, foundMap); - name = nameParts.join('/'); - } - } - - return name; - } - - function makeRequire(relName, forceSync) { - return function () { - //A version of a require function that passes a moduleName - //value for items that may need to - //look up paths relative to the moduleName - var args = aps.call(arguments, 0); - - //If first arg is not require('string'), and there is only - //one arg, it is the array form without a callback. Insert - //a null so that the following concat is correct. - if (typeof args[0] !== 'string' && args.length === 1) { - args.push(null); - } - return req.apply(undef, args.concat([relName, forceSync])); - }; - } - - function makeNormalize(relName) { - return function (name) { - return normalize(name, relName); - }; - } - - function makeLoad(depName) { - return function (value) { - defined[depName] = value; - }; - } - - function callDep(name) { - if (hasProp(waiting, name)) { - var args = waiting[name]; - delete waiting[name]; - defining[name] = true; - main.apply(undef, args); - } - - if (!hasProp(defined, name) && !hasProp(defining, name)) { - throw new Error('No ' + name); - } - return defined[name]; - } - - //Turns a plugin!resource to [plugin, resource] - //with the plugin being undefined if the name - //did not have a plugin prefix. - function splitPrefix(name) { - var prefix, - index = name ? name.indexOf('!') : -1; - if (index > -1) { - prefix = name.substring(0, index); - name = name.substring(index + 1, name.length); - } - return [prefix, name]; - } - - /** - * Makes a name map, normalizing the name, and using a plugin - * for normalization if necessary. Grabs a ref to plugin - * too, as an optimization. - */ - makeMap = function (name, relName) { - var plugin, - parts = splitPrefix(name), - prefix = parts[0]; - - name = parts[1]; - - if (prefix) { - prefix = normalize(prefix, relName); - plugin = callDep(prefix); - } - - //Normalize according - if (prefix) { - if (plugin && plugin.normalize) { - name = plugin.normalize(name, makeNormalize(relName)); - } else { - name = normalize(name, relName); - } - } else { - name = normalize(name, relName); - parts = splitPrefix(name); - prefix = parts[0]; - name = parts[1]; - if (prefix) { - plugin = callDep(prefix); - } - } - - //Using ridiculous property names for space reasons - return { - f: prefix ? prefix + '!' + name : name, //fullName - n: name, - pr: prefix, - p: plugin - }; - }; - - function makeConfig(name) { - return function () { - return (config && config.config && config.config[name]) || {}; - }; - } - - handlers = { - require: function (name) { - return makeRequire(name); - }, - exports: function (name) { - var e = defined[name]; - if (typeof e !== 'undefined') { - return e; - } else { - return (defined[name] = {}); - } - }, - module: function (name) { - return { - id: name, - uri: '', - exports: defined[name], - config: makeConfig(name) - }; - } - }; - - main = function (name, deps, callback, relName) { - var cjsModule, depName, ret, map, i, - args = [], - callbackType = typeof callback, - usingExports; - - //Use name if no relName - relName = relName || name; - - //Call the callback to define the module, if necessary. - if (callbackType === 'undefined' || callbackType === 'function') { - //Pull out the defined dependencies and pass the ordered - //values to the callback. - //Default to [require, exports, module] if no deps - deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps; - for (i = 0; i < deps.length; i += 1) { - map = makeMap(deps[i], relName); - depName = map.f; - - //Fast path CommonJS standard dependencies. - if (depName === "require") { - args[i] = handlers.require(name); - } else if (depName === "exports") { - //CommonJS module spec 1.1 - args[i] = handlers.exports(name); - usingExports = true; - } else if (depName === "module") { - //CommonJS module spec 1.1 - cjsModule = args[i] = handlers.module(name); - } else if (hasProp(defined, depName) || - hasProp(waiting, depName) || - hasProp(defining, depName)) { - args[i] = callDep(depName); - } else if (map.p) { - map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {}); - args[i] = defined[depName]; - } else { - throw new Error(name + ' missing ' + depName); - } - } - - ret = callback ? callback.apply(defined[name], args) : undefined; - - if (name) { - //If setting exports via "module" is in play, - //favor that over return value and exports. After that, - //favor a non-undefined return value over exports use. - if (cjsModule && cjsModule.exports !== undef && - cjsModule.exports !== defined[name]) { - defined[name] = cjsModule.exports; - } else if (ret !== undef || !usingExports) { - //Use the return value from the function. - defined[name] = ret; - } - } - } else if (name) { - //May just be an object definition for the module. Only - //worry about defining if have a module name. - defined[name] = callback; - } - }; - - requirejs = require = req = function (deps, callback, relName, forceSync, alt) { - if (typeof deps === "string") { - if (handlers[deps]) { - //callback in this case is really relName - return handlers[deps](callback); - } - //Just return the module wanted. In this scenario, the - //deps arg is the module name, and second arg (if passed) - //is just the relName. - //Normalize module name, if it contains . or .. - return callDep(makeMap(deps, callback).f); - } else if (!deps.splice) { - //deps is a config object, not an array. - config = deps; - if (config.deps) { - req(config.deps, config.callback); - } - if (!callback) { - return; - } - - if (callback.splice) { - //callback is an array, which means it is a dependency list. - //Adjust args if there are dependencies - deps = callback; - callback = relName; - relName = null; - } else { - deps = undef; - } - } - - //Support require(['a']) - callback = callback || function () {}; - - //If relName is a function, it is an errback handler, - //so remove it. - if (typeof relName === 'function') { - relName = forceSync; - forceSync = alt; - } - - //Simulate async callback; - if (forceSync) { - main(undef, deps, callback, relName); - } else { - //Using a non-zero value because of concern for what old browsers - //do, and latest browsers "upgrade" to 4 if lower value is used: - //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout: - //If want a value immediately, use require('id') instead -- something - //that works in almond on the global level, but not guaranteed and - //unlikely to work in other AMD implementations. - setTimeout(function () { - main(undef, deps, callback, relName); - }, 4); - } - - return req; - }; - - /** - * Just drops the config on the floor, but returns req in case - * the config return value is used. - */ - req.config = function (cfg) { - return req(cfg); - }; - - /** - * Expose module registry for debugging and tooling - */ - requirejs._defined = defined; - - define = function (name, deps, callback) { - - //This module may not have dependencies - if (!deps.splice) { - //deps is not an array, so probably means - //an object literal or factory function for - //the value. Adjust args. - callback = deps; - deps = []; - } - - if (!hasProp(defined, name) && !hasProp(waiting, name)) { - waiting[name] = [name, deps, callback]; - } - }; - - define.amd = { - jQuery: true - }; -}()); - -define("../libs/almond/almond", function(){}); - -define('event',["exports"], function (exports) { - - - /** - * DOM event utilities - */ - - var Event = { - add: function add(obj, type, func, capture) { - if (obj.addEventListener) { - obj.addEventListener(type, func, capture); - } else if (obj.attachEvent) { - obj.attachEvent("on" + type, func); - } else { - obj["on" + type] = func; - } - }, - remove: function remove(obj, type, func, capture) { - if (obj.detachEvent) { - obj.detachEvent("on" + type, func); - } else if (obj.removeEventListener) { - obj.removeEventListener(type, func, capture); - } else { - obj["on" + type] = null; - } - }, - stop: function stop(evt) { - if (!evt) { - evt = window.event; - } - if (evt.stopPropagation) { - evt.stopPropagation(); - } else { - evt.cancelBubble = true; - } - }, - cancel: function cancel(evt) { - if (!evt) { - evt = window.event; - } - if (evt.preventDefault) { - evt.preventDefault(); - } else { - evt.returnValue = false; - } - } - }; - - exports.Event = Event; -}); -//# sourceMappingURL=event.js.map; -define('dom',["exports"], function (exports) { - - - /** - * DOM utilities - */ - - var Dom = {}; - - /** - * Returns text + text of children of given node - * @param {NodeElement} node - * @return {String} - */ - Dom.getText = function (node) { - var s = node.textContent || node.innerText || node.innerHTML.replace(/<[^<>]+>/g, ""); - s = s.replace(/^\s+/, "").replace(/\s+$/, ""); - return s; - }; - - /** - * Creates an html element with given collection of attributes - * @param {String} tag a string of the html tag to create - * @param {Array} an undetermined number of arrays containing the with 2 - * items, the attribute name and its value ['id','myId'] - * @return {Object} created element - */ - Dom.create = function (tag) { - if (!tag || tag === "") { - return; - } - - var el = document.createElement(tag), - args = arguments; - - if (args.length > 1) { - for (var i = 0; i < args.length; i++) { - var argtype = typeof args[i]; - if (argtype.toLowerCase() === "object" && args[i].length === 2) { - el.setAttribute(args[i][0], args[i][1]); - } - } - } - return el; - }; - - /** - * Returns a text node with given text - * @param {String} text - * @return {Object} - */ - Dom.text = function (text) { - return document.createTextNode(text); - }; - - /** - * Returns offset position of passed element - * @param {object} obj [description] - * @return {object} literal object with left and top values - */ - Dom.position = function (obj) { - var l = 0, - t = 0; - if (obj && obj.offsetParent) { - do { - l += obj.offsetLeft; - t += obj.offsetTop; - } while (obj == obj.offsetParent); - } - return { left: l, top: t }; - }; - - Dom.hasClass = function (ele, cls) { - if (!ele) { - return false; - } - - if (supportsClassList()) { - return ele.classList.contains(cls); - } - return ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)")); - }; - - Dom.addClass = function (ele, cls) { - if (!ele) { - return; - } - - if (supportsClassList()) { - ele.classList.add(cls); - return; - } - - if (ele.className === "") { - ele.className = cls; - } else if (!this.hasClass(ele, cls)) { - ele.className += " " + cls; - } - }; - - Dom.removeClass = function (ele, cls) { - if (!ele) { - return; - } - - if (supportsClassList()) { - ele.classList.remove(cls); - return; - } - var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)", "g"); - ele.className = ele.className.replace(reg, ""); - }; - - /** - * Creates and returns an option element - * @param {String} text option text - * @param {String} value option value - * @param {Boolean} isSel whether option is selected - * @return {Object} option element - */ - Dom.createOpt = function (text, value, isSel) { - var isSelected = isSel ? true : false, - opt = isSelected ? this.create("option", ["value", value], ["selected", "true"]) : this.create("option", ["value", value]); - opt.appendChild(this.text(text)); - return opt; - }; - - /** - * Creates and returns a checklist item - * @param {Number} chkIndex index of check item - * @param {String} chkValue check item value - * @param {String} labelText check item label text - * @return {Object} li DOM element - */ - Dom.createCheckItem = function (chkIndex, chkValue, labelText) { - var li = this.create("li"), - label = this.create("label", ["for", chkIndex]), - check = this.create("input", ["id", chkIndex], ["name", chkIndex], ["type", "checkbox"], ["value", chkValue]); - label.appendChild(check); - label.appendChild(this.text(labelText)); - li.appendChild(label); - li.label = label; - li.check = check; - return li; - }; - - Dom.id = function (id) { - return document.getElementById(id); - }; - - Dom.tag = function (o, tagname) { - return o.getElementsByTagName(tagname); - }; - - // HTML5 classList API - function supportsClassList() { - return document.documentElement.classList; - } - - exports.Dom = Dom; -}); -//# sourceMappingURL=dom.js.map; -define('string',["exports"], function (exports) { - - - /** - * String utilities - */ - - var Str = {}; - - Str.lower = function (text) { - return text.toLowerCase(); - }; - - Str.upper = function (text) { - return text.toUpperCase(); - }; - - Str.trim = function (text) { - if (text.trim) { - return text.trim(); - } - return text.replace(/^\s*|\s*$/g, ""); - }; - - Str.isEmpty = function (text) { - return this.trim(text) === ""; - }; - - Str.rgxEsc = function (text) { - function escape(e) { - var a = new RegExp("\\" + e, "g"); - text = text.replace(a, "\\" + e); - } - - var chars = ["\\", "[", "^", "$", ".", "|", "?", "*", "+", "(", ")"]; - for (var e = 0; e < chars.length; e++) { - escape(chars[e]); - } - return text; - }; - - Str.matchCase = function (text, mc) { - if (!mc) { - return this.lower(text); - } - return text; - }; - - exports.Str = Str; -}); -//# sourceMappingURL=string.js.map; -define('cookie',["exports"], function (exports) { - - - /** - * Cookie utilities - */ - - var Cookie = {}; - - Cookie.write = function (name, value, hours) { - var expire = ""; - if (hours) { - expire = new Date(new Date().getTime() + hours * 3600000); - expire = "; expires=" + expire.toGMTString(); - } - document.cookie = name + "=" + escape(value) + expire; - }; - - Cookie.read = function (name) { - var cookieValue = "", - search = name + "="; - if (document.cookie.length > 0) { - var cookie = document.cookie, - offset = cookie.indexOf(search); - if (offset !== -1) { - offset += search.length; - var end = cookie.indexOf(";", offset); - if (end === -1) { - end = cookie.length; - } - cookieValue = unescape(cookie.substring(offset, end)); - } - } - return cookieValue; - }; - - Cookie.remove = function (name) { - this.write(name, "", -1); - }; - - Cookie.valueToArray = function (name, separator) { - if (!separator) { - separator = ","; - } - //reads the cookie - var val = this.read(name); - //creates an array with filters' values - var arr = val.split(separator); - return arr; - }; - - Cookie.getValueByIndex = function (name, index, separator) { - if (!separator) { - separator = ","; - } - //reads the cookie - var val = this.valueToArray(name, separator); - return val[index]; - }; - - exports.Cookie = Cookie; -}); -//# sourceMappingURL=cookie.js.map; -define('types',["exports"], function (exports) { - - - /** - * Types utilities - */ - - var Types = {}; - - var UNDEFINED = void 0; - - /** - * Checks if var exists and is an object - * @param {String or Object} v - * @return {Boolean} - */ - Types.isObj = function (v) { - var isO = false; - if (typeof v === "string") { - if (window[v] && typeof window[v] === "object") { - isO = true; - } - } else { - if (v && typeof v === "object") { - isO = true; - } - } - return isO; - }; - - /** - * Checks if passed parameter is a function - * @param {Function} fn - * @return {Boolean} - */ - Types.isFn = function (fn) { - return fn && fn.constructor == Function; - }; - - /** - * Checks if passed param is an array - * @param {Array} obj - * @return {Boolean} - */ - Types.isArray = function (obj) { - return obj && obj.constructor == Array; - }; - - /** - * Determines if passed param is undefined - * @param {Any} o - * @return {Boolean} - */ - Types.isUndef = function (o) { - return o === UNDEFINED; - }; - - exports.Types = Types; -}); -//# sourceMappingURL=types.js.map; -define('array',["exports", "string"], function (exports, _string) { - - - /** - * Array utilities - */ - - var Str = _string.Str; - - var Arr = { - has: function has(arr, val, caseSensitive) { - var sCase = caseSensitive === undefined ? false : caseSensitive; - for (var i = 0; i < arr.length; i++) { - if (Str.matchCase(arr[i].toString(), sCase) == val) { - return true; - } - } - return false; - }, - indexByValue: function indexByValue(arr, val, caseSensitive) { - var sCase = caseSensitive === undefined ? false : caseSensitive; - for (var i = 0; i < arr.length; i++) { - if (Str.matchCase(arr[i].toString(), sCase) == val) { - return i; - } - } - return -1; - } - }; - - exports.Arr = Arr; -}); -//# sourceMappingURL=array.js.map; -define('helpers',["exports"], function (exports) { - - - /** - * Misc helpers - */ - - var Helpers = { - isIE: function isIE() { - return /msie|MSIE/.test(navigator.userAgent); - }, - - removeNbFormat: function removeNbFormat(data, format) { - if (!data) { - return; - } - if (!format) { - format = "us"; - } - var n = data; - if (str.lower(format) === "us") { - n = +n.replace(/[^\d\.-]/g, ""); - } else { - n = +n.replace(/[^\d\,-]/g, "").replace(",", "."); - } - return n; - } - }; - - exports.Helpers = Helpers; -}); -//# sourceMappingURL=helpers.js.map; -define('date',["exports"], function (exports) { - - - /** - * Date utilities - */ - - var DateHelper = { - isValid: function isValid(dateStr, format) { - if (!format) { - format = "DMY"; - } - format = format.toUpperCase(); - if (format.length != 3) { - if (format === "DDMMMYYYY") { - var d = this.format(dateStr, format); - dateStr = d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear(); - format = "DMY"; - } - } - if (format.indexOf("M") === -1 || format.indexOf("D") === -1 || format.indexOf("Y") === -1) { - format = "DMY"; - } - var reg1, reg2; - // If the year is first - if (format.substring(0, 1) == "Y") { - reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/; - reg2 = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/; - } else if (format.substring(1, 2) == "Y") { - // If the year is second - reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/; - reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/; - } else { - // The year must be third - reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/; - reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/; - } - // If it doesn't conform to the right format (with either a 2 digit year or - // 4 digit year), fail - if (reg1.test(dateStr) === false && reg2.test(dateStr) === false) { - return false; - } - // Split into 3 parts based on what the divider was - var parts = dateStr.split(RegExp.$1); - var mm, dd, yy; - // Check to see if the 3 parts end up making a valid date - if (format.substring(0, 1) === "M") { - mm = parts[0]; - } else if (format.substring(1, 2) === "M") { - mm = parts[1]; - } else { - mm = parts[2]; - } - if (format.substring(0, 1) === "D") { - dd = parts[0]; - } else if (format.substring(1, 2) === "D") { - dd = parts[1]; - } else { - dd = parts[2]; - } - if (format.substring(0, 1) === "Y") { - yy = parts[0]; - } else if (format.substring(1, 2) === "Y") { - yy = parts[1]; - } else { - yy = parts[2]; - } - if (parseInt(yy, 10) <= 50) { - yy = (parseInt(yy, 10) + 2000).toString(); - } - if (parseInt(yy, 10) <= 99) { - yy = (parseInt(yy, 10) + 1900).toString(); - } - var dt = new Date(parseInt(yy, 10), parseInt(mm, 10) - 1, parseInt(dd, 10), 0, 0, 0, 0); - if (parseInt(dd, 10) != dt.getDate()) { - return false; - } - if (parseInt(mm, 10) - 1 != dt.getMonth()) { - return false; - } - return true; - }, - format: (function (_format) { - var _formatWrapper = function format(_x, _x2) { - return _format.apply(this, arguments); - }; - - _formatWrapper.toString = function () { - return _format.toString(); - }; - - return _formatWrapper; - })(function (dateStr, format) { - if (!format) { - format = "DMY"; - } - if (!dateStr || dateStr === "") { - return new Date(1001, 0, 1); - } - var oDate, parts; - - function y2kDate(yr) { - if (yr === undefined) { - return 0; - } - if (yr.length > 2) { - return yr; - } - var y; - //>50 belong to 1900 - if (yr <= 99 && yr > 50) { - y = "19" + yr; - } - //<50 belong to 2000 - if (yr < 50 || yr === "00") { - y = "20" + yr; - } - return y; - } - - function mmm2mm(mmm) { - if (mmm === undefined) { - return 0; - } - var mondigit; - var MONTH_NAMES = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december", "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]; - for (var m_i = 0; m_i < MONTH_NAMES.length; m_i++) { - var month_name = MONTH_NAMES[m_i]; - if (mmm.toLowerCase() === month_name) { - mondigit = m_i + 1; - break; - } - } - if (mondigit > 11 || mondigit < 23) { - mondigit = mondigit - 12; - } - if (mondigit < 1 || mondigit > 12) { - return 0; - } - return mondigit; - } - - switch (format.toUpperCase()) { - case "DDMMMYYYY": - parts = dateStr.replace(/[- \/.]/g, " ").split(" "); - oDate = new Date(y2kDate(parts[2]), mmm2mm(parts[1]) - 1, parts[0]); - break; - case "DMY": - parts = dateStr.replace(/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/, "$1 $3 $5").split(" "); - oDate = new Date(y2kDate(parts[2]), parts[1] - 1, parts[0]); - break; - case "MDY": - parts = dateStr.replace(/^(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])([- \/.])((\d\d)?\d\d)$/, "$1 $3 $5").split(" "); - oDate = new Date(y2kDate(parts[2]), parts[0] - 1, parts[1]); - break; - case "YMD": - parts = dateStr.replace(/^((\d\d)?\d\d)([- \/.])(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])$/, "$1 $4 $6").split(" "); - oDate = new Date(y2kDate(parts[0]), parts[1] - 1, parts[2]); - break; - default: - //in case format is not correct - parts = dateStr.replace(/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/, "$1 $3 $5").split(" "); - oDate = new Date(y2kDate(parts[2]), parts[1] - 1, parts[0]); - break; - } - return oDate; - }) - }; - - exports.DateHelper = DateHelper; -}); -//# sourceMappingURL=date.js.map; -define('sort',["exports", "string"], function (exports, _string) { - - - /** - * Sort helpers - */ - - var Str = _string.Str; - - var Sort = { - ignoreCase: function ignoreCase(a, b) { - var x = Str.lower(a); - var y = Str.lower(b); - return x < y ? -1 : x > y ? 1 : 0; - } - }; - - exports.Sort = Sort; -}); -//# sourceMappingURL=sort.js.map; -define('modules/store',["exports", "../cookie"], function (exports, _cookie) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Cookie = _cookie.Cookie; - - var Store = exports.Store = (function () { - - /** - * Store, persistence manager - * @param {Object} tf TableFilter instance - */ - - function Store(tf) { - _classCallCheck(this, Store); - - var f = tf.config(); - - this.duration = !isNaN(f.set_cookie_duration) ? parseInt(f.set_cookie_duration, 10) : 100000; - - this.tf = tf; - } - - _prototypeProperties(Store, null, { - saveFilterValues: { - - /** - * Store filters' values in cookie - * @param {String} cookie name - */ - - value: function saveFilterValues(name) { - var tf = this.tf; - var fltValues = []; - //store filters' values - for (var i = 0; i < tf.fltIds.length; i++) { - var value = tf.getFilterValue(i); - if (value === "") { - value = " "; - } - fltValues.push(value); - } - //adds array size - fltValues.push(tf.fltIds.length); - - //writes cookie - Cookie.write(name, fltValues.join(tf.separator), this.duration); - }, - writable: true, - configurable: true - }, - getFilterValues: { - - /** - * Retrieve filters' values from cookie - * @param {String} cookie name - * @return {Array} - */ - - value: function getFilterValues(name) { - var flts = Cookie.read(name); - var rgx = new RegExp(this.tf.separator, "g"); - // filters' values array - return flts.split(rgx); - }, - writable: true, - configurable: true - }, - savePageNb: { - - /** - * Store page number in cookie - * @param {String} cookie name - */ - - value: function savePageNb(name) { - Cookie.write(name, this.tf.Cpt.paging.currentPageNb, this.duration); - }, - writable: true, - configurable: true - }, - getPageNb: { - - /** - * Retrieve page number from cookie - * @param {String} cookie name - * @return {String} - */ - - value: function getPageNb(name) { - return Cookie.read(name); - }, - writable: true, - configurable: true - }, - savePageLength: { - - /** - * Store page length in cookie - * @param {String} cookie name - */ - - value: function savePageLength(name) { - Cookie.write(name, this.tf.Cpt.paging.resultsPerPageSlc.selectedIndex, this.duration); - }, - writable: true, - configurable: true - }, - getPageLength: { - - /** - * Retrieve page length from cookie - * @param {String} cookie name - * @return {String} - */ - - value: function getPageLength(name) { - return Cookie.read(name); - }, - writable: true, - configurable: true - } - }); - - return Store; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=store.js.map; -define('modules/gridLayout',["exports", "../dom", "../types", "../helpers", "../event"], function (exports, _dom, _types, _helpers, _event) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - var Types = _types.Types; - var Helpers = _helpers.Helpers; - var Event = _event.Event; - - var GridLayout = exports.GridLayout = (function () { - - /** - * Grid layout, table with fixed headers - * @param {Object} tf TableFilter instance - */ - - function GridLayout(tf) { - _classCallCheck(this, GridLayout); - - var f = tf.config(); - - //defines grid width - this.gridWidth = f.grid_width || null; - //defines grid height - this.gridHeight = f.grid_height || null; - //defines css class for main container - this.gridMainContCssClass = f.grid_cont_css_class || "grd_Cont"; - //defines css class for div containing table - this.gridContCssClass = f.grid_tbl_cont_css_class || "grd_tblCont"; - //defines css class for div containing headers' table - this.gridHeadContCssClass = f.grid_tblHead_cont_css_class || "grd_headTblCont"; - //defines css class for div containing rows counter, paging etc. - this.gridInfDivCssClass = f.grid_inf_grid_css_class || "grd_inf"; - //defines which row contains column headers - this.gridHeadRowIndex = f.grid_headers_row_index || 0; - //array of headers row indexes to be placed in header table - this.gridHeadRows = f.grid_headers_rows || [0]; - //generate filters in table headers - this.gridEnableFilters = f.grid_enable_default_filters !== undefined ? f.grid_enable_default_filters : true; - //default col width - this.gridDefaultColWidth = f.grid_default_col_width || "100px"; - //enables/disables columns resizer - this.gridEnableColResizer = f.grid_enable_cols_resizer !== undefined ? f.grid_enable_cols_resizer : false; - //defines col resizer script path - this.gridColResizerPath = f.grid_cont_col_resizer_path || this.basePath + "TFExt_ColsResizer/TFExt_ColsResizer.js"; - - this.gridColElms = []; - - this.tf = tf; - } - - _prototypeProperties(GridLayout, null, { - init: { - - /** - * Generates a grid with fixed headers - */ - - value: function init() { - var tf = this.tf; - var f = tf.config(); - var tbl = tf.tbl; - - if (!tf.gridLayout) { - return; - } - - tf.isExternalFlt = true; - - // default width of 100px if column widths not set - if (!tf.hasColWidth) { - tf.colWidth = []; - for (var k = 0; k < tf.nbCells; k++) { - var colW, - cell = tbl.rows[this.gridHeadRowIndex].cells[k]; - if (cell.width !== "") { - colW = cell.width; - } else if (cell.style.width !== "") { - colW = parseInt(cell.style.width, 10); - } else { - colW = this.gridDefaultColWidth; - } - tf.colWidth[k] = colW; - } - tf.hasColWidth = true; - } - tf.setColWidths(this.gridHeadRowIndex); - - var tblW; //initial table width - if (tbl.width !== "") { - tblW = tbl.width; - } else if (tbl.style.width !== "") { - tblW = parseInt(tbl.style.width, 10); - } else { - tblW = tbl.clientWidth; - } - - //Main container: it will contain all the elements - this.tblMainCont = Dom.create("div", ["id", tf.prfxMainTblCont + tf.id]); - this.tblMainCont.className = this.gridMainContCssClass; - if (this.gridWidth) { - this.tblMainCont.style.width = this.gridWidth; - } - tbl.parentNode.insertBefore(this.tblMainCont, tbl); - - //Table container: div wrapping content table - this.tblCont = Dom.create("div", ["id", tf.prfxTblCont + tf.id]); - this.tblCont.className = this.gridContCssClass; - if (this.gridWidth) { - this.tblCont.style.width = this.gridWidth; - } - if (this.gridHeight) { - this.tblCont.style.height = this.gridHeight; - } - tbl.parentNode.insertBefore(this.tblCont, tbl); - var t = tbl.parentNode.removeChild(tbl); - this.tblCont.appendChild(t); - - //In case table width is expressed in % - if (tbl.style.width === "") { - tbl.style.width = (tf._containsStr("%", tblW) ? tbl.clientWidth : tblW) + "px"; - } - - var d = this.tblCont.parentNode.removeChild(this.tblCont); - this.tblMainCont.appendChild(d); - - //Headers table container: div wrapping headers table - this.headTblCont = Dom.create("div", ["id", tf.prfxHeadTblCont + tf.id]); - this.headTblCont.className = this.gridHeadContCssClass; - if (this.gridWidth) { - this.headTblCont.style.width = this.gridWidth; - } - - //Headers table - this.headTbl = Dom.create("table", ["id", tf.prfxHeadTbl + tf.id]); - var tH = Dom.create("tHead"); //IE<7 needs it - - //1st row should be headers row, ids are added if not set - //Those ids are used by the sort feature - var hRow = tbl.rows[this.gridHeadRowIndex]; - var sortTriggers = []; - for (var n = 0; n < tf.nbCells; n++) { - var c = hRow.cells[n]; - var thId = c.getAttribute("id"); - if (!thId || thId === "") { - thId = tf.prfxGridTh + n + "_" + tf.id; - c.setAttribute("id", thId); - } - sortTriggers.push(thId); - } - - //Filters row is created - var filtersRow = Dom.create("tr"); - if (this.gridEnableFilters && tf.fltGrid) { - tf.externalFltTgtIds = []; - for (var j = 0; j < tf.nbCells; j++) { - var fltTdId = tf.prfxFlt + j + tf.prfxGridFltTd + tf.id; - var cl = Dom.create(tf.fltCellTag, ["id", fltTdId]); - filtersRow.appendChild(cl); - tf.externalFltTgtIds[j] = fltTdId; - } - } - //Headers row are moved from content table to headers table - for (var i = 0; i < this.gridHeadRows.length; i++) { - var headRow = tbl.rows[this.gridHeadRows[0]]; - tH.appendChild(headRow); - } - this.headTbl.appendChild(tH); - if (tf.filtersRowIndex === 0) { - tH.insertBefore(filtersRow, hRow); - } else { - tH.appendChild(filtersRow); - } - - this.headTblCont.appendChild(this.headTbl); - this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont); - - //THead needs to be removed in content table for sort feature - var thead = Dom.tag(tbl, "thead"); - if (thead.length > 0) { - tbl.removeChild(thead[0]); - } - - //Headers table style - this.headTbl.style.width = tbl.style.width; - this.headTbl.style.tableLayout = "fixed"; - tbl.style.tableLayout = "fixed"; - this.headTbl.cellPadding = tbl.cellPadding; - this.headTbl.cellSpacing = tbl.cellSpacing; - - //content table without headers needs col widths to be reset - tf.setColWidths(); - - //Headers container width - this.headTblCont.style.width = this.tblCont.clientWidth + "px"; - - tbl.style.width = ""; - - //scroll synchronisation - var o = this; - - Event.add(this.tblCont, "scroll", function (evt) { - //this = scroll element - var scrollLeft = this.scrollLeft; - o.headTblCont.scrollLeft = scrollLeft; - //New pointerX calc taking into account scrollLeft - if (!o.isPointerXOverwritten) { - try { - o.Evt.pointerX = function (evt) { - var e = evt || global.event; - var bdScrollLeft = tf_StandardBody().scrollLeft + scrollLeft; - return e.pageX + scrollLeft || e.clientX + bdScrollLeft; - }; - o.isPointerXOverwritten = true; - } catch (err) { - o.isPointerXOverwritten = false; - } - } - }); - - //Sort is enabled if not specified in config object - if (f.sort !== false) { - tf.sort = true; - tf.sortConfig.asyncSort = true; - tf.sortConfig.triggerIds = sortTriggers; - } - - if (this.gridEnableColResizer) { - if (!tf.hasExtensions) { - tf.extensions = { - name: ["ColumnsResizer_" + tf.id], - src: [this.gridColResizerPath], - description: ["Columns Resizing"], - initialize: [function (o) { - o.SetColsResizer("ColumnsResizer_" + o.id); - }] - }; - tf.hasExtensions = true; - } else { - if (!tf._containsStr("colsresizer", Str.lower(tf.extensions.src.toString()))) { - tf.extensions.name.push("ColumnsResizer_" + tf.id); - tf.extensions.src.push(tf.gridColResizerPath); - tf.extensions.description.push("Columns Resizing"); - tf.extensions.initialize.push(function (o) { - o.SetColsResizer("ColumnsResizer_" + o.id); - }); - } - } - } - - //Default columns resizer properties for grid layout - f.col_resizer_cols_headers_table = this.headTbl.getAttribute("id"); - f.col_resizer_cols_headers_index = this.gridHeadRowIndex; - f.col_resizer_width_adjustment = 0; - f.col_enable_text_ellipsis = false; - - //Cols generation for all browsers excepted IE<=7 - o.tblHasColTag = Dom.tag(tbl, "col").length > 0 ? true : false; - - //Col elements are enough to keep column widths after sorting and - //filtering - var createColTags = function createColTags(o) { - if (!o) { - return; - } - for (var k = tf.nbCells - 1; k >= 0; k--) { - var col = Dom.create("col", ["id", tf.id + "_col_" + k]); - tbl.firstChild.parentNode.insertBefore(col, tbl.firstChild); - col.style.width = tf.colWidth[k]; - o.gridColElms[k] = col; - } - o.tblHasColTag = true; - }; - if (!o.tblHasColTag) { - createColTags(o); - } else { - var cols = Dom.tag(tbl, "col"); - for (var ii = 0; ii < tf.nbCells; ii++) { - cols[ii].setAttribute("id", tf.id + "_col_" + ii); - cols[ii].style.width = tf.colWidth[ii]; - o.gridColElms.push(cols[ii]); - } - } - - var afterColResizedFn = Types.isFn(f.on_after_col_resized) ? f.on_after_col_resized : null; - f.on_after_col_resized = function (o, colIndex) { - if (!colIndex) { - return; - } - var w = o.crWColsRow.cells[colIndex].style.width; - var col = o.gridColElms[colIndex]; - col.style.width = w; - - var thCW = o.crWColsRow.cells[colIndex].clientWidth; - var tdCW = o.crWRowDataTbl.cells[colIndex].clientWidth; - - if (thCW != tdCW /*&& !Helpers.isIE()*/) { - o.headTbl.style.width = tbl.clientWidth + "px"; - } - - if (afterColResizedFn) { - afterColResizedFn.call(null, o, colIndex); - } - }; - - if (tbl.clientWidth !== this.headTbl.clientWidth) { - tbl.style.width = this.headTbl.clientWidth + "px"; - } - - // Re-adjust reference row - //tf.refRow = Helpers.isIE() ? (tf.refRow+1) : 0; - }, - writable: true, - configurable: true - }, - destroy: { - - /** - * Removes the grid layout - */ - - value: function destroy() { - var tf = this.tf; - var tbl = tf.tbl; - - if (!tf.gridLayout) { - return; - } - var t = tbl.parentNode.removeChild(tbl); - this.tblMainCont.parentNode.insertBefore(t, this.tblMainCont); - this.tblMainCont.parentNode.removeChild(this.tblMainCont); - - this.tblMainCont = null; - this.headTblCont = null; - this.headTbl = null; - this.tblCont = null; - - tbl.outerHTML = tf.sourceTblHtml; - //needed to keep reference of table element - tbl = Dom.id(tf.id); - }, - writable: true, - configurable: true - } - }); - - return GridLayout; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=gridLayout.js.map; -define('modules/loader',["exports", "../dom", "../types"], function (exports, _dom, _types) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - var Types = _types.Types; - - var global = window; - - /** - * Loading message/spinner - * @param {Object} tf TableFilter instance - */ - - var Loader = exports.Loader = (function () { - function Loader(tf) { - _classCallCheck(this, Loader); - - // TableFilter configuration - var f = tf.config(); - //id of container element - this.loaderTgtId = f.loader_target_id || null; - //div containing loader - this.loaderDiv = null; - //defines loader text - this.loaderText = f.loader_text || "Loading..."; - //defines loader innerHtml - this.loaderHtml = f.loader_html || null; - //defines css class for loader div - this.loaderCssClass = f.loader_css_class || "loader"; - //delay for hiding loader - this.loaderCloseDelay = 200; - //callback function before loader is displayed - this.onShowLoader = Types.isFn(f.on_show_loader) ? f.on_show_loader : null; - //callback function after loader is closed - this.onHideLoader = Types.isFn(f.on_hide_loader) ? f.on_hide_loader : null; - - this.tf = tf; - - var containerDiv = Dom.create("div", ["id", tf.prfxLoader + tf.id]); - containerDiv.className = this.loaderCssClass; - - var targetEl = !this.loaderTgtId ? tf.tbl.parentNode : Dom.id(this.loaderTgtId); - if (!this.loaderTgtId) { - targetEl.insertBefore(containerDiv, tf.tbl); - } else { - targetEl.appendChild(containerDiv); - } - this.loaderDiv = Dom.id(tf.prfxLoader + tf.id); - if (!this.loaderHtml) { - this.loaderDiv.appendChild(Dom.text(this.loaderText)); - } else { - this.loaderDiv.innerHTML = this.loaderHtml; - } - } - - _prototypeProperties(Loader, null, { - show: { - value: function show(p) { - var _this = this; - - if (!this.tf.loader || !this.loaderDiv || this.loaderDiv.style.display === p) { - return; - } - - var displayLoader = function () { - if (!_this.loaderDiv) { - return; - } - if (_this.onShowLoader && p !== "none") { - _this.onShowLoader.call(null, _this); - } - _this.loaderDiv.style.display = p; - if (_this.onHideLoader && p === "none") { - _this.onHideLoader.call(null, _this); - } - }; - - var t = p === "none" ? this.loaderCloseDelay : 1; - global.setTimeout(displayLoader, t); - }, - writable: true, - configurable: true - }, - remove: { - value: function remove() { - if (!this.loaderDiv) { - return; - } - var tf = this.tf, - targetEl = !this.loaderTgtId ? tf.gridLayout ? tf.Cpt.gridLayout.tblCont : tf.tbl.parentNode : Dom.id(this.loaderTgtId); - targetEl.removeChild(this.loaderDiv); - this.loaderDiv = null; - }, - writable: true, - configurable: true - } - }); - - return Loader; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=loader.js.map; -define('modules/highlightKeywords',["exports", "../dom", "../string"], function (exports, _dom, _string) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - var Str = _string.Str; - - var HighlightKeyword = exports.HighlightKeyword = (function () { - - /** - * HighlightKeyword, highlight matched keyword - * @param {Object} tf TableFilter instance - */ - - function HighlightKeyword(tf) { - _classCallCheck(this, HighlightKeyword); - - var f = tf.config(); - //defines css class for highlighting - this.highlightCssClass = f.highlight_css_class || "keyword"; - this.highlightedNodes = []; - - this.tf = tf; - } - - _prototypeProperties(HighlightKeyword, null, { - highlight: { - - /** - * highlight occurences of searched term in passed node - * @param {Node} node - * @param {String} word Searched term - * @param {String} cssClass Css class name - */ - - value: function highlight(node, word, cssClass) { - // Iterate into this nodes childNodes - if (node.hasChildNodes) { - var children = node.childNodes; - for (var i = 0; i < children.length; i++) { - this.highlight(children[i], word, cssClass); - } - } - - if (node.nodeType === 3) { - var tempNodeVal = Str.lower(node.nodeValue); - var tempWordVal = Str.lower(word); - if (tempNodeVal.indexOf(tempWordVal) != -1) { - var pn = node.parentNode; - if (pn && pn.className != cssClass) { - // word not highlighted yet - var nv = node.nodeValue, - ni = tempNodeVal.indexOf(tempWordVal), - - // Create a load of replacement nodes - before = Dom.text(nv.substr(0, ni)), - docWordVal = nv.substr(ni, word.length), - after = Dom.text(nv.substr(ni + word.length)), - hiwordtext = Dom.text(docWordVal), - hiword = Dom.create("span"); - hiword.className = cssClass; - hiword.appendChild(hiwordtext); - pn.insertBefore(before, node); - pn.insertBefore(hiword, node); - pn.insertBefore(after, node); - pn.removeChild(node); - this.highlightedNodes.push(hiword.firstChild); - } - } - } - }, - writable: true, - configurable: true - }, - unhighlight: { - - /** - * Removes highlight to nodes matching passed string - * @param {String} word - * @param {String} cssClass Css class to remove - */ - - value: function unhighlight(word, cssClass) { - var arrRemove = []; - var highlightedNodes = this.highlightedNodes; - for (var i = 0; i < highlightedNodes.length; i++) { - var n = highlightedNodes[i]; - if (!n) { - continue; - } - var tempNodeVal = Str.lower(n.nodeValue), - tempWordVal = Str.lower(word); - if (tempNodeVal.indexOf(tempWordVal) !== -1) { - var pn = n.parentNode; - if (pn && pn.className === cssClass) { - var prevSib = pn.previousSibling, - nextSib = pn.nextSibling; - if (!prevSib || !nextSib) { - continue; - } - nextSib.nodeValue = prevSib.nodeValue + n.nodeValue + nextSib.nodeValue; - prevSib.nodeValue = ""; - n.nodeValue = ""; - arrRemove.push(i); - } - } - } - for (var k = 0; k < arrRemove.length; k++) { - highlightedNodes.splice(arrRemove[k], 1); - } - }, - writable: true, - configurable: true - }, - unhighlightAll: { - - /** - * Clear all occurrences of highlighted nodes - */ - - value: function unhighlightAll() { - if (!this.tf.highlightKeywords || !this.tf.searchArgs) { - return; - } - for (var y = 0; y < this.tf.searchArgs.length; y++) { - this.unhighlight(this.tf.searchArgs[y], this.highlightCssClass); - } - this.highlightedNodes = []; - }, - writable: true, - configurable: true - } - }); - - return HighlightKeyword; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=highlightKeywords.js.map; -define('modules/popupFilter',["exports", "../types", "../dom", "../event", "../helpers"], function (exports, _types, _dom, _event, _helpers) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Types = _types.Types; - var Dom = _dom.Dom; - var Event = _event.Event; - var Helpers = _helpers.Helpers; - - var PopupFilter = exports.PopupFilter = (function () { - - /** - * Pop-up filter component - * @param {Object} tf TableFilter instance - */ - - function PopupFilter(tf) { - _classCallCheck(this, PopupFilter); - - // Configuration object - var f = tf.config(); - - // Enable external filters behaviour - tf.isExternalFlt = true; - tf.externalFltTgtIds = []; - - //filter icon path - this.popUpImgFlt = f.popup_filters_image || tf.themesPath + "icn_filter.gif"; - //active filter icon path - this.popUpImgFltActive = f.popup_filters_image_active || tf.themesPath + "icn_filterActive.gif"; - this.popUpImgFltHtml = f.popup_filters_image_html || "\"Column"; - //defines css class for popup div containing filter - this.popUpDivCssClass = f.popup_div_css_class || "popUpFilter"; - //callback function before popup filtes is opened - this.onBeforePopUpOpen = Types.isFn(f.on_before_popup_filter_open) ? f.on_before_popup_filter_open : null; - //callback function after popup filtes is opened - this.onAfterPopUpOpen = Types.isFn(f.on_after_popup_filter_open) ? f.on_after_popup_filter_open : null; - //callback function before popup filtes is closed - this.onBeforePopUpClose = Types.isFn(f.on_before_popup_filter_close) ? f.on_before_popup_filter_close : null; - //callback function after popup filtes is closed - this.onAfterPopUpClose = Types.isFn(f.on_after_popup_filter_close) ? f.on_after_popup_filter_close : null; - - //stores filters spans - this.popUpFltSpans = []; - //stores filters icons - this.popUpFltImgs = []; - //stores filters containers - this.popUpFltElms = this.popUpFltElmCache || []; - this.popUpFltAdjustToContainer = true; - - this.tf = tf; - } - - _prototypeProperties(PopupFilter, null, { - onClick: { - value: function onClick(e) { - var evt = e || global.event, - elm = evt.target.parentNode, - colIndex = parseInt(elm.getAttribute("ci"), 10); - - this.closeAll(colIndex); - this.toggle(colIndex); - - if (this.popUpFltAdjustToContainer) { - var popUpDiv = this.popUpFltElms[colIndex], - header = this.tf.getHeaderElement(colIndex), - headerWidth = header.clientWidth * 0.95; - if (Helpers.isIE()) { - var headerLeft = Dom.position(header).left; - popUpDiv.style.left = headerLeft + "px"; - } - popUpDiv.style.width = parseInt(headerWidth, 10) + "px"; - } - Event.cancel(evt); - Event.stop(evt); - }, - writable: true, - configurable: true - }, - init: { - - /** - * Initialize DOM elements - */ - - value: function init() { - var _this = this; - - var tf = this.tf; - for (var i = 0; i < tf.nbCells; i++) { - if (tf["col" + i] === tf.fltTypeNone) { - continue; - } - var popUpSpan = Dom.create("span", ["id", tf.prfxPopUpSpan + tf.id + "_" + i], ["ci", i]); - popUpSpan.innerHTML = this.popUpImgFltHtml; - var header = tf.getHeaderElement(i); - header.appendChild(popUpSpan); - Event.add(popUpSpan, "click", function (evt) { - _this.onClick(evt); - }); - this.popUpFltSpans[i] = popUpSpan; - this.popUpFltImgs[i] = popUpSpan.firstChild; - } - }, - writable: true, - configurable: true - }, - buildAll: { - - /** - * Build all pop-up filters elements - */ - - value: function buildAll() { - for (var i = 0; i < this.popUpFltElmCache.length; i++) { - this.build(i, this.popUpFltElmCache[i]); - } - }, - writable: true, - configurable: true - }, - build: { - - /** - * Build a specified pop-up filter elements - * @param {Number} colIndex Column index - * @param {Object} div Optional container DOM element - */ - - value: function build(colIndex, div) { - var tf = this.tf; - var popUpDiv = !div ? Dom.create("div", ["id", tf.prfxPopUpDiv + tf.id + "_" + colIndex]) : div; - popUpDiv.className = this.popUpDivCssClass; - tf.externalFltTgtIds.push(popUpDiv.id); - var header = tf.getHeaderElement(colIndex); - header.insertBefore(popUpDiv, header.firstChild); - Event.add(popUpDiv, "click", function (evt) { - Event.stop(evt); - }); - this.popUpFltElms[colIndex] = popUpDiv; - }, - writable: true, - configurable: true - }, - toggle: { - - /** - * Toogle visibility of specified filter - * @param {Number} colIndex Column index - */ - - value: function toggle(colIndex) { - var tf = this.tf, - popUpFltElm = this.popUpFltElms[colIndex]; - - if (popUpFltElm.style.display === "none" || popUpFltElm.style.display === "") { - if (this.onBeforePopUpOpen) { - this.onBeforePopUpOpen.call(null, this, this.popUpFltElms[colIndex], colIndex); - } - popUpFltElm.style.display = "block"; - if (tf["col" + colIndex] === tf.fltTypeInp) { - tf.GetFilterElement(colIndex).focus(); - } - if (this.onAfterPopUpOpen) { - this.onAfterPopUpOpen.call(null, this, this.popUpFltElms[colIndex], colIndex); - } - } else { - if (this.onBeforePopUpClose) { - this.onBeforePopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex); - } - popUpFltElm.style.display = "none"; - if (this.onAfterPopUpClose) { - this.onAfterPopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex); - } - } - }, - writable: true, - configurable: true - }, - closeAll: { - - /** - * Close all filters excepted for the specified one if any - * @param {Number} exceptIdx Column index of the filter to not close - */ - - value: function closeAll(exceptIdx) { - for (var i = 0; i < this.popUpFltElms.length; i++) { - if (i === exceptIdx) { - continue; - } - var popUpFltElm = this.popUpFltElms[i]; - if (popUpFltElm) { - popUpFltElm.style.display = "none"; - } - } - }, - writable: true, - configurable: true - }, - buildIcons: { - - /** - * Build all the icons representing the pop-up filters - */ - - value: function buildIcons() { - for (var i = 0; i < this.popUpFltImgs.length; i++) { - this.buildIcon(i, false); - } - }, - writable: true, - configurable: true - }, - buildIcon: { - - /** - * Build specified icon - * @param {Number} colIndex Column index - * @param {Boolean} active Apply active state - */ - - value: function buildIcon(colIndex, active) { - var activeImg = Types.isUndef(active) ? true : active; - if (this.popUpFltImgs[colIndex]) { - this.popUpFltImgs[colIndex].src = active ? this.popUpImgFltActive : this.popUpImgFlt; - } - }, - writable: true, - configurable: true - }, - destroy: { - - /** - * Remove pop-up filters - */ - - value: function destroy() { - this.popUpFltElmCache = []; - for (var i = 0; i < this.popUpFltElms.length; i++) { - var popUpFltElm = this.popUpFltElms[i], - popUpFltSpan = this.popUpFltSpans[i], - popUpFltImg = this.popUpFltImgs[i]; - if (popUpFltElm) { - popUpFltElm.parentNode.removeChild(popUpFltElm); - this.popUpFltElmCache[i] = popUpFltElm; - } - popUpFltElm = null; - if (popUpFltSpan) { - popUpFltSpan.parentNode.removeChild(popUpFltSpan); - } - popUpFltSpan = null; - if (popUpFltImg) { - popUpFltImg.parentNode.removeChild(popUpFltImg); - } - popUpFltImg = null; - } - this.popUpFltElms = []; - this.popUpFltSpans = []; - this.popUpFltImgs = []; - }, - writable: true, - configurable: true - } - }); - - return PopupFilter; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=popupFilter.js.map; -define('modules/dropdown',["exports", "../dom", "../array", "../string", "../sort"], function (exports, _dom, _array, _string, _sort) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - var array = _array.Arr; - var Str = _string.Str; - var Sort = _sort.Sort; - - var Dropdown = exports.Dropdown = (function () { - - /** - * Dropdown UI component - * @param {Object} tf TableFilter instance - */ - - function Dropdown(tf) { - _classCallCheck(this, Dropdown); - - // Configuration object - var f = tf.config(); - - this.enableSlcResetFilter = f.enable_slc_reset_filter ? false : true; - //defines empty option text - this.nonEmptyText = f.non_empty_text || "(Non empty)"; - //sets select filling method: 'innerHTML' or 'createElement' - this.slcFillingMethod = f.slc_filling_method || "createElement"; - //IE only, tooltip text appearing on select before it is populated - this.activateSlcTooltip = f.activate_slc_tooltip || "Click to activate"; - //tooltip text appearing on multiple select - this.multipleSlcTooltip = f.multiple_slc_tooltip || "Use Ctrl key for multiple selections"; - - this.isCustom = null; - this.opts = null; - this.optsTxt = null; - this.slcInnerHtml = null; - - this.tf = tf; - } - - _prototypeProperties(Dropdown, null, { - build: { - - /** - * Build drop-down filter UI asynchronously - * @param {Number} colIndex Column index - * @param {Boolean} isRefreshed Enable linked refresh behaviour - * @param {Boolean} isExternal Render in external container - * @param {String} extSlcId External container id - */ - - value: function build(colIndex, isRefreshed, isExternal, extSlcId) { - var tf = this.tf; - tf.EvtManager(tf.Evt.name.dropdown, { - slcIndex: colIndex, - slcRefreshed: isRefreshed, - slcExternal: isExternal, - slcId: extSlcId - }); - }, - writable: true, - configurable: true - }, - _build: { - - /** - * Build drop-down filter UI - * @param {Number} colIndex Column index - * @param {Boolean} isRefreshed Enable linked refresh behaviour - * @param {Boolean} isExternal Render in external container - * @param {String} extSlcId External container id - */ - - value: function _build(colIndex) { - var isRefreshed = arguments[1] === undefined ? false : arguments[1]; - var isExternal = arguments[2] === undefined ? false : arguments[2]; - var extSlcId = arguments[3] === undefined ? null : arguments[3]; - - var tf = this.tf; - colIndex = parseInt(colIndex, 10); - - this.opts = []; - this.optsTxt = []; - this.slcInnerHtml = ""; - - var slcId = tf.fltIds[colIndex]; - if (!Dom.id(slcId) && !isExternal || !Dom.id(extSlcId) && isExternal) { - return; - } - var slc = !isExternal ? Dom.id(slcId) : Dom.id(extSlcId), - rows = tf.tbl.rows, - matchCase = tf.matchCase, - fillMethod = Str.lower(this.slcFillingMethod); - - //custom select test - this.isCustom = tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex); - - //custom selects text - var activeFlt; - if (isRefreshed && tf.activeFilterId) { - activeFlt = tf.activeFilterId.split("_")[0]; - activeFlt = activeFlt.split(tf.prfxFlt)[1]; - } - - /*** remember grid values ***/ - var fltsValues = [], - fltArr = []; - if (tf.rememberGridValues) { - fltsValues = tf.Cpt.store.getFilterValues(tf.fltsValuesCookie); - if (fltsValues && !Str.isEmpty(fltsValues.toString())) { - if (this.isCustom) { - fltArr.push(fltsValues[colIndex]); - } else { - fltArr = fltsValues[colIndex].split(" " + tf.orOperator + " "); - } - } - } - - var excludedOpts = null, - filteredDataCol = null; - if (isRefreshed && tf.disableExcludedOptions) { - excludedOpts = []; - filteredDataCol = []; - } - - for (var k = tf.refRow; k < tf.nbRows; k++) { - // always visible rows don't need to appear on selects as always - // valid - if (tf.hasVisibleRows && array.has(tf.visibleRows, k) && !tf.paging) { - continue; - } - - var cell = rows[k].cells, - nchilds = cell.length; - - // checks if row has exact cell # - if (nchilds !== tf.nbCells || this.isCustom) { - continue; - } - - // this loop retrieves cell data - for (var j = 0; j < nchilds; j++) { - if (colIndex === j && (!isRefreshed || isRefreshed && tf.disableExcludedOptions) || colIndex == j && isRefreshed && (rows[k].style.display === "" && !tf.paging || tf.paging && (!tf.validRowsIndex || tf.validRowsIndex && array.has(tf.validRowsIndex, k)) && (activeFlt === undefined || activeFlt == colIndex || activeFlt != colIndex && array.has(tf.validRowsIndex, k)))) { - var cell_data = tf.getCellData(j, cell[j]), - - //Vary Peter's patch - cell_string = Str.matchCase(cell_data, matchCase); - - // checks if celldata is already in array - if (!array.has(this.opts, cell_string, matchCase)) { - this.opts.push(cell_data); - } - - if (isRefreshed && tf.disableExcludedOptions) { - var filteredCol = filteredDataCol[j]; - if (!filteredCol) { - filteredCol = this.GetFilteredDataCol(j); - } - if (!array.has(filteredCol, cell_string, matchCase) && !array.has(excludedOpts, cell_string, matchCase) && !this.isFirstLoad) { - excludedOpts.push(cell_data); - } - } - } //if colIndex==j - } //for j - } //for k - - //Retrieves custom values - if (this.isCustom) { - var customValues = tf.__getCustomValues(colIndex); - this.opts = customValues[0]; - this.optsTxt = customValues[1]; - } - - if (tf.sortSlc && !this.isCustom) { - if (!matchCase) { - this.opts.sort(Sort.ignoreCase); - if (excludedOpts) { - excludedOpts.sort(Sort.ignoreCase); - } - } else { - this.opts.sort(); - if (excludedOpts) { - excludedOpts.sort(); - } - } - } - - //asc sort - if (tf.sortNumAsc && array.has(tf.sortNumAsc, colIndex)) { - try { - this.opts.sort(numSortAsc); - if (excludedOpts) { - excludedOpts.sort(numSortAsc); - } - if (this.isCustom) { - this.optsTxt.sort(numSortAsc); - } - } catch (e) { - this.opts.sort(); - if (excludedOpts) { - excludedOpts.sort(); - } - if (this.isCustom) { - this.optsTxt.sort(); - } - } //in case there are alphanumeric values - } - //desc sort - if (tf.sortNumDesc && array.has(tf.sortNumDesc, colIndex)) { - try { - this.opts.sort(numSortDesc); - if (excludedOpts) { - excludedOpts.sort(numSortDesc); - } - if (this.isCustom) { - this.optsTxt.sort(numSortDesc); - } - } catch (e) { - this.opts.sort(); - if (excludedOpts) { - excludedOpts.sort(); - } - if (this.isCustom) { - this.optsTxt.sort(); - } - } //in case there are alphanumeric values - } - - //populates drop-down - this.addOptions(colIndex, slc, isRefreshed, excludedOpts, fltsValues, fltArr); - }, - writable: true, - configurable: true - }, - addOptions: { - - /** - * Add drop-down options - * @param {Number} colIndex Column index - * @param {Object} slc Select Dom element - * @param {Boolean} isRefreshed Enable linked refresh behaviour - * @param {Array} excludedOpts Array of excluded options - * @param {Array} fltsValues Collection of persisted filter values - * @param {Array} fltArr Collection of persisted filter values - */ - - value: function addOptions(colIndex, slc, isRefreshed, excludedOpts, fltsValues, fltArr) { - var tf = this.tf, - fillMethod = Str.lower(this.slcFillingMethod), - slcValue = slc.value; - - slc.innerHTML = ""; - slc = this.addFirstOption(slc); - - for (var y = 0; y < this.opts.length; y++) { - if (this.opts[y] === "") { - continue; - } - var val = this.opts[y]; //option value - var lbl = this.isCustom ? this.optsTxt[y] : val; //option text - var isDisabled = false; - if (isRefreshed && this.disableExcludedOptions && array.has(excludedOpts, Str.matchCase(val, tf.matchCase), tf.matchCase)) { - isDisabled = true; - } - - if (fillMethod === "innerhtml") { - var slcAttr = ""; - if (tf.fillSlcOnDemand && slcValue === this.opts[y]) { - slcAttr = "selected=\"selected\""; - } - this.slcInnerHtml += ""; - } else { - var opt; - //fill select on demand - if (tf.fillSlcOnDemand && slcValue === this.opts[y] && tf["col" + colIndex] === tf.fltTypeSlc) { - opt = Dom.createOpt(lbl, val, true); - } else { - if (tf["col" + colIndex] !== tf.fltTypeMulti) { - opt = Dom.createOpt(lbl, val, fltsValues[colIndex] !== " " && val === fltsValues[colIndex] ? true : false); - } else { - opt = Dom.createOpt(lbl, val, array.has(fltArr, Str.matchCase(this.opts[y], tf.matchCase), tf.matchCase) || fltArr.toString().indexOf(val) !== -1 ? true : false); - } - } - if (isDisabled) { - opt.disabled = true; - } - slc.appendChild(opt); - } - } // for y - - if (fillMethod === "innerhtml") { - slc.innerHTML += this.slcInnerHtml; - } - slc.setAttribute("filled", "1"); - }, - writable: true, - configurable: true - }, - addFirstOption: { - - /** - * Add drop-down header option - * @param {Object} slc Select DOM element - */ - - value: function addFirstOption(slc) { - var tf = this.tf, - fillMethod = Str.lower(this.slcFillingMethod); - - if (fillMethod === "innerhtml") { - this.slcInnerHtml += ""; - } else { - var opt0 = Dom.createOpt(!this.enableSlcResetFilter ? "" : tf.displayAllText, ""); - if (!this.enableSlcResetFilter) { - opt0.style.display = "none"; - } - slc.appendChild(opt0); - if (tf.enableEmptyOption) { - var opt1 = Dom.createOpt(tf.emptyText, tf.emOperator); - slc.appendChild(opt1); - } - if (tf.enableNonEmptyOption) { - var opt2 = Dom.createOpt(tf.nonEmptyText, tf.nmOperator); - slc.appendChild(opt2); - } - } - return slc; - }, - writable: true, - configurable: true - } - }); - - return Dropdown; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=dropdown.js.map; -define('modules/checkList',["exports", "../dom", "../array", "../string", "../sort", "../event"], function (exports, _dom, _array, _string, _sort, _event) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - var array = _array.Arr; - var Str = _string.Str; - var Sort = _sort.Sort; - var Event = _event.Event; - - var CheckList = exports.CheckList = (function () { - - /** - * Checklist UI component - * @param {Object} tf TableFilter instance - */ - - function CheckList(tf) { - _classCallCheck(this, CheckList); - - // Configuration object - var f = tf.config(); - - this.checkListDiv = []; //checklist container div - //defines css class for div containing checklist filter - this.checkListDivCssClass = f.div_checklist_css_class || "div_checklist"; - //defines css class for checklist filters - this.checkListCssClass = f.checklist_css_class || "flt_checklist"; - //defines css class for checklist item (li) - this.checkListItemCssClass = f.checklist_item_css_class || "flt_checklist_item"; - //defines css class for selected checklist item (li) - this.checkListSlcItemCssClass = f.checklist_selected_item_css_class || "flt_checklist_slc_item"; - //Load on demand text - this.activateCheckListTxt = f.activate_checklist_text || "Click to load filter data"; - //defines css class for checklist filters - this.checkListItemDisabledCssClass = f.checklist_item_disabled_css_class || "flt_checklist_item_disabled"; - this.enableCheckListResetFilter = f.enable_checklist_reset_filter === false ? false : true; - - this.isCustom = null; - this.opts = null; - this.optsTxt = null; - - this.tf = tf; - } - - _prototypeProperties(CheckList, null, { - onChange: { - - // TODO: add _OnSlcChange event here - - value: function onChange(evt) { - this.tf.Evt._OnSlcChange(evt); - }, - writable: true, - configurable: true - }, - optionClick: { - value: function optionClick(evt) { - this.setCheckListValues(evt.target); - this.onChange(evt); - }, - writable: true, - configurable: true - }, - build: { - - /** - * Build checklist UI asynchronously - * @param {Number} colIndex Column index - * @param {Boolean} isExternal Render in external container - * @param {String} extFltId External container id - */ - - value: function build(colIndex, isExternal, extFltId) { - var tf = this.tf; - tf.EvtManager(tf.Evt.name.checklist, { slcIndex: colIndex, slcExternal: isExternal, slcId: extFltId }); - }, - writable: true, - configurable: true - }, - _build: { - - /** - * Build checklist UI - * @param {Number} colIndex Column index - * @param {Boolean} isExternal Render in external container - * @param {String} extFltId External container id - */ - - value: function _build(colIndex) { - var _this = this; - - var isExternal = arguments[1] === undefined ? false : arguments[1]; - var extFltId = arguments[2] === undefined ? null : arguments[2]; - - var tf = this.tf; - colIndex = parseInt(colIndex, 10); - - this.opts = []; - this.optsTxt = []; - - var divFltId = tf.prfxCheckListDiv + colIndex + "_" + tf.id; - if (!Dom.id(divFltId) && !isExternal || !Dom.id(extFltId) && isExternal) { - return; - } - - var flt = !isExternal ? this.checkListDiv[colIndex] : Dom.id(extFltId); - var ul = Dom.create("ul", ["id", tf.fltIds[colIndex]], ["colIndex", colIndex]); - ul.className = this.checkListCssClass; - Event.add(ul, "change", function (evt) { - _this.onChange(evt); - }); - - var rows = tf.tbl.rows; - this.isCustom = tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex); - - var activeFlt; - if (tf.refreshFilters && tf.activeFilterId) { - activeFlt = tf.activeFilterId.split("_")[0]; - activeFlt = activeFlt.split(tf.prfxFlt)[1]; - } - - var excludedOpts, - filteredDataCol = []; - if (tf.refreshFilters && tf.disableExcludedOptions) { - excludedOpts = []; - } - - for (var k = tf.refRow; k < tf.nbRows; k++) { - // always visible rows don't need to appear on selects as always - // valid - if (tf.hasVisibleRows && array.has(tf.visibleRows, k) && !tf.paging) { - continue; - } - - var cells = rows[k].cells; - var ncells = cells.length; - - // checks if row has exact cell # - if (ncells !== tf.nbCells || this.isCustom) { - continue; - } - - // this loop retrieves cell data - for (var j = 0; j < ncells; j++) { - if (colIndex === j && (!tf.refreshFilters || tf.refreshFilters && tf.disableExcludedOptions) || colIndex === j && tf.refreshFilters && (rows[k].style.display === "" && !tf.paging || tf.paging && (!activeFlt || activeFlt === colIndex || activeFlt != colIndex && array.has(tf.validRowsIndex, k)))) { - var cell_data = tf.getCellData(j, cells[j]); - //Vary Peter's patch - var cell_string = Str.matchCase(cell_data, tf.matchCase); - // checks if celldata is already in array - if (!array.has(this.opts, cell_string, tf.matchCase)) { - this.opts.push(cell_data); - } - var filteredCol = filteredDataCol[j]; - if (tf.refreshFilters && tf.disableExcludedOptions) { - if (!filteredCol) { - filteredDataCol[j] = tf.GetFilteredDataCol(j); - } - if (!array.has(filteredCol, cell_string, tf.matchCase) && !array.has(excludedOpts, cell_string, tf.matchCase) && !tf.isFirstLoad) { - excludedOpts.push(cell_data); - } - } - } - } - } - - //Retrieves custom values - if (this.isCustom) { - var customValues = tf.__getCustomValues(colIndex); - this.opts = customValues[0]; - this.optsTxt = customValues[1]; - } - - if (tf.sortSlc && !this.isCustom) { - if (!tf.matchCase) { - this.opts.sort(Sort.ignoreCase); - if (excludedOpts) { - excludedOpts.sort(Sort.ignoreCase); - } - } else { - this.opts.sort(); - if (excludedOpts) { - excludedOpts.sort(); - } - } - } - //asc sort - if (tf.sortNumAsc && array.has(tf.sortNumAsc, colIndex)) { - try { - this.opts.sort(numSortAsc); - if (excludedOpts) { - excludedOpts.sort(numSortAsc); - } - if (this.isCustom) { - this.optsTxt.sort(numSortAsc); - } - } catch (e) { - this.opts.sort(); - if (excludedOpts) { - excludedOpts.sort(); - } - if (this.isCustom) { - this.optsTxt.sort(); - } - } //in case there are alphanumeric values - } - //desc sort - if (tf.sortNumDesc && array.has(tf.sortNumDesc, colIndex)) { - try { - this.opts.sort(numSortDesc); - if (excludedOpts) { - excludedOpts.sort(numSortDesc); - } - if (this.isCustom) { - this.optsTxt.sort(numSortDesc); - } - } catch (e) { - this.opts.sort(); - if (excludedOpts) { - excludedOpts.sort(); - } - if (this.isCustom) { - this.optsTxt.sort(); - } - } //in case there are alphanumeric values - } - - this.addChecks(colIndex, ul, tf.separator); - - if (tf.fillSlcOnDemand) { - flt.innerHTML = ""; - } - flt.appendChild(ul); - flt.setAttribute("filled", "1"); - }, - writable: true, - configurable: true - }, - addChecks: { - - /** - * Add checklist options - * @param {Number} colIndex Column index - * @param {Object} ul Ul element - * @param {String} separator Data separator - */ - - value: function addChecks(colIndex, ul, separator) { - var _this = this; - - var tf = this.tf; - var chkCt = this.addTChecks(colIndex, ul); - var flts_values = [], - fltArr = []; //remember grid values - var store = tf.Cpt.store; - var tmpVal = store ? store.getFilterValues(tf.fltsValuesCookie)[colIndex] : null; - if (tmpVal && Str.trim(tmpVal).length > 0) { - if (tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex)) { - fltArr.push(tmpVal); - } else { - fltArr = tmpVal.split(" " + tf.orOperator + " "); - } - } - - for (var y = 0; y < this.opts.length; y++) { - var val = this.opts[y]; //item value - var lbl = this.isCustom ? this.optsTxt[y] : val; //item text - var li = Dom.createCheckItem(tf.fltIds[colIndex] + "_" + (y + chkCt), val, lbl); - li.className = this.checkListItemCssClass; - if (tf.refreshFilters && tf.disableExcludedOptions && array.has(excludedOpts, Str.matchCase(val, tf.matchCase), tf.matchCase)) { - Dom.addClass(li, this.checkListItemDisabledCssClass); - li.check.disabled = true; - li.disabled = true; - } else { - Event.add(li.check, "click", function (evt) { - _this.optionClick(evt); - }); - } - ul.appendChild(li); - - if (val === "") { - //item is hidden - li.style.display = "none"; - } - - /*** remember grid values ***/ - if (tf.rememberGridValues) { - if (tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex) && fltArr.toString().indexOf(val) != -1 || array.has(fltArr, Str.matchCase(val, tf.matchCase), tf.matchCase)) { - li.check.checked = true; - this.setCheckListValues(li.check); - } - } - } - }, - writable: true, - configurable: true - }, - addTChecks: { - - /** - * Add checklist header option - * @param {Number} colIndex Column index - * @param {Object} ul Ul element - */ - - value: function addTChecks(colIndex, ul) { - var _this = this; - - var tf = this.tf; - var chkCt = 1; - var li0 = Dom.createCheckItem(tf.fltIds[colIndex] + "_0", "", tf.displayAllText); - li0.className = this.checkListItemCssClass; - ul.appendChild(li0); - - Event.add(li0.check, "click", function (evt) { - _this.optionClick(evt); - }); - - if (!this.enableCheckListResetFilter) { - li0.style.display = "none"; - } - - if (tf.enableEmptyOption) { - var li1 = Dom.createCheckItem(tf.fltIds[colIndex] + "_1", tf.emOperator, tf.emptyText); - li1.className = this.checkListItemCssClass; - ul.appendChild(li1); - Event.add(li1.check, "click", function (evt) { - _this.optionClick(evt); - }); - chkCt++; - } - - if (tf.enableNonEmptyOption) { - var li2 = Dom.createCheckItem(tf.fltIds[colIndex] + "_2", tf.nmOperator, tf.nonEmptyText); - li2.className = this.checkListItemCssClass; - ul.appendChild(li2); - Event.add(li2.check, "click", function (evt) { - _this.optionClick(evt); - }); - chkCt++; - } - return chkCt; - }, - writable: true, - configurable: true - }, - setCheckListValues: { - - /** - * Store checked options in DOM element attribute - * @param {Object} o checklist option DOM element - */ - - value: function setCheckListValues(o) { - if (!o) { - return; - } - var tf = this.tf; - var chkValue = o.value; //checked item value - var chkIndex = parseInt(o.id.split("_")[2], 10); - var filterTag = "ul", - itemTag = "li"; - var n = o; - - //ul tag search - while (Str.lower(n.nodeName) !== filterTag) { - n = n.parentNode; - } - - var li = n.childNodes[chkIndex]; - var colIndex = n.getAttribute("colIndex"); - var fltValue = n.getAttribute("value"); //filter value (ul tag) - var fltIndexes = n.getAttribute("indexes"); //selected items (ul tag) - - if (o.checked) { - //show all item - if (chkValue === "") { - if (fltIndexes && fltIndexes !== "") { - //items indexes - var indSplit = fltIndexes.split(tf.separator); - //checked items loop - for (var u = 0; u < indSplit.length; u++) { - //checked item - var cChk = Dom.id(tf.fltIds[colIndex] + "_" + indSplit[u]); - if (cChk) { - cChk.checked = false; - Dom.removeClass(n.childNodes[indSplit[u]], this.checkListSlcItemCssClass); - } - } - } - n.setAttribute("value", ""); - n.setAttribute("indexes", ""); - } else { - fltValue = fltValue ? fltValue : ""; - chkValue = Str.trim(fltValue + " " + chkValue + " " + tf.orOperator); - chkIndex = fltIndexes + chkIndex + tf.separator; - n.setAttribute("value", chkValue); - n.setAttribute("indexes", chkIndex); - //1st option unchecked - if (Dom.id(tf.fltIds[colIndex] + "_0")) { - Dom.id(tf.fltIds[colIndex] + "_0").checked = false; - } - } - - if (Str.lower(li.nodeName) === itemTag) { - Dom.removeClass(n.childNodes[0], this.checkListSlcItemCssClass); - Dom.addClass(li, this.checkListSlcItemCssClass); - } - } else { - //removes values and indexes - if (chkValue !== "") { - var replaceValue = new RegExp(Str.rgxEsc(chkValue + " " + tf.orOperator)); - fltValue = fltValue.replace(replaceValue, ""); - n.setAttribute("value", Str.trim(fltValue)); - - var replaceIndex = new RegExp(Str.rgxEsc(chkIndex + tf.separator)); - fltIndexes = fltIndexes.replace(replaceIndex, ""); - n.setAttribute("indexes", fltIndexes); - } - if (Str.lower(li.nodeName) === itemTag) { - Dom.removeClass(li, this.checkListSlcItemCssClass); - } - } - }, - writable: true, - configurable: true - } - }); - - return CheckList; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=checkList.js.map; -define('modules/rowsCounter',["exports", "../dom", "../types", "../helpers"], function (exports, _dom, _types, _helpers) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - var Types = _types.Types; - var Helpers = _helpers.Helpers; - - var RowsCounter = exports.RowsCounter = (function () { - - /** - * Rows counter - * @param {Object} tf TableFilter instance - */ - - function RowsCounter(tf) { - _classCallCheck(this, RowsCounter); - - // TableFilter configuration - var f = tf.config(); - - //id of custom container element - this.rowsCounterTgtId = f.rows_counter_target_id || null; - //element containing tot nb rows - this.rowsCounterDiv = null; - //element containing tot nb rows label - this.rowsCounterSpan = null; - //defines rows counter text - this.rowsCounterText = f.rows_counter_text || "Rows: "; - this.fromToTextSeparator = f.from_to_text_separator || "-"; - this.overText = f.over_text || " / "; - //defines css class rows counter - this.totRowsCssClass = f.tot_rows_css_class || "tot"; - //callback raised before counter is refreshed - this.onBeforeRefreshCounter = Types.isFn(f.on_before_refresh_counter) ? f.on_before_refresh_counter : null; - //callback raised after counter is refreshed - this.onAfterRefreshCounter = Types.isFn(f.on_after_refresh_counter) ? f.on_after_refresh_counter : null; - - this.tf = tf; - } - - _prototypeProperties(RowsCounter, null, { - init: { - value: function init() { - var tf = this.tf; - - if (!tf.hasGrid() && !tf.isFirstLoad || this.rowsCounterSpan) { - return; - } - - //rows counter container - var countDiv = Dom.create("div", ["id", tf.prfxCounter + tf.id]); - countDiv.className = this.totRowsCssClass; - //rows counter label - var countSpan = Dom.create("span", ["id", tf.prfxTotRows + tf.id]); - var countText = Dom.create("span", ["id", tf.prfxTotRowsTxt + tf.id]); - countText.appendChild(Dom.text(this.rowsCounterText)); - - // counter is added to defined element - if (!this.rowsCounterTgtId) { - tf.setToolbar(); - } - var targetEl = !this.rowsCounterTgtId ? tf.lDiv : Dom.id(this.rowsCounterTgtId); - - //IE only: clears all for sure - if (this.rowsCounterDiv && Helpers.isIE()) { - this.rowsCounterDiv.outerHTML = ""; - } - //default container: 'lDiv' - if (!this.rowsCounterTgtId) { - countDiv.appendChild(countText); - countDiv.appendChild(countSpan); - targetEl.appendChild(countDiv); - } else { - //custom container, no need to append statusDiv - targetEl.appendChild(countText); - targetEl.appendChild(countSpan); - } - this.rowsCounterDiv = countDiv; - this.rowsCounterSpan = countSpan; - - this.refresh(); - }, - writable: true, - configurable: true - }, - refresh: { - value: function refresh(p) { - if (!this.rowsCounterSpan) { - return; - } - - var tf = this.tf; - - if (this.onBeforeRefreshCounter) { - this.onBeforeRefreshCounter.call(null, tf, this.rowsCounterSpan); - } - - var totTxt; - if (!tf.paging) { - if (p && p !== "") { - totTxt = p; - } else { - totTxt = tf.nbFilterableRows - tf.nbHiddenRows - (tf.hasVisibleRows ? tf.visibleRows.length : 0); - } - } else { - var paging = tf.Cpt.paging; - if (paging) { - //paging start row - var paging_start_row = parseInt(paging.startPagingRow, 10) + (tf.nbVisibleRows > 0 ? 1 : 0); - var paging_end_row = paging_start_row + paging.pagingLength - 1 <= tf.nbVisibleRows ? paging_start_row + paging.pagingLength - 1 : tf.nbVisibleRows; - totTxt = paging_start_row + this.fromToTextSeparator + paging_end_row + this.overText + tf.nbVisibleRows; - } - } - this.rowsCounterSpan.innerHTML = totTxt; - if (this.onAfterRefreshCounter) { - this.onAfterRefreshCounter.call(null, tf, this.rowsCounterSpan, totTxt); - } - }, - writable: true, - configurable: true - }, - destroy: { - value: function destroy() { - var tf = this.tf; - if (!tf.hasGrid()) { - return; - } - if (!this.rowsCounterSpan) { - return; - } - - if (!this.rowsCounterTgtId && this.rowsCounterDiv) { - //IE only: clears all for sure - if (Helpers.isIE()) { - this.rowsCounterDiv.outerHTML = ""; - } else { - this.rowsCounterDiv.parentNode.removeChild(this.rowsCounterDiv); - } - } else { - Dom.id(this.rowsCounterTgtId).innerHTML = ""; - } - this.rowsCounterSpan = null; - this.rowsCounterDiv = null; - }, - writable: true, - configurable: true - } - }); - - return RowsCounter; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=rowsCounter.js.map; -define('modules/statusBar',["exports", "../dom", "../event", "../types", "../helpers"], function (exports, _dom, _event, _types, _helpers) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - var Event = _event.Event; - var Types = _types.Types; - var Helpers = _helpers.Helpers; - - var global = window; - - var StatusBar = exports.StatusBar = (function () { - - /** - * Status bar UI component - * @param {Object} tf TableFilter instance - */ - - function StatusBar(tf) { - _classCallCheck(this, StatusBar); - - // Configuration object - var f = tf.config(); - - //id of custom container element - this.statusBarTgtId = f.status_bar_target_id || null; - //element containing status bar label - this.statusBarDiv = null; - //status bar - this.statusBarSpan = null; - //status bar label - this.statusBarSpanText = null; - //defines status bar text - this.statusBarText = f.status_bar_text || ""; - //defines css class status bar - this.statusBarCssClass = f.status_bar_css_class || "status"; - //delay for status bar clearing - this.statusBarCloseDelay = 250; - - //calls function before message is displayed - this.onBeforeShowMsg = Types.isFn(f.on_before_show_msg) ? f.on_before_show_msg : null; - //calls function after message is displayed - this.onAfterShowMsg = Types.isFn(f.on_after_show_msg) ? f.on_after_show_msg : null; - - this.tf = tf; - } - - _prototypeProperties(StatusBar, null, { - init: { - value: function init() { - var tf = this.tf; - if (!tf.hasGrid() && !tf.isFirstLoad) { - return; - } - - //status bar container - var statusDiv = Dom.create("div", ["id", tf.prfxStatus + tf.id]); - statusDiv.className = this.statusBarCssClass; - - //status bar label - var statusSpan = Dom.create("span", ["id", tf.prfxStatusSpan + tf.id]); - //preceding text - var statusSpanText = Dom.create("span", ["id", tf.prfxStatusTxt + tf.id]); - statusSpanText.appendChild(Dom.text(this.statusBarText)); - - // target element container - if (!this.statusBarTgtId) { - tf.setToolbar(); - } - var targetEl = !this.statusBarTgtId ? tf.lDiv : Dom.id(this.statusBarTgtId); - - // TODO: use alternative to outerHTML - if (this.statusBarDiv && Helpers.isIE()) { - this.statusBarDiv.outerHTML = ""; - } - - //default container: 'lDiv' - if (!this.statusBarTgtId) { - statusDiv.appendChild(statusSpanText); - statusDiv.appendChild(statusSpan); - targetEl.appendChild(statusDiv); - } else { - // custom container, no need to append statusDiv - targetEl.appendChild(statusSpanText); - targetEl.appendChild(statusSpan); - } - - this.statusBarDiv = statusDiv; - this.statusBarSpan = statusSpan; - this.statusBarSpanText = statusSpanText; - }, - writable: true, - configurable: true - }, - message: { - value: function message() { - var _this = this; - - var t = arguments[0] === undefined ? "" : arguments[0]; - - var tf = this.tf; - if (!tf.statusBar || !this.statusBarSpan) { - return; - } - if (this.onBeforeShowMsg) { - this.onBeforeShowMsg.call(null, this.tf, t); - } - - var d = t === "" ? this.statusBarCloseDelay : 1; - global.setTimeout(function () { - _this.statusBarSpan.innerHTML = t; - if (_this.onAfterShowMsg) { - _this.onAfterShowMsg.call(null, _this.tf, t); - } - }, d); - }, - writable: true, - configurable: true - }, - destroy: { - value: function destroy() { - var tf = this.tf; - if (!tf.hasGrid() || !this.statusBarDiv) { - return; - } - - this.statusBarDiv.innerHTML = ""; - this.statusBarDiv.parentNode.removeChild(this.statusBarDiv); - this.statusBarSpan = null; - this.statusBarSpanText = null; - this.statusBarDiv = null; - }, - writable: true, - configurable: true - } - }); - - return StatusBar; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=statusBar.js.map; -define('modules/paging',["exports", "../dom", "../types", "../string", "../helpers", "../event"], function (exports, _dom, _types, _string, _helpers, _event) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - var Types = _types.Types; - var Str = _string.Str; - var Helpers = _helpers.Helpers; - var Event = _event.Event; - - var Paging = exports.Paging = (function () { - - /** - * Pagination component - * @param {Object} tf TableFilter instance - */ - - function Paging(tf) { - _classCallCheck(this, Paging); - - // Configuration object - var f = tf.config(); - - //css class for paging buttons (previous,next,etc.) - this.btnPageCssClass = f.paging_btn_css_class || "pgInp"; - //stores paging select element - this.pagingSlc = null; - //results per page select element - this.resultsPerPageSlc = null; - //id of container element - this.pagingTgtId = f.paging_target_id || null; - //defines table paging length - this.pagingLength = !isNaN(f.paging_length) ? f.paging_length : 10; - //id of container element - this.resultsPerPageTgtId = f.results_per_page_target_id || null; - //css class for paging select element - this.pgSlcCssClass = f.paging_slc_css_class || "pgSlc"; - //css class for paging input element - this.pgInpCssClass = f.paging_inp_css_class || "pgNbInp"; - //stores results per page text and values - this.resultsPerPage = f.results_per_page || null; - //enables/disables results per page drop-down - this.hasResultsPerPage = Types.isArray(this.resultsPerPage); - //defines css class for results per page select - this.resultsSlcCssClass = f.results_slc_css_class || "rspg"; - //css class for label preceding results per page select - this.resultsSpanCssClass = f.results_span_css_class || "rspgSpan"; - //1st row index of current page - this.startPagingRow = 0; - //total nb of pages - this.nbPages = 0; - //current page nb - this.currentPageNb = 1; - //defines next page button text - this.btnNextPageText = f.btn_next_page_text || ">"; - //defines previous page button text - this.btnPrevPageText = f.btn_prev_page_text || "<"; - //defines last page button text - this.btnLastPageText = f.btn_last_page_text || ">|"; - //defines first page button text - this.btnFirstPageText = f.btn_first_page_text || "|<"; - //defines next page button html - this.btnNextPageHtml = f.btn_next_page_html || (!tf.enableIcons ? null : ""); - //defines previous page button html - this.btnPrevPageHtml = f.btn_prev_page_html || (!tf.enableIcons ? null : ""); - //defines last page button html - this.btnFirstPageHtml = f.btn_first_page_html || (!tf.enableIcons ? null : ""); - //defines previous page button html - this.btnLastPageHtml = f.btn_last_page_html || (!tf.enableIcons ? null : ""); - //defines text preceeding page selector drop-down - this.pageText = f.page_text || " Page "; - //defines text after page selector drop-down - this.ofText = f.of_text || " of "; - //css class for span containing tot nb of pages - this.nbPgSpanCssClass = f.nb_pages_css_class || "nbpg"; - //enables/disables paging buttons - this.hasPagingBtns = f.paging_btns === false ? false : true; - //defines previous page button html - this.pageSelectorType = f.page_selector_type || tf.fltTypeSlc; - //calls function before page is changed - this.onBeforeChangePage = Types.isFn(f.on_before_change_page) ? f.on_before_change_page : null; - //calls function before page is changed - this.onAfterChangePage = Types.isFn(f.on_after_change_page) ? f.on_after_change_page : null; - var start_row = this.refRow; - var nrows = this.nbRows; - //calculates page nb - this.nbPages = Math.ceil((nrows - start_row) / this.pagingLength); - - //Paging elements events - var o = this; - // Paging DOM events - this.evt = { - slcIndex: function slcIndex() { - return o.pageSelectorType === tf.fltTypeSlc ? o.pagingSlc.options.selectedIndex : parseInt(o.pagingSlc.value, 10) - 1; - }, - nbOpts: function nbOpts() { - return o.pageSelectorType === tf.fltTypeSlc ? parseInt(o.pagingSlc.options.length, 10) - 1 : o.nbPages - 1; - }, - next: function next() { - var nextIndex = o.evt.slcIndex() < o.evt.nbOpts() ? o.evt.slcIndex() + 1 : 0; - o.changePage(nextIndex); - }, - prev: function prev() { - var prevIndex = o.evt.slcIndex() > 0 ? o.evt.slcIndex() - 1 : o.evt.nbOpts(); - o.changePage(prevIndex); - }, - last: function last() { - o.changePage(o.evt.nbOpts()); - }, - first: function first() { - o.changePage(0); - }, - _detectKey: function _detectKey(e) { - var key = tf.Evt.getKeyCode(e); - if (key === 13) { - if (tf.sorted) { - tf.filter(); - o.changePage(o.evt.slcIndex()); - } else { - o.changePage(); - } - this.blur(); - } - }, - slcPagesChange: null, - nextEvt: null, - prevEvt: null, - lastEvt: null, - firstEvt: null - }; - - this.tf = tf; - } - - _prototypeProperties(Paging, null, { - init: { - - /** - * Initialize DOM elements - */ - - value: function init() { - var _this = this; - - var slcPages; - var tf = this.tf; - var evt = this.evt; - - // Check resultsPerPage is in expected format and initialise the - // results per page component - if (this.hasResultsPerPage) { - if (this.resultsPerPage.length < 2) { - this.hasResultsPerPage = false; - } else { - this.pagingLength = this.resultsPerPage[1][0]; - this.setResultsPerPage(); - } - } - - /*==================================================== - - onchange event for paging select - =====================================================*/ - evt.slcPagesChange = function (event) { - // if(evt._Paging._OnSlcPagesChangeEvt){ - // evt._Paging._OnSlcPagesChangeEvt(); - // } - _this.changePage(); - event.target.blur(); - }; - - // Paging drop-down list selector - if (this.pageSelectorType === tf.fltTypeSlc) { - slcPages = Dom.create(tf.fltTypeSlc, ["id", tf.prfxSlcPages + tf.id]); - slcPages.className = this.pgSlcCssClass; - Event.add(slcPages, "change", evt.slcPagesChange); - } - - // Paging input selector - if (this.pageSelectorType === tf.fltTypeInp) { - slcPages = Dom.create(tf.fltTypeInp, ["id", tf.prfxSlcPages + tf.id], ["value", this.currentPageNb]); - slcPages.className = this.pgInpCssClass; - Event.add(slcPages, "keypress", evt._detectKey); - } - - // btns containers - var btnNextSpan = Dom.create("span", ["id", tf.prfxBtnNextSpan + tf.id]); - var btnPrevSpan = Dom.create("span", ["id", tf.prfxBtnPrevSpan + tf.id]); - var btnLastSpan = Dom.create("span", ["id", tf.prfxBtnLastSpan + tf.id]); - var btnFirstSpan = Dom.create("span", ["id", tf.prfxBtnFirstSpan + tf.id]); - - if (this.hasPagingBtns) { - // Next button - if (!this.btnNextPageHtml) { - var btn_next = Dom.create(tf.fltTypeInp, ["id", tf.prfxBtnNext + tf.id], ["type", "button"], ["value", this.btnNextPageText], ["title", "Next"]); - btn_next.className = this.btnPageCssClass; - Event.add(btn_next, "click", evt.next); - btnNextSpan.appendChild(btn_next); - } else { - btnNextSpan.innerHTML = this.btnNextPageHtml; - Event.add(btnNextSpan, "click", evt.next); - } - // Previous button - if (!this.btnPrevPageHtml) { - var btn_prev = Dom.create(tf.fltTypeInp, ["id", tf.prfxBtnPrev + tf.id], ["type", "button"], ["value", this.btnPrevPageText], ["title", "Previous"]); - btn_prev.className = this.btnPageCssClass; - Event.add(btn_prev, "click", evt.prev); - btnPrevSpan.appendChild(btn_prev); - } else { - btnPrevSpan.innerHTML = this.btnPrevPageHtml; - Event.add(btnPrevSpan, "click", evt.prev); - } - // Last button - if (!this.btnLastPageHtml) { - var btn_last = Dom.create(tf.fltTypeInp, ["id", tf.prfxBtnLast + tf.id], ["type", "button"], ["value", this.btnLastPageText], ["title", "Last"]); - btn_last.className = this.btnPageCssClass; - Event.add(btn_last, "click", evt.last); - btnLastSpan.appendChild(btn_last); - } else { - btnLastSpan.innerHTML = this.btnLastPageHtml; - Event.add(btnLastSpan, "click", evt.last); - } - // First button - if (!this.btnFirstPageHtml) { - var btn_first = Dom.create(tf.fltTypeInp, ["id", tf.prfxBtnFirst + tf.id], ["type", "button"], ["value", this.btnFirstPageText], ["title", "First"]); - btn_first.className = this.btnPageCssClass; - Event.add(btn_first, "click", evt.first); - btnFirstSpan.appendChild(btn_first); - } else { - btnFirstSpan.innerHTML = this.btnFirstPageHtml; - Event.add(btnFirstSpan, "click", evt.first); - } - } - - // paging elements (buttons+drop-down list) are added to defined element - if (!this.pagingTgtId) { - tf.setToolbar(); - } - var targetEl = !this.pagingTgtId ? tf.mDiv : Dom.id(this.pagingTgtId); - targetEl.appendChild(btnFirstSpan); - targetEl.appendChild(btnPrevSpan); - - var pgBeforeSpan = Dom.create("span", ["id", tf.prfxPgBeforeSpan + tf.id]); - pgBeforeSpan.appendChild(Dom.text(this.pageText)); - pgBeforeSpan.className = this.nbPgSpanCssClass; - targetEl.appendChild(pgBeforeSpan); - targetEl.appendChild(slcPages); - var pgAfterSpan = Dom.create("span", ["id", tf.prfxPgAfterSpan + tf.id]); - pgAfterSpan.appendChild(Dom.text(this.ofText)); - pgAfterSpan.className = this.nbPgSpanCssClass; - targetEl.appendChild(pgAfterSpan); - var pgspan = Dom.create("span", ["id", tf.prfxPgSpan + tf.id]); - pgspan.className = this.nbPgSpanCssClass; - pgspan.appendChild(Dom.text(" " + this.nbPages + " ")); - targetEl.appendChild(pgspan); - targetEl.appendChild(btnNextSpan); - targetEl.appendChild(btnLastSpan); - this.pagingSlc = Dom.id(tf.prfxSlcPages + tf.id); - - // if this.rememberGridValues==true this.setPagingInfo() is called - // in ResetGridValues() method - if (!tf.rememberGridValues || this.isPagingRemoved) { - this.setPagingInfo(); - } - if (!tf.fltGrid) { - tf.ValidateAllRows(); - this.setPagingInfo(tf.validRowsIndex); - } - - this.isPagingRemoved = false; - }, - writable: true, - configurable: true - }, - addPaging: { - - /** - * Add paging when filters are already instanciated - * @param {Boolean} filterTable Execute filtering once paging instanciated - */ - - value: function addPaging() { - var filterTable = arguments[0] === undefined ? false : arguments[0]; - - var tf = this.tf; - if (!tf.hasGrid() || tf.paging) { - return; - } - tf.paging = true; - this.isPagingRemoved = true; - this.init(); - tf.resetValues(); - if (filterTable) { - tf.filter(); - } - }, - writable: true, - configurable: true - }, - setPagingInfo: { - - /** - * Calculate number of pages based on valid rows - * Refresh paging select according to number of pages - * @param {Array} validRows Collection of valid rows - */ - - value: function setPagingInfo(validRows) { - var tf = this.tf; - var rows = tf.tbl.rows; - var mdiv = !this.pagingTgtId ? tf.mDiv : Dom.id(this.pagingTgtId); - var pgspan = Dom.id(tf.prfxPgSpan + tf.id); - //stores valid rows indexes - if (validRows && validRows.length > 0) { - tf.validRowsIndex = validRows; - } else { - //re-sets valid rows indexes array - tf.validRowsIndex = []; - - //counts rows to be grouped - for (var j = tf.refRow; j < tf.nbRows; j++) { - var row = rows[j]; - if (!row) { - continue; - } - var isRowValid = row.getAttribute("validRow"); - if (isRowValid === "true" || !isRowValid) { - tf.validRowsIndex.push(j); - } - } - } - - //calculate nb of pages - this.nbPages = Math.ceil(tf.validRowsIndex.length / this.pagingLength); - //refresh page nb span - pgspan.innerHTML = this.nbPages; - //select clearing shortcut - if (this.pageSelectorType === tf.fltTypeSlc) { - this.pagingSlc.innerHTML = ""; - } - - if (this.nbPages > 0) { - mdiv.style.visibility = "visible"; - if (this.pageSelectorType === tf.fltTypeSlc) { - for (var z = 0; z < this.nbPages; z++) { - var currOpt = new Option(z + 1, z * this.pagingLength, false, false); - this.pagingSlc.options[z] = currOpt; - } - } else { - //input type - this.pagingSlc.value = this.currentPageNb; - } - } else { - /*** if no results paging select and buttons are hidden ***/ - mdiv.style.visibility = "hidden"; - } - this.groupByPage(tf.validRowsIndex); - }, - writable: true, - configurable: true - }, - groupByPage: { - - /** - * Group table rows by page and display valid rows - * @param {Array} validRows Collection of valid rows - */ - - value: function groupByPage(validRows) { - var tf = this.tf; - var rows = tf.tbl.rows; - var paging_end_row = parseInt(this.startPagingRow, 10) + parseInt(this.pagingLength, 10); - - //store valid rows indexes - if (validRows) { - tf.validRowsIndex = validRows; - } - - //this loop shows valid rows of current page - for (var h = 0; h < tf.validRowsIndex.length; h++) { - var r = rows[tf.validRowsIndex[h]]; - if (h >= this.startPagingRow && h < paging_end_row) { - if (r.getAttribute("validRow") === "true" || !r.getAttribute("validRow")) { - r.style.display = ""; - } - if (tf.alternateBgs && tf.Cpt.alternateRows) { - tf.Cpt.alternateRows.setRowBg(tf.validRowsIndex[h], h); - } - } else { - r.style.display = "none"; - if (tf.alternateBgs && tf.Cpt.alternateRows) { - tf.Cpt.alternateRows.removeRowBg(tf.validRowsIndex[h]); - } - } - } - - tf.nbVisibleRows = tf.validRowsIndex.length; - tf.isStartBgAlternate = false; - //re-applies filter behaviours after filtering process - tf.applyGridProps(); - }, - writable: true, - configurable: true - }, - setPage: { - - /** - * Show page based on passed param value (string or number): - * @param {String} or {Number} cmd possible string values: 'next', - * 'previous', 'last', 'first' or page number as per param - */ - - value: function setPage(cmd) { - var tf = this.tf; - if (!tf.hasGrid() || !this.paging) { - return; - } - var btnEvt = this.evt, - cmdtype = typeof cmd; - if (cmdtype === "string") { - switch (Str.lower(cmd)) { - case "next": - btnEvt.next(); - break; - case "previous": - btnEvt.prev(); - break; - case "last": - btnEvt.last(); - break; - case "first": - btnEvt.first(); - break; - default: - btnEvt.next(); - break; - } - } else if (cmdtype === "number") { - this.changePage(cmd - 1); - } - }, - writable: true, - configurable: true - }, - setResultsPerPage: { - - /** - * Generates UI elements for the number of results per page drop-down - */ - - value: function setResultsPerPage() { - var _this = this; - - var tf = this.tf; - var evt = this.evt; - - if (!tf.hasGrid() && !tf.isFirstLoad) { - return; - } - if (this.resultsPerPageSlc || !this.resultsPerPage) { - return; - } - - /*==================================================== - - onchange event for results per page select - =====================================================*/ - evt.slcResultsChange = function (ev) { - _this.changeResultsPerPage(); - ev.target.blur(); - }; - - var slcR = Dom.create(tf.fltTypeSlc, ["id", tf.prfxSlcResults + tf.id]); - slcR.className = tf.resultsSlcCssClass; - var slcRText = this.resultsPerPage[0], - slcROpts = this.resultsPerPage[1]; - var slcRSpan = Dom.create("span", ["id", tf.prfxSlcResultsTxt + tf.id]); - slcRSpan.className = this.resultsSpanCssClass; - - // results per page select is added to external element - if (!this.resultsPerPageTgtId) { - tf.setToolbar(); - } - var targetEl = !this.resultsPerPageTgtId ? tf.rDiv : Dom.id(this.resultsPerPageTgtId); - slcRSpan.appendChild(Dom.text(slcRText)); - targetEl.appendChild(slcRSpan); - targetEl.appendChild(slcR); - - this.resultsPerPageSlc = Dom.id(tf.prfxSlcResults + tf.id); - - for (var r = 0; r < slcROpts.length; r++) { - var currOpt = new Option(slcROpts[r], slcROpts[r], false, false); - this.resultsPerPageSlc.options[r] = currOpt; - } - Event.add(slcR, "change", evt.slcResultsChange); - }, - writable: true, - configurable: true - }, - removeResultsPerPage: { - - /** - * Remove number of results per page UI elements - */ - - value: function removeResultsPerPage() { - var tf = this.tf; - if (!tf.hasGrid() || !this.resultsPerPageSlc || !this.resultsPerPage) { - return; - } - var slcR = this.resultsPerPageSlc, - slcRSpan = Dom.id(tf.prfxSlcResultsTxt + tf.id); - if (slcR) { - slcR.parentNode.removeChild(slcR); - } - if (slcRSpan) { - slcRSpan.parentNode.removeChild(slcRSpan); - } - this.resultsPerPageSlc = null; - }, - writable: true, - configurable: true - }, - changePage: { - - /** - * Change the page asynchronously according to passed index - * @param {Number} index Index of the page (0-n) - */ - - value: function changePage(index) { - var tf = this.tf; - var evt = tf.Evt; - tf.EvtManager(evt.name.changepage, { pgIndex: index }); - }, - writable: true, - configurable: true - }, - changeResultsPerPage: { - - /** - * Change rows asynchronously according to page results - */ - - value: function changeResultsPerPage() { - var tf = this.tf; - var evt = tf.Evt; - tf.EvtManager(evt.name.changeresultsperpage); - }, - writable: true, - configurable: true - }, - resetPage: { - - /** - * Re-set asynchronously page nb at page re-load - */ - - value: function resetPage() { - var tf = this.tf; - var evt = tf.Evt; - tf.EvtManager(evt.name.resetpage); - }, - writable: true, - configurable: true - }, - resetPageLength: { - - /** - * Re-set asynchronously page length at page re-load - */ - - value: function resetPageLength() { - var tf = this.tf; - var evt = tf.Evt; - tf.EvtManager(evt.name.resetpagelength); - }, - writable: true, - configurable: true - }, - _changePage: { - - /** - * Change the page according to passed index - * @param {Number} index Index of the page (0-n) - */ - - value: function _changePage(index) { - var tf = this.tf; - - if (!tf.paging) { - return; - } - if (index === null) { - index = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.options.selectedIndex : this.pagingSlc.value - 1; - } - if (index >= 0 && index <= this.nbPages - 1) { - if (this.onBeforeChangePage) { - this.onBeforeChangePage.call(null, this, index); - } - this.currentPageNb = parseInt(index, 10) + 1; - if (this.pageSelectorType === tf.fltTypeSlc) { - this.pagingSlc.options[index].selected = true; - } else { - this.pagingSlc.value = this.currentPageNb; - } - - if (tf.rememberPageNb) { - tf.Cpt.store.savePageNb(tf.pgNbCookie); - } - this.startPagingRow = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.value : index * this.pagingLength; - - this.groupByPage(); - - if (this.onAfterChangePage) { - this.onAfterChangePage.call(null, this, index); - } - } - }, - writable: true, - configurable: true - }, - _changeResultsPerPage: { - - /** - * Change rows according to page results - */ - - value: function _changeResultsPerPage() { - var tf = this.tf; - - if (!tf.paging) { - return; - } - var slcR = this.resultsPerPageSlc; - var slcPagesSelIndex = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.selectedIndex : parseInt(this.pagingSlc.value - 1, 10); - this.pagingLength = parseInt(slcR.options[slcR.selectedIndex].value, 10); - this.startPagingRow = this.pagingLength * slcPagesSelIndex; - - if (!isNaN(this.pagingLength)) { - if (this.startPagingRow >= tf.nbFilterableRows) { - this.startPagingRow = tf.nbFilterableRows - this.pagingLength; - } - this.setPagingInfo(); - - if (this.pageSelectorType === tf.fltTypeSlc) { - var slcIndex = this.pagingSlc.options.length - 1 <= slcPagesSelIndex ? this.pagingSlc.options.length - 1 : slcPagesSelIndex; - this.pagingSlc.options[slcIndex].selected = true; - } - if (tf.rememberPageLen) { - tf.Cpt.store.savePageLength(tf.pgLenCookie); - } - } - }, - writable: true, - configurable: true - }, - _resetPage: { - - /** - * Re-set page nb at page re-load - */ - - value: function _resetPage(name) { - var tf = this.tf; - var pgnb = tf.Cpt.store.getPageNb(name); - if (pgnb !== "") { - this.changePage(pgnb - 1); - } - }, - writable: true, - configurable: true - }, - _resetPageLength: { - - /** - * Re-set page length at page re-load - */ - - value: function _resetPageLength(name) { - var tf = this.tf; - if (!tf.paging) { - return; - } - var pglenIndex = tf.Cpt.store.getPageLength(name); - - if (pglenIndex !== "") { - this.resultsPerPageSlc.options[pglenIndex].selected = true; - this.changeResultsPerPage(); - } - }, - writable: true, - configurable: true - }, - destroy: { - - /** - * Remove paging feature - */ - - value: function destroy() { - var tf = this.tf; - - if (!tf.hasGrid()) { - return; - } - // btns containers - var btnNextSpan, btnPrevSpan, btnLastSpan, btnFirstSpan; - var pgBeforeSpan, pgAfterSpan, pgspan; - btnNextSpan = Dom.id(tf.prfxBtnNextSpan + tf.id); - btnPrevSpan = Dom.id(tf.prfxBtnPrevSpan + tf.id); - btnLastSpan = Dom.id(tf.prfxBtnLastSpan + tf.id); - btnFirstSpan = Dom.id(tf.prfxBtnFirstSpan + tf.id); - //span containing 'Page' text - pgBeforeSpan = Dom.id(tf.prfxPgBeforeSpan + tf.id); - //span containing 'of' text - pgAfterSpan = Dom.id(tf.prfxPgAfterSpan + tf.id); - //span containing nb of pages - pgspan = Dom.id(tf.prfxPgSpan + tf.id); - - var evt = this.evt; - - if (this.pagingSlc) { - if (this.pageSelectorType === tf.fltTypeSlc) { - Event.remove(this.pagingSlc, "change", evt.slcPagesChange); - } else if (this.pageSelectorType === tf.fltTypeInp) { - Event.remove(this.pagingSlc, "keypress", evt._detectKey); - } - this.pagingSlc.parentNode.removeChild(this.pagingSlc); - } - - if (btnNextSpan) { - Event.remove(btnNextSpan, "click", evt.next); - btnNextSpan.parentNode.removeChild(btnNextSpan); - } - - if (btnPrevSpan) { - Event.remove(btnPrevSpan, "click", evt.prev); - btnPrevSpan.parentNode.removeChild(btnPrevSpan); - } - - if (btnLastSpan) { - Event.remove(btnLastSpan, "click", evt.last); - btnLastSpan.parentNode.removeChild(btnLastSpan); - } - - if (btnFirstSpan) { - Event.remove(btnFirstSpan, "click", evt.first); - btnFirstSpan.parentNode.removeChild(btnFirstSpan); - } - - if (pgBeforeSpan) { - pgBeforeSpan.parentNode.removeChild(pgBeforeSpan); - } - - if (pgAfterSpan) { - pgAfterSpan.parentNode.removeChild(pgAfterSpan); - } - - if (pgspan) { - pgspan.parentNode.removeChild(pgspan); - } - - if (this.hasResultsPerPage) { - this.removeResultsPerPage(); - } - - this.pagingSlc = null; - this.nbPages = 0; - this.isPagingRemoved = true; - tf.paging = false; - }, - writable: true, - configurable: true - } - }); - - return Paging; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=paging.js.map; -define('modules/clearButton',["exports", "../dom", "../event"], function (exports, _dom, _event) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - var Event = _event.Event; - - var ClearButton = exports.ClearButton = (function () { - - /** - * Clear button component - * @param {Object} tf TableFilter instance - */ - - function ClearButton(tf) { - _classCallCheck(this, ClearButton); - - // Configuration object - var f = tf.config(); - - //id of container element - this.btnResetTgtId = f.btn_reset_target_id || null; - //reset button element - this.btnResetEl = null; - //defines reset text - this.btnResetText = f.btn_reset_text || "Reset"; - //defines reset button tooltip - this.btnResetTooltip = f.btn_reset_tooltip || "Clear filters"; - //defines reset button innerHtml - this.btnResetHtml = f.btn_reset_html || (!tf.enableIcons ? null : ""); - - this.tf = tf; - } - - _prototypeProperties(ClearButton, null, { - onClick: { - value: function onClick() { - this.tf.clearFilters(); - }, - writable: true, - configurable: true - }, - init: { - - /** - * Build DOM elements - */ - - value: function init() { - var _this = this; - - var tf = this.tf; - - if (!tf.hasGrid() && !tf.isFirstLoad && tf.btnResetEl) { - return; - } - - var resetspan = Dom.create("span", ["id", tf.prfxResetSpan + tf.id]); - - // reset button is added to defined element - if (!this.btnResetTgtId) { - tf.setToolbar(); - } - var targetEl = !this.btnResetTgtId ? tf.rDiv : Dom.id(this.btnResetTgtId); - targetEl.appendChild(resetspan); - - if (!this.btnResetHtml) { - var fltreset = Dom.create("a", ["href", "javascript:void(0);"]); - fltreset.className = tf.btnResetCssClass; - fltreset.appendChild(Dom.text(this.btnResetText)); - resetspan.appendChild(fltreset); - // fltreset.onclick = this.Evt._Clear; - Event.add(fltreset, "click", function () { - _this.onClick(); - }); - } else { - resetspan.innerHTML = this.btnResetHtml; - var resetEl = resetspan.firstChild; - // resetEl.onclick = this.Evt._Clear; - Event.add(resetEl, "click", function () { - _this.onClick(); - }); - } - this.btnResetEl = resetspan.firstChild; - }, - writable: true, - configurable: true - }, - destroy: { - - /** - * Remove clear button UI - */ - - value: function destroy() { - var tf = this.tf; - - if (!tf.hasGrid() || !this.btnResetEl) { - return; - } - - var resetspan = Dom.id(tf.prfxResetSpan + tf.id); - if (resetspan) { - resetspan.parentNode.removeChild(resetspan); - } - this.btnResetEl = null; - }, - writable: true, - configurable: true - } - }); - - return ClearButton; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=clearButton.js.map; -define('modules/help',["exports", "../dom", "../event"], function (exports, _dom, _event) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - var Event = _event.Event; - - var Help = exports.Help = (function () { - - /** - * Help UI component - * @param {Object} tf TableFilter instance - */ - - function Help(tf) { - _classCallCheck(this, Help); - - // Configuration object - var f = tf.config(); - - //id of custom container element for instructions - this.helpInstrTgtId = f.help_instructions_target_id || null; - //id of custom container element for instructions - this.helpInstrContTgtId = f.help_instructions_container_target_id || null; - //defines help text - this.helpInstrText = f.help_instructions_text ? f.help_instructions_text : "Use the filters above each column to filter and limit table " + "data. Avanced searches can be performed by using the following " + "operators:
<, <=, >, " + ">=, =, *, !, {, }, " + "||,&&, [empty], [nonempty], " + "rgx:
These operators are described here:
" + "http://tablefilter.free.fr/#operators
"; - //defines help innerHtml - this.helpInstrHtml = f.help_instructions_html || null; - //defines reset button text - this.helpInstrBtnText = f.help_instructions_btn_text || "?"; - //defines reset button innerHtml - this.helpInstrBtnHtml = f.help_instructions_btn_html || null; - //defines css class for help button - this.helpInstrBtnCssClass = f.help_instructions_btn_css_class || "helpBtn"; - //defines css class for help container - this.helpInstrContCssClass = f.help_instructions_container_css_class || "helpCont"; - //help button element - this.helpInstrBtnEl = null; - //help content div - this.helpInstrContEl = null; - this.helpInstrDefaultHtml = "

HTML Table " + "Filter Generator v. " + tf.version + "

" + "" + "http://tablefilter.free.fr
" + "©2009-" + tf.year + " Max Guglielmi." + "
" + "Close
"; - - this.tf = tf; - } - - _prototypeProperties(Help, null, { - init: { - value: function init() { - var _this = this; - - if (this.helpInstrBtnEl) { - return; - } - - var tf = this.tf; - - var helpspan = Dom.create("span", ["id", tf.prfxHelpSpan + tf.id]); - var helpdiv = Dom.create("div", ["id", tf.prfxHelpDiv + tf.id]); - - //help button is added to defined element - if (!this.helpInstrTgtId) { - tf.setToolbar(); - } - var targetEl = !this.helpInstrTgtId ? tf.rDiv : Dom.id(this.helpInstrTgtId); - targetEl.appendChild(helpspan); - - var divContainer = !this.helpInstrContTgtId ? helpspan : Dom.id(this.helpInstrContTgtId); - - if (!this.helpInstrBtnHtml) { - divContainer.appendChild(helpdiv); - var helplink = Dom.create("a", ["href", "javascript:void(0);"]); - helplink.className = this.helpInstrBtnCssClass; - helplink.appendChild(Dom.text(this.helpInstrBtnText)); - helpspan.appendChild(helplink); - Event.add(helplink, "click", function () { - _this.toggle(); - }); - } else { - helpspan.innerHTML = this.helpInstrBtnHtml; - var helpEl = helpspan.firstChild; - Event.add(helpEl, "click", function () { - _this.toggle(); - }); - divContainer.appendChild(helpdiv); - } - - if (!this.helpInstrHtml) { - helpdiv.innerHTML = this.helpInstrText; - helpdiv.className = this.helpInstrContCssClass; - Event.add(helpdiv, "dblclick", function () { - _this.toggle(); - }); - } else { - if (this.helpInstrContTgtId) { - divContainer.appendChild(helpdiv); - } - helpdiv.innerHTML = this.helpInstrHtml; - if (!this.helpInstrContTgtId) { - helpdiv.className = this.helpInstrContCssClass; - Event.add(helpdiv, "dblclick", function () { - _this.toggle(); - }); - } - } - helpdiv.innerHTML += this.helpInstrDefaultHtml; - Event.add(helpdiv, "click", function () { - _this.toggle(); - }); - - this.helpInstrContEl = helpdiv; - this.helpInstrBtnEl = helpspan; - }, - writable: true, - configurable: true - }, - toggle: { - - /** - * Toggle help pop-up - */ - - value: function toggle() { - if (!this.helpInstrContEl) { - return; - } - var divDisplay = this.helpInstrContEl.style.display; - if (divDisplay === "" || divDisplay === "none") { - this.helpInstrContEl.style.display = "block"; - // TODO: use CSS instead for element positioning - var btnLeft = Dom.position(this.helpInstrBtnEl).left; - if (!this.helpInstrContTgtId) { - this.helpInstrContEl.style.left = btnLeft - this.helpInstrContEl.clientWidth + 25 + "px"; - } - } else { - this.helpInstrContEl.style.display = "none"; - } - }, - writable: true, - configurable: true - }, - destroy: { - - /** - * Remove help UI - */ - - value: function destroy() { - if (!this.helpInstrBtnEl) { - return; - } - this.helpInstrBtnEl.parentNode.removeChild(this.helpInstrBtnEl); - this.helpInstrBtnEl = null; - if (!this.helpInstrContEl) { - return; - } - this.helpInstrContEl.parentNode.removeChild(this.helpInstrContEl); - this.helpInstrContEl = null; - }, - writable: true, - configurable: true - } - }); - - return Help; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=help.js.map; -define('modules/alternateRows',["exports", "../dom"], function (exports, _dom) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - - var AlternateRows = exports.AlternateRows = (function () { - - /** - * Alternating rows color - * @param {Object} tf TableFilter instance - */ - - function AlternateRows(tf) { - _classCallCheck(this, AlternateRows); - - var f = tf.config(); - //defines css class for even rows - this.evenCss = f.even_row_css_class || "even"; - //defines css class for odd rows - this.oddCss = f.odd_row_css_class || "odd"; - - this.tf = tf; - } - - _prototypeProperties(AlternateRows, null, { - init: { - - /** - * Sets alternating rows color - */ - - value: function init() { - if (!this.tf.hasGrid() && !this.tf.isFirstLoad) { - return; - } - var rows = this.tf.tbl.rows; - var noValidRowsIndex = this.tf.validRowsIndex === null; - //1st index - var beginIndex = noValidRowsIndex ? this.tf.refRow : 0; - // nb indexes - var indexLen = noValidRowsIndex ? this.tf.nbFilterableRows + beginIndex : this.tf.validRowsIndex.length; - var idx = 0; - - //alternates bg color - for (var j = beginIndex; j < indexLen; j++) { - var rowIdx = noValidRowsIndex ? j : this.tf.validRowsIndex[j]; - this.setRowBg(rowIdx, idx); - idx++; - } - }, - writable: true, - configurable: true - }, - setRowBg: { - - /** - * Sets row background color - * @param {Number} rowIdx Row index - * @param {Number} idx Valid rows collection index needed to calculate bg - * color - */ - - value: function setRowBg(rowIdx, idx) { - if (!this.tf.alternateBgs || isNaN(rowIdx)) { - return; - } - var rows = this.tf.tbl.rows; - var i = !idx ? rowIdx : idx; - this.removeRowBg(rowIdx); - Dom.addClass(rows[rowIdx], i % 2 ? this.evenCss : this.oddCss); - }, - writable: true, - configurable: true - }, - removeRowBg: { - - /** - * Removes row background color - * @param {Number} idx Row index - */ - - value: function removeRowBg(idx) { - if (isNaN(idx)) { - return; - } - var rows = this.tf.tbl.rows; - Dom.removeClass(rows[idx], this.oddCss); - Dom.removeClass(rows[idx], this.evenCss); - }, - writable: true, - configurable: true - }, - remove: { - - /** - * Removes all row background color - */ - - value: function remove() { - if (!this.tf.hasGrid()) { - return; - } - var row = this.tf.tbl.rows; - for (var i = this.tf.refRow; i < this.tf.nbRows; i++) { - this.removeRowBg(i); - } - this.tf.isStartBgAlternate = true; - }, - writable: true, - configurable: true - }, - enable: { - value: function enable() { - this.tf.alternateBgs = true; - }, - writable: true, - configurable: true - }, - disable: { - value: function disable() { - this.tf.alternateBgs = false; - }, - writable: true, - configurable: true - } - }); - - return AlternateRows; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=alternateRows.js.map; -define('modules/colOps',["exports", "../dom", "../string", "../types"], function (exports, _dom, _string, _types) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Dom = _dom.Dom; - var Str = _string.Str; - var Types = _types.Types; - - var ColOps = exports.ColOps = (function () { - - /** - * Column calculations - * @param {Object} tf TableFilter instance - */ - - function ColOps(tf) { - _classCallCheck(this, ColOps); - - var f = tf.config(); - this.colOperation = f.col_operation; - - //calls function before col operation - this.onBeforeOperation = Types.isFn(f.on_before_operation) ? f.on_before_operation : null; - //calls function after col operation - this.onAfterOperation = Types.isFn(f.on_after_operation) ? f.on_after_operation : null; - - this.tf = tf; - } - - _prototypeProperties(ColOps, null, { - calc: { - - /** - * Calculates columns' values - * Configuration options are stored in 'colOperation' property - * - 'id' contains ids of elements showing result (array) - * - 'col' contains the columns' indexes (array) - * - 'operation' contains operation type (array, values: 'sum', 'mean', - * 'min', 'max', 'median', 'q1', 'q3') - * - 'write_method' array defines which method to use for displaying the - * result (innerHTML, setValue, createTextNode) - default: 'innerHTML' - * - 'tot_row_index' defines in which row results are displayed - * (integers array) - * - * - changes made by Nuovella: - * (1) optimized the routine (now it will only process each column once), - * (2) added calculations for the median, lower and upper quartile. - */ - - value: function calc() { - if (!this.tf.isFirstLoad && !this.tf.hasGrid()) { - return; - } - - if (this.onBeforeOperation) { - this.onBeforeOperation.call(null, this.tf); - } - - var colOperation = this.colOperation, - labelId = colOperation.id, - colIndex = colOperation.col, - operation = colOperation.operation, - outputType = colOperation.write_method, - totRowIndex = colOperation.tot_row_index, - excludeRow = colOperation.exclude_row, - decimalPrecision = colOperation.decimal_precision !== undefined ? colOperation.decimal_precision : 2; - - //nuovella: determine unique list of columns to operate on - var ucolIndex = [], - ucolMax = 0; - ucolIndex[ucolMax] = colIndex[0]; - - for (var ii = 1; ii < colIndex.length; ii++) { - var saved = 0; - //see if colIndex[ii] is already in the list of unique indexes - for (var jj = 0; jj <= ucolMax; jj++) { - if (ucolIndex[jj] === colIndex[ii]) { - saved = 1; - } - } - //if not saved then, save the index; - if (saved === 0) { - ucolMax++; - ucolIndex[ucolMax] = colIndex[ii]; - } - } - - if (Str.lower(typeof labelId) == "object" && Str.lower(typeof colIndex) == "object" && Str.lower(typeof operation) == "object") { - var row = this.tf.tbl.rows, - colvalues = []; - - for (var ucol = 0; ucol <= ucolMax; ucol++) { - //this retrieves col values - //use ucolIndex because we only want to pass through this loop - //once for each column get the values in this unique column - colvalues.push(this.tf.getColValues(ucolIndex[ucol], true, excludeRow)); - - //next: calculate all operations for this column - var result, - nbvalues = 0, - temp, - meanValue = 0, - sumValue = 0, - minValue = null, - maxValue = null, - q1Value = null, - medValue = null, - q3Value = null, - meanFlag = 0, - sumFlag = 0, - minFlag = 0, - maxFlag = 0, - q1Flag = 0, - medFlag = 0, - q3Flag = 0, - theList = [], - opsThisCol = [], - decThisCol = [], - labThisCol = [], - oTypeThisCol = [], - mThisCol = -1; - - for (var k = 0; k < colIndex.length; k++) { - if (colIndex[k] === ucolIndex[ucol]) { - mThisCol++; - opsThisCol[mThisCol] = Str.lower(operation[k]); - decThisCol[mThisCol] = decimalPrecision[k]; - labThisCol[mThisCol] = labelId[k]; - oTypeThisCol = outputType !== undefined && Str.lower(typeof outputType) === "object" ? outputType[k] : null; - - switch (opsThisCol[mThisCol]) { - case "mean": - meanFlag = 1; - break; - case "sum": - sumFlag = 1; - break; - case "min": - minFlag = 1; - break; - case "max": - maxFlag = 1; - break; - case "median": - medFlag = 1; - break; - case "q1": - q1Flag = 1; - break; - case "q3": - q3Flag = 1; - break; - } - } - } - - for (var j = 0; j < colvalues[ucol].length; j++) { - //sort the list for calculation of median and quartiles - if (q1Flag == 1 || q3Flag == 1 || medFlag == 1) { - if (j < colvalues[ucol].length - 1) { - for (k = j + 1; k < colvalues[ucol].length; k++) { - if (eval(colvalues[ucol][k]) < eval(colvalues[ucol][j])) { - temp = colvalues[ucol][j]; - colvalues[ucol][j] = colvalues[ucol][k]; - colvalues[ucol][k] = temp; - } - } - } - } - var cvalue = parseFloat(colvalues[ucol][j]); - theList[j] = parseFloat(cvalue); - - if (!isNaN(cvalue)) { - nbvalues++; - if (sumFlag === 1 || meanFlag === 1) { - sumValue += parseFloat(cvalue); - } - if (minFlag === 1) { - if (minValue === null) { - minValue = parseFloat(cvalue); - } else { - minValue = parseFloat(cvalue) < minValue ? parseFloat(cvalue) : minValue; - } - } - if (maxFlag === 1) { - if (maxValue === null) { - maxValue = parseFloat(cvalue); - } else { - maxValue = parseFloat(cvalue) > maxValue ? parseFloat(cvalue) : maxValue; - } - } - } - } //for j - if (meanFlag === 1) { - meanValue = sumValue / nbvalues; - } - if (medFlag === 1) { - var aux = 0; - if (nbvalues % 2 === 1) { - aux = Math.floor(nbvalues / 2); - medValue = theList[aux]; - } else { - medValue = (theList[nbvalues / 2] + theList[nbvalues / 2 - 1]) / 2; - } - } - var posa; - if (q1Flag === 1) { - posa = 0; - posa = Math.floor(nbvalues / 4); - if (4 * posa == nbvalues) { - q1Value = (theList[posa - 1] + theList[posa]) / 2; - } else { - q1Value = theList[posa]; - } - } - if (q3Flag === 1) { - posa = 0; - var posb = 0; - posa = Math.floor(nbvalues / 4); - if (4 * posa === nbvalues) { - posb = 3 * posa; - q3Value = (theList[posb] + theList[posb - 1]) / 2; - } else { - q3Value = theList[nbvalues - posa - 1]; - } - } - - for (var i = 0; i <= mThisCol; i++) { - switch (opsThisCol[i]) { - case "mean": - result = meanValue; - break; - case "sum": - result = sumValue; - break; - case "min": - result = minValue; - break; - case "max": - result = maxValue; - break; - case "median": - result = medValue; - break; - case "q1": - result = q1Value; - break; - case "q3": - result = q3Value; - break; - } - - var precision = !isNaN(decThisCol[i]) ? decThisCol[i] : 2; - - //if outputType is defined - if (oTypeThisCol && result) { - result = result.toFixed(precision); - - if (Dom.id(labThisCol[i])) { - switch (Str.lower(oTypeThisCol)) { - case "innerhtml": - if (isNaN(result) || !isFinite(result) || nbvalues === 0) { - Dom.id(labThisCol[i]).innerHTML = "."; - } else { - Dom.id(labThisCol[i]).innerHTML = result; - } - break; - case "setvalue": - Dom.id(labThisCol[i]).value = result; - break; - case "createtextnode": - var oldnode = Dom.id(labThisCol[i]).firstChild; - var txtnode = Dom.text(result); - Dom.id(labThisCol[i]).replaceChild(txtnode, oldnode); - break; - } //switch - } - } else { - try { - if (isNaN(result) || !isFinite(result) || nbvalues === 0) { - Dom.id(labThisCol[i]).innerHTML = "."; - } else { - Dom.id(labThisCol[i]).innerHTML = result.toFixed(precision); - } - } catch (e) {} //catch - } //else - } //for i - - // row(s) with result are always visible - var totRow = totRowIndex && totRowIndex[ucol] ? row[totRowIndex[ucol]] : null; - if (totRow) { - totRow.style.display = ""; - } - } //for ucol - } //if typeof - - if (this.onAfterOperation) { - this.onAfterOperation.call(null, this.tf); - } - }, - writable: true, - configurable: true - } - }); - - return ColOps; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=colOps.js.map; -/*----------------------------------------------------------------------------\ -| Sortable Table 1.12 | -|-----------------------------------------------------------------------------| -| Created by Erik Arvidsson | -| (http://webfx.eae.net/contact.html#erik) | -| For WebFX (http://webfx.eae.net/) | -|-----------------------------------------------------------------------------| -| A DOM 1 based script that allows an ordinary HTML table to be sortable. | -|-----------------------------------------------------------------------------| -| Copyright (c) 1998 - 2006 Erik Arvidsson | -|-----------------------------------------------------------------------------| -| Licensed under the Apache License, Version 2.0 (the "License"); you may not | -| use this file except in compliance with the License. You may obtain a copy | -| of the License at http://www.apache.org/licenses/LICENSE-2.0 | -| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | -| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | -| License for the specific language governing permissions and limitations | -| under the License. | -|-----------------------------------------------------------------------------| -| 2003-01-10 | First version | -| 2003-01-19 | Minor changes to the date parsing | -| 2003-01-28 | JScript 5.0 fixes (no support for 'in' operator) | -| 2003-02-01 | Sloppy typo like error fixed in getInnerText | -| 2003-07-04 | Added workaround for IE cellIndex bug. | -| 2003-11-09 | The bDescending argument to sort was not correctly working | -| | Using onclick DOM0 event if no support for addEventListener | -| | or attachEvent | -| 2004-01-13 | Adding addSortType and removeSortType which makes it a lot | -| | easier to add new, custom sort types. | -| 2004-01-27 | Switch to use descending = false as the default sort order. | -| | Change defaultDescending to suit your needs. | -| 2004-03-14 | Improved sort type None look and feel a bit | -| 2004-08-26 | Made the handling of tBody and tHead more flexible. Now you | -| | can use another tHead or no tHead, and you can chose some | -| | other tBody. | -| 2006-04-25 | Changed license to Apache Software License 2.0 | -|-----------------------------------------------------------------------------| -| Created 2003-01-10 | All changes are in the log above. | Updated 2006-04-25 | -\----------------------------------------------------------------------------*/ - - -function SortableTable(oTable, oSortTypes) { - - this.sortTypes = oSortTypes || []; - - this.sortColumn = null; - this.descending = null; - - var oThis = this; - this._headerOnclick = function (e) { - oThis.headerOnclick(e); - }; - - if (oTable) { - this.setTable( oTable ); - this.document = oTable.ownerDocument || oTable.document; - } - else { - this.document = document; - } - - - // only IE needs this - var win = this.document.defaultView || this.document.parentWindow; - this._onunload = function () { - oThis.destroy(); - }; - if (win && typeof win.attachEvent != "undefined") { - win.attachEvent("onunload", this._onunload); - } -} - -SortableTable.gecko = navigator.product == "Gecko"; -SortableTable.msie = /msie/i.test(navigator.userAgent); -// Mozilla is faster when doing the DOM manipulations on -// an orphaned element. MSIE is not -SortableTable.removeBeforeSort = SortableTable.gecko; - -SortableTable.prototype.onsort = function () {}; - -// default sort order. true -> descending, false -> ascending -SortableTable.prototype.defaultDescending = false; - -// shared between all instances. This is intentional to allow external files -// to modify the prototype -SortableTable.prototype._sortTypeInfo = {}; - -SortableTable.prototype.setTable = function (oTable) { - if ( this.tHead ) - this.uninitHeader(); - this.element = oTable; - this.setTHead( oTable.tHead ); - this.setTBody( oTable.tBodies[0] ); -}; - -SortableTable.prototype.setTHead = function (oTHead) { - if (this.tHead && this.tHead != oTHead ) - this.uninitHeader(); - this.tHead = oTHead; - this.initHeader( this.sortTypes ); -}; - -SortableTable.prototype.setTBody = function (oTBody) { - this.tBody = oTBody; -}; - -SortableTable.prototype.setSortTypes = function ( oSortTypes ) { - if ( this.tHead ) - this.uninitHeader(); - this.sortTypes = oSortTypes || []; - if ( this.tHead ) - this.initHeader( this.sortTypes ); -}; - -// adds arrow containers and events -// also binds sort type to the header cells so that reordering columns does -// not break the sort types -SortableTable.prototype.initHeader = function (oSortTypes) { - if (!this.tHead) return; - var cells = this.tHead.rows[0].cells; - var doc = this.tHead.ownerDocument || this.tHead.document; - this.sortTypes = oSortTypes || []; - var l = cells.length; - var img, c; - for (var i = 0; i < l; i++) { - c = cells[i]; - if (this.sortTypes[i] != null && this.sortTypes[i] != "None") { - img = doc.createElement("IMG"); - img.src = "images/blank.png"; - c.appendChild(img); - if (this.sortTypes[i] != null) - c._sortType = this.sortTypes[i]; - if (typeof c.addEventListener != "undefined") - c.addEventListener("click", this._headerOnclick, false); - else if (typeof c.attachEvent != "undefined") - c.attachEvent("onclick", this._headerOnclick); - else - c.onclick = this._headerOnclick; - } - else - { - c.setAttribute( "_sortType", oSortTypes[i] ); - c._sortType = "None"; - } - } - this.updateHeaderArrows(); -}; - -// remove arrows and events -SortableTable.prototype.uninitHeader = function () { - if (!this.tHead) return; - var cells = this.tHead.rows[0].cells; - var l = cells.length; - var c; - for (var i = 0; i < l; i++) { - c = cells[i]; - if (c._sortType != null && c._sortType != "None") { - c.removeChild(c.lastChild); - if (typeof c.removeEventListener != "undefined") - c.removeEventListener("click", this._headerOnclick, false); - else if (typeof c.detachEvent != "undefined") - c.detachEvent("onclick", this._headerOnclick); - c._sortType = null; - c.removeAttribute( "_sortType" ); - } - } -}; - -SortableTable.prototype.updateHeaderArrows = function () { - if (!this.tHead) return; - var cells = this.tHead.rows[0].cells; - var l = cells.length; - var img; - for (var i = 0; i < l; i++) { - if (cells[i]._sortType != null && cells[i]._sortType != "None") { - img = cells[i].lastChild; - if (i == this.sortColumn) - img.className = "sort-arrow " + (this.descending ? "descending" : "ascending"); - else - img.className = "sort-arrow"; - } - } -}; - -SortableTable.prototype.headerOnclick = function (e) { - // find TD element - var el = e.target || e.srcElement; - while (el.tagName != "TD") - el = el.parentNode; - - this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex); -}; - -// IE returns wrong cellIndex when columns are hidden -SortableTable.getCellIndex = function (oTd) { - var cells = oTd.parentNode.childNodes - var l = cells.length; - var i; - for (i = 0; cells[i] != oTd && i < l; i++) - ; - return i; -}; - -SortableTable.prototype.getSortType = function (nColumn) { - return this.sortTypes[nColumn] || "String"; -}; - -// only nColumn is required -// if bDescending is left out the old value is taken into account -// if sSortType is left out the sort type is found from the sortTypes array - -SortableTable.prototype.sort = function (nColumn, bDescending, sSortType) { - if (!this.tBody) return; - if (sSortType == null) - sSortType = this.getSortType(nColumn); - - // exit if None - if (sSortType == "None") - return; - - if (bDescending == null) { - if (this.sortColumn != nColumn) - this.descending = this.defaultDescending; - else - this.descending = !this.descending; - } - else - this.descending = bDescending; - - this.sortColumn = nColumn; - - if (typeof this.onbeforesort == "function") - this.onbeforesort(); - - var f = this.getSortFunction(sSortType, nColumn); - var a = this.getCache(sSortType, nColumn); - var tBody = this.tBody; - - a.sort(f); - - if (this.descending) - a.reverse(); - - if (SortableTable.removeBeforeSort) { - // remove from doc - var nextSibling = tBody.nextSibling; - var p = tBody.parentNode; - p.removeChild(tBody); - } - - // insert in the new order - var l = a.length; - for (var i = 0; i < l; i++) - tBody.appendChild(a[i].element); - - if (SortableTable.removeBeforeSort) { - // insert into doc - p.insertBefore(tBody, nextSibling); - } - - this.updateHeaderArrows(); - - this.destroyCache(a); - - if (typeof this.onsort == "function") - this.onsort(); -}; - -SortableTable.prototype.asyncSort = function (nColumn, bDescending, sSortType) { - var oThis = this; - this._asyncsort = function () { - oThis.sort(nColumn, bDescending, sSortType); - }; - window.setTimeout(this._asyncsort, 1); -}; - -SortableTable.prototype.getCache = function (sType, nColumn) { - if (!this.tBody) return []; - var rows = this.tBody.rows; - var l = rows.length; - var a = new Array(l); - var r; - for (var i = 0; i < l; i++) { - r = rows[i]; - a[i] = { - value: this.getRowValue(r, sType, nColumn), - element: r - }; - }; - return a; -}; - -SortableTable.prototype.destroyCache = function (oArray) { - var l = oArray.length; - for (var i = 0; i < l; i++) { - oArray[i].value = null; - oArray[i].element = null; - oArray[i] = null; - } -}; - -SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) { - // if we have defined a custom getRowValue use that - if (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue) - return this._sortTypeInfo[sType].getRowValue(oRow, nColumn); - - var s; - var c = oRow.cells[nColumn]; - if (typeof c.innerText != "undefined") - s = c.innerText; - else - s = SortableTable.getInnerText(c); - return this.getValueFromString(s, sType); -}; - -SortableTable.getInnerText = function (oNode) { - var s = ""; - var cs = oNode.childNodes; - var l = cs.length; - for (var i = 0; i < l; i++) { - switch (cs[i].nodeType) { - case 1: //ELEMENT_NODE - s += SortableTable.getInnerText(cs[i]); - break; - case 3: //TEXT_NODE - s += cs[i].nodeValue; - break; - } - } - return s; -}; - -SortableTable.prototype.getValueFromString = function (sText, sType) { - if (this._sortTypeInfo[sType]) - return this._sortTypeInfo[sType].getValueFromString( sText ); - return sText; - /* - switch (sType) { - case "Number": - return Number(sText); - case "CaseInsensitiveString": - return sText.toUpperCase(); - case "Date": - var parts = sText.split("-"); - var d = new Date(0); - d.setFullYear(parts[0]); - d.setDate(parts[2]); - d.setMonth(parts[1] - 1); - return d.valueOf(); - } - return sText; - */ - }; - -SortableTable.prototype.getSortFunction = function (sType, nColumn) { - if (this._sortTypeInfo[sType]) - return this._sortTypeInfo[sType].compare; - return SortableTable.basicCompare; -}; - -SortableTable.prototype.destroy = function () { - this.uninitHeader(); - var win = this.document.parentWindow; - if (win && typeof win.detachEvent != "undefined") { // only IE needs this - win.detachEvent("onunload", this._onunload); - } - this._onunload = null; - this.element = null; - this.tHead = null; - this.tBody = null; - this.document = null; - this._headerOnclick = null; - this.sortTypes = null; - this._asyncsort = null; - this.onsort = null; -}; - -// Adds a sort type to all instance of SortableTable -// sType : String - the identifier of the sort type -// fGetValueFromString : function ( s : string ) : T - A function that takes a -// string and casts it to a desired format. If left out the string is just -// returned -// fCompareFunction : function ( n1 : T, n2 : T ) : Number - A normal JS sort -// compare function. Takes two values and compares them. If left out less than, -// <, compare is used -// fGetRowValue : function( oRow : HTMLTRElement, nColumn : int ) : T - A function -// that takes the row and the column index and returns the value used to compare. -// If left out then the innerText is first taken for the cell and then the -// fGetValueFromString is used to convert that string the desired value and type - -SortableTable.prototype.addSortType = function (sType, fGetValueFromString, fCompareFunction, fGetRowValue) { - this._sortTypeInfo[sType] = { - type: sType, - getValueFromString: fGetValueFromString || SortableTable.idFunction, - compare: fCompareFunction || SortableTable.basicCompare, - getRowValue: fGetRowValue - }; -}; - -// this removes the sort type from all instances of SortableTable -SortableTable.prototype.removeSortType = function (sType) { - delete this._sortTypeInfo[sType]; -}; - -SortableTable.basicCompare = function compare(n1, n2) { - if (n1.value < n2.value) - return -1; - if (n2.value < n1.value) - return 1; - return 0; -}; - -SortableTable.idFunction = function (x) { - return x; -}; - -SortableTable.toUpperCase = function (s) { - return s.toUpperCase(); -}; - -SortableTable.toDate = function (s) { - var parts = s.split("-"); - var d = new Date(0); - d.setFullYear(parts[0]); - d.setDate(parts[2]); - d.setMonth(parts[1] - 1); - return d.valueOf(); -}; - - -// add sort types -SortableTable.prototype.addSortType("Number", Number); -SortableTable.prototype.addSortType("CaseInsensitiveString", SortableTable.toUpperCase); -SortableTable.prototype.addSortType("Date", SortableTable.toDate); -SortableTable.prototype.addSortType("String"); -// None is a special case -; -define("extensions/sortabletable/sortabletable", (function (global) { - return function () { - var ret, fn; - return ret || global.SortableTable; - }; -}(this))); - -define('extensions/sortabletable/adapterSortabletable',["exports", "../../types", "../../dom", "../../array", "../../event", "../../date", "../../helpers"], function (exports, _types, _dom, _array, _event, _date, _helpers) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var Types = _types.Types; - var Dom = _dom.Dom; - var array = _array.Arr; - var Event = _event.Event; - var DateHelper = _date.DateHelper; - var Helpers = _helpers.Helpers; - - var AdapterSortableTable = exports.AdapterSortableTable = (function () { - - /** - * SortableTable Adapter module - * @param {Object} tf TableFilter instance - */ - - function AdapterSortableTable(tf) { - _classCallCheck(this, AdapterSortableTable); - - // Configuration object - var f = tf.config(); - - this.isPaged = false; - - //indicates if tables was sorted - this.sorted = false; - - // edit .sort-arrow.descending / .sort-arrow.ascending in filtergrid.css - // to reflect any path change - this.sortImgPath = f.sort_images_path || tf.themesPath; - this.sortImgBlank = f.sort_image_blank || "blank.png"; - this.sortImgClassName = f.sort_image_class_name || "sort-arrow"; - this.sortImgAscClassName = f.sort_image_asc_class_name || "ascending"; - this.sortImgDescClassName = f.sort_image_desc_class_name || "descending"; - //cell attribute storing custom key - this.sortCustomKey = f.sort_custom_key || "data-tf-sortKey"; - - /*** TF additional events ***/ - //additional paging events for alternating background - // o.Evt._Paging.nextEvt = function(){ if(o.sorted && o.alternateBgs) o.Filter(); } - // o.Evt._Paging.prevEvt = o.Evt._Paging.nextEvt; - // o.Evt._Paging.firstEvt = o.Evt._Paging.nextEvt; - // o.Evt._Paging.lastEvt = o.Evt._Paging.nextEvt; - // o.Evt._OnSlcPagesChangeEvt = o.Evt._Paging.nextEvt; - - // callback invoked after sort is loaded and instanciated - this.onSortLoaded = Types.isFn(f.on_sort_loaded) ? f.on_sort_loaded : null; - // callback invoked before table is sorted - this.onBeforeSort = Types.isFn(f.on_before_sort) ? f.on_before_sort : null; - // callback invoked after table is sorted - this.onAfterSort = Types.isFn(f.on_after_sort) ? f.on_after_sort : null; - - this.tf = tf; - } - - _prototypeProperties(AdapterSortableTable, null, { - init: { - value: function init() { - var tf = this.tf; - var sortConfig = tf.sortConfig; - - // SortableTable class sanity check (sortabletable.js) - if (Types.isUndef(SortableTable)) { - throw new Error("SortableTable class not found."); - } - - this.overrideSortableTable(); - this.setSortTypes(); - - //Column sort at start - if (sortConfig.sortCol) { - this.stt.sort(sortConfig.sortCol[0], sortConfig.sortCol[1]); - } - - tf.isSortEnabled = true; - if (this.onSortLoaded) { - this.onSortLoaded.call(null, tf, this); - } - - /*** SortableTable callbacks ***/ - this.stt.onbeforesort = function () { - if (this.onBeforeSort) { - this.onBeforeSort.call(null, tf, this.stt.sortColumn); - } - - tf.performSort(); - - /*** sort behaviour for paging ***/ - if (tf.paging) { - this.isPaged = true; - tf.paging = false; - tf.Cpt.paging.destroy(); - } - }; - - this.stt.onsort = function () { - this.sorted = true; - - //rows alternating bg issue - // TODO: move into AlternateRows component - if (tf.alternateBgs) { - var rows = tf.tbl.rows, - c = 0; - - var setClass = function setClass(row, i, removeOnly) { - if (Types.isUndef(removeOnly)) { - removeOnly = false; - } - var altRows = tf.Cpt.alternateRows, - oddCls = altRows.oddCss, - evenCls = altRows.evenCss; - Dom.removeClass(row, oddCls); - Dom.removeClass(row, evenCls); - - if (!removeOnly) { - Dom.addClass(row, i % 2 ? oddCls : evenCls); - } - }; - - for (var i = tf.refRow; i < tf.nbRows; i++) { - var isRowValid = rows[i].getAttribute("validRow"); - if (tf.paging && rows[i].style.display === "") { - setClass(rows[i], c); - c++; - } else { - if ((isRowValid === "true" || isRowValid === null) && rows[i].style.display === "") { - setClass(rows[i], c); - c++; - } else { - setClass(rows[i], c, true); - } - } - } - } - //sort behaviour for paging - if (this.isPaged) { - var paginator = tf.Cpt.paging, - config = tf.config(); - if (paginator.hasResultsPerPage) { - var slc = paginator.resultsPerPageSlc; - config.paging_length = slc.options[slc.selectedIndex].value; - } - paginator.addPaging(false); - paginator.setPage(paginator.currentPageNb); - this.isPaged = false; - } - - if (this.onAfterSort) { - this.onAfterSort.call(null, tf, tf.stt.sortColumn); - } - }; - }, - writable: true, - configurable: true - }, - overrideSortableTable: { - value: function overrideSortableTable() { - var adpt = this, - tf = this.tf; - - /** - * Overrides headerOnclick method in order to handle th event - * @param {Object} e [description] - */ - SortableTable.prototype.headerOnclick = function (evt) { - if (!tf.sort) { - return; - } - // find Header element - var el = evt.target || evt.srcElement, - tagName = el.tagName; - - while (tagName !== "TD" && tagName !== "TH") { - el = el.parentNode; - } - - this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex); - }; - - /** - * Overrides getCellIndex IE returns wrong cellIndex when columns are - * hidden - * @param {Object} oTd TD element - * @return {Number} Cell index - */ - SortableTable.getCellIndex = function (oTd) { - var cells = oTd.parentNode.cells, - l = cells.length, - i; - for (i = 0; cells[i] != oTd && i < l; i++) {} - return i; - }; - - /** - * Overrides initHeader in order to handle filters row position - * @param {Array} oSortTypes - */ - SortableTable.prototype.initHeader = function (oSortTypes) { - var stt = this; - if (!stt.tHead) { - throw new Error("Sorting feature requires a THEAD element"); - } - stt.headersRow = tf.headersRow; - var cells = stt.tHead.rows[stt.headersRow].cells; - var doc = stt.tHead.ownerDocument || stt.tHead.document; - stt.sortTypes = oSortTypes || []; - var l = cells.length; - var img, c; - for (var i = 0; i < l; i++) { - c = cells[i]; - if (stt.sortTypes[i] !== null && stt.sortTypes[i] !== "None") { - c.style.cursor = "pointer"; - img = Dom.create("img", ["src", adpt.sortImgPath + adpt.sortImgBlank]); - c.appendChild(img); - if (stt.sortTypes[i] !== null) { - c.setAttribute("_sortType", stt.sortTypes[i]); - } - Event.add(c, "click", stt._headerOnclick); - } else { - c.setAttribute("_sortType", oSortTypes[i]); - c._sortType = "None"; - } - } - stt.updateHeaderArrows(); - }; - - /** - * Overrides updateHeaderArrows in order to handle arrows indicators - */ - SortableTable.prototype.updateHeaderArrows = function () { - var stt = this; - var cells, l, img; - // external headers - if (tf.sortConfig.asyncSort && tf.sortConfig.triggerIds !== null) { - var triggers = tf.sortConfig.triggerIds; - cells = []; - l = triggers.length; - for (var j = 0; j < triggers.length; j++) { - cells.push(Dom.id(triggers[j])); - } - } else { - if (!this.tHead) { - return; - } - cells = stt.tHead.rows[stt.headersRow].cells; - l = cells.length; - } - for (var i = 0; i < l; i++) { - var cellAttr = cells[i].getAttribute("_sortType"); - if (cellAttr !== null && cellAttr !== "None") { - img = cells[i].lastChild || cells[i]; - if (img.nodeName.toLowerCase() !== "img") { - img = Dom.create("img", ["src", adpt.sortImgPath + adpt.sortImgBlank]); - cells[i].appendChild(img); - } - if (i === stt.sortColumn) { - img.className = adpt.sortImgClassName + " " + (this.descending ? adpt.sortImgDescClassName : adpt.sortImgAscClassName); - } else { - img.className = adpt.sortImgClassName; - } - } - } - }; - - /** - * Overrides getRowValue for custom key value feature - * @param {Object} oRow Row element - * @param {String} sType - * @param {Number} nColumn - * @return {String} - */ - SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) { - var stt = this; - // if we have defined a custom getRowValue use that - var sortTypeInfo = stt._sortTypeInfo[sType]; - if (sortTypeInfo && sortTypeInfo.getRowValue) { - return sortTypeInfo.getRowValue(oRow, nColumn); - } - var c = oRow.cells[nColumn]; - var s = SortableTable.getInnerText(c); - return stt.getValueFromString(s, sType); - }; - - /** - * Overrides getInnerText in order to avoid Firefox unexpected sorting - * behaviour with untrimmed text elements - * @param {Object} oNode DOM element - * @return {String} DOM element inner text - */ - SortableTable.getInnerText = function (oNode) { - if (oNode.getAttribute(tf.sortCustomKey) != null) { - return oNode.getAttribute(tf.sortCustomKey); - } else { - return Dom.getText(oNode); - } - }; - }, - writable: true, - configurable: true - }, - setSortTypes: { - value: function setSortTypes() { - var _this = this; - - var tf = this.tf, - configSort = tf.sortConfig, - configSortTypes = configSort.sortTypes, - sortTypes = []; - - for (var i = 0; i < tf.nbCells; i++) { - var colType; - - if (configSortTypes !== null && configSortTypes[i] != null) { - colType = configSortTypes[i].toLowerCase(); - if (colType === "none") { - colType = "None"; - } - } else { - // resolve column types - if (tf.hasColNbFormat && tf.colNbFormat[i] !== null) { - colType = tf.colNbFormat[i].toLowerCase(); - } else if (tf.hasColDateType && tf.colDateType[i] !== null) { - colType = tf.colDateType[i].toLowerCase() + "date"; - } else { - colType = "String"; - } - } - sortTypes.push(colType); - } - - //Public TF method to add sort type - this.addSortType = function () { - SortableTable.prototype.addSortType(arguments[0], arguments[1], arguments[2], arguments[3]); - }; - - //Custom sort types - this.addSortType("number", Number); - this.addSortType("caseinsensitivestring", SortableTable.toUpperCase); - this.addSortType("date", SortableTable.toDate); - this.addSortType("string"); - this.addSortType("us", this.usNumberConverter); - this.addSortType("eu", this.euNumberConverter); - this.addSortType("dmydate", this.dmyDateConverter); - this.addSortType("ymddate", this.ymdDateConverter); - this.addSortType("mdydate", this.mdyDateConverter); - this.addSortType("ddmmmyyyydate", this.ddmmmyyyyDateConverter); - this.addSortType("ipaddress", this.ipAddress, this.sortIP); - - this.stt = new SortableTable(tf.tbl, sortTypes); - - /*** external table headers adapter ***/ - if (configSort.asyncSort && configSort.triggerIds !== null) { - var triggers = configSort.triggerIds; - for (var j = 0; j < triggers.length; j++) { - if (triggers[j] === null) { - continue; - } - var trigger = Dom.id(triggers[j]); - if (trigger) { - trigger.style.cursor = "pointer"; - // trigger.onclick = function(){ - // if(o.sort) - // o.st.asyncSort( triggers.tf_IndexByValue(this.id, true) ); - // } - Event.add(trigger, "click", function (evt) { - var elm = evt.target; - if (!_this.tf.sort) { - return; - } - _this.stt.asyncSort( - // triggers.tf_IndexByValue(this.id, true) - Arr.indexByValue(triggers, elm.id, true)); - }); - trigger.setAttribute("_sortType", sortTypes[j]); - } - } - } - }, - writable: true, - configurable: true - }, - usNumberConverter: { - - //Converters - - value: function usNumberConverter(s) { - return Helpers.removeNbFormat(s, "us"); - }, - writable: true, - configurable: true - }, - euNumberConverter: { - value: function euNumberConverter(s) { - return Helpers.removeNbFormat(s, "eu"); - }, - writable: true, - configurable: true - }, - dateConverter: { - value: function dateConverter(s, format) { - return DateHelper.format(s, format); - }, - writable: true, - configurable: true - }, - dmyDateConverter: { - value: function dmyDateConverter(s) { - return this.dateConverter(s, "DMY"); - }, - writable: true, - configurable: true - }, - mdyDateConverter: { - value: function mdyDateConverter(s) { - return this.dateConverter(s, "MDY"); - }, - writable: true, - configurable: true - }, - ymdDateConverter: { - value: function ymdDateConverter(s) { - return this.dateConverter(s, "YMD"); - }, - writable: true, - configurable: true - }, - ddmmmyyyyDateConverter: { - value: function ddmmmyyyyDateConverter(s) { - return this.dateConverter(s, "DDMMMYYYY"); - }, - writable: true, - configurable: true - }, - ipAddress: { - value: function ipAddress(value) { - var vals = value.split("."); - for (var x in vals) { - var val = vals[x]; - while (3 > val.length) { - val = "0" + val; - } - vals[x] = val; - } - return vals.join("."); - }, - writable: true, - configurable: true - }, - sortIP: { - value: function sortIP(a, b) { - var aa = this.ipAddress(a.value.toLowerCase()); - var bb = this.ipAddress(b.value.toLowerCase()); - if (aa == bb) { - return 0; - } else if (aa < bb) { - return -1; - } else { - return 1; - } - }, - writable: true, - configurable: true - } - }); - - return AdapterSortableTable; - })(); - - Object.defineProperty(exports, "__esModule", { - value: true - }); -}); -//# sourceMappingURL=adapterSortabletable.js.map; -define('tablefilter',["exports", "module", "event", "dom", "string", "cookie", "types", "array", "helpers", "date", "sort", "modules/store", "modules/gridLayout", "modules/loader", "modules/highlightKeywords", "modules/popupFilter", "modules/dropdown", "modules/checkList", "modules/rowsCounter", "modules/statusBar", "modules/paging", "modules/clearButton", "modules/help", "modules/alternateRows", "modules/colOps", "extensions/sortabletable/sortabletable", "extensions/sortabletable/adapterSortabletable"], function (exports, module, _event, _dom, _string, _cookie, _types, _array, _helpers, _date, _sort, _modulesStore, _modulesGridLayout, _modulesLoader, _modulesHighlightKeywords, _modulesPopupFilter, _modulesDropdown, _modulesCheckList, _modulesRowsCounter, _modulesStatusBar, _modulesPaging, _modulesClearButton, _modulesHelp, _modulesAlternateRows, _modulesColOps, _extensionsSortabletableSortabletable, _extensionsSortabletableAdapterSortabletable) { - - - var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - /* ------------------------------------------------------------------------ - - HTML Table Filter Generator v3.0 - - By Max Guglielmi (tablefilter.free.fr) - - Licensed under the MIT License - --------------------------------------------------------------------------- - - Special credit to: - Cedric Wartel, cnx.claude@free.fr, Florent Hirchy, Váry Péter, - Anthony Maes, Nuovella Williams, Fuggerbit, Venkata Seshagiri Rao - Raya, Piepiax, Manuel Kern, Baladhandayutham for active contribution - and/or inspiration - ------------------------------------------------------------------------ */ - - var evt = _event.Event; - var dom = _dom.Dom; - var str = _string.Str; - var cookie = _cookie.Cookie; - var types = _types.Types; - var array = _array.Arr; - var hlp = _helpers.Helpers; - var dateHelper = _date.DateHelper; - var Sort = _sort.Sort; - - // Modules - var Store = _modulesStore.Store; - var GridLayout = _modulesGridLayout.GridLayout; - var Loader = _modulesLoader.Loader; - var HighlightKeyword = _modulesHighlightKeywords.HighlightKeyword; - var PopupFilter = _modulesPopupFilter.PopupFilter; - var Dropdown = _modulesDropdown.Dropdown; - var CheckList = _modulesCheckList.CheckList; - var RowsCounter = _modulesRowsCounter.RowsCounter; - var StatusBar = _modulesStatusBar.StatusBar; - var Paging = _modulesPaging.Paging; - var ClearButton = _modulesClearButton.ClearButton; - var Help = _modulesHelp.Help; - var AlternateRows = _modulesAlternateRows.AlternateRows; - var ColOps = _modulesColOps.ColOps; - var AdapterSortableTable = _extensionsSortabletableAdapterSortabletable.AdapterSortableTable; - - var global = window, - isValidDate = dateHelper.isValid, - formatDate = dateHelper.format, - doc = global.document; - - var TableFilter = (function () { - - /** - * TF object constructor - * @param {String} id Table id - * @param {Number} row index indicating the 1st row - * @param {Object} configuration object - */ - - function TableFilter(id) { - _classCallCheck(this, TableFilter); - - if (arguments.length === 0) { - return; - } - - this.id = id; - this.version = "3.0"; - this.year = new Date().getFullYear(); - this.tbl = dom.id(id); - this.startRow = null; - this.refRow = null; - this.headersRow = null; - this.cfg = {}; - this.nbFilterableRows = null; - this.nbRows = null; - this.nbCells = null; - this._hasGrid = false; - this.enableModules = false; - - if (!this.tbl || str.lower(this.tbl.nodeName) !== "table" || this.getRowsNb() === 0) { - throw new Error("Could not instantiate TableFilter class: " + "HTML table not found."); - } - - if (arguments.length > 1) { - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - var argtype = typeof arg; - switch (str.lower(argtype)) { - case "number": - this.startRow = arg; - break; - case "object": - this.cfg = arg; - break; - } - } - } - - // configuration object - var f = this.cfg; - - //Start row et cols nb - this.refRow = this.startRow === null ? 2 : this.startRow + 1; - try { - this.nbCells = this.getCellsNb(this.refRow); - } catch (e) { - this.nbCells = this.getCellsNb(0); - } - - //default script base path - this.basePath = f.base_path !== undefined ? f.base_path : ""; - - /*** filter types ***/ - this.fltTypeInp = "input"; - this.fltTypeSlc = "select"; - this.fltTypeMulti = "multiple"; - this.fltTypeCheckList = "checklist"; - this.fltTypeNone = "none"; - this.fltCol = []; //filter type of each column - - for (var j = 0; j < this.nbCells; j++) { - var cfgCol = f["col_" + j]; - var col = !cfgCol ? this.fltTypeInp : str.lower(cfgCol); - this.fltCol.push(col); - this["col" + j] = col; - } - - /*** Developer's additional methods ***/ - this.publicMethods = f.public_methods !== undefined ? f.public_methods : false; - - /*** filters' grid properties ***/ - - //enables/disables filter grid - this.fltGrid = f.grid === false ? false : true; - - /*** Grid layout ***/ - //enables/disables grid layout (fixed headers) - this.gridLayout = f.grid_layout ? true : false; - this.sourceTblHtml = null; - if (this.gridLayout) { - //Firefox does not support outerHTML property... - if (this.tbl.outerHTML === undefined) { - setOuterHtml(); - } - this.sourceTblHtml = this.tbl.outerHTML; - } - /*** ***/ - - this.filtersRowIndex = f.filters_row_index || 0; - this.headersRow = f.headers_row_index || (this.filtersRowIndex === 0 ? 1 : 0); - - if (this.gridLayout) { - if (this.headersRow > 1) { - this.filtersRowIndex = this.headersRow + 1; - } else { - this.filtersRowIndex = 1; - this.headersRow = 0; - } - } - - //defines tag of the cells containing filters (td/th) - this.fltCellTag = f.filters_cell_tag !== "th" || f.filters_cell_tag !== "td" ? "td" : f.filters_cell_tag; - - //stores filters ids - this.fltIds = []; - //stores filters DOM elements - this.fltElms = []; - //stores filters values - this.searchArgs = null; - //stores table data - this.tblData = []; - //stores valid rows indexes (rows visible upon filtering) - this.validRowsIndex = null; - //stores filters row element - this.fltGridEl = null; - //is first load boolean - this.isFirstLoad = true; - //container div for paging elements, reset btn etc. - this.infDiv = null; - //div for rows counter - this.lDiv = null; - //div for reset button and results per page select - this.rDiv = null; - //div for paging elements - this.mDiv = null; - //table container div for fixed headers (IE only) - this.contDiv = null; - - //defines css class for div containing paging elements, rows counter etc. - this.infDivCssClass = f.inf_div_css_class || "inf"; - //defines css class for left div - this.lDivCssClass = f.left_div_css_class || "ldiv"; - //defines css class for right div - this.rDivCssClass = f.right_div_css_class || "rdiv"; - //defines css class for mid div - this.mDivCssClass = f.middle_div_css_class || "mdiv"; - //table container div css class - this.contDivCssClass = f.content_div_css_class || "cont"; - - /*** filters' grid appearance ***/ - //stylesheet file - this.stylesheet = f.stylesheet || this.basePath + "filtergrid.css"; - this.stylesheetId = this.id + "_style"; - //defines css class for filters row - this.fltsRowCssClass = f.flts_row_css_class || "fltrow"; - //enables/disables icons (paging, reset button) - this.enableIcons = f.enable_icons === false ? false : true; - //enables/disbles rows alternating bg colors - this.alternateBgs = f.alternate_rows === true ? true : false; - //defines widths of columns - this.hasColWidth = f.col_width === true ? true : false; - this.colWidth = this.hasColWidth ? f.col_width : null; - //enables/disables fixed headers - this.fixedHeaders = f.fixed_headers === true ? true : false; - //tbody height if fixed headers enabled - this.tBodyH = !isNaN(f.tbody_height) ? f.tbody_height : 200; - //defines css class for filters - this.fltCssClass = f.flt_css_class || "flt"; - //defines css class for multiple selects filters - this.fltMultiCssClass = f.flt_multi_css_class || "flt_multi"; - //defines css class for filters - this.fltSmallCssClass = f.flt_small_css_class || "flt_s"; - //defines css class for single-filter - this.singleFltCssClass = f.single_flt_css_class || "single_flt"; - this.isStartBgAlternate = true; - - /*** filters' grid behaviours ***/ - //enables/disables enter key - this.enterKey = f.enter_key === false ? false : true; - //enables/disables alternative fn call - this.isModFilterFn = f.mod_filter_fn === true ? true : false; - // used by tf_DetectKey fn - this.modFilterFn = this.isModFilterFn ? f.mod_filter_fn : null; - //calls function before filtering starts - this.onBeforeFilter = types.isFn(f.on_before_filter) ? f.on_before_filter : null; - //calls function after filtering - this.onAfterFilter = types.isFn(f.on_after_filter) ? f.on_after_filter : null; - //enables/disables case sensitivity - this.matchCase = f.match_case === true ? true : false; - //enables/disbles exact match for search - this.exactMatch = f.exact_match === true ? true : false; - //refreshes drop-down lists upon validation - this.linkedFilters = f.linked_filters === true ? true : false; - //wheter excluded options are disabled - this.disableExcludedOptions = f.disable_excluded_options === true ? true : false; - //stores active filter element - this.activeFlt = null; - //id of active filter - this.activeFilterId = null; - //enables/disbles column operation(sum,mean) - this.hasColOperation = f.col_operation ? true : false; - this.colOperation = null; - //enables always visible rows - this.hasVisibleRows = f.rows_always_visible ? true : false; - //array containing always visible rows - this.visibleRows = this.hasVisibleRows ? f.rows_always_visible : []; - //defines search type: include or exclude - this.searchType = f.search_type || "include"; - //enables/disables external filters generation - this.isExternalFlt = f.external_flt_grid === true ? true : false; - //array containing ids of external elements containing filters - this.externalFltTgtIds = f.external_flt_grid_ids || null; - //stores filters elements if isExternalFlt is true - this.externalFltEls = []; - //delays any filtering process if loader true - this.execDelay = !isNaN(f.exec_delay) ? parseInt(f.exec_delay, 10) : 100; - //calls function when filters grid loaded - this.onFiltersLoaded = types.isFn(f.on_filters_loaded) ? f.on_filters_loaded : null; - //enables/disables single filter search - this.singleSearchFlt = f.single_search_filter === true ? true : false; - //calls function after row is validated - this.onRowValidated = types.isFn(f.on_row_validated) ? f.on_row_validated : null; - //array defining columns for customCellData event - this.customCellDataCols = f.custom_cell_data_cols ? f.custom_cell_data_cols : []; - //calls custom function for retrieving cell data - this.customCellData = types.isFn(f.custom_cell_data) ? f.custom_cell_data : null; - //input watermark text array - this.watermark = f.watermark || ""; - this.isWatermarkArray = types.isArray(this.watermark); - //id of toolbar container element - this.toolBarTgtId = f.toolbar_target_id || null; - //enables/disables help div - this.helpInstructions = f.help_instructions || false; - //popup filters - this.popUpFilters = f.popup_filters === true ? true : false; - //active columns color - this.markActiveColumns = f.mark_active_columns === true ? true : false; - //defines css class for active column header - this.activeColumnsCssClass = f.active_columns_css_class || "activeHeader"; - //calls function before active column header is marked - this.onBeforeActiveColumn = types.isFn(f.on_before_active_column) ? f.on_before_active_column : null; - //calls function after active column header is marked - this.onAfterActiveColumn = types.isFn(f.on_after_active_column) ? f.on_after_active_column : null; - - /*** select filter's customisation and behaviours ***/ - //defines 1st option text - this.displayAllText = f.display_all_text || ""; - //enables/disables empty option in combo-box filters - this.enableEmptyOption = f.enable_empty_option === true ? true : false; - //defines empty option text - this.emptyText = f.empty_text || "(Empty)"; - //enables/disables non empty option in combo-box filters - this.enableNonEmptyOption = f.enable_non_empty_option === true ? true : false; - //defines empty option text - this.nonEmptyText = f.non_empty_text || "(Non empty)"; - //enables/disables onChange event on combo-box - this.onSlcChange = f.on_change === false ? false : true; - //enables/disables select options sorting - this.sortSlc = f.sort_select === false ? false : true; - //enables/disables ascending numeric options sorting - this.isSortNumAsc = f.sort_num_asc === true ? true : false; - this.sortNumAsc = this.isSortNumAsc ? f.sort_num_asc : null; - //enables/disables descending numeric options sorting - this.isSortNumDesc = f.sort_num_desc === true ? true : false; - this.sortNumDesc = this.isSortNumDesc ? f.sort_num_desc : null; - //enabled selects are populated on demand - this.fillSlcOnDemand = f.fill_slc_on_demand === true ? true : false; - this.hasCustomSlcOptions = types.isObj(f.custom_slc_options) ? true : false; - this.customSlcOptions = types.isArray(f.custom_slc_options) ? f.custom_slc_options : null; - - /*** Filter operators ***/ - this.rgxOperator = f.regexp_operator || "rgx:"; - this.emOperator = f.empty_operator || "[empty]"; - this.nmOperator = f.nonempty_operator || "[nonempty]"; - this.orOperator = f.or_operator || "||"; - this.anOperator = f.and_operator || "&&"; - this.grOperator = f.greater_operator || ">"; - this.lwOperator = f.lower_operator || "<"; - this.leOperator = f.lower_equal_operator || "<="; - this.geOperator = f.greater_equal_operator || ">="; - this.dfOperator = f.different_operator || "!"; - this.lkOperator = f.like_operator || "*"; - this.eqOperator = f.equal_operator || "="; - this.stOperator = f.start_with_operator || "{"; - this.enOperator = f.end_with_operator || "}"; - this.curExp = f.cur_exp || "^[¥£€$]"; - this.separator = f.separator || ","; - - /*** rows counter ***/ - //show/hides rows counter - this.rowsCounter = f.rows_counter === true ? true : false; - - /*** status bar ***/ - //show/hides status bar - this.statusBar = f.status_bar === true ? true : false; - - /*** loader ***/ - //enables/disables loader/spinner indicator - this.loader = f.loader === true ? true : false; - - /*** validation - reset buttons/links ***/ - //show/hides filter's validation button - this.displayBtn = f.btn === true ? true : false; - //defines validation button text - this.btnText = f.btn_text || (!this.enableIcons ? "Go" : ""); - //defines css class for validation button - this.btnCssClass = f.btn_css_class || (!this.enableIcons ? "btnflt" : "btnflt_icon"); - //show/hides reset link - this.btnReset = f.btn_reset === true ? true : false; - //defines css class for reset button - this.btnResetCssClass = f.btn_reset_css_class || "reset"; - //callback function before filters are cleared - this.onBeforeReset = types.isFn(f.on_before_reset) ? f.on_before_reset : null; - //callback function after filters are cleared - this.onAfterReset = types.isFn(f.on_after_reset) ? f.on_after_reset : null; - - /*** paging ***/ - //enables/disables table paging - this.paging = f.paging === true ? true : false; - this.nbVisibleRows = 0; //nb visible rows - this.nbHiddenRows = 0; //nb hidden rows - - /*** webfx sort adapter ***/ - //enables/disables default table sorting - this.sort = f.sort === true ? true : false; - //indicates if sort is set (used in tfAdapter.sortabletable.js) - this.isSortEnabled = false; - this.sortConfig = f.sort_config || {}; - this.sortConfig.name = this.sortConfig.name !== undefined ? f.sort_config.name : "sortabletable"; - this.sortConfig.src = this.sortConfig.src !== undefined ? f.sort_config.src : this.basePath + "extensions/sortabletable/" + "sortabletable.js"; - this.sortConfig.adapterSrc = this.sortConfig.adapter_src !== undefined ? f.sort_config.adapter_src : this.basePath + "extensions/sortabletable/adapterSortabletable.js"; - this.sortConfig.initialize = this.sortConfig.initialize !== undefined ? f.sort_config.initialize : function (o) {}; - this.sortConfig.sortTypes = types.isArray(this.sortConfig.sort_types) ? f.sort_config.sort_types : []; - this.sortConfig.sortCol = this.sortConfig.sort_col !== undefined ? f.sort_config.sort_col : null; - this.sortConfig.asyncSort = this.sortConfig.async_sort === true ? true : false; - this.sortConfig.triggerIds = types.isArray(this.sortConfig.sort_trigger_ids) ? f.sort_config.sort_trigger_ids : []; - - /*** ezEditTable extension ***/ - //enables/disables table selection feature - this.selectable = f.selectable === true ? true : false; - //enables/disables editable table feature - this.editable = f.editable === true ? true : false; - this.ezEditTableConfig = f.ezEditTable_config || {}; - this.ezEditTableConfig.name = this.ezEditTableConfig.name !== undefined ? f.ezEditTable_config.name : "ezedittable"; - this.ezEditTableConfig.src = this.ezEditTableConfig.src !== undefined ? f.ezEditTable_config.src : this.basePath + "ezEditTable/ezEditTable.js"; - //ezEditTable stylesheet not imported by default as filtergrid.css - //applies - this.ezEditTableConfig.loadStylesheet = this.ezEditTableConfig.loadStylesheet === true ? true : false; - this.ezEditTableConfig.stylesheet = this.ezEditTableConfig.stylesheet || this.basePath + "ezEditTable/ezEditTable.css"; - this.ezEditTableConfig.stylesheetName = this.ezEditTableConfig.stylesheetName !== undefined ? f.ezEditTable_config.stylesheetName : "ezEditTableCss"; - this.ezEditTableConfig.err = "Failed to instantiate EditTable " + "object.\n\"ezEditTable\" module may not be available."; - - /*** onkeyup event ***/ - //enables/disables onkeyup event, table is filtered when user stops - //typing - this.onKeyUp = f.on_keyup === true ? true : false; - //onkeyup delay timer (msecs) - this.onKeyUpDelay = !isNaN(f.on_keyup_delay) ? f.on_keyup_delay : 900; - this.isUserTyping = null; //typing indicator - this.onKeyUpTimer = undefined; - - /*** keyword highlighting ***/ - //enables/disables keyword highlighting - this.highlightKeywords = f.highlight_keywords === true ? true : false; - - /*** data types ***/ - //defines default date type (european DMY) - this.defaultDateType = f.default_date_type || "DMY"; - //defines default thousands separator - //US = ',' EU = '.' - this.thousandsSeparator = f.thousands_separator || ","; - //defines default decimal separator - //US & javascript = '.' EU = ',' - this.decimalSeparator = f.decimal_separator || "."; - //enables number format per column - this.hasColNbFormat = f.col_number_format === true ? true : false; - //array containing columns nb formats - this.colNbFormat = types.isArray(this.hasColNbFormat) ? f.col_number_format : null; - //enables date type per column - this.hasColDateType = f.col_date_type === true ? true : false; - //array containing columns date type - this.colDateType = types.isArray(this.hasColDateType) ? f.col_date_type : null; - - /*** status messages ***/ - //filtering - this.msgFilter = f.msg_filter || "Filtering data..."; - //populating drop-downs - this.msgPopulate = f.msg_populate || "Populating filter..."; - //populating drop-downs - this.msgPopulateCheckList = f.msg_populate_checklist || "Populating list..."; - //changing paging page - this.msgChangePage = f.msg_change_page || "Collecting paging data..."; - //clearing filters - this.msgClear = f.msg_clear || "Clearing filters..."; - //changing nb results/page - this.msgChangeResults = f.msg_change_results || "Changing results per page..."; - //re-setting grid values - this.msgResetValues = f.msg_reset_grid_values || "Re-setting filters values..."; - //re-setting page - this.msgResetPage = f.msg_reset_page || "Re-setting page..."; - //re-setting page length - this.msgResetPageLength = f.msg_reset_page_length || "Re-setting page length..."; - //table sorting - this.msgSort = f.msg_sort || "Sorting data..."; - //extensions loading - this.msgLoadExtensions = f.msg_load_extensions || "Loading extensions..."; - //themes loading - this.msgLoadThemes = f.msg_load_themes || "Loading theme(s)..."; - - /*** ids prefixes ***/ - //css class name added to table - this.prfxTf = "TF"; - //filters (inputs - selects) - this.prfxFlt = "flt"; - //validation button - this.prfxValButton = "btn"; - //container div for paging elements, rows counter etc. - this.prfxInfDiv = "inf_"; - //left div - this.prfxLDiv = "ldiv_"; - //right div - this.prfxRDiv = "rdiv_"; - //middle div - this.prfxMDiv = "mdiv_"; - //table container if fixed headers enabled - this.prfxContentDiv = "cont_"; - //checklist filter container div - this.prfxCheckListDiv = "chkdiv_"; - //pages select - this.prfxSlcPages = "slcPages_"; - //results per page select - this.prfxSlcResults = "slcResults_"; - //label preciding results per page select - this.prfxSlcResultsTxt = "slcResultsTxt_"; - //span containing next page button - this.prfxBtnNextSpan = "btnNextSpan_"; - //span containing previous page button - this.prfxBtnPrevSpan = "btnPrevSpan_"; - //span containing last page button - this.prfxBtnLastSpan = "btnLastSpan_"; - //span containing first page button - this.prfxBtnFirstSpan = "btnFirstSpan_"; - //next button - this.prfxBtnNext = "btnNext_"; - //previous button - this.prfxBtnPrev = "btnPrev_"; - //last button - this.prfxBtnLast = "btnLast_"; - //first button - this.prfxBtnFirst = "btnFirst_"; - //span for tot nb pages - this.prfxPgSpan = "pgspan_"; - //span preceding pages select (contains 'Page') - this.prfxPgBeforeSpan = "pgbeforespan_"; - //span following pages select (contains ' of ') - this.prfxPgAfterSpan = "pgafterspan_"; - //rows counter div - this.prfxCounter = "counter_"; - //nb displayed rows label - this.prfxTotRows = "totrows_span_"; - //label preceding nb rows label - this.prfxTotRowsTxt = "totRowsTextSpan_"; - //span containing reset button - this.prfxResetSpan = "resetspan_"; - //loader div - this.prfxLoader = "load_"; - //status bar div - this.prfxStatus = "status_"; - //status bar label - this.prfxStatusSpan = "statusSpan_"; - //text preceding status bar label - this.prfxStatusTxt = "statusText_"; - //filter values cookie - this.prfxCookieFltsValues = "tf_flts_"; - //page nb cookie - this.prfxCookiePageNb = "tf_pgnb_"; - //page length cookie - this.prfxCookiePageLen = "tf_pglen_"; - //div containing grid elements if grid_layout true - this.prfxMainTblCont = "gridCont_"; - //div containing table if grid_layout true - this.prfxTblCont = "tblCont_"; - //div containing headers table if grid_layout true - this.prfxHeadTblCont = "tblHeadCont_"; - //headers' table if grid_layout true - this.prfxHeadTbl = "tblHead_"; - //id of td containing the filter if grid_layout true - this.prfxGridFltTd = "_td_"; - //id of th containing column header if grid_layout true - this.prfxGridTh = "tblHeadTh_"; - //id prefix for help elements - this.prfxHelpSpan = "helpSpan_"; - //id prefix for help elements - this.prfxHelpDiv = "helpDiv_"; - //id prefix for pop-up filter span - this.prfxPopUpSpan = "popUpSpan_"; - //id prefix for pop-up div containing filter - this.prfxPopUpDiv = "popUpDiv_"; - - /*** cookies ***/ - this.hasStoredValues = false; - //remembers filters values on page load - this.rememberGridValues = f.remember_grid_values === true ? true : false; - //cookie storing filter values - this.fltsValuesCookie = this.prfxCookieFltsValues + this.id; - //remembers page nb on page load - this.rememberPageNb = this.paging && f.remember_page_number ? true : false; - //cookie storing page nb - this.pgNbCookie = this.prfxCookiePageNb + this.id; - //remembers page length on page load - this.rememberPageLen = this.paging && f.remember_page_length ? true : false; - //cookie storing page length - this.pgLenCookie = this.prfxCookiePageLen + this.id; - - /*** extensions ***/ - //imports external script - this.hasExtensions = f.extensions === true ? true : false; - this.extensions = this.hasExtensions ? f.extensions : null; - - /*** themes ***/ - this.enableDefaultTheme = f.enable_default_theme === true ? true : false; - //imports themes - this.hasThemes = f.enable_default_theme || f.themes && types.isObj(f.themes) ? true : false; - this.themes = this.hasThemes ? f.themes : null; - //themes path - this.themesPath = f.themes_path || this.basePath + "TF_Themes/"; - - // Features registry - this.Cpt = { - loader: null, - alternateRows: null, - colOps: null, - rowsCounter: null, - gridLayout: null, - store: null, - highlightKeywords: null, - paging: null, - checkList: null, - dropdown: null, - popupFilter: null, - clearButton: null, - help: null, - statusBar: null - }; - - // Extensions registry - this.Extensions = { - sort: null - }; - - /*** TF events ***/ - var o = this; - this.Evt = { - name: { - filter: "Filter", - dropdown: "dropdown", - checklist: "checkList", - changepage: "changePage", - clear: "Clear", - changeresultsperpage: "changeResults", - resetvalues: "ResetValues", - resetpage: "resetPage", - resetpagelength: "resetPageLength", - sort: "Sort", - loadextensions: "LoadExtensions", - loadthemes: "LoadThemes" - }, - getKeyCode: function getKeyCode(evt) { - return evt.charCode ? evt.charCode : evt.keyCode ? evt.keyCode : evt.which ? evt.which : 0; - }, - /*==================================================== - - Detects key for a given element - =====================================================*/ - _DetectKey: function _DetectKey(e) { - if (!o.enterKey) { - return; - } - var _evt = e || global.event; - if (_evt) { - var key = o.Evt.getKeyCode(_evt); - if (key === 13) { - o._filter(); - evt.cancel(_evt); - evt.stop(_evt); - } else { - o.isUserTyping = true; - global.clearInterval(o.onKeyUpTimer); - o.onKeyUpTimer = undefined; - } - } //if evt - }, - /*==================================================== - - onkeyup event for text filters - =====================================================*/ - _OnKeyUp: function _OnKeyUp(e) { - if (!o.onKeyUp) { - return; - } - var _evt = e || global.event; - var key = o.Evt.getKeyCode(_evt); - o.isUserTyping = false; - - function filter() { - global.clearInterval(o.onKeyUpTimer); - o.onKeyUpTimer = undefined; - if (!o.isUserTyping) { - o.filter(); - o.isUserTyping = null; - } - } - - if (key !== 13 && key !== 9 && key !== 27 && key !== 38 && key !== 40) { - if (o.onKeyUpTimer === undefined) { - o.onKeyUpTimer = global.setInterval(filter, o.onKeyUpDelay); - } - } else { - global.clearInterval(o.onKeyUpTimer); - o.onKeyUpTimer = undefined; - } - }, - /*==================================================== - - onkeydown event for input filters - =====================================================*/ - _OnKeyDown: function _OnKeyDown(e) { - if (!o.onKeyUp) { - return; - } - o.isUserTyping = true; - }, - /*==================================================== - - onblur event for input filters - =====================================================*/ - _OnInpBlur: function _OnInpBlur(e) { - if (o.onKeyUp) { - o.isUserTyping = false; - global.clearInterval(o.onKeyUpTimer); - } - if (o.ezEditTable) { - if (o.editable) { - o.ezEditTable.Editable.Set(); - } - if (o.selectable) { - o.ezEditTable.Selection.Set(); - } - } - }, - /*==================================================== - - onfocus event for input filters - =====================================================*/ - _OnInpFocus: function _OnInpFocus(e) { - var _evt = e || global.event; - o.activeFilterId = this.getAttribute("id"); - o.activeFlt = dom.id(o.activeFilterId); - if (o.popUpFilters) { - evt.cancel(_evt); - evt.stop(_evt); - } - if (o.ezEditTable) { - if (o.editable) { - o.ezEditTable.Editable.Remove(); - } - if (o.selectable) { - o.ezEditTable.Selection.Remove(); - } - } - }, - /*==================================================== - - onfocus event for select filters - =====================================================*/ - _OnSlcFocus: function _OnSlcFocus(e) { - var _evt = e || global.event; - o.activeFilterId = this.getAttribute("id"); - o.activeFlt = dom.id(o.activeFilterId); - // select is populated when element has focus - if (o.fillSlcOnDemand && this.getAttribute("filled") === "0") { - var ct = this.getAttribute("ct"); - o.Cpt.dropdown._build(ct); - } - if (o.popUpFilters) { - evt.cancel(_evt); - evt.stop(_evt); - } - }, - /*==================================================== - - onchange event for select filters - =====================================================*/ - _OnSlcChange: function _OnSlcChange(e) { - if (!o.activeFlt) { - return; - } - var colIndex = o.activeFlt.getAttribute("colIndex"); - //Checks filter is a checklist and caller is not null - // if(o.activeFlt && colIndex && - // o['col'+colIndex]===o.fltTypeCheckList && - // !o.Evt._OnSlcChange.caller){ return; } - var _evt = e || global.event; - if (o.popUpFilters) { - evt.stop(_evt); - } - if (o.onSlcChange) { - o.filter(); - } - }, - /*==================================================== - - onblur event for select filters - =====================================================*/ - _OnSlcBlur: function _OnSlcBlur(e) {}, - /*==================================================== - - onclick event for checklist filters - =====================================================*/ - _OnCheckListClick: function _OnCheckListClick() { - if (o.fillSlcOnDemand && this.getAttribute("filled") === "0") { - var ct = this.getAttribute("ct"); - o.Cpt.checkList._build(ct); - o.Cpt.checkList.checkListDiv[ct].onclick = null; - o.Cpt.checkList.checkListDiv[ct].title = ""; - } - }, - /*==================================================== - - onclick event for checklist filter container - =====================================================*/ - _OnCheckListFocus: function _OnCheckListFocus(e) { - o.activeFilterId = this.firstChild.getAttribute("id"); - o.activeFlt = dom.id(o.activeFilterId); - }, - _OnCheckListBlur: function _OnCheckListBlur(e) {}, - /*==================================================== - - onclick event for validation button - (btn property) - =====================================================*/ - _OnBtnClick: function _OnBtnClick() { - o.filter(); - }, - _OnSlcPagesChangeEvt: null, //used by sort adapter - /*==================================================== - - onclick event slc parent node (enables filters) - IE only - =====================================================*/ - _EnableSlc: function _EnableSlc() { - this.firstChild.disabled = false; - this.firstChild.focus(); - this.onclick = null; - }, - - _Paging: { //used by sort adapter - nextEvt: null, - prevEvt: null, - lastEvt: null, - firstEvt: null - } - }; - } - - _prototypeProperties(TableFilter, null, { - init: { - - /*==================================================== - - initialises filtering grid bar behaviours and - layout - =====================================================*/ - - value: function init() { - if (this._hasGrid) { - return; - } - if (!this.tbl) { - this.tbl = dom.id(this.id); - } - if (this.gridLayout) { - this.refRow = this.startRow === null ? 0 : this.startRow; - } - if (this.popUpFilters && (this.filtersRowIndex === 0 && this.headersRow === 1 || this.gridLayout)) { - this.headersRow = 0; - } - var f = this.cfg, - n = this.singleSearchFlt ? 1 : this.nbCells, - inpclass; - - if (window["tf_" + this.id] === undefined) { - window["tf_" + this.id] = this; - } - - //loads stylesheet if not imported - //Issues with browsers != IE, IE rules in this case - this.includeFile(this.stylesheetId, this.stylesheet, null, "link"); - - //loads theme - if (this.hasThemes) { - this._LoadThemes(); - } - - if (this.rememberGridValues || this.rememberPageNb || this.rememberPageLen) { - //var Store = require('modules/store').Store; - // import {Store} from 'modules/store'; - this.Cpt.store = new Store(this); - } - - if (this.gridLayout) { - // var GridLayout = require('modules/gridLayout').GridLayout; - // import {GridLayout} from 'modules/gridLayout'; - this.Cpt.gridLayout = new GridLayout(this); - this.Cpt.gridLayout.init(); - } - - if (this.loader) { - if (!this.Cpt.loader) { - // var Loader = require('modules/loader').Loader; - // import {Loader} from 'modules/loader'; - this.Cpt.loader = new Loader(this); - } - } - - if (this.highlightKeywords) { - // var Highlight = - // require('modules/highlightKeywords').HighlightKeyword; - // import {HighlightKeyword} from 'modules/highlightKeywords'; - this.Cpt.highlightKeyword = new HighlightKeyword(this); - } - - if (this.popUpFilters) { - if (!this.Cpt.popupFilter) { - // var PopupFilter = require('modules/popupFilter').PopupFilter; - // import {PopupFilter} from 'modules/popupFilter'; - this.Cpt.popupFilter = new PopupFilter(this); - } - this.Cpt.popupFilter.init(); - } - - //filters grid is not generated - if (!this.fltGrid) { - this.refRow = this.refRow - 1; - if (this.gridLayout) { - this.refRow = 0; - } - this.nbFilterableRows = this.getRowsNb(); - this.nbVisibleRows = this.nbFilterableRows; - this.nbRows = this.nbFilterableRows + this.refRow; - } else { - if (this.isFirstLoad) { - var fltrow; - if (!this.gridLayout) { - var thead = dom.tag(this.tbl, "thead"); - if (thead.length > 0) { - fltrow = thead[0].insertRow(this.filtersRowIndex); - } else { - fltrow = this.tbl.insertRow(this.filtersRowIndex); - } - - if (this.headersRow > 1 && this.filtersRowIndex <= this.headersRow && !this.popUpFilters) { - this.headersRow++; - } - if (this.popUpFilters) { - this.headersRow++; - } - - fltrow.className = this.fltsRowCssClass; - //Disable for grid_layout - if (this.isExternalFlt && (!this.gridLayout || this.popUpFilters)) { - fltrow.style.display = "none"; - } - } - - this.nbFilterableRows = this.getRowsNb(); - this.nbVisibleRows = this.nbFilterableRows; - this.nbRows = this.tbl.rows.length; - - for (var i = 0; i < n; i++) { - // this loop adds filters - - if (this.popUpFilters) { - this.Cpt.popupFilter.build(i); - } - - var fltcell = dom.create(this.fltCellTag), - col = this["col" + i], - externalFltTgtId = this.isExternalFlt && this.externalFltTgtIds ? this.externalFltTgtIds[i] : null; - - if (this.singleSearchFlt) { - fltcell.colSpan = this.nbCells; - } - if (!this.gridLayout) { - fltrow.appendChild(fltcell); - } - inpclass = i == n - 1 && this.displayBtn ? this.fltSmallCssClass : this.fltCssClass; - - if (col === undefined) { - col = f["col_" + i] === undefined ? this.fltTypeInp : str.lower(f["col_" + i]); - } - - //only 1 input for single search - if (this.singleSearchFlt) { - col = this.fltTypeInp; - inpclass = this.singleFltCssClass; - } - - //drop-down filters - if (col === this.fltTypeSlc || col === this.fltTypeMulti) { - if (!this.Cpt.dropdown) { - // var Dropdown = require('modules/dropdown').Dropdown; - // import {Dropdown} from 'modules/dropdown'; - this.Cpt.dropdown = new Dropdown(this); - } - var dropdown = this.Cpt.dropdown; - - var slc = dom.create(this.fltTypeSlc, ["id", this.prfxFlt + i + "_" + this.id], ["ct", i], ["filled", "0"]); - - if (col === this.fltTypeMulti) { - slc.multiple = this.fltTypeMulti; - slc.title = dropdown.multipleSlcTooltip; - } - slc.className = str.lower(col) === this.fltTypeSlc ? inpclass : this.fltMultiCssClass; // for ie<=6 - - //filter is appended in desired external element - if (externalFltTgtId) { - dom.id(externalFltTgtId).appendChild(slc); - this.externalFltEls.push(slc); - } else { - fltcell.appendChild(slc); - } - - this.fltIds.push(this.prfxFlt + i + "_" + this.id); - - if (!this.fillSlcOnDemand) { - dropdown._build(i); - } - - evt.add(slc, "keypress", this.Evt._DetectKey); - evt.add(slc, "change", this.Evt._OnSlcChange); - evt.add(slc, "focus", this.Evt._OnSlcFocus); - evt.add(slc, "blur", this.Evt._OnSlcBlur); - - //1st option is created here since dropdown.build isn't - //invoked - if (this.fillSlcOnDemand) { - var opt0 = dom.createOpt(this.displayAllText, ""); - slc.appendChild(opt0); - } - } - // checklist - else if (col === this.fltTypeCheckList) { - if (!this.Cpt.checkList) { - // var CheckList = - // require('modules/checkList').CheckList; - // import {CheckList} from 'modules/checkList'; - this.Cpt.checkList = new CheckList(this); - } - - var divCont = dom.create("div", ["id", this.prfxCheckListDiv + i + "_" + this.id], ["ct", i], ["filled", "0"]); - divCont.className = this.Cpt.checkList.checkListDivCssClass; - - //filter is appended in desired element - if (externalFltTgtId) { - dom.id(externalFltTgtId).appendChild(divCont); - this.externalFltEls.push(divCont); - } else { - fltcell.appendChild(divCont); - } - - this.Cpt.checkList.checkListDiv[i] = divCont; - this.fltIds.push(this.prfxFlt + i + "_" + this.id); - if (!this.fillSlcOnDemand) { - this.Cpt.checkList._build(i); - } - - if (this.fillSlcOnDemand) { - evt.add(divCont, "click", this.Evt._OnCheckListClick); - divCont.appendChild(dom.text(this.Cpt.checkList.activateCheckListTxt)); - } - - evt.add(divCont, "click", this.Evt._OnCheckListFocus); - } else { - //show/hide input - var inptype = col === this.fltTypeInp ? "text" : "hidden"; - var inp = dom.create(this.fltTypeInp, ["id", this.prfxFlt + i + "_" + this.id], ["type", inptype], ["ct", i]); - if (inptype !== "hidden" && this.watermark) { - inp.setAttribute("placeholder", this.isWatermarkArray ? this.watermark[i] : this.watermark); - } - inp.className = inpclass; - inp.onfocus = this.Evt._OnInpFocus; - - //filter is appended in desired element - if (externalFltTgtId) { - dom.id(externalFltTgtId).appendChild(inp); - this.externalFltEls.push(inp); - } else { - fltcell.appendChild(inp); - } - - this.fltIds.push(this.prfxFlt + i + "_" + this.id); - - inp.onkeypress = this.Evt._DetectKey; - inp.onkeydown = this.Evt._OnKeyDown; - inp.onkeyup = this.Evt._OnKeyUp; - inp.onblur = this.Evt._OnInpBlur; - - if (this.rememberGridValues) { - var flts_values = this.Cpt.store.getFilterValues(this.fltsValuesCookie); - if (flts_values[i] != " ") { - this.setFilterValue(i, flts_values[i], false); - } - } - } - // this adds submit button - if (i == n - 1 && this.displayBtn) { - var btn = dom.create(this.fltTypeInp, ["id", this.prfxValButton + i + "_" + this.id], ["type", "button"], ["value", this.btnText]); - btn.className = this.btnCssClass; - - //filter is appended in desired element - if (externalFltTgtId) { - dom.id(externalFltTgtId).appendChild(btn); - } else { - fltcell.appendChild(btn); - } - - btn.onclick = this.Evt._OnBtnClick; - } //if - } // for i - } else { - this._resetGrid(); - } //if isFirstLoad - } //if this.fltGrid - - /* Filter behaviours */ - if (this.rowsCounter) { - // var RowsCounter = require('modules/rowsCounter').RowsCounter; - // import {RowsCounter} from 'modules/rowsCounter'; - this.Cpt.rowsCounter = new RowsCounter(this); - this.Cpt.rowsCounter.init(); - } - if (this.statusBar) { - // var StatusBar = require('modules/statusBar').StatusBar; - // import {StatusBar} from 'modules/statusBar'; - this.Cpt.statusBar = new StatusBar(this); - this.Cpt.statusBar.init(); - } - if (this.paging) { - // var Paging = require('modules/paging').Paging; - // import {Paging} from 'modules/paging'; - this.Cpt.paging = new Paging(this); - this.Cpt.paging.init(); - } - if (this.btnReset) { - // var ClearButton = require('modules/clearButton').ClearButton; - // import {ClearButton} from 'modules/clearButton'; - this.Cpt.clearButton = new ClearButton(this); - this.Cpt.clearButton.init(); - } - if (this.helpInstructions) { - // var Help = require('modules/help').Help; - // import {Help} from 'modules/help'; - this.Cpt.help = new Help(this); - this.Cpt.help.init(); - } - if (this.hasColWidth && !this.gridLayout) { - this.setColWidths(); - } - if (this.alternateBgs) { - //1st time only if no paging and rememberGridValues - // var AlternateRows = require('modules/alternateRows').AlternateRows; - // import {AlternateRows} from 'modules/alternateRows'; - this.Cpt.alternateRows = new AlternateRows(this); - this.Cpt.alternateRows.init(); - } - if (this.hasColOperation) { - // var ColOps = require('modules/colOps').ColOps; - // import {ColOps} from 'modules/colOps'; - this.Cpt.colOps = new ColOps(this); - this.Cpt.colOps.calc(); - } - if (this.sort /*|| this.gridLayout*/) { - this.setSort(); - } - if (this.selectable || this.editable) { - this.SetEditable(); - } - - this.isFirstLoad = false; - this._hasGrid = true; - - if (this.rememberGridValues || this.rememberPageLen || this.rememberPageNb) { - this.resetValues(); - } - - //TF css class is added to table - if (!this.gridLayout) { - dom.addClass(this.tbl, this.prfxTf); - } - - if (this.loader) { - this.Cpt.loader.show("none"); - } - - /* Loads extensions */ - if (this.hasExtensions) { - this.LoadExtensions(); - } - - if (this.onFiltersLoaded) { - this.onFiltersLoaded.call(null, this); - } - }, - writable: true, - configurable: true - }, - EvtManager: { - - /*==================================================== - - TF events manager - - Params: - - event name (string) - - config object (optional literal object) - =====================================================*/ - - value: function EvtManager(evt, s) { - var o = this; - var slcIndex = s && s.slcIndex !== undefined ? s.slcIndex : null; - var slcExternal = s && s.slcExternal !== undefined ? s.slcExternal : false; - var slcId = s && s.slcId !== undefined ? s.slcId : null; - var pgIndex = s && s.pgIndex !== undefined ? s.pgIndex : null; - - function efx() { - if (!evt) { - return; - } - switch (evt) { - case o.Evt.name.filter: - if (o.isModFilterFn) { - o.modFilterFn.call(null, o); - } else { - o._filter(); - } - break; - case o.Evt.name.dropdown: - if (o.linkedFilters) { - o.Cpt.dropdown._build(slcIndex, true); - } else { - o.Cpt.dropdown._build(slcIndex, false, slcExternal, slcId); - } - break; - case o.Evt.name.checklist: - o.Cpt.checkList._build(slcIndex, slcExternal, slcId); - break; - case o.Evt.name.changepage: - o.Cpt.paging._changePage(pgIndex); - break; - case o.Evt.name.clear: - o._clearFilters(); - o._filter(); - break; - case o.Evt.name.changeresultsperpage: - o.Cpt.paging._changeResultsPerPage(); - break; - case o.Evt.name.resetvalues: - o._resetValues(); - o._filter(); - break; - case o.Evt.name.resetpage: - o.Cpt.paging._resetPage(o.pgNbCookie); - break; - case o.Evt.name.resetpagelength: - o.Cpt.paging._resetPageLength(o.pgLenCookie); - break; - case o.Evt.name.sort: - void 0; - break; - case o.Evt.name.loadextensions: - o._LoadExtensions(); - break; - case o.Evt.name.loadthemes: - o._LoadThemes(); - break; - default: - //to be used by extensions events when needed - o["_" + evt].call(null, o, s); - break; - } - if (o.statusBar) { - o.Cpt.statusBar.message(""); - } - if (o.loader) { - o.Cpt.loader.show("none"); - } - } - - if (this.loader || this.statusBar) { - try { - this.Cpt.loader.show(""); - // this.StatusMsg(o['msg'+evt]); - this.Cpt.statusBar.message(this["msg" + evt]); - } catch (e) {} - global.setTimeout(efx, this.execDelay); - } else { - efx(); - } - }, - writable: true, - configurable: true - }, - ImportModule: { - value: function ImportModule(module) { - if (!module.path || !module.name) { - return; - } - this.includeFile(module.name, module.path, module.init); - }, - writable: true, - configurable: true - }, - LoadExtensions: { - value: function LoadExtensions() { - if (!this.Ext) { - /*** TF extensions ***/ - var o = this; - this.Ext = { - list: {}, - add: function add(extName, extDesc, extPath, extCallBack) { - var file = extPath.split("/")[extPath.split("/").length - 1], - re = new RegExp(file), - path = extPath.replace(re, ""); - o.Ext.list[extName] = { - name: extName, - description: extDesc, - file: file, - path: path, - callback: extCallBack - }; - } - }; - } - this.EvtManager(this.Evt.name.loadextensions); - }, - writable: true, - configurable: true - }, - _LoadExtensions: { - - /*==================================================== - - loads TF extensions - =====================================================*/ - - value: function _LoadExtensions() { - if (!this.hasExtensions || !types.isArray(this.extensions.name) || !types.isArray(this.extensions.src)) { - return; - } - var ext = this.extensions; - for (var e = 0; e < ext.name.length; e++) { - var extPath = ext.src[e], - extName = ext.name[e], - extInit = ext.initialize && ext.initialize[e] ? ext.initialize[e] : null, - extDesc = ext.description && ext.description[e] ? ext.description[e] : null; - - //Registers extension - this.Ext.add(extName, extDesc, extPath, extInit); - if (this.isImported(extPath)) { - extInit.call(null, this); - } else { - this.includeFile(extName, extPath, extInit); - } - } - }, - writable: true, - configurable: true - }, - LoadThemes: { - value: function LoadThemes() { - this.EvtManager(this.Evt.name.loadthemes); - }, - writable: true, - configurable: true - }, - _LoadThemes: { - - /*==================================================== - - loads TF themes - =====================================================*/ - - value: function _LoadThemes() { - if (!this.hasThemes) { - return; - } - if (!this.Thm) { - /*** TF themes ***/ - var o = this; - this.Thm = { - list: {}, - add: function add(thmName, thmDesc, thmPath, thmCallBack) { - var file = thmPath.split("/")[thmPath.split("/").length - 1], - re = new RegExp(file), - path = thmPath.replace(re, ""); - o.Thm.list[thmName] = { - name: thmName, - description: thmDesc, - file: file, - path: path, - callback: thmCallBack - }; - } - }; - } - - //Default theme config - if (this.enableDefaultTheme) { - this.themes = { - name: ["DefaultTheme"], - src: [this.themesPath + "Default/TF_Default.css"], - description: ["Default Theme"] - }; - this.Thm.add("DefaultTheme", this.themesPath + "Default/TF_Default.css", "Default Theme"); - } - if (types.isArray(this.themes.name) && types.isArray(this.themes.src)) { - var thm = this.themes; - for (var i = 0; i < thm.name.length; i++) { - var thmPath = thm.src[i], - thmName = thm.name[i], - thmInit = thm.initialize && thm.initialize[i] ? thm.initialize[i] : null, - thmDesc = thm.description && thm.description[i] ? thm.description[i] : null; - - //Registers theme - this.Thm.add(thmName, thmDesc, thmPath, thmInit); - - if (!this.isImported(thmPath, "link")) { - this.includeFile(thmName, thmPath, null, "link"); - } - if (types.isFn(thmInit)) { - thmInit.call(null, this); - } - } - } - - //Some elements need to be overriden for theme - //Reset button - this.btnResetText = null; - this.btnResetHtml = ""; - - //Paging buttons - this.btnPrevPageHtml = ""; - this.btnNextPageHtml = ""; - this.btnFirstPageHtml = ""; - this.btnLastPageHtml = ""; - - //Loader - this.loader = true; - this.loaderHtml = "
"; - this.loaderText = null; - }, - writable: true, - configurable: true - }, - remove: { - - /*==================================================== - - removes a filter grid - =====================================================*/ - - value: function remove() { - if (this.fltGrid && this._hasGrid) { - var rows = this.tbl.rows; - if (this.paging) { - this.Cpt.paging.destroy(); - } - if (this.statusBar) { - this.Cpt.statusBar.destroy(); - } - if (this.rowsCounter) { - this.Cpt.rowsCounter.destroy(); - } - if (this.btnReset) { - this.Cpt.clearButton.destroy(); - } - if (this.helpInstructions) { - this.Cpt.help.destroy(); - } - if (this.isExternalFlt && !this.popUpFilters) { - this.removeExternalFlts(); - } - if (this.infDiv) { - this.removeToolbar(); - } - if (this.highlightKeywords) { - this.Cpt.highlightKeyword.unhighlightAll(); - } - if (this.sort) { - this.RemoveSort(); - } - if (this.loader) { - this.Cpt.loader.remove(); - } - if (this.popUpFilters) { - this.Cpt.popupFilter.destroy(); - } - if (this.markActiveColumns) { - this.clearActiveColumns(); - } - if (this.editable || this.selectable) { - this.RemoveEditable(); - } - //this loop shows all rows and removes validRow attribute - for (var j = this.refRow; j < this.nbRows; j++) { - rows[j].style.display = ""; - try { - if (rows[j].hasAttribute("validRow")) { - rows[j].removeAttribute("validRow"); - } - } catch (e) { - //ie<=6 doesn't support hasAttribute method - var row = rows[j]; - var attribs = row.attributes; - for (var x = 0; x < attribs.length; x++) { - if (str.lower(attribs.nodeName) === "validrow") { - row.removeAttribute("validRow"); - } - } - } - - //removes alternating colors - if (this.alternateBgs) { - this.Cpt.alternateRows.removeRowBg(j); - } - } //for j - - if (this.fltGrid && !this.gridLayout) { - this.fltGridEl = rows[this.filtersRowIndex]; - this.tbl.deleteRow(this.filtersRowIndex); - } - if (this.gridLayout) { - this.Cpt.gridLayout.destroy(); - } - dom.removeClass(this.tbl, this.prfxTf); - this.activeFlt = null; - this.isStartBgAlternate = true; - this._hasGrid = false; - this.tbl = null; - } //if this.fltGrid - }, - writable: true, - configurable: true - }, - setToolbar: { - - /*==================================================== - - Generates div above table where paging, - reset button, rows counter label etc. are placed - =====================================================*/ - - value: function setToolbar() { - if (this.infDiv !== null) { - return; - } - - /*** container div ***/ - var infdiv = dom.create("div", ["id", this.prfxInfDiv + this.id]); - infdiv.className = this.infDivCssClass; - - //custom container - if (this.toolBarTgtId) { - dom.id(this.toolBarTgtId).appendChild(infdiv); - } - //grid-layout - else if (this.gridLayout) { - this.Cpt.gridLayout.tblMainCont.appendChild(infdiv); - infdiv.className = this.gridInfDivCssClass; - } - //default location: just above the table - else { - this.tbl.parentNode.insertBefore(infdiv, this.tbl); - } - this.infDiv = dom.id(this.prfxInfDiv + this.id); - - /*** left div containing rows # displayer ***/ - var ldiv = dom.create("div", ["id", this.prfxLDiv + this.id]); - ldiv.className = this.lDivCssClass; - infdiv.appendChild(ldiv); - this.lDiv = dom.id(this.prfxLDiv + this.id); - - /*** right div containing reset button - + nb results per page select ***/ - var rdiv = dom.create("div", ["id", this.prfxRDiv + this.id]); - rdiv.className = this.rDivCssClass; - infdiv.appendChild(rdiv); - this.rDiv = dom.id(this.prfxRDiv + this.id); - - /*** mid div containing paging elements ***/ - var mdiv = dom.create("div", ["id", this.prfxMDiv + this.id]); - mdiv.className = this.mDivCssClass; - infdiv.appendChild(mdiv); - this.mDiv = dom.id(this.prfxMDiv + this.id); - - // Enable help instructions by default is topbar is generated - if (!this.helpInstructions) { - if (!this.Cpt.help) { - // var Help = require('modules/help').Help; - // import {Help} from 'modules/help'; - this.Cpt.help = new Help(this); - } - this.Cpt.help.init(); - } - }, - writable: true, - configurable: true - }, - removeToolbar: { - - /*==================================================== - - Removes div above table where paging, - reset button, rows counter label etc. are placed - =====================================================*/ - - value: function removeToolbar() { - if (!this.infDiv) { - return; - } - this.infDiv.parentNode.removeChild(this.infDiv); - this.infDiv = null; - }, - writable: true, - configurable: true - }, - removeExternalFlts: { - - /*==================================================== - - removes external filters - =====================================================*/ - - value: function removeExternalFlts() { - if (!this.isExternalFlt && !this.externalFltTgtIds) { - return; - } - for (var ct = 0; ct < this.externalFltTgtIds.length; ct++) { - var externalFltTgtId = this.externalFltTgtIds[ct], - externalFlt = dom.id(externalFltTgtId); - if (externalFlt) { - externalFlt.innerHTML = ""; - } - } - }, - writable: true, - configurable: true - }, - setSort: { - - /*==================================================== - - Sets sorting feature by loading - WebFX Sortable Table 1.12 plugin by Erik Arvidsson - and TF adapter by Max Guglielmi - =====================================================*/ - - value: function setSort() { - var adapterSortabletable = new AdapterSortableTable(this); - this.Extensions.sort = adapterSortabletable; - adapterSortabletable.init(); - }, - writable: true, - configurable: true - }, - setOldSort: { - value: function setOldSort() { - var fn = this.Evt._EnableSort, - sortConfig = this.sortConfig, - o = this; - - if (!types.isFn(fn)) { - - /*==================================================== - - enables table sorting - =====================================================*/ - this.Evt._EnableSort = function () { - //gridLayout needs sort to be re-enabled - if (o.isSortEnabled && !o.gridLayout) { - return; - } - - // if(o.isImported(sortConfig.adapterSrc)){ - // sortConfig.initialize.call(null,o); - // } else { - // o.includeFile( - // sortConfig.name+'_adapter', - // sortConfig.adapterSrc, - // function(){ sortConfig.initialize.call(null, o); } - // ); - // } - // define( - // 'extensions/sortabletable/adapterSortabletable', - // function(){} - // ); - // require.config({ - // baseUrl: '../dist', - // paths: { - // 'a': '/tablefilter', - // 'SortableTable': - // '/extensions/sortabletable/sortabletable', - // 'sortabletable': - // '/extensions/sortabletable/adapterSortabletable' - // }, - // name: '../dist/extensions/sortabletable/adapterSortabletable' - // }); - - // Lazy loading for the sort extension - // console.log('lazy', define); - // define(['require'], function(require){ - // console.log(require); - // - var AdapterSortableTable = require(["extensions/sortabletable/adapterSortabletable"], function (adapterSortabletable) { - o.Extensions.sort = new adapterSortabletable(o); - o.Extensions.sort.init(); - }); - - // o.includeFile( - // 'sortConfig.name', - // o.basePath + '/extensions/sortabletable/adapterSortabletable.js', - // function(){ - // console.log(AdapterSortableTable); - // }); - - // }); - }; - } - - function loadSortableTable() { - console.log("loadSortable"); - if (o.isImported(sortConfig.src)) { - o.Evt._EnableSort(); - } else { - o.includeFile(sortConfig.name, sortConfig.src, o.Evt._EnableSort); - } - } - - // Import require.js if required for production environment - console.log("is require loaded: " + o.isImported("require.js")); - if (o.isImported("require.js")) { - loadSortableTable(); - } else { - o.includeFile("tf-requirejs", o.basePath + "require.js", o.Evt._EnableSort); - - // o.includeFile('tf-requirejs', - // o.basePath + 'require.js', - // function(){ - // Lazy loading for the sort extension - // console.log('lazy', define); - // define(['require'], function(require){ - // console.log(require); - // var AdapterSortableTable = require( - // ['extensions/sortabletable/adapterSortabletable'], - // function(adapterSortabletable){ - // console.log(adapterSortabletable); - // // o.Extensions.sort = new adapterSortabletable(o); - // // o.Extensions.sort.init(); - // }); - // }); - // } - // ); - } - }, - writable: true, - configurable: true - }, - removeSort: { - - /*==================================================== - - removes sorting feature - =====================================================*/ - - value: function removeSort() { - this.sort = false; - }, - writable: true, - configurable: true - }, - performSort: { - value: function performSort() { - this.EvtManager(this.Evt.name.sort); - }, - writable: true, - configurable: true - }, - SetEditable: { - - /*==================================================== - - Sets selection or edition features by loading - ezEditTable script by Max Guglielmi - =====================================================*/ - - value: function SetEditable() { - var ezEditConfig = this.ezEditTableConfig; - if (this.isImported(ezEditConfig.src)) { - this._EnableEditable(); - } else { - this.includeFile(ezEditConfig.name, ezEditConfig.src, this._EnableEditable); - } - if (ezEditConfig.loadStylesheet && !this.isImported(ezEditConfig.stylesheet, "link")) { - this.includeFile(ezEditConfig.stylesheetName, ezEditConfig.stylesheet, null, "link"); - } - }, - writable: true, - configurable: true - }, - RemoveEditable: { - - /*==================================================== - - Removes selection or edition features - =====================================================*/ - - value: function RemoveEditable() { - var ezEditTable = this.ezEditTable; - if (ezEditTable) { - if (this.selectable) { - ezEditTable.Selection.ClearSelections(); - ezEditTable.Selection.Remove(); - } - if (this.editable) { - ezEditTable.Editable.Remove(); - } - } - }, - writable: true, - configurable: true - }, - ResetEditable: { - - /*==================================================== - - Resets selection or edition features after - removal - =====================================================*/ - - value: function ResetEditable() { - var ezEditTable = this.ezEditTable; - if (ezEditTable) { - if (this.selectable) { - ezEditTable.Selection.Set(); - } - if (this.editable) { - ezEditTable.Editable.Set(); - } - } - }, - writable: true, - configurable: true - }, - _EnableEditable: { - value: function _EnableEditable(o) { - if (!o) { - o = this; - } - - //start row for EditTable constructor needs to be calculated - var startRow, - ezEditConfig = o.ezEditTableConfig, - thead = dom.tag(o.tbl, "thead"); - - //if thead exists and startRow not specified, startRow is calculated - //automatically by EditTable - if (thead.length > 0 && !ezEditConfig.startRow) { - startRow = undefined; - } - //otherwise startRow config property if any or TableFilter refRow - else { - startRow = ezEditConfig.startRow || o.refRow; - } - - ezEditConfig.scroll_into_view = ezEditConfig.scroll_into_view === false ? false : true; - ezEditConfig.base_path = ezEditConfig.base_path || o.basePath + "ezEditTable/"; - ezEditConfig.editable = o.editable = o.cfg.editable; - ezEditConfig.selection = o.selectable = o.cfg.selectable; - - if (o.selectable) { - ezEditConfig.default_selection = ezEditConfig.default_selection || "row"; - } - //CSS Styles - ezEditConfig.active_cell_css = ezEditConfig.active_cell_css || "ezETSelectedCell"; - - o._lastValidRowIndex = 0; - o._lastRowIndex = 0; - - if (o.selectable) { - //Row navigation needs to be calculated according to TableFilter's - //validRowsIndex array - var onAfterSelection = function onAfterSelection(et, selectedElm, e) { - //table is not filtered - if (!o.validRowsIndex) { - return; - } - var validIndexes = o.validRowsIndex, - validIdxLen = validIndexes.length, - row = et.defaultSelection !== "row" ? selectedElm.parentNode : selectedElm, - - //cell for default_selection = 'both' or 'cell' - cell = selectedElm.nodeName === "TD" ? selectedElm : null, - keyCode = e !== undefined ? et.Event.GetKey(e) : 0, - isRowValid = array.has(validIndexes, row.rowIndex), - nextRowIndex, - - //pgup/pgdown keys - d = keyCode === 34 || keyCode === 33 ? o.pagingLength || et.nbRowsPerPage : 1; - - //If next row is not valid, next valid filtered row needs to be - //calculated - if (!isRowValid) { - //Selection direction up/down - if (row.rowIndex > o._lastRowIndex) { - //last row - if (row.rowIndex >= validIndexes[validIdxLen - 1]) { - nextRowIndex = validIndexes[validIdxLen - 1]; - } else { - var calcRowIndex = o._lastValidRowIndex + d; - if (calcRowIndex > validIdxLen - 1) { - nextRowIndex = validIndexes[validIdxLen - 1]; - } else { - nextRowIndex = validIndexes[calcRowIndex]; - } - } - } else { - //first row - if (row.rowIndex <= validIndexes[0]) { - nextRowIndex = validIndexes[0]; - } else { - var v = validIndexes[o._lastValidRowIndex - d]; - nextRowIndex = v ? v : validIndexes[0]; - } - } - o._lastRowIndex = row.rowIndex; - DoSelection(nextRowIndex); - } else { - //If filtered row is valid, special calculation for - //pgup/pgdown keys - if (keyCode !== 34 && keyCode !== 33) { - o._lastValidRowIndex = array.indexByValue(validIndexes, row.rowIndex); - o._lastRowIndex = row.rowIndex; - } else { - if (keyCode === 34) { - //pgdown - //last row - if (o._lastValidRowIndex + d <= validIdxLen - 1) { - nextRowIndex = validIndexes[o._lastValidRowIndex + d]; - } else { - nextRowIndex = [validIdxLen - 1]; - } - } else { - //pgup - //first row - if (o._lastValidRowIndex - d <= validIndexes[0]) { - nextRowIndex = validIndexes[0]; - } else { - nextRowIndex = validIndexes[o._lastValidRowIndex - d]; - } - } - o._lastRowIndex = nextRowIndex; - o._lastValidRowIndex = array.indexByValue(validIndexes, nextRowIndex); - DoSelection(nextRowIndex); - } - } - - //Next valid filtered row needs to be selected - var DoSelection = function DoSelection(nextRowIndex) { - if (et.defaultSelection === "row") { - et.Selection.SelectRowByIndex(nextRowIndex); - } else { - et.ClearSelections(); - var cellIndex = selectedElm.cellIndex, - row = o.tbl.rows[nextRowIndex]; - if (et.defaultSelection === "both") { - et.Selection.SelectRowByIndex(nextRowIndex); - } - if (row) { - et.Selection.SelectCell(row.cells[cellIndex]); - } - } - //Table is filtered - if (o.validRowsIndex.length !== o.getRowsNb()) { - var r = o.tbl.rows[nextRowIndex]; - if (r) { - r.scrollIntoView(false); - } - if (cell) { - if (cell.cellIndex === o.getCellsNb() - 1 && o.gridLayout) { - o.tblCont.scrollLeft = 100000000; - } else if (cell.cellIndex === 0 && o.gridLayout) { - o.tblCont.scrollLeft = 0; - } else { - cell.scrollIntoView(false); - } - } - } - }; - }; - - //Page navigation has to be enforced whenever selected row is out of - //the current page range - var onBeforeSelection = function onBeforeSelection(et, selectedElm, e) { - var row = et.defaultSelection !== "row" ? selectedElm.parentNode : selectedElm; - if (o.paging) { - if (o.nbPages > 1) { - //page length is re-assigned in case it has changed - et.nbRowsPerPage = o.pagingLength; - var validIndexes = o.validRowsIndex, - validIdxLen = validIndexes.length, - pagingEndRow = parseInt(o.startPagingRow, 10) + parseInt(o.pagingLength, 10); - var rowIndex = row.rowIndex; - if (rowIndex === validIndexes[validIdxLen - 1] && o.currentPageNb != o.nbPages) { - // o.SetPage('last'); - o.Cpt.paging.setPage("last"); - } else if (rowIndex == validIndexes[0] && o.currentPageNb !== 1) { - // o.SetPage('first'); - o.Cpt.paging.setPage("first"); - } else if (rowIndex > validIndexes[pagingEndRow - 1] && rowIndex < validIndexes[validIdxLen - 1]) { - // o.SetPage('next'); - o.Cpt.paging.setPage("next"); - } else if (rowIndex < validIndexes[o.startPagingRow] && rowIndex > validIndexes[0]) { - // o.SetPage('previous'); - o.Cpt.paging.setPage("previous"); - } - } - } - }; - - //Selected row needs to be visible when paging is activated - if (o.paging) { - o.onAfterChangePage = function (tf, i) { - var et = tf.ezEditTable; - var row = et.Selection.GetActiveRow(); - if (row) { - row.scrollIntoView(false); - } - var cell = et.Selection.GetActiveCell(); - if (cell) { - cell.scrollIntoView(false); - } - }; - } - - //Rows navigation when rows are filtered is performed with the - //EditTable row selection callback events - if (ezEditConfig.default_selection === "row") { - var fnB = ezEditConfig.on_before_selected_row; - ezEditConfig.on_before_selected_row = function () { - onBeforeSelection(arguments[0], arguments[1], arguments[2]); - if (fnB) { - fnB.call(null, arguments[0], arguments[1], arguments[2]); - } - }; - var fnA = ezEditConfig.on_after_selected_row; - ezEditConfig.on_after_selected_row = function () { - onAfterSelection(arguments[0], arguments[1], arguments[2]); - if (fnA) { - fnA.call(null, arguments[0], arguments[1], arguments[2]); - } - }; - } else { - var fnD = ezEditConfig.on_before_selected_cell; - ezEditConfig.on_before_selected_cell = function () { - onBeforeSelection(arguments[0], arguments[1], arguments[2]); - if (fnD) { - fnD.call(null, arguments[0], arguments[1], arguments[2]); - } - }; - var fnC = ezEditConfig.on_after_selected_cell; - ezEditConfig.on_after_selected_cell = function () { - onAfterSelection(arguments[0], arguments[1], arguments[2]); - if (fnC) { - fnC.call(null, arguments[0], arguments[1], arguments[2]); - } - }; - } - } - if (o.editable) { - //Added or removed rows, TF rows number needs to be re-calculated - var fnE = ezEditConfig.on_added_dom_row; - ezEditConfig.on_added_dom_row = function () { - o.nbFilterableRows++; - if (!o.paging) { - o.Cpt.rowsCounter.refresh(); - } else { - o.nbRows++; - o.nbVisibleRows++; - o.nbFilterableRows++; - o.paging = false; - o.Cpt.paging.destroy(); - o.Cpt.paging.addPaging(); - } - if (o.alternateBgs) { - o.Cpt.alternateRows.init(); - } - if (fnE) { - fnE.call(null, arguments[0], arguments[1], arguments[2]); - } - }; - if (ezEditConfig.actions && ezEditConfig.actions["delete"]) { - var fnF = ezEditConfig.actions["delete"].on_after_submit; - ezEditConfig.actions["delete"].on_after_submit = function () { - o.nbFilterableRows--; - if (!o.paging) { - o.Cpt.rowsCounter.refresh(); - } else { - o.nbRows--; - o.nbVisibleRows--; - o.nbFilterableRows--; - o.paging = false; - o.Cpt.paging.destroy(); - o.Cpt.paging.addPaging(false); - } - if (o.alternateBgs) { - o.Cpt.alternateRows.init(); - } - if (fnF) { - fnF.call(null, arguments[0], arguments[1]); - } - }; - } - } - - try { - o.ezEditTable = new EditTable(o.id, ezEditConfig, startRow); - o.ezEditTable.Init(); - } catch (e) { - console.log(ezEditConfig.err); - } - }, - writable: true, - configurable: true - }, - resetValues: { - - /*==================================================== - - IE bug: it seems there is no way to make - multiple selections programatically, only last - selection is kept (multiple select previously - populated via DOM) - - Work-around: defer selection with a setTimeout - If you find a more elegant solution to - this let me know ;-) - - For the moment only this solution seems to work! - - Params: - - slc = select object (select obj) - - index to be selected (integer) - - execute filtering (boolean) - =====================================================*/ - // __deferMultipleSelection: function(slc,index,filter){ - // if(str.lower(slc.nodeName)!=='select'){ - // return; - // } - // var doFilter = filter===undefined ? false : filter; - // var o = this; - // global.setTimeout(function(){ - // slc.options[0].selected = false; - - // if(slc.options[index].value===''){ - // slc.options[index].selected = false; - // } - // else{ - // slc.options[index].selected = true; - // if(doFilter){ - // o.filter(); - // } - // } - // }, 0.1); - // }, - - /*==================================================== - - Returns an array [[values],[texts]] with - custom values for a given filter - - Param: column index (integer) - =====================================================*/ - // _getCustomValues: function(colIndex){ - // if(!colIndex){ - // return; - // } - // //custom select test - // var isCustomSlc = this.hasCustomSlcOptions && - // array.has(this.customSlcOptions.cols, colIndex); - // if(!isCustomSlc){ - // return; - // } - // var optTxt = [], optArray = []; - // var index = array.indexByValue(this.customSlcOptions.cols, colIndex); - // var slcValues = this.customSlcOptions.values[index]; - // var slcTexts = this.customSlcOptions.texts[index]; - // var slcSort = this.customSlcOptions.sorts[index]; - // for(var r=0; r