summaryrefslogtreecommitdiffstats
path: root/core/js/sharedialogexpirationview.js
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-08-21 19:35:13 +0200
committerVincent Petry <pvince81@owncloud.com>2015-09-16 07:23:26 +0200
commitffd4e0dc5a1977885b639b3ba1bb87a533e6a75a (patch)
tree297e35cc5fa7df4fbf03237ee08a0f96e1d070dc /core/js/sharedialogexpirationview.js
parentf9c232c4ce16b101fce233f1f20e0cafc7e4d1fa (diff)
downloadnextcloud-server-ffd4e0dc5a1977885b639b3ba1bb87a533e6a75a.tar.gz
nextcloud-server-ffd4e0dc5a1977885b639b3ba1bb87a533e6a75a.zip
split off expirationView
Diffstat (limited to 'core/js/sharedialogexpirationview.js')
-rw-r--r--core/js/sharedialogexpirationview.js93
1 files changed, 93 insertions, 0 deletions
diff --git a/core/js/sharedialogexpirationview.js b/core/js/sharedialogexpirationview.js
new file mode 100644
index 00000000000..e752c66bf35
--- /dev/null
+++ b/core/js/sharedialogexpirationview.js
@@ -0,0 +1,93 @@
+/*
+ * 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 =
+ '<input type="checkbox" name="expirationCheckbox" id="expirationCheckbox" value="1" />' +
+ '<label for="expirationCheckbox">{{setExpirationLabel}}</label>' +
+ '<label for="expirationDate" class="hidden-visually">{{expirationLabel}}</label>' +
+ '<input id="expirationDate" type="text" placeholder="{{expirationDatePlaceholder}}" class="hidden" />' +
+ '<em id="defaultExpireMessage">{{defaultExpireMessage}}</em>'
+ ;
+
+ /**
+ * @class OCA.Share.ShareDialogExpirationView
+ * @member {OC.Share.ShareItemModel} model
+ * @member {jQuery} $el
+ * @memberof OCA.Sharing
+ * @classdesc
+ *
+ * Represents the expiration part in the GUI of the share dialogue
+ *
+ */
+ var ShareDialogExpirationView = 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) {
+ if(!_.isUndefined(options.configModel)) {
+ this.configModel = options.configModel;
+ } else {
+ console.warn('missing OC.Share.ShareConfigModel');
+ }
+ },
+
+ render: function() {
+ var defaultExpireMessage = '';
+ if( (this.model.isFolder() || this.model.isFile())
+ && this.configModel.isDefaultExpireDateEnforced()) {
+ defaultExpireMessage = t(
+ 'core',
+ 'The public link will expire no later than {days} days after it is created',
+ {'days': this.configModel.getDefaultExpireDate()}
+ );
+ }
+
+ var expirationTemplate = this.template();
+ this.$el.empty();
+ this.$el.append(expirationTemplate({
+ setExpirationLabel: t('core', 'Set expiration date'),
+ expirationLabel: t('core', 'Expiration'),
+ expirationDatePlaceholder: t('core', 'Expiration date'),
+ defaultExpireMessage: defaultExpireMessage
+ }));
+
+ return this;
+ },
+
+ /**
+ * @returns {Function} from Handlebars
+ * @private
+ */
+ template: function () {
+ if (!this._template) {
+ this._template = Handlebars.compile(TEMPLATE);
+ }
+ return this._template;
+ }
+
+ });
+
+ OC.Share.ShareDialogExpirationView = ShareDialogExpirationView;
+
+})();