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