mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
update electron window
This commit is contained in:
@@ -125,4 +125,4 @@ gulp.task('default', function (cb) {
|
|||||||
runSequence('del', 'build', 'watch', cb)
|
runSequence('del', 'build', 'watch', cb)
|
||||||
})
|
})
|
||||||
|
|
||||||
// require('./gulp-electron')(gulp)
|
require('./gulp-electron')(gulp)
|
||||||
|
|||||||
@@ -10,34 +10,33 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
|
||||||
<meta name="description" content="CodeXen - Short code storage service">
|
<meta name="description" content="CodeXen - Short code storage service">
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../all.css" media="screen" title="no title" charset="utf-8">
|
<link rel="stylesheet" href="../../vendor/css/font-awesome.css" media="screen" title="no title" charset="utf-8">
|
||||||
|
<link rel="stylesheet" href="../../main.css" media="screen" title="no title" charset="utf-8">
|
||||||
</head>
|
</head>
|
||||||
<body class="popup-body" ng-controller="PopUpController">
|
<body class="popup-body" ng-controller="PopUpController">
|
||||||
|
|
||||||
<!-- Dev!!-->
|
<div class="search-block">
|
||||||
<button style="position:fixed;bottom:0;right:0;padding:5px;z-index:1000;" type="button" name="button" ng-click="toggleDev()">DEV!</button>
|
|
||||||
|
|
||||||
<div ng-click="focusSearchInput()" class="search-block">
|
|
||||||
<input ng-change="filterList(searchNeedle)" search-input id="search-input" type="text" class="form-control" ng-model="searchNeedle" ng-change="refreshResult">
|
<input ng-change="filterList(searchNeedle)" search-input id="search-input" type="text" class="form-control" ng-model="searchNeedle" ng-change="refreshResult">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="result-block row-fluid">
|
<div class="result-block row-fluid">
|
||||||
<ul ng-click="focusList()" class="result-list left-pane" ng-class="{focused:isFocusing == 2}">
|
<ul class="result-list left-pane" ng-class="{focused:isFocusing == 2}">
|
||||||
<li ng-click="selectItem($index)" ng-repeat="snippet in filteredSnippets"><a ng-class="{selected:$index == selectIndex}" href="#">{{snippet.description}}</a></li>
|
<li ng-click="selectSnippet($index)" ng-repeat="snippet in filteredSnippets" ng-class="{active:$index == selectIndex}"><a href="#">{{snippet.description}}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="right-pane">
|
<div class="right-pane">
|
||||||
<div ng-click="focusControl()" class="result-detail-control">
|
<div class="result-detail-control">
|
||||||
<button ng-class="{focus: controlIndex == 1}" id="btnClipboard" type="button" name="button" class="btn btn-default"><i class="fa fa-clipboard"></i></button>
|
<button id="btnClipboard" type="button" name="button" class="btn btn-default"><i class="fa fa-clipboard"></i></button>
|
||||||
<button ng-class="{focus: controlIndex == 2}" id="btnEdit" type="button" name="button" class="btn btn-default"><i class="fa fa-edit"></i></button>
|
<button id="btnEdit" type="button" name="button" class="btn btn-default"><i class="fa fa-edit"></i></button>
|
||||||
<button ng-class="{focus: controlIndex == 3}" id="btnShare" type="button" name="button" class="btn btn-default"><i class="fa fa-share"></i></button>
|
<button id="btnShare" type="button" name="button" class="btn btn-default"><i class="fa fa-share"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div ng-click="focusContent()" id="aceView" class="result-detail-content"
|
<div id="aceView" class="result-detail-content"
|
||||||
ui-ace="{
|
ui-ace="{
|
||||||
showGutter: false,
|
showGutter: false,
|
||||||
useWrapMode: true,
|
useWrapMode: true,
|
||||||
mode:selectedItem.mode.toLowerCase(),
|
mode:selectedItem.mode.toLowerCase(),
|
||||||
onLoad : aceLoaded
|
onLoad: aceLoaded,
|
||||||
|
theme: 'solarized_dark'
|
||||||
}"
|
}"
|
||||||
|
|
||||||
readonly
|
readonly
|
||||||
|
|||||||
@@ -3,15 +3,6 @@
|
|||||||
var remote = require('remote')
|
var remote = require('remote')
|
||||||
var ipc = require('ipc')
|
var ipc = require('ipc')
|
||||||
|
|
||||||
var SEARCH_INPUT = 1
|
|
||||||
var RESULT_LIST = 2
|
|
||||||
var RESULT_CONTROL = 3
|
|
||||||
var RESULT_CONTENT = 4
|
|
||||||
// var btnClipboard = document.getElementById('btnClipboard')
|
|
||||||
// var btnEdit = document.getElementById('btnEdit')
|
|
||||||
// var btnShare = document.getElementById('btnShare')
|
|
||||||
var aceView = document.getElementById('aceView')
|
|
||||||
|
|
||||||
angular.module('codexen.popup', [
|
angular.module('codexen.popup', [
|
||||||
'ui.ace',
|
'ui.ace',
|
||||||
'satellizer',
|
'satellizer',
|
||||||
@@ -27,214 +18,146 @@ angular.module('codexen.popup', [
|
|||||||
// Setup Events
|
// Setup Events
|
||||||
remote.getCurrentWindow().on('focus', function () {
|
remote.getCurrentWindow().on('focus', function () {
|
||||||
$scope.$apply(focusSearchInput)
|
$scope.$apply(focusSearchInput)
|
||||||
|
loadSnippets()
|
||||||
})
|
})
|
||||||
|
|
||||||
hotkeys.bindTo($scope)
|
hotkeys.bindTo($scope)
|
||||||
.add('down', function (e) {
|
.add('down', function (e) {
|
||||||
switch ($scope.isFocusing) {
|
nextSnippet()
|
||||||
case RESULT_LIST:
|
|
||||||
selectNextItem()
|
|
||||||
break
|
|
||||||
case RESULT_CONTROL:
|
|
||||||
focusContent()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
.add('up', function (e) {
|
.add('up', function (e) {
|
||||||
switch ($scope.isFocusing) {
|
priorSnippet()
|
||||||
case RESULT_LIST:
|
|
||||||
selectPriorItem()
|
|
||||||
break
|
|
||||||
case RESULT_CONTENT:
|
|
||||||
focusControl()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
.add('right', function (e) {
|
.add('right', function (e) {
|
||||||
if ($scope.isFocusing === RESULT_LIST) {
|
|
||||||
focusControl()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if ($scope.isFocusing === RESULT_CONTROL) {
|
|
||||||
nextControl()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.add('left', function (e) {
|
.add('left', function (e) {
|
||||||
if ($scope.isFocusing === RESULT_CONTROL) {
|
|
||||||
priorControl()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.add('esc', function (e) {
|
.add('esc', function (e) {
|
||||||
switch ($scope.isFocusing) {
|
|
||||||
case RESULT_LIST:
|
|
||||||
focusSearchInput()
|
|
||||||
break
|
|
||||||
case RESULT_CONTROL:
|
|
||||||
focusList()
|
|
||||||
break
|
|
||||||
case RESULT_CONTENT:
|
|
||||||
console.log('esc fr content')
|
|
||||||
focusControl()
|
|
||||||
break
|
|
||||||
case SEARCH_INPUT:
|
|
||||||
hidePopUp()
|
hidePopUp()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.add('shift+tab', function (e) {
|
.add('shift+tab', function (e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if ($scope.isFocusing === RESULT_CONTROL) {
|
|
||||||
priorControl()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.add('tab', function (e) {
|
.add('tab', function (e) {
|
||||||
e.preventDefault()
|
|
||||||
if ($scope.isFocusing === RESULT_LIST) {
|
|
||||||
focusControl()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if ($scope.isFocusing === RESULT_CONTROL) {
|
|
||||||
nextControl()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.add('enter', function (e) {
|
.add('enter', function (e) {
|
||||||
switch ($scope.isFocusing) {
|
|
||||||
case RESULT_LIST:
|
|
||||||
console.log($scope.selectedItem.content)
|
console.log($scope.selectedItem.content)
|
||||||
ipc.send('writeCode', $scope.selectedItem.content)
|
ipc.send('writeCode', $scope.selectedItem.content)
|
||||||
break
|
|
||||||
}
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
$scope.aceLoaded = function (editor) {
|
$scope.aceLoaded = function (editor) {
|
||||||
editor.commands.addCommand({
|
editor.commands.addCommand({
|
||||||
name: 'escape',
|
name: 'escape',
|
||||||
bindKey: {win: 'esc', mac: 'esc'},
|
bindKey: {win: 'esc', mac: 'esc'},
|
||||||
exec: function (editor) {
|
exec: function (editor) {
|
||||||
editor.blur()
|
editor.blur()
|
||||||
focusControl()
|
|
||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
},
|
},
|
||||||
readOnly: true
|
readOnly: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.$on('nextSnippetRequested', function (e) {
|
||||||
|
e.stopPropagation()
|
||||||
|
nextSnippet()
|
||||||
|
})
|
||||||
|
|
||||||
|
$scope.$on('priorSnippetRequested', function (e) {
|
||||||
|
e.stopPropagation()
|
||||||
|
priorSnippet()
|
||||||
|
})
|
||||||
|
|
||||||
|
$scope.$on('snippetSubmitted', function (e) {
|
||||||
|
if ($scope.filteredSnippets.length > 0) ipc.send('writeCode', $scope.selectedItem.content)
|
||||||
|
else console.log('\x07')
|
||||||
|
e.stopPropagation()
|
||||||
|
})
|
||||||
|
|
||||||
// Init Data
|
// Init Data
|
||||||
$scope.snippets = []
|
$scope.snippets = []
|
||||||
|
|
||||||
var userId = $auth.getPayload().sub
|
Snippet.findMine()
|
||||||
Snippet.findByUser(userId)
|
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
$scope.snippets = data.snippets
|
$scope.snippets = data
|
||||||
filterList()
|
filterList()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Functions
|
// Result Item control
|
||||||
|
$scope.selectIndex = 0
|
||||||
|
|
||||||
|
$scope.selectSnippet = selectSnippet
|
||||||
|
$scope.filterList = filterList
|
||||||
|
$scope.focusSearchInput = focusSearchInput
|
||||||
|
|
||||||
// Search Filter
|
// Search Filter
|
||||||
|
function loadSnippets () {
|
||||||
|
Snippet.findMine()
|
||||||
|
.success(function (data) {
|
||||||
|
$scope.snippets = data
|
||||||
|
filterList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function filterList (needle) {
|
function filterList (needle) {
|
||||||
$scope.filteredSnippets = $filter('filter')($scope.snippets, needle)
|
$scope.filteredSnippets = $filter('filter')($scope.snippets, needle)
|
||||||
$scope.selectIndex = 0
|
firstSnippet()
|
||||||
selectItem($scope.selectIndex)
|
}
|
||||||
|
|
||||||
|
function selectSnippet (index) {
|
||||||
|
if (index !== undefined) $scope.selectIndex = index
|
||||||
|
$scope.selectedItem = $scope.filteredSnippets[$scope.selectIndex]
|
||||||
|
}
|
||||||
|
|
||||||
|
function firstSnippet () {
|
||||||
|
$scope.selectIndex = 0
|
||||||
|
selectSnippet($scope.selectIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
function priorSnippet () {
|
||||||
|
if ($scope.selectIndex > 0) $scope.selectIndex -= 1
|
||||||
|
selectSnippet()
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextSnippet () {
|
||||||
|
if ($scope.selectIndex < $scope.filteredSnippets.length - 1) {
|
||||||
|
$scope.selectIndex += 1
|
||||||
|
}
|
||||||
|
selectSnippet()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Focusing Search Input
|
||||||
|
function focusSearchInput () {
|
||||||
|
document.getElementById('search-input').focus()
|
||||||
}
|
}
|
||||||
$scope.filterList = filterList
|
|
||||||
|
|
||||||
function hidePopUp () {
|
function hidePopUp () {
|
||||||
ipc.send('hidePopUp')
|
ipc.send('hidePopUp')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result Item control
|
|
||||||
$scope.selectIndex = 0
|
|
||||||
|
|
||||||
$scope.selectItem = selectItem
|
|
||||||
function selectItem (index) {
|
|
||||||
$scope.selectIndex = index
|
|
||||||
$scope.selectedItem = $scope.filteredSnippets[index]
|
|
||||||
|
|
||||||
$scope.controlIndex = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectNextItem () {
|
|
||||||
if ($scope.selectIndex >= ($scope.filteredSnippets.length - 1)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
selectItem(++$scope.selectIndex)
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectPriorItem () {
|
|
||||||
if ($scope.selectIndex === 0) {
|
|
||||||
focusSearchInput()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
selectItem(--$scope.selectIndex)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Focusing control
|
|
||||||
$scope.isFocusing = 0
|
|
||||||
|
|
||||||
function focusSearchInput () {
|
|
||||||
$scope.isFocusing = SEARCH_INPUT
|
|
||||||
document.getElementById('search-input').focus()
|
|
||||||
|
|
||||||
$scope.controlIndex = 0
|
|
||||||
}
|
|
||||||
$scope.focusSearchInput = focusSearchInput
|
|
||||||
|
|
||||||
function focusList () {
|
|
||||||
$scope.isFocusing = RESULT_LIST
|
|
||||||
document.getElementById('search-input').blur()
|
|
||||||
|
|
||||||
$scope.controlIndex = 0
|
|
||||||
}
|
|
||||||
$scope.focusList = focusList
|
|
||||||
|
|
||||||
function focusControl () {
|
|
||||||
if ($scope.controlIndex === 0) {
|
|
||||||
$scope.controlIndex = 1
|
|
||||||
}
|
|
||||||
$scope.isFocusing = RESULT_CONTROL
|
|
||||||
}
|
|
||||||
$scope.focusControl = focusControl
|
|
||||||
|
|
||||||
function focusContent () {
|
|
||||||
angular.element(aceView).scope().focus()
|
|
||||||
$scope.isFocusing = RESULT_CONTENT
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.controlIndex = 0
|
|
||||||
|
|
||||||
function nextControl () {
|
|
||||||
if ($scope.controlIndex === 3) {
|
|
||||||
$scope.controlIndex = 0
|
|
||||||
focusContent()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
$scope.controlIndex ++
|
|
||||||
}
|
|
||||||
|
|
||||||
function priorControl () {
|
|
||||||
if ($scope.controlIndex === 1) {
|
|
||||||
focusList()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
$scope.controlIndex --
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.directive('searchInput', function () {
|
.directive('searchInput', function () {
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
link: function (scope, el, attr) {
|
link: function (scope, el, attr) {
|
||||||
el.on('keydown', function (e) {
|
el.on('keydown', function (e) {
|
||||||
|
|
||||||
// Down key => Focus on Result list
|
// Down key => Focus on Result list
|
||||||
if (e.keyCode === 40) {
|
if (e.keyCode === 40) {
|
||||||
scope.focusList()
|
scope.$emit('nextSnippetRequested')
|
||||||
e.preventDefault()
|
// e.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Up key => Focus on Result list
|
||||||
|
if (e.keyCode === 38) {
|
||||||
|
scope.$emit('priorSnippetRequested')
|
||||||
|
// e.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Up key => Focus on Result list
|
||||||
|
if (e.keyCode === 13) {
|
||||||
|
scope.$emit('snippetSubmitted')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Esc key => Dismiss popup
|
// Esc key => Dismiss popup
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
@import "../../src/variables";
|
|
||||||
@import "../../src/mixins";
|
|
||||||
|
|
||||||
$selected-color: white;
|
|
||||||
$selected-bg: $brand-primary;
|
|
||||||
|
|
||||||
$focused-shadow-color: $brand-primary;
|
|
||||||
|
|
||||||
|
|
||||||
.popup-body{
|
|
||||||
.search-block{
|
|
||||||
padding: 5px;
|
|
||||||
height:44px;
|
|
||||||
position:absolute;
|
|
||||||
top: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.result-block{
|
|
||||||
position:absolute;
|
|
||||||
top: 44px;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
.left-pane{
|
|
||||||
margin: 0;
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: 40%;
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
|
|
||||||
}
|
|
||||||
.result-list{
|
|
||||||
list-style:none;
|
|
||||||
padding: 0;
|
|
||||||
&.focused{
|
|
||||||
border: solid 1px $brand-primary;
|
|
||||||
}
|
|
||||||
li{
|
|
||||||
a{
|
|
||||||
display:block;
|
|
||||||
padding: 5px 10px;
|
|
||||||
border-bottom: 1px solid $border-color;
|
|
||||||
|
|
||||||
&.selected{
|
|
||||||
color: $selected-color;
|
|
||||||
background-color: $selected-bg;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
border-right: 1px solid $border-color;
|
|
||||||
}
|
|
||||||
.right-pane{
|
|
||||||
position: absolute;
|
|
||||||
left: 40%;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: 60%;
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.result-detail-control{
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 34px;
|
|
||||||
}
|
|
||||||
.result-detail-content{
|
|
||||||
position: absolute;
|
|
||||||
top: 34px;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ angular.module('codexen.popup')
|
|||||||
|
|
||||||
|
|
||||||
angular.module('codexen.popup')
|
angular.module('codexen.popup')
|
||||||
.factory('Snippet', function ($http, apiUrl) {
|
.factory('Snippet', function ($http, $auth, apiUrl) {
|
||||||
var findByUser = function (user) {
|
var findByUser = function (user) {
|
||||||
var url = apiUrl + 'snippets/search'
|
var url = apiUrl + 'snippets/search'
|
||||||
|
|
||||||
@@ -21,16 +21,22 @@ angular.module('codexen.popup')
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var findMine = function (params) {
|
||||||
|
var url = apiUrl + 'snippets/my'
|
||||||
|
|
||||||
|
return $http.get(url, {params: params})
|
||||||
|
}
|
||||||
|
|
||||||
var create = function (params) {
|
var create = function (params) {
|
||||||
var url = apiUrl + 'snippets/create'
|
var url = apiUrl + 'snippets/create'
|
||||||
|
|
||||||
return $http.post(url, params)
|
return $http.post(url, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
var show = function (id) {
|
var show = function (id, params) {
|
||||||
var url = apiUrl + 'snippets/id/' + id
|
var url = apiUrl + 'snippets/id/' + id
|
||||||
|
|
||||||
return $http.get(url)
|
return $http.get(url, {params: params})
|
||||||
}
|
}
|
||||||
|
|
||||||
var update = function (id, params) {
|
var update = function (id, params) {
|
||||||
@@ -47,6 +53,7 @@ angular.module('codexen.popup')
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
findByUser: findByUser,
|
findByUser: findByUser,
|
||||||
|
findMine: findMine,
|
||||||
create: create,
|
create: create,
|
||||||
show: show,
|
show: show,
|
||||||
delete: destroy,
|
delete: destroy,
|
||||||
|
|||||||
59
electron_src/styles/_popup.styl
Normal file
59
electron_src/styles/_popup.styl
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
.popup-body
|
||||||
|
.search-block
|
||||||
|
padding: 5px
|
||||||
|
height:44px
|
||||||
|
position:absolute
|
||||||
|
top: 0
|
||||||
|
width: 100%
|
||||||
|
|
||||||
|
.result-block
|
||||||
|
position:absolute
|
||||||
|
top: 44px
|
||||||
|
bottom: 0
|
||||||
|
width: 100%
|
||||||
|
overflow: hidden
|
||||||
|
.left-pane
|
||||||
|
margin: 0
|
||||||
|
position: absolute
|
||||||
|
left: 0
|
||||||
|
top: 0
|
||||||
|
bottom: 0
|
||||||
|
width: 40%
|
||||||
|
overflow-y: auto
|
||||||
|
overflow-x: hidden
|
||||||
|
.result-list
|
||||||
|
list-style:none
|
||||||
|
padding: 0
|
||||||
|
border-right: 1px solid $border-color
|
||||||
|
li
|
||||||
|
&:nth-child(even)
|
||||||
|
background-color $baseBackgroundColor
|
||||||
|
&:nth-child(odd)
|
||||||
|
background-color lighten($baseBackgroundColor, 2%)
|
||||||
|
&.active
|
||||||
|
color: $textColorSelected
|
||||||
|
background-color: $btnPrimary
|
||||||
|
a
|
||||||
|
display:block
|
||||||
|
padding: 5px 10px
|
||||||
|
border-bottom 1px solid $baseBorderColor
|
||||||
|
|
||||||
|
.right-pane
|
||||||
|
position: absolute
|
||||||
|
left: 40%
|
||||||
|
top: 0
|
||||||
|
bottom: 0
|
||||||
|
width: 60%
|
||||||
|
overflow-y: auto
|
||||||
|
overflow-x: hidden
|
||||||
|
.result-detail-control
|
||||||
|
position: absolute
|
||||||
|
top: 0
|
||||||
|
width: 100%
|
||||||
|
height: 34px
|
||||||
|
|
||||||
|
.result-detail-content
|
||||||
|
position: absolute
|
||||||
|
top: 34px
|
||||||
|
bottom: 0
|
||||||
|
width: 100%
|
||||||
13
electron_src/styles/main.styl
Normal file
13
electron_src/styles/main.styl
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
@import '../../src/styles/_vars'
|
||||||
|
@import '../../src/styles/mixins/*'
|
||||||
|
|
||||||
|
@import '../../src/styles/_bootstrap'
|
||||||
|
|
||||||
|
@import '../../src/styles/_index'
|
||||||
|
@import '../../src/styles/_shared'
|
||||||
|
|
||||||
|
@import '../../src/styles/modals/*'
|
||||||
|
@import '../../src/styles/directives/*'
|
||||||
|
@import '../../src/styles/states/*'
|
||||||
|
|
||||||
|
@import '_popup'
|
||||||
100
gulp-electron.js
100
gulp-electron.js
@@ -1,61 +1,63 @@
|
|||||||
var sass = require('gulp-sass')
|
require('dotenv').load()
|
||||||
|
var env = process.env
|
||||||
|
|
||||||
|
var styl = require('gulp-stylus')
|
||||||
var autoprefixer = require('gulp-autoprefixer')
|
var autoprefixer = require('gulp-autoprefixer')
|
||||||
var templateCache = require('gulp-angular-templatecache')
|
var templateCache = require('gulp-angular-templatecache')
|
||||||
var globby = require('globby')
|
var globby = require('globby')
|
||||||
var template = require('gulp-template')
|
var template = require('gulp-template')
|
||||||
var concat = require('gulp-concat')
|
|
||||||
var del = require('del')
|
var del = require('del')
|
||||||
var runSequence = require('run-sequence')
|
var runSequence = require('run-sequence')
|
||||||
var merge = require('merge-stream')
|
var plumber = require('gulp-plumber')
|
||||||
|
var notify = require('gulp-notify')
|
||||||
var changed = require('gulp-changed')
|
var changed = require('gulp-changed')
|
||||||
var cached = require('gulp-cached')
|
|
||||||
var remember = require('gulp-remember')
|
|
||||||
var livereload = require('gulp-livereload')
|
var livereload = require('gulp-livereload')
|
||||||
var childProcess = require('child_process')
|
var merge = require('merge-stream')
|
||||||
|
|
||||||
var config = require('./build.config.js')
|
var config = require('./build.config.js')
|
||||||
|
|
||||||
// for Dist
|
|
||||||
var rev = require('gulp-rev')
|
|
||||||
var ngAnnotate = require('gulp-ng-annotate')
|
|
||||||
var uglify = require('gulp-uglify')
|
|
||||||
var minifyCss = require('gulp-minify-css')
|
|
||||||
|
|
||||||
module.exports = function (gulp) {
|
module.exports = function (gulp) {
|
||||||
|
|
||||||
|
gulp.task('elec-env', function () {
|
||||||
/*
|
return gulp.src('tpls/env.js')
|
||||||
* Electron build
|
.pipe(template({
|
||||||
*/
|
apiUrl: env.BUILD_API_URL
|
||||||
gulp.task('elec-js', function(){
|
}))
|
||||||
var src = gulp.src(['src/**/*.js'])
|
.pipe(gulp.dest('electron_build/config'))
|
||||||
.pipe(changed('electron_build'))
|
|
||||||
.pipe(gulp.dest('electron_build'))
|
|
||||||
var elecSrc = gulp.src(['electron_src/**/*.js'])
|
|
||||||
.pipe(changed('electron_build/electron'))
|
|
||||||
.pipe(gulp.dest('electron_build/electron'))
|
|
||||||
var elecHtml = gulp.src(['electron_src/**/*.html'])
|
|
||||||
.pipe(changed('electron_build/electron'))
|
|
||||||
.pipe(gulp.dest('electron_build/electron'))
|
|
||||||
|
|
||||||
return merge(src, elecSrc, elecHtml)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('elec-sass', function () {
|
gulp.task('elec-js', function () {
|
||||||
return gulp.src(['src/**/*.scss', 'electron_src/**/*.scss'])
|
var main = gulp.src('src/**/*.js')
|
||||||
.pipe(cached('styles'))
|
.pipe(changed('electron_build'))
|
||||||
.pipe(sass().on('error', sass.logError))
|
|
||||||
.pipe(autoprefixer())
|
|
||||||
.pipe(remember('styles'))
|
|
||||||
.pipe(concat('all.css'))
|
|
||||||
.pipe(gulp.dest('electron_build'))
|
.pipe(gulp.dest('electron_build'))
|
||||||
|
|
||||||
|
var electron = gulp.src('electron_src/**/*.js')
|
||||||
|
.pipe(changed('electron_build/electron'))
|
||||||
|
.pipe(gulp.dest('electron_build/electron'))
|
||||||
|
|
||||||
|
return merge(main, electron)
|
||||||
|
})
|
||||||
|
|
||||||
|
gulp.task('elec-styl', function () {
|
||||||
|
return gulp.src('electron_src/styles/main.styl')
|
||||||
|
.pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
|
||||||
|
.pipe(styl())
|
||||||
|
.pipe(autoprefixer())
|
||||||
|
.pipe(gulp.dest('electron_build'))
|
||||||
|
.pipe(notify('Stylus!!'))
|
||||||
|
.pipe(livereload())
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('elec-tpls', function () {
|
gulp.task('elec-tpls', function () {
|
||||||
return gulp.src('src/**/*.tpl.html')
|
var main = gulp.src('src/**/*.tpl.html')
|
||||||
.pipe(templateCache())
|
.pipe(templateCache())
|
||||||
.pipe(gulp.dest('electron_build'))
|
.pipe(gulp.dest('electron_build'))
|
||||||
|
|
||||||
|
var electron = gulp.src('electron_src/**/*.tpl.html')
|
||||||
|
.pipe(templateCache())
|
||||||
|
.pipe(gulp.dest('electron_build/electron'))
|
||||||
|
|
||||||
|
return merge(main, electron)
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('elec-index', function () {
|
gulp.task('elec-index', function () {
|
||||||
@@ -72,13 +74,19 @@ module.exports = function (gulp) {
|
|||||||
var scripts = filter(files, 'js')
|
var scripts = filter(files, 'js')
|
||||||
var styles = filter(files, 'css')
|
var styles = filter(files, 'css')
|
||||||
|
|
||||||
return gulp.src('src/index.html')
|
var main = gulp.src('src/index.html')
|
||||||
.pipe(template({
|
.pipe(template({
|
||||||
scripts: scripts,
|
scripts: scripts,
|
||||||
styles: styles,
|
styles: styles,
|
||||||
env: 'build'
|
env: env
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest('electron_build'))
|
.pipe(gulp.dest('electron_build'))
|
||||||
|
.pipe(livereload())
|
||||||
|
|
||||||
|
var electron = gulp.src('electron_src/**/index.html')
|
||||||
|
.pipe(gulp.dest('electron_build/electron'))
|
||||||
|
|
||||||
|
return merge(main, electron)
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('elec-vendor', function () {
|
gulp.task('elec-vendor', function () {
|
||||||
@@ -88,6 +96,10 @@ module.exports = function (gulp) {
|
|||||||
return vendor.src
|
return vendor.src
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vendorFiles.push('node_modules/font-awesome/**/font-awesome.css')
|
||||||
|
vendorFiles.push('node_modules/font-awesome/**/fontawesome-webfont.*')
|
||||||
|
vendorFiles.push('node_modules/font-awesome/**/FontAwesome.*')
|
||||||
|
|
||||||
return gulp.src(vendorFiles)
|
return gulp.src(vendorFiles)
|
||||||
.pipe(gulp.dest('electron_build/vendor'))
|
.pipe(gulp.dest('electron_build/vendor'))
|
||||||
})
|
})
|
||||||
@@ -99,17 +111,19 @@ module.exports = function (gulp) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('elec-build', function (cb) {
|
gulp.task('elec-build', function (cb) {
|
||||||
runSequence(['elec-js', 'elec-sass', 'elec-tpls', 'elec-vendor', 'elec-resources'], 'elec-index', cb)
|
runSequence(['elec-env', 'elec-js', 'elec-styl', 'elec-tpls', 'elec-vendor', 'elec-resources'], 'elec-index', cb)
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('elec-watch', function (cb) {
|
gulp.task('elec-watch', function (cb) {
|
||||||
gulp.watch(['src/**/*.js', 'electron_src/**/*.js', 'electron_src/**/*.html'], ['elec-js'])
|
gulp.watch(['.env', 'tpls/env.js'], ['elec-env'])
|
||||||
|
|
||||||
gulp.watch(['src/**/*.scss', 'electron_src/**/*.scss'], ['elec-sass'])
|
gulp.watch(['src/**/*.js', 'electron_src/**/*.js'], ['elec-js'])
|
||||||
|
|
||||||
|
gulp.watch(['src/styles/**/*.styl', 'electron_src/styles/**/*.styl'], ['elec-styl'])
|
||||||
|
|
||||||
gulp.watch('src/**/*.tpl.html', ['elec-tpls'])
|
gulp.watch('src/**/*.tpl.html', ['elec-tpls'])
|
||||||
|
|
||||||
gulp.watch(['electron_build/**/*', '!electron_build/vendor/**/*', '!electron_build/electron/**/*'], ['elec-index'])
|
gulp.watch(['electron_build/**/*.js', 'src/index.html', 'src/index.html', 'electron_src/**/index.html'], ['elec-index'])
|
||||||
|
|
||||||
livereload.listen()
|
livereload.listen()
|
||||||
})
|
})
|
||||||
|
|||||||
75
main.js
75
main.js
@@ -12,8 +12,6 @@ app.on('window-all-closed', function () {
|
|||||||
if (process.platform !== 'darwin') app.quit()
|
if (process.platform !== 'darwin') app.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
var robot = require('robotjs')
|
|
||||||
|
|
||||||
var clipboard = require('clipboard')
|
var clipboard = require('clipboard')
|
||||||
|
|
||||||
var Tray = require('tray')
|
var Tray = require('tray')
|
||||||
@@ -22,6 +20,12 @@ var appIcon = null
|
|||||||
app.on('ready', function () {
|
app.on('ready', function () {
|
||||||
appIcon = new Tray('./icon.png')
|
appIcon = new Tray('./icon.png')
|
||||||
appIcon.setToolTip('This is my application.')
|
appIcon.setToolTip('This is my application.')
|
||||||
|
appIcon.on('clicked', function () {
|
||||||
|
if (mainWindow == null) {
|
||||||
|
makeNewMainWindow()
|
||||||
|
}
|
||||||
|
mainWindow.show()
|
||||||
|
})
|
||||||
|
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
@@ -33,12 +37,9 @@ app.on('ready', function () {
|
|||||||
|
|
||||||
mainWindow.loadUrl('file://' + __dirname + '/electron_build/index.html')
|
mainWindow.loadUrl('file://' + __dirname + '/electron_build/index.html')
|
||||||
|
|
||||||
|
makeNewMainWindow()
|
||||||
// mainWindow.openDevTools()
|
// mainWindow.openDevTools()
|
||||||
|
|
||||||
mainWindow.on('closed', function () {
|
|
||||||
console.log('main closed')
|
|
||||||
mainWindow = null
|
|
||||||
})
|
|
||||||
|
|
||||||
var globalShortcut = require('global-shortcut')
|
var globalShortcut = require('global-shortcut')
|
||||||
|
|
||||||
@@ -56,14 +57,7 @@ app.on('ready', function () {
|
|||||||
|
|
||||||
app.on('activate-with-no-open-windows', function () {
|
app.on('activate-with-no-open-windows', function () {
|
||||||
if (mainWindow == null) {
|
if (mainWindow == null) {
|
||||||
console.log('new WIndow!')
|
makeNewMainWindow()
|
||||||
mainWindow = new BrowserWindow({width: 800, height: 600})
|
|
||||||
|
|
||||||
mainWindow.loadUrl('file://' + __dirname + '/electron_build/index.html')
|
|
||||||
|
|
||||||
mainWindow.on('closed', function () {
|
|
||||||
mainWindow = null
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
mainWindow.show()
|
mainWindow.show()
|
||||||
})
|
})
|
||||||
@@ -76,8 +70,8 @@ app.on('ready', function () {
|
|||||||
if (fromMain) {
|
if (fromMain) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mainWindow.hide()
|
mainWindow ? mainWindow.hide() : null
|
||||||
Menu.sendActionToFirstResponder('hide:');
|
Menu.sendActionToFirstResponder('hide:')
|
||||||
}
|
}
|
||||||
|
|
||||||
popUpWindow.hide()
|
popUpWindow.hide()
|
||||||
@@ -89,27 +83,22 @@ app.on('ready', function () {
|
|||||||
})
|
})
|
||||||
ipc.on('writeCode', function (e, code) {
|
ipc.on('writeCode', function (e, code) {
|
||||||
clipboard.writeText(code)
|
clipboard.writeText(code)
|
||||||
// setTimeout(function () {
|
|
||||||
// robot.typeString(code)
|
|
||||||
// }, 200)
|
|
||||||
hidePopUp()
|
hidePopUp()
|
||||||
})
|
})
|
||||||
|
|
||||||
var fromMain
|
var fromMain
|
||||||
// Register a 'ctrl+x' shortcut listener.
|
// Register a 'ctrl+x' shortcut listener.
|
||||||
var ret = globalShortcut.register('ctrl+tab+shift', function () {
|
var ret = globalShortcut.register('ctrl+tab+shift', function () {
|
||||||
|
|
||||||
if (popUpWindow.isVisible()) {
|
if (popUpWindow.isVisible()) {
|
||||||
hidePopUp()
|
hidePopUp()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fromMain = mainWindow.isFocused()
|
fromMain = mainWindow ? mainWindow.isFocused() : false
|
||||||
popUpWindow.show()
|
popUpWindow.show()
|
||||||
|
|
||||||
})
|
})
|
||||||
if (!ret) console.log('registerion fails')
|
if (!ret) console.log('registerion fails')
|
||||||
|
|
||||||
|
|
||||||
// MENU
|
// MENU
|
||||||
var Menu = require('menu')
|
var Menu = require('menu')
|
||||||
var template = [
|
var template = [
|
||||||
@@ -150,8 +139,8 @@ app.on('ready', function () {
|
|||||||
{
|
{
|
||||||
label: 'Quit',
|
label: 'Quit',
|
||||||
accelerator: 'Command+Q',
|
accelerator: 'Command+Q',
|
||||||
click: function() { app.quit(); }
|
click: function () { app.quit() }
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -189,7 +178,7 @@ app.on('ready', function () {
|
|||||||
label: 'Select All',
|
label: 'Select All',
|
||||||
accelerator: 'Command+A',
|
accelerator: 'Command+A',
|
||||||
selector: 'selectAll:'
|
selector: 'selectAll:'
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -198,13 +187,13 @@ app.on('ready', function () {
|
|||||||
{
|
{
|
||||||
label: 'Reload',
|
label: 'Reload',
|
||||||
accelerator: 'Command+R',
|
accelerator: 'Command+R',
|
||||||
click: function() { BrowserWindow.getFocusedWindow().reloadIgnoringCache(); }
|
click: function () { BrowserWindow.getFocusedWindow().reloadIgnoringCache() }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Toggle DevTools',
|
label: 'Toggle DevTools',
|
||||||
accelerator: 'Alt+Command+I',
|
accelerator: 'Alt+Command+I',
|
||||||
click: function() { BrowserWindow.getFocusedWindow().toggleDevTools(); }
|
click: function () { BrowserWindow.getFocusedWindow().toggleDevTools() }
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -226,16 +215,36 @@ app.on('ready', function () {
|
|||||||
{
|
{
|
||||||
label: 'Bring All to Front',
|
label: 'Bring All to Front',
|
||||||
selector: 'arrangeInFront:'
|
selector: 'arrangeInFront:'
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Help',
|
label: 'Help',
|
||||||
submenu: []
|
submenu: []
|
||||||
},
|
}
|
||||||
];
|
]
|
||||||
|
|
||||||
menu = Menu.buildFromTemplate(template);
|
var menu = Menu.buildFromTemplate(template)
|
||||||
|
|
||||||
Menu.setApplicationMenu(menu);
|
Menu.setApplicationMenu(menu)
|
||||||
|
|
||||||
|
function makeNewMainWindow () {
|
||||||
|
console.log('new Window!')
|
||||||
|
mainWindow = new BrowserWindow({
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
'web-preferences': {
|
||||||
|
'overlay-scrollbars': true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
mainWindow.loadUrl('file://' + __dirname + '/electron_build/index.html')
|
||||||
|
|
||||||
|
mainWindow.on('closed', function () {
|
||||||
|
console.log('main closed')
|
||||||
|
mainWindow = null
|
||||||
|
app.dock.hide()
|
||||||
|
})
|
||||||
|
app.dock.show()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user