@ -68,6 +68,9 @@
/** @type {object} **/
_lastSuggestions : undefined ,
/** @type {int} **/
_pendingOperationsCount : 0 ,
events : {
'focus .shareWithField' : 'onShareWithFieldFocus' ,
'input .shareWithField' : 'onShareWithFieldChanged' ,
@ -339,6 +342,7 @@
$loading . removeClass ( 'hidden' ) ;
$loading . addClass ( 'inlineblock' ) ;
$confirm . addClass ( 'hidden' ) ;
this . _pendingOperationsCount ++ ;
$shareWithField . removeClass ( 'error' )
. tooltip ( 'hide' ) ;
@ -349,9 +353,12 @@
perPage ,
view . model
) . done ( function ( suggestions ) {
$loading . addClass ( 'hidden' ) ;
$loading . removeClass ( 'inlineblock' ) ;
$confirm . removeClass ( 'hidden' ) ;
view . _pendingOperationsCount -- ;
if ( view . _pendingOperationsCount === 0 ) {
$loading . addClass ( 'hidden' ) ;
$loading . removeClass ( 'inlineblock' ) ;
$confirm . removeClass ( 'hidden' ) ;
}
if ( suggestions . length > 0 ) {
$shareWithField
@ -386,9 +393,12 @@
response ( ) ;
}
} ) . fail ( function ( message ) {
$loading . addClass ( 'hidden' ) ;
$loading . removeClass ( 'inlineblock' ) ;
$confirm . removeClass ( 'hidden' ) ;
view . _pendingOperationsCount -- ;
if ( view . _pendingOperationsCount === 0 ) {
$loading . addClass ( 'hidden' ) ;
$loading . removeClass ( 'inlineblock' ) ;
$confirm . removeClass ( 'hidden' ) ;
}
if ( message ) {
OC . Notification . showTemporary ( t ( 'core' , 'An error occurred ("{message}"). Please try again' , { message : message } ) ) ;
@ -431,6 +441,8 @@
} ,
_onSelectRecipient : function ( e , s ) {
var self = this ;
e . preventDefault ( ) ;
// Ensure that the keydown handler for the input field is not
// called; otherwise it would try to add the recipient again, which
@ -438,11 +450,14 @@
e . stopImmediatePropagation ( ) ;
$ ( e . target ) . attr ( 'disabled' , true )
. val ( s . item . label ) ;
var $loading = this . $el . find ( '.shareWithLoading' ) ;
$loading . removeClass ( 'hidden' )
. addClass ( 'inlineblock' ) ;
var $confirm = this . $el . find ( '.shareWithConfirm' ) ;
$loading . removeClass ( 'hidden' ) ;
$loading . addClass ( 'inlineblock' ) ;
$confirm . addClass ( 'hidden' ) ;
this . _pendingOperationsCount ++ ;
this . model . addShare ( s . item . value , { success : function ( ) {
// Adding a share changes the suggestions.
@ -450,16 +465,24 @@
$ ( e . target ) . val ( '' )
. attr ( 'disabled' , false ) ;
$loading . addClass ( 'hidden' )
. removeClass ( 'inlineblock' ) ;
$confirm . removeClass ( 'hidden' ) ;
self . _pendingOperationsCount -- ;
if ( self . _pendingOperationsCount === 0 ) {
$loading . addClass ( 'hidden' ) ;
$loading . removeClass ( 'inlineblock' ) ;
$confirm . removeClass ( 'hidden' ) ;
}
} , error : function ( obj , msg ) {
OC . Notification . showTemporary ( msg ) ;
$ ( e . target ) . attr ( 'disabled' , false )
. autocomplete ( 'search' , $ ( e . target ) . val ( ) ) ;
$loading . addClass ( 'hidden' )
. removeClass ( 'inlineblock' ) ;
$confirm . removeClass ( 'hidden' ) ;
self . _pendingOperationsCount -- ;
if ( self . _pendingOperationsCount === 0 ) {
$loading . addClass ( 'hidden' ) ;
$loading . removeClass ( 'inlineblock' ) ;
$confirm . removeClass ( 'hidden' ) ;
}
} } ) ;
} ,
@ -472,6 +495,7 @@
$loading . removeClass ( 'hidden' ) ;
$loading . addClass ( 'inlineblock' ) ;
$confirm . addClass ( 'hidden' ) ;
this . _pendingOperationsCount ++ ;
$shareWithField . prop ( 'disabled' , true ) ;
@ -485,9 +509,12 @@
$shareWithField . autocomplete ( 'disable' ) ;
var restoreUI = function ( ) {
$loading . addClass ( 'hidden' ) ;
$loading . removeClass ( 'inlineblock' ) ;
$confirm . removeClass ( 'hidden' ) ;
self . _pendingOperationsCount -- ;
if ( self . _pendingOperationsCount === 0 ) {
$loading . addClass ( 'hidden' ) ;
$loading . removeClass ( 'inlineblock' ) ;
$confirm . removeClass ( 'hidden' ) ;
}
$shareWithField . prop ( 'disabled' , false ) ;
$shareWithField . focus ( ) ;