Move more javascript around.

This commit is contained in:
James Cole
2016-01-29 18:39:50 +01:00
parent d669b75352
commit 3a12ad192f
6 changed files with 74 additions and 52 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,47 @@
/*
* create-edit.js
* Copyright (C) 2016 Sander Dorigo
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/* globals what:true, $, doSwitch, txt, middleCrumbName, title,button, middleCrumbUrl, piggiesLength, breadcrumbs */
$(document).ready(function () {
"use strict";
if ($('input[name="expense_account"]').length > 0) {
$.getJSON('json/expense-accounts').success(function (data) {
$('input[name="expense_account"]').typeahead({source: data});
});
}
if ($('input[name="tags"]').length > 0) {
$.getJSON('json/tags').success(function (data) {
var opt = {
typeahead: {
source: data
}
};
$('input[name="tags"]').tagsinput(
opt
);
});
}
if ($('input[name="revenue_account"]').length > 0) {
$.getJSON('json/revenue-accounts').success(function (data) {
$('input[name="revenue_account"]').typeahead({source: data});
});
}
if ($('input[name="description"]').length > 0 && what !== undefined) {
$.getJSON('json/transaction-journals/' + what).success(function (data) {
$('input[name="description"]').typeahead({source: data});
});
}
if ($('input[name="category"]').length > 0) {
$.getJSON('json/categories').success(function (data) {
$('input[name="category"]').typeahead({source: data});
});
}
});

View File

@@ -1,44 +1,17 @@
/*
* create.js
* Copyright (C) 2016 Sander Dorigo
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/* globals what:true, $, doSwitch, txt, middleCrumbName, title,button, middleCrumbUrl, piggiesLength, breadcrumbs */ /* globals what:true, $, doSwitch, txt, middleCrumbName, title,button, middleCrumbUrl, piggiesLength, breadcrumbs */
$(document).ready(function () { $(document).ready(function () {
"use strict"; "use strict";
if ($('input[name="expense_account"]').length > 0) {
$.getJSON('json/expense-accounts').success(function (data) {
$('input[name="expense_account"]').typeahead({source: data});
});
}
if ($('input[name="tags"]').length > 0) { // respond to switch buttons when
$.getJSON('json/tags').success(function (data) { // creating stuff:
var opt = {
typeahead: {
source: data
}
};
$('input[name="tags"]').tagsinput(
opt
);
});
}
if ($('input[name="revenue_account"]').length > 0) {
$.getJSON('json/revenue-accounts').success(function (data) {
$('input[name="revenue_account"]').typeahead({source: data});
});
}
if ($('input[name="description"]').length > 0 && what !== undefined) {
$.getJSON('json/transaction-journals/' + what).success(function (data) {
$('input[name="description"]').typeahead({source: data});
});
}
if ($('input[name="category"]').length > 0) {
$.getJSON('json/categories').success(function (data) {
$('input[name="category"]').typeahead({source: data});
});
}
// respond to switch buttons:
if (doSwitch) { if (doSwitch) {
updateButtons(); updateButtons();
updateForm(); updateForm();

View File

@@ -0,0 +1,13 @@
/*
* edit.js
* Copyright (C) 2016 Sander Dorigo
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/* globals $ */
$(document).ready(function () {
"use strict";
// no special JS for edit transaction.
});

View File

@@ -126,7 +126,8 @@
</script> </script>
<script type="text/javascript" src="js/bootstrap3-typeahead.min.js"></script> <script type="text/javascript" src="js/bootstrap3-typeahead.min.js"></script>
<script type="text/javascript" src="js/bootstrap-tagsinput.min.js"></script> <script type="text/javascript" src="js/bootstrap-tagsinput.min.js"></script>
<script type="text/javascript" src="js/transactions.js"></script> <script type="text/javascript" src="js/transactions/create-edit.js"></script>
<script type="text/javascript" src="js/transactions/create.js"></script>
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}

View File

@@ -107,7 +107,8 @@
</script> </script>
<script type="text/javascript" src="js/bootstrap3-typeahead.min.js"></script> <script type="text/javascript" src="js/bootstrap3-typeahead.min.js"></script>
<script type="text/javascript" src="js/bootstrap-tagsinput.min.js"></script> <script type="text/javascript" src="js/bootstrap-tagsinput.min.js"></script>
<script type="text/javascript" src="js/transactions.js"></script> <script type="text/javascript" src="js/transactions/create-edit.js"></script>
<script type="text/javascript" src="js/transactions/edit.js"></script>
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link href="css/bootstrap-tagsinput.css" type="text/css" rel="stylesheet" media="all"> <link href="css/bootstrap-tagsinput.css" type="text/css" rel="stylesheet" media="all">