Skip to content

Commit

Permalink
Fix #307 Load Akhand Paath View correctly (#320)
Browse files Browse the repository at this point in the history
* Fix #307 Load Akhand Paath View correctly

* Fixed disabling of apv during casting

* add sub label for apv switch
  • Loading branch information
tsingh777 authored and navdeepsinghkhalsa committed Sep 30, 2018
1 parent 20779b6 commit bca0700
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 23 deletions.
4 changes: 2 additions & 2 deletions www/js/banidb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ const getAng = ShabadID => (
Realm.open(realmDB.realmVerseSchema)
.then((realm) => {
const row = realm.objects('Verse').filtered('ANY Shabads.ShabadID == $0', ShabadID)[0];
const { PageNo, SourceID } = row;
const { PageNo, Source } = row;
resolve({
PageNo,
SourceID,
SourceID: Source.SourceID,
});
});
})
Expand Down
3 changes: 3 additions & 0 deletions www/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ global.platform.ipc.on('cast-session-active', () => {

store.set('userPrefs.slide-layout.display-options.akhandpaatt', false);
store.set('userPrefs.slide-layout.display-options.disable-akhandpaatt', true);
global.webview.send('clear-apv');
global.platform.ipc.send('clear-apv');

document.body.classList.remove('akhandpaatt');
global.core.platformMethod('updateSettings');
});
Expand Down
4 changes: 4 additions & 0 deletions www/js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const tingle = require('./vendor/tingle');
const request = require('request');
const moment = require('moment');
const electron = require('electron');
const { store } = require('electron').remote.require('./app');

