Proyectos de Subversion Moodle

Rev

Rev 4 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 4 Rev 5
Línea 23... Línea 23...
23
    /**
23
    /**
24
     * Manage updating of visibility state of elements related to Reactions and Difficulty tracks,
24
     * Manage updating of visibility state of elements related to Reactions and Difficulty tracks,
25
     * depending on whether they are enabled or not.
25
     * depending on whether they are enabled or not.
26
     */
26
     */
27
    function manageElementsVisibility() {
27
    function manageElementsVisibility() {
28
        var $enableReactions = $('[name="config_enable_point_views"]');
28
        var $enableReactions = $('#id_config_enable_point_views');
29
        var $enableDifficultyTracks = $('[name="config_enable_difficultytracks"]');
29
        var $enableDifficultyTracks = $('#id_config_enable_difficultytracks');
Línea 30... Línea 30...
30
 
30
 
31
        var updateElementsVisibility = function() {
31
        var updateElementsVisibility = function() {
32
            var reactionsEnabled = $enableReactions.val() > 0;
32
            var reactionsEnabled = $enableReactions.val() > 0;
Línea 33... Línea 33...
33
            var difficultyTracksEnabled = $enableDifficultyTracks.val() > 0;
33
            var difficultyTracksEnabled = $enableDifficultyTracks.val() > 0;
Línea 34... Línea 34...
34
 
34
 
35
            $('fieldset[id^=id_activities_header]').toggle(reactionsEnabled || difficultyTracksEnabled);
35
            $('#id_activities_header').toggle(reactionsEnabled || difficultyTracksEnabled);
36
 
36
 
Línea 37... Línea 37...
37
            $('.reactions, fieldset[id^=id_images_header]').toggle(reactionsEnabled);
37
            $('.reactions, #id_images_header').toggle(reactionsEnabled);
Línea 104... Línea 104...
104
                }
104
                }
105
            });
105
            });
106
        });
106
        });
107
    }
107
    }
Línea 108... Línea -...
108
 
-
 
109
    /**
-
 
110
     * Setup change listener to update track color responsively when it is changed from select.
-
 
111
     * @param {Object} trackcolors Mapping of trackname => CSS color.
-
 
112
     */
-
 
113
    function setupDifficultyTrackChange(trackcolors) {
-
 
114
        // Difficulty track change.
-
 
115
        $('.moduletrackselect select').change(function() {
-
 
116
            $('#track_' + $(this).data('id')).css({
-
 
117
                'background-color': trackcolors[$(this).val()] // Change track color.
-
 
118
            });
-
 
119
        }).change(); // Update track colors once on page load.
-
 
120
    }
-
 
121
 
108
 
122
    return {
109
    return {
Línea 123... Línea 110...
123
        init: function(envconf, trackcolors) {
110
        init: function(envconf, trackcolors) {
Línea 124... Línea 111...
124
 
111
 
Línea 125... Línea 112...
125
            manageElementsVisibility();
112
            manageElementsVisibility();
-
 
113
 
-
 
114
            manageEnableDisableButtons();
-
 
115
 
-
 
116
            // Difficulty track change.
-
 
117
            $('.moduletrackselect select').change(function() {
Línea 126... Línea 118...
126
 
118
                $('#track_' + $(this).data('id')).css({
127
            manageEnableDisableButtons();
119
                    'background-color': trackcolors[$(this).val()] // Change track color.
128
 
120
                });
129
            setupDifficultyTrackChange(trackcolors);
121
            }).change(); // Update track colors once on page load.
Línea 141... Línea 133...
141
                    function() {
133
                    function() {
142
                        $('.pix-preview[data-source="custom"], #delete_custom_pix').remove(); // Remove emoji preview and button.
134
                        $('.pix-preview[data-source="custom"], #delete_custom_pix').remove(); // Remove emoji preview and button.
143
                        // Refresh draft area files.
135
                        // Refresh draft area files.
144
                        // # For an unknown reason, the following instruction with jQuery does not work
136
                        // # For an unknown reason, the following instruction with jQuery does not work
145
                        // # (or at least does not trigger the expected listener).
137
                        // # (or at least does not trigger the expected listener).
146
                        document.querySelector('[id^=fitem_id_config_point_views_pix] .fp-path-folder-name').click();
138
                        document.querySelector('#fitem_id_config_point_views_pix .fp-path-folder-name').click();
147
                    }
139
                    }
148
            );
140
            );
Línea 149... Línea 141...
149
 
141
 
150
            // Update current emoji on emoji change.
142
            // Update current emoji on emoji change.
Línea 207... Línea 199...
207
                                    M.util.get_string('reactionsresetsuccessfully', 'block_point_view'),
199
                                    M.util.get_string('reactionsresetsuccessfully', 'block_point_view'),
208
                                    M.util.get_string('ok', 'moodle'));
200
                                    M.util.get_string('ok', 'moodle'));
209
                        }
201
                        }
210
                );
202
                );
211
            });
203
            });
212
        },
204
        }
213
 
-
 
214
        setupDifficultyTrackChange: setupDifficultyTrackChange
-
 
215
    };
205
    };
216
});
206
});
217
207