summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadomir Dopieralski <openstack@sheep.art.pl>2015-03-27 13:19:15 +0100
committerRadomir Dopieralski <openstack@sheep.art.pl>2015-03-27 13:19:15 +0100
commitbd371d09fd1d7578356f10c1196c9030caf21efe (patch)
treeee15e23b13425165f1db72eeef14ca7257e9fc44
parentb0494942f6e4e7a4e179a4b137c791bfc11de06b (diff)
downloadtuskar-ui-bd371d09fd1d7578356f10c1196c9030caf21efe.tar.gz
Move performance box code into a js file.
Change-Id: I2597d813978487f47583da3f121a7faa5f285ce9
-rw-r--r--tuskar_ui/infrastructure/static/infrastructure/js/tuskar.performance.js25
-rw-r--r--tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html27
-rw-r--r--tuskar_ui/infrastructure/templates/infrastructure/_scripts.html1
3 files changed, 28 insertions, 25 deletions
diff --git a/tuskar_ui/infrastructure/static/infrastructure/js/tuskar.performance.js b/tuskar_ui/infrastructure/static/infrastructure/js/tuskar.performance.js
new file mode 100644
index 00000000..23658f10
--- /dev/null
+++ b/tuskar_ui/infrastructure/static/infrastructure/js/tuskar.performance.js
@@ -0,0 +1,25 @@
+tuskar.performance = (function () {
+ 'use strict';
+
+ var module = {};
+
+ module.show_hide_datepickers = function () {
+ var date_options = $("#date_options");
+ date_options.change(function(evt) {
+ if ($(this).find("option:selected").val() === "other"){
+ evt.stopPropagation();
+ $("#date_from, #date_to").val('');
+ $("#date_from_group, #date_to_group").show();
+ } else {
+ $("#date_from_group, #date_to_group").hide();
+ }
+ });
+ if (date_options.find("option:selected").val() === "other"){
+ $("#date_from_group, #date_to_group").show();
+ } else {
+ $("#date_from_group, #date_to_group").hide();
+ }
+ };
+
+ return module;
+} ());
diff --git a/tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html b/tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html
index 6c27e91e..1ad01607 100644
--- a/tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html
+++ b/tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html
@@ -52,31 +52,8 @@
</div>
<script type="text/javascript">
- if (typeof $ !== 'undefined') {
- show_hide_datepickers();
- } else {
- addHorizonLoadEvent(function() {
- show_hide_datepickers();
- });
- }
- // TODO(lsmola) Pull the common code into a js file.
- function show_hide_datepickers() {
- var date_options = $("#date_options");
- date_options.change(function(evt) {
- if ($(this).find("option:selected").val() === "other"){
- evt.stopPropagation();
- $("#date_from, #date_to").val('');
- $("#date_from_group, #date_to_group").show();
- } else {
- $("#date_from_group, #date_to_group").hide();
- }
- });
- if (date_options.find("option:selected").val() === "other"){
- $("#date_from_group, #date_to_group").show();
- } else {
- $("#date_from_group, #date_to_group").hide();
- }
- }
+ (window.$ || window.addHorizonLoadEvent)(
+ tuskar.performance.show_hide_datepickers);
</script>
<div id="node-charts" class="nodes row">
diff --git a/tuskar_ui/infrastructure/templates/infrastructure/_scripts.html b/tuskar_ui/infrastructure/templates/infrastructure/_scripts.html
index d1c9b77c..61d91811 100644
--- a/tuskar_ui/infrastructure/templates/infrastructure/_scripts.html
+++ b/tuskar_ui/infrastructure/templates/infrastructure/_scripts.html
@@ -9,6 +9,7 @@
<script src='{{ STATIC_URL }}infrastructure/js/tuskar.number_picker.js' type='text/javascript' charset='utf-8'></script>
<script src='{{ STATIC_URL }}infrastructure/js/tuskar.edit_plan.js' type='text/javascript' charset='utf-8'></script>
<script src='{{ STATIC_URL }}infrastructure/js/tuskar.deployment_progress.js' type='text/javascript' charset='utf-8'></script>
+ <script src='{{ STATIC_URL }}infrastructure/js/tuskar.performance.js' type='text/javascript' charset='utf-8'></script>
{% endblock %}
{% comment %} Tuskar-UI Client-side Templates (These should *not* be inside the "compress" tag.) {% endcomment %}