romo 0.19.10 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,5 @@
1
- $.fn.romoIndicatorTextInput = function() {
2
- return $.map(this, function(element) {
3
- return new RomoIndicatorTextInput(element);
4
- });
5
- }
6
-
7
- var RomoIndicatorTextInput = function(element) {
8
- this.elem = $(element);
1
+ var RomoIndicatorTextInput = RomoComponent(function(elem) {
2
+ this.elem = elem;
9
3
 
10
4
  this.defaultIndicatorClass = undefined;
11
5
  this.defaultIndicatorPaddingPx = 5;
@@ -14,107 +8,92 @@ var RomoIndicatorTextInput = function(element) {
14
8
  this.doInit();
15
9
  this._bindElem();
16
10
 
17
- this.elem.trigger('indicatorTextInput:ready', [this]);
18
- }
19
-
20
- RomoIndicatorTextInput.prototype.doInit = function() {
21
- // override as needed
22
- }
11
+ Romo.trigger(this.elem, 'romoIndicatorTextInput:ready', [this]);
12
+ });
23
13
 
24
14
  RomoIndicatorTextInput.prototype.doEnable = function() {
25
- this.elem.prop('disabled', false);
26
- this.elem.removeClass('disabled');
27
- this.indicatorElem.removeClass('disabled');
15
+ this.elem.disabled = false;
16
+ Romo.removeClass([this.elem, this.indicatorElem], 'disabled');
28
17
  }
29
18
 
30
19
  RomoIndicatorTextInput.prototype.doDisable = function() {
31
- this.elem.prop('disabled', true);
32
- this.elem.addClass('disabled');
33
- this.indicatorElem.addClass('disabled');
20
+ this.elem.disabled = true;
21
+ Romo.addClass([this.elem, this.indicatorElem], 'disabled');
34
22
  }
35
23
 
36
24
  RomoIndicatorTextInput.prototype.doShow = function() {
37
- this._show(this.elem);
38
- this._show(this.indicatorElem);
25
+ Romo.show([this.elem, this.indicatorElem]);
39
26
  this._placeIndicatorElem();
40
27
  }
41
28
 
42
29
  RomoIndicatorTextInput.prototype.doHide = function() {
43
- this._hide(this.elem);
44
- this._hide(this.indicatorElem);
30
+ Romo.hide([this.elem, this.indicatorElem]);
45
31
  }
46
32
 
47
- /* private */
33
+ // private
48
34
 
49
35
  RomoIndicatorTextInput.prototype._bindElem = function() {
50
- var elemWrapper = $('<div class="romo-indicator-text-input-wrapper"></div>');
51
- elemWrapper.css({'display': (this.elem.data('romo-indicator-text-input-elem-display') || 'inline-block')});
52
- if (this.elem.data('romo-indicator-text-input-btn-group') === true) {
53
- elemWrapper.addClass('romo-btn-group');
36
+ var elemWrapper = Romo.elems('<div class="romo-indicator-text-input-wrapper"></div>')[0];
37
+ Romo.setStyle(elemWrapper, 'display', (Romo.data(this.elem, 'romo-indicator-text-input-elem-display') || 'inline-block'));
38
+ if (Romo.data(this.elem, 'romo-indicator-text-input-btn-group') === true) {
39
+ Romo.addClass(elemWrapper, 'romo-btn-group');
54
40
  }
55
41
 
56
- this.elem.before(elemWrapper);
57
- elemWrapper.append(this.elem);
42
+ Romo.before(this.elem, elemWrapper);
43
+ Romo.append(elemWrapper, this.elem);
44
+ Romo.parentChildElems.add(this.elem, [elemWrapper]);
58
45
 
59
- // the elem wrapper should be treated like a child elem. add it to Romo's
60
- // parent-child elems so it will be removed when the elem (input) is removed.
61
- // delay adding it b/c the `append` statement above is not a "move", it is
62
- // a "remove" and "add" so if added immediately the "remove" part will
63
- // incorrectly remove the wrapper. Any value will do - I chose 1 arbitrarily.
64
- setTimeout($.proxy(function() {
65
- Romo.parentChildElems.add(this.elem, [elemWrapper]);
66
- }, this), 1);
67
-
68
- this.indicatorElem = $();
69
- var indicatorClass = this.elem.data('romo-indicator-text-input-indicator') || this.defaultIndicatorClass;
46
+ this.indicatorElem = undefined;
47
+ var indicatorClass = Romo.data(this.elem, 'romo-indicator-text-input-indicator') || this.defaultIndicatorClass;
70
48
  if (indicatorClass !== undefined && indicatorClass !== 'none') {
71
- this.indicatorElem = $('<div class="romo-indicator-text-input-indicator"><div><i class="'+indicatorClass+'"></i></div></div>');
72
- this.elem.after(this.indicatorElem);
73
- this.indicatorElem.on('click', $.proxy(this._onIndicatorClick, this));
49
+ this.indicatorElem = Romo.elems('<div class="romo-indicator-text-input-indicator"><div><i class="'+indicatorClass+'"></i></div></div>')[0];
50
+ Romo.after(this.elem, this.indicatorElem);
51
+ Romo.on(this.indicatorElem, 'click', Romo.proxy(this._onIndicatorClick, this));
74
52
  this._placeIndicatorElem();
75
53
 
76
- this.indicatorIconContainerElem = this.indicatorElem.find('div');
77
- if (this.elem.data('romo-indicator-text-input-indicator-basis-size') !== undefined) {
78
- this.indicatorIconContainerElem.attr(
79
- 'data-romo-indicator-basis-size',
80
- this.elem.data('romo-indicator-text-input-indicator-basis-size')
54
+ this.indicatorIconContainerElem = Romo.find(this.indicatorElem, 'div')[0];
55
+ if (Romo.data(this.elem, 'romo-indicator-text-input-spinner-basis-size') !== undefined) {
56
+ Romo.setData(
57
+ this.indicatorIconContainerElem,
58
+ 'romo-spinner-basis-size',
59
+ Romo.data(this.elem, 'romo-indicator-text-input-spinner-basis-size')
81
60
  )
82
61
  }
83
- this.indicatorIconContainerElem.romoIndicator();
62
+ new RomoSpinner(this.indicatorIconContainerElem);
84
63
 
85
- this.elem.on('indicatorTextInput:triggerPlaceIndicator', $.proxy(function(e) {
64
+ Romo.on(this.elem, 'romoIndicatorTextInput:triggerPlaceIndicator', Romo.proxy(function(e) {
86
65
  this._placeIndicatorElem();
87
66
  }, this));
88
- this.elem.on('indicatorTextInput:triggerIndicatorStart', $.proxy(function(e, basisSize) {
89
- this.indicatorIconContainerElem.trigger('indicator:triggerStart', [basisSize]);
67
+ Romo.on(this.elem, 'romoIndicatorTextInput:triggerSpinnerStart', Romo.proxy(function(e, basisSize) {
68
+ Romo.trigger(this.indicatorIconContainerElem, 'romoSpinner:triggerStart', [basisSize]);
90
69
  }, this));
91
- this.elem.on('indicatorTextInput:triggerIndicatorStop', $.proxy(function(e) {
92
- this.indicatorIconContainerElem.trigger('indicator:triggerStop');
70
+ Romo.on(this.elem, 'romoIndicatorTextInput:triggerSpinnerStop', Romo.proxy(function(e) {
71
+ Romo.trigger(this.indicatorIconContainerElem, 'romoSpinner:triggerStop');
93
72
  }, this));
94
73
  }
95
74
 
96
- this.elem.on('indicatorTextInput:triggerEnable', $.proxy(function(e) {
75
+ Romo.on(this.elem, 'romoIndicatorTextInput:triggerEnable', Romo.proxy(function(e) {
97
76
  this.doEnable();
98
77
  }, this));
99
- this.elem.on('indicatorTextInput:triggerDisable', $.proxy(function(e) {
78
+ Romo.on(this.elem, 'romoIndicatorTextInput:triggerDisable', Romo.proxy(function(e) {
100
79
  this.doDisable();
101
80
  }, this));
102
- this.elem.on('indicatorTextInput:triggerShow', $.proxy(function(e) {
81
+ Romo.on(this.elem, 'romoIndicatorTextInput:triggerShow', Romo.proxy(function(e) {
103
82
  this.doShow();
104
83
  }, this));
105
- this.elem.on('indicatorTextInput:triggerHide', $.proxy(function(e) {
84
+ Romo.on(this.elem, 'romoIndicatorTextInput:triggerHide', Romo.proxy(function(e) {
106
85
  this.doHide();
107
86
  }, this));
108
87
  }
109
88
 
110
89
  RomoIndicatorTextInput.prototype._placeIndicatorElem = function() {
111
90
  if (this.indicatorElem !== undefined) {
112
- this.indicatorElem.css({'line-height': this.elem.css('height')});
113
- if (this.elem.prop('disabled') === true) {
114
- this.indicatorElem.addClass('disabled');
91
+ Romo.setStyle(this.indicatorElem, 'line-height', Romo.css(this.elem, 'height'));
92
+ if (this.elem.disabled === true) {
93
+ Romo.addClass(this.indicatorElem, 'disabled');
115
94
  }
116
- if (this.elem.css('display') === 'none') {
117
- this._hide(this.indicatorElem);
95
+ if (Romo.css(this.elem, 'display') === 'none') {
96
+ Romo.hide(this.indicatorElem);
118
97
  }
119
98
 
120
99
  var indicatorPaddingPx = this._getIndicatorPaddingPx();
@@ -122,58 +101,48 @@ RomoIndicatorTextInput.prototype._placeIndicatorElem = function() {
122
101
  var indicatorPosition = this._getIndicatorPosition();
123
102
 
124
103
  // add a pixel to account for the default input border
125
- this.indicatorElem.css(indicatorPosition, indicatorPaddingPx+1);
104
+ Romo.setStyle(this.indicatorElem, indicatorPosition, indicatorPaddingPx+1+'px');
126
105
 
127
106
  // left-side padding
128
107
  // + indicator width
129
108
  // + right-side padding
130
109
  var inputPaddingPx = indicatorPaddingPx + indicatorWidthPx + indicatorPaddingPx;
131
- this.elem.css('padding-'+indicatorPosition, inputPaddingPx+'px');
110
+ Romo.setStyle(this.elem, 'padding-'+indicatorPosition, inputPaddingPx+'px');
132
111
  }
133
112
  }
134
113
 
135
- RomoIndicatorTextInput.prototype._onIndicatorClick = function(e) {
136
- if (e !== undefined) {
137
- e.preventDefault();
138
- e.stopPropagation();
139
- }
140
- if (this.elem.prop('disabled') === false) {
141
- this.elem.focus();
142
- this.elem.trigger('indicatorTextInput:indicatorClick');
143
- }
144
- }
145
-
146
- // private
147
-
148
- RomoIndicatorTextInput.prototype._show = function(elem) {
149
- elem.css('display', '');
150
- }
151
-
152
- RomoIndicatorTextInput.prototype._hide = function(elem) {
153
- elem.css('display', 'none');
154
- }
155
-
156
114
  RomoIndicatorTextInput.prototype._getIndicatorPaddingPx = function() {
157
115
  return (
158
- this.elem.data('romo-indicator-text-input-indicator-padding-px') ||
116
+ Romo.data(this.elem, 'romo-indicator-text-input-indicator-padding-px') ||
159
117
  this.defaultIndicatorPaddingPx
160
118
  );
161
119
  }
162
120
 
163
121
  RomoIndicatorTextInput.prototype._getIndicatorWidthPx = function() {
164
122
  return (
165
- this.elem.data('romo-indicator-text-input-indicator-width-px') ||
166
- parseInt(Romo.getComputedStyle(this.indicatorElem[0], "width"), 10)
123
+ Romo.data(this.elem, 'romo-indicator-text-input-indicator-width-px') ||
124
+ parseInt(Romo.css(this.indicatorElem, "width"), 10)
167
125
  );
168
126
  }
169
127
 
170
128
  RomoIndicatorTextInput.prototype._getIndicatorPosition = function() {
171
129
  return (
172
- this.elem.data('romo-indicator-text-input-indicator-position') ||
130
+ Romo.data(this.elem, 'romo-indicator-text-input-indicator-position') ||
173
131
  this.defaultIndicatorPosition
174
132
  );
175
133
  }
176
134
 
177
- Romo.onInitUI(function(e) {
178
- Romo.initUIElems(e, '[data-romo-indicator-text-input-auto="true"]').romoIndicatorTextInput();
179
- });
135
+ // event functions
136
+
137
+ RomoIndicatorTextInput.prototype.romoEvFn._onIndicatorClick = function(e) {
138
+ e.preventDefault();
139
+
140
+ if (this.elem.disabled === false) {
141
+ this.elem.focus();
142
+ Romo.trigger(this.elem, 'romoIndicatorTextInput:indicatorClick');
143
+ }
144
+ }
145
+
146
+ // init
147
+
148
+ Romo.addElemsInitSelector('[data-romo-indicator-text-input-auto="true"]', RomoIndicatorTextInput);
@@ -1,89 +1,96 @@
1
- $.fn.romoInline = function() {
2
- return $.map(this, function(element) {
3
- return new RomoInline(element);
4
- });
1
+ var RomoInline = RomoComponent(function(elem) {
2
+ this.elem = elem;
3
+
4
+ this.doInit();
5
+ this._bindElem();
6
+
7
+ Romo.trigger(this.elem, 'romoInline:ready', [this]);
8
+ });
9
+
10
+ RomoInline.prototype.doShow = function() {
11
+ Romo.show(this.elem);
12
+ if (this.toggleElem !== undefined) {
13
+ Romo.hide(this.toggleElem);
14
+ }
15
+ Romo.trigger(this.elem, 'romoInline:show', [this]);
16
+ }
17
+
18
+ RomoInline.prototype.doDismiss = function() {
19
+ if (this.toggleElem !== undefined) {
20
+ Romo.show(this.toggleElem);
21
+ }
22
+ Romo.hide(this.elem);
23
+ Romo.trigger(this.elem, 'romoInline:dismiss', [this]);
5
24
  }
6
25
 
7
- var RomoInline = function(element) {
8
- this.elem = $(element);
9
- this.toggleElem = $(this.elem.data('romo-inline-toggle'));
10
- this.dismissElem = undefined;
26
+ // private
27
+
28
+ RomoInline.prototype._bindElem = function() {
29
+ this._bindDismiss();
11
30
 
12
- this.elem.on('inline:triggerDismiss', $.proxy(this.onDismissClick, this));
13
- this.elem.on('inline:triggerShow', $.proxy(function(e) {
31
+ this.toggleElem = Romo.f(Romo.data(this.elem, 'romo-inline-toggle'))[0];
32
+
33
+ Romo.on(this.elem, 'romoInline:triggerDismiss', Romo.proxy(this._onDismissClick, this));
34
+ Romo.on(this.elem, 'romoInline:triggerShow', Romo.proxy(function(e) {
14
35
  this.doShow();
15
36
  }, this));
16
37
 
17
- this.elem.on('romoAjax:callStart', $.proxy(function(e, romoAjax) {
18
- this.doLoadStart();
38
+ Romo.on(this.elem, 'romoAjax:callStart', Romo.proxy(function(e, romoAjax) {
39
+ this._loadStart();
19
40
  return false;
20
41
  }, this));
21
- this.elem.on('romoAjax:callSuccess', $.proxy(function(e, data, romoAjax) {
22
- this.doLoadSuccess(data);
42
+ Romo.on(this.elem, 'romoAjax:callSuccess', Romo.proxy(function(e, data, romoAjax) {
43
+ this._loadSuccess(data);
23
44
  return false;
24
45
  }, this));
25
- this.elem.on('romoAjax:callError', $.proxy(function(e, xhr, romoAjax) {
26
- this.doLoadError(xhr);
46
+ Romo.on(this.elem, 'romoAjax:callError', Romo.proxy(function(e, xhr, romoAjax) {
47
+ this._loadError(xhr);
27
48
  return false;
28
49
  }, this));
29
-
30
- this.doBindDismiss();
31
- this.doInit();
32
- this.elem.trigger('inline:ready', [this]);
33
50
  }
34
51
 
35
- RomoInline.prototype.doInit = function() {
36
- // override as needed
52
+ RomoInline.prototype._bindDismiss = function() {
53
+ this.dismissElems = Romo.find(this.elem, '[data-romo-inline-dismiss]');
54
+ Romo.on(this.dismissElems, 'click', Romo.proxy(this._onDismissClick, this));
37
55
  }
38
56
 
39
- RomoInline.prototype.doLoadStart = function() {
40
- this.elem.html('');
41
- this.elem.trigger('inline:loadStart', [this]);
57
+ RomoInline.prototype._loadStart = function() {
58
+ Romo.updateHtml(this.elem, '');
59
+ Romo.trigger(this.elem, 'romoInline:loadStart', [this]);
42
60
  }
43
61
 
44
- RomoInline.prototype.doLoadSuccess = function(data) {
62
+ RomoInline.prototype._loadSuccess = function(data) {
45
63
  this.doShow();
46
- Romo.initHtml(this.elem, data);
47
- this.doBindDismiss();
48
- this.elem.trigger('inline:loadSuccess', [data, this]);
64
+ Romo.initUpdateHtml(this.elem, data);
65
+ this._bindDismiss();
66
+ Romo.trigger(this.elem, 'romoInline:loadSuccess', [data, this]);
49
67
  }
50
68
 
51
- RomoInline.prototype.doLoadError = function(xhr) {
69
+ RomoInline.prototype._loadError = function(xhr) {
52
70
  this.doShow();
53
- this.elem.trigger('inline:loadError', [xhr, this]);
71
+ Romo.trigger(this.elem, 'romoInline:loadError', [xhr, this]);
54
72
  }
55
73
 
56
- RomoInline.prototype.doBindDismiss = function() {
57
- this.dismissElem = this.elem.find('[data-romo-inline-dismiss]');
58
- this.dismissElem.unbind('click');
59
- this.dismissElem.on('click', $.proxy(this.onDismissClick, this));
60
- }
74
+ // event functions
61
75
 
62
- RomoInline.prototype.onDismissClick = function(e) {
63
- if (e !== undefined) {
64
- e.preventDefault();
65
- }
76
+ RomoInline.prototype.romoEvFn._onDismissClick = function(e) {
77
+ e.preventDefault();
66
78
 
67
- if (this.dismissElem.data('romo-inline-dismiss') === 'confirm') {
68
- this.elem.trigger('inline:confirmDismiss', [this]);
69
- } else if (this.dismissElem.hasClass('disabled') === false) {
70
- this.doDismiss();
79
+ var disabled = this.dismissElems.reduce(function(disabled, dismissElem) {
80
+ return disabled || Romo.hasClass(dismissElem, 'disabled');
81
+ }, false);
82
+ if (!disabled) {
83
+ var confirm = this.dismissElems.reduce(function(confirm, dismissElem) {
84
+ return confirm || Romo.data(dismissElem, 'romo-inline-dismiss') === 'confirm';
85
+ }, false);
86
+ if (confirm) {
87
+ Romo.trigger(this.elem, 'romoInline:confirmDismiss', [this]);
88
+ } else {
89
+ this.doDismiss();
90
+ }
71
91
  }
72
92
  }
73
93
 
74
- RomoInline.prototype.doDismiss = function() {
75
- this.toggleElem.show();
76
- this.elem.hide();
77
- this.elem.trigger('inline:dismiss', [this]);
78
- }
79
-
80
- RomoInline.prototype.doShow = function() {
81
- this.elem.show();
82
- this.toggleElem.hide();
83
- this.elem.trigger('inline:show', [this]);
84
- }
85
-
86
- Romo.onInitUI(function(e) {
87
- Romo.initUIElems(e, '[data-romo-inline-auto="true"]').romoInline();
88
- });
94
+ // init
89
95
 
96
+ Romo.addElemsInitSelector('[data-romo-inline-auto="true"]', RomoInline);
@@ -1,99 +1,100 @@
1
- $.fn.romoInlineForm = function() {
2
- return $.map(this, function(element) {
3
- return new RomoInlineForm(element);
4
- });
5
- }
1
+ var RomoInlineForm = RomoComponent(function(elem) {
2
+ this.elem = elem;
6
3
 
7
- var RomoInlineForm = function(element) {
8
- this.elem = $(element);
4
+ this.doInit();
5
+ this._bindElem();
9
6
 
10
- this.inline = this.elem.romoInline()[0];
11
- this.doBindInline();
7
+ Romo.trigger(this.elem, 'romoInlineForm:ready', [this]);
8
+ });
12
9
 
13
- this.form = undefined;
14
- this.elem.on('inlineForm:form:triggerSubmit', $.proxy(function(e) {
15
- if (this.form != undefined) {
16
- this.form.elem.trigger('form:triggerSubmit', []);
10
+ // private
11
+
12
+ RomoInlineForm.prototype._bindElem = function() {
13
+ Romo.on(this.elem, 'romoInlineForm:romoForm:triggerSubmit', Romo.proxy(function(e) {
14
+ if (this.romoForm !== undefined) {
15
+ Romo.trigger(this.romoForm.elem, 'romoForm:triggerSubmit', []);
17
16
  }
18
17
  }, this));
19
- this.elem.on('inlineForm:inline:triggerInvoke', $.proxy(function(e) {
20
- this.inline.elem.trigger('inline:triggerInvoke', []);
18
+ Romo.on(this.elem, 'romoInlineForm:romoInline:triggerInvoke', Romo.proxy(function(e) {
19
+ Romo.trigger(this.romoInline.elem, 'romoInline:triggerInvoke', []);
21
20
  }, this));
22
- this.elem.on('inlineForm:inline:triggerDismiss', $.proxy(function(e) {
23
- this.inline.elem.trigger('inline:triggerDismiss', []);
21
+ Romo.on(this.elem, 'romoInlineForm:romoInline:triggerDismiss', Romo.proxy(function(e) {
22
+ Romo.trigger(this.romoInline.elem, 'romoInline:triggerDismiss', []);
24
23
  }, this));
25
- this.doBindForm();
26
- this.elem.on('inline:loadSuccess', $.proxy(function(e, data, inline) {
27
- this.doBindForm();
28
- this.elem.trigger('inlineForm:formReady', [this.form, this]);
24
+ Romo.on(this.elem, 'romoInline:loadSuccess', Romo.proxy(function(e, data, romoInline) {
25
+ this._bindForm();
26
+ Romo.trigger(this.elem, 'romoInlineForm:formReady', [this.romoForm, this]);
29
27
  }, this));
30
28
 
31
- this.doInit();
32
- this.elem.trigger('inlineForm:ready', [this]);
29
+ this._bindInline();
30
+ this._bindForm();
33
31
  }
34
32
 
35
- RomoInlineForm.prototype.doInit = function() {
36
- // override as needed
37
- }
33
+ RomoInlineForm.prototype._bindInline = function() {
34
+ this.romoInline = new RomoInline(this.elem);
38
35
 
39
- RomoInlineForm.prototype.doBindInline = function() {
40
- this.elem.on('inline:ready', $.proxy(function(e, inline) {
41
- this.elem.trigger('inlineForm:inline:ready', [inline, this]);
36
+ Romo.on(this.elem, 'romoInline:ready', Romo.proxy(function(e, romoInline) {
37
+ Romo.trigger(this.elem, 'romoInlineForm:romoInline:ready', [romoInline, this]);
42
38
  }, this));
43
- this.elem.on('inline:loadStart', $.proxy(function(e, inline) {
44
- this.elem.trigger('inlineForm:inline:loadStart', [inline, this]);
39
+ Romo.on(this.elem, 'romoInline:loadStart', Romo.proxy(function(e, romoInline) {
40
+ Romo.trigger(this.elem, 'romoInlineForm:romoInline:loadStart', [romoInline, this]);
45
41
  }, this));
46
- this.elem.on('inline:loadSuccess', $.proxy(function(e, data, inline) {
47
- this.elem.trigger('inlineForm:inline:loadSuccess', [data, inline, this]);
42
+ Romo.on(this.elem, 'romoInline:loadSuccess', Romo.proxy(function(e, data, romoInline) {
43
+ Romo.trigger(this.elem, 'romoInlineForm:romoInline:loadSuccess', [data, romoInline, this]);
48
44
  }, this));
49
- this.elem.on('inline:loadError', $.proxy(function(e, xhr, inline) {
50
- this.elem.trigger('inlineForm:inline:loadError', [xhr, inline, this]);
45
+ Romo.on(this.elem, 'romoInline:loadError', Romo.proxy(function(e, xhr, romoInline) {
46
+ Romo.trigger(this.elem, 'romoInlineForm:romoInline:loadError', [xhr, romoInline, this]);
51
47
  }, this));
52
- this.elem.on('inline:show', $.proxy(function(e, inline) {
53
- this.elem.trigger('inlineForm:inline:show', [inline, this]);
48
+ Romo.on(this.elem, 'romoInline:show', Romo.proxy(function(e, romoInline) {
49
+ Romo.trigger(this.elem, 'romoInlineForm:romoInline:show', [romoInline, this]);
54
50
  }, this));
55
- this.elem.on('inline:dismiss', $.proxy(function(e, inline) {
56
- this.elem.trigger('inlineForm:inline:dismiss', [inline, this]);
51
+ Romo.on(this.elem, 'romoInline:dismiss', Romo.proxy(function(e, romoInline) {
52
+ Romo.trigger(this.elem, 'romoInlineForm:romoInline:dismiss', [romoInline, this]);
57
53
  }, this));
58
- this.elem.on('inline:confirmDismiss', $.proxy(function(e, inline) {
59
- this.elem.trigger('inlineForm:inline:confirmDismiss', [inline, this]);
54
+ Romo.on(this.elem, 'romoInline:confirmDismiss', Romo.proxy(function(e, romoInline) {
55
+ Romo.trigger(this.elem, 'romoInlineForm:romoInline:confirmDismiss', [romoInline, this]);
60
56
  }, this));
61
57
  }
62
58
 
63
- RomoInlineForm.prototype.doBindForm = function() {
64
- var formElem = this.elem.find('[data-romo-form-auto="inlineForm"]');
59
+ RomoInlineForm.prototype._bindForm = function() {
60
+ this.romoForm = undefined;
61
+ var formElem = Romo.find(this.elem, '[data-romo-form-auto="inlineForm"]')[0];
65
62
 
66
- formElem.on('form:clearMsgs', $.proxy(function(e, form) {
67
- this.elem.trigger('inlineForm:form:clearMsgs', [form, this]);
68
- }, this));
69
- formElem.on('form:ready', $.proxy(function(e, form) {
70
- this.elem.trigger('inlineForm:form:ready', [form, this]);
71
- }, this));
72
- formElem.on('form:confirmSubmit', $.proxy(function(e, form) {
73
- this.elem.trigger('inlineForm:form:confirmSubmit', [form, this]);
74
- }, this));
75
- formElem.on('form:beforeSubmit', $.proxy(function(e, form) {
76
- this.elem.trigger('inlineForm:form:beforeSubmit', [form, this]);
77
- }, this));
78
- formElem.on('form:submitSuccess', $.proxy(function(e, data, form) {
79
- this.elem.trigger('inlineForm:form:submitSuccess', [data, form, this]);
80
- }, this));
81
- formElem.on('form:submitInvalidMsgs', $.proxy(function(e, msgs, xhr, form) {
82
- this.elem.trigger('inlineForm:form:submitInvalidMsgs', [msgs, xhr, form, this]);
83
- }, this));
84
- formElem.on('form:submitXhrError', $.proxy(function(e, xhr, form) {
85
- this.elem.trigger('inlineForm:form:submitXhrError', [xhr, form, this]);
86
- }, this));
87
- formElem.on('form:submitError', $.proxy(function(e, xhr, form) {
88
- this.elem.trigger('inlineForm:form:submitError', [xhr, form, this]);
89
- }, this));
63
+ if (formElem !== undefined) {
64
+ Romo.on(formElem, 'romoForm:clearMsgs', Romo.proxy(function(e, romoForm) {
65
+ Romo.trigger(this.elem, 'romoInlineForm:romoForm:clearMsgs', [romoForm, this]);
66
+ }, this));
67
+ Romo.on(formElem, 'romoForm:ready', Romo.proxy(function(e, romoForm) {
68
+ Romo.trigger(this.elem, 'romoInlineForm:romoForm:ready', [romoForm, this]);
69
+ }, this));
70
+ Romo.on(formElem, 'romoForm:confirmSubmit', Romo.proxy(function(e, form) {
71
+ Romo.trigger(this.elem, 'romoInlineForm:romoForm:confirmSubmit', [romoForm, this]);
72
+ }, this));
73
+ Romo.on(formElem, 'romoForm:beforeSubmit', Romo.proxy(function(e, romoForm) {
74
+ Romo.trigger(this.elem, 'romoInlineForm:romoForm:beforeSubmit', [romoForm, this]);
75
+ }, this));
76
+ Romo.on(formElem, 'romoForm:submitSuccess', Romo.proxy(function(e, data, romoForm) {
77
+ Romo.trigger(this.elem, 'romoInlineForm:romoForm:submitSuccess', [data, romoForm, this]);
78
+ }, this));
79
+ Romo.on(formElem, 'romoForm:submitInvalidMsgs', Romo.proxy(function(e, msgs, xhr, romoForm) {
80
+ Romo.trigger(this.elem, 'romoInlineForm:romoForm:submitInvalidMsgs', [msgs, xhr, romoForm, this]);
81
+ }, this));
82
+ Romo.on(formElem, 'romoForm:submitXhrError', Romo.proxy(function(e, xhr, romoForm) {
83
+ Romo.trigger(this.elem, 'romoInlineForm:romoForm:submitXhrError', [xhr, romoForm, this]);
84
+ }, this));
85
+ Romo.on(formElem, 'romoForm:submitError', Romo.proxy(function(e, xhr, romoForm) {
86
+ Romo.trigger(this.elem, 'romoInlineForm:romoForm:submitError', [xhr, romoForm, this]);
87
+ }, this));
88
+
89
+ var submitElems = Romo.find(this.elem, '[data-romo-form-submit]');
90
+ var spinnerElems = Romo.find(this.elem, '[data-romo-spinner-auto="true"]');
90
91
 
91
- var submitElement = this.elem.find('[data-romo-form-submit]')[0];
92
- var indicatorElements = this.elem.find('[data-romo-indicator-auto="true"]');
93
- this.form = formElem.romoForm(submitElement, indicatorElements)[0];
92
+ this.romoForm = new RomoForm(formElem, submitElems, spinnerElems);
93
+ }
94
94
  }
95
95
 
96
- Romo.onInitUI(function(e) {
97
- Romo.initUIElems(e, '[data-romo-inlineForm-auto="true"]').romoInlineForm();
98
- });
96
+ // event functions
97
+
98
+ // init
99
99
 
100
+ Romo.addElemsInitSelector('[data-romo-inlineForm-auto="true"]', RomoInlineForm);