Skip to content

Commit 1c7f89f

Browse files
committed
initial port to 1.0 UI
1 parent 543844c commit 1c7f89f

File tree

8 files changed

+210
-166
lines changed

8 files changed

+210
-166
lines changed

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
bower_components
22
vulcanized.js
3-
vulcanized.html
3+
vulcanized.html
4+
index.build.html
5+
index.build.js

Diff for: background.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
chrome.app.runtime.onLaunched.addListener(function(launchData) {
88
chrome.app.window.create(
9-
'index.html',
9+
'index.html',//Open the minified and CSP enabled code
1010
{
1111
id: 'mainWindow',
1212
bounds: {width: 800, height: 600}

Diff for: bower.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
"author": "",
77
"private": true,
88
"dependencies": {
9-
"polymer": "Polymer/polymer#^0.5.2",
10-
"core-elements": "Polymer/core-elements#^0.5.2",
11-
"prettify-element": "SmokyBob/prettify-element#master",
12-
"paper-button": "Polymer/paper-button#~0.5.2",
13-
"paper-dropdown-menu": "Polymer/paper-dropdown-menu#~0.5.2",
14-
"paper-dropdown": "Polymer/paper-dropdown#~0.5.2",
15-
"paper-input": "Polymer/paper-input#~0.5.2",
16-
"paper-toggle-button": "Polymer/paper-toggle-button#~0.5.2"
9+
"polymer": "Polymer/polymer#^1.0.5",
10+
"prettify-element": "smokybob/prettify-element#1.0",
11+
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.1",
12+
"iron-icons": "PolymerElements/iron-icons#^1.0.1",
13+
"paper-input": "PolymerElements/paper-input#^1.0.0",
14+
"paper-button": "PolymerElements/paper-button#^1.0.1",
15+
"paper-toggle-button": "PolymerElements/paper-toggle-button#^1.0.1"
1716
}
1817
}

Diff for: index.html

+27-19
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,33 @@
22
<html>
33
<head>
44
<title>PrettyCode</title>
5-
<link rel="stylesheet" href="styles.css">
5+
<!--<link rel="stylesheet" href="styles.css">-->
66
<link rel="stylesheet" href="fonts.css">
77
<link rel="import" href="bower_components/polymer/polymer.html">
8+
<link rel="import" href="bower_components/iron-flex-layout/classes/iron-flex-layout.html">
89
<link rel="import" href="bower_components/prettify-element/prettify-element.html">
9-
<link rel="import" href="bower_components/core-icons/core-icons.html">
10-
<link rel="import" href="bower_components/core-menu/core-menu.html">
11-
<link rel="import" href="bower_components/paper-item/paper-item.html">
10+
<link rel="import" href="bower_components/iron-icons/iron-icons.html">
1211
<link rel="import" href="bower_components/paper-input/paper-input.html">
13-
<link rel="import" href="bower_components/paper-input/paper-autogrow-textarea.html">
12+
<link rel="import" href="bower_components/paper-input/paper-textarea.html">
1413
<link rel="import" href="bower_components/paper-button/paper-button.html">
1514
<link rel="import" href="bower_components/paper-toggle-button/paper-toggle-button.html">
16-
<link rel="import" href="bower_components/paper-dropdown/paper-dropdown.html">
17-
<link rel="import" href="bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
15+
16+
<link rel="import" href="styles.html">
1817
</head>
1918

20-
<body unresolved fit>
21-
<template id='mainContent' is="auto-binding">
22-
<div fit layout vertical>
23-
<div horizontal layout style="margin-top:5px">
19+
<body class="fit">
20+
<template id="mainContent" is="dom-bind">
21+
<div class="fit layout vertical">
22+
<div class="horizontal layout" style="margin-top:5px">
2423
<div style="margin:5px">Light</div>
25-
<paper-toggle-button id="ptbTheme" style="margin:5px" on-change="{{chTheme}}"></paper-toggle-button>
24+
<paper-toggle-button id="ptbTheme"
25+
style="margin:5px"
26+
on-change="chTheme"></paper-toggle-button>
2627
<div style="margin:5px">Dark</div>
2728
</div>
28-
<div layout horizontal>
29+
<div class="layout horizontal">
2930
<!--Language selection hidden as now the lang class id difficult to set on the prettify-element-->
31+
<!--
3032
<paper-dropdown-menu id="pdmLanguage" label="Select Language"
3133
on-core-select="{{languageSelected}}">
3234
<paper-dropdown id="lang" class="dropdown">
@@ -41,16 +43,22 @@
4143
</core-menu>
4244
</paper-dropdown>
4345
</paper-dropdown-menu>
44-
<paper-input id="ptDimension" label="Font size (pt)" value="{{fontPt}}"
45-
floatingLabel="true" on-change="{{ptChange}}"
46+
-->
47+
<paper-input id="ptDimension" label="Font size (pt)"
48+
value="{{fontPt}}" on-change="ptChange"
49+
always-float-label
4650
style="margin-left:10px;" ></paper-input>
4751
</div>
48-
<paper-autogrow-textarea id="agTa" maxrows='20'>
49-
<textarea id="taCode"></textarea>
50-
</paper-autogrow-textarea>
52+
<paper-textarea id="agTa" value="{{code}}">
53+
</paper-textarea>
5154
<div id="slidesWarnings">
5255
</div>
53-
<prettify-element id="destination" text="{{code}}" language="{{language}}" on-tap="{{selPrettyCode}}" flex style='overflow:auto'></prettify-element>
56+
<prettify-element id="destination"
57+
text="{{code}}"
58+
language="{{language}}"
59+
on-tap="selPrettyCode"
60+
class="flex"
61+
style="overflow:auto"></prettify-element>
5462
</div>
5563
</template>
5664

Diff for: main.js

+43-44
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22
var mainContent = document.querySelector('#mainContent');
33

44
//Get data from the syncStorage
5-
chrome.storage.sync.get(["language","theCode","theme","fontPt"],function(localStorage){
6-
mainContent.language = localStorage.language || '--';
7-
mainContent.code = localStorage.theCode || '';
8-
mainContent.theme = localStorage.theme || 'light';
9-
mainContent.fontPt = localStorage.fontPt || 14;
10-
11-
12-
});
13-
mainContent.addEventListener('template-bound', function(){
14-
5+
chrome.storage.sync.get(
6+
['language', 'theCode', 'theme', 'fontPt'],
7+
function(localStorage) {
8+
mainContent.language = localStorage.language || '--';
9+
mainContent.code = localStorage.theCode || '';
10+
mainContent.theme = localStorage.theme || 'light';
11+
mainContent.fontPt = localStorage.fontPt || 14;
12+
});
13+
mainContent.addEventListener('template-bound', function() {
1514
//Set the font-size
1615
mainContent.ptChange();
1716

1817
//Now that the template is bound update the code in the textArea
19-
mainContent.$.taCode.value = mainContent.code;
20-
mainContent.$.agTa.update(mainContent.$.taCode); //Update the autoGrowArea;
18+
//mainContent.$.codeValue = mainContent.code;
19+
//mainContent.$.agTa.update(mainContent.$.taCode); //Update the autoGrowArea;
2120

2221
//Add a change listener to the textArea
2322
mainContent.$.taCode.addEventListener('input', function() {
@@ -30,18 +29,18 @@ mainContent.addEventListener('template-bound', function(){
3029
});
3130

3231
//Find the label of the selected language to set it on the paper-dropdown-menu
33-
var mnItems =document.querySelectorAll('paper-item');
34-
[].some.call(mnItems, function(mnItem){
35-
if (mnItem.dataset.value==mainContent.language){
32+
var mnItems = document.querySelectorAll('paper-item');
33+
[].some.call(mnItems, function(mnItem) {
34+
if (mnItem.dataset.value == mainContent.language) {
3635
//Item found, update the selectedItem to change the label
37-
mainContent.$.pdmLanguage.selectedItemLabel=mnItem.innerText;
36+
mainContent.$.pdmLanguage.selectedItemLabel = mnItem.innerText;
3837
return true;
3938
}
4039
return false;
4140
});
4241

4342
//Select the theme on the slider
44-
mainContent.$.ptbTheme.checked=(mainContent.theme=='dark');
43+
mainContent.$.ptbTheme.checked = (mainContent.theme == 'dark');
4544

4645
//Set the theme and lang on all the components
4746
setThemeAndLang();
@@ -50,7 +49,7 @@ mainContent.addEventListener('template-bound', function(){
5049
mainContent.validateForSlides();
5150
});
5251

53-
var setThemeAndLang = function(){
52+
var setThemeAndLang = function() {
5453
//Change the classes on the prettyprint element accordingly
5554
document.body.className = 'theme-' + mainContent.theme;
5655

@@ -62,12 +61,12 @@ var setThemeAndLang = function(){
6261
/*if (mainContent.lang != '--') {
6362
mainContent.$.destination.className += ' lang-' + mainContent.lang;
6463
}*/
65-
}
64+
};
6665

67-
mainContent.languageSelected = function(selMenu){
66+
mainContent.languageSelected = function(selMenu) {
6867
//Changed selected language, update the value and store
69-
if(selMenu.detail.isSelected){
70-
mainContent.language=selMenu.detail.item.dataset.value;
68+
if (selMenu.detail.isSelected) {
69+
mainContent.language = selMenu.detail.item.dataset.value;
7170
chrome.storage.sync.set({'language': mainContent.language}, function() {
7271
//Nothing to do
7372
});
@@ -76,13 +75,13 @@ mainContent.languageSelected = function(selMenu){
7675
setThemeAndLang();
7776
}
7877

79-
}
78+
};
8079

81-
mainContent.chTheme = function(){
80+
mainContent.chTheme = function() {
8281
//if checked theme is dark, otherwise light
83-
if(mainContent.$.ptbTheme.checked){
82+
if (mainContent.$.ptbTheme.checked) {
8483
mainContent.theme = 'dark';
85-
}else{
84+
}else {
8685
mainContent.theme = 'light';
8786
}
8887
chrome.storage.sync.set({'theme': mainContent.theme}, function() {
@@ -92,13 +91,13 @@ mainContent.chTheme = function(){
9291
//Set the theme and lang
9392
setThemeAndLang();
9493

95-
}
94+
};
9695

97-
var ptToPx = function(valPt){
98-
return (16/12)*valPt;//return the font-size in px from the ptValue
99-
}
96+
var ptToPx = function(valPt) {
97+
return (16 / 12) * valPt;//return the font-size in px from the ptValue
98+
};
10099

101-
mainContent.ptChange = function(){
100+
mainContent.ptChange = function() {
102101
//TODO:Validate the value before saving it and using it to calculate the px value
103102

104103
chrome.storage.sync.set({'fontPt': mainContent.fontPt}, function() {
@@ -116,9 +115,9 @@ mainContent.ptChange = function(){
116115
var preElement = mainContent.$.destination.shadowRoot.querySelector('pre');
117116
preElement.style.fontSize = fontPx;
118117

119-
}
118+
};
120119

121-
mainContent.selPrettyCode = function(sender){
120+
mainContent.selPrettyCode = function(sender) {
122121
//Get the pre element inside the prettyfy-element
123122
var preElement = sender.currentTarget.shadowRoot.querySelector('pre');
124123

@@ -130,30 +129,30 @@ mainContent.selPrettyCode = function(sender){
130129
selection.removeAllRanges();
131130
selection.addRange(range);
132131

133-
}
132+
};
134133

135-
mainContent.validateForSlides = function(){
136-
var divW = document.querySelector("#slidesWarnings");
134+
mainContent.validateForSlides = function() {
135+
var divW = document.querySelector('#slidesWarnings');
137136
var warn = [];
138137

139138
var MAX_LINES = 20;
140139
if ((mainContent.code.match(/\n/g) || []).length >= MAX_LINES) {
141-
warn.push('More than ' + MAX_LINES + ' lines of code will be hard to read on a slide.');
140+
warn.push('More than ' + MAX_LINES +
141+
' lines of code will be hard to read on a slide.');
142142
}
143143

144144
var lines = mainContent.code.split('\n') || [];
145145
var MAX_LINE_LENGTH = 80;
146146
for (var i = 0; i < lines.length; i++) {
147147
if (lines[i].length > MAX_LINE_LENGTH) {
148-
warn.push('Line ' + (i + 1) + ' has more than ' + MAX_LINE_LENGTH + ' characters!');
148+
warn.push('Line ' + (i + 1) + ' has more than ' +
149+
MAX_LINE_LENGTH + ' characters!');
149150
}
150151
}
151-
if (warn.length>0){
152+
if (warn.length > 0) {
152153
divW.innerHTML = warn.join('<br>');
153-
}else{
154-
divW.innerHTML='Perfect code for slides';
154+
}else {
155+
divW.innerHTML = 'Perfect code for slides';
155156
}
156-
}
157-
158-
157+
};
159158

Diff for: manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"short_name": "PrettyCode",
55
"description": "Code prettyfier following guidelines for GDE Videos",
66

7-
"version": "0.0.2.1",
7+
"version": "0.9.0",
88

99
"icons": {
1010
"32": "assets/favicon_32.png",

Diff for: styles.css

-92
This file was deleted.

0 commit comments

Comments
 (0)