summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js')
-rw-r--r--core/js/js.js22
-rw-r--r--core/js/multiselect.js6
-rw-r--r--core/js/share.js107
3 files changed, 90 insertions, 45 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 586d698f3a2..73711b3fbc5 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -666,11 +666,17 @@ $(document).ready(function(){
}
}else if(event.keyCode===27){//esc
OC.search.hide();
+ if (FileList && typeof FileList.unfilter === 'function') { //TODO add hook system
+ FileList.unfilter();
+ }
}else{
var query=$('#searchbox').val();
if(OC.search.lastQuery!==query){
OC.search.lastQuery=query;
OC.search.currentResult=-1;
+ if (FileList && typeof FileList.filter === 'function') { //TODO add hook system
+ FileList.filter(query);
+ }
if(query.length>2){
OC.search(query);
}else{
@@ -808,6 +814,13 @@ function formatDate(date){
return $.datepicker.formatDate(datepickerFormatDate, date)+' '+date.getHours()+':'+((date.getMinutes()<10)?'0':'')+date.getMinutes();
}
+// taken from http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery
+function getURLParameter(name) {
+ return decodeURI(
+ (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, null])[1]
+ );
+}
+
/**
* takes an absolute timestamp and return a string with a human-friendly relative date
* @param int a Unix timestamp
@@ -892,6 +905,15 @@ $.fn.selectRange = function(start, end) {
};
/**
+ * check if an element exists.
+ * allows you to write if ($('#myid').exists()) to increase readability
+ * @link http://stackoverflow.com/questions/31044/is-there-an-exists-function-for-jquery
+ */
+jQuery.fn.exists = function(){
+ return this.length > 0;
+};
+
+/**
* Calls the server periodically every 15 mins to ensure that session doesnt
* time out
*/
diff --git a/core/js/multiselect.js b/core/js/multiselect.js
index bc4223feb64..48d521e1856 100644
--- a/core/js/multiselect.js
+++ b/core/js/multiselect.js
@@ -176,10 +176,10 @@
});
button.parent().data('preventHide',false);
if(settings.createText){
- var li=$('<li class="creator">+ <em>'+settings.createText+'<em></li>');
+ var li=$('<li class="creator">+ '+settings.createText+'</li>');
li.click(function(event){
li.empty();
- var input=$('<input class="new">');
+ var input=$('<input type="text" class="new">');
li.append(input);
input.focus();
input.css('width',button.innerWidth());
@@ -316,4 +316,4 @@
return span;
};
-})( jQuery ); \ No newline at end of file
+})( jQuery );
diff --git a/core/js/share.js b/core/js/share.js
index 4664594e657..a34542a8abd 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -4,57 +4,76 @@ OC.Share={
SHARE_TYPE_LINK:3,
SHARE_TYPE_EMAIL:4,
itemShares:[],
- statuses:[],
+ statuses:{},
droppedDown:false,
+ /**
+ * Loads ALL share statuses from server, stores them in OC.Share.statuses then
+ * calls OC.Share.updateIcons() to update the files "Share" icon to "Shared"
+ * according to their share status and share type.
+ */
loadIcons:function(itemType) {
// Load all share icons
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemsSharedStatuses', itemType: itemType }, function(result) {
if (result && result.status === 'success') {
+ OC.Share.statuses = {};
$.each(result.data, function(item, data) {
OC.Share.statuses[item] = data;
- var hasLink = data['link'];
- // Links override shared in terms of icon display
- if (hasLink) {
- var image = OC.imagePath('core', 'actions/public');
- } else {
- var image = OC.imagePath('core', 'actions/shared');
- }
- if (itemType != 'file' && itemType != 'folder') {
- $('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center');
- } else {
- var file = $('tr[data-id="'+item+'"]');
- if (file.length > 0) {
- var action = $(file).find('.fileactions .action[data-action="Share"]');
- var img = action.find('img').attr('src', image);
- action.addClass('permanent');
- action.html(' '+t('core', 'Shared')).prepend(img);
- } else {
- var dir = $('#dir').val();
- if (dir.length > 1) {
- var last = '';
- var path = dir;
- // Search for possible parent folders that are shared
- while (path != last) {
- if (path == data['path']) {
- var actions = $('.fileactions .action[data-action="Share"]');
- $.each(actions, function(index, action) {
- var img = $(action).find('img');
- if (img.attr('src') != OC.imagePath('core', 'actions/public')) {
- img.attr('src', image);
- $(action).addClass('permanent');
- $(action).html(' '+t('core', 'Shared')).prepend(img);
- }
- });
+ });
+ OC.Share.updateIcons(itemType);
+ }
+ });
+ },
+ /**
+ * Updates the files' "Share" icons according to the known
+ * sharing states stored in OC.Share.statuses.
+ * (not reloaded from server)
+ */
+ updateIcons:function(itemType){
+ var item;
+ for (item in OC.Share.statuses){
+ var data = OC.Share.statuses[item];
+
+ var hasLink = data['link'];
+ // Links override shared in terms of icon display
+ if (hasLink) {
+ var image = OC.imagePath('core', 'actions/public');
+ } else {
+ var image = OC.imagePath('core', 'actions/shared');
+ }
+ if (itemType != 'file' && itemType != 'folder') {
+ $('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center');
+ } else {
+ var file = $('tr[data-id="'+item+'"]');
+ if (file.length > 0) {
+ var action = $(file).find('.fileactions .action[data-action="Share"]');
+ var img = action.find('img').attr('src', image);
+ action.addClass('permanent');
+ action.html(' '+t('core', 'Shared')).prepend(img);
+ } else {
+ var dir = $('#dir').val();
+ if (dir.length > 1) {
+ var last = '';
+ var path = dir;
+ // Search for possible parent folders that are shared
+ while (path != last) {
+ if (path == data['path'] && !data['link']) {
+ var actions = $('.fileactions .action[data-action="Share"]');
+ $.each(actions, function(index, action) {
+ var img = $(action).find('img');
+ if (img.attr('src') != OC.imagePath('core', 'actions/public')) {
+ img.attr('src', image);
+ $(action).addClass('permanent');
+ $(action).html(' '+t('core', 'Shared')).prepend(img);
}
- last = path;
- path = OC.Share.dirname(path);
- }
+ });
}
+ last = path;
+ path = OC.Share.dirname(path);
}
}
- });
+ }
}
- });
+ }
},
updateIcon:function(itemType, itemSource) {
var shares = false;
@@ -214,7 +233,9 @@ OC.Share={
if (data.shares) {
$.each(data.shares, function(index, share) {
if (share.share_type == OC.Share.SHARE_TYPE_LINK) {
- OC.Share.showLink(share.token, share.share_with, itemSource);
+ if ( !('file_target' in share) ) {
+ OC.Share.showLink(share.token, share.share_with, itemSource);
+ }
} else {
if (share.collection) {
OC.Share.addShareWith(share.share_type, share.share_with, share.share_with_displayname, share.permissions, possiblePermissions, share.collection);
@@ -233,6 +254,7 @@ OC.Share={
// } else {
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getShareWith', search: search.term, itemShares: OC.Share.itemShares }, function(result) {
if (result.status == 'success' && result.data.length > 0) {
+ $( "#shareWith" ).autocomplete( "option", "autoFocus", true );
response(result.data);
} else {
// Suggest sharing via email if valid email address
@@ -240,6 +262,7 @@ OC.Share={
// if (pattern.test(search.term)) {
// response([{label: t('core', 'Share via email:')+' '+search.term, value: {shareType: OC.Share.SHARE_TYPE_EMAIL, shareWith: search.term}}]);
// } else {
+ $( "#shareWith" ).autocomplete( "option", "autoFocus", false );
response([t('core', 'No people found')]);
// }
}
@@ -412,7 +435,7 @@ OC.Share={
dateFormat : 'dd-mm-yy'
});
}
-}
+};
$(document).ready(function() {
@@ -501,7 +524,7 @@ $(document).ready(function() {
$(document).on('change', '#dropdown .permissions', function() {
if ($(this).attr('name') == 'edit') {
- var li = $(this).parent().parent()
+ var li = $(this).parent().parent();
var checkboxes = $('.permissions', li);
var checked = $(this).is(':checked');
// Check/uncheck Create, Update, and Delete checkboxes if Edit is checked/unck