angieBabel / blockly

Automatically exported from code.google.com/p/blockly
0 stars 0 forks source link

Centering Dialogs and include titles #249

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,

Thanks for all the great work on Blockly!

I'm developing a programming game where the teacher can configure the missions 
available to his students. 

I´m proposing two modifications of the dialogs: their centralizing and adding 
text in the modal dialogs. My version of showDialog is below, and maybe you'll 
consider perform this modification in BlocklyApps.

BlocklyApps.showDialogEx = function(content, origin, animate, modal, centered,  

                                    title, style, disposeFunc) {
  ...
  // here is the same code of the original showDialog 
  ...
  if (modal) {

    ...
    // here is the same code of the original showDialog 
    ...
    header.id = 'dialogHeader';
    if (title != null)
        header.innerHTML = "<b>" + title + "</b>";

    ...
    // here is the same code of the original showDialog 
    ...
  }
  dialog.appendChild(content);
  content.className = content.className.replace('dialogHiddenContent', '');

  if (centered) {
     dialog.style['top'] =
         Math.max(0, ((window.innerHeight - dialog.clientHeight) / 2)) + "px";

     dialog.style['left'] =
         Math.max(0, ((window.innerWidth - dialog.clientWidth) / 2)) + "px";
  }
    ...
    // here is the same code of the original showDialog 
    ...
};

To reuse this code above, you can modify the original showDialog as:
BlocklyApps.showDialog = function(content, origin, animate, modal, style, 
disposeFunc) {
   BlocklyApps.showDialogEx(content, origin, animate, modal, false, null, style, disposeFunc);
}

Thanks,

Adilson

Original issue reported on code.google.com by adilson...@gmail.com on 10 Sep 2014 at 2:52

GoogleCodeExporter commented 8 years ago
BlocklyApps has been unwoven from Blockly and is no longer part of the package. 
 This code is now over at Blockly Games:
https://github.com/google/blockly-games/blob/master/appengine/js/lib-dialogs.js

However, note that using innerHTML leaves you vulnerable to XSS injection and 
security issues.  It is best to use createTextNode instead.

Original comment by neil.fra...@gmail.com on 9 Mar 2015 at 2:32