Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
544cdb94
Commit
544cdb94
authored
Jan 22, 2016
by
carlosperate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Blockly to allow easy replacement of window.prompt by async version.
parent
b26b7884
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
26 deletions
+64
-26
blockly/README.md
blockly/README.md
+5
-0
blockly/core/field_textinput.js
blockly/core/field_textinput.js
+1
-1
blockly/core/field_variable.js
blockly/core/field_variable.js
+30
-25
blockly/core/utils.js
blockly/core/utils.js
+28
-0
No files found.
blockly/README.md
View file @
544cdb94
...
@@ -15,6 +15,11 @@ It adds the following features:
...
@@ -15,6 +15,11 @@ It adds the following features:
*
Procedures core class modified to include the Arduino setup() and loop() functions
*
Procedures core class modified to include the Arduino setup() and loop() functions
*
Minor visual changes to the zoom icons positioning
*
Minor visual changes to the zoom icons positioning
The following features are planned to be push upstream (list will be updated as PR get accepted):
*
Fix toolbox XML nodes injected into blockly under IE (works on Chrome and Firefox)
*
Replaces window.prompt uses to a local version that can easily be replaced by an asynchronous HTML version
All other changes and fixes have been submitted to the original Blockly repository for inclusion into the upstream master branch.
All other changes and fixes have been submitted to the original Blockly repository for inclusion into the upstream master branch.
This fork gets frequent upstream pulls to maintain it up to date.
This fork gets frequent upstream pulls to maintain it up to date.
...
...
blockly/core/field_textinput.js
View file @
544cdb94
...
@@ -113,7 +113,7 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(opt_quietInput) {
...
@@ -113,7 +113,7 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(opt_quietInput) {
if
(
!
quietInput
&&
(
goog
.
userAgent
.
MOBILE
||
goog
.
userAgent
.
ANDROID
||
if
(
!
quietInput
&&
(
goog
.
userAgent
.
MOBILE
||
goog
.
userAgent
.
ANDROID
||
goog
.
userAgent
.
IPAD
))
{
goog
.
userAgent
.
IPAD
))
{
// Mobile browsers have issues with in-line textareas (focus & keyboards).
// Mobile browsers have issues with in-line textareas (focus & keyboards).
var
newValue
=
window
.
prompt
(
Blockly
.
Msg
.
CHANGE_VALUE_TITLE
,
this
.
text_
);
var
newValue
=
Blockly
.
prompt
(
Blockly
.
Msg
.
CHANGE_VALUE_TITLE
,
this
.
text_
);
if
(
this
.
sourceBlock_
&&
this
.
changeHandler_
)
{
if
(
this
.
sourceBlock_
&&
this
.
changeHandler_
)
{
var
override
=
this
.
changeHandler_
(
newValue
);
var
override
=
this
.
changeHandler_
(
newValue
);
if
(
override
!==
undefined
)
{
if
(
override
!==
undefined
)
{
...
...
blockly/core/field_variable.js
View file @
544cdb94
...
@@ -29,6 +29,7 @@ goog.provide('Blockly.FieldVariable');
...
@@ -29,6 +29,7 @@ goog.provide('Blockly.FieldVariable');
goog
.
require
(
'
Blockly.FieldDropdown
'
);
goog
.
require
(
'
Blockly.FieldDropdown
'
);
goog
.
require
(
'
Blockly.Msg
'
);
goog
.
require
(
'
Blockly.Msg
'
);
goog
.
require
(
'
Blockly.Variables
'
);
goog
.
require
(
'
Blockly.Variables
'
);
goog
.
require
(
'
Blockly.utils
'
);
goog
.
require
(
'
goog.string
'
);
goog
.
require
(
'
goog.string
'
);
...
@@ -159,9 +160,9 @@ Blockly.FieldVariable.dropdownCreate = function() {
...
@@ -159,9 +160,9 @@ Blockly.FieldVariable.dropdownCreate = function() {
* @this {!Blockly.FieldVariable}
* @this {!Blockly.FieldVariable}
*/
*/
Blockly
.
FieldVariable
.
dropdownChange
=
function
(
text
)
{
Blockly
.
FieldVariable
.
dropdownChange
=
function
(
text
)
{
function
promptName
(
promptText
,
defaultText
)
{
function
promptName
(
promptText
,
defaultText
,
callback
)
{
Blockly
.
hideChaff
();
Blockly
.
hideChaff
();
var
newVar
=
window
.
prompt
(
promptText
,
defaultText
);
var
newVar
=
Blockly
.
prompt
(
promptText
,
defaultText
,
function
(
newVar
)
{
// Merge runs of whitespace. Strip leading and trailing whitespace.
// Merge runs of whitespace. Strip leading and trailing whitespace.
// Beyond this, all names are legal.
// Beyond this, all names are legal.
if
(
newVar
)
{
if
(
newVar
)
{
...
@@ -172,26 +173,30 @@ Blockly.FieldVariable.dropdownChange = function(text) {
...
@@ -172,26 +173,30 @@ Blockly.FieldVariable.dropdownChange = function(text) {
newVar
=
null
;
newVar
=
null
;
}
}
}
}
return
newVar
;
callback
(
newVar
);
});
}
}
var
workspace
=
this
.
sourceBlock_
.
workspace
;
var
workspace
=
this
.
sourceBlock_
.
workspace
;
if
(
text
==
Blockly
.
Msg
.
RENAME_VARIABLE
)
{
if
(
text
==
Blockly
.
Msg
.
RENAME_VARIABLE
)
{
var
oldVar
=
this
.
getText
();
var
oldVar
=
this
.
getText
();
text
=
promptName
(
Blockly
.
Msg
.
RENAME_VARIABLE_TITLE
.
replace
(
'
%1
'
,
oldVar
),
promptName
(
Blockly
.
Msg
.
RENAME_VARIABLE_TITLE
.
replace
(
'
%1
'
,
oldVar
),
oldVar
);
oldVar
,
function
(
text
)
{
if
(
text
)
{
if
(
text
)
{
Blockly
.
Variables
.
renameVariable
(
oldVar
,
text
,
workspace
);
Blockly
.
Variables
.
renameVariable
(
oldVar
,
text
,
workspace
);
}
}
});
return
null
;
return
null
;
}
else
if
(
text
==
Blockly
.
Msg
.
NEW_VARIABLE
)
{
}
else
if
(
text
==
Blockly
.
Msg
.
NEW_VARIABLE
)
{
text
=
promptName
(
Blockly
.
Msg
.
NEW_VARIABLE_TITLE
,
''
);
/*promptName(Blockly.Msg.NEW_VARIABLE_TITLE, '', function(text) {
// Since variables are case-insensitive, ensure that if the new variable
// Since variables are case-insensitive, ensure that if the new variable
// matches with an existing variable, the new case prevails throughout.
// matches with an existing variable, the new case prevails throughout.
if (text) {
if (text) {
Blockly.Variables.renameVariable(text, text, workspace);
Blockly.Variables.renameVariable(text, text, workspace);
return
text
;
//TODO: need to add here what too do with the newly created variable
}
}
return
null
;
});*/
//TODO: this return variable needs to be made redundant
return
Blockly
.
Variables
.
generateUniqueName
(
workspace
);
}
}
return
undefined
;
return
undefined
;
};
};
blockly/core/utils.js
View file @
544cdb94
...
@@ -591,3 +591,31 @@ Blockly.genUid.crypto_ = this.crypto;
...
@@ -591,3 +591,31 @@ Blockly.genUid.crypto_ = this.crypto;
*/
*/
Blockly
.
genUid
.
soup_
=
'
!#$%()*+,-./:;=?@[]^_`{|}~
'
+
Blockly
.
genUid
.
soup_
=
'
!#$%()*+,-./:;=?@[]^_`{|}~
'
+
'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
'
;
'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
'
;
/**
* Local prompt function created to allow blockly developers to overwrite it
* with a customised version. This version uses the default window.prompt
* functionality, but it has been designed to be easily replaced by an
* asynchronous HTML based prompt.
* @param {string} message Main text message for the window prompt.
* @param {string=} opt_defaultInput Input string to be displayed by default.
* @param {function=} opt_callback Optional function callback to process the
* user input.
* @return {undefined|null|string} If no callback is provided it returns the
* value directly from window.prompt (null or string), otherwise it
* returns undefined.
*/
Blockly
.
prompt
=
function
(
message
,
opt_defaultInput
,
opt_callback
)
{
if
(
opt_callback
===
undefined
)
{
// If no callback provided to revert back to the normal blockly prompt
return
window
.
prompt
(
message
,
opt_defaultInput
);
}
else
{
// window.prompt still a blocking function, but returns value via callback
if
(
typeof
opt_callback
==
'
function
'
)
{
opt_callback
(
window
.
prompt
(
message
,
opt_defaultInput
));
}
else
{
console
.
log
(
'
Blocky prompt callback needs to be a callable function.
'
);
}
}
return
undefined
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment