Skip to content

Commit

Permalink
v1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
fontainejp committed Jan 6, 2020
1 parent f543b37 commit e9c7057
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 170 deletions.
4 changes: 2 additions & 2 deletions ffau.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ window.addEventListener('load', function load(event) {
if (localStorage.getItem('contentHTML')=="on") {
ffau.clearWorkspace()
} else {
editor.setValue('<!DOCTYPE HTML>\n<html lang="fr">\n <head>\n <meta charset="utf-8">\n <link rel="stylesheet" href="css/bootstrap.min.3.3.6.css">\n <link rel="stylesheet" href="css/fontawesome.css">\n </head>\n <body>\n\n </body>\n</html>',1)
editor.setValue('<!DOCTYPE HTML>\n<html lang="fr">\n <head>\n <meta charset="utf-8">\n </head>\n <body>\n\n </body>\n</html>',1)
}
})
$('#btn_search').on('click', function(){
Expand Down Expand Up @@ -212,7 +212,7 @@ window.addEventListener('load', function load(event) {
}
})
$('#codeORblock').on("change", function(){
var data = '<!DOCTYPE HTML>\n<html lang="fr">\n <head>\n <meta charset="utf-8">\n <link rel="stylesheet" href="css/bootstrap.min.3.3.6.css">\n <link rel="stylesheet" href="css/fontawesome.css">\n </head>\n <body>\n'+document.getElementById('blockly_r').innerHTML+' </body>\n</html>'
var data = document.getElementById('blockly_r').srcdoc
if (localStorage.getItem('contentHTML')=="on") {
if (localStorage.getItem('size')) {
document.getElementById('content_code').style.fontSize = localStorage.getItem('size')
Expand Down
114 changes: 44 additions & 70 deletions www/blocs&generateurs/ffau/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,6 @@ function CSSEscape(input) {
function isNewTabUrl(input) {
return URLRegex.test(input) || (!input.includes('http://') && !input.includes('https://')) && !hashRegex.test(input) && input.length > 0;
}
// CSS file
Blockly.Blocks['css'] = {
init: function () {
this.jsonInit({
"message0": '<CSS> %1 %2 </CSS>',
"args0": [
{
"type": "input_dummy"
},
{
"type": "input_statement",
"name": "content",
"check": "style"
}
],
"colour": 290
});
}
};
Blockly.html['css'] = function (block) {
var statement = Blockly.html.statementToCode(block, 'content');
return '';
};
// Style
Blockly.Blocks['style'] = {
init: function () {
Expand All @@ -78,9 +55,7 @@ Blockly.Blocks['style'] = {
],
"previousStatement": "header",
"nextStatement": "header",
"colour": 290,
"tooltip": "Style tag",
"helpUrl": "https://www.w3schools.com/tags/tag_style.asp"
"colour": 290
});
}
};
Expand All @@ -106,9 +81,7 @@ Blockly.Blocks['stylearg'] = {
],
"previousStatement": "args",
"nextStatement": "args",
"colour": 290,
"tooltip": "Style modifier",
"helpUrl": "https://www.w3schools.com/css/css_howto.asp"
"colour": 290
});
}
};
Expand Down Expand Up @@ -148,11 +121,38 @@ Blockly.html['cssitem'] = function (block) {
var stmt = Blockly.html.statementToCode(block, 'content');
var mod = Blockly.html.statementToCode(block, 'modifier', Blockly.html.ORDER_ATOMIC);
mod = mod.split(' ').join(''); // remove spaces

var selector = CSSEscape(block.getFieldValue('selector'));

return selector + mod + '{\n' + stmt + '}\n';
};
//Other tag
Blockly.Blocks['othercss'] = {
init: function() {
this.jsonInit({
"message0": '%1 : %2 ;',
"args0": [
{
"type": "field_input",
"name": "property",
"text": "property"
},
{
"type": "field_input",
"name": "value",
"text": "value"
}
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290
});
}
};
Blockly.html['othercss'] = function(block){
var property = block.getFieldValue('property');
var value = block.getFieldValue('value');
var code = property+': '+value+';\n';
return code;
};
// Font-family
Blockly.Blocks['fontfamily'] = {
init: function () {
Expand All @@ -167,9 +167,7 @@ Blockly.Blocks['fontfamily'] = {
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290,
"tooltip": "CSS font-family",
"helpUrl": "https://www.w3schools.com/cssref/pr_font_font-family.asp"
"colour": 290
});
}
};
Expand All @@ -191,9 +189,7 @@ Blockly.Blocks['fontsize'] = {
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290,
"tooltip": "CSS font-size",
"helpUrl": "https://www.w3schools.com/cssref/pr_font_font-size.asp"
"colour": 290
});
}
};
Expand Down Expand Up @@ -240,9 +236,7 @@ Blockly.Blocks['fontweight'] = {
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290,
"tooltip": "Font-weight CSS property",
"helpUrl": "https://www.w3schools.com/cssref/pr_font_weight.asp"
"colour": 290
});
}
};
Expand Down Expand Up @@ -286,9 +280,7 @@ Blockly.Blocks['margin'] = {
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290,
"tooltip": "CSS Margin",
"helpUrl": "https://www.w3schools.com/cssref/pr_margin.asp"
"colour": 290
});
}
};
Expand Down Expand Up @@ -333,9 +325,7 @@ Blockly.Blocks['padding'] = {
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290,
"tooltip": "CSS Padding",
"helpUrl": "https://www.w3schools.com/cssref/pr_padding.asp"
"colour": 290
});
}
};
Expand Down Expand Up @@ -365,9 +355,7 @@ Blockly.Blocks['texttransform'] = {
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290,
"tooltip": "CSS Text-transform",
"helpUrl": "https://www.w3schools.com/cssref/pr_text_text-transform.asp"
"colour": 290
});
}
};
Expand All @@ -394,9 +382,7 @@ Blockly.Blocks['textalign'] = {
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290,
"tooltip": "CSS Text-align",
"helpUrl": "https://www.w3schools.com/cssref/pr_text_text-align.asp"
"colour": 290
})
}
};
Expand All @@ -418,9 +404,7 @@ Blockly.Blocks['bgcolor-new'] = {
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290,
"tooltip": "CSS Background-Color",
"helpUrl": "https://www.w3schools.com/css/css_background.asp"
"colour": 290
});
}
};
Expand Down Expand Up @@ -646,9 +630,7 @@ Blockly.Blocks['widthheightnum'] = {
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290,
"tooltip": "CSS Width/height",
"helpUrl": "https://www.w3schools.com/css/css_dimension.asp"
"colour": 290
});
}
};
Expand Down Expand Up @@ -678,9 +660,7 @@ Blockly.Blocks['float'] = {
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290,
"tooltip": "Float an element left or right",
"helpUrl": "https://www.w3schools.com/cssref/pr_class_float.asp"
"colour": 290
});
}
};
Expand Down Expand Up @@ -742,9 +722,7 @@ Blockly.Blocks['verticalalign'] = {
],
"previousStatement": "stylecontent",
"nextStatement": "stylecontent",
"colour": 290,
"tooltip": "Vertical-align CSS property",
"helpUrl": "https://www.w3schools.com/cssref/pr_pos_vertical-align.asp"
"colour": 290
})
}
};
Expand Down Expand Up @@ -787,9 +765,7 @@ Blockly.Blocks['hex_picker'] = {
}
],
"output": "color",
"colour": 290,
"tooltip": "HTML HEX color picker",
"helpUrl": "https://www.w3schools.com/html/html_colors.asp"
"colour": 290
});
}
};
Expand Down Expand Up @@ -859,9 +835,7 @@ Blockly.Blocks['color_picker'] = {
}
],
"output": "color",
"colour": 290,
"tooltip": "HTML color picker",
"helpUrl": "https://www.w3schools.com/html/html_colors.asp"
"colour": 290
});
}
};
Expand Down
139 changes: 52 additions & 87 deletions www/blocs&generateurs/ffau/html.js

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions www/ffau.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
<li role="presentation" class="active"><a href="#blocklyDiv" aria-controls="blocklyDiv" role="tab" data-toggle="tab"></a></li>
<li role="presentation"><a href="#content_code" aria-controls="content_code" role="tab" data-toggle="tab"></a></li>
</ul>
<input type="file" id="loadText" accept=".www, .html" style="display:none">
<div id="header">
<div id="btn_left">
<input id="codeORblock" checked data-toggle="toggle" data-onstyle="default" data-on="<img src='media/icon.png' style='height:20px'>" data-off="<i class='fa fa-code fa-1_5x'></i>" type="checkbox">
</div>
<div id="btn_center" class="btn-toolbar">
<input type="file" id="loadText" accept=".www, .html" style="display:none">
<div class="btn-group">
<button id="btn_new" class="btn btn-default"><i class="fa fa-file fa-1_5x btn_color"></i></button>
<div class="btn-group">
Expand Down Expand Up @@ -83,7 +83,7 @@
<div role="tabpanel" id="blocklyDiv" class="tab-pane fade in active" style="position: relative;"></div>
<div role="tabpanel" id="content_code" class="tab-pane fade" onChange="update()"></div>
</div>
<div id="blockly_r"></div>
<iframe id="blockly_r" style="border-top:none"></iframe>
</div>
<!-- modal -->
<div class="modal fade" id="configModal" tabindex="-1" role="dialog" aria-labelledby="configModalLabel" aria-hidden="true">
Expand Down Expand Up @@ -396,10 +396,16 @@
</div>
<xml id="toolbox" style="display:none">
<category colour="210" name="Structure">
<block type="base"></block>
<block type="html"></block>
<block type="head"></block>
<block type="title"></block>
<block type="bootstrap"></block>
<block type="fontawesome"></block>
<block type="body"></block>
<block type="divider"></block>
<block type="linebreak"></block>
<block type="hline"></block>
<block type="base"></block>
</category>
<category colour="65" name="Texte">
<block type="emptytext"></block>
Expand Down Expand Up @@ -452,10 +458,10 @@
<block type="emptyarg"></block>
</category>
<category colour="290" name="CSS">
<block type="css"></block>
<block type="style"></block>
<block type="stylearg"></block>
<block type="cssitem"></block>
<block type="othercss"></block>
<category colour="290" name="Texte">
<block type="fontsize"></block>
<block type="fontweight"></block>
Expand Down Expand Up @@ -499,7 +505,7 @@
})
function update(){
var ace = editor.getValue();
document.getElementById("blockly_r").innerHTML = ace
document.getElementById("blockly_r").srcdoc = ace
}
require('../resources/app/ffau.js')
</script>
Expand Down
14 changes: 8 additions & 6 deletions www/js/ffau/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,8 @@ class Ffau {
// add listener to workspace
this.ffauWorkspace.addChangeListener(function () {
// generate the code using Blockly.html from generator.js
let code = Blockly.html.workspaceToCode(this.ffauWorkspace);
// if iframe has been initialised
if (this.iframe) {
this.iframe.src = "data:text/html;charset=utf-8," + encodeURIComponent(code);
}
document.getElementById('blockly_r').innerHTML = code;
var code = Blockly.html.workspaceToCode(this.ffauWorkspace);
document.getElementById('blockly_r').srcdoc = code;
}.bind(this) /* bind parent scope */);
}
/**
Expand Down Expand Up @@ -218,9 +214,15 @@ class Ffau {
a.click();
}
}
/**
* To reverse your last action
*/
undo() {
this.ffauWorkspace.undo(0);
}
/**
* To reverse your last Undo
*/
redo() {
this.ffauWorkspace.undo(1);
}
Expand Down

0 comments on commit e9c7057

Please sign in to comment.