Skip to content

Commit

Permalink
jTable v2.3.1
Browse files Browse the repository at this point in the history
Bugfixes (#161, #254, #357, #570, #822) and localizations.
  • Loading branch information
hikalkan committed Sep 21, 2013
1 parent 4d2ec0b commit 88e4d6e
Show file tree
Hide file tree
Showing 11 changed files with 294 additions and 197 deletions.
2 changes: 1 addition & 1 deletion dev/jquery.jtable.build.txt
@@ -1,4 +1,4 @@
create jquery.jtable.js
create ..\jquery.jtable.js
add jquery.jtable.header.txt
add jquery.jtable.core.js
add jquery.jtable.utils.js
Expand Down
20 changes: 17 additions & 3 deletions dev/jquery.jtable.core.js
Expand Up @@ -3,6 +3,15 @@
*************************************************************************/
(function ($) {

var unloadingPage;

$(window).on('beforeunload', function () {
unloadingPage = true;
});
$(window).on('unload', function () {
unloadingPage = false;
});

$.widget("hik.jtable", {

/************************************************************************
Expand Down Expand Up @@ -107,7 +116,7 @@
this._createErrorDialogDiv();
this._addNoDataRow();

this._cookieKeyPrefix = this._generateCookieKeyPrefix();
this._cookieKeyPrefix = this._generateCookieKeyPrefix();
},

/* Normalizes some options for all fields (sets default values).
Expand Down Expand Up @@ -1099,9 +1108,14 @@
};

//Override error
opts.error = function () {
opts.error = function (jqXHR, textStatus, errorThrown) {
if (unloadingPage) {
jqXHR.abort();
return;
}

if (options.error) {
options.error();
options.error(arguments);
}
};

Expand Down
39 changes: 25 additions & 14 deletions dev/jquery.jtable.creation.js
Expand Up @@ -39,6 +39,11 @@
*************************************************************************/
_create: function () {
base._create.apply(this, arguments);

if (!this.options.actions.createAction) {
return;
}

this._createAddRecordDialogDiv();
},

Expand All @@ -47,11 +52,6 @@
_createAddRecordDialogDiv: function () {
var self = this;

//Check if createAction is supplied
if (!self.options.actions.createAction) {
return;
}

//Create a div for dialog and add to container element
self._$addRecordDiv = $('<div />')
.appendTo(self._$mainContainer);
Expand All @@ -75,13 +75,7 @@
id: 'AddRecordDialogSaveButton',
text: self.options.messages.save,
click: function () {
var $saveButton = $('#AddRecordDialogSaveButton');
var $addRecordForm = self._$addRecordDiv.find('form');

if (self._trigger("formSubmitting", null, { form: $addRecordForm, formType: 'create' }) != false) {
self._setEnabledOfDialogButton($saveButton, false, self.options.messages.saving);
self._saveAddRecordForm($addRecordForm, $saveButton);
}
self._onSaveClickedOnCreateForm();
}
}],
close: function () {
Expand Down Expand Up @@ -111,6 +105,18 @@
});
}
},

_onSaveClickedOnCreateForm: function () {
var self = this;

var $saveButton = $('#AddRecordDialogSaveButton');
var $addRecordForm = self._$addRecordDiv.find('form');

if (self._trigger("formSubmitting", null, { form: $addRecordForm, formType: 'create' }) != false) {
self._setEnabledOfDialogButton($saveButton, false, self.options.messages.saving);
self._saveAddRecordForm($addRecordForm, $saveButton);
}
},

/************************************************************************
* PUBLIC METHODS *
Expand Down Expand Up @@ -192,7 +198,7 @@
var self = this;

//Create add new record form
var $addRecordForm = $('<form id="jtable-create-form" class="jtable-dialog-form jtable-create-form" action="' + self.options.actions.createAction + '" method="POST"></form>');
var $addRecordForm = $('<form id="jtable-create-form" class="jtable-dialog-form jtable-create-form"></form>');

//Create input elements
for (var i = 0; i < self._fieldList.length; i++) {
Expand Down Expand Up @@ -234,6 +240,11 @@

self._makeCascadeDropDowns($addRecordForm, undefined, 'create');

$addRecordForm.submit(function () {
self._onSaveClickedOnCreateForm();
return false;
});

//Open the form
self._$addRecordDiv.append($addRecordForm).dialog('open');
self._trigger("formCreated", null, { form: $addRecordForm, formType: 'create' });
Expand All @@ -248,7 +259,7 @@
$addRecordForm.data('submitting', true);

self._submitFormUsingAjax(
$addRecordForm.attr('action'),
self.options.actions.createAction,
$addRecordForm.serialize(),
function (data) {

Expand Down
5 changes: 5 additions & 0 deletions dev/jquery.jtable.deletion.js
Expand Up @@ -56,6 +56,11 @@
*************************************************************************/
_createDeleteDialogDiv: function () {
var self = this;

//Check if deleteAction is supplied
if (!self.options.actions.deleteAction) {
return;
}

//Create div element for delete confirmation dialog
self._$deleteRecordDiv = $('<div><p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><span class="jtable-delete-confirm-message"></span></p></div>').appendTo(self._$mainContainer);
Expand Down
51 changes: 34 additions & 17 deletions dev/jquery.jtable.editing.js
Expand Up @@ -43,6 +43,11 @@
*************************************************************************/
_create: function () {
base._create.apply(this, arguments);

if (!this.options.actions.updateAction) {
return;
}

this._createEditDialogDiv();
},

Expand Down Expand Up @@ -74,19 +79,7 @@
id: 'EditDialogSaveButton',
text: self.options.messages.save,
click: function () {

//row maybe removed by another source, if so, do nothing
if (self._$editingRow.hasClass('jtable-row-removed')) {
self._$editDiv.dialog('close');
return;
}

var $saveButton = self._$editDiv.find('#EditDialogSaveButton');
var $editForm = self._$editDiv.find('form');
if (self._trigger("formSubmitting", null, { form: $editForm, formType: 'edit', row: self._$editingRow }) != false) {
self._setEnabledOfDialogButton($saveButton, false, self.options.messages.saving);
self._saveEditForm($editForm, $saveButton);
}
self._onSaveClickedOnEditForm();
}
}],
close: function () {
Expand All @@ -99,8 +92,27 @@
});
},

