combo_auto_box 0.0.29 → 0.0.30
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.
- data/lib/combo_auto_box/version.rb +1 -1
- data/vendor/assets/javascripts/combo-auto-box.js +109 -17
- metadata +2 -2
@@ -90,7 +90,7 @@ var ComboAutoBox = {
|
|
90
90
|
return false;
|
91
91
|
}
|
92
92
|
});
|
93
|
-
|
93
|
+
|
94
94
|
$('#' + inputId).autocomplete({
|
95
95
|
source: setAutoCompleteSource(inputId),
|
96
96
|
select: function(event, ui) {
|
@@ -292,20 +292,32 @@ var ComboAutoBox = {
|
|
292
292
|
if ((options.html == null) || (options.html.id == null)) {
|
293
293
|
html = html + ' id="' + generateAnId('combo-auto-box') + '"';
|
294
294
|
}
|
295
|
+
|
296
|
+
if (options.bootstrap) {
|
297
|
+
html = html + ' class="form-control" '
|
298
|
+
}
|
295
299
|
|
296
|
-
|
300
|
+
return '<' + html + '>';
|
297
301
|
};
|
298
302
|
|
299
303
|
// On click opens modal image tag inside "i" tag through css
|
300
304
|
var generateExpander = function () {
|
301
305
|
if (options.type == 'simple') {
|
306
|
+
if (options.bootstrap) {
|
307
|
+
return '<span class="input-group-btn" title="' + i18nShowSearchOptions(options.lang) + '"><button class="btn btn-default" type="button"><i class="glyphicon glyphicon-chevron-down"></i></button></span>';
|
308
|
+
} else {
|
302
309
|
return '<span class="simple" title="' + i18nShowSearchOptions(options.lang) + '"><i></i></span>';
|
310
|
+
}
|
303
311
|
} else if (options.type == 'multiple') {
|
304
312
|
return '<span class="multiple">' + options.label + ':</span>';
|
305
313
|
}
|
306
314
|
};
|
307
315
|
|
308
316
|
var adjustExpanderImage = function() {
|
317
|
+
if (options.bootstrap) {
|
318
|
+
return true;
|
319
|
+
}
|
320
|
+
|
309
321
|
if (options.type == 'simple') {
|
310
322
|
spanTag = $('#' + container + ' > div.container-combo-auto-box > span.simple');
|
311
323
|
|
@@ -402,19 +414,21 @@ var ComboAutoBox = {
|
|
402
414
|
|
403
415
|
// Global div for combo auto box
|
404
416
|
var generateDivTag = function () {
|
405
|
-
var
|
417
|
+
var klass = 'container-combo-auto-box'
|
406
418
|
if (options.type == 'multiple') {
|
407
|
-
|
419
|
+
klass = klass + ' multiple'
|
408
420
|
} else if (options.type == 'searchable') {
|
409
|
-
|
421
|
+
klass = klass + ' searchable'
|
422
|
+
} else if ((options.type == 'simple') && (options.bootstrap)) {
|
423
|
+
klass = klass + '-bootstrap input-group'
|
410
424
|
}
|
411
425
|
|
412
|
-
return '<div class="
|
426
|
+
return '<div class="' + klass + '">' + generateInputTag() + '</div>';
|
413
427
|
};
|
414
428
|
|
415
429
|
// dialog modal
|
416
430
|
var generateDivDialogModal = function (modalDialogId) {
|
417
|
-
|
431
|
+
$('<div id="'+ modalDialogId +'" class="dialog-modal"><div class="head"><span class="label">' + options.label + '</span><span class="close" title="Close">X</span></div><div class="list"><ul></ul></div></div>').appendTo('#' + container);
|
418
432
|
|
419
433
|
$('#' + modalDialogId + ' > div.head > span.close').click(function() {
|
420
434
|
$('#' + modalDialogId).dialog('close');
|
@@ -432,9 +446,40 @@ var ComboAutoBox = {
|
|
432
446
|
|
433
447
|
$("#" + modalDialogId).siblings('div.ui-dialog-titlebar').remove();
|
434
448
|
|
435
|
-
|
436
|
-
|
437
|
-
|
449
|
+
if ((options.type == 'simple') && (options.bootstrap)) {
|
450
|
+
$('#' + container + ' > div.container-combo-auto-box-bootstrap > span > button').click(function() {
|
451
|
+
openModalDialog(modalDialogId)
|
452
|
+
});
|
453
|
+
} else {
|
454
|
+
$('#' + container + ' > div.container-combo-auto-box > span.' + options.type).click(function() {
|
455
|
+
openModalDialog(modalDialogId)
|
456
|
+
});
|
457
|
+
}
|
458
|
+
};
|
459
|
+
|
460
|
+
// dialog modal
|
461
|
+
var generateBootstrapDialogModal = function (modalDialogId) {
|
462
|
+
modal = '<div class="modal fade" id="' + modalDialogId + '" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
|
463
|
+
'<div class="modal-dialog">' +
|
464
|
+
'<div class="modal-content">' +
|
465
|
+
'<div class="modal-header">' +
|
466
|
+
'<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>' +
|
467
|
+
'<h4 class="modal-title">' + options.label + '</h4>' +
|
468
|
+
'</div>' +
|
469
|
+
'<div class="modal-body">' +
|
470
|
+
'<div class="list-group" style="overflow:auto;height:440px"></div>' +
|
471
|
+
'</div>' +
|
472
|
+
'</div>' +
|
473
|
+
'</div>' +
|
474
|
+
'</div>';
|
475
|
+
|
476
|
+
$(modal).appendTo('#' + container);
|
477
|
+
|
478
|
+
getListForModalDialog(modalDialogId);
|
479
|
+
|
480
|
+
$('#' + container + ' > div.container-combo-auto-box-bootstrap > span > button').click(function() {
|
481
|
+
$('#' + modalDialogId).modal('show');
|
482
|
+
});
|
438
483
|
};
|
439
484
|
|
440
485
|
// Selects an item form modal dialog when clicked on
|
@@ -459,12 +504,20 @@ var ComboAutoBox = {
|
|
459
504
|
|
460
505
|
// set list for modal dialog
|
461
506
|
var setListForModalDialog = function (modalDialogId, data) {
|
507
|
+
if (options.bootstrap) {
|
508
|
+
setListForBootstrapModalDialog(modalDialogId, data);
|
509
|
+
} else {
|
510
|
+
setListForSimpleModalDialog(modalDialogId, data);
|
511
|
+
}
|
512
|
+
};
|
513
|
+
|
514
|
+
var setListForSimpleModalDialog = function (modalDialogId, data) {
|
462
515
|
var items = [];
|
463
516
|
|
464
517
|
$.each(data, function(index){
|
465
518
|
items.push('<li><span class="combo-auto-box-item-id">' + data[index].id +'</span><span class="combo-auto-box-item-label">'+ data[index].label + '</span></li>');
|
466
519
|
});
|
467
|
-
|
520
|
+
|
468
521
|
$('#' + modalDialogId + ' > div.list').css('height', ($('#' + modalDialogId).dialog("option", "height") - 60) + 'px');
|
469
522
|
$('#' + modalDialogId + ' > div.list > ul').html(items.join(''));
|
470
523
|
$('#' + modalDialogId + ' > div.list > ul > li').click(function() {
|
@@ -484,19 +537,50 @@ var ComboAutoBox = {
|
|
484
537
|
}
|
485
538
|
});
|
486
539
|
};
|
540
|
+
|
541
|
+
var setListForBootstrapModalDialog = function (modalDialogId, data) {
|
542
|
+
var items = [];
|
543
|
+
|
544
|
+
$.each(data, function(index){
|
545
|
+
items.push('<a href="javascript:void(0);" class="list-group-item"><span class="combo-auto-box-item-id" style="display:none;">' + data[index].id +'</span><span class="combo-auto-box-item-label">'+ data[index].label + '</span></a>');
|
546
|
+
});
|
547
|
+
|
548
|
+
$('#' + modalDialogId + ' > div.modal-dialog > div.modal-content > div.modal-body > div.list-group').html(items.join(''));
|
549
|
+
$('#' + modalDialogId + ' > div.modal-dialog > div.modal-content > div.modal-body > div.list-group > a').click(function() {
|
550
|
+
var thisId = $(this).children('span.combo-auto-box-item-id').text();
|
551
|
+
var thisLabel = $(this).children('span.combo-auto-box-item-label').text();
|
552
|
+
|
553
|
+
if (options.type == 'simple') {
|
554
|
+
$('#' + container + ' > div.container-combo-auto-box-bootstrap > input').val(thisLabel);
|
555
|
+
selectData(thisId, thisLabel);
|
556
|
+
} else if (options.type == 'multiple') {
|
557
|
+
$('#' + container + ' > div.container-combo-auto-box > input').val('');
|
558
|
+
addMultipleItem($('#' + container + ' > div.container-combo-auto-box > input').attr('id'), thisId, thisLabel);
|
559
|
+
$('#' + container + ' > div.container-combo-auto-box > input[type="text"]').focus();
|
560
|
+
selectData(thisId, thisLabel);
|
561
|
+
}
|
562
|
+
|
563
|
+
$('#' + modalDialogId).modal('hide');
|
564
|
+
|
565
|
+
});
|
566
|
+
};
|
487
567
|
|
488
568
|
// opens modal dialog
|
489
569
|
var openModalDialog = function (modalDialogId) {
|
490
|
-
|
570
|
+
$('#' + modalDialogId).dialog("open");
|
491
571
|
};
|
492
572
|
|
493
573
|
// starting generate modial dialog
|
494
574
|
var generateModalDialog = function (textField) {
|
495
|
-
|
575
|
+
if (options.bootstrap) {
|
576
|
+
$(generateExpander()).appendTo('#' + container + ' > div.container-combo-auto-box-bootstrap');
|
577
|
+
generateBootstrapDialogModal(generateAnId('model-dialog'));
|
578
|
+
} else {
|
579
|
+
$(generateExpander()).prependTo('#' + container + ' > div.container-combo-auto-box');
|
580
|
+
adjustExpanderImage();
|
581
|
+
generateDivDialogModal(generateAnId('model-dialog'));
|
582
|
+
}
|
496
583
|
|
497
|
-
adjustExpanderImage();
|
498
|
-
|
499
|
-
generateDivDialogModal(generateAnId('model-dialog'));
|
500
584
|
};
|
501
585
|
|
502
586
|
// add multiple item
|
@@ -739,12 +823,20 @@ var ComboAutoBox = {
|
|
739
823
|
options.not_found_accepted = false;
|
740
824
|
}
|
741
825
|
|
826
|
+
if (options.bootstrap == null) {
|
827
|
+
options.bootstrap = false;
|
828
|
+
}
|
829
|
+
|
742
830
|
validLanguage();
|
743
831
|
validType();
|
744
832
|
|
745
833
|
$('#' + container).html(generateDivTag());
|
746
834
|
|
747
|
-
|
835
|
+
if (options.bootstrap) {
|
836
|
+
textField = $('#' + container + ' > div.container-combo-auto-box-bootstrap > input');
|
837
|
+
} else {
|
838
|
+
textField = $('#' + container + ' > div.container-combo-auto-box > input');
|
839
|
+
}
|
748
840
|
bindAutoComplete(textField.attr('id'));
|
749
841
|
|
750
842
|
if (options.type == 'simple') {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: combo_auto_box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.30
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|