This repository has been archived by the owner on Nov 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from yjlintw/titlebar
Titlebar
- Loading branch information
Showing
9 changed files
with
74 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ node_modules/ | |
legacy/ | ||
dist/ | ||
build/ | ||
npm-debug.log | ||
npm-debug.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 57 additions & 25 deletions
82
renderer-process/viewcontrollers/titlebar-viewcontroller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters