Commit 466559b59a96f1e4c6ef54091fbcf05bc475ff2d
Committed by
Gabriela Navarro
1 parent
2e14336d
Exists in
master
and in
5 other branches
Execute complete_registration javascript only when needed
Showing
5 changed files
with
69 additions
and
53 deletions
Show diff stats
lib/software_communities_plugin.rb
| ... | ... | @@ -132,9 +132,9 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin |
| 132 | 132 | views/new-software.js |
| 133 | 133 | views/user-edit-profile.js |
| 134 | 134 | views/create-institution.js |
| 135 | + views/complete-registration.js | |
| 135 | 136 | initializer.js |
| 136 | 137 | app.js |
| 137 | - mpog-incomplete-registration.js | |
| 138 | 138 | mpog-search.js |
| 139 | 139 | software-catalog.js |
| 140 | 140 | mpog-software-block.js | ... | ... |
public/initializer.js
| ... | ... | @@ -3,11 +3,12 @@ var dependencies = [ |
| 3 | 3 | 'EditSoftware', |
| 4 | 4 | 'NewSoftware', |
| 5 | 5 | 'UserEditProfile', |
| 6 | - 'CreateInstitution' | |
| 6 | + 'CreateInstitution', | |
| 7 | + 'CompleteRegistration' | |
| 7 | 8 | ]; |
| 8 | 9 | |
| 9 | 10 | |
| 10 | -modulejs.define('Initializer', dependencies, function(cp, es, ns, uep, ci) { | |
| 11 | +modulejs.define('Initializer', dependencies, function(cp, es, ns, uep, ci, cr) { | |
| 11 | 12 | 'use strict'; |
| 12 | 13 | |
| 13 | 14 | |
| ... | ... | @@ -36,6 +37,11 @@ modulejs.define('Initializer', dependencies, function(cp, es, ns, uep, ci) { |
| 36 | 37 | if( ci.isCreateInstitution() ) { |
| 37 | 38 | ci.init(); |
| 38 | 39 | } |
| 40 | + | |
| 41 | + | |
| 42 | + if( cr.isCompleteRegistration() ) { | |
| 43 | + cr.init(); | |
| 44 | + } | |
| 39 | 45 | } |
| 40 | 46 | }; |
| 41 | 47 | }); | ... | ... |
public/mpog-incomplete-registration.js
| ... | ... | @@ -1,38 +0,0 @@ |
| 1 | -(function() { | |
| 2 | - var AJAX_URL = { | |
| 3 | - hide_registration_incomplete_percentage: | |
| 4 | - url_with_subdirectory("/plugin/software_communities/hide_registration_incomplete_percentage") | |
| 5 | - }; | |
| 6 | - | |
| 7 | - | |
| 8 | - function hide_incomplete_percentage(evt) { | |
| 9 | - evt.preventDefault(); | |
| 10 | - | |
| 11 | - jQuery.get(AJAX_URL.hide_registration_incomplete_percentage, {hide:true}, function(response){ | |
| 12 | - if( response == true ) | |
| 13 | - jQuery("#complete_registration").fadeOut(); | |
| 14 | - }); | |
| 15 | - } | |
| 16 | - | |
| 17 | - function show_complete_progressbar() { | |
| 18 | - var percentage = jQuery("#complete_registration_message span").html(); | |
| 19 | - var canvas_tag = document.getElementById("complete_registration_percentage"); | |
| 20 | - | |
| 21 | - if( canvas_tag != null ) { | |
| 22 | - var context = canvas_tag.getContext("2d"); | |
| 23 | - | |
| 24 | - percentage = canvas_tag.width*(percentage/100.0); | |
| 25 | - | |
| 26 | - context.beginPath(); | |
| 27 | - context.rect(0, 0, percentage, canvas_tag.height); | |
| 28 | - context.fillStyle = '#00FF00'; | |
| 29 | - context.fill(); | |
| 30 | - } | |
| 31 | - } | |
| 32 | - | |
| 33 | - jQuery(document).ready(function(){ | |
| 34 | - jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage); | |
| 35 | - | |
| 36 | - show_complete_progressbar(); | |
| 37 | - }); | |
| 38 | -})(); | |
| 39 | 0 | \ No newline at end of file |
| ... | ... | @@ -0,0 +1,60 @@ |
| 1 | +modulejs.define('CompleteRegistration', ['jquery', 'NoosferoRoot'], function($, NoosferoRoot) { | |
| 2 | + 'use strict'; | |
| 3 | + | |
| 4 | + | |
| 5 | + var AJAX_URL = { | |
| 6 | + hide_registration_incomplete_percentage: | |
| 7 | + NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/hide_registration_incomplete_percentage") | |
| 8 | + }; | |
| 9 | + | |
| 10 | + | |
| 11 | + function hide_incomplete_percentage(evt) { | |
| 12 | + evt.preventDefault(); | |
| 13 | + | |
| 14 | + jQuery.get(AJAX_URL.hide_registration_incomplete_percentage, {hide:true}, function(response){ | |
| 15 | + if( response === true ) { | |
| 16 | + jQuery("#complete_registration").fadeOut(); | |
| 17 | + } | |
| 18 | + }); | |
| 19 | + } | |
| 20 | + | |
| 21 | + | |
| 22 | + function show_complete_progressbar() { | |
| 23 | + var percentage = jQuery("#complete_registration_message span").html(); | |
| 24 | + var canvas_tag = document.getElementById("complete_registration_percentage"); | |
| 25 | + | |
| 26 | + if( canvas_tag !== null ) { | |
| 27 | + var context = canvas_tag.getContext("2d"); | |
| 28 | + | |
| 29 | + percentage = canvas_tag.width*(percentage/100.0); | |
| 30 | + | |
| 31 | + context.beginPath(); | |
| 32 | + context.rect(0, 0, percentage, canvas_tag.height); | |
| 33 | + context.fillStyle = '#00FF00'; | |
| 34 | + context.fill(); | |
| 35 | + } | |
| 36 | + } | |
| 37 | + | |
| 38 | + | |
| 39 | + function repositioning_bar_percentage() { | |
| 40 | + var complete_message = $("#complete_registration").remove(); | |
| 41 | + | |
| 42 | + $(".profile-info-options").before(complete_message); | |
| 43 | + } | |
| 44 | + | |
| 45 | + | |
| 46 | + return { | |
| 47 | + isCompleteRegistration: function() { | |
| 48 | + return $("#complete_registration").length === 1; | |
| 49 | + }, | |
| 50 | + | |
| 51 | + | |
| 52 | + init: function() { | |
| 53 | + repositioning_bar_percentage(); | |
| 54 | + | |
| 55 | + jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage); | |
| 56 | + | |
| 57 | + show_complete_progressbar(); | |
| 58 | + } | |
| 59 | + } | |
| 60 | +}); | |
| 0 | 61 | \ No newline at end of file | ... | ... |
views/incomplete_registration.html.erb
| ... | ... | @@ -9,15 +9,3 @@ |
| 9 | 9 | </div> |
| 10 | 10 | </div> |
| 11 | 11 | </div> |
| 12 | - | |
| 13 | -<script type="text/javascript"> | |
| 14 | - (function($){ | |
| 15 | - 'use strict'; | |
| 16 | - | |
| 17 | - $(document).ready(function(){ | |
| 18 | - var complete_message = $("#complete_registration").remove(); | |
| 19 | - | |
| 20 | - $(".profile-info-options").before(complete_message); | |
| 21 | - }); | |
| 22 | - })(jQuery); | |
| 23 | -</script> | |
| 24 | 12 | \ No newline at end of file | ... | ... |