assoc_whisperer 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/assoc_whisp.js +28 -32
- data/assoc_whisperer.gemspec +5 -3
- data/lib/assoc_whisperer/template.rb +2 -0
- data/lib/assoc_whisperer/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27b9b727c24d4854931accf16f95b6a7e5a37057
|
4
|
+
data.tar.gz: 43ecbae14277e0a36f996810f630c2ddce36ce82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 920c4fa5f5ddf259352295b986077d31642efa307da7ced452693d9df971637dd9d24b1b9254d3ad703eb6346fd1cd09b863a7aaa791c6ee5ef05e44a50ef186
|
7
|
+
data.tar.gz: 57e24abab50e7e490d7c5ac592920b6014c2fe92f3262205632d3a731bbcda1e0cf60fd3e6d11636f7964be620a8b9bb1d00033e43d5b907a67f01e763bf8743
|
@@ -22,6 +22,7 @@ document.AssocWhisperer = (function () {
|
|
22
22
|
base: el,
|
23
23
|
text_field: el.children('.text_field'),
|
24
24
|
value_field: el.children('.value_field'),
|
25
|
+
dropdown_button: el.children('.dropdown_button'),
|
25
26
|
list: null
|
26
27
|
};
|
27
28
|
opts = el.data('opts');
|
@@ -32,7 +33,7 @@ document.AssocWhisperer = (function () {
|
|
32
33
|
w = Object.create(proto, {
|
33
34
|
nodes: {value: _nodes},
|
34
35
|
focused: {value: false, writable: true},
|
35
|
-
filled: {value: _nodes
|
36
|
+
filled: {value: _nodes.value_field.val()!=='', writable: true},
|
36
37
|
// setting
|
37
38
|
action: {value: opts['action']},
|
38
39
|
params: {value: opts['params']}
|
@@ -56,17 +57,17 @@ document.AssocWhisperer = (function () {
|
|
56
57
|
if (_timer) clearTimeout(_timer);
|
57
58
|
if (w.filled) {
|
58
59
|
w.filled = false;
|
59
|
-
_nodes
|
60
|
-
_nodes
|
60
|
+
_nodes.value_field.val('');
|
61
|
+
_nodes.text_field.addClass('unfilled');
|
61
62
|
}
|
62
63
|
|
63
|
-
input_text = _nodes
|
64
|
+
input_text = _nodes.text_field.val();
|
64
65
|
if (input_text==='') {
|
65
66
|
w.removeList();
|
66
67
|
}
|
67
68
|
else {
|
68
|
-
if (_nodes
|
69
|
-
_nodes
|
69
|
+
if (_nodes.list) {
|
70
|
+
_nodes.list.addClass('invalid');
|
70
71
|
}
|
71
72
|
_timer = setTimeout(function () {
|
72
73
|
if (w.client_side) {
|
@@ -82,10 +83,10 @@ document.AssocWhisperer = (function () {
|
|
82
83
|
}, 700);
|
83
84
|
}
|
84
85
|
});
|
85
|
-
_nodes.text_field.on('click', function(){ _nodes
|
86
|
+
_nodes.text_field.on('click', function(){ _nodes.text_field.select(); });
|
86
87
|
_nodes.text_field.focus(function(){ w.focused = true; });
|
87
88
|
_nodes.text_field.blur(function(){ onBlur(); });
|
88
|
-
|
89
|
+
_nodes.dropdown_button.on('click', function(){
|
89
90
|
var f;
|
90
91
|
if (_timer) clearTimeout(_timer);
|
91
92
|
if (w.client_side) {
|
@@ -93,10 +94,10 @@ document.AssocWhisperer = (function () {
|
|
93
94
|
// var input_text;
|
94
95
|
// if (w.filled) showList(w.full_data);
|
95
96
|
// else {
|
96
|
-
// input_text = _nodes
|
97
|
+
// input_text = _nodes.text_field.val();
|
97
98
|
// showList(digest(input_text==='' ? null : input_text));
|
98
99
|
// }
|
99
|
-
// _nodes
|
100
|
+
// _nodes.list.focus();
|
100
101
|
// };
|
101
102
|
// if (!w.full_data) query(w, null, function (html_text) {
|
102
103
|
// w.full_data = $(html_text);
|
@@ -105,13 +106,13 @@ document.AssocWhisperer = (function () {
|
|
105
106
|
// else f();
|
106
107
|
}
|
107
108
|
else {
|
108
|
-
query(w, (w.filled ? null : _nodes
|
109
|
+
query(w, (w.filled ? null : _nodes.text_field.val()), function (html_text) {
|
109
110
|
showList($(html_text));
|
110
|
-
_nodes
|
111
|
+
_nodes.list.focus();
|
111
112
|
});
|
112
113
|
}
|
113
114
|
});
|
114
|
-
|
115
|
+
_nodes.dropdown_button.removeClass('querying'); // css class is set, hence gif gets pre-loaded
|
115
116
|
|
116
117
|
// // For local full_data finds matching rows and shows them.
|
117
118
|
// function digest(input_text) {
|
@@ -129,19 +130,16 @@ document.AssocWhisperer = (function () {
|
|
129
130
|
|
130
131
|
// Attaches a List sent by html string within Whisperer's tag. Positions it underneath the text field.
|
131
132
|
function showList (list) {
|
132
|
-
var base_dom;
|
133
133
|
w.removeList();
|
134
134
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
list.css('min-width', base_dom.width());
|
139
|
-
list.css('left', base_dom.offset().left);
|
140
|
-
list.css('top', base_dom.position().top + base_dom.outerHeight());
|
135
|
+
list.css('min-width', _nodes.base.width());
|
136
|
+
list.css('left', _nodes.base.offset().left);
|
137
|
+
list.css('top', _nodes.base.position().top + _nodes.base.outerHeight());
|
141
138
|
list.focus(function(){ w.focused = true; });
|
142
139
|
list.blur(function(){ onBlur(); });
|
143
|
-
|
140
|
+
_nodes.base.append(list);
|
144
141
|
|
142
|
+
_nodes.list = list;
|
145
143
|
list.find('div').on('click', function(el){ w.select($(el.currentTarget)); });
|
146
144
|
}
|
147
145
|
|
@@ -163,9 +161,9 @@ document.AssocWhisperer = (function () {
|
|
163
161
|
// Removes the List should there be any.
|
164
162
|
Object.defineProperty(proto, 'removeList', {
|
165
163
|
value: function () {
|
166
|
-
if (this.nodes
|
167
|
-
this.nodes
|
168
|
-
this.nodes
|
164
|
+
if (this.nodes.list) {
|
165
|
+
this.nodes.list.detach();
|
166
|
+
this.nodes.list = null
|
169
167
|
}
|
170
168
|
}
|
171
169
|
});
|
@@ -176,9 +174,9 @@ document.AssocWhisperer = (function () {
|
|
176
174
|
var text;
|
177
175
|
if (row.length!==1) return;
|
178
176
|
text = row.text();
|
179
|
-
this.nodes
|
180
|
-
this.nodes
|
181
|
-
this.nodes
|
177
|
+
this.nodes.text_field.val(text);
|
178
|
+
this.nodes.text_field.removeClass('unfilled');
|
179
|
+
this.nodes.value_field.val(row.attr('data-value'));
|
182
180
|
this.filled = true;
|
183
181
|
this.removeList();
|
184
182
|
}
|
@@ -186,10 +184,8 @@ document.AssocWhisperer = (function () {
|
|
186
184
|
|
187
185
|
// Actual ajax request for given input
|
188
186
|
function query (w, input, on_success) {
|
189
|
-
var btn;
|
190
187
|
klass.querying = true;
|
191
|
-
|
192
|
-
btn.addClass('querying');
|
188
|
+
w.nodes.dropdown_button.addClass('querying');
|
193
189
|
w.params['input'] = input;
|
194
190
|
$.ajax(w.action, {
|
195
191
|
type: 'GET',
|
@@ -199,7 +195,7 @@ document.AssocWhisperer = (function () {
|
|
199
195
|
success: on_success,
|
200
196
|
complete: function () {
|
201
197
|
klass.querying = false;
|
202
|
-
|
198
|
+
w.nodes.dropdown_button.removeClass('querying');
|
203
199
|
}
|
204
200
|
}
|
205
201
|
);
|
@@ -224,7 +220,7 @@ document.AssocWhisperer = (function () {
|
|
224
220
|
// Sets a value to Whisperer
|
225
221
|
Object.defineProperty(klass, 'setValueFor', {
|
226
222
|
value: function (value, whisp_action) {
|
227
|
-
findWhisperer(whisp_action).nodes
|
223
|
+
findWhisperer(whisp_action).nodes.value_field.val(value);
|
228
224
|
}
|
229
225
|
});
|
230
226
|
|
data/assoc_whisperer.gemspec
CHANGED
@@ -16,8 +16,10 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
# spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
# spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
# spec.add_development_dependency 'cucumber'
|
24
|
+
# spec.add_development_dependency 'capybara-webkit'
|
23
25
|
end
|
@@ -7,6 +7,7 @@ module AssocWhisperer
|
|
7
7
|
def initialize(action, opts={})
|
8
8
|
@action = action[0]=='/' ? action : "#{AssocWhisperer.def_url}/#{action}"
|
9
9
|
@opts = opts
|
10
|
+
@opts[:dropdown_button] = true if @opts[:dropdown_button].nil?
|
10
11
|
end
|
11
12
|
|
12
13
|
def params(params)
|
@@ -63,6 +64,7 @@ module AssocWhisperer
|
|
63
64
|
end
|
64
65
|
|
65
66
|
def dropdown_button_tag
|
67
|
+
return '' unless @opts[:dropdown_button].is_a? TrueClass
|
66
68
|
"<span class=\"dropdown_button querying\">\u25BE</span>"
|
67
69
|
end
|
68
70
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assoc_whisperer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Želazko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
84
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.4.3
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Rails tag assoc_whisperer for forms
|