This commit is contained in:
James Cole committed 2018-01-22 18:37:59 +01:00
1 parent bc4d801c12
commit 9a26d6d49f
9 files changed
+33 -34

No files matched your search

+1 -1
View File
@@ -32,7 +32,7 @@ $(document).ready(function () {
function setAutocompletes() {
$.getJSON('json/categories').done(function (data) {
$('input[name="category"]').typeahead({source: data});
$('input[name="category"]').typeahead({source: data, autoSelect: false});
});
$.getJSON('json/tags').done(function (data) {
+1 -1
View File
@@ -296,7 +296,7 @@ function updateTriggerInput(selectList) {
function createAutoComplete(input, URI) {
input.typeahead('destroy');
$.getJSON(URI).done(function (data) {
input.typeahead({source: data});
input.typeahead({source: data, autoSelect: false});
});
}
+6 -7
View File
@@ -24,17 +24,16 @@ $(document).ready(function () {
"use strict";
$.getJSON('json/categories').done(function (data) {
$('input[name="category"]').typeahead({source: data});
$('input[name="category"]').typeahead({source: data, autoSelect: false});
});
$.getJSON('json/tags').done(function (data) {
var opt = {
typeahead: {
source: data,
afterSelect: function () {
this.$element.val("");
}
}
source: data,
afterSelect: function () {
this.$element.val("");
},
autoSelect: false
};
$('input[name="tags"]').tagsinput(
opt
+3 -3
View File
@@ -26,18 +26,18 @@ $(document).ready(function () {
// destination account names:
if ($('input[name^="destination_account_name["]').length > 0) {
$.getJSON('json/expense-accounts').done(function (data) {
$('input[name^="destination_account_name["]').typeahead({source: data});
$('input[name^="destination_account_name["]').typeahead({source: data, autoSelect: false});
});
}
// source account name
if ($('input[name^="source_account_name["]').length > 0) {
$.getJSON('json/revenue-accounts').done(function (data) {
$('input[name^="source_account_name["]').typeahead({source: data});
$('input[name^="source_account_name["]').typeahead({source: data, autoSelect: false});
});
}
$.getJSON('json/categories').done(function (data) {
$('input[name^="category["]').typeahead({source: data});
$('input[name^="category["]').typeahead({source: data, autoSelect: false});
});
});
+8 -9
View File
@@ -47,12 +47,11 @@ function runModernizer() {
function setCommonAutocomplete() {
$.getJSON('json/tags').done(function (data) {
var opt = {
typeahead: {
source: data,
afterSelect: function () {
this.$element.val("");
}
}
source: data,
afterSelect: function () {
this.$element.val("");
},
autoSelect: false,
};
$('input[name="tags"]').tagsinput(
opt
@@ -61,18 +60,18 @@ function setCommonAutocomplete() {
if ($('input[name="destination_account_name"]').length > 0) {
$.getJSON('json/expense-accounts').done(function (data) {
$('input[name="destination_account_name"]').typeahead({source: data});
$('input[name="destination_account_name"]').typeahead({source: data, autoSelect: false});
});
}
if ($('input[name="source_account_name"]').length > 0) {
$.getJSON('json/revenue-accounts').done(function (data) {
$('input[name="source_account_name"]').typeahead({source: data});
$('input[name="source_account_name"]').typeahead({source: data, autoSelect: false});
});
}
$.getJSON('json/categories').done(function (data) {
$('input[name="category"]').typeahead({source: data});
$('input[name="category"]').typeahead({source: data, autoSelect: false});
});
}
+1 -1
View File
@@ -98,7 +98,7 @@ function updateNativeCurrency(useAccountCurrency) {
*/
function updateDescription() {
$.getJSON('json/transaction-journals/' + what).done(function (data) {
$('input[name="description"]').typeahead('destroy').typeahead({source: data});
$('input[name="description"]').typeahead('destroy').typeahead({source: data, autoSelect: false});
});
$('#ffInput_description').focus();
}
+1 -1
View File
@@ -94,7 +94,7 @@ function getAccountId() {
*/
function setAutocompletes() {
$.getJSON('json/transaction-journals/' + what).done(function (data) {
$('input[name="description"]').typeahead({source: data});
$('input[name="description"]').typeahead({source: data, autoSelect: false});
});
}
+11 -10
View File
@@ -33,23 +33,23 @@ $(document).ready(function () {
$.getJSON('json/expense-accounts').done(function (data) {
destAccounts = data;
$('input[name$="destination_account_name]"]').typeahead({source: destAccounts});
$('input[name$="destination_account_name]"]').typeahead({source: destAccounts, autoSelect: false});
});
$.getJSON('json/revenue-accounts').done(function (data) {
srcAccounts = data;
$('input[name$="source_account_name]"]').typeahead({source: srcAccounts});
$('input[name$="source_account_name]"]').typeahead({source: srcAccounts, autoSelect: false});
});
$.getJSON('json/categories').done(function (data) {
categories = data;
$('input[name$="category]"]').typeahead({source: categories});
$('input[name$="category]"]').typeahead({source: categories, autoSelect: false});
});
$.getJSON('json/transaction-journals/' + what).done(function (data) {
descriptions = data;
$('input[name="journal_description"]').typeahead({source: descriptions});
$('input[name$="description]"]').typeahead({source: descriptions});
$('input[name="journal_description"]').typeahead({source: descriptions, autoSelect: false});
$('input[name$="description]"]').typeahead({source: descriptions, autoSelect: false});
});
$.getJSON('json/tags').done(function (data) {
@@ -59,7 +59,8 @@ $(document).ready(function () {
source: data,
afterSelect: function () {
this.$element.val("");
}
},
autoSelect: false
}
};
$('input[name="tags"]').tagsinput(
@@ -114,17 +115,17 @@ function cloneDivRow() {
source.find('input[name$="][amount]"]').val("").on('input', calculateSum);
if (destAccounts.length > 0) {
source.find('input[name$="destination_account_name]"]').typeahead({source: destAccounts});
source.find('input[name$="destination_account_name]"]').typeahead({source: destAccounts, autoSelect: false});
}
if (destAccounts.length > 0) {
source.find('input[name$="source_account_name]"]').typeahead({source: srcAccounts});
source.find('input[name$="source_account_name]"]').typeahead({source: srcAccounts, autoSelect: false});
}
if (categories.length > 0) {
source.find('input[name$="category]"]').typeahead({source: categories});
source.find('input[name$="category]"]').typeahead({source: categories, autoSelect: false});
}
if (descriptions.length > 0) {
source.find('input[name$="description]"]').typeahead({source: descriptions});
source.find('input[name$="description]"]').typeahead({source: descriptions, autoSelect: false});
}
$('div.split_row_holder').append(source);
+1 -1
View File
@@ -1 +1 @@
!function(a,b){"use strict";"undefined"!=typeof module&&module.exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):b(a.jQuery)}(this,function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.defaults,d),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.select=this.options.select||this.select,this.autoSelect="boolean"!=typeof this.options.autoSelect||this.options.autoSelect,this.highlighter=this.options.highlighter||this.highlighter,this.render=this.options.render||this.render,this.updater=this.options.updater||this.updater,this.displayText=this.options.displayText||this.displayText,this.itemLink=this.options.itemLink||this.itemLink,this.followLinkOnSelect=this.options.followLinkOnSelect||this.followLinkOnSelect,this.source=this.options.source,this.delay=this.options.delay,this.$menu=a(this.options.menu),this.$appendTo=this.options.appendTo?a(this.options.appendTo):null,this.fitToElement="boolean"==typeof this.options.fitToElement&&this.options.fitToElement,this.shown=!1,this.listen(),this.showHintOnFocus=("boolean"==typeof this.options.showHintOnFocus||"all"===this.options.showHintOnFocus)&&this.options.showHintOnFocus,this.afterSelect=this.options.afterSelect,this.afterEmptySelect=this.options.afterEmptySelect,this.addItem=!1,this.value=this.$element.val()||this.$element.text(),this.keyPressed=!1,this.focused=this.$element.is(":focus")};b.prototype={constructor:b,setDefault:function(a){if(this.$element.data("active",a),this.autoSelect||a){var b=this.updater(a);b||(b=""),this.$element.val(this.displayText(b)||b).text(this.displayText(b)||b).change(),this.afterSelect(b)}return this.hide()},select:function(){var a=this.$menu.find(".active").data("value");if(this.$element.data("active",a),this.autoSelect||a){var b=this.updater(a);b||(b=""),this.$element.val(this.displayText(b)||b).text(this.displayText(b)||b).change(),this.afterSelect(b),this.followLinkOnSelect&&this.itemLink(a)?(document.location=this.itemLink(a),this.afterSelect(b)):this.followLinkOnSelect&&!this.itemLink(a)?this.afterEmptySelect(b):this.afterSelect(b)}else this.afterEmptySelect(b);return this.hide()},updater:function(a){return a},setSource:function(a){this.source=a},show:function(){var b,c=a.extend({},this.$element.position(),{height:this.$element[0].offsetHeight}),d="function"==typeof this.options.scrollHeight?this.options.scrollHeight.call():this.options.scrollHeight;if(this.shown?b=this.$menu:this.$appendTo?(b=this.$menu.appendTo(this.$appendTo),this.hasSameParent=this.$appendTo.is(this.$element.parent())):(b=this.$menu.insertAfter(this.$element),this.hasSameParent=!0),!this.hasSameParent){b.css("position","fixed");var e=this.$element.offset();c.top=e.top,c.left=e.left}var f=a(b).parent().hasClass("dropup"),g=f?"auto":c.top+c.height+d,h=a(b).hasClass("dropdown-menu-right"),i=h?"auto":c.left;return b.css({top:g,left:i}).show(),!0===this.options.fitToElement&&b.css("width",this.$element.outerWidth()+"px"),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(b){if(this.query=void 0!==b&&null!==b?b:this.$element.val(),this.query.length<this.options.minLength&&!this.options.showHintOnFocus)return this.shown?this.hide():this;var c=a.proxy(function(){a.isFunction(this.source)&&3===this.source.length?this.source(this.query,a.proxy(this.process,this),a.proxy(this.process,this)):a.isFunction(this.source)?this.source(this.query,a.proxy(this.process,this)):this.source&&this.process(this.source)},this);clearTimeout(this.lookupWorker),this.lookupWorker=setTimeout(c,this.delay)},process:function(b){var c=this;return b=a.grep(b,function(a){return c.matcher(a)}),b=this.sorter(b),b.length||this.options.addItem?(b.length>0?this.$element.data("active",b[0]):this.$element.data("active",null),"all"!=this.options.items&&(b=b.slice(0,this.options.items)),this.options.addItem&&b.push(this.options.addItem),this.render(b).show()):this.shown?this.hide():this},matcher:function(a){return~this.displayText(a).toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(a){for(var b,c=[],d=[],e=[];b=a.shift();){var f=this.displayText(b);f.toLowerCase().indexOf(this.query.toLowerCase())?~f.indexOf(this.query)?d.push(b):e.push(b):c.push(b)}return c.concat(d,e)},highlighter:function(a){var b=this.query;if(""===b)return a;var c,d=a.match(/(>)([^<]*)(<)/g),e=[],f=[];if(d&&d.length)for(c=0;c<d.length;++c)d[c].length>2&&e.push(d[c]);else e=[],e.push(a);b=b.replace(/[\(\)\/\.\*\+\?\[\]]/g,function(a){return"\\"+a});var g,h=new RegExp(b,"g");for(c=0;c<e.length;++c)(g=e[c].match(h))&&g.length>0&&f.push(e[c]);for(c=0;c<f.length;++c)a=a.replace(f[c],f[c].replace(h,"<strong>$&</strong>"));return a},render:function(b){var c=this,d=this,e=!1,f=[],g=c.options.separator;return a.each(b,function(a,c){a>0&&c[g]!==b[a-1][g]&&f.push({__type:"divider"}),!c[g]||0!==a&&c[g]===b[a-1][g]||f.pushLine truncated
!function(root,factory){"use strict";"undefined"!=typeof module&&module.exports?module.exports=factory(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],function($){return factory($)}):factory(root.jQuery)}(this,function($){"use strict";var Typeahead=function(element,options){this.$element=$(element),this.options=$.extend({},Typeahead.defaults,options),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.select=this.options.select||this.select,this.autoSelect="boolean"!=typeof this.options.autoSelect||this.options.autoSelect,this.highlighter=this.options.highlighter||this.highlighter,this.render=this.options.render||this.render,this.updater=this.options.updater||this.updater,this.displayText=this.options.displayText||this.displayText,this.itemLink=this.options.itemLink||this.itemLink,this.itemTitle=this.options.itemTitle||this.itemTitle,this.followLinkOnSelect=this.options.followLinkOnSelect||this.followLinkOnSelect,this.source=this.options.source,this.delay=this.options.delay,this.theme=this.options.theme&&this.options.themes&&this.options.themes[this.options.theme]||Typeahead.defaults.themes[Typeahead.defaults.theme],this.$menu=$(this.options.menu||this.theme.menu),this.$appendTo=this.options.appendTo?$(this.options.appendTo):null,this.fitToElement="boolean"==typeof this.options.fitToElement&&this.options.fitToElement,this.shown=!1,this.listen(),this.showHintOnFocus=("boolean"==typeof this.options.showHintOnFocus||"all"===this.options.showHintOnFocus)&&this.options.showHintOnFocus,this.afterSelect=this.options.afterSelect,this.afterEmptySelect=this.options.afterEmptySelect,this.addItem=!1,this.value=this.$element.val()||this.$element.text(),this.keyPressed=!1,this.focused=this.$element.is(":focus")};Typeahead.prototype={constructor:Typeahead,setDefault:function(val){if(this.$element.data("active",val),this.autoSelect||val){var newVal=this.updater(val);newVal||(newVal=""),this.$element.val(this.displayText(newVal)||newVal).text(this.displayText(newVal)||newVal).change(),this.afterSelect(newVal)}return this.hide()},select:function(){var val=this.$menu.find(".active").data("value");if(this.$element.data("active",val),this.autoSelect||val){var newVal=this.updater(val);newVal||(newVal=""),this.$element.val(this.displayText(newVal)||newVal).text(this.displayText(newVal)||newVal).change(),this.afterSelect(newVal),this.followLinkOnSelect&&this.itemLink(val)?(document.location=this.itemLink(val),this.afterSelect(newVal)):this.followLinkOnSelect&&!this.itemLink(val)?this.afterEmptySelect(newVal):this.afterSelect(newVal)}else this.afterEmptySelect(newVal);return this.hide()},updater:function(item){return item},setSource:function(source){this.source=source},show:function(){var element,pos=$.extend({},this.$element.position(),{height:this.$element[0].offsetHeight}),scrollHeight="function"==typeof this.options.scrollHeight?this.options.scrollHeight.call():this.options.scrollHeight;if(this.shown?element=this.$menu:this.$appendTo?(element=this.$menu.appendTo(this.$appendTo),this.hasSameParent=this.$appendTo.is(this.$element.parent())):(element=this.$menu.insertAfter(this.$element),this.hasSameParent=!0),!this.hasSameParent){element.css("position","fixed");var offset=this.$element.offset();pos.top=offset.top,pos.left=offset.left}var newTop=$(element).parent().hasClass("dropup")?"auto":pos.top+pos.height+scrollHeight,newLeft=$(element).hasClass("dropdown-menu-right")?"auto":pos.left;return element.css({top:newTop,left:newLeft}).show(),!0===this.options.fitToElement&&element.css("width",this.$element.outerWidth()+"px"),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(query){if(this.query=void 0!==query&&null!==query?query:this.$element.val(),this.query.length<this.options.minLength&&!this.options.showHintOnFocus)return this.shown?this.hide():this;var worker=$.proxy(function(){$.isFunction(this.source)&&3===this.source.length?this.source(this.query,$.proxy(this.process,this),$.proxy(this.process,this)):$.isFunction(this.source)?this.source(this.query,$.proxy(this.process,this)):this.source&&this.process(this.source)},this);clearTimeout(this.lookupWorker),this.lookupWorker=setTimeout(worker,this.delay)},process:function(items){var that=this;return items=$.grep(items,function(item){return that.matcher(item)}),(items=this.sorter(items)).length||this.options.addItem?(items.length>0?this.$element.data("active",items[0]):this.$element.data("active",null),"all"!=this.options.items&&(items=items.slice(0,this.options.items)),this.options.addItem&&items.push(this.options.addItem),this.render(items).show()):this.shown?this.hide():this},matcher:function(item){return~this.displayText(item).toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(items){for(var item,beginswith=[],caseSensitive=[],caseInsensitive=[];item=items.shift();){var it=this.displayText(item);it.toLowerCase().indexOf(this.query.toLowerCase()Line truncated