From 40caeeac0da9b0265ec361f68f2c28574fc06b64 Mon Sep 17 00:00:00 2001 From: Sam Thomson Date: Tue, 15 Jan 2019 09:41:40 +0700 Subject: [PATCH 1/4] merge --- .gitmodules | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitmodules b/.gitmodules index b594082..3cccde8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "themes/navy/layout/partial/shared-partials"] path = themes/navy/layout/partial/shared-partials url = https://github.com/status-im/status.im-partials +[submodule "themes/navy/source/js/shared-js"] + path = themes/navy/source/js/shared-js + url = git@github.com:status-im/status-im-js.git From 0d91513c8997bb43d3470e31a5ed5c40a4caa577 Mon Sep 17 00:00:00 2001 From: Sam Thomson Date: Tue, 15 Jan 2019 09:51:14 +0700 Subject: [PATCH 2/4] add shared js to gulp build --- gulpfile.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index a77babf..f451e71 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -37,7 +37,11 @@ var config = { paths: { src: { scss: './themes/navy/source/scss/*.scss', - js: './themes/navy/source/js/main.js', + js: [ + './themes/navy/source/js/shared-js/js/utils.js', + './themes/navy/source/js/shared-js/js/popups.js', + './themes/navy/source/js/main.js', + ] }, dist: { css: './public/css', From eaec08f7955f83c93625f9390df7b03e384bb89d Mon Sep 17 00:00:00 2001 From: Sam Thomson Date: Tue, 15 Jan 2019 10:05:51 +0700 Subject: [PATCH 3/4] swap out old duplicated code for new shared code --- themes/navy/source/js/main.js | 56 ++--------------------------------- 1 file changed, 3 insertions(+), 53 deletions(-) diff --git a/themes/navy/source/js/main.js b/themes/navy/source/js/main.js index c64457c..6639667 100644 --- a/themes/navy/source/js/main.js +++ b/themes/navy/source/js/main.js @@ -63,43 +63,8 @@ $(document).ready(function () { /* Popups */ -let community = document.querySelectorAll(".item--dropdown-community")[0] -let projects = document.querySelectorAll(".item--dropdown-projects")[0] - -let popups = document.querySelectorAll(".popup-wrap") -let overlays = document.querySelectorAll(".popup-overlay") -let closeButtons = document.querySelectorAll(".popup__button--close") - -let activePopup = null; -let activeOverlay = null; - -community.addEventListener('click', function(event){ - showPopup(popups[0]) - event.preventDefault() -}) - -projects.addEventListener('click', function(event){ - showPopup(popups[1]) - event.preventDefault() -}) - -closeButtons.forEach((button) => { - button.addEventListener('click', closeActivePopup) -}) - -overlays.forEach((overlay) => { - overlay.addEventListener('click', closeActivePopup) -}) - -function showPopup(whichPopup) { - activePopup = whichPopup - addClassToElement(whichPopup, "popup--shown"); -} - -function closeActivePopup() { - removeClassFromElement(activePopup, "popup--shown"); - activePopup = null; -} +var addClassToElement = require('./shared-js/js/utils').addClassToElement; +var removeClassFromElement = require('./shared-js/js/utils').removeClassFromElement; /* Code highlighting */ @@ -153,19 +118,4 @@ function showNav() { function closeNav() { removeClassFromElement(nav, "mobile-nav--shown"); -} - -/*--- Utils ---*/ -function addClassToElement(element, className) { - (element.classList) ? element.classList.add(className) : element.className += ' ' + className - return element -} - -function removeClassFromElement(element, className) { - if(element.classList) { - element.classList.remove(className) - } else { - element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ') - } - return element -} +} \ No newline at end of file From acb1ada4c765f7a89ba2b6ee3987cd801ab8396c Mon Sep 17 00:00:00 2001 From: Sam Thomson Date: Tue, 15 Jan 2019 10:08:21 +0700 Subject: [PATCH 4/4] remove built js, no need for it to be in repo --- .gitignore | 6 +- themes/navy/source/js/vendor.js | 172 ---------------------------- themes/navy/source/js/vendor.js.map | 15 --- 3 files changed, 5 insertions(+), 188 deletions(-) delete mode 100644 themes/navy/source/js/vendor.js delete mode 100644 themes/navy/source/js/vendor.js.map diff --git a/.gitignore b/.gitignore index 6684837..896953a 100644 --- a/.gitignore +++ b/.gitignore @@ -54,4 +54,8 @@ packages/* .vagrant .vagrant/* -.env \ No newline at end of file +.env + +# built assets +themes/navy/source/js/vendor.js +themes/navy/source/js/vendor.js.map diff --git a/themes/navy/source/js/vendor.js b/themes/navy/source/js/vendor.js deleted file mode 100644 index 310df13..0000000 --- a/themes/navy/source/js/vendor.js +++ /dev/null @@ -1,172 +0,0 @@ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i' + val.title + '

