romo 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b9c55d4322da24e884d4cce58ba340dd43c1b351
4
+ data.tar.gz: ce87f221e2ef4a9798e305662427a0b4a7f34460
5
+ SHA512:
6
+ metadata.gz: 5511534ab1c0bd81bfa4a707e2f0138d92e34d94d0b27338c51982fdbf95d2e1b5f33e2a79d99dfbf190677c7cc47dad8439608f974d7abbe84b111e540408f2
7
+ data.tar.gz: 32852b7567b42db8823c02826d38527a672e28b693f86a333a9585e9ff783619236a682fe79b3a0eb83148bb651508a69a4589912b33a45e5864a8987b221ae4
@@ -11,23 +11,12 @@ var RomoForm = function(element, givenSubmitElement, givenIndicatorElements) {
11
11
  this.defaultIndicatorElems = this.elem.find('[data-romo-indicator-auto="true"]');
12
12
  this.indicatorElems = $(givenIndicatorElements || this.defaultIndicatorElems);
13
13
  this.changeSubmitElems = this.elem.find('[data-romo-form-change-submit="true"]');
14
-
15
- this.elem.on('keypress', $.proxy(this.onFormKeyPress, this));
16
- this.defaultSubmitElem.unbind('click');
17
- this.submitElem.unbind('click');
18
- this.submitElem.on('click', $.proxy(this.onSubmitClick, this));
19
- this.changeSubmitElems.on('change', $.proxy(function(e) {
20
- this.elem.trigger('form:triggerSubmit');
21
- }, this));
22
- this.elem.on('form:triggerSubmit', $.proxy(this.onSubmitClick, this));
23
-
24
- if (this.elem.data('romo-form-reload-page') === true) {
25
- this.elem.on('form:submitSuccess', function(e, data, form) {
26
- Romo.reloadPage();
27
- })
28
- }
14
+ this.onkeySubmitElems = this.elem.find('[data-romo-form-onkey-submit="true"]');
29
15
 
30
16
  this.defaultListValuesDelim = ',';
17
+ this.onkeyDefaultSubmitDelay = 300; // 0.3 secs
18
+ this.submitQueued = false;
19
+ this.submitRunning = false;
31
20
 
32
21
  this.removeEmptyGetParams = this.elem.data('romo-form-remove-empty-get-params')
33
22
  if (this.removeEmptyGetParams === undefined) {
@@ -40,6 +29,7 @@ var RomoForm = function(element, givenSubmitElement, givenIndicatorElements) {
40
29
  }
41
30
 
42
31
  this.doInit();
32
+ this.doBindForm();
43
33
  this.elem.trigger('form:clearMsgs', [this]);
44
34
  this.elem.trigger('form:ready', [this]);
45
35
  }
@@ -48,10 +38,36 @@ RomoForm.prototype.doInit = function() {
48
38
  // override as needed
49
39
  }
50
40
 
41
+ RomoForm.prototype.doBindForm = function() {
42
+ this.defaultSubmitElem.unbind('click');
43
+ this.submitElem.unbind('click');
44
+ this.submitElem.on('click', $.proxy(this.onSubmitClick, this));
45
+
46
+ this.changeSubmitElems.on('change', $.proxy(function(e) {
47
+ this.elem.trigger('form:triggerSubmit');
48
+ }, this));
49
+ this.onkeySubmitElems.on('onkey:trigger', $.proxy(function(e, triggerEvent, onkey) {
50
+ clearTimeout(this.onkeySubmitTimeout);
51
+ this.onkeySubmitTimeout = setTimeout($.proxy(function() {
52
+ this.elem.trigger('form:triggerSubmit');
53
+ }, this), onkey.elem.data('romo-form-onkey-submit-delay') || this.onkeyDefaultSubmitDelay);
54
+ }, this));
55
+ this.elem.on('form:triggerSubmit', $.proxy(this.onSubmitClick, this));
56
+
57
+ this.elem.on('keypress', $.proxy(this.onFormKeyPress, this));
58
+
59
+ if (this.elem.data('romo-form-reload-page') === true) {
60
+ this.elem.on('form:submitSuccess', function(e, data, form) {
61
+ Romo.reloadPage();
62
+ })
63
+ }
64
+
65
+ }
66
+
51
67
  RomoForm.prototype.onFormKeyPress = function(e) {
52
68
  var target = $(e.target);
53
69
 
54
- if(target.is(':not(TEXTAREA)') && e.which === 13 /* Enter */) {
70
+ if(target.is(':not(TEXTAREA)') && e.keyCode === 13 /* Enter */) {
55
71
  e.preventDefault();
56
72
  this.onSubmitClick();
57
73
  }
@@ -68,20 +84,16 @@ RomoForm.prototype.onSubmitClick = function(e) {
68
84
  }
69
85
 
70
86
  RomoForm.prototype.doSubmit = function() {
71
- this.indicatorElems.trigger('indicator:triggerStart');
72
- this.elem.trigger('form:beforeSubmit', [this]);
73
-
74
- if (this.elem.attr('method').toUpperCase() === 'GET') {
75
- this._doGetSubmit();
76
- } else {
77
- this._doNonGetSubmit();
87
+ this.submitQueued = true;
88
+ if (this.submitRunning === false) {
89
+ this._doSubmit();
78
90
  }
79
91
  }
80
92
 
81
93
  RomoForm.prototype.onSubmitSuccess = function(data, status, xhr) {
82
94
  this.elem.trigger('form:clearMsgs');
83
95
  this.elem.trigger('form:submitSuccess', [data, this]);
84
- this.elem.trigger('form:submitComplete', [this]);
96
+ this._doCompleteSubmit();
85
97
  }
86
98
 
87
99
  RomoForm.prototype.onSubmitError = function(xhr, errorType, error) {
@@ -93,8 +105,32 @@ RomoForm.prototype.onSubmitError = function(xhr, errorType, error) {
93
105
  this.elem.trigger('form:submitXhrError', [xhr, this]);
94
106
  }
95
107
  this.elem.trigger('form:submitError', [xhr, this]);
96
- this.elem.trigger('form:submitComplete', [this]);
97
108
  this.indicatorElems.trigger('indicator:triggerStop');
109
+ this._doCompleteSubmit();
110
+ }
111
+
112
+ // private
113
+
114
+ RomoForm.prototype._doCompleteSubmit = function() {
115
+ this.elem.trigger('form:submitComplete', [this]);
116
+ if (this.submitQueued === true) {
117
+ this._doSubmit();
118
+ } else {
119
+ this.submitRunning = false;
120
+ }
121
+ }
122
+
123
+ RomoForm.prototype._doSubmit = function() {
124
+ this.submitQueued = false;
125
+ this.submitRunning = true;
126
+ this.indicatorElems.trigger('indicator:triggerStart');
127
+ this.elem.trigger('form:beforeSubmit', [this]);
128
+
129
+ if (this.elem.attr('method').toUpperCase() === 'GET') {
130
+ this._doGetSubmit();
131
+ } else {
132
+ this._doNonGetSubmit();
133
+ }
98
134
  }
99
135
 
100
136
  RomoForm.prototype._doGetSubmit = function() {
@@ -0,0 +1,35 @@
1
+ $.fn.romoOnkey = function() {
2
+ return $.map(this, function(element) {
3
+ return new RomoOnkey(element);
4
+ });
5
+ }
6
+
7
+ var RomoOnkey = function(element) {
8
+ this.elem = $(element);
9
+ this.defaultTriggerOn = 'keydown';
10
+
11
+ this.doInit();
12
+
13
+ this.triggerOn = this.elem.data('romo-onkey-on') || this.defaultTriggerOn;
14
+ this.elem.on(this.triggerOn, $.proxy(this.onTrigger, this));
15
+
16
+ this.elem.trigger('onkey:ready', [this]);
17
+ }
18
+
19
+ RomoOnkey.prototype.doInit = function() {
20
+ // override as needed
21
+ }
22
+
23
+ RomoOnkey.prototype.onTrigger = function(e) {
24
+ if (this.elem.hasClass('disabled') === false) {
25
+ this.doTrigger(e);
26
+ }
27
+ }
28
+
29
+ RomoOnkey.prototype.doTrigger = function(triggerEvent) {
30
+ this.elem.trigger('onkey:trigger', [triggerEvent, this]);
31
+ }
32
+
33
+ Romo.onInitUI(function(e) {
34
+ Romo.initUIElems(e, '[data-romo-onkey-auto="true"]').romoOnkey();
35
+ });
data/lib/romo/dassets.rb CHANGED
@@ -43,6 +43,7 @@ module Romo::Dassets
43
43
  c.combination "js/romo.js", [
44
44
  'js/romo/base.js',
45
45
  'js/romo/invoke.js',
46
+ 'js/romo/onkey.js',
46
47
  'js/romo/form.js',
47
48
  'js/romo/dropdown.js',
48
49
  'js/romo/dropdown_form.js',
data/lib/romo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Romo
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -45,6 +45,7 @@ module Romo::Dassets
45
45
  exp_js_sources = [
46
46
  'js/romo/base.js',
47
47
  'js/romo/invoke.js',
48
+ 'js/romo/onkey.js',
48
49
  'js/romo/form.js',
49
50
  'js/romo/dropdown.js',
50
51
  'js/romo/dropdown_form.js',
metadata CHANGED
@@ -1,50 +1,39 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: romo
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 0
10
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Kelly Redding
14
8
  - Collin Redding
15
9
  autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
-
19
- date: 2015-01-28 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ~>
26
- - !ruby/object:Gem::Version
27
- hash: 27
28
- segments:
29
- - 2
30
- - 12
31
- version: "2.12"
32
- type: :development
12
+ date: 2015-02-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
33
15
  name: assert
34
- version_requirements: *id001
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.12'
21
+ type: :development
35
22
  prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2.12'
36
28
  description: A UI Toolkit
37
- email:
29
+ email:
38
30
  - kelly@kellyredding.com
39
31
  - collin.redding@me.com
40
32
  executables: []
41
-
42
33
  extensions: []
43
-
44
34
  extra_rdoc_files: []
45
-
46
- files:
47
- - .gitignore
35
+ files:
36
+ - ".gitignore"
48
37
  - Gemfile
49
38
  - LICENSE.txt
50
39
  - README.md
@@ -79,6 +68,7 @@ files:
79
68
  - assets/js/romo/invoke.js
80
69
  - assets/js/romo/modal.js
81
70
  - assets/js/romo/modal_form.js
71
+ - assets/js/romo/onkey.js
82
72
  - assets/js/romo/select.js
83
73
  - assets/js/romo/select_dropdown.js
84
74
  - assets/js/romo/sortable.js
@@ -95,39 +85,30 @@ files:
95
85
  - test/unit/romo_tests.rb
96
86
  - tmp/.gitkeep
97
87
  homepage: http://github.com/redding/romo
98
- licenses:
88
+ licenses:
99
89
  - MIT
90
+ metadata: {}
100
91
  post_install_message:
101
92
  rdoc_options: []
102
-
103
- require_paths:
93
+ require_paths:
104
94
  - lib
105
- required_ruby_version: !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
108
97
  - - ">="
109
- - !ruby/object:Gem::Version
110
- hash: 3
111
- segments:
112
- - 0
113
- version: "0"
114
- required_rubygems_version: !ruby/object:Gem::Requirement
115
- none: false
116
- requirements:
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
117
102
  - - ">="
118
- - !ruby/object:Gem::Version
119
- hash: 3
120
- segments:
121
- - 0
122
- version: "0"
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
123
105
  requirements: []
124
-
125
106
  rubyforge_project:
126
- rubygems_version: 1.8.25
107
+ rubygems_version: 2.4.5
127
108
  signing_key:
128
- specification_version: 3
109
+ specification_version: 4
129
110
  summary: A UI Toolkit
130
- test_files:
111
+ test_files:
131
112
  - test/helper.rb
132
113
  - test/support/.gitkeep
133
114
  - test/system/.gitkeep