From d0d85d44b83e64a141f0272abff7c003cc41d631 Mon Sep 17 00:00:00 2001 From: bbalganjjm Date: Tue, 27 Jan 2015 18:36:09 +0900 Subject: [PATCH] Append feature N.form - 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) --- lib/natural_js/natural.ui.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/natural_js/natural.ui.js b/lib/natural_js/natural.ui.js index 3d20f02e6..93c5de148 100644 --- a/lib/natural_js/natural.ui.js +++ b/lib/natural_js/natural.ui.js @@ -1,5 +1,5 @@ /*! - * Natural-UI v0.8.2.2 + * Natural-UI v0.8.2.3 * bbalganjjm@gmail.com * * Copyright 2014 KIM HWANG MAN @@ -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, { @@ -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 { @@ -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); @@ -1364,6 +1367,9 @@ } if(data !== undefined) { opts.data = data; + if(opts.revert) { + this.revertData = $.extend({}, data[row]); + } } var this_ = this; var vals; @@ -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() { @@ -1703,6 +1712,7 @@ select : false, multiselect : false, hover : false, + revert : false, createRowDelay : 1, scrollPaging : { idx : 0, @@ -1868,7 +1878,8 @@ html: opts.html, validate : opts.validate, extObj : this_, - extRow : i + extRow : i, + revert : opts.revert }).bind(); tbodyTempClone.show(delay, function() { @@ -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 {