Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #92 from yjlintw/titlebar
Browse files Browse the repository at this point in the history
Titlebar
  • Loading branch information
yjlintw authored May 3, 2017
2 parents b9dcbd2 + f26c7ff commit 7729987
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ node_modules/
legacy/
dist/
build/
npm-debug.log
npm-debug.log*
4 changes: 4 additions & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ h1, h2 {
top: 0;
-webkit-app-region: drag;
margin: 0; }
.titlebar #titlebar-title {
text-align: center;
line-height: 25px;
color: white; }

.titlebar-close,
.titlebar-minimize,
Expand Down
5 changes: 5 additions & 0 deletions assets/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ h1, h2 {
top: 0;
-webkit-app-region: drag;
margin: 0;
#titlebar-title {
text-align: center;
line-height: $titlebar-height;
color: white;
}
}

.titlebar-close,
Expand Down
71 changes: 0 additions & 71 deletions npm-debug.log.1845718106

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "comic-reader",
"productName:": "Comic Reader",
"productName": "Comic Reader",
"author": "Team Comic Reader",
"version": "0.1.15",
"version": "0.1.16",
"description": "A simple comic reader app",
"main": "main.js",
"devDependencies": {
Expand Down
82 changes: 57 additions & 25 deletions renderer-process/viewcontrollers/titlebar-viewcontroller.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,60 @@
var titlebar = require('titlebar');
var titlebar = require('titlebar')();
var pjson = require('../../package.json');
const remote = require('electron').remote;

module.exports = {
updateTitle: updateTitle
}

var log = function(name) {
return function(e) {
console.log(name, e);
};
};
var t = titlebar()
.appendTo(document.querySelector('#titlebar'))
.on('close', function() {
var window = remote.getCurrentWindow();
window.close();
})
.on('minimize', function() {
var window = remote.getCurrentWindow();
window.minimize();
})
.on('fullscreen', function() {
var window = remote.getCurrentWindow();
window.setFullScreen(!window.isFullScreen());

})
.on('maximize', function() {
var window = remote.getCurrentWindow();
window.maximize();
});


function updateTitle() {
if ($('#read-view').hasClass('is-hidden')) {
setTitle(pjson.productName);
} else {
var comicTitle = $('#comic-header').attr('title');
var episode = $('.chapter-entry.active').text();
setTitle(comicTitle, [episode]);
}
}

function setTitle(name, options) {
var result = name;
if (options !== undefined) {
var subtitle = options.join('-');
result += '-' + subtitle;

}
$("#titlebar-title").text(result);
}


function lateInit() {
titlebar.appendTo(document.querySelector('#titlebar'))
.on('close', function() {
var window = remote.getCurrentWindow();
window.close();
})
.on('minimize', function() {
var window = remote.getCurrentWindow();
window.minimize();
})
.on('fullscreen', function() {
var window = remote.getCurrentWindow();
window.setFullScreen(!window.isFullScreen());

})
.on('maximize', function() {
var window = remote.getCurrentWindow();
window.maximize();
});

var div = document.createElement('div');
div.id = 'titlebar-title';
titlebar.element.appendChild(div);

setTitle(pjson.productName);
}


$(document).ready(lateInit);
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// var subscriber = require('../subscribe-viewmodel');
var read_viewcontroller = require('./read-viewcontroller');
var titlebar_viewcontroller = require('./titlebar-viewcontroller');

// Variable definition
var updateAllUIFunc;
Expand Down Expand Up @@ -95,6 +96,8 @@ function onTabEntryClick() {
if ($(this).attr('id') == "tab-read") {
read_viewcontroller.scrollToPage(-1);
}

titlebar_viewcontroller.updateTitle();
}


Expand Down
2 changes: 2 additions & 0 deletions renderer-process/viewmodels/comicparse-viewmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var favorite_viewcontroller = require('../viewcontrollers/favorite-viewcontrolle
var read_viewcontroller = require('../viewcontrollers/read-viewcontroller');
var viewswitch_viewcontroller = require("../viewcontrollers/view-switch-viewcontroller");
var translate_viewcontroller = require("../viewcontrollers/translate-viewcontroller");
var titlebar_viewcontroller = require("../viewcontrollers/titlebar-viewcontroller");

module.exports = {
selectComic: selectComic
Expand Down Expand Up @@ -196,6 +197,7 @@ function updateChapterList() {
read_viewcontroller.updateChapterList(comic_data);
var keypath = "comic." + read_viewcontroller.getCurHost() + "." + read_viewcontroller.getCurTitleKey();
settings.set(keypath, comic_data);
titlebar_viewcontroller.updateTitle();
}

/**
Expand Down
1 change: 0 additions & 1 deletion renderer-process/viewmodels/subscribe-viewmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ function updateSubscribeUIStatus() {
favorite_viewcontroller.updateSubscribeUI(all_comic_data, hasSubscription());
read_viewcontroller.updateSubscribeUI(all_comic_data);
translate_viewcontroller.translate();

var page_idx = read_viewcontroller.getCurrentPageIdx();
var titlekey = read_viewcontroller.getCurTitleKey();
var host = read_viewcontroller.getCurHost();
Expand Down

0 comments on commit 7729987

Please sign in to comment.