Commit 05fc8a5c58579bfb4f27939c5a24b95bc08c3ff2
Committed by
Gabriela Navarro
1 parent
ecbff9f5
Exists in
master
and in
79 other branches
Create an initializer and load ControlPanel
Showing
9 changed files
with
126 additions
and
82 deletions
Show diff stats
lib/software_communities_plugin.rb
| @@ -122,8 +122,11 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -122,8 +122,11 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
| 122 | %w( | 122 | %w( |
| 123 | vendor/jquery.maskedinput.min.js | 123 | vendor/jquery.maskedinput.min.js |
| 124 | vendor/modulejs-1.5.0.min.js | 124 | vendor/modulejs-1.5.0.min.js |
| 125 | - spb-utils.js | ||
| 126 | - mpog-software.js | 125 | + vendor/jquery.js |
| 126 | + lib/noosfero-root.js | ||
| 127 | + lib/select-element.js | ||
| 128 | + views/control-panel.js | ||
| 129 | + initializer.js | ||
| 127 | mpog-software-validations.js | 130 | mpog-software-validations.js |
| 128 | mpog-user-validations.js | 131 | mpog-user-validations.js |
| 129 | mpog-institution-validations.js | 132 | mpog-institution-validations.js |
| @@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
| 1 | +var dependencies = [ | ||
| 2 | + 'ControlPanel' | ||
| 3 | +]; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +modulejs.define('Initializer', dependencies, function(cp) { | ||
| 7 | + if( cp.isControlPanel() ) { | ||
| 8 | + cp.init(); | ||
| 9 | + } | ||
| 10 | +}); | ||
| 11 | + | ||
| 12 | + | ||
| 13 | +(function() { | ||
| 14 | + 'use strict'; | ||
| 15 | + | ||
| 16 | + var $ = modulejs.require('jquery'); | ||
| 17 | + Initializer = modulejs.require('Initializer'); | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + $(document).ready(function() { | ||
| 21 | + Initializer(); | ||
| 22 | + }); | ||
| 23 | +})(); | ||
| 0 | \ No newline at end of file | 24 | \ No newline at end of file |
| @@ -0,0 +1,32 @@ | @@ -0,0 +1,32 @@ | ||
| 1 | +modulejs.define('SelectElement', function() { | ||
| 2 | + function SelectElement(name, id) { | ||
| 3 | + this.select = document.createElement("select"); | ||
| 4 | + } | ||
| 5 | + | ||
| 6 | + | ||
| 7 | + SelectElement.prototype.setAttr = function(attr, value) { | ||
| 8 | + return this.select.setAttribute(attr, value); | ||
| 9 | + }; | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + SelectElement.prototype.addOption = function(option) { | ||
| 13 | + return this.select.add(option); | ||
| 14 | + }; | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + SelectElement.prototype.getSelect = function() { | ||
| 18 | + return this.select; | ||
| 19 | + }; | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + SelectElement.generateOption = function(value, text) { | ||
| 23 | + var option; | ||
| 24 | + option = document.createElement("option"); | ||
| 25 | + option.setAttribute("value", value); | ||
| 26 | + option.text = text; | ||
| 27 | + return option; | ||
| 28 | + }; | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + return SelectElement; | ||
| 32 | +}); |
public/mpog-software.js
| @@ -1,42 +0,0 @@ | @@ -1,42 +0,0 @@ | ||
| 1 | -(function(){ | ||
| 2 | - function hide_infos(){ | ||
| 3 | - jQuery(".language-info").hide(); | ||
| 4 | - jQuery(".database-info").hide(); | ||
| 5 | - jQuery(".libraries-info").hide(); | ||
| 6 | - jQuery(".operating-system-info").hide(); | ||
| 7 | - jQuery(".language-button-hide").hide(); | ||
| 8 | - jQuery(".database-button-hide").hide(); | ||
| 9 | - jQuery(".libraries-button-hide").hide(); | ||
| 10 | - jQuery(".operating-system-button-hide").hide(); | ||
| 11 | - } | ||
| 12 | - | ||
| 13 | - function add_software_on_control_panel(control_panel) { | ||
| 14 | - var software_link = jQuery(".control-panel-software-link").remove(); | ||
| 15 | - | ||
| 16 | - if( software_link.size() > 0 ) { | ||
| 17 | - control_panel.prepend(software_link); | ||
| 18 | - } | ||
| 19 | - } | ||
| 20 | - | ||
| 21 | - function add_institution_on_control_panel(control_panel) { | ||
| 22 | - var institution_link = jQuery(".control-panel-instituton-link").remove(); | ||
| 23 | - | ||
| 24 | - if( institution_link.size() > 0 ) { | ||
| 25 | - control_panel.prepend(institution_link); | ||
| 26 | - } | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | - function add_itens_on_controla_panel() { | ||
| 30 | - var control_panel = jQuery(".control-panel"); | ||
| 31 | - | ||
| 32 | - if( control_panel.size() > 0 ) { | ||
| 33 | - add_software_on_control_panel(control_panel); | ||
| 34 | - add_institution_on_control_panel(control_panel); | ||
| 35 | - } | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - jQuery(document).ready(function(){ | ||
| 39 | - add_itens_on_controla_panel(); | ||
| 40 | - hide_infos(); | ||
| 41 | - }); | ||
| 42 | -})(); | ||
| 43 | \ No newline at end of file | 0 | \ No newline at end of file |
public/software-catalog.js
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | function show_head_message() { | 10 | function show_head_message() { |
| 11 | - if ($("#filter-categories-select-catalog").text().blank()){ | 11 | + if ($("#filter-categories-select-catalog").text()){ |
| 12 | $("#filter-categories-select-catalog").hide(); | 12 | $("#filter-categories-select-catalog").hide(); |
| 13 | $("#filter-option-catalog-software").show(); | 13 | $("#filter-option-catalog-software").show(); |
| 14 | }else{ | 14 | }else{ |
public/spb-utils.js
| @@ -1,37 +0,0 @@ | @@ -1,37 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | -* "Class" for select and option html generation | ||
| 3 | -*/ | ||
| 4 | -var SelectElement = (function() { | ||
| 5 | - function SelectElement(name, id) { | ||
| 6 | - this.select = document.createElement("select"); | ||
| 7 | - } | ||
| 8 | - | ||
| 9 | - SelectElement.prototype.setAttr = function(attr, value) { | ||
| 10 | - return this.select.setAttribute(attr, value); | ||
| 11 | - }; | ||
| 12 | - | ||
| 13 | - SelectElement.prototype.addOption = function(option) { | ||
| 14 | - return this.select.add(option); | ||
| 15 | - }; | ||
| 16 | - | ||
| 17 | - SelectElement.prototype.getSelect = function() { | ||
| 18 | - return this.select; | ||
| 19 | - }; | ||
| 20 | - | ||
| 21 | - SelectElement.generateOption = function(value, text) { | ||
| 22 | - var option; | ||
| 23 | - option = document.createElement("option"); | ||
| 24 | - option.setAttribute("value", value); | ||
| 25 | - option.text = text; | ||
| 26 | - return option; | ||
| 27 | - }; | ||
| 28 | - | ||
| 29 | - return SelectElement; | ||
| 30 | -})(); | ||
| 31 | - | ||
| 32 | - | ||
| 33 | -function url_with_subdirectory(url) { | ||
| 34 | - var subdirectory = jQuery("meta[property='noosfero:root']").attr("content"); | ||
| 35 | - | ||
| 36 | - return subdirectory+url; | ||
| 37 | -} | ||
| 38 | \ No newline at end of file | 0 | \ No newline at end of file |
| @@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
| 1 | +modulejs.define('ControlPanel', ['jquery'], function($) { | ||
| 2 | + function hide_infos(){ | ||
| 3 | + $(".language-info").hide(); | ||
| 4 | + $(".database-info").hide(); | ||
| 5 | + $(".libraries-info").hide(); | ||
| 6 | + $(".operating-system-info").hide(); | ||
| 7 | + $(".language-button-hide").hide(); | ||
| 8 | + $(".database-button-hide").hide(); | ||
| 9 | + $(".libraries-button-hide").hide(); | ||
| 10 | + $(".operating-system-button-hide").hide(); | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + function add_software_on_control_panel(control_panel) { | ||
| 15 | + var software_link = $(".control-panel-software-link").remove(); | ||
| 16 | + | ||
| 17 | + if( software_link.size() > 0 ) { | ||
| 18 | + control_panel.prepend(software_link); | ||
| 19 | + } | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + function add_institution_on_control_panel(control_panel) { | ||
| 24 | + var institution_link = $(".control-panel-instituton-link").remove(); | ||
| 25 | + | ||
| 26 | + if( institution_link.size() > 0 ) { | ||
| 27 | + control_panel.prepend(institution_link); | ||
| 28 | + } | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + function add_itens_on_controla_panel() { | ||
| 33 | + var control_panel = $(".control-panel"); | ||
| 34 | + | ||
| 35 | + if( control_panel.size() > 0 ) { | ||
| 36 | + add_software_on_control_panel(control_panel); | ||
| 37 | + add_institution_on_control_panel(control_panel); | ||
| 38 | + } | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + | ||
| 42 | + return { | ||
| 43 | + isControlPanel: function() { | ||
| 44 | + return $("#profile-editor-index").length == 1; | ||
| 45 | + }, | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + init: function() { | ||
| 49 | + add_itens_on_controla_panel(); | ||
| 50 | + hide_infos(); | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | +}); |