-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from portabilis/portabilis-patch-2022-04-01
Portabilis patch 01/04/2022
- Loading branch information
Showing
197 changed files
with
2,009 additions
and
643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
app/assets/javascripts/views/descriptive_exams/functions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,68 @@ | ||
function createSummerNote(element, options = {}) { | ||
$(element).summernote({ | ||
lang: 'pt-BR', | ||
toolbar: options.toolbar || [], | ||
disableDragAndDrop : true, | ||
callbacks : { | ||
onPaste : function (event) { | ||
var thisNote = $(this); | ||
var updatePastedText = function(someNote){ | ||
var original = someNote.summernote('code'); | ||
var cleaned = CleanPastedHTML(original); | ||
|
||
someNote.summernote('code', cleaned); | ||
}; | ||
|
||
setTimeout(function () { | ||
updatePastedText(thisNote); | ||
}, 10); | ||
} | ||
} | ||
}); | ||
|
||
if (options.disabled) { | ||
$(element).each(function(index, el) { | ||
$(el).summernote('disable'); | ||
}) | ||
} | ||
} | ||
|
||
function CleanPastedHTML(input) { | ||
var stringStripper = /(\n|\r| class=(")?Mso[a-zA-Z] (")?)/g; | ||
var output = input.replace(stringStripper, ' '); | ||
var commentSripper = new RegExp('<!--(.*?)-->','g'); | ||
var output = output.replace(commentSripper, ''); | ||
var tagStripper = new RegExp('<(/)*(meta|link|span|\\?xml:|st1:|o:|font)(.*?)>','gi'); | ||
output = output.replace(tagStripper, ''); | ||
var badTags = getTags(output) | ||
for (var i=0; i< badTags.length; i ) { | ||
tagStripper = new RegExp('<' badTags[i] '.*?' badTags[i] '(.*?)>', 'gi'); | ||
output = output.replace(tagStripper, ''); | ||
} | ||
var badAttributes = ['style', 'start']; | ||
for (var i=0; i< badAttributes.length; i ) { | ||
var attributeStripper = new RegExp(' ' badAttributes[i] '="(.*?)"','gi'); | ||
output = output.replace(attributeStripper, ''); | ||
} | ||
|
||
return output; | ||
} | ||
|
||
function getTags(htmlString){ | ||
var tmpTag = document.createElement("div"); | ||
tmpTag.innerHTML = htmlString; | ||
|
||
var all = tmpTag.getElementsByTagName("*"); | ||
var goodTags = ['DIV', 'P', 'B', 'I', 'U', 'BR']; | ||
var tags = []; | ||
|
||
for (var i = 0, max = all.length; i < max; i ) { | ||
var tagname = all[i].tagName; | ||
|
||
if (tags.indexOf(tagname) == -1 && !goodTags.includes(tagname)) { | ||
tags.push(tagname); | ||
} | ||
} | ||
|
||
return tags | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,3 @@ | ||
$(function () { | ||
createSummerNote("textarea[id^=descriptive_exam_students_attributes_]", { disabled: true }) | ||
}); |
70 changes: 3 additions & 67 deletions
70
app/assets/javascripts/views/descriptive_exams/student_fields.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 1,9 @@ | ||
$(function () { | ||
$('textarea[maxLength]').maxlength(); | ||
|
||
$("textarea[id^=descriptive_exam_students_attributes_]").summernote({ | ||
lang: 'pt-BR', | ||
createSummerNote("textarea[id^=descriptive_exam_students_attributes_]", { | ||
toolbar: [ | ||
['font', ['bold', 'italic', 'underline', 'clear']], | ||
], | ||
disableDragAndDrop : true, | ||
callbacks : { | ||
onPaste : function (event) { | ||
var thisNote = $(this); | ||
var updatePastedText = function(someNote){ | ||
var original = someNote.summernote('code'); | ||
var cleaned = CleanPastedHTML(original); | ||
|
||
someNote.summernote('code', cleaned); | ||
}; | ||
|
||
setTimeout(function () { | ||
//the function is called after the text is really pasted. | ||
updatePastedText(thisNote); | ||
}, 10); | ||
} | ||
} | ||
}); | ||
|
||
function CleanPastedHTML(input) { | ||
// 1. remove line breaks / Mso classes | ||
var stringStripper = /(\n|\r| class=(")?Mso[a-zA-Z] (")?)/g; | ||
var output = input.replace(stringStripper, ' '); | ||
// 2. strip Word generated HTML comments | ||
var commentSripper = new RegExp('<!--(.*?)-->','g'); | ||
var output = output.replace(commentSripper, ''); | ||
var tagStripper = new RegExp('<(/)*(meta|link|span|\\?xml:|st1:|o:|font)(.*?)>','gi'); | ||
// 3. remove tags leave content if any | ||
output = output.replace(tagStripper, ''); | ||
// 4. Remove everything in between and including tags '<style(.)style(.)>' | ||
var badTags = getTags(output) | ||
// remove all tags except ['DIV', 'P', 'B', 'I', 'U', 'BR']; | ||
for (var i=0; i< badTags.length; i ) { | ||
tagStripper = new RegExp('<' badTags[i] '.*?' badTags[i] '(.*?)>', 'gi'); | ||
output = output.replace(tagStripper, ''); | ||
} | ||
// 5. remove attributes ' style="..."' | ||
var badAttributes = ['style', 'start']; | ||
for (var i=0; i< badAttributes.length; i ) { | ||
var attributeStripper = new RegExp(' ' badAttributes[i] '="(.*?)"','gi'); | ||
output = output.replace(attributeStripper, ''); | ||
} | ||
|
||
return output; | ||
} | ||
|
||
function getTags(htmlString){ | ||
var tmpTag = document.createElement("div"); | ||
tmpTag.innerHTML = htmlString; | ||
|
||
var all = tmpTag.getElementsByTagName("*"); | ||
var goodTags = ['DIV', 'P', 'B', 'I', 'U', 'BR']; | ||
var tags = []; | ||
|
||
for (var i = 0, max = all.length; i < max; i ) { | ||
var tagname = all[i].tagName; | ||
|
||
if (tags.indexOf(tagname) == -1 && !goodTags.includes(tagname)) { | ||
tags.push(tagname); | ||
} | ||
} | ||
|
||
return tags | ||
} | ||
] | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,11 @@ | ||
$(document).ready(function() { | ||
'use strict'; | ||
|
||
let flashMessages = new FlashMessages(), | ||
redirect_link_report_card = Routes.teacher_report_cards_pt_br_path(), | ||
redirect_link_conceptual_exams = Routes.conceptual_exams_pt_br_path(), | ||
redirect_link_descriptive_exams = Routes.new_descriptive_exam_pt_br_path(), | ||
message = `O <b>Registros de avaliações numéricas</b> apresentará somente as notas lançadas nos diários de avaliação e recuperações numéricas. Para conferência de notas conceituais e/ou descritivas acessar, respectivamente, o <a href="${redirect_link_report_card}"><b>Boletim do professor</b></a> ou as telas de <a href="${redirect_link_conceptual_exams}"><b>Diário de avaliações conceituais</b></a> e <a href="${redirect_link_descriptive_exams}"><b>Avaliações descritivas</b></a>.`; | ||
|
||
flashMessages.info(message); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.