Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Use a JQuery modal dialog to allow for editing of exercises from view page

Roland Geider6871df3bb9d4
diff --git a/exercises/templates/edit_exercise.html b/exercises/templates/edit_exercise.html
index 9d255a667..e14c44f22 100644
--- a/exercises/templates/edit_exercise.html
+++ b/exercises/templates/edit_exercise.html
@@ -4,12 +4,9 @@
{% block header %}
<script src="{% static "js/tinymce/tiny_mce.js" %}"></script>
+<script src="{% static "js/workout-manager.js" %}"></script>
<script type="text/javascript">
-tinyMCE.init({
- // General options
- mode : "textareas",
- theme : "simple"
- });
+init_tinymce();
</script>
{% endblock %}
diff --git a/exercises/templates/view.html b/exercises/templates/view.html
index fc99df406..30298ef1e 100644
--- a/exercises/templates/view.html
+++ b/exercises/templates/view.html
@@ -2,6 +2,41 @@
{% load i18n %}
{% load staticfiles %}
+
+{% block header %}
+<script src="{% static "js/jquery-ui.js" %}"></script>
+<script src="{% static "js/tinymce/tiny_mce.js" %}"></script>
+<script src="{% static "js/workout-manager.js" %}"></script>
+
+<script>
+$(document).ready(function() {
+// Initialise a modal dialog
+ $("#ajax-info").dialog({
+ autoOpen: false,
+ width: 600,
+ modal: true,
+ });
+
+
+ // Load the edit dialog when a user wants to edit an exercise
+ $(".modal-dialog").click(function(e) {
+ e.preventDefault();
+ targetUrl = $(this).attr("href");
+
+ $("#ajax-info").load(targetUrl + " .ym-form", function() {
+
+ // Initialise the WYSIWYG editor
+ init_tinymce();
+ }
+ );
+ $("#ajax-info").dialog("open");
+
+
+ });
+});
+
+</script>
+{% endblock %}
<!--
Title
-->
@@ -67,6 +102,12 @@
</form>
+<div class="apple_overlay" id="overlay" title="Basic dialog">
+ <!-- the external content is loaded inside this tag -->
+ <div class="contentWrap"></div>
+</div>
+
+<div id="exposeMask"></div>
{% endblock %}
@@ -77,19 +118,20 @@
{% block sidebar %}
{% if perms.exercises %}
<h3>{% trans "Options" %}</h3>
-
<p>
- <a href="{% url exercises.views.exercise_edit exercise.id %}">
- <img src="{% static "images/icons/edit.svg" %}"
+ <a href="{% url exercises.views.exercise_edit exercise.id %}"
+ class="modal-dialog">
+ <img src="{% static 'images/icons/edit.svg' %}"
width="32"
height="32"
- alt="{% trans 'Edit' %}">
+ alt="{% trans 'Edit' %}"
+ >
{% trans "Edit" %}
</a>
</p>
<p>
<a href="{% url exercises.views.exercise_delete exercise.id %}">
- <img src="{% static "images/icons/trash.svg" %}"
+ <img src="{% static 'images/icons/trash.svg' %}"
width="32"
height="32"
alt="{% trans 'Delete' %}">
diff --git a/manager/static/js/workout-manager.js b/manager/static/js/workout-manager.js
index 3978befc6..af1c9e547 100644
--- a/manager/static/js/workout-manager.js
+++ b/manager/static/js/workout-manager.js
@@ -139,4 +139,16 @@ function setup_inplace_editing()
}
});
});
-}
\ No newline at end of file
+}
+
+
+/*
+ * Init calls for tinyMCE editor
+ */
+function init_tinymce () {
+ tinyMCE.init({
+ // General options
+ mode : "textareas",
+ theme : "simple"
+ });
+}
diff --git a/manager/templates/base.html b/manager/templates/base.html
index c1f8f87dc..04a99ab31 100644
--- a/manager/templates/base.html
+++ b/manager/templates/base.html
@@ -77,7 +77,7 @@
<div class="ym-wbox">
<section class="ym-grid linearize-level-1">
<article class="ym-g66 ym-gl content">
- <div class="ym-gbox-left ym-clearfix">
+ <div class="ym-gbox-left ym-clearfix" id="main-content">
{% block content %}{% endblock %}
</div>
</article>