aboutsummaryrefslogtreecommitdiffstats
path: root/static/tabulator/js/jquery_wrapper.js
blob: e8ff80f2ffcea72ea791bd1eebeec435af8faf5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * This file is part of the Tabulator package.
 *
 * (c) Oliver Folkerd <oliver.folkerd@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * Full Documentation & Demos can be found at: http://olifolkerd.github.io/tabulator/
 *
 */

(function (root, factory) {
	"use strict";
	if (typeof define === 'function' && define.amd) {
		define(['jquery', 'tabulator', 'jquery-ui'], factory);
	}
	else if(typeof module !== 'undefined' && module.exports) {
		module.exports = factory(
			require('jquery'),
			require('tabulator'),
			require('jquery-ui')
		);
	}
	else {
		factory(root.jQuery, root.Tabulator);
	}
}(this, function ($, Tabulator) {

	$.widget("ui.tabulator", {
		_create:function(){
			var options = Object.assign({}, this.options);

			delete options.create;
			delete options.disabled;

			this.table = new Tabulator(this.element[0], options);

			//map tabulator functions to jquery wrapper
			for(var key in Tabulator.prototype){
				if(typeof Tabulator.prototype[key] === "function" && key.charAt(0) !== "_"){
					this[key] = this.table[key].bind(this.table);
				}
			}
		},

		_setOption: function(option, value){
			console.error("Tabulator jQuery wrapper does not support setting options after the table has been instantiated");
		},

		_destroy: function(option, value){
			this.table.destroy();
		},
	});
}));