This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resilves: #3 add support for Hebrew language delete jquery
- Loading branch information
Showing
5 changed files
with
50 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,35 @@ | ||
/*! | ||
* automatic Direction v1.2 | ||
* automatic Direction v1.3 | ||
* By Milad Dehghan (http://dehghan.net) | ||
* github: https://github.com/miladd3/automatic-direction | ||
*/ | ||
window.addEventListener('load', function() { | ||
var elements = [].slice.call(document.querySelectorAll('.dir-auto')); | ||
|
||
var elements = [].slice.call(document.querySelectorAll('.dir-auto')); | ||
elements.forEach(function(el) { | ||
var farsiCountNode = el.parentNode.querySelector('.count-f'), | ||
latinCountNode = el.parentNode.querySelector('.count-e'), | ||
hebrewCountNode = el.parentNode.querySelector('.count-h'), | ||
countNode = el.parentNode.querySelector('.count-all'); | ||
|
||
elements.forEach(function(el) { | ||
var farsiCountNode = el.parentNode.querySelector('.count-f'), | ||
latinCountNode = el.parentNode.querySelector('.count-e'), | ||
countNode = el.parentNode.querySelector('.count-all'); | ||
|
||
el.addEventListener('keyup', function(e) { | ||
var value = e.target.value, | ||
farsiChars = value.match(/[\u0600-\u06FF]/g), | ||
spaceChars = value.match(/\s/g), | ||
count = value.length, | ||
farsiCount = farsiChars ? farsiChars.length : 0, | ||
el.addEventListener('keyup', function(e) { | ||
var value = e.target.value, | ||
farsiChars = value.match(/[\u0600-\u06FF]/g), | ||
hebrewChars = value.match(/[\u0590-\u05FF]/g), | ||
spaceChars = value.match(/\s/g), | ||
count = value.length, | ||
farsiCount = farsiChars ? farsiChars.length : 0, | ||
hebrewCount = hebrewChars ? hebrewChars.length : 0, | ||
spaceCount = spaceChars ? spaceChars.length : 0, | ||
latinCount = count - farsiCount - spaceCount; | ||
|
||
e.target.setAttribute('dir', (farsiCount > latinCount) ? 'rtl' : 'ltr'); | ||
rtlCount = farsiCount + hebrewCount; | ||
latinCount = count - farsiCount - spaceCount - hebrewCount; | ||
|
||
if(farsiCountNode) farsiCountNode.innerHTML = farsiCount; | ||
if(latinCountNode) latinCountNode.innerHTML = latinCount; | ||
if(countNode) countNode.innerHTML = count; | ||
}); | ||
}); | ||
e.target.setAttribute('dir', rtlCount > latinCount ? 'rtl' : 'ltr'); | ||
|
||
if (farsiCountNode) farsiCountNode.innerHTML = farsiCount; | ||
if (latinCountNode) latinCountNode.innerHTML = latinCount; | ||
if (hebrewCountNode) hebrewCountNode.innerHTML = hebrewCount; | ||
if (countNode) countNode.innerHTML = count; | ||
}); | ||
}); | ||
}); |
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,32 +1,35 @@ | ||
/*! | ||
* automatic Direction v1.2 | ||
* automatic Direction v1.3 | ||
* By Milad Dehghan (http://dehghan.net) | ||
* github: https://github.com/miladd3/automatic-direction | ||
*/ | ||
window.addEventListener('load', function() { | ||
var elements = [].slice.call(document.querySelectorAll('.dir-auto')); | ||
|
||
var elements = [].slice.call(document.querySelectorAll('.dir-auto')); | ||
elements.forEach(function(el) { | ||
var farsiCountNode = el.parentNode.querySelector('.count-f'), | ||
latinCountNode = el.parentNode.querySelector('.count-e'), | ||
hebrewCountNode = el.parentNode.querySelector('.count-h'), | ||
countNode = el.parentNode.querySelector('.count-all'); | ||
|
||
elements.forEach(function(el) { | ||
var farsiCountNode = el.parentNode.querySelector('.count-f'), | ||
latinCountNode = el.parentNode.querySelector('.count-e'), | ||
countNode = el.parentNode.querySelector('.count-all'); | ||
|
||
el.addEventListener('keyup', function(e) { | ||
var value = e.target.value, | ||
farsiChars = value.match(/[\u0600-\u06FF]/g), | ||
spaceChars = value.match(/\s/g), | ||
count = value.length, | ||
farsiCount = farsiChars ? farsiChars.length : 0, | ||
el.addEventListener('keyup', function(e) { | ||
var value = e.target.value, | ||
farsiChars = value.match(/[\u0600-\u06FF]/g), | ||
hebrewChars = value.match(/[\u0590-\u05FF]/g), | ||
spaceChars = value.match(/\s/g), | ||
count = value.length, | ||
farsiCount = farsiChars ? farsiChars.length : 0, | ||
hebrewCount = hebrewChars ? hebrewChars.length : 0, | ||
spaceCount = spaceChars ? spaceChars.length : 0, | ||
latinCount = count - farsiCount - spaceCount; | ||
|
||
e.target.setAttribute('dir', (farsiCount > latinCount) ? 'rtl' : 'ltr'); | ||
rtlCount = farsiCount + hebrewCount; | ||
latinCount = count - farsiCount - spaceCount - hebrewCount; | ||
|
||
if(farsiCountNode) farsiCountNode.innerHTML = farsiCount; | ||
if(latinCountNode) latinCountNode.innerHTML = latinCount; | ||
if(countNode) countNode.innerHTML = count; | ||
}); | ||
}); | ||
e.target.setAttribute('dir', rtlCount > latinCount ? 'rtl' : 'ltr'); | ||
|
||
if (farsiCountNode) farsiCountNode.innerHTML = farsiCount; | ||
if (latinCountNode) latinCountNode.innerHTML = latinCount; | ||
if (hebrewCountNode) hebrewCountNode.innerHTML = hebrewCount; | ||
if (countNode) countNode.innerHTML = count; | ||
}); | ||
}); | ||
}); |
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 was deleted.
Oops, something went wrong.