|
|
|
@ -1,13 +1,13 @@
@@ -1,13 +1,13 @@
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* 漢字標準格式 v2.1.1 |
|
|
|
|
* 漢字標準格式 v2.2.0 |
|
|
|
|
* --- |
|
|
|
|
* Hanzi-optimised CSS Mode |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* Lisence: MIT Lisence |
|
|
|
|
* Last Modified: 2013/10/21 |
|
|
|
|
* Last Modified: 2013/11/27 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
@ -16,7 +16,7 @@ jQuery.noConflict();
@@ -16,7 +16,7 @@ jQuery.noConflict();
|
|
|
|
|
|
|
|
|
|
(function($){ |
|
|
|
|
|
|
|
|
|
var version = '2.1.1', |
|
|
|
|
var version = '2.2.0', |
|
|
|
|
|
|
|
|
|
tests = [], |
|
|
|
|
rubies, |
|
|
|
@ -30,6 +30,11 @@ jQuery.noConflict();
@@ -30,6 +30,11 @@ jQuery.noConflict();
|
|
|
|
|
|
|
|
|
|
han = function() { |
|
|
|
|
$(document).on('ready', function(){ |
|
|
|
|
|
|
|
|
|
// `unicode-range`
|
|
|
|
|
classes.push( ( test_for_unicoderange() ? '' : 'no-' ) + 'unicoderange' ); |
|
|
|
|
|
|
|
|
|
// The 4(-1) Typefaces
|
|
|
|
|
fontfaces['songti'] = test_for_fontface( 'Han Songti' ); |
|
|
|
|
fontfaces['kaiti'] = test_for_fontface( 'Han Kaiti' ); |
|
|
|
|
fontfaces['fangsong'] = test_for_fontface( 'Han Fangsong' ); |
|
|
|
@ -38,6 +43,7 @@ jQuery.noConflict();
@@ -38,6 +43,7 @@ jQuery.noConflict();
|
|
|
|
|
classes.push( ( fontfaces[font] ? '' : 'no-' ) + 'fontface-' + font ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// altogether
|
|
|
|
|
$('html').addClass( classes.join(' ') ); |
|
|
|
|
|
|
|
|
|
init(); |
|
|
|
@ -130,7 +136,7 @@ jQuery.noConflict();
@@ -130,7 +136,7 @@ jQuery.noConflict();
|
|
|
|
|
/* |
|
|
|
|
* 漢拉間隙 |
|
|
|
|
* --- |
|
|
|
|
* Gaps between Hanzi and Latin Letter |
|
|
|
|
* Kerning between Hanzi and Latin Letter |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
@ -175,27 +181,39 @@ jQuery.noConflict();
@@ -175,27 +181,39 @@ jQuery.noConflict();
|
|
|
|
|
/* |
|
|
|
|
* 修正相鄰註記元素`<u>`的底線相連問題 |
|
|
|
|
* --- |
|
|
|
|
* fixing the underline-adjacency issues on `<u>` element |
|
|
|
|
* fixing the underline-adjacency issue on `<u>` element |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
if ( $('html').hasClass('han-lab-underline') ) |
|
|
|
|
$(range).find('u').charize('', true, true); |
|
|
|
|
else |
|
|
|
|
$(range).each(function() { |
|
|
|
|
var html = $(this).html(); |
|
|
|
|
$(range).find('u').each(function(){ |
|
|
|
|
var next = this.nextSibling; |
|
|
|
|
|
|
|
|
|
_ignore(next); |
|
|
|
|
_adj(next); |
|
|
|
|
|
|
|
|
|
$(this) |
|
|
|
|
.html( html.replace(/<\/u>(<!--.*?-->|<wbr[ ]?[\/]?>)*?<u(\s.*?)*?>/ig, '</u>$1<u data-adjacent $2>') ) |
|
|
|
|
.find('u[data-adjacent]').addClass('adjacent').removeAttr('data-adjacent'); |
|
|
|
|
|
|
|
|
|
function _adj( next ) { |
|
|
|
|
if ( next.nodeName === "U" ) |
|
|
|
|
$(next).addClass('adjacent'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function _ignore( next ) { |
|
|
|
|
if ( next.nodeName === "WBR" || next.nodeType == 8 ) { |
|
|
|
|
var next = next.nextSibling; |
|
|
|
|
_ignore(next); |
|
|
|
|
_adj(next); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 強調元素`<em>`的着重號 |
|
|
|
|
* --- |
|
|
|
|
* punctuation: CJK emphasis dots |
|
|
|
|
* on `<em>` element |
|
|
|
|
* punctuation: CJK emphasis dots on `<em>` element |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
@ -206,7 +224,7 @@ jQuery.noConflict();
@@ -206,7 +224,7 @@ jQuery.noConflict();
|
|
|
|
|
|
|
|
|
|
/* 修正引言元素`<q>`不為WebKit引擎支援的問題 |
|
|
|
|
* --- |
|
|
|
|
* punctuation: CJK quotes on `<q>` (WebKit) |
|
|
|
|
* punctuation: Quote issue on `<q>` element (WebKit) |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
@ -305,13 +323,17 @@ jQuery.noConflict();
@@ -305,13 +323,17 @@ jQuery.noConflict();
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_for_fontface = function( font ) { |
|
|
|
|
test_for_fontface = function( test, compare, zi ) { |
|
|
|
|
if ( !tests['fontface']() ) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
var test = test, |
|
|
|
|
compare = compare || 'sans-serif', |
|
|
|
|
zi = zi || '辭Q'; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
var sans = write_on_canvas( '辭Q', 'sans-serif' ), |
|
|
|
|
test = write_on_canvas( '辭Q', font ), |
|
|
|
|
var sans = write_on_canvas( zi, compare ), |
|
|
|
|
test = write_on_canvas( zi, test ), |
|
|
|
|
support; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -349,6 +371,10 @@ jQuery.noConflict();
@@ -349,6 +371,10 @@ jQuery.noConflict();
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_for_unicoderange = function() { |
|
|
|
|
return !test_for_fontface( 'han-unicode-range', 'Arial, "Droid Sans"', 'a' ); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------- |
|
|
|
|
* Unicode區域說明(6.2.0) |
|
|
|
@ -375,7 +401,7 @@ jQuery.noConflict();
@@ -375,7 +401,7 @@ jQuery.noConflict();
|
|
|
|
|
* CJK一般:[\u4E00-\u9FFF] |
|
|
|
|
* CJK擴展-A區:[\u3400-\u4DB5] |
|
|
|
|
* CJK擴展-B區:[\u20000-\u2A6D6] |
|
|
|
|
* CJK Unicode 4.1:[\u9FA6-\u9FBB][\uFA70-\uFAD9] |
|
|
|
|
* CJK Unicode 4.1:[\u9FA6-\u9FBB]、[\uFA70-\uFAD9] |
|
|
|
|
* CJK Unicode 5.1:[\u9FBC-\u9FC3] |
|
|
|
|
* CJK擴展-C區:[\u2A700-\u2B734] |
|
|
|
|
* CJK擴展-D區:[\u2B740-\u2B81D](急用漢字) |
|
|
|
@ -385,7 +411,9 @@ jQuery.noConflict();
@@ -385,7 +411,9 @@ jQuery.noConflict();
|
|
|
|
|
* 數字「〇」:[\u3007] |
|
|
|
|
* 日文假名:[\u3040-\u309E][\u30A1-\u30FA][\u30FD\u30FE](**註**:排除片假名中點、長音符) |
|
|
|
|
* |
|
|
|
|
* CJK相容表意文字:[\uF900-\uFAFF](**註**:不使用) |
|
|
|
|
* CJK相容表意文字: |
|
|
|
|
* [\uF900-\uFAFF](**註**:不使用) |
|
|
|
|
* [\uFA0E-\uFA0F\uFA11\uFA13-\uFA14\uFA1F\uFA21\uFA23-\uFA24\uFA27-\uFA29](**註**:12個例外) |
|
|
|
|
* -------------------------------------------------------- |
|
|
|
|
* |
|
|
|
|
** 符號 |
|
|
|
@ -413,7 +441,7 @@ jQuery.noConflict();
@@ -413,7 +441,7 @@ jQuery.noConflict();
|
|
|
|
|
|
|
|
|
|
unicode['hanzi'] = [ |
|
|
|
|
'[\u4E00-\u9FFF]', |
|
|
|
|
'[\u3400-\u4DB5\u9FA6-\u9FBB\uFA70-\uFAD9\u9FBC-\u9FC3\u3007\u3040-\u309E\u30A1-\u30FA\u30FD\u30FE]', |
|
|
|
|
'[\u3400-\u4DB5\u9FA6-\u9FBB\uFA70-\uFAD9\u9FBC-\u9FC3\u3007\u3040-\u309E\u30A1-\u30FA\u30FD\u30FE\uFA0E-\uFA0F\uFA11\uFA13-\uFA14\uFA1F\uFA21\uFA23-\uFA24\uFA27-\uFA29]', |
|
|
|
|
'[\uD840-\uD868][\uDC00-\uDFFF]|\uD869[\uDC00-\uDEDF]', |
|
|
|
|
'\uD86D[\uDC00-\uDF3F]|[\uD86A-\uD86C][\uDC00-\uDFFF]|\uD869[\uDF00-\uDFFF]', |
|
|
|
|
'\uD86D[\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1F]', |
|
|
|
@ -684,14 +712,10 @@ jQuery.noConflict();
@@ -684,14 +712,10 @@ jQuery.noConflict();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tests
|
|
|
|
|
for ( var feature in tests ) { |
|
|
|
|
classes.push( ( tests[feature]() ? '' : 'no-' ) + feature ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( !tester ) |
|
|
|
|
var tester = ''; |
|
|
|
|
|
|
|
|
@ -699,7 +723,8 @@ jQuery.noConflict();
@@ -699,7 +723,8 @@ jQuery.noConflict();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
!function(window) { |
|
|
|
|
eval("tester = ({\n" + tester.replace(/\n$/ig, '\nfont: test_for_fontface\n}') + ")"); |
|
|
|
|
eval("tester = ({\n" + tester.replace(/\n$/ig, |
|
|
|
|
'\nunicoderange: test_for_unicoderange, \nfont: test_for_fontface\n}') + ")"); |
|
|
|
|
}(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1223,3 +1248,22 @@ window.findAndReplaceDOMText = (function() {
@@ -1223,3 +1248,22 @@ window.findAndReplaceDOMText = (function() {
|
|
|
|
|
return exposed; |
|
|
|
|
|
|
|
|
|
}()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|