Skip to content

Commit

Permalink
Added support for uploading files for Linux
Browse files Browse the repository at this point in the history
Temporary fix, currently Chrome closes the popup upon an upload file
attempt. This is circumvented by opening a popup in place as the popup
will not be closed when the file dialog appears. This resolves Wassup789#13.
  • Loading branch information
Wassup789 committed Sep 27, 2016
1 parent d49e1ee commit 78a709f
Show file tree
Hide file tree
Showing 8 changed files with 405 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ settings.html
js/settings.js
pages/edit-notification.js
pages/edit-notification.html
pages/upload-file.js
pages/upload-file.html

# Windows image file caches
Thumbs.db
Expand Down
20 changes: 19 additions & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ module.exports = function(grunt){
},
files: ["pages/edit-notification_edit.html", "pages/edit-notification_edit.js", "pages/edit-notification.css"],
tasks: ["vulcanize"]
},
uploadFileTemporary: {
options: {
spawn: false,
interrupt: true
},
files: ["pages/upload-file_edit.html", "pages/upload-file_edit.js", "pages/upload-file.css"],
tasks: ["vulcanize"]
}
},
vulcanize: {
Expand All @@ -36,7 +44,16 @@ module.exports = function(grunt){
files: {
"pages/edit-notification.html": "pages/edit-notification_edit.html"
}
}
},
uploadFileTemporary: {
options: {
inlineCss: false,
csp: "upload-file.js"
},
files: {
"pages/upload-file.html": "pages/upload-file_edit.html"
}
}
}
});

