jquery-kladr-rails 1.4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +1 -0
- data/jquery-kladr-rails.gemspec +23 -0
- data/lib/jquery/kladr/rails.rb +11 -0
- data/lib/jquery/kladr/rails/version.rb +7 -0
- data/vendor/assets/images/jquery.kladr.spinner.png +0 -0
- data/vendor/assets/javascripts/jquery.kladr.js +515 -0
- data/vendor/assets/stylesheets/jquery.kladr.css.erb +46 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c44ccafe77ee57fb6b6fe974e6749a6695b187cd
|
4
|
+
data.tar.gz: 006f7874a2cf2ae8ed41c2576452a31ee60d5e81
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a243803e7cbdd90a4c3a20f33c7b83aa1d06856cdc1dbce0dd42fb6c9bf79f923f2fd40a660dd96f7284380e5c28673b370b1d4a186ed357234827e5d4470c1
|
7
|
+
data.tar.gz: a38e244fa0a608d2693596d78aa030442916eec8fa03479936797c503a448f42a16cfeb554b0146c065650ca6751f06ef2b5709622a7066226aefa808f26ed48
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Novikov Andrey
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
KLADR API JS client for Rails Asset Pipeline
|
2
|
+
============================================
|
3
|
+
|
4
|
+
[JS client for KLADR API servise as jQuery plugin] [plugin] by [@garakh] [author] packaged for Ruby on Rails asset pipeline.
|
5
|
+
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/jquery-kladr-rails.png)](http://badge.fury.io/rb/jquery-kladr-rails)
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'jquery-kladr-rails'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Add this line to `app/assets/stylesheets/application.css`:
|
20
|
+
|
21
|
+
*= require jquery.kladr
|
22
|
+
|
23
|
+
Add this line to `app/assets/javascripts/application.js`:
|
24
|
+
|
25
|
+
//= require jquery.kladr
|
26
|
+
|
27
|
+
Usage
|
28
|
+
-----
|
29
|
+
|
30
|
+
See the original [plugin] README and official [examples].
|
31
|
+
|
32
|
+
Contributing
|
33
|
+
------------
|
34
|
+
|
35
|
+
1. Fork it
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create new Pull Request
|
40
|
+
|
41
|
+
### Version policy
|
42
|
+
|
43
|
+
This gem version number is in form of **X.Y.Z.P**, where **X.Y.Z** is a version of original [plugin] and **P** is a gem-specific patch level.
|
44
|
+
|
45
|
+
[plugin]: https://github.com/garakh/kladrapi-jsclient
|
46
|
+
[author]: https://github.com/garakh
|
47
|
+
[examples]: http://kladr-api.ru/examples/ "Official site examples"
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jquery/kladr/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'jquery-kladr-rails'
|
8
|
+
spec.version = Jquery::Kladr::Rails::VERSION
|
9
|
+
spec.authors = ['Andrey Novikov']
|
10
|
+
spec.email = ['envek@envek.name']
|
11
|
+
spec.description = %q{KLADR API jQuery client plugin for Ruby on Rails asset pipeline}
|
12
|
+
spec.summary = %q{This gem packages the KLADR API jQuery client plugin for address autocompletion for Rails 3.1+ asset pipeline.}
|
13
|
+
spec.homepage = 'https://github.com/Envek/jquery-kladr-rails'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
end
|
Binary file
|
@@ -0,0 +1,515 @@
|
|
1
|
+
(function($) {
|
2
|
+
$.kladr = {};
|
3
|
+
|
4
|
+
// Service URL
|
5
|
+
$.kladr.url = 'http://kladr-api.ru/api.php';
|
6
|
+
|
7
|
+
// Enum KLADR object types
|
8
|
+
$.kladr.type = {
|
9
|
+
region: 'region',
|
10
|
+
district: 'district',
|
11
|
+
city: 'city',
|
12
|
+
street: 'street',
|
13
|
+
building: 'building'
|
14
|
+
};
|
15
|
+
|
16
|
+
// Send query to service
|
17
|
+
$.kladr.api = function(query, callback) {
|
18
|
+
var params = {};
|
19
|
+
|
20
|
+
if( query.token ) params.token = query.token;
|
21
|
+
if( query.key ) params.key = query.key;
|
22
|
+
if( query.type ) params.contentType = query.type;
|
23
|
+
if( query.name ) params.query = query.name;
|
24
|
+
|
25
|
+
if( query.parentType && query.parentId ){
|
26
|
+
params[query.parentType+'Id'] = query.parentId;
|
27
|
+
}
|
28
|
+
|
29
|
+
if( query.withParents ) params.withParent = 1;
|
30
|
+
params.limit = query.limit ? query.limit : 2000;
|
31
|
+
|
32
|
+
var completed = false;
|
33
|
+
|
34
|
+
$.getJSON($.kladr.url + "?callback=?",
|
35
|
+
params,
|
36
|
+
function(data) {
|
37
|
+
if(completed) return;
|
38
|
+
completed = true;
|
39
|
+
callback && callback( data.result );
|
40
|
+
}
|
41
|
+
);
|
42
|
+
|
43
|
+
setTimeout(function() {
|
44
|
+
if(completed) return;
|
45
|
+
completed = true;
|
46
|
+
console.error('Request error');
|
47
|
+
callback && callback( [] );
|
48
|
+
}, 5000);
|
49
|
+
};
|
50
|
+
|
51
|
+
// Check existence object
|
52
|
+
$.kladr.check = function(query, callback) {
|
53
|
+
query.withParents = false;
|
54
|
+
query.limit = 1;
|
55
|
+
|
56
|
+
$.kladr.api(query, function(objs) {
|
57
|
+
if(objs && objs.length){
|
58
|
+
callback && callback(objs[0]);
|
59
|
+
} else {
|
60
|
+
callback && callback(false);
|
61
|
+
}
|
62
|
+
});
|
63
|
+
};
|
64
|
+
})(jQuery);
|
65
|
+
|
66
|
+
(function($, undefined) {
|
67
|
+
$.fn.kladr = function(param1, param2) {
|
68
|
+
|
69
|
+
var result = undefined;
|
70
|
+
this.each(function() {
|
71
|
+
var res = kladr($(this), param1, param2);
|
72
|
+
if(result == undefined) result = res;
|
73
|
+
});
|
74
|
+
|
75
|
+
return result;
|
76
|
+
|
77
|
+
function kladr(input, param1, param2) {
|
78
|
+
var ac = null;
|
79
|
+
var spinner = null;
|
80
|
+
|
81
|
+
var options = null;
|
82
|
+
var defaultOptions = {
|
83
|
+
token: null,
|
84
|
+
key: null,
|
85
|
+
type: null,
|
86
|
+
parentType: null,
|
87
|
+
parentId: null,
|
88
|
+
limit: 10,
|
89
|
+
withParents: false,
|
90
|
+
verify: false,
|
91
|
+
showSpinner: true,
|
92
|
+
arrowSelect: true,
|
93
|
+
current: null,
|
94
|
+
|
95
|
+
open: null,
|
96
|
+
close: null,
|
97
|
+
send: null,
|
98
|
+
received: null,
|
99
|
+
select: null,
|
100
|
+
check: null,
|
101
|
+
|
102
|
+
source: function(query, callback) {
|
103
|
+
var params = {
|
104
|
+
token: options.token,
|
105
|
+
key: options.token,
|
106
|
+
type: options.type,
|
107
|
+
name: query,
|
108
|
+
parentType: options.parentType,
|
109
|
+
parentId: options.parentId,
|
110
|
+
withParents: options.withParents,
|
111
|
+
limit: options.limit
|
112
|
+
};
|
113
|
+
|
114
|
+
$.kladr.api(params, callback);
|
115
|
+
},
|
116
|
+
|
117
|
+
labelFormat: function(obj, query) {
|
118
|
+
var label = '';
|
119
|
+
|
120
|
+
var name = obj.name.toLowerCase();
|
121
|
+
query = query.toLowerCase();
|
122
|
+
|
123
|
+
var start = name.indexOf(query);
|
124
|
+
start = start > 0 ? start : 0;
|
125
|
+
|
126
|
+
if(obj.typeShort){
|
127
|
+
label += obj.typeShort + '. ';
|
128
|
+
}
|
129
|
+
|
130
|
+
if(query.length < obj.name.length){
|
131
|
+
label += obj.name.substr(0, start);
|
132
|
+
label += '<strong>' + obj.name.substr(start, query.length) + '</strong>';
|
133
|
+
label += obj.name.substr(start+query.length, obj.name.length-query.length-start);
|
134
|
+
} else {
|
135
|
+
label += '<strong>' + obj.name + '</strong>';
|
136
|
+
}
|
137
|
+
|
138
|
+
return label;
|
139
|
+
},
|
140
|
+
|
141
|
+
valueFormat: function(obj, query) {
|
142
|
+
return obj.name;
|
143
|
+
}
|
144
|
+
};
|
145
|
+
|
146
|
+
var keys = {
|
147
|
+
up: 38,
|
148
|
+
down: 40,
|
149
|
+
esc: 27,
|
150
|
+
enter: 13
|
151
|
+
};
|
152
|
+
|
153
|
+
var spinnerInterval = null;
|
154
|
+
|
155
|
+
return init(param1, param2, function() {
|
156
|
+
var isActive = false;
|
157
|
+
|
158
|
+
create();
|
159
|
+
position();
|
160
|
+
|
161
|
+
input.keyup(open);
|
162
|
+
input.keydown(keyselect);
|
163
|
+
input.change(function(){
|
164
|
+
if(!isActive) change();
|
165
|
+
});
|
166
|
+
input.blur(function(){
|
167
|
+
if(!isActive) close();
|
168
|
+
});
|
169
|
+
|
170
|
+
ac.on('click', 'li, a', mouseselect);
|
171
|
+
ac.on('mouseenter', 'li', function(){
|
172
|
+
var $this = $(this);
|
173
|
+
|
174
|
+
ac.find('li.active').removeClass('active');
|
175
|
+
$this.addClass('active');
|
176
|
+
|
177
|
+
var obj = $this.find('a').data('kladr-object');
|
178
|
+
trigger('preselect', obj);
|
179
|
+
|
180
|
+
isActive = true;
|
181
|
+
});
|
182
|
+
ac.on('mouseleave', 'li', function(){
|
183
|
+
$(this).removeClass('active');
|
184
|
+
isActive = false;
|
185
|
+
});
|
186
|
+
|
187
|
+
$(window).resize(position);
|
188
|
+
});
|
189
|
+
|
190
|
+
function init( param1, param2, callback ) {
|
191
|
+
options = input.data('kladr-options');
|
192
|
+
|
193
|
+
if(param2 !== undefined){
|
194
|
+
options[param1] = param2;
|
195
|
+
input.data('kladr-options', options);
|
196
|
+
return input;
|
197
|
+
}
|
198
|
+
|
199
|
+
if($.type(param1) === 'string'){
|
200
|
+
if(!options) return null;
|
201
|
+
return options[param1];
|
202
|
+
}
|
203
|
+
|
204
|
+
if(options){
|
205
|
+
return input;
|
206
|
+
}
|
207
|
+
|
208
|
+
options = defaultOptions;
|
209
|
+
if($.type(param1) === 'object'){
|
210
|
+
for(var i in param1){
|
211
|
+
options[i] = param1[i];
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
input.data('kladr-options', options);
|
216
|
+
callback && callback();
|
217
|
+
return input;
|
218
|
+
};
|
219
|
+
|
220
|
+
function create() {
|
221
|
+
var container = $(document.getElementById('kladr_autocomplete'));
|
222
|
+
var inputName = input.attr('name');
|
223
|
+
|
224
|
+
if(!container.length){
|
225
|
+
container = $('<div id="kladr_autocomplete"></div>').appendTo('body');
|
226
|
+
}
|
227
|
+
|
228
|
+
input.attr('autocomplete', 'off');
|
229
|
+
|
230
|
+
ac = $('<ul class="kladr_autocomplete_'+inputName+'" style="display: none;"></ul>');
|
231
|
+
ac.appendTo(container);
|
232
|
+
|
233
|
+
spinner = $('<div class="spinner kladr_autocomplete_'+inputName+'_spinner" class="spinner" style="display: none;"></div>');
|
234
|
+
spinner.appendTo(container);
|
235
|
+
};
|
236
|
+
|
237
|
+
function render(objs, query) {
|
238
|
+
ac.empty();
|
239
|
+
for(var i in objs){
|
240
|
+
var obj = objs[i];
|
241
|
+
var value = options.valueFormat(obj, query);
|
242
|
+
var label = options.labelFormat(obj, query);
|
243
|
+
|
244
|
+
var a = $('<a data-val="'+value+'">'+label+'</a>');
|
245
|
+
a.data('kladr-object', obj);
|
246
|
+
|
247
|
+
var li = $('<li></li>').append(a);
|
248
|
+
li.appendTo(ac);
|
249
|
+
}
|
250
|
+
};
|
251
|
+
|
252
|
+
function position() {
|
253
|
+
var inputOffset = input.offset();
|
254
|
+
var inputWidth = input.outerWidth();
|
255
|
+
var inputHeight = input.outerHeight();
|
256
|
+
|
257
|
+
ac.css({
|
258
|
+
top: inputOffset.top + inputHeight + 'px',
|
259
|
+
left: inputOffset.left
|
260
|
+
});
|
261
|
+
|
262
|
+
var differ = ac.outerWidth() - ac.width();
|
263
|
+
ac.width(inputWidth - differ);
|
264
|
+
|
265
|
+
var spinnerWidth = spinner.width();
|
266
|
+
var spinnerHeight = spinner.height();
|
267
|
+
|
268
|
+
spinner.css({
|
269
|
+
top: inputOffset.top + (inputHeight - spinnerHeight)/2 - 1,
|
270
|
+
left: inputOffset.left + inputWidth - spinnerWidth - 2,
|
271
|
+
});
|
272
|
+
};
|
273
|
+
|
274
|
+
function open(event) {
|
275
|
+
// return on keyup control keys
|
276
|
+
if((event.which > 8) && (event.which < 46)) return;
|
277
|
+
|
278
|
+
if(!validate()) return;
|
279
|
+
|
280
|
+
var query = key(input.val());
|
281
|
+
if(!$.trim(query)){
|
282
|
+
close();
|
283
|
+
return;
|
284
|
+
}
|
285
|
+
|
286
|
+
spinnerShow();
|
287
|
+
trigger('send');
|
288
|
+
|
289
|
+
options.source(query, function(objs) {
|
290
|
+
spinnerHide();
|
291
|
+
trigger('received');
|
292
|
+
|
293
|
+
if(!input.is(':focus')){
|
294
|
+
close();
|
295
|
+
return;
|
296
|
+
}
|
297
|
+
|
298
|
+
if(!$.trim(input.val()) || !objs.length){
|
299
|
+
close();
|
300
|
+
return;
|
301
|
+
}
|
302
|
+
|
303
|
+
render(objs, query);
|
304
|
+
position();
|
305
|
+
ac.slideDown(50);
|
306
|
+
trigger('open');
|
307
|
+
});
|
308
|
+
};
|
309
|
+
|
310
|
+
function close() {
|
311
|
+
select();
|
312
|
+
ac.hide();
|
313
|
+
trigger('close');
|
314
|
+
};
|
315
|
+
|
316
|
+
function validate() {
|
317
|
+
switch(options.type){
|
318
|
+
case $.kladr.type.region:
|
319
|
+
case $.kladr.type.district:
|
320
|
+
case $.kladr.type.city:
|
321
|
+
if(options.parentType && !options.parentId)
|
322
|
+
{
|
323
|
+
console.error('parentType is defined and parentId in not');
|
324
|
+
return false;
|
325
|
+
}
|
326
|
+
break;
|
327
|
+
case $.kladr.type.street:
|
328
|
+
if(options.parentType != $.kladr.type.city){
|
329
|
+
console.error('For street parentType must equal "city"');
|
330
|
+
return false;
|
331
|
+
}
|
332
|
+
if(!options.parentId){
|
333
|
+
console.error('For street parentId must defined');
|
334
|
+
return false;
|
335
|
+
}
|
336
|
+
break;
|
337
|
+
case $.kladr.type.building:
|
338
|
+
if(options.parentType != $.kladr.type.street){
|
339
|
+
console.error('For building parentType must equal "street"');
|
340
|
+
return false;
|
341
|
+
}
|
342
|
+
if(!options.parentId){
|
343
|
+
console.error('For building parentId must defined');
|
344
|
+
return false;
|
345
|
+
}
|
346
|
+
break;
|
347
|
+
default:
|
348
|
+
console.error('type must defined and equal "region", "district", "city", "street" or "building"');
|
349
|
+
return false;
|
350
|
+
}
|
351
|
+
|
352
|
+
if(options.limit < 1){
|
353
|
+
console.error('limit must greater than 0');
|
354
|
+
return false;
|
355
|
+
}
|
356
|
+
|
357
|
+
return true;
|
358
|
+
};
|
359
|
+
|
360
|
+
function select() {
|
361
|
+
var a = ac.find('.active a');
|
362
|
+
if(!a.length) return;
|
363
|
+
|
364
|
+
input.val(a.attr('data-val'));
|
365
|
+
options.current = a.data('kladr-object');
|
366
|
+
input.data('kladr-options', options);
|
367
|
+
trigger('select', options.current);
|
368
|
+
};
|
369
|
+
|
370
|
+
function keyselect(event) {
|
371
|
+
var active = ac.find('li.active');
|
372
|
+
switch(event.which){
|
373
|
+
case keys.up:
|
374
|
+
if(active.length) {
|
375
|
+
active.removeClass('active');
|
376
|
+
active = active.prev();
|
377
|
+
} else {
|
378
|
+
active = ac.find('li').last();
|
379
|
+
}
|
380
|
+
active.addClass('active');
|
381
|
+
|
382
|
+
var obj = active.find('a').data('kladr-object');
|
383
|
+
trigger('preselect', obj);
|
384
|
+
|
385
|
+
if(options.arrowSelect) select();
|
386
|
+
break;
|
387
|
+
case keys.down:
|
388
|
+
if(active.length) {
|
389
|
+
active.removeClass('active');
|
390
|
+
active = active.next();
|
391
|
+
} else {
|
392
|
+
active = ac.find('li').first();
|
393
|
+
}
|
394
|
+
active.addClass('active');
|
395
|
+
|
396
|
+
var obj = active.find('a').data('kladr-object');
|
397
|
+
trigger('preselect', obj);
|
398
|
+
|
399
|
+
if(options.arrowSelect) select();
|
400
|
+
break;
|
401
|
+
case keys.esc:
|
402
|
+
active.removeClass('active');
|
403
|
+
close();
|
404
|
+
break;
|
405
|
+
case keys.enter:
|
406
|
+
if(!options.arrowSelect) select();
|
407
|
+
active.removeClass('active');
|
408
|
+
close();
|
409
|
+
return false;
|
410
|
+
}
|
411
|
+
};
|
412
|
+
|
413
|
+
function mouseselect() {
|
414
|
+
var a = $(this);
|
415
|
+
if(a.is('li')) a = a.find('a');
|
416
|
+
close();
|
417
|
+
input.focus();
|
418
|
+
return false;
|
419
|
+
};
|
420
|
+
|
421
|
+
function change() {
|
422
|
+
if(!options.verify) return;
|
423
|
+
|
424
|
+
if(!validate()) return;
|
425
|
+
|
426
|
+
var query = key(input.val());
|
427
|
+
if(!$.trim(query)) return;
|
428
|
+
|
429
|
+
spinnerShow();
|
430
|
+
trigger('send');
|
431
|
+
|
432
|
+
options.source(query, function(objs) {
|
433
|
+
spinnerHide();
|
434
|
+
trigger('received');
|
435
|
+
|
436
|
+
var obj = null;
|
437
|
+
for(var i=0; i<objs.length; i++){
|
438
|
+
var queryLowerCase = query.toLowerCase();
|
439
|
+
var nameLowerCase = objs[i].name.toLowerCase();
|
440
|
+
if(queryLowerCase == nameLowerCase){
|
441
|
+
obj = objs[i];
|
442
|
+
break;
|
443
|
+
}
|
444
|
+
}
|
445
|
+
|
446
|
+
if(obj) input.val(options.valueFormat(obj, query));
|
447
|
+
|
448
|
+
options.current = obj;
|
449
|
+
input.data('kladr-options', options);
|
450
|
+
trigger('check', options.current);
|
451
|
+
});
|
452
|
+
};
|
453
|
+
|
454
|
+
function key(val) {
|
455
|
+
var en = "1234567890qazwsxedcrfvtgbyhnujmik,ol.p;[']- " +
|
456
|
+
"QAZWSXEDCRFVTGBYHNUJMIK<OL>P:{\"} ";
|
457
|
+
|
458
|
+
var ru = "1234567890йфяцычувскамепинртгоьшлбщдюзжхэъ- " +
|
459
|
+
"ЙФЯЦЫЧУВСКАМЕПИНРТГОЬШЛБЩДЮЗЖХЭЪ ";
|
460
|
+
|
461
|
+
var strNew = '';
|
462
|
+
var ch;
|
463
|
+
var index;
|
464
|
+
for( var i=0; i<val.length; i++ ){
|
465
|
+
ch = val[i];
|
466
|
+
index = en.indexOf(ch);
|
467
|
+
|
468
|
+
if(index > -1){
|
469
|
+
strNew += ru[index];
|
470
|
+
continue;
|
471
|
+
}
|
472
|
+
|
473
|
+
strNew += ch;
|
474
|
+
}
|
475
|
+
|
476
|
+
return strNew;
|
477
|
+
};
|
478
|
+
|
479
|
+
function trigger(event, obj) {
|
480
|
+
if(!event) return;
|
481
|
+
input.trigger('kladr_'+event, obj);
|
482
|
+
if(options[event]) options[event].call(input.get(0), obj);
|
483
|
+
};
|
484
|
+
|
485
|
+
function spinnerStart() {
|
486
|
+
if(spinnerInterval) return;
|
487
|
+
|
488
|
+
var top = -0.2;
|
489
|
+
spinnerInterval = setInterval(function() {
|
490
|
+
if(!spinner.is(':visible')){
|
491
|
+
clearInterval(spinnerInterval);
|
492
|
+
spinnerInterval = null;
|
493
|
+
return;
|
494
|
+
}
|
495
|
+
|
496
|
+
spinner.css('background-position', '0% '+top+'%');
|
497
|
+
|
498
|
+
top += 5.555556;
|
499
|
+
if(top > 95) top = -0.2;
|
500
|
+
}, 30);
|
501
|
+
};
|
502
|
+
|
503
|
+
function spinnerShow() {
|
504
|
+
if(options.showSpinner) {
|
505
|
+
spinner.show();
|
506
|
+
spinnerStart();
|
507
|
+
}
|
508
|
+
};
|
509
|
+
|
510
|
+
function spinnerHide() {
|
511
|
+
spinner.hide();
|
512
|
+
};
|
513
|
+
};
|
514
|
+
};
|
515
|
+
})(jQuery);
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#kladr_autocomplete ul{
|
2
|
+
position: absolute;
|
3
|
+
display: block;
|
4
|
+
margin: 0;
|
5
|
+
padding: 0;
|
6
|
+
border: 1px solid rgb(138, 138, 138);
|
7
|
+
border-radius: 3px;
|
8
|
+
background-color: white;
|
9
|
+
z-index: 9999;
|
10
|
+
}
|
11
|
+
|
12
|
+
#kladr_autocomplete li{
|
13
|
+
display: list-item;
|
14
|
+
list-style-type: none;
|
15
|
+
margin: 0;
|
16
|
+
padding: 3px 5px;
|
17
|
+
overflow: hidden;
|
18
|
+
border: 1px solid white;
|
19
|
+
border-bottom: 1px solid rgb(189, 189, 189);
|
20
|
+
}
|
21
|
+
|
22
|
+
#kladr_autocomplete li.active{
|
23
|
+
background-color: rgb(224, 224, 224);
|
24
|
+
border-radius: 3px;
|
25
|
+
border: 1px solid rgb(151, 151, 151);
|
26
|
+
}
|
27
|
+
|
28
|
+
#kladr_autocomplete a{
|
29
|
+
display: block;
|
30
|
+
cursor: default;
|
31
|
+
width: 10000px;
|
32
|
+
}
|
33
|
+
|
34
|
+
#kladr_autocomplete .spinner{
|
35
|
+
position: absolute;
|
36
|
+
display: block;
|
37
|
+
margin: 0;
|
38
|
+
padding: 0;
|
39
|
+
width: 20px;
|
40
|
+
height: 20px;
|
41
|
+
background-color: transparent;
|
42
|
+
background-image: url(<%= image_path 'jquery.kladr.spinner.png' %>);
|
43
|
+
background-position: center center;
|
44
|
+
background-repeat: no-repeat;
|
45
|
+
z-index: 9999;
|
46
|
+
}
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery-kladr-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrey Novikov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: KLADR API jQuery client plugin for Ruby on Rails asset pipeline
|
42
|
+
email:
|
43
|
+
- envek@envek.name
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- jquery-kladr-rails.gemspec
|
54
|
+
- lib/jquery/kladr/rails.rb
|
55
|
+
- lib/jquery/kladr/rails/version.rb
|
56
|
+
- vendor/assets/images/jquery.kladr.spinner.png
|
57
|
+
- vendor/assets/javascripts/jquery.kladr.js
|
58
|
+
- vendor/assets/stylesheets/jquery.kladr.css.erb
|
59
|
+
homepage: https://github.com/Envek/jquery-kladr-rails
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.1.11
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: This gem packages the KLADR API jQuery client plugin for address autocompletion
|
83
|
+
for Rails 3.1+ asset pipeline.
|
84
|
+
test_files: []
|