forked from lebowski42/dokuwiki-owncloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
140 lines (123 loc) · 3.86 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
* jQuery-stuff to handle filelist and versionlist on detailpage
*
* @license GPL 3 (http://www.gnu.org/licenses/gpl.html)
* @author Martin Schulte <lebowski[at]corvus[dot]uberspace[dot]de>, 2013
*/
var filelist = {
start: function(){
var fileid;
var $container = jQuery('.filelistOC');
$container.each(function(){
$current = jQuery(this);
fileid = parseInt($current.attr("class").replace('filelistOC fileid',''));
$row = $current.find('.load').parent();
filelist.subfolder('',$row,'level0',fileid);
});
},
folderContent: function(data, $place, level){
var $response=jQuery(data);
$folder = $response.find('.mf_folder');
$folder.removeAttr('href');
$folder.css('cursor','pointer');
$place.replaceWith($response);
$folder.each(function(){filelist.folderEvent(jQuery(this),level);});
},
subfolder: function(dir, $row, level,fileid){
jQuery.ajax({
type: 'POST',
url: DOKU_BASE + '/lib/plugins/owncloud/ajax/filelist.php',
data: {dir: dir, fileid: fileid, level: level},
success: function(data) {filelist.folderContent(data, $row, level);},
async:false
});
},
folderEvent: function(folder,level){
folder.bind('click', function() {
var $row = folder.parent().parent();
nextLevel = 'level'+(parseInt(level.replace('level',''))+1);
if($row.hasClass('expanded')){
$row.nextAll('.'+nextLevel).remove();
$row.removeClass('expanded').addClass('collapsed');
}else{
var dir = folder.attr('title');
$row.after('<tr><td colspan="5" class="load"></td></tr>');
filelist.subfolder(dir,$row.next(),nextLevel);
$row.removeClass('collapsed').addClass('expanded');
}
});
}
};
var filehistory = {
start: function(file){
var $container = jQuery('.historyOC');
$container.each(function(){
$current = jQuery(this);
$row = $current.find('.load').parent();
jQuery.ajax({
type: 'POST',
url: DOKU_BASE + '/lib/plugins/owncloud/ajax/history.php',
data: {file: file},
success: function(ret) {if(ret != file){filehistory.putContent(ret, $row);}else{}},
async:false
});
});
},
putContent: function(data, $place){
//var $response=jQuery(data);
$place.replaceWith(data);
},
};
var Usedmedia = {
start: function(){
var $ol = jQuery('#usedmedia');
var $items = $ol.children();
jQuery.each($items,function(){
$li = jQuery(this);
//$li.append('<div class="load3"></div>');
Usedmedia.addInfo($li);
});
var $link = jQuery('#usemediadetail');
$link.off('click');
$link.click(Usedmedia.collapse);
},
addInfo: function(li){
//li.append("<ul><li>"+li.attr('fileid')+"</li><li>Mein Text</li></ul>");
if(!li.hasClass('expand')){
jQuery.ajax({
type: 'POST',
url: DOKU_BASE + '/lib/plugins/owncloud/ajax/usedMedia.php',
data: {fileid: li.attr('fileid')},
success: function(data) {
//li.find('.load3').remove();
li.append(data);
li.addClass('expand')
},
async:true
});
}
},
collapse: function(){
var $ol = jQuery('#usedmedia');
var $items = $ol.children();
jQuery.each($items,function(){
jQuery(this).find('.filedesc').remove();
jQuery(this).removeClass('expand');
});
var $link = jQuery('#usemediadetail');
$link.off('click');
$link.click(Usedmedia.start);
}
};
jQuery(document).ready(function() {
var $link = jQuery('#usemediadetail');
$link.off('click');
$link.click(Usedmedia.start);
if (jQuery('div.filelistOC').length > 0) {
filelist.start();
}
if (jQuery('div.historyOC').length > 0) {
var file = jQuery('div.historyOC').attr("data-file");
filehistory.start(file);
}
});