Commit b537c7ff8764e39572de1e698dcb429e75f2f81e
1 parent
669145d6
Exists in
master
and in
2 other branches
Fix dropdown menu and use jQuery for compatibility
Showing
1 changed file
with
50 additions
and
37 deletions
Show diff stats
src/colab-spb-theme-plugin/colab_spb_theme/templates/accounts/user_update_form.html
... | ... | @@ -8,20 +8,33 @@ |
8 | 8 | {{ block.super }} |
9 | 9 | {% endblock %} |
10 | 10 | |
11 | +{% block bootstrap_js %} | |
12 | + <script>jQuery.noConflict();</script> | |
13 | + {% if not bootstrap_conflict %} | |
14 | + {{block.super}} | |
15 | + {% endif %} | |
16 | +{% endblock%} | |
17 | + | |
18 | +{% block jquery_js %} | |
19 | + {% if not jquery_conflict %} | |
20 | + {{block.super}} | |
21 | + {% endif %} | |
22 | +{% endblock %} | |
23 | + | |
11 | 24 | {% block head_js %} |
12 | 25 | {% for widget in widgets_profile %} |
13 | 26 | {{widget.get_header}} |
14 | 27 | {% endfor %} |
15 | 28 | <script> |
16 | -$(function() { | |
29 | +jQuery(function() { | |
17 | 30 | |
18 | - $('#add-email').on('click', function(event) { | |
19 | - $.ajax({ | |
31 | + jQuery('#add-email').on('click', function(event) { | |
32 | + jQuery.ajax({ | |
20 | 33 | url: "{% url 'archive_email_view' %}", |
21 | 34 | type: 'post', |
22 | - data: { email: $('#new_email').val(), user: '{{ user_.pk }}' }, | |
35 | + data: { email: jQuery('#new_email').val(), user: '{{ user_.pk }}' }, | |
23 | 36 | beforeSend: function(xhr, settings) { |
24 | - xhr.setRequestHeader("X-CSRFToken", $.cookie('csrftoken')); | |
37 | + xhr.setRequestHeader("X-CSRFToken", jQuery.cookie('csrftoken')); | |
25 | 38 | } |
26 | 39 | }).done(function() { |
27 | 40 | location.reload(); |
... | ... | @@ -30,71 +43,71 @@ $(function() { |
30 | 43 | event.preventDefault(); |
31 | 44 | }); |
32 | 45 | |
33 | - $('#new_email').on('keypress', function(event) { | |
46 | + jQuery('#new_email').on('keypress', function(event) { | |
34 | 47 | if (event.which == 13) { |
35 | 48 | event.preventDefault(); |
36 | - $('#add-email').trigger('click'); | |
49 | + jQuery('#add-email').trigger('click'); | |
37 | 50 | } |
38 | 51 | }); |
39 | 52 | |
40 | - $('.delete-email').on('click', function(event) { | |
41 | - var $email_block = $(event.target).parent().parent(); | |
42 | - $.ajax({ | |
53 | + jQuery('.delete-email').on('click', function(event) { | |
54 | + var $email_block = jQuery(event.target).parent().parent(); | |
55 | + jQuery.ajax({ | |
43 | 56 | url: "{% url 'archive_email_view' %}", |
44 | 57 | type: 'delete', |
45 | 58 | data: { |
46 | - email: $('.email-address', $email_block).text(), | |
59 | + email: jQuery('.email-address', $email_block).text(), | |
47 | 60 | user: '{{ user_.pk }}' |
48 | 61 | }, |
49 | 62 | context: $email_block[0], |
50 | 63 | beforeSend: function(xhr, settings) { |
51 | - xhr.setRequestHeader("X-CSRFToken", $.cookie('csrftoken')); | |
64 | + xhr.setRequestHeader("X-CSRFToken", jQuery.cookie('csrftoken')); | |
52 | 65 | } |
53 | 66 | }).done(function() { |
54 | - $(this).remove(); | |
67 | + jQuery(this).remove(); | |
55 | 68 | }); |
56 | 69 | |
57 | 70 | event.preventDefault(); |
58 | 71 | }); |
59 | 72 | |
60 | - $('.verify-email').on('click', function(event) { | |
61 | - var $email_block = $(event.target).parent().parent(); | |
62 | - $.ajax({ | |
73 | + jQuery('.verify-email').on('click', function(event) { | |
74 | + var $email_block = jQuery(event.target).parent().parent(); | |
75 | + jQuery.ajax({ | |
63 | 76 | url: "{% url 'archive_email_validation_view' %}", |
64 | 77 | type: 'post', |
65 | 78 | data: { |
66 | - email: $('.email-address', $email_block).text(), | |
79 | + email: jQuery('.email-address', $email_block).text(), | |
67 | 80 | user: '{{ user_.pk }}' |
68 | 81 | }, |
69 | 82 | context: $email_block[0], |
70 | 83 | beforeSend: function(xhr, settings) { |
71 | - xhr.setRequestHeader("X-CSRFToken", $.cookie('csrftoken')); | |
84 | + xhr.setRequestHeader("X-CSRFToken", jQuery.cookie('csrftoken')); | |
72 | 85 | } |
73 | 86 | }).done(function() { |
74 | - var email = $('.email-address', $(this)).text(); | |
87 | + var email = jQuery('.email-address', jQuery(this)).text(); | |
75 | 88 | var msg = '{% trans "We sent a verification email to " %}' + email + '. ' + |
76 | 89 | '{% trans "Please follow the instructions in it." %}'; |
77 | - $('#alert-message').text(msg); | |
78 | - $('#alert-js').removeClass('alert-warning').addClass('alert-success'); | |
79 | - $('#alert-js').show(); | |
90 | + jQuery('#alert-message').text(msg); | |
91 | + jQuery('#alert-js').removeClass('alert-warning').addClass('alert-success'); | |
92 | + jQuery('#alert-js').show(); | |
80 | 93 | window.scroll(0, 0); |
81 | - $('.verify-email').button('reset'); | |
94 | + jQuery('.verify-email').button('reset'); | |
82 | 95 | }); |
83 | 96 | |
84 | 97 | event.preventDefault(); |
85 | 98 | }); |
86 | 99 | |
87 | - $('.set-primary').on('click', function(event) { | |
88 | - var $email_block = $(event.target).parent().parent(); | |
89 | - $.ajax({ | |
100 | + jQuery('.set-primary').on('click', function(event) { | |
101 | + var $email_block = jQuery(event.target).parent().parent(); | |
102 | + jQuery.ajax({ | |
90 | 103 | url: "{% url 'archive_email_view' %}", |
91 | 104 | type: 'update', |
92 | 105 | data: { |
93 | - email: $('.email-address', $email_block).text(), | |
106 | + email: jQuery('.email-address', $email_block).text(), | |
94 | 107 | user: '{{ user_.pk }}' |
95 | 108 | }, |
96 | 109 | beforeSend: function(xhr, settings) { |
97 | - xhr.setRequestHeader("X-CSRFToken", $.cookie('csrftoken')); | |
110 | + xhr.setRequestHeader("X-CSRFToken", jQuery.cookie('csrftoken')); | |
98 | 111 | } |
99 | 112 | }).done(function() { |
100 | 113 | location.reload(); |
... | ... | @@ -104,20 +117,20 @@ $(function() { |
104 | 117 | }); |
105 | 118 | |
106 | 119 | // User feedbacks |
107 | - $('.panel-default').on('click', '.set-primary, .verify-email, .delete-email', function() { | |
108 | - $(this).button('loading'); | |
120 | + jQuery('.panel-default').on('click', '.set-primary, .verify-email, .delete-email', function() { | |
121 | + jQuery(this).button('loading'); | |
109 | 122 | }); |
110 | 123 | |
111 | 124 | // Active profile bars |
112 | 125 | active = function (identifier){ |
113 | - $('#navbar li').each(function(index,value){ | |
114 | - $(this).removeClass('active'); | |
126 | + jQuery('#navbar li').each(function(index,value){ | |
127 | + jQuery(this).removeClass('active'); | |
115 | 128 | }) |
116 | - $(identifier).addClass('active'); | |
117 | - $('#profile_content .profile_item').each(function(index,value){ | |
118 | - $(this).addClass('hidden'); | |
129 | + jQuery(identifier).addClass('active'); | |
130 | + jQuery('#profile_content .profile_item').each(function(index,value){ | |
131 | + jQuery(this).addClass('hidden'); | |
119 | 132 | }) |
120 | - $(identifier+'-content').removeClass('hidden'); | |
133 | + jQuery(identifier+'-content').removeClass('hidden'); | |
121 | 134 | } |
122 | 135 | if (location.hash != '') active(location.hash) |
123 | 136 | }); |
... | ... | @@ -223,7 +236,7 @@ $(function() { |
223 | 236 | </div> |
224 | 237 | </div> |
225 | 238 | </div> |
226 | - <div id="password_container" class="col-lg-4 col-md-5 col-sm-12 col-xm-12"> | |
239 | + <div id="password_container" class="col-lg-4 col-md-5 col-sm-12 col-xm-12"> | |
227 | 240 | <div class="panel panel-default"> |
228 | 241 | <div class="panel-heading"> |
229 | 242 | <h3 class="panel-title"> | ... | ... |