diff --git a/dist/jquery.kui.all.js b/dist/jquery.kui.all.js new file mode 100644 index 0000000..3fbf97f --- /dev/null +++ b/dist/jquery.kui.all.js @@ -0,0 +1,1953 @@ +/*! kui - v0.0.1 - 2015-01-16 +* https://github.com/konecta/kui +* Copyright (c) 2015 Nelson Paez; Licensed MIT */ +/*! + * + * +++++++++++++++++++++ Core +++++++++++++++++++++ + * + */ + +(function ($) { + + // Collection method. + $.fn.kui = function () { + return this.each(function (i) { + // Do something to each selected element. + $(this).html('kui' + i); + }); + }; + + // Static method. + $.kui = function (options) { + // Override default options with passed-in options. + options = $.extend({}, $.kui.options, options); + // Return the name of your plugin plus a punctuation character. + return 'kui' + options.punctuation; + }; + + // Static method default options. + $.kui.options = { + punctuation: '.' + }; + + // Custom selector. + $.expr[':'].kui = function (elem) { + // Does this element contain the name of your plugin? + return $(elem).text().indexOf('kui') !== -1; + }; + + // Formularios + $.kui.formulario = { + + nuevo_elemento: function(solo_lectura,elemento,item,campo){ + + /* + * Tipos de campo: + * - texto (no hace falta aclarar, es el tipo por defecto) + * - booleano + * - numero (enteros) + * - decimal + * - archivo + * - combo (requiere que se envíe "campo.opciones", que es un objeto que contiene: + * origen (requerido, puede ser una URL a un servicio o un array de objetos) + * id (requerido) + * formato (requerido) + * ajax (opcional, por defecto GET) + * data (opcional, por defecto { + _search false + filters null + page 1 + rows 10 + sidx // acá va el valor de campo.opciones.id + sord asc + todos true + }) + * - fecha + * - hora + * - fecha-hora + */ + + var input; + + var valor_input = function(){ + return typeof campo.formato === 'function'? + campo.formato.call(this,item[campo.nombre],item) + : item[campo.nombre]; + }; + + var crear_input_select = function(tipo){ + return $('<'+tipo+'>').addClass('form-control') + .attr('data-rol','input') + .attr('name',campo.nombre) + .attr('placeholder', + campo.placeholder===undefined? + campo.titulo : campo.placeholder) + .attr('title', + campo.mensaje===undefined? + 'El formato ingresado no es correcto para ' + campo.titulo : campo.mensaje) + .val(valor_input()) + .prop('required',campo.requerido); + }; + + var crear_input = function(icono){ + + if(campo.icono!==undefined){ + icono=campo.icono; + } + + var nuevo_input = crear_input_select('input'); + + if(campo.simple){ + nuevo_input.appendTo(elemento); + }else{ + var inputGroup = $('