Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 35... Línea 35...
35
import {dispatchEvent} from 'core/event_dispatcher';
35
import {dispatchEvent} from 'core/event_dispatcher';
36
import {eventTypes} from './events';
36
import {eventTypes} from './events';
37
import {getString} from 'core/str';
37
import {getString} from 'core/str';
38
import {prefetchStrings} from 'core/prefetch';
38
import {prefetchStrings} from 'core/prefetch';
39
import {notifyFilterContentUpdated} from 'core/event';
39
import {notifyFilterContentUpdated} from 'core/event';
-
 
40
import PendingPromise from 'core/pending';
Línea 40... Línea 41...
40
 
41
 
41
/**
42
/**
42
 * The minimum spacing for tour step to display.
43
 * The minimum spacing for tour step to display.
43
 *
44
 *
Línea 484... Línea 485...
484
    _gotoStep(stepConfig, direction) {
485
    _gotoStep(stepConfig, direction) {
485
        if (!stepConfig) {
486
        if (!stepConfig) {
486
            return this.endTour();
487
            return this.endTour();
487
        }
488
        }
Línea -... Línea 489...
-
 
489
 
-
 
490
        const pendingPromise = new PendingPromise(`tool_usertours/tour:_gotoStep-${stepConfig.stepNumber}`);
488
 
491
 
489
        if (typeof stepConfig.delay !== 'undefined' && stepConfig.delay && !stepConfig.delayed) {
492
        if (typeof stepConfig.delay !== 'undefined' && stepConfig.delay && !stepConfig.delayed) {
490
            stepConfig.delayed = true;
493
            stepConfig.delayed = true;
-
 
494
            window.setTimeout(function(stepConfig, direction) {
-
 
495
                this._gotoStep(stepConfig, direction);
-
 
496
                pendingPromise.resolve();
Línea 491... Línea 497...
491
            window.setTimeout(this._gotoStep.bind(this), stepConfig.delay, stepConfig, direction);
497
            }, stepConfig.delay, stepConfig, direction);
492
 
498
 
493
            return this;
499
            return this;
494
        } else if (!stepConfig.orphan && !this.isStepActuallyVisible(stepConfig)) {
500
        } else if (!stepConfig.orphan && !this.isStepActuallyVisible(stepConfig)) {
-
 
501
            const fn = direction == -1 ? 'getPreviousStepNumber' : 'getNextStepNumber';
-
 
502
            this.gotoStep(this[fn](stepConfig.stepNumber), direction);
-
 
503
 
495
            let fn = direction == -1 ? 'getPreviousStepNumber' : 'getNextStepNumber';
504
            pendingPromise.resolve();
Línea 496... Línea 505...
496
            return this.gotoStep(this[fn](stepConfig.stepNumber), direction);
505
            return this;
Línea 497... Línea 506...
497
        }
506
        }
498
 
507
 
499
        this.hide();
508
        this.hide();
500
 
509
 
501
        const stepRenderEvent = this.dispatchEvent(eventTypes.stepRender, {stepConfig}, true);
510
        const stepRenderEvent = this.dispatchEvent(eventTypes.stepRender, {stepConfig}, true);
Línea -... Línea 511...
-
 
511
        if (!stepRenderEvent.defaultPrevented) {
502
        if (!stepRenderEvent.defaultPrevented) {
512
            this.renderStep(stepConfig);
503
            this.renderStep(stepConfig);
513
            this.dispatchEvent(eventTypes.stepRendered, {stepConfig});
Línea 504... Línea 514...
504
            this.dispatchEvent(eventTypes.stepRendered, {stepConfig});
514
        }
505
        }
515
 
Línea 821... Línea 831...
821
            this.currentStepNode.css({
831
            this.currentStepNode.css({
822
                top: 0,
832
                top: 0,
823
                left: 0,
833
                left: 0,
824
            });
834
            });
Línea -... Línea 835...
-
 
835
 
825
 
836
            const pendingPromise = new PendingPromise(`tool_usertours/tour:addStepToPage-${stepConfig.stepNumber}`);
826
            animationTarget
837
            animationTarget
827
                .animate({
838
                .animate({
828
                    scrollTop: this.calculateScrollTop(stepConfig),
839
                    scrollTop: this.calculateScrollTop(stepConfig),
829
                }).promise().then(function() {
840
                }).promise().then(function() {
830
                        this.positionStep(stepConfig);
841
                        this.positionStep(stepConfig);
-
 
842
                        this.revealStep(stepConfig);
831
                        this.revealStep(stepConfig);
843
                        pendingPromise.resolve();
832
                        return;
844
                        return;
833
                    }.bind(this))
845
                    }.bind(this))
834
                    .catch(function() {
846
                    .catch(function() {
835
                        // Silently fail.
847
                        // Silently fail.
Línea 898... Línea 910...
898
     * @chainable
910
     * @chainable
899
     * @return {Object} this.
911
     * @return {Object} this.
900
     */
912
     */
901
    revealStep(stepConfig) {
913
    revealStep(stepConfig) {
902
        // Fade the step in.
914
        // Fade the step in.
-
 
915
        const pendingPromise = new PendingPromise(`tool_usertours/tour:revealStep-${stepConfig.stepNumber}`);
903
        this.currentStepNode.fadeIn('', $.proxy(function() {
916
        this.currentStepNode.fadeIn('', $.proxy(function() {
904
                // Announce via ARIA.
917
                // Announce via ARIA.
905
                this.announceStep(stepConfig);
918
                this.announceStep(stepConfig);
Línea 906... Línea 919...
906
 
919
 
Línea 911... Línea 924...
911
                    // There seems to be an issue with Jaws where it only reads the dialogue title initially.
924
                    // There seems to be an issue with Jaws where it only reads the dialogue title initially.
912
                    // This second focus helps it to read the full dialogue.
925
                    // This second focus helps it to read the full dialogue.
913
                    if (this.currentStepNode) {
926
                    if (this.currentStepNode) {
914
                        this.currentStepNode.focus();
927
                        this.currentStepNode.focus();
915
                    }
928
                    }
-
 
929
                    pendingPromise.resolve();
916
                }, this), 100);
930
                }, this), 100);
Línea 917... Línea 931...
917
 
931
 
Línea 918... Línea 932...
918
            }, this));
932
            }, this));
Línea 1158... Línea 1172...
1158
        const stepHideEvent = this.dispatchEvent(eventTypes.stepHide, {}, true);
1172
        const stepHideEvent = this.dispatchEvent(eventTypes.stepHide, {}, true);
1159
        if (stepHideEvent.defaultPrevented) {
1173
        if (stepHideEvent.defaultPrevented) {
1160
            return this;
1174
            return this;
1161
        }
1175
        }
Línea -... Línea 1176...
-
 
1176
 
1162
 
1177
        const pendingPromise = new PendingPromise('tool_usertours/tour:hide');
1163
        if (this.currentStepNode && this.currentStepNode.length) {
1178
        if (this.currentStepNode && this.currentStepNode.length) {
1164
            this.currentStepNode.hide();
1179
            this.currentStepNode.hide();
1165
            if (this.currentStepPopper) {
1180
            if (this.currentStepPopper) {
1166
                this.currentStepPopper.destroy();
1181
                this.currentStepPopper.destroy();
Línea 1192... Línea 1207...
1192
 
1207
 
1193
            // Clear the step configuration.
1208
            // Clear the step configuration.
1194
            this.currentStepConfig = null;
1209
            this.currentStepConfig = null;
Línea 1195... Línea -...
1195
        }
-
 
1196
 
-
 
1197
        let fadeTime = 0;
-
 
1198
        if (transition) {
-
 
1199
            fadeTime = 400;
-
 
1200
        }
1210
        }
1201
 
1211
 
1202
        // Remove the backdrop features.
1212
        // Remove the backdrop features.
-
 
1213
        $('[data-flexitour="step-background"]').remove();
-
 
1214
        $('[data-flexitour="step-backdrop"]').removeAttr('data-flexitour');
-
 
1215
 
-
 
1216
        const backdrop = $('[data-flexitour="backdrop"]');
-
 
1217
        if (backdrop.length) {
1203
        $('[data-flexitour="step-background"]').remove();
1218
            if (transition) {
1204
        $('[data-flexitour="step-backdrop"]').removeAttr('data-flexitour');
1219
                const backdropRemovalPromise = new PendingPromise('tool_usertours/tour:hide:backdrop');
-
 
1220
                backdrop.fadeOut(400, function() {
-
 
1221
                    $(this).remove();
-
 
1222
                    backdropRemovalPromise.resolve();
-
 
1223
                });
-
 
1224
            } else {
1205
        $('[data-flexitour="backdrop"]').fadeOut(fadeTime, function() {
1225
                backdrop.remove();
Línea 1206... Línea 1226...
1206
            $(this).remove();
1226
            }
1207
        });
1227
        }
1208
 
1228
 
1209
        // Remove aria-describedby and tabindex attributes.
1229
        // Remove aria-describedby and tabindex attributes.
Línea 1223... Línea 1243...
1223
 
1243
 
Línea 1224... Línea 1244...
1224
        this.dispatchEvent(eventTypes.stepHidden);
1244
        this.dispatchEvent(eventTypes.stepHidden);
1225
 
1245
 
-
 
1246
        this.currentStepNode = null;
-
 
1247
        this.currentStepPopper = null;
1226
        this.currentStepNode = null;
1248
 
1227
        this.currentStepPopper = null;
1249
        pendingPromise.resolve();
Línea 1228... Línea 1250...
1228
        return this;
1250
        return this;
1229
    }
1251
    }