2017-05-07 22:09:04 +02:00
|
|
|
###
|
|
|
|
@licstart The following is the entire license notice for the JavaScript code in this page.
|
|
|
|
|
|
|
|
frTypo, la typographie française simplifiée
|
|
|
|
|
|
|
|
Copyright (C) 2013 acoeuro
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
@licend The above is the entire license notice for the JavaScript code in this page.
|
|
|
|
###
|
|
|
|
|
2017-10-02 16:36:20 +02:00
|
|
|
# La forme principale pour gérer les ponctuations hautes après une lettre,
|
|
|
|
# ou en début de nœud html,
|
|
|
|
# et qui peut contenir des espaces
|
2017-10-07 18:52:15 +02:00
|
|
|
regexp = /(^|[\wàéèêç])\s*([!?:;»%€¢]+)(\s|[^\w\/]|$)/g
|
2017-10-02 16:36:20 +02:00
|
|
|
|
|
|
|
regexpPost = /([«])\s*([\w])/g
|
|
|
|
|
2017-10-07 18:52:15 +02:00
|
|
|
$(document).on 'turbolinks:load', ->
|
2017-05-07 22:09:04 +02:00
|
|
|
if $('html').attr('lang') == 'fr'
|
|
|
|
# Ne devrait s'appliquer qu'à une page en français
|
|
|
|
$('body *').contents().filter ->
|
|
|
|
this.nodeType == Node.TEXT_NODE
|
|
|
|
|
|
|
|
.filter ->
|
|
|
|
# Supprime les éléments pouvant utiliser des ponctuations sans nécessiter
|
|
|
|
# un espacement
|
2019-09-15 14:15:30 +02:00
|
|
|
0 > ['CODE', 'PRE', 'STYLE', 'TEXTAREA'].indexOf this.parentNode.tagName
|
2017-05-07 22:09:04 +02:00
|
|
|
|
2017-10-07 18:52:15 +02:00
|
|
|
.filter ->
|
2017-10-08 00:49:59 +02:00
|
|
|
!$(this).parent().hasClass('finePre') &&
|
|
|
|
!$(this).parent().hasClass('start_time') &&
|
|
|
|
!$(this).parent().hasClass('end_time')
|
2017-10-07 18:52:15 +02:00
|
|
|
|
2017-05-07 22:09:04 +02:00
|
|
|
.filter ->
|
|
|
|
this.nodeValue.match(regexp)? || this.nodeValue.match(regexpPost)?
|
|
|
|
|
|
|
|
.each ->
|
|
|
|
$(this).replaceWith ->
|
|
|
|
this.nodeValue
|
|
|
|
.replace(regexp, '$1<span class="finePre">$2</span>$3')
|
|
|
|
.replace(regexpPost, '<span class="finePost">$1</span>$2')
|