Skip to content

Commit 4155879

Browse files
committed
fix: restore AppsSlideToggle feature
Signed-off-by: John Molakvoæ <[email protected]> Signed-off-by: nextcloud-command <[email protected]>
1 parent 1ebea4f commit 4155879

File tree

9 files changed

+191
-7
lines changed

9 files changed

+191
-7
lines changed

core/src/OC/apps.js

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/**
2+
* @copyright Bernhard Posselt 2014
3+
*
4+
* @author Christoph Wurst <[email protected]>
5+
* @author John Molakvoæ <[email protected]>
6+
*
7+
* @license AGPL-3.0-or-later
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
import $ from 'jquery'
25+
26+
let dynamicSlideToggleEnabled = false
27+
28+
const Apps = {
29+
enableDynamicSlideToggle() {
30+
dynamicSlideToggleEnabled = true
31+
},
32+
}
33+
34+
/**
35+
* Shows the #app-sidebar and add .with-app-sidebar to subsequent siblings
36+
*
37+
* @param {object} [$el] sidebar element to show, defaults to $('#app-sidebar')
38+
*/
39+
Apps.showAppSidebar = function($el) {
40+
const $appSidebar = $el || $('#app-sidebar')
41+
$appSidebar.removeClass('disappear').show()
42+
$('#app-content').trigger(new $.Event('appresized'))
43+
}
44+
45+
/**
46+
* Shows the #app-sidebar and removes .with-app-sidebar from subsequent
47+
* siblings
48+
*
49+
* @param {object} [$el] sidebar element to hide, defaults to $('#app-sidebar')
50+
*/
51+
Apps.hideAppSidebar = function($el) {
52+
const $appSidebar = $el || $('#app-sidebar')
53+
$appSidebar.hide().addClass('disappear')
54+
$('#app-content').trigger(new $.Event('appresized'))
55+
}
56+
57+
/**
58+
* Provides a way to slide down a target area through a button and slide it
59+
* up if the user clicks somewhere else. Used for the news app settings and
60+
* add new field.
61+
*
62+
* Usage:
63+
* <button data-apps-slide-toggle=".slide-area">slide</button>
64+
* <div class=".slide-area" class="hidden">I'm sliding up</div>
65+
*/
66+
export const registerAppsSlideToggle = () => {
67+
let buttons = $('[data-apps-slide-toggle]')
68+
69+
if (buttons.length === 0) {
70+
$('#app-navigation').addClass('without-app-settings')
71+
}
72+
73+
$(document).click(function(event) {
74+
75+
if (dynamicSlideToggleEnabled) {
76+
buttons = $('[data-apps-slide-toggle]')
77+
}
78+
79+
buttons.each(function(index, button) {
80+
81+
const areaSelector = $(button).data('apps-slide-toggle')
82+
const area = $(areaSelector)
83+
84+
/**
85+
*
86+
*/
87+
function hideArea() {
88+
area.slideUp(OC.menuSpeed * 4, function() {
89+
area.trigger(new $.Event('hide'))
90+
})
91+
area.removeClass('opened')
92+
$(button).removeClass('opened')
93+
}
94+
95+
/**
96+
*
97+
*/
98+
function showArea() {
99+
area.slideDown(OC.menuSpeed * 4, function() {
100+
area.trigger(new $.Event('show'))
101+
})
102+
area.addClass('opened')
103+
$(button).addClass('opened')
104+
const input = $(areaSelector + ' [autofocus]')
105+
if (input.length === 1) {
106+
input.focus()
107+
}
108+
}
109+
110+
// do nothing if the area is animated
111+
if (!area.is(':animated')) {
112+
113+
// button toggles the area
114+
if ($(button).is($(event.target).closest('[data-apps-slide-toggle]'))) {
115+
if (area.is(':visible')) {
116+
hideArea()
117+
} else {
118+
showArea()
119+
}
120+
121+
// all other areas that have not been clicked but are open
122+
// should be slid up
123+
} else {
124+
const closest = $(event.target).closest(areaSelector)
125+
if (area.is(':visible') && closest[0] !== area[0]) {
126+
hideArea()
127+
}
128+
}
129+
}
130+
})
131+
132+
})
133+
}
134+
135+
export default Apps

core/src/OC/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
processAjaxError,
3131
registerXHRForErrorProcessing,
3232
} from './xhr-error.js'
33+
import Apps from './apps.js'
3334
import { AppConfig, appConfig } from './appconfig.js'
3435
import { appSettings } from './appsettings.js'
3536
import appswebroots from './appswebroots.js'
@@ -137,7 +138,7 @@ export default {
137138
* @deprecated 17.0.0
138139
*/
139140
fileIsBlacklisted: file => !!(file.match(Config.blacklist_files_regex)),
140-
141+
Apps,
141142
addScript,
142143
addStyle,
143144
AppConfig,

core/src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*
2424
*/
2525

26+
import { registerAppsSlideToggle } from './OC/apps.js'
2627
import $ from 'jquery'
2728
import 'core-js/stable/index.js'
2829
import 'regenerator-runtime/runtime.js'
@@ -38,6 +39,7 @@ import { initCore } from './init.js'
3839

3940
window.addEventListener('DOMContentLoaded', function() {
4041
initCore()
42+
registerAppsSlideToggle()
4143

4244
// fallback to hashchange when no history support
4345
if (window.history.pushState) {

dist/core-login.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-login.js.LICENSE.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,29 @@
280280
*
281281
*/
282282

283+
/**
284+
* @copyright Bernhard Posselt 2014
285+
*
286+
* @author Christoph Wurst <[email protected]>
287+
* @author John Molakvoæ <[email protected]>
288+
*
289+
* @license AGPL-3.0-or-later
290+
*
291+
* This program is free software: you can redistribute it and/or modify
292+
* it under the terms of the GNU Affero General Public License as
293+
* published by the Free Software Foundation, either version 3 of the
294+
* License, or (at your option) any later version.
295+
*
296+
* This program is distributed in the hope that it will be useful,
297+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
298+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
299+
* GNU Affero General Public License for more details.
300+
*
301+
* You should have received a copy of the GNU Affero General Public License
302+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
303+
*
304+
*/
305+
283306
/**
284307
* @copyright Copyright (c) 2016 Joas Schilling <[email protected]>
285308
*

dist/core-login.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-main.js.LICENSE.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,29 @@
428428
*
429429
*/
430430

431+
/**
432+
* @copyright Bernhard Posselt 2014
433+
*
434+
* @author Christoph Wurst <[email protected]>
435+
* @author John Molakvoæ <[email protected]>
436+
*
437+
* @license AGPL-3.0-or-later
438+
*
439+
* This program is free software: you can redistribute it and/or modify
440+
* it under the terms of the GNU Affero General Public License as
441+
* published by the Free Software Foundation, either version 3 of the
442+
* License, or (at your option) any later version.
443+
*
444+
* This program is distributed in the hope that it will be useful,
445+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
446+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
447+
* GNU Affero General Public License for more details.
448+
*
449+
* You should have received a copy of the GNU Affero General Public License
450+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
451+
*
452+
*/
453+
431454
/**
432455
* @copyright Copyright (c) 2016 Christoph Wurst <[email protected]>
433456
*

dist/core-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)