Skip to content

Commit cad4911

Browse files
committed
Fixed some code releated issues.
1 parent b153b89 commit cad4911

File tree

13 files changed

+1003
-262
lines changed

13 files changed

+1003
-262
lines changed

package-lock.json

Lines changed: 649 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* @fileoverview Drawing definitions for the simple Framework.
3+
*
4+
* @license Copyright 2018 The Coding with Chrome Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author [email protected] (Markus Bordihn)
19+
*/
20+
goog.provide('cwc.framework.simple.DrawInstruction');
21+
22+
goog.require('goog.color');
23+
goog.require('goog.color.alpha');
24+
25+
26+
/**
27+
* Draws a circle on the stage.
28+
* @param {number} x The x value for the center of the circle.
29+
* @param {number} y The y value for the center of the circle.
30+
* @param {number} radius
31+
* @return {!Object} This draw instructions.
32+
* @export
33+
*/
34+
cwc.framework.simple.DrawInstruction.circle = function(x, y, radius) {
35+
return function(display) {
36+
display.arc(x, y, (radius || 25), 0, 2 * Math.PI, false);
37+
};
38+
};

src/ui/blockly/blockly.js

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
goog.provide('cwc.ui.Blockly');
2121

2222
goog.require('cwc.soy.ui.Blockly');
23+
goog.require('cwc.ui.BlocklyConfig');
2324
goog.require('cwc.ui.BlocklyToolbar');
2425
goog.require('cwc.ui.BlocklyToolbox');
2526
goog.require('cwc.ui.Helper');
@@ -64,9 +65,6 @@ cwc.ui.Blockly = function(helper) {
6465
/** @type {Element} */
6566
this.nodeEditor = null;
6667

67-
/** @type {string} */
68-
this.mediaFiles = '../external/blockly/';
69-
7068
/** @type {boolean} */
7169
this.modified = false;
7270

@@ -97,27 +95,6 @@ cwc.ui.Blockly = function(helper) {
9795
/** @private {string} */
9896
this.viewName_ = '';
9997

100-
/** @private {Object} */
101-
this.options_ = {
102-
'path': this.mediaFiles,
103-
'toolbox': '<xml><category></category></xml>',
104-
'trashcan': true,
105-
'grid': {
106-
'spacing': 20,
107-
'length': 3,
108-
'colour': '#ccc',
109-
'snap': true,
110-
},
111-
'zoom': {
112-
'controls': true,
113-
'wheel': true,
114-
'startScale': 1.0,
115-
'maxScale': 3,
116-
'minScale': 0.5,
117-
'scaleSpeed': 1.1,
118-
},
119-
};
120-
12198
/** @private {!cwc.utils.Logger} */
12299
this.log_ = new cwc.utils.Logger(this.name);
123100
};
@@ -128,7 +105,8 @@ cwc.ui.Blockly = function(helper) {
128105
* @param {Element=} node
129106
* @param {Object=} options Optional dictionary of options.
130107
*/
131-
cwc.ui.Blockly.prototype.decorate = function(node, options = this.options_) {
108+
cwc.ui.Blockly.prototype.decorate = function(node,
109+
options = cwc.ui.BlocklyConfig) {
132110
this.node = node || goog.dom.getElement(this.prefix + 'chrome');
133111
if (!this.node) {
134112
console.error('Invalid Blockly node:', this.node);

src/ui/blockly/blockly_config.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @fileoverview Blockly Config for Blockly Editor.
3+
*
4+
* @license Copyright 2018 The Coding with Chrome Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author [email protected] (Markus Bordihn)
19+
*/
20+
goog.provide('cwc.ui.BlocklyConfig');
21+
22+
23+
/**
24+
* @emum {string|objct<string>|array<string>}
25+
*/
26+
cwc.ui.BlocklyConfig = {
27+
'path': '../external/blockly/',
28+
'toolbox': '<xml><category></category></xml>',
29+
'trashcan': true,
30+
'grid': {
31+
'spacing': 20,
32+
'length': 3,
33+
'colour': '#ccc',
34+
'snap': true,
35+
},
36+
'zoom': {
37+
'controls': true,
38+
'wheel': true,
39+
'startScale': 1.0,
40+
'maxScale': 3,
41+
'minScale': 0.5,
42+
'scaleSpeed': 1.1,
43+
},
44+
};

src/ui/editor/editor.js

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ goog.require('cwc.soy.ui.Editor');
2424
goog.require('cwc.ui.EditorAutocompleteBlacklistCodes');
2525
goog.require('cwc.ui.EditorAutocompleteBlacklistKeys');
2626
goog.require('cwc.ui.EditorAutocompleteList');
27+
goog.require('cwc.ui.EditorConfig');
2728
goog.require('cwc.ui.EditorContent');
2829
goog.require('cwc.ui.EditorHint');
2930
goog.require('cwc.ui.EditorInfobar');
@@ -87,12 +88,6 @@ cwc.ui.Editor = function(helper) {
8788
/** @type {cwc.ui.EditorToolbar} */
8889
this.toolbar = null;
8990

90-
/** @type {!Array} */
91-
this.rulers = [{'color': '#ccc', 'column': 80, 'lineStyle': 'dashed'}];
92-
93-
/** @type {string} */
94-
this.theme = 'default';
95-
9691
/** @type {cwc.ui.StatusBar} */
9792
this.statusBar = null;
9893

@@ -114,30 +109,6 @@ cwc.ui.Editor = function(helper) {
114109
/** @private {cwc.ui.EditorType|string} */
115110
this.editorType_ = cwc.ui.EditorType.UNKNOWN;
116111

117-
/** @private {Object} */
118-
this.options_ = {
119-
'autoCloseBrackets': true,
120-
'autoCloseTags': true,
121-
'foldGutter': true,
122-
'gutters': [
123-
'CodeMirror-linenumbers',
124-
'CodeMirror-foldgutter',
125-
'CodeMirror-lint-markers',
126-
],
127-
'highlightSelectionMatches': {'showToken': /\w/},
128-
'hint': this.editorHint_,
129-
'lineNumbers': true,
130-
'matchTags': {'bothTags': true},
131-
'rulers': this.rulers,
132-
'showTrailingSpace': true,
133-
'styleActiveLine': true,
134-
'theme': this.theme,
135-
'foldOptions': {
136-
'widget': '\u22EF',
137-
},
138-
'onUpdateLinting': this.handleLint_.bind(this),
139-
};
140-
141112
/** @private {boolean} */
142113
this.isVisible_ = true;
143114

@@ -219,7 +190,7 @@ cwc.ui.Editor.prototype.decorate = function(node) {
219190
* @param {Element=} node
220191
*/
221192
cwc.ui.Editor.prototype.decorateEditor = function(node) {
222-
this.editor = new CodeMirror(node, this.options_);
193+
this.editor = new CodeMirror(node, cwc.ui.EditorConfig);
223194
this.editor.setOption('extraKeys', {
224195
'Ctrl-Q': function(cm) {
225196
cm.foldCode(cm.getCursor());
@@ -681,15 +652,6 @@ cwc.ui.Editor.prototype.handleKeyUp_ = function(cm, e) {
681652
};
682653

683654

684-
/**
685-
* @param {Object} e
686-
* @private
687-
*/
688-
cwc.ui.Editor.prototype.handleLint_ = function(e) {
689-
this.log_.info('lint', e);
690-
};
691-
692-
693655
/**
694656
* Cleans up the event listener and any other modification.
695657
* @private

src/ui/editor/editor_config.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* @fileoverview Code Editor Config for the Coding with Chrome editor.
3+
*
4+
* @license Copyright 2018 The Coding with Chrome Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author [email protected] (Markus Bordihn)
19+
*/
20+
goog.provide('cwc.ui.EditorConfig');
21+
22+
23+
/**
24+
* @emum {string|objct<string>|array<string>}
25+
*/
26+
cwc.ui.EditorConfig = {
27+
'autoCloseBrackets': true,
28+
'autoCloseTags': true,
29+
'foldGutter': true,
30+
'gutters': [
31+
'CodeMirror-linenumbers',
32+
'CodeMirror-foldgutter',
33+
'CodeMirror-lint-markers',
34+
],
35+
'highlightSelectionMatches': {'showToken': /\w/},
36+
'hint': 'anyword',
37+
'lineNumbers': true,
38+
'matchTags': {'bothTags': true},
39+
'rulers': [
40+
{
41+
'color': '#ccc',
42+
'column': 80,
43+
'lineStyle': 'dashed',
44+
},
45+
],
46+
'showTrailingSpace': true,
47+
'styleActiveLine': true,
48+
'theme': 'default',
49+
'foldOptions': {
50+
'widget': '\u22EF',
51+
},
52+
};

0 commit comments

Comments
 (0)