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

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2016-11-15 04:03:59 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2016-11-15 04:03:59 +0300
commit587cc39e0362719332d410b7a4d5ddcc68788eeb (patch)
treec982c369cdda542c3a4de08be11c893e5364838c /plugins/Marketplace/angularjs/marketplace/marketplace.directive.js
parent64314b26dbc6619d535002bdb79b9e55d1fc87db (diff)
Update Marketplace to work with new API (#10799)
* starting to port marketplace to piwik 3 * updating tests * fix translation key * fix various issues * use material select * fix plugin upload * deprecate license_homepage plugin metadata and link to a LICENSE[.md|.txt] file if found (#10756) * deprecate license_homepage plugin metadata, and link to a LICENSE[.md|.txt] file if found * Make license view HTML only without menu * fix tests and update * fix some links did not work * we need to show warnings even when plugin is installed, not only when activated. otherwise it is not clear why something is not downloadable * fix install was not working * improved responsiveness of marketplace * fix more tests * fix search was shown when only a few plugins are there * fix ui tests * fix some translations * fix tests and remove duplicated test
Diffstat (limited to 'plugins/Marketplace/angularjs/marketplace/marketplace.directive.js')
-rw-r--r--plugins/Marketplace/angularjs/marketplace/marketplace.directive.js132
1 files changed, 132 insertions, 0 deletions
diff --git a/plugins/Marketplace/angularjs/marketplace/marketplace.directive.js b/plugins/Marketplace/angularjs/marketplace/marketplace.directive.js
new file mode 100644
index 0000000000..96812865d6
--- /dev/null
+++ b/plugins/Marketplace/angularjs/marketplace/marketplace.directive.js
@@ -0,0 +1,132 @@
+/*!
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+/**
+ * Usage:
+ * <div piwik-marketplace>
+ */
+(function () {
+
+ angular.module('piwikApp').directive('piwikMarketplace', piwikMarketplace);
+
+ piwikMarketplace.$inject = ['piwik', '$timeout'];
+
+ function piwikMarketplace(piwik, $timeout){
+
+ return {
+ restrict: 'A',
+ compile: function (element, attrs) {
+
+ return function (scope, element, attrs) {
+
+ $timeout(function () {
+
+
+ $('.installAllPaidPlugins').click(function (event) {
+ event.preventDefault();
+
+ piwikHelper.modalConfirm('#installAllPaidPluginsAtOnce');
+ });
+
+ $('.uploadPlugin').click(function (event) {
+ event.preventDefault();
+
+ piwikHelper.modalConfirm('#installPluginByUpload', {});
+ });
+
+
+ $('#uploadPluginForm').submit(function (event) {
+
+ var $zipFile = $('[name=pluginZip]');
+ var fileName = $zipFile.val();
+
+ if (!fileName || '.zip' != fileName.slice(-4)) {
+ event.preventDefault();
+ alert(_pk_translate('CorePluginsAdmin_NoZipFileSelected'));
+ }
+ });
+
+ // Keeps the plugin descriptions the same height
+ $('.marketplace .plugin .description').dotdotdot({
+ after: 'a.more',
+ watch: 'window'
+ });
+
+ function syncMaxHeight2 (selector) {
+
+ if (!selector) {
+ return;
+ }
+
+ var $nodes = $(selector);
+
+ if (!$nodes || !$nodes.length) {
+ return;
+ }
+
+ var maxh3 = null;
+ var maxMeta = null;
+ var maxFooter = null;
+ var nodesToUpdate = [];
+ var lastTop = 0;
+ $nodes.each(function (index, node) {
+ var $node = $(node);
+ var top = $node.offset().top;
+
+ if (lastTop !== top) {
+ nodesToUpdate = [];
+ lastTop = top;
+ maxh3 = null;
+ maxMeta = null;
+ maxFooter = null;
+ }
+
+ nodesToUpdate.push($node);
+
+ var heightH3 = $node.find('h3').height();
+ var heightMeta = $node.find('.metadata').height();
+ var heightFooter = $node.find('.footer').height();
+
+ if (!maxh3) {
+ maxh3 = heightH3;
+ } else if (maxh3 < heightH3) {
+ maxh3 = heightH3;
+ }
+
+ if (!maxMeta) {
+ maxMeta = heightMeta;
+ } else if (maxMeta < heightMeta) {
+ maxMeta = heightMeta;
+ }
+
+ if (!maxFooter) {
+ maxFooter = heightFooter;
+ } else if (maxFooter < heightFooter) {
+ maxFooter = heightFooter;
+ }
+
+ $.each(nodesToUpdate, function (index, $node) {
+ if (maxh3) {
+ $node.find('h3').height(maxh3 + 'px');
+ }
+ if (maxMeta) {
+ $node.find('.metadata').height(maxMeta + 'px');
+ }
+ if (maxFooter) {
+ $node.find('.footer').height(maxFooter + 'px');
+ }
+ });
+ });
+ }
+ syncMaxHeight2('.marketplace .plugin');
+
+ });
+ };
+ }
+ };
+ }
+})(); \ No newline at end of file