' + val.title + '

' + excerpt + '

Read More '); - }); - } - }); - - function getWords(str) { - return str.split(/\s+/).slice(0, 25).join(" "); - } - - var months = { '01': 'Jan', '02': 'Feb', '03': 'Mar', '04': 'Apr', '05': 'May', '06': 'Jun', '07': 'Jul', '08': 'Aug', '09': 'Sep', '10': 'Oct', '11': 'Nov', '12': 'Dec' }; - url = 'https://our.status.im/ghost/api/v0.1/posts/?order=published_at%20desc&limit=2&formats=plaintext&client_id=ghost-frontend&client_secret=2b055fcd57ba'; - - $.ajax({ - type: "get", - url: url, - success: function (response) { - response.posts = response.posts.reverse(); - $.each(response.posts, function (index, val) { - var excerpt = ''; - if (val.custom_excerpt != null) { - excerpt = val.custom_excerpt; - } else { - excerpt = getWords(val.plaintext); - } - var newDate = new Date(val.published_at); - var minutes = newDate.getMinutes(); - minutes = minutes + ""; - if (minutes.length == 1) { - minutes = '0' + minutes; - } - $('.latest-posts').prepend(' \ -
\ - \ -

' + val.title + '

\ -
\ - '); - }); - } - }); -}); - -/* Popups */ - -let community = document.querySelectorAll(".item--dropdown-community")[0]; -let projects = document.querySelectorAll(".item--dropdown-projects")[0]; - -let popups = document.querySelectorAll(".popup-wrap"); -let overlays = document.querySelectorAll(".popup-overlay"); -let closeButtons = document.querySelectorAll(".popup__button--close"); - -let activePopup = null; -let activeOverlay = null; - -community.addEventListener('click', function (event) { - showPopup(popups[0]); - event.preventDefault(); -}); - -projects.addEventListener('click', function (event) { - showPopup(popups[1]); - event.preventDefault(); -}); - -closeButtons.forEach(button => { - button.addEventListener('click', closeActivePopup); -}); - -overlays.forEach(overlay => { - overlay.addEventListener('click', closeActivePopup); -}); - -function showPopup(whichPopup) { - activePopup = whichPopup; - addClassToElement(whichPopup, "popup--shown"); -} - -function closeActivePopup() { - removeClassFromElement(activePopup, "popup--shown"); - activePopup = null; -} - -/* Code highlighting */ - -function highlight() { - $('pre code').each(function (i, block) { - hljs.highlightBlock(block); - }); -} -$(document).ready(function () { - try { - highlight(); - } catch (err) { - console.log("retrying..."); - setTimeout(function () { - highlight(); - }, 2500); - } - - var clipboard = new ClipboardJS(".btn"); - clipboard.on('success', function (e) { - var id = $(e.trigger).attr("data-clipboard-target"); - $(id).toggleClass("flash"); - setTimeout(function () { - $(id).toggleClass("flash"); - }, 200); - e.clearSelection(); - }); -}); - -/* Mobile Nav */ - -let moreLink = document.querySelectorAll(".item--more")[0]; - -let nav = document.querySelectorAll(".mobile-nav-wrap")[0]; -let navOverlay = document.querySelectorAll(".mobile-nav-overlay")[0]; -let navCloseButton = document.querySelectorAll(".mobile-nav-close")[0]; - -moreLink.addEventListener('click', function (event) { - showNav(); - event.preventDefault(); -}); - -navCloseButton.addEventListener('click', closeNav); -navOverlay.addEventListener('click', closeNav); - -function showNav() { - addClassToElement(nav, "mobile-nav--shown"); -} - -function closeNav() { - removeClassFromElement(nav, "mobile-nav--shown"); -} - -/*--- Utils ---*/ -function addClassToElement(element, className) { - element.classList ? element.classList.add(className) : element.className += ' ' + className; - return element; -} - -function removeClassFromElement(element, className) { - if (element.classList) { - element.classList.remove(className); - } else { - element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' '); - } - return element; -} - -},{}]},{},[1]) -//# sourceMappingURL=vendor.js.map diff --git a/themes/navy/source/js/vendor.js.map b/themes/navy/source/js/vendor.js.map deleted file mode 100644 index 6b6ad6f..0000000 --- a/themes/navy/source/js/vendor.js.map +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": 3, - "sources": [ - "node_modules/browser-pack/_prelude.js", - "themes/navy/source/js/main.js" - ], - "names": [], - "mappings": "AAAA;ACAA,EAAE,QAAF,EAAY,KAAZ,CAAkB,YAAY;;AAE5B;AACA,IAAE,eAAF,EAAmB,MAAnB,CAA0B,EAAE,mCAAF,EAAuC,CAAvC,CAA1B;AACA,IAAE,eAAF,EAAmB,MAAnB,CAA0B,EAAE,kCAAF,EAAsC,CAAtC,CAA1B;;AAEA,MAAI,MAAM,uKAAV;AACA,MAAI,UAAU,CAAC,SAAS,QAAV,EAAoB,IAApB,EAA0B,SAAS,IAAnC,EAAyC,SAAS,QAAlD,EAA4D,IAA5D,CAAiE,EAAjE,CAAd;;AAEA,IAAE,IAAF,CAAO;AACL,UAAM,KADD;AAEL,SAAK,GAFA;AAGL,aAAS,UAAU,QAAV,EAAoB;AAC3B,eAAS,KAAT,GAAiB,SAAS,KAAT,CAAe,OAAf,EAAjB;AACA,QAAE,IAAF,CAAO,SAAS,KAAhB,EAAuB,UAAU,KAAV,EAAiB,GAAjB,EAAsB;AAC3C,YAAI,UAAU,EAAd;AACA,YAAG,IAAI,cAAJ,IAAsB,IAAzB,EAA+B;AAC7B,oBAAU,IAAI,cAAd;AACD,SAFD,MAEK;AACH,oBAAU,SAAS,IAAI,SAAb,CAAV;AACD;AACD,UAAE,uBAAF,EAA2B,OAA3B,CAAmC,iEAAgE,IAAI,IAApE,GAA0E,0DAA1E,GAAsI,IAAI,aAA1I,GAAyJ,SAAzJ,GAAoK,IAAI,KAAxK,GAA+K,2CAA/K,GAA4N,IAAI,IAAhO,GAAsO,IAAtO,GAA4O,IAAI,KAAhP,GAAuP,cAAvP,GAAuQ,OAAvQ,GAAgR,qCAAhR,GAAuT,IAAI,IAA3T,GAAiU,wBAAjU,GAA2V,OAA3V,GAAoW,kCAAvY;AACD,OARD;AASD;AAdI,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,SAAT,GAAsB,QAAQ,SAAR,CAAkB,GAAlB,CAAsB,SAAtB,CAAtB,GAAyD,QAAQ,SAAR,IAAqB,MAAM,SAApF;AACA,SAAO,OAAP;AACD;;AAED,SAAS,sBAAT,CAAgC,OAAhC,EAAyC,SAAzC,EAAoD;AAClD,MAAG,QAAQ,SAAX,EAAsB;AACpB,YAAQ,SAAR,CAAkB,MAAlB,CAAyB,SAAzB;AACD,GAFD,MAEO;AACL,YAAQ,SAAR,GAAoB,QAAQ,SAAR,CAAkB,OAAlB,CAA0B,IAAI,MAAJ,CAAW,YAAY,UAAU,KAAV,CAAgB,GAAhB,EAAqB,IAArB,CAA0B,GAA1B,CAAZ,GAA6C,SAAxD,EAAmE,IAAnE,CAA1B,EAAoG,GAApG,CAApB;AACD;AACD,SAAO,OAAP;AACD", - "file": "generated.js", - "sourceRoot": "", - "sourcesContent": [ - "(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i\"'+

