summaryrefslogtreecommitdiffstats
path: root/core/js/sharedialoglinkshareview.js
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-08-21 15:40:50 +0200
committerVincent Petry <pvince81@owncloud.com>2015-09-16 07:23:26 +0200
commitf9c232c4ce16b101fce233f1f20e0cafc7e4d1fa (patch)
tree9924799f1fcc7bef0683ed19211aa9d3f5a17085 /core/js/sharedialoglinkshareview.js
parent277b786886de7979fea308595e4cf658e85aacf7 (diff)
downloadnextcloud-server-f9c232c4ce16b101fce233f1f20e0cafc7e4d1fa.tar.gz
nextcloud-server-f9c232c4ce16b101fce233f1f20e0cafc7e4d1fa.zip
split off linkShareView
Diffstat (limited to 'core/js/sharedialoglinkshareview.js')
-rw-r--r--core/js/sharedialoglinkshareview.js143
1 files changed, 143 insertions, 0 deletions
diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js
new file mode 100644
index 00000000000..ccd705803f6
--- /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 =
+ '<div id="link" class="linkShare">' +
+ ' <span class="icon-loading-small hidden"></span>' +
+ ' <input type="checkbox" name="linkCheckbox" id="linkCheckbox" value="1" /><label for="linkCheckbox">{{linkShareLabel}}</label>' +
+ ' <br />' +
+ ' <label for="linkText" class="hidden-visually">{{urlLabel}}</label>' +
+ ' <input id="linkText" type="text" readonly="readonly" />' +
+ ' <input type="checkbox" name="showPassword" id="showPassword" value="1" class="hidden" /><label for="showPassword" class="hidden-visually">{{enablePasswordLabel}}</label>' +
+ ' <div id="linkPass">' +
+ ' <label for="linkPassText" class="hidden-visually">{{passwordLabel}}</label>' +
+ ' <input id="linkPassText" type="password" placeholder="passwordPlaceholder" />' +
+ ' <span class="icon-loading-small hidden"></span>' +
+ ' </div>' +
+ ' {{#if publicUpload}}' +
+ ' <div id="allowPublicUploadWrapper" class="hidden">' +
+ ' <span class="icon-loading-small hidden"></span>' +
+ ' <input type="checkbox" value="1" name="allowPublicUpload" id="sharingDialogAllowPublicUpload" {{{publicUploadChecked}}} />' +
+ ' <label for="sharingDialogAllowPublicUpload">{{publicUploadLabel}}</label>' +
+ ' </div>' +
+ ' {{/if}}' +
+ ' {{#if mailPublicNotificationEnabled}}' +
+ ' <form id="emailPrivateLink">' +
+ ' <input id="email" class="hidden" value="" placeholder="{{mailPrivatePlaceholder}}" type="text" />' +
+ ' <input id="emailButton" class="hidden" type="submit" value="{{mailButtonText}}" />' +
+ ' </form>' +
+ ' {{/if}}' +
+ '</div>'
+ ;
+
+ /**
+ * @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;
+
+})();