diff --git a/cms/static/js/forms.js b/cms/static/js/forms.js new file mode 100644 index 0000000..f068d7a --- /dev/null +++ b/cms/static/js/forms.js @@ -0,0 +1,60 @@ +/*** + * + * This file build forms from a given set of specifications (in JSON) format + */ + +var _form =function(_id,_data) { + this._data = _data // {input,defaults,choices} + this._id = _id + // + // let's clean up the data : + this._data.defaults = (this._data.defaults == null)? {}:this._data.defaults + this._data.choices = (this._data.choices == null)?{}: this._data.choices + this.render = function (){ + _title = $('
').html(this._id).addClass(this._id) + var _input = this._data.input + var _defaults = this._data.defaults + var _choices = this._data.choices + + _input.forEach (_label=>{ + _value = _defaults[_label] + if (_choices[_label]){ + + }else{ + // + // This + + _input = this.get.input(_label,_value) + } + + }) + } + + this.get = {} + this.get.input = function (label,value){ + _frame = $('') + _label = $('').html(label) + _input = $('').attr('placeholder',label.0.replace(/_/,' ').trim()).addClass("input-"+label) + $(_input)[0].data = label + if (value){ + $(_input).val(value) + } + _frame.append(_label,_input) + return _frame + } + this.get.choice= function (label,_default,choices) { + var _input = this.get.input(label,_default) + $(input).addClass("hidden-input") + $(_input).on('click',function (){ + + }) + _pane = $('') + choices.forEach(_value=>{ + _option = $('