Proyectos de Subversion Moodle

Rev

Rev 5 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5 Rev 6
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 = $('#id_config_enable_point_views');
28
        var $enableReactions = $('[name="config_enable_point_views"]');
29
        var $enableDifficultyTracks = $('#id_config_enable_difficultytracks');
29
        var $enableDifficultyTracks = $('[name="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
            $('#id_activities_header').toggle(reactionsEnabled || difficultyTracksEnabled);
35
            $('fieldset[id^=id_activities_header]').toggle(reactionsEnabled || difficultyTracksEnabled);
36
 
36
 
Línea 37... Línea 37...
37
            $('.reactions, #id_images_header').toggle(reactionsEnabled);
37
            $('.reactions, fieldset[id^=id_images_header]').toggle(reactionsEnabled);
Línea 104... Línea 104...
104
                }
104
                }
105
            });
105
            });
106
        });
106
        });
107
    }
107
    }
Línea -... Línea 108...
-
 
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
    }
108
 
121
 
109
    return {
122
    return {
Línea 110... Línea 123...
110
        init: function(envconf, trackcolors) {
123
        init: function(envconf, trackcolors) {
Línea 111... Línea 124...
111
 
124
 
Línea 112... Línea 125...
112
            manageElementsVisibility();
125
            manageElementsVisibility();
113
 
-
 
114
            manageEnableDisableButtons();
-
 
115
 
-
 
116
            // Difficulty track change.
-
 
117
            $('.moduletrackselect select').change(function() {
-
 
Línea 118... Línea 126...
118
                $('#track_' + $(this).data('id')).css({
126
 
119
                    'background-color': trackcolors[$(this).val()] // Change track color.
127
            manageEnableDisableButtons();
120
                });
128
 
121
            }).change(); // Update track colors once on page load.
129
            setupDifficultyTrackChange(trackcolors);
Línea 133... Línea 141...
133
                    function() {
141
                    function() {
134
                        $('.pix-preview[data-source="custom"], #delete_custom_pix').remove(); // Remove emoji preview and button.
142
                        $('.pix-preview[data-source="custom"], #delete_custom_pix').remove(); // Remove emoji preview and button.
135
                        // Refresh draft area files.
143
                        // Refresh draft area files.
136
                        // # For an unknown reason, the following instruction with jQuery does not work
144
                        // # For an unknown reason, the following instruction with jQuery does not work
137
                        // # (or at least does not trigger the expected listener).
145
                        // # (or at least does not trigger the expected listener).
138
                        document.querySelector('#fitem_id_config_point_views_pix .fp-path-folder-name').click();
146
                        document.querySelector('[id^=fitem_id_config_point_views_pix] .fp-path-folder-name').click();
139
                    }
147
                    }
140
            );
148
            );
Línea 141... Línea 149...
141
 
149
 
142
            // Update current emoji on emoji change.
150
            // Update current emoji on emoji change.
Línea 199... Línea 207...
199
                                    M.util.get_string('reactionsresetsuccessfully', 'block_point_view'),
207
                                    M.util.get_string('reactionsresetsuccessfully', 'block_point_view'),
200
                                    M.util.get_string('ok', 'moodle'));
208
                                    M.util.get_string('ok', 'moodle'));
201
                        }
209
                        }
202
                );
210
                );
203
            });
211
            });
204
        }
212
        },
-
 
213
 
-
 
214
        setupDifficultyTrackChange: setupDifficultyTrackChange
205
    };
215
    };
206
});
216
});
207
217