summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--static/js/add.js6
-rw-r--r--static/js/cats.js39
-rw-r--r--static/js/kosten.js81
-rw-r--r--static/js/kosten.ls26
-rw-r--r--static/js/lib.js6
-rw-r--r--static/js/show.js17
-rw-r--r--templates/categories/manage.jinja5
-rw-r--r--templates/expenses/add.jinja3
-rw-r--r--templates/expenses/show.jinja7
-rw-r--r--templates/layout.jinja3
10 files changed, 101 insertions, 92 deletions
diff --git a/static/js/add.js b/static/js/add.js
deleted file mode 100644
index 76c1f4a..0000000
--- a/static/js/add.js
+++ /dev/null
@@ -1,6 +0,0 @@
-$(document).ready(function(){
- $("input[name=date]").datepicker({
- dateFormat: 'dd.mm.yy',
- firstDay: 1
- });
-})
diff --git a/static/js/cats.js b/static/js/cats.js
deleted file mode 100644
index e65cc28..0000000
--- a/static/js/cats.js
+++ /dev/null
@@ -1,39 +0,0 @@
-var counter = 0;
-
-$(document).ready(function(){
- $("li > span").click(function(){
- var span = $(this);
- var img = $("img#add").copy().attr('src', function() { return this.src.replace("add", "undo"); });
-
- img.click(function(){
- var input = $(this).prev();
-
- $(this).remove();
- input.fadeOut("slow",
- function() {
- span.toggle();
- });
-
- input.val(span.text());
- });
-
- span.toggle();
- $(this).next().fadeIn("slow", function() {$(this).after(img); });
- });
-
- $("img#add").click(function(){
- var input = $("input#new").copy();
- var img = $(this).copy().attr('src', function() { return this.src.replace("add", "minus"); });
- img.click(function() { $(this).parent().fadeOut("slow", function() { $(this).remove(); }) });
-
- input.attr('name', function() { return this.name + counter; })
- .removeAttr('style')
- .insertBefore($(this).parent())
- .wrap("<li />");
-
- input.parent().append(img)
- .hide().fadeIn("slow", function (){ input.focus(); });
-
- counter = counter + 1;
- });
-})
diff --git a/static/js/kosten.js b/static/js/kosten.js
new file mode 100644
index 0000000..c1df1ca
--- /dev/null
+++ b/static/js/kosten.js
@@ -0,0 +1,81 @@
+// Generated by LiveScript 1.2.0
+(function(){
+ var jq, addJS, showJS, catsJS, out$ = typeof exports != 'undefined' && exports || this;
+ jQuery.fn.extend({
+ copy: function(){
+ return this.clone().removeAttr('id class');
+ }
+ });
+ jq = function(f){
+ return function(){
+ $(f);
+ };
+ };
+ out$.addJS = addJS = jq(function(){
+ return $('input[name=date]').datepicker({
+ dateFormat: 'dd.mm.yy',
+ firstDay: 1
+ });
+ });
+ out$.showJS = showJS = jq(function(){
+ $(".detail span").click(function(){
+ return $(this).prevAll('.mark:last').click();
+ });
+ $(".detail > .mark").click(function(){
+ if (this.src.indexOf('closed') !== -1) {
+ this.src = this.src.replace('closed', 'open');
+ } else {
+ this.src = this.src.replace('open', 'closed');
+ }
+ return $(this).nextAll('.details:first').toggle();
+ });
+ return $('.details').hide();
+ });
+ out$.catsJS = catsJS = jq(function(){
+ var counter, add_img, new_input, new_image;
+ counter = 0;
+ add_img = $('img#add');
+ new_input = $('input#new');
+ new_image = function(new_name){
+ var x$;
+ x$ = add_img.copy();
+ x$.attr('src', function(){
+ return this.src.replace('add', new_name);
+ });
+ return x$;
+ };
+ $("li > span").click(function(){
+ var span, input, x$, img;
+ span = $(this);
+ input = span.next();
+ x$ = img = new_image('undo');
+ x$.click(function(){
+ $(this).remove();
+ input.val(span.text());
+ return input.fadeOut('slow', function(){
+ return span.toggle();
+ });
+ });
+ span.toggle();
+ return input.fadeIn('slow', function(){
+ return img.insertAfter(input);
+ });
+ });
+ return add_img.click(function(){
+ var input, x$, img;
+ input = new_input.copy();
+ x$ = img = new_image('minus');
+ x$.click(function(){
+ return $(this).parent().fadeOut('slow', function(){
+ return $(this).remove();
+ });
+ });
+ input.attr('name', function(){
+ return this.name + counter;
+ }).removeAttr('style').wrap("<li />").parent().append(img).hide().insertBefore(add_img.parent()).fadeIn('slow', function(){
+ return input.focus();
+ });
+ return counter++;
+ });
+ });
+}).call(this);
diff --git a/static/js/kosten.ls b/static/js/kosten.ls
index 443210a..8bf746d 100644
--- a/static/js/kosten.ls
+++ b/static/js/kosten.ls
@@ -1,7 +1,7 @@
jQuery.fn.extend do
copy : -> @clone!remove-attr 'id class'
-jq = (f) -> $ !-> f
+jq = (f) -> !-> $ f
# Add
export addJS = jq ->
@@ -27,26 +27,26 @@ export showJS = jq ->
# Categories
export catsJS = jq ->
counter = 0
- add_img = $ \image#add
+ add_img = $ \img#add
new_input = $ \input#new
new_image = (new_name) ->
# we need to copy the image to get the correct URL
add_img.copy!
- .. .attr \src -> @src.replace \add new_name
+ ..attr \src -> @src.replace \add new_name
$ "li > span" .click ->
span = $ @
input = span.next!
img = new_image \undo
- .. .click ->
- $ @ .remove!
+ ..click ->
+ $ @ .remove!
- # reset text
- input.val span.text!
+ # reset text
+ input.val span.text!
- <- input.fade-out \slow
- span.toggle!
+ <- input.fade-out \slow
+ span.toggle!
span.toggle!
<- input.fade-in \slow
@@ -55,9 +55,9 @@ export catsJS = jq ->
add_img.click ->
input = new_input.copy!
img = new_image \minus
- .. .click ->
- <- $ @ .parent!fade-out \slow
- $ @ .remove!
+ ..click ->
+ <- $ @ .parent!fade-out \slow
+ $ @ .remove!
input.attr \name -> @name + counter
.remove-attr \style
@@ -66,6 +66,6 @@ export catsJS = jq ->
.append img
.hide!
.insert-before add_img.parent!
- .fade-in \slow input.focus
+ .fade-in \slow -> input.focus!
counter++
diff --git a/static/js/lib.js b/static/js/lib.js
deleted file mode 100644
index 43b0dc8..0000000
--- a/static/js/lib.js
+++ /dev/null
@@ -1,6 +0,0 @@
-jQuery.fn.extend({
- // copies an object and removes 'id' and 'class' values
- copy: function() {
- return this.clone().removeAttr("id").removeAttr("class");
- }
-});
diff --git a/static/js/show.js b/static/js/show.js
deleted file mode 100644
index 04b9a83..0000000
--- a/static/js/show.js
+++ /dev/null
@@ -1,17 +0,0 @@
-$(document).ready(function(){
-
- $(".detail span").click(function() {
- $(this).prevAll(".mark:last").click();
- });
-
- $(".detail > .mark").click(function() {
- if (this.src.indexOf("closed") != -1)
- this.src = this.src.replace("closed", "open");
- else
- this.src = this.src.replace("open", "closed");
-
- $(this).nextAll(".details:first").toggle();
- })
-
- $(".details").hide();
-})
diff --git a/templates/categories/manage.jinja b/templates/categories/manage.jinja
index efa91b6..7125c53 100644
--- a/templates/categories/manage.jinja
+++ b/templates/categories/manage.jinja
@@ -2,10 +2,7 @@
{% block heading %} Kategorien {% endblock %}
-{% block js %}
- {{ super() }}
- <script type="text/javascript" src="{{ "js/cats.js" | static_url }}"></script>
-{% endblock %}
+{% set JSFunction = "catsJS" %}
{% block content %}
<form name="categories" method="post">
diff --git a/templates/expenses/add.jinja b/templates/expenses/add.jinja
index 388341a..d63f844 100644
--- a/templates/expenses/add.jinja
+++ b/templates/expenses/add.jinja
@@ -5,10 +5,11 @@
Neue Ausgabe hinzufügen
{% endblock %}
+{% set JSFunction = "addJS" %}
+
{% block js %}
{{ super() }}
<script type="text/javascript" src="{{ "jqueryui/jquery-ui.js" | static_url }}"></script>
- <script type="text/javascript" src="{{ "js/add.js" | static_url }}"></script>
{% endblock %}
{% block style %}
diff --git a/templates/expenses/show.jinja b/templates/expenses/show.jinja
index a3b9422..8052757 100644
--- a/templates/expenses/show.jinja
+++ b/templates/expenses/show.jinja
@@ -1,6 +1,8 @@
{% extends "layout.jinja" %}
{% from "macros.jinja" import left_arrow, right_arrow, colorize %}
+{% set JSFunction = "showJS" %}
+
{% block heading %}
{% if exps | length > 1 %}
Aktuelle Kosten
@@ -9,11 +11,6 @@
{% endif %}
{% endblock %}
-{% block js %}
- {{ super() }}
- <script type="text/javascript" src="{{ "js/show.js" | static_url }}"></script>
-{% endblock %}
-
{% block content %}
{% for e in exps %}
{% if exps | length > 1 %}<h2>{{e|date}}</h2>{% endif %}
diff --git a/templates/layout.jinja b/templates/layout.jinja
index 85df3a4..ee082f9 100644
--- a/templates/layout.jinja
+++ b/templates/layout.jinja
@@ -5,7 +5,8 @@
{% if not g.is_mobile %}
{% block js %}
<script type="text/javascript" src="{{ "js/jquery-1.10.2.js" | static_url }}"></script>
- <script type="text/javascript" src="{{ "js/lib.js" | static_url }}"></script>
+ <script type="text/javascript" src="{{ "js/kosten.js" | static_url }}"></script>
+ {% if JSFunction %}<script type="text/javascript">{{ JSFunction }}()</script> {% endif %}
{% endblock %}
{% endif %}
<link rel="shortcut icon" href="{{ "images/currency.png" | static_url }}" type="image/icon">