smalruby-editor 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/LEGAL +4 -3
- data/app/assets/javascripts/blocks/character.js.coffee.erb +7 -3
- data/app/assets/javascripts/blocks/events.js.coffee.erb +7 -10
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +119 -31
- data/app/assets/javascripts/blocks/motion.js.coffee.erb +16 -20
- data/app/assets/javascripts/blocks/operators.js.coffee.erb +1 -1
- data/app/assets/javascripts/blocks/pen.js.coffee.erb +2 -1
- data/app/assets/javascripts/blocks/ruby.js.coffee.erb +3 -3
- data/app/assets/javascripts/blocks/sensing.js.coffee.erb +8 -8
- data/app/assets/javascripts/blocks/sound.js.coffee.erb +3 -1
- data/app/assets/javascripts/fix_blockly.js.erb +105 -0
- data/app/assets/javascripts/generators/ruby.js.coffee.erb +3 -0
- data/app/assets/javascripts/msg/en_us.js +67 -17
- data/app/assets/javascripts/msg/ja.js +151 -95
- data/app/assets/javascripts/{smalruby.js.coffee → smalruby.js.coffee.erb} +35 -16
- data/app/assets/javascripts/views/character_selector_view.js.coffee +2 -2
- data/app/assets/javascripts/views/{load_modal_view.js.coffee → load_modal_view.js.coffee.erb} +8 -2
- data/app/assets/javascripts/views/main_menu_view.js.coffee.erb +33 -48
- data/app/assets/javascripts/views/signin_modal_view.js.coffee.erb +43 -0
- data/app/assets/stylesheets/application.css +3 -1
- data/app/assets/stylesheets/toolbox.css.scss.erb +2 -56
- data/app/assets/stylesheets/toolbox_default.css.scss.erb +34 -0
- data/app/assets/stylesheets/toolbox_smalrubot_s1.css.scss.erb +31 -0
- data/app/assets/stylesheets/toolbox_smalrubot_v3.css.scss.erb +32 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/source_codes_controller.rb +6 -3
- data/app/helpers/application_helper.rb +12 -0
- data/app/helpers/editor_helper.rb +25 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action.rb +13 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action_with_sec.rb +14 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_ir_photoreflector_value.rb +29 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_led_turn_on_or_off.rb +22 -0
- data/app/views/editor/_block_tab.html.haml +7 -6
- data/app/views/editor/_reset_modal.html.haml +4 -4
- data/app/views/editor/_signin_modal.html.haml +8 -9
- data/app/views/editor/_toolbox_default.html.haml +504 -0
- data/app/views/editor/_toolbox_smalrubot_s1.html.haml +171 -0
- data/app/views/editor/_toolbox_smalrubot_v3.html.haml +177 -0
- data/app/views/editor/index.html.haml +12 -2
- data/app/views/layouts/application.html.erb +1 -0
- data/config/environments/production.rb +1 -0
- data/config/locales/en.yml +19 -16
- data/config/locales/ja.yml +28 -25
- data/demos/hardware_led.rb.xml +79 -79
- data/lib/smalruby_editor.rb +58 -0
- data/lib/smalruby_editor/config.rb +22 -0
- data/lib/smalruby_editor/version.rb +1 -1
- data/public/blockly/media/anon.jpeg +0 -0
- data/public/blockly/media/handclosed.cur +0 -0
- data/public/blockly/media/handdelete.cur +0 -0
- data/public/blockly/media/progress.gif +0 -0
- data/public/blockly/media/sprites.png +0 -0
- data/smalruby-editor.gemspec +2 -1
- data/spec/acceptance/base.feature +3 -3
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action.feature +107 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action_with_sec.feature +151 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_ir_photoreflector_value.feature +100 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature +73 -0
- data/spec/acceptance/ruby_mode/translate.feature +6 -6
- data/spec/acceptance/standalone/save.feature +3 -3
- data/spec/acceptance/standalone/signin.feature +1 -2
- data/spec/lib/smalruby_editor_spec.rb +21 -11
- data/spec/models/concerns/ruby_to_block/block/hardware__smalrubot_s1_spec.rb +279 -0
- data/vendor/assets/javascripts/blockly/blockly_compressed.js +995 -668
- data/vendor/assets/javascripts/blockly/blocks_compressed.js +138 -114
- data/vendor/assets/javascripts/blockly/msg/js/en_us.js +6 -6
- data/vendor/assets/javascripts/blockly/msg/js/ja.js +42 -28
- metadata +66 -25
- data/app/assets/javascripts/fix_blockly.js +0 -128
- data/app/assets/javascripts/views/signin_modal_view.js.coffee +0 -33
- data/app/views/editor/_toolbox.html.haml +0 -496
- data/public/blockly/media/trashbody.png +0 -0
- data/public/blockly/media/trashlid.png +0 -0
- data/public/blockly/media/tree.png +0 -0
@@ -1,3 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
require 'smalruby_editor'
|
3
|
+
require 'smalruby_editor/blockly_message_helper'
|
4
|
+
%>
|
5
|
+
|
1
6
|
window.SmalrubyEditor = {}
|
2
7
|
window.changed = false
|
3
8
|
window.textEditor = null
|
@@ -16,7 +21,7 @@ window.successMessage = (title, msg = '', selector = '#messages') ->
|
|
16
21
|
window.errorMessage = (msg, selector = '#messages') ->
|
17
22
|
html = $('<div class="alert alert-error" style="display: none">')
|
18
23
|
.append('<button type="button" class="close" data-dismiss="alert">×</button>')
|
19
|
-
.append(
|
24
|
+
.append("<h4><i class=\"icon-exclamation-sign\"></i>#{<%= bm('common_error') %>}</h4>")
|
20
25
|
.append(msg)
|
21
26
|
$(selector).append(html)
|
22
27
|
html.fadeIn('slow')
|
@@ -30,12 +35,16 @@ window.Smalruby =
|
|
30
35
|
Collections: {}
|
31
36
|
Views: {}
|
32
37
|
Routers: {}
|
38
|
+
Features: []
|
39
|
+
|
40
|
+
username: null
|
41
|
+
|
33
42
|
initialize: ->
|
34
43
|
$.ajaxSetup
|
35
44
|
headers:
|
36
45
|
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
|
37
46
|
|
38
|
-
# HACK: Underscore
|
47
|
+
# HACK: Underscoreのテンプレートの\<\%, \%\>はHamlと組み合わせたときに
|
39
48
|
# HTML要素の属性がHamlによってエスケープされてしまうため使いにく
|
40
49
|
# い。そこで、それぞれ{{, }}に変更する。
|
41
50
|
_.extend(_.templateSettings, {
|
@@ -44,17 +53,6 @@ window.Smalruby =
|
|
44
53
|
interpolate: /{{=([\s\S]+?)}}/
|
45
54
|
})
|
46
55
|
|
47
|
-
# HACK: 一度開いたジャンルを2回クリックしても閉じないように修正
|
48
|
-
Blockly.Toolbox.TreeNode.prototype.onMouseDown = (e) ->
|
49
|
-
if @hasChildren() && @isUserCollapsible_
|
50
|
-
@toggle()
|
51
|
-
@select()
|
52
|
-
else if @isSelected()
|
53
|
-
#@getTree().setSelectedItem(null)
|
54
|
-
else
|
55
|
-
@select()
|
56
|
-
@updateRow()
|
57
|
-
|
58
56
|
@Collections.CharacterSet = new Smalruby.CharacterSet()
|
59
57
|
|
60
58
|
@Views.MainMenuView = new Smalruby.MainMenuView()
|
@@ -72,7 +70,7 @@ window.Smalruby =
|
|
72
70
|
Smalruby.downloading = false
|
73
71
|
window.onbeforeunload = (event) ->
|
74
72
|
if !Smalruby.downloading && window.changed
|
75
|
-
return '
|
73
|
+
return <%= bm('.will_disapper_your_program') %>
|
76
74
|
else
|
77
75
|
Smalruby.downloading = false
|
78
76
|
return
|
@@ -85,8 +83,6 @@ window.Smalruby =
|
|
85
83
|
toolbox: document.getElementById('toolbox')
|
86
84
|
trashcan: true
|
87
85
|
|
88
|
-
Blockly.Toolbox.tree_.expandAll()
|
89
|
-
|
90
86
|
@blocklyFirst = true
|
91
87
|
@blocklyLoading = false
|
92
88
|
Blockly.addChangeListener =>
|
@@ -110,6 +106,7 @@ window.Smalruby =
|
|
110
106
|
textEditor.setTheme('ace/theme/clouds')
|
111
107
|
textEditor.setShowInvisibles(true)
|
112
108
|
textEditor.gotoLine(0, 0)
|
109
|
+
textEditor.setReadOnly(@isEnabled('readonly_ruby_mode'))
|
113
110
|
textEditor.on 'change', (e) =>
|
114
111
|
unless @translating
|
115
112
|
window.changed = true
|
@@ -120,6 +117,8 @@ window.Smalruby =
|
|
120
117
|
session.setTabSize(2)
|
121
118
|
session.setUseSoftTabs(true)
|
122
119
|
|
120
|
+
@addCharacterFromBeginning()
|
121
|
+
|
123
122
|
loadXml: (data, workspace = Blockly.mainWorkspace) ->
|
124
123
|
xml = Blockly.Xml.textToDom(data)
|
125
124
|
workspace.clear()
|
@@ -172,6 +171,7 @@ window.Smalruby =
|
|
172
171
|
$('#filename').val('')
|
173
172
|
window.textEditor.getSession().getDocument().setValue('')
|
174
173
|
window.textEditor.moveCursorTo(0, 0)
|
174
|
+
@addCharacterFromBeginning()
|
175
175
|
window.changed = false
|
176
176
|
|
177
177
|
# 国際化したメッセージを取得する
|
@@ -182,5 +182,24 @@ window.Smalruby =
|
|
182
182
|
else
|
183
183
|
name
|
184
184
|
|
185
|
+
addCharacterFromBeginning: ->
|
186
|
+
if @isEnabled('add_character_from_beginning')
|
187
|
+
constume = 'cat1.png'
|
188
|
+
c = new Smalruby.Character
|
189
|
+
name: @Collections.CharacterSet.uniqueName(constume)
|
190
|
+
costumes: [constume]
|
191
|
+
x: 200
|
192
|
+
y: 200
|
193
|
+
@Collections.CharacterSet.add(c)
|
194
|
+
@Views.CharacterSelectorView.prevBlock = null
|
195
|
+
@Views.CharacterSelectorView.addBlock_(c)
|
196
|
+
window.changed = false
|
197
|
+
|
198
|
+
isEnabled: (feature) ->
|
199
|
+
@Features.indexOf(feature) != -1
|
200
|
+
|
185
201
|
$(document).ready ->
|
186
202
|
Smalruby.initialize()
|
203
|
+
|
204
|
+
if Smalruby.username == null && Smalruby.isEnabled('must_signin')
|
205
|
+
Smalruby.Views.SigninModalView.render()
|
@@ -61,14 +61,14 @@ Smalruby.CharacterSelectorView = Backbone.View.extend({
|
|
61
61
|
@render()
|
62
62
|
|
63
63
|
addBlock_: (character) ->
|
64
|
-
newBlock =
|
64
|
+
newBlock = Blockly.Block.obtain(Blockly.mainWorkspace, 'character_new')
|
65
65
|
newBlock.setCharacter(character)
|
66
66
|
newBlock.initSvg()
|
67
67
|
newBlock.render()
|
68
68
|
@moveByNewBlock_(newBlock)
|
69
69
|
newBlock.select()
|
70
70
|
|
71
|
-
onStartBlock =
|
71
|
+
onStartBlock = Blockly.Block.obtain(Blockly.mainWorkspace, 'events_on_start')
|
72
72
|
onStartBlock.initSvg()
|
73
73
|
onStartBlock.render()
|
74
74
|
newBlock.getInput('DO').connection.connect(onStartBlock.previousConnection)
|
data/app/assets/javascripts/views/{load_modal_view.js.coffee → load_modal_view.js.coffee.erb}
RENAMED
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
<%
|
2
|
+
require 'smalruby_editor'
|
3
|
+
require 'smalruby_editor/blockly_message_helper'
|
4
|
+
%>
|
5
|
+
|
6
|
+
# load dialog view
|
2
7
|
Smalruby.LoadModalView = Backbone.View.extend
|
3
8
|
events:
|
4
9
|
'click #load-modal-ok-button': 'onOk'
|
@@ -26,6 +31,7 @@ Smalruby.LoadModalView = Backbone.View.extend
|
|
26
31
|
|
27
32
|
unblock = =>
|
28
33
|
@$el.find('.modal-body').unblock()
|
34
|
+
null # HACK: if return unblock(), does not call fail().
|
29
35
|
|
30
36
|
@$el.modal('show')
|
31
37
|
|
@@ -51,7 +57,7 @@ Smalruby.LoadModalView = Backbone.View.extend
|
|
51
57
|
.then(unblock, unblock)
|
52
58
|
.fail =>
|
53
59
|
@$el.modal('hide')
|
54
|
-
errorMessage('
|
60
|
+
errorMessage(<%= bm('.error') %>)
|
55
61
|
|
56
62
|
onOk: ->
|
57
63
|
switch @type
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'smalruby_editor/blockly_message_helper'
|
4
4
|
%>
|
5
5
|
|
6
|
-
#
|
6
|
+
# navigation menu view
|
7
7
|
Smalruby.MainMenuView = Backbone.View.extend
|
8
8
|
el: '#main-menu'
|
9
9
|
|
@@ -152,34 +152,26 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
152
152
|
clearMessages()
|
153
153
|
|
154
154
|
@blockUI
|
155
|
-
title:
|
156
|
-
"""
|
157
|
-
#{<%= bm('.download_blockui_title') %>}
|
158
|
-
"""
|
155
|
+
title: <%= bm('.download_blockui_title') %>
|
159
156
|
message: <%= bm('.download_blockui_message') %>
|
160
|
-
notice:
|
161
|
-
"""
|
162
|
-
ダウンロードしたプログラムは、<br>
|
163
|
-
Windowsだと「ruby #{sourceCode.get('filename')}」、<br>
|
164
|
-
Macだと「rsdl #{sourceCode.get('filename')}」で実行できます。
|
165
|
-
"""
|
166
157
|
|
167
158
|
sourceCode.save2()
|
168
159
|
.then (data) ->
|
169
160
|
window.changed = false
|
170
|
-
window.successMessage('
|
161
|
+
window.successMessage(goog.getMsg(<%= bm('.download_succeeded') %>,
|
162
|
+
{ filename: sourceCode.get('filename') }))
|
171
163
|
Smalruby.downloading = true
|
172
164
|
$('#download-link').click()
|
173
165
|
.then(@unblockUI, @unblockUI)
|
174
166
|
.fail ->
|
175
|
-
window.errorMessage('
|
167
|
+
window.errorMessage(<%= bm('.download_error') %>)
|
176
168
|
|
177
169
|
onLoadLocal: (e) ->
|
178
170
|
e.preventDefault()
|
179
171
|
|
180
172
|
# TODO: window.changed -> Smalruby.Models.SourceCode.changed
|
181
173
|
if window.changed
|
182
|
-
return unless confirm('
|
174
|
+
return unless confirm(<%= bm('.load_confirm') %>)
|
183
175
|
|
184
176
|
Smalruby.Views.LoadModalView.render()
|
185
177
|
|
@@ -188,7 +180,7 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
188
180
|
|
189
181
|
# TODO: window.changed -> Smalruby.Models.SourceCode.changed
|
190
182
|
if window.changed
|
191
|
-
return unless confirm('
|
183
|
+
return unless confirm(<%= bm('.load_confirm') %>)
|
192
184
|
$('input#load-file[name="source_code[file]"]').click()
|
193
185
|
|
194
186
|
onSave: (e) ->
|
@@ -196,7 +188,7 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
196
188
|
|
197
189
|
filename = $.trim($('#filename').val())
|
198
190
|
if filename.length <= 0
|
199
|
-
window.errorMessage('
|
191
|
+
window.errorMessage(<%= bm('.save_error_no_name') %>)
|
200
192
|
$('#filename').focus()
|
201
193
|
return
|
202
194
|
|
@@ -208,29 +200,23 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
208
200
|
clearMessages()
|
209
201
|
|
210
202
|
@blockUI
|
211
|
-
title:
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
message: 'プログラムをセーブしています。'
|
216
|
-
notice:
|
217
|
-
"""
|
218
|
-
プログラムの名前は「#{sourceCode.get('filename')}」です。<br>
|
219
|
-
プログラムはホームディレクトリにセーブします。<br>
|
220
|
-
"""
|
203
|
+
title: <%= bm('.save_blockui_title') %>
|
204
|
+
message: <%= bm('.save_blockui_message') %>
|
205
|
+
notice: goog.getMsg(<%= bm('.save_blockui_notice') %>,
|
206
|
+
{ filename: sourceCode.get('filename') })
|
221
207
|
|
222
|
-
errorMsg = '
|
208
|
+
errorMsg = <%= bm('.save_error_message') %>
|
223
209
|
sourceCode.save2()
|
224
210
|
.then (data) ->
|
225
211
|
sourceCode.write()
|
226
212
|
.then (data) =>
|
227
213
|
@confirmOverwrite_.call @, data, sourceCode, ->
|
228
|
-
errorMsg = '
|
214
|
+
errorMsg = <%= bm('.save_canceled') %>
|
229
215
|
.then(@unblockUI, @unblockUI)
|
230
216
|
.done ->
|
231
217
|
Smalruby.savedFilename = sourceCode.get('filename')
|
232
218
|
window.changed = false
|
233
|
-
window.successMessage('
|
219
|
+
window.successMessage(<%= bm('.save_succeeded') %>)
|
234
220
|
.fail ->
|
235
221
|
window.errorMessage(errorMsg)
|
236
222
|
|
@@ -242,31 +228,24 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
242
228
|
sourceCode = @getSourceCode()
|
243
229
|
|
244
230
|
@blockUI
|
245
|
-
title:
|
246
|
-
|
247
|
-
|
248
|
-
"""
|
249
|
-
message: 'プログラムの文法をチェックしています。'
|
250
|
-
notice:
|
251
|
-
"""
|
252
|
-
このチェックは簡易的なものですので、<br>
|
253
|
-
プログラムを動かすとエラーが見つかるかもしれません。
|
254
|
-
"""
|
231
|
+
title: <%= bm('.check_blockui_title') %>
|
232
|
+
message: <%= bm('.check_blockui_message') %>
|
233
|
+
notice: <%= bm('.check_blockui_notice') %>
|
255
234
|
|
256
235
|
sourceCode.check()
|
257
236
|
.then (data) ->
|
258
237
|
if data.length == 0
|
259
|
-
window.successMessage('
|
238
|
+
window.successMessage(<%= bm('.check_succeeded') %>, <%= bm('.check_succeeded_notice') %>)
|
260
239
|
else
|
261
240
|
for errorInfo in data
|
262
241
|
do (errorInfo) ->
|
263
|
-
msg = "#{errorInfo.row}
|
242
|
+
msg = "#{errorInfo.row}#{<%= bm('.common_lines') %>}"
|
264
243
|
if errorInfo.column > 0
|
265
|
-
msg += "
|
244
|
+
msg += "#{<%= bm('.common_comma') %>}#{errorInfo.column}#{<%= bm('.common_letters') %>}"
|
266
245
|
window.errorMessage(msg + ": #{errorInfo.message}")
|
267
246
|
.then(@unblockUI, @unblockUI)
|
268
247
|
.fail ->
|
269
|
-
errorMessage('
|
248
|
+
errorMessage(<%= bm('.check_error') %>)
|
270
249
|
|
271
250
|
onReset: (e) ->
|
272
251
|
e.preventDefault()
|
@@ -291,13 +270,17 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
291
270
|
})
|
292
271
|
.then(
|
293
272
|
(data) ->
|
273
|
+
Smalruby.username = null
|
294
274
|
$('#signin-button').show()
|
295
275
|
$('#signout-button').hide()
|
296
276
|
$('#username-label').text('')
|
297
277
|
$('#username-button').hide()
|
298
|
-
successMessage('
|
278
|
+
successMessage(<%= bm('.signout_succeeded') %>)
|
279
|
+
|
280
|
+
if Smalruby.isEnabled('must_signin')
|
281
|
+
Smalruby.Views.SigninModalView.render()
|
299
282
|
->
|
300
|
-
errorMessage('
|
283
|
+
errorMessage(<%= bm('.signout_error') %>)
|
301
284
|
)
|
302
285
|
|
303
286
|
onUsername: (e) ->
|
@@ -358,7 +341,8 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
358
341
|
confirmOverwrite_: (data, sourceCode, canceled = $.noop) ->
|
359
342
|
if data.source_code.error
|
360
343
|
if sourceCode.get('filename') == Smalruby.savedFilename ||
|
361
|
-
confirm(
|
344
|
+
confirm(goog.getMsg(<%= bm('.common_confirm_overwrite') %>,
|
345
|
+
{ filename: sourceCode.get('filename') }))
|
362
346
|
sourceCode.write(true)
|
363
347
|
else
|
364
348
|
canceled.call()
|
@@ -366,7 +350,8 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
366
350
|
|
367
351
|
load: (info) ->
|
368
352
|
if info.error
|
369
|
-
window.errorMessage(
|
353
|
+
window.errorMessage(goog.getMsg(<%= bm('.load_error') %>,
|
354
|
+
{ filename: info.filename, error: info.error }))
|
370
355
|
else
|
371
356
|
clearMessages()
|
372
357
|
|
@@ -395,4 +380,4 @@ Smalruby.MainMenuView = Backbone.View.extend
|
|
395
380
|
# TODO: window.changed -> Smalruby.Models.SourceCode.changed
|
396
381
|
window.changed = false
|
397
382
|
Smalruby.changedAfterTranslating = true
|
398
|
-
window.successMessage('
|
383
|
+
window.successMessage(<%= bm('.load_succeeded') %>)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<%
|
2
|
+
require 'smalruby_editor'
|
3
|
+
require 'smalruby_editor/blockly_message_helper'
|
4
|
+
%>
|
5
|
+
|
6
|
+
# signin dialog view
|
7
|
+
Smalruby.SigninModalView = Backbone.View.extend
|
8
|
+
events:
|
9
|
+
'click #signin-modal-ok-button': 'onOk' # FIXME: 本当は#signin-modal .ok-buttonを指定したいができなかった
|
10
|
+
|
11
|
+
initialize: ->
|
12
|
+
Smalruby.ignoreEnterKey(@$el)
|
13
|
+
@$el.on 'shown', =>
|
14
|
+
@$el.find('#signin-modal-username')
|
15
|
+
.focus()
|
16
|
+
|
17
|
+
render: ->
|
18
|
+
@$el.find('#signin-modal-username')
|
19
|
+
.val($('#username-label').text())
|
20
|
+
@$el.modal
|
21
|
+
backdrop: 'static'
|
22
|
+
@$el.modal('show')
|
23
|
+
|
24
|
+
onOk: (e) ->
|
25
|
+
username = @$el.find('input[name=username]').val()
|
26
|
+
if $.trim(username).length > 0
|
27
|
+
$.post('/sessions/', { username: username })
|
28
|
+
.then(
|
29
|
+
(data) ->
|
30
|
+
Smalruby.username = data
|
31
|
+
$('#signin-button').hide()
|
32
|
+
$('#signout-button').show()
|
33
|
+
$('#username-label').text(data)
|
34
|
+
$('#username-button').show()
|
35
|
+
successMessage(<%= bm('.signed_in') %>)
|
36
|
+
new $.Deferred().resolve().promise()
|
37
|
+
->
|
38
|
+
errorMessage(<%= bm('.error') %>)
|
39
|
+
new $.Deferred().resolve().promise()
|
40
|
+
)
|
41
|
+
.done =>
|
42
|
+
if Smalruby.username != null || !Smalruby.isEnabled('must_signin')
|
43
|
+
@$el.modal('hide')
|
@@ -1,58 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
def hsv_to_rgb(h, s, v)
|
4
|
-
s /= 100.0
|
5
|
-
v /= 100.0
|
6
|
-
c = v * s
|
7
|
-
x = c * (1 - ((h / 60.0) % 2 - 1).abs)
|
8
|
-
m = v - c
|
9
|
-
r, g, b = *(
|
10
|
-
case
|
11
|
-
when h < 60 then [c, x, 0]
|
12
|
-
when h < 120 then [x, c, 0]
|
13
|
-
when h < 180 then [0, c, x]
|
14
|
-
when h < 240 then [0, x, c]
|
15
|
-
when h < 300 then [x, 0, c]
|
16
|
-
else [c, 0, x]
|
17
|
-
end
|
18
|
-
)
|
19
|
-
[r, g, b].map { |channel|
|
20
|
-
((channel + m) * 255).ceil
|
21
|
-
}.map { |c|
|
22
|
-
'%02x' % c
|
23
|
-
}.join
|
24
|
-
end
|
25
|
-
|
26
|
-
require 'smalruby_editor'
|
27
|
-
colors = SmalrubyEditor::COLORS
|
28
|
-
|
29
|
-
hues = [
|
30
|
-
colors[:motion],
|
31
|
-
colors[:looks],
|
32
|
-
colors[:sound],
|
33
|
-
colors[:pen],
|
34
|
-
colors[:data],
|
35
|
-
colors[:events],
|
36
|
-
colors[:control],
|
37
|
-
colors[:sensing],
|
38
|
-
colors[:operators],
|
39
|
-
colors[:etc],
|
40
|
-
]
|
41
|
-
|
42
|
-
colors = hues.map { |h|
|
43
|
-
[hsv_to_rgb(h, 100, 80), hsv_to_rgb(h, 100, 100)]
|
44
|
-
}
|
45
|
-
|
46
|
-
colors.each.with_index(1) do |(color, active_color), index|
|
47
|
-
%>
|
1
|
+
div.blocklyTreeRoot {
|
2
|
+
padding: 0;
|
48
3
|
|
49
|
-
div[aria-level="1"][aria-posinset="<%= index %>"] {
|
50
4
|
.blocklyTreeRow {
|
51
5
|
margin-bottom: 1px;
|
52
6
|
padding-top: 1px;
|
53
7
|
padding-bottom: 1px;
|
54
8
|
color: white;
|
55
|
-
background-color: #<%= color %> !important;
|
56
9
|
|
57
10
|
span.blocklyTreeIcon, span.blocklyTreeLabel {
|
58
11
|
font-size: 14px;
|
@@ -61,12 +14,5 @@ div[aria-level="1"][aria-posinset="<%= index %>"] {
|
|
61
14
|
|
62
15
|
.blocklyTreeRow.blocklyTreeSelected {
|
63
16
|
font-weight: bold;
|
64
|
-
background-color: #<%= active_color %> !important;
|
65
17
|
}
|
66
18
|
}
|
67
|
-
|
68
|
-
<% end %>
|
69
|
-
|
70
|
-
div.blocklyTreeRoot {
|
71
|
-
padding: 0;
|
72
|
-
}
|