forked from json-schema-form/angular-schema-form-material
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaterial-decorator.min.js
1 lines (1 loc) · 11.9 KB
/
material-decorator.min.js
1
angular.module("schemaForm").run(["$templateCache",function(e){e.put("decorators/material/actions-trcl.html",'<div class="btn-group schema-form-actions {{form.htmlClass}}" ng-transclude=""></div>'),e.put("decorators/material/actions.html",'<div class="btn-group schema-form-actions {{form.htmlClass}}"><input ng-repeat-start="item in form.items" type="submit" class="btn {{ item.style || \'btn-default\' }} {{form.fieldHtmlClass}}" value="{{item.title}}" ng-if="item.type === \'submit\'"> <button ng-repeat-end="" class="btn {{ item.style || \'btn-default\' }} {{form.fieldHtmlClass}}" type="button" ng-disabled="form.readonly" ng-if="item.type !== \'submit\'" ng-click="buttonClick($event,item)">{{item.title}}</button></div>'),e.put("decorators/material/array.html",'<div sf-array="form" class="schema-form-array {{form.htmlClass}}" ng-model="$$value$$" ng-model-options="form.ngModelOptions"><h3 ng-show="form.title && form.notitle !== true">{{ form.title }}</h3><ol class="list-group" ng-model="modelArray" ui-sortable=""><li class="list-group-item {{form.fieldHtmlClass}}" ng-repeat="item in modelArray track by $index"><button ng-hide="form.readonly || form.remove === null" ng-click="deleteFromArray($index)" style="position: relative; z-index: 20;" type="button" class="close pull-right"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button><sf-decorator ng-init="arrayIndex = $index" form="copyWithIndex($index)"></sf-decorator></li></ol><div class="clearfix" style="padding: 15px;"><button ng-hide="form.readonly || form.add === null" ng-click="appendToArray()" type="button" class="btn {{ form.style.add || \'btn-default\' }} pull-right"><i class="glyphicon glyphicon-plus"></i> {{ form.add || \'Add\'}}</button></div><div class="help-block" ng-show="(hasError() && errorMessage(schemaError())) || form.description" ng-bind-html="(hasError() && errorMessage(schemaError())) || form.description"></div></div>'),e.put("decorators/material/checkbox.html",'<div class="checkbox schema-form-checkbox {{form.htmlClass}}"><md-checkbox sf-changed="form" ng-disabled="form.readonly" schema-validate="form" name="{{form.key.slice(-1)[0]}}" ng-model="$$value$$" aria-label="{{::form.title}}"><span ng-bind-html="form.title"></span></md-checkbox><div ng-messages="ngModel.$error"><div sf-message="" ng-message=""></div></div></div>'),e.put("decorators/material/checkboxes.html",'<div sf-array="form" ng-model="$$value$$" class="form-group schema-form-checkboxes {{form.htmlClass}}" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess()}"><label class="control-label" ng-show="showTitle()">{{form.title}}</label><div class="checkbox" ng-repeat="val in titleMapValues track by $index"><md-checkbox ng-model="titleMapValues[$index]" sf-changed="form" ng-disabled="form.readonly" name="{{form.key.slice(-1)[0]}}" ng-true-value="true" ng-false-value="false" aria-label="{{form.title || form.key.slice(-1)[0]}}"><span ng-bind-html="form.titleMap[$index].name"></span></md-checkbox></div><div ng-messages="ngModel.$error"><div sf-message="" ng-message=""></div></div></div>'),e.put("decorators/material/default.html",'<md-input-container class="schema-form-{{form.type}} {{form.htmlClass}}"><label ng-show="showTitle()" for="{{form.key.slice(-1)[0]}}">{{form.title}}</label><input ng-model="$$value$$" ng-show="form.key" type="{{form.type}}" step="any" sf-changed="form" placeholder="{{form.placeholder}}" id="{{form.key.slice(-1)[0]}}" ng-class="form.fieldHtmlClass" ng-disabled="form.readonly" name="{{form.key.slice(-1)[0]}}" sf-type-parser="form.schema" schema-validate="form"><div ng-messages="ngModel.$error"><div sf-message="" ng-message=""></div></div></md-input-container>'),e.put("decorators/material/fieldset-trcl.html",'<fieldset ng-disabled="form.readonly" class="standard {{form.htmlClass}}" flex=""><legend ng-show="form.title">{{ form.title }}</legend><div ng-transclude=""></div></fieldset>'),e.put("decorators/material/fieldset.html",'<fieldset ng-disabled="form.readonly" class="standard {{form.htmlClass}}" flex=""><legend ng-show="form.title">{{ form.title }}</legend><sf-decorator ng-repeat="item in form.items" form="item"></sf-decorator></fieldset>'),e.put("decorators/material/help.html",'<div class="helpvalue schema-form-helpvalue {{form.htmlClass}}" ng-bind-html="form.helpvalue"></div>'),e.put("decorators/material/radio-buttons.html",'<div class="form-group schema-form-radiobuttons {{form.htmlClass}}" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess()}"><div><label class="control-label" ng-show="showTitle()">{{form.title}}</label></div><div class="btn-group"><label class="btn {{ (item.value === $$value$$) ? form.style.selected || \'btn-default\' : form.style.unselected || \'btn-default\'; }}" ng-class="{ active: item.value === $$value$$ }" ng-repeat="item in form.titleMap"><input type="radio" class="{{form.fieldHtmlClass}}" sf-changed="form" style="display: none;" ng-disabled="form.readonly" ng-model="$$value$$" ng-model-options="form.ngModelOptions" schema-validate="form" ng-value="item.value" name="{{form.key.join(\'.\')}}"> <span ng-bind-html="item.name"></span></label></div><div class="help-block" sf-message="form.description"></div></div>'),e.put("decorators/material/radios-inline.html",'<div class="form-group schema-form-radios-inline {{form.htmlClass}}" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess()}"><label class="control-label" ng-show="showTitle()">{{form.title}}</label><md-radio-group layout="row" ng-model="$$value$$" ng-model-options="form.ngModelOptions" class="{{form.fieldHtmlClass}}" ng-class="{ active: item.value === $$value$$ }" sf-changed="form" schema-validate="form" ng-disabled="form.readonly" name="{{form.key.join(\'.\')}}"><md-radio-button ng-repeat="item in form.titleMap" ng-value="item.value"><span ng-bind-html="item.name"></span></md-radio-button></md-radio-group><div class="help-block md-caption" sf-message="form.description"></div></div>'),e.put("decorators/material/radios.html",'<div class="form-group schema-form-radios {{form.htmlClass}}" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess()}"><label class="control-label" ng-show="showTitle()">{{form.title}}</label><md-radio-group ng-model="$$value$$" ng-model-options="form.ngModelOptions" class="{{form.fieldHtmlClass}}" ng-class="{ active: item.value === $$value$$ }" sf-changed="form" schema-validate="form" ng-disabled="form.readonly" name="{{form.key.join(\'.\')}}"><md-radio-button ng-repeat="item in form.titleMap" ng-value="item.value"><span ng-bind-html="item.name"></span></md-radio-button></md-radio-group><div class="help-block md-caption" sf-message="form.description"></div></div>'),e.put("decorators/material/section.html",'<div class="schema-form-section {{form.htmlClass}}"><sf-decorator ng-repeat="item in form.items" form="item"></sf-decorator></div>'),e.put("decorators/material/select.html",'<div class="form-group {{form.htmlClass}} schema-form-select" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}"><md-select ng-model="$$value$$"><md-select-label ng-show="showTitle()">{{form.title}}</md-select-label><md-optgroup ng-repeat-start="(key, opt) in form.titleMap | orderBy:\'group\' as optGroups" ng-if="opt.group && opt.group != optGroups[key-1].group" label="{{opt.group}}"><md-option ng-repeat="(key, filtered) in form.titleMap | filter: {group: opt.group} | orderBy:\'name\' as opts" ng-value="filtered.value">{{filtered.name}}</md-option></md-optgroup><md-option ng-repeat-end="" ng-if="!opt.group" ng-value="opt.value">{{opt.name}}</md-option></md-select><p class="help-block md-caption" sf-message="form.description"></p></div>'),e.put("decorators/material/submit.html",'<section class="schema-form-submit {{form.htmlClass}}"><md-button class="md-raised {{ form.style || \'md-primary\' }} {{form.fieldHtmlClass}}" ng-disabled="form.readonly">{{form.title}}</md-button></section>'),e.put("decorators/material/tabarray.html",'<div sf-array="form" ng-init="selected = { tab: 0 }" class="clearfix schema-form-tabarray schema-form-tabarray-{{form.tabType || \'left\'}} {{form.htmlClass}}"><div ng-if="!form.tabType || form.tabType !== \'right\'" ng-class="{\'col-xs-3\': !form.tabType || form.tabType === \'left\'}"><ul class="nav nav-tabs" ng-class="{ \'tabs-left\': !form.tabType || form.tabType === \'left\'}"><li ng-repeat="item in modelArray track by $index" ng-click="$event.preventDefault() || (selected.tab = $index)" ng-class="{active: selected.tab === $index}"><a href="#">{{interp(form.title,{\'$index\':$index, value: item}) || $index}}</a></li><li ng-hide="form.readonly" ng-click="$event.preventDefault() || (selected.tab = appendToArray().length - 1)"><a href="#"><i class="glyphicon glyphicon-plus"></i> {{ form.add || \'Add\'}}</a></li></ul></div><div ng-class="{\'col-xs-9\': !form.tabType || form.tabType === \'left\' || form.tabType === \'right\'}"><div class="tab-content {{form.fieldHtmlClass}}"><div class="tab-pane clearfix" ng-repeat="item in modelArray track by $index" ng-show="selected.tab === $index" ng-class="{active: selected.tab === $index}"><sf-decorator ng-init="arrayIndex = $index" form="copyWithIndex($index)"></sf-decorator><button ng-hide="form.readonly" ng-click="selected.tab = deleteFromArray($index).length - 1" type="button" class="btn {{ form.style.remove || \'btn-default\' }} pull-right"><i class="glyphicon glyphicon-trash"></i> {{ form.remove || \'Remove\'}}</button></div></div></div><div ng-if="form.tabType === \'right\'" class="col-xs-3"><ul class="nav nav-tabs tabs-right"><li ng-repeat="item in modelArray track by $index" ng-click="$event.preventDefault() || (selected.tab = $index)" ng-class="{active: selected.tab === $index}"><a href="#">{{interp(form.title,{\'$index\':$index, value: item}) || $index}}</a></li><li ng-hide="form.readonly" ng-click="$event.preventDefault() || appendToArray()"><a href="#"><i class="glyphicon glyphicon-plus"></i> {{ form.add || \'Add\'}}</a></li></ul></div></div>'),e.put("decorators/material/tabs.html",'<div ng-init="selected = { tab: 0 }" class="schema-form-tabs {{form.htmlClass}}"><ul class="nav nav-tabs"><li ng-repeat="tab in form.tabs" ng-disabled="form.readonly" ng-click="$event.preventDefault() || (selected.tab = $index)" ng-class="{active: selected.tab === $index}"><a href="#">{{ tab.title }}</a></li></ul><div class="tab-content {{form.fieldHtmlClass}}"><div class="tab-pane" ng-disabled="form.readonly" ng-repeat="tab in form.tabs" ng-show="selected.tab === $index" ng-class="{active: selected.tab === $index}"><bootstrap-decorator ng-repeat="item in tab.items" form="item"></bootstrap-decorator></div></div></div>'),e.put("decorators/material/textarea.html",'<md-input-container class="{{form.htmlClass}} schema-form-textarea"><label ng-show="showTitle()" for="{{form.key.slice(-1)[0]}}">{{form.title}}</label> <textarea ng-class="form.fieldHtmlClass" id="{{form.key.slice(-1)[0]}}" sf-changed="form" ng-disabled="form.readonly" ng-model="$$value$$" schema-validate="form" name="{{form.key.slice(-1)[0]}}"></textarea><div ng-messages="ngModel.$error"><div sf-message="" ng-message=""></div></div></md-input-container>')}]),angular.module("schemaForm").config(["schemaFormDecoratorsProvider",function(e){var a="decorators/material/";e.defineDecorator("materialDecorator",{textarea:{template:a+"textarea.html"},fieldset:{template:a+"fieldset.html"},"default":{template:a+"default.html"},select:{template:a+"select.html"},checkbox:{template:a+"checkbox.html"},checkboxes:{template:a+"checkboxes.html"},radios:{template:a+"radios.html"},"radios-inline":{template:a+"radios-inline.html"},radiobuttons:{template:a+"radio-buttons.html"},submit:{template:a+"submit.html"}})}]),angular.module("schemaForm").directive("sfTypeParser",function(){return{restrict:"A",scope:!1,require:"ngModel",link:function(e,a,t,l){var s=e.$watch(t.sfTypeParser,function(e){if(e){var a=-1!==e.type.indexOf("number"),t=-1!==e.type.indexOf("integer"),r=/^[0-9]*$/;(a||t)&&l.$parsers.push(function(e){var t;return a?t=parseFloat(e):r.test(e)&&(t=parseInt(e,10)),console.log("parser",r.test(e),e,t),void 0===t||isNaN(t)?e:t}),s()}})}}});