aboutsummaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js')
-rw-r--r--core/js/jquery.ocdialog.js6
-rw-r--r--core/js/maintenance-check.js5
-rw-r--r--core/js/oc-dialogs.js3
-rw-r--r--core/js/setup.js2
-rw-r--r--core/js/share.js41
-rw-r--r--core/js/tests/specs/shareSpec.js133
6 files changed, 174 insertions, 16 deletions
diff --git a/core/js/jquery.ocdialog.js b/core/js/jquery.ocdialog.js
index e48e3e8df6a..ea034f0aff7 100644
--- a/core/js/jquery.ocdialog.js
+++ b/core/js/jquery.ocdialog.js
@@ -78,8 +78,12 @@
var pos = self.parent.position();
self.$dialog.css({
left: pos.left + ($(window).innerWidth() - self.$dialog.outerWidth())/2,
- top: pos.top + ($(window).innerHeight() - self.$dialog.outerHeight())/2
+ top: pos.top + ($(window).innerHeight() - self.$dialog.outerHeight())/2,
+ width: Math.min(self.options.width, $(window).innerWidth() - 20 ),
+ height: Math.min(self.options.height, $(window).innerHeight() - 20)
});
+ // set sizes of content
+ self._setSizes();
});
this._setOptions(this.options);
diff --git a/core/js/maintenance-check.js b/core/js/maintenance-check.js
index 061a434214b..663f7fb5f00 100644
--- a/core/js/maintenance-check.js
+++ b/core/js/maintenance-check.js
@@ -3,10 +3,7 @@ window.setInterval(checkStatus, 20000);
function checkStatus() {
var request = new XMLHttpRequest();
- var ocroot = location.pathname.substr(
- 0, location.pathname.indexOf('index.php')
- );
- request.open("GET", ocroot+'status.php', true);
+ request.open("GET", OC.webroot+'/status.php', true);
request.onreadystatechange = function() {
if (request.readyState === 4) {
var response = request.responseText;
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index afd7debb695..0692a9df5ca 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -207,7 +207,8 @@ var OCdialogs = {
self.$filePicker.ocdialog({
closeOnEscape: true,
- width: (4/5)*$(document).width(),
+ // max-width of 600
+ width: Math.min((4/5)*$(document).width(), 600),
height: 420,
modal: modal,
buttons: buttonlist,
diff --git a/core/js/setup.js b/core/js/setup.js
index 95237165b40..fd2547867ff 100644
--- a/core/js/setup.js
+++ b/core/js/setup.js
@@ -9,6 +9,8 @@ $(document).ready(function() {
};
$('#selectDbType').buttonset();
+ // change links inside an info box back to their default appearance
+ $('#selectDbType p.info a').button('destroy');
if($('#hasSQLite').val()){
$('#use_other_db').hide();
diff --git a/core/js/share.js b/core/js/share.js
index 6723b829ca5..121ee97d17f 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -839,6 +839,24 @@ OC.Share={
$('#defaultExpireMessage').slideDown(OC.menuSpeed);
}
$.datepicker.setDefaults(datePickerOptions);
+ },
+ /**
+ * Get the default Expire date
+ *
+ * @return {String} The expire date
+ */
+ getDefaultExpirationDate:function() {
+ var expireDateString = '';
+ if (oc_appconfig.core.defaultExpireDateEnabled) {
+ var date = new Date().getTime();
+ var expireAfterMs = oc_appconfig.core.defaultExpireDate * 24 * 60 * 60 * 1000;
+ var expireDate = new Date(date + expireAfterMs);
+ var month = expireDate.getMonth() + 1;
+ var year = expireDate.getFullYear();
+ var day = expireDate.getDate();
+ expireDateString = year + "-" + month + '-' + day + ' 00:00:00';
+ }
+ return expireDateString;
}
};
@@ -986,18 +1004,15 @@ $(document).ready(function() {
$('#linkPassText').attr('placeholder', t('core', 'Choose a password for the public link'));
// Reset link
$('#linkText').val('');
+ $('#showPassword').prop('checked', false);
+ $('#linkPass').hide();
+ $('#sharingDialogAllowPublicUpload').prop('checked', false);
+ $('#expirationCheckbox').prop('checked', false);
+ $('#expirationDate').hide();
var expireDateString = '';
- if (oc_appconfig.core.defaultExpireDateEnabled) {
- var date = new Date().getTime();
- var expireAfterMs = oc_appconfig.core.defaultExpireDate * 24 * 60 * 60 * 1000;
- var expireDate = new Date(date + expireAfterMs);
- var month = expireDate.getMonth() + 1;
- var year = expireDate.getFullYear();
- var day = expireDate.getDate();
- expireDateString = year + "-" + month + '-' + day + ' 00:00:00';
- }
// Create a link
if (oc_appconfig.core.enforcePasswordForPublicLink === false) {
+ expireDateString = OC.Share.getDefaultExpirationDate();
$loading.removeClass('hidden');
$button.addClass('hidden');
$button.prop('disabled', true);
@@ -1135,8 +1150,10 @@ $(document).ready(function() {
permissions = OC.PERMISSION_READ;
}
+ var expireDateString = OC.Share.getDefaultExpirationDate();
+
$loading.removeClass('hidden');
- OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, itemSourceName, function(data) {
+ OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, itemSourceName, expireDateString, function(data) {
$loading.addClass('hidden');
linkPassText.val('');
linkPassText.attr('placeholder', t('core', 'Password protected'));
@@ -1145,8 +1162,12 @@ $(document).ready(function() {
OC.Share.showLink(data.token, "password set", itemSource);
OC.Share.updateIcon(itemType, itemSource);
}
+ $('#dropdown').trigger(new $.Event('sharesChanged', {shares: OC.Share.currentShares}));
});
+ if (expireDateString !== '') {
+ OC.Share.showExpirationDate(expireDateString);
+ }
}
});
diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js
index 3e9a0b247d7..c075351b9f5 100644
--- a/core/js/tests/specs/shareSpec.js
+++ b/core/js/tests/specs/shareSpec.js
@@ -228,6 +228,112 @@ describe('OC.Share tests', function() {
oc_appconfig.core.enforcePasswordForPublicLink = old;
});
+ it('reset password on toggle of share', function() {
+ $('#allowShareWithLink').val('yes');
+ OC.Share.showDropDown(
+ 'file',
+ 123,
+ $container,
+ true,
+ 31,
+ 'shared_file_name.txt'
+ );
+ $('#dropdown [name=linkCheckbox]').click();
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz'}, status: 'success'})
+ );
+
+ //Password protection should be unchecked and password field not visible
+ expect($('#dropdown [name=showPassword]').prop('checked')).toEqual(false);
+ expect($('#dropdown #linkPass').is(":visible")).toEqual(false);
+
+ // Toggle and set password
+ $('#dropdown [name=showPassword]').click();
+ $('#dropdown #linkPassText').val('foo');
+ $('#dropdown #linkPassText').trigger(new $.Event('keyup', {keyCode: 13}));
+ fakeServer.requests[1].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz2'}, status: 'success'})
+ );
+
+ // Unshare
+ $('#dropdown [name=linkCheckbox]').click();
+ fakeServer.requests[2].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({status: 'success'})
+ );
+
+ // Toggle share again
+ $('#dropdown [name=linkCheckbox]').click();
+ fakeServer.requests[3].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz3'}, status: 'success'})
+ );
+
+
+ // Password checkbox should be unchecked
+ expect($('#dropdown [name=showPassword]').prop('checked')).toEqual(false);
+ expect($('#dropdown #linkPass').is(":visible")).toEqual(false);
+ });
+ it('reset expiration on toggle of share', function() {
+ $('#allowShareWithLink').val('yes');
+ OC.Share.showDropDown(
+ 'file',
+ 123,
+ $container,
+ true,
+ 31,
+ 'shared_file_name.txt'
+ );
+ $('#dropdown [name=linkCheckbox]').click();
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz'}, status: 'success'})
+ );
+
+ //Expiration should be unchecked and expiration field not visible
+ expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(false);
+ expect($('#dropdown #expirationDate').is(":visible")).toEqual(false);
+
+ // Toggle and set password
+ $('#dropdown [name=expirationCheckbox]').click();
+ d = new Date();
+ d.setDate(d.getDate() + 1);
+ date=d.getDate() + '-' + (d.getMonth()+1) + '-' + d.getFullYear();
+ $('#dropdown #expirationDate').val(date);
+ $('#dropdown #expirationDate').change();
+ fakeServer.requests[1].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz2'}, status: 'success'})
+ );
+
+ // Unshare
+ $('#dropdown [name=linkCheckbox]').click();
+ fakeServer.requests[2].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({status: 'success'})
+ );
+
+ // Toggle share again
+ $('#dropdown [name=linkCheckbox]').click();
+ fakeServer.requests[3].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz3'}, status: 'success'})
+ );
+
+ // Recheck expire visibility
+ expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(false);
+ expect($('#dropdown #expirationDate').is(":visible")).toEqual(false);
+ });
it('shows populated link share when a link share exists', function() {
loadItemStub.returns({
reshare: [],
@@ -419,6 +525,7 @@ describe('OC.Share tests', function() {
};
loadItemStub.returns(shareData);
oc_appconfig.core.defaultExpireDate = 7;
+ oc_appconfig.core.enforcePasswordForPublicLink = false;
oc_appconfig.core.defaultExpireDateEnabled = false;
oc_appconfig.core.defaultExpireDateEnforced = false;
});
@@ -474,6 +581,32 @@ describe('OC.Share tests', function() {
$('#dropdown [name=expirationCheckbox]').click();
expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(true);
});
+ it('enforces default date when enforced date setting is enabled and password is enforced', function() {
+ /* jshint camelcase:false */
+ oc_appconfig.core.enforcePasswordForPublicLink = true;
+ oc_appconfig.core.defaultExpireDateEnabled = true;
+ oc_appconfig.core.defaultExpireDateEnforced = true;
+ showDropDown();
+ $('#dropdown [name=linkCheckbox]').click();
+
+ //Enter password
+ $('#dropdown #linkPassText').val('foo');
+ $('#dropdown #linkPassText').trigger(new $.Event('keyup', {keyCode: 13}));
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({data: {token: 'xyz'}, status: 'success'})
+ );
+
+ expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(true);
+ // TODO: those zeros must go...
+ expect($('#dropdown #expirationDate').val()).toEqual('2014-1-27 00:00:00');
+
+ // disabling is not allowed
+ expect($('#dropdown [name=expirationCheckbox]').prop('disabled')).toEqual(true);
+ $('#dropdown [name=expirationCheckbox]').click();
+ expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(true);
+ });
it('displayes email form when sending emails is enabled', function() {
$('input[name=mailPublicNotificationEnabled]').val('yes');
showDropDown();