File indexing completed on 2024-05-12 06:01:02
0001 "use strict"; 0002 0003 function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 0004 0005 /** 0006 * Timeago is a jQuery plugin that makes it easy to support automatically 0007 * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago"). 0008 * 0009 * @name timeago 0010 * @version 1.6.4 0011 * @requires jQuery v1.2.3+ 0012 * @author Ryan McGeary 0013 * @license MIT License - http://www.opensource.org/licenses/mit-license.php 0014 * 0015 * For usage and examples, visit: 0016 * http://timeago.yarp.com/ 0017 * 0018 * Copyright (c) 2008-2017, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org) 0019 */ 0020 (function (factory) { 0021 if (typeof define === 'function' && define.amd) { 0022 // AMD. Register as an anonymous module. 0023 define(['jquery'], factory); 0024 } else if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === 'object' && _typeof(module.exports) === 'object') { 0025 factory(require('jquery')); 0026 } else { 0027 // Browser globals 0028 factory(jQuery); 0029 } 0030 })(function ($) { 0031 $.timeago = function (timestamp) { 0032 if (timestamp instanceof Date) { 0033 return inWords(timestamp); 0034 } else if (typeof timestamp === "string") { 0035 return inWords($.timeago.parse(timestamp)); 0036 } else if (typeof timestamp === "number") { 0037 return inWords(new Date(timestamp)); 0038 } else { 0039 return inWords($.timeago.datetime(timestamp)); 0040 } 0041 }; 0042 0043 var $t = $.timeago; 0044 $.extend($.timeago, { 0045 settings: { 0046 refreshMillis: 60000, 0047 allowPast: true, 0048 allowFuture: false, 0049 localeTitle: false, 0050 cutoff: 0, 0051 autoDispose: true, 0052 strings: { 0053 prefixAgo: null, 0054 prefixFromNow: null, 0055 suffixAgo: "ago", 0056 suffixFromNow: "from now", 0057 inPast: 'any moment now', 0058 seconds: "less than a minute", 0059 minute: "about a minute", 0060 minutes: "%d minutes", 0061 hour: "about an hour", 0062 hours: "about %d hours", 0063 day: "a day", 0064 days: "%d days", 0065 month: "about a month", 0066 months: "%d months", 0067 year: "about a year", 0068 years: "%d years", 0069 wordSeparator: " ", 0070 numbers: [] 0071 } 0072 }, 0073 inWords: function inWords(distanceMillis) { 0074 if (!this.settings.allowPast && !this.settings.allowFuture) { 0075 throw 'timeago allowPast and allowFuture settings can not both be set to false.'; 0076 } 0077 0078 var $l = this.settings.strings; 0079 var prefix = $l.prefixAgo; 0080 var suffix = $l.suffixAgo; 0081 0082 if (this.settings.allowFuture) { 0083 if (distanceMillis < 0) { 0084 prefix = $l.prefixFromNow; 0085 suffix = $l.suffixFromNow; 0086 } 0087 } 0088 0089 if (!this.settings.allowPast && distanceMillis >= 0) { 0090 return this.settings.strings.inPast; 0091 } 0092 0093 var seconds = Math.abs(distanceMillis) / 1000; 0094 var minutes = seconds / 60; 0095 var hours = minutes / 60; 0096 var days = hours / 24; 0097 var years = days / 365; 0098 0099 function substitute(stringOrFunction, number) { 0100 var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction; 0101 var value = $l.numbers && $l.numbers[number] || number; 0102 return string.replace(/%d/i, value); 0103 } 0104 0105 var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) || seconds < 90 && substitute($l.minute, 1) || minutes < 45 && substitute($l.minutes, Math.round(minutes)) || minutes < 90 && substitute($l.hour, 1) || hours < 24 && substitute($l.hours, Math.round(hours)) || hours < 42 && substitute($l.day, 1) || days < 30 && substitute($l.days, Math.round(days)) || days < 45 && substitute($l.month, 1) || days < 365 && substitute($l.months, Math.round(days / 30)) || years < 1.5 && substitute($l.year, 1) || substitute($l.years, Math.round(years)); 0106 var separator = $l.wordSeparator || ""; 0107 0108 if ($l.wordSeparator === undefined) { 0109 separator = " "; 0110 } 0111 0112 return $.trim([prefix, words, suffix].join(separator)); 0113 }, 0114 parse: function parse(iso8601) { 0115 var s = $.trim(iso8601); 0116 s = s.replace(/\.\d+/, ""); // remove milliseconds 0117 0118 s = s.replace(/-/, "/").replace(/-/, "/"); 0119 s = s.replace(/T/, " ").replace(/Z/, " UTC"); 0120 s = s.replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2"); // -04:00 -> -0400 0121 0122 s = s.replace(/([\+\-]\d\d)$/, " $100"); // +09 -> +0900 0123 0124 return new Date(s); 0125 }, 0126 datetime: function datetime(elem) { 0127 var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title"); 0128 return $t.parse(iso8601); 0129 }, 0130 isTime: function isTime(elem) { 0131 // jQuery's `is()` doesn't play well with HTML5 in IE 0132 return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time"); 0133 } 0134 }); // functions that can be called via $(el).timeago('action') 0135 // init is default when no action is given 0136 // functions are called with context of a single element 0137 0138 var functions = { 0139 init: function init() { 0140 functions.dispose.call(this); 0141 var refresh_el = $.proxy(refresh, this); 0142 refresh_el(); 0143 var $s = $t.settings; 0144 0145 if ($s.refreshMillis > 0) { 0146 this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis); 0147 } 0148 }, 0149 update: function update(timestamp) { 0150 var date = timestamp instanceof Date ? timestamp : $t.parse(timestamp); 0151 $(this).data('timeago', { 0152 datetime: date 0153 }); 0154 0155 if ($t.settings.localeTitle) { 0156 $(this).attr("title", date.toLocaleString()); 0157 } 0158 0159 refresh.apply(this); 0160 }, 0161 updateFromDOM: function updateFromDOM() { 0162 $(this).data('timeago', { 0163 datetime: $t.parse($t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title")) 0164 }); 0165 refresh.apply(this); 0166 }, 0167 dispose: function dispose() { 0168 if (this._timeagoInterval) { 0169 window.clearInterval(this._timeagoInterval); 0170 this._timeagoInterval = null; 0171 } 0172 } 0173 }; 0174 0175 $.fn.timeago = function (action, options) { 0176 var fn = action ? functions[action] : functions.init; 0177 0178 if (!fn) { 0179 throw new Error("Unknown function name '" + action + "' for timeago"); 0180 } // each over objects here and call the requested function 0181 0182 0183 this.each(function () { 0184 fn.call(this, options); 0185 }); 0186 return this; 0187 }; 0188 0189 function refresh() { 0190 var $s = $t.settings; //check if it's still visible 0191 0192 if ($s.autoDispose && !$.contains(document.documentElement, this)) { 0193 //stop if it has been removed 0194 $(this).timeago("dispose"); 0195 return this; 0196 } 0197 0198 var data = prepareData(this); 0199 0200 if (!isNaN(data.datetime)) { 0201 if ($s.cutoff === 0 || Math.abs(distance(data.datetime)) < $s.cutoff) { 0202 $(this).text(inWords(data.datetime)); 0203 } else { 0204 if ($(this).attr('title').length > 0) { 0205 $(this).text($(this).attr('title')); 0206 } 0207 } 0208 } 0209 0210 return this; 0211 } 0212 0213 function prepareData(element) { 0214 element = $(element); 0215 0216 if (!element.data("timeago")) { 0217 element.data("timeago", { 0218 datetime: $t.datetime(element) 0219 }); 0220 var text = $.trim(element.text()); 0221 0222 if ($t.settings.localeTitle) { 0223 element.attr("title", element.data('timeago').datetime.toLocaleString()); 0224 } else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) { 0225 element.attr("title", text); 0226 } 0227 } 0228 0229 return element.data("timeago"); 0230 } 0231 0232 function inWords(date) { 0233 return $t.inWords(distance(date)); 0234 } 0235 0236 function distance(date) { 0237 return new Date().getTime() - date.getTime(); 0238 } // fix for IE6 suckage 0239 0240 0241 document.createElement("abbr"); 0242 document.createElement("time"); 0243 }); 0244 "use strict"; 0245 0246 function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 0247 0248 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 0249 0250 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 0251 0252 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 0253 0254 function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 0255 0256 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 0257 0258 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 0259 0260 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 0261 0262 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 0263 0264 window.hpHelpers = function () { 0265 function dechex(number) { 0266 // discuss at: http://locutus.io/php/dechex/ 0267 // original by: Philippe Baumann 0268 // bugfixed by: Onno Marsman (https://twitter.com/onnomarsman) 0269 // improved by: http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript 0270 // input by: pilus 0271 // example 1: dechex(10) 0272 // returns 1: 'a' 0273 // example 2: dechex(47) 0274 // returns 2: '2f' 0275 // example 3: dechex(-1415723993) 0276 // returns 3: 'ab9dc427' 0277 if (number < 0) { 0278 number = 0xFFFFFFFF + number + 1; 0279 } 0280 0281 return parseInt(number, 10).toString(16); 0282 } 0283 0284 function calculateScoreColor(score) { 0285 var blue, 0286 red, 0287 green, 0288 defaultColor = 200; 0289 0290 if (score > 50) { 0291 red = defaultColor - (score - 50) * 4; 0292 green = defaultColor; 0293 blue = defaultColor - (score - 50) * 4; 0294 } else if (score < 51) { 0295 red = defaultColor; 0296 green = defaultColor - (score - 50) * 4; 0297 blue = defaultColor - (score - 50) * 4; 0298 } 0299 0300 return "rgb(" + red + "," + green + "," + blue + ")"; 0301 } 0302 0303 return { 0304 dechex: dechex, 0305 calculateScoreColor: calculateScoreColor 0306 }; 0307 }(); 0308 0309 var CarouselsModule = 0310 /*#__PURE__*/ 0311 function (_React$Component) { 0312 _inherits(CarouselsModule, _React$Component); 0313 0314 function CarouselsModule(props) { 0315 var _this; 0316 0317 _classCallCheck(this, CarouselsModule); 0318 0319 _this = _possibleConstructorReturn(this, _getPrototypeOf(CarouselsModule).call(this, props)); 0320 _this.state = {}; 0321 _this.initCarouselModule = _this.initCarouselModule.bind(_assertThisInitialized(_this)); 0322 _this.updateDimensions = _this.updateDimensions.bind(_assertThisInitialized(_this)); 0323 _this.convertDataObject = _this.convertDataObject.bind(_assertThisInitialized(_this)); 0324 return _this; 0325 } 0326 0327 _createClass(CarouselsModule, [{ 0328 key: "componentWillMount", 0329 value: function componentWillMount() { 0330 this.updateDimensions(); 0331 } 0332 }, { 0333 key: "componentWillUnmount", 0334 value: function componentWillUnmount() { 0335 window.removeEventListener("resize", this.updateDimensions); 0336 window.removeEventListener("orientationchange", this.updateDimensions); 0337 } 0338 }, { 0339 key: "componentDidMount", 0340 value: function componentDidMount() { 0341 this.initCarouselModule(); 0342 } 0343 }, { 0344 key: "initCarouselModule", 0345 value: function initCarouselModule() { 0346 window.addEventListener("resize", this.updateDimensions); 0347 window.addEventListener("orientationchange", this.updateDimensions); 0348 var env = "live"; 0349 0350 if (location.hostname.endsWith('cc')) { 0351 env = "test"; 0352 } else if (location.hostname.endsWith('localhost')) { 0353 env = "test"; 0354 } 0355 0356 this.setState({ 0357 env: env 0358 }, function () { 0359 this.convertDataObject(); 0360 }); 0361 } 0362 }, { 0363 key: "updateDimensions", 0364 value: function updateDimensions() { 0365 var width = window.innerWidth; 0366 var device; 0367 0368 if (width >= 910) { 0369 device = "large"; 0370 } else if (width < 910 && width >= 610) { 0371 device = "mid"; 0372 } else if (width < 610) { 0373 device = "tablet"; 0374 } 0375 0376 this.setState({ 0377 device: device 0378 }); 0379 } 0380 }, { 0381 key: "convertDataObject", 0382 value: function convertDataObject() { 0383 var productGroupsArray = []; 0384 0385 for (var i in window.data) { 0386 if (i !== "comments" && i !== "featureProducts") { 0387 var productGroup = { 0388 title: window.data[i].title, 0389 catIds: window.data[i].catIds, 0390 products: JSON.parse(window.data[i].products) 0391 }; 0392 productGroupsArray.push(productGroup); 0393 } 0394 } 0395 0396 this.setState({ 0397 productGroupsArray: productGroupsArray, 0398 loading: false 0399 }); 0400 } 0401 }, { 0402 key: "render", 0403 value: function render() { 0404 var _this2 = this; 0405 0406 var productCarouselsContainer; 0407 0408 if (this.state.loading === false) { 0409 productCarouselsContainer = this.state.productGroupsArray.map(function (pgc, index) { 0410 //if (pgc.catIds){ 0411 return React.createElement("div", { 0412 key: index, 0413 className: "section" 0414 }, React.createElement("div", { 0415 className: "container" 0416 }, React.createElement(Carousel, { 0417 products: pgc.products, 0418 device: _this2.state.device, 0419 title: pgc.title, 0420 catIds: pgc.catIds, 0421 link: '/', 0422 env: _this2.state.env 0423 }))); //} 0424 }); 0425 } 0426 0427 return React.createElement("div", { 0428 id: "carousels-module" 0429 }, productCarouselsContainer); 0430 } 0431 }]); 0432 0433 return CarouselsModule; 0434 }(React.Component); 0435 0436 var Carousel = 0437 /*#__PURE__*/ 0438 function (_React$Component2) { 0439 _inherits(Carousel, _React$Component2); 0440 0441 function Carousel(props) { 0442 var _this3; 0443 0444 _classCallCheck(this, Carousel); 0445 0446 _this3 = _possibleConstructorReturn(this, _getPrototypeOf(Carousel).call(this, props)); 0447 _this3.state = { 0448 products: _this3.props.products, 0449 disableleftArrow: true 0450 }; 0451 _this3.updateDimensions = _this3.updateDimensions.bind(_assertThisInitialized(_this3)); 0452 _this3.animateProductCarousel = _this3.animateProductCarousel.bind(_assertThisInitialized(_this3)); 0453 _this3.getNextProductsBatch = _this3.getNextProductsBatch.bind(_assertThisInitialized(_this3)); 0454 return _this3; 0455 } 0456 0457 _createClass(Carousel, [{ 0458 key: "componentWillMount", 0459 value: function componentWillMount() { 0460 window.addEventListener("resize", this.updateDimensions); 0461 } 0462 }, { 0463 key: "componentDidMount", 0464 value: function componentDidMount() { 0465 this.updateDimensions(); 0466 } 0467 }, { 0468 key: "updateDimensions", 0469 value: function updateDimensions(animateCarousel) { 0470 var itemsPerRow = 5; 0471 0472 if (window.hpVersion === 2) { 0473 if (this.props.device === 'large') { 0474 itemsPerRow = 6; 0475 } else if (this.props.device === 'mid') { 0476 itemsPerRow = 6; 0477 } else if (this.props.device === 'tablet') { 0478 itemsPerRow = 2; 0479 } 0480 } 0481 0482 var containerWidth; 0483 0484 if (window.page === "opendesktop") { 0485 containerWidth = $('#main-content').width(); 0486 } else if (window.page === "appimages" || window.page === "libreoffice") { 0487 containerWidth = $('#introduction').find('.container').width(); 0488 } 0489 0490 var containerNumber = Math.ceil(this.state.products.length / (itemsPerRow - 1)); 0491 var itemWidth = containerWidth / itemsPerRow; 0492 var sliderWidth = (containerWidth - itemWidth) * containerNumber; 0493 var sliderPosition = 0; 0494 0495 if (this.state.sliderPosition) { 0496 sliderPosition = this.state.sliderPosition; 0497 } 0498 0499 if (window.page === "appimages" || window.page === "libreoffice") { 0500 $('#carousel-module-container').width(containerWidth); 0501 } 0502 0503 this.setState({ 0504 sliderPosition: sliderPosition, 0505 containerWidth: containerWidth, 0506 containerNumber: containerNumber, 0507 sliderWidth: sliderWidth, 0508 itemWidth: itemWidth, 0509 itemsPerRow: itemsPerRow - 1 0510 }, function () { 0511 if (animateCarousel) { 0512 this.animateProductCarousel('right', animateCarousel); 0513 } else if (this.state.finishedProducts) { 0514 this.setState({ 0515 disableRightArrow: true 0516 }); 0517 } 0518 }); 0519 } 0520 }, { 0521 key: "animateProductCarousel", 0522 value: function animateProductCarousel(dir, animateCarousel) { 0523 var newSliderPosition = this.state.sliderPosition; 0524 var endPoint = this.state.sliderWidth - (this.state.containerWidth - this.state.itemWidth); 0525 0526 if (dir === 'left') { 0527 if (this.state.sliderPosition > 0) { 0528 //newSliderPosition = this.state.sliderPosition - (this.state.containerWidth - this.state.itemWidth); 0529 if (this.state.containerWidth < this.state.itemWidth * 3) { 0530 newSliderPosition = this.state.sliderPosition - this.state.itemWidth; 0531 } else { 0532 newSliderPosition = this.state.sliderPosition - this.state.itemWidth * 2; 0533 } 0534 } 0535 } else { 0536 if (Math.trunc(this.state.sliderPosition) < Math.trunc(endPoint)) { 0537 //newSliderPosition = this.state.sliderPosition + (this.state.containerWidth - this.state.itemWidth); 0538 if (this.state.containerWidth < this.state.itemWidth * 3) { 0539 newSliderPosition = this.state.sliderPosition + this.state.itemWidth; 0540 } else { 0541 newSliderPosition = this.state.sliderPosition + this.state.itemWidth * 2; 0542 } 0543 } else { 0544 newSliderPosition = 0; 0545 /*if (!animateCarousel){ 0546 if (this.state.products.length >= 15 || this.state.finishedProducts){ 0547 newSliderPosition = 0; 0548 } else { 0549 this.getNextProductsBatch(); 0550 } 0551 }*/ 0552 } 0553 } 0554 0555 this.setState({ 0556 sliderPosition: newSliderPosition 0557 }, function () { 0558 var disableleftArrow = false; 0559 0560 if (this.state.sliderPosition <= 0) { 0561 disableleftArrow = true; 0562 } 0563 0564 var disableRightArrow = false; 0565 /*if (this.state.sliderPosition >= endPoint && this.state.finishedProducts === true){ 0566 disableRightArrow = true; 0567 }*/ 0568 0569 this.setState({ 0570 disableRightArrow: disableRightArrow, 0571 disableleftArrow: disableleftArrow 0572 }); 0573 }); 0574 } 0575 }, { 0576 key: "getNextProductsBatch", 0577 value: function getNextProductsBatch() { 0578 this.setState({ 0579 disableRightArrow: true 0580 }, function () { 0581 var limit = this.state.itemsPerRow * (this.state.containerNumber + 1) - this.state.products.length; 0582 0583 if (limit <= 0) { 0584 limit = this.state.itemsPerRow; 0585 } 0586 0587 var url; 0588 0589 if (!this.props.catIds) { 0590 url = "/home/getnewactiveplingedproductjson/?limit=" + limit + "&offset=" + this.state.offset; 0591 } else { 0592 url = "/home/showlastproductsjson/?page=1&limit=" + limit + "&offset=" + this.state.offset + "&catIDs=" + this.props.catIds + "&isoriginal=0"; 0593 } 0594 0595 var self = this; 0596 $.ajax({ 0597 url: url, 0598 cache: false 0599 }).done(function (response) { 0600 var products = self.state.products, 0601 finishedProducts = false, 0602 animateCarousel = true; 0603 0604 if (response.length > 0) { 0605 products = products.concat(response); 0606 } else { 0607 finishedProducts = true; 0608 animateCarousel = false; 0609 } 0610 0611 if (response.length < limit) { 0612 finishedProducts = true; 0613 } 0614 0615 self.setState({ 0616 products: products, 0617 offset: self.state.offset + response.length, 0618 finishedProducts: finishedProducts 0619 }, function () { 0620 self.updateDimensions(animateCarousel); 0621 }); 0622 }); 0623 }); 0624 } 0625 }, { 0626 key: "render", 0627 value: function render() { 0628 var _this4 = this; 0629 0630 var carouselItemsDisplay; 0631 0632 if (this.state.products && this.state.products.length > 0) { 0633 var plingedProduct = false; 0634 if (!this.props.catIds) plingedProduct = true; 0635 carouselItemsDisplay = this.state.products.map(function (product, index) { 0636 return React.createElement(CarouselItem, { 0637 key: index, 0638 product: product, 0639 itemWidth: _this4.state.itemWidth, 0640 env: _this4.props.env, 0641 plingedProduct: plingedProduct 0642 }); 0643 }); 0644 } 0645 0646 var carouselArrowLeftDisplay; 0647 0648 if (this.state.disableleftArrow) { 0649 carouselArrowLeftDisplay = React.createElement("a", { 0650 className: "carousel-arrow arrow-left disabled" 0651 }, React.createElement("span", { 0652 className: "glyphicon glyphicon-chevron-left" 0653 })); 0654 } else { 0655 carouselArrowLeftDisplay = React.createElement("a", { 0656 onClick: function onClick() { 0657 return _this4.animateProductCarousel('left'); 0658 }, 0659 className: "carousel-arrow arrow-left" 0660 }, React.createElement("span", { 0661 className: "glyphicon glyphicon-chevron-left" 0662 })); 0663 } 0664 0665 var carouselArrowRightDisplay; 0666 0667 if (this.state.disableRightArrow) { 0668 carouselArrowRightDisplay = React.createElement("a", { 0669 className: "carousel-arrow arrow-right disabled" 0670 }, React.createElement("span", { 0671 className: "glyphicon glyphicon-chevron-right" 0672 })); 0673 } else { 0674 carouselArrowRightDisplay = React.createElement("a", { 0675 onClick: function onClick() { 0676 return _this4.animateProductCarousel('right'); 0677 }, 0678 className: "carousel-arrow arrow-right" 0679 }, React.createElement("span", { 0680 className: "glyphicon glyphicon-chevron-right" 0681 })); 0682 } 0683 0684 var hpVersionClass = "one"; 0685 var carouselWrapperStyling = {}; 0686 var carouselArrowsMargin; 0687 0688 if (window.hpVersion === 2 && this.state.itemWidth) { 0689 hpVersionClass = "two"; 0690 var itemHeightMultiplier; // if (this.state.itemWidth > 150){ 0691 0692 itemHeightMultiplier = 1.35; 0693 /*} else { 0694 itemHeightMultiplier = 1.85; 0695 }*/ 0696 0697 carouselWrapperStyling = { 0698 "paddingLeft": this.state.itemWidth / 2, 0699 "paddingRight": this.state.itemWidth / 2, 0700 "height": this.state.itemWidth * itemHeightMultiplier 0701 }; 0702 carouselArrowsMargin = this.state.itemWidth / 4; 0703 } 0704 0705 var urlSuffix = ''; 0706 0707 if (window.page === "libreoffice") { 0708 urlSuffix = "/s/LibreOffice"; 0709 } 0710 0711 var titleLink = urlSuffix + "/browse/cat/" + this.props.catIds + "/"; 0712 0713 if (!this.props.catIds) { 0714 titleLink = "/community#plingedproductsPanel"; 0715 } else if (this.props.catIds.indexOf(',') > 0) { 0716 titleLink = urlSuffix + "/browse/"; 0717 } 0718 0719 return React.createElement("div", { 0720 className: "product-carousel " + hpVersionClass 0721 }, React.createElement("div", { 0722 className: "product-carousel-header" 0723 }, React.createElement("h2", null, React.createElement("a", { 0724 href: titleLink 0725 }, this.props.title, " ", React.createElement("span", { 0726 className: "glyphicon glyphicon-chevron-right" 0727 })))), React.createElement("div", { 0728 className: "product-carousel-wrapper", 0729 style: carouselWrapperStyling 0730 }, React.createElement("div", { 0731 className: "product-carousel-left", 0732 style: { 0733 "left": carouselArrowsMargin 0734 } 0735 }, carouselArrowLeftDisplay), React.createElement("div", { 0736 className: "product-carousel-container" 0737 }, React.createElement("div", { 0738 className: "product-carousel-slider", 0739 style: { 0740 "width": this.state.sliderWidth, 0741 "left": "-" + this.state.sliderPosition + "px" 0742 } 0743 }, carouselItemsDisplay)), React.createElement("div", { 0744 className: "product-carousel-right", 0745 style: { 0746 "right": carouselArrowsMargin 0747 } 0748 }, carouselArrowRightDisplay))); 0749 } 0750 }]); 0751 0752 return Carousel; 0753 }(React.Component); 0754 0755 var CarouselItem = 0756 /*#__PURE__*/ 0757 function (_React$Component3) { 0758 _inherits(CarouselItem, _React$Component3); 0759 0760 function CarouselItem(props) { 0761 var _this5; 0762 0763 _classCallCheck(this, CarouselItem); 0764 0765 _this5 = _possibleConstructorReturn(this, _getPrototypeOf(CarouselItem).call(this, props)); 0766 _this5.state = {}; 0767 return _this5; 0768 } 0769 0770 _createClass(CarouselItem, [{ 0771 key: "render", 0772 value: function render() { 0773 var paddingTop; 0774 var productInfoDisplay = React.createElement("div", { 0775 className: "product-info" 0776 }, React.createElement("span", { 0777 className: "product-info-title" 0778 }, this.props.product.title), React.createElement("span", { 0779 className: "product-info-user" 0780 }, this.props.product.username)); 0781 0782 if (window.hpVersion === 2) { 0783 if (this.props.itemWidth) { 0784 paddingTop = this.props.itemWidth * 1.35 / 2 - 10; 0785 } 0786 0787 var lastDate; 0788 0789 if (this.props.product.changed_at) { 0790 lastDate = this.props.product.changed_at; 0791 } else { 0792 lastDate = this.props.product.created_at; 0793 } 0794 0795 var cDate = new Date(lastDate); // cDate = cDate.toString(); 0796 // const createdDate = cDate.split(' ')[1] + " " + cDate.split(' ')[2] + " " + cDate.split(' ')[3]; 0797 0798 var createdDate = jQuery.timeago(cDate); // const productScoreColor = window.hpHelpers.calculateScoreColor(this.props.product.laplace_score); 0799 0800 var infoDisplay; 0801 var scoreDisplay = React.createElement("div", { 0802 className: "score-info" 0803 }, React.createElement("div", { 0804 className: "score-number" 0805 }, "Score ", (this.props.product.laplace_score / 10).toFixed(1), "%"), React.createElement("div", { 0806 className: "score-bar-container" 0807 }, React.createElement("div", { 0808 className: "score-bar", 0809 style: { 0810 "width": this.props.product.laplace_score / 10 + "%" 0811 } 0812 }))); 0813 infoDisplay = scoreDisplay; 0814 0815 if (this.props.plingedProduct) { 0816 var plingDisplay = React.createElement("div", { 0817 className: "plings" 0818 }, React.createElement("img", { 0819 src: "/images/system/pling-btn-active.png" 0820 }), this.props.product.sum_plings); 0821 infoDisplay = React.createElement("div", null, plingDisplay, scoreDisplay); 0822 } 0823 /*let scoreDisplay; 0824 if (this.props.plingedProduct){ 0825 scoreDisplay = ( 0826 <div className="score-info plings"> 0827 <img src="/images/system/pling-btn-active.png" /> 0828 {this.props.product.sum_plings} 0829 </div> 0830 ); 0831 } else { 0832 scoreDisplay = ( 0833 <div className="score-info"> 0834 <div className="score-number"> 0835 score {this.props.product.laplace_score + "%"} 0836 </div> 0837 <div className="score-bar-container"> 0838 <div className={"score-bar"} style={{"width":this.props.product.laplace_score + "%"}}></div> 0839 </div> 0840 </div> 0841 ); 0842 }*/ 0843 0844 0845 productInfoDisplay = React.createElement("div", { 0846 className: "product-info" 0847 }, React.createElement("span", { 0848 className: "product-info-title" 0849 }, this.props.product.title), React.createElement("span", { 0850 className: "product-info-category" 0851 }, this.props.product.cat_title), React.createElement("span", { 0852 className: "product-info-date" 0853 }, createdDate), infoDisplay); 0854 } 0855 0856 var projectUrl = ""; 0857 0858 if (window.page === "libreoffice") { 0859 projectUrl = window.baseUrl + "p/" + this.props.product.project_id; 0860 } else { 0861 projectUrl = "/p/" + this.props.product.project_id; 0862 } 0863 0864 return React.createElement("div", { 0865 className: "product-carousel-item", 0866 style: { 0867 "width": this.props.itemWidth 0868 } 0869 }, React.createElement("div", { 0870 className: "product-carousel-item-wrapper" 0871 }, React.createElement("a", { 0872 href: projectUrl, 0873 style: { 0874 "paddingTop": paddingTop 0875 } 0876 }, React.createElement("figure", { 0877 style: { 0878 "height": paddingTop 0879 } 0880 }, React.createElement("img", { 0881 className: "very-rounded-corners", 0882 src: this.props.product.image_small 0883 })), productInfoDisplay))); 0884 } 0885 }]); 0886 0887 return CarouselItem; 0888 }(React.Component); 0889 0890 ReactDOM.render(React.createElement(CarouselsModule, null), document.getElementById('carousel-module-container'));