const modal = new tingle.Modal({
footer: true,
Expand Down Expand Up @@ -298,6 +299,9 @@ module.exports = {
$listOfShabadOptions.appendChild(hukamnamaButton);
$listOfShabadOptions.appendChild(anandKarajButton);
$listOfShabadOptions.appendChild(notificationButton);

// when the app is reloaded, enable the control for akhandpaatt
store.set('userPrefs.slide-layout.display-options.disable-akhandpaatt', false);
settings.init();
},

Expand Down
14 changes: 9 additions & 5 deletions www/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,12 +610,16 @@ module.exports = {

printShabad(rows, ShabadID, LineID) {
const lineID = LineID || rows[0].ID;
const shabadID = ShabadID || rows[0].Shabads[0].ShabadID;
let mainLine;
const shabad = this.$shabad;
const apv = document.body.classList.contains('akhandpaatt');

// remove currently printed shabad.
while (shabad.firstChild) {
shabad.removeChild(shabad.firstChild);
// remove currently printed shabad if not in apv mode.
if (!apv) {
while (shabad.firstChild) {
shabad.removeChild(shabad.firstChild);
}
}

rows.forEach((item) => {
Expand All @@ -631,7 +635,7 @@ module.exports = {
}`,
{
'data-line-id': item.ID,
onclick: e => this.clickShabad(e, item.ShabadID || ShabadID,
onclick: e => this.clickShabad(e, item.ShabadID || shabadID,
item.ID, item),
},
[
Expand All @@ -655,7 +659,7 @@ module.exports = {
.offsetTop;
this.$shabadContainer.scrollTop = curPankteeTop;
// send the line to app.js, which will send it to the viewer window as well as obs file
global.controller.sendLine(ShabadID, lineID, mainLine);
global.controller.sendLine(shabadID, lineID, mainLine);
// Hide next and previous links before loading first and last shabad
const $shabadNext = document.querySelector('#shabad-next');
const $shabadPrev = document.querySelector('#shabad-prev');
Expand Down
26 changes: 24 additions & 2 deletions www/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,33 @@ function addDisplayTab() {
type: 'checkbox',
value: option,
};
if (option === 'akhandpaatt') {
switchListAttrs.disabled = store.get('userPrefs.slide-layout.display-options.disable-akhandpaatt');
switchListAttrs.title = 'Disabled during casting';
}
if (userPrefs[catKey][settingKey][option]) {
switchListAttrs.checked = true;
}
let optionLabel = setting.options[option];
let subLabel = false;
if (typeof setting.options[option] === 'object') {
optionLabel = setting.options[option].label;
subLabel = setting.options[option].subLabel;
}
switchList.appendChild(
h('li',
[
h('span', setting.options[option]),
h('span', optionLabel),
h('div.switch',
[
h(`input#${optionId}`,
switchListAttrs),
h('label',
{
htmlFor: optionId })])]));
if (subLabel) {
switchList.appendChild(h('div.sub-label', subLabel));
}
});
document.getElementById('display-tab-content').appendChild(switchList);
}
Expand Down Expand Up @@ -215,17 +228,26 @@ function createSettingsPage(userPrefs) {
if (userPrefs[catKey][settingKey][option]) {
switchListAttrs.checked = true;
}
let optionLabel = setting.options[option];
let subLabel = false;
if (typeof setting.options[option] === 'object') {
optionLabel = setting.options[option].label;
subLabel = setting.options[option].subLabel;
}
switchList.appendChild(
h('li',
[
h('span', setting.options[option]),
h('span', optionLabel),
h('div.switch',
[
h(`input#${optionId}`,
switchListAttrs),
h('label',
{
htmlFor: optionId })])]));
if (subLabel) {
switchList.appendChild(h('div.sub-label', subLabel));
}
});
settingCat.appendChild(switchList);
break;
Expand Down
5 changes: 4 additions & 1 deletion www/js/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
"title": "Display Options",
"type": "switch",
"options": {
"akhandpaatt": "Akhand Paatth View (Beta)",
"akhandpaatt": {
"label": "Akhand Paatth View (Beta)",
"subLabel": "(Google ChromeCast Unavailable)"
},
"larivaar": "Larivaar",
"left-align": "Left-Align",
"autoplay": "Auto Play",
Expand Down
29 changes: 16 additions & 13 deletions www/js/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,23 @@ const castToReceiver = () => {

const castShabadLine = (lineID) => {
document.querySelector('.viewer-controls').innerHTML = '';
castCur = decks[currentShabad][lineID];
let nextLine = '';
if (decks[currentShabad][lineID + 1]) {
nextLine = decks[currentShabad][lineID + 1].gurmukhi;
}
castCur.nextLine = nextLine;
castToReceiver();
// make sure that the deck is created before attempting to cast it.
if (decks && decks[currentShabad]) {
castCur = decks[currentShabad][lineID];
let nextLine = '';
if (decks[currentShabad][lineID + 1]) {
nextLine = decks[currentShabad][lineID + 1].gurmukhi;
}
castCur.nextLine = nextLine;
castToReceiver();

const activeSlide = document.querySelector('.deck.active .slide.active').children;
Array.prototype.forEach.call(activeSlide, ((element) => {
const icons = iconsetHtml(`icons-${element.classList[0]}`, element.innerHTML);
if (icons) document.querySelector('.viewer-controls').appendChild(icons);
}));

const activeSlide = document.querySelector('.deck.active .slide.active').children;
Array.prototype.forEach.call(activeSlide, ((element) => {
const icons = iconsetHtml(`icons-${element.classList[0]}`, element.innerHTML);
if (icons) document.querySelector('.viewer-controls').appendChild(icons);
}));
}
};

const castText = (text, isGurmukhi) => {
Expand Down Expand Up @@ -293,7 +297,6 @@ const showLine = (ShabadID, LineID) => {
} else {
smoothScroll(`#apv #slide${LineID}`);
}
castShabadLine(LineID);
} else if (newShabadID in decks) {
const $shabadDeck = document.getElementById(`shabad${newShabadID}`);
if (currentShabad !== newShabadID || !$shabadDeck.classList.contains('active')) {
Expand Down
6 changes: 6 additions & 0 deletions www/src/scss/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@
}
}
}

.sub-label {
font-size: smaller;
font-weight: lighter;
margin-left: 1.5rem;
}

0 comments on commit bca0700

Please sign in to comment.