From 15729bba1a568add4092183c80b986d462488fa5 Mon Sep 17 00:00:00 2001 From: Niko Date: Tue, 8 Oct 2013 09:17:22 +0200 Subject: [PATCH] update to 1.0.8 --- dist/jquery.jsForm-1.0.5.js | 2410 ---------------- dist/jquery.jsForm-1.0.6.js | 2454 ----------------- ...jsForm-1.0.7.js => jquery.jsForm-1.0.8.js} | 11 +- dist/jquery.jsForm.1.0.5.min.js | 6 - dist/jquery.jsForm.1.0.6.min.js | 6 - dist/jquery.jsForm.1.0.7.min.js | 6 - dist/jquery.jsForm.1.0.8.min.js | 6 + dist/jquery.jsForm.min.map | 2 +- jsForm.jquery.json | 2 +- package.json | 6 +- 10 files changed, 17 insertions(+), 4892 deletions(-) delete mode 100644 dist/jquery.jsForm-1.0.5.js delete mode 100644 dist/jquery.jsForm-1.0.6.js rename dist/{jquery.jsForm-1.0.7.js => jquery.jsForm-1.0.8.js} (96%) delete mode 100644 dist/jquery.jsForm.1.0.5.min.js delete mode 100644 dist/jquery.jsForm.1.0.6.min.js delete mode 100644 dist/jquery.jsForm.1.0.7.min.js create mode 100644 dist/jquery.jsForm.1.0.8.min.js diff --git a/dist/jquery.jsForm-1.0.5.js b/dist/jquery.jsForm-1.0.5.js deleted file mode 100644 index 1b30359..0000000 --- a/dist/jquery.jsForm-1.0.5.js +++ /dev/null @@ -1,2410 +0,0 @@ -/** - * jquery.jsForm - * ------------- - * JsForm control for handling html UI with json objects - * @version 1.0 - * @class - * @author Niko Berger - * @license MIT License GPL - */ -;(function( $, window, undefined ){ - "use strict"; - - var JSFORM_INIT_FUNCTIONS = {}, // remember initialization functions - JSFORM_MAP = {}; // remember all forms - - - /** - * @param element {Node} the cotnainer node that should be converted to a jsForm - * @param options {object} the configuraton object - * @constructor - */ - function JsForm (element, options) { - var $this = $(element); - - // create the options - this.options = $.extend({}, { - /** - * enable form control rendering (if jsForm.controls is available) and validation - */ - controls: true, - /** - * the object used to fill/collect data - */ - data: null, - /** - * the prefix used to annotate theinput fields - */ - prefix: "data", - /** - * set to false to only validate visible fields. - * This is discouraged especially when you have tabs or similar elements in your form. - */ - validateHidden: true - }, options); - - // read prefix from dom - if($this.attr("data-prefix") && (this.options.prefix === "data" || this.options.prefix === "")) { - if($this.attr("data-prefix") !== "") { - this.options.prefix = $this.attr("data-prefix"); - } - } - - this.element = element; - - this._init(); - } - - /** - * init the portlet - load the config - * @private - */ - JsForm.prototype._init = function() { - // init the basic dom functionality - this._domInit(); - - // enable form controls - if(this.options.controls) { - if($.jsFormControls) { - $(this.element).jsFormControls(); - } else { - try { - if(typeof console !== "undefined") { - console.log("jquery.JsForm.controls not available!"); - } - } catch(ex) { - // ignore - } - } - } - - // fill/init with the first data - this._fill(this.element, this.options.data, this.options.prefix); - }; - - - /** - * init the dom. This can be called multiple times. - * this will also enable "add", "insert" and "delete" for collections - * @private - */ - JsForm.prototype._domInit = function() { - var form = $(this.element); - var that = this; - var prefix = this.options.prefix; - - // collection lists with buttons - that._initCollection(form, prefix); - }; - - /** - * initialize collections - */ - JsForm.prototype._initCollection = function(form, prefix) { - // all collections - var collectionMap = {}, - that = this; - $(form).data().collections = collectionMap; - - $(".collection", form).each(function() { - var colName = $(this).attr("data-field"); - // skip collections without a data-field mapping - if (!colName || colName.indexOf(prefix + ".") !== 0) { - return; - } - - var container = $(this); - - // remember the collection - var cols = collectionMap[colName]; - if(cols) { - cols.push(container); - } else { - collectionMap[colName] = [container]; - } - - //init the collection - that._initList(container); - - // after adding: check if we want reorder control - if(!container.hasClass("ui-sortable") && container.hasClass("sortable") && container.sortable) { - // get the config object - var config = container.attr("data-sortable"); - if(!config) { - config = {}; - } else { - config = JSON.parse(config); - } - - container.sortable(config); - container.on("sortstop", function( event, ui ) { - that._reorder(container); - }); - } - - }); - - $(".add", form).each(function(){ - var fieldName = $(this).attr("data-field"); - if(!fieldName) { - return; - } - - // only init once - if($(this).data("collections")) { - return; - } - - // add the collection - $(this).data().collections = collectionMap[fieldName]; - - $(this).click(function(ev){ - ev.preventDefault(); - - // search for a collection with that name - $.each($(this).data("collections"), function() { - var tmpl = $(this).data("template"); - // and has a template - if(tmpl) { - var line = tmpl.clone(true); - $(this).append(line); - $(line).addClass("POJO"); - $(line).data("pojo", {}); - - that._addCollectionControls(line); - - // trigger a callback - $(this).trigger("addCollection", [line, $(line).data().pojo]); - - // fill the line with data - that._fillData(line, $(line).data().pojo, fieldName.substring(fieldName.indexOf('.')+1)); - - // its possible to have "sub" collections - that._initCollection(line, fieldName.substring(fieldName.indexOf('.')+1)); - - // trigger a callback after the data has been rendered) - $(this).trigger("postAddCollection", [line, $(line).data().pojo]); - - - } - }); - }); - }); - - // insert: similar to add - but works with events - $(".insert", form).each(function(){ - var fieldName = $(this).attr("data-field"); - if(!fieldName) { - return; - } - - // only init once - if($(this).data("collections")) { - return; - } - - // remember the collections - $(this).data("collections", collectionMap[$(this).attr("data-field")]); - - $(this).on("insert", function(ev, pojo){ - if(!pojo) - pojo = $(this).data().pojo; - - // insert only works if there is a pojo - if(!pojo) { - return; - } - var beforeInsertCallback = $(this).data("beforeInsert"); - if(beforeInsertCallback && $.isFunction(beforeInsertCallback)) { - pojo = beforeInsertCallback(pojo); - - // insert only works if there is a pojo - if(!pojo) { - return; - } - } - - // search for a collection with that name - $.each($(this).data("collections"), function() { - var tmpl = $(this).data("template"); - // and has a template - if(tmpl) { - var line = tmpl.clone(true); - // mark that this is a pojo - line.addClass("POJO"); - // add the pojo - line.data().pojo = pojo; - - that._addCollectionControls(line); - - // its possible to have "sub" collections - that._initCollection(line); - - // trigger a callback - $(this).trigger("addCollection", [line, $(line).data().pojo]); - - // fill the "information" - that._fillData(line, pojo, fieldName.substring(fieldName.indexOf('.')+1)); - - $(this).append(line); - } - }); - - // empty field - $(this).val(""); - $(this).data().pojo = null; - $(this).focus(); - }); - }); - - // insert: helper button (triggers insert) - $(".insertAction", form).each(function(){ - var fieldName = $(this).attr("data-field"); - if(!fieldName) { - return; - } - - // only init once - if($(this).data("inserter")) { - return; - } - - // find the insert element for this data-field - var inserter = $(this).parent().find(".insert"); - if(!inserter) { - return; - } - - // remember the inserter - $(this).data("inserter", inserter); - - $(this).click(function(ev){ - ev.preventDefault(); - $(this).data("inserter").trigger("insert"); - return false; - }); - - }); - - $("input.object", form).each(function(){ - $(this).on("update", function(evt){ - var pojo = $(this).data().pojo; - if (pojo && $(this).attr("data-display")) { - $(this).val(that._renderObject(pojo, $(this).attr("data-display"))); - } - }); - }); - - // fileupload - $("input.blob", form).each(function(){ - // only available on input type file - if($(this).attr("type") !== "file") { - return; - } - - var blobInput = $(this); - - // bind on change - $(this).on("change", function(evt){ - - //get file name - var fileName = $(this).val().split(/\\/).pop(); - blobInput.data("name", fileName); - - var files = evt.target.files; // FileList object - // Loop through the FileList (and render image files as thumbnails.(skip for ie < 9) - if(files && files.length) { - $.each(files, function() { - var reader = new FileReader(); - - // closure to capture the file information - reader.onload = function(e) { - // get the result - blobInput.data("blob", e.target.result); - }; - - // Read in the image file as a data URL. - reader.readAsDataURL(this); - - $(this).trigger("fileChange"); - }); - } - }); - - - }); - - // manage - obsolete - $(".manage", form).each(function(){ - var fieldName = $(this).attr("data-field"); - if(!fieldName) { - return; - } - - // remember the collections - $(this).data("collections", collectionMap[fieldName]); - - // start the multi-select - $(this).click(function(){ - var dataService = $(this).attr("data-service"); - var collectionList = $(this).data("collections"); - - var btn = $(this); - var display = $(this).attr("data-display"); - if(display) { - display = display.split(","); - } - - DataUtils.run(dataService, function(data){ - var select = $(''); - select.data("collections", collectionList); - btn.data("select", select); - $.each(data, function(){ - var cur = this; - var optionDisplay = ""; - if(!display) { - optionDisplay = cur; - } else { - for(var j = 0; j < display.length; j++) { - optionDisplay += cur[display[j]] + " "; - } - } - var option = $(''); - // check if we need to "select" that option - $(collectionList).each(function() { - $(this).children().each(function(count, ele){ - if(cur.id === $(ele).data("pojo").id) { - option.attr("selected", "selected"); - } - }); - }); - select.append(option); - option.data("pojo", cur); - }); - - btn.after(select); - btn.hide(); - - select.multiselect({ - autoOpen: true, - open: function(){ - //reposition - $(this).multiselect("widget").css("top", $(select).next().offset().top); - $(this).multiselect("widget").css("left", $(select).next().offset().left); - // hide button - $(select).next().hide(); - }, - close: function(){ - btn.show(); - select.remove(); - $(this).multiselect("destroy"); - } - }).multiselectfilter().bind("multiselectclick multiselectcheckall multiselectuncheckall", - function( event, ui ){ - var checkedValues = $.map($(this).multiselect("getChecked"), function( input ){ - // we only get the same "value" - so check the option list for the correct pojo - return $("option[value='"+input.value+"']", select).data("pojo"); - }); - - // update collection - $.each($(select).data("collections"), function(){ - that._fillList($(this), checkedValues, fieldName); - }); - // reposition - btn.hide(); - $(select).next().show(); - $(this).multiselect("widget").css("top", $(select).next().offset().top); - $(this).multiselect("widget").css("left", $(select).next().offset().left); - $(select).next().hide(); - }); - }); - }); - }); - }; - - /** - * init a container that has a tempalate child (first child). - * @param container the contianer element - * @private - */ - JsForm.prototype._initList = function(container) { - // avoid double initialisation - if(container.data("template")) { - return; - } - - // get all children - var tmpl = container.children().detach(); - - // remove an id if there is one - tmpl.removeAttr("id"); - container.data("template", tmpl); - }; - - /** - * clear/reset a form. The prefix is normally predefined by init - * @param form the form - * @param prefix the optional prefix used to identify fields for this form - */ - JsForm.prototype._clear = function(form, prefix) { - // get the prefix from the form if not given - if(!prefix) { - prefix = this.options.prefix; - } - - $(form).removeData("pojo"); - $("input,select,textarea", form).each(function(){ - var name = $(this).attr("name"); - // empty name - ignore - if (!name || name.indexOf(prefix + ".") !== 0) { - return; - } - // cut away the prefix - name = name.substring((prefix+".").length); - // skip empty - if(name.length < 1) { - return; - } - - // remove all pojos - $(this).removeData("pojo"); - - if($(this).attr("type") === "checkbox") { - $(this).prop("checked", false); - } else { - $(this).val(""); - } - if($(this).hasClass("blob")) { - $(this).removeData("blob"); - } - // special type select box: select the FIRST child - if($(this).is("select")) { - $('option[selected="selected"]', this).removeAttr('selected'); - $('option:first', this).attr('selected', true); - - $(this).val($("option:first", this).val()).change(); - } - // trigger change - $(this).change(); - }); - - $(".collection", form).each(function() { - var fieldname = $(this).attr("data-field"); - // only collections with the correct prefix - if(!fieldname || fieldname.indexOf(prefix+".") !== 0) { - return; - } - // get rid of all - $(this).empty(); - }); - - }; - /** - * ceate a pojo from a form. Takes special data definition classes into account: - * - * @param start the element to start from (ie. the form or tr) - * @param pojo the pojo to write everything to - * @param prefix a prefix: only fields with the given prefix will be included in the pojo - * @private - */ - JsForm.prototype._createPojoFromInput = function (start, prefix, pojo) { - // check if we have an "original" pojo - var startObj = null; - var that = this; - - // get it from the starting dom element - if($(start).data("pojo")) { - startObj = $(start).data("pojo"); - } - - // if we have an object, use this as base and fill the pojo - if(startObj) { - $.extend(true, pojo, startObj); - } - - $(start).find("input,select,textarea").each(function(){ - var name = $(this).attr("name"); - - // empty name - ignore - if (!name) { - return; - } - - // skip grayed (=calculated) or transient fields - if($(this).hasClass("transient")) { - return; - } - - // must start with prefix - if(name.indexOf(prefix + ".") !== 0) { - return; - } - - $(this).trigger("validate", true); - - // cut away the prefix - name = name.substring((prefix+".").length); - - // skip empty - if(name.length < 1) { - pojo = $(this).val(); - return false; - } - - var val = $(this).val(); - - if($(this).hasClass("emptynull")) { // nullable fields do not send empty string - if(val === "" || val.trim() === "") { - val = null; - } - } else if($(this).hasClass("object") || $(this).hasClass("POJO")) { - val = $(this).data("pojo"); - } else if($(this).hasClass("blob")) { // file upload blob - val = $(this).data("blob"); - } else - // set empty numbers or dates to null - if(val === "" && ($(this).hasClass("number") || $(this).hasClass("dateFilter")|| $(this).hasClass("dateTimeFilter"))) { - val = null; - } - - // check for percentage: this is input / 100 - if ($(this).hasClass("percent")) { - val = that._getNumber(val); - if(isNaN(val)) { - val = 0; - } else { - val /= 100; - } - } - - if ($(this).hasClass("number") || $(this).hasClass("currency")) { - val = that._getNumber(val); - if(isNaN(val)) { - val = 0; - } - } - if($(this).attr("type") === "checkbox" || $(this).attr("type") === "CHECKBOX") { - val = $(this).is(':checked'); - } - - // check if we have a . - if so split - if (name.indexOf(".") === -1) - { - pojo[name] = val; - } - else - { - var parts = name.split("."); - - var d0 = pojo[parts[0]]; - var d1, d2; - - // multiple parts: make sure its an object - if (!d0 || !$.isPlainObject(d0)) { - pojo[parts[0]] = {}; - d0 = pojo[parts[0]]; - } - - if (parts.length === 2) { - d0[parts[1]] = val; - } else if (parts.length === 3) { - d1 = d0[parts[1]]; - if(d1 === undefined) { - d1 = {}; - d0[parts[1]] = d1; - } - d1[parts[2]] = val; - } else if (parts.length === 4) - { - d1 = d0[parts[1]]; - d2 = d1[parts[2]]; - if(d2 === undefined) { - d2 = {}; - d1[parts[2]] = d2; - } - d1[parts[2]] = val; - d2[parts[3]] = val; - } - // more should not be necessary - } - }); - - return pojo; - }; - - - /** - * fill a dom subtree with data. - * - * @param parent the root of the subtree - * @param data the data - * @param prefix the prefix used to find fields - * @private - */ - JsForm.prototype._fillData = function (parent, data, prefix) { - var that = this; - var $parent = $(parent); - - // locate all "fields" - $parent.find(".field").each(function() { - var name = $(this).data("name"); - if(!name) { - if(this.nodeName.toUpperCase() === 'A') { - name = $(this).attr("href"); - $(this).attr("href", "#"); - }else if(this.nodeName.toUpperCase() === 'IMG') { - name = $(this).attr("src"); - if(name.indexOf("#") === 0) { - name = name.substring(1); - } - $(this).attr("src", "#"); - }else { - name = $(this).text(); - } - $(this).data("name", name); - $(this).show(); - } - - if(!prefix || name.indexOf(prefix + ".") >= 0) { - var cname = name; - if (prefix) { - cname = cname.substring(prefix.length + 1); - } - var cdata = that._get(data, cname); - - if(!cdata) { - cdata = ""; - } - - // check for percentage: this is value * 100 - if ($(this).hasClass("percent") && !isNaN(cdata)) { - cdata = 100 * Number(cdata); - } - - // format the string - if($.jsFormControls) - cdata = $.jsFormControls.Format.format(this, cdata); - - if(this.nodeName.toUpperCase() === 'A') { - $(this).attr("href", cdata); - } else if(this.nodeName.toUpperCase() === 'IMG') { - $(this).attr("src", cdata); - } - else if(this.nodeName.toUpperCase() === "DIV"){ - $(this).html(cdata); - } else { - $(this).text(cdata); - } - } - }); - - $("input", $parent).each(function() { - var name = $(this).attr("name"); - if(!name) { - return; - } - - // ignore file inputs - they cannot be "prefilled" - if($(this).attr("type") == "file") { - return; - } - - if(!prefix || name.indexOf(prefix + ".") >= 0) { - var cname = name; - if (prefix) { - cname = cname.substring(prefix.length + 1); - } - - var cdata = that._get(data, cname); - - // check for percentage: this is value * 100 - if ($(this).hasClass("percent") && !isNaN(cdata)) { - cdata = 100 * Number(cdata); - } else if($.isPlainObject(cdata)) { - $(this).data().pojo = cdata; - $(this).addClass("POJO"); - cdata = that._renderObject(cdata, $(this).attr("data-display")); - } - - - if($(this).attr("type") === "checkbox") { - $(this).prop("checked", (cdata === true || cdata === "true")); - $(this).change(); - } else { - if(!cdata) { - cdata = ""; - } - - // format the string - if($.jsFormControls) - cdata = $.jsFormControls.Format.format(this, cdata); - - $(this).val(cdata); - $(this).change(); - } - } - }); - - $("select", $parent).each(function() { - var name = $(this).attr("name"); - if(!name) { - return; - } - - if(!prefix || name.indexOf(prefix + ".") >= 0) { - var cname = name; - if (prefix) { - cname = cname.substring(prefix.length + 1); - } - // remove "old" selected options - $(this).children("option").removeAttr("selected"); - - var value = that._get(data, cname); - // try selecting based on the id - if (value.id) { - $(this).children("option[value='"+value.id+"']").attr("selected", true); - // actually set the value and trigger the change - $(this).val(value.id).change(); - return; - } - - $(this).children("option[value='"+value+"']").attr("selected", true); - $(this).val(value).change(); - } - }); - - $("textarea", $parent).each(function() { - var name = $(this).attr("name"); - if(!name) { - return; - } - - if(!prefix || name.indexOf(prefix + ".") >= 0) { - var cname = name; - if (prefix) { - cname = cname.substring(prefix.length + 1); - } - $(this).val(that._get(data,cname)); - $(this).change(); - } - }); - }; - - /** - * ceate a pojo from a form. Takes special data definition classes into account: - * - * @param ignoreInvalid return a pojo, even if fields do not pass client side validation - * @return a new pojo - */ - JsForm.prototype.get = function(ignoreInvalid) { - var form = $(this.element); - var that = this; - var originalPojo = this.options.data; - var prefix = this.options.prefix; - - // get the pojo - var pojo = {}; - if(originalPojo && $.isPlainObject(originalPojo)) { - pojo = originalPojo; - } - - // fill the base - that._createPojoFromInput(form, prefix, pojo); - - // check for invalid fields - var invalid = false; - if(!this.options.validateHidden) { - form.find(".invalid").filter(":visible").each(function(){ - invalid = true; - $(this).focus(); - return false; - }); - } else { - form.find(".invalid").each(function(){ - invalid = true; - $(this).focus(); - return false; - }); - } - - // get the collection - if(this._getCollection(form, prefix, pojo, ignoreInvalid)) { - invalid = true; - } - - if(!ignoreInvalid && invalid) { - return null; - } - - return pojo; - }; - - /** - * fill a pojo based on collections - * @param form {DOMElement} the base element to start looking for collections - * @param prefix {string} the prefix used - * @param pojo {object} the object to fill - * @param ignoreInvalid {boolean} if true the function will return as soon as an invalid field is found - * @return true if the colelction encountered an invalid field - */ - JsForm.prototype._getCollection = function(form, prefix, pojo, ignoreInvalid) { - var that = this; - // check for invalid fields - var invalid = false; - - form.find(".collection").each(function() { - if(!ignoreInvalid && invalid) { - return; - } - - var fieldname = $(this).attr("data-field"); - // only collections with the correct prefix - if(!fieldname || fieldname.indexOf(prefix+".") !== 0) { - return; - } - - fieldname = fieldname.substring((prefix+".").length); - if(fieldname.length < 1) { - return; - } - - var colParent = that._getParent(pojo, fieldname, true); - - // get only the last part - if(fieldname.indexOf('.') !== -1) { - fieldname = fieldname.substring(fieldname.lastIndexOf('.') + 1); - } - - // clear the collection - colParent[fieldname] = []; - - // go through all direct childs - each one is an element - $(this).children().each(function(){ - if(!ignoreInvalid && invalid) { - return; - } - - var ele = {}; - ele = that._createPojoFromInput($(this), fieldname, ele); - - // also collect sub-collections - that._getCollection($(this), fieldname, ele, ignoreInvalid); - - // check if the pojo is empty - if(!that._isEmpty(ele)) { - if($(".invalid", this).length > 0) { - invalid = true; - } - colParent[fieldname].push(ele); - } else { - $(".invalid", this).removeClass("invalid"); - } - }); - }); - - return invalid; - }; - - /** - * Get the data object used as a base for get(). - * Note that modifying this directly migh result into unwanted results - * when working with some functions that rely on this object. - * - * @returns the original data object - */ - JsForm.prototype.getData = function() { - // make srue we do have an object to work with - if(!this.options.data) { - this.options.data = {}; - } - return this.options.data; - }; - - /** - * uses form element and replaces them with "spans" that contain the actual content. - * the original "inputs" are hidden - * @param form the form - * @param enable true: switch inputs with spans, false: switch spans back, undefined: toggle - */ - JsForm.prototype.preventEditing = function(prevent) { - var $this = $(this.element); - - if(typeof prevent === "undefined") { - // get the disable from the form itself - prevent = $this.data("disabled")?false:true; - } else { - // already in that state - if(prevent === $this.data("disabled")) { - return; - } - } - - if (prevent) - { - $this.find("input, textarea").each(function() { - if ($(this).closest("span.form")[0]) - return; - if($(this).attr("type") == "hidden") - return; - var val = $(this).val(); - if (val === "null" || val === null || $(this).attr("type") === "submit") - val = ""; - if($(this).hasClass("trueFalse")) { - if($(this).is(':checked')) - val = 'X'; - else - val = ' '; - } - - // convert \n to brs - escape all other html - val = val.replace(//g, ">").replace(/\n/g, "
"); - var thespan = $(''+val+''); - if($(this).parent().hasClass("ui-wrapper")) - $(this).parent().hide().wrap(thespan); - else - $(this).hide().wrap(thespan); - }); - // selects are handled slightly different - $this.find("select").each(function() { - if ($(this).closest("span.form")[0]) - return; - - var val = $(this).children(":selected").html(); - if (val === "null" || val === null) - val = ""; - - var thespan = $(''+val+''); - - // toggle switches work a little different - if($(this).hasClass("ui-toggle-switch")) { - $(this).prev().hide().wrap(thespan); - } - else { - $(this).hide().wrap(thespan); - } - }); - } - else - { - $this.find("span.form").each(function() { - // remove text and then unwrap - var ele = $(this).children("input,select,textarea,.ui-wrapper,.ui-toggle-switch").show().detach(); - $(this).before(ele); - $(this).remove(); - }); - } - - $this.data("disabled", prevent); - }; - - /** - * validate a given form - * @return true if the form has no invalid fields, false otherwise - */ - JsForm.prototype.validate = function() { - // get the prefix from the form if not given - //var prefix = this.options.prefix; - - // validation - $(".required,.regexp,.date,.mandatory,.number,.validate", this.element).change(); - - // check for invalid fields - if($(".invalid", this.element).length > 0) { - return false; - } - - return true; - }; - - /** - * fill a form based on a pojo. - * @param form the form - * @param data the data object used to fill the form - * @param prefix the optional prefix used to identify fields for this form - * @private - */ - JsForm.prototype._fill = function(form, data, prefix) { - // get the prefix from the form if not given - if(!prefix) { - prefix = this.config.prefix; - } - - this._clear(form, prefix); - - $(form).addClass("POJO"); - $(form).data("pojo", data); - - // fill base - this._fillData(form, data, prefix); - this._fillCollection(form, data, prefix); - - // mark fields - }; - - /** - * @param container the container element - * @param data an array containing the the data - * @param prefix a prefix for each line of data - * @private - */ - JsForm.prototype._fillCollection = function(container, data, prefix) { - var that = this; - // fill collections - $(".collection", container).each(function() { - var container = $(this), - fieldname = $(this).attr("data-field"); - // only collections with the correct prefix - if(!data || !fieldname || fieldname.indexOf(prefix+".") !== 0) { - return; - } - - // data for the collection filling - var colData = null; - - var cname = fieldname; - // remove the prefix - if (prefix) { - cname = cname.substring(prefix.length + 1); - } - colData = that._get(data, cname); - - if(colData) { - // fill the collection - that._fillList(container, colData, cname); - } - }); - }; - - /** - * @param container the container element - * @param data an array containing the the data - * @param prefix a prefix for each line of data - * @param lineFunc function(line,cur) - can return false to skip the line - * @private - */ - JsForm.prototype._fillList = function(container, data, prefix, lineFunc) { - var tmpl = container.data("template"), - that = this; - if(!tmpl) { - return; - } - // clean out previous list - container.empty(); - - // not an array - if(!$.isArray(data)) { - return; - } - - // cut away any prefixes - only the fieldname is used - if(prefix.indexOf('.') !== -1) { - prefix = prefix.substring(prefix.lastIndexOf('.')+1); - } - - - // check if we need to sort the array - if($(container).hasClass("sort")) { - var sortField = $(container).attr("data-sort"); - if(sortField) { - switch($(container).attr("data-sorttype")) { - case 'alpha': - data.sort(); - break; - case 'alphainsensitiv': - data.sort(function(a,b){ - a = a[sortField]; - b = b[sortField]; - if(a) a = a.toLowerCase(); - if(b) b = b.toLowerCase(); - if(ab) - return 1; - return 0; - }); - break; - default: - data.sort(function(a,b){ - return a[sortField] - b[sortField]; - }); - } - // descending: reverse - if($(container).attr("data-sortdesc")) { - data.reverse(); - } - } - } - - if(!lineFunc) { - if($.isFunction(prefix)) { - lineFunc = prefix; - prefix = null; - } - } - - for(var i = 0; i < data.length; i++) { - var cur = data[i]; - var line = tmpl.clone(true); - // save current line - line.data("pojo", cur); - line.addClass("POJO"); - - if(lineFunc) { - if(lineFunc(line, cur) === false) { - continue; - } - } - - that._addCollectionControls(line); - - if(prefix) { - that._fillData(line, cur, prefix); - // enable collection controls - that._initCollection(line, prefix); - // fill with data - that._fillCollection(line, cur, prefix); - } - container.append(line); - - } - }; - - /** - * add controls into a collection entry(i.e. delete) - * @param line the new collection - * @private - */ - JsForm.prototype._addCollectionControls = function(line) { - var that = this; - - // enable controls on the line - if($.jsFormControls) { - $(line).jsFormControls(); - } - - $(".delete", line).click(function(){ - var ele = $(this).closest(".POJO"); - // trigger a callback - $(this).closest(".collection").trigger("deleteCollection", [ele, $(ele).data().pojo]); - ele.remove(); - }); - $(".sortUp", line).click(function(){ - // check if there is an up - var ele = $(this).closest(".POJO"); - var prev = ele.prev(".POJO"); - if(prev.size() === 0) { - // no previous element - return - return; - } - ele.detach(); - prev.before(ele); - // reorder (if possible) - that._reorder(ele); - }); - $(".sortDown", line).click(function(){ - // check if there is a down - var ele = $(this).closest(".POJO"); - var next = ele.next(".POJO"); - if(next.size() === 0) { - // no next element - return - return; - } - ele.detach(); - next.after(ele); - // reorder (if possible) - that._reorder(ele); - }); - - // if collection is sortable: refresh it - var container = $(line).closest(".collection"); - if(container.hasClass("sortable")&& $(container).sortable) { - container.sortable("refresh"); - } - }; - - /** - * Reorder a collection (actually its fields) - * @param ele one element of the collection or the collection itself - * @private - */ - JsForm.prototype._reorder = function(ele) { - if(!ele.attr("data-sort")) { - ele = ele.closest(".collection"); - } - - // get the field to use for sorting - var sortField = $(ele).attr("data-sort"); - if(!sortField || ($(ele).attr("data-sorttype") && $(ele).attr("data-sorttype") !== "number") || - ($(ele).attr("data-sortdesc") && $(ele).attr("data-sortdesc") !== "false")) { - return; - } - - // go through each child and get the pojo - var prio = 0; - $.each($(ele).children(), function(){ - var data = $(this).data("pojo"); - // no data yet - add one - if(!data) { - data = {}; - $(this).data("pojo", data); - } - - data[sortField] = prio++; - }); - }; - - /** - * render an object based on a string. - * Note: comma is a special char and cannot be used! - * @param obj the object - * @param skin the string to render with (i.e. id, ":", test) - * @private - */ - JsForm.prototype._renderObject = function(obj, skin) { - if(!skin || !obj) - return ""; - var that = this; - var ret = ""; - $.each(skin.split(","), function(){ - var val = this.trim(); - if(val.indexOf("'") === 0 || val.indexOf('"') === 0) { - ret += val.substring(1, val.length - 1); - } else { - ret += that._get(obj, val); - } - }); - return ret; - }; - - /** - * Retrieve a value from a given object by using dot-notation - * @param obj the object to start with - * @param the child to get (dot notation) - * @param create set to true and non-existant levels will be created (always returns non-null) - * @private - */ - JsForm.prototype._get = function(obj, expr, create) { - var ret, p, prm = "", i; - if(typeof expr === "function") { - return expr(obj); - } - if (!obj) { - return ""; - } - // reference the object itself - if(expr === "") - return obj; - - ret = obj[expr]; - if(!ret) { - try { - if(typeof expr === "string") { - prm = expr.split('.'); - } - - i = prm.length; - if(i) { - ret = obj; - while(ret && i--) { - p = prm.shift(); - // create the levels - if(create && !ret[p]) { - ret[p] = {}; - } - ret = ret[p]; - } - } - } catch(e) { /* ignore */ } - } - if(ret === null || ret === undefined) { - ret = ""; - } - // trim the return - if(ret.trim) { - return ret.trim(); - } - return ret; - }; - - - /** - * get the "parent" object of a given dot-notation. this will not return the actual - * element given in the dot notation but itws parent (i.e.: when using a.b.c -> it will return b) - * @param obj the object to start with - * @param the child to get (dot notation) - * @param create set to true and non-existant levels will be created (always returns non-null) - * @private - */ - JsForm.prototype._getParent = function(obj, expr, create) { - if(expr.indexOf('.') === -1) - return obj; - - expr = expr.substring(0, expr.lastIndexOf('.')); - return this._get(obj, expr, create); - }; - - /** - * helper function to get the number of a value - * @param num the string - * @returns a number or null - * @private - */ - JsForm.prototype._getNumber = function(num) { - if (!num) { - return null; - } - - if($.format) - return $.format.number(num); - - // either we have , (for komma) or a . and at least 3 following numbers (not a round komma) - if(num.indexOf(",") != -1 || (num.length - num.indexOf('.') > 3)) - { - num = num.replace(/\./g, "").replace(",", "."); - } - return Number(num); - }; - - /** - * checks if a variable is empty. This will check array, and whole objects. If a json object - * only contains empty "elements" then it is considered as empty. - * Empty for a number is 0/-1 - * Empty for a boolena is false - * - * @param pojo the pojo to check - * @returns {Boolean} true if it is empty - * @private - */ - JsForm.prototype._isEmpty = function(pojo) { - // boolean false, null, undefined - if(!pojo) { - return true; - } - - // array - if($.isArray(pojo)) { - // zero length - if(pojo.length === 0) { - return true; - } - - // check each element - for(var i = 0; i < pojo.length; i++) { - if(!this._isEmpty()) { - return false; - } - } - return true; - } - // an object - if($.isPlainObject(pojo)) { - if($.isEmptyObject(pojo)) { - return true; - } - - for(var f in pojo){ - if(!this._isEmpty(pojo[f])) { - return false; - } - } - return true; - } - - // a number - if(!isNaN(pojo)) { - if (Number(pojo) === 0 || Number(pojo) === -1) { - return true; - } - return false; - } - - // a string - return (pojo === "" || pojo === " "); - }; - - /** - * compare a pojo with a form. Takes special data definition classes into account: - * - * @param start the element to start from (ie. the form or tr) - * @param pojo the pojo to write everything to - * @param prefix a prefix: only fields with the given prefix will be included in the pojo - * @private - */ - JsForm.prototype._pojoDifferFromInput = function (start, prefix, pojo) { - var differs = false; - $("input,select,textarea", start).each(function(){ - // skip if we found a dif - if(differs) { - return; - } - - var name = $(this).attr("name"); - // empty name - ignore - if (!name) { - return; - } - - // skip grayed (=calculated) or transient fields - if($(this).hasClass("transient")) { - return; - } - - // must start with prefix - if(name.indexOf(prefix + ".") !== 0) { - return; - } - - // cut away the prefix - name = name.substring((prefix+".").length); - - // skip empty - if(name.length < 1) { - return; - } - - var val = $(this).val(); - // set empty numbers to null - if(val === "" && ($(this).hasClass("number") || $(this).hasClass("dateFilter")|| $(this).hasClass("dateTimeFilter"))) { - val = null; - } - if ($(this).hasClass("number") || $(this).hasClass("currency")) { - val = that._getNumber(val); - if(isNaN(val)) { - val = 0; - } - } - if($(this).attr("type") === "checkbox" || $(this).attr("type") === "CHECKBOX") { - val = $(this).is(':checked'); - } - - // check if we have a . - if so split - if (name.indexOf(".") === -1) - { - // the vals differ - if(pojo[name] !== val) { - differs = true; - } - } - else - { - var parts = name.split("."); - - var d0 = pojo[parts[0]]; - var d1, d2; - - if (!d0) { - differs = true; - return; - } - - if (parts.length === 2) { - // the vals differ - if(d0[parts[1]] !== val) { - differs = true; - } - } else if (parts.length === 3) { - d1 = d0[parts[1]]; - // the vals differ - if(d1[parts[2]] !== val) { - differs = true; - } - } else if (parts.length === 4) - { - d1 = d0[parts[1]]; - d2 = d1[parts[2]]; - // the vals differ - if(d2[parts[3]] !== val) { - differs = true; - } - } - // more should not be necessary - } - }); - return differs; - }; - - /** - * Compares a pojo with form fields - * @param pojo the pojo to compare with - * @return true if any change between formfields and the pojo is found - */ - JsForm.prototype.equals = function(pojo) { - var that = this; - var form = this.element; - var prefix = this.options.prefix; - - // check the base - if(this._pojoDifferFromInput(form, prefix, pojo)) { - return false; - } - - var differs = false; - - // check for invalid fields - if($(".invalid", form).length > 0) { - return false; - } - - $(".collection", form).each(function() { - if(differs) { - return; - } - - var fieldname = $(this).attr("data-field"); - // only collections with the correct prefix - if(!fieldname || fieldname.indexOf(prefix+".") !== 0) { - return; - } - - fieldname = fieldname.substring((prefix+".").length); - if(fieldname.length < 1) { - return; - } - - var childCounter = 0; - // go through all direct childs - each one is an element - $(this).children().each(function(){ - if(differs) { - return; - } - - // check if we have more elements - if(childCounter >= pojo[fieldname].length) { - differs = true; - return; - } - - var ele = pojo[fieldname][childCounter++]; - if(that._pojoDifferFromInput($(this), fieldname, ele)) { - differs = true; - } - }); - - if(childCounter < pojo[fieldname].length) { - differs = true; - } - }); - - // we want to know if its equals -> return not - return !differs; - }; - - /** - * fill the form with data. - * - * @param data {object} the data - * @private - */ - JsForm.prototype.fill = function(pojo) { - // clear first - this.clear(); - // set the new data - this.options.data = pojo; - // fill everything - this._fill(this.element, this.options.data, this.options.prefix); - }; - - - /** - * Clear all fields in a form - */ - JsForm.prototype.clear = function() { - // clear first - this._clear(this.element, this.options.prefix); - }; - - /** - * destroy the jsform and its resources. - * @private - */ - JsForm.prototype.destroy = function( ) { - return $(this.element).each(function(){ - $(window).unbind('.jsForm'); - $(this).removeData('jsForm'); - }); - }; - - // init and call methods - $.fn.jsForm = function ( method ) { - // Method calling logic - if ( typeof method === 'object' || ! method ) { - return this.each(function () { - if (!$(this).data('jsForm')) { - $(this).data('jsForm', new JsForm( this, method )); - } - }); - } else { - var args = Array.prototype.slice.call( arguments, 1 ), - jsForm; - // none found - if(this.length === 0) { - return null; - } - // only one - return directly - if(this.length === 1) { - jsForm = $(this).data('jsForm'); - if (jsForm) { - if(method.indexOf("_") !== 0 && jsForm[method]) { - var ret = jsForm[method].apply(jsForm, args); - return ret; - } - - $.error( 'Method ' + method + ' does not exist on jQuery.jsForm' ); - return false; - } - } - - return this.each(function () { - jsForm = $.data(this, 'jsForm'); - if (jsForm) { - if(method.indexOf("_") !== 0 && jsForm[method]) { - return jsForm[method].apply(jsForm, args); - } else { - $.error( 'Method ' + method + ' does not exist on jQuery.jsForm' ); - return false; - } - } - }); - } - }; - - /** - * global jsForm function for intialisation - */ - $.jsForm = function ( name, initFunc ) { - var jsForms = JSFORM_MAP[name]; - // initFunc is a function -> initialize - if($.isFunction(initFunc)) { - // call init if already initialized - if(jsForms) { - $.each(jsForms, function(){ - initFunc(this, $(this.element)); - }); - } - - // remember for future initializations - JSFORM_INIT_FUNCTIONS[name] = initFunc; - } else { - // call init if already initialized - if(jsForms) { - var method = initFunc; - var args = Array.prototype.slice.call( arguments, 2 ); - $.each(portlets, function(){ - this[method].apply(this, args); - }); - } - } - }; - -})( jQuery, window ); - -/** - * jquery.jsForm.controls - * ---------------------- - * UI Controls and Field validation - * @version 1.0 - * @class - * @author Niko Berger - * @license MIT License GPL - */ -;(function( $, window, undefined ){ - "use strict"; - - var JSFORM_INIT_FUNCTIONS = {}, // remember initialization functions - JSFORM_MAP = {}; // remember all forms - - /** - * handlebars extension (+simple date format) - */ - if(typeof Handlebars !== "undefined") { - Handlebars.registerHelper("currency", function(data){ - if(!data) - return "0"; - return $.jsFormControls.Format.currency(data); - }); - Handlebars.registerHelper("dec", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.decimal(data); - }); - Handlebars.registerHelper("percent", function(data){ - if(!data) - return "0"; - return $.jsFormControls.Format.decimal(data*100); - }); - Handlebars.registerHelper("date", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.date(data); - }); - Handlebars.registerHelper("time", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.time(data); - }); - Handlebars.registerHelper("datetime", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.dateTime(data); - }); - Handlebars.registerHelper("dateTime", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.dateTime(data); - }); - Handlebars.registerHelper("timespan", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.humanTime(data); - }); - } - - function JsFormControls(element) { - this.element = element; - - // init the dom functionality - this._domInit(); - } - - /** - * init the dom. This can be called multiple times. - * this will also enable "add", "insert" and "delete" for collections - * @private - */ - JsFormControls.prototype._domInit = function() { - var location = $(this.element); - - // validation - // check required (this is the first check) - location.find("input.mandatory,textarea.mandatory").on("keyup", function(){ - // check for "null" as value as well - if($(this).val().length > 0 && $(this).val() !== "null") { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - }); - - location.find("input.mandatory,textarea.mandatory").on("change", function(){ - if($(this).hasClass("object")) { - if($(this).data().pojo) { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - return; - } - // check for "null" as value as well - if($(this).val().length > 0 && $(this).val() !== "null") { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - }).change(); - - location.find("select.mandatory").change(function(){ - // check for "null" as value as well - if($(this).val() !== null && $(this).val() !== "null" && $(this).val().length > 0) { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - }).change(); - - // show datepicker for all inputs - location.find("input.date").each(function(){ - var format = $(this).attr("data-format"); - // only if jquery ui is available - if($(this).datepicker) { - if(format) - $(this).datepicker({dateFormat: format}); - else - $(this).datepicker(); - } - }); - - - // input validation (number) - var numberRegexp = new RegExp("^[0-9]+$"); - location.find("input.number").keyup(function(){ - var val = $(this).val(); - if(val.length > 0) { - if($(this).hasClass("autoclean")) { - $(this).val(val.replace(/[^0-9]/g, "")); - } - else { - if(numberRegexp.test($(this).val())) { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - } - } - }).keyup(); - - // regular expression - location.find("input.regexp").each(function(){ - if($(this).hasClass("autoclean")) { - $(this).data("regexp", new RegExp($(this).attr("data-regexp"), "g")); - } - else { - $(this).data("regexp", new RegExp($(this).attr("data-regexp"))); - } - - $(this).keyup(function(){ - var val = $(this).val(); - if(val.length > 0) { - var regexp = $(this).data("regexp"); - if($(this).hasClass("autoclean")) { - $(this).val(val.replace(regexp, "")); - } - else { - if(regexp.test($(this).val())) { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - } - } else { - // if not mandatory: nothing is valid - if(!$(this).hasClass("mandatory")) { - $(this).removeClass("invalid").addClass("valid"); - } - } - }).keyup(); - $(this).change(function(){ - $(this).keyup(); - }); - }); - - /* rotatestate stontrol */ - location.find("input.rotatestate").each(function(){ - var states = $(this).attr("data-state-values"); - var defaultClass = $(this).attr("data-state-class"); - // no need to continue if there are no states - if(!states) { - return; - } - - try { - states = JSON.parse(states); - } catch (ex) { - // do not need to continue if we cannot parse the states - return; - } - - var stateControl = $(""); - if($(this).attr("title")) { - stateControl.attr("title", $(this).attr("title")); - } - if($(this).attr("data-state-style")) { - stateControl.attr("style", $(this).attr("data-state-style")); - } - stateControl.data("states", states); - stateControl.data("control", this); - stateControl.data("activeState", null); - $(this).data("control", stateControl); - if(defaultClass) { - stateControl.addClass(defaultClass); - } - - // click on the control starts rotating - stateControl.click(function(){ - var cState = $(this).data().activeState; - var cStates = $(this).data().states; - var control = $(this).data().control; - var newState = null; - - if(cState !== null) { - // go to the 'next' state - for(var i = 0; i < cStates.length; i++) { - if(cStates[i].value === cState.value) { - // last element - if(i === cStates.length - 1) { - newState = cStates[0]; - } else { - newState = cStates[i+1]; - } - break; - } - } - } else { - // no state yet - set the first entry as state - newState = cStates[0]; - } - - $(control).attr("value", newState.value); - // trigger change - $(control).change(); - }); - - // make sure to update state if the value is changed - $(this).change(function(){ - var control = $($(this).data().control); - var cState = control.data().activeState; - var cStates = control.data().states; - - if(cState !== null) { - // remove "old state" - control.removeClass(cState['class']); - } - - // add new State - var val = $(this).val(); - $.each(cStates, function(){ - if(this.value === val) { - control.data().activeState = this; - if(this.title) { - control.attr("title", this.title); - } - control.addClass(this['class']); - return false; - } - }); - }); - - // trigger initial state - $(this).change(); - $(this).after(stateControl); - $(this).hide(); - }); - }; - - - /** - * validate a given form - * @return true if the form has no invalid fields, false otherwise - */ - JsFormControls.prototype.validate = function() { - // validation - $(".required,.regexp,.date,.mandatory,.number,.validate", this.element).change(); - - // check for invalid fields - if($(".invalid", this.element).length > 0) { - return false; - } - - return true; - }; - - // init and call methods - $.fn.jsFormControls = function ( method ) { - // Method calling logic - if ( typeof method === 'object' || ! method ) { - return this.each(function () { - if (!$(this).data('jsFormControls')) { - $(this).data('jsFormControls', new JsFormControls( this, method )); - } - }); - } else { - var args = Array.prototype.slice.call( arguments, 1 ); - - // only one - return directly - if(this.length == 1) { - var jsFormControls = $(this).data('jsFormControls'); - if (jsFormControls) { - if(method.indexOf("_") !== 0 && jsFormControls[method]) { - var ret = jsFormControls[method].apply(jsFormControls, args); - return ret; - } - - $.error( 'Method ' + method + ' does not exist on jQuery.jsFormControls' ); - return false; - } - } - - return this.each(function () { - var jsFormControls = $.data(this, 'jsFormControls'); - if (jsFormControls) { - if(method.indexOf("_") !== 0 && jsFormControls[method]) { - return jsFormControls[method].apply(jsFormControls, args); - } else { - $.error( 'Method ' + method + ' does not exist on jQuery.jsFormControls' ); - return false; - } - } - }); - } - }; - - /** - * global jsForm function for intialisation - */ - $.jsFormControls = function ( name, initFunc ) { - var jsForms; - // initFunc is a function -> initialize - if($.isFunction(initFunc)) { - // call init if already initialized - jsForms = JSFORM_MAP[name]; - if(jsForms) { - $.each(jsForms, function(){ - initFunc(this, $(this.element)); - }); - } - - // remember for future initializations - JSFORM_INIT_FUNCTIONS[name] = initFunc; - } else { - // call init if already initialized - jsForms = JSFORM_MAP[name]; - if(jsForms) { - var method = initFunc; - var args = Array.prototype.slice.call( arguments, 2 ); - $.each(portlets, function(){ - this[method].apply(this, args); - }); - } - } - }; - - $.jsFormControls.Format = { - /** - * format a string based on teh classes in a dom element - */ - format: function(ele, cdata) { - if($(ele).hasClass("dateTime")) { - return $.jsFormControls.Format.dateTime(cdata); - } if($(ele).hasClass("datetime")) { - return $.jsFormControls.Format.dateTime(cdata); - } else if($(ele).hasClass("date")) { - return $.jsFormControls.Format.date(cdata); - } else if($(ele).hasClass("currency")) { - return $.jsFormControls.Format.currency(cdata); - } else if($(ele).hasClass("number")) { - return $.jsFormControls.Format.decimal(cdata); - } - - return cdata; - }, - - /** - * format boolean into an ui-icon - * @param value true or false - * @returns the ui-icon span - */ - checkBox: function(row, cell, value, columnDef, dataContext) { - // cleanup parameters (direct call vs. slickgrid) - if(typeof value === "undefined") { - value = row; - row = null; - } - - if(value) { - return ' '; - } else { - return ' '; - } - - return value; - }, - - - /** - * @private - */ - _getNumber: function(num) { - if (!num) { - return null; - } - - if($.format) - return $.format.number(num); - - // either we have , (for komma) or a . and at least 3 following numbers (not a rounden komma) - if(num.indexOf(",") !== -1 || (num.length - num.indexOf('.') > 3)) - { - num = num.replace(/\./g, "").replace(",", "."); - } - return Number(num); - }, - - - /** - * @private - */ - _pad: function(val) { - var o = (val < 10) ? "0" : ""; - o += val; - return o; - }, - - - /** - * @private - */ - decimal: function(num) { - if (num === "" || !num || isNaN(num)) { - return num; - } - - if($.format) - return $.format.number(num, $(document).data().i18n.number.format); - - var comma = 0; - if (Math.abs(num - Math.floor(num)) > 0.001) { - comma = 2; - } - // convert to a nice number for display - var n = num, - c = isNaN(c = Math.abs(comma)) ? 2 : comma, - d = ',', // decimal d == undefined ? "," : d, - t = '.', // thousand: t == undefined ? "." : t, - i = parseInt(n = Math.abs( +n || 0).toFixed(c), 10) + "", - j = (j = i.length) > 3 ? j % 3 : 0; - return (num<0 ? "-" : "") + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); - }, - - - /** - * @private - */ - currency: function(row, cell, cellvalue, columnDef, dataContext) { - // cleanup parameters (direct call vs. slickgrid) - if(!cellvalue || isNaN(cellvalue)) { - cellvalue = row; - row = null; - } - - if(!cellvalue) { - if(cell) { - return " "; - } - return ""; - } - - return $.jsFormControls.Format.decimal(cellvalue); - }, - - /** - * @private - */ - dateTime: function(row, cell, cellvalue, columnDef, dataContext) { - // cleanup parameters (direct call vs. slickgrid) - if(!cellvalue || isNaN(cellvalue)) { - cellvalue = row; - row = null; - } - - if(!cellvalue) { - if(cell) { - return " "; - } - return ""; - } - - return (this.date(cellvalue) + " " + this.time(cellvalue)); - }, - - /** - * @private - */ - date: function(row, cell, cellvalue, columnDef, dataContext) { - - // cleanup parameters (direct call vs. slickgrid) - if(!cellvalue || isNaN(cellvalue)) { - cellvalue = row; - row = null; - } - - if(!cellvalue) { - if(cell) { - return " "; - } - return ""; - } - - var d = new Date(); - d.setTime(cellvalue); - var year = d.getYear(); - if(year < 1900) { - year += 1900; - } - - if($.format) - return $.format.date(d, $(document).data().i18n.date.shortDateFormat); - else - return this._pad(d.getDate()) + "." + this._pad((d.getMonth()+1)) + "." + this._pad(year); - }, - - /** - * @private - */ - time: function(row, cell, value, columnDef, dataContext) { - // cleanup parameters (direct call vs. slickgrid) - if(!value) { - value = row; - row = null; - } - - if(!value) { - if(cell) { - return " "; - } - return ""; - } - - var d = new Date(); - d.setTime(value); - if($.format) - return $.format.date(d, $(document).data().i18n.date.timeFormat); - else - return this._pad(d.getHours()) + ":" + this._pad(d.getMinutes()); // + ":" + pad(d.getSeconds()); don't need seconds - }, - - /** - * - * @param value a string value to format - * @param allowms true to allow komma (i.e. 00.00) - * @return something in the form of 00:00.00 - * @private - */ - timespan: function(row, cell, value, columnDef, dataContext, allowcomma) { - // cleanup parameters (direct call vs. slickgrid) - if(!value) { - value = row; - allowcomma = cell; - row = null; - cell = null; - } - - var tokens = value.split(":"); - // check each token - for(var i=0; i 0) { - out += h + "h "; - // ignore seconds and milliseconds if we have hours - s = 0; - value = 0; - } - if (m > 0) { - out += m + "m "; - // ignore milliseconds - value = 0; - } - if (s > 0) { - out += s + "s "; - value = 0; - } - - if (value > 0) { - out += value + "ms"; - } - // trim output - return out.trim(); - } - }; - -})( jQuery, window ); - - -/** - * @returns the trimmed string - */ -String.prototype.trim = function() { - return this.replace(/^\s+|\s+$/g, ""); -}; - -/* check start of a string */ -String.prototype.startsWith = function(str) { - if((this === null) || (this.length <= 0)) - return false; - if((str === null) || (str == "null") || (str.length <= 0)) - return false; - if(this.substr(0, str.length) == str) - return true; - return false; -}; - -/* check start of a string */ -String.prototype.startsWithIgnoreCase = function(str) { - if((this === null) || (this.length <= 0)) - return false; - if((str === null) || (str == "null") || (str.length <= 0)) - return false; - if(this.substr(0, str.length).toLowerCase() == str.toLowerCase()) - return true; - return false; -}; - -/* check end of a string */ -String.prototype.endsWith = function(str) { - if((this === null) || (this.length <= 0)) - return false; - if((str === null) || (str == "null") || (str.length <= 0) || (str.length > this.length)) - return false; - if(this.substr(this.length - str.length) == str) - return true; - return false; -}; \ No newline at end of file diff --git a/dist/jquery.jsForm-1.0.6.js b/dist/jquery.jsForm-1.0.6.js deleted file mode 100644 index 991d739..0000000 --- a/dist/jquery.jsForm-1.0.6.js +++ /dev/null @@ -1,2454 +0,0 @@ -/** - * jquery.jsForm - * ------------- - * JsForm control for handling html UI with json objects - * @version 1.0 - * @class - * @author Niko Berger - * @license MIT License GPL - */ -;(function( $, window, undefined ){ - "use strict"; - - var JSFORM_INIT_FUNCTIONS = {}, // remember initialization functions - JSFORM_MAP = {}; // remember all forms - - - /** - * @param element {Node} the cotnainer node that should be converted to a jsForm - * @param options {object} the configuraton object - * @constructor - */ - function JsForm (element, options) { - var $this = $(element); - - // create the options - this.options = $.extend({}, { - /** - * enable form control rendering (if jsForm.controls is available) and validation - */ - controls: true, - /** - * the object used to fill/collect data - */ - data: null, - /** - * the prefix used to annotate theinput fields - */ - prefix: "data", - /** - * set to false to only validate visible fields. - * This is discouraged especially when you have tabs or similar elements in your form. - */ - validateHidden: true, - /** - * skip empty values when getting an object - */ - skipEmpty: false - }, options); - - // read prefix from dom - if($this.attr("data-prefix") && (this.options.prefix === "data" || this.options.prefix === "")) { - if($this.attr("data-prefix") !== "") { - this.options.prefix = $this.attr("data-prefix"); - } - } - - this.element = element; - - this._init(); - } - - /** - * init the portlet - load the config - * @private - */ - JsForm.prototype._init = function() { - // init the basic dom functionality - this._domInit(); - - // enable form controls - if(this.options.controls) { - if($.jsFormControls) { - $(this.element).jsFormControls(); - } else { - try { - if(typeof console !== "undefined") { - console.log("jquery.JsForm.controls not available!"); - } - } catch(ex) { - // ignore - } - } - } - - // fill/init with the first data - this._fill(this.element, this.options.data, this.options.prefix); - }; - - - /** - * init the dom. This can be called multiple times. - * this will also enable "add", "insert" and "delete" for collections - * @private - */ - JsForm.prototype._domInit = function() { - var form = $(this.element); - var that = this; - var prefix = this.options.prefix; - - // collection lists with buttons - that._initCollection(form, prefix); - }; - - /** - * initialize collections - */ - JsForm.prototype._initCollection = function(form, prefix) { - // all collections - var collectionMap = {}, - that = this; - $(form).data().collections = collectionMap; - - $(".collection", form).each(function() { - var colName = $(this).attr("data-field"); - // skip collections without a data-field mapping - if (!colName || colName.indexOf(prefix + ".") !== 0) { - return; - } - - var container = $(this); - - // remember the collection - var cols = collectionMap[colName]; - if(cols) { - cols.push(container); - } else { - collectionMap[colName] = [container]; - } - - //init the collection - that._initList(container); - - // after adding: check if we want reorder control - if(!container.hasClass("ui-sortable") && container.hasClass("sortable") && container.sortable) { - // get the config object - var config = container.attr("data-sortable"); - if(!config) { - config = {}; - } else { - config = JSON.parse(config); - } - - container.sortable(config); - container.on("sortstop", function( event, ui ) { - that._reorder(container); - }); - } - - }); - - $(".add", form).each(function(){ - var fieldName = $(this).attr("data-field"); - if(!fieldName) { - return; - } - - // only init once - if($(this).data("collections")) { - return; - } - - // add the collection - $(this).data().collections = collectionMap[fieldName]; - - $(this).click(function(ev){ - ev.preventDefault(); - - // search for a collection with that name - $.each($(this).data("collections"), function() { - var tmpl = $(this).data("template"); - // and has a template - if(tmpl) { - var line = tmpl.clone(true); - $(this).append(line); - $(line).addClass("POJO"); - $(line).data("pojo", {}); - - that._addCollectionControls(line); - - // trigger a callback - $(this).trigger("addCollection", [line, $(line).data().pojo]); - - // fill the line with data - that._fillData(line, $(line).data().pojo, fieldName.substring(fieldName.indexOf('.')+1)); - - // its possible to have "sub" collections - that._initCollection(line, fieldName.substring(fieldName.indexOf('.')+1)); - - // trigger a callback after the data has been rendered) - $(this).trigger("postAddCollection", [line, $(line).data().pojo]); - - - } - }); - }); - }); - - // insert: similar to add - but works with events - $(".insert", form).each(function(){ - var fieldName = $(this).attr("data-field"); - if(!fieldName) { - return; - } - - // only init once - if($(this).data("collections")) { - return; - } - - // remember the collections - $(this).data("collections", collectionMap[$(this).attr("data-field")]); - - $(this).on("insert", function(ev, pojo){ - if(!pojo) - pojo = $(this).data().pojo; - - // insert only works if there is a pojo - if(!pojo) { - return; - } - var beforeInsertCallback = $(this).data("beforeInsert"); - if(beforeInsertCallback && $.isFunction(beforeInsertCallback)) { - pojo = beforeInsertCallback(pojo); - - // insert only works if there is a pojo - if(!pojo) { - return; - } - } - - // search for a collection with that name - $.each($(this).data("collections"), function() { - var tmpl = $(this).data("template"); - // and has a template - if(tmpl) { - var line = tmpl.clone(true); - // mark that this is a pojo - line.addClass("POJO"); - // add the pojo - line.data().pojo = pojo; - - that._addCollectionControls(line); - - // its possible to have "sub" collections - that._initCollection(line); - - // trigger a callback - $(this).trigger("addCollection", [line, $(line).data().pojo]); - - // fill the "information" - that._fillData(line, pojo, fieldName.substring(fieldName.indexOf('.')+1)); - - $(this).append(line); - } - }); - - // empty field - $(this).val(""); - $(this).data().pojo = null; - $(this).focus(); - }); - }); - - // insert: helper button (triggers insert) - $(".insertAction", form).each(function(){ - var fieldName = $(this).attr("data-field"); - if(!fieldName) { - return; - } - - // only init once - if($(this).data("inserter")) { - return; - } - - // find the insert element for this data-field - var inserter = $(this).parent().find(".insert"); - if(!inserter) { - return; - } - - // remember the inserter - $(this).data("inserter", inserter); - - $(this).click(function(ev){ - ev.preventDefault(); - $(this).data("inserter").trigger("insert"); - return false; - }); - - }); - - $("input.object", form).each(function(){ - $(this).on("update", function(evt){ - var pojo = $(this).data().pojo; - if (pojo && $(this).attr("data-display")) { - $(this).val(that._renderObject(pojo, $(this).attr("data-display"))); - } - }); - }); - - // fileupload - $("input.blob", form).each(function(){ - // only available on input type file - if($(this).attr("type") !== "file") { - return; - } - - var blobInput = $(this); - - // bind on change - $(this).on("change", function(evt){ - - //get file name - var fileName = $(this).val().split(/\\/).pop(); - blobInput.data("name", fileName); - - var files = evt.target.files; // FileList object - // Loop through the FileList (and render image files as thumbnails.(skip for ie < 9) - if(files && files.length) { - $.each(files, function() { - var reader = new FileReader(); - - // closure to capture the file information - reader.onload = function(e) { - // get the result - blobInput.data("blob", e.target.result); - }; - - // Read in the image file as a data URL. - reader.readAsDataURL(this); - - $(this).trigger("fileChange"); - }); - } - }); - - - }); - - // manage - obsolete - $(".manage", form).each(function(){ - var fieldName = $(this).attr("data-field"); - if(!fieldName) { - return; - } - - // remember the collections - $(this).data("collections", collectionMap[fieldName]); - - // start the multi-select - $(this).click(function(){ - var dataService = $(this).attr("data-service"); - var collectionList = $(this).data("collections"); - - var btn = $(this); - var display = $(this).attr("data-display"); - if(display) { - display = display.split(","); - } - - DataUtils.run(dataService, function(data){ - var select = $(''); - select.data("collections", collectionList); - btn.data("select", select); - $.each(data, function(){ - var cur = this; - var optionDisplay = ""; - if(!display) { - optionDisplay = cur; - } else { - for(var j = 0; j < display.length; j++) { - optionDisplay += cur[display[j]] + " "; - } - } - var option = $(''); - // check if we need to "select" that option - $(collectionList).each(function() { - $(this).children().each(function(count, ele){ - if(cur.id === $(ele).data("pojo").id) { - option.attr("selected", "selected"); - } - }); - }); - select.append(option); - option.data("pojo", cur); - }); - - btn.after(select); - btn.hide(); - - select.multiselect({ - autoOpen: true, - open: function(){ - //reposition - $(this).multiselect("widget").css("top", $(select).next().offset().top); - $(this).multiselect("widget").css("left", $(select).next().offset().left); - // hide button - $(select).next().hide(); - }, - close: function(){ - btn.show(); - select.remove(); - $(this).multiselect("destroy"); - } - }).multiselectfilter().bind("multiselectclick multiselectcheckall multiselectuncheckall", - function( event, ui ){ - var checkedValues = $.map($(this).multiselect("getChecked"), function( input ){ - // we only get the same "value" - so check the option list for the correct pojo - return $("option[value='"+input.value+"']", select).data("pojo"); - }); - - // update collection - $.each($(select).data("collections"), function(){ - that._fillList($(this), checkedValues, fieldName); - }); - // reposition - btn.hide(); - $(select).next().show(); - $(this).multiselect("widget").css("top", $(select).next().offset().top); - $(this).multiselect("widget").css("left", $(select).next().offset().left); - $(select).next().hide(); - }); - }); - }); - }); - }; - - /** - * init a container that has a tempalate child (first child). - * @param container the contianer element - * @private - */ - JsForm.prototype._initList = function(container) { - // avoid double initialisation - if(container.data("template")) { - return; - } - - // get all children - var tmpl = container.children().detach(); - - // remove an id if there is one - tmpl.removeAttr("id"); - container.data("template", tmpl); - }; - - /** - * clear/reset a form. The prefix is normally predefined by init - * @param form the form - * @param prefix the optional prefix used to identify fields for this form - */ - JsForm.prototype._clear = function(form, prefix) { - // get the prefix from the form if not given - if(!prefix) { - prefix = this.options.prefix; - } - - $(form).removeData("pojo"); - $("input,select,textarea", form).each(function(){ - var name = $(this).attr("name"); - // empty name - ignore - if (!name || name.indexOf(prefix + ".") !== 0) { - return; - } - // cut away the prefix - name = name.substring((prefix+".").length); - // skip empty - if(name.length < 1) { - return; - } - - // remove all pojos - $(this).removeData("pojo"); - - if($(this).attr("type") === "checkbox") { - $(this).prop("checked", false); - } else { - $(this).val(""); - } - if($(this).hasClass("blob")) { - $(this).removeData("blob"); - } - // special type select box: select the FIRST child - if($(this).is("select")) { - $('option[selected="selected"]', this).removeAttr('selected'); - $('option:first', this).attr('selected', true); - - $(this).val($("option:first", this).val()).change(); - } - // trigger change - $(this).change(); - }); - - $(".collection", form).each(function() { - var fieldname = $(this).attr("data-field"); - // only collections with the correct prefix - if(!fieldname || fieldname.indexOf(prefix+".") !== 0) { - return; - } - // get rid of all - $(this).empty(); - }); - - }; - /** - * ceate a pojo from a form. Takes special data definition classes into account: - *
    - *
  • number|currency: the content will be transformed into a number (default string
  • - *
  • transient: will be ignored
  • - *
  • prefix.fieldname.value: will create the whole object subtree
  • - *
- * @param start the element to start from (ie. the form or tr) - * @param pojo the pojo to write everything to - * @param prefix a prefix: only fields with the given prefix will be included in the pojo - * @private - */ - JsForm.prototype._createPojoFromInput = function (start, prefix, pojo) { - // check if we have an "original" pojo - var startObj = null; - var that = this; - - // get it from the starting dom element - if($(start).data("pojo")) { - startObj = $(start).data("pojo"); - } - - // if we have an object, use this as base and fill the pojo - if(startObj) { - $.extend(true, pojo, startObj); - } - - $(start).find("input,select,textarea").each(function(){ - var name = $(this).attr("name"); - - // empty name - ignore - if (!name) { - return; - } - - // skip grayed (=calculated) or transient fields - if($(this).hasClass("transient")) { - return; - } - - // must start with prefix - if(name.indexOf(prefix + ".") !== 0) { - return; - } - - $(this).trigger("validate", true); - - // cut away the prefix - name = name.substring((prefix+".").length); - - // skip empty names - if(name.length < 1) { - pojo = $(this).val(); - return false; - } - - var val = $(this).val(); - - // ignore empty values when skipEmpty is set - if(that.options.skipEmpty && (val === "" || val.trim() === "")) { - return; - } - - if($(this).hasClass("emptynull") && (val === "" || val.trim() === "")) { // nullable fields do not send empty string - val = null; - } else if($(this).hasClass("object") || $(this).hasClass("POJO")) { - if($("option:selected", this).data() && $("option:selected", this).data().pojo) { - val = $("option:selected", this).data().pojo; - } else - val = $(this).data("pojo"); - } else if($(this).hasClass("blob")) { // file upload blob - val = $(this).data("blob"); - } else - // set empty numbers or dates to null - if(val === "" && ($(this).hasClass("number") || $(this).hasClass("dateFilter")|| $(this).hasClass("dateTimeFilter"))) { - val = null; - } - - // check for percentage: this is input / 100 - if ($(this).hasClass("percent")) { - val = that._getNumber(val); - if(isNaN(val)) { - val = 0; - } else { - val /= 100; - } - } - - if ($(this).hasClass("number") || $(this).hasClass("currency")) { - val = that._getNumber(val); - if(isNaN(val)) { - val = 0; - } - } - else if($(this).attr("type") === "checkbox" || $(this).attr("type") === "CHECKBOX") { - val = $(this).is(':checked'); - } - else if($(this).hasClass("bool")) { - val = ($(this).val() === "true"); - } - - // check if we have a . - if so split - if (name.indexOf(".") === -1) - { - pojo[name] = val; - } - else - { - var parts = name.split("."); - - var d0 = pojo[parts[0]]; - var d1, d2; - - // multiple parts: make sure its an object - if (!d0 || !$.isPlainObject(d0)) { - pojo[parts[0]] = {}; - d0 = pojo[parts[0]]; - } - - if (parts.length === 2) { - d0[parts[1]] = val; - } else if (parts.length === 3) { - d1 = d0[parts[1]]; - if(d1 === undefined) { - d1 = {}; - d0[parts[1]] = d1; - } - d1[parts[2]] = val; - } else if (parts.length === 4) - { - d1 = d0[parts[1]]; - d2 = d1[parts[2]]; - if(d2 === undefined) { - d2 = {}; - d1[parts[2]] = d2; - } - d1[parts[2]] = val; - d2[parts[3]] = val; - } - // more should not be necessary - } - }); - - return pojo; - }; - - - /** - * fill a dom subtree with data. - *
    - *
  • <span class="field">prefix.fieldname</span> - *
  • <input name="prefix.fieldname"/> - *
  • <a class="field" href="prefix.fieldname">linktest</a> - *
  • <img class="field" src="prefix.fieldname"/> - *
- * @param parent the root of the subtree - * @param data the data - * @param prefix the prefix used to find fields - * @private - */ - JsForm.prototype._fillData = function (parent, data, prefix) { - var that = this; - var $parent = $(parent); - - // locate all "fields" - $parent.find(".field").each(function() { - var name = $(this).data("name"); - if(!name) { - if(this.nodeName.toUpperCase() === 'A') { - name = $(this).attr("href"); - $(this).attr("href", "#"); - }else if(this.nodeName.toUpperCase() === 'IMG') { - name = $(this).attr("src"); - if(name.indexOf("#") === 0) { - name = name.substring(1); - } - $(this).attr("src", "#"); - }else { - name = $(this).text(); - } - $(this).data("name", name); - $(this).show(); - } - - if(!prefix || name.indexOf(prefix + ".") >= 0) { - var cname = name; - if (prefix) { - cname = cname.substring(prefix.length + 1); - } - var cdata = that._get(data, cname); - - if(!cdata) { - cdata = ""; - } - - // check for percentage: this is value * 100 - if ($(this).hasClass("percent") && !isNaN(cdata)) { - cdata = 100 * Number(cdata); - } - - // format the string - if($.jsFormControls) - cdata = $.jsFormControls.Format.format(this, cdata); - - if(this.nodeName.toUpperCase() === 'A') { - $(this).attr("href", cdata); - } else if(this.nodeName.toUpperCase() === 'IMG') { - $(this).attr("src", cdata); - } - else if(this.nodeName.toUpperCase() === "DIV"){ - $(this).html(cdata); - } else { - $(this).text(cdata); - } - } - }); - - $("input", $parent).each(function() { - var name = $(this).attr("name"); - if(!name) { - return; - } - - // ignore file inputs - they cannot be "prefilled" - if($(this).attr("type") == "file") { - return; - } - - if(!prefix || name.indexOf(prefix + ".") >= 0) { - var cname = name; - if (prefix) { - cname = cname.substring(prefix.length + 1); - } - - var cdata = that._get(data, cname); - - // check for percentage: this is value * 100 - if ($(this).hasClass("percent") && !isNaN(cdata)) { - cdata = 100 * Number(cdata); - } else if($.isPlainObject(cdata)) { - $(this).data().pojo = cdata; - $(this).addClass("POJO"); - cdata = that._renderObject(cdata, $(this).attr("data-display")); - } - - - if($(this).attr("type") === "checkbox") { - $(this).prop("checked", (cdata === true || cdata === "true")); - $(this).change(); - } else { - if(!cdata) { - cdata = ""; - } - - // format the string - if($.jsFormControls) - cdata = $.jsFormControls.Format.format(this, cdata); - - $(this).val(cdata); - $(this).change(); - } - } - }); - - $("select", $parent).each(function() { - var name = $(this).attr("name"); - if(!name) { - return; - } - - if(!prefix || name.indexOf(prefix + ".") >= 0) { - var cname = name; - if (prefix) { - cname = cname.substring(prefix.length + 1); - } - // remove "old" selected options - $(this).children("option").removeAttr("selected"); - var pk = $(this).attr("data-key"); - if(!pk) { - pk = "id"; - } - - var value = that._get(data, cname); - // try selecting based on the id - if (value[pk]) { - $(this).children("option[value='"+value[pk]+"']").attr("selected", true); - // actually set the value and trigger the change - $(this).val(value[pk]).change(); - return; - } else if($(this).hasClass("bool")) { - value = value ? "true" : "false"; - } - - $(this).children("option[value='"+value+"']").attr("selected", true); - $(this).val(value).change(); - } - }); - - $("textarea", $parent).each(function() { - var name = $(this).attr("name"); - if(!name) { - return; - } - - if(!prefix || name.indexOf(prefix + ".") >= 0) { - var cname = name; - if (prefix) { - cname = cname.substring(prefix.length + 1); - } - $(this).val(that._get(data,cname)); - $(this).change(); - } - }); - }; - - /** - * ceate a pojo from a form. Takes special data definition classes into account: - *
    - *
  • number: the content will be transformed into a number (default string
  • - *
  • trueFalse: boolean - *
  • collection: existing collections are replaced if "class=collection" elements exist - *
- * @param ignoreInvalid return a pojo, even if fields do not pass client side validation - * @return a new pojo - */ - JsForm.prototype.get = function(ignoreInvalid) { - var form = $(this.element); - var that = this; - var originalPojo = this.options.data; - var prefix = this.options.prefix; - - // get the pojo - var pojo = {}; - if(originalPojo && $.isPlainObject(originalPojo)) { - pojo = originalPojo; - } - - // fill the base - that._createPojoFromInput(form, prefix, pojo); - - // check for invalid fields - var invalid = false; - if(!this.options.validateHidden) { - form.find(".invalid").filter(":visible").each(function(){ - invalid = true; - $(this).focus(); - return false; - }); - } else { - form.find(".invalid").each(function(){ - invalid = true; - $(this).focus(); - return false; - }); - } - - // get the collection - if(this._getCollection(form, prefix, pojo, ignoreInvalid)) { - invalid = true; - } - - if(!ignoreInvalid && invalid) { - return null; - } - - return pojo; - }; - - /** - * fill a pojo based on collections - * @param form {DOMElement} the base element to start looking for collections - * @param prefix {string} the prefix used - * @param pojo {object} the object to fill - * @param ignoreInvalid {boolean} if true the function will return as soon as an invalid field is found - * @return true if the colelction encountered an invalid field - */ - JsForm.prototype._getCollection = function(form, prefix, pojo, ignoreInvalid) { - var that = this; - // check for invalid fields - var invalid = false; - - form.find(".collection").each(function() { - if(!ignoreInvalid && invalid) { - return; - } - - var fieldname = $(this).attr("data-field"); - // only collections with the correct prefix - if(!fieldname || fieldname.indexOf(prefix+".") !== 0) { - return; - } - - fieldname = fieldname.substring((prefix+".").length); - if(fieldname.length < 1) { - return; - } - - var colParent = that._getParent(pojo, fieldname, true); - - // get only the last part - if(fieldname.indexOf('.') !== -1) { - fieldname = fieldname.substring(fieldname.lastIndexOf('.') + 1); - } - - // clear the collection - colParent[fieldname] = []; - - // go through all direct childs - each one is an element - $(this).children().each(function(){ - if(!ignoreInvalid && invalid) { - return; - } - - var ele = {}; - ele = that._createPojoFromInput($(this), fieldname, ele); - - // also collect sub-collections - that._getCollection($(this), fieldname, ele, ignoreInvalid); - - // check if the pojo is empty - if(!that._isEmpty(ele)) { - if($(".invalid", this).length > 0) { - invalid = true; - } - colParent[fieldname].push(ele); - } else { - $(".invalid", this).removeClass("invalid"); - } - }); - }); - - return invalid; - }; - - /** - * Get the data object used as a base for get(). - * Note that modifying this directly migh result into unwanted results - * when working with some functions that rely on this object. - * - * @returns the original data object - */ - JsForm.prototype.getData = function() { - // make srue we do have an object to work with - if(!this.options.data) { - this.options.data = {}; - } - return this.options.data; - }; - - /** - * uses form element and replaces them with "spans" that contain the actual content. - * the original "inputs" are hidden - * @param form the form - * @param enable true: switch inputs with spans, false: switch spans back, undefined: toggle - */ - JsForm.prototype.preventEditing = function(prevent) { - var $this = $(this.element); - - if(typeof prevent === "undefined") { - // get the disable from the form itself - prevent = $this.data("disabled")?false:true; - } else { - // already in that state - if(prevent === $this.data("disabled")) { - return; - } - } - - if (prevent) - { - $this.find("input, textarea").each(function() { - if ($(this).closest("span.form")[0]) - return; - if($(this).attr("type") == "hidden") - return; - var val = $(this).val(); - if (val === "null" || val === null || $(this).attr("type") === "submit") - val = ""; - if($(this).hasClass("trueFalse")) { - if($(this).is(':checked')) - val = 'X'; - else - val = ' '; - } - - // convert \n to brs - escape all other html - val = val.replace(//g, ">").replace(/\n/g, "
"); - var thespan = $(''+val+''); - if($(this).parent().hasClass("ui-wrapper")) - $(this).parent().hide().wrap(thespan); - else - $(this).hide().wrap(thespan); - }); - // selects are handled slightly different - $this.find("select").each(function() { - if ($(this).closest("span.form")[0]) - return; - - var val = $(this).children(":selected").html(); - if (val === "null" || val === null) - val = ""; - - var thespan = $(''+val+''); - - // toggle switches work a little different - if($(this).hasClass("ui-toggle-switch")) { - $(this).prev().hide().wrap(thespan); - } - else { - $(this).hide().wrap(thespan); - } - }); - } - else - { - $this.find("span.form").each(function() { - // remove text and then unwrap - var ele = $(this).children("input,select,textarea,.ui-wrapper,.ui-toggle-switch").show().detach(); - $(this).before(ele); - $(this).remove(); - }); - } - - $this.data("disabled", prevent); - }; - - /** - * validate a given form - * @return true if the form has no invalid fields, false otherwise - */ - JsForm.prototype.validate = function() { - // get the prefix from the form if not given - //var prefix = this.options.prefix; - - // validation - $(".required,.regexp,.date,.mandatory,.number,.validate", this.element).change(); - - // check for invalid fields - if($(".invalid", this.element).length > 0) { - return false; - } - - return true; - }; - - /** - * fill a form based on a pojo. - * @param form the form - * @param data the data object used to fill the form - * @param prefix the optional prefix used to identify fields for this form - * @private - */ - JsForm.prototype._fill = function(form, data, prefix) { - // get the prefix from the form if not given - if(!prefix) { - prefix = this.config.prefix; - } - - this._clear(form, prefix); - - $(form).addClass("POJO"); - $(form).data("pojo", data); - - // fill base - this._fillData(form, data, prefix); - this._fillCollection(form, data, prefix); - }; - - /** - * @param container the container element - * @param data an array containing the the data - * @param prefix a prefix for each line of data - * @private - */ - JsForm.prototype._fillCollection = function(container, data, prefix) { - var that = this; - // fill collections - $(".collection", container).each(function() { - var container = $(this), - fieldname = $(this).attr("data-field"); - // only collections with the correct prefix - if(!data || !fieldname || fieldname.indexOf(prefix+".") !== 0) { - return; - } - - // data for the collection filling - var colData = null; - - var cname = fieldname; - // remove the prefix - if (prefix) { - cname = cname.substring(prefix.length + 1); - } - colData = that._get(data, cname); - - if(colData) { - // fill the collection - that._fillList(container, colData, cname); - } - }); - }; - - /** - * @param container the container element - * @param data an array containing the the data - * @param prefix a prefix for each line of data - * @param lineFunc function(line,cur) - can return false to skip the line - * @private - */ - JsForm.prototype._fillList = function(container, data, prefix, lineFunc) { - var tmpl = container.data("template"), - that = this; - if(!tmpl) { - return; - } - // clean out previous list - container.empty(); - - // not an array - if(!$.isArray(data)) { - return; - } - - // cut away any prefixes - only the fieldname is used - if(prefix.indexOf('.') !== -1) { - prefix = prefix.substring(prefix.lastIndexOf('.')+1); - } - - - // check if we need to sort the array - if($(container).hasClass("sort")) { - var sortField = $(container).attr("data-sort"); - if(sortField) { - switch($(container).attr("data-sorttype")) { - case 'alpha': - data.sort(); - break; - case 'alphainsensitiv': - data.sort(function(a,b){ - a = a[sortField]; - b = b[sortField]; - if(a) a = a.toLowerCase(); - if(b) b = b.toLowerCase(); - if(ab) - return 1; - return 0; - }); - break; - default: - data.sort(function(a,b){ - return a[sortField] - b[sortField]; - }); - } - // descending: reverse - if($(container).attr("data-sortdesc")) { - data.reverse(); - } - } - } - - if(!lineFunc) { - if($.isFunction(prefix)) { - lineFunc = prefix; - prefix = null; - } - } - - for(var i = 0; i < data.length; i++) { - var cur = data[i]; - var line = tmpl.clone(true); - // save current line - line.data("pojo", cur); - line.addClass("POJO"); - - if(lineFunc) { - if(lineFunc(line, cur) === false) { - continue; - } - } - - that._addCollectionControls(line); - - if(prefix) { - that._fillData(line, cur, prefix); - // enable collection controls - that._initCollection(line, prefix); - // fill with data - that._fillCollection(line, cur, prefix); - } - container.append(line); - - } - }; - - /** - * add controls into a collection entry(i.e. delete) - * @param line the new collection - * @private - */ - JsForm.prototype._addCollectionControls = function(line) { - var that = this; - - // enable controls on the line - if($.jsFormControls) { - $(line).jsFormControls(); - } - - $(".delete", line).click(function(){ - var ele = $(this).closest(".POJO"); - // trigger a callback - $(this).closest(".collection").trigger("deleteCollection", [ele, $(ele).data().pojo]); - ele.remove(); - }); - $(".sortUp", line).click(function(){ - // check if there is an up - var ele = $(this).closest(".POJO"); - var prev = ele.prev(".POJO"); - if(prev.size() === 0) { - // no previous element - return - return; - } - ele.detach(); - prev.before(ele); - // reorder (if possible) - that._reorder(ele); - }); - $(".sortDown", line).click(function(){ - // check if there is a down - var ele = $(this).closest(".POJO"); - var next = ele.next(".POJO"); - if(next.size() === 0) { - // no next element - return - return; - } - ele.detach(); - next.after(ele); - // reorder (if possible) - that._reorder(ele); - }); - - // if collection is sortable: refresh it - var container = $(line).closest(".collection"); - if(container.hasClass("sortable")&& $(container).sortable) { - container.sortable("refresh"); - } - }; - - /** - * Reorder a collection (actually its fields) - * @param ele one element of the collection or the collection itself - * @private - */ - JsForm.prototype._reorder = function(ele) { - if(!ele.attr("data-sort")) { - ele = ele.closest(".collection"); - } - - // get the field to use for sorting - var sortField = $(ele).attr("data-sort"); - if(!sortField || ($(ele).attr("data-sorttype") && $(ele).attr("data-sorttype") !== "number") || - ($(ele).attr("data-sortdesc") && $(ele).attr("data-sortdesc") !== "false")) { - return; - } - - // go through each child and get the pojo - var prio = 0; - $.each($(ele).children(), function(){ - var data = $(this).data("pojo"); - // no data yet - add one - if(!data) { - data = {}; - $(this).data("pojo", data); - } - - data[sortField] = prio++; - }); - }; - - /** - * render an object based on a string. - * Note: comma is a special char and cannot be used! - * @param obj the object - * @param skin the string to render with (i.e. id, ":", test) - * @private - */ - JsForm.prototype._renderObject = function(obj, skin) { - if(!skin || !obj) - return ""; - var that = this; - var ret = ""; - $.each(skin.split(","), function(){ - var val = this.trim(); - if(val.indexOf("'") === 0 || val.indexOf('"') === 0) { - ret += val.substring(1, val.length - 1); - } else { - ret += that._get(obj, val); - } - }); - return ret; - }; - - /** - * Retrieve a value from a given object by using dot-notation - * @param obj the object to start with - * @param the child to get (dot notation) - * @param create set to true and non-existant levels will be created (always returns non-null) - * @private - */ - JsForm.prototype._get = function(obj, expr, create) { - var ret, p, prm = "", i; - if(typeof expr === "function") { - return expr(obj); - } - if (!obj) { - return ""; - } - // reference the object itself - if(expr === "") - return obj; - - ret = obj[expr]; - if(!ret) { - try { - if(typeof expr === "string") { - prm = expr.split('.'); - } - - i = prm.length; - if(i) { - ret = obj; - while(ret && i--) { - p = prm.shift(); - // create the levels - if(create && !ret[p]) { - ret[p] = {}; - } - ret = ret[p]; - } - } - } catch(e) { /* ignore */ } - } - if(ret === null || ret === undefined) { - ret = ""; - } - // trim the return - if(ret.trim) { - return ret.trim(); - } - return ret; - }; - - - /** - * get the "parent" object of a given dot-notation. this will not return the actual - * element given in the dot notation but itws parent (i.e.: when using a.b.c -> it will return b) - * @param obj the object to start with - * @param the child to get (dot notation) - * @param create set to true and non-existant levels will be created (always returns non-null) - * @private - */ - JsForm.prototype._getParent = function(obj, expr, create) { - if(expr.indexOf('.') === -1) - return obj; - - expr = expr.substring(0, expr.lastIndexOf('.')); - return this._get(obj, expr, create); - }; - - /** - * helper function to get the number of a value - * @param num the string - * @returns a number or null - * @private - */ - JsForm.prototype._getNumber = function(num) { - if (!num) { - return null; - } - - if($.format) - return $.format.number(num); - - // either we have , (for komma) or a . and at least 3 following numbers (not a round komma) - if(num.indexOf(",") != -1 || (num.length - num.indexOf('.') > 3)) - { - num = num.replace(/\./g, "").replace(",", "."); - } - return Number(num); - }; - - /** - * checks if a variable is empty. This will check array, and whole objects. If a json object - * only contains empty "elements" then it is considered as empty. - * Empty for a number is 0/-1 - * Empty for a boolena is false - * - * @param pojo the pojo to check - * @returns {Boolean} true if it is empty - * @private - */ - JsForm.prototype._isEmpty = function(pojo) { - // boolean false, null, undefined - if(!pojo) { - return true; - } - - // array - if($.isArray(pojo)) { - // zero length - if(pojo.length === 0) { - return true; - } - - // check each element - for(var i = 0; i < pojo.length; i++) { - if(!this._isEmpty()) { - return false; - } - } - return true; - } - // an object - if($.isPlainObject(pojo)) { - if($.isEmptyObject(pojo)) { - return true; - } - - for(var f in pojo){ - if(!this._isEmpty(pojo[f])) { - return false; - } - } - return true; - } - - // a number - if(!isNaN(pojo)) { - if (Number(pojo) === 0 || Number(pojo) === -1) { - return true; - } - return false; - } - - // a string - return (pojo === "" || pojo === " "); - }; - - /** - * compare a pojo with a form. Takes special data definition classes into account: - *
    - *
  • number|currency: the content will be transformed into a number (default string
  • - *
  • transient: will be ignored
  • - *
  • prefix.fieldname.value: will create the whole object subtree
  • - *
- * @param start the element to start from (ie. the form or tr) - * @param pojo the pojo to write everything to - * @param prefix a prefix: only fields with the given prefix will be included in the pojo - * @private - */ - JsForm.prototype._pojoDifferFromInput = function (start, prefix, pojo) { - var differs = false; - $("input,select,textarea", start).each(function(){ - // skip if we found a dif - if(differs) { - return; - } - - var name = $(this).attr("name"); - // empty name - ignore - if (!name) { - return; - } - - // skip grayed (=calculated) or transient fields - if($(this).hasClass("transient")) { - return; - } - - // must start with prefix - if(name.indexOf(prefix + ".") !== 0) { - return; - } - - // cut away the prefix - name = name.substring((prefix+".").length); - - // skip empty - if(name.length < 1) { - return; - } - - var val = $(this).val(); - // set empty numbers to null - if(val === "" && ($(this).hasClass("number") || $(this).hasClass("dateFilter")|| $(this).hasClass("dateTimeFilter"))) { - val = null; - } - if ($(this).hasClass("number") || $(this).hasClass("currency")) { - val = that._getNumber(val); - if(isNaN(val)) { - val = 0; - } - } - if($(this).attr("type") === "checkbox" || $(this).attr("type") === "CHECKBOX") { - val = $(this).is(':checked'); - } - - // check if we have a . - if so split - if (name.indexOf(".") === -1) - { - // the vals differ - if(pojo[name] !== val) { - differs = true; - } - } - else - { - var parts = name.split("."); - - var d0 = pojo[parts[0]]; - var d1, d2; - - if (!d0) { - differs = true; - return; - } - - if (parts.length === 2) { - // the vals differ - if(d0[parts[1]] !== val) { - differs = true; - } - } else if (parts.length === 3) { - d1 = d0[parts[1]]; - // the vals differ - if(d1[parts[2]] !== val) { - differs = true; - } - } else if (parts.length === 4) - { - d1 = d0[parts[1]]; - d2 = d1[parts[2]]; - // the vals differ - if(d2[parts[3]] !== val) { - differs = true; - } - } - // more should not be necessary - } - }); - return differs; - }; - - /** - * Compares a pojo with form fields - * @param pojo the pojo to compare with - * @return true if any change between formfields and the pojo is found - */ - JsForm.prototype.equals = function(pojo) { - var that = this; - var form = this.element; - var prefix = this.options.prefix; - - // check the base - if(this._pojoDifferFromInput(form, prefix, pojo)) { - return false; - } - - var differs = false; - - // check for invalid fields - if($(".invalid", form).length > 0) { - return false; - } - - $(".collection", form).each(function() { - if(differs) { - return; - } - - var fieldname = $(this).attr("data-field"); - // only collections with the correct prefix - if(!fieldname || fieldname.indexOf(prefix+".") !== 0) { - return; - } - - fieldname = fieldname.substring((prefix+".").length); - if(fieldname.length < 1) { - return; - } - - var childCounter = 0; - // go through all direct childs - each one is an element - $(this).children().each(function(){ - if(differs) { - return; - } - - // check if we have more elements - if(childCounter >= pojo[fieldname].length) { - differs = true; - return; - } - - var ele = pojo[fieldname][childCounter++]; - if(that._pojoDifferFromInput($(this), fieldname, ele)) { - differs = true; - } - }); - - if(childCounter < pojo[fieldname].length) { - differs = true; - } - }); - - // we want to know if its equals -> return not - return !differs; - }; - - /** - * fill the form with data. - *
    - *
  • <span class="field">prefix.fieldname</span> - *
  • <input name="prefix.fieldname"/> - *
  • <a class="field" href="prefix.fieldname">linktest</a> - *
  • <img class="field" src="prefix.fieldname"/> - *
- * @param data {object} the data - */ - JsForm.prototype.fill = function(pojo) { - // clear first - this.clear(); - // set the new data - this.options.data = pojo; - // fill everything - this._fill(this.element, this.options.data, this.options.prefix); - }; - - /** - * reset a form with the last data, overwriting any changes. - */ - JsForm.prototype.reset = function() { - // clear first - this.clear(); - // fill everything - this._fill(this.element, this.options.data, this.options.prefix); - }; - - /** - * Clear all fields in a form - */ - JsForm.prototype.clear = function() { - // clear first - this._clear(this.element, this.options.prefix); - }; - - /** - * destroy the jsform and its resources. - * @private - */ - JsForm.prototype.destroy = function( ) { - return $(this.element).each(function(){ - $(window).unbind('.jsForm'); - $(this).removeData('jsForm'); - }); - }; - - // init and call methods - $.fn.jsForm = function ( method ) { - // Method calling logic - if ( typeof method === 'object' || ! method ) { - return this.each(function () { - if (!$(this).data('jsForm')) { - $(this).data('jsForm', new JsForm( this, method )); - } - }); - } else { - var args = Array.prototype.slice.call( arguments, 1 ), - jsForm; - // none found - if(this.length === 0) { - return null; - } - // only one - return directly - if(this.length === 1) { - jsForm = $(this).data('jsForm'); - if (jsForm) { - if(method.indexOf("_") !== 0 && jsForm[method]) { - var ret = jsForm[method].apply(jsForm, args); - return ret; - } - - $.error( 'Method ' + method + ' does not exist on jQuery.jsForm' ); - return false; - } - } - - return this.each(function () { - jsForm = $.data(this, 'jsForm'); - if (jsForm) { - if(method.indexOf("_") !== 0 && jsForm[method]) { - return jsForm[method].apply(jsForm, args); - } else { - $.error( 'Method ' + method + ' does not exist on jQuery.jsForm' ); - return false; - } - } - }); - } - }; - - /** - * global jsForm function for intialisation - */ - $.jsForm = function ( name, initFunc ) { - var jsForms = JSFORM_MAP[name]; - // initFunc is a function -> initialize - if($.isFunction(initFunc)) { - // call init if already initialized - if(jsForms) { - $.each(jsForms, function(){ - initFunc(this, $(this.element)); - }); - } - - // remember for future initializations - JSFORM_INIT_FUNCTIONS[name] = initFunc; - } else { - // call init if already initialized - if(jsForms) { - var method = initFunc; - var args = Array.prototype.slice.call( arguments, 2 ); - $.each(portlets, function(){ - this[method].apply(this, args); - }); - } - } - }; - -})( jQuery, window ); - -/** - * jquery.jsForm.controls - * ---------------------- - * UI Controls and Field validation - * @version 1.0 - * @class - * @author Niko Berger - * @license MIT License GPL - */ -;(function( $, window, undefined ){ - "use strict"; - - var JSFORM_INIT_FUNCTIONS = {}, // remember initialization functions - JSFORM_MAP = {}; // remember all forms - - /** - * handlebars extension (+simple date format) - */ - if(typeof Handlebars !== "undefined") { - Handlebars.registerHelper("currency", function(data){ - if(!data) - return "0"; - return $.jsFormControls.Format.currency(data); - }); - Handlebars.registerHelper("dec", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.decimal(data); - }); - Handlebars.registerHelper("percent", function(data){ - if(!data) - return "0"; - return $.jsFormControls.Format.decimal(data*100); - }); - Handlebars.registerHelper("date", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.date(data); - }); - Handlebars.registerHelper("time", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.time(data); - }); - Handlebars.registerHelper("datetime", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.dateTime(data); - }); - Handlebars.registerHelper("dateTime", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.dateTime(data); - }); - Handlebars.registerHelper("timespan", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.humanTime(data); - }); - Handlebars.registerHelper("byte", function(data){ - if(!data) - return ""; - return $.jsFormControls.Format.byte(data); - }); - } - - function JsFormControls(element) { - this.element = element; - - // init the dom functionality - this._domInit(); - } - - /** - * init the dom. This can be called multiple times. - * this will also enable "add", "insert" and "delete" for collections - * @private - */ - JsFormControls.prototype._domInit = function() { - var location = $(this.element); - - // validation - // check required (this is the first check) - location.find("input.mandatory,textarea.mandatory").on("keyup", function(){ - // check for "null" as value as well - if($(this).val().length > 0 && $(this).val() !== "null") { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - }); - - location.find("input.mandatory,textarea.mandatory").on("change", function(){ - if($(this).hasClass("object")) { - if($(this).data().pojo) { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - return; - } - // check for "null" as value as well - if($(this).val().length > 0 && $(this).val() !== "null") { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - }).change(); - - location.find("select.mandatory").change(function(){ - // check for "null" as value as well - if($(this).val() !== null && $(this).val() !== "null" && $(this).val().length > 0) { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - }).change(); - - // show datepicker for all inputs - location.find("input.date").each(function(){ - var format = $(this).attr("data-format"); - // only if jquery ui is available - if($(this).datepicker) { - if(format) - $(this).datepicker({dateFormat: format}); - else - $(this).datepicker(); - } - }); - - - // input validation (number) - var numberRegexp = new RegExp("^[0-9]+$"); - location.find("input.number").keyup(function(){ - var val = $(this).val(); - if(val.length > 0) { - if($(this).hasClass("autoclean")) { - $(this).val(val.replace(/[^0-9]/g, "")); - } - else { - if(numberRegexp.test($(this).val())) { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - } - } - }).keyup(); - - // regular expression - location.find("input.regexp").each(function(){ - if($(this).hasClass("autoclean")) { - $(this).data("regexp", new RegExp($(this).attr("data-regexp"), "g")); - } - else { - $(this).data("regexp", new RegExp($(this).attr("data-regexp"))); - } - - $(this).keyup(function(){ - var val = $(this).val(); - if(val.length > 0) { - var regexp = $(this).data("regexp"); - if($(this).hasClass("autoclean")) { - $(this).val(val.replace(regexp, "")); - } - else { - if(regexp.test($(this).val())) { - $(this).addClass("valid").removeClass("invalid"); - } else { - $(this).removeClass("valid").addClass("invalid"); - } - } - } else { - // if not mandatory: nothing is valid - if(!$(this).hasClass("mandatory")) { - $(this).removeClass("invalid").addClass("valid"); - } - } - }).keyup(); - $(this).change(function(){ - $(this).keyup(); - }); - }); - - /* rotatestate stontrol */ - location.find("input.rotatestate").each(function(){ - var states = $(this).attr("data-state-values"); - var defaultClass = $(this).attr("data-state-class"); - // no need to continue if there are no states - if(!states) { - return; - } - - try { - states = JSON.parse(states); - } catch (ex) { - // do not need to continue if we cannot parse the states - return; - } - - var stateControl = $(""); - if($(this).attr("title")) { - stateControl.attr("title", $(this).attr("title")); - } - if($(this).attr("data-state-style")) { - stateControl.attr("style", $(this).attr("data-state-style")); - } - stateControl.data("states", states); - stateControl.data("control", this); - stateControl.data("activeState", null); - $(this).data("control", stateControl); - if(defaultClass) { - stateControl.addClass(defaultClass); - } - - // click on the control starts rotating - stateControl.click(function(){ - var cState = $(this).data().activeState; - var cStates = $(this).data().states; - var control = $(this).data().control; - var newState = null; - - if(cState !== null) { - // go to the 'next' state - for(var i = 0; i < cStates.length; i++) { - if(cStates[i].value === cState.value) { - // last element - if(i === cStates.length - 1) { - newState = cStates[0]; - } else { - newState = cStates[i+1]; - } - break; - } - } - } else { - // no state yet - set the first entry as state - newState = cStates[0]; - } - - $(control).attr("value", newState.value); - // trigger change - $(control).change(); - }); - - // make sure to update state if the value is changed - $(this).change(function(){ - var control = $($(this).data().control); - var cState = control.data().activeState; - var cStates = control.data().states; - - if(cState !== null) { - // remove "old state" - control.removeClass(cState['class']); - } - - // add new State - var val = $(this).val(); - $.each(cStates, function(){ - if(this.value === val) { - control.data().activeState = this; - if(this.title) { - control.attr("title", this.title); - } - control.addClass(this['class']); - return false; - } - }); - }); - - // trigger initial state - $(this).change(); - $(this).after(stateControl); - $(this).hide(); - }); - }; - - - /** - * validate a given form - * @return true if the form has no invalid fields, false otherwise - */ - JsFormControls.prototype.validate = function() { - // validation - $(".required,.regexp,.date,.mandatory,.number,.validate", this.element).change(); - - // check for invalid fields - if($(".invalid", this.element).length > 0) { - return false; - } - - return true; - }; - - // init and call methods - $.fn.jsFormControls = function ( method ) { - // Method calling logic - if ( typeof method === 'object' || ! method ) { - return this.each(function () { - if (!$(this).data('jsFormControls')) { - $(this).data('jsFormControls', new JsFormControls( this, method )); - } - }); - } else { - var args = Array.prototype.slice.call( arguments, 1 ); - - // only one - return directly - if(this.length == 1) { - var jsFormControls = $(this).data('jsFormControls'); - if (jsFormControls) { - if(method.indexOf("_") !== 0 && jsFormControls[method]) { - var ret = jsFormControls[method].apply(jsFormControls, args); - return ret; - } - - $.error( 'Method ' + method + ' does not exist on jQuery.jsFormControls' ); - return false; - } - } - - return this.each(function () { - var jsFormControls = $.data(this, 'jsFormControls'); - if (jsFormControls) { - if(method.indexOf("_") !== 0 && jsFormControls[method]) { - return jsFormControls[method].apply(jsFormControls, args); - } else { - $.error( 'Method ' + method + ' does not exist on jQuery.jsFormControls' ); - return false; - } - } - }); - } - }; - - /** - * global jsForm function for intialisation - */ - $.jsFormControls = function ( name, initFunc ) { - var jsForms; - // initFunc is a function -> initialize - if($.isFunction(initFunc)) { - // call init if already initialized - jsForms = JSFORM_MAP[name]; - if(jsForms) { - $.each(jsForms, function(){ - initFunc(this, $(this.element)); - }); - } - - // remember for future initializations - JSFORM_INIT_FUNCTIONS[name] = initFunc; - } else { - // call init if already initialized - jsForms = JSFORM_MAP[name]; - if(jsForms) { - var method = initFunc; - var args = Array.prototype.slice.call( arguments, 2 ); - $.each(portlets, function(){ - this[method].apply(this, args); - }); - } - } - }; - - $.jsFormControls.Format = { - /** - * format a string based on teh classes in a dom element - */ - format: function(ele, cdata) { - if($(ele).hasClass("dateTime")) { - return $.jsFormControls.Format.dateTime(cdata); - } if($(ele).hasClass("datetime")) { - return $.jsFormControls.Format.dateTime(cdata); - } else if($(ele).hasClass("date")) { - return $.jsFormControls.Format.date(cdata); - } else if($(ele).hasClass("currency")) { - return $.jsFormControls.Format.currency(cdata); - } else if($(ele).hasClass("byte")) { - return $.jsFormControls.Format.byte(cdata); - } else if($(ele).hasClass("number")) { - return $.jsFormControls.Format.decimal(cdata); - } - - return cdata; - }, - - /** - * format boolean into an ui-icon - * @param value true or false - * @returns the ui-icon span - */ - checkBox: function(row, cell, value, columnDef, dataContext) { - // cleanup parameters (direct call vs. slickgrid) - if(typeof value === "undefined") { - value = row; - row = null; - } - - if(value) { - return ' '; - } else { - return ' '; - } - - return value; - }, - - - /** - * @private - */ - _getNumber: function(num) { - if (!num) { - return null; - } - - if($.format) - return $.format.number(num); - - // either we have , (for komma) or a . and at least 3 following numbers (not a rounden komma) - if(num.indexOf(",") !== -1 || (num.length - num.indexOf('.') > 3)) - { - num = num.replace(/\./g, "").replace(",", "."); - } - return Number(num); - }, - - - /** - * @private - */ - _pad: function(val) { - var o = (val < 10) ? "0" : ""; - o += val; - return o; - }, - - - byte: function(bytes) { - if (bytes === "" || !bytes || isNaN(bytes)) { - return bytes; - } - - var unit = 1024; - if (bytes < unit) return bytes + " B"; - var exp = Math.floor(Math.log(bytes) / Math.log(unit)); - var pre = "KMGTPE".charAt(exp-1) + "B"; - return Math.round(bytes*10 / Math.pow(unit, exp))/10 + pre; - }, - - /** - * @private - */ - decimal: function(num) { - if (num === "" || !num || isNaN(num)) { - return num; - } - - if($.format) - return $.format.number(num, $(document).data().i18n.number.format); - - var comma = 0; - if (Math.abs(num - Math.floor(num)) > 0.001) { - comma = 2; - } - // convert to a nice number for display - var n = num, - c = isNaN(c = Math.abs(comma)) ? 2 : comma, - d = ',', // decimal d == undefined ? "," : d, - t = '.', // thousand: t == undefined ? "." : t, - i = parseInt(n = Math.abs( +n || 0).toFixed(c), 10) + "", - j = (j = i.length) > 3 ? j % 3 : 0; - return (num<0 ? "-" : "") + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); - }, - - - /** - * @private - */ - currency: function(row, cell, cellvalue, columnDef, dataContext) { - // cleanup parameters (direct call vs. slickgrid) - if(!cellvalue || isNaN(cellvalue)) { - cellvalue = row; - row = null; - } - - if(!cellvalue) { - if(cell) { - return " "; - } - return ""; - } - - return $.jsFormControls.Format.decimal(cellvalue); - }, - - /** - * @private - */ - dateTime: function(row, cell, cellvalue, columnDef, dataContext) { - // cleanup parameters (direct call vs. slickgrid) - if(!cellvalue || isNaN(cellvalue)) { - cellvalue = row; - row = null; - } - - if(!cellvalue) { - if(cell) { - return " "; - } - return ""; - } - - return (this.date(cellvalue) + " " + this.time(cellvalue)); - }, - - /** - * @private - */ - date: function(row, cell, cellvalue, columnDef, dataContext) { - - // cleanup parameters (direct call vs. slickgrid) - if(!cellvalue || isNaN(cellvalue)) { - cellvalue = row; - row = null; - } - - if(!cellvalue) { - if(cell) { - return " "; - } - return ""; - } - - var d = new Date(); - d.setTime(cellvalue); - var year = d.getYear(); - if(year < 1900) { - year += 1900; - } - - if($.format) - return $.format.date(d, $(document).data().i18n.date.shortDateFormat); - else - return this._pad(d.getDate()) + "." + this._pad((d.getMonth()+1)) + "." + this._pad(year); - }, - - /** - * @private - */ - time: function(row, cell, value, columnDef, dataContext) { - // cleanup parameters (direct call vs. slickgrid) - if(!value) { - value = row; - row = null; - } - - if(!value) { - if(cell) { - return " "; - } - return ""; - } - - var d = new Date(); - d.setTime(value); - if($.format) - return $.format.date(d, $(document).data().i18n.date.timeFormat); - else - return this._pad(d.getHours()) + ":" + this._pad(d.getMinutes()); // + ":" + pad(d.getSeconds()); don't need seconds - }, - - /** - * - * @param value a string value to format - * @param allowms true to allow komma (i.e. 00.00) - * @return something in the form of 00:00.00 - * @private - */ - timespan: function(row, cell, value, columnDef, dataContext, allowcomma) { - // cleanup parameters (direct call vs. slickgrid) - if(!value) { - value = row; - allowcomma = cell; - row = null; - cell = null; - } - - var tokens = value.split(":"); - // check each token - for(var i=0; i 0) { - out += h + "h "; - // ignore seconds and milliseconds if we have hours - s = 0; - value = 0; - } - if (m > 0) { - out += m + "m "; - // ignore milliseconds - value = 0; - } - if (s > 0) { - out += s + "s "; - value = 0; - } - - if (value > 0) { - out += value + "ms"; - } - // trim output - return out.trim(); - } - }; - -})( jQuery, window ); - - -/** - * @returns the trimmed string - */ -String.prototype.trim = function() { - return this.replace(/^\s+|\s+$/g, ""); -}; - -/* check start of a string */ -String.prototype.startsWith = function(str) { - if((this === null) || (this.length <= 0)) - return false; - if((str === null) || (str == "null") || (str.length <= 0)) - return false; - if(this.substr(0, str.length) == str) - return true; - return false; -}; - -/* check start of a string */ -String.prototype.startsWithIgnoreCase = function(str) { - if((this === null) || (this.length <= 0)) - return false; - if((str === null) || (str == "null") || (str.length <= 0)) - return false; - if(this.substr(0, str.length).toLowerCase() == str.toLowerCase()) - return true; - return false; -}; - -/* check end of a string */ -String.prototype.endsWith = function(str) { - if((this === null) || (this.length <= 0)) - return false; - if((str === null) || (str == "null") || (str.length <= 0) || (str.length > this.length)) - return false; - if(this.substr(this.length - str.length) == str) - return true; - return false; -}; \ No newline at end of file diff --git a/dist/jquery.jsForm-1.0.7.js b/dist/jquery.jsForm-1.0.8.js similarity index 96% rename from dist/jquery.jsForm-1.0.7.js rename to dist/jquery.jsForm-1.0.8.js index 751f406..e08fc12 100644 --- a/dist/jquery.jsForm-1.0.7.js +++ b/dist/jquery.jsForm-1.0.8.js @@ -570,11 +570,6 @@ // cut away the prefix name = name.substring((prefix+".").length); - // skip empty names - if(name.length < 1) { - pojo = $(this).val(); - return false; - } var val = $(this).val(); @@ -627,6 +622,12 @@ val = ($(this).val() === "true"); } + // handle simple collection + if(name.length < 1) { + pojo = val; + return false; + } + // check if we have a . - if so split if (name.indexOf(".") === -1) { diff --git a/dist/jquery.jsForm.1.0.5.min.js b/dist/jquery.jsForm.1.0.5.min.js deleted file mode 100644 index 22f65f1..0000000 --- a/dist/jquery.jsForm.1.0.5.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * jQuery.jsForm v1.0.5 | (c) 2013 Niko Berger http://www.gargan.org/ - * Usage: https://github.com/corinis/jsForm - */ -(function(t,e,a){"use strict";function i(e,a){var i=t(e);this.options=t.extend({},{controls:!0,data:null,prefix:"data",validateHidden:!0},a),!i.attr("data-prefix")||"data"!==this.options.prefix&&""!==this.options.prefix||""!==i.attr("data-prefix")&&(this.options.prefix=i.attr("data-prefix")),this.element=e,this._init()}var s={},n={};i.prototype._init=function(){if(this._domInit(),this.options.controls)if(t.jsFormControls)t(this.element).jsFormControls();else try{"undefined"!=typeof console&&console.log("jquery.JsForm.controls not available!")}catch(e){}this._fill(this.element,this.options.data,this.options.prefix)},i.prototype._domInit=function(){var e=t(this.element),a=this,i=this.options.prefix;a._initCollection(e,i)},i.prototype._initCollection=function(e,a){var i={},s=this;t(e).data().collections=i,t(".collection",e).each(function(){var e=t(this).attr("data-field");if(e&&0===e.indexOf(a+".")){var n=t(this),r=i[e];if(r?r.push(n):i[e]=[n],s._initList(n),!n.hasClass("ui-sortable")&&n.hasClass("sortable")&&n.sortable){var o=n.attr("data-sortable");o=o?JSON.parse(o):{},n.sortable(o),n.on("sortstop",function(){s._reorder(n)})}}}),t(".add",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections")||(t(this).data().collections=i[e],t(this).click(function(a){a.preventDefault(),t.each(t(this).data("collections"),function(){var a=t(this).data("template");if(a){var i=a.clone(!0);t(this).append(i),t(i).addClass("POJO"),t(i).data("pojo",{}),s._addCollectionControls(i),t(this).trigger("addCollection",[i,t(i).data().pojo]),s._fillData(i,t(i).data().pojo,e.substring(e.indexOf(".")+1)),s._initCollection(i,e.substring(e.indexOf(".")+1)),t(this).trigger("postAddCollection",[i,t(i).data().pojo])}})})))}),t(".insert",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections")||(t(this).data("collections",i[t(this).attr("data-field")]),t(this).on("insert",function(a,i){if(i||(i=t(this).data().pojo),i){var n=t(this).data("beforeInsert");n&&t.isFunction(n)&&!(i=n(i))||(t.each(t(this).data("collections"),function(){var a=t(this).data("template");if(a){var n=a.clone(!0);n.addClass("POJO"),n.data().pojo=i,s._addCollectionControls(n),s._initCollection(n),t(this).trigger("addCollection",[n,t(n).data().pojo]),s._fillData(n,i,e.substring(e.indexOf(".")+1)),t(this).append(n)}}),t(this).val(""),t(this).data().pojo=null,t(this).focus())}})))}),t(".insertAction",e).each(function(){var e=t(this).attr("data-field");if(e&&!t(this).data("inserter")){var a=t(this).parent().find(".insert");a&&(t(this).data("inserter",a),t(this).click(function(e){return e.preventDefault(),t(this).data("inserter").trigger("insert"),!1}))}}),t("input.object",e).each(function(){t(this).on("update",function(){var e=t(this).data().pojo;e&&t(this).attr("data-display")&&t(this).val(s._renderObject(e,t(this).attr("data-display")))})}),t("input.blob",e).each(function(){if("file"===t(this).attr("type")){var e=t(this);t(this).on("change",function(a){var i=t(this).val().split(/\\/).pop();e.data("name",i);var s=a.target.files;s&&s.length&&t.each(s,function(){var a=new FileReader;a.onload=function(t){e.data("blob",t.target.result)},a.readAsDataURL(this),t(this).trigger("fileChange")})})}}),t(".manage",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections",i[e]),t(this).click(function(){var a=t(this).attr("data-service"),i=t(this).data("collections"),n=t(this),r=t(this).attr("data-display");r&&(r=r.split(",")),DataUtils.run(a,function(a){var o=t('');o.data("collections",i),n.data("select",o),t.each(a,function(){var e=this,a="";if(r)for(var s=0;r.length>s;s++)a+=e[r[s]]+" ";else a=e;var n=t('");t(i).each(function(){t(this).children().each(function(a,i){e.id===t(i).data("pojo").id&&n.attr("selected","selected")})}),o.append(n),n.data("pojo",e)}),n.after(o),n.hide(),o.multiselect({autoOpen:!0,open:function(){t(this).multiselect("widget").css("top",t(o).next().offset().top),t(this).multiselect("widget").css("left",t(o).next().offset().left),t(o).next().hide()},close:function(){n.show(),o.remove(),t(this).multiselect("destroy")}}).multiselectfilter().bind("multiselectclick multiselectcheckall multiselectuncheckall",function(){var a=t.map(t(this).multiselect("getChecked"),function(e){return t("option[value='"+e.value+"']",o).data("pojo")});t.each(t(o).data("collections"),function(){s._fillList(t(this),a,e)}),n.hide(),t(o).next().show(),t(this).multiselect("widget").css("top",t(o).next().offset().top),t(this).multiselect("widget").css("left",t(o).next().offset().left),t(o).next().hide()})})}))})},i.prototype._initList=function(t){if(!t.data("template")){var e=t.children().detach();e.removeAttr("id"),t.data("template",e)}},i.prototype._clear=function(e,a){a||(a=this.options.prefix),t(e).removeData("pojo"),t("input,select,textarea",e).each(function(){var e=t(this).attr("name");e&&0===e.indexOf(a+".")&&(e=e.substring((a+".").length),1>e.length||(t(this).removeData("pojo"),"checkbox"===t(this).attr("type")?t(this).prop("checked",!1):t(this).val(""),t(this).hasClass("blob")&&t(this).removeData("blob"),t(this).is("select")&&(t('option[selected="selected"]',this).removeAttr("selected"),t("option:first",this).attr("selected",!0),t(this).val(t("option:first",this).val()).change()),t(this).change()))}),t(".collection",e).each(function(){var e=t(this).attr("data-field");e&&0===e.indexOf(a+".")&&t(this).empty()})},i.prototype._createPojoFromInput=function(e,i,s){var n=null,r=this;return t(e).data("pojo")&&(n=t(e).data("pojo")),n&&t.extend(!0,s,n),t(e).find("input,select,textarea").each(function(){var e=t(this).attr("name");if(e&&!t(this).hasClass("transient")&&0===e.indexOf(i+".")){if(t(this).trigger("validate",!0),e=e.substring((i+".").length),1>e.length)return s=t(this).val(),!1;var n=t(this).val();if(t(this).hasClass("emptynull")?(""===n||""===n.trim())&&(n=null):t(this).hasClass("object")||t(this).hasClass("POJO")?n=t(this).data("pojo"):t(this).hasClass("blob")?n=t(this).data("blob"):""===n&&(t(this).hasClass("number")||t(this).hasClass("dateFilter")||t(this).hasClass("dateTimeFilter"))&&(n=null),t(this).hasClass("percent")&&(n=r._getNumber(n),isNaN(n)?n=0:n/=100),(t(this).hasClass("number")||t(this).hasClass("currency"))&&(n=r._getNumber(n),isNaN(n)&&(n=0)),("checkbox"===t(this).attr("type")||"CHECKBOX"===t(this).attr("type"))&&(n=t(this).is(":checked")),-1===e.indexOf("."))s[e]=n;else{var o,l,h=e.split("."),c=s[h[0]];c&&t.isPlainObject(c)||(s[h[0]]={},c=s[h[0]]),2===h.length?c[h[1]]=n:3===h.length?(o=c[h[1]],o===a&&(o={},c[h[1]]=o),o[h[2]]=n):4===h.length&&(o=c[h[1]],l=o[h[2]],l===a&&(l={},o[h[2]]=l),o[h[2]]=n,l[h[3]]=n)}}}),s},i.prototype._fillData=function(e,i,s){var n=this,r=t(e);r.find(".field").each(function(){var e=t(this).data("name");if(e||("A"===this.nodeName.toUpperCase()?(e=t(this).attr("href"),t(this).attr("href","#")):"IMG"===this.nodeName.toUpperCase()?(e=t(this).attr("src"),0===e.indexOf("#")&&(e=e.substring(1)),t(this).attr("src","#")):e=t(this).text(),t(this).data("name",e),t(this).show()),!s||e.indexOf(s+".")>=0){var a=e;s&&(a=a.substring(s.length+1));var r=n._get(i,a);r||(r=""),t(this).hasClass("percent")&&!isNaN(r)&&(r=100*Number(r)),t.jsFormControls&&(r=t.jsFormControls.Format.format(this,r)),"A"===this.nodeName.toUpperCase()?t(this).attr("href",r):"IMG"===this.nodeName.toUpperCase()?t(this).attr("src",r):"DIV"===this.nodeName.toUpperCase()?t(this).html(r):t(this).text(r)}}),t("input",r).each(function(){var e=t(this).attr("name");if(e&&"file"!=t(this).attr("type")&&(!s||e.indexOf(s+".")>=0)){var a=e;s&&(a=a.substring(s.length+1));var r=n._get(i,a);t(this).hasClass("percent")&&!isNaN(r)?r=100*Number(r):t.isPlainObject(r)&&(t(this).data().pojo=r,t(this).addClass("POJO"),r=n._renderObject(r,t(this).attr("data-display"))),"checkbox"===t(this).attr("type")?(t(this).prop("checked",r===!0||"true"===r),t(this).change()):(r||(r=""),t.jsFormControls&&(r=t.jsFormControls.Format.format(this,r)),t(this).val(r),t(this).change())}}),t("select",r).each(function(){var e=t(this).attr("name");if(e&&(!s||e.indexOf(s+".")>=0)){var r=e;s&&(r=r.substring(s.length+1)),t(this).children("option").removeAttr("selected");var o=n._get(i,r);if(o.id)return t(this).children("option[value='"+o.id+"']").attr("selected",!0),t(this).val(o.id).change(),a;t(this).children("option[value='"+o+"']").attr("selected",!0),t(this).val(o).change()}}),t("textarea",r).each(function(){var e=t(this).attr("name");if(e&&(!s||e.indexOf(s+".")>=0)){var a=e;s&&(a=a.substring(s.length+1)),t(this).val(n._get(i,a)),t(this).change()}})},i.prototype.get=function(e){var a=t(this.element),i=this,s=this.options.data,n=this.options.prefix,r={};s&&t.isPlainObject(s)&&(r=s),i._createPojoFromInput(a,n,r);var o=!1;return this.options.validateHidden?a.find(".invalid").each(function(){return o=!0,t(this).focus(),!1}):a.find(".invalid").filter(":visible").each(function(){return o=!0,t(this).focus(),!1}),this._getCollection(a,n,r,e)&&(o=!0),!e&&o?null:r},i.prototype._getCollection=function(e,a,i,s){var n=this,r=!1;return e.find(".collection").each(function(){if(s||!r){var e=t(this).attr("data-field");if(e&&0===e.indexOf(a+".")&&(e=e.substring((a+".").length),!(1>e.length))){var o=n._getParent(i,e,!0);-1!==e.indexOf(".")&&(e=e.substring(e.lastIndexOf(".")+1)),o[e]=[],t(this).children().each(function(){if(s||!r){var a={};a=n._createPojoFromInput(t(this),e,a),n._getCollection(t(this),e,a,s),n._isEmpty(a)?t(".invalid",this).removeClass("invalid"):(t(".invalid",this).length>0&&(r=!0),o[e].push(a))}})}}}),r},i.prototype.getData=function(){return this.options.data||(this.options.data={}),this.options.data},i.prototype.preventEditing=function(e){var i=t(this.element);if(e===a)e=i.data("disabled")?!1:!0;else if(e===i.data("disabled"))return;e?(i.find("input, textarea").each(function(){if(!t(this).closest("span.form")[0]&&"hidden"!=t(this).attr("type")){var e=t(this).val();("null"===e||null===e||"submit"===t(this).attr("type"))&&(e=""),t(this).hasClass("trueFalse")&&(e=t(this).is(":checked")?"X":" "),e=e.replace(//g,">").replace(/\n/g,"
");var a=t(''+e+"");t(this).parent().hasClass("ui-wrapper")?t(this).parent().hide().wrap(a):t(this).hide().wrap(a)}}),i.find("select").each(function(){if(!t(this).closest("span.form")[0]){var e=t(this).children(":selected").html();("null"===e||null===e)&&(e="");var a=t(''+e+"");t(this).hasClass("ui-toggle-switch")?t(this).prev().hide().wrap(a):t(this).hide().wrap(a)}})):i.find("span.form").each(function(){var e=t(this).children("input,select,textarea,.ui-wrapper,.ui-toggle-switch").show().detach();t(this).before(e),t(this).remove()}),i.data("disabled",e)},i.prototype.validate=function(){return t(".required,.regexp,.date,.mandatory,.number,.validate",this.element).change(),t(".invalid",this.element).length>0?!1:!0},i.prototype._fill=function(e,a,i){i||(i=this.config.prefix),this._clear(e,i),t(e).addClass("POJO"),t(e).data("pojo",a),this._fillData(e,a,i),this._fillCollection(e,a,i)},i.prototype._fillCollection=function(e,a,i){var s=this;t(".collection",e).each(function(){var e=t(this),n=t(this).attr("data-field");if(a&&n&&0===n.indexOf(i+".")){var r=null,o=n;i&&(o=o.substring(i.length+1)),r=s._get(a,o),r&&s._fillList(e,r,o)}})},i.prototype._fillList=function(e,a,i,s){var n=e.data("template"),r=this;if(n&&(e.empty(),t.isArray(a))){if(-1!==i.indexOf(".")&&(i=i.substring(i.lastIndexOf(".")+1)),t(e).hasClass("sort")){var o=t(e).attr("data-sort");if(o){switch(t(e).attr("data-sorttype")){case"alpha":a.sort();break;case"alphainsensitiv":a.sort(function(t,e){return t=t[o],e=e[o],t&&(t=t.toLowerCase()),e&&(e=e.toLowerCase()),e>t?-1:t>e?1:0});break;default:a.sort(function(t,e){return t[o]-e[o]})}t(e).attr("data-sortdesc")&&a.reverse()}}s||t.isFunction(i)&&(s=i,i=null);for(var l=0;a.length>l;l++){var h=a[l],c=n.clone(!0);c.data("pojo",h),c.addClass("POJO"),s&&s(c,h)===!1||(r._addCollectionControls(c),i&&(r._fillData(c,h,i),r._initCollection(c,i),r._fillCollection(c,h,i)),e.append(c))}}},i.prototype._addCollectionControls=function(e){var a=this;t.jsFormControls&&t(e).jsFormControls(),t(".delete",e).click(function(){var e=t(this).closest(".POJO");t(this).closest(".collection").trigger("deleteCollection",[e,t(e).data().pojo]),e.remove()}),t(".sortUp",e).click(function(){var e=t(this).closest(".POJO"),i=e.prev(".POJO");0!==i.size()&&(e.detach(),i.before(e),a._reorder(e))}),t(".sortDown",e).click(function(){var e=t(this).closest(".POJO"),i=e.next(".POJO");0!==i.size()&&(e.detach(),i.after(e),a._reorder(e))});var i=t(e).closest(".collection");i.hasClass("sortable")&&t(i).sortable&&i.sortable("refresh")},i.prototype._reorder=function(e){e.attr("data-sort")||(e=e.closest(".collection"));var a=t(e).attr("data-sort");if(!(!a||t(e).attr("data-sorttype")&&"number"!==t(e).attr("data-sorttype")||t(e).attr("data-sortdesc")&&"false"!==t(e).attr("data-sortdesc"))){var i=0;t.each(t(e).children(),function(){var e=t(this).data("pojo");e||(e={},t(this).data("pojo",e)),e[a]=i++})}},i.prototype._renderObject=function(e,a){if(!a||!e)return"";var i=this,s="";return t.each(a.split(","),function(){var t=this.trim();s+=0===t.indexOf("'")||0===t.indexOf('"')?t.substring(1,t.length-1):i._get(e,t)}),s},i.prototype._get=function(t,e,i){var s,n,r,o="";if("function"==typeof e)return e(t);if(!t)return"";if(""===e)return t;if(s=t[e],!s)try{if("string"==typeof e&&(o=e.split(".")),r=o.length)for(s=t;s&&r--;)n=o.shift(),i&&!s[n]&&(s[n]={}),s=s[n]}catch(l){}return(null===s||s===a)&&(s=""),s.trim?s.trim():s},i.prototype._getParent=function(t,e,a){return-1===e.indexOf(".")?t:(e=e.substring(0,e.lastIndexOf(".")),this._get(t,e,a))},i.prototype._getNumber=function(e){return e?t.format?t.format.number(e):((-1!=e.indexOf(",")||e.length-e.indexOf(".")>3)&&(e=e.replace(/\./g,"").replace(",",".")),Number(e)):null},i.prototype._isEmpty=function(e){if(!e)return!0;if(t.isArray(e)){if(0===e.length)return!0;for(var a=0;e.length>a;a++)if(!this._isEmpty())return!1;return!0}if(t.isPlainObject(e)){if(t.isEmptyObject(e))return!0;for(var i in e)if(!this._isEmpty(e[i]))return!1;return!0}return isNaN(e)?""===e||" "===e:0===Number(e)||-1===Number(e)?!0:!1},i.prototype._pojoDifferFromInput=function(e,i,s){var n=!1;return t("input,select,textarea",e).each(function(){if(!n){var e=t(this).attr("name");if(e&&!(t(this).hasClass("transient")||0!==e.indexOf(i+".")||(e=e.substring((i+".").length),1>e.length))){var r=t(this).val();if(""===r&&(t(this).hasClass("number")||t(this).hasClass("dateFilter")||t(this).hasClass("dateTimeFilter"))&&(r=null),(t(this).hasClass("number")||t(this).hasClass("currency"))&&(r=that._getNumber(r),isNaN(r)&&(r=0)),("checkbox"===t(this).attr("type")||"CHECKBOX"===t(this).attr("type"))&&(r=t(this).is(":checked")),-1===e.indexOf("."))s[e]!==r&&(n=!0);else{var o,l,h=e.split("."),c=s[h[0]];if(!c)return n=!0,a;2===h.length?c[h[1]]!==r&&(n=!0):3===h.length?(o=c[h[1]],o[h[2]]!==r&&(n=!0)):4===h.length&&(o=c[h[1]],l=o[h[2]],l[h[3]]!==r&&(n=!0))}}}}),n},i.prototype.equals=function(e){var i=this,s=this.element,n=this.options.prefix;if(this._pojoDifferFromInput(s,n,e))return!1;var r=!1;return t(".invalid",s).length>0?!1:(t(".collection",s).each(function(){if(!r){var s=t(this).attr("data-field");if(s&&0===s.indexOf(n+".")&&(s=s.substring((n+".").length),!(1>s.length))){var o=0;t(this).children().each(function(){if(!r){if(o>=e[s].length)return r=!0,a;var n=e[s][o++];i._pojoDifferFromInput(t(this),s,n)&&(r=!0)}}),e[s].length>o&&(r=!0)}}}),!r)},i.prototype.fill=function(t){this.clear(),this.options.data=t,this._fill(this.element,this.options.data,this.options.prefix)},i.prototype.clear=function(){this._clear(this.element,this.options.prefix)},i.prototype.destroy=function(){return t(this.element).each(function(){t(e).unbind(".jsForm"),t(this).removeData("jsForm")})},t.fn.jsForm=function(e){if("object"!=typeof e&&e){var s,n=Array.prototype.slice.call(arguments,1);if(0===this.length)return null;if(1===this.length&&(s=t(this).data("jsForm"))){if(0!==e.indexOf("_")&&s[e]){var r=s[e].apply(s,n);return r}return t.error("Method "+e+" does not exist on jQuery.jsForm"),!1}return this.each(function(){return s=t.data(this,"jsForm"),s?0!==e.indexOf("_")&&s[e]?s[e].apply(s,n):(t.error("Method "+e+" does not exist on jQuery.jsForm"),!1):a})}return this.each(function(){t(this).data("jsForm")||t(this).data("jsForm",new i(this,e))})},t.jsForm=function(e,a){var i=n[e];if(t.isFunction(a))i&&t.each(i,function(){a(this,t(this.element))}),s[e]=a;else if(i){var r=a,o=Array.prototype.slice.call(arguments,2);t.each(portlets,function(){this[r].apply(this,o)})}}})(jQuery,window),function(t){"use strict";function e(t){this.element=t,this._domInit()}var a={},i={};"undefined"!=typeof Handlebars&&(Handlebars.registerHelper("currency",function(e){return e?t.jsFormControls.Format.currency(e):"0"}),Handlebars.registerHelper("dec",function(e){return e?t.jsFormControls.Format.decimal(e):""}),Handlebars.registerHelper("percent",function(e){return e?t.jsFormControls.Format.decimal(100*e):"0"}),Handlebars.registerHelper("date",function(e){return e?t.jsFormControls.Format.date(e):""}),Handlebars.registerHelper("time",function(e){return e?t.jsFormControls.Format.time(e):""}),Handlebars.registerHelper("datetime",function(e){return e?t.jsFormControls.Format.dateTime(e):""}),Handlebars.registerHelper("dateTime",function(e){return e?t.jsFormControls.Format.dateTime(e):""}),Handlebars.registerHelper("timespan",function(e){return e?t.jsFormControls.Format.humanTime(e):""})),e.prototype._domInit=function(){var e=t(this.element);e.find("input.mandatory,textarea.mandatory").on("keyup",function(){t(this).val().length>0&&"null"!==t(this).val()?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}),e.find("input.mandatory,textarea.mandatory").on("change",function(){return t(this).hasClass("object")?(t(this).data().pojo?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"),undefined):(t(this).val().length>0&&"null"!==t(this).val()?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"),undefined)}).change(),e.find("select.mandatory").change(function(){null!==t(this).val()&&"null"!==t(this).val()&&t(this).val().length>0?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}).change(),e.find("input.date").each(function(){var e=t(this).attr("data-format");t(this).datepicker&&(e?t(this).datepicker({dateFormat:e}):t(this).datepicker())});var a=RegExp("^[0-9]+$");e.find("input.number").keyup(function(){var e=t(this).val();e.length>0&&(t(this).hasClass("autoclean")?t(this).val(e.replace(/[^0-9]/g,"")):a.test(t(this).val())?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"))}).keyup(),e.find("input.regexp").each(function(){t(this).hasClass("autoclean")?t(this).data("regexp",RegExp(t(this).attr("data-regexp"),"g")):t(this).data("regexp",RegExp(t(this).attr("data-regexp"))),t(this).keyup(function(){var e=t(this).val();if(e.length>0){var a=t(this).data("regexp");t(this).hasClass("autoclean")?t(this).val(e.replace(a,"")):a.test(t(this).val())?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}else t(this).hasClass("mandatory")||t(this).removeClass("invalid").addClass("valid")}).keyup(),t(this).change(function(){t(this).keyup()})}),e.find("input.rotatestate").each(function(){var e=t(this).attr("data-state-values"),a=t(this).attr("data-state-class");if(e){try{e=JSON.parse(e)}catch(i){return}var s=t("");t(this).attr("title")&&s.attr("title",t(this).attr("title")),t(this).attr("data-state-style")&&s.attr("style",t(this).attr("data-state-style")),s.data("states",e),s.data("control",this),s.data("activeState",null),t(this).data("control",s),a&&s.addClass(a),s.click(function(){var e=t(this).data().activeState,a=t(this).data().states,i=t(this).data().control,s=null;if(null!==e){for(var n=0;a.length>n;n++)if(a[n].value===e.value){s=n===a.length-1?a[0]:a[n+1];break}}else s=a[0];t(i).attr("value",s.value),t(i).change()}),t(this).change(function(){var e=t(t(this).data().control),a=e.data().activeState,i=e.data().states;null!==a&&e.removeClass(a["class"]);var s=t(this).val();t.each(i,function(){return this.value===s?(e.data().activeState=this,this.title&&e.attr("title",this.title),e.addClass(this["class"]),!1):undefined})}),t(this).change(),t(this).after(s),t(this).hide()}})},e.prototype.validate=function(){return t(".required,.regexp,.date,.mandatory,.number,.validate",this.element).change(),t(".invalid",this.element).length>0?!1:!0},t.fn.jsFormControls=function(a){if("object"!=typeof a&&a){var i=Array.prototype.slice.call(arguments,1);if(1==this.length){var s=t(this).data("jsFormControls");if(s){if(0!==a.indexOf("_")&&s[a]){var n=s[a].apply(s,i);return n}return t.error("Method "+a+" does not exist on jQuery.jsFormControls"),!1}}return this.each(function(){var e=t.data(this,"jsFormControls");return e?0!==a.indexOf("_")&&e[a]?e[a].apply(e,i):(t.error("Method "+a+" does not exist on jQuery.jsFormControls"),!1):undefined})}return this.each(function(){t(this).data("jsFormControls")||t(this).data("jsFormControls",new e(this,a))})},t.jsFormControls=function(e,s){var n;if(t.isFunction(s))n=i[e],n&&t.each(n,function(){s(this,t(this.element))}),a[e]=s;else if(n=i[e]){var r=s,o=Array.prototype.slice.call(arguments,2);t.each(portlets,function(){this[r].apply(this,o)})}},t.jsFormControls.Format={format:function(e,a){return t(e).hasClass("dateTime")?t.jsFormControls.Format.dateTime(a):t(e).hasClass("datetime")?t.jsFormControls.Format.dateTime(a):t(e).hasClass("date")?t.jsFormControls.Format.date(a):t(e).hasClass("currency")?t.jsFormControls.Format.currency(a):t(e).hasClass("number")?t.jsFormControls.Format.decimal(a):a},checkBox:function(t,e,a){return a===undefined&&(a=t,t=null),a?' ':' '},_getNumber:function(e){return e?t.format?t.format.number(e):((-1!==e.indexOf(",")||e.length-e.indexOf(".")>3)&&(e=e.replace(/\./g,"").replace(",",".")),Number(e)):null},_pad:function(t){var e=10>t?"0":"";return e+=t},decimal:function(e){if(""===e||!e||isNaN(e))return e;if(t.format)return t.format.number(e,t(document).data().i18n.number.format);var a=0;Math.abs(e-Math.floor(e))>.001&&(a=2);var i=e,s=isNaN(s=Math.abs(a))?2:a,n=",",r=".",o=parseInt(i=Math.abs(+i||0).toFixed(s),10)+"",l=(l=o.length)>3?l%3:0;return(0>e?"-":"")+(l?o.substr(0,l)+r:"")+o.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+r)+(s?n+Math.abs(i-o).toFixed(s).slice(2):"")},currency:function(e,a,i){return(!i||isNaN(i))&&(i=e,e=null),i?t.jsFormControls.Format.decimal(i):a?" ":""},dateTime:function(t,e,a){return(!a||isNaN(a))&&(a=t,t=null),a?this.date(a)+" "+this.time(a):e?" ":""},date:function(e,a,i){if((!i||isNaN(i))&&(i=e,e=null),!i)return a?" ":"";var s=new Date;s.setTime(i);var n=s.getYear();return 1900>n&&(n+=1900),t.format?t.format.date(s,t(document).data().i18n.date.shortDateFormat):this._pad(s.getDate())+"."+this._pad(s.getMonth()+1)+"."+this._pad(n)},time:function(e,a,i){if(i||(i=e,e=null),!i)return a?" ":"";var s=new Date;return s.setTime(i),t.format?t.format.date(s,t(document).data().i18n.date.timeFormat):this._pad(s.getHours())+":"+this._pad(s.getMinutes())},timespan:function(t,e,a,i,s,n){a||(a=t,n=e,t=null,e=null);for(var r=a.split(":"),o=0;r.length>o;o++){var l=Number(r[o]);l&&"NaN"!==l||(l=0),r[o]=this._pad(l)}return 0>=r.length?"0:00":1==r.length?"0:"+this._pad(allowkomma?r[0]:Math.floor(r[0])):2==r.length?allowkomma?r[0]:Math.floor(r[0])+":"+this._pad(allowkomma?r[1]:Math.floor(r[1])):allowkomma?r[0]:Math.floor(r[0])+":"+this._pad(allowkomma?r[1]:Math.floor(r[1]))+":"+pad(allowkomma?r[2]:Math.floor(r[2]))},humanTime:function(t,e,a){if(a||(a=t,t=null),isNaN(a))return a&&0!==a.length?a:"-";var i=Math.floor(a/36e5);a-=36e5*i;var s=Math.floor(a/6e4);a-=6e4*s;var n=Math.floor(a/1e3);a-=1e3*n;var r="";return i>0&&(r+=i+"h ",n=0,a=0),s>0&&(r+=s+"m ",a=0),n>0&&(r+=n+"s ",a=0),a>0&&(r+=a+"ms"),r.trim()}}}(jQuery,window),String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")},String.prototype.startsWith=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length?!1:this.substr(0,t.length)==t?!0:!1},String.prototype.startsWithIgnoreCase=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length?!1:this.substr(0,t.length).toLowerCase()==t.toLowerCase()?!0:!1},String.prototype.endsWith=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length||t.length>this.length?!1:this.substr(this.length-t.length)==t?!0:!1}; -//@ sourceMappingURL=dist/jquery.jsForm.min.map \ No newline at end of file diff --git a/dist/jquery.jsForm.1.0.6.min.js b/dist/jquery.jsForm.1.0.6.min.js deleted file mode 100644 index c310c8d..0000000 --- a/dist/jquery.jsForm.1.0.6.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * jQuery.jsForm v1.0.6 | (c) 2013 Niko Berger http://www.gargan.org/ - * Usage: https://github.com/corinis/jsForm - */ -(function(t,e,a){"use strict";function i(e,a){var i=t(e);this.options=t.extend({},{controls:!0,data:null,prefix:"data",validateHidden:!0,skipEmpty:!1},a),!i.attr("data-prefix")||"data"!==this.options.prefix&&""!==this.options.prefix||""!==i.attr("data-prefix")&&(this.options.prefix=i.attr("data-prefix")),this.element=e,this._init()}var s={},r={};i.prototype._init=function(){if(this._domInit(),this.options.controls)if(t.jsFormControls)t(this.element).jsFormControls();else try{"undefined"!=typeof console&&console.log("jquery.JsForm.controls not available!")}catch(e){}this._fill(this.element,this.options.data,this.options.prefix)},i.prototype._domInit=function(){var e=t(this.element),a=this,i=this.options.prefix;a._initCollection(e,i)},i.prototype._initCollection=function(e,a){var i={},s=this;t(e).data().collections=i,t(".collection",e).each(function(){var e=t(this).attr("data-field");if(e&&0===e.indexOf(a+".")){var r=t(this),n=i[e];if(n?n.push(r):i[e]=[r],s._initList(r),!r.hasClass("ui-sortable")&&r.hasClass("sortable")&&r.sortable){var o=r.attr("data-sortable");o=o?JSON.parse(o):{},r.sortable(o),r.on("sortstop",function(){s._reorder(r)})}}}),t(".add",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections")||(t(this).data().collections=i[e],t(this).click(function(a){a.preventDefault(),t.each(t(this).data("collections"),function(){var a=t(this).data("template");if(a){var i=a.clone(!0);t(this).append(i),t(i).addClass("POJO"),t(i).data("pojo",{}),s._addCollectionControls(i),t(this).trigger("addCollection",[i,t(i).data().pojo]),s._fillData(i,t(i).data().pojo,e.substring(e.indexOf(".")+1)),s._initCollection(i,e.substring(e.indexOf(".")+1)),t(this).trigger("postAddCollection",[i,t(i).data().pojo])}})})))}),t(".insert",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections")||(t(this).data("collections",i[t(this).attr("data-field")]),t(this).on("insert",function(a,i){if(i||(i=t(this).data().pojo),i){var r=t(this).data("beforeInsert");r&&t.isFunction(r)&&!(i=r(i))||(t.each(t(this).data("collections"),function(){var a=t(this).data("template");if(a){var r=a.clone(!0);r.addClass("POJO"),r.data().pojo=i,s._addCollectionControls(r),s._initCollection(r),t(this).trigger("addCollection",[r,t(r).data().pojo]),s._fillData(r,i,e.substring(e.indexOf(".")+1)),t(this).append(r)}}),t(this).val(""),t(this).data().pojo=null,t(this).focus())}})))}),t(".insertAction",e).each(function(){var e=t(this).attr("data-field");if(e&&!t(this).data("inserter")){var a=t(this).parent().find(".insert");a&&(t(this).data("inserter",a),t(this).click(function(e){return e.preventDefault(),t(this).data("inserter").trigger("insert"),!1}))}}),t("input.object",e).each(function(){t(this).on("update",function(){var e=t(this).data().pojo;e&&t(this).attr("data-display")&&t(this).val(s._renderObject(e,t(this).attr("data-display")))})}),t("input.blob",e).each(function(){if("file"===t(this).attr("type")){var e=t(this);t(this).on("change",function(a){var i=t(this).val().split(/\\/).pop();e.data("name",i);var s=a.target.files;s&&s.length&&t.each(s,function(){var a=new FileReader;a.onload=function(t){e.data("blob",t.target.result)},a.readAsDataURL(this),t(this).trigger("fileChange")})})}}),t(".manage",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections",i[e]),t(this).click(function(){var a=t(this).attr("data-service"),i=t(this).data("collections"),r=t(this),n=t(this).attr("data-display");n&&(n=n.split(",")),DataUtils.run(a,function(a){var o=t('');o.data("collections",i),r.data("select",o),t.each(a,function(){var e=this,a="";if(n)for(var s=0;n.length>s;s++)a+=e[n[s]]+" ";else a=e;var r=t('");t(i).each(function(){t(this).children().each(function(a,i){e.id===t(i).data("pojo").id&&r.attr("selected","selected")})}),o.append(r),r.data("pojo",e)}),r.after(o),r.hide(),o.multiselect({autoOpen:!0,open:function(){t(this).multiselect("widget").css("top",t(o).next().offset().top),t(this).multiselect("widget").css("left",t(o).next().offset().left),t(o).next().hide()},close:function(){r.show(),o.remove(),t(this).multiselect("destroy")}}).multiselectfilter().bind("multiselectclick multiselectcheckall multiselectuncheckall",function(){var a=t.map(t(this).multiselect("getChecked"),function(e){return t("option[value='"+e.value+"']",o).data("pojo")});t.each(t(o).data("collections"),function(){s._fillList(t(this),a,e)}),r.hide(),t(o).next().show(),t(this).multiselect("widget").css("top",t(o).next().offset().top),t(this).multiselect("widget").css("left",t(o).next().offset().left),t(o).next().hide()})})}))})},i.prototype._initList=function(t){if(!t.data("template")){var e=t.children().detach();e.removeAttr("id"),t.data("template",e)}},i.prototype._clear=function(e,a){a||(a=this.options.prefix),t(e).removeData("pojo"),t("input,select,textarea",e).each(function(){var e=t(this).attr("name");e&&0===e.indexOf(a+".")&&(e=e.substring((a+".").length),1>e.length||(t(this).removeData("pojo"),"checkbox"===t(this).attr("type")?t(this).prop("checked",!1):t(this).val(""),t(this).hasClass("blob")&&t(this).removeData("blob"),t(this).is("select")&&(t('option[selected="selected"]',this).removeAttr("selected"),t("option:first",this).attr("selected",!0),t(this).val(t("option:first",this).val()).change()),t(this).change()))}),t(".collection",e).each(function(){var e=t(this).attr("data-field");e&&0===e.indexOf(a+".")&&t(this).empty()})},i.prototype._createPojoFromInput=function(e,i,s){var r=null,n=this;return t(e).data("pojo")&&(r=t(e).data("pojo")),r&&t.extend(!0,s,r),t(e).find("input,select,textarea").each(function(){var e=t(this).attr("name");if(e&&!t(this).hasClass("transient")&&0===e.indexOf(i+".")){if(t(this).trigger("validate",!0),e=e.substring((i+".").length),1>e.length)return s=t(this).val(),!1;var r=t(this).val();if(!n.options.skipEmpty||""!==r&&""!==r.trim())if(!t(this).hasClass("emptynull")||""!==r&&""!==r.trim()?t(this).hasClass("object")||t(this).hasClass("POJO")?r=t("option:selected",this).data()&&t("option:selected",this).data().pojo?t("option:selected",this).data().pojo:t(this).data("pojo"):t(this).hasClass("blob")?r=t(this).data("blob"):""===r&&(t(this).hasClass("number")||t(this).hasClass("dateFilter")||t(this).hasClass("dateTimeFilter"))&&(r=null):r=null,t(this).hasClass("percent")&&(r=n._getNumber(r),isNaN(r)?r=0:r/=100),t(this).hasClass("number")||t(this).hasClass("currency")?(r=n._getNumber(r),isNaN(r)&&(r=0)):"checkbox"===t(this).attr("type")||"CHECKBOX"===t(this).attr("type")?r=t(this).is(":checked"):t(this).hasClass("bool")&&(r="true"===t(this).val()),-1===e.indexOf("."))s[e]=r;else{var o,l,h=e.split("."),c=s[h[0]];c&&t.isPlainObject(c)||(s[h[0]]={},c=s[h[0]]),2===h.length?c[h[1]]=r:3===h.length?(o=c[h[1]],o===a&&(o={},c[h[1]]=o),o[h[2]]=r):4===h.length&&(o=c[h[1]],l=o[h[2]],l===a&&(l={},o[h[2]]=l),o[h[2]]=r,l[h[3]]=r)}}}),s},i.prototype._fillData=function(e,i,s){var r=this,n=t(e);n.find(".field").each(function(){var e=t(this).data("name");if(e||("A"===this.nodeName.toUpperCase()?(e=t(this).attr("href"),t(this).attr("href","#")):"IMG"===this.nodeName.toUpperCase()?(e=t(this).attr("src"),0===e.indexOf("#")&&(e=e.substring(1)),t(this).attr("src","#")):e=t(this).text(),t(this).data("name",e),t(this).show()),!s||e.indexOf(s+".")>=0){var a=e;s&&(a=a.substring(s.length+1));var n=r._get(i,a);n||(n=""),t(this).hasClass("percent")&&!isNaN(n)&&(n=100*Number(n)),t.jsFormControls&&(n=t.jsFormControls.Format.format(this,n)),"A"===this.nodeName.toUpperCase()?t(this).attr("href",n):"IMG"===this.nodeName.toUpperCase()?t(this).attr("src",n):"DIV"===this.nodeName.toUpperCase()?t(this).html(n):t(this).text(n)}}),t("input",n).each(function(){var e=t(this).attr("name");if(e&&"file"!=t(this).attr("type")&&(!s||e.indexOf(s+".")>=0)){var a=e;s&&(a=a.substring(s.length+1));var n=r._get(i,a);t(this).hasClass("percent")&&!isNaN(n)?n=100*Number(n):t.isPlainObject(n)&&(t(this).data().pojo=n,t(this).addClass("POJO"),n=r._renderObject(n,t(this).attr("data-display"))),"checkbox"===t(this).attr("type")?(t(this).prop("checked",n===!0||"true"===n),t(this).change()):(n||(n=""),t.jsFormControls&&(n=t.jsFormControls.Format.format(this,n)),t(this).val(n),t(this).change())}}),t("select",n).each(function(){var e=t(this).attr("name");if(e&&(!s||e.indexOf(s+".")>=0)){var n=e;s&&(n=n.substring(s.length+1)),t(this).children("option").removeAttr("selected");var o=t(this).attr("data-key");o||(o="id");var l=r._get(i,n);if(l[o])return t(this).children("option[value='"+l[o]+"']").attr("selected",!0),t(this).val(l[o]).change(),a;t(this).hasClass("bool")&&(l=l?"true":"false"),t(this).children("option[value='"+l+"']").attr("selected",!0),t(this).val(l).change()}}),t("textarea",n).each(function(){var e=t(this).attr("name");if(e&&(!s||e.indexOf(s+".")>=0)){var a=e;s&&(a=a.substring(s.length+1)),t(this).val(r._get(i,a)),t(this).change()}})},i.prototype.get=function(e){var a=t(this.element),i=this,s=this.options.data,r=this.options.prefix,n={};s&&t.isPlainObject(s)&&(n=s),i._createPojoFromInput(a,r,n);var o=!1;return this.options.validateHidden?a.find(".invalid").each(function(){return o=!0,t(this).focus(),!1}):a.find(".invalid").filter(":visible").each(function(){return o=!0,t(this).focus(),!1}),this._getCollection(a,r,n,e)&&(o=!0),!e&&o?null:n},i.prototype._getCollection=function(e,a,i,s){var r=this,n=!1;return e.find(".collection").each(function(){if(s||!n){var e=t(this).attr("data-field");if(e&&0===e.indexOf(a+".")&&(e=e.substring((a+".").length),!(1>e.length))){var o=r._getParent(i,e,!0);-1!==e.indexOf(".")&&(e=e.substring(e.lastIndexOf(".")+1)),o[e]=[],t(this).children().each(function(){if(s||!n){var a={};a=r._createPojoFromInput(t(this),e,a),r._getCollection(t(this),e,a,s),r._isEmpty(a)?t(".invalid",this).removeClass("invalid"):(t(".invalid",this).length>0&&(n=!0),o[e].push(a))}})}}}),n},i.prototype.getData=function(){return this.options.data||(this.options.data={}),this.options.data},i.prototype.preventEditing=function(e){var i=t(this.element);if(e===a)e=i.data("disabled")?!1:!0;else if(e===i.data("disabled"))return;e?(i.find("input, textarea").each(function(){if(!t(this).closest("span.form")[0]&&"hidden"!=t(this).attr("type")){var e=t(this).val();("null"===e||null===e||"submit"===t(this).attr("type"))&&(e=""),t(this).hasClass("trueFalse")&&(e=t(this).is(":checked")?"X":" "),e=e.replace(//g,">").replace(/\n/g,"
");var a=t(''+e+"");t(this).parent().hasClass("ui-wrapper")?t(this).parent().hide().wrap(a):t(this).hide().wrap(a)}}),i.find("select").each(function(){if(!t(this).closest("span.form")[0]){var e=t(this).children(":selected").html();("null"===e||null===e)&&(e="");var a=t(''+e+"");t(this).hasClass("ui-toggle-switch")?t(this).prev().hide().wrap(a):t(this).hide().wrap(a)}})):i.find("span.form").each(function(){var e=t(this).children("input,select,textarea,.ui-wrapper,.ui-toggle-switch").show().detach();t(this).before(e),t(this).remove()}),i.data("disabled",e)},i.prototype.validate=function(){return t(".required,.regexp,.date,.mandatory,.number,.validate",this.element).change(),t(".invalid",this.element).length>0?!1:!0},i.prototype._fill=function(e,a,i){i||(i=this.config.prefix),this._clear(e,i),t(e).addClass("POJO"),t(e).data("pojo",a),this._fillData(e,a,i),this._fillCollection(e,a,i)},i.prototype._fillCollection=function(e,a,i){var s=this;t(".collection",e).each(function(){var e=t(this),r=t(this).attr("data-field");if(a&&r&&0===r.indexOf(i+".")){var n=null,o=r;i&&(o=o.substring(i.length+1)),n=s._get(a,o),n&&s._fillList(e,n,o)}})},i.prototype._fillList=function(e,a,i,s){var r=e.data("template"),n=this;if(r&&(e.empty(),t.isArray(a))){if(-1!==i.indexOf(".")&&(i=i.substring(i.lastIndexOf(".")+1)),t(e).hasClass("sort")){var o=t(e).attr("data-sort");if(o){switch(t(e).attr("data-sorttype")){case"alpha":a.sort();break;case"alphainsensitiv":a.sort(function(t,e){return t=t[o],e=e[o],t&&(t=t.toLowerCase()),e&&(e=e.toLowerCase()),e>t?-1:t>e?1:0});break;default:a.sort(function(t,e){return t[o]-e[o]})}t(e).attr("data-sortdesc")&&a.reverse()}}s||t.isFunction(i)&&(s=i,i=null);for(var l=0;a.length>l;l++){var h=a[l],c=r.clone(!0);c.data("pojo",h),c.addClass("POJO"),s&&s(c,h)===!1||(n._addCollectionControls(c),i&&(n._fillData(c,h,i),n._initCollection(c,i),n._fillCollection(c,h,i)),e.append(c))}}},i.prototype._addCollectionControls=function(e){var a=this;t.jsFormControls&&t(e).jsFormControls(),t(".delete",e).click(function(){var e=t(this).closest(".POJO");t(this).closest(".collection").trigger("deleteCollection",[e,t(e).data().pojo]),e.remove()}),t(".sortUp",e).click(function(){var e=t(this).closest(".POJO"),i=e.prev(".POJO");0!==i.size()&&(e.detach(),i.before(e),a._reorder(e))}),t(".sortDown",e).click(function(){var e=t(this).closest(".POJO"),i=e.next(".POJO");0!==i.size()&&(e.detach(),i.after(e),a._reorder(e))});var i=t(e).closest(".collection");i.hasClass("sortable")&&t(i).sortable&&i.sortable("refresh")},i.prototype._reorder=function(e){e.attr("data-sort")||(e=e.closest(".collection"));var a=t(e).attr("data-sort");if(!(!a||t(e).attr("data-sorttype")&&"number"!==t(e).attr("data-sorttype")||t(e).attr("data-sortdesc")&&"false"!==t(e).attr("data-sortdesc"))){var i=0;t.each(t(e).children(),function(){var e=t(this).data("pojo");e||(e={},t(this).data("pojo",e)),e[a]=i++})}},i.prototype._renderObject=function(e,a){if(!a||!e)return"";var i=this,s="";return t.each(a.split(","),function(){var t=this.trim();s+=0===t.indexOf("'")||0===t.indexOf('"')?t.substring(1,t.length-1):i._get(e,t)}),s},i.prototype._get=function(t,e,i){var s,r,n,o="";if("function"==typeof e)return e(t);if(!t)return"";if(""===e)return t;if(s=t[e],!s)try{if("string"==typeof e&&(o=e.split(".")),n=o.length)for(s=t;s&&n--;)r=o.shift(),i&&!s[r]&&(s[r]={}),s=s[r]}catch(l){}return(null===s||s===a)&&(s=""),s.trim?s.trim():s},i.prototype._getParent=function(t,e,a){return-1===e.indexOf(".")?t:(e=e.substring(0,e.lastIndexOf(".")),this._get(t,e,a))},i.prototype._getNumber=function(e){return e?t.format?t.format.number(e):((-1!=e.indexOf(",")||e.length-e.indexOf(".")>3)&&(e=e.replace(/\./g,"").replace(",",".")),Number(e)):null},i.prototype._isEmpty=function(e){if(!e)return!0;if(t.isArray(e)){if(0===e.length)return!0;for(var a=0;e.length>a;a++)if(!this._isEmpty())return!1;return!0}if(t.isPlainObject(e)){if(t.isEmptyObject(e))return!0;for(var i in e)if(!this._isEmpty(e[i]))return!1;return!0}return isNaN(e)?""===e||" "===e:0===Number(e)||-1===Number(e)?!0:!1},i.prototype._pojoDifferFromInput=function(e,i,s){var r=!1;return t("input,select,textarea",e).each(function(){if(!r){var e=t(this).attr("name");if(e&&!(t(this).hasClass("transient")||0!==e.indexOf(i+".")||(e=e.substring((i+".").length),1>e.length))){var n=t(this).val();if(""===n&&(t(this).hasClass("number")||t(this).hasClass("dateFilter")||t(this).hasClass("dateTimeFilter"))&&(n=null),(t(this).hasClass("number")||t(this).hasClass("currency"))&&(n=that._getNumber(n),isNaN(n)&&(n=0)),("checkbox"===t(this).attr("type")||"CHECKBOX"===t(this).attr("type"))&&(n=t(this).is(":checked")),-1===e.indexOf("."))s[e]!==n&&(r=!0);else{var o,l,h=e.split("."),c=s[h[0]];if(!c)return r=!0,a;2===h.length?c[h[1]]!==n&&(r=!0):3===h.length?(o=c[h[1]],o[h[2]]!==n&&(r=!0)):4===h.length&&(o=c[h[1]],l=o[h[2]],l[h[3]]!==n&&(r=!0))}}}}),r},i.prototype.equals=function(e){var i=this,s=this.element,r=this.options.prefix;if(this._pojoDifferFromInput(s,r,e))return!1;var n=!1;return t(".invalid",s).length>0?!1:(t(".collection",s).each(function(){if(!n){var s=t(this).attr("data-field");if(s&&0===s.indexOf(r+".")&&(s=s.substring((r+".").length),!(1>s.length))){var o=0;t(this).children().each(function(){if(!n){if(o>=e[s].length)return n=!0,a;var r=e[s][o++];i._pojoDifferFromInput(t(this),s,r)&&(n=!0)}}),e[s].length>o&&(n=!0)}}}),!n)},i.prototype.fill=function(t){this.clear(),this.options.data=t,this._fill(this.element,this.options.data,this.options.prefix)},i.prototype.reset=function(){this.clear(),this._fill(this.element,this.options.data,this.options.prefix)},i.prototype.clear=function(){this._clear(this.element,this.options.prefix)},i.prototype.destroy=function(){return t(this.element).each(function(){t(e).unbind(".jsForm"),t(this).removeData("jsForm")})},t.fn.jsForm=function(e){if("object"!=typeof e&&e){var s,r=Array.prototype.slice.call(arguments,1);if(0===this.length)return null;if(1===this.length&&(s=t(this).data("jsForm"))){if(0!==e.indexOf("_")&&s[e]){var n=s[e].apply(s,r);return n}return t.error("Method "+e+" does not exist on jQuery.jsForm"),!1}return this.each(function(){return s=t.data(this,"jsForm"),s?0!==e.indexOf("_")&&s[e]?s[e].apply(s,r):(t.error("Method "+e+" does not exist on jQuery.jsForm"),!1):a})}return this.each(function(){t(this).data("jsForm")||t(this).data("jsForm",new i(this,e))})},t.jsForm=function(e,a){var i=r[e];if(t.isFunction(a))i&&t.each(i,function(){a(this,t(this.element))}),s[e]=a;else if(i){var n=a,o=Array.prototype.slice.call(arguments,2);t.each(portlets,function(){this[n].apply(this,o)})}}})(jQuery,window),function(t){"use strict";function e(t){this.element=t,this._domInit()}var a={},i={};"undefined"!=typeof Handlebars&&(Handlebars.registerHelper("currency",function(e){return e?t.jsFormControls.Format.currency(e):"0"}),Handlebars.registerHelper("dec",function(e){return e?t.jsFormControls.Format.decimal(e):""}),Handlebars.registerHelper("percent",function(e){return e?t.jsFormControls.Format.decimal(100*e):"0"}),Handlebars.registerHelper("date",function(e){return e?t.jsFormControls.Format.date(e):""}),Handlebars.registerHelper("time",function(e){return e?t.jsFormControls.Format.time(e):""}),Handlebars.registerHelper("datetime",function(e){return e?t.jsFormControls.Format.dateTime(e):""}),Handlebars.registerHelper("dateTime",function(e){return e?t.jsFormControls.Format.dateTime(e):""}),Handlebars.registerHelper("timespan",function(e){return e?t.jsFormControls.Format.humanTime(e):""}),Handlebars.registerHelper("byte",function(e){return e?t.jsFormControls.Format.byte(e):""})),e.prototype._domInit=function(){var e=t(this.element);e.find("input.mandatory,textarea.mandatory").on("keyup",function(){t(this).val().length>0&&"null"!==t(this).val()?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}),e.find("input.mandatory,textarea.mandatory").on("change",function(){return t(this).hasClass("object")?(t(this).data().pojo?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"),undefined):(t(this).val().length>0&&"null"!==t(this).val()?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"),undefined)}).change(),e.find("select.mandatory").change(function(){null!==t(this).val()&&"null"!==t(this).val()&&t(this).val().length>0?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}).change(),e.find("input.date").each(function(){var e=t(this).attr("data-format");t(this).datepicker&&(e?t(this).datepicker({dateFormat:e}):t(this).datepicker())});var a=RegExp("^[0-9]+$");e.find("input.number").keyup(function(){var e=t(this).val();e.length>0&&(t(this).hasClass("autoclean")?t(this).val(e.replace(/[^0-9]/g,"")):a.test(t(this).val())?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"))}).keyup(),e.find("input.regexp").each(function(){t(this).hasClass("autoclean")?t(this).data("regexp",RegExp(t(this).attr("data-regexp"),"g")):t(this).data("regexp",RegExp(t(this).attr("data-regexp"))),t(this).keyup(function(){var e=t(this).val();if(e.length>0){var a=t(this).data("regexp");t(this).hasClass("autoclean")?t(this).val(e.replace(a,"")):a.test(t(this).val())?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}else t(this).hasClass("mandatory")||t(this).removeClass("invalid").addClass("valid")}).keyup(),t(this).change(function(){t(this).keyup()})}),e.find("input.rotatestate").each(function(){var e=t(this).attr("data-state-values"),a=t(this).attr("data-state-class");if(e){try{e=JSON.parse(e)}catch(i){return}var s=t("");t(this).attr("title")&&s.attr("title",t(this).attr("title")),t(this).attr("data-state-style")&&s.attr("style",t(this).attr("data-state-style")),s.data("states",e),s.data("control",this),s.data("activeState",null),t(this).data("control",s),a&&s.addClass(a),s.click(function(){var e=t(this).data().activeState,a=t(this).data().states,i=t(this).data().control,s=null;if(null!==e){for(var r=0;a.length>r;r++)if(a[r].value===e.value){s=r===a.length-1?a[0]:a[r+1];break}}else s=a[0];t(i).attr("value",s.value),t(i).change()}),t(this).change(function(){var e=t(t(this).data().control),a=e.data().activeState,i=e.data().states;null!==a&&e.removeClass(a["class"]);var s=t(this).val();t.each(i,function(){return this.value===s?(e.data().activeState=this,this.title&&e.attr("title",this.title),e.addClass(this["class"]),!1):undefined})}),t(this).change(),t(this).after(s),t(this).hide()}})},e.prototype.validate=function(){return t(".required,.regexp,.date,.mandatory,.number,.validate",this.element).change(),t(".invalid",this.element).length>0?!1:!0},t.fn.jsFormControls=function(a){if("object"!=typeof a&&a){var i=Array.prototype.slice.call(arguments,1);if(1==this.length){var s=t(this).data("jsFormControls");if(s){if(0!==a.indexOf("_")&&s[a]){var r=s[a].apply(s,i);return r}return t.error("Method "+a+" does not exist on jQuery.jsFormControls"),!1}}return this.each(function(){var e=t.data(this,"jsFormControls");return e?0!==a.indexOf("_")&&e[a]?e[a].apply(e,i):(t.error("Method "+a+" does not exist on jQuery.jsFormControls"),!1):undefined})}return this.each(function(){t(this).data("jsFormControls")||t(this).data("jsFormControls",new e(this,a))})},t.jsFormControls=function(e,s){var r;if(t.isFunction(s))r=i[e],r&&t.each(r,function(){s(this,t(this.element))}),a[e]=s;else if(r=i[e]){var n=s,o=Array.prototype.slice.call(arguments,2);t.each(portlets,function(){this[n].apply(this,o)})}},t.jsFormControls.Format={format:function(e,a){return t(e).hasClass("dateTime")?t.jsFormControls.Format.dateTime(a):t(e).hasClass("datetime")?t.jsFormControls.Format.dateTime(a):t(e).hasClass("date")?t.jsFormControls.Format.date(a):t(e).hasClass("currency")?t.jsFormControls.Format.currency(a):t(e).hasClass("byte")?t.jsFormControls.Format.byte(a):t(e).hasClass("number")?t.jsFormControls.Format.decimal(a):a},checkBox:function(t,e,a){return a===undefined&&(a=t,t=null),a?' ':' '},_getNumber:function(e){return e?t.format?t.format.number(e):((-1!==e.indexOf(",")||e.length-e.indexOf(".")>3)&&(e=e.replace(/\./g,"").replace(",",".")),Number(e)):null},_pad:function(t){var e=10>t?"0":"";return e+=t},"byte":function(t){if(""===t||!t||isNaN(t))return t;var e=1024;if(e>t)return t+" B";var a=Math.floor(Math.log(t)/Math.log(e)),i="KMGTPE".charAt(a-1)+"B";return Math.round(10*t/Math.pow(e,a))/10+i},decimal:function(e){if(""===e||!e||isNaN(e))return e;if(t.format)return t.format.number(e,t(document).data().i18n.number.format);var a=0;Math.abs(e-Math.floor(e))>.001&&(a=2);var i=e,s=isNaN(s=Math.abs(a))?2:a,r=",",n=".",o=parseInt(i=Math.abs(+i||0).toFixed(s),10)+"",l=(l=o.length)>3?l%3:0;return(0>e?"-":"")+(l?o.substr(0,l)+n:"")+o.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+n)+(s?r+Math.abs(i-o).toFixed(s).slice(2):"")},currency:function(e,a,i){return(!i||isNaN(i))&&(i=e,e=null),i?t.jsFormControls.Format.decimal(i):a?" ":""},dateTime:function(t,e,a){return(!a||isNaN(a))&&(a=t,t=null),a?this.date(a)+" "+this.time(a):e?" ":""},date:function(e,a,i){if((!i||isNaN(i))&&(i=e,e=null),!i)return a?" ":"";var s=new Date;s.setTime(i);var r=s.getYear();return 1900>r&&(r+=1900),t.format?t.format.date(s,t(document).data().i18n.date.shortDateFormat):this._pad(s.getDate())+"."+this._pad(s.getMonth()+1)+"."+this._pad(r)},time:function(e,a,i){if(i||(i=e,e=null),!i)return a?" ":"";var s=new Date;return s.setTime(i),t.format?t.format.date(s,t(document).data().i18n.date.timeFormat):this._pad(s.getHours())+":"+this._pad(s.getMinutes())},timespan:function(t,e,a,i,s,r){a||(a=t,r=e,t=null,e=null);for(var n=a.split(":"),o=0;n.length>o;o++){var l=Number(n[o]);l&&"NaN"!==l||(l=0),n[o]=this._pad(l)}return 0>=n.length?"0:00":1==n.length?"0:"+this._pad(allowkomma?n[0]:Math.floor(n[0])):2==n.length?allowkomma?n[0]:Math.floor(n[0])+":"+this._pad(allowkomma?n[1]:Math.floor(n[1])):allowkomma?n[0]:Math.floor(n[0])+":"+this._pad(allowkomma?n[1]:Math.floor(n[1]))+":"+pad(allowkomma?n[2]:Math.floor(n[2]))},humanTime:function(t,e,a){if(a||(a=t,t=null),isNaN(a))return a&&0!==a.length?a:"-";var i=Math.floor(a/36e5);a-=36e5*i;var s=Math.floor(a/6e4);a-=6e4*s;var r=Math.floor(a/1e3);a-=1e3*r;var n="";return i>0&&(n+=i+"h ",r=0,a=0),s>0&&(n+=s+"m ",a=0),r>0&&(n+=r+"s ",a=0),a>0&&(n+=a+"ms"),n.trim()}}}(jQuery,window),String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")},String.prototype.startsWith=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length?!1:this.substr(0,t.length)==t?!0:!1},String.prototype.startsWithIgnoreCase=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length?!1:this.substr(0,t.length).toLowerCase()==t.toLowerCase()?!0:!1},String.prototype.endsWith=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length||t.length>this.length?!1:this.substr(this.length-t.length)==t?!0:!1}; -//@ sourceMappingURL=dist/jquery.jsForm.min.map \ No newline at end of file diff --git a/dist/jquery.jsForm.1.0.7.min.js b/dist/jquery.jsForm.1.0.7.min.js deleted file mode 100644 index d771956..0000000 --- a/dist/jquery.jsForm.1.0.7.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * jQuery.jsForm v1.0.7 | (c) 2013 Niko Berger http://www.gargan.org/ - * Usage: https://github.com/corinis/jsForm - */ -(function(t,e,a){"use strict";function i(e,a){var i=t(e);this.options=t.extend({},{controls:!0,data:null,prefix:"data",validateHidden:!0,skipEmpty:!1},a),!i.attr("data-prefix")||"data"!==this.options.prefix&&""!==this.options.prefix||""!==i.attr("data-prefix")&&(this.options.prefix=i.attr("data-prefix")),this.element=e,this._init()}var s={},n={};i.prototype._init=function(){if(this._domInit(),this.options.controls)if(t.jsFormControls)t(this.element).jsFormControls();else try{"undefined"!=typeof console&&console.log("jquery.JsForm.controls not available!")}catch(e){}this._fill(this.element,this.options.data,this.options.prefix)},i.prototype._domInit=function(){var e=t(this.element),a=this,i=this.options.prefix;a._initCollection(e,i)},i.prototype._debug=function(t){"undefined"!=typeof console&&console.log("JsForm: "+t)},i.prototype._initCollection=function(e,a){var i={},s=this;t(e).data().collections=i,t(".collection",e).each(function(){var e=t(this).attr("data-field");if(e&&0===e.indexOf(a+".")){var n=t(this),r=i[e];if(r?r.push(n):i[e]=[n],s._initList(n),!n.hasClass("ui-sortable")&&n.hasClass("sortable")&&n.sortable){var o=n.attr("data-sortable");o=o?JSON.parse(o):{},n.sortable(o),n.on("sortstop",function(){s._reorder(n)})}}}),t(".add",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections")||(t(this).data().collections=i[e],t(this).click(function(a){a.preventDefault(),t.each(t(this).data("collections"),function(){var a=t(this).data("template");if(a){var i=a.clone(!0);t(this).append(i),t(i).addClass("POJO"),t(i).data("pojo",{}),s._addCollectionControls(i),t(this).trigger("addCollection",[i,t(i).data().pojo]),s._fillData(i,t(i).data().pojo,e.substring(e.indexOf(".")+1)),s._initCollection(i,e.substring(e.indexOf(".")+1)),t(this).trigger("postAddCollection",[i,t(i).data().pojo])}})})))}),t(".insert",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections")||(t(this).data("collections",i[t(this).attr("data-field")]),t(this).on("insert",function(a,i){if(i||(i=t(this).data().pojo),i){var n=t(this).data("beforeInsert");n&&t.isFunction(n)&&!(i=n(i))||(t.each(t(this).data("collections"),function(){var a=t(this).data("template");if(a){var n=a.clone(!0);n.addClass("POJO"),n.data().pojo=i,s._addCollectionControls(n),s._initCollection(n),t(this).trigger("addCollection",[n,t(n).data().pojo]),s._fillData(n,i,e.substring(e.indexOf(".")+1)),t(this).append(n)}}),t(this).val(""),t(this).data().pojo=null,t(this).focus())}})))}),t(".insertAction",e).each(function(){var e=t(this).attr("data-field");if(e&&!t(this).data("inserter")){var a=t(this).parent().find(".insert");a&&(t(this).data("inserter",a),t(this).click(function(e){return e.preventDefault(),t(this).data("inserter").trigger("insert"),!1}))}}),t("input.object",e).each(function(){t(this).on("update",function(){var e=t(this).data().pojo;e&&t(this).attr("data-display")&&t(this).val(s._renderObject(e,t(this).attr("data-display")))})}),t("input.blob",e).each(function(){if("file"===t(this).attr("type")){var e=t(this);t(this).on("change",function(a){var i=t(this).val().split(/\\/).pop();e.data("name",i);var s=a.target.files;s&&s.length&&t.each(s,function(){var a=new FileReader;a.onload=function(t){e.data("blob",t.target.result)},a.readAsDataURL(this),t(this).trigger("fileChange")})})}}),t(".manage",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections",i[e]),t(this).click(function(){var a=t(this).attr("data-service"),i=t(this).data("collections"),n=t(this),r=t(this).attr("data-display");r&&(r=r.split(",")),DataUtils.run(a,function(a){var o=t('');o.data("collections",i),n.data("select",o),t.each(a,function(){var e=this,a="";if(r)for(var s=0;r.length>s;s++)a+=e[r[s]]+" ";else a=e;var n=t('");t(i).each(function(){t(this).children().each(function(a,i){e.id===t(i).data("pojo").id&&n.attr("selected","selected")})}),o.append(n),n.data("pojo",e)}),n.after(o),n.hide(),o.multiselect({autoOpen:!0,open:function(){t(this).multiselect("widget").css("top",t(o).next().offset().top),t(this).multiselect("widget").css("left",t(o).next().offset().left),t(o).next().hide()},close:function(){n.show(),o.remove(),t(this).multiselect("destroy")}}).multiselectfilter().bind("multiselectclick multiselectcheckall multiselectuncheckall",function(){var a=t.map(t(this).multiselect("getChecked"),function(e){return t("option[value='"+e.value+"']",o).data("pojo")});t.each(t(o).data("collections"),function(){s._fillList(t(this),a,e)}),n.hide(),t(o).next().show(),t(this).multiselect("widget").css("top",t(o).next().offset().top),t(this).multiselect("widget").css("left",t(o).next().offset().left),t(o).next().hide()})})}))})},i.prototype._initList=function(t){if(!t.data("template")){var e=t.children().detach();e.removeAttr("id"),t.data("template",e)}},i.prototype._clear=function(e,a){a||(a=this.options.prefix),t(e).removeData("pojo"),t("input,select,textarea",e).each(function(){var e=t(this).attr("name");e&&0===e.indexOf(a+".")&&(e=e.substring((a+".").length),1>e.length||(t(this).removeData("pojo"),"checkbox"===t(this).attr("type")?t(this).prop("checked",!1):t(this).val(""),t(this).hasClass("blob")&&t(this).removeData("blob"),t(this).is("select")&&(t('option[selected="selected"]',this).removeAttr("selected"),t("option:first",this).attr("selected",!0),t(this).val(t("option:first",this).val()).change()),t(this).change()))}),t(".collection",e).each(function(){var e=t(this).attr("data-field");e&&0===e.indexOf(a+".")&&t(this).empty()})},i.prototype._createPojoFromInput=function(e,i,s){var n=null,r=this;return t(e).data("pojo")&&(n=t(e).data("pojo")),n&&t.extend(!0,s,n),t(e).find("input,select,textarea,.jsobject").each(function(){var e=t(this).attr("data-name");if(e||(e=t(this).attr("name")),e&&!t(this).hasClass("transient")&&0===e.indexOf(i+".")){if(t(this).trigger("validate",!0),e=e.substring((i+".").length),1>e.length)return s=t(this).val(),!1;var n=t(this).val();if(t(this).hasClass("jsobject")&&(n=t(this).data("pojo")),!r.options.skipEmpty||n&&""!==n&&""!==n.trim())if(!t(this).hasClass("emptynull")||n&&""!==n&&"null"!==n&&""!==n.trim()?t(this).hasClass("object")||t(this).hasClass("POJO")?n=t("option:selected",this).data()&&t("option:selected",this).data().pojo?t("option:selected",this).data().pojo:t(this).data("pojo"):t(this).hasClass("blob")?n=t(this).data("blob"):""===n&&(t(this).hasClass("number")||t(this).hasClass("integer")||t(this).hasClass("dateFilter")||t(this).hasClass("dateTimeFilter"))&&(n=null):n=null,t(this).hasClass("percent")&&(n=r._getNumber(n),isNaN(n)?n=0:n/=100),t(this).hasClass("number")||t(this).hasClass("integer")||t(this).hasClass("currency")?(n=r._getNumber(n),isNaN(n)&&(n=0)):"checkbox"===t(this).attr("type")||"CHECKBOX"===t(this).attr("type")?n=t(this).is(":checked"):t(this).hasClass("bool")&&(n="true"===t(this).val()),-1===e.indexOf("."))s[e]=n;else{var o,l,h=e.split("."),d=s[h[0]];d&&t.isPlainObject(d)||(s[h[0]]={},d=s[h[0]]),2===h.length?d[h[1]]=n:3===h.length?(o=d[h[1]],o===a&&(o={},d[h[1]]=o),o[h[2]]=n):4===h.length&&(o=d[h[1]],l=o[h[2]],l===a&&(l={},o[h[2]]=l),o[h[2]]=n,l[h[3]]=n)}}}),s},i.prototype._fillData=function(e,i,s){var n=this,r=t(e);r.find(".field").each(function(){var e=t(this).data("name");if(e||("A"===this.nodeName.toUpperCase()?(e=t(this).attr("href"),t(this).attr("href","#")):"IMG"===this.nodeName.toUpperCase()?(e=t(this).attr("src"),0===e.indexOf("#")&&(e=e.substring(1)),t(this).attr("src","#")):e=t(this).text(),t(this).data("name",e),t(this).show()),!s||e.indexOf(s+".")>=0){var a=e;s&&(a=a.substring(s.length+1));var r=n._get(i,a);r||(r=""),t(this).hasClass("percent")&&!isNaN(r)&&(r=100*Number(r)),t.jsFormControls&&(r=t.jsFormControls.Format.format(this,r)),"A"===this.nodeName.toUpperCase()?t(this).attr("href",r):"IMG"===this.nodeName.toUpperCase()?t(this).attr("src",r):"DIV"===this.nodeName.toUpperCase()?t(this).html(r):t(this).text(r)}}),t("input",r).each(function(){var e=t(this).attr("name");if(e&&"file"!=t(this).attr("type")&&(!s||e.indexOf(s+".")>=0)){var a=e;s&&(a=a.substring(s.length+1));var r=n._get(i,a);t(this).hasClass("percent")&&!isNaN(r)?r=100*Number(r):t.isPlainObject(r)&&(t(this).data().pojo=r,t(this).addClass("POJO"),r=n._renderObject(r,t(this).attr("data-display"))),"checkbox"===t(this).attr("type")?(t(this).prop("checked",r===!0||"true"===r),t(this).change()):(r||(r=""),t.jsFormControls&&(r=t.jsFormControls.Format.format(this,r)),t(this).val(r),t(this).change())}}),t("select",r).each(function(){var e=t(this).attr("name");if(e&&(!s||e.indexOf(s+".")>=0)){var r=e;s&&(r=r.substring(s.length+1)),t(this).children("option").removeAttr("selected");var o=t(this).attr("data-key");o||(o="id");var l=n._get(i,r);if(l[o]||!isNaN(l[o]))return t(this).children("option[value='"+l[o]+"']").attr("selected",!0),t(this).val(l[o]).change(),a;t(this).hasClass("bool")&&(l=l?"true":"false"),t(this).children("option[value='"+l+"']").attr("selected",!0),t(this).val(l).change()}}),t("textarea",r).each(function(){var e=t(this).attr("name");if(e&&(!s||e.indexOf(s+".")>=0)){var a=e;s&&(a=a.substring(s.length+1)),t(this).val(n._get(i,a)),t(this).change()}})},i.prototype.get=function(e){var a=t(this.element),i=this,s=this.options.data,n=this.options.prefix,r={};s&&t.isPlainObject(s)&&(r=s),i._createPojoFromInput(a,n,r);var o=!1;return this.options.validateHidden?a.find(".invalid").each(function(){return o=!0,t(this).focus(),!1}):a.find(".invalid").filter(":visible").each(function(){return o=!0,t(this).focus(),e||i._debug("Found invalid field: "+t(this).attr("name")),!1}),this._getCollection(a,n,r,e)&&(o=!0),!e&&o?null:r},i.prototype._getCollection=function(e,a,i,s){var n=this,r=!1;return e.find(".collection").each(function(){if(s||!r){var e=t(this).attr("data-field");if(e&&0===e.indexOf(a+".")&&(e=e.substring((a+".").length),!(1>e.length))){var o=n._getParent(i,e,!0);-1!==e.indexOf(".")&&(e=e.substring(e.lastIndexOf(".")+1)),o[e]=[],t(this).children().each(function(){if(s||!r){var a={};a=n._createPojoFromInput(t(this),e,a),n._getCollection(t(this),e,a,s),n._isEmpty(a)?t(".invalid",this).removeClass("invalid"):(t(".invalid",this).length>0&&(r=!0),o[e].push(a))}})}}}),r},i.prototype.getData=function(){return this.options.data||(this.options.data={}),this.options.data},i.prototype.preventEditing=function(e){var i=t(this.element);if(e===a)e=i.data("disabled")?!1:!0;else if(e===i.data("disabled"))return;e?(i.find("input, textarea").each(function(){if(!t(this).closest("span.form")[0]&&"hidden"!=t(this).attr("type")){var e=t(this).val();("null"===e||null===e||"submit"===t(this).attr("type"))&&(e=""),t(this).hasClass("trueFalse")&&(e=t(this).is(":checked")?"X":" "),e=e.replace(//g,">").replace(/\n/g,"
");var a=t(''+e+"");t(this).parent().hasClass("ui-wrapper")?t(this).parent().hide().wrap(a):t(this).hide().wrap(a)}}),i.find("select").each(function(){if(!t(this).closest("span.form")[0]){var e=t(this).children(":selected").html();("null"===e||null===e)&&(e="");var a=t(''+e+"");t(this).hasClass("ui-toggle-switch")?t(this).prev().hide().wrap(a):t(this).hide().wrap(a)}})):i.find("span.form").each(function(){var e=t(this).children("input,select,textarea,.ui-wrapper,.ui-toggle-switch").show().detach();t(this).before(e),t(this).remove()}),i.data("disabled",e)},i.prototype.validate=function(){return t(".required,.regexp,.date,.mandatory,.number,.validate,.integer",this.element).change(),t(".invalid",this.element).length>0?!1:!0},i.prototype._fill=function(e,a,i){i||(i=this.config.prefix),this._clear(e,i),t(e).addClass("POJO"),t(e).data("pojo",a),this._fillData(e,a,i),this._fillCollection(e,a,i)},i.prototype._fillCollection=function(e,a,i){var s=this;t(".collection",e).each(function(){var e=t(this),n=t(this).attr("data-field");if(a&&n&&0===n.indexOf(i+".")){var r=null,o=n;i&&(o=o.substring(i.length+1)),r=s._get(a,o),r&&s._fillList(e,r,o)}})},i.prototype._fillList=function(e,a,i,s){var n=e.data("template"),r=this;if(n&&(e.empty(),t.isArray(a))){if(-1!==i.indexOf(".")&&(i=i.substring(i.lastIndexOf(".")+1)),t(e).hasClass("sort")){var o=t(e).attr("data-sort");if(o){switch(t(e).attr("data-sorttype")){case"alpha":a.sort();break;case"alphainsensitiv":a.sort(function(t,e){return t=t[o],e=e[o],t&&(t=t.toLowerCase()),e&&(e=e.toLowerCase()),e>t?-1:t>e?1:0});break;default:a.sort(function(t,e){return t[o]-e[o]})}t(e).attr("data-sortdesc")&&a.reverse()}}s||t.isFunction(i)&&(s=i,i=null);for(var l=0;a.length>l;l++){var h=a[l],d=n.clone(!0);d.data("pojo",h),d.addClass("POJO"),s&&s(d,h)===!1||(r._addCollectionControls(d),i&&(r._fillData(d,h,i),r._initCollection(d,i),r._fillCollection(d,h,i)),e.append(d))}}},i.prototype._addCollectionControls=function(e){var a=this;t.jsFormControls&&t(e).jsFormControls(),t(".delete",e).click(function(){var e=t(this).closest(".POJO");t(this).closest(".collection").trigger("deleteCollection",[e,t(e).data().pojo]),e.remove()}),t(".sortUp",e).click(function(){var e=t(this).closest(".POJO"),i=e.prev(".POJO");0!==i.size()&&(e.detach(),i.before(e),a._reorder(e))}),t(".sortDown",e).click(function(){var e=t(this).closest(".POJO"),i=e.next(".POJO");0!==i.size()&&(e.detach(),i.after(e),a._reorder(e))});var i=t(e).closest(".collection");i.hasClass("sortable")&&t(i).sortable&&i.sortable("refresh")},i.prototype._reorder=function(e){e.attr("data-sort")||(e=e.closest(".collection"));var a=t(e).attr("data-sort");if(!(!a||t(e).attr("data-sorttype")&&"number"!==t(e).attr("data-sorttype")||t(e).attr("data-sortdesc")&&"false"!==t(e).attr("data-sortdesc"))){var i=0;t.each(t(e).children(),function(){var e=t(this).data("pojo");e||(e={},t(this).data("pojo",e)),e[a]=i++})}},i.prototype._renderObject=function(e,a){if(!a||!e)return"";var i=this,s="";return t.each(a.split(","),function(){var t=this.trim();s+=0===t.indexOf("'")||0===t.indexOf('"')?t.substring(1,t.length-1):i._get(e,t)}),s},i.prototype._get=function(t,e,i){var s,n,r,o="";if("function"==typeof e)return e(t);if(!t)return"";if(""===e)return t;if(s=t[e],!s)try{if("string"==typeof e&&(o=e.split(".")),r=o.length)for(s=t;s&&r--;)n=o.shift(),i&&!s[n]&&(s[n]={}),s=s[n]}catch(l){}return(null===s||s===a)&&(s=""),s.trim?s.trim():s},i.prototype._getParent=function(t,e,a){return-1===e.indexOf(".")?t:(e=e.substring(0,e.lastIndexOf(".")),this._get(t,e,a))},i.prototype._getNumber=function(e){return e?t.format?t.format.number(e):((-1!=e.indexOf(",")||e.length-e.indexOf(".")>3)&&(e=e.replace(/\./g,"").replace(",",".")),Number(e)):null},i.prototype._isEmpty=function(e){if(!e)return!0;if(t.isArray(e)){if(0===e.length)return!0;for(var a=0;e.length>a;a++)if(!this._isEmpty())return!1;return!0}if(t.isPlainObject(e)){if(t.isEmptyObject(e))return!0;for(var i in e)if(!this._isEmpty(e[i]))return!1;return!0}return isNaN(e)?""===e||" "===e:0===Number(e)||-1===Number(e)?!0:!1},i.prototype._pojoDifferFromInput=function(e,i,s){var n=!1;return t("input,select,textarea",e).each(function(){if(!n){var e=t(this).attr("name");if(e&&!(t(this).hasClass("transient")||0!==e.indexOf(i+".")||(e=e.substring((i+".").length),1>e.length))){var r=t(this).val();if(""===r&&(t(this).hasClass("number")||t(this).hasClass("dateFilter")||t(this).hasClass("dateTimeFilter"))&&(r=null),(t(this).hasClass("number")||t(this).hasClass("currency"))&&(r=that._getNumber(r),isNaN(r)&&(r=0)),("checkbox"===t(this).attr("type")||"CHECKBOX"===t(this).attr("type"))&&(r=t(this).is(":checked")),-1===e.indexOf("."))s[e]!==r&&(n=!0);else{var o,l,h=e.split("."),d=s[h[0]];if(!d)return n=!0,a;2===h.length?d[h[1]]!==r&&(n=!0):3===h.length?(o=d[h[1]],o[h[2]]!==r&&(n=!0)):4===h.length&&(o=d[h[1]],l=o[h[2]],l[h[3]]!==r&&(n=!0))}}}}),n},i.prototype.equals=function(e){var i=this,s=this.element,n=this.options.prefix;if(this._pojoDifferFromInput(s,n,e))return!1;var r=!1;return t(".invalid",s).length>0?!1:(t(".collection",s).each(function(){if(!r){var s=t(this).attr("data-field");if(s&&0===s.indexOf(n+".")&&(s=s.substring((n+".").length),!(1>s.length))){var o=0;t(this).children().each(function(){if(!r){if(o>=e[s].length)return r=!0,a;var n=e[s][o++];i._pojoDifferFromInput(t(this),s,n)&&(r=!0)}}),e[s].length>o&&(r=!0)}}}),!r)},i.prototype.fill=function(t){this.options.data=t,this._fill(this.element,this.options.data,this.options.prefix)},i.prototype.reset=function(){this.clear(),this._fill(this.element,this.options.data,this.options.prefix)},i.prototype.clear=function(){this._clear(this.element,this.options.prefix)},i.prototype.destroy=function(){return t(this.element).each(function(){t(e).unbind(".jsForm"),t(this).removeData("jsForm")})},t.fn.jsForm=function(e){if("object"!=typeof e&&e){var s,n=Array.prototype.slice.call(arguments,1);if(0===this.length)return null;if(1===this.length&&(s=t(this).data("jsForm"))){if(0!==e.indexOf("_")&&s[e]){var r=s[e].apply(s,n);return r}return t.error("Method "+e+" does not exist on jQuery.jsForm"),!1}return this.each(function(){return s=t.data(this,"jsForm"),s?0!==e.indexOf("_")&&s[e]?s[e].apply(s,n):(t.error("Method "+e+" does not exist on jQuery.jsForm"),!1):a})}return this.each(function(){t(this).data("jsForm")||t(this).data("jsForm",new i(this,e))})},t.jsForm=function(e,a){var i=n[e];if(t.isFunction(a))i&&t.each(i,function(){a(this,t(this.element))}),s[e]=a;else if(i){var r=a,o=Array.prototype.slice.call(arguments,2);t.each(portlets,function(){this[r].apply(this,o)})}}})(jQuery,window),function(t){"use strict";function e(t){this.element=t,this._domInit()}var a={},i={};"undefined"!=typeof Handlebars&&(Handlebars.registerHelper("currency",function(e){return e?t.jsFormControls.Format.currency(e):"0"}),Handlebars.registerHelper("dec",function(e){return e?t.jsFormControls.Format.decimal(e):""}),Handlebars.registerHelper("percent",function(e){return e?t.jsFormControls.Format.decimal(100*e):"0"}),Handlebars.registerHelper("date",function(e){return e?t.jsFormControls.Format.date(e):""}),Handlebars.registerHelper("time",function(e){return e?t.jsFormControls.Format.time(e):""}),Handlebars.registerHelper("datetime",function(e){return e?t.jsFormControls.Format.dateTime(e):""}),Handlebars.registerHelper("dateTime",function(e){return e?t.jsFormControls.Format.dateTime(e):""}),Handlebars.registerHelper("timespan",function(e){return e?t.jsFormControls.Format.humanTime(e):""}),Handlebars.registerHelper("byte",function(e){return e?t.jsFormControls.Format.byte(e):""})),e.prototype._domInit=function(){var e=t(this.element);e.find("input.mandatory,textarea.mandatory").on("keyup",function(){t(this).val().length>0&&"null"!==t(this).val()?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}),e.find("input.mandatory,textarea.mandatory").on("change",function(){return t(this).hasClass("object")?(t(this).data().pojo?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"),undefined):(t(this).val().length>0&&"null"!==t(this).val()?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"),undefined)}).change(),e.find("select.mandatory").change(function(){null!==t(this).val()&&"null"!==t(this).val()&&t(this).val().length>0?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}).change(),e.find("input.date").each(function(){var e=t(this).attr("data-format");t(this).datepicker&&(e?t(this).datepicker({dateFormat:e}):t(this).datepicker())});var a=RegExp("^[0-9.,-]+$");e.find("input.number").keyup(function(){var e=t(this).val();e.length>0&&(t(this).hasClass("autoclean")?t(this).val(e.replace(/[^0-9.,-]/g,"")):a.test(t(this).val())?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"))}).keyup();var i=RegExp("^[0-9]+$");e.find("input.integer").keyup(function(){var e=t(this).val();e.length>0&&(t(this).hasClass("autoclean")?t(this).val(e.replace(/[^0-9]/g,"")):i.test(t(this).val())?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"))}).keyup(),e.find("input.regexp").each(function(){t(this).hasClass("autoclean")?t(this).data("regexp",RegExp(t(this).attr("data-regexp"),"g")):t(this).data("regexp",RegExp(t(this).attr("data-regexp"))),t(this).keyup(function(){var e=t(this).val();if(e.length>0){var a=t(this).data("regexp");t(this).hasClass("autoclean")?t(this).val(e.replace(a,"")):a.test(t(this).val())?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}else t(this).hasClass("mandatory")||t(this).removeClass("invalid").addClass("valid")}).keyup(),t(this).change(function(){t(this).keyup()})}),e.find("input.rotatestate").each(function(){var e=t(this).attr("data-state-values"),a=t(this).attr("data-state-class");if(e){try{e=JSON.parse(e)}catch(i){return}var s=t("");t(this).attr("title")&&s.attr("title",t(this).attr("title")),t(this).attr("data-state-style")&&s.attr("style",t(this).attr("data-state-style")),s.data("states",e),s.data("control",this),s.data("activeState",null),t(this).data("control",s),a&&s.addClass(a),s.click(function(){var e=t(this).data().activeState,a=t(this).data().states,i=t(this).data().control,s=null;if(null!==e){for(var n=0;a.length>n;n++)if(a[n].value===e.value){s=n===a.length-1?a[0]:a[n+1];break}}else s=a[0];t(i).attr("value",s.value),t(i).change()}),t(this).change(function(){var e=t(t(this).data().control),a=e.data().activeState,i=e.data().states;null!==a&&e.removeClass(a["class"]);var s=t(this).val();t.each(i,function(){return this.value===s?(e.data().activeState=this,this.title&&e.attr("title",this.title),e.addClass(this["class"]),!1):undefined})}),t(this).change(),t(this).after(s),t(this).hide()}})},e.prototype.validate=function(){return t(".required,.regexp,.date,.mandatory,.number,.validate",this.element).change(),t(".invalid",this.element).length>0?!1:!0},t.fn.jsFormControls=function(a){if("object"!=typeof a&&a){var i=Array.prototype.slice.call(arguments,1);if(1==this.length){var s=t(this).data("jsFormControls");if(s){if(0!==a.indexOf("_")&&s[a]){var n=s[a].apply(s,i);return n}return t.error("Method "+a+" does not exist on jQuery.jsFormControls"),!1}}return this.each(function(){var e=t.data(this,"jsFormControls");return e?0!==a.indexOf("_")&&e[a]?e[a].apply(e,i):(t.error("Method "+a+" does not exist on jQuery.jsFormControls"),!1):undefined})}return this.each(function(){t(this).data("jsFormControls")||t(this).data("jsFormControls",new e(this,a))})},t.jsFormControls=function(e,s){var n;if(t.isFunction(s))n=i[e],n&&t.each(n,function(){s(this,t(this.element))}),a[e]=s;else if(n=i[e]){var r=s,o=Array.prototype.slice.call(arguments,2);t.each(portlets,function(){this[r].apply(this,o)})}},t.jsFormControls.Format={format:function(e,a){return t(e).hasClass("dateTime")?t.jsFormControls.Format.dateTime(a):t(e).hasClass("datetime")?t.jsFormControls.Format.dateTime(a):t(e).hasClass("date")?t.jsFormControls.Format.date(a):t(e).hasClass("currency")?t.jsFormControls.Format.currency(a):t(e).hasClass("byte")?t.jsFormControls.Format.byte(a):t(e).hasClass("number")?t.jsFormControls.Format.decimal(a):a},checkBox:function(t,e,a){return a===undefined&&(a=t,t=null),a?' ':' '},_getNumber:function(e){return e?t.format?t.format.number(e):((-1!==e.indexOf(",")||e.length-e.indexOf(".")>3)&&(e=e.replace(/\./g,"").replace(",",".")),Number(e)):null},_pad:function(t){var e=10>t?"0":"";return e+=t},"byte":function(t){if(""===t||!t||isNaN(t))return t;var e=1024;if(e>t)return t+" B";var a=Math.floor(Math.log(t)/Math.log(e)),i="KMGTPE".charAt(a-1)+"B";return Math.round(10*t/Math.pow(e,a))/10+i},decimal:function(e){if(""===e||!e||isNaN(e))return e;var a={format:"#,##0.###",groupingSeparator:",",decimalSeparator:"."};if("undefined"!=typeof i18n&&(a=i18n.number),t(document).data().i18n!==undefined&&(a=t(document).data().i18n.number),t.format&&a)return t.format.number(e,a);var i=0;Math.abs(e-Math.floor(e))>.001&&(i=2);var s=e,n=isNaN(n=Math.abs(i))?2:i,r=a.decimalSeparator,o=a.groupingSeparator,l=parseInt(s=Math.abs(+s||0).toFixed(n),10)+"",h=(h=l.length)>3?h%3:0;return(0>e?"-":"")+(h?l.substr(0,h)+o:"")+l.substr(h).replace(/(\d{3})(?=\d)/g,"$1"+o)+(n?r+Math.abs(s-l).toFixed(n).slice(2):"")},currency:function(e,a,i){return(!i||isNaN(i))&&(i=e,e=null),i?t.jsFormControls.Format.decimal(i):a?" ":""},dateTime:function(t,e,a){return(!a||isNaN(a))&&(a=t,t=null),a?this.date(a)+" "+this.time(a):e?" ":""},date:function(e,a,i){if((!i||isNaN(i))&&(i=e,e=null),!i)return a?" ":"";var s=new Date;s.setTime(i);var n=s.getYear();1900>n&&(n+=1900);var r=null;return"undefined"!=typeof i18n&&(r=i18n.date),t(document).data().i18n!==undefined&&(r=t(document).data().i18n.date),t.format?t.format.date(s,r.shortDateFormat):this._pad(s.getDate())+"."+this._pad(s.getMonth()+1)+"."+this._pad(n)},time:function(e,a,i){if(i||(i=e,e=null),!i)return a?" ":"";var s=new Date;return s.setTime(i),t.format?t.format.date(s,t(document).data().i18n.date.timeFormat):this._pad(s.getHours())+":"+this._pad(s.getMinutes())},timespan:function(t,e,a,i,s,n){a||(a=t,n=e,t=null,e=null);for(var r=a.split(":"),o=0;r.length>o;o++){var l=Number(r[o]);l&&"NaN"!==l||(l=0),r[o]=this._pad(l)}return 0>=r.length?"0:00":1==r.length?"0:"+this._pad(allowkomma?r[0]:Math.floor(r[0])):2==r.length?allowkomma?r[0]:Math.floor(r[0])+":"+this._pad(allowkomma?r[1]:Math.floor(r[1])):allowkomma?r[0]:Math.floor(r[0])+":"+this._pad(allowkomma?r[1]:Math.floor(r[1]))+":"+pad(allowkomma?r[2]:Math.floor(r[2]))},humanTime:function(t,e,a){if(a||(a=t,t=null),isNaN(a))return a&&0!==a.length?a:"-";var i=Math.floor(a/36e5);a-=36e5*i;var s=Math.floor(a/6e4);a-=6e4*s;var n=Math.floor(a/1e3);a-=1e3*n;var r="";return i>0&&(r+=i+"h ",n=0,a=0),s>0&&(r+=s+"m ",a=0),n>0&&(r+=n+"s ",a=0),a>0&&(r+=a+"ms"),r.trim()}}}(jQuery,window),String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")},String.prototype.startsWith=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length?!1:this.substr(0,t.length)==t?!0:!1},String.prototype.startsWithIgnoreCase=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length?!1:this.substr(0,t.length).toLowerCase()==t.toLowerCase()?!0:!1},String.prototype.endsWith=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length||t.length>this.length?!1:this.substr(this.length-t.length)==t?!0:!1}; -//@ sourceMappingURL=dist/jquery.jsForm.min.map \ No newline at end of file diff --git a/dist/jquery.jsForm.1.0.8.min.js b/dist/jquery.jsForm.1.0.8.min.js new file mode 100644 index 0000000..dddc7b1 --- /dev/null +++ b/dist/jquery.jsForm.1.0.8.min.js @@ -0,0 +1,6 @@ +/*! + * jQuery.jsForm v1.0.8 | (c) 2013 Niko Berger http://www.gargan.org/ + * Usage: https://github.com/corinis/jsForm + */ +(function(t,e,a){"use strict";function i(e,a){var i=t(e);this.options=t.extend({},{controls:!0,data:null,prefix:"data",validateHidden:!0,skipEmpty:!1},a),!i.attr("data-prefix")||"data"!==this.options.prefix&&""!==this.options.prefix||""!==i.attr("data-prefix")&&(this.options.prefix=i.attr("data-prefix")),this.element=e,this._init()}var s={},n={};i.prototype._init=function(){if(this._domInit(),this.options.controls)if(t.jsFormControls)t(this.element).jsFormControls();else try{"undefined"!=typeof console&&console.log("jquery.JsForm.controls not available!")}catch(e){}this._fill(this.element,this.options.data,this.options.prefix)},i.prototype._domInit=function(){var e=t(this.element),a=this,i=this.options.prefix;a._initCollection(e,i)},i.prototype._debug=function(t){"undefined"!=typeof console&&console.log("JsForm: "+t)},i.prototype._initCollection=function(e,a){var i={},s=this;t(e).data().collections=i,t(".collection",e).each(function(){var e=t(this).attr("data-field");if(e&&0===e.indexOf(a+".")){var n=t(this),r=i[e];if(r?r.push(n):i[e]=[n],s._initList(n),!n.hasClass("ui-sortable")&&n.hasClass("sortable")&&n.sortable){var o=n.attr("data-sortable");o=o?JSON.parse(o):{},n.sortable(o),n.on("sortstop",function(){s._reorder(n)})}}}),t(".add",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections")||(t(this).data().collections=i[e],t(this).click(function(a){a.preventDefault(),t.each(t(this).data("collections"),function(){var a=t(this).data("template");if(a){var i=a.clone(!0);t(this).append(i),t(i).addClass("POJO"),t(i).data("pojo",{}),s._addCollectionControls(i),t(this).trigger("addCollection",[i,t(i).data().pojo]),s._fillData(i,t(i).data().pojo,e.substring(e.indexOf(".")+1)),s._initCollection(i,e.substring(e.indexOf(".")+1)),t(this).trigger("postAddCollection",[i,t(i).data().pojo])}})})))}),t(".insert",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections")||(t(this).data("collections",i[t(this).attr("data-field")]),t(this).on("insert",function(a,i){if(i||(i=t(this).data().pojo),i){var n=t(this).data("beforeInsert");n&&t.isFunction(n)&&!(i=n(i))||(t.each(t(this).data("collections"),function(){var a=t(this).data("template");if(a){var n=a.clone(!0);n.addClass("POJO"),n.data().pojo=i,s._addCollectionControls(n),s._initCollection(n),t(this).trigger("addCollection",[n,t(n).data().pojo]),s._fillData(n,i,e.substring(e.indexOf(".")+1)),t(this).append(n)}}),t(this).val(""),t(this).data().pojo=null,t(this).focus())}})))}),t(".insertAction",e).each(function(){var e=t(this).attr("data-field");if(e&&!t(this).data("inserter")){var a=t(this).parent().find(".insert");a&&(t(this).data("inserter",a),t(this).click(function(e){return e.preventDefault(),t(this).data("inserter").trigger("insert"),!1}))}}),t("input.object",e).each(function(){t(this).on("update",function(){var e=t(this).data().pojo;e&&t(this).attr("data-display")&&t(this).val(s._renderObject(e,t(this).attr("data-display")))})}),t("input.blob",e).each(function(){if("file"===t(this).attr("type")){var e=t(this);t(this).on("change",function(a){var i=t(this).val().split(/\\/).pop();e.data("name",i);var s=a.target.files;s&&s.length&&t.each(s,function(){var a=new FileReader;a.onload=function(t){e.data("blob",t.target.result)},a.readAsDataURL(this),t(this).trigger("fileChange")})})}}),t(".manage",e).each(function(){var e=t(this).attr("data-field");e&&(t(this).data("collections",i[e]),t(this).click(function(){var a=t(this).attr("data-service"),i=t(this).data("collections"),n=t(this),r=t(this).attr("data-display");r&&(r=r.split(",")),DataUtils.run(a,function(a){var o=t('');o.data("collections",i),n.data("select",o),t.each(a,function(){var e=this,a="";if(r)for(var s=0;r.length>s;s++)a+=e[r[s]]+" ";else a=e;var n=t('");t(i).each(function(){t(this).children().each(function(a,i){e.id===t(i).data("pojo").id&&n.attr("selected","selected")})}),o.append(n),n.data("pojo",e)}),n.after(o),n.hide(),o.multiselect({autoOpen:!0,open:function(){t(this).multiselect("widget").css("top",t(o).next().offset().top),t(this).multiselect("widget").css("left",t(o).next().offset().left),t(o).next().hide()},close:function(){n.show(),o.remove(),t(this).multiselect("destroy")}}).multiselectfilter().bind("multiselectclick multiselectcheckall multiselectuncheckall",function(){var a=t.map(t(this).multiselect("getChecked"),function(e){return t("option[value='"+e.value+"']",o).data("pojo")});t.each(t(o).data("collections"),function(){s._fillList(t(this),a,e)}),n.hide(),t(o).next().show(),t(this).multiselect("widget").css("top",t(o).next().offset().top),t(this).multiselect("widget").css("left",t(o).next().offset().left),t(o).next().hide()})})}))})},i.prototype._initList=function(t){if(!t.data("template")){var e=t.children().detach();e.removeAttr("id"),t.data("template",e)}},i.prototype._clear=function(e,a){a||(a=this.options.prefix),t(e).removeData("pojo"),t("input,select,textarea",e).each(function(){var e=t(this).attr("name");e&&0===e.indexOf(a+".")&&(e=e.substring((a+".").length),1>e.length||(t(this).removeData("pojo"),"checkbox"===t(this).attr("type")?t(this).prop("checked",!1):t(this).val(""),t(this).hasClass("blob")&&t(this).removeData("blob"),t(this).is("select")&&(t('option[selected="selected"]',this).removeAttr("selected"),t("option:first",this).attr("selected",!0),t(this).val(t("option:first",this).val()).change()),t(this).change()))}),t(".collection",e).each(function(){var e=t(this).attr("data-field");e&&0===e.indexOf(a+".")&&t(this).empty()})},i.prototype._createPojoFromInput=function(e,i,s){var n=null,r=this;return t(e).data("pojo")&&(n=t(e).data("pojo")),n&&t.extend(!0,s,n),t(e).find("input,select,textarea,.jsobject").each(function(){var e=t(this).attr("data-name");if(e||(e=t(this).attr("name")),e&&!t(this).hasClass("transient")&&0===e.indexOf(i+".")){t(this).trigger("validate",!0),e=e.substring((i+".").length);var n=t(this).val();if(t(this).hasClass("jsobject")&&(n=t(this).data("pojo")),!r.options.skipEmpty||n&&""!==n&&""!==n.trim()){if(!t(this).hasClass("emptynull")||n&&""!==n&&"null"!==n&&""!==n.trim()?t(this).hasClass("object")||t(this).hasClass("POJO")?n=t("option:selected",this).data()&&t("option:selected",this).data().pojo?t("option:selected",this).data().pojo:t(this).data("pojo"):t(this).hasClass("blob")?n=t(this).data("blob"):""===n&&(t(this).hasClass("number")||t(this).hasClass("integer")||t(this).hasClass("dateFilter")||t(this).hasClass("dateTimeFilter"))&&(n=null):n=null,t(this).hasClass("percent")&&(n=r._getNumber(n),isNaN(n)?n=0:n/=100),t(this).hasClass("number")||t(this).hasClass("integer")||t(this).hasClass("currency")?(n=r._getNumber(n),isNaN(n)&&(n=0)):"checkbox"===t(this).attr("type")||"CHECKBOX"===t(this).attr("type")?n=t(this).is(":checked"):t(this).hasClass("bool")&&(n="true"===t(this).val()),1>e.length)return s=n,!1;if(-1===e.indexOf("."))s[e]=n;else{var o,l,h=e.split("."),d=s[h[0]];d&&t.isPlainObject(d)||(s[h[0]]={},d=s[h[0]]),2===h.length?d[h[1]]=n:3===h.length?(o=d[h[1]],o===a&&(o={},d[h[1]]=o),o[h[2]]=n):4===h.length&&(o=d[h[1]],l=o[h[2]],l===a&&(l={},o[h[2]]=l),o[h[2]]=n,l[h[3]]=n)}}}}),s},i.prototype._fillData=function(e,i,s){var n=this,r=t(e);r.find(".field").each(function(){var e=t(this).data("name");if(e||("A"===this.nodeName.toUpperCase()?(e=t(this).attr("href"),t(this).attr("href","#")):"IMG"===this.nodeName.toUpperCase()?(e=t(this).attr("src"),0===e.indexOf("#")&&(e=e.substring(1)),t(this).attr("src","#")):e=t(this).text(),t(this).data("name",e),t(this).show()),!s||e.indexOf(s+".")>=0){var a=e;s&&(a=a.substring(s.length+1));var r=n._get(i,a);r||(r=""),t(this).hasClass("percent")&&!isNaN(r)&&(r=100*Number(r)),t.jsFormControls&&(r=t.jsFormControls.Format.format(this,r)),"A"===this.nodeName.toUpperCase()?t(this).attr("href",r):"IMG"===this.nodeName.toUpperCase()?t(this).attr("src",r):"DIV"===this.nodeName.toUpperCase()?t(this).html(r):t(this).text(r)}}),t("input",r).each(function(){var e=t(this).attr("name");if(e&&"file"!=t(this).attr("type")&&(!s||e.indexOf(s+".")>=0)){var a=e;s&&(a=a.substring(s.length+1));var r=n._get(i,a);t(this).hasClass("percent")&&!isNaN(r)?r=100*Number(r):t.isPlainObject(r)&&(t(this).data().pojo=r,t(this).addClass("POJO"),r=n._renderObject(r,t(this).attr("data-display"))),"checkbox"===t(this).attr("type")?(t(this).prop("checked",r===!0||"true"===r),t(this).change()):(r||(r=""),t.jsFormControls&&(r=t.jsFormControls.Format.format(this,r)),t(this).val(r),t(this).change())}}),t("select",r).each(function(){var e=t(this).attr("name");if(e&&(!s||e.indexOf(s+".")>=0)){var r=e;s&&(r=r.substring(s.length+1)),t(this).children("option").removeAttr("selected");var o=t(this).attr("data-key");o||(o="id");var l=n._get(i,r);if(l[o]||!isNaN(l[o]))return t(this).children("option[value='"+l[o]+"']").attr("selected",!0),t(this).val(l[o]).change(),a;t(this).hasClass("bool")&&(l=l?"true":"false"),t(this).children("option[value='"+l+"']").attr("selected",!0),t(this).val(l).change()}}),t("textarea",r).each(function(){var e=t(this).attr("name");if(e&&(!s||e.indexOf(s+".")>=0)){var a=e;s&&(a=a.substring(s.length+1)),t(this).val(n._get(i,a)),t(this).change()}})},i.prototype.get=function(e){var a=t(this.element),i=this,s=this.options.data,n=this.options.prefix,r={};s&&t.isPlainObject(s)&&(r=s),i._createPojoFromInput(a,n,r);var o=!1;return this.options.validateHidden?a.find(".invalid").each(function(){return o=!0,t(this).focus(),!1}):a.find(".invalid").filter(":visible").each(function(){return o=!0,t(this).focus(),e||i._debug("Found invalid field: "+t(this).attr("name")),!1}),this._getCollection(a,n,r,e)&&(o=!0),!e&&o?null:r},i.prototype._getCollection=function(e,a,i,s){var n=this,r=!1;return e.find(".collection").each(function(){if(s||!r){var e=t(this).attr("data-field");if(e&&0===e.indexOf(a+".")&&(e=e.substring((a+".").length),!(1>e.length))){var o=n._getParent(i,e,!0);-1!==e.indexOf(".")&&(e=e.substring(e.lastIndexOf(".")+1)),o[e]=[],t(this).children().each(function(){if(s||!r){var a={};a=n._createPojoFromInput(t(this),e,a),n._getCollection(t(this),e,a,s),n._isEmpty(a)?t(".invalid",this).removeClass("invalid"):(t(".invalid",this).length>0&&(r=!0),o[e].push(a))}})}}}),r},i.prototype.getData=function(){return this.options.data||(this.options.data={}),this.options.data},i.prototype.preventEditing=function(e){var i=t(this.element);if(e===a)e=i.data("disabled")?!1:!0;else if(e===i.data("disabled"))return;e?(i.find("input, textarea").each(function(){if(!t(this).closest("span.form")[0]&&"hidden"!=t(this).attr("type")){var e=t(this).val();("null"===e||null===e||"submit"===t(this).attr("type"))&&(e=""),t(this).hasClass("trueFalse")&&(e=t(this).is(":checked")?"X":" "),e=e.replace(//g,">").replace(/\n/g,"
");var a=t(''+e+"");t(this).parent().hasClass("ui-wrapper")?t(this).parent().hide().wrap(a):t(this).hide().wrap(a)}}),i.find("select").each(function(){if(!t(this).closest("span.form")[0]){var e=t(this).children(":selected").html();("null"===e||null===e)&&(e="");var a=t(''+e+"");t(this).hasClass("ui-toggle-switch")?t(this).prev().hide().wrap(a):t(this).hide().wrap(a)}})):i.find("span.form").each(function(){var e=t(this).children("input,select,textarea,.ui-wrapper,.ui-toggle-switch").show().detach();t(this).before(e),t(this).remove()}),i.data("disabled",e)},i.prototype.validate=function(){return t(".required,.regexp,.date,.mandatory,.number,.validate,.integer",this.element).change(),t(".invalid",this.element).length>0?!1:!0},i.prototype._fill=function(e,a,i){i||(i=this.config.prefix),this._clear(e,i),t(e).addClass("POJO"),t(e).data("pojo",a),this._fillData(e,a,i),this._fillCollection(e,a,i)},i.prototype._fillCollection=function(e,a,i){var s=this;t(".collection",e).each(function(){var e=t(this),n=t(this).attr("data-field");if(a&&n&&0===n.indexOf(i+".")){var r=null,o=n;i&&(o=o.substring(i.length+1)),r=s._get(a,o),r&&s._fillList(e,r,o)}})},i.prototype._fillList=function(e,a,i,s){var n=e.data("template"),r=this;if(n&&(e.empty(),t.isArray(a))){if(-1!==i.indexOf(".")&&(i=i.substring(i.lastIndexOf(".")+1)),t(e).hasClass("sort")){var o=t(e).attr("data-sort");if(o){switch(t(e).attr("data-sorttype")){case"alpha":a.sort();break;case"alphainsensitiv":a.sort(function(t,e){return t=t[o],e=e[o],t&&(t=t.toLowerCase()),e&&(e=e.toLowerCase()),e>t?-1:t>e?1:0});break;default:a.sort(function(t,e){return t[o]-e[o]})}t(e).attr("data-sortdesc")&&a.reverse()}}s||t.isFunction(i)&&(s=i,i=null);for(var l=0;a.length>l;l++){var h=a[l],d=n.clone(!0);d.data("pojo",h),d.addClass("POJO"),s&&s(d,h)===!1||(r._addCollectionControls(d),i&&(r._fillData(d,h,i),r._initCollection(d,i),r._fillCollection(d,h,i)),e.append(d))}}},i.prototype._addCollectionControls=function(e){var a=this;t.jsFormControls&&t(e).jsFormControls(),t(".delete",e).click(function(){var e=t(this).closest(".POJO");t(this).closest(".collection").trigger("deleteCollection",[e,t(e).data().pojo]),e.remove()}),t(".sortUp",e).click(function(){var e=t(this).closest(".POJO"),i=e.prev(".POJO");0!==i.size()&&(e.detach(),i.before(e),a._reorder(e))}),t(".sortDown",e).click(function(){var e=t(this).closest(".POJO"),i=e.next(".POJO");0!==i.size()&&(e.detach(),i.after(e),a._reorder(e))});var i=t(e).closest(".collection");i.hasClass("sortable")&&t(i).sortable&&i.sortable("refresh")},i.prototype._reorder=function(e){e.attr("data-sort")||(e=e.closest(".collection"));var a=t(e).attr("data-sort");if(!(!a||t(e).attr("data-sorttype")&&"number"!==t(e).attr("data-sorttype")||t(e).attr("data-sortdesc")&&"false"!==t(e).attr("data-sortdesc"))){var i=0;t.each(t(e).children(),function(){var e=t(this).data("pojo");e||(e={},t(this).data("pojo",e)),e[a]=i++})}},i.prototype._renderObject=function(e,a){if(!a||!e)return"";var i=this,s="";return t.each(a.split(","),function(){var t=this.trim();s+=0===t.indexOf("'")||0===t.indexOf('"')?t.substring(1,t.length-1):i._get(e,t)}),s},i.prototype._get=function(t,e,i){var s,n,r,o="";if("function"==typeof e)return e(t);if(!t)return"";if(""===e)return t;if(s=t[e],!s)try{if("string"==typeof e&&(o=e.split(".")),r=o.length)for(s=t;s&&r--;)n=o.shift(),i&&!s[n]&&(s[n]={}),s=s[n]}catch(l){}return(null===s||s===a)&&(s=""),s.trim?s.trim():s},i.prototype._getParent=function(t,e,a){return-1===e.indexOf(".")?t:(e=e.substring(0,e.lastIndexOf(".")),this._get(t,e,a))},i.prototype._getNumber=function(e){return e?t.format?t.format.number(e):((-1!=e.indexOf(",")||e.length-e.indexOf(".")>3)&&(e=e.replace(/\./g,"").replace(",",".")),Number(e)):null},i.prototype._isEmpty=function(e){if(!e)return!0;if(t.isArray(e)){if(0===e.length)return!0;for(var a=0;e.length>a;a++)if(!this._isEmpty())return!1;return!0}if(t.isPlainObject(e)){if(t.isEmptyObject(e))return!0;for(var i in e)if(!this._isEmpty(e[i]))return!1;return!0}return isNaN(e)?""===e||" "===e:0===Number(e)||-1===Number(e)?!0:!1},i.prototype._pojoDifferFromInput=function(e,i,s){var n=!1;return t("input,select,textarea",e).each(function(){if(!n){var e=t(this).attr("name");if(e&&!(t(this).hasClass("transient")||0!==e.indexOf(i+".")||(e=e.substring((i+".").length),1>e.length))){var r=t(this).val();if(""===r&&(t(this).hasClass("number")||t(this).hasClass("dateFilter")||t(this).hasClass("dateTimeFilter"))&&(r=null),(t(this).hasClass("number")||t(this).hasClass("currency"))&&(r=that._getNumber(r),isNaN(r)&&(r=0)),("checkbox"===t(this).attr("type")||"CHECKBOX"===t(this).attr("type"))&&(r=t(this).is(":checked")),-1===e.indexOf("."))s[e]!==r&&(n=!0);else{var o,l,h=e.split("."),d=s[h[0]];if(!d)return n=!0,a;2===h.length?d[h[1]]!==r&&(n=!0):3===h.length?(o=d[h[1]],o[h[2]]!==r&&(n=!0)):4===h.length&&(o=d[h[1]],l=o[h[2]],l[h[3]]!==r&&(n=!0))}}}}),n},i.prototype.equals=function(e){var i=this,s=this.element,n=this.options.prefix;if(this._pojoDifferFromInput(s,n,e))return!1;var r=!1;return t(".invalid",s).length>0?!1:(t(".collection",s).each(function(){if(!r){var s=t(this).attr("data-field");if(s&&0===s.indexOf(n+".")&&(s=s.substring((n+".").length),!(1>s.length))){var o=0;t(this).children().each(function(){if(!r){if(o>=e[s].length)return r=!0,a;var n=e[s][o++];i._pojoDifferFromInput(t(this),s,n)&&(r=!0)}}),e[s].length>o&&(r=!0)}}}),!r)},i.prototype.fill=function(t){this.options.data=t,this._fill(this.element,this.options.data,this.options.prefix)},i.prototype.reset=function(){this.clear(),this._fill(this.element,this.options.data,this.options.prefix)},i.prototype.clear=function(){this._clear(this.element,this.options.prefix)},i.prototype.destroy=function(){return t(this.element).each(function(){t(e).unbind(".jsForm"),t(this).removeData("jsForm")})},t.fn.jsForm=function(e){if("object"!=typeof e&&e){var s,n=Array.prototype.slice.call(arguments,1);if(0===this.length)return null;if(1===this.length&&(s=t(this).data("jsForm"))){if(0!==e.indexOf("_")&&s[e]){var r=s[e].apply(s,n);return r}return t.error("Method "+e+" does not exist on jQuery.jsForm"),!1}return this.each(function(){return s=t.data(this,"jsForm"),s?0!==e.indexOf("_")&&s[e]?s[e].apply(s,n):(t.error("Method "+e+" does not exist on jQuery.jsForm"),!1):a})}return this.each(function(){t(this).data("jsForm")||t(this).data("jsForm",new i(this,e))})},t.jsForm=function(e,a){var i=n[e];if(t.isFunction(a))i&&t.each(i,function(){a(this,t(this.element))}),s[e]=a;else if(i){var r=a,o=Array.prototype.slice.call(arguments,2);t.each(portlets,function(){this[r].apply(this,o)})}}})(jQuery,window),function(t){"use strict";function e(t){this.element=t,this._domInit()}var a={},i={};"undefined"!=typeof Handlebars&&(Handlebars.registerHelper("currency",function(e){return e?t.jsFormControls.Format.currency(e):"0"}),Handlebars.registerHelper("dec",function(e){return e?t.jsFormControls.Format.decimal(e):""}),Handlebars.registerHelper("percent",function(e){return e?t.jsFormControls.Format.decimal(100*e):"0"}),Handlebars.registerHelper("date",function(e){return e?t.jsFormControls.Format.date(e):""}),Handlebars.registerHelper("time",function(e){return e?t.jsFormControls.Format.time(e):""}),Handlebars.registerHelper("datetime",function(e){return e?t.jsFormControls.Format.dateTime(e):""}),Handlebars.registerHelper("dateTime",function(e){return e?t.jsFormControls.Format.dateTime(e):""}),Handlebars.registerHelper("timespan",function(e){return e?t.jsFormControls.Format.humanTime(e):""}),Handlebars.registerHelper("byte",function(e){return e?t.jsFormControls.Format.byte(e):""})),e.prototype._domInit=function(){var e=t(this.element);e.find("input.mandatory,textarea.mandatory").on("keyup",function(){t(this).val().length>0&&"null"!==t(this).val()?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}),e.find("input.mandatory,textarea.mandatory").on("change",function(){return t(this).hasClass("object")?(t(this).data().pojo?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"),undefined):(t(this).val().length>0&&"null"!==t(this).val()?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"),undefined)}).change(),e.find("select.mandatory").change(function(){null!==t(this).val()&&"null"!==t(this).val()&&t(this).val().length>0?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}).change(),e.find("input.date").each(function(){var e=t(this).attr("data-format");t(this).datepicker&&(e?t(this).datepicker({dateFormat:e}):t(this).datepicker())});var a=RegExp("^[0-9.,-]+$");e.find("input.number").keyup(function(){var e=t(this).val();e.length>0&&(t(this).hasClass("autoclean")?t(this).val(e.replace(/[^0-9.,-]/g,"")):a.test(t(this).val())?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"))}).keyup();var i=RegExp("^[0-9]+$");e.find("input.integer").keyup(function(){var e=t(this).val();e.length>0&&(t(this).hasClass("autoclean")?t(this).val(e.replace(/[^0-9]/g,"")):i.test(t(this).val())?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid"))}).keyup(),e.find("input.regexp").each(function(){t(this).hasClass("autoclean")?t(this).data("regexp",RegExp(t(this).attr("data-regexp"),"g")):t(this).data("regexp",RegExp(t(this).attr("data-regexp"))),t(this).keyup(function(){var e=t(this).val();if(e.length>0){var a=t(this).data("regexp");t(this).hasClass("autoclean")?t(this).val(e.replace(a,"")):a.test(t(this).val())?t(this).addClass("valid").removeClass("invalid"):t(this).removeClass("valid").addClass("invalid")}else t(this).hasClass("mandatory")||t(this).removeClass("invalid").addClass("valid")}).keyup(),t(this).change(function(){t(this).keyup()})}),e.find("input.rotatestate").each(function(){var e=t(this).attr("data-state-values"),a=t(this).attr("data-state-class");if(e){try{e=JSON.parse(e)}catch(i){return}var s=t("");t(this).attr("title")&&s.attr("title",t(this).attr("title")),t(this).attr("data-state-style")&&s.attr("style",t(this).attr("data-state-style")),s.data("states",e),s.data("control",this),s.data("activeState",null),t(this).data("control",s),a&&s.addClass(a),s.click(function(){var e=t(this).data().activeState,a=t(this).data().states,i=t(this).data().control,s=null;if(null!==e){for(var n=0;a.length>n;n++)if(a[n].value===e.value){s=n===a.length-1?a[0]:a[n+1];break}}else s=a[0];t(i).attr("value",s.value),t(i).change()}),t(this).change(function(){var e=t(t(this).data().control),a=e.data().activeState,i=e.data().states;null!==a&&e.removeClass(a["class"]);var s=t(this).val();t.each(i,function(){return this.value===s?(e.data().activeState=this,this.title&&e.attr("title",this.title),e.addClass(this["class"]),!1):undefined})}),t(this).change(),t(this).after(s),t(this).hide()}})},e.prototype.validate=function(){return t(".required,.regexp,.date,.mandatory,.number,.validate",this.element).change(),t(".invalid",this.element).length>0?!1:!0},t.fn.jsFormControls=function(a){if("object"!=typeof a&&a){var i=Array.prototype.slice.call(arguments,1);if(1==this.length){var s=t(this).data("jsFormControls");if(s){if(0!==a.indexOf("_")&&s[a]){var n=s[a].apply(s,i);return n}return t.error("Method "+a+" does not exist on jQuery.jsFormControls"),!1}}return this.each(function(){var e=t.data(this,"jsFormControls");return e?0!==a.indexOf("_")&&e[a]?e[a].apply(e,i):(t.error("Method "+a+" does not exist on jQuery.jsFormControls"),!1):undefined})}return this.each(function(){t(this).data("jsFormControls")||t(this).data("jsFormControls",new e(this,a))})},t.jsFormControls=function(e,s){var n;if(t.isFunction(s))n=i[e],n&&t.each(n,function(){s(this,t(this.element))}),a[e]=s;else if(n=i[e]){var r=s,o=Array.prototype.slice.call(arguments,2);t.each(portlets,function(){this[r].apply(this,o)})}},t.jsFormControls.Format={format:function(e,a){return t(e).hasClass("dateTime")?t.jsFormControls.Format.dateTime(a):t(e).hasClass("datetime")?t.jsFormControls.Format.dateTime(a):t(e).hasClass("date")?t.jsFormControls.Format.date(a):t(e).hasClass("currency")?t.jsFormControls.Format.currency(a):t(e).hasClass("byte")?t.jsFormControls.Format.byte(a):t(e).hasClass("number")?t.jsFormControls.Format.decimal(a):a},checkBox:function(t,e,a){return a===undefined&&(a=t,t=null),a?' ':' '},_getNumber:function(e){return e?t.format?t.format.number(e):((-1!==e.indexOf(",")||e.length-e.indexOf(".")>3)&&(e=e.replace(/\./g,"").replace(",",".")),Number(e)):null},_pad:function(t){var e=10>t?"0":"";return e+=t},"byte":function(t){if(""===t||!t||isNaN(t))return t;var e=1024;if(e>t)return t+" B";var a=Math.floor(Math.log(t)/Math.log(e)),i="KMGTPE".charAt(a-1)+"B";return Math.round(10*t/Math.pow(e,a))/10+i},decimal:function(e){if(""===e||!e||isNaN(e))return e;var a={format:"#,##0.###",groupingSeparator:",",decimalSeparator:"."};if("undefined"!=typeof i18n&&(a=i18n.number),t(document).data().i18n!==undefined&&(a=t(document).data().i18n.number),t.format&&a)return t.format.number(e,a);var i=0;Math.abs(e-Math.floor(e))>.001&&(i=2);var s=e,n=isNaN(n=Math.abs(i))?2:i,r=a.decimalSeparator,o=a.groupingSeparator,l=parseInt(s=Math.abs(+s||0).toFixed(n),10)+"",h=(h=l.length)>3?h%3:0;return(0>e?"-":"")+(h?l.substr(0,h)+o:"")+l.substr(h).replace(/(\d{3})(?=\d)/g,"$1"+o)+(n?r+Math.abs(s-l).toFixed(n).slice(2):"")},currency:function(e,a,i){return(!i||isNaN(i))&&(i=e,e=null),i?t.jsFormControls.Format.decimal(i):a?" ":""},dateTime:function(t,e,a){return(!a||isNaN(a))&&(a=t,t=null),a?this.date(a)+" "+this.time(a):e?" ":""},date:function(e,a,i){if((!i||isNaN(i))&&(i=e,e=null),!i)return a?" ":"";var s=new Date;s.setTime(i);var n=s.getYear();1900>n&&(n+=1900);var r=null;return"undefined"!=typeof i18n&&(r=i18n.date),t(document).data().i18n!==undefined&&(r=t(document).data().i18n.date),t.format?t.format.date(s,r.shortDateFormat):this._pad(s.getDate())+"."+this._pad(s.getMonth()+1)+"."+this._pad(n)},time:function(e,a,i){if(i||(i=e,e=null),!i)return a?" ":"";var s=new Date;return s.setTime(i),t.format?t.format.date(s,t(document).data().i18n.date.timeFormat):this._pad(s.getHours())+":"+this._pad(s.getMinutes())},timespan:function(t,e,a,i,s,n){a||(a=t,n=e,t=null,e=null);for(var r=a.split(":"),o=0;r.length>o;o++){var l=Number(r[o]);l&&"NaN"!==l||(l=0),r[o]=this._pad(l)}return 0>=r.length?"0:00":1==r.length?"0:"+this._pad(allowkomma?r[0]:Math.floor(r[0])):2==r.length?allowkomma?r[0]:Math.floor(r[0])+":"+this._pad(allowkomma?r[1]:Math.floor(r[1])):allowkomma?r[0]:Math.floor(r[0])+":"+this._pad(allowkomma?r[1]:Math.floor(r[1]))+":"+pad(allowkomma?r[2]:Math.floor(r[2]))},humanTime:function(t,e,a){if(a||(a=t,t=null),isNaN(a))return a&&0!==a.length?a:"-";var i=Math.floor(a/36e5);a-=36e5*i;var s=Math.floor(a/6e4);a-=6e4*s;var n=Math.floor(a/1e3);a-=1e3*n;var r="";return i>0&&(r+=i+"h ",n=0,a=0),s>0&&(r+=s+"m ",a=0),n>0&&(r+=n+"s ",a=0),a>0&&(r+=a+"ms"),r.trim()}}}(jQuery,window),String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")},String.prototype.startsWith=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length?!1:this.substr(0,t.length)==t?!0:!1},String.prototype.startsWithIgnoreCase=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length?!1:this.substr(0,t.length).toLowerCase()==t.toLowerCase()?!0:!1},String.prototype.endsWith=function(t){return null===this||0>=this.length?!1:null===t||"null"==t||0>=t.length||t.length>this.length?!1:this.substr(this.length-t.length)==t?!0:!1}; +//@ sourceMappingURL=dist/jquery.jsForm.min.map \ No newline at end of file diff --git a/dist/jquery.jsForm.min.map b/dist/jquery.jsForm.min.map index 5f07bab..7dc58fc 100644 --- a/dist/jquery.jsForm.min.map +++ b/dist/jquery.jsForm.min.map @@ -1 +1 @@ -{"version":3,"file":"dist/jquery.jsForm.1.0.7.min.js","sources":["dist/jquery.jsForm-1.0.7.js"],"names":["$","window","undefined","JsForm","element","options","$this","this","extend","controls","data","prefix","validateHidden","skipEmpty","attr","_init","JSFORM_INIT_FUNCTIONS","JSFORM_MAP","prototype","_domInit","jsFormControls","console","log","ex","_fill","form","that","_initCollection","_debug","msg","collectionMap","collections","each","colName","indexOf","container","cols","push","_initList","hasClass","sortable","config","JSON","parse","on","_reorder","fieldName","click","ev","preventDefault","tmpl","line","clone","append","addClass","_addCollectionControls","trigger","pojo","_fillData","substring","beforeInsertCallback","isFunction","val","focus","inserter","parent","find","_renderObject","blobInput","evt","fileName","split","pop","files","target","length","reader","FileReader","onload","e","result","readAsDataURL","dataService","collectionList","btn","display","DataUtils","run","select","cur","optionDisplay","j","option","children","count","ele","id","after","hide","multiselect","autoOpen","open","css","next","offset","top","left","close","show","remove","multiselectfilter","bind","checkedValues","map","input","value","_fillList","detach","removeAttr","_clear","removeData","name","prop","is","change","fieldname","empty","_createPojoFromInput","start","startObj","trim","_getNumber","isNaN","d1","d2","parts","d0","isPlainObject","$parent","nodeName","toUpperCase","text","cname","cdata","_get","Number","Format","format","html","pk","get","ignoreInvalid","originalPojo","invalid","filter","_getCollection","colParent","_getParent","lastIndexOf","_isEmpty","removeClass","getData","preventEditing","prevent","closest","replace","thespan","wrap","prev","before","validate","_fillCollection","colData","lineFunc","isArray","sortField","sort","a","b","toLowerCase","reverse","i","size","prio","obj","skin","ret","expr","create","p","prm","shift","num","number","isEmptyObject","f","_pojoDifferFromInput","differs","equals","childCounter","fill","reset","clear","destroy","unbind","fn","jsForm","method","args","Array","slice","call","arguments","apply","error","initFunc","jsForms","portlets","jQuery","JsFormControls","Handlebars","registerHelper","currency","decimal","date","time","dateTime","humanTime","byte","location","datepicker","dateFormat","numberRegexp","RegExp","keyup","test","integerRegexp","regexp","states","defaultClass","stateControl","cState","activeState","cStates","control","newState","title","checkBox","row","cell","_pad","o","bytes","unit","exp","Math","floor","pre","charAt","round","pow","numberformat","groupingSeparator","decimalSeparator","i18n","document","comma","abs","n","c","d","t","parseInt","toFixed","substr","cellvalue","Date","setTime","year","getYear","dateformat","shortDateFormat","getDate","getMonth","timeFormat","getHours","getMinutes","timespan","columnDef","dataContext","allowcomma","tokens","nt","allowkomma","pad","h","m","s","out","String","startsWith","str","startsWithIgnoreCase","endsWith"],"mappings":"CASC,SAAWA,EAAGC,EAAQC,GACtB,YAWA,SAASC,GAAQC,EAASC,GACzB,GAAIC,GAAQN,EAAEI,EAGdG,MAAKF,QAAUL,EAAEQ,WAIhBC,UAAU,EAIVC,KAAM,KAINC,OAAQ,OAKRC,gBAAgB,EAIhBC,WAAW,GACTR,IAGAC,EAAMQ,KAAK,gBAA2C,SAAxBP,KAAKF,QAAQM,QAA6C,KAAxBJ,KAAKF,QAAQM,QAC9C,KAA9BL,EAAMQ,KAAK,iBACbP,KAAKF,QAAQM,OAASL,EAAMQ,KAAK,gBAInCP,KAAKH,QAAUA,EAEfG,KAAKQ,QA9CN,GAAIC,MACJC,IAoDAd,GAAOe,UAAUH,MAAQ,WAKxB,GAHAR,KAAKY,WAGFZ,KAAKF,QAAQI,SACf,GAAGT,EAAEoB,eACJpB,EAAEO,KAAKH,SAASgB,qBAEhB,KACuB,mBAAZC,UACTA,QAAQC,IAAI,yCAEZ,MAAMC,IAOVhB,KAAKiB,MAAMjB,KAAKH,QAASG,KAAKF,QAAQK,KAAMH,KAAKF,QAAQM,SAS1DR,EAAOe,UAAUC,SAAW,WAC3B,GAAIM,GAAOzB,EAAEO,KAAKH,SACdsB,EAAOnB,KACPI,EAASJ,KA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AELsL,EAAI,IACPC,GAAOD,EAAI,KACXtL,EAAQ,GAGLA,EAAQ,IACXuL,GAAOvL,EAAQ,MAGTuL,EAAIxK,UAIXwF,OAAQzN,QAMZ0S,OAAOzR,UAAUgH,KAAO,WACvB,MAAO3H,MAAK8J,QAAQ,aAAc,KAInCsI,OAAOzR,UAAU0R,WAAa,SAASC,GACtC,MAAa,QAATtS,MAAkC,GAAfA,KAAKoE,QACpB,EACI,OAARkO,GAAyB,QAAPA,GAAiC,GAAdA,EAAIlO,QACrC,EACLpE,KAAK2Q,OAAO,EAAG2B,EAAIlO,SAAWkO,GACzB,GACD,GAIRF,OAAOzR,UAAU4R,qBAAuB,SAASD,GAChD,MAAa,QAATtS,MAAkC,GAAfA,KAAKoE,QACpB,EACI,OAARkO,GAAyB,QAAPA,GAAiC,GAAdA,EAAIlO,QACrC,EACLpE,KAAK2Q,OAAO,EAAG2B,EAAIlO,QAAQwG,eAAiB0H,EAAI1H,eAC3C,GACD,GAIRwH,OAAOzR,UAAU6R,SAAW,SAASF,GACpC,MAAa,QAATtS,MAAkC,GAAfA,KAAKoE,QACpB,EACI,OAARkO,GAAyB,QAAPA,GAAiC,GAAdA,EAAIlO,QAAiBkO,EAAIlO,OAASpE,KAAKoE,QACxE,EACLpE,KAAK2Q,OAAO3Q,KAAKoE,OAASkO,EAAIlO,SAAWkO,GACpC,GACD"} \ No newline at end of file +{"version":3,"file":"dist/jquery.jsForm.1.0.8.min.js","sources":["dist/jquery.jsForm-1.0.8.js"],"names":["$","window","undefined","JsForm","element","options","$this","this","extend","controls","data","prefix","validateHidden","skipEmpty","attr","_init","JSFORM_INIT_FUNCTIONS","JSFORM_MAP","prototype","_domInit","jsFormControls","console","log","ex","_fill","form","that","_initCollection","_debug","msg","collectionMap","collections","each","colName","indexOf","container","cols","push","_initList","hasClass","sortable","config","JSON","parse","on","_reorder","fieldName","click","ev","preventDefault","tmpl","line","clone","append","addClass","_addCollectionControls","trigger","pojo","_fillData","substring","beforeInsertCallback","isFunction","val","focus","inserter","parent","find","_renderObject","blobInput","evt","fileName","split","pop","files","target","length","reader","FileReader","onload","e","result","readAsDataURL","dataService","collectionList","btn","display","DataUtils","run","select","cur","optionDisplay","j","option","children","count","ele","id","after","hide","multiselect","autoOpen","open","css","next","offset","top","left","close","show","remove","multiselectfilter","bind","checkedValues","map","input","value","_fillList","detach","removeAttr","_clear","removeData","name","prop","is","change","fieldname","empty","_createPojoFromInput","start","startObj","trim","_getNumber","isNaN","d1","d2","parts","d0","isPlainObject","$parent","nodeName","toUpperCase","text","cname","cdata","_get","Number","Format","format","html","pk","get","ignoreInvalid","originalPojo","invalid","filter","_getCollection","colParent","_getParent","lastIndexOf","_isEmpty","removeClass","getData","preventEditing","prevent","closest","replace","thespan","wrap","prev","before","validate","_fillCollection","colData","lineFunc","isArray","sortField","sort","a","b","toLowerCase","reverse","i","size","prio","obj","skin","ret","expr","create","p","prm","shift","num","number","isEmptyObject","f","_pojoDifferFromInput","differs","equals","childCounter","fill","reset","clear","destroy","unbind","fn","jsForm","method","args","Array","slice","call","arguments","apply","error","initFunc","jsForms","portlets","jQuery","JsFormControls","Handlebars","registerHelper","currency","decimal","date","time","dateTime","humanTime","byte","location","datepicker","dateFormat","numberRegexp","RegExp","keyup","test","integerRegexp","regexp","states","defaultClass","stateControl","cState","activeState","cStates","control","newState","title","checkBox","row","cell","_pad","o","bytes","unit","exp","Math","floor","pre","charAt","round","pow","numberformat","groupingSeparator","decimalSeparator","i18n","document","comma","abs","n","c","d","t","parseInt","toFixed","substr","cellvalue","Date","setTime","year","getYear","dateformat","shortDateFormat","getDate","getMonth","timeFormat","getHours","getMinutes","timespan","columnDef","dataContext","allowcomma","tokens","nt","allowkomma","pad","h","m","s","out","String","startsWith","str","startsWithIgnoreCase","endsWith"],"mappings":"CASC,SAAWA,EAAGC,EAAQC,GACtB,YAWA,SAASC,GAAQC,EAASC,GACzB,GAAIC,GAAQN,EAAEI,EAGdG,MAAKF,QAAUL,EAAEQ,WAIhB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GACD,GAIRwH,OAAOzR,UAAU6R,SAAW,SAASF,GACpC,MAAa,QAATtS,MAAkC,GAAfA,KAAKoE,QACpB,EACI,OAARkO,GAAyB,QAAPA,GAAiC,GAAdA,EAAIlO,QAAiBkO,EAAIlO,OAASpE,KAAKoE,QACxE,EACLpE,KAAK2Q,OAAO3Q,KAAKoE,OAASkO,EAAIlO,SAAWkO,GACpC,GACD"} \ No newline at end of file diff --git a/jsForm.jquery.json b/jsForm.jquery.json index 2361125..1b12af1 100644 --- a/jsForm.jquery.json +++ b/jsForm.jquery.json @@ -7,7 +7,7 @@ "json", "data" ], - "version": "1.0.7", + "version": "1.0.8", "author": { "name": "Niko Berger" }, diff --git a/package.json b/package.json index 7ebe3bf..d518d75 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "jquery.jsForm", - "title": "jQuery JSON Form", - "description": "jQuery based form library to handle data in js objects\nIt allows you to handle data within a javascript object (like from a JSON request) with plain html.\n\nThe main features of this library are:\n Full standard html with data available in a js object\n Update an existing js object with changes done within a form\n Provide basic functions for formatting (i.e. date/time, money) using html markup\n Provide form validation functionality\n handle collections (arrays) with subobjects\n provides helper methods to handle array manipulation (add new entry/remove an entry) using only html markup\n Can be used in connection with an autocomplete function to add new array objects", - "version": "1.0.7", + "title": "jQuery JSON Form - jsForm", + "description": "jQuery based form library to tansfer json objects to html forms and back.\nIt allows you to handle data within a javascript object (like from a AJAX request) and then modify all fields/properties by simply creating a html form with the correct naming schema.\n\nThe main features of this library are:\n Full standard html with data available in a js object\n Update an existing js object with changes done within a form\n Provide basic functions for formatting (i.e. date/time, money) using html markup\n Provide form validation functionality\n handle collections (arrays) with subobjects\n provides helper methods to handle array manipulation (add new entry/remove an entry) using only html markup\n Can be used in connection with an autocomplete function to add new array objects", + "version": "1.0.8", "homepage": "https://github.com/corinis/jsForm", "author": { "name": "Niko Berger",