'+ val.title +'

'+ excerpt +'

Read More ');\n });\n }\n });\n\n function getWords(str) {\n return str.split(/\\s+/).slice(0,25).join(\" \");\n }\n\n var months = {'01':'Jan', '02':'Feb', '03':'Mar', '04':'Apr', '05':'May', '06':'Jun', '07':'Jul', '08':'Aug', '09':'Sep', '10':'Oct', '11':'Nov', '12':'Dec'};\n url = 'https://our.status.im/ghost/api/v0.1/posts/?order=published_at%20desc&limit=2&formats=plaintext&client_id=ghost-frontend&client_secret=2b055fcd57ba';\n\n $.ajax({\n type: \"get\",\n url: url,\n success: function (response) {\n response.posts = response.posts.reverse();\n $.each(response.posts, function (index, val) {\n var excerpt = '';\n if(val.custom_excerpt != null) {\n excerpt = val.custom_excerpt;\n }else{\n excerpt = getWords(val.plaintext);\n }\n var newDate = new Date(val.published_at);\n var minutes = newDate.getMinutes();\n minutes = minutes + \"\";\n if(minutes.length == 1){\n minutes = '0' + minutes;\n }\n $('.latest-posts').prepend(' \\\n
\\\n \\\n

'+ val.title +'

