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,112 +1,113 @@
1
- $.fn.romoModalForm = function() {
2
- return $.map(this, function(element) {
3
- return new RomoModalForm(element);
4
- });
5
- }
1
+ var RomoModalForm = RomoComponent(function(elem) {
2
+ this.elem = elem;
6
3
 
7
- var RomoModalForm = function(element) {
8
- this.elem = $(element);
4
+ this.doInit();
5
+ this._bindElem();
9
6
 
10
- this.modal = this.elem.romoModal()[0];
11
- this.doBindModal();
7
+ Romo.trigger(this.elem, 'romoModalForm:ready', [this]);
8
+ });
12
9
 
13
- this.form = undefined;
14
- this.elem.on('modalForm:form:triggerSubmit', $.proxy(function(e) {
15
- if (this.form != undefined) {
16
- this.form.elem.trigger('form:triggerSubmit', []);
10
+ // private
11
+
12
+ RomoModalForm.prototype._bindElem = function() {
13
+ Romo.on(this.elem, 'romoModalForm: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.doBindForm();
20
- this.elem.on('modal:loadBodySuccess', $.proxy(function(e, data, modal) {
21
- this.doBindForm();
22
- this.elem.trigger('modalForm:formReady', [this.form, this]);
18
+ Romo.on(this.elem, 'romoModal:loadBodySuccess', Romo.proxy(function(e, data, romoModal) {
19
+ this._bindForm();
20
+ Romo.trigger(this.elem, 'romoModalForm:formReady', [this.romoForm, this]);
23
21
  }, this));
24
22
 
25
- this.doInit();
26
- this.elem.trigger('modalForm:ready', [this]);
23
+ this._bindModal();
24
+ this._bindForm();
27
25
  }
28
26
 
29
- RomoModalForm.prototype.doInit = function() {
30
- // override as needed
31
- }
27
+ RomoModalForm.prototype._bindModal = function() {
28
+ this.romoModal = new RomoModal(this.elem);
32
29
 
33
- RomoModalForm.prototype.doBindModal = function() {
34
- if (this.elem.data('romo-modal-clear-content') === undefined) {
35
- this.elem.attr('data-romo-modal-clear-content', 'true');
30
+ if (Romo.data(this.elem, 'romo-modal-clear-content') === undefined) {
31
+ Romo.setData(this.elem, 'romo-modal-clear-content', 'true');
36
32
  }
37
33
 
38
- this.elem.on('modal:ready', $.proxy(function(e, modal) {
39
- this.elem.trigger('modalForm:modal:ready', [modal, this]);
34
+ Romo.on(this.elem, 'romoModal:ready', Romo.proxy(function(e, romoModal) {
35
+ Romo.trigger(this.elem, 'romoModalForm:romoModal:ready', [romoModal, this]);
40
36
  }, this));
41
- this.elem.on('modal:toggle', $.proxy(function(e, modal) {
42
- this.elem.trigger('modalForm:modal:toggle', [modal, this]);
37
+ Romo.on(this.elem, 'romoModal:toggle', Romo.proxy(function(e, romoModal) {
38
+ Romo.trigger(this.elem, 'romoModalForm:romoModal:toggle', [romoModal, this]);
43
39
  }, this));
44
- this.elem.on('modal:popupOpen', $.proxy(function(e, modal) {
45
- this.elem.trigger('modalForm:modal:popupOpen', [modal, this]);
40
+ Romo.on(this.elem, 'romoModal:popupOpen', Romo.proxy(function(e, romoModal) {
41
+ Romo.trigger(this.elem, 'romoModalForm:romoModal:popupOpen', [romoModal, this]);
46
42
  }, this));
47
- this.elem.on('modal:popupClose', $.proxy(function(e, modal) {
48
- this.elem.trigger('modalForm:modal:popupClose', [modal, this]);
43
+ Romo.on(this.elem, 'romoModal:popupClose', Romo.proxy(function(e, romoModal) {
44
+ Romo.trigger(this.elem, 'romoModalForm:romoModal:popupClose', [romoModal, this]);
49
45
  }, this));
50
- this.elem.on('modal:dragStart', $.proxy(function(e, modal) {
51
- this.elem.trigger('modalForm:modal:dragStart', [modal, this]);
46
+ Romo.on(this.elem, 'romoModal:dragStart', Romo.proxy(function(e, romoModal) {
47
+ Romo.trigger(this.elem, 'romoModalForm:romoModal:dragStart', [romoModal, this]);
52
48
  }, this));
53
- this.elem.on('modal:dragMove', $.proxy(function(e, placeX, placeY, modal) {
54
- this.elem.trigger('modalForm:modal:dragMove', [placeX, placeY, modal, this]);
49
+ Romo.on(this.elem, 'romoModal:dragMove', Romo.proxy(function(e, placeX, placeY, romoModal) {
50
+ Romo.trigger(this.elem, 'romoModalForm:romoModal:dragMove', [placeX, placeY, romoModal, this]);
55
51
  }, this));
56
- this.elem.on('modal:dragStop', $.proxy(function(e, modal) {
57
- this.elem.trigger('modalForm:modal:dragStop', [modal, this]);
52
+ Romo.on(this.elem, 'romoModal:dragStop', Romo.proxy(function(e, romoModal) {
53
+ Romo.trigger(this.elem, 'romoModalForm:romoModal:dragStop', [romoModal, this]);
58
54
  }, this));
59
- this.elem.on('modal:loadBodyStart', $.proxy(function(e, modal) {
60
- this.elem.trigger('modalForm:modal:loadBodyStart', [modal, this]);
55
+ Romo.on(this.elem, 'romoModal:loadBodyStart', Romo.proxy(function(e, romoModal) {
56
+ Romo.trigger(this.elem, 'romoModalForm:romoModal:loadBodyStart', [romoModal, this]);
61
57
  }, this));
62
- this.elem.on('modal:loadBodySuccess', $.proxy(function(e, data, modal) {
63
- this.elem.trigger('modalForm:modal:loadBodySuccess', [data, modal, this]);
58
+ Romo.on(this.elem, 'romoModal:loadBodySuccess', Romo.proxy(function(e, data, romoModal) {
59
+ Romo.trigger(this.elem, 'romoModalForm:romoModal:loadBodySuccess', [data, romoModal, this]);
64
60
  }, this));
65
- this.elem.on('modal:loadBodyError', $.proxy(function(e, xhr, modal) {
66
- this.elem.trigger('modalForm:modal:loadBodyError', [xhr, modal, this]);
61
+ Romo.on(this.elem, 'romoModal:loadBodyError', Romo.proxy(function(e, xhr, romoModal) {
62
+ Romo.trigger(this.elem, 'romoModalForm:romoModal:loadBodyError', [xhr, romoModal, this]);
67
63
  }, this));
68
- this.elem.on('modal:dismiss', $.proxy(function(e, modal) {
69
- this.elem.trigger('modalForm:modal:dismiss', [modal, this]);
64
+ Romo.on(this.elem, 'romoModal:dismiss', Romo.proxy(function(e, romoModal) {
65
+ Romo.trigger(this.elem, 'romoModalForm:romoModal:dismiss', [romoModal, this]);
70
66
  }, this));
71
67
  }
72
68
 
73
- RomoModalForm.prototype.doBindForm = function() {
74
- var formElem = this.modal.popupElem.find('[data-romo-form-auto="modalForm"]');
69
+ RomoModalForm.prototype._bindForm = function() {
70
+ this.romoForm = undefined;
71
+ var formElem = Romo.find(this.romoModal.popupElem, '[data-romo-form-auto="modalForm"]')[0];
75
72
 
76
- formElem.on('form:clearMsgs', $.proxy(function(e, form) {
77
- this.elem.trigger('modalForm:form:clearMsgs', [form, this]);
78
- }, this));
79
- formElem.on('form:ready', $.proxy(function(e, form) {
80
- this.elem.trigger('modalForm:form:ready', [form, this]);
81
- }, this));
82
- formElem.on('form:confirmSubmit', $.proxy(function(e, form) {
83
- this.elem.trigger('modalForm:form:confirmSubmit', [form, this]);
84
- }, this));
85
- formElem.on('form:beforeSubmit', $.proxy(function(e, form) {
86
- this.elem.trigger('modalForm:form:beforeSubmit', [form, this]);
87
- }, this));
88
- formElem.on('form:submitSuccess', $.proxy(function(e, data, form) {
89
- this.elem.trigger('modalForm:form:submitSuccess', [data, form, this]);
90
- }, this));
91
- formElem.on('form:submitInvalidMsgs', $.proxy(function(e, msgs, xhr, form) {
92
- this.elem.trigger('modalForm:form:submitInvalidMsgs', [msgs, xhr, form, this]);
93
- }, this));
94
- formElem.on('form:submitXhrError', $.proxy(function(e, xhr, form) {
95
- this.elem.trigger('modalForm:form:submitXhrError', [xhr, form, this]);
96
- }, this));
97
- formElem.on('form:submitError', $.proxy(function(e, xhr, form) {
98
- this.elem.trigger('modalForm:form:submitError', [xhr, form, this]);
99
- }, this));
100
- formElem.on('form:browserSubmit', $.proxy(function(e, form) {
101
- this.elem.trigger('modalForm:form:browserSubmit', [form, this]);
102
- }, this));
73
+ if (formElem !== undefined) {
74
+ Romo.on(formElem, 'romoForm:clearMsgs', Romo.proxy(function(e, romoForm) {
75
+ Romo.trigger(this.elem, 'romoModalForm:romoForm:clearMsgs', [romoForm, this]);
76
+ }, this));
77
+ Romo.on(formElem, 'romoForm:ready', Romo.proxy(function(e, romoForm) {
78
+ Romo.trigger(this.elem, 'romoModalForm:romoForm:ready', [romoForm, this]);
79
+ }, this));
80
+ Romo.on(formElem, 'romoForm:confirmSubmit', Romo.proxy(function(e, romoForm) {
81
+ Romo.trigger(this.elem, 'romoModalForm:romoForm:confirmSubmit', [romoForm, this]);
82
+ }, this));
83
+ Romo.on(formElem, 'romoForm:beforeSubmit', Romo.proxy(function(e, romoForm) {
84
+ Romo.trigger(this.elem, 'romoModalForm:romoForm:beforeSubmit', [romoForm, this]);
85
+ }, this));
86
+ Romo.on(formElem, 'romoForm:submitSuccess', Romo.proxy(function(e, data, romoForm) {
87
+ Romo.trigger(this.elem, 'romoModalForm:romoForm:submitSuccess', [data, romoForm, this]);
88
+ }, this));
89
+ Romo.on(formElem, 'romoForm:submitInvalidMsgs', Romo.proxy(function(e, msgs, xhr, romoForm) {
90
+ Romo.trigger(this.elem, 'romoModalForm:romoForm:submitInvalidMsgs', [msgs, xhr, romoForm, this]);
91
+ }, this));
92
+ Romo.on(formElem, 'romoForm:submitXhrError', Romo.proxy(function(e, xhr, romoForm) {
93
+ Romo.trigger(this.elem, 'romoModalForm:romoForm:submitXhrError', [xhr, romoForm, this]);
94
+ }, this));
95
+ Romo.on(formElem, 'romoForm:submitError', Romo.proxy(function(e, xhr, romoForm) {
96
+ Romo.trigger(this.elem, 'romoModalForm:romoForm:submitError', [xhr, romoForm, this]);
97
+ }, this));
98
+ Romo.on(formElem, 'romoForm:browserSubmit', Romo.proxy(function(e, romoForm) {
99
+ Romo.trigger(this.elem, 'romoModalForm:romoForm:browserSubmit', [romoForm, this]);
100
+ }, this));
103
101
 
104
- var submitElement = this.modal.popupElem.find('[data-romo-form-submit]')[0];
105
- var indicatorElements = this.modal.popupElem.find('[data-romo-indicator-auto="true"]');
106
- this.form = formElem.romoForm(submitElement, indicatorElements)[0];
102
+ var submitElems = Romo.find(this.romoModal.popupElem, '[data-romo-form-submit]');
103
+ var spinnerElems = Romo.find(this.romoModal.popupElem, '[data-romo-spinner-auto="true"]');
104
+
105
+ this.romoForm = new RomoForm(formElem, submitElems, spinnerElems);
106
+ }
107
107
  }
108
108
 
109
- Romo.onInitUI(function(e) {
110
- Romo.initUIElems(e, '[data-romo-modalForm-auto="true"]').romoModalForm();
111
- });
109
+ // event functions
110
+
111
+ // init
112
112
 
113
+ Romo.addElemsInitSelector('[data-romo-modalForm-auto="true"]', RomoModalForm);
@@ -1,35 +1,38 @@
1
- $.fn.romoOnkey = function() {
2
- return $.map(this, function(element) {
3
- return new RomoOnkey(element);
4
- });
5
- }
1
+ var RomoOnkey = RomoComponent(function(elem) {
2
+ this.elem = elem;
6
3
 
7
- var RomoOnkey = function(element) {
8
- this.elem = $(element);
9
4
  this.defaultTriggerOn = 'keydown';
5
+ this.defaultDelayMs = 0;
6
+ this.delayTimeout = undefined;
10
7
 
11
8
  this.doInit();
12
9
 
13
- this.triggerOn = this.elem.data('romo-onkey-on') || this.defaultTriggerOn;
14
- this.elem.on(this.triggerOn, $.proxy(this.onTrigger, this));
10
+ this.triggerOn = Romo.data(this.elem, 'romo-onkey-on') || this.defaultTriggerOn;
11
+ Romo.on(this.elem, this.triggerOn, Romo.proxy(this._onTrigger, this));
15
12
 
16
- this.elem.trigger('onkey:ready', [this]);
17
- }
13
+ Romo.trigger(this.elem, 'romoOnkey:ready', [this]);
14
+ });
15
+
16
+ // private
18
17
 
19
- RomoOnkey.prototype.doInit = function() {
20
- // override as needed
18
+ RomoOnkey.prototype._doTrigger = function(triggerEvent) {
19
+ clearTimeout(this.delayTimeout);
20
+ this.delayTimeout = setTimeout(
21
+ Romo.proxy(function() {
22
+ Romo.trigger(this.elem, 'romoOnkey:trigger', [triggerEvent, this]);
23
+ }, this),
24
+ Romo.data(this.elem, 'romo-onkey-delay-ms') || this.defaultDelayMs
25
+ );
21
26
  }
22
27
 
23
- RomoOnkey.prototype.onTrigger = function(e) {
24
- if (this.elem.hasClass('disabled') === false) {
25
- this.doTrigger(e);
28
+ // event functions
29
+
30
+ RomoOnkey.prototype.romoEvFn._onTrigger = function(e) {
31
+ if (Romo.hasClass(this.elem, 'disabled') === false) {
32
+ this._doTrigger(e);
26
33
  }
27
34
  }
28
35
 
29
- RomoOnkey.prototype.doTrigger = function(triggerEvent) {
30
- this.elem.trigger('onkey:trigger', [triggerEvent, this]);
31
- }
36
+ // init
32
37
 
33
- Romo.onInitUI(function(e) {
34
- Romo.initUIElems(e, '[data-romo-onkey-auto="true"]').romoOnkey();
35
- });
38
+ Romo.addElemsInitSelector('[data-romo-onkey-auto="true"]', RomoOnkey);