From a846caa38791c3ec654180e01325de4e9e5d203c Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 5 Jun 2013 16:27:33 -0400 Subject: [PATCH 01/12] added post button to mobile menu --- public/css/style.less | 3 ++- public/templates/footer.tpl | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/public/css/style.less b/public/css/style.less index 5b5216cba7..abe74ca575 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -583,10 +583,11 @@ body .navbar .nodebb-inline-block { } #mobile-menu { - #mobile-menu-btn { + button { color: #eee; padding: 10px; text-shadow: none; + -webkit-tap-highlight-color: rgba(0,0,0,0); } } diff --git a/public/templates/footer.tpl b/public/templates/footer.tpl index 818c79482b..a828b4f5c1 100644 --- a/public/templates/footer.tpl +++ b/public/templates/footer.tpl @@ -13,6 +13,7 @@
+
From 5bb9933f4a28092d55730ceb463da34c15897b7e Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 5 Jun 2013 17:00:58 -0400 Subject: [PATCH 02/12] added functionality to post button. also introduced some underlying concepts regarding modules and pulling template vars --- public/src/ajaxify.js | 3 ++- public/src/app.js | 5 +++++ public/src/modules/mobileMenu.js | 25 +++++++++++++++++++++++-- public/src/templates.js | 6 +++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 1aa52e16de..9a70ebd194 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -47,7 +47,8 @@ var ajaxify = {}; } jQuery('#footer, #content').fadeOut(100); - + + templates.flush(); templates.load_template(function() { exec_body_scripts(content); diff --git a/public/src/app.js b/public/src/app.js index eb35b16652..7e315533e2 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -191,6 +191,11 @@ var socket, socket.emit('api:user.get_online_users', uids); } + // here is where all modules' onNavigate should be called, I think. + require(['mobileMenu'], function(mobileMenu) { + mobileMenu.onNavigate(); + }); + populate_online_users(); diff --git a/public/src/modules/mobileMenu.js b/public/src/modules/mobileMenu.js index 7f5183348f..2880e26464 100644 --- a/public/src/modules/mobileMenu.js +++ b/public/src/modules/mobileMenu.js @@ -4,7 +4,8 @@ define(function() { var categories = null, overlay = null, - menuBtn = null; + menuBtn = null, + postBtn = null; function loadCategories(callback) { @@ -63,9 +64,27 @@ define(function() { } + mobileMenu.onNavigate = function() { + var cid = templates.get('category_id'); + + if (cid) { + postBtn.style.display = 'inline-block'; + postBtn.onclick = function() { + require(['composer'], function(cmp) { + cmp.push(0, cid); //todo check if in post + }); + }; + } else { + postBtn.style.display = 'none'; + } + + }; + + mobileMenu.init = function() { overlay = overlay || document.getElementById('mobile-menu-overlay'); menuBtn = menuBtn || document.getElementById('mobile-menu-btn'); + postBtn = postBtn || document.getElementById('mobile-post-btn'); menuBtn.onclick = function() { animateIcons(); @@ -73,9 +92,11 @@ define(function() { loadCategories(displayCategories); + mobileMenu.onNavigate(); } return { - init: mobileMenu.init + init: mobileMenu.init, + onNavigate: mobileMenu.onNavigate } }); \ No newline at end of file diff --git a/public/src/templates.js b/public/src/templates.js index b3ea78105c..4a39277c2b 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -169,7 +169,7 @@ if (!templates[tpl_url] || !template_data) return; document.getElementById('content').innerHTML = templates[tpl_url].parse(JSON.parse(template_data)); - + jQuery('#content [template-variable]').each(function(index, element) { templates.set(element.getAttribute('template-variable'), element.value); }); @@ -181,6 +181,10 @@ } + templates.flush = function() { + parsed_variables = {}; + } + templates.get = function(key) { return parsed_variables[key]; } From 2a304c5c909674c3857498f23d20fc5c48ae66ad Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 5 Jun 2013 17:05:44 -0400 Subject: [PATCH 03/12] improved animations for mobileMenu again (opacity). need to check if this seriously slows down older devices. --- public/css/style.less | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/public/css/style.less b/public/css/style.less index abe74ca575..815bfb654a 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -592,7 +592,6 @@ body .navbar .nodebb-inline-block { } #mobile-menu-overlay { - display: none; background: rgba(0, 0, 0, 0.85); position: fixed; @@ -609,9 +608,9 @@ body .navbar .nodebb-inline-block { -ms-transition: opacity 150ms ease; -o-transition: opacity 150ms ease; transition: opacity 150ms ease; - + z-index: -1; &.menu-visible { - display: block; + z-index: 99; opacity: 1; } From 220d80e3a1fa247d47495a600875c39382a2182c Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 5 Jun 2013 17:08:11 -0400 Subject: [PATCH 04/12] added ability to add forum to iOS homescreen as an app --- public/templates/header.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/public/templates/header.tpl b/public/templates/header.tpl index b51176b196..a75863dd3e 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -5,6 +5,7 @@ + From 3fa41ab3161fb7da309332cd291c440b0db2c6f9 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 5 Jun 2013 17:09:47 -0400 Subject: [PATCH 05/12] rehide address bar on mobile after page load completes --- public/src/app.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/src/app.js b/public/src/app.js index 7e315533e2..e6dc71d7f8 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -199,6 +199,7 @@ var socket, populate_online_users(); + window.scrollTo(0, 1); } socket.on('api:user.get_online_users', function(users) { From 950fdefd7bd6b9ad560010f592af4b80a7e6c77f Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 5 Jun 2013 17:10:00 -0400 Subject: [PATCH 06/12] rehide address bar on mobile after page load completes --- public/src/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/app.js b/public/src/app.js index e6dc71d7f8..4ea87866bb 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -199,7 +199,7 @@ var socket, populate_online_users(); - window.scrollTo(0, 1); + window.scrollTo(0, 1); // rehide address bar on mobile after page load completes. } socket.on('api:user.get_online_users', function(users) { From 2638c03752f672fa0288e57b2113c12c2debf402 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 5 Jun 2013 17:14:10 -0400 Subject: [PATCH 07/12] added timeout to address bar hiding (as per the official way of accomplishing this task ) --- public/src/ajaxify.js | 2 +- public/src/app.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 9a70ebd194..d5daa8d907 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -47,7 +47,7 @@ var ajaxify = {}; } jQuery('#footer, #content').fadeOut(100); - + templates.flush(); templates.load_template(function() { exec_body_scripts(content); diff --git a/public/src/app.js b/public/src/app.js index 4ea87866bb..11095a8e1d 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -199,7 +199,9 @@ var socket, populate_online_users(); - window.scrollTo(0, 1); // rehide address bar on mobile after page load completes. + setTimeout(function() { + window.scrollTo(0, 1); // rehide address bar on mobile after page load completes. + }, 100); } socket.on('api:user.get_online_users', function(users) { From 95830c3c7cc8c9b940baa5798be94ff0f3f2fe8b Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 5 Jun 2013 17:19:18 -0400 Subject: [PATCH 08/12] getting rid of the highlight colour on links and buttons to make it feel more app-ish --- public/css/style.less | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/css/style.less b/public/css/style.less index 815bfb654a..fbb5618144 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -41,6 +41,10 @@ body { } } +button, a { + -webkit-tap-highlight-color: rgba(0,0,0,0); +} + .none { display: none !important; } From 1803595fa22753e7f21fb4b1f4b8f0b848cf252b Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 5 Jun 2013 17:59:20 -0400 Subject: [PATCH 09/12] starting: mobile sidebar menu (intending to take the span3 hidden on mobile and turn it into a slidein sidebar) --- public/src/app.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/public/src/app.js b/public/src/app.js index 11095a8e1d..2a30f3c867 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -240,5 +240,23 @@ var socket, } } }, false); + + + addTouchEvents(); }); + + + + + function addTouchEvents() { + var el = jQuery("#content"), + width = el.width(); + + el.on('touchmove', function(e) { + //this.style.marginLeft = - parseInt(width - event.touches[0].pageX) + 'px'; + }); + el.on('touchend', function(e) { + this.style.marginLeft = 'auto'; + }) + } }()); From a8f6222824dc12236cc534608ac7ae185fcd64a0 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 6 Jun 2013 10:51:13 -0400 Subject: [PATCH 10/12] part2 of mobile sidebar menu. still disabled for now going to come back to this later. --- public/css/style.less | 12 +++++++++ public/src/app.js | 51 +++++++++++++++++++++++++++++++---- public/templates/category.tpl | 2 +- public/templates/footer.tpl | 4 +++ 4 files changed, 63 insertions(+), 6 deletions(-) diff --git a/public/css/style.less b/public/css/style.less index fbb5618144..5903c56a7d 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -647,4 +647,16 @@ body .navbar .nodebb-inline-block { } } +} + + + + +#mobile-sidebar { + height: 100%; + position: absolute; + left: 100%; + top: 0px; + overflow: hidden; + margin-top: 60px; } \ No newline at end of file diff --git a/public/src/app.js b/public/src/app.js index 2a30f3c867..6002156e4c 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -249,14 +249,55 @@ var socket, function addTouchEvents() { + return; // later. + + + // click simulation just for testing/sanity purposes. + var el = jQuery("#content"), + sidebar = jQuery('#mobile-sidebar'), width = el.width(); - el.on('touchmove', function(e) { - //this.style.marginLeft = - parseInt(width - event.touches[0].pageX) + 'px'; + function onTouchMove(ev) { + var coordinates = window.event ? window.event.touches[0] : ev.touches[0]; + + el.css({ + marginLeft: -parseInt(width - coordinates.pageX) + 'px', + paddingRight: parseInt(width - coordinates.pageX) + 'px'}); + + sidebar.css({ + marginLeft: -parseInt(width - coordinates.pageX) + 'px', + width: parseInt(width - coordinates.pageX) + 'px' + }); + } + + function onMouseMove(ev) { + ev.touches = [{pageX: ev.pageX, pageY: ev.pageY}]; + onTouchMove(ev); + } + + function onTouchEnd() { + el.css({ + marginLeft: '0px', + paddingRight: '0px' + }); + + sidebar.css({ + marginLeft: '0px', + width: '0px' + }); + } + + el.on('touchmove', onTouchMove); + el.on('mousedown', function() { + el.on('mousemove', onMouseMove); }); - el.on('touchend', function(e) { - this.style.marginLeft = 'auto'; - }) + + el.on('touchend', onTouchEnd); + el.on('mouseup', function() { + el.off('mousemove'); + onTouchEnd(); + }); + } }()); diff --git a/public/templates/category.tpl b/public/templates/category.tpl index 39ccda6c94..e730e33e34 100644 --- a/public/templates/category.tpl +++ b/public/templates/category.tpl @@ -45,7 +45,7 @@
-
+