first commit
This commit is contained in:
73
public/js/app.js
vendored
Normal file
73
public/js/app.js
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
$(document).ready(function(e) {
|
||||
var authorOptions = {
|
||||
placeholder: 'Authors',
|
||||
tags: true,
|
||||
ajax: {
|
||||
url: '/authors/search',
|
||||
dataType: 'json'
|
||||
// Additional AJAX parameters go here; see the end of this chapter for the full code of this example
|
||||
}
|
||||
};
|
||||
|
||||
var locationOptions = {
|
||||
placeholder: 'Location',
|
||||
tags: true
|
||||
};
|
||||
|
||||
$('#add-form .select2-author').select2(authorOptions);
|
||||
|
||||
$('#add-form .select2-location').select2(locationOptions);
|
||||
|
||||
$('#add-form').on('keyup', '.barcode_input', function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
// Do something
|
||||
e.preventDefault();
|
||||
|
||||
var $row = $(this).closest('.form-row');
|
||||
|
||||
$.get('/lookup/' + $(this).val(), function(res) {
|
||||
$row.find('input[name*=name]').val(res.title);
|
||||
|
||||
var $authors = $row.find('.select2-author');
|
||||
|
||||
for (var i = 0; i < res.authors.length; i++) {
|
||||
$authors.append($('<option>', {value: res.authors[i], text: res.authors[i], selected: 'selected'}));
|
||||
}
|
||||
|
||||
$authors.trigger('change');
|
||||
}, 'json');
|
||||
|
||||
var count = emptyRowCount();
|
||||
|
||||
console.log('Empty rows:', count);
|
||||
|
||||
if (count < 1) {
|
||||
var $template = $('#add-template'),
|
||||
$clone = $template.clone();
|
||||
|
||||
$clone.find('input[type=text]').val('');
|
||||
|
||||
$clone.removeClass('invisible').addClass('form-row');
|
||||
|
||||
$row.parent().append($clone);
|
||||
|
||||
$clone.find('.barcode_input').focus();
|
||||
$clone.find('.select2-author').select2(authorOptions);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function emptyRowCount() {
|
||||
var $barcodes = $('#add-form .barcode_input');
|
||||
|
||||
var count = 0;
|
||||
|
||||
$barcodes.each(function() {
|
||||
if ($(this).val() == '') {
|
||||
count++;
|
||||
}
|
||||
});
|
||||
|
||||
return count;
|
||||
}
|
6287
public/js/bootstrap.bundle.js
vendored
Normal file
6287
public/js/bootstrap.bundle.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
public/js/bootstrap.bundle.js.map
Normal file
1
public/js/bootstrap.bundle.js.map
Normal file
File diff suppressed because one or more lines are too long
7
public/js/bootstrap.bundle.min.js
vendored
Normal file
7
public/js/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/js/bootstrap.bundle.min.js.map
Normal file
1
public/js/bootstrap.bundle.min.js.map
Normal file
File diff suppressed because one or more lines are too long
3850
public/js/bootstrap.js
vendored
Normal file
3850
public/js/bootstrap.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
public/js/bootstrap.js.map
Normal file
1
public/js/bootstrap.js.map
Normal file
File diff suppressed because one or more lines are too long
7
public/js/bootstrap.min.js
vendored
Normal file
7
public/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/js/bootstrap.min.js.map
Normal file
1
public/js/bootstrap.min.js.map
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user