| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
g> |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
var dialogParentEffect = { |
| 13 |
duration: animationTime(300), |
| 14 |
windowAdded: function (window) { |
| 15 |
"use strict"; |
| 16 |
window.minimizedChanged.connect(() => { |
| 17 |
if (window.minimized) { |
| 18 |
dialogParentEffect.cancelAnimationInstant(window); |
| 19 |
} else { |
| 20 |
dialogParentEffect.restartAnimation(window); |
| 21 |
} |
| 22 |
}); |
| 23 |
window.windowModalityChanged.connect(dialogParentEffect.windowModalityChanged); |
| 24 |
window.windowDesktopsChanged.connect(dialogParentEffect.cancelAnimationInstant); |
| 25 |
window.windowDesktopsChanged.connect(dialogParentEffect.restartAnimation); |
| 26 |
|
| 27 |
if (window.modal) { |
| 28 |
dialogParentEffect.dialogGotModality(window); |
| 29 |
} |
| 30 |
}, |
| 31 |
dialogGotModality: function (window) { |
| 32 |
"use strict"; |
| 33 |
var mainWindows = window.mainWindows(); |
| 34 |
for (var i = 0; i < mainWindows.length; ++i) { |
| 35 |
dialogParentEffect.startAnimation(mainWindows[i]); |
| 36 |
} |
| 37 |
}, |
| 38 |
startAnimation: function (window) { |
| 39 |
"use strict"; |
| 40 |
if (window.visible === false) { |
| 41 |
return; |
| 42 |
} |
| 43 |
if (window.dialogParentAnimation) { |
| 44 |
if (redirect(window.dialogParentAnimation, Effect.Forward)) { |
| 45 |
return; |
| 46 |
} |
| 47 |
cancel(window.dialogParentAnimation); |
| 48 |
} |
| 49 |
window.dialogParentAnimation = set({ |
| 50 |
window: window, |
| 51 |
duration: dialogParentEffect.duration, |
| 52 |
keepAlive: false, |
| 53 |
animations: [{ |
| 54 |
type: Effect.Saturation, |
| 55 |
to: 0.4 |
| 56 |
}, { |
| 57 |
type: Effect.Brightness, |
| 58 |
to: 0.6 |
| 59 |
}] |
| 60 |
}); |
| 61 |
}, |
| 62 |
windowClosed: function (window) { |
| 63 |
"use strict"; |
| 64 |
if (window.modal) { |
| 65 |
dialogParentEffect.dialogLostModality(window); |
| 66 |
} |
| 67 |
}, |
| 68 |
dialogLostModality: function (window) { |
| 69 |
"use strict"; |
| 70 |
var mainWindows = window.mainWindows(); |
| 71 |
for (var i = 0; i < mainWindows.length; ++i) { |
| 72 |
dialogParentEffect.cancelAnimationSmooth(mainWindows[i]); |
| 73 |
} |
| 74 |
}, |
| 75 |
cancelAnimationInstant: function (window) { |
| 76 |
"use strict"; |
| 77 |
if (window.dialogParentAnimation) { |
| 78 |
cancel(window.dialogParentAnimation); |
| 79 |
delete window.dialogParentAnimation; |
| 80 |
} |
| 81 |
}, |
| 82 |
cancelAnimationSmooth: function (window) { |
| 83 |
"use strict"; |
| 84 |
if (!window.dialogParentAnimation) { |
| 85 |
return; |
| 86 |
} |
| 87 |
if (redirect(window.dialogParentAnimation, Effect.Backward)) { |
| 88 |
return; |
| 89 |
} |
| 90 |
cancel(window.dialogParentAnimation); |
| 91 |
delete window.dialogParentEffect; |
| 92 |
}, |
| 93 |
desktopChanged: function () { |
| 94 |
"use strict"; |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
if (dialogParentEffect.globallyInhibited()) { |
| 101 |
return; |
| 102 |
} |
| 103 |
|
| 104 |
const windows = effects.stackingOrder; |
| 105 |
for (const window of windows) { |
| 106 |
dialogParentEffect.cancelAnimationInstant(window); |
| 107 |
dialogParentEffect.restartAnimation(window); |
| 108 |
} |
| 109 |
}, |
| 110 |
windowModalityChanged: function (window) { |
| 111 |
"use strict"; |
| 112 |
dialogParentEffect.refreshWindowEffect(window); |
| 113 |
}, |
| 114 |
restartAnimation: function (window) { |
| 115 |
"use strict"; |
| 116 |
if (window === null || window.findModal() === null) { |
| 117 |
return; |
| 118 |
} |
| 119 |
dialogParentEffect.startAnimation(window); |
| 120 |
if (window.dialogParentAnimation) { |
| 121 |
complete(window.dialogParentAnimation); |
| 122 |
} |
| 123 |
}, |
| 124 |
activeFullScreenOrColorPickerChanged: function () { |
| 125 |
"use strict"; |
| 126 |
const windows = effects.stackingOrder; |
| 127 |
for (const window of windows) { |
| 128 |
dialogParentEffect.refreshWindowEffect(window); |
| 129 |
} |
| 130 |
}, |
| 131 |
globallyInhibited: function () { |
| 132 |
return effects.hasActiveFullScreenEffect || effects.colorPickerActive; |
| 133 |
}, |
| 134 |
refreshWindowEffect: function (window) { |
| 135 |
if (dialogParentEffect.globallyInhibited() || !window.modal) { |
| 136 |
dialogParentEffect.dialogLostModality(window); |
| 137 |
} else { |
| 138 |
dialogParentEffect.dialogGotModality(window); |
| 139 |
} |
| 140 |
}, |
| 141 |
init: function () { |
| 142 |
"use strict"; |
| 143 |
var i, windows; |
| 144 |
effects.windowAdded.connect(dialogParentEffect.windowAdded); |
| 145 |
effects.windowClosed.connect(dialogParentEffect.windowClosed); |
| 146 |
effects.desktopChanged.connect(dialogParentEffect.desktopChanged); |
| 147 |
effects.activeFullScreenEffectChanged.connect( |
| 148 |
dialogParentEffect.activeFullScreenOrColorPickerChanged); |
| 149 |
effects.colorPickerActiveChanged.connect( |
| 150 |
dialogParentEffect.activeFullScreenOrColorPickerChanged); |
| 151 |
|
| 152 |
windows = effects.stackingOrder; |
| 153 |
for (i = 0; i < windows.length; i += 1) { |
| 154 |
dialogParentEffect.windowAdded(windows[i]); |
| 155 |
} |
| 156 |
} |
| 157 |
}; |
| 158 |
dialogParentEffect.init(); |