Skip to content

Commit

Permalink
Append feature N.form
Browse files Browse the repository at this point in the history
 - Revert bug fix
 - Add revert option
   * if revert option value is true, activate the revert
function(default value is false)
 
append feature N.grid
 - Add revert option
    * if revert option value is true, activate the revert
function(default value is false)
  • Loading branch information
bbalganjjm committed Jan 27, 2015
1 parent 7fd93c0 commit d0d85d4
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions lib/natural_js/natural.ui.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Natural-UI v0.8.2.2
* Natural-UI v0.8.2.3
* [email protected]
*
* Copyright 2014 KIM HWANG MAN
Expand All @@ -8,7 +8,7 @@
* Date: 2014-09-26T11:11Z
*/
(function(window, $) {
var version = "0.8.2.2";
var version = "0.8.2.3";

// N local variables
$.fn.extend(N, {
Expand Down Expand Up @@ -1307,8 +1307,9 @@
addTop : false,
fRules : null,
vRules : null,
extObj : null, // for N.grid,
extRow : -1 // for N.grid
extObj : null, // for N.grid
extRow : -1, // for N.grid
revert : false
};

try {
Expand All @@ -1331,7 +1332,9 @@
}
this.options.context.addClass("form__");

this.revertData = $.extend({}, this.options.data[this.options.row]);
if(this.options.revert) {
this.revertData = $.extend({}, this.options.data[this.options.row]);
}

this.options.context.instance("form", this);

Expand Down Expand Up @@ -1364,6 +1367,9 @@
}
if(data !== undefined) {
opts.data = data;
if(opts.revert) {
this.revertData = $.extend({}, data[row]);
}
}
var this_ = this;
var vals;
Expand Down Expand Up @@ -1557,9 +1563,12 @@
},
revert : function() {
var opts = this.options;
if(!opts.revert) {
N.error("[N.form.revert]Can not revert. N.form's revert option value is false");
}
opts.data[opts.row] = $.extend({}, this.revertData);
N.ds.instance(opts.extObj !== null ? opts.extObj : this).notify(opts.extRow > -1 ? opts.extRow : opts.row);
this.update(opts.row);
N.ds.instance(opts.extObj !== null ? opts.extObj : this).notify(opts.extRow > -1 ? opts.extRow : opts.row);
return this;
},
validate : function() {
Expand Down Expand Up @@ -1703,6 +1712,7 @@
select : false,
multiselect : false,
hover : false,
revert : false,
createRowDelay : 1,
scrollPaging : {
idx : 0,
Expand Down Expand Up @@ -1868,7 +1878,8 @@
html: opts.html,
validate : opts.validate,
extObj : this_,
extRow : i
extRow : i,
revert : opts.revert
}).bind();

tbodyTempClone.show(delay, function() {
Expand Down Expand Up @@ -1949,6 +1960,9 @@
},
revert : function(row) {
var opts = this.options;
if(!opts.revert) {
N.error("[N.form.revert]Can not revert. N.form's revert option value is false");
}
if(row !== undefined) {
opts.context.find("tbody:eq(" + String(row) + ")").instance("form").revert();
} else {
Expand Down

0 comments on commit d0d85d4

Please sign in to comment.