Skip to content

Commit

Permalink
Implemented callbacks: clusterWillChange, clusterChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
NeXTs committed Nov 10, 2015
1 parent c76864b commit d89eee2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
12 changes: 8 additions & 4 deletions clusterize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Clusterize.js - v0.12.0 - 2015-08-14
/*! Clusterize.js - v0.13.0 - 2015-11-10
* http://NeXTs.github.com/Clusterize.js/
* Copyright (c) 2015 Denis Lukov; Licensed MIT */

Expand Down Expand Up @@ -40,12 +40,13 @@
no_data_class: 'clusterize-no-data',
no_data_text: 'No data',
keep_parity: true,
verify_change: false
verify_change: false,
callbacks: {}
}

// public parameters
self.options = {};
var options = ['rows_in_block', 'blocks_in_cluster', 'verify_change', 'show_no_data_row', 'no_data_class', 'no_data_text', 'keep_parity', 'tag'];
var options = ['rows_in_block', 'blocks_in_cluster', 'verify_change', 'show_no_data_row', 'no_data_class', 'no_data_text', 'keep_parity', 'tag', 'callbacks'];
for(var i = 0, option; option = options[i]; i++) {
self.options[option] = typeof data[option] != 'undefined' && data[option] != null
? data[option]
Expand Down Expand Up @@ -250,10 +251,13 @@
// if necessary verify data changed and insert to DOM
insertToDOM: function(rows, cache) {
var data = this.generate(rows, this.getClusterNum()),
outer_data = data.rows.join('');
outer_data = data.rows.join(''),
callbacks = this.options.callbacks;
if( ! this.options.verify_change || this.options.verify_change && this.dataChanged(outer_data, cache)) {
callbacks.clusterWillChange && callbacks.clusterWillChange();
this.html(outer_data);
this.options.content_tag == 'ol' && this.content_elem.setAttribute('start', data.rows_above);
callbacks.clusterChanged && callbacks.clusterChanged();
}
},
// unfortunately ie <= 9 does not allow to use innerHTML for table elements, so make a workaround
Expand Down
16 changes: 8 additions & 8 deletions clusterize.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clusterize.js",
"version": "0.12.0",
"version": "0.13.0",
"description": "Tiny vanilla JS plugin to display large data sets easily",
"main": "clusterize.js",
"style": "clusterize.css",
Expand Down

0 comments on commit d89eee2

Please sign in to comment.