diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js
new file mode 100644
index 0000000000..ccd705803f
--- /dev/null
+++ b/core/js/sharedialoglinkshareview.js
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2015
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+(function() {
+ if (!OC.Share) {
+ OC.Share = {};
+ }
+
+ var TEMPLATE =
+ '
'
+ ;
+
+ /**
+ * @class OCA.Share.ShareDialogLinkShareView
+ * @member {OC.Share.ShareItemModel} model
+ * @member {jQuery} $el
+ * @memberof OCA.Sharing
+ * @classdesc
+ *
+ * Represents the GUI of the share dialogue
+ *
+ */
+ var ShareDialogLinkShareView = OC.Backbone.View.extend({
+ /** @type {string} **/
+ id: 'shareDialogLinkShare',
+
+ /** @type {OC.Share.ShareConfigModel} **/
+ configModel: undefined,
+
+ /** @type {Function} **/
+ _template: undefined,
+
+ /** @type {boolean} **/
+ showLink: true,
+
+ initialize: function(options) {
+ var view = this;
+
+ this.model.on('change:permissions', function() {
+ view.render();
+ });
+
+ this.model.on('change:itemType', function() {
+ view.render();
+ });
+
+ this.model.on('change:allowPublicUploadStatus', function() {
+ view.render();
+ });
+
+ if(!_.isUndefined(options.configModel)) {
+ this.configModel = options.configModel;
+ } else {
+ console.warn('missing OC.Share.ShareConfigModel');
+ }
+ },
+
+ render: function() {
+ if( !this.model.hasSharePermission()
+ || !this.showLink
+ || !this.configModel.isShareWithLinkAllowed())
+ {
+ this.$el.empty();
+ return this;
+ }
+
+ var publicUpload =
+ this.model.isFolder()
+ && this.model.hasCreatePermission()
+ && this.configModel.isPublicUploadEnabled();
+
+ var publicUploadChecked = '';
+ if(this.model.isPublicUploadAllowed()) {
+ publicUploadChecked = 'checked="checked"';
+ }
+
+ var linkShareTemplate = this.template();
+ this.$el.empty();
+ this.$el.append(linkShareTemplate({
+ linkShareLabel: t('core', 'Share link'),
+ urlLabel: t('core', 'Link'),
+ enablePasswordLabel: t('core', 'Password protect'),
+ passwordLabel: t('core', 'Password'),
+ passwordPlaceholder: t('core', 'Choose a password for the public link'),
+ publicUpload: publicUpload,
+ publicUploadChecked: publicUploadChecked,
+ publicUploadLabel: t('core', 'Allow editing'),
+ mailPublicNotificationEnabled: this.configModel.isMailPublicNotificationEnabled(),
+ mailPrivatePlaceholder: t('core', 'Email link to person'),
+ mailButtonText: t('core', 'Send')
+ }));
+
+ return this;
+ },
+
+ /**
+ * @returns {Function} from Handlebars
+ * @private
+ */
+ template: function () {
+ if (!this._template) {
+ this._template = Handlebars.compile(TEMPLATE);
+ }
+ return this._template;
+ }
+
+ });
+
+ OC.Share.ShareDialogLinkShareView = ShareDialogLinkShareView;
+
+})();
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js
index 6701777863..cc9590815a 100644
--- a/core/js/sharedialogview.js
+++ b/core/js/sharedialogview.js
@@ -25,7 +25,7 @@
'' +
'{{#if shareAllowed}}' +
- '{{{linkShare}}}' +
+ '' +
'{{else}}' +
'{{{noSharing}}}' +
'{{/if}}' +
@@ -36,35 +36,6 @@
'';
- var TEMPLATE_LINK_SHARE =
- ''
- ;
-
var TEMPLATE_NO_SHARING =
''
;
@@ -105,6 +76,9 @@
/** @type {object} **/
resharerInfoView: undefined,
+ /** @type {object} **/
+ linkShareView: undefined,
+
initialize: function(options) {
var view = this;
this.model.on('change', function() {
@@ -130,6 +104,10 @@
? new OC.Share.ShareDialogResharerInfoView(subViewOptions)
: options.resharerInfoView;
+ this.linkShareView = _.isUndefined(options.linkShareView)
+ ? new OC.Share.ShareDialogLinkShareView(subViewOptions)
+ : options.linkShareView;
+
},
render: function() {
@@ -139,7 +117,6 @@
shareLabel: t('core', 'Share'),
sharePlaceholder: this._renderSharePlaceholderPart(),
remoteShareInfo: this._renderRemoteShareInfoPart(),
- linkShare: this._renderLinkSharePart(),
shareAllowed: this.model.hasSharePermission(),
noSharing: this._renderNoSharing(),
expiration: this._renderExpirationPart()
@@ -148,6 +125,11 @@
this.resharerInfoView.$el = this.$el.find('.resharerInfo');
this.resharerInfoView.render();
+ if(this.model.hasSharePermission()) {
+ this.linkShareView.$el = this.$el.find('.linkShare');
+ this.linkShareView.render();
+ }
+
this.$el.find('.hasTooltip').tooltip();
if(this.configModel.areAvatarsEnabled()) {
this.$el.find('.avatar').avatar(this.model.getReshareOwner, 32);
@@ -164,6 +146,7 @@
*/
setShowLink: function(showLink) {
this._showLink = (typeof showLink === 'boolean') ? showLink : true;
+ this.linkShareView.showLink = this._showLink;
},
_renderRemoteShareInfoPart: function() {
@@ -179,41 +162,6 @@
return remoteShareInfo;
},
- _renderLinkSharePart: function() {
- var linkShare = '';
- if( this.model.hasSharePermission()
- && this._showLink
- && this.configModel.isShareWithLinkAllowed())
- {
- var linkShareTemplate = this._getLinkShareTemplate();
-
- var publicUpload =
- this.model.isFolder()
- && this.model.hasCreatePermission()
- && this.configModel.isPublicUploadEnabled();
-
- var publicUploadChecked = '';
- if(this.model.isPublicUploadAllowed) {
- publicUploadChecked = 'checked="checked"';
- }
-
- linkShare = linkShareTemplate({
- linkShareLabel: t('core', 'Share link'),
- urlLabel: t('core', 'Link'),
- enablePasswordLabel: t('core', 'Password protect'),
- passwordLabel: t('core', 'Password'),
- passwordPlaceholder: t('core', 'Choose a password for the public link'),
- publicUpload: publicUpload,
- publicUploadChecked: publicUploadChecked,
- publicUploadLabel: t('core', 'Allow editing'),
- mailPublicNotificationEnabled: this.configModel.isMailPublicNotificationEnabled(),
- mailPrivatePlaceholder: t('core', 'Email link to person'),
- mailButtonText: t('core', 'Send')
- });
- }
- return linkShare;
- },
-
_renderSharePlaceholderPart: function () {
var sharePlaceholder = t('core', 'Share with users or groups …');
if (this.configModel.isRemoteShareAllowed()) {
@@ -278,20 +226,6 @@
*/
_getRemoteShareInfoTemplate: function() {
return this._getTemplate('remoteShareInfo', TEMPLATE_REMOTE_SHARE_INFO);
- },
-
- /**
- * returns the info template for link sharing
- *
- * @returns {Function}
- * @private
- */
- _getLinkShareTemplate: function() {
- return this._getTemplate('linkShare', TEMPLATE_LINK_SHARE);
- },
-
- _getReshareTemplate: function() {
- return this._getTemplate('reshare', TEMPLATE_RESHARER_INFO);
}
});
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 10d0480ab8..ea4f01c0a9 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -86,6 +86,7 @@ class Share extends Constants {
\OC_Util::addScript('core', 'shareconfigmodel');
\OC_Util::addScript('core', 'shareitemmodel');
\OC_Util::addScript('core', 'sharedialogresharerinfoview');
+ \OC_Util::addScript('core', 'sharedialoglinkshareview');
\OC_Util::addScript('core', 'sharedialogview');
\OC_Util::addScript('core', 'share');
\OC_Util::addStyle('core', 'share');