Unverified Commit 4ad2aad7 authored by Yi (Flora) Liu's avatar Yi (Flora) Liu Committed by GitHub
Browse files

Yiliu/master/update mobile sidebar (#204)



* Update sidebar menu for Quicksilver styles
Signed-off-by: Eric Poirier's avatarEric Poirier <eric.poirier@eclipse-foundation.org>

* Create separate layout for the new sidebar
Signed-off-by: Eric Poirier's avatarEric Poirier <eric.poirier@eclipse-foundation.org>

* Add sidebar-block for third-parent page only
Signed-off-by: Eric Poirier's avatarEric Poirier <eric.poirier@eclipse-foundation.org>

* Update mobile sidebar based on Eric sidebar
Signed-off-by: Yi Liu's avatarYi Liu <yi.liu@eclipse-foundation.org>

* Adjust mobile sidebar based on Eric sidebar block
Signed-off-by: Yi Liu's avatarYi Liu <yi.liu@eclipse-foundation.org>

* one more fix of paddings
Signed-off-by: Yi Liu's avatarYi Liu <yi.liu@eclipse-foundation.org>

* Add pre back
Signed-off-by: Yi Liu's avatarYi Liu <yi.liu@eclipse-foundation.org>

* sync updates from Eric
Signed-off-by: Yi Liu's avatarYi Liu <yi.liu@eclipse-foundation.org>

* add bottom spacing for children, use offset instead of empty div
Signed-off-by: Yi Liu's avatarYi Liu <yi.liu@eclipse-foundation.org>

* remove not needed prev., use offset
Signed-off-by: Yi Liu's avatarYi Liu <yi.liu@eclipse-foundation.org>

* sync if eq current page
Signed-off-by: Yi Liu's avatarYi Liu <yi.liu@eclipse-foundation.org>

* use cond, and default instead of scratch
Signed-off-by: Yi Liu's avatarYi Liu <yi.liu@eclipse-foundation.org>

* remove ^ in package, scratch check lower
Signed-off-by: Yi Liu's avatarYi Liu <yi.liu@eclipse-foundation.org>

* remove home text, make margin-top-20
Signed-off-by: Yi Liu's avatarYi Liu <yi.liu@eclipse-foundation.org>
Co-authored-by: Eric Poirier's avatarEric Poirier <eric.poirier@eclipse-foundation.org>
Co-authored-by: Christopher Guindon's avatarChristopher Guindon <chris.guindon@eclipse-foundation.org>
parent 9f09ca6b
......@@ -24,6 +24,7 @@ googleAnalytics = ""
table_classes = "table table-bordered"
hide_cfa_same_page = true
show_collapsible_menu = true
sidebar_layout = "default"
[Author]
name = "Christopher Guindon"
......
......@@ -253,16 +253,29 @@
url = "/translations"
weight = 3
parent = "home"
identifier = "translation-guide"
[[sidebar]]
name = "Translation Guide 1"
url = "/translations"
weight = 1
parent = "translation-guide"
[[sidebar]]
name = "Translation Guide 2"
url = "/translations"
weight = 1
parent = "translation-guide"
[[sidebar]]
name = "Third parent"
url = "/third-parent"
weight = 2
pre = "<i class=\"fa fa-github fa-fw\"></i>"
pre = "<i class=\"sidebar-menu-icon\" data-feather=\"github\"></i>"
identifier = "third-parent"
[[sidebar]]
name = "test children"
name = "Test Children"
url = "/third-parent/test-children"
weight = 1
parent = "third-parent"
......@@ -270,7 +283,7 @@
identifier = "test-children"
[[sidebar]]
name = "test children 2"
name = "Test Children 2"
url = "/third-parent/test-children-2"
weight = 1
parent = "third-parent"
......@@ -278,18 +291,16 @@
identifier = "test-children-2"
[[sidebar]]
name = "test children's children-1"
name = "Test Children Children 1"
url = "/third-parent/test-children/test-children-children"
weight = 1
parent = "test-children"
pre = "<i class=\"fa fa-chevron-right fa-fw\"></i>"
[[sidebar]]
name = "test children's children-2"
name = "Test Children Children 2"
url = "/third-parent/test-children/test-children-children-2"
weight = 2
parent = "test-children"
pre = "<i class=\"fa fa-chevron-right fa-fw\"></i>"
[[sidebar]]
name = "Membership"
......
......@@ -244,7 +244,7 @@
identifier = "third-parent"
[[sidebar]]
name = "test children"
name = "Test Children"
url = "/third-parent/test-children"
weight = 1
parent = "third-parent"
......@@ -252,7 +252,7 @@
identifier = "test-children"
[[sidebar]]
name = "test children 2"
name = "Test Children 2"
url = "/third-parent/test-children-2"
weight = 1
parent = "third-parent"
......@@ -260,14 +260,14 @@
identifier = "test-children-2"
[[sidebar]]
name = "test children's children-1"
name = "Test Children's children-1"
url = "/third-parent/test-children/test-children-children"
weight = 1
parent = "test-children"
pre = "<i class=\"fa fa-chevron-right fa-fw\"></i>"
[[sidebar]]
name = "test children's children-2"
name = "Test Children's children-2"
url = "/third-parent/test-children/test-children-children-2"
weight = 2
parent = "test-children"
......
......@@ -4,6 +4,7 @@ headline: "headline"
date: 2018-04-05T16:09:45-04:00
description: "description"
hide_sidebar: false
sidebar_layout: "sidebar_block"
---
Third Parent
\ No newline at end of file
---
title: "Test Children 222"
title: "Test Children 2"
headline: "headline"
date: 2018-04-05T16:09:45-04:00
description: "description"
......
---
title: "Test Children Children Two"
title: "Test Children Children 2"
headline: "headline"
date: 2018-04-05T16:09:45-04:00
description: "description"
......
---
title: "Test Children Children One"
title: "Test Children Children 1"
headline: "headline"
date: 2018-04-05T16:09:45-04:00
description: "description"
......
......@@ -21,38 +21,55 @@
{{ end }}
{{$currentSection := .Scratch.Get "currentSection" }}
<!--- Sidebar layout --->
{{ $sidebarLayout := .Page.Params.sidebar_layout | default .Site.Params.sidebar_layout | default "default" }}
{{ $classname := cond (eq $sidebarLayout "sidebar_block") "sidebar-block" "collapsible-menu" }}
<!----------------------- Collapisible start ------------------------------------>
{{ range .Site.Menus.sidebar }}
{{$parentItem := . }}
{{ if and (.HasChildren) (eq $currentSection $parentItem.Identifier) }}
<div class="collapsible-menu container hidden-lg hidden-md visible-sm visible-xs">
<div class="container collapsible-menu-item related-content">
<div class="{{ $classname }} margin-top-20 container hidden-lg hidden-md visible-sm visible-xs">
<div class="container padding-left-0 padding-right-0 {{ $classname }}-item related-content">
<a href="#sidebars-contents" data-toggle="collapse" aria-expanded="false" aria-controls="sidebars-contents">
<div class="col-xs-6"><i class="fa fa-plus fa-bars"></i></div>
<div class="col-xs-18 collapsible-menu-text">Related Content</div>
<div class="col-xs-18 {{ $classname }}-text">Related Content</div>
</a>
</div>
<div class="container collapse" id="sidebars-contents">
</div>
<div class="container collapse {{ if eq $classname "sidebar-block" }} padding-left-0 padding-right-0 {{ end }}" id="sidebars-contents">
{{ range .Children }}
{{ if eq .HasChildren false }}
<div class="row collapsible-menu-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<div class="row {{ $classname }}-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-18 col-xs-offset-6 collapsible-menu-text">{{ .Name }}</div>
<div class="col-xs-6">{{ .Pre }}</div>
<div class="col-xs-18 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
{{ end }} <!-- if eq .HasChildren false end -->
{{ if .HasChildren }}
<div class="row collapsible-menu-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<div class="row {{ $classname }}-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="#sub-children-{{ .Identifier }}" data-toggle="collapse" aria-expanded="false" aria-controls="sub-children{{ .Identifier }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-6">{{ .Pre }}</div>
<div class="col-xs-18 collapsible-menu-text">{{ .Name }}</div>
<div class="col-xs-18 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
<div class="row collapsible-menu-sub-items collapse" id="sub-children-{{ .Identifier }}">
<div class="row {{ $classname }}-sub-items {{ if eq $classname "sidebar-block" }} margin-bottom-20 {{ end }} collapse" id="sub-children-{{ .Identifier }}">
<!-- Check if current parent menu has children and has own url, we should add an entry to goto this parent -->
{{ if .URL }}
<div class="row {{ $classname }}-sub-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-18 col-xs-offset-6 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
{{ end }}
{{ range .Children }}
<div class="row collapsible-menu-sub-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<div class="row {{ $classname }}-sub-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-18 col-xs-offset-6 collapsible-menu-text">{{ .Name }}</div>
<div class="col-xs-18 col-xs-offset-6 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
{{ end }} <!--Children's Children end-->
......@@ -62,7 +79,7 @@
</div>
{{ end }} <!-- if .HasChildren end -->
{{ end }} <!-- range .Site.Menus.sidebar end -->
</div> <!-- div id="collapsible-menu" end -->
</div> <!-- div id="{{ $classname }}" end -->
<!-------------------- Collapisible end ----------------------------------------->
{{ end }} <!-- if or (eq $currentPage.Params.show_collapsible_menu true) (eq .Site.Params.show_collapsible_menu true) end-->
......
......@@ -12,9 +12,14 @@
-->
{{ if ne .Page.Params.hide_sidebar true }}
{{ $sidebarLayout := .Page.Params.sidebar_layout | default .Site.Params.sidebar_layout | default "default" }}
</div>
<div class="{{- .Params.main_sidebar_class | default .Site.Params.main_sidebar_class | default "col-md-6 padding-bottom-30"}}">
{{ partial "sidebar.html" . }}
{{ if eq $sidebarLayout "default" }}
{{ partial "sidebar.html" . }}
{{ else if eq $sidebarLayout "sidebar_block" }}
{{ partial "sidebar-block.html" . }}
{{ end }}
</div>
</div>
{{ end }}
......
<!--
Copyright (c) 2018 Eclipse Foundation, Inc.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
Contributors:
Christopher Guindon <chris.guindon@eclipse-foundation.org>
SPDX-License-Identifier: EPL-2.0
-->
{{ if isset .Site.Menus "sidebar" }}
{{ $currentPage := . }}
{{ .Scratch.Set "currentSection" "home" }}
{{ if $currentPage.Section }}
{{ .Scratch.Set "currentSection" $currentPage.Section }}
{{ end }}
{{$currentSection := .Scratch.Get "currentSection" }}
{{ range .Site.Menus.sidebar }}
{{$parentItem := . }}
{{ if and (.HasChildren) (eq $currentSection $parentItem.Identifier) }}
<aside class="sidebar-block">
{{ range .Children }}
{{ if .HasChildren }}
<div class="row sidebar-block-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-6">{{ .Pre }}</div>
<div class="col-xs-18 sidebar-block-text">{{ .Name }}</div>
</a>
</div>
<div class="row sidebar-block-sub-items margin-bottom-20">
{{ range .Children }}
<div class="row sidebar-block-sub-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-18 col-xs-offset-6 sidebar-block-text">{{ .Name }}</div>
</a>
</div>
{{ end }}
</div>
{{ else if or (eq $parentItem.Identifier $currentSection) (eq .Parent $currentSection) }}
<div class="row sidebar-block-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-6">{{ .Pre }}</div>
<div class="col-xs-18 sidebar-block-text">{{ .Name }}</div>
</a>
</div>
{{ end }}
{{ end }}
</aside>
{{ end }}
{{ end }}
{{ end }}
<!--
Copyright (c) 2018 Eclipse Foundation, Inc.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
Contributors:
Christopher Guindon <chris.guindon@eclipse-foundation.org>
SPDX-License-Identifier: EPL-2.0
-->
......@@ -42,4 +39,4 @@
</aside>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
\ No newline at end of file
......@@ -3997,17 +3997,17 @@
"integrity": "sha512-T7mYop3aDpRHIQaUYcmzmh6j9MAe560n6ukqjJMbVC6bVTau7dSpvB18bcsBPPtOSe10cKxhJFtlbEzLa0LL1g=="
},
"node_modules/elliptic": {
"version": "6.5.3",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",
"version": "6.5.4",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
"integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
"dependencies": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
"bn.js": "^4.11.9",
"brorand": "^1.1.0",
"hash.js": "^1.0.0",
"hmac-drbg": "^1.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.0"
"hmac-drbg": "^1.0.1",
"inherits": "^2.0.4",
"minimalistic-assert": "^1.0.1",
"minimalistic-crypto-utils": "^1.0.1"
}
},
"node_modules/elliptic/node_modules/bn.js": {
......@@ -15609,17 +15609,17 @@
"integrity": "sha512-T7mYop3aDpRHIQaUYcmzmh6j9MAe560n6ukqjJMbVC6bVTau7dSpvB18bcsBPPtOSe10cKxhJFtlbEzLa0LL1g=="
},
"elliptic": {
"version": "6.5.3",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",
"version": "6.5.4",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
"integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
"requires": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
"bn.js": "^4.11.9",
"brorand": "^1.1.0",
"hash.js": "^1.0.0",
"hmac-drbg": "^1.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.0"
"hmac-drbg": "^1.0.1",
"inherits": "^2.0.4",
"minimalistic-assert": "^1.0.1",
"minimalistic-crypto-utils": "^1.0.1"
},
"dependencies": {
"bn.js": {
......
function _createForOfIteratorHelper(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0,n=function(){};return{s:n,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var EclipseFdnAdopters=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"precompiledRegex",/<([^>]*?)>;(\s?[\w-]*?="(?:\\"|[^"])*";){0,}\s?rel="next"/),_defineProperty(this,"default_options",{project_id:"",selector:".eclipsefdn-adopters",ul_classes:"",logo_white:!1,working_group:"",src_root:"https://api.eclipse.org/adopters",src_projects_prefix:"/projects"}),_defineProperty(this,"getList",(function(e){var t=this.getMergedOptions(e);this.fireCall(t,(function(e){this.createProjectList(e,t,document.querySelectorAll(t.selector)),this.scrollToAnchor()}))})),_defineProperty(this,"getWGList",(function(e){var t=this,r=this.getMergedOptions(e);this.fireCall(r,(function(e){t.createWGProjectsList(e,r,document.querySelectorAll(r.selector)),t.scrollToAnchor()}))}))}return _createClass(e,[{key:"getMergedOptions",value:function(e){var t=JSON.parse(JSON.stringify(this.default_options));if(void 0!==e&&"object"===_typeof(e))for(var r in this.default_options)void 0===e[r]||"string"!=typeof e[r]&&"boolean"!=typeof e[r]||(t[r]=e[r]);return t}},{key:"fireCall",value:function(e,t){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=this,i=new XMLHttpRequest;i.onreadystatechange=function(){if(4==this.readyState&&200==this.status){var r=JSON.parse(this.responseText);(Array.isArray(o)||o.length)&&(r=o.concat(r));var a=i.getResponseHeader("Link");if(null!==a){var l=a.match(n.precompiledRegex);null!==l?(e.next=l[1],n.fireCall(e,t,r)):t(r)}else t(r)}else 4==this.readyState&&console.log("Error while retrieving adopters data, could not complete operation")},void 0!==e.next?r=e.next:(r=e.src_root+e.src_projects_prefix,void 0!==e.project_id&&""!==e.project_id.trim()&&(r+="/"+e.project_id),void 0!==e.working_group&&""!==e.working_group.trim()&&(r+="?working_group="+e.working_group)),i.open("GET",r,!0),i.send()}},{key:"createWGProjectsList",value:function(e,t,r){var o,n=_createForOfIteratorHelper(e);try{for(n.s();!(o=n.n()).done;){var i=o.value,a=JSON.parse(JSON.stringify(t));a.project_id=i.project_id;var l=document.createElement("h2");l.textContent=i.name,l.setAttribute("id",i.project_id);for(var s=0;s<r.length;s++)r[s].appendChild(l);var c=document.createElement("a");c.setAttribute("class","btn btn-xs btn-secondary margin-left-10 uppercase"),c.setAttribute("href","https://projects.eclipse.org/projects/"+i.project_id),c.textContent=i.project_id,l.appendChild(c),this.createProjectList(e,a,r)}}catch(e){n.e(e)}finally{n.f()}}},{key:"createProjectList",value:function(e,t,r){var o=document.createElement("ul");if(void 0!==e){var n,i=_createForOfIteratorHelper(e);try{for(i.s();!(n=i.n()).done;){var a=n.value;if(t.project_id===a.project_id){var l,s=_createForOfIteratorHelper(a.adopters);try{for(s.s();!(l=s.n()).done;){var c=l.value,p="";void 0!==c.homepage_url&&(p=c.homepage_url);var u="";void 0!==c.name&&(u=c.name);var f="";void 0!==c.logo&&(f=c.logo),!0===t.logo_white&&void 0!==c.logo_white&&(f=c.logo_white);var d=document.createElement("li"),y=document.createElement("a"),h=document.createElement("img");y.setAttribute("href",p),h.setAttribute("alt",u),h.setAttribute("src",t.src_root+"/assets/images/adopters/"+f),h.setAttribute("class","adopters-img"),y.appendChild(h),d.appendChild(y),o.appendChild(d)}}catch(e){s.e(e)}finally{s.f()}}}}catch(e){i.e(e)}finally{i.f()}}for(var _=0;_<r.length;_++)""!==t.ul_classes&&o.setAttribute("class",t.ul_classes),r[_].appendChild(o)}},{key:"scrollToAnchor",value:function(){if(location.hash){var e=location.hash.replace("#","");document.getElementById("".concat(e)).scrollIntoView()}}}]),e}(),eclipseFdnAdopters=new EclipseFdnAdopters;
function _createForOfIteratorHelper(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0,n=function(){};return{s:n,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var EclipseFdnAdopters=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"precompiledRegex",/<([^>]*?)>;(\s?[\w-]*?="(?:\\"|[^"])*";){0,}\s?rel="next"/),_defineProperty(this,"default_options",{project_id:"",selector:".eclipsefdn-adopters",ul_classes:"",logo_white:!1,working_group:"",src_root:"https://api.eclipse.org/adopters",src_projects_prefix:"/projects"}),_defineProperty(this,"getList",(function(e){var t=this,r=this.getMergedOptions(e);this.fireCall(r,(function(e){t.createProjectList(e,r,document.querySelectorAll(r.selector)),t.scrollToAnchor()}))})),_defineProperty(this,"getWGList",(function(e){var t=this,r=this.getMergedOptions(e);this.fireCall(r,(function(e){t.createWGProjectsList(e,r,document.querySelectorAll(r.selector)),t.scrollToAnchor()}))}))}return _createClass(e,[{key:"getMergedOptions",value:function(e){var t=JSON.parse(JSON.stringify(this.default_options));if(void 0!==e&&"object"===_typeof(e))for(var r in this.default_options)void 0===e[r]||"string"!=typeof e[r]&&"boolean"!=typeof e[r]||(t[r]=e[r]);return t}},{key:"fireCall",value:function(e,t){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=this,i=new XMLHttpRequest;i.onreadystatechange=function(){if(4==this.readyState&&200==this.status){var r=JSON.parse(this.responseText);(Array.isArray(o)||o.length)&&(r=o.concat(r));var a=i.getResponseHeader("Link");if(null!==a){var l=a.match(n.precompiledRegex);null!==l?(e.next=l[1],n.fireCall(e,t,r)):t(r)}else t(r)}else 4==this.readyState&&console.log("Error while retrieving adopters data, could not complete operation")},void 0!==e.next?r=e.next:(r=e.src_root+e.src_projects_prefix,void 0!==e.project_id&&""!==e.project_id.trim()&&(r+="/"+e.project_id),void 0!==e.working_group&&""!==e.working_group.trim()&&(r+="?working_group="+e.working_group)),i.open("GET",r,!0),i.send()}},{key:"createWGProjectsList",value:function(e,t,r){var o,n=_createForOfIteratorHelper(e);try{for(n.s();!(o=n.n()).done;){var i=o.value,a=JSON.parse(JSON.stringify(t));a.project_id=i.project_id;var l=document.createElement("h2");l.textContent=i.name,l.setAttribute("id",i.project_id);for(var s=0;s<r.length;s++)r[s].appendChild(l);var c=document.createElement("a");c.setAttribute("class","btn btn-xs btn-secondary margin-left-10 uppercase"),c.setAttribute("href","https://projects.eclipse.org/projects/"+i.project_id),c.textContent=i.project_id,l.appendChild(c),this.createProjectList(e,a,r)}}catch(e){n.e(e)}finally{n.f()}}},{key:"createProjectList",value:function(e,t,r){var o=document.createElement("ul");if(void 0!==e){var n,i=_createForOfIteratorHelper(e);try{for(i.s();!(n=i.n()).done;){var a=n.value;if(t.project_id===a.project_id){var l,s=_createForOfIteratorHelper(a.adopters);try{for(s.s();!(l=s.n()).done;){var c=l.value,p="";void 0!==c.homepage_url&&(p=c.homepage_url);var u="";void 0!==c.name&&(u=c.name);var f="";void 0!==c.logo&&(f=c.logo),!0===t.logo_white&&void 0!==c.logo_white&&(f=c.logo_white);var d=document.createElement("li"),y=document.createElement("a"),h=document.createElement("img");y.setAttribute("href",p),h.setAttribute("alt",u),h.setAttribute("src",t.src_root+"/assets/images/adopters/"+f),h.setAttribute("class","adopters-img"),y.appendChild(h),d.appendChild(y),o.appendChild(d)}}catch(e){s.e(e)}finally{s.f()}}}}catch(e){i.e(e)}finally{i.f()}}for(var _=0;_<r.length;_++)""!==t.ul_classes&&o.setAttribute("class",t.ul_classes),r[_].appendChild(o)}},{key:"scrollToAnchor",value:function(){if(location.hash){var e=location.hash.replace("#","");document.getElementById("".concat(e)).scrollIntoView()}}}]),e}(),eclipseFdnAdopters=new EclipseFdnAdopters;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment