Commit 7b66681c authored by Ian Dennis Miller's avatar Ian Dennis Miller

split out zoom, appearances

zoom works with article filter
zoom_in and zoom_out
parent a9185f4e
var appearances = "visible";
var toggle_appearance = function(id) {
var container = document.getElementById(id);
var el = container.getElementsByClassName("appearance")[0];
if (el.style.display != "block") {
el.style.display = "block";
}
else {
el.style.display = "none";
}
}
var hide_appearances = function() {
var els = document.querySelectorAll('.appearance');
for (var i = 0; i < els.length; i++){
els[i].style.display = "none";
}
appearances = "hidden";
}
var show_appearances = function() {
var els = document.querySelectorAll('.appearance');
for (var i = 0; i < els.length; i++){
els[i].style.display = "block";
}
appearances = "visible";
}
var toggle_appearances = function() {
if (appearances == "hidden") {
show_appearances();
}
else {
hide_appearances();
}
}
var filtered = false;
var filter_id = "";
var toggle_article = function(id) {
// find the article button
var button = document.getElementById(id + "-button");
filtered = true;
hide_picker();
untoggle_article();
close_ui();
......
var divs = document.getElementsByClassName("card");
var counter = 0;
var filtered = false;
var focused = true;
var filter_id = "";
var appearances = "visible";
var swiper = new Swipe(document.getElementsByTagName('body')[0]);
function main() {
......
/* focus */
var toggle_focus = function() {
if (focused) {
show_all();
}
else {
hide_all();
}
}
var really_hide_all = function() {
for (var i = 0; i < divs.length; i++){
divs[i].style.display = "none";
}
}
var hide_all = function() {
really_hide_all();
focused = true;
close_ui();
if (!filtered) {
counter = 0;
refresh(divs);
}
else {
var els = document.querySelectorAll('[about="#' + filter_id + '"]');
refresh(els);
}
var el = document.getElementsByTagName("body")[0];
el.classList.add('focused');
}
var show_all = function() {
focused = false;
close_ui();
if (filtered) {
hide_all();
var els = document.querySelectorAll('[about="#' + filter_id + '"]');
for (var i = 0; i < els.length; i++){
els[i].style.display = "block";
}
}
else {
for (var i = 0; i < divs.length; i++){
divs[i].style.display = "block";
}
}
var el = document.getElementsByTagName("body")[0];
el.classList.remove('focused');
}
var refresh = function(els) {
for (var i = 0; i < els.length; i++){
els[i].style.display = "none";
}
els[counter].style.display = "block";
}
/* focus: previous/next */
var show_next = function() {
if (!focused) { return; }
var els;
if (filtered) {
els = document.querySelectorAll('[about="#' + filter_id + '"]');
}
else {
els = divs;
}
if (counter < (els.length-1)) {
counter++;
}
refresh(els);
}
var show_previous = function() {
if (!focused) { return; }
var els;
if (filtered) {
els = document.querySelectorAll('[about="#' + filter_id + '"]');
}
else {
els = divs;
}
if (counter > 0) {
counter--;
}
refresh(els);
}
/* Appearance */
var toggle_appearance = function(id) {
var container = document.getElementById(id);
var el = container.getElementsByClassName("appearance")[0];
if (el.style.display != "block") {
el.style.display = "block";
}
else {
el.style.display = "none";
}
}
var hide_appearances = function() {
var els = document.querySelectorAll('.appearance');
for (var i = 0; i < els.length; i++){
els[i].style.display = "none";
}
appearances = "hidden";
}
var show_appearances = function() {
var els = document.querySelectorAll('.appearance');
for (var i = 0; i < els.length; i++){
els[i].style.display = "block";
}
appearances = "visible";
}
var toggle_appearances = function() {
if (appearances == "hidden") {
show_appearances();
}
else {
hide_appearances();
}
}
/* help */
var toggle_help = function() {
......
......@@ -98,6 +98,7 @@ var do_search = function(terms) {
}
var show_results = function(terms, matches) {
focused = false;
really_hide_all();
for (var id in matches) {
show_card(id);
......
/* focus */
var focused = false;
var counter = 0;
var toggle_focus = function() {
close_ui();
if (focused) {
zoom_out();
}
else {
zoom_in();
}
}
var zoom_in = function() {
focused = true;
var els = document.querySelectorAll('[about="#' + filter_id + '"]');
// refresh(els);
for (var i = 0; i < els.length; i++){
els[i].style.display = "none";
}
els[counter].style.display = "block";
var el = document.getElementsByTagName("body")[0];
el.classList.add('focused');
}
var zoom_out = function() {
focused = false;
really_hide_all();
var els = document.querySelectorAll('[about="#' + filter_id + '"]');
for (var i = 0; i < els.length; i++){
els[i].style.display = "block";
}
var el = document.getElementsByTagName("body")[0];
el.classList.remove('focused');
}
var really_hide_all = function() {
for (var i = 0; i < divs.length; i++){
divs[i].style.display = "none";
}
}
var hide_all = function() {
really_hide_all();
focused = true;
close_ui();
if (!filtered) {
counter = 0;
refresh(divs);
}
else {
var els = document.querySelectorAll('[about="#' + filter_id + '"]');
refresh(els);
}
var el = document.getElementsByTagName("body")[0];
el.classList.add('focused');
}
var show_all = function() {
focused = false;
close_ui();
if (filtered) {
hide_all();
var els = document.querySelectorAll('[about="#' + filter_id + '"]');
for (var i = 0; i < els.length; i++){
els[i].style.display = "block";
}
}
else {
for (var i = 0; i < divs.length; i++){
divs[i].style.display = "block";
}
}
var el = document.getElementsByTagName("body")[0];
el.classList.remove('focused');
}
var refresh = function(els) {
for (var i = 0; i < els.length; i++){
els[i].style.display = "none";
}
els[counter].style.display = "block";
}
/* focus: previous/next */
var show_next = function() {
if (!focused) { return; }
var els;
if (filtered) {
els = document.querySelectorAll('[about="#' + filter_id + '"]');
}
else {
els = divs;
}
if (counter < (els.length-1)) {
counter++;
}
refresh(els);
}
var show_previous = function() {
if (!focused) { return; }
var els;
if (filtered) {
els = document.querySelectorAll('[about="#' + filter_id + '"]');
}
else {
els = divs;
}
if (counter > 0) {
counter--;
}
refresh(els);
}
......@@ -77,6 +77,8 @@ var keywords = {{ keywords_json }};
{% include 'js/articles.js' %}
{% include 'js/keywords.js' %}
{% include 'js/pager.js' %}
{% include 'js/zoom.js' %}
{% include 'js/appearance.js' %}
{% include 'js/search.js' %}
{% include 'js/keyboard.js' %}
{% include 'js/main.js' %}
......
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