File indexing completed on 2024-05-12 06:01:02
0001 "use strict"; 0002 0003 window.appHelpers = function () { 0004 function getEnv(domain) { 0005 var env; 0006 0007 if (this.splitByLastDot(domain) === 'com' || this.splitByLastDot(domain) === 'org') { 0008 env = 'live'; 0009 } else { 0010 env = 'test'; 0011 } 0012 0013 return env; 0014 } 0015 0016 function getDeviceWidth(width) { 0017 var device; 0018 0019 if (width > 1720) { 0020 device = "very-huge"; 0021 } else if (width < 1720 && width > 1500) { 0022 device = "huge"; 0023 } else if (width < 1500 && width > 1250) { 0024 device = "full"; 0025 } else if (width < 1250 && width >= 1000) { 0026 device = "large"; 0027 } else if (width < 1000 && width >= 661) { 0028 device = "mid"; 0029 } else if (width < 661 && width >= 400) { 0030 device = "tablet"; 0031 } else if (width < 400) { 0032 device = "phone"; 0033 } 0034 0035 return device; 0036 } 0037 0038 function splitByLastDot(text) { 0039 var index = text.lastIndexOf('.'); 0040 return text.slice(index + 1); 0041 } 0042 0043 function getTimeAgo(datetime) { 0044 var a = timeago().format(datetime); 0045 return a; 0046 } 0047 0048 function getFileSize(size) { 0049 if (isNaN(size)) size = 0; 0050 if (size < 1024) return size + ' Bytes'; 0051 size /= 1024; 0052 if (size < 1024) return size.toFixed(2) + ' Kb'; 0053 size /= 1024; 0054 if (size < 1024) return size.toFixed(2) + ' Mb'; 0055 size /= 1024; 0056 if (size < 1024) return size.toFixed(2) + ' Gb'; 0057 size /= 1024; 0058 return size.toFixed(2) + ' Tb'; 0059 } 0060 0061 function generateFilterUrl(location, currentCat) { 0062 var link = {}; 0063 0064 if (currentCat && currentCat !== 0) { 0065 link.base = "/browse/cat/" + currentCat + "/ord/"; 0066 } else { 0067 link.base = "/browse/ord/"; 0068 } 0069 0070 if (location.search) link.search = location.search; 0071 return link; 0072 } 0073 0074 function generateFileDownloadHash(file, env) { 0075 var salt; 0076 0077 if (env === "test") { 0078 salt = "vBHnf7bbdhz120bhNsd530LsA2mkMvh6sDsCm4jKlm23D186Fj"; 0079 } else { 0080 salt = "Kcn6cv7&dmvkS40Hna§4ffcvl=021nfMs2sdlPs123MChf4s0K"; 0081 } 0082 0083 var timestamp = Math.floor(new Date().getTime() / 1000 + 3600); 0084 var hash = md5(salt + file.collection_id + timestamp); 0085 return hash; 0086 } 0087 0088 return { 0089 getEnv: getEnv, 0090 getDeviceWidth: getDeviceWidth, 0091 splitByLastDot: splitByLastDot, 0092 getTimeAgo: getTimeAgo, 0093 getFileSize: getFileSize, 0094 generateFilterUrl: generateFilterUrl, 0095 generateFileDownloadHash: generateFileDownloadHash 0096 }; 0097 }(); 0098 "use strict"; 0099 0100 window.categoryHelpers = function () { 0101 function findCurrentCategories(categories, catId) { 0102 var currentCategories = {}; 0103 categories.forEach(function (mc, index) { 0104 if (parseInt(mc.id) === catId) { 0105 currentCategories.category = mc; 0106 } else { 0107 var cArray = categoryHelpers.convertCatChildrenObjectToArray(mc.children); 0108 cArray.forEach(function (sc, index) { 0109 if (parseInt(sc.id) === catId) { 0110 currentCategories.category = mc; 0111 currentCategories.subcategory = sc; 0112 } else { 0113 var scArray = categoryHelpers.convertCatChildrenObjectToArray(sc.children); 0114 scArray.forEach(function (ssc, index) { 0115 if (parseInt(ssc.id) === catId) { 0116 currentCategories.category = mc; 0117 currentCategories.subcategory = sc; 0118 currentCategories.secondSubCategory = ssc; 0119 } 0120 }); 0121 } 0122 }); 0123 } 0124 }); 0125 return currentCategories; 0126 } 0127 0128 function convertCatChildrenObjectToArray(children) { 0129 var cArray = []; 0130 0131 for (var i in children) { 0132 cArray.push(children[i]); 0133 } 0134 0135 return cArray; 0136 } 0137 0138 return { 0139 findCurrentCategories: findCurrentCategories, 0140 convertCatChildrenObjectToArray: convertCatChildrenObjectToArray 0141 }; 0142 }(); 0143 "use strict"; 0144 0145 window.productHelpers = function () { 0146 function getNumberOfProducts(device, numRows) { 0147 var num; 0148 0149 if (device === "very-huge") { 0150 num = 7; 0151 } else if (device === "huge") { 0152 num = 6; 0153 } else if (device === "full") { 0154 num = 5; 0155 } else if (device === "large") { 0156 num = 4; 0157 } else if (device === "mid") { 0158 num = 3; 0159 } else if (device === "tablet") { 0160 num = 2; 0161 } else if (device === "phone") { 0162 num = 1; 0163 } 0164 0165 if (numRows) num = num * numRows; 0166 return num; 0167 } 0168 0169 function generatePaginationObject(numPages, pathname, currentCategoy, order, page) { 0170 var pagination = []; 0171 var baseHref = "/browse"; 0172 0173 if (pathname.indexOf('cat') > -1) { 0174 baseHref += "/cat/" + currentCategoy; 0175 } 0176 0177 if (page > 1) { 0178 var prev = { 0179 number: 'previous', 0180 link: baseHref + "/page/" + parseInt(page - 1) + "/ord/" + order 0181 }; 0182 pagination.push(prev); 0183 } 0184 0185 for (var i = 0; i < numPages; i++) { 0186 var p = { 0187 number: parseInt(i + 1), 0188 link: baseHref + "/page/" + parseInt(i + 1) + "/ord/" + order 0189 }; 0190 pagination.push(p); 0191 } 0192 0193 if (page < numPages) { 0194 var next = { 0195 number: 'next', 0196 link: baseHref + "/page/" + parseInt(page + 1) + "/ord/" + order 0197 }; 0198 pagination.push(next); 0199 } 0200 0201 return pagination; 0202 } 0203 0204 function calculateProductRatings(ratings) { 0205 var pRating; 0206 var totalUp = 0, 0207 totalDown = 0; 0208 ratings.forEach(function (r, index) { 0209 if (r.rating_active === "1") { 0210 if (r.user_like === "1") { 0211 totalUp += 1; 0212 } else if (r.user_dislike === "1") { 0213 totalDown += 1; 0214 } 0215 } 0216 }); 0217 pRating = 100 / ratings.length * (totalUp - totalDown); 0218 return pRating; 0219 } 0220 0221 function getActiveRatingsNumber(ratings) { 0222 var activeRatingsNumber = 0; 0223 ratings.forEach(function (r, index) { 0224 if (r.rating_active === "1") { 0225 activeRatingsNumber += 1; 0226 } 0227 }); 0228 return activeRatingsNumber; 0229 } 0230 0231 function getFilesSummary(files) { 0232 var summery = { 0233 downloads: 0, 0234 archived: 0, 0235 fileSize: 0, 0236 total: 0 0237 }; 0238 files.forEach(function (file, index) { 0239 summery.total += 1; 0240 summery.fileSize += parseInt(file.size); 0241 summery.downloads += parseInt(file.downloaded_count); 0242 }); 0243 return summery; 0244 } 0245 0246 function checkIfLikedByUser(user, likes) { 0247 var likedByUser = false; 0248 likes.forEach(function (like, index) { 0249 if (user.member_id === like.member_id) { 0250 likedByUser = true; 0251 } 0252 }); 0253 return likedByUser; 0254 } 0255 0256 function getLoggedUserRatingOnProduct(user, ratings) { 0257 var userRating = -1; 0258 ratings.forEach(function (r, index) { 0259 if (r.member_id === user.member_id) { 0260 if (r.user_like === "1") { 0261 userRating = 1; 0262 } else { 0263 userRating = 0; 0264 } 0265 } 0266 }); 0267 return userRating; 0268 } 0269 0270 function calculateProductLaplaceScore(ratings) { 0271 var laplace_score = 0; 0272 var upvotes = 0; 0273 var downvotes = 0; 0274 ratings.forEach(function (rating, index) { 0275 if (rating.rating_active === "1") { 0276 if (rating.user_like === "1") { 0277 upvotes += 1; 0278 } else if (rating.user_like === "0") { 0279 downvotes += 1; 0280 } 0281 } 0282 }); 0283 laplace_score = Math.round((upvotes + 6) / (upvotes + downvotes + 12), 2) * 100; 0284 return laplace_score; 0285 } 0286 0287 return { 0288 getNumberOfProducts: getNumberOfProducts, 0289 generatePaginationObject: generatePaginationObject, 0290 calculateProductRatings: calculateProductRatings, 0291 getActiveRatingsNumber: getActiveRatingsNumber, 0292 getFilesSummary: getFilesSummary, 0293 checkIfLikedByUser: checkIfLikedByUser, 0294 getLoggedUserRatingOnProduct: getLoggedUserRatingOnProduct, 0295 calculateProductLaplaceScore: calculateProductLaplaceScore 0296 }; 0297 }(); 0298 "use strict"; 0299 0300 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); } 0301 0302 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 0303 0304 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); } } 0305 0306 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 0307 0308 function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 0309 0310 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 0311 0312 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 0313 0314 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); } 0315 0316 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 0317 0318 var ProductGroupScrollWrapper = 0319 /*#__PURE__*/ 0320 function (_React$Component) { 0321 _inherits(ProductGroupScrollWrapper, _React$Component); 0322 0323 function ProductGroupScrollWrapper(props) { 0324 var _this; 0325 0326 _classCallCheck(this, ProductGroupScrollWrapper); 0327 0328 _this = _possibleConstructorReturn(this, _getPrototypeOf(ProductGroupScrollWrapper).call(this, props)); 0329 _this.state = { 0330 products: [], 0331 offset: 0 0332 }; 0333 _this.onProductGroupScroll = _this.onProductGroupScroll.bind(_assertThisInitialized(_this)); 0334 _this.loadMoreProducts = _this.loadMoreProducts.bind(_assertThisInitialized(_this)); 0335 return _this; 0336 } 0337 0338 _createClass(ProductGroupScrollWrapper, [{ 0339 key: "componentWillMount", 0340 value: function componentWillMount() { 0341 window.addEventListener("scroll", this.onProductGroupScroll); 0342 } 0343 }, { 0344 key: "componentDidMount", 0345 value: function componentDidMount() { 0346 this.loadMoreProducts(); 0347 } 0348 }, { 0349 key: "onProductGroupScroll", 0350 value: function onProductGroupScroll() { 0351 var end = $("footer").offset().top; 0352 var viewEnd = $(window).scrollTop() + $(window).height(); 0353 var distance = end - viewEnd; 0354 0355 if (distance < 0 && this.state.loadingMoreProducts !== true) { 0356 this.setState({ 0357 loadingMoreProducts: true 0358 }, function () { 0359 this.loadMoreProducts(); 0360 }); 0361 } 0362 } 0363 }, { 0364 key: "loadMoreProducts", 0365 value: function loadMoreProducts() { 0366 var itemsPerScroll = 50; 0367 var moreProducts = store.getState().products.slice(this.state.offset, this.state.offset + itemsPerScroll); 0368 var products = this.state.products.concat(moreProducts); 0369 var offset = this.state.offset + itemsPerScroll; 0370 this.setState({ 0371 products: products, 0372 offset: offset, 0373 loadingMoreProducts: false 0374 }); 0375 } 0376 }, { 0377 key: "render", 0378 value: function render() { 0379 var loadingMoreProductsDisplay; 0380 0381 if (this.state.loadingMoreProducts) { 0382 loadingMoreProductsDisplay = React.createElement("div", { 0383 className: "product-group-scroll-loading-container" 0384 }, React.createElement("div", { 0385 className: "icon-wrapper" 0386 }, React.createElement("span", { 0387 className: "glyphicon glyphicon-refresh spinning" 0388 }))); 0389 } 0390 0391 return React.createElement("div", { 0392 className: "product-group-scroll-wrapper" 0393 }, React.createElement(ProductGroup, { 0394 products: this.state.products, 0395 device: this.props.device 0396 }), loadingMoreProductsDisplay); 0397 } 0398 }]); 0399 0400 return ProductGroupScrollWrapper; 0401 }(React.Component); 0402 0403 var ProductGroup = 0404 /*#__PURE__*/ 0405 function (_React$Component2) { 0406 _inherits(ProductGroup, _React$Component2); 0407 0408 function ProductGroup() { 0409 _classCallCheck(this, ProductGroup); 0410 0411 return _possibleConstructorReturn(this, _getPrototypeOf(ProductGroup).apply(this, arguments)); 0412 } 0413 0414 _createClass(ProductGroup, [{ 0415 key: "render", 0416 value: function render() { 0417 var products; 0418 0419 if (this.props.products) { 0420 var productsArray = this.props.products; 0421 0422 if (this.props.numRows) { 0423 var limit = productHelpers.getNumberOfProducts(this.props.device, this.props.numRows); 0424 productsArray = productsArray.slice(0, limit); 0425 } 0426 0427 products = productsArray.map(function (product, index) { 0428 return React.createElement(ProductGroupItem, { 0429 key: index, 0430 product: product 0431 }); 0432 }); 0433 } 0434 0435 var sectionHeader; 0436 0437 if (this.props.title) { 0438 sectionHeader = React.createElement("div", { 0439 className: "section-header" 0440 }, React.createElement("h3", { 0441 className: "mdl-color-text--primary" 0442 }, this.props.title), React.createElement("div", { 0443 className: "actions" 0444 }, React.createElement("a", { 0445 href: this.props.link, 0446 className: "mdl-button mdl-js-button mdl-button--colored mdl-button--raised mdl-js-ripple-effect mdl-color--primary" 0447 }, "see more"))); 0448 } 0449 0450 return React.createElement("div", { 0451 className: "products-showcase" 0452 }, sectionHeader, React.createElement("div", { 0453 className: "products-container row" 0454 }, products)); 0455 } 0456 }]); 0457 0458 return ProductGroup; 0459 }(React.Component); 0460 0461 var ProductGroupItem = 0462 /*#__PURE__*/ 0463 function (_React$Component3) { 0464 _inherits(ProductGroupItem, _React$Component3); 0465 0466 function ProductGroupItem() { 0467 _classCallCheck(this, ProductGroupItem); 0468 0469 return _possibleConstructorReturn(this, _getPrototypeOf(ProductGroupItem).apply(this, arguments)); 0470 } 0471 0472 _createClass(ProductGroupItem, [{ 0473 key: "render", 0474 value: function render() { 0475 var imageBaseUrl; 0476 0477 if (store.getState().env === 'live') { 0478 imageBaseUrl = 'cn.opendesktop.org'; 0479 } else { 0480 imageBaseUrl = 'cn.pling.it'; 0481 } 0482 0483 return React.createElement("div", { 0484 className: "product square" 0485 }, React.createElement("div", { 0486 className: "content" 0487 }, React.createElement("div", { 0488 className: "product-wrapper mdl-shadow--2dp" 0489 }, React.createElement("a", { 0490 href: "/p/" + this.props.product.project_id 0491 }, React.createElement("div", { 0492 className: "product-image-container" 0493 }, React.createElement("figure", null, React.createElement("img", { 0494 className: "very-rounded-corners", 0495 src: 'https://' + imageBaseUrl + '/cache/200x171/img/' + this.props.product.image_small 0496 }), React.createElement("span", { 0497 className: "product-info-title" 0498 }, this.props.product.title))), React.createElement("div", { 0499 className: "product-info" 0500 }, React.createElement("span", { 0501 className: "product-info-description" 0502 }, this.props.product.description)))))); 0503 } 0504 }]); 0505 0506 return ProductGroupItem; 0507 }(React.Component); 0508 "use strict"; 0509 0510 var reducer = Redux.combineReducers({ 0511 products: productsReducer, 0512 product: productReducer, 0513 lightboxGallery: lightboxGalleryReducer, 0514 pagination: paginationReducer, 0515 topProducts: topProductsReducer, 0516 categories: categoriesReducer, 0517 comments: commentsReducer, 0518 users: usersReducer, 0519 user: userReducer, 0520 supporters: supportersReducer, 0521 domain: domainReducer, 0522 env: envReducer, 0523 device: deviceReducer, 0524 view: viewReducer, 0525 filters: filtersReducer 0526 }); 0527 /* reducers */ 0528 0529 function productsReducer() { 0530 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0531 var action = arguments.length > 1 ? arguments[1] : undefined; 0532 0533 if (action.type === 'SET_PRODUCTS') { 0534 return action.products; 0535 } else { 0536 return state; 0537 } 0538 } 0539 0540 function productReducer() { 0541 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0542 var action = arguments.length > 1 ? arguments[1] : undefined; 0543 0544 if (action.type === 'SET_PRODUCT') { 0545 return action.product; 0546 } else if (action.type === 'SET_PRODUCT_FILES') { 0547 var s = Object.assign({}, state, { 0548 r_files: action.files 0549 }); 0550 return s; 0551 } else if (action.type === 'SET_PRODUCT_UPDATES') { 0552 var _s = Object.assign({}, state, { 0553 r_updates: action.updates 0554 }); 0555 0556 return _s; 0557 } else if (action.type === 'SET_PRODUCT_RATINGS') { 0558 var _s2 = Object.assign({}, state, { 0559 r_ratings: action.ratings 0560 }); 0561 0562 return _s2; 0563 } else if (action.type === 'SET_PRODUCT_LIKES') { 0564 var _s3 = Object.assign({}, state, { 0565 r_likes: action.likes 0566 }); 0567 0568 return _s3; 0569 } else if (action.type === 'SET_PRODUCT_PLINGS') { 0570 var _s4 = Object.assign({}, state, { 0571 r_plings: action.plings 0572 }); 0573 0574 return _s4; 0575 } else if (action.type === 'SET_PRODUCT_USER_RATINGS') { 0576 var _s5 = Object.assign({}, state, { 0577 r_userRatings: action.userRatings 0578 }); 0579 0580 return _s5; 0581 } else if (action.type === 'SET_PRODUCT_GALLERY') { 0582 var _s6 = Object.assign({}, state, { 0583 r_gallery: action.gallery 0584 }); 0585 0586 return _s6; 0587 } else if (action.type === 'SET_PRODUCT_COMMENTS') { 0588 var _s7 = Object.assign({}, state, { 0589 r_comments: action.comments 0590 }); 0591 0592 return _s7; 0593 } else if (action.type === 'SET_PRODUCT_ORIGINS') { 0594 var _s8 = Object.assign({}, state, { 0595 r_origins: action.origins 0596 }); 0597 0598 return _s8; 0599 } else if (action.type === 'SET_PRODUCT_RELATED') { 0600 var _s9 = Object.assign({}, state, { 0601 r_related: action.related 0602 }); 0603 0604 return _s9; 0605 } else if (action.type === 'SET_PRODUCT_MORE_PRODUCTS') { 0606 var _s10 = Object.assign({}, state, { 0607 r_more_products: action.products 0608 }); 0609 0610 return _s10; 0611 } else if (action.type === 'SET_PRODUCT_MORE_PRODUCTS_OTHER_USERS') { 0612 var _s11 = Object.assign({}, state, { 0613 r_more_products_other_users: action.products 0614 }); 0615 0616 return _s11; 0617 } else if (action.type === 'SET_PRODUCT_TAGS') { 0618 var _s12 = Object.assign({}, state, { 0619 r_tags_user: action.userTags, 0620 r_tags_system: action.systemTags 0621 }); 0622 0623 return _s12; 0624 } else { 0625 return state; 0626 } 0627 } 0628 0629 function lightboxGalleryReducer() { 0630 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0631 var action = arguments.length > 1 ? arguments[1] : undefined; 0632 0633 if (action.type === 'SHOW_LIGHTBOX') { 0634 var s = Object.assign({}, state, { 0635 show: true, 0636 currentItem: action.item 0637 }); 0638 return s; 0639 } else if (action.type === 'HIDE_LIGHTBOX') { 0640 var _s13 = Object.assign({}, state, { 0641 show: false 0642 }); 0643 0644 return _s13; 0645 } else { 0646 return state; 0647 } 0648 } 0649 0650 function paginationReducer() { 0651 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0652 var action = arguments.length > 1 ? arguments[1] : undefined; 0653 0654 if (action.type === 'SET_PAGINATION') { 0655 return action.pagination; 0656 } else { 0657 return state; 0658 } 0659 } 0660 0661 function topProductsReducer() { 0662 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0663 var action = arguments.length > 1 ? arguments[1] : undefined; 0664 0665 if (action.type === 'SET_TOP_PRODUCTS') { 0666 return action.products; 0667 } else { 0668 return state; 0669 } 0670 } 0671 0672 function categoriesReducer() { 0673 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0674 var action = arguments.length > 1 ? arguments[1] : undefined; 0675 0676 if (action.type === 'SET_CATEGORIES') { 0677 var s = Object.assign({}, state, { 0678 items: categories 0679 }); 0680 return s; 0681 } else if (action.type === 'SET_CURRENT_CAT') { 0682 var _s14 = Object.assign({}, state, { 0683 current: action.cat 0684 }); 0685 0686 return _s14; 0687 } else if (action.type === 'SET_CURRENT_SUBCAT') { 0688 var _s15 = Object.assign({}, state, { 0689 currentSub: action.cat 0690 }); 0691 0692 return _s15; 0693 } else if (action.type === 'SET_CURRENT_SECONDSUBCAT') { 0694 var _s16 = Object.assign({}, state, { 0695 currentSecondSub: action.cat 0696 }); 0697 0698 return _s16; 0699 } else { 0700 return state; 0701 } 0702 } 0703 0704 function commentsReducer() { 0705 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0706 var action = arguments.length > 1 ? arguments[1] : undefined; 0707 0708 if (action.type === 'SET_COMMENTS') { 0709 return action.comments; 0710 } else { 0711 return state; 0712 } 0713 } 0714 0715 function usersReducer() { 0716 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0717 var action = arguments.length > 1 ? arguments[1] : undefined; 0718 0719 if (action.type === 'SET_USERS') { 0720 return action.users; 0721 } else { 0722 return state; 0723 } 0724 } 0725 0726 function userReducer() { 0727 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0728 var action = arguments.length > 1 ? arguments[1] : undefined; 0729 0730 if (action.type === 'SET_USER') { 0731 return action.user; 0732 } else { 0733 return state; 0734 } 0735 } 0736 0737 function supportersReducer() { 0738 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0739 var action = arguments.length > 1 ? arguments[1] : undefined; 0740 0741 if (action.type === 'SET_SUPPORTERS') { 0742 return action.supporters; 0743 } else { 0744 return state; 0745 } 0746 } 0747 0748 function domainReducer() { 0749 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0750 var action = arguments.length > 1 ? arguments[1] : undefined; 0751 0752 if (action.type === 'SET_DOMAIN') { 0753 return action.domain; 0754 } else { 0755 return state; 0756 } 0757 } 0758 0759 function envReducer() { 0760 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0761 var action = arguments.length > 1 ? arguments[1] : undefined; 0762 0763 if (action.type === 'SET_ENV') { 0764 return action.env; 0765 } else { 0766 return state; 0767 } 0768 } 0769 0770 function deviceReducer() { 0771 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0772 var action = arguments.length > 1 ? arguments[1] : undefined; 0773 0774 if (action.type === 'SET_DEVICE') { 0775 return action.device; 0776 } else { 0777 return state; 0778 } 0779 } 0780 0781 function viewReducer() { 0782 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0783 var action = arguments.length > 1 ? arguments[1] : undefined; 0784 0785 if (action.type === 'SET_VIEW') { 0786 return action.view; 0787 } else { 0788 return state; 0789 } 0790 } 0791 0792 function filtersReducer() { 0793 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 0794 var action = arguments.length > 1 ? arguments[1] : undefined; 0795 0796 if (action.type === 'SET_FILTERS') { 0797 return action.filters; 0798 } else { 0799 return state; 0800 } 0801 } 0802 /* /reducers */ 0803 0804 /* dispatch */ 0805 0806 0807 function setProducts(products) { 0808 return { 0809 type: 'SET_PRODUCTS', 0810 products: products 0811 }; 0812 } 0813 0814 function setProduct(product) { 0815 return { 0816 type: 'SET_PRODUCT', 0817 product: product 0818 }; 0819 } 0820 0821 function setProductFiles(files) { 0822 return { 0823 type: 'SET_PRODUCT_FILES', 0824 files: files 0825 }; 0826 } 0827 0828 function setProductUpdates(updates) { 0829 return { 0830 type: 'SET_PRODUCT_UPDATES', 0831 updates: updates 0832 }; 0833 } 0834 0835 function setProductRatings(ratings) { 0836 return { 0837 type: 'SET_PRODUCT_RATINGS', 0838 ratings: ratings 0839 }; 0840 } 0841 0842 function setProductLikes(likes) { 0843 return { 0844 type: 'SET_PRODUCT_LIKES', 0845 likes: likes 0846 }; 0847 } 0848 0849 function setProductPlings(plings) { 0850 return { 0851 type: 'SET_PRODUCT_PLINGS', 0852 plings: plings 0853 }; 0854 } 0855 0856 function setProductUserRatings(userRatings) { 0857 return { 0858 type: 'SET_PRODUCT_USER_RATINGS', 0859 userRatings: userRatings 0860 }; 0861 } 0862 0863 function setProductGallery(gallery) { 0864 return { 0865 type: 'SET_PRODUCT_GALLERY', 0866 gallery: gallery 0867 }; 0868 } 0869 0870 function setProductComments(comments) { 0871 return { 0872 type: 'SET_PRODUCT_COMMENTS', 0873 comments: comments 0874 }; 0875 } 0876 0877 function setProductOrigins(origins) { 0878 return { 0879 type: 'SET_PRODUCT_ORIGINS', 0880 origins: origins 0881 }; 0882 } 0883 0884 function setProductRelated(related) { 0885 return { 0886 type: 'SET_PRODUCT_RELATED', 0887 related: related 0888 }; 0889 } 0890 0891 function setProductMoreProducts(products) { 0892 return { 0893 type: 'SET_PRODUCT_MORE_PRODUCTS', 0894 products: products 0895 }; 0896 } 0897 0898 function setProductMoreProductsOtherUsers(products) { 0899 return { 0900 type: 'SET_PRODUCT_MORE_PRODUCTS_OTHER_USERS', 0901 products: products 0902 }; 0903 } 0904 0905 function setProductTags(userTags, systemTags) { 0906 return { 0907 type: 'SET_PRODUCT_TAGS', 0908 userTags: userTags, 0909 systemTags: systemTags 0910 }; 0911 } 0912 0913 function showLightboxGallery(num) { 0914 return { 0915 type: 'SHOW_LIGHTBOX', 0916 item: num 0917 }; 0918 } 0919 0920 function hideLightboxGallery() { 0921 return { 0922 type: 'HIDE_LIGHTBOX' 0923 }; 0924 } 0925 0926 function setPagination(pagination) { 0927 return { 0928 type: 'SET_PAGINATION', 0929 pagination: pagination 0930 }; 0931 } 0932 0933 function setTopProducts(topProducts) { 0934 return { 0935 type: 'SET_TOP_PRODUCTS', 0936 products: topProducts 0937 }; 0938 } 0939 0940 function setCategories(categories) { 0941 return { 0942 type: 'SET_CATEGORIES', 0943 categories: categories 0944 }; 0945 } 0946 0947 function setCurrentCategory(cat) { 0948 return { 0949 type: 'SET_CURRENT_CAT', 0950 cat: cat 0951 }; 0952 } 0953 0954 function setCurrentSubCategory(cat) { 0955 return { 0956 type: 'SET_CURRENT_SUBCAT', 0957 cat: cat 0958 }; 0959 } 0960 0961 function setCurrentSecondSubCategory(cat) { 0962 return { 0963 type: 'SET_CURRENT_SECONDSUBCAT', 0964 cat: cat 0965 }; 0966 } 0967 0968 function setComments(comments) { 0969 return { 0970 type: 'SET_COMMENTS', 0971 comments: comments 0972 }; 0973 } 0974 0975 function setUsers(users) { 0976 return { 0977 type: 'SET_USERS', 0978 users: users 0979 }; 0980 } 0981 0982 function setUser(user) { 0983 return { 0984 type: 'SET_USER', 0985 user: user 0986 }; 0987 } 0988 0989 function setSupporters(supporters) { 0990 return { 0991 type: 'SET_SUPPORTERS', 0992 supporters: supporters 0993 }; 0994 } 0995 0996 function setDomain(domain) { 0997 return { 0998 type: 'SET_DOMAIN', 0999 domain: domain 1000 }; 1001 } 1002 1003 function setEnv(env) { 1004 return { 1005 type: 'SET_ENV', 1006 env: env 1007 }; 1008 } 1009 1010 function setDevice(device) { 1011 return { 1012 type: 'SET_DEVICE', 1013 device: device 1014 }; 1015 } 1016 1017 function setView(view) { 1018 return { 1019 type: 'SET_VIEW', 1020 view: view 1021 }; 1022 } 1023 1024 function setFilters(filters) { 1025 return { 1026 type: 'SET_FILTERS', 1027 filters: filters 1028 }; 1029 } 1030 /* /dispatch */ 1031 "use strict"; 1032 1033 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); } 1034 1035 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1036 1037 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); } } 1038 1039 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 1040 1041 function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 1042 1043 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 1044 1045 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 1046 1047 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); } 1048 1049 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 1050 1051 var ExplorePage = 1052 /*#__PURE__*/ 1053 function (_React$Component) { 1054 _inherits(ExplorePage, _React$Component); 1055 1056 function ExplorePage(props) { 1057 var _this; 1058 1059 _classCallCheck(this, ExplorePage); 1060 1061 _this = _possibleConstructorReturn(this, _getPrototypeOf(ExplorePage).call(this, props)); 1062 _this.state = { 1063 device: store.getState().device, 1064 minHeight: 'auto' 1065 }; 1066 _this.updateContainerHeight = _this.updateContainerHeight.bind(_assertThisInitialized(_this)); 1067 return _this; 1068 } 1069 1070 _createClass(ExplorePage, [{ 1071 key: "componentWillReceiveProps", 1072 value: function componentWillReceiveProps(nextProps) { 1073 if (nextProps.device) { 1074 this.setState({ 1075 device: nextProps.device 1076 }); 1077 } 1078 1079 if (nextProps.products) { 1080 this.setState({ 1081 products: nextProps.products 1082 }); 1083 } 1084 1085 if (nextProps.filters) { 1086 this.setState({ 1087 filters: filters 1088 }); 1089 } 1090 } 1091 }, { 1092 key: "updateContainerHeight", 1093 value: function updateContainerHeight(sideBarHeight) { 1094 this.setState({ 1095 minHeight: sideBarHeight + 100 1096 }); 1097 } 1098 }, { 1099 key: "render", 1100 value: function render() { 1101 var titleDisplay; 1102 1103 if (this.props.categories) { 1104 var title = ""; 1105 1106 if (this.props.categories.currentSecondSub) { 1107 title = this.props.categories.currentSecondSub.title; 1108 } else { 1109 if (this.props.categories.currentSub) { 1110 title = this.props.categories.currentSub.title; 1111 } else { 1112 if (this.props.categories.current) { 1113 title = this.props.categories.current.title; 1114 } 1115 } 1116 } 1117 1118 if (title.length > 0) { 1119 titleDisplay = React.createElement("div", { 1120 className: "explore-page-category-title" 1121 }, React.createElement("h2", null, title), React.createElement("small", null, store.getState().pagination.totalcount, " results")); 1122 } 1123 } 1124 1125 return React.createElement("div", { 1126 id: "explore-page" 1127 }, React.createElement("div", { 1128 className: "wrapper" 1129 }, React.createElement("div", { 1130 className: "main-content-container", 1131 style: { 1132 "minHeight": this.state.minHeight 1133 } 1134 }, React.createElement("div", { 1135 className: "left-sidebar-container" 1136 }, React.createElement(ExploreLeftSideBarWrapper, { 1137 updateContainerHeight: this.updateContainerHeight 1138 })), React.createElement("div", { 1139 className: "main-content" 1140 }, titleDisplay, React.createElement("div", { 1141 className: "top-bar" 1142 }, React.createElement(ExploreTopBarWrapper, null)), React.createElement("div", { 1143 className: "explore-products-container" 1144 }, React.createElement(ProductGroupScrollWrapper, { 1145 device: this.state.device 1146 }), React.createElement(PaginationWrapper, null)))), React.createElement("div", { 1147 className: "right-sidebar-container" 1148 }, React.createElement(ExploreRightSideBarWrapper, null)))); 1149 } 1150 }]); 1151 1152 return ExplorePage; 1153 }(React.Component); 1154 1155 var mapStateToExploreProps = function mapStateToExploreProps(state) { 1156 var device = state.device; 1157 var products = state.products; 1158 var categories = state.categories; 1159 return { 1160 device: device, 1161 products: products, 1162 categories: categories 1163 }; 1164 }; 1165 1166 var mapDispatchToExploreProps = function mapDispatchToExploreProps(dispatch) { 1167 return { 1168 dispatch: dispatch 1169 }; 1170 }; 1171 1172 var ExplorePageWrapper = ReactRedux.connect(mapStateToExploreProps, mapDispatchToExploreProps)(ExplorePage); 1173 1174 var ExploreTopBar = 1175 /*#__PURE__*/ 1176 function (_React$Component2) { 1177 _inherits(ExploreTopBar, _React$Component2); 1178 1179 function ExploreTopBar(props) { 1180 var _this2; 1181 1182 _classCallCheck(this, ExploreTopBar); 1183 1184 _this2 = _possibleConstructorReturn(this, _getPrototypeOf(ExploreTopBar).call(this, props)); 1185 _this2.state = {}; 1186 return _this2; 1187 } 1188 1189 _createClass(ExploreTopBar, [{ 1190 key: "render", 1191 value: function render() { 1192 var categories = this.props.categories; 1193 var currentId; 1194 1195 if (categories.current) { 1196 currentId = categories.current.id; 1197 } 1198 1199 if (categories.currentSub) { 1200 currentId = categories.currentSub.id; 1201 } 1202 1203 if (categories.currentSecondSub) { 1204 currentId = categories.currentSecondSub.id; 1205 } 1206 1207 var link = appHelpers.generateFilterUrl(window.location, currentId); 1208 var linkSearch = ""; 1209 1210 if (link.search) { 1211 linkSearch = link.search; 1212 } 1213 1214 return React.createElement("div", { 1215 className: "explore-top-bar" 1216 }, React.createElement("a", { 1217 href: link.base + "latest" + linkSearch, 1218 className: this.props.filters.order === "latest" ? "item active" : "item" 1219 }, "Latest"), React.createElement("a", { 1220 href: link.base + "top" + linkSearch, 1221 className: this.props.filters.order === "top" ? "item active" : "item" 1222 }, "Top")); 1223 } 1224 }]); 1225 1226 return ExploreTopBar; 1227 }(React.Component); 1228 1229 var mapStateToExploreTopBarProps = function mapStateToExploreTopBarProps(state) { 1230 var filters = state.filters; 1231 var categories = state.categories; 1232 return { 1233 filters: filters, 1234 categories: categories 1235 }; 1236 }; 1237 1238 var mapDispatchToExploreTopBarProps = function mapDispatchToExploreTopBarProps(dispatch) { 1239 return { 1240 dispatch: dispatch 1241 }; 1242 }; 1243 1244 var ExploreTopBarWrapper = ReactRedux.connect(mapStateToExploreTopBarProps, mapDispatchToExploreTopBarProps)(ExploreTopBar); 1245 1246 var ExploreLeftSideBar = 1247 /*#__PURE__*/ 1248 function (_React$Component3) { 1249 _inherits(ExploreLeftSideBar, _React$Component3); 1250 1251 function ExploreLeftSideBar(props) { 1252 var _this3; 1253 1254 _classCallCheck(this, ExploreLeftSideBar); 1255 1256 _this3 = _possibleConstructorReturn(this, _getPrototypeOf(ExploreLeftSideBar).call(this, props)); 1257 _this3.state = {}; 1258 return _this3; 1259 } 1260 1261 _createClass(ExploreLeftSideBar, [{ 1262 key: "componentDidMount", 1263 value: function componentDidMount() { 1264 var sideBarHeight = $('#left-sidebar').height(); 1265 this.props.updateContainerHeight(sideBarHeight); 1266 } 1267 }, { 1268 key: "render", 1269 value: function render() { 1270 var categoryTree; 1271 1272 if (this.props.categories) { 1273 categoryTree = this.props.categories.items.map(function (cat, index) { 1274 return React.createElement(ExploreSideBarItem, { 1275 key: index, 1276 category: cat 1277 }); 1278 }); 1279 } 1280 1281 return React.createElement("aside", { 1282 className: "explore-left-sidebar", 1283 id: "left-sidebar" 1284 }, React.createElement("ul", null, React.createElement("li", { 1285 className: "category-item" 1286 }, React.createElement("a", { 1287 className: this.props.categories.current === 0 ? "active" : "", 1288 href: "/browse/ord/" + filters.order 1289 }, React.createElement("span", { 1290 className: "title" 1291 }, "All"))), categoryTree)); 1292 } 1293 }]); 1294 1295 return ExploreLeftSideBar; 1296 }(React.Component); 1297 1298 var mapStateToExploreLeftSideBarProps = function mapStateToExploreLeftSideBarProps(state) { 1299 var categories = state.categories; 1300 var filters = state.filters; 1301 return { 1302 categories: categories 1303 }; 1304 }; 1305 1306 var mapDispatchToExploreLeftSideBarProps = function mapDispatchToExploreLeftSideBarProps(dispatch) { 1307 return { 1308 dispatch: dispatch 1309 }; 1310 }; 1311 1312 var ExploreLeftSideBarWrapper = ReactRedux.connect(mapStateToExploreLeftSideBarProps, mapDispatchToExploreLeftSideBarProps)(ExploreLeftSideBar); 1313 1314 var ExploreSideBarItem = 1315 /*#__PURE__*/ 1316 function (_React$Component4) { 1317 _inherits(ExploreSideBarItem, _React$Component4); 1318 1319 function ExploreSideBarItem() { 1320 _classCallCheck(this, ExploreSideBarItem); 1321 1322 return _possibleConstructorReturn(this, _getPrototypeOf(ExploreSideBarItem).apply(this, arguments)); 1323 } 1324 1325 _createClass(ExploreSideBarItem, [{ 1326 key: "render", 1327 value: function render() { 1328 var order = store.getState().filters.order; 1329 var categories = store.getState().categories; 1330 var currentId, currentSubId, currentSecondSubId; 1331 1332 if (categories.current) { 1333 currentId = categories.current.id; 1334 } 1335 1336 if (categories.currentSub) { 1337 currentSubId = categories.currentSub.id; 1338 } 1339 1340 if (categories.currentSecondSub) { 1341 currentSecondSubId = categories.currentSecondSub.id; 1342 } 1343 1344 var active; 1345 1346 if (currentId === this.props.category.id || currentSubId === this.props.category.id || currentSecondSubId === this.props.category.id) { 1347 active = true; 1348 } 1349 1350 var subcatMenu; 1351 1352 if (this.props.category.has_children === true && active) { 1353 var cArray = categoryHelpers.convertCatChildrenObjectToArray(this.props.category.children); 1354 var subcategories = cArray.map(function (cat, index) { 1355 return React.createElement(ExploreSideBarItem, { 1356 key: index, 1357 category: cat 1358 }); 1359 }); 1360 subcatMenu = React.createElement("ul", null, subcategories); 1361 } 1362 1363 return React.createElement("li", { 1364 className: "category-item" 1365 }, React.createElement("a", { 1366 className: active === true ? "active" : "", 1367 href: "/browse/cat/" + this.props.category.id + "/ord/" + order + window.location.search 1368 }, React.createElement("span", { 1369 className: "title" 1370 }, this.props.category.title), React.createElement("span", { 1371 className: "product-counter" 1372 }, this.props.category.product_count)), subcatMenu); 1373 } 1374 }]); 1375 1376 return ExploreSideBarItem; 1377 }(React.Component); 1378 1379 var Pagination = 1380 /*#__PURE__*/ 1381 function (_React$Component5) { 1382 _inherits(Pagination, _React$Component5); 1383 1384 function Pagination(props) { 1385 var _this4; 1386 1387 _classCallCheck(this, Pagination); 1388 1389 _this4 = _possibleConstructorReturn(this, _getPrototypeOf(Pagination).call(this, props)); 1390 _this4.state = {}; 1391 return _this4; 1392 } 1393 1394 _createClass(Pagination, [{ 1395 key: "componentDidMount", 1396 value: function componentDidMount() { 1397 var itemsPerPage = 50; 1398 var numPages = Math.ceil(this.props.pagination.totalcount / itemsPerPage); 1399 var pagination = productHelpers.generatePaginationObject(numPages, window.location.pathname, this.props.currentCategoy, this.props.filters.order, this.props.pagination.page); 1400 this.setState({ 1401 pagination: pagination 1402 }, function () {}); 1403 } 1404 }, { 1405 key: "render", 1406 value: function render() { 1407 var _this5 = this; 1408 1409 var paginationDisplay; 1410 1411 if (this.state.pagination && this.props.pagination.totalcount > 50) { 1412 var pagination = this.state.pagination.map(function (pi, index) { 1413 var numberDisplay; 1414 1415 if (pi.number === 'previous') { 1416 numberDisplay = React.createElement("span", { 1417 className: "num-wrap" 1418 }, React.createElement("i", { 1419 className: "material-icons" 1420 }, "arrow_back_ios"), React.createElement("span", null, pi.number)); 1421 } else if (pi.number === 'next') { 1422 numberDisplay = React.createElement("span", { 1423 className: "num-wrap" 1424 }, React.createElement("span", null, pi.number), React.createElement("i", { 1425 className: "material-icons" 1426 }, "arrow_forward_ios")); 1427 } else { 1428 numberDisplay = pi.number; 1429 } 1430 1431 var cssClass; 1432 1433 if (pi.number === _this5.props.pagination.page) { 1434 cssClass = "active"; 1435 } 1436 1437 return React.createElement("li", { 1438 key: index 1439 }, React.createElement("a", { 1440 href: pi.link, 1441 className: cssClass 1442 }, numberDisplay)); 1443 }); 1444 paginationDisplay = React.createElement("ul", null, pagination); 1445 } 1446 1447 return React.createElement("div", { 1448 id: "pagination-container" 1449 }, React.createElement("div", { 1450 className: "wrapper" 1451 }, paginationDisplay)); 1452 } 1453 }]); 1454 1455 return Pagination; 1456 }(React.Component); 1457 1458 var mapStateToPaginationProps = function mapStateToPaginationProps(state) { 1459 var pagination = state.pagination; 1460 var filters = state.filters; 1461 var currentCategoy = state.categories.current; 1462 return { 1463 pagination: pagination, 1464 filters: filters, 1465 currentCategoy: currentCategoy 1466 }; 1467 }; 1468 1469 var mapDispatchToPaginationProps = function mapDispatchToPaginationProps(dispatch) { 1470 return { 1471 dispatch: dispatch 1472 }; 1473 }; 1474 1475 var PaginationWrapper = ReactRedux.connect(mapStateToPaginationProps, mapDispatchToPaginationProps)(Pagination); 1476 1477 var ExploreRightSideBar = 1478 /*#__PURE__*/ 1479 function (_React$Component6) { 1480 _inherits(ExploreRightSideBar, _React$Component6); 1481 1482 function ExploreRightSideBar(props) { 1483 var _this6; 1484 1485 _classCallCheck(this, ExploreRightSideBar); 1486 1487 _this6 = _possibleConstructorReturn(this, _getPrototypeOf(ExploreRightSideBar).call(this, props)); 1488 _this6.state = {}; 1489 return _this6; 1490 } 1491 1492 _createClass(ExploreRightSideBar, [{ 1493 key: "render", 1494 value: function render() { 1495 return React.createElement("aside", { 1496 className: "explore-right-sidebar" 1497 }, React.createElement("div", { 1498 className: "ers-section" 1499 }, React.createElement("a", { 1500 href: "https://www.opendesktop.org/p/1175480/", 1501 target: "_blank" 1502 }, React.createElement("img", { 1503 id: "download-app", 1504 src: "/images/system/download-app.png" 1505 }))), React.createElement("div", { 1506 className: "ers-section" 1507 }, React.createElement("a", { 1508 href: "/support", 1509 id: "become-a-supporter", 1510 className: "mdl-button mdl-js-button mdl-button--colored mdl-button--raised mdl-js-ripple-effect mdl-color--primary" 1511 }, "Become a supporter")), React.createElement("div", { 1512 className: "ers-section" 1513 }, React.createElement(ExploreSupportersContainerWrapper, null)), React.createElement("div", { 1514 className: "ers-section" 1515 }, React.createElement(RssNewsContainer, null)), React.createElement("div", { 1516 className: "ers-section" 1517 }, React.createElement(BlogFeedContainer, null)), React.createElement("div", { 1518 className: "ers-section" 1519 }, React.createElement(ExploreCommentsContainerWrapper, null)), React.createElement("div", { 1520 className: "ers-section" 1521 }, React.createElement(ExploreTopProductsWrapper, null))); 1522 } 1523 }]); 1524 1525 return ExploreRightSideBar; 1526 }(React.Component); 1527 1528 var mapStateToExploreRightSideBarProps = function mapStateToExploreRightSideBarProps(state) { 1529 var categories = state.categories; 1530 var filters = state.filters; 1531 return { 1532 categories: categories 1533 }; 1534 }; 1535 1536 var mapDispatchToExploreRightSideBarProps = function mapDispatchToExploreRightSideBarProps(dispatch) { 1537 return { 1538 dispatch: dispatch 1539 }; 1540 }; 1541 1542 var ExploreRightSideBarWrapper = ReactRedux.connect(mapStateToExploreRightSideBarProps, mapDispatchToExploreRightSideBarProps)(ExploreRightSideBar); 1543 1544 var ExploreSupportersContainer = 1545 /*#__PURE__*/ 1546 function (_React$Component7) { 1547 _inherits(ExploreSupportersContainer, _React$Component7); 1548 1549 function ExploreSupportersContainer(props) { 1550 var _this7; 1551 1552 _classCallCheck(this, ExploreSupportersContainer); 1553 1554 _this7 = _possibleConstructorReturn(this, _getPrototypeOf(ExploreSupportersContainer).call(this, props)); 1555 _this7.state = {}; 1556 return _this7; 1557 } 1558 1559 _createClass(ExploreSupportersContainer, [{ 1560 key: "render", 1561 value: function render() { 1562 var supportersContainer; 1563 1564 if (this.props.supporters) { 1565 var cArray = categoryHelpers.convertCatChildrenObjectToArray(this.props.supporters); 1566 var supporters = cArray.map(function (sp, index) { 1567 return React.createElement("div", { 1568 className: "supporter-item", 1569 key: index 1570 }, React.createElement("a", { 1571 href: "/member/" + sp.member_id, 1572 className: "item" 1573 }, React.createElement("img", { 1574 src: sp.profile_image_url 1575 }))); 1576 }); 1577 supportersContainer = React.createElement("div", { 1578 className: "supporter-list-wrapper" 1579 }, supporters); 1580 } 1581 1582 return React.createElement("div", { 1583 id: "supporters-container", 1584 className: "sidebar-feed-container" 1585 }, React.createElement("h3", null, this.props.supporters.length, " people support those who create freedom"), supportersContainer); 1586 } 1587 }]); 1588 1589 return ExploreSupportersContainer; 1590 }(React.Component); 1591 1592 var mapStateToExploreSupportersContainerProps = function mapStateToExploreSupportersContainerProps(state) { 1593 var supporters = state.supporters; 1594 return { 1595 supporters: supporters 1596 }; 1597 }; 1598 1599 var mapDispatchToExploreSupportersContainerProps = function mapDispatchToExploreSupportersContainerProps(dispatch) { 1600 return { 1601 dispatch: dispatch 1602 }; 1603 }; 1604 1605 var ExploreSupportersContainerWrapper = ReactRedux.connect(mapStateToExploreSupportersContainerProps, mapDispatchToExploreSupportersContainerProps)(ExploreSupportersContainer); 1606 1607 var RssNewsContainer = 1608 /*#__PURE__*/ 1609 function (_React$Component8) { 1610 _inherits(RssNewsContainer, _React$Component8); 1611 1612 function RssNewsContainer(props) { 1613 var _this8; 1614 1615 _classCallCheck(this, RssNewsContainer); 1616 1617 _this8 = _possibleConstructorReturn(this, _getPrototypeOf(RssNewsContainer).call(this, props)); 1618 _this8.state = {}; 1619 return _this8; 1620 } 1621 1622 _createClass(RssNewsContainer, [{ 1623 key: "componentDidMount", 1624 value: function componentDidMount() { 1625 var self = this; 1626 $.getJSON("https://blog.opendesktop.org/?json=1&callback=?", function (res) { 1627 self.setState({ 1628 items: res.posts 1629 }); 1630 }); 1631 } 1632 }, { 1633 key: "render", 1634 value: function render() { 1635 var feedItemsContainer; 1636 1637 if (this.state.items) { 1638 var feedItems = this.state.items.slice(0, 3).map(function (fi, index) { 1639 return React.createElement("li", { 1640 key: index 1641 }, React.createElement("a", { 1642 className: "title", 1643 href: fi.url 1644 }, React.createElement("span", null, fi.title)), React.createElement("span", { 1645 className: "info-row" 1646 }, React.createElement("span", { 1647 className: "date" 1648 }, appHelpers.getTimeAgo(fi.date)), React.createElement("span", { 1649 className: "comment-counter" 1650 }, fi.comment_count, " comments"))); 1651 }); 1652 feedItemsContainer = React.createElement("ul", null, feedItems); 1653 } 1654 1655 return React.createElement("div", { 1656 id: "rss-new-container", 1657 className: "sidebar-feed-container" 1658 }, React.createElement("h3", null, "News"), feedItemsContainer); 1659 } 1660 }]); 1661 1662 return RssNewsContainer; 1663 }(React.Component); 1664 1665 var BlogFeedContainer = 1666 /*#__PURE__*/ 1667 function (_React$Component9) { 1668 _inherits(BlogFeedContainer, _React$Component9); 1669 1670 function BlogFeedContainer(props) { 1671 var _this9; 1672 1673 _classCallCheck(this, BlogFeedContainer); 1674 1675 _this9 = _possibleConstructorReturn(this, _getPrototypeOf(BlogFeedContainer).call(this, props)); 1676 _this9.state = {}; 1677 return _this9; 1678 } 1679 1680 _createClass(BlogFeedContainer, [{ 1681 key: "componentDidMount", 1682 value: function componentDidMount() { 1683 var self = this; 1684 $.ajax("https://forum.opendesktop.org/latest.json").then(function (result) { 1685 var topics = result.topic_list.topics; 1686 topics.sort(function (a, b) { 1687 return new Date(b.last_posted_at) - new Date(a.last_posted_at); 1688 }); 1689 topics = topics.slice(0, 3); 1690 self.setState({ 1691 items: topics 1692 }); 1693 }); 1694 } 1695 }, { 1696 key: "render", 1697 value: function render() { 1698 var feedItemsContainer; 1699 1700 if (this.state.items) { 1701 var feedItems = this.state.items.map(function (fi, index) { 1702 return React.createElement("li", { 1703 key: index 1704 }, React.createElement("a", { 1705 className: "title", 1706 href: "https://forum.opendesktop.org//t/" + fi.id 1707 }, React.createElement("span", null, fi.title)), React.createElement("span", { 1708 className: "info-row" 1709 }, React.createElement("span", { 1710 className: "date" 1711 }, appHelpers.getTimeAgo(fi.created_at)), React.createElement("span", { 1712 className: "comment-counter" 1713 }, fi.reply_count, " replies"))); 1714 }); 1715 feedItemsContainer = React.createElement("ul", null, feedItems); 1716 } 1717 1718 return React.createElement("div", { 1719 id: "blog-feed-container", 1720 className: "sidebar-feed-container" 1721 }, React.createElement("h3", null, "Forum"), feedItemsContainer); 1722 } 1723 }]); 1724 1725 return BlogFeedContainer; 1726 }(React.Component); 1727 1728 var ExploreCommentsContainer = 1729 /*#__PURE__*/ 1730 function (_React$Component10) { 1731 _inherits(ExploreCommentsContainer, _React$Component10); 1732 1733 function ExploreCommentsContainer(props) { 1734 var _this10; 1735 1736 _classCallCheck(this, ExploreCommentsContainer); 1737 1738 _this10 = _possibleConstructorReturn(this, _getPrototypeOf(ExploreCommentsContainer).call(this, props)); 1739 _this10.state = {}; 1740 return _this10; 1741 } 1742 1743 _createClass(ExploreCommentsContainer, [{ 1744 key: "render", 1745 value: function render() { 1746 var commentsContainer; 1747 1748 if (this.props.comments) { 1749 var comments = this.props.comments.map(function (cm, index) { 1750 return React.createElement("li", { 1751 key: index 1752 }, React.createElement("div", { 1753 className: "cm-content" 1754 }, React.createElement("span", { 1755 className: "cm-userinfo" 1756 }, React.createElement("img", { 1757 src: cm.profile_image_url 1758 }), React.createElement("span", { 1759 className: "username" 1760 }, React.createElement("a", { 1761 href: "/p/" + cm.comment_target_id 1762 }, cm.username))), React.createElement("a", { 1763 className: "title", 1764 href: "/member/" + cm.member_id 1765 }, React.createElement("span", null, cm.title)), React.createElement("span", { 1766 className: "content" 1767 }, cm.comment_text), React.createElement("span", { 1768 className: "info-row" 1769 }, React.createElement("span", { 1770 className: "date" 1771 }, appHelpers.getTimeAgo(cm.comment_created_at))))); 1772 }); 1773 commentsContainer = React.createElement("ul", null, comments); 1774 } 1775 1776 return React.createElement("div", { 1777 id: "blog-feed-container", 1778 className: "sidebar-feed-container" 1779 }, React.createElement("h3", null, "Forum"), commentsContainer); 1780 } 1781 }]); 1782 1783 return ExploreCommentsContainer; 1784 }(React.Component); 1785 1786 var mapStateToExploreCommentsContainerProps = function mapStateToExploreCommentsContainerProps(state) { 1787 var comments = state.comments; 1788 return { 1789 comments: comments 1790 }; 1791 }; 1792 1793 var mapDispatchToExploreCommentsContainerProps = function mapDispatchToExploreCommentsContainerProps(dispatch) { 1794 return { 1795 dispatch: dispatch 1796 }; 1797 }; 1798 1799 var ExploreCommentsContainerWrapper = ReactRedux.connect(mapStateToExploreCommentsContainerProps, mapDispatchToExploreCommentsContainerProps)(ExploreCommentsContainer); 1800 1801 var ExploreTopProducts = 1802 /*#__PURE__*/ 1803 function (_React$Component11) { 1804 _inherits(ExploreTopProducts, _React$Component11); 1805 1806 function ExploreTopProducts(props) { 1807 var _this11; 1808 1809 _classCallCheck(this, ExploreTopProducts); 1810 1811 _this11 = _possibleConstructorReturn(this, _getPrototypeOf(ExploreTopProducts).call(this, props)); 1812 _this11.state = {}; 1813 return _this11; 1814 } 1815 1816 _createClass(ExploreTopProducts, [{ 1817 key: "render", 1818 value: function render() { 1819 var topProductsContainer; 1820 1821 if (this.props.topProducts) { 1822 var imageBaseUrl; 1823 1824 if (store.getState().env === 'live') { 1825 imageBaseUrl = 'cn.opendesktop.org'; 1826 } else { 1827 imageBaseUrl = 'cn.pling.it'; 1828 } 1829 1830 var topProducts = this.props.topProducts.map(function (tp, index) { 1831 return React.createElement("li", { 1832 key: index 1833 }, React.createElement("img", { 1834 src: "https://" + imageBaseUrl + "/cache/40x40/img/" + tp.image_small 1835 }), React.createElement("a", { 1836 href: "/p/" + tp.project_id 1837 }, tp.title), React.createElement("span", { 1838 className: "cat-name" 1839 }, tp.cat_title)); 1840 }); 1841 topProductsContainer = React.createElement("ol", null, topProducts); 1842 } 1843 1844 return React.createElement("div", { 1845 id: "top-products-container", 1846 className: "sidebar-feed-container" 1847 }, React.createElement("h3", null, "3 Months Ranking"), React.createElement("small", null, "(based on downloads)"), topProductsContainer); 1848 } 1849 }]); 1850 1851 return ExploreTopProducts; 1852 }(React.Component); 1853 1854 var mapStateToExploreTopProductsProps = function mapStateToExploreTopProductsProps(state) { 1855 var topProducts = state.topProducts; 1856 return { 1857 topProducts: topProducts 1858 }; 1859 }; 1860 1861 var mapDispatchToExploreTopProductsProps = function mapDispatchToExploreTopProductsProps(dispatch) { 1862 return { 1863 dispatch: dispatch 1864 }; 1865 }; 1866 1867 var ExploreTopProductsWrapper = ReactRedux.connect(mapStateToExploreTopProductsProps, mapDispatchToExploreTopProductsProps)(ExploreTopProducts); 1868 "use strict"; 1869 1870 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); } 1871 1872 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1873 1874 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); } } 1875 1876 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 1877 1878 function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 1879 1880 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 1881 1882 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 1883 1884 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); } 1885 1886 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 1887 1888 var HomePage = 1889 /*#__PURE__*/ 1890 function (_React$Component) { 1891 _inherits(HomePage, _React$Component); 1892 1893 function HomePage(props) { 1894 var _this; 1895 1896 _classCallCheck(this, HomePage); 1897 1898 _this = _possibleConstructorReturn(this, _getPrototypeOf(HomePage).call(this, props)); 1899 _this.state = { 1900 device: store.getState().device, 1901 products: store.getState().products 1902 }; 1903 return _this; 1904 } 1905 1906 _createClass(HomePage, [{ 1907 key: "componentWillReceiveProps", 1908 value: function componentWillReceiveProps(nextProps) { 1909 if (nextProps.device) { 1910 this.setState({ 1911 device: nextProps.device 1912 }); 1913 } 1914 1915 if (nextProps.products) { 1916 this.setState({ 1917 products: nextProps.products 1918 }); 1919 } 1920 } 1921 }, { 1922 key: "render", 1923 value: function render() { 1924 return React.createElement("div", { 1925 id: "homepage" 1926 }, React.createElement("div", { 1927 className: "hp-wrapper" 1928 }, React.createElement(Introduction, { 1929 device: this.state.device, 1930 count: window.totalProjects 1931 }))); 1932 } 1933 }]); 1934 1935 return HomePage; 1936 }(React.Component); 1937 1938 var mapStateToHomePageProps = function mapStateToHomePageProps(state) { 1939 var device = state.device; 1940 var products = state.products; 1941 return { 1942 device: device, 1943 products: products 1944 }; 1945 }; 1946 1947 var mapDispatchToHomePageProps = function mapDispatchToHomePageProps(dispatch) { 1948 return { 1949 dispatch: dispatch 1950 }; 1951 }; 1952 1953 var HomePageWrapper = ReactRedux.connect(mapStateToHomePageProps, mapDispatchToHomePageProps)(HomePage); 1954 1955 var Introduction = 1956 /*#__PURE__*/ 1957 function (_React$Component2) { 1958 _inherits(Introduction, _React$Component2); 1959 1960 function Introduction() { 1961 _classCallCheck(this, Introduction); 1962 1963 return _possibleConstructorReturn(this, _getPrototypeOf(Introduction).apply(this, arguments)); 1964 } 1965 1966 _createClass(Introduction, [{ 1967 key: "render", 1968 value: function render() { 1969 var introductionText, siteTitle, buttonsContainer; 1970 1971 if (window.page === "appimages") { 1972 siteTitle = "AppImageHub"; 1973 introductionText = React.createElement("p", null, "This catalog has ", this.props.count, " AppImages and counting.", React.createElement("br", null), "AppImages are self-contained apps which can simply be downloaded & run on any Linux distribution. For easy integration, download AppImageLauncher:"); 1974 buttonsContainer = React.createElement("div", { 1975 className: "actions" 1976 }, React.createElement("a", { 1977 href: "/p/1228228", 1978 className: "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored mdl-color--primary" 1979 }, React.createElement("img", { 1980 src: "/theme/react/assets/img/icon-download_white.png" 1981 }), " AppImageLauncher"), React.createElement("a", { 1982 href: "/browse", 1983 className: "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored mdl-color--primary" 1984 }, "Browse all apps"), React.createElement("a", { 1985 href: "https://chat.opendesktop.org/#/room/#appimagehub:chat.opendesktop.org", 1986 className: "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored mdl-color--primary", 1987 style: { 1988 "margin-left": "50px" 1989 } 1990 }, "Join our chat #AppImageHub")); 1991 } else if (window.page === "libreoffice") { 1992 siteTitle = "LibreOffice"; 1993 introductionText = React.createElement("p", null, "Extensions add new features to your LibreOffice or make the use of already existing ones easier. Currently there are ", this.props.count, " project(s) available."); 1994 buttonsContainer = React.createElement("div", { 1995 className: "actions green" 1996 }, React.createElement("a", { 1997 href: window.baseUrl + "product/add", 1998 className: "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored mdl-color--primary" 1999 }, "Add Extension"), React.createElement("a", { 2000 href: window.baseUrl + "browse/", 2001 className: "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored mdl-color--primary" 2002 }, "Browse all Extensions")); 2003 } 2004 2005 return React.createElement("div", { 2006 id: "introduction", 2007 className: "section" 2008 }, React.createElement("div", { 2009 className: "container" 2010 }, React.createElement("article", null, React.createElement("h2", { 2011 className: "mdl-color-text--primary" 2012 }, "Welcome to ", siteTitle), introductionText, buttonsContainer))); 2013 } 2014 }]); 2015 2016 return Introduction; 2017 }(React.Component); 2018 2019 var HpIntroSection = 2020 /*#__PURE__*/ 2021 function (_React$Component3) { 2022 _inherits(HpIntroSection, _React$Component3); 2023 2024 function HpIntroSection(props) { 2025 var _this2; 2026 2027 _classCallCheck(this, HpIntroSection); 2028 2029 _this2 = _possibleConstructorReturn(this, _getPrototypeOf(HpIntroSection).call(this, props)); 2030 _this2.state = {}; 2031 return _this2; 2032 } 2033 2034 _createClass(HpIntroSection, [{ 2035 key: "render", 2036 value: function render() { 2037 return React.createElement("div", { 2038 id: "homepage-search-container", 2039 className: "section intro" 2040 }, React.createElement("div", { 2041 className: "container" 2042 }, React.createElement("article", null, React.createElement("p", null, "Search thousands of snaps used by millions of people across 50 Linux distributions")), React.createElement("div", { 2043 id: "hp-search-form-container" 2044 }, React.createElement("select", { 2045 className: "mdl-selectfield__select" 2046 }, React.createElement("option", null, "categories")), React.createElement("input", { 2047 type: "text" 2048 }), React.createElement("button", null, "search")))); 2049 } 2050 }]); 2051 2052 return HpIntroSection; 2053 }(React.Component); 2054 2055 var mapStateToHpIntroSectionProps = function mapStateToHpIntroSectionProps(state) { 2056 var categories = state.categories; 2057 return { 2058 categories: categories 2059 }; 2060 }; 2061 2062 var mapDispatchToHpIntroSectionProps = function mapDispatchToHpIntroSectionProps(dispatch) { 2063 return { 2064 dispatch: dispatch 2065 }; 2066 }; 2067 2068 var HpIntroSectionWrapper = ReactRedux.connect(mapStateToHpIntroSectionProps, mapDispatchToHpIntroSectionProps)(HpIntroSection); 2069 2070 var ProductCarousel = 2071 /*#__PURE__*/ 2072 function (_React$Component4) { 2073 _inherits(ProductCarousel, _React$Component4); 2074 2075 function ProductCarousel(props) { 2076 var _this3; 2077 2078 _classCallCheck(this, ProductCarousel); 2079 2080 _this3 = _possibleConstructorReturn(this, _getPrototypeOf(ProductCarousel).call(this, props)); 2081 _this3.state = { 2082 showRightArrow: true, 2083 showLeftArrow: false 2084 }; 2085 _this3.updateDimensions = _this3.updateDimensions.bind(_assertThisInitialized(_this3)); 2086 _this3.animateProductCarousel = _this3.animateProductCarousel.bind(_assertThisInitialized(_this3)); 2087 return _this3; 2088 } 2089 2090 _createClass(ProductCarousel, [{ 2091 key: "componentWillMount", 2092 value: function componentWillMount() { 2093 window.addEventListener("resize", this.updateDimensions); 2094 } 2095 }, { 2096 key: "componentDidMount", 2097 value: function componentDidMount() { 2098 this.updateDimensions(); 2099 } 2100 }, { 2101 key: "updateDimensions", 2102 value: function updateDimensions() { 2103 var containerWidth = $('#introduction').find('.container').width(); 2104 var sliderWidth = containerWidth * 3; 2105 var itemWidth = containerWidth / 5; 2106 this.setState({ 2107 sliderPosition: 0, 2108 containerWidth: containerWidth, 2109 sliderWidth: sliderWidth, 2110 itemWidth: itemWidth 2111 }); 2112 } 2113 }, { 2114 key: "animateProductCarousel", 2115 value: function animateProductCarousel(dir) { 2116 var newSliderPosition = this.state.sliderPosition; 2117 2118 if (dir === 'left') { 2119 newSliderPosition = this.state.sliderPosition - this.state.containerWidth; 2120 } else { 2121 newSliderPosition = this.state.sliderPosition + this.state.containerWidth; 2122 } 2123 2124 this.setState({ 2125 sliderPosition: newSliderPosition 2126 }, function () { 2127 var showLeftArrow = true, 2128 showRightArrow = true; 2129 var endPoint = this.state.sliderWidth - this.state.containerWidth; 2130 2131 if (this.state.sliderPosition <= 0) { 2132 showLeftArrow = false; 2133 } 2134 2135 if (this.state.sliderPosition >= endPoint) { 2136 showRightArrow = false; 2137 } 2138 2139 this.setState({ 2140 showLeftArrow: showLeftArrow, 2141 showRightArrow: showRightArrow 2142 }); 2143 }); 2144 } 2145 }, { 2146 key: "render", 2147 value: function render() { 2148 var _this4 = this; 2149 2150 var carouselItemsDisplay; 2151 2152 if (this.props.products && this.props.products.length > 0) { 2153 carouselItemsDisplay = this.props.products.map(function (product, index) { 2154 return React.createElement(ProductCarouselItem, { 2155 key: index, 2156 product: product, 2157 itemWidth: _this4.state.itemWidth 2158 }); 2159 }); 2160 } 2161 2162 var rightArrowDisplay, leftArrowDisplay; 2163 2164 if (this.state.showLeftArrow) { 2165 leftArrowDisplay = React.createElement("div", { 2166 className: "product-carousel-left" 2167 }, React.createElement("a", { 2168 onClick: function onClick() { 2169 return _this4.animateProductCarousel('left'); 2170 }, 2171 className: "carousel-arrow arrow-left" 2172 }, React.createElement("i", { 2173 className: "material-icons" 2174 }, "chevron_left"))); 2175 } 2176 2177 if (this.state.showRightArrow) { 2178 rightArrowDisplay = React.createElement("div", { 2179 className: "product-carousel-right" 2180 }, React.createElement("a", { 2181 onClick: function onClick() { 2182 return _this4.animateProductCarousel('right'); 2183 }, 2184 className: "carousel-arrow arrow-right" 2185 }, React.createElement("i", { 2186 className: "material-icons" 2187 }, "chevron_right"))); 2188 } 2189 2190 return React.createElement("div", { 2191 className: "product-carousel" 2192 }, React.createElement("div", { 2193 className: "product-carousel-header" 2194 }, React.createElement("h2", null, React.createElement("a", { 2195 href: this.props.link 2196 }, this.props.title, React.createElement("i", { 2197 className: "material-icons" 2198 }, "chevron_right")))), React.createElement("div", { 2199 className: "product-carousel-wrapper" 2200 }, leftArrowDisplay, React.createElement("div", { 2201 className: "product-carousel-container" 2202 }, React.createElement("div", { 2203 className: "product-carousel-slider", 2204 style: { 2205 "width": this.state.sliderWidth, 2206 "left": "-" + this.state.sliderPosition + "px" 2207 } 2208 }, carouselItemsDisplay)), rightArrowDisplay)); 2209 } 2210 }]); 2211 2212 return ProductCarousel; 2213 }(React.Component); 2214 2215 var ProductCarouselItem = 2216 /*#__PURE__*/ 2217 function (_React$Component5) { 2218 _inherits(ProductCarouselItem, _React$Component5); 2219 2220 function ProductCarouselItem(props) { 2221 var _this5; 2222 2223 _classCallCheck(this, ProductCarouselItem); 2224 2225 _this5 = _possibleConstructorReturn(this, _getPrototypeOf(ProductCarouselItem).call(this, props)); 2226 _this5.state = {}; 2227 return _this5; 2228 } 2229 2230 _createClass(ProductCarouselItem, [{ 2231 key: "render", 2232 value: function render() { 2233 var imageBaseUrl; 2234 2235 if (store.getState().env === 'live') { 2236 imageBaseUrl = 'cn.opendesktop.org'; 2237 } else { 2238 imageBaseUrl = 'cn.pling.it'; 2239 } 2240 2241 return React.createElement("div", { 2242 className: "product-carousel-item", 2243 style: { 2244 "width": this.props.itemWidth 2245 } 2246 }, React.createElement("a", { 2247 href: "/p/" + this.props.product.project_id 2248 }, React.createElement("figure", null, React.createElement("img", { 2249 className: "very-rounded-corners", 2250 src: 'https://' + imageBaseUrl + '/cache/200x171/img/' + this.props.product.image_small 2251 })), React.createElement("div", { 2252 className: "product-info" 2253 }, React.createElement("span", { 2254 className: "product-info-title" 2255 }, this.props.product.title), React.createElement("span", { 2256 className: "product-info-user" 2257 }, this.props.product.username)))); 2258 } 2259 }]); 2260 2261 return ProductCarouselItem; 2262 }(React.Component); 2263 "use strict"; 2264 2265 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 2266 2267 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); } 2268 2269 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 2270 2271 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); } } 2272 2273 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 2274 2275 function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 2276 2277 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 2278 2279 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 2280 2281 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); } 2282 2283 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 2284 2285 var ProductView = 2286 /*#__PURE__*/ 2287 function (_React$Component) { 2288 _inherits(ProductView, _React$Component); 2289 2290 function ProductView(props) { 2291 var _this; 2292 2293 _classCallCheck(this, ProductView); 2294 2295 _this = _possibleConstructorReturn(this, _getPrototypeOf(ProductView).call(this, props)); 2296 _this.state = { 2297 tab: 'comments', 2298 showDownloadSection: false 2299 }; 2300 _this.toggleTab = _this.toggleTab.bind(_assertThisInitialized(_this)); 2301 _this.toggleDownloadSection = _this.toggleDownloadSection.bind(_assertThisInitialized(_this)); 2302 return _this; 2303 } 2304 2305 _createClass(ProductView, [{ 2306 key: "componentDidMount", 2307 value: function componentDidMount() { 2308 var downloadTableHeight = $('#product-download-section').find('#files-tab').height(); 2309 downloadTableHeight += 80; 2310 this.setState({ 2311 downloadTableHeight: downloadTableHeight 2312 }); 2313 } 2314 }, { 2315 key: "componentWillReceiveProps", 2316 value: function componentWillReceiveProps(nextProps) { 2317 if (nextProps.product !== this.props.product) { 2318 this.forceUpdate(); 2319 } 2320 2321 if (nextProps.lightboxGallery !== this.props.lightboxGallery) { 2322 this.forceUpdate(); 2323 } 2324 } 2325 }, { 2326 key: "toggleTab", 2327 value: function toggleTab(tab) { 2328 this.setState({ 2329 tab: tab 2330 }); 2331 } 2332 }, { 2333 key: "toggleDownloadSection", 2334 value: function toggleDownloadSection() { 2335 var showDownloadSection = this.state.showDownloadSection === true ? false : true; 2336 this.setState({ 2337 showDownloadSection: showDownloadSection 2338 }); 2339 } 2340 }, { 2341 key: "render", 2342 value: function render() { 2343 var productGalleryDisplay; 2344 2345 if (this.props.product.r_gallery.length > 0) { 2346 productGalleryDisplay = React.createElement(ProductViewGallery, { 2347 product: this.props.product 2348 }); 2349 } 2350 2351 var productGalleryLightboxDisplay; 2352 2353 if (this.props.lightboxGallery.show === true) { 2354 productGalleryLightboxDisplay = React.createElement(ProductGalleryLightbox, { 2355 product: this.props.product 2356 }); 2357 } 2358 2359 var downloadSectionDisplayHeight; 2360 2361 if (this.state.showDownloadSection === true) { 2362 downloadSectionDisplayHeight = this.state.downloadTableHeight; 2363 } 2364 2365 return React.createElement("div", { 2366 id: "product-page" 2367 }, React.createElement("div", { 2368 id: "product-download-section", 2369 style: { 2370 "height": downloadSectionDisplayHeight 2371 } 2372 }, React.createElement(ProductViewFilesTab, { 2373 product: this.props.product, 2374 files: this.props.product.r_files 2375 })), React.createElement(ProductViewHeader, { 2376 product: this.props.product, 2377 user: this.props.user, 2378 onDownloadBtnClick: this.toggleDownloadSection 2379 }), productGalleryDisplay, React.createElement(ProductDescription, { 2380 product: this.props.product 2381 }), React.createElement(ProductNavBar, { 2382 onTabToggle: this.toggleTab, 2383 tab: this.state.tab, 2384 product: this.props.product 2385 }), React.createElement(ProductViewContent, { 2386 product: this.props.product, 2387 user: this.props.user, 2388 tab: this.state.tab 2389 }), productGalleryLightboxDisplay); 2390 } 2391 }]); 2392 2393 return ProductView; 2394 }(React.Component); 2395 2396 var mapStateToProductPageProps = function mapStateToProductPageProps(state) { 2397 var product = state.product; 2398 var user = state.user; 2399 var lightboxGallery = state.lightboxGallery; 2400 return { 2401 product: product, 2402 user: user, 2403 lightboxGallery: lightboxGallery 2404 }; 2405 }; 2406 2407 var mapDispatchToProductPageProps = function mapDispatchToProductPageProps(dispatch) { 2408 return { 2409 dispatch: dispatch 2410 }; 2411 }; 2412 2413 var ProductViewWrapper = ReactRedux.connect(mapStateToProductPageProps, mapDispatchToProductPageProps)(ProductView); 2414 2415 var ProductViewHeader = 2416 /*#__PURE__*/ 2417 function (_React$Component2) { 2418 _inherits(ProductViewHeader, _React$Component2); 2419 2420 function ProductViewHeader(props) { 2421 var _this2; 2422 2423 _classCallCheck(this, ProductViewHeader); 2424 2425 _this2 = _possibleConstructorReturn(this, _getPrototypeOf(ProductViewHeader).call(this, props)); 2426 _this2.state = {}; 2427 return _this2; 2428 } 2429 2430 _createClass(ProductViewHeader, [{ 2431 key: "render", 2432 value: function render() { 2433 var imageBaseUrl; 2434 2435 if (store.getState().env === 'live') { 2436 imageBaseUrl = 'cn.opendesktop.org'; 2437 } else { 2438 imageBaseUrl = 'cn.pling.it'; 2439 } 2440 2441 var productTagsDisplay; 2442 2443 if (this.props.product.r_tags_user) { 2444 var tagsArray = this.props.product.r_tags_user.split(','); 2445 var tags = tagsArray.map(function (tag, index) { 2446 return React.createElement("span", { 2447 className: "mdl-chip", 2448 key: index 2449 }, React.createElement("span", { 2450 className: "mdl-chip__text" 2451 }, React.createElement("span", { 2452 className: "glyphicon glyphicon-tag" 2453 }), React.createElement("a", { 2454 href: "search/projectSearchText/" + tag + "/f/tags" 2455 }, tag))); 2456 }); 2457 productTagsDisplay = React.createElement("div", { 2458 className: "product-tags" 2459 }, tags); 2460 } 2461 2462 return React.createElement("div", { 2463 className: "wrapper", 2464 id: "product-view-header" 2465 }, React.createElement("div", { 2466 className: "container" 2467 }, React.createElement("div", { 2468 className: "section mdl-grid" 2469 }, React.createElement("div", { 2470 className: "product-view-header-left" 2471 }, React.createElement("figure", { 2472 className: "image-container" 2473 }, React.createElement("img", { 2474 src: 'https://' + imageBaseUrl + '/cache/140x140/img/' + this.props.product.image_small 2475 })), React.createElement("div", { 2476 className: "product-info" 2477 }, React.createElement("h1", null, this.props.product.title), React.createElement("div", { 2478 className: "info-row" 2479 }, React.createElement("a", { 2480 className: "user", 2481 href: "/member/" + this.props.product.member_id 2482 }, React.createElement("span", { 2483 className: "avatar" 2484 }, React.createElement("img", { 2485 src: this.props.product.profile_image_url 2486 })), React.createElement("span", { 2487 className: "username" 2488 }, this.props.product.username)), React.createElement("a", { 2489 href: "/browse/cat/" + this.props.product.project_category_id + "/order/latest?new=1" 2490 }, React.createElement("span", null, this.props.product.cat_title)), productTagsDisplay))), React.createElement("div", { 2491 className: "product-view-header-right" 2492 }, React.createElement("div", { 2493 className: "details-container" 2494 }, React.createElement("a", { 2495 onClick: this.props.onDownloadBtnClick, 2496 href: "#", 2497 className: "mdl-button mdl-js-button mdl-button--colored mdl-button--raised mdl-js-ripple-effect mdl-color--primary" 2498 }, "Download"), React.createElement(ProductViewHeaderLikes, { 2499 product: this.props.product, 2500 user: this.props.user 2501 }), React.createElement("div", { 2502 id: "product-view-header-right-side" 2503 }, React.createElement(ProductViewHeaderRatings, { 2504 product: this.props.product, 2505 user: this.props.user 2506 }))))))); 2507 } 2508 }]); 2509 2510 return ProductViewHeader; 2511 }(React.Component); 2512 2513 var ProductViewHeaderLikes = 2514 /*#__PURE__*/ 2515 function (_React$Component3) { 2516 _inherits(ProductViewHeaderLikes, _React$Component3); 2517 2518 function ProductViewHeaderLikes(props) { 2519 var _this3; 2520 2521 _classCallCheck(this, ProductViewHeaderLikes); 2522 2523 _this3 = _possibleConstructorReturn(this, _getPrototypeOf(ProductViewHeaderLikes).call(this, props)); 2524 _this3.state = {}; 2525 _this3.onUserLike = _this3.onUserLike.bind(_assertThisInitialized(_this3)); 2526 return _this3; 2527 } 2528 2529 _createClass(ProductViewHeaderLikes, [{ 2530 key: "componentDidMount", 2531 value: function componentDidMount() { 2532 var user = store.getState().user; 2533 var likedByUser = productHelpers.checkIfLikedByUser(user, this.props.product.r_likes); 2534 this.setState({ 2535 likesTotal: this.props.product.r_likes.length, 2536 likedByUser: likedByUser 2537 }); 2538 } 2539 }, { 2540 key: "onUserLike", 2541 value: function onUserLike() { 2542 if (this.props.user.username) { 2543 var url = "/p/" + this.props.product.project_id + "/followproject/"; 2544 var self = this; 2545 $.ajax({ 2546 url: url, 2547 cache: false 2548 }).done(function (response) { 2549 // error 2550 if (response.status === "error") { 2551 self.setState({ 2552 msg: response.msg 2553 }); 2554 } else { 2555 // delete 2556 if (response.action === "delete") { 2557 var likesTotal = self.state.likesTotal - 1; 2558 self.setState({ 2559 likesTotal: likesTotal, 2560 likedByUser: false 2561 }); 2562 } // insert 2563 else { 2564 var _likesTotal = self.state.likesTotal + 1; 2565 2566 self.setState({ 2567 likesTotal: _likesTotal, 2568 likedByUser: true 2569 }); 2570 } 2571 } 2572 }); 2573 } else { 2574 this.setState({ 2575 msg: 'please login to like' 2576 }); 2577 } 2578 } 2579 }, { 2580 key: "render", 2581 value: function render() { 2582 var cssContainerClass, cssHeartClass; 2583 2584 if (this.state.likedByUser === true) { 2585 cssContainerClass = "liked-by-user"; 2586 cssHeartClass = "plingheart fa heartproject fa-heart"; 2587 } else { 2588 cssHeartClass = "plingheart fa fa-heart-o heartgrey"; 2589 } 2590 2591 return React.createElement("div", { 2592 className: cssContainerClass, 2593 id: "likes-container" 2594 }, React.createElement("div", { 2595 className: "likes" 2596 }, React.createElement("i", { 2597 className: cssHeartClass 2598 }), React.createElement("span", { 2599 onClick: this.onUserLike 2600 }, this.state.likesTotal)), React.createElement("div", { 2601 className: "likes-label-container" 2602 }, this.state.msg)); 2603 } 2604 }]); 2605 2606 return ProductViewHeaderLikes; 2607 }(React.Component); 2608 2609 var ProductViewHeaderRatings = 2610 /*#__PURE__*/ 2611 function (_React$Component4) { 2612 _inherits(ProductViewHeaderRatings, _React$Component4); 2613 2614 function ProductViewHeaderRatings(props) { 2615 var _this4; 2616 2617 _classCallCheck(this, ProductViewHeaderRatings); 2618 2619 _this4 = _possibleConstructorReturn(this, _getPrototypeOf(ProductViewHeaderRatings).call(this, props)); 2620 _this4.state = { 2621 userIsOwner: '', 2622 action: '', 2623 laplace_score: _this4.props.product.laplace_score 2624 }; 2625 _this4.onRatingFormResponse = _this4.onRatingFormResponse.bind(_assertThisInitialized(_this4)); 2626 return _this4; 2627 } 2628 2629 _createClass(ProductViewHeaderRatings, [{ 2630 key: "componentDidMount", 2631 value: function componentDidMount() { 2632 var userIsOwner = false; 2633 2634 if (this.props.user && this.props.user.member_id === this.props.product.member_id) { 2635 userIsOwner = true; 2636 } 2637 2638 var userRating = -1; 2639 2640 if (userIsOwner === false) { 2641 userRating = productHelpers.getLoggedUserRatingOnProduct(this.props.user, this.props.product.r_ratings); 2642 } 2643 2644 this.setState({ 2645 userIsOwner: userIsOwner, 2646 userRating: userRating 2647 }); 2648 } 2649 }, { 2650 key: "onRatingBtnClick", 2651 value: function onRatingBtnClick(action) { 2652 this.setState({ 2653 showModal: false 2654 }, function () { 2655 this.setState({ 2656 action: action, 2657 showModal: true 2658 }, function () { 2659 $('#ratings-form-modal').modal('show'); 2660 }); 2661 }); 2662 } 2663 }, { 2664 key: "onRatingFormResponse", 2665 value: function onRatingFormResponse(modalResponse, val) { 2666 var self = this; 2667 this.setState({ 2668 errorMsg: '' 2669 }, function () { 2670 jQuery.ajax({ 2671 data: {}, 2672 url: '/p/' + this.props.product.project_id + '/loadratings/', 2673 method: 'get', 2674 error: function error(jqXHR, textStatus, errorThrown) { 2675 self.setState({ 2676 errorMsg: textStatus + " " + errorThrown 2677 }); 2678 $('#ratings-form-modal').modal('hide'); 2679 }, 2680 success: function success(response) { 2681 // const laplace_score = productHelpers.calculateProductLaplaceScore(response); 2682 store.dispatch(setProductRatings(response)); 2683 if (modalResponse.status !== "ok") self.setState({ 2684 errorMsg: modalResponse.status + " - " + modalResponse.message 2685 }); 2686 self.setState({ 2687 laplace_score: modalResponse.laplace_score 2688 }, function () {}); 2689 $('#ratings-form-modal').modal('hide'); 2690 } 2691 }); 2692 }); 2693 } 2694 }, { 2695 key: "render", 2696 value: function render() { 2697 var _this5 = this; 2698 2699 var ratingsFormModalDisplay; 2700 2701 if (this.state.showModal === true) { 2702 if (this.props.user.username) { 2703 ratingsFormModalDisplay = React.createElement(RatingsFormModal, { 2704 user: this.props.user, 2705 userIsOwner: this.state.userIsOwner, 2706 userRating: this.state.userRating, 2707 action: this.state.action, 2708 product: this.props.product, 2709 onRatingFormResponse: this.onRatingFormResponse 2710 }); 2711 } else { 2712 ratingsFormModalDisplay = React.createElement("div", { 2713 className: "modal please-login", 2714 id: "ratings-form-modal", 2715 tabIndex: "-1", 2716 role: "dialog" 2717 }, React.createElement("div", { 2718 className: "modal-dialog", 2719 role: "document" 2720 }, React.createElement("div", { 2721 className: "modal-content" 2722 }, React.createElement("div", { 2723 className: "modal-header" 2724 }, React.createElement("h4", { 2725 className: "modal-title" 2726 }, "Please Login"), React.createElement("button", { 2727 type: "button", 2728 id: "review-modal-close", 2729 className: "close", 2730 "data-dismiss": "modal", 2731 "aria-label": "Close" 2732 }, React.createElement("span", { 2733 "aria-hidden": "true" 2734 }, "\xD7"))), React.createElement("div", { 2735 className: "modal-body" 2736 }, React.createElement("a", { 2737 href: "/login/" 2738 }, "Login"))))); 2739 } 2740 } 2741 2742 return React.createElement("div", { 2743 className: "ratings-bar-container" 2744 }, React.createElement("div", { 2745 className: "ratings-bar-left", 2746 onClick: function onClick() { 2747 return _this5.onRatingBtnClick('minus'); 2748 } 2749 }, React.createElement("i", { 2750 className: "material-icons" 2751 }, "remove")), React.createElement("div", { 2752 className: "ratings-bar-holder" 2753 }, React.createElement("div", { 2754 className: "green ratings-bar", 2755 style: { 2756 "width": this.state.laplace_score + "%" 2757 } 2758 }), React.createElement("div", { 2759 className: "ratings-bar-empty", 2760 style: { 2761 "width": 100 - this.state.laplace_score + "%" 2762 } 2763 })), React.createElement("div", { 2764 className: "ratings-bar-right", 2765 onClick: function onClick() { 2766 return _this5.onRatingBtnClick('plus'); 2767 } 2768 }, React.createElement("i", { 2769 className: "material-icons" 2770 }, "add")), ratingsFormModalDisplay, React.createElement("p", { 2771 className: "ratings-bar-error-msg-container" 2772 }, this.state.errorMsg)); 2773 } 2774 }]); 2775 2776 return ProductViewHeaderRatings; 2777 }(React.Component); 2778 2779 var RatingsFormModal = 2780 /*#__PURE__*/ 2781 function (_React$Component5) { 2782 _inherits(RatingsFormModal, _React$Component5); 2783 2784 function RatingsFormModal(props) { 2785 var _this6; 2786 2787 _classCallCheck(this, RatingsFormModal); 2788 2789 _this6 = _possibleConstructorReturn(this, _getPrototypeOf(RatingsFormModal).call(this, props)); 2790 _this6.state = { 2791 action: _this6.props.action 2792 }; 2793 _this6.submitRatingForm = _this6.submitRatingForm.bind(_assertThisInitialized(_this6)); 2794 _this6.onTextAreaInputChange = _this6.onTextAreaInputChange.bind(_assertThisInitialized(_this6)); 2795 return _this6; 2796 } 2797 2798 _createClass(RatingsFormModal, [{ 2799 key: "componentDidMount", 2800 value: function componentDidMount() { 2801 var actionIcon; 2802 2803 if (this.props.action === 'plus') { 2804 actionIcon = '+'; 2805 } else if (this.props.action === 'minus') { 2806 actionIcon = '-'; 2807 } 2808 2809 this.setState({ 2810 action: this.props.action, 2811 actionIcon: actionIcon, 2812 text: actionIcon 2813 }, function () { 2814 this.forceUpdate(); 2815 }); 2816 } 2817 }, { 2818 key: "onTextAreaInputChange", 2819 value: function onTextAreaInputChange(e) { 2820 this.setState({ 2821 text: e.target.value 2822 }); 2823 } 2824 }, { 2825 key: "submitRatingForm", 2826 value: function submitRatingForm() { 2827 this.setState({ 2828 loading: true 2829 }, function () { 2830 var self = this; 2831 var v; 2832 2833 if (this.state.action === 'plus') { 2834 v = '1'; 2835 } else { 2836 v = '2'; 2837 } 2838 2839 jQuery.ajax({ 2840 data: { 2841 p: this.props.product.project_id, 2842 m: this.props.user.member_id, 2843 v: v, 2844 pm: this.props.product.member_id, 2845 otxt: this.state.text, 2846 userrate: this.props.userRating, 2847 msg: this.state.text 2848 }, 2849 url: '/productcomment/addreplyreview/', 2850 method: 'post', 2851 error: function error() { 2852 var msg = "Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error."; 2853 self.setState({ 2854 msg: msg 2855 }); 2856 }, 2857 success: function success(response) { 2858 self.props.onRatingFormResponse(response, v); 2859 } 2860 }); 2861 }); 2862 } 2863 }, { 2864 key: "render", 2865 value: function render() { 2866 var textAreaDisplay, modalBtnDisplay; 2867 2868 if (!this.props.user) { 2869 textAreaDisplay = React.createElement("p", null, "Please login to comment"); 2870 modalBtnDisplay = React.createElement("button", { 2871 type: "button", 2872 className: "btn btn-secondary", 2873 "data-dismiss": "modal" 2874 }, "Close"); 2875 } else { 2876 if (this.props.userIsOwner) { 2877 textAreaDisplay = React.createElement("p", null, "Project owner not allowed"); 2878 modalBtnDisplay = React.createElement("button", { 2879 type: "button", 2880 className: "btn btn-secondary", 2881 "data-dismiss": "modal" 2882 }, "Close"); 2883 } else if (this.state.text) { 2884 textAreaDisplay = React.createElement("textarea", { 2885 onChange: this.onTextAreaInputChange, 2886 defaultValue: this.state.text, 2887 className: "form-control" 2888 }); 2889 2890 if (this.state.loading !== true) { 2891 if (this.state.msg) { 2892 modalBtnDisplay = React.createElement("p", null, this.state.msg); 2893 } else { 2894 modalBtnDisplay = React.createElement("button", { 2895 onClick: this.submitRatingForm, 2896 type: "button", 2897 className: "btn btn-primary" 2898 }, "Rate Now"); 2899 } 2900 } else { 2901 modalBtnDisplay = React.createElement("span", { 2902 className: "glyphicon glyphicon-refresh spinning" 2903 }); 2904 } 2905 } 2906 } 2907 2908 return React.createElement("div", { 2909 className: "modal", 2910 id: "ratings-form-modal", 2911 tabIndex: "-1", 2912 role: "dialog" 2913 }, React.createElement("div", { 2914 className: "modal-dialog", 2915 role: "document" 2916 }, React.createElement("div", { 2917 className: "modal-content" 2918 }, React.createElement("div", { 2919 className: "modal-header" 2920 }, React.createElement("div", { 2921 className: this.props.action + " action-icon-container" 2922 }, this.state.actionIcon), React.createElement("h5", { 2923 className: "modal-title" 2924 }, "Add Comment (min. 1 char):"), React.createElement("button", { 2925 type: "button", 2926 id: "review-modal-close", 2927 className: "close", 2928 "data-dismiss": "modal", 2929 "aria-label": "Close" 2930 }, React.createElement("span", { 2931 "aria-hidden": "true" 2932 }, "\xD7"))), React.createElement("div", { 2933 className: "modal-body" 2934 }, textAreaDisplay), React.createElement("div", { 2935 className: "modal-footer" 2936 }, modalBtnDisplay)))); 2937 } 2938 }]); 2939 2940 return RatingsFormModal; 2941 }(React.Component); 2942 2943 var ProductViewGallery = 2944 /*#__PURE__*/ 2945 function (_React$Component6) { 2946 _inherits(ProductViewGallery, _React$Component6); 2947 2948 function ProductViewGallery(props) { 2949 var _this7; 2950 2951 _classCallCheck(this, ProductViewGallery); 2952 2953 _this7 = _possibleConstructorReturn(this, _getPrototypeOf(ProductViewGallery).call(this, props)); 2954 _this7.state = { 2955 loading: true, 2956 currentItem: 1, 2957 galleryWrapperMarginLeft: 0 2958 }; 2959 _this7.updateDimensions = _this7.updateDimensions.bind(_assertThisInitialized(_this7)); 2960 _this7.onLeftArrowClick = _this7.onLeftArrowClick.bind(_assertThisInitialized(_this7)); 2961 _this7.onRightArrowClick = _this7.onRightArrowClick.bind(_assertThisInitialized(_this7)); 2962 _this7.animateGallerySlider = _this7.animateGallerySlider.bind(_assertThisInitialized(_this7)); 2963 return _this7; 2964 } 2965 2966 _createClass(ProductViewGallery, [{ 2967 key: "componentDidMount", 2968 value: function componentDidMount() { 2969 window.addEventListener("resize", this.updateDimensions); 2970 this.updateDimensions(); 2971 } 2972 }, { 2973 key: "componentWillUnmount", 2974 value: function componentWillUnmount() { 2975 window.removeEventListener("resize", this.updateDimensions); 2976 } 2977 }, { 2978 key: "updateDimensions", 2979 value: function updateDimensions() { 2980 var productGallery = document.getElementById('product-gallery'); 2981 var itemsWidth = 300; 2982 var itemsTotal = this.props.product.r_gallery.length + 1; 2983 this.setState({ 2984 itemsWidth: itemsWidth, 2985 itemsTotal: itemsTotal, 2986 loading: false 2987 }); 2988 } 2989 }, { 2990 key: "onLeftArrowClick", 2991 value: function onLeftArrowClick() { 2992 var nextItem; 2993 2994 if (this.state.currentItem <= 1) { 2995 nextItem = this.state.itemsTotal; 2996 } else { 2997 nextItem = this.state.currentItem - 1; 2998 } 2999 3000 var marginLeft = this.state.itemsWidth * (nextItem - 1); 3001 this.animateGallerySlider(nextItem, marginLeft); 3002 } 3003 }, { 3004 key: "onRightArrowClick", 3005 value: function onRightArrowClick() { 3006 var nextItem; 3007 3008 if (this.state.currentItem === this.state.itemsTotal) { 3009 nextItem = 1; 3010 } else { 3011 nextItem = this.state.currentItem + 1; 3012 } 3013 3014 var marginLeft = this.state.itemsWidth * (nextItem - 1); 3015 this.animateGallerySlider(nextItem, marginLeft); 3016 } 3017 }, { 3018 key: "animateGallerySlider", 3019 value: function animateGallerySlider(nextItem, marginLeft) { 3020 this.setState({ 3021 currentItem: nextItem, 3022 galleryWrapperMarginLeft: "-" + marginLeft + "px" 3023 }); 3024 } 3025 }, { 3026 key: "onGalleryItemClick", 3027 value: function onGalleryItemClick(num) { 3028 store.dispatch(showLightboxGallery(num)); 3029 } 3030 }, { 3031 key: "render", 3032 value: function render() { 3033 var _this8 = this; 3034 3035 var galleryDisplay; 3036 3037 if (this.props.product.embed_code && this.props.product.embed_code.length > 0) { 3038 var imageBaseUrl; 3039 3040 if (store.getState().env === 'live') { 3041 imageBaseUrl = 'http://cn.opendesktop.org'; 3042 } else { 3043 imageBaseUrl = 'http://cn.pling.it'; 3044 } 3045 3046 if (this.props.product.r_gallery.length > 0) { 3047 var itemsWidth = this.state.itemsWidth; 3048 var currentItem = this.state.currentItem; 3049 var self = this; 3050 var moreItems = this.props.product.r_gallery.map(function (gi, index) { 3051 return React.createElement("div", { 3052 key: index, 3053 onClick: function onClick() { 3054 return _this8.onGalleryItemClick(index + 2); 3055 }, 3056 className: currentItem === index + 2 ? "active-gallery-item gallery-item" : "gallery-item" 3057 }, React.createElement("img", { 3058 className: "media-item", 3059 src: imageBaseUrl + "/img/" + gi 3060 })); 3061 }); 3062 galleryDisplay = React.createElement("div", { 3063 id: "product-gallery" 3064 }, React.createElement("a", { 3065 className: "gallery-arrow arrow-left", 3066 onClick: this.onLeftArrowClick 3067 }, React.createElement("i", { 3068 className: "material-icons" 3069 }, "chevron_left")), React.createElement("div", { 3070 className: "section" 3071 }, React.createElement("div", { 3072 style: { 3073 "width": this.state.itemsWidth * this.state.itemsTotal + "px", 3074 "marginLeft": this.state.galleryWrapperMarginLeft 3075 }, 3076 className: "gallery-items-wrapper" 3077 }, React.createElement("div", { 3078 onClick: function onClick() { 3079 return _this8.onGalleryItemClick(1); 3080 }, 3081 dangerouslySetInnerHTML: { 3082 __html: this.props.product.embed_code 3083 }, 3084 className: this.state.currentItem === 1 ? "active-gallery-item gallery-item" : "gallery-item" 3085 }), moreItems)), React.createElement("a", { 3086 className: "gallery-arrow arrow-right", 3087 onClick: this.onRightArrowClick 3088 }, React.createElement("i", { 3089 className: "material-icons" 3090 }, "chevron_right"))); 3091 } 3092 } 3093 3094 return React.createElement("div", { 3095 className: "section", 3096 id: "product-view-gallery-container" 3097 }, React.createElement("div", { 3098 className: "container" 3099 }, React.createElement("div", { 3100 className: "section" 3101 }, galleryDisplay))); 3102 } 3103 }]); 3104 3105 return ProductViewGallery; 3106 }(React.Component); 3107 3108 var ProductGalleryLightbox = 3109 /*#__PURE__*/ 3110 function (_React$Component7) { 3111 _inherits(ProductGalleryLightbox, _React$Component7); 3112 3113 function ProductGalleryLightbox(props) { 3114 var _this9; 3115 3116 _classCallCheck(this, ProductGalleryLightbox); 3117 3118 _this9 = _possibleConstructorReturn(this, _getPrototypeOf(ProductGalleryLightbox).call(this, props)); 3119 var currentItem; 3120 3121 if (store.getState().lightboxGallery) { 3122 currentItem = store.getState().lightboxGallery.currentItem; 3123 } else { 3124 currentItem = 1; 3125 } 3126 3127 _this9.state = { 3128 currentItem: currentItem, 3129 loading: true 3130 }; 3131 _this9.updateDimensions = _this9.updateDimensions.bind(_assertThisInitialized(_this9)); 3132 _this9.toggleNextGalleryItem = _this9.toggleNextGalleryItem.bind(_assertThisInitialized(_this9)); 3133 _this9.togglePrevGalleryItem = _this9.togglePrevGalleryItem.bind(_assertThisInitialized(_this9)); 3134 _this9.animateGallerySlider = _this9.animateGallerySlider.bind(_assertThisInitialized(_this9)); 3135 _this9.onThumbnailClick = _this9.onThumbnailClick.bind(_assertThisInitialized(_this9)); 3136 return _this9; 3137 } 3138 3139 _createClass(ProductGalleryLightbox, [{ 3140 key: "componentDidMount", 3141 value: function componentDidMount() { 3142 window.addEventListener("resize", this.updateDimensions); 3143 this.updateDimensions(); 3144 } 3145 }, { 3146 key: "componentWillUnmount", 3147 value: function componentWillUnmount() { 3148 window.removeEventListener("resize", this.updateDimensions); 3149 } 3150 }, { 3151 key: "updateDimensions", 3152 value: function updateDimensions() { 3153 var thumbnailsSectionWidth = document.getElementById('thumbnails-section').offsetWidth; 3154 var itemsWidth = 300; 3155 var itemsTotal = this.props.product.r_gallery.length + 1; 3156 var thumbnailsMarginLeft = 0; 3157 3158 if (this.state.currentItem * itemsWidth > thumbnailsSectionWidth) { 3159 thumbnailsMarginLeft = thumbnailsSectionWidth - this.state.currentItem * itemsWidth; 3160 } 3161 3162 this.setState({ 3163 itemsWidth: itemsWidth, 3164 itemsTotal: itemsTotal, 3165 thumbnailsSectionWidth: thumbnailsSectionWidth, 3166 thumbnailsMarginLeft: thumbnailsMarginLeft, 3167 loading: false 3168 }); 3169 } 3170 }, { 3171 key: "togglePrevGalleryItem", 3172 value: function togglePrevGalleryItem() { 3173 var nextItem; 3174 3175 if (this.state.currentItem <= 1) { 3176 nextItem = this.state.itemsTotal; 3177 } else { 3178 nextItem = this.state.currentItem - 1; 3179 } 3180 3181 this.animateGallerySlider(nextItem); 3182 } 3183 }, { 3184 key: "toggleNextGalleryItem", 3185 value: function toggleNextGalleryItem() { 3186 var nextItem; 3187 3188 if (this.state.currentItem === this.state.itemsTotal) { 3189 nextItem = 1; 3190 } else { 3191 nextItem = this.state.currentItem + 1; 3192 } 3193 3194 this.animateGallerySlider(nextItem); 3195 } 3196 }, { 3197 key: "animateGallerySlider", 3198 value: function animateGallerySlider(currentItem) { 3199 this.setState({ 3200 currentItem: currentItem 3201 }, function () { 3202 this.updateDimensions(); 3203 }); 3204 } 3205 }, { 3206 key: "onThumbnailClick", 3207 value: function onThumbnailClick(num) { 3208 this.animateGallerySlider(num); 3209 } 3210 }, { 3211 key: "hideLightbox", 3212 value: function hideLightbox() { 3213 store.dispatch(hideLightboxGallery()); 3214 } 3215 }, { 3216 key: "render", 3217 value: function render() { 3218 var _this10 = this; 3219 3220 var imageBaseUrl; 3221 3222 if (store.getState().env === 'live') { 3223 imageBaseUrl = 'http://cn.opendesktop.org'; 3224 } else { 3225 imageBaseUrl = 'http://cn.pling.it'; 3226 } 3227 3228 var currentItem = this.state.currentItem; 3229 var self = this; 3230 var thumbnails = this.props.product.r_gallery.map(function (gi, index) { 3231 return React.createElement("div", { 3232 key: index, 3233 onClick: function onClick() { 3234 return self.onThumbnailClick(index + 2); 3235 }, 3236 className: self.state.currentItem === index + 2 ? "active thumbnail-item" : "thumbnail-item" 3237 }, React.createElement("img", { 3238 className: "media-item", 3239 src: imageBaseUrl + "/img/" + gi 3240 })); 3241 }); 3242 var mainItemDisplay; 3243 3244 if (currentItem === 1) { 3245 mainItemDisplay = React.createElement("div", { 3246 dangerouslySetInnerHTML: { 3247 __html: this.props.product.embed_code 3248 } 3249 }); 3250 } else { 3251 var mainItem = this.props.product.r_gallery[currentItem - 2]; 3252 mainItemDisplay = React.createElement("img", { 3253 className: "media-item", 3254 src: imageBaseUrl + "/img/" + mainItem 3255 }); 3256 } 3257 3258 return React.createElement("div", { 3259 id: "product-gallery-lightbox" 3260 }, React.createElement("a", { 3261 id: "close-lightbox", 3262 onClick: this.hideLightbox 3263 }, React.createElement("i", { 3264 className: "material-icons" 3265 }, "cancel")), React.createElement("div", { 3266 id: "lightbox-gallery-main-view" 3267 }, React.createElement("a", { 3268 className: "gallery-arrow", 3269 onClick: this.togglePrevGalleryItem, 3270 id: "arrow-left" 3271 }, React.createElement("i", { 3272 className: "material-icons" 3273 }, "chevron_left")), React.createElement("div", { 3274 className: "current-gallery-item" 3275 }, mainItemDisplay), React.createElement("a", { 3276 className: "gallery-arrow", 3277 onClick: this.toggleNextGalleryItem, 3278 id: "arrow-right" 3279 }, React.createElement("i", { 3280 className: "material-icons" 3281 }, "chevron_right"))), React.createElement("div", { 3282 id: "lightbox-gallery-thumbnails" 3283 }, React.createElement("div", { 3284 className: "section", 3285 id: "thumbnails-section" 3286 }, React.createElement("div", { 3287 id: "gallery-items-wrapper", 3288 style: { 3289 "width": this.state.itemsTotal * this.state.itemsWidth + "px", 3290 "marginLeft": this.state.thumbnailsMarginLeft + "px" 3291 } 3292 }, React.createElement("div", { 3293 onClick: function onClick() { 3294 return _this10.onThumbnailClick(1); 3295 }, 3296 dangerouslySetInnerHTML: { 3297 __html: this.props.product.embed_code 3298 }, 3299 className: this.state.currentItem === 1 ? "active thumbnail-item" : "thumbnail-item" 3300 }), thumbnails)))); 3301 } 3302 }]); 3303 3304 return ProductGalleryLightbox; 3305 }(React.Component); 3306 3307 var ProductDescription = 3308 /*#__PURE__*/ 3309 function (_React$Component8) { 3310 _inherits(ProductDescription, _React$Component8); 3311 3312 function ProductDescription(props) { 3313 var _this11; 3314 3315 _classCallCheck(this, ProductDescription); 3316 3317 _this11 = _possibleConstructorReturn(this, _getPrototypeOf(ProductDescription).call(this, props)); 3318 _this11.state = {}; 3319 return _this11; 3320 } 3321 3322 _createClass(ProductDescription, [{ 3323 key: "render", 3324 value: function render() { 3325 return React.createElement("div", { 3326 id: "product-description", 3327 className: "section" 3328 }, React.createElement("div", { 3329 className: "container" 3330 }, React.createElement("div", { 3331 className: "main-content" 3332 }, React.createElement("article", null, React.createElement("p", { 3333 dangerouslySetInnerHTML: { 3334 __html: this.props.product.description 3335 } 3336 })), React.createElement("aside", null, React.createElement("ul", null, React.createElement("li", null, React.createElement("span", { 3337 className: "key" 3338 }, "License"), React.createElement("span", { 3339 className: "val" 3340 }, this.props.product.project_license_title)), React.createElement("li", null, React.createElement("span", { 3341 className: "key" 3342 }, "Last Update"), React.createElement("span", { 3343 className: "val" 3344 }, this.props.product.changed_at.split(' ')[0]))))))); 3345 } 3346 }]); 3347 3348 return ProductDescription; 3349 }(React.Component); 3350 3351 var ProductNavBar = 3352 /*#__PURE__*/ 3353 function (_React$Component9) { 3354 _inherits(ProductNavBar, _React$Component9); 3355 3356 function ProductNavBar() { 3357 _classCallCheck(this, ProductNavBar); 3358 3359 return _possibleConstructorReturn(this, _getPrototypeOf(ProductNavBar).apply(this, arguments)); 3360 } 3361 3362 _createClass(ProductNavBar, [{ 3363 key: "render", 3364 value: function render() { 3365 var _this12 = this; 3366 3367 var productNavBarDisplay; 3368 var filesMenuItem, ratingsMenuItem, favsMenuItem, plingsMenuItem; 3369 3370 if (this.props.product.r_files.length > 0) { 3371 filesMenuItem = React.createElement("a", { 3372 className: this.props.tab === "files" ? "item active" : "item", 3373 onClick: function onClick() { 3374 return _this12.props.onTabToggle('files'); 3375 } 3376 }, "Files (", this.props.product.r_files.length, ")"); 3377 } 3378 3379 if (this.props.product.r_ratings.length > 0) { 3380 var activeRatingsNumber = productHelpers.getActiveRatingsNumber(this.props.product.r_ratings); 3381 ratingsMenuItem = React.createElement("a", { 3382 className: this.props.tab === "ratings" ? "item active" : "item", 3383 onClick: function onClick() { 3384 return _this12.props.onTabToggle('ratings'); 3385 } 3386 }, "Ratings & Reviews (", activeRatingsNumber, ")"); 3387 } 3388 3389 if (this.props.product.r_likes.length > 0) { 3390 favsMenuItem = React.createElement("a", { 3391 className: this.props.tab === "favs" ? "item active" : "item", 3392 onClick: function onClick() { 3393 return _this12.props.onTabToggle('favs'); 3394 } 3395 }, "Favs (", this.props.product.r_likes.length, ")"); 3396 } 3397 3398 if (this.props.product.r_plings.length > 0) { 3399 plingsMenuItem = React.createElement("a", { 3400 className: this.props.tab === "plings" ? "item active" : "item", 3401 onClick: function onClick() { 3402 return _this12.props.onTabToggle('plings'); 3403 } 3404 }, "Plings (", this.props.product.r_plings.length, ")"); 3405 } 3406 3407 return React.createElement("div", { 3408 className: "wrapper" 3409 }, React.createElement("div", { 3410 className: "container" 3411 }, React.createElement("div", { 3412 className: "explore-top-bar" 3413 }, React.createElement("a", { 3414 className: this.props.tab === "comments" ? "item active" : "item", 3415 onClick: function onClick() { 3416 return _this12.props.onTabToggle('comments'); 3417 } 3418 }, "Comments (", this.props.product.r_comments.length, ")"), filesMenuItem, ratingsMenuItem, favsMenuItem, plingsMenuItem))); 3419 } 3420 }]); 3421 3422 return ProductNavBar; 3423 }(React.Component); 3424 3425 var ProductViewContent = 3426 /*#__PURE__*/ 3427 function (_React$Component10) { 3428 _inherits(ProductViewContent, _React$Component10); 3429 3430 function ProductViewContent() { 3431 _classCallCheck(this, ProductViewContent); 3432 3433 return _possibleConstructorReturn(this, _getPrototypeOf(ProductViewContent).apply(this, arguments)); 3434 } 3435 3436 _createClass(ProductViewContent, [{ 3437 key: "render", 3438 value: function render() { 3439 var currentTabDisplay; 3440 3441 if (this.props.tab === 'comments') { 3442 currentTabDisplay = React.createElement("div", { 3443 className: "product-tab", 3444 id: "comments-tab" 3445 }, React.createElement(ProductCommentsContainer, { 3446 product: this.props.product, 3447 user: this.props.user 3448 })); 3449 } else if (this.props.tab === 'files') { 3450 currentTabDisplay = React.createElement(ProductViewFilesTab, { 3451 product: this.props.product, 3452 files: this.props.product.r_files 3453 }); 3454 } else if (this.props.tab === 'ratings') { 3455 currentTabDisplay = React.createElement(ProductViewRatingsTabWrapper, { 3456 ratings: this.props.product.r_ratings 3457 }); 3458 } else if (this.props.tab === 'favs') { 3459 currentTabDisplay = React.createElement(ProductViewFavTab, { 3460 likes: this.props.product.r_likes 3461 }); 3462 } else if (this.props.tab === 'plings') { 3463 currentTabDisplay = React.createElement(ProductViewPlingsTab, { 3464 plings: this.props.product.r_plings 3465 }); 3466 } 3467 3468 return React.createElement("div", { 3469 className: "wrapper" 3470 }, React.createElement("div", { 3471 className: "container" 3472 }, React.createElement("div", { 3473 className: "section", 3474 id: "product-view-content-container" 3475 }, currentTabDisplay))); 3476 } 3477 }]); 3478 3479 return ProductViewContent; 3480 }(React.Component); 3481 3482 var ProductCommentsContainer = 3483 /*#__PURE__*/ 3484 function (_React$Component11) { 3485 _inherits(ProductCommentsContainer, _React$Component11); 3486 3487 function ProductCommentsContainer(props) { 3488 var _this13; 3489 3490 _classCallCheck(this, ProductCommentsContainer); 3491 3492 _this13 = _possibleConstructorReturn(this, _getPrototypeOf(ProductCommentsContainer).call(this, props)); 3493 _this13.state = {}; 3494 return _this13; 3495 } 3496 3497 _createClass(ProductCommentsContainer, [{ 3498 key: "render", 3499 value: function render() { 3500 var _this14 = this; 3501 3502 var commentsDisplay; 3503 var cArray = categoryHelpers.convertCatChildrenObjectToArray(this.props.product.r_comments); 3504 3505 if (cArray.length > 0) { 3506 var product = this.props.product; 3507 var comments = cArray.map(function (c, index) { 3508 if (c.level === 1) { 3509 return React.createElement(CommentItem, { 3510 user: _this14.props.user, 3511 product: product, 3512 comment: c.comment, 3513 key: index, 3514 level: 1 3515 }); 3516 } 3517 }); 3518 commentsDisplay = React.createElement("div", { 3519 className: "comment-list" 3520 }, comments); 3521 } 3522 3523 return React.createElement("div", { 3524 className: "product-view-section", 3525 id: "product-comments-container" 3526 }, React.createElement(CommentForm, { 3527 user: this.props.user, 3528 product: this.props.product 3529 }), commentsDisplay); 3530 } 3531 }]); 3532 3533 return ProductCommentsContainer; 3534 }(React.Component); 3535 3536 var CommentForm = 3537 /*#__PURE__*/ 3538 function (_React$Component12) { 3539 _inherits(CommentForm, _React$Component12); 3540 3541 function CommentForm(props) { 3542 var _this15; 3543 3544 _classCallCheck(this, CommentForm); 3545 3546 _this15 = _possibleConstructorReturn(this, _getPrototypeOf(CommentForm).call(this, props)); 3547 _this15.state = { 3548 text: '', 3549 errorMsg: '', 3550 errorTitle: '', 3551 loading: false 3552 }; 3553 _this15.updateCommentText = _this15.updateCommentText.bind(_assertThisInitialized(_this15)); 3554 _this15.submitComment = _this15.submitComment.bind(_assertThisInitialized(_this15)); 3555 _this15.updateComments = _this15.updateComments.bind(_assertThisInitialized(_this15)); 3556 return _this15; 3557 } 3558 3559 _createClass(CommentForm, [{ 3560 key: "updateCommentText", 3561 value: function updateCommentText(e) { 3562 this.setState({ 3563 text: e.target.value 3564 }); 3565 } 3566 }, { 3567 key: "submitComment", 3568 value: function submitComment() { 3569 this.setState({ 3570 loading: true 3571 }, function () { 3572 var msg = this.state.text; 3573 var self = this; 3574 var data = { 3575 p: this.props.product.project_id, 3576 m: this.props.user.member_id, 3577 msg: this.state.text 3578 }; 3579 3580 if (this.props.comment) { 3581 data.i = this.props.comment.comment_id; 3582 } 3583 3584 jQuery.ajax({ 3585 data: data, 3586 url: '/productcomment/addreply/', 3587 type: 'post', 3588 dataType: 'json', 3589 error: function error(jqXHR, textStatus, errorThrown) { 3590 var results = JSON && JSON.parse(jqXHR.responseText) || $.parseJSON(jqXHR.responseText); 3591 self.setState({ 3592 errorMsg: results.message, 3593 errorTitle: results.title, 3594 login_url: results.login_url, 3595 status: 'error' 3596 }); 3597 }, 3598 success: function success(results) { 3599 var baseUrl; 3600 3601 if (store.getState().env === 'live') { 3602 baseUrl = 'cn.opendesktop.org'; 3603 } else { 3604 baseUrl = 'cn.pling.it'; 3605 } 3606 3607 $.ajax({ 3608 url: '/productcomment?p=' + self.props.product.project_id, 3609 cache: false 3610 }).done(function (response) { 3611 self.updateComments(response); 3612 }); 3613 } 3614 }); 3615 }); 3616 } 3617 }, { 3618 key: "updateComments", 3619 value: function updateComments(response) { 3620 store.dispatch(setProductComments(response)); 3621 this.setState({ 3622 text: '', 3623 loading: false 3624 }, function () { 3625 if (this.props.hideReplyForm) { 3626 this.props.hideReplyForm(); 3627 } 3628 }); 3629 } 3630 }, { 3631 key: "render", 3632 value: function render() { 3633 var commentFormDisplay; 3634 3635 if (this.props.user.username) { 3636 if (this.state.loading) { 3637 commentFormDisplay = React.createElement("div", { 3638 className: "comment-form-container" 3639 }, React.createElement("p", null, React.createElement("span", { 3640 className: "glyphicon glyphicon-refresh spinning" 3641 }), " posting comment")); 3642 } else { 3643 var submitBtnDisplay; 3644 3645 if (this.state.text.length === 0) { 3646 submitBtnDisplay = React.createElement("button", { 3647 disabled: "disabled", 3648 type: "button", 3649 className: "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored mdl-color--primary" 3650 }, "send"); 3651 } else { 3652 submitBtnDisplay = React.createElement("button", { 3653 onClick: this.submitComment, 3654 type: "button", 3655 className: "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored mdl-color--primary" 3656 }, React.createElement("span", { 3657 className: "glyphicon glyphicon-send" 3658 }), "send"); 3659 } 3660 3661 var errorDisplay; 3662 3663 if (this.state.status === 'error') { 3664 errorDisplay = React.createElement("div", { 3665 className: "comment-form-error-display-container" 3666 }, React.createElement("div", { 3667 dangerouslySetInnerHTML: { 3668 __html: this.state.errorTitle 3669 } 3670 }), React.createElement("div", { 3671 dangerouslySetInnerHTML: { 3672 __html: this.state.errorMsg 3673 } 3674 })); 3675 } 3676 3677 commentFormDisplay = React.createElement("div", { 3678 className: "comment-form-container" 3679 }, React.createElement("span", null, "Add Comment"), React.createElement("textarea", { 3680 className: "form-control", 3681 onChange: this.updateCommentText, 3682 value: this.state.text 3683 }), errorDisplay, submitBtnDisplay); 3684 } 3685 } else { 3686 commentFormDisplay = React.createElement("p", null, "Please ", React.createElement("a", { 3687 href: "/login?redirect=ohWn43n4SbmJZWlKUZNl2i1_s5gggiCE" 3688 }, "login"), " or ", React.createElement("a", { 3689 href: "/register" 3690 }, "register"), " to add a comment"); 3691 } 3692 3693 return React.createElement("div", { 3694 id: "product-page-comment-form-container" 3695 }, commentFormDisplay); 3696 } 3697 }]); 3698 3699 return CommentForm; 3700 }(React.Component); 3701 3702 var CommentItem = 3703 /*#__PURE__*/ 3704 function (_React$Component13) { 3705 _inherits(CommentItem, _React$Component13); 3706 3707 function CommentItem(props) { 3708 var _this16; 3709 3710 _classCallCheck(this, CommentItem); 3711 3712 _this16 = _possibleConstructorReturn(this, _getPrototypeOf(CommentItem).call(this, props)); 3713 _this16.state = { 3714 showCommentReplyForm: false 3715 }; 3716 _this16.filterByCommentLevel = _this16.filterByCommentLevel.bind(_assertThisInitialized(_this16)); 3717 _this16.onToggleReplyForm = _this16.onToggleReplyForm.bind(_assertThisInitialized(_this16)); 3718 _this16.onReportComment = _this16.onReportComment.bind(_assertThisInitialized(_this16)); 3719 _this16.onConfirmReportClick = _this16.onConfirmReportClick.bind(_assertThisInitialized(_this16)); 3720 return _this16; 3721 } 3722 3723 _createClass(CommentItem, [{ 3724 key: "filterByCommentLevel", 3725 value: function filterByCommentLevel(val) { 3726 if (val.level > this.props.level && this.props.comment.comment_id === val.comment.comment_parent_id) { 3727 return val; 3728 } 3729 } 3730 }, { 3731 key: "onToggleReplyForm", 3732 value: function onToggleReplyForm() { 3733 var showCommentReplyForm = this.state.showCommentReplyForm === true ? false : true; 3734 this.setState({ 3735 showCommentReplyForm: showCommentReplyForm 3736 }); 3737 } 3738 }, { 3739 key: "onReportComment", 3740 value: function onReportComment() { 3741 $('#report-' + this.props.comment.comment_id).modal('show'); 3742 } 3743 }, { 3744 key: "onConfirmReportClick", 3745 value: function onConfirmReportClick(commentId, productId) { 3746 jQuery.ajax({ 3747 data: { 3748 i: commentId, 3749 p: productId 3750 }, 3751 url: "/report/comment/", 3752 type: "POST", 3753 dataType: "json", 3754 error: function error(jqXHR, textStatus, errorThrown) { 3755 var results = JSON && JSON.parse(jqXHR.responseText) || $.parseJSON(jqXHR.responseText); 3756 $("#report-" + commentId).find('.modal-header-text').empty().append(results.title); 3757 $("#report-" + commentId).find('.modal-body').empty().append(results.message); 3758 setTimeout(function () { 3759 $("#report-" + commentId).modal('hide'); 3760 }, 2000); 3761 }, 3762 success: function success(results) { 3763 if (results.status == 'ok') { 3764 $("#report-" + commentId).find(".comment-report-p").empty().html(results.message.split('</p>')[0].split('<p>')[1]); 3765 } 3766 3767 if (results.status == 'error') { 3768 if (results.message != '') { 3769 $("#report-" + commentId).find(".comment-report-p").empty().html(results.message); 3770 } else { 3771 $("#report-" + commentId).find(".comment-report-p").empty().html('Service is temporarily unavailable.'); 3772 } 3773 } 3774 3775 setTimeout(function () { 3776 $("#report-" + commentId).modal('hide'); 3777 }, 2000); 3778 } 3779 }); 3780 } 3781 }, { 3782 key: "render", 3783 value: function render() { 3784 var commentRepliesContainer; 3785 var filteredComments = categoryHelpers.convertCatChildrenObjectToArray(this.props.product.r_comments).filter(this.filterByCommentLevel); 3786 3787 if (filteredComments.length > 0) { 3788 var product = this.props.product; 3789 var user = this.props.user; 3790 var comments = filteredComments.map(function (c, index) { 3791 return React.createElement(CommentItem, { 3792 user: user, 3793 product: product, 3794 comment: c.comment, 3795 key: index, 3796 level: c.level 3797 }); 3798 }); 3799 commentRepliesContainer = React.createElement("div", { 3800 className: "comment-item-replies-container" 3801 }, comments); 3802 } 3803 3804 var displayIsSupporter; 3805 3806 if (this.props.comment.issupporter === "1") { 3807 displayIsSupporter = React.createElement("li", null, React.createElement("span", { 3808 className: "is-supporter-display uc-icon" 3809 }, "S")); 3810 } 3811 3812 var displayIsCreater; 3813 3814 if (this.props.comment.member_id === this.props.product.member_id) { 3815 displayIsCreater = React.createElement("li", null, React.createElement("span", { 3816 className: "is-creater-display uc-icon" 3817 }, "C")); 3818 } 3819 3820 var commentReplyFormDisplay; 3821 3822 if (this.state.showCommentReplyForm) { 3823 commentReplyFormDisplay = React.createElement(CommentForm, { 3824 comment: this.props.comment, 3825 user: this.props.user, 3826 product: this.props.product, 3827 hideReplyForm: this.onToggleReplyForm 3828 }); 3829 } 3830 3831 return React.createElement("div", { 3832 className: "comment-item" 3833 }, React.createElement("div", { 3834 className: "comment-user-avatar" 3835 }, React.createElement("img", { 3836 src: this.props.comment.profile_image_url 3837 })), React.createElement("div", { 3838 className: "comment-item-content" 3839 }, React.createElement("div", { 3840 className: "comment-item-header" 3841 }, React.createElement("ul", null, React.createElement("li", null, React.createElement("a", { 3842 className: "comment-username", 3843 href: "/member/" + this.props.comment.member_id 3844 }, this.props.comment.username)), displayIsSupporter, displayIsCreater, React.createElement("li", null, React.createElement("span", { 3845 className: "comment-created-at" 3846 }, appHelpers.getTimeAgo(this.props.comment.comment_created_at))))), React.createElement("div", { 3847 className: "comment-item-text" 3848 }, this.props.comment.comment_text), React.createElement("div", { 3849 className: "comment-item-actions" 3850 }, React.createElement("a", { 3851 onClick: this.onToggleReplyForm 3852 }, React.createElement("i", { 3853 className: "material-icons reverse" 3854 }, "reply"), React.createElement("span", null, "Reply")), React.createElement("a", { 3855 onClick: this.onReportComment 3856 }, React.createElement("i", { 3857 className: "material-icons" 3858 }, "warning"), React.createElement("span", null, "Report")), React.createElement(ReportCommentModal, { 3859 comment: this.props.comment, 3860 product: this.props.product, 3861 user: this.props.user, 3862 onConfirmReportClick: this.onConfirmReportClick 3863 }))), commentReplyFormDisplay, commentRepliesContainer); 3864 } 3865 }]); 3866 3867 return CommentItem; 3868 }(React.Component); 3869 3870 var ReportCommentModal = 3871 /*#__PURE__*/ 3872 function (_React$Component14) { 3873 _inherits(ReportCommentModal, _React$Component14); 3874 3875 function ReportCommentModal(props) { 3876 var _this17; 3877 3878 _classCallCheck(this, ReportCommentModal); 3879 3880 _this17 = _possibleConstructorReturn(this, _getPrototypeOf(ReportCommentModal).call(this, props)); 3881 _this17.state = { 3882 status: "ready" 3883 }; 3884 return _this17; 3885 } 3886 3887 _createClass(ReportCommentModal, [{ 3888 key: "onConfirmReportClick", 3889 value: function onConfirmReportClick(commmentId, productId) { 3890 this.setState({ 3891 status: "loading" 3892 }, function () { 3893 this.props.onConfirmReportClick(commmentId, productId); 3894 }); 3895 } 3896 }, { 3897 key: "render", 3898 value: function render() { 3899 var _this18 = this; 3900 3901 var confirmActionButtonIconDisplay; 3902 3903 if (this.state.status === "ready") { 3904 confirmActionButtonIconDisplay = React.createElement("i", { 3905 className: "material-icons reverse" 3906 }, "reply"); 3907 } else if (this.state.status === "loading") { 3908 confirmActionButtonIconDisplay = React.createElement("span", { 3909 className: "glyphicon glyphicon-refresh spinning" 3910 }); 3911 } 3912 3913 return React.createElement("div", { 3914 className: "modal report-comment-modal", 3915 id: "report-" + this.props.comment.comment_id, 3916 tabIndex: "-1", 3917 role: "dialog" 3918 }, React.createElement("div", { 3919 className: "modal-dialog", 3920 role: "document" 3921 }, React.createElement("div", { 3922 className: "modal-content" 3923 }, React.createElement("div", { 3924 className: "modal-header" 3925 }, React.createElement("h4", { 3926 className: "modal-title" 3927 }, "Report Comment"), React.createElement("button", { 3928 type: "button", 3929 id: "review-modal-close", 3930 className: "close", 3931 "data-dismiss": "modal", 3932 "aria-label": "Close" 3933 }, React.createElement("span", { 3934 "aria-hidden": "true" 3935 }, "\xD7"))), React.createElement("div", { 3936 className: "modal-body" 3937 }, React.createElement("p", { 3938 className: "comment-report-p" 3939 }, "Do you really want to report this comment?")), React.createElement("div", { 3940 className: "modal-footer" 3941 }, React.createElement("a", { 3942 onClick: function onClick() { 3943 return _this18.onConfirmReportClick(_this18.props.comment.comment_id, _this18.props.product.project_id); 3944 } 3945 }, confirmActionButtonIconDisplay, " yes"))))); 3946 } 3947 }]); 3948 3949 return ReportCommentModal; 3950 }(React.Component); 3951 3952 var ProductViewFilesTab = 3953 /*#__PURE__*/ 3954 function (_React$Component15) { 3955 _inherits(ProductViewFilesTab, _React$Component15); 3956 3957 function ProductViewFilesTab() { 3958 _classCallCheck(this, ProductViewFilesTab); 3959 3960 return _possibleConstructorReturn(this, _getPrototypeOf(ProductViewFilesTab).apply(this, arguments)); 3961 } 3962 3963 _createClass(ProductViewFilesTab, [{ 3964 key: "render", 3965 value: function render() { 3966 var _this19 = this; 3967 3968 var filesDisplay; 3969 var files = this.props.files.map(function (f, index) { 3970 return React.createElement(ProductViewFilesTabItem, { 3971 product: _this19.props.product, 3972 key: index, 3973 file: f 3974 }); 3975 }); 3976 var summeryRow = productHelpers.getFilesSummary(this.props.files); 3977 filesDisplay = React.createElement("tbody", null, files, React.createElement("tr", null, React.createElement("td", null, summeryRow.total, " files (0 archived)"), React.createElement("td", null), React.createElement("td", null), React.createElement("td", null), React.createElement("td", null), React.createElement("td", null, summeryRow.downloads), React.createElement("td", null), React.createElement("td", null, appHelpers.getFileSize(summeryRow.fileSize)), React.createElement("td", null), React.createElement("td", null))); 3978 return React.createElement("div", { 3979 id: "files-tab", 3980 className: "product-tab" 3981 }, React.createElement("table", { 3982 className: "mdl-data-table mdl-js-data-table mdl-shadow--2dp" 3983 }, React.createElement("thead", null, React.createElement("tr", null, React.createElement("th", { 3984 className: "mdl-data-table__cell--non-numericm" 3985 }, "File"), React.createElement("th", { 3986 className: "mdl-data-table__cell--non-numericm" 3987 }, "Version"), React.createElement("th", { 3988 className: "mdl-data-table__cell--non-numericm" 3989 }, "Description"), React.createElement("th", { 3990 className: "mdl-data-table__cell--non-numericm" 3991 }, "Packagetype"), React.createElement("th", { 3992 className: "mdl-data-table__cell--non-numericm" 3993 }, "Architecture"), React.createElement("th", { 3994 className: "mdl-data-table__cell--non-numericm" 3995 }, "Downloads"), React.createElement("th", { 3996 className: "mdl-data-table__cell--non-numericm" 3997 }, "Date"), React.createElement("th", { 3998 className: "mdl-data-table__cell--non-numericm" 3999 }, "Filesize"), React.createElement("th", { 4000 className: "mdl-data-table__cell--non-numericm" 4001 }, "DL"), React.createElement("th", { 4002 className: "mdl-data-table__cell--non-numericm" 4003 }, "OCS-Install"))), filesDisplay)); 4004 } 4005 }]); 4006 4007 return ProductViewFilesTab; 4008 }(React.Component); 4009 4010 var ProductViewFilesTabItem = 4011 /*#__PURE__*/ 4012 function (_React$Component16) { 4013 _inherits(ProductViewFilesTabItem, _React$Component16); 4014 4015 function ProductViewFilesTabItem(props) { 4016 var _this20; 4017 4018 _classCallCheck(this, ProductViewFilesTabItem); 4019 4020 _this20 = _possibleConstructorReturn(this, _getPrototypeOf(ProductViewFilesTabItem).call(this, props)); 4021 _this20.state = { 4022 downloadLink: "" 4023 }; 4024 return _this20; 4025 } 4026 4027 _createClass(ProductViewFilesTabItem, [{ 4028 key: "componentDidMount", 4029 value: function componentDidMount() { 4030 var baseUrl, downloadLinkUrlAttr; 4031 4032 if (store.getState().env === 'live') { 4033 baseUrl = 'opendesktop.org'; 4034 downloadLinkUrlAttr = "https%3A%2F%dl.opendesktop.org%2Fapi%2F"; 4035 } else { 4036 baseUrl = 'pling.cc'; 4037 downloadLinkUrlAttr = "https%3A%2F%2Fcc.ppload.com%2Fapi%2F"; 4038 } 4039 4040 var f = this.props.file; 4041 var timestamp = Math.floor(new Date().getTime() / 1000 + 3600); 4042 var fileDownloadHash = appHelpers.generateFileDownloadHash(f, store.getState().env); 4043 var downloadLink = "https://" + baseUrl + "/p/" + this.props.product.project_id + "/startdownload?file_id=" + f.id + "&file_name=" + f.title + "&file_type=" + f.type + "&file_size=" + f.size + "&url=" + downloadLinkUrlAttr + "files%2Fdownload%2Fid%2F" + f.id + "%2Fs%2F" + fileDownloadHash + "%2Ft%2F" + timestamp + "%2Fu%2F" + this.props.product.member_id + "%2F" + f.title; 4044 this.setState({ 4045 downloadLink: downloadLink 4046 }); 4047 } 4048 }, { 4049 key: "render", 4050 value: function render() { 4051 var f = this.props.file; 4052 return React.createElement("tr", null, React.createElement("td", { 4053 className: "mdl-data-table__cell--non-numericm" 4054 }, React.createElement("a", { 4055 href: this.state.downloadLink 4056 }, f.title)), React.createElement("td", null, f.version), React.createElement("td", { 4057 className: "mdl-data-table__cell--non-numericm" 4058 }, f.description), React.createElement("td", { 4059 className: "mdl-data-table__cell--non-numericm" 4060 }, f.packagename), React.createElement("td", { 4061 className: "mdl-data-table__cell--non-numericm" 4062 }, f.archname), React.createElement("td", null, f.downloaded_count), React.createElement("td", { 4063 className: "mdl-data-table__cell--non-numericm" 4064 }, appHelpers.getTimeAgo(f.created_timestamp)), React.createElement("td", { 4065 className: "mdl-data-table__cell--non-numericm" 4066 }, appHelpers.getFileSize(f.size)), React.createElement("td", null, React.createElement("a", { 4067 href: this.state.downloadLink 4068 }, React.createElement("i", { 4069 className: "material-icons" 4070 }, "cloud_download"))), React.createElement("td", null, f.ocs_compatible)); 4071 } 4072 }]); 4073 4074 return ProductViewFilesTabItem; 4075 }(React.Component); 4076 4077 var ProductViewRatingsTab = 4078 /*#__PURE__*/ 4079 function (_React$Component17) { 4080 _inherits(ProductViewRatingsTab, _React$Component17); 4081 4082 function ProductViewRatingsTab(props) { 4083 var _this21; 4084 4085 _classCallCheck(this, ProductViewRatingsTab); 4086 4087 _this21 = _possibleConstructorReturn(this, _getPrototypeOf(ProductViewRatingsTab).call(this, props)); 4088 _this21.state = { 4089 filter: 'active' 4090 }; 4091 _this21.filterLikes = _this21.filterLikes.bind(_assertThisInitialized(_this21)); 4092 _this21.filterDislikes = _this21.filterDislikes.bind(_assertThisInitialized(_this21)); 4093 _this21.filterActive = _this21.filterActive.bind(_assertThisInitialized(_this21)); 4094 _this21.setFilter = _this21.setFilter.bind(_assertThisInitialized(_this21)); 4095 return _this21; 4096 } 4097 4098 _createClass(ProductViewRatingsTab, [{ 4099 key: "filterLikes", 4100 value: function filterLikes(rating) { 4101 if (rating.user_like === "1") { 4102 return rating; 4103 } 4104 } 4105 }, { 4106 key: "filterDislikes", 4107 value: function filterDislikes(rating) { 4108 if (rating.user_dislike === "1") { 4109 return rating; 4110 } 4111 } 4112 }, { 4113 key: "filterActive", 4114 value: function filterActive(rating) { 4115 if (rating.rating_active === "1") { 4116 return rating; 4117 } 4118 } 4119 }, { 4120 key: "setFilter", 4121 value: function setFilter(filter) { 4122 this.setState({ 4123 filter: filter 4124 }); 4125 } 4126 }, { 4127 key: "render", 4128 value: function render() { 4129 var _this22 = this; 4130 4131 var ratingsLikes = this.props.ratings.filter(this.filterLikes); 4132 var ratingsDislikes = this.props.ratings.filter(this.filterDislikes); 4133 var ratingsActive = this.props.ratings.filter(this.filterActive); 4134 var ratingsDisplay; 4135 4136 if (this.props.ratings.length > 0) { 4137 var ratings; 4138 4139 if (this.state.filter === "all") { 4140 ratings = this.props.ratings; 4141 } else if (this.state.filter === "active") { 4142 ratings = ratingsActive; 4143 } else if (this.state.filter === "dislikes") { 4144 ratings = ratingsDislikes; 4145 } else if (this.state.filter === "likes") { 4146 ratings = ratingsLikes; 4147 } 4148 4149 var ratingsItems = ratings.map(function (r, index) { 4150 return React.createElement(RatingItem, { 4151 key: index, 4152 rating: r 4153 }); 4154 }); 4155 ratingsDisplay = React.createElement("div", { 4156 className: "product-ratings-list comment-list" 4157 }, ratingsItems); 4158 } 4159 4160 var subMenuItemClassName = " mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"; 4161 var subMenuActiveItemClassName = "active mdl-button--colored mdl-color--primary item"; 4162 return React.createElement("div", { 4163 id: "ratings-tab", 4164 className: "product-tab" 4165 }, React.createElement("div", { 4166 className: "ratings-filters-menu" 4167 }, React.createElement("span", { 4168 className: "btn-container", 4169 onClick: function onClick() { 4170 return _this22.setFilter("dislikes"); 4171 } 4172 }, React.createElement("a", { 4173 className: this.state.filter === "dislikes" ? subMenuActiveItemClassName + subMenuItemClassName : subMenuItemClassName, 4174 onClick: this.showDislikes 4175 }, "show dislikes (", ratingsDislikes.length, ")")), React.createElement("span", { 4176 className: "btn-container", 4177 onClick: function onClick() { 4178 return _this22.setFilter("likes"); 4179 } 4180 }, React.createElement("a", _defineProperty({ 4181 onClick: this.setDislikesFilter, 4182 className: this.state.filter === "likes" ? subMenuActiveItemClassName + subMenuItemClassName : subMenuItemClassName 4183 }, "onClick", this.showLikes), "show likes (", ratingsLikes.length, ")")), React.createElement("span", { 4184 className: "btn-container", 4185 onClick: function onClick() { 4186 return _this22.setFilter("active"); 4187 } 4188 }, React.createElement("a", _defineProperty({ 4189 onClick: this.setDislikesFilter, 4190 className: this.state.filter === "active" ? subMenuActiveItemClassName + subMenuItemClassName : subMenuItemClassName 4191 }, "onClick", this.showActive), "show active reviews (", ratingsActive.length, ")")), React.createElement("span", { 4192 className: "btn-container", 4193 onClick: function onClick() { 4194 return _this22.setFilter("all"); 4195 } 4196 }, React.createElement("a", _defineProperty({ 4197 onClick: this.setDislikesFilter, 4198 className: this.state.filter === "all" ? subMenuActiveItemClassName + subMenuItemClassName : subMenuItemClassName 4199 }, "onClick", this.showAll), "show all (", this.props.ratings.length, ")"))), ratingsDisplay); 4200 } 4201 }]); 4202 4203 return ProductViewRatingsTab; 4204 }(React.Component); 4205 4206 var mapStateToProductViewRatingsTabProps = function mapStateToProductViewRatingsTabProps(state) { 4207 var ratings = state.product.r_ratings; 4208 return { 4209 ratings: ratings 4210 }; 4211 }; 4212 4213 var mapDispatchToProductViewRatingsTabProps = function mapDispatchToProductViewRatingsTabProps(dispatch) { 4214 return { 4215 dispatch: dispatch 4216 }; 4217 }; 4218 4219 var ProductViewRatingsTabWrapper = ReactRedux.connect(mapStateToProductViewRatingsTabProps, mapDispatchToProductViewRatingsTabProps)(ProductViewRatingsTab); 4220 4221 var RatingItem = 4222 /*#__PURE__*/ 4223 function (_React$Component18) { 4224 _inherits(RatingItem, _React$Component18); 4225 4226 function RatingItem(props) { 4227 var _this23; 4228 4229 _classCallCheck(this, RatingItem); 4230 4231 _this23 = _possibleConstructorReturn(this, _getPrototypeOf(RatingItem).call(this, props)); 4232 _this23.state = {}; 4233 return _this23; 4234 } 4235 4236 _createClass(RatingItem, [{ 4237 key: "render", 4238 value: function render() { 4239 return React.createElement("div", { 4240 className: "product-rating-item comment-item" 4241 }, React.createElement("div", { 4242 className: "rating-user-avatar comment-user-avatar" 4243 }, React.createElement("img", { 4244 src: this.props.rating.profile_image_url 4245 })), React.createElement("div", { 4246 className: "rating-item-content comment-item-content" 4247 }, React.createElement("div", { 4248 className: "rating-item-header comment-item-header" 4249 }, React.createElement("a", { 4250 href: "/member/" + this.props.rating.member_id 4251 }, this.props.rating.username), React.createElement("span", { 4252 className: "comment-created-at" 4253 }, appHelpers.getTimeAgo(this.props.rating.created_at))), React.createElement("div", { 4254 className: "rating-item-text comment-item-text" 4255 }, this.props.rating.comment_text))); 4256 } 4257 }]); 4258 4259 return RatingItem; 4260 }(React.Component); 4261 4262 var ProductViewFavTab = 4263 /*#__PURE__*/ 4264 function (_React$Component19) { 4265 _inherits(ProductViewFavTab, _React$Component19); 4266 4267 function ProductViewFavTab(props) { 4268 var _this24; 4269 4270 _classCallCheck(this, ProductViewFavTab); 4271 4272 _this24 = _possibleConstructorReturn(this, _getPrototypeOf(ProductViewFavTab).call(this, props)); 4273 _this24.state = {}; 4274 return _this24; 4275 } 4276 4277 _createClass(ProductViewFavTab, [{ 4278 key: "render", 4279 value: function render() { 4280 var favsDisplay; 4281 4282 if (this.props.likes) { 4283 var favs = this.props.likes.map(function (like, index) { 4284 return React.createElement(UserCardItem, { 4285 key: index, 4286 like: like 4287 }); 4288 }); 4289 favsDisplay = React.createElement("div", { 4290 className: "favs-list supporter-list" 4291 }, favs); 4292 } 4293 4294 return React.createElement("div", { 4295 className: "product-tab", 4296 id: "fav-tab" 4297 }, favsDisplay); 4298 } 4299 }]); 4300 4301 return ProductViewFavTab; 4302 }(React.Component); 4303 4304 var ProductViewPlingsTab = 4305 /*#__PURE__*/ 4306 function (_React$Component20) { 4307 _inherits(ProductViewPlingsTab, _React$Component20); 4308 4309 function ProductViewPlingsTab(props) { 4310 var _this25; 4311 4312 _classCallCheck(this, ProductViewPlingsTab); 4313 4314 _this25 = _possibleConstructorReturn(this, _getPrototypeOf(ProductViewPlingsTab).call(this, props)); 4315 _this25.state = {}; 4316 return _this25; 4317 } 4318 4319 _createClass(ProductViewPlingsTab, [{ 4320 key: "render", 4321 value: function render() { 4322 var plingsDisplay; 4323 4324 if (this.props.plings) { 4325 var plings = this.props.plings.map(function (pling, index) { 4326 return React.createElement(UserCardItem, { 4327 key: index, 4328 pling: pling 4329 }); 4330 }); 4331 plingsDisplay = React.createElement("div", { 4332 className: "plings-list supporter-list" 4333 }, plings); 4334 } 4335 4336 return React.createElement("div", { 4337 className: "product-tab", 4338 id: "plings-tab" 4339 }, plingsDisplay); 4340 } 4341 }]); 4342 4343 return ProductViewPlingsTab; 4344 }(React.Component); 4345 4346 var UserCardItem = 4347 /*#__PURE__*/ 4348 function (_React$Component21) { 4349 _inherits(UserCardItem, _React$Component21); 4350 4351 function UserCardItem(props) { 4352 var _this26; 4353 4354 _classCallCheck(this, UserCardItem); 4355 4356 _this26 = _possibleConstructorReturn(this, _getPrototypeOf(UserCardItem).call(this, props)); 4357 _this26.state = {}; 4358 return _this26; 4359 } 4360 4361 _createClass(UserCardItem, [{ 4362 key: "render", 4363 value: function render() { 4364 var item; 4365 4366 if (this.props.like) { 4367 item = this.props.like; 4368 } else if (this.props.pling) { 4369 item = this.props.pling; 4370 } 4371 4372 var cardTypeDisplay; 4373 4374 if (this.props.like) { 4375 cardTypeDisplay = React.createElement("i", { 4376 className: "fa fa-heart myfav", 4377 "aria-hidden": "true" 4378 }); 4379 } else if (this.props.pling) { 4380 cardTypeDisplay = React.createElement("img", { 4381 src: "/images/system/pling-btn-active.png" 4382 }); 4383 } 4384 4385 return React.createElement("div", { 4386 className: "supporter-list-item" 4387 }, React.createElement("div", { 4388 className: "item-content" 4389 }, React.createElement("div", { 4390 className: "user-avatar" 4391 }, React.createElement("img", { 4392 src: item.profile_image_url 4393 })), React.createElement("span", { 4394 className: "username" 4395 }, React.createElement("a", { 4396 href: "/member/" + item.member_id 4397 }, item.username)), React.createElement("span", { 4398 className: "card-type-holder" 4399 }, cardTypeDisplay), React.createElement("span", { 4400 className: "created-at" 4401 }, appHelpers.getTimeAgo(item.created_at)))); 4402 } 4403 }]); 4404 4405 return UserCardItem; 4406 }(React.Component); 4407 "use strict"; 4408 4409 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); } 4410 4411 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 4412 4413 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); } } 4414 4415 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 4416 4417 function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 4418 4419 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 4420 4421 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 4422 4423 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); } 4424 4425 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 4426 4427 var _ReactRedux = ReactRedux, 4428 Provider = _ReactRedux.Provider, 4429 connect = _ReactRedux.connect; 4430 var store = Redux.createStore(reducer); 4431 4432 var App = 4433 /*#__PURE__*/ 4434 function (_React$Component) { 4435 _inherits(App, _React$Component); 4436 4437 function App(props) { 4438 var _this; 4439 4440 _classCallCheck(this, App); 4441 4442 _this = _possibleConstructorReturn(this, _getPrototypeOf(App).call(this, props)); 4443 _this.state = { 4444 loading: true, 4445 version: 1 4446 }; 4447 _this.updateDimensions = _this.updateDimensions.bind(_assertThisInitialized(_this)); 4448 return _this; 4449 } 4450 4451 _createClass(App, [{ 4452 key: "componentWillMount", 4453 value: function componentWillMount() { 4454 // device 4455 this.updateDimensions(); 4456 } 4457 }, { 4458 key: "componentDidMount", 4459 value: function componentDidMount() { 4460 // domain 4461 store.dispatch(setDomain(window.location.hostname)); // env 4462 4463 var env = appHelpers.getEnv(window.location.hostname); 4464 store.dispatch(setEnv(env)); // device 4465 4466 window.addEventListener("resize", this.updateDimensions); // view 4467 4468 if (window.view) store.dispatch(setView(view)); // products 4469 4470 if (window.products) { 4471 store.dispatch(setProducts(products)); 4472 } // product (single) 4473 4474 4475 if (window.product) { 4476 store.dispatch(setProduct(product)); 4477 store.dispatch(setProductFiles(filesJson)); 4478 store.dispatch(setProductUpdates(updatesJson)); 4479 store.dispatch(setProductRatings(ratingsJson)); 4480 store.dispatch(setProductLikes(likeJson)); 4481 store.dispatch(setProductPlings(projectplingsJson)); 4482 store.dispatch(setProductUserRatings(ratingOfUserJson)); 4483 store.dispatch(setProductGallery(galleryPicturesJson)); 4484 store.dispatch(setProductComments(commentsJson)); 4485 store.dispatch(setProductOrigins(originsJson)); 4486 store.dispatch(setProductRelated(relatedJson)); 4487 store.dispatch(setProductMoreProducts(moreProductsJson)); 4488 store.dispatch(setProductMoreProductsOtherUsers(moreProductsOfOtherUsrJson)); 4489 store.dispatch(setProductTags(tagsuserJson, tagssystemJson)); 4490 } // pagination 4491 4492 4493 if (window.pagination) { 4494 store.dispatch(setPagination(pagination)); 4495 } // filters 4496 4497 4498 if (window.filters) { 4499 store.dispatch(setFilters(filters)); 4500 } // top products 4501 4502 4503 if (window.topProducts) { 4504 store.dispatch(setTopProducts(topProducts)); 4505 } // categories 4506 4507 4508 if (window.categories) { 4509 // set categories 4510 store.dispatch(setCategories(categories)); 4511 4512 if (window.catId) { 4513 // current categories 4514 var currentCategories = categoryHelpers.findCurrentCategories(categories, catId); 4515 store.dispatch(setCurrentCategory(currentCategories.category)); 4516 store.dispatch(setCurrentSubCategory(currentCategories.subcategory)); 4517 store.dispatch(setCurrentSecondSubCategory(currentCategories.secondSubCategory)); 4518 } 4519 } // supporters 4520 4521 4522 if (window.supporters) { 4523 store.dispatch(setSupporters(supporters)); 4524 } // comments 4525 4526 4527 if (window.comments) { 4528 store.dispatch(setComments(comments)); 4529 } // user 4530 4531 4532 if (window.user) { 4533 store.dispatch(setUser(user)); 4534 } // finish loading 4535 4536 4537 this.setState({ 4538 loading: false 4539 }); 4540 } 4541 }, { 4542 key: "componentWillUnmount", 4543 value: function componentWillUnmount() { 4544 // device 4545 window.removeEventListener("resize", this.updateDimensions); 4546 } 4547 }, { 4548 key: "updateDimensions", 4549 value: function updateDimensions() { 4550 var device = appHelpers.getDeviceWidth(window.innerWidth); 4551 store.dispatch(setDevice(device)); 4552 } 4553 }, { 4554 key: "render", 4555 value: function render() { 4556 var displayView = React.createElement(HomePageWrapper, null); 4557 4558 if (store.getState().view === 'explore') { 4559 displayView = React.createElement(ExplorePageWrapper, null); 4560 } else if (store.getState().view === 'product') { 4561 displayView = React.createElement(ProductViewWrapper, null); 4562 } 4563 4564 return React.createElement("div", { 4565 id: "app-root" 4566 }, displayView); 4567 } 4568 }]); 4569 4570 return App; 4571 }(React.Component); 4572 4573 var AppWrapper = 4574 /*#__PURE__*/ 4575 function (_React$Component2) { 4576 _inherits(AppWrapper, _React$Component2); 4577 4578 function AppWrapper() { 4579 _classCallCheck(this, AppWrapper); 4580 4581 return _possibleConstructorReturn(this, _getPrototypeOf(AppWrapper).apply(this, arguments)); 4582 } 4583 4584 _createClass(AppWrapper, [{ 4585 key: "render", 4586 value: function render() { 4587 return React.createElement(Provider, { 4588 store: store 4589 }, React.createElement(App, null)); 4590 } 4591 }]); 4592 4593 return AppWrapper; 4594 }(React.Component); 4595 4596 ReactDOM.render(React.createElement(AppWrapper, null), document.getElementById('explore-content'));