Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Paroz <oparoz@users.noreply.github.com>2017-05-16 22:42:47 +0300
committerGitHub <noreply@github.com>2017-05-16 22:42:47 +0300
commit669c17b4e3a9ffbb2901d78378db3f7702a0cc06 (patch)
treec036fb5ac5916a00d7dc617722b521508b17b24c
parenta20b7345e8f5f93f16f634dfda6ecfec9d270c80 (diff)
parent5c9830242d2c42c039202e1f482b36f16112a625 (diff)
Merge pull request #254 from nextcloud/socialsharingv12.0.0beta4
Add social sharing to share dialog
-rw-r--r--css/share.css38
-rw-r--r--css/slideshow.css1
-rw-r--r--js/vendor/nextcloud/share.js67
-rw-r--r--lib/AppInfo/Application.php3
-rw-r--r--lib/Controller/PageController.php10
-rw-r--r--tests/unit/Controller/PageControllerTest.php11
6 files changed, 124 insertions, 6 deletions
diff --git a/css/share.css b/css/share.css
index 56e5b845..7acb5974 100644
--- a/css/share.css
+++ b/css/share.css
@@ -39,7 +39,9 @@
}
#dropdown .shareWithRemoteInfo {
- padding: 11px 20px;
+ padding: 11px;
+ right: 17px;
+ top: 18px;
}
#dropdown .avatar {
@@ -113,8 +115,12 @@ a.unshare {
}
#dropdown input[type="text"],#dropdown input[type="password"] {
- width: 86%;
- margin-left: 7px;
+ width: 100%;
+ padding-right: 44px;
+ text-overflow: ellipsis;
+}
+#dropdown input#linkText.no-menu-item {
+ padding-right: 6px;
}
#dropdown form {
@@ -127,6 +133,32 @@ a.unshare {
display:none;
}
+#linkText-container {
+ position: relative;
+}
+
+#linkTextMore,
+.shareWithRemoteInfo {
+ position: absolute;
+ right: 0;
+ top: 0;
+ margin: 0 !important;
+ background-color: transparent;
+ border: none;
+}
+
+#slideshow #linkTextMore {
+ padding: 17px;
+}
+
+#slideshow #linkSocial {
+ right: -5px;
+}
+
+#linkSocial .icon {
+ background-size: 16px;
+}
+
#link #showPassword img {
padding-left:5px;
width:12px;
diff --git a/css/slideshow.css b/css/slideshow.css
index fc31c8f7..dda5d0ec 100644
--- a/css/slideshow.css
+++ b/css/slideshow.css
@@ -143,6 +143,7 @@
width: 24px;
height: 24px;
padding-top: 8px;
+ background: transparent;
}
#slideshow > .name {
diff --git a/js/vendor/nextcloud/share.js b/js/vendor/nextcloud/share.js
index ebe565f8..4d397bb4 100644
--- a/js/vendor/nextcloud/share.js
+++ b/js/vendor/nextcloud/share.js
@@ -229,7 +229,12 @@
html += '<label for="linkText" class="hidden-visually">' + t('core', 'Link') +
'</label>';
+ html += '<div id="linkText-container">';
html += '<input id="linkText" type="text" readonly="readonly" />';
+ html += '<a id="linkTextMore" class="button icon-more" href="#"></a>';
+ html += '<div id="linkSocial" class="popovermenu bubble menu hidden"></div>';
+ html += '</div>';
+
html +=
'<input type="checkbox" class="checkbox checkbox--right" ' +
'name="showPassword" id="showPassword" value="1" />' +
@@ -594,6 +599,31 @@
$('#emailPrivateLink #email').show();
$('#emailPrivateLink #emailButton').show();
$('#allowPublicUploadWrapper').show();
+ $('#linkTextMore').show();
+ $('#linkSocial').hide();
+ $('#linkSocial').html('');
+
+ var ul = $('<ul/>');
+
+ OC.Share.Social.Collection.each(function(model) {
+ var url = model.get('url');
+ url = url.replace('{{reference}}', link);
+
+ var li = $('<li>' +
+ '<a href="#" class="menuitem pop-up" data-url="' + url + '" data-window="'+model.get('newWindow')+'">' +
+ '<span class="icon ' + model.get('iconClass') + '"></span>' +
+ '<span>' + model.get('name') + '</span>' +
+ '</a>');
+ li.appendTo(ul);
+ });
+ ul.appendTo('#linkSocial');
+
+ if (OC.Share.Social.Collection.length === 0) {
+ $('#linkTextMore').hide();
+ $linkText.addClass('no-menu-item');
+ } else {
+ $linkText.removeClass('no-menu-item');
+ }
},
/**
*
@@ -602,6 +632,8 @@
$('#linkText').slideUp(OC.menuSpeed);
$('#defaultExpireMessage').hide();
$('#showPassword+label').hide();
+ $('#linkSocial').hide();
+ $('#linkTextMore').hide();
$('#linkPass').slideUp(OC.menuSpeed);
$('#emailPrivateLink #email').hide();
$('#emailPrivateLink #emailButton').hide();
@@ -1030,6 +1062,8 @@ $(document).ready(function () {
$('#linkText').val('');
$('#showPassword').prop('checked', false);
$('#linkPass').hide();
+ $('#linkSocial').hide();
+ $('#linkTextMore').hide();
$('#sharingDialogAllowPublicUpload').prop('checked', false);
$('#expirationCheckbox').prop('checked', false);
$('#expirationDate').hide();
@@ -1293,6 +1327,39 @@ $(document).ready(function () {
OC.dialogs.alert(t('core', result.data.message), t('core', 'Warning'));
}
});
+ });
+ $(document).on('click', '#dropdown .pop-up', function(event) {
+ event.preventDefault();
+ event.stopPropagation();
+
+ var url = $(event.currentTarget).data('url');
+ var newWindow = $(event.currentTarget).data('window');
+ $(event.currentTarget).tooltip('hide');
+ if (url) {
+ if (newWindow === true) {
+ 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);
+ } else {
+ window.location.href = url;
+ }
+ }
+ });
+
+ $(document).on('click', '.icon-more', function(event) {
+ event.preventDefault();
+ event.stopPropagation();
+
+ var children = event.currentTarget.parentNode.children;
+
+ $.each(children, function (key, value) {
+ if (value.classList.contains('popovermenu')) {
+ $(value).toggle();
+ }
+ });
});
});
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index b4c55e9a..d5d0de46 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -51,6 +51,7 @@ use OCA\Gallery\Middleware\EnvCheckMiddleware;
use OCA\Gallery\Utility\EventSource;
use OCA\OcUtility\AppInfo\Application as OcUtility;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Class Application
@@ -80,7 +81,7 @@ class Application extends App {
$c->query('Environment'),
$c->query('OCP\IURLGenerator'),
$c->query('OCP\IConfig'),
- $c->query('Session')
+ $c->query(EventDispatcherInterface::class)
);
}
);
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index f02be40c..1cef864e 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -25,6 +25,7 @@ use OCP\AppFramework\Http\RedirectResponse;
use OCA\Gallery\Environment\Environment;
use OCA\Gallery\Http\ImageResponse;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Generates templates for the landing page from within ownCloud, the public
@@ -40,6 +41,8 @@ class PageController extends Controller {
private $urlGenerator;
/** @var IConfig */
private $appConfig;
+ /** @var EventDispatcherInterface */
+ private $dispatcher;
/**
* Constructor
@@ -49,19 +52,22 @@ class PageController extends Controller {
* @param Environment $environment
* @param IURLGenerator $urlGenerator
* @param IConfig $appConfig
+ * @param EventDispatcherInterface $dispatcher
*/
public function __construct(
$appName,
IRequest $request,
Environment $environment,
IURLGenerator $urlGenerator,
- IConfig $appConfig
+ IConfig $appConfig,
+ EventDispatcherInterface $dispatcher
) {
parent::__construct($appName, $request);
$this->environment = $environment;
$this->urlGenerator = $urlGenerator;
$this->appConfig = $appConfig;
+ $this->dispatcher = $dispatcher;
}
/**
@@ -84,6 +90,8 @@ class PageController extends Controller {
// Parameters sent to the template
$params = $this->getIndexParameters($appName);
+ $this->dispatcher->dispatch('OCP\Share::loadSocial');
+
// Will render the page using the template found in templates/index.php
$response = new TemplateResponse($appName, 'index', $params);
$this->addContentSecurityToResponse($response);
diff --git a/tests/unit/Controller/PageControllerTest.php b/tests/unit/Controller/PageControllerTest.php
index 3fc89d29..9e47ef7e 100644
--- a/tests/unit/Controller/PageControllerTest.php
+++ b/tests/unit/Controller/PageControllerTest.php
@@ -23,6 +23,7 @@ use OCP\AppFramework\Http\RedirectResponse;
use OCA\Gallery\Controller\PageController;
use OCA\Gallery\Environment\Environment;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* @package OCA\Gallery\Controller
@@ -41,6 +42,8 @@ class PageControllerTest extends \Test\TestCase {
private $appConfig;
/** @var PageController */
protected $controller;
+ /** @var EventDispatcherInterface */
+ protected $dispatcher;
/**
* Test set up
@@ -60,12 +63,14 @@ class PageControllerTest extends \Test\TestCase {
$this->appConfig = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
->getMock();
+ $this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$this->controller = new PageController(
$this->appName,
$this->request,
$this->environment,
$this->urlGenerator,
- $this->appConfig
+ $this->appConfig,
+ $this->dispatcher
);
}
@@ -87,6 +92,10 @@ class PageControllerTest extends \Test\TestCase {
$publicUploadEnabled, $mailNotificationEnabled, $mailPublicNotificationEnabled
);
+ $this->dispatcher->expects($this->once())
+ ->method('dispatch')
+ ->with('OCP\Share::loadSocial');
+
$template = new TemplateResponse($this->appName, 'index', $params);
$response = $this->controller->index();