diff --git a/app/assets/javascripts/dragdrop.js b/app/assets/javascripts/dragdrop.js index f25895e68a..a7dba36628 100644 --- a/app/assets/javascripts/dragdrop.js +++ b/app/assets/javascripts/dragdrop.js @@ -17,34 +17,26 @@ jQuery(function() { ); } - $('.dropzone').on('dragover',function(e) { - e.preventDefault(); - $('.dropzone').addClass('hover'); - }); - $('#side-dropzone').on('dragover',function(e) { - e.preventDefault(); - $('#side-dropzone').addClass('hover'); - }); - $('.dropzone').on('dragout',function(e) { - $('.dropzone').removeClass('hover'); - }); - $('#side-dropzone').on('dragout',function(e) { - $('#side-dropzone').removeClass('hover'); - }); - $('.dropzone').on('drop',function(e) { - const params = getEditorParams(e.target); // defined in editorHelper.js - e.preventDefault(); - if (params.hasOwnProperty('dSelected')) { - $D.selected = params['dSelected']; - } - $E.initialize(params); - }); - $('#side-dropzone').on('drop',function(e) { - e.preventDefault(); - }); - // these functions are also used on /wiki/edit and /wiki/new pages $('.dropzone').each(function() { + $(this).on('dragenter',function(e) { + e.preventDefault(); + $(e.currentTarget).addClass('hover'); + }); + + $(this).on('dragleave',function(e) { + $(e.currentTarget).removeClass('hover'); + }); + + $(this).on('drop',function(e) { + const params = getEditorParams(e.target); // defined in editorHelper.js + e.preventDefault(); + if (params.hasOwnProperty('dSelected')) { + $D.selected = params['dSelected']; + } + $E.initialize(params); + }); + $(this).fileupload({ url: "/images", paramName: "image[photo]", @@ -55,6 +47,7 @@ jQuery(function() { 'nid':$D.nid }, start: function(e) { + $(e.target).removeClass('hover'); // 'start' function runs: // 1. when user drag-and-drops image // 2. when user clicks on upload button. @@ -62,23 +55,17 @@ jQuery(function() { $D.selected = $(e.target).closest('div.comment-form-wrapper'); // the above line is redundant in drag & drop, because it's assigned in 'drop' listener too. // on /wiki/new & /wiki/edit, $D.selected will = undefined from this assignment - $('#imagebar .inline_image_drop').show(); - $('#create_progress').show(); - $('#create_uploading').show(); elem = $($D.selected).closest('div.comment-form-wrapper').eq(0); - elem.find('#create_progress').eq(0).show(); - elem.find('#create_uploading').eq(0).show(); - elem.find('#create_prompt').eq(0).hide(); - elem.find('.dropzone').eq(0).removeClass('hover'); + elem.find('.progress-bar-container').eq(0).show(); + elem.find('.uploading-text').eq(0).show(); + elem.find('.choose-one-prompt-text').eq(0).hide(); }, done: function (e, data) { - $('#create_progress').hide(); - $('#create_uploading').hide(); - $('#imagebar .inline_image_drop').hide(); elem = $($D.selected).closest('div.comment-form-wrapper').eq(0); - elem.find('#create_progress').hide(); - elem.find('#create_uploading').hide(); - elem.find('#create_prompt').show(); + elem.find('.progress-bar-container').hide(); + elem.find('.progress-bar').css('width', 0); + elem.find('.uploading-text').hide(); + elem.find('.choose-one-prompt-text').show(); var extension = data.result['filename'].split('.')[data.result['filename'].split('.').length - 1]; var file_url = data.result.url.split('?')[0]; var file_type; if (['gif', 'GIF', 'jpeg', 'JPEG', 'jpg', 'JPG', 'png', 'PNG'].includes(extension)) file_type = 'image' @@ -105,15 +92,27 @@ jQuery(function() { }, // see callbacks at https://github.com/blueimp/jQuery-File-Upload/wiki/Options - fileuploadfail: function(e,data) { + // fileuploadfail: function(e,data) { - }, + // }, progressall: function (e, data) { - return progressAll('#create_progress .progress-bar', data); + const closestProgressBar = $($D.selected).closest('div.comment-form-wrapper').find('.progress-bar').eq(0); + return progressAll(closestProgressBar, data); } }); }); + $('#side-dropzone').on('dragover',function(e) { + e.preventDefault(); + $('#side-dropzone').addClass('hover'); + }); + $('#side-dropzone').on('dragout',function(e) { + $('#side-dropzone').removeClass('hover'); + }); + $('#side-dropzone').on('drop',function(e) { + e.preventDefault(); + }); + $('#side-dropzone').fileupload({ url: "/images", paramName: "image[photo]", diff --git a/app/assets/stylesheets/editor.css b/app/assets/stylesheets/editor.css index c7b6d02024..cc6fd976a2 100644 --- a/app/assets/stylesheets/editor.css +++ b/app/assets/stylesheets/editor.css @@ -32,17 +32,17 @@ pre { background-color: #f5f5f5; border: 1px solid #ccc; border-radius: 4px; + } - // Account for some code outputs that place code tags in pre tags + /* Account for some code outputs that place code tags in pre tags */ code { - padding: 0; + padding: 0px; font-size: inherit; color: inherit; white-space: pre-wrap; background-color: transparent; border-radius: 0; } -} /* Adding the bug-btn stylings below, but they can be removed once the next version of the editor is released. */ @@ -142,7 +142,7 @@ version of the editor is released. */ } @media (max-width: 480px) { - #dropzone textarea { + .dropzone textarea { height:300px; } } @@ -151,7 +151,7 @@ version of the editor is released. */ margin-bottom:10px; } -#dropzone textarea { +.dropzone textarea { border-bottom:none; margin-bottom:0; -webkit-border-radius: 4px 4px 0 0; @@ -160,7 +160,7 @@ version of the editor is released. */ resize: vertical; } -#imagebar { +.imagebar { color: #aaa; border:1px solid #bbb; border-top:none; @@ -171,31 +171,28 @@ version of the editor is released. */ } @media (max-width: 768px) { - #imagebar { + .imagebar { width:100%; } } -#imagebar p { +.imagebar p { border-top:2px dotted #ddd; padding:8px 12px 0px; } -#dropzone.hover #imagebar { +.dropzone.hover .imagebar { background:#eee; } -#dropzone.hover textarea { - background:#f8f8f8; +.dropzone.hover textarea { + background:#f8f8f8 } -#imagebar .progress { - margin:10px; - width:30%; -} - -#dropzone.hover textarea { - background:#f8f8f8; +.imagebar .progress-bar-container { + margin: 10px; + width: 30%; + background-color: #aaa; } #side-progress { diff --git a/app/assets/stylesheets/question.css b/app/assets/stylesheets/question.css index 99b51a0742..fb314f7b3f 100644 --- a/app/assets/stylesheets/question.css +++ b/app/assets/stylesheets/question.css @@ -118,7 +118,6 @@ table th a:hover { visibility: hidden; } -.question-show textarea, .question-show pre { margin: 0; padding: 0; diff --git a/app/views/comments/_edit.html.erb b/app/views/comments/_edit.html.erb index 55ac41a49f..71196006a0 100644 --- a/app/views/comments/_edit.html.erb +++ b/app/views/comments/_edit.html.erb @@ -14,15 +14,15 @@
-
-