diff options
author | Sam Tuke <sam@donttravelempty.com> | 2012-04-26 16:48:43 +0100 |
---|---|---|
committer | Sam Tuke <sam@donttravelempty.com> | 2012-04-26 16:48:43 +0100 |
commit | c693ee2adb1b8b251d7905791eeca0946c31c68b (patch) | |
tree | 10adcf853dff62b6a842728ce023b49c54eba9e2 /apps/files_versions/js | |
parent | 6312067ab58b3d7121ed8e3211030f77eda699bd (diff) | |
download | nextcloud-server-c693ee2adb1b8b251d7905791eeca0946c31c68b.tar.gz nextcloud-server-c693ee2adb1b8b251d7905791eeca0946c31c68b.zip |
added available version names to files dropdown menu via new ajax script
Diffstat (limited to 'apps/files_versions/js')
-rw-r--r-- | apps/files_versions/js/versions.js | 89 |
1 files changed, 61 insertions, 28 deletions
diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index 325ef823a9c..5018b75f154 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -9,9 +9,28 @@ $(document).ready(function(){ createVersionsDropdown(filename, file) - //window.location='../apps/files_versions/history.php?path='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); - - + $.ajax({ + type: 'GET', + url: OC.linkTo('files_versions', 'ajax/getVersions.php'), + dataType: 'json', + data: {source: file}, + async: false, + success: function(versions) { + if (versions) { + + // icon = OC.imagePath('core', 'actions/shared'); + // $.each(users, function(index, row) { + // if (row.uid_shared_with == 'public') { + // icon = OC.imagePath('core', 'actions/public'); + // } + // }); + // } else { + // icon = OC.imagePath('core', 'actions/share'); + } + shared_status[file]= { timestamp: new Date().getTime(), icon: icon }; + } + }); + }); }); @@ -21,17 +40,14 @@ function createVersionsDropdown(filename, files) { //alert( historyUrl ); var html = '<div id="dropdown" class="drop" data-file="'+files+'">'; html += '<div id="private">'; - html += '<select data-placeholder="File Version" id="share_with" class="chzen-select">'; - html += '<option value=""></option>'; + html += '<select data-placeholder="File Version" id="found_versions" class="chzen-select">'; + html += '<option value="">Select version</option>'; html += '</select>'; - html += '<ul id="shared_list"></ul>'; html += '</div>'; - html += '<div id="public">'; html += '<input type="button" name="makelink" id="makelink" value="Revert file" />'; html += '<input type="button" onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" value="More..." />'; html += '<br />'; html += '<input id="link" style="display:none; width:90%;" />'; - html += '</div>'; if (filename) { $('tr').filterAttr('data-file',filename).addClass('mouseOver'); @@ -39,27 +55,44 @@ function createVersionsDropdown(filename, files) { } else { $(html).appendTo($('thead .share')); } -// $.getJSON(OC.linkTo('files_sharing', 'ajax/userautocomplete.php'), function(users) { -// if (users) { -// $.each(users, function(index, row) { -// $(row).appendTo('#share_with'); -// }); -// $('#share_with').trigger('liszt:updated'); -// } -// }); -// $.getJSON(OC.linkTo('files_sharing', 'ajax/getitem.php'), { source: files }, function(users) { -// if (users) { -// $.each(users, function(index, row) { -// if (row.uid_shared_with == 'public') { -// showPublicLink(row.token, '/'+filename); -// } else if (isNaN(index)) { -// addUser(row.uid_shared_with, row.permissions, index.substr(0, index.lastIndexOf('-'))); -// } else { -// addUser(row.uid_shared_with, row.permissions, false); -// } -// }); -// } + +// $.getJSON(OC.linkTo('files_sharing', 'ajax/userautocomplete.php'), function(users) { +// if (users) { +// $.each(users, function(index, row) { +// $(row).appendTo('#share_with'); // }); +// $('#share_with').trigger('liszt:updated'); +// } +// }); + $.getJSON(OC.linkTo('files_versions', 'ajax/getVersions.php'), { source: files }, function(versions) { + if (versions) { + + $.each( versions, function(index, row ) { + + addVersion( row ); + }); + + } + + }); + + 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'); + } $('#dropdown').show('blind'); $('#share_with').chosen(); |