-
Notifications
You must be signed in to change notification settings - Fork 351
Expand file tree
/
Copy pathplugin.js
More file actions
54 lines (46 loc) · 1.4 KB
/
plugin.js
File metadata and controls
54 lines (46 loc) · 1.4 KB
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
// GRID PLUGIN DEFINITION
// =====================
var old = $.fn.bootgrid;
$.fn.bootgrid = function (option)
{
var args = Array.prototype.slice.call(arguments, 1),
returnValue = null,
elements = this.each(function (index)
{
var $this = $(this),
instance = $this.data(namespace),
options = typeof option === "object" && option;
if (!instance && option === "destroy")
{
return;
}
if (!instance)
{
$this.data(namespace, (instance = new Grid(this, options)));
init.call(instance);
}
if (typeof option === "string")
{
if (option.indexOf("get") === 0 && index === 0)
{
returnValue = instance[option].apply(instance, args);
}
else if (option.indexOf("get") !== 0)
{
return instance[option].apply(instance, args);
}
}
});
return (typeof option === "string" && option.indexOf("get") === 0) ? returnValue : elements;
};
$.fn.bootgrid.Constructor = Grid;
// GRID NO CONFLICT
// ===============
$.fn.bootgrid.noConflict = function ()
{
$.fn.bootgrid = old;
return this;
};
// GRID DATA-API
// ============
$("[data-toggle=\"bootgrid\"]").bootgrid();