dropdowns in top menu + changes in tutorial engine
authorJan Szejko <janek37@gmail.com>
Wed, 15 Mar 2017 17:06:11 +0000 (18:06 +0100)
committerJan Szejko <janek37@gmail.com>
Wed, 15 Mar 2017 17:06:11 +0000 (18:06 +0100)
redakcja/static/js/catalogue/catalogue.js
redakcja/templates/registration/head_login.html

index 2b5a942..cb96d11 100755 (executable)
@@ -61,8 +61,9 @@
         function tutreset() {
             if (start) $(start).popover('hide');
             start = null;
+            var all_tutorial = $('[data-toggle="tutorial"]');
 
-            tutorial = $.makeArray($('[data-toggle="tutorial"]').sort(
+            tutorial = $.makeArray(all_tutorial.sort(
                 function(a, b) {return $(a).attr('data-tutorial') < $(b).attr('data-tutorial') ? -1 : 1}
             ));
 
                 $.each(tutorial, function(i, e) {
                     var but = (i < tutorial.length - 1) ? '>>' : 'OK';
                     $(e).popover({
-                        title: 'Tutorial',
+                        title: '<a class="btn btn-default tutorial-off" href="#-" id="tutoff'+i+'" style="float:right; padding:0 8px 4px 8px; position:relative; top:-6px; right:-10px;">&times;</a>Tutorial',
                         trigger: 'focus',
-                        template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div><div><a class="btn btn-default tutorial-off" href="#-" id="tutoff'+i+'">&times;</a><a style="float:right" class="btn btn-default tutorial-next" href="#-" id="nt'+i+'">' + but + '</a></div></div>'
-                    }).on('shown.bs.popover', function () {
-                        if (!$(e).data('tut-yet')) {
-                            $("#tutoff"+i).on('click', tutoff);
-                            $("#nt"+i).on('click', tut);
-                            $(e).data('tut-yet', 'yes');
-                        }
+                        html: 'true',
+                        template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div><div><a style="float:right" class="btn btn-default tutorial-next" href="#-" id="nt'+i+'">' + but + '</a></div></div>'
                     });
-                    //$(start).on('hide.bs.popover', tut);
                 });
                 first_reset = false;
+            } else {
+                all_tutorial.popover('enable');
             }
         }
         
             return false;
         }
         function tutoff() {
+            $(this).popover('hide');
             if (start) $(start).popover('hide');
             start = null;
             sessionStorage.removeItem("tutorial");
+            $('[data-toggle="tutorial"]').popover('disable');
             return false;
         }
         function tut() {
-            if (start) $(start).popover('hide');
+            if (start) {
+                $(start).popover('hide').popover('disable');
+            }
             if (tutorial.length) {
                 start = tutorial.shift();
                 $(start).popover('show');
-                //~ if (!$(start).data('tut-yet')) {
-                    //~ $(".popover .tutorial-off").on('click', tutoff);
-                    //~ $(".popover .tutorial-next").on('click', tut);
-                    //~ $(start).data('tut-yet', 'yes');
-                //~ }
             }
             else {
                 start = null;
             return false;
         }
         $('#tutModal').on('hidden.bs.modal', tut);
-        
-        if (sessionStorage.getItem("tutorial") == "on" && $("#tuton").length == 0) {
+
+        var $tuton = $("#tuton");
+        if (sessionStorage.getItem("tutorial") == "on" && $tuton.length == 0) {
             tutreset();
             tut();
         }
-        $("#tuton").on('click', tuton);
-
-
+        $tuton.on('click', tuton);
+        $(document).on('click', '.tutorial-off', tutoff);
+        $(document).on('click', '.tutorial-next', tut);
     });
 })(jQuery);
 
index f743f40..3077af3 100644 (file)
 <li><a href="/platform/" style="color: white">{% trans "About" %}</a></li>
 <li><a href="/appyourschool/" style="color: white">{% trans "App Your School" %}</a></li>
 {#<li><a href="/competition/" style="color: white">{% trans "Competition" %}</a></li>#}
-<li><a href="{% url 'organizations_new' %}" style="color: white"
-    {% if request.path == '/' %}
+<li class="dropdown" {% if request.path == '/' %}
     data-toggle="tutorial" data-tutorial="1" data-placement="bottom"
-    data-content='{% trans "Create an organization here. Organizations help manage team's work." %}'
-    {% endif %}
->{% trans "New organization" %}</a></li>
-<li><a href="{% url 'catalogue_create_missing' %}" style="color: white"
-    {% if request.path == '/' %}
+    data-content='{% trans "Organizations help manage team’s work. You can create a new organization and view all organizations." %}'
+    {% endif %}>
+    <a href="#" class="dropdown-toggle" type="button" data-toggle="dropdown" style="color: white">
+        {% trans "Organizations" %}
+        <span class="caret"></span>
+    </a>
+    <ul class="dropdown-menu">
+        <li><a href="{% url 'organizations_new' %}">{% trans "New organization" %}</a></li>
+        <li><a href="{% url 'organizations' %}">{% trans "All organizations" %}</a></li>
+    </ul>
+</li>
+<li class="dropdown" {% if request.path == '/' %}
     data-toggle="tutorial" data-tutorial="2" data-placement="bottom"
-    data-content="{% trans 'Start editing a new resource.' %}"
-    {% endif %}
->{% trans "New resource" %}</a></li>
+    data-content='{% trans "Here you can start editing a new resource or view your resources and all published resources." %}'
+    {% endif %}>
+    <a href="#" class="dropdown-toggle" type="button" data-toggle="dropdown" style="color: white">
+        {% trans "Resources" %}
+        <span class="caret"></span>
+    </a>
+    <ul class="dropdown-menu">
+        <li><a href="{% url 'catalogue_create_missing' %}">{% trans "New resource" %}</a></li>
+        {% if user.is_authenticated %}
+            <li><a href="{% url 'catalogue_user' %}">{% trans "My resources" %}</a></li>
+        {% endif %}
+        <li><a href="{% url 'catalogue_finished' %}">{% trans "Finished resources" %}</a></li>
+    </ul>
+</li>
+
 
 {% if user.is_authenticated %}
-<li><a href="{% url 'catalogue_user' %}" style="color: white">{% trans "My resources" %}</a></li>
 
     <li class="dropdown">
         <style>
@@ -51,7 +68,6 @@
             {% else %}
             <li role="presentation" class="dropdown-header">{% trans "You are not a member of any organizations" %}</li>
             {% endif %}
-            <li><a href="{% url 'organizations_new' %}">{% trans "New organization" %}</a></li>
             <li role="presentation" class="divider"></li>
             <li><a href="{% url 'organizations_user_edit' %}">{% trans "Edit my data" %}</a></li>
             {% if user.is_staff %}