Skip to content

Commit 189e5ff

Browse files
update
1 parent f06160d commit 189e5ff

15 files changed

Lines changed: 96 additions & 44 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| Название | Автор | Дата создания | Дата обновления |
22
| --- | --- | --- | --- |
3-
| EvoFileManagerDialog Evolution CMS | Чернышёв Андрей aka ProjectSoft <[email protected]> | 2017-11-24 | 2026-05-07 |
3+
| EvoFileManagerDialog Evolution CMS | Чернышёв Андрей aka ProjectSoft <[email protected]> | 2017-11-24 | 2026-05-08 |
44

55
# EvoFileManagerDialog
66

assets/plugins/filemanageropen/css/main.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
h1 {
116116
margin-bottom: 1.6rem;
117117
}
118+
.gener_popup .evo-popup-header,
118119
.kcfinder_popup .evo-popup-header {
119120
box-shadow: 0 0 16px 2px #bbb;
120121
z-index: 2;

assets/plugins/filemanageropen/css/main.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ h1 {
139139
margin-bottom: 1.6rem;
140140
}
141141

142+
.gener_popup,
142143
.kcfinder_popup {
143144
.evo-popup-header {
144145
box-shadow: 0 0 16px 2px #bbb;

assets/plugins/filemanageropen/css/main.min.css

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

assets/plugins/filemanageropen/js/main.js

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
;(function(document, window, $){
22
window.lastImageCtrl = '';
33
window.lastFileCtrl = '';
4-
const icon_header = "fa fa-external-link";
4+
const icon_header = "fa fa-folder-open";
55
var currentWin = window,
66
$actions,
7-
showAlert = window.filemanageropen_alert || 0,
8-
showButtons = window.filemanageropen_showbtn || 0;
7+
showAlert = parseInt(window.filemanageropen_alert) || 0,
8+
showButtons = parseInt(window.filemanageropen_showbtn) || 0;
99
window_init = function(){
1010
// Переопределяем метод window.open
1111
(function(proxied) {
@@ -33,8 +33,8 @@
3333
evoMod.popup(
3434
{
3535
url: window.location.origin + window.location.pathname + srg[0],
36-
addclass: 'kcfinder_popup',
37-
title: "gener",
36+
addclass: 'gener_popup',
37+
title: window.fmolang["load"],
3838
icon: icon_header,
3939
iframe: 'iframe',
4040
position: 'center center',
@@ -80,13 +80,19 @@
8080
}
8181
return dir;
8282
},
83+
alertPopup = function(message = "", file_path = "", type = "default") {
84+
let evoMod = window.modx || window.parent.modx || window.parent.parent.modx;
85+
file_path = file_path.split("\n").join("<br>");
86+
evoMod.alert( `${message}<br>${file_path}`, type);
87+
},
8388
copyFilePath = function(file_path){
8489
var fl = window.fmolang;
8590
file_path = file_path.join("\n");
8691
if(currentWin.navigator.clipboard){
8792
currentWin.navigator.clipboard.writeText(file_path).then(function(){
8893
if(showAlert){
89-
currentWin.alert(fl["copy"] + "\n" + file_path);
94+
//currentWin.alert(fl["copy"] + "\n" + file_path);
95+
alertPopup(fl["copy"], file_path, 'success');
9096
}
9197
}, function(err){
9298
alternativeCopyFilePath(file_path);
@@ -104,14 +110,16 @@
104110
input.focus();
105111
input.select();
106112
if(!currentWin.document.execCommand('copy')) {
107-
currentWin.alert(fl["nocopy"]);
113+
//currentWin.alert(fl["nocopy"]);
114+
alertPopup(fl["nocopy"], "", 'danger');
115+
}else{
116+
if(showAlert){
117+
alertPopup(fl["copy"], path, 'success');
118+
}
108119
}
109120
currentWin.document.body.removeChild(input);
110-
if(showAlert){
111-
currentWin.alert(fl["copy"] + "\n" + path);
112-
}
113121
} catch (err) {
114-
currentWin.alert(fl["nocopy"]);
122+
alertPopup(fl["nocopy"], "", 'danger');
115123
}
116124
}
117125
};
@@ -127,22 +135,40 @@
127135
// Переопределяем глобальную функию OpenServerBrowser
128136
window.OpenServerBrowser = function(url) {
129137
let evoMod = window.modx || window.parent.modx || window.parent.parent.modx;
130-
//let evoPopupHeader;
131138
let popup;
132139
let pWidth;
133140
let pHeight;
134141
let myReq;
142+
let intIframe;
143+
let popupIframe;
135144
const eventHandler = (event) => {
136145
//
137146
let data = typeof event.data == "string" ? JSON.parse(event.data) : event.data;
138147
switch(data.type){
139148
case "kcfinder:change-title":
140149
if(evoPopupHeader) {
141-
evoPopupHeader.innerHTML = `<i class="${icon_header}"></i>${data.title}`;
150+
const regex = /^(kcfinder)/i;
151+
const subst = `<i class="${icon_header}"></i>$1`;
152+
data.title = data.title.replace(regex, subst);
153+
evoPopupHeader.innerHTML = data.title;
142154
}
143155
break;
144156
}
145157
};
158+
const iframeLoad = function(e) {
159+
if (e.target.contentDocument.title) {
160+
// Если есть шапка попапа
161+
if(evoPopupHeader) {
162+
// Перезапись заголовка
163+
const regex = /^(kcfinder)/i;
164+
const subst = `<i class="${icon_header}"></i>$1`;
165+
evoPopupHeader.innerHTML = e.target.contentDocument.title.replace(regex, subst);
166+
// Остановить прелоадер
167+
evoMod.main.stopWork();
168+
}
169+
}
170+
}
171+
// Ресайз попапа с kcfinder
146172
const eventResizeHandler = function() {
147173
if ( popup ) {
148174
let w,
@@ -172,7 +198,7 @@
172198
{
173199
addclass: 'kcfinder_popup',
174200
url: url,
175-
title: `<i class="${icon_header}">File Manager Dialog`,
201+
title: window.fmolang["kcfinder"],
176202
icon: icon_header,
177203
iframe: 'iframe',
178204
position: 'center center',
@@ -183,27 +209,32 @@
183209
resize: !0,
184210
overlay: 1,
185211
overlayclose: 1,
186-
onclose: function() {
212+
onclose: function(e, obj) {
187213
if(typeof reloadElementsInTree == 'function'){
188214
setTimeout(reloadElementsInTree, 400);
189215
}
216+
popupIframe && popupIframe.removeEventListener('load', iframeLoad)
190217
// Удалить
218+
popupIframe = null;
191219
evoPopupHeader = null;
192220
window.removeEventListener('message', eventHandler);
193221
// остановка
194222
cancelAnimationFrame(myReq);
195223
popup = null;
196224
},
225+
// Если подобная функция всё же будет
226+
onshow: function(e, obj) {
227+
evoPopupHeader = obj.querySelector('.evo-popup-header');
228+
popupIframe = obj.querySelector('iframe');
229+
// Подписываемся на события
230+
window.addEventListener('message', eventHandler);
231+
// старт ресайза.
232+
myReq = requestAnimationFrame(eventResizeHandler);
233+
popupIframe && popupIframe.addEventListener('load', iframeLoad);
234+
},
197235
wrap: document.body
198236
}
199237
);
200-
setTimeout(() => {
201-
let popupEl = popup.el;
202-
evoPopupHeader = popupEl.querySelector('.evo-popup-header');
203-
window.addEventListener('message', eventHandler);
204-
// старт
205-
myReq = requestAnimationFrame(eventResizeHandler);
206-
}, 100);
207238
}
208239
}
209240
// Переопределяем глобальную функию BrowseServer
@@ -271,10 +302,17 @@
271302
var $td = $('#actions');
272303
if($td.length){
273304
var fl = window.fmolang;
305+
// Сделать логику на показ определённых клавишь
274306
var html = `<div class="evoflbw_wrapper btn-group">`;
275-
html += `<a href="evoflbw:button" data-type="images" class="btn btn-secondary"><i class="fas fa-file-image fa"></i><span>` + fl["images"] + `</span></a>`;
276-
html += `<a href="evoflbw:button" data-type="media" class="btn btn-secondary"><i class="fas fa-file-video fa"></i><span>` + fl["media"] + `</span></a>`;
277-
html += `<a href="evoflbw:button" data-type="files" class="btn btn-secondary"><i class="fas fa-file-alt fa"></i><span>` + fl["files"] + `</span></a>`;
307+
if(parseInt(fl["showimage"]) || 0) {
308+
html += `<a href="evoflbw:button" data-type="images" class="btn btn-secondary"><i class="fas fa-file-image fa"></i><span>` + fl["images"] + `</span></a>`;
309+
}
310+
if(parseInt(fl["showfile"]) || 0){
311+
html += `<a href="evoflbw:button" data-type="files" class="btn btn-secondary"><i class="fas fa-file-alt fa"></i><span>` + fl["files"] + `</span></a>`;
312+
}
313+
if(parseInt(fl["showmedia"]) || 0){
314+
html += `<a href="evoflbw:button" data-type="media" class="btn btn-secondary"><i class="fas fa-file-video fa"></i><span>` + fl["media"] + `</span></a>`;
315+
}
278316
html += `</div>`;
279317
$td.append(html);
280318
$('a[href*="evoflbw:"]').on('click', function(e){

0 commit comments

Comments
 (0)