").addClass(this.editRowClass);
return this._eachField(function(b) {
var d = this._getItemFieldValue(a, b);
this._prepareCell("", b, "editcss").append(this.renderTemplate(b.editTemplate || "", b, {
value: d,
item: a
})).appendTo(c)
}), c
},
updateItem: function(a, b) {
1 === arguments.length && (b = a);
var c = a ? this.rowByItem(a) : this._editingRow;
return (b = b || this._getValidatedEditedItem()) ? this._updateRow(c, b) : void 0
},
_getValidatedEditedItem: function() {
var a = this._getEditedItem();
return this._validateItem(a, this._getEditRow()) ? a : null
},
_updateRow: function(a, c) {
var d = a.data(g),
e = this._itemIndex(d),
f = b.extend(!0, {}, d, c),
h = this._callEventHandler(this.onItemUpdating, {
row: a,
item: f,
itemIndex: e,
previousItem: d
});
return this._controllerCall("updateItem", f, h.cancel, function(g) {
var h = b.extend(!0, {}, d);
f = g || b.extend(!0, d, c);
var i = this._finishUpdate(a, f, e);
this._callEventHandler(this.onItemUpdated, {
row: i,
item: f,
itemIndex: e,
previousItem: h
})
})
},
_rowIndex: function(a) {
return this._content.children().index(b(a))
},
_itemIndex: function(a) {
return b.inArray(a, this.data)
},
_finishUpdate: function(a, b, c) {
this.cancelEdit(), this.data[c] = b;
var d = this._createRow(b, c);
return a.replaceWith(d), d
},
_getEditedItem: function() {
var a = {};
return this._eachField(function(b) {
b.editing && this._setItemFieldValue(a, b, b.editValue())
}), a
},
cancelEdit: function() {
this._editingRow && (this._getEditRow().remove(), this._editingRow.show(), this._editingRow = null)
},
_getEditRow: function() {
return this._editingRow && this._editingRow.data(h)
},
deleteItem: function(b) {
var c = this.rowByItem(b);
if (c.length && (!this.confirmDeleting || a.confirm(t(this.deleteConfirm, this, c.data(g))))) return this._deleteRow(c)
},
_deleteRow: function(a) {
var b = a.data(g),
c = this._itemIndex(b),
d = this._callEventHandler(this.onItemDeleting, {
row: a,
item: b,
itemIndex: c
});
return this._controllerCall("deleteItem", b, d.cancel, function() {
this._loadStrategy.finishDelete(b, c), this._callEventHandler(this.onItemDeleted, {
row: a,
item: b,
itemIndex: c
})
})
}
}, b.fn.jsGrid = function(a) {
var e = b.makeArray(arguments),
g = e.slice(1),
h = this;
return this.each(function() {
var e, i = b(this),
j = i.data(f);
if (j)
if ("string" == typeof a) {
if (e = j[a].apply(j, g), e !== c && e !== j) return h = e, !1
} else j._detachWindowResizeCallback(), j._init(a), j.render();
else new d(i, a)
}), h
};
var w = {},
x = function(a) {
var c;
b.isPlainObject(a) ? c = d.prototype : (c = w[a].prototype, a = arguments[1] || {}), b.extend(c, a)
},
y = {},
z = function(a) {
var c = b.isPlainObject(a) ? a : y[a];
if (!c) throw Error("unknown locale " + a);
A(jsGrid, c)
},
A = function(a, c) {
b.each(c, function(c, d) {
return b.isPlainObject(d) ? void A(a[c] || a[c[0].toUpperCase() + c.slice(1)], d) : void(a.hasOwnProperty(c) ? a[c] = d : a.prototype[c] = d)
})
};
a.jsGrid = {
Grid: d,
fields: w,
setDefaults: x,
locales: y,
locale: z,
version: "1.5.3"
}
}(window, jQuery),
function(a, b) {
function c(a) {
this._init(a)
}
c.prototype = {
container: "body",
message: "Loading...",
shading: !0,
zIndex: 1e3,
shaderClass: "jsgrid-load-shader",
loadPanelClass: "jsgrid-load-panel",
_init: function(a) {
b.extend(!0, this, a), this._initContainer(), this._initShader(), this._initLoadPanel()
},
_initContainer: function() {
this._container = b(this.container)
},
_initShader: function() {
this.shading && (this._shader = b("").addClass(this.shaderClass).hide().css({
position: "absolute",
top: 0,
right: 0,
bottom: 0,
left: 0,
zIndex: this.zIndex
}).appendTo(this._container))
},
_initLoadPanel: function() {
this._loadPanel = b(" ").addClass(this.loadPanelClass).text(this.message).hide().css({
position: "absolute",
top: "50%",
left: "50%",
zIndex: this.zIndex
}).appendTo(this._container)
},
show: function() {
var a = this._loadPanel.show(),
b = a.outerWidth(),
c = a.outerHeight();
a.css({
marginTop: -c / 2,
marginLeft: -b / 2
}), this._shader.show()
},
hide: function() {
this._loadPanel.hide(), this._shader.hide()
}
}, a.LoadIndicator = c
}(jsGrid, jQuery),
function(a, b) {
function c(a) {
this._grid = a
}
function d(a) {
this._grid = a, this._itemsCount = 0
}
c.prototype = {
firstDisplayIndex: function() {
var a = this._grid;
return a.option("paging") ? (a.option("pageIndex") - 1) * a.option("pageSize") : 0
},
lastDisplayIndex: function() {
var a = this._grid,
b = a.option("data").length;
return a.option("paging") ? Math.min(a.option("pageIndex") * a.option("pageSize"), b) : b
},
itemsCount: function() {
return this._grid.option("data").length
},
openPage: function() {
this._grid.refresh()
},
loadParams: function() {
return {}
},
sort: function() {
return this._grid._sortData(), this._grid.refresh(), b.Deferred().resolve().promise()
},
reset: function() {
return this._grid.refresh(), b.Deferred().resolve().promise()
},
finishLoad: function(a) {
this._grid.option("data", a)
},
finishInsert: function(a) {
var b = this._grid;
b.option("data").push(a), b.refresh()
},
finishDelete: function(a, b) {
var c = this._grid;
c.option("data").splice(b, 1), c.reset()
}
}, d.prototype = {
firstDisplayIndex: function() {
return 0
},
lastDisplayIndex: function() {
return this._grid.option("data").length
},
itemsCount: function() {
return this._itemsCount
},
openPage: function() {
this._grid.loadData()
},
loadParams: function() {
var a = this._grid;
return {
pageIndex: a.option("pageIndex"),
pageSize: a.option("pageSize")
}
},
reset: function() {
return this._grid.loadData()
},
sort: function() {
return this._grid.loadData()
},
finishLoad: function(a) {
this._itemsCount = a.itemsCount, this._grid.option("data", a.data)
},
finishInsert: function() {
this._grid.search()
},
finishDelete: function() {
this._grid.search()
}
}, a.loadStrategies = {
DirectLoadingStrategy: c,
PageLoadingStrategy: d
}
}(jsGrid, jQuery),
function(a) {
var b = function(a) {
return "undefined" != typeof a && null !== a
},
c = {
string: function(a, c) {
return b(a) || b(c) ? b(a) ? b(c) ? ("" + a).localeCompare("" + c) : 1 : -1 : 0
},
number: function(a, b) {
return a - b
},
date: function(a, b) {
return a - b
},
numberAsString: function(a, b) {
return parseFloat(a) - parseFloat(b)
}
};
a.sortStrategies = c
}(jsGrid, jQuery),
function(a, b, c) {
function d(a) {
this._init(a)
}
d.prototype = {
_init: function(a) {
b.extend(!0, this, a)
},
validate: function(a) {
var c = [];
return b.each(this._normalizeRules(a.rules), function(d, e) {
if (!e.validator(a.value, a.item, e.param)) {
var f = b.isFunction(e.message) ? e.message(a.value, a.item) : e.message;
c.push(f)
}
}), c
},
_normalizeRules: function(a) {
return b.isArray(a) || (a = [a]), b.map(a, b.proxy(function(a) {
return this._normalizeRule(a)
}, this))
},
_normalizeRule: function(a) {
if ("string" == typeof a && (a = {
validator: a
}), b.isFunction(a) && (a = {
validator: a
}), !b.isPlainObject(a)) throw Error("wrong validation config specified");
return a = b.extend({}, a), b.isFunction(a.validator) ? a : this._applyNamedValidator(a, a.validator)
},
_applyNamedValidator: function(a, c) {
delete a.validator;
var d = e[c];
if (!d) throw Error('unknown validator "' + c + '"');
return b.isFunction(d) && (d = {
validator: d
}), b.extend({}, d, a)
}
}, a.Validation = d;
var e = {
required: {
message: "Field is required",
validator: function(a) {
return a !== c && null !== a && "" !== a
}
},
rangeLength: {
message: "Field value length is out of the defined range",
validator: function(a, b, c) {
return a.length >= c[0] && a.length <= c[1]
}
},
minLength: {
message: "Field value is too short",
validator: function(a, b, c) {
return a.length >= c
}
},
maxLength: {
message: "Field value is too long",
validator: function(a, b, c) {
return a.length <= c
}
},
pattern: {
message: "Field value is not matching the defined pattern",
validator: function(a, b, c) {
return "string" == typeof c && (c = new RegExp("^(?:" + c + ")$")), c.test(a)
}
},
range: {
message: "Field value is out of the defined range",
validator: function(a, b, c) {
return a >= c[0] && a <= c[1]
}
},
min: {
message: "Field value is too small",
validator: function(a, b, c) {
return a >= c
}
},
max: {
message: "Field value is too large",
validator: function(a, b, c) {
return c >= a
}
}
};
a.validators = e
}(jsGrid, jQuery),
function(a, b, c) {
function d(a) {
b.extend(!0, this, a), this.sortingFunc = this._getSortingFunc()
}
d.prototype = {
name: "",
title: null,
css: "",
align: "",
width: 100,
visible: !0,
filtering: !0,
inserting: !0,
editing: !0,
sorting: !0,
sorter: "string",
headerTemplate: function() {
return this.title === c || null === this.title ? this.name : this.title
},
itemTemplate: function(a) {
return a
},
filterTemplate: function() {
return ""
},
insertTemplate: function() {
return ""
},
editTemplate: function(a, b) {
return this._value = a, this.itemTemplate(a, b)
},
filterValue: function() {
return ""
},
insertValue: function() {
return ""
},
editValue: function() {
return this._value
},
_getSortingFunc: function() {
var c = this.sorter;
if (b.isFunction(c)) return c;
if ("string" == typeof c) return a.sortStrategies[c];
throw Error('wrong sorter for the field "' + this.name + '"!')
}
}, a.Field = d
}(jsGrid, jQuery),
function(a, b) {
function c(a) {
d.call(this, a)
}
var d = a.Field;
c.prototype = new d({
autosearch: !0,
readOnly: !1,
filterTemplate: function() {
if (!this.filtering) return "";
var a = this._grid,
b = this.filterControl = this._createTextBox();
return this.autosearch && b.on("keypress", function(b) {
13 === b.which && (a.search(), b.preventDefault())
}), b
},
insertTemplate: function() {
return this.inserting ? this.insertControl = this._createTextBox() : ""
},
editTemplate: function(a) {
if (!this.editing) return this.itemTemplate.apply(this, arguments);
var b = this.editControl = this._createTextBox();
return b.val(a), b
},
filterValue: function() {
return this.filterControl.val()
},
insertValue: function() {
return this.insertControl.val()
},
editValue: function() {
return this.editControl.val()
},
_createTextBox: function() {
return b("").attr("type", "text").prop("readonly", !!this.readOnly)
}
}), a.fields.text = a.TextField = c
}(jsGrid, jQuery),
function(a, b, c) {
function d(a) {
e.call(this, a)
}
var e = a.TextField;
d.prototype = new e({
sorter: "number",
align: "right",
readOnly: !1,
filterValue: function() {
return this.filterControl.val() ? parseInt(this.filterControl.val() || 0, 10) : c
},
insertValue: function() {
return this.insertControl.val() ? parseInt(this.insertControl.val() || 0, 10) : c
},
editValue: function() {
return this.editControl.val() ? parseInt(this.editControl.val() || 0, 10) : c
},
_createTextBox: function() {
return b("").attr("type", "number").prop("readonly", !!this.readOnly)
}
}), a.fields.number = a.NumberField = d
}(jsGrid, jQuery),
function(a, b) {
function c(a) {
d.call(this, a)
}
var d = a.TextField;
c.prototype = new d({
insertTemplate: function() {
return this.inserting ? this.insertControl = this._createTextArea() : ""
},
editTemplate: function(a) {
if (!this.editing) return this.itemTemplate.apply(this, arguments);
var b = this.editControl = this._createTextArea();
return b.val(a), b
},
_createTextArea: function() {
return b("
|