\\\n
\\\n ');\n });\n }\n });\n\n});\n\n/* Popups */\n\nlet community = document.querySelectorAll(\".item--dropdown-community\")[0]\nlet projects = document.querySelectorAll(\".item--dropdown-projects\")[0]\n\nlet popups = document.querySelectorAll(\".popup-wrap\")\nlet overlays = document.querySelectorAll(\".popup-overlay\")\nlet closeButtons = document.querySelectorAll(\".popup__button--close\")\n\nlet activePopup = null;\nlet activeOverlay = null;\n\ncommunity.addEventListener('click', function(event){\n showPopup(popups[0])\n event.preventDefault()\n})\n\nprojects.addEventListener('click', function(event){\n showPopup(popups[1])\n event.preventDefault()\n})\n\ncloseButtons.forEach((button) => {\n button.addEventListener('click', closeActivePopup)\n})\n\noverlays.forEach((overlay) => {\n overlay.addEventListener('click', closeActivePopup)\n})\n\nfunction showPopup(whichPopup) {\n activePopup = whichPopup\n addClassToElement(whichPopup, \"popup--shown\");\n}\n\nfunction closeActivePopup() {\n removeClassFromElement(activePopup, \"popup--shown\");\n activePopup = null;\n}\n\n/* Code highlighting */\n\nfunction highlight() {\n $('pre code').each(function(i, block) {\n hljs.highlightBlock(block);\n });\n}\n $(document).ready(function() {\n try {\n highlight();\n } catch(err) {\n console.log(\"retrying...\")\n setTimeout(function() {\n highlight();\n }, 2500)\n }\n\n var clipboard = new ClipboardJS(\".btn\");\n clipboard.on('success', function(e) {\n var id = $(e.trigger).attr(\"data-clipboard-target\");\n $(id).toggleClass(\"flash\");\n setTimeout(function() {\n $(id).toggleClass(\"flash\");\n }, 200);\n e.clearSelection();\n })\n})\n\n/* Mobile Nav */\n\nlet moreLink = document.querySelectorAll(\".item--more\")[0]\n\nlet nav = document.querySelectorAll(\".mobile-nav-wrap\")[0]\nlet navOverlay = document.querySelectorAll(\".mobile-nav-overlay\")[0]\nlet navCloseButton = document.querySelectorAll(\".mobile-nav-close\")[0]\n\n\nmoreLink.addEventListener('click', function(event){\n showNav()\n event.preventDefault()\n})\n\nnavCloseButton.addEventListener('click', closeNav)\nnavOverlay.addEventListener('click', closeNav)\n\n\nfunction showNav() {\n addClassToElement(nav, \"mobile-nav--shown\");\n}\n\nfunction closeNav() {\n removeClassFromElement(nav, \"mobile-nav--shown\");\n}\n\n/*--- Utils ---*/\nfunction addClassToElement(element, className) {\n (element.classList) ? element.classList.add(className) : element.className += ' ' + className\n return element\n}\n\nfunction removeClassFromElement(element, className) {\n if(element.classList) {\n element.classList.remove(className)\n } else {\n element.className = element.className.replace(new RegExp('(^|\\\\b)' + className.split(' ').join('|') + '(\\\\b|$)', 'gi'), ' ')\n }\n return element\n}\n" - ] -} \ No newline at end of file