Expand All @@ -45,4 +62,5 @@ module.exports = function(grunt){

grunt.registerTask("default", ["vulcanize", "watch"]);
grunt.registerTask("editNotification", ["vulcanize", "watch"]);
grunt.registerTask("uploadFileTemporary", ["vulcanize", "watch"]);
};
9 changes: 7 additions & 2 deletions js/settings_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,12 @@ function registerListeners(){

//Start of file uploader
$("#settings_sound_upload").on("click", function(){
$("#fileUploader").click();
chrome.runtime.getPlatformInfo(function(info) {
if(info.os == "linux")
chrome.windows.create({url: "pages/upload-file.html", type: "popup", width: 600, height: 270});
else
$("#fileUploader").click();
});
});
$("#fileUploader").on("change", function(){
createToast(getString("uploading"));
Expand Down Expand Up @@ -1209,7 +1214,7 @@ function addPaperItem(listboxElem, title, value) {
* Clears all items from the paper-listbox
*/
function clearPaperItems(listboxElem) {
$Poly(listboxElem).innerHTML = ""
$Poly(listboxElem).innerHTML = "";
}

/**
Expand Down
3 changes: 1 addition & 2 deletions pages/edit-notification_edit.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<!DOCTYPE html>
<html lang="en">
<head>
Expand Down Expand Up @@ -163,7 +162,7 @@
<script>
HTMLImports.whenReady(function () {
Polymer({
is: 'main-element'
is: "main-element"
});
});
</script>
Expand Down
126 changes: 126 additions & 0 deletions pages/upload-file.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
* {
box-sizing:border-box;
-webkit-user-select: none;
}
.selectable {-webkit-user-select: text;}
.noninteractable {pointer-events: none;}

body{
font-size:12px;
color:#252525;
padding: 0;
margin: 0;
text-shadow: none;
font-family: Roboto, Arial, sans-serif;
font-weight: 400;
overflow-x:hidden;
background: #efefef;
width: 100%;
height: 100%;
box-sizing:border-box;
}
.unscrollable {overflow: hidden!important;}

a, .link{
text-decoration: none;
cursor:pointer;
color: #448aff;
font-weight: 500;
}

::-webkit-scrollbar {
width: 5px;
}

::-webkit-scrollbar-thumb {
border-radius: 5px;
background: rgba(0,0,0,0.4);
}
#launch_screen {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: #FFFFFF;
z-index: 10000;
}
#launch_screen-header {
height: 56px;
background: #f44336;
}
#launch_screen-logo {
position: absolute;
height: 128px;
width: 128px;
top: calc(50% + 28px - 64px);
left: calc(50% - 64px);
background: url("../img/128.png");
animation: shakeAnimation 4s linear infinite;
z-index: 1;
}
@keyframes shakeAnimation {
0% {transform: rotate( 0deg);}
25% {transform: rotate( 0deg);}
30% {transform: rotate( 5deg);}
35% {transform: rotate(-5deg);}
40% {transform: rotate( 5deg);}
45% {transform: rotate(-5deg);}
50% {transform: rotate( 5deg);}
55% {transform: rotate(-5deg);}
60% {transform: rotate( 5deg);}
65% {transform: rotate(-5deg);}
70% {transform: rotate( 5deg);}
75% {transform: rotate( 0deg);}
100% {transform: rotate( 0deg);}
}
#launch_screen-ripple {
position: absolute;
top: calc(50% + 28px);
left: 50%;
transform: translate(-50%, -50%);
width: 100px;
height: 100px;
border-radius: 50%;
background: rgba(244,67,54,0.3);
animation: rippleAnimation 1.5s linear infinite;
}
@keyframes rippleAnimation {
0% {
width: 50px;
height: 50px;
opacity: 0;
}
25% {
opacity: 1;
}
50% {
width: 200px;
height: 200px;
}
100% {
width: 350px;
height: 350px;
opacity: 0;
}
}

#header_img {
height: 32px;
}

#content {
display: flex;
justify-content: center;
align-items: center;
padding: 30px 0;
}

.label[i18n] {
font-size: 14px;
font-weight: bold;
}

.label[i18n]:after {content: ":";margin-right: 4px;}

#content paper-card .card-content {padding-top: 5px;}
100 changes: 100 additions & 0 deletions pages/upload-file_edit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>

<link rel="import" href="../bower_components/iron-pages/iron-pages.html">
<link rel="import" href="../bower_components/paper-header-panel/paper-header-panel.html">
<link rel="import" href="../bower_components/paper-toolbar/paper-toolbar.html">
<link rel="import" href="../bower_components/paper-card/paper-card.html">
<link rel="import" href="../bower_components/paper-button/paper-button.html">
<link rel="import" href="../bower_components/paper-toast/paper-toast.html">
<link rel="import" href="../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../bower_components/paper-listbox/paper-listbox.html">
<link rel="import" href="../bower_components/paper-item/paper-item.html">
<link rel="import" href="../bower_components/iron-icon/iron-icon.html">
<link rel="import" href="../bower_components/iron-icons/iron-icons.html">
<link rel="import" href="../bower_components/iron-icons/av-icons.html">

<link rel="stylesheet" type="text/css" href="upload-file.css" />
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="upload-file_edit.js"></script>
</head>
<body>
<div id="launch_screen">
<div id="launch_screen-header"></div>
<div id="launch_screen-logo"></div>
<div id="launch_screen-ripple"></div>
</div>
<dom-module id="main-element">
<template>
<style>
:host {
--primary-color: var(--paper-red-500);
--light-primary-color: var(--paper-red-100);
--dark-primary-color: var(--paper-red-700);
}
paper-toolbar .title {
margin-left: 5px;
}
paper-header-panel {
min-height: 100vh;
}
paper-slider {
--paper-slider-active-color: var(--dark-primary-color);
--paper-slider-secondary-color: var(--primary-color);
--paper-slider-knob-color: var(--primary-color);
--paper-slider-pin-color: var(--dark-primary-color);
cursor: pointer;
}
paper-button[raised] {
background-color: var(--primary-color);
color: white;
}
paper-button iron-icon {
margin: 0 6px 0 2px;
}
paper-card {
--paper-card-header: {
border-bottom: 1px solid #D4D4D4;
}
}
paper-card .card-actions {
color: var(--primary-color);
}
</style>
<input id="fileUploader" type="file" accept="audio/*" hidden>
<paper-toast text="" class="fit-bottom"></paper-toast>
<paper-header-panel mode="standard">
<paper-toolbar id="toolbar">
<img id="header_img" src="../img/yt_logo.png" />
<span class="title">Notifications - <span i18n="settings_editSettings_notificationSound"></span></span>
</paper-toolbar>
<div id="content" class="fit">

<paper-card>
<div class="card-content">
<span class="label" i18n="settings_editSettings_notificationSound"></span>
<paper-dropdown-menu id="settings_sound_list">
<paper-listbox class="dropdown-content"></paper-listbox>
</paper-dropdown-menu>
<paper-button id="settings_sound_upload" raised>
<iron-icon icon="icons:file-upload"></iron-icon>
<span i18n="settings_editSettings_uploadSound"></span>
</paper-button>
</div>
</paper-card>
</div>
</paper-header-panel>
</template>
<script>
HTMLImports.whenReady(function () {
Polymer({
is: "main-element"
});
});
</script>
</dom-module>
<main-element></main-element>
</body>
</html>
Loading

0 comments on commit 78a709f

Please sign in to comment.