-
Notifications
You must be signed in to change notification settings - Fork 42
/
autofields-bootstrap.min.js
6 lines (6 loc) · 5.33 KB
/
autofields-bootstrap.min.js
1
2
3
4
5
6
/**
* @license Autofields v2.2.8
* (c) 2021 Justin Maier http://justmaier.github.io/angular-autoFields-bootstrap
* License: MIT
*/
"use strict";angular.module("autofields.bootstrap",["autofields.standard","ui.bootstrap"]).config(["$autofieldsProvider",function(r){r.settings.classes.container.push("form-group"),r.settings.classes.input.push("form-control"),r.settings.classes.label.push("control-label"),r.registerHandler("checkbox",function(e,t,s){t=r.field(e,t,"<input/>");return t.label&&t.label.prepend(t.input),t.input.removeClass("form-control"),t.fieldContainer}),r.settings.dateSettings={datepickerPopup:"MMMM dd, yyyy"},r.settings.scope.datepickerOptions={showWeeks:!1},r.settings.scope.openCalendar=function(e,t,s){s.preventDefault(),s.stopPropagation(),e[t]=!e[t]},r.registerHandler("date",function(e,t,s){var n={type:"text",uibDatepickerPopup:t.datepickerPopup||e.options.dateSettings.datepickerPopup,datepickerOptions:e.options.datepickerOptions||"datepickerOptions",isOpen:"$property_cleanOpen"};return t.attr&&1==t.attr.disabled||(t.$addons=[{button:!0,icon:"glyphicon glyphicon-calendar",attr:{ngClick:'openCalendar("$property_cleanOpen",$event)'}}]),r.field(e,t,"<input/>",n).fieldContainer}),r.registerHandler("static",function(e,t,s){t.showWeeks||e.options.dateSettings.showWeeks,t.datepickerPopup||e.options.dateSettings.datepickerPopup;e=r.field(e,t,"<p/>"),t=angular.element("<p/>");return t.attr("ng-bind",e.input.attr("ng-model")),t.addClass("form-control-static"),e.input.replaceWith(t),e.fieldContainer}),r.settings.classes.row=r.settings.classes.row||[],r.settings.classes.row.push("row"),r.settings.classes.col=r.settings.classes.col||[],r.settings.classes.col.push("col-sm-$size"),r.settings.classes.colOffset=r.settings.classes.colOffset||[],r.settings.classes.colOffset.push("col-sm-offset-$size"),r.registerHandler("multiple",function(o,a,e){var i=angular.element("<div/>");return i.addClass(o.options.classes.row.join(" ")),angular.forEach(a.fields,function(e,t){var s=angular.element("<div/>"),n="multiple"!=e.type&&e.columns||a.columns;s.addClass(o.options.classes.col.join(" ").replace(/\$size/g,n)),s.append(r.createField(o,e,t)),i.append(s)}),i}),r.settings.classes.helpBlock=r.settings.classes.helpBlock||[],r.settings.classes.helpBlock.push("help-block"),r.registerMutator("helpBlock",function(e,t,s){return t.help&&(s.helpBlock=angular.element("<p/>"),s.helpBlock.addClass(e.options.classes.helpBlock.join(" ")),s.helpBlock.html(t.help),s.fieldContainer.append(s.helpBlock)),s}),r.settings.classes.inputGroup=["input-group"],r.settings.classes.inputGroupAddon=["input-group-addon"],r.settings.classes.inputGroupAddonButton=["input-group-btn"],r.settings.classes.button=["btn","btn-default"],r.registerMutator("addons",function(o,a,i){if(!a.$addons&&!a.addons)return i;i.inputGroup=angular.element("<div/>"),i.inputGroup.addClass(r.settings.classes.inputGroup.join(" "));var l=[];return angular.forEach(a.$addons||a.addons,function(e){var t,s=angular.element("<span/>"),n=null;s.addClass(r.settings.classes.inputGroupAddon.join(" ")),e.button&&(s.attr("class",r.settings.classes.inputGroupAddonButton.join(" ")),(n=angular.element('<button type="button"/>')).addClass(r.settings.classes.button.join(" ")),s.append(n)),null!=e.icon&&((t=angular.element("<i/>")).addClass(e.icon),(n||s).append(t)),null!=e.content&&(n||s).html(e.content),e.attr&&r.setAttributes(o,a,n||s,e.attr),e.before?i.inputGroup.append(s):l.push(s)}),i.inputGroup.append(i.input),angular.forEach(l,function(e){i.inputGroup.append(e)}),i.fieldContainer.append(i.inputGroup),i}),r.settings.layout={type:"basic",labelSize:2,inputSize:10},r.registerMutator("horizontalForm",function(e,t,s){if(!e.options.layout||"horizontal"!=e.options.layout.type)return e.container.removeClass("form-horizontal"),s;var n=r.settings.classes.col[0],o=r.settings.classes.colOffset[0],a=t.labelSize||e.options.layout.labelSize,i=t.inputSize||e.options.layout.inputSize;e.container.addClass("form-horizontal");e=angular.element("<div/>");return e.addClass(n.replace(/\$size/gi,i)),s.label&&"checkbox"!=t.type?(s.label.addClass(n.replace(/\$size/gi,a)),s.label.after(e)):(s.fieldContainer.prepend(e),e.addClass(o.replace(/\$size/g,a))),"checkbox"==t.type?(s.fieldContainer.removeClass("checkbox"),(a=angular.element("<div/>")).addClass("checkbox"),a.append(s.label),e.append(a)):e.append(s.inputGroup||s.input),t.help&&e.append(s.helpBlock),s},{require:"helpBlock"})}]),angular.module("autofields.bootstrap.validation",["autofields.validation"]).config(["$uibTooltipProvider",function(e){e.setTriggers({"keyup focus":"blur"}),e.options({placement:"top",animation:!1})}]).config(["$autofieldsProvider",function(n){n.settings.attributes.container.ngClass="{'has-error':"+n.settings.validation.invalid+", 'has-success':"+n.settings.validation.valid+"}",n.settings.attributes.input.uibPopover="{{("+n.settings.validation.valid+") ? '$validMsg' : ($errorMsgs)}}",n.settings.noPopover=["date"],n.registerMutator("bootstrap-validation",function(e,t,s){return s.validation&&-1==n.settings.noPopover.indexOf(t.type)&&s.msgs.length?(t=s.input.attr("uib-popover").replace(/\$validMsg/gi,s.validMsg).replace(/\$errorMsgs/gi,s.msgs.join("+")),s.input.attr({"uib-popover-trigger":"keyup focus","uib-popover":t})):s.input.removeAttr("uib-popover"),s},{require:"validation",override:!0})}]),angular.module("autofields",["autofields.bootstrap","autofields.bootstrap.validation"]);