/* Saves editing form to server.
*************************************************************************/
_onSaveClickedOnEditForm: function () {
var self = this;

//row maybe removed by another source, if so, do nothing
if (self._$editingRow.hasClass('jtable-row-removed')) {
self._$editDiv.dialog('close');
return;
}

var $saveButton = $('#EditDialogSaveButton');
var $editForm = self._$editDiv.find('form');
if (self._trigger("formSubmitting", null, { form: $editForm, formType: 'edit', row: self._$editingRow }) != false) {
self._setEnabledOfDialogButton($saveButton, false, self.options.messages.saving);
self._saveEditForm($editForm, $saveButton);
}
},

/************************************************************************
* PUNLIC METHODS *
* PUBLIC METHODS *
*************************************************************************/

/* Updates a record on the table (optionally on the server also)
Expand Down Expand Up @@ -218,7 +230,7 @@
var record = $tableRow.data('record');

//Create edit form
var $editForm = $('<form id="jtable-edit-form" class="jtable-dialog-form jtable-edit-form" action="' + self.options.actions.updateAction + '" method="POST"></form>');
var $editForm = $('<form id="jtable-edit-form" class="jtable-dialog-form jtable-edit-form"></form>');

//Create input fields
for (var i = 0; i < self._fieldList.length; i++) {
Expand Down Expand Up @@ -266,9 +278,14 @@
form: $editForm
}));
}

self._makeCascadeDropDowns($editForm, record, 'edit');

$editForm.submit(function () {
self._onSaveClickedOnEditForm();
return false;
});

//Open dialog
self._$editingRow = $tableRow;
self._$editDiv.append($editForm).dialog('open');
Expand All @@ -280,7 +297,7 @@
_saveEditForm: function ($editForm, $saveButton) {
var self = this;
self._submitFormUsingAjax(
$editForm.attr('action'),
self.options.actions.updateAction,
$editForm.serialize(),
function (data) {
//Check for errors
Expand Down
2 changes: 1 addition & 1 deletion dev/jquery.jtable.header.txt
@@ -1,6 +1,6 @@
/*

jTable 2.3.0
jTable 2.3.1
http://www.jtable.org

---------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions dev/jquery.jtable.masterchild.js
Expand Up @@ -133,14 +133,14 @@
/* Overrides _removeRowsFromTable method to remove child rows of deleted rows.
*************************************************************************/
_removeRowsFromTable: function ($rows, reason) {
var self = this;
//var self = this;

if (reason == 'deleted') {
$rows.each(function () {
var $row = $(this);
var $childRow = $row.data('childRow');
if ($childRow) {
self.closeChildTable($row);
//self.closeChildTable($row); //Removed since it causes "Uncaught Error: cannot call methods on jtable prior to initialization; attempted to call method 'destroy'"
$childRow.remove();
}
});
Expand Down
2 changes: 1 addition & 1 deletion dev/jquery.jtable.sorting.js
Expand Up @@ -181,4 +181,4 @@

});

})(jQuery);
})(jQuery);
2 changes: 1 addition & 1 deletion jTable.jquery.json
Expand Up @@ -11,7 +11,7 @@
"paging",
"sorting"
],
"version": "2.3.0",
"version": "2.3.1",
"author": {
"name": "Halil ibrahim Kalkan",
"email": "halil@jtable.org",
Expand Down

0 comments on commit 88e4d6e

Please sign in to comment.