Commit 97d916c2 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review
Browse files

Fix IE issue when adding a blocktype (Bug 1341413)



The dynamic change of an input element from type=radio to type hidden
caused its value set to "" in IE.
It would be better to just hiding it instead of changing its type.

Change-Id: Id6a86f2e9a4bba2f2988e7fcbc3fac8f3d8468a2
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent 12496549
...@@ -103,14 +103,9 @@ ...@@ -103,14 +103,9 @@
$(this).remove(); $(this).remove();
}); });
// Remove radio buttons for moving block types into place // Hide radio buttons for moving block types into place
$('#content-editor input.blocktype-radio').each(function() { $('#content-editor input.blocktype-radio').each(function() {
if (ViewManager.isIE6 || ViewManager.isIE7 || ViewManager.isIE8) { $(this).hide();
$(this).hide();
}
else {
$(this).get(0).type = 'hidden';
}
}); });
// Remove the a href links that are needed for when js is turned off // Remove the a href links that are needed for when js is turned off
...@@ -405,11 +400,10 @@ ...@@ -405,11 +400,10 @@
function makeNewBlocksDraggable() { function makeNewBlocksDraggable() {
$('.blocktype-list div.blocktype').each(function() { $('.blocktype-list div.blocktype').each(function() {
$(this).find('.blocktypelink').off('click keydown'); // remove old event handlers $(this).find('.blocktypelink').off('mousedown keydown'); // remove old event handlers
$(this).find('.blocktypelink').on('click keydown', function(e) { $(this).find('.blocktypelink').on('mousedown keydown', function(e) {
var keyCode = $.ui.keyCode;
// Add a block when click left button or press 'Space bar' or 'Enter' key // Add a block when click left button or press 'Space bar' or 'Enter' key
if (((e.type == 'click' && e.button == 0) || e.keyCode == keyCode.SPACE || e.keyCode == keyCode.ENTER) && ($('#addblock').is(':hidden'))) { if (isHit(e) && $('#addblock').is(':hidden')) {
startAddBlock($(this)); startAddBlock($(this));
} }
}); });
...@@ -441,13 +435,13 @@ ...@@ -441,13 +435,13 @@
*/ */
function keytabbinginadialog(dialog, firstelement, lastelement) { function keytabbinginadialog(dialog, firstelement, lastelement) {
firstelement.keydown(function(e) { firstelement.keydown(function(e) {
if (e.keyCode === 9 && e.shiftKey) { if (e.keyCode === $j.ui.keyCode.TAB && e.shiftKey) {
lastelement.focus(); lastelement.focus();
e.preventDefault(); e.preventDefault();
} }
}); });
lastelement.keydown(function(e) { lastelement.keydown(function(e) {
if (e.keyCode === 9 && !e.shiftKey) { if (e.keyCode === $j.ui.keyCode.TAB && !e.shiftKey) {
firstelement.focus(); firstelement.focus();
e.preventDefault(); e.preventDefault();
} }
...@@ -899,13 +893,9 @@ ...@@ -899,13 +893,9 @@
forEach(getElementsByTagAndClassName('input', 'blocktype-radio', 'top-pane'), function(i) { forEach(getElementsByTagAndClassName('input', 'blocktype-radio', 'top-pane'), function(i) {
setNodeAttribute(i, 'style', 'display:inline'); setNodeAttribute(i, 'style', 'display:inline');
}); });
// Remove radio buttons for moving block types into place // Hide radio buttons for moving block types into place
$('#top-pane input.blocktype-radio').each(function() { $('#top-pane input.blocktype-radio').each(function() {
//$(this).attr('type', 'hidden'); // not allowed in jquery $(this).hide();
$(this).get(0).type = 'hidden'; // TODO need to test this across browsers
if (ViewManager.isIE7 || ViewManager.isIE6) {
$(this).hide();
}
}); });
} }
else { else {
...@@ -1014,7 +1004,7 @@ ...@@ -1014,7 +1004,7 @@
* return true if the mousedown is <LEFT BUTTON> or the keydown is <Space> or <Enter> * return true if the mousedown is <LEFT BUTTON> or the keydown is <Space> or <Enter>
*/ */
function isHit(e) { function isHit(e) {
return (e.which == 1 || e.button == 11 || e.keyCode == 13 || e.keyCode == 32); return (e.which === 1 || e.button === 1 || e.keyCode === $j.ui.keyCode.SPACE || e.keyCode === $j.ui.keyCode.ENTER);
} }
/* /*
* Initialises the dialog used to add and move blocks * Initialises the dialog used to add and move blocks
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment