summaryrefslogtreecommitdiffstats
path: root/core/js/sharedialoglinkshareview.js
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2017-03-03 13:27:06 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2017-03-03 13:27:06 +0100
commitfd71b8bde8fc003b0f160075825402c4fab1d54c (patch)
tree20e84d51af59e8bf6e4d66b5910a3781ee38072a /core/js/sharedialoglinkshareview.js
parenta85327fe87ce471b04a14839e7b7b7dae4298753 (diff)
downloadnextcloud-server-fd71b8bde8fc003b0f160075825402c4fab1d54c.tar.gz
nextcloud-server-fd71b8bde8fc003b0f160075825402c4fab1d54c.zip
Move social buttons to menu
* If there are social sharing buttons move them and the copy action to a menu * If there are no social sharing buttons just leave the copy action where it is directly Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'core/js/sharedialoglinkshareview.js')
-rw-r--r--core/js/sharedialoglinkshareview.js103
1 files changed, 95 insertions, 8 deletions
diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js
index 84a3d18942f..014819d5103 100644
--- a/core/js/sharedialoglinkshareview.js
+++ b/core/js/sharedialoglinkshareview.js
@@ -27,7 +27,12 @@
'<div class="oneline">' +
'<label for="linkText-{{cid}}" class="hidden-visually">{{urlLabel}}</label>' +
'<input id="linkText-{{cid}}" class="linkText {{#unless isLinkShare}}hidden{{/unless}}" type="text" readonly="readonly" value="{{shareLinkURL}}" />' +
- '<a class="{{#unless isLinkShare}}hidden-visually{{/unless}} clipboardButton icon icon-clippy" data-clipboard-target="#linkText-{{cid}}"></a>' +
+ '{{#if singleAction}}' +
+ '<a class="{{#unless isLinkShare}}hidden-visually{{/unless}} clipboardButton icon icon-clippy" data-clipboard-target="#linkText-{{cid}}"></a>' +
+ '{{else}}' +
+ '<a href="#"><span class="linkMore icon icon-more"></span></a>' +
+ '{{{popoverMenu}}}' +
+ '{{/if}}' +
'</div>' +
' {{#if publicUpload}}' +
'<div id="allowPublicUploadWrapper">' +
@@ -64,6 +69,27 @@
'{{#if noSharingPlaceholder}}<input id="shareWith-{{cid}}" class="shareWithField" type="text" placeholder="{{noSharingPlaceholder}}" disabled="disabled"/>{{/if}}' +
'{{/if}}'
;
+ var TEMPLATE_POPOVER_MENU =
+ '<div class="popovermenu bubble hidden menu">' +
+ '<ul>' +
+ '<li>' +
+ '<span class="shareOption menuitem">' +
+ '<button class="icon clipboardButton icon-clippy"' +
+ 'data-clipboard-target="#linkText-{{cid}}">{{copyLabel}}' +
+ '</button>' +
+ '</span>' +
+ '</li>' +
+ '{{#each social}}' +
+ '<li>' +
+ '<span class="shareOption menuitem">' +
+ '<button class="icon {{iconClass}} pop-up"' +
+ 'data-url="{{url}}">{{label}}' +
+ '</button>' +
+ '</span>' +
+ '</li>' +
+ '{{/each}}' +
+ '</ul>' +
+ '</div>';
/**
* @class OCA.Share.ShareDialogLinkShareView
@@ -85,6 +111,9 @@
/** @type {Function} **/
_template: undefined,
+ /** @type {Function} **/
+ _popoverMenuTemplate: undefined,
+
/** @type {boolean} **/
showLink: true,
@@ -96,7 +125,9 @@
'change .publicUploadCheckbox': 'onAllowPublicUploadChange',
'change .publicEditingCheckbox': 'onAllowPublicEditingChange',
'change .hideFileListCheckbox': 'onHideFileListChange',
- 'click .showPasswordCheckbox': 'onShowPasswordClick'
+ 'click .showPasswordCheckbox': 'onShowPasswordClick',
+ 'click .icon-more': 'onToggleMenu',
+ 'click .pop-up': 'onPopUpClick'
},
initialize: function(options) {
@@ -150,8 +181,7 @@
.tooltip('show');
_.delay(function() {
$input.tooltip('hide')
- .attr('data-original-title', t('core', 'Copy'))
- .tooltip('fixTitle');
+ .tooltip("destroy");
}, 3000);
});
clipboard.on('error', function (e) {
@@ -173,7 +203,7 @@
_.delay(function () {
$input.tooltip('hide')
.attr('data-original-title', t('core', 'Copy'))
- .tooltip('fixTitle');
+ .tooltip("destroy");
}, 3000);
});
@@ -354,6 +384,26 @@
&& isLinkShare
&& this.model.updatePermissionPossible();
+ var link = this.model.get('linkShare').link;
+ var social = [];
+ OC.Share.Social.Collection.each(function(model) {
+ var url = model.get('url');
+ url = url.replace('{{reference}}', link);
+
+ social.push({
+ url: url,
+ label: t('core', 'Share to {name}', {name: model.get('name')}),
+ name: model.get('name'),
+ iconClass: model.get('iconClass')
+ });
+ });
+
+ var popover = this.popoverMenuTemplate({
+ cid: this.cid,
+ copyLabel: t('core', 'Copy'),
+ social: social
+ });
+
this.$el.html(linkShareTemplate({
cid: this.cid,
shareAllowed: true,
@@ -376,16 +426,27 @@
publicEditingLabel: t('core', 'Allow editing'),
hideFileListLabel: t('core', 'File drop (upload only)'),
mailPrivatePlaceholder: t('core', 'Email link to person'),
- mailButtonText: t('core', 'Send')
+ mailButtonText: t('core', 'Send'),
+ singleAction: OC.Share.Social.Collection.size() == 0,
+ popoverMenu: popover
}));
- this.$el.find('.clipboardButton').tooltip({placement: 'bottom', title: t('core', 'Copy'), trigger: 'hover'});
-
this.delegateEvents();
return this;
},
+ onToggleMenu: function(event) {
+ event.preventDefault();
+ event.stopPropagation();
+ var $element = $(event.target);
+ var $li = $element.closest('.oneline');
+ var $menu = $li.find('.popovermenu');
+
+ OC.showMenu(null, $menu);
+ this._menuOpen = $li.data('share-id');
+ },
+
/**
* @returns {Function} from Handlebars
* @private
@@ -395,6 +456,32 @@
this._template = Handlebars.compile(TEMPLATE);
}
return this._template;
+ },
+
+ /**
+ * renders the popover template and returns the resulting HTML
+ *
+ * @param {Object} data
+ * @returns {string}
+ */
+ popoverMenuTemplate: function(data) {
+ if(!this._popoverMenuTemplate) {
+ this._popoverMenuTemplate = Handlebars.compile(TEMPLATE_POPOVER_MENU);
+ }
+ return this._popoverMenuTemplate(data);
+ },
+
+ onPopUpClick: function(event) {
+ var url = $(event.target).data('url');
+ $(event.target).tooltip('hide');
+ if (url) {
+ var width = 600;
+ var height = 400;
+ var left = (screen.width/2)-(width/2);
+ var top = (screen.height/2)-(height/2);
+
+ window.open(url, 'name', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left);
+ }
}
});