forked from connors/photon
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minimal implementation example of buttons
- Loading branch information
Showing
7 changed files
with
99 additions
and
1 deletion.
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
Large diffs are not rendered by default.
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
|
||
photon.start(document); | ||
|
||
}) |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
var photon = (function(){ | ||
|
||
var photon = {}; | ||
|
||
photon.start = function(section){ | ||
|
||
section = section || document; | ||
|
||
// helper to iterate over selector | ||
var _foreachElement = function(selector, callback){ | ||
var nodeList = section.querySelectorAll(selector); | ||
Array.prototype.forEach.call(nodeList, function (item) { | ||
callback(item); | ||
}) | ||
}; | ||
|
||
var remoteWindow = require('remote').getCurrentWindow(); | ||
|
||
// Close window | ||
_foreachElement("[action-close-window]", function(item){ | ||
item.addEventListener("click", function(){ | ||
remoteWindow.close(); | ||
}); | ||
}); | ||
|
||
// Minimize window | ||
_foreachElement("[action-minimize-window]", function(item){ | ||
item.addEventListener("click", function(){ | ||
remoteWindow.minimize(); | ||
}); | ||
}); | ||
|
||
// (un)Maximize window | ||
_foreachElement("[action-maximize-window]", function(item){ | ||
item.addEventListener("click", function(){ | ||
if (remoteWindow.isMaximized()) { | ||
remoteWindow.unmaximize(); | ||
} else { | ||
remoteWindow.maximize(); | ||
} | ||
}); | ||
}); | ||
|
||
|
||
}; | ||
|
||
return photon; | ||
|
||
})(); |
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