11/*!
2- angular-xeditable - 0.9 .0
2+ angular-xeditable - 0.10 .0
33Edit-in-place for angular.js
4- Build date: 2018-07-20
4+ Build date: 2019-06-24
55*/
66/**
7- * Angular-xeditable module
7+ * Angular-xeditable module
88 *
99 */
1010angular . module ( 'xeditable' , [ ] )
1111
1212
1313/**
14- * Default options.
14+ * Default options.
1515 *
1616 * @namespace editable-options
1717 */
1818//todo: maybe better have editableDefaults, not options...
1919. value ( 'editableOptions' , {
2020 /**
21- * Theme. Possible values `bs3`, `bs2`, `default`.
21+ * Theme. Possible values `bs4`, ` bs3`, `bs2`, `default`.
2222 * Default is `default`
23- *
23+ *
2424 * @var {string} theme
2525 * @memberOf editable-options
26- */
26+ */
2727 theme : 'default' ,
2828 /**
29- * icon_set. Possible values `font-awesome`, `default`.
29+ * icon_set. Possible values `font-awesome`, `default`.
3030 * Default is `default`
31- *
31+ *
3232 * @var {string} icon set
3333 * @memberOf editable-options
34- */
34+ */
3535 icon_set : 'default' ,
3636 /**
37- * Whether to show buttons for single editable element.
38- * Possible values `right`, `no`.
37+ * Whether to show buttons for single editable element.
38+ * Possible values `right`, `no`.
3939 * Default is `right`
40- *
40+ *
4141 * @var {string} buttons
4242 * @memberOf editable-options
43- */
43+ */
4444 buttons : 'right' ,
4545 /**
46- * Default value for `blur` attribute of single editable element.
47- * Can be `cancel|submit|ignore`.
46+ * Default value for `blur` attribute of single editable element.
47+ * Can be `cancel|submit|ignore`.
4848 * Default is `cancel`
49- *
49+ *
5050 * @var {string} blurElem
5151 * @memberOf editable-options
5252 */
5353 blurElem : 'cancel' ,
5454 /**
55- * Default value for `blur` attribute of editable form.
56- * Can be `cancel|submit|ignore`.
55+ * Default value for `blur` attribute of editable form.
56+ * Can be `cancel|submit|ignore`.
5757 * Default is `ignore`.
58- *
58+ *
5959 * @var {string} blurForm
6060 * @memberOf editable-options
6161 */
6262 blurForm : 'ignore' ,
6363 /**
64- * How input elements get activated. Possible values: `focus|select|none`.
64+ * How input elements get activated. Possible values: `focus|select|none`.
6565 * Default is `focus`
6666 *
6767 * @var {string} activate
6868 * @memberOf editable-options
6969 */
7070 activate : 'focus' ,
7171 /**
72- * Whether to disable x-editable. Can be overloaded on each element.
72+ * Whether to disable x-editable. Can be overloaded on each element.
7373 * Default is `false`
7474 *
7575 * @var {boolean} isDisabled
7676 * @memberOf editable-options
7777 */
7878 isDisabled : false ,
79-
79+
8080 /**
81- * Event, on which the edit mode gets activated.
82- * Can be any event.
81+ * Event, on which the edit mode gets activated.
82+ * Can be any event.
8383 * Default is `click`
8484 *
8585 * @var {string} activationEvent
@@ -88,7 +88,7 @@ angular.module('xeditable', [])
8888 activationEvent : 'click' ,
8989
9090 /**
91- * The default title of the submit button.
91+ * The default title of the submit button.
9292 * Default is `Submit`
9393 *
9494 * @var {string} submitButtonTitle
@@ -97,7 +97,7 @@ angular.module('xeditable', [])
9797 submitButtonTitle : 'Submit' ,
9898
9999 /**
100- * The default aria label of the submit button.
100+ * The default aria label of the submit button.
101101 * Default is `Submit`
102102 *
103103 * @var {string} submitButtonAriaLabel
@@ -106,7 +106,7 @@ angular.module('xeditable', [])
106106 submitButtonAriaLabel : 'Submit' ,
107107
108108 /**
109- * The default title of the cancel button.
109+ * The default title of the cancel button.
110110 * Default is `Cancel`
111111 *
112112 * @var {string} cancelButtonTitle
@@ -115,7 +115,7 @@ angular.module('xeditable', [])
115115 cancelButtonTitle : 'Cancel' ,
116116
117117 /**
118- * The default aria label of the cancel button.
118+ * The default aria label of the cancel button.
119119 * Default is `Cancel`
120120 *
121121 * @var {string} cancelButtonAriaLabel
@@ -124,7 +124,7 @@ angular.module('xeditable', [])
124124 cancelButtonAriaLabel : 'Cancel' ,
125125
126126 /**
127- * The default title of the clear button.
127+ * The default title of the clear button.
128128 * Default is `Clear`
129129 *
130130 * @var {string} clearButtonTitle
@@ -133,7 +133,7 @@ angular.module('xeditable', [])
133133 clearButtonTitle : 'Clear' ,
134134
135135 /**
136- * The default aria label of the clear button.
136+ * The default aria label of the clear button.
137137 * Default is `Clear`
138138 *
139139 * @var {string} clearButtonAriaLabel
@@ -142,7 +142,7 @@ angular.module('xeditable', [])
142142 clearButtonAriaLabel : 'Clear' ,
143143
144144 /**
145- * Whether to display the clear button.
145+ * Whether to display the clear button.
146146 * Default is `false`
147147 *
148148 * @var {boolean} displayClearButton
@@ -253,8 +253,10 @@ angular.module('xeditable').directive('editableBsdate', ['editableDirectiveFacto
253253
254254 //See if calendar button should be displayed
255255 if ( showCalendarButton === "true" ) {
256- var buttonDatePicker = angular . element ( '<button type="button" class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></button>' ) ;
257- var buttonWrapper = angular . element ( '<span class="input-group-btn"></span>' ) ;
256+ var buttonDatePicker = angular . element ( '<button type="button" class="' +
257+ this . theme . calendarButtonClass + '"><i class="' +
258+ this . icon_set . calendar + '"></i></button>' ) ;
259+ var buttonWrapper = angular . element ( '<span class="' + this . theme . buttonGroupAppendClass + '"></span>' ) ;
258260
259261 buttonDatePicker . attr ( 'ng-click' , attrs . eNgClick ) ;
260262
@@ -376,6 +378,7 @@ angular.module('xeditable').directive('editableChecklist', [
376378 var parsed = editableNgOptionsParser ( this . attrs . eNgOptions ) ;
377379 var ngChangeHtml = '' ;
378380 var ngChecklistComparatorHtml = '' ;
381+ var ngDisabled = '' ;
379382
380383 if ( this . attrs . eNgChange ) {
381384 ngChangeHtml = ' ng-change="' + this . attrs . eNgChange + '"' ;
@@ -384,10 +387,14 @@ angular.module('xeditable').directive('editableChecklist', [
384387 if ( this . attrs . eChecklistComparator ) {
385388 ngChecklistComparatorHtml = ' checklist-comparator="' + this . attrs . eChecklistComparator + '"' ;
386389 }
390+
391+ if ( this . attrs . eNgDisabled ) {
392+ ngDisabled = ' ng-disabled="' + this . attrs . eNgDisabled + '"' ;
393+ }
387394
388395 var html = '<label ng-repeat="' + parsed . ngRepeat + '">' +
389396 '<input type="checkbox" checklist-model="$parent.$parent.$data" checklist-value="' + parsed . locals . valueFn + '"' +
390- ngChangeHtml + ngChecklistComparatorHtml + '>' +
397+ ngChangeHtml + ngChecklistComparatorHtml + ngDisabled + '>' +
391398 '<span ng-bind="' + parsed . locals . displayFn + '"></span></label>' ;
392399
393400 this . inputEl . removeAttr ( 'ng-model' ) ;
@@ -2615,19 +2622,28 @@ angular.module('xeditable').factory('editableIcons', function() {
26152622 'bs2' : {
26162623 ok : 'icon-ok icon-white' ,
26172624 cancel : 'icon-remove' ,
2618- clear : 'icon-trash'
2625+ clear : 'icon-trash' ,
2626+ calendar : 'icon-calendar'
26192627 } ,
26202628 'bs3' : {
26212629 ok : 'glyphicon glyphicon-ok' ,
26222630 cancel : 'glyphicon glyphicon-remove' ,
2623- clear : 'glyphicon glyphicon-trash'
2631+ clear : 'glyphicon glyphicon-trash' ,
2632+ calendar : 'glyphicon glyphicon-calendar'
2633+ } ,
2634+ 'bs4' : {
2635+ ok : 'fa fa-check' ,
2636+ cancel : 'fa fa-times' ,
2637+ clear : 'fa fa-trash' ,
2638+ calendar : 'fa fa-calendar'
26242639 }
26252640 } ,
26262641 external : {
26272642 'font-awesome' : {
26282643 ok : 'fa fa-check' ,
26292644 cancel : 'fa fa-times' ,
2630- clear : 'fa fa-trash'
2645+ clear : 'fa fa-trash' ,
2646+ calendar : 'fa fa-calendar'
26312647 }
26322648 }
26332649 } ;
@@ -2672,8 +2688,9 @@ angular.module('xeditable').factory('editableThemes', function() {
26722688 cancelTpl : '<button type="button" class="btn" ng-click="$form.$cancel()">' +
26732689 '<span></span>' +
26742690 '</button>' ,
2675- resetTpl : '<button type="reset" class="btn btn-danger">clear</button>'
2676-
2691+ resetTpl : '<button type="reset" class="btn btn-danger">clear</button>' ,
2692+ calendarButtonClass : 'btn' ,
2693+ buttonGroupAppendClass : 'input-append'
26772694 } ,
26782695
26792696 //bs3
@@ -2694,6 +2711,8 @@ angular.module('xeditable').factory('editableThemes', function() {
26942711 buttonsClass : '' ,
26952712 //bs3 specific prop to change standard inputs class: input-sm, input-lg
26962713 inputClass : '' ,
2714+ calendarButtonClass : 'btn btn-default' ,
2715+ buttonGroupAppendClass : 'input-group-btn' ,
26972716 postrender : function ( ) {
26982717 //apply `form-control` class to std inputs
26992718 switch ( this . directiveName ) {
@@ -2734,7 +2753,69 @@ angular.module('xeditable').factory('editableThemes', function() {
27342753 }
27352754 }
27362755 } ,
2737-
2756+
2757+ //bs4
2758+ 'bs4' : {
2759+ formTpl : '<form class="form-inline editable-wrap" role="form"></form>' ,
2760+ noformTpl : '<span class="editable-wrap"></span>' ,
2761+ controlsTpl : '<div class="editable-controls form-group"></div>' ,
2762+ inputTpl : '' ,
2763+ errorTpl : '<div class="editable-error form-text invalid-feedback" data-ng-if="$error" data-ng-bind-html="$error"></div>' ,
2764+ buttonsTpl : '<span class="editable-buttons"></span>' ,
2765+ submitTpl : '<button type="submit" class="btn btn-primary"><span></span></button>' ,
2766+ cancelTpl : '<button type="button" class="btn btn-secondary" ng-click="$form.$cancel()">' +
2767+ '<span></span>' +
2768+ '</button>' ,
2769+ resetTpl : '<button type="reset" class="btn btn-danger">clear</button>' ,
2770+
2771+ //bs4 specific prop to change buttons class: btn-sm, btn-lg
2772+ buttonsClass : '' ,
2773+ //bs4 specific prop to change standard inputs class: form-control-sm, form-control-lg
2774+ inputClass : '' ,
2775+ calendarButtonClass : 'btn btn-secondary' ,
2776+ buttonGroupAppendClass : 'input-group-append' ,
2777+ postrender : function ( ) {
2778+ //apply `form-control` class to std inputs
2779+ switch ( this . directiveName ) {
2780+ case 'editableText' :
2781+ case 'editableSelect' :
2782+ case 'editableTextarea' :
2783+ case 'editableEmail' :
2784+ case 'editableTel' :
2785+ case 'editableNumber' :
2786+ case 'editableUrl' :
2787+ case 'editableSearch' :
2788+ case 'editableDate' :
2789+ case 'editableDatetime' :
2790+ case 'editableBsdate' :
2791+ case 'editableTime' :
2792+ case 'editableMonth' :
2793+ case 'editableWeek' :
2794+ case 'editablePassword' :
2795+ case 'editableDatetimeLocal' :
2796+ this . inputEl . addClass ( 'form-control' ) ;
2797+ this . inputEl . attr ( 'ng-class' , "{'is-invalid': $error}" ) ;
2798+ if ( this . theme . inputClass ) {
2799+ // don`t apply `form-control-sm` and `form-control-lg` to select multiple
2800+ // should be fixed in bs itself!
2801+ if ( this . inputEl . attr ( 'multiple' ) &&
2802+ ( this . theme . inputClass === 'form-control-sm' || this . theme . inputClass === 'form-control-lg' ) ) {
2803+ break ;
2804+ }
2805+ this . inputEl . addClass ( this . theme . inputClass ) ;
2806+ }
2807+ break ;
2808+ case 'editableCheckbox' :
2809+ this . editorEl . addClass ( 'form-check' ) ;
2810+ }
2811+
2812+ //apply buttonsClass (bs4 specific!)
2813+ if ( this . buttonsEl && this . theme . buttonsClass ) {
2814+ this . buttonsEl . find ( 'button' ) . addClass ( this . theme . buttonsClass ) ;
2815+ }
2816+ }
2817+ } ,
2818+
27382819 //semantic-ui
27392820 'semantic' : {
27402821 formTpl : '<form class="editable-wrap ui form" ng-class="{\'error\': $error}" role="form"></form>' ,
0 commit comments