2012-04-30 17:18:00 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
$('#versions').bind('change', function() {
|
|
|
|
var checked = 1;
|
|
|
|
if (!this.checked) {
|
|
|
|
checked = 0;
|
|
|
|
}
|
|
|
|
$.post(OC.filePath('files_versions','ajax','togglesettings.php'), 'versions='+checked);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2012-04-25 12:56:43 +00:00
|
|
|
$(document).ready(function(){
|
2012-05-02 21:26:41 +00:00
|
|
|
if (typeof FileActions !== 'undefined') {
|
|
|
|
// Add history button to files/index.php
|
|
|
|
FileActions.register('file','History',function(){return OC.imagePath('core','actions/history')},function(filename){
|
|
|
|
|
|
|
|
if (scanFiles.scanning){return;}//workaround to prevent additional http request block scanning feedback
|
2012-05-11 12:17:37 +00:00
|
|
|
|
2012-05-02 21:26:41 +00:00
|
|
|
var file = $('#dir').val()+'/'+filename;
|
|
|
|
|
|
|
|
createVersionsDropdown(filename, file)
|
|
|
|
|
2012-04-26 15:48:43 +00:00
|
|
|
});
|
2012-05-02 21:26:41 +00:00
|
|
|
}
|
2012-04-25 12:56:43 +00:00
|
|
|
});
|
2012-04-23 21:54:49 +00:00
|
|
|
|
2012-04-26 12:41:22 +00:00
|
|
|
function createVersionsDropdown(filename, files) {
|
2012-05-11 12:17:37 +00:00
|
|
|
|
2012-05-11 16:13:58 +00:00
|
|
|
var historyUrl = OC.linkTo('files_versions', 'history.php?path='+encodeURIComponent( $( '#dir' ).val() ).replace( /%2F/g, '/' )+'/'+encodeURIComponent( filename ) )
|
|
|
|
|
2012-04-25 16:37:45 +00:00
|
|
|
var html = '<div id="dropdown" class="drop" data-file="'+files+'">';
|
|
|
|
html += '<div id="private">';
|
2012-04-26 15:48:43 +00:00
|
|
|
html += '<select data-placeholder="File Version" id="found_versions" class="chzen-select">';
|
2012-04-27 12:19:16 +00:00
|
|
|
html += '<option value="">Saved versions</option>';
|
2012-04-25 16:37:45 +00:00
|
|
|
html += '</select>';
|
|
|
|
html += '</div>';
|
2012-04-27 12:19:16 +00:00
|
|
|
//html += '<input type="button" value="Revert file" onclick="revertFile()" />';
|
|
|
|
html += '<input type="button" value="Revert file..." onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" />';
|
2012-04-25 16:37:45 +00:00
|
|
|
html += '<br />';
|
|
|
|
html += '<input id="link" style="display:none; width:90%;" />';
|
|
|
|
|
|
|
|
if (filename) {
|
|
|
|
$('tr').filterAttr('data-file',filename).addClass('mouseOver');
|
|
|
|
$(html).appendTo($('tr').filterAttr('data-file',filename).find('td.filename'));
|
|
|
|
} else {
|
|
|
|
$(html).appendTo($('thead .share'));
|
|
|
|
}
|
2012-04-26 15:48:43 +00:00
|
|
|
|
2012-05-11 12:17:37 +00:00
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
|
|
|
url: OC.linkTo('files_versions', 'ajax/getVersions.php'),
|
|
|
|
dataType: 'json',
|
|
|
|
data: { source: files },
|
|
|
|
async: false,
|
|
|
|
success: function( versions ) {
|
|
|
|
|
|
|
|
//alert("helo "+OC.linkTo('files_versions', 'ajax/getVersions.php'));
|
2012-04-26 15:48:43 +00:00
|
|
|
|
2012-05-11 12:17:37 +00:00
|
|
|
if (versions) {
|
|
|
|
|
|
|
|
$.each( versions, function(index, row ) {
|
|
|
|
|
|
|
|
addVersion( row );
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
2012-04-26 15:48:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-04-26 17:45:17 +00:00
|
|
|
function revertFile() {
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
|
|
|
url: OC.linkTo('files_versions', 'ajax/rollbackVersion.php'),
|
|
|
|
dataType: 'json',
|
|
|
|
data: {path: file, revision: 'revision'},
|
|
|
|
async: false,
|
|
|
|
success: function(versions) {
|
|
|
|
if (versions) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-04-26 15:48:43 +00:00
|
|
|
function addVersion( name ) {
|
|
|
|
|
|
|
|
var version = '<option>'+name+'</option>';
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
// var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"');
|
|
|
|
// var style = ((permissions == 0) ? 'style="display:none;"' : '');
|
|
|
|
// var user = '<li data-uid_shared_with="'+uid_shared_with+'">';
|
|
|
|
// user += '<a href="" class="unshare" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core','actions/delete')+'"/></a>';
|
|
|
|
// user += uid_shared_with;
|
|
|
|
// user += '<input type="checkbox" name="permissions" id="'+uid_shared_with+'" class="permissions" '+checked+' />';
|
|
|
|
// user += '<label for="'+uid_shared_with+'" '+style+'>can edit</label>';
|
|
|
|
// user += '</li>';
|
|
|
|
// }
|
|
|
|
|
|
|
|
$(version).appendTo('#found_versions');
|
|
|
|
}
|
2012-04-25 16:37:45 +00:00
|
|
|
|
|
|
|
$('#dropdown').show('blind');
|
|
|
|
$('#share_with').chosen();
|
|
|
|
|
2012-04-30 17:18:00 +00:00
|
|
|
}
|