Version Description
Download this release
Release Info
Developer | tenpura |
Plugin | WP Multibyte Patch |
Version | 2.3 |
Comparing to | |
See all releases |
Code changes from version 2.2 to 2.3
- ext/ja/class.php +2 -2
- js/20140817/wplink.min.js +0 -1
- js/{20140817 → 20141213}/wplink.js +4 -0
- js/20141213/wplink.min.js +1 -0
- js/wplink.js +135 -62
- js/wplink.min.js +1 -1
- readme.txt +3 -3
- wp-multibyte-patch.php +7 -7
ext/ja/class.php
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
* WP Multibyte Patch Japanese Locale Extension
|
4 |
*
|
5 |
* @package WP_Multibyte_Patch
|
6 |
-
* @version 2.
|
7 |
* @author Seisuke Kuraishi <210pura@gmail.com>
|
8 |
-
* @copyright Copyright (c)
|
9 |
* @license http://opensource.org/licenses/gpl-2.0.php GPLv2
|
10 |
* @link http://eastcoder.com/code/wp-multibyte-patch/
|
11 |
*/
|
3 |
* WP Multibyte Patch Japanese Locale Extension
|
4 |
*
|
5 |
* @package WP_Multibyte_Patch
|
6 |
+
* @version 2.3
|
7 |
* @author Seisuke Kuraishi <210pura@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2015 Seisuke Kuraishi, Tinybit Inc.
|
9 |
* @license http://opensource.org/licenses/gpl-2.0.php GPLv2
|
10 |
* @link http://eastcoder.com/code/wp-multibyte-patch/
|
11 |
*/
|
js/20140817/wplink.min.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
var wpLink;!function(a){var b,c,d,e,f={},g={},h="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){f.wrap=a("#wp-link-wrap"),f.dialog=a("#wp-link"),f.backdrop=a("#wp-link-backdrop"),f.submit=a("#wp-link-submit"),f.close=a("#wp-link-close"),f.url=a("#url-field"),f.nonce=a("#_ajax_linking_nonce"),f.title=a("#link-title-field"),f.openInNewTab=a("#link-target-checkbox"),f.search=a("#search-field"),g.search=new d(a("#search-results")),g.recent=new d(a("#most-recent-results")),g.elements=f.dialog.find(".query-results"),f.queryNotice=a("#query-notice-message"),f.queryNoticeTextDefault=f.queryNotice.find(".query-notice-default"),f.queryNoticeTextHint=f.queryNotice.find(".query-notice-hint"),f.dialog.keydown(wpLink.keydown),f.dialog.keyup(wpLink.keyup),f.submit.click(function(a){a.preventDefault(),wpLink.update()}),f.close.add(f.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),g.elements.on("river-select",wpLink.updateFields),f.search.on("focus.wplink",function(){f.queryNoticeTextDefault.hide(),f.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){f.queryNoticeTextDefault.show(),f.queryNoticeTextHint.addClass("screen-reader-text").hide()}),f.search.keyup(function(){var a=this;window.clearTimeout(c),c=window.setTimeout(function(){wpLink.searchInternalLinks.call(a)},500)})},open:function(c){var d;wpLink.range=null,c&&(window.wpActiveEditor=c),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(d=tinymce.get(wpActiveEditor),b=d&&!d.isHidden()?d:null,b&&tinymce.isIE&&(b.windowManager.bookmark=b.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),f.wrap.show(),f.backdrop.show(),wpLink.refresh(),a(document).trigger("wplink-open",f.wrap))},isMCE:function(){return b&&!b.isHidden()},refresh:function(){g.search.refresh(),g.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():wpLink.setDefaultValues(),h?f.url.focus().blur():f.url.focus()[0].select(),g.recent.ul.children().length||g.recent.ajax()},mceRefresh:function(){var a;(a=b.dom.getParent(b.selection.getNode(),"A"))?(f.url.val(b.dom.getAttrib(a,"href")),f.title.val(b.dom.getAttrib(a,"title")),f.openInNewTab.prop("checked","_blank"===b.dom.getAttrib(a,"target")),f.submit.val(wpLinkL10n.update)):wpLink.setDefaultValues()},close:function(){wpLink.isMCE()?b.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),f.backdrop.hide(),f.wrap.hide(),a(document).trigger("wplink-close",f.wrap)},getAttrs:function(){return{href:f.url.val(),title:f.title.val(),target:f.openInNewTab.prop("checked")?"_blank":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,e,f,g,h=wpLink.textarea;h&&(a=wpLink.getAttrs(),a.href&&"http://"!=a.href&&(b='<a href="'+a.href+'"',a.title&&(f=a.title.replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),b+=' title="'+f+'"'),a.target&&(b+=' target="'+a.target+'"'),b+=">",document.selection&&wpLink.range?(h.focus(),wpLink.range.text=b+wpLink.range.text+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof h.selectionStart&&(c=h.selectionStart,d=h.selectionEnd,g=h.value.substring(c,d),b=b+g+"</a>",e=c+b.length,c==d&&(e-="</a>".length),h.value=h.value.substring(0,c)+b+h.value.substring(d,h.value.length),h.selectionStart=h.selectionEnd=e),wpLink.close(),h.focus()))},mceUpdate:function(){var a,c=wpLink.getAttrs();return wpLink.close(),b.focus(),tinymce.isIE&&b.selection.moveToBookmark(b.windowManager.bookmark),a=b.dom.getParent(b.selection.getNode(),"a[href]"),c.href&&"http://"!=c.href?(a?b.dom.setAttribs(a,c):b.execCommand("mceInsertLink",!1,c),void b.selection.collapse()):void b.execCommand("unlink")},updateFields:function(a,b){f.url.val(b.children(".item-permalink").val()),f.title.val(b.hasClass("no-title")?"":b.children(".item-title").text())},setDefaultValues:function(){var a=b&&b.selection.getContent(),c=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,d=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;f.url.val(a&&c.test(a)?"mailto:"+a:a&&d.test(a)?a.replace(/&|�?38;/gi,"&"):"http://"),f.title.val(""),f.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var b,c=a(this),d=c.val();if(d.length>1){if(g.recent.hide(),g.search.show(),wpLink.lastSearch==d)return;wpLink.lastSearch=d,b=c.parent().find(".spinner").show(),g.search.change(d),g.search.ajax(function(){b.hide()})}else g.search.hide(),g.recent.show()},next:function(){g.search.next(),g.recent.next()},prev:function(){g.search.prev(),g.recent.prev()},keydown:function(b){var c,d,e=a.ui.keyCode;e.ESCAPE===b.keyCode?(wpLink.close(),b.stopImmediatePropagation()):e.TAB===b.keyCode&&(d=b.target.id,"wp-link-submit"!==d||b.shiftKey?"wp-link-close"===d&&b.shiftKey&&(f.submit.focus(),b.preventDefault()):(f.close.focus(),b.preventDefault())),(b.keyCode===e.UP||b.keyCode===e.DOWN)&&(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(c=b.keyCode===e.UP?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[c](),wpLink.keyInterval=setInterval(wpLink[c],wpLink.keySensitivity),b.preventDefault())},keyup:function(b){var c=a.ui.keyCode;(b.which===c.UP||b.which===c.DOWN)&&(clearInterval(wpLink.keyInterval),b.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a},toggleInternalLinking:function(a){var b=f.wrap.hasClass("search-panel-visible");f.wrap.toggleClass("search-panel-visible",!b),setUserSetting("wplink",b?"0":"1"),f[b?"url":"search"].focus(),a.preventDefault()}},d=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(d.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),0>e?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new e(a),this.element.scrollTop(0))},process:function(b,c){var d="",e=!0,f="",g=1==c.page;b?a.each(b,function(){f=e?"alternate":"",f+=this.title?"":" no-title",d+=f?'<li class="'+f+'">':"<li>",d+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',d+='<span class="item-title">',d+=this.title?this.title:wpLinkL10n.noTitle,d+='</span><span class="item-info">'+this.info+"</span></li>",e=!e}):g&&(d+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[g?"html":"append"](d)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var c=b.scrollTop(),d=c+b.height();!a.query.ready()||d<a.contentHeight.height()-wpLink.riverBottomThreshold||(a.waiting.show(),b.scrollTop(c+a.waiting.outerHeight()),a.ajax(function(){a.waiting.hide()}))},wpLink.timeToTriggerRiver)}}),e=function(a){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=a},a.extend(e.prototype,{ready:function(){return!(this.querying||this.allLoaded)},ajax:function(b){var c=this,d={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:f.nonce.val()};this.search&&(d.search=this.search),this.querying=!0,a.post(ajaxurl,d,function(a){c.page++,c.querying=!1,c.allLoaded=!a,b(a,d)},"json")}}),a(document).ready(wpLink.init)}(jQuery);
|
|
js/{20140817 → 20141213}/wplink.js
RENAMED
@@ -77,6 +77,8 @@ var wpLink;
|
|
77 |
open: function( editorId ) {
|
78 |
var ed;
|
79 |
|
|
|
|
|
80 |
wpLink.range = null;
|
81 |
|
82 |
if ( editorId ) {
|
@@ -166,6 +168,8 @@ var wpLink;
|
|
166 |
},
|
167 |
|
168 |
close: function() {
|
|
|
|
|
169 |
if ( ! wpLink.isMCE() ) {
|
170 |
wpLink.textarea.focus();
|
171 |
|
77 |
open: function( editorId ) {
|
78 |
var ed;
|
79 |
|
80 |
+
$( document.body ).addClass( 'modal-open' );
|
81 |
+
|
82 |
wpLink.range = null;
|
83 |
|
84 |
if ( editorId ) {
|
168 |
},
|
169 |
|
170 |
close: function() {
|
171 |
+
$( document.body ).removeClass( 'modal-open' );
|
172 |
+
|
173 |
if ( ! wpLink.isMCE() ) {
|
174 |
wpLink.textarea.focus();
|
175 |
|
js/20141213/wplink.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
var wpLink;!function(a){var b,c,d,e,f={},g={},h="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){f.wrap=a("#wp-link-wrap"),f.dialog=a("#wp-link"),f.backdrop=a("#wp-link-backdrop"),f.submit=a("#wp-link-submit"),f.close=a("#wp-link-close"),f.url=a("#url-field"),f.nonce=a("#_ajax_linking_nonce"),f.title=a("#link-title-field"),f.openInNewTab=a("#link-target-checkbox"),f.search=a("#search-field"),g.search=new d(a("#search-results")),g.recent=new d(a("#most-recent-results")),g.elements=f.dialog.find(".query-results"),f.queryNotice=a("#query-notice-message"),f.queryNoticeTextDefault=f.queryNotice.find(".query-notice-default"),f.queryNoticeTextHint=f.queryNotice.find(".query-notice-hint"),f.dialog.keydown(wpLink.keydown),f.dialog.keyup(wpLink.keyup),f.submit.click(function(a){a.preventDefault(),wpLink.update()}),f.close.add(f.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),g.elements.on("river-select",wpLink.updateFields),f.search.on("focus.wplink",function(){f.queryNoticeTextDefault.hide(),f.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){f.queryNoticeTextDefault.show(),f.queryNoticeTextHint.addClass("screen-reader-text").hide()}),f.search.keyup(function(){var a=this;window.clearTimeout(c),c=window.setTimeout(function(){wpLink.searchInternalLinks.call(a)},500)})},open:function(c){var d;a(document.body).addClass("modal-open"),wpLink.range=null,c&&(window.wpActiveEditor=c),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(d=tinymce.get(wpActiveEditor),b=d&&!d.isHidden()?d:null,b&&tinymce.isIE&&(b.windowManager.bookmark=b.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),f.wrap.show(),f.backdrop.show(),wpLink.refresh(),a(document).trigger("wplink-open",f.wrap))},isMCE:function(){return b&&!b.isHidden()},refresh:function(){g.search.refresh(),g.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():wpLink.setDefaultValues(),h?f.url.focus().blur():f.url.focus()[0].select(),g.recent.ul.children().length||g.recent.ajax()},mceRefresh:function(){var a;(a=b.dom.getParent(b.selection.getNode(),"A"))?(f.url.val(b.dom.getAttrib(a,"href")),f.title.val(b.dom.getAttrib(a,"title")),f.openInNewTab.prop("checked","_blank"===b.dom.getAttrib(a,"target")),f.submit.val(wpLinkL10n.update)):wpLink.setDefaultValues()},close:function(){a(document.body).removeClass("modal-open"),wpLink.isMCE()?b.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),f.backdrop.hide(),f.wrap.hide(),a(document).trigger("wplink-close",f.wrap)},getAttrs:function(){return{href:f.url.val(),title:f.title.val(),target:f.openInNewTab.prop("checked")?"_blank":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,e,f,g,h=wpLink.textarea;h&&(a=wpLink.getAttrs(),a.href&&"http://"!=a.href&&(b='<a href="'+a.href+'"',a.title&&(f=a.title.replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),b+=' title="'+f+'"'),a.target&&(b+=' target="'+a.target+'"'),b+=">",document.selection&&wpLink.range?(h.focus(),wpLink.range.text=b+wpLink.range.text+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof h.selectionStart&&(c=h.selectionStart,d=h.selectionEnd,g=h.value.substring(c,d),b=b+g+"</a>",e=c+b.length,c==d&&(e-="</a>".length),h.value=h.value.substring(0,c)+b+h.value.substring(d,h.value.length),h.selectionStart=h.selectionEnd=e),wpLink.close(),h.focus()))},mceUpdate:function(){var a,c=wpLink.getAttrs();return wpLink.close(),b.focus(),tinymce.isIE&&b.selection.moveToBookmark(b.windowManager.bookmark),a=b.dom.getParent(b.selection.getNode(),"a[href]"),c.href&&"http://"!=c.href?(a?b.dom.setAttribs(a,c):b.execCommand("mceInsertLink",!1,c),void b.selection.collapse()):void b.execCommand("unlink")},updateFields:function(a,b){f.url.val(b.children(".item-permalink").val()),f.title.val(b.hasClass("no-title")?"":b.children(".item-title").text())},setDefaultValues:function(){var a=b&&b.selection.getContent(),c=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,d=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;f.url.val(a&&c.test(a)?"mailto:"+a:a&&d.test(a)?a.replace(/&|�?38;/gi,"&"):"http://"),f.title.val(""),f.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var b,c=a(this),d=c.val();if(d.length>1){if(g.recent.hide(),g.search.show(),wpLink.lastSearch==d)return;wpLink.lastSearch=d,b=c.parent().find(".spinner").show(),g.search.change(d),g.search.ajax(function(){b.hide()})}else g.search.hide(),g.recent.show()},next:function(){g.search.next(),g.recent.next()},prev:function(){g.search.prev(),g.recent.prev()},keydown:function(b){var c,d,e=a.ui.keyCode;e.ESCAPE===b.keyCode?(wpLink.close(),b.stopImmediatePropagation()):e.TAB===b.keyCode&&(d=b.target.id,"wp-link-submit"!==d||b.shiftKey?"wp-link-close"===d&&b.shiftKey&&(f.submit.focus(),b.preventDefault()):(f.close.focus(),b.preventDefault())),(b.keyCode===e.UP||b.keyCode===e.DOWN)&&(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(c=b.keyCode===e.UP?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[c](),wpLink.keyInterval=setInterval(wpLink[c],wpLink.keySensitivity),b.preventDefault())},keyup:function(b){var c=a.ui.keyCode;(b.which===c.UP||b.which===c.DOWN)&&(clearInterval(wpLink.keyInterval),b.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a},toggleInternalLinking:function(a){var b=f.wrap.hasClass("search-panel-visible");f.wrap.toggleClass("search-panel-visible",!b),setUserSetting("wplink",b?"0":"1"),f[b?"url":"search"].focus(),a.preventDefault()}},d=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(d.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),0>e?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new e(a),this.element.scrollTop(0))},process:function(b,c){var d="",e=!0,f="",g=1==c.page;b?a.each(b,function(){f=e?"alternate":"",f+=this.title?"":" no-title",d+=f?'<li class="'+f+'">':"<li>",d+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',d+='<span class="item-title">',d+=this.title?this.title:wpLinkL10n.noTitle,d+='</span><span class="item-info">'+this.info+"</span></li>",e=!e}):g&&(d+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[g?"html":"append"](d)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var c=b.scrollTop(),d=c+b.height();!a.query.ready()||d<a.contentHeight.height()-wpLink.riverBottomThreshold||(a.waiting.show(),b.scrollTop(c+a.waiting.outerHeight()),a.ajax(function(){a.waiting.hide()}))},wpLink.timeToTriggerRiver)}}),e=function(a){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=a},a.extend(e.prototype,{ready:function(){return!(this.querying||this.allLoaded)},ajax:function(b){var c=this,d={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:f.nonce.val()};this.search&&(d.search=this.search),this.querying=!0,a.post(ajaxurl,d,function(a){c.page++,c.querying=!1,c.allLoaded=!a,b(a,d)},"json")}}),a(document).ready(wpLink.init)}(jQuery);
|
js/wplink.js
CHANGED
@@ -2,11 +2,15 @@
|
|
2 |
var wpLink;
|
3 |
|
4 |
( function( $ ) {
|
5 |
-
var editor, searchTimer, River, Query,
|
6 |
inputs = {},
|
7 |
rivers = {},
|
8 |
isTouch = ( 'ontouchend' in document );
|
9 |
|
|
|
|
|
|
|
|
|
10 |
wpLink = {
|
11 |
timeToTriggerRiver: 150,
|
12 |
minRiverAJAXDuration: 200,
|
@@ -21,14 +25,14 @@ var wpLink;
|
|
21 |
inputs.backdrop = $( '#wp-link-backdrop' );
|
22 |
inputs.submit = $( '#wp-link-submit' );
|
23 |
inputs.close = $( '#wp-link-close' );
|
24 |
-
|
25 |
-
|
|
|
|
|
26 |
inputs.nonce = $( '#_ajax_linking_nonce' );
|
27 |
-
|
28 |
-
inputs.
|
29 |
-
|
30 |
-
inputs.openInNewTab = $( '#link-target-checkbox' );
|
31 |
-
inputs.search = $( '#search-field' );
|
32 |
// Build Rivers
|
33 |
rivers.search = new River( $( '#search-results' ) );
|
34 |
rivers.recent = new River( $( '#most-recent-results' ) );
|
@@ -72,6 +76,21 @@ var wpLink;
|
|
72 |
wpLink.searchInternalLinks.call( self );
|
73 |
}, 500 );
|
74 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
},
|
76 |
|
77 |
open: function( editorId ) {
|
@@ -114,6 +133,7 @@ var wpLink;
|
|
114 |
inputs.backdrop.show();
|
115 |
|
116 |
wpLink.refresh();
|
|
|
117 |
$( document ).trigger( 'wplink-open', inputs.wrap );
|
118 |
},
|
119 |
|
@@ -129,6 +149,8 @@ var wpLink;
|
|
129 |
if ( wpLink.isMCE() ) {
|
130 |
wpLink.mceRefresh();
|
131 |
} else {
|
|
|
|
|
132 |
wpLink.setDefaultValues();
|
133 |
}
|
134 |
|
@@ -146,24 +168,57 @@ var wpLink;
|
|
146 |
if ( ! rivers.recent.ul.children().length ) {
|
147 |
rivers.recent.ajax();
|
148 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
},
|
150 |
|
151 |
mceRefresh: function() {
|
152 |
-
var
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
inputs.openInNewTab.prop( 'checked',
|
161 |
-
// Update save prompt.
|
162 |
inputs.submit.val( wpLinkL10n.update );
|
|
|
|
|
|
|
|
|
163 |
|
164 |
-
|
|
|
|
|
165 |
} else {
|
166 |
-
|
|
|
167 |
}
|
168 |
},
|
169 |
|
@@ -183,45 +238,46 @@ var wpLink;
|
|
183 |
|
184 |
inputs.backdrop.hide();
|
185 |
inputs.wrap.hide();
|
|
|
|
|
|
|
186 |
$( document ).trigger( 'wplink-close', inputs.wrap );
|
187 |
},
|
188 |
|
189 |
getAttrs: function() {
|
190 |
return {
|
191 |
-
href: inputs.url.val(),
|
192 |
-
title: inputs.title.val(),
|
193 |
target: inputs.openInNewTab.prop( 'checked' ) ? '_blank' : ''
|
194 |
};
|
195 |
},
|
196 |
|
197 |
update: function() {
|
198 |
-
if ( wpLink.isMCE() )
|
199 |
wpLink.mceUpdate();
|
200 |
-
else
|
201 |
wpLink.htmlUpdate();
|
|
|
202 |
},
|
203 |
|
204 |
htmlUpdate: function() {
|
205 |
-
var attrs, html, begin, end, cursor,
|
206 |
textarea = wpLink.textarea;
|
207 |
|
208 |
-
if ( ! textarea )
|
209 |
return;
|
|
|
210 |
|
211 |
attrs = wpLink.getAttrs();
|
|
|
212 |
|
213 |
// If there's no href, return.
|
214 |
-
if ( ! attrs.href
|
215 |
return;
|
|
|
216 |
|
217 |
// Build HTML
|
218 |
html = '<a href="' + attrs.href + '"';
|
219 |
|
220 |
-
if ( attrs.title ) {
|
221 |
-
title = attrs.title.replace( /</g, '<' ).replace( />/g, '>' ).replace( /"/g, '"' );
|
222 |
-
html += ' title="' + title + '"';
|
223 |
-
}
|
224 |
-
|
225 |
if ( attrs.target ) {
|
226 |
html += ' target="' + attrs.target + '"';
|
227 |
}
|
@@ -234,25 +290,29 @@ var wpLink;
|
|
234 |
// Note: If no text is selected, IE will not place the cursor
|
235 |
// inside the closing tag.
|
236 |
textarea.focus();
|
237 |
-
wpLink.range.text = html + wpLink.range.text + '</a>';
|
238 |
wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
|
239 |
wpLink.range.select();
|
240 |
|
241 |
wpLink.range = null;
|
242 |
} else if ( typeof textarea.selectionStart !== 'undefined' ) {
|
243 |
// W3C
|
244 |
-
begin
|
245 |
-
end
|
246 |
-
selection
|
247 |
-
html
|
248 |
-
cursor
|
249 |
|
250 |
// If no text is selected, place the cursor inside the closing tag.
|
251 |
-
if ( begin
|
252 |
-
cursor -=
|
|
|
253 |
|
254 |
-
textarea.value =
|
255 |
-
textarea.value.substring(
|
|
|
|
|
|
|
256 |
|
257 |
// Update cursor position
|
258 |
textarea.selectionStart = textarea.selectionEnd = cursor;
|
@@ -263,8 +323,8 @@ var wpLink;
|
|
263 |
},
|
264 |
|
265 |
mceUpdate: function() {
|
266 |
-
var
|
267 |
-
|
268 |
|
269 |
wpLink.close();
|
270 |
editor.focus();
|
@@ -273,34 +333,50 @@ var wpLink;
|
|
273 |
editor.selection.moveToBookmark( editor.windowManager.bookmark );
|
274 |
}
|
275 |
|
276 |
-
|
277 |
-
|
278 |
-
// If the values are empty, unlink and return
|
279 |
-
if ( ! attrs.href || attrs.href == 'http://' ) {
|
280 |
editor.execCommand( 'unlink' );
|
281 |
return;
|
282 |
}
|
283 |
|
|
|
|
|
|
|
284 |
if ( link ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
editor.dom.setAttribs( link, attrs );
|
286 |
} else {
|
287 |
-
|
|
|
|
|
|
|
|
|
288 |
}
|
289 |
-
|
290 |
-
// Move the cursor to the end of the selection
|
291 |
-
editor.selection.collapse();
|
292 |
},
|
293 |
|
294 |
updateFields: function( e, li ) {
|
295 |
inputs.url.val( li.children( '.item-permalink' ).val() );
|
296 |
-
inputs.title.val( li.hasClass( 'no-title' ) ? '' : li.children( '.item-title' ).text() );
|
297 |
},
|
298 |
|
299 |
setDefaultValues: function() {
|
300 |
-
var selection
|
301 |
emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
|
302 |
urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;
|
303 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
if ( selection && emailRegexp.test( selection ) ) {
|
305 |
// Selection is email address
|
306 |
inputs.url.val( 'mailto:' + selection );
|
@@ -309,12 +385,9 @@ var wpLink;
|
|
309 |
inputs.url.val( selection.replace( /&|�?38;/gi, '&' ) );
|
310 |
} else {
|
311 |
// Set URL to default.
|
312 |
-
inputs.url.val( '
|
313 |
}
|
314 |
|
315 |
-
// Set description to default.
|
316 |
-
inputs.title.val( '' );
|
317 |
-
|
318 |
// Update save prompt.
|
319 |
inputs.submit.val( wpLinkL10n.save );
|
320 |
},
|
@@ -332,11 +405,11 @@ var wpLink;
|
|
332 |
return;
|
333 |
|
334 |
wpLink.lastSearch = search;
|
335 |
-
waiting = t.parent().find('.spinner').
|
336 |
|
337 |
rivers.search.change( search );
|
338 |
rivers.search.ajax( function() {
|
339 |
-
waiting.
|
340 |
});
|
341 |
} else {
|
342 |
rivers.search.hide();
|
@@ -572,11 +645,11 @@ var wpLink;
|
|
572 |
if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold )
|
573 |
return;
|
574 |
|
575 |
-
self.waiting.
|
576 |
el.scrollTop( newTop + self.waiting.outerHeight() );
|
577 |
|
578 |
self.ajax( function() {
|
579 |
-
self.waiting.
|
580 |
});
|
581 |
}, wpLink.timeToTriggerRiver );
|
582 |
}
|
2 |
var wpLink;
|
3 |
|
4 |
( function( $ ) {
|
5 |
+
var editor, searchTimer, River, Query, correctedURL,
|
6 |
inputs = {},
|
7 |
rivers = {},
|
8 |
isTouch = ( 'ontouchend' in document );
|
9 |
|
10 |
+
function getLink() {
|
11 |
+
return editor.dom.getParent( editor.selection.getNode(), 'a' );
|
12 |
+
}
|
13 |
+
|
14 |
wpLink = {
|
15 |
timeToTriggerRiver: 150,
|
16 |
minRiverAJAXDuration: 200,
|
25 |
inputs.backdrop = $( '#wp-link-backdrop' );
|
26 |
inputs.submit = $( '#wp-link-submit' );
|
27 |
inputs.close = $( '#wp-link-close' );
|
28 |
+
|
29 |
+
// Input
|
30 |
+
inputs.text = $( '#wp-link-text' );
|
31 |
+
inputs.url = $( '#wp-link-url' );
|
32 |
inputs.nonce = $( '#_ajax_linking_nonce' );
|
33 |
+
inputs.openInNewTab = $( '#wp-link-target' );
|
34 |
+
inputs.search = $( '#wp-link-search' );
|
35 |
+
|
|
|
|
|
36 |
// Build Rivers
|
37 |
rivers.search = new River( $( '#search-results' ) );
|
38 |
rivers.recent = new River( $( '#most-recent-results' ) );
|
76 |
wpLink.searchInternalLinks.call( self );
|
77 |
}, 500 );
|
78 |
});
|
79 |
+
|
80 |
+
function correctURL() {
|
81 |
+
var url = $.trim( inputs.url.val() );
|
82 |
+
|
83 |
+
if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
|
84 |
+
inputs.url.val( 'http://' + url );
|
85 |
+
correctedURL = url;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
inputs.url.on( 'paste', function() {
|
90 |
+
setTimeout( correctURL, 0 );
|
91 |
+
} );
|
92 |
+
|
93 |
+
inputs.url.on( 'blur', correctURL );
|
94 |
},
|
95 |
|
96 |
open: function( editorId ) {
|
133 |
inputs.backdrop.show();
|
134 |
|
135 |
wpLink.refresh();
|
136 |
+
|
137 |
$( document ).trigger( 'wplink-open', inputs.wrap );
|
138 |
},
|
139 |
|
149 |
if ( wpLink.isMCE() ) {
|
150 |
wpLink.mceRefresh();
|
151 |
} else {
|
152 |
+
inputs.wrap.removeClass( 'has-text-field' );
|
153 |
+
inputs.text.val( '' );
|
154 |
wpLink.setDefaultValues();
|
155 |
}
|
156 |
|
168 |
if ( ! rivers.recent.ul.children().length ) {
|
169 |
rivers.recent.ajax();
|
170 |
}
|
171 |
+
|
172 |
+
correctedURL = inputs.url.val().replace( /^http:\/\//, '' );
|
173 |
+
},
|
174 |
+
|
175 |
+
hasSelectedText: function( linkNode ) {
|
176 |
+
var html = editor.selection.getContent();
|
177 |
+
|
178 |
+
// Partial html and not a fully selected anchor element
|
179 |
+
if ( /</.test( html ) && ( ! /^<a [^>]+>[^<]+<\/a>$/.test( html ) || html.indexOf('href=') === -1 ) ) {
|
180 |
+
return false;
|
181 |
+
}
|
182 |
+
|
183 |
+
if ( linkNode ) {
|
184 |
+
var nodes = linkNode.childNodes, i;
|
185 |
+
|
186 |
+
if ( nodes.length === 0 ) {
|
187 |
+
return false;
|
188 |
+
}
|
189 |
+
|
190 |
+
for ( i = nodes.length - 1; i >= 0; i-- ) {
|
191 |
+
if ( nodes[i].nodeType != 3 ) {
|
192 |
+
return false;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
return true;
|
198 |
},
|
199 |
|
200 |
mceRefresh: function() {
|
201 |
+
var text,
|
202 |
+
selectedNode = editor.selection.getNode(),
|
203 |
+
linkNode = editor.dom.getParent( selectedNode, 'a[href]' ),
|
204 |
+
onlyText = this.hasSelectedText( linkNode );
|
205 |
+
|
206 |
+
if ( linkNode ) {
|
207 |
+
text = linkNode.innerText || linkNode.textContent;
|
208 |
+
inputs.url.val( editor.dom.getAttrib( linkNode, 'href' ) );
|
209 |
+
inputs.openInNewTab.prop( 'checked', '_blank' === editor.dom.getAttrib( linkNode, 'target' ) );
|
|
|
210 |
inputs.submit.val( wpLinkL10n.update );
|
211 |
+
} else {
|
212 |
+
text = editor.selection.getContent({ format: 'text' });
|
213 |
+
this.setDefaultValues();
|
214 |
+
}
|
215 |
|
216 |
+
if ( onlyText ) {
|
217 |
+
inputs.text.val( text || '' );
|
218 |
+
inputs.wrap.addClass( 'has-text-field' );
|
219 |
} else {
|
220 |
+
inputs.text.val( '' );
|
221 |
+
inputs.wrap.removeClass( 'has-text-field' );
|
222 |
}
|
223 |
},
|
224 |
|
238 |
|
239 |
inputs.backdrop.hide();
|
240 |
inputs.wrap.hide();
|
241 |
+
|
242 |
+
correctedURL = false;
|
243 |
+
|
244 |
$( document ).trigger( 'wplink-close', inputs.wrap );
|
245 |
},
|
246 |
|
247 |
getAttrs: function() {
|
248 |
return {
|
249 |
+
href: $.trim( inputs.url.val() ),
|
|
|
250 |
target: inputs.openInNewTab.prop( 'checked' ) ? '_blank' : ''
|
251 |
};
|
252 |
},
|
253 |
|
254 |
update: function() {
|
255 |
+
if ( wpLink.isMCE() ) {
|
256 |
wpLink.mceUpdate();
|
257 |
+
} else {
|
258 |
wpLink.htmlUpdate();
|
259 |
+
}
|
260 |
},
|
261 |
|
262 |
htmlUpdate: function() {
|
263 |
+
var attrs, text, html, begin, end, cursor, selection,
|
264 |
textarea = wpLink.textarea;
|
265 |
|
266 |
+
if ( ! textarea ) {
|
267 |
return;
|
268 |
+
}
|
269 |
|
270 |
attrs = wpLink.getAttrs();
|
271 |
+
text = inputs.text.val();
|
272 |
|
273 |
// If there's no href, return.
|
274 |
+
if ( ! attrs.href ) {
|
275 |
return;
|
276 |
+
}
|
277 |
|
278 |
// Build HTML
|
279 |
html = '<a href="' + attrs.href + '"';
|
280 |
|
|
|
|
|
|
|
|
|
|
|
281 |
if ( attrs.target ) {
|
282 |
html += ' target="' + attrs.target + '"';
|
283 |
}
|
290 |
// Note: If no text is selected, IE will not place the cursor
|
291 |
// inside the closing tag.
|
292 |
textarea.focus();
|
293 |
+
wpLink.range.text = html + ( text || wpLink.range.text ) + '</a>';
|
294 |
wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
|
295 |
wpLink.range.select();
|
296 |
|
297 |
wpLink.range = null;
|
298 |
} else if ( typeof textarea.selectionStart !== 'undefined' ) {
|
299 |
// W3C
|
300 |
+
begin = textarea.selectionStart;
|
301 |
+
end = textarea.selectionEnd;
|
302 |
+
selection = text || textarea.value.substring( begin, end );
|
303 |
+
html = html + selection + '</a>';
|
304 |
+
cursor = begin + html.length;
|
305 |
|
306 |
// If no text is selected, place the cursor inside the closing tag.
|
307 |
+
if ( begin === end && ! selection ) {
|
308 |
+
cursor -= 4;
|
309 |
+
}
|
310 |
|
311 |
+
textarea.value = (
|
312 |
+
textarea.value.substring( 0, begin ) +
|
313 |
+
html +
|
314 |
+
textarea.value.substring( end, textarea.value.length )
|
315 |
+
);
|
316 |
|
317 |
// Update cursor position
|
318 |
textarea.selectionStart = textarea.selectionEnd = cursor;
|
323 |
},
|
324 |
|
325 |
mceUpdate: function() {
|
326 |
+
var attrs = wpLink.getAttrs(),
|
327 |
+
link, text;
|
328 |
|
329 |
wpLink.close();
|
330 |
editor.focus();
|
333 |
editor.selection.moveToBookmark( editor.windowManager.bookmark );
|
334 |
}
|
335 |
|
336 |
+
if ( ! attrs.href ) {
|
|
|
|
|
|
|
337 |
editor.execCommand( 'unlink' );
|
338 |
return;
|
339 |
}
|
340 |
|
341 |
+
link = getLink();
|
342 |
+
text = inputs.text.val();
|
343 |
+
|
344 |
if ( link ) {
|
345 |
+
if ( text ) {
|
346 |
+
if ( 'innerText' in link ) {
|
347 |
+
link.innerText = text;
|
348 |
+
} else {
|
349 |
+
link.textContent = text;
|
350 |
+
}
|
351 |
+
}
|
352 |
+
|
353 |
editor.dom.setAttribs( link, attrs );
|
354 |
} else {
|
355 |
+
if ( text ) {
|
356 |
+
editor.selection.setNode( editor.dom.create( 'a', attrs, text ) );
|
357 |
+
} else {
|
358 |
+
editor.execCommand( 'mceInsertLink', false, attrs );
|
359 |
+
}
|
360 |
}
|
|
|
|
|
|
|
361 |
},
|
362 |
|
363 |
updateFields: function( e, li ) {
|
364 |
inputs.url.val( li.children( '.item-permalink' ).val() );
|
|
|
365 |
},
|
366 |
|
367 |
setDefaultValues: function() {
|
368 |
+
var selection,
|
369 |
emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
|
370 |
urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;
|
371 |
|
372 |
+
if ( this.isMCE() ) {
|
373 |
+
selection = editor.selection.getContent();
|
374 |
+
} else if ( document.selection && wpLink.range ) {
|
375 |
+
selection = wpLink.range.text;
|
376 |
+
} else if ( typeof this.textarea.selectionStart !== 'undefined' ) {
|
377 |
+
selection = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd );
|
378 |
+
}
|
379 |
+
|
380 |
if ( selection && emailRegexp.test( selection ) ) {
|
381 |
// Selection is email address
|
382 |
inputs.url.val( 'mailto:' + selection );
|
385 |
inputs.url.val( selection.replace( /&|�?38;/gi, '&' ) );
|
386 |
} else {
|
387 |
// Set URL to default.
|
388 |
+
inputs.url.val( '' );
|
389 |
}
|
390 |
|
|
|
|
|
|
|
391 |
// Update save prompt.
|
392 |
inputs.submit.val( wpLinkL10n.save );
|
393 |
},
|
405 |
return;
|
406 |
|
407 |
wpLink.lastSearch = search;
|
408 |
+
waiting = t.parent().find( '.spinner' ).addClass( 'is-active' );
|
409 |
|
410 |
rivers.search.change( search );
|
411 |
rivers.search.ajax( function() {
|
412 |
+
waiting.removeClass( 'is-active' );
|
413 |
});
|
414 |
} else {
|
415 |
rivers.search.hide();
|
645 |
if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold )
|
646 |
return;
|
647 |
|
648 |
+
self.waiting.addClass( 'is-active' );
|
649 |
el.scrollTop( newTop + self.waiting.outerHeight() );
|
650 |
|
651 |
self.ajax( function() {
|
652 |
+
self.waiting.removeClass( 'is-active' );
|
653 |
});
|
654 |
}, wpLink.timeToTriggerRiver );
|
655 |
}
|
js/wplink.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var wpLink;!function(a){
|
1 |
+
var wpLink;!function(a){function b(){return c.dom.getParent(c.selection.getNode(),"a")}var c,d,e,f,g,h={},i={},j="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){function b(){var b=a.trim(h.url.val());b&&g!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(h.url.val("http://"+b),g=b)}h.wrap=a("#wp-link-wrap"),h.dialog=a("#wp-link"),h.backdrop=a("#wp-link-backdrop"),h.submit=a("#wp-link-submit"),h.close=a("#wp-link-close"),h.text=a("#wp-link-text"),h.url=a("#wp-link-url"),h.nonce=a("#_ajax_linking_nonce"),h.openInNewTab=a("#wp-link-target"),h.search=a("#wp-link-search"),i.search=new e(a("#search-results")),i.recent=new e(a("#most-recent-results")),i.elements=h.dialog.find(".query-results"),h.queryNotice=a("#query-notice-message"),h.queryNoticeTextDefault=h.queryNotice.find(".query-notice-default"),h.queryNoticeTextHint=h.queryNotice.find(".query-notice-hint"),h.dialog.keydown(wpLink.keydown),h.dialog.keyup(wpLink.keyup),h.submit.click(function(a){a.preventDefault(),wpLink.update()}),h.close.add(h.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),i.elements.on("river-select",wpLink.updateFields),h.search.on("focus.wplink",function(){h.queryNoticeTextDefault.hide(),h.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){h.queryNoticeTextDefault.show(),h.queryNoticeTextHint.addClass("screen-reader-text").hide()}),h.search.keyup(function(){var a=this;window.clearTimeout(d),d=window.setTimeout(function(){wpLink.searchInternalLinks.call(a)},500)}),h.url.on("paste",function(){setTimeout(b,0)}),h.url.on("blur",b)},open:function(b){var d;a(document.body).addClass("modal-open"),wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(d=tinymce.get(wpActiveEditor),c=d&&!d.isHidden()?d:null,c&&tinymce.isIE&&(c.windowManager.bookmark=c.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),h.wrap.show(),h.backdrop.show(),wpLink.refresh(),a(document).trigger("wplink-open",h.wrap))},isMCE:function(){return c&&!c.isHidden()},refresh:function(){i.search.refresh(),i.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():(h.wrap.removeClass("has-text-field"),h.text.val(""),wpLink.setDefaultValues()),j?h.url.focus().blur():h.url.focus()[0].select(),i.recent.ul.children().length||i.recent.ajax(),g=h.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b=c.selection.getContent();if(/</.test(b)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(b)||-1===b.indexOf("href=")))return!1;if(a){var d,e=a.childNodes;if(0===e.length)return!1;for(d=e.length-1;d>=0;d--)if(3!=e[d].nodeType)return!1}return!0},mceRefresh:function(){var a,b=c.selection.getNode(),d=c.dom.getParent(b,"a[href]"),e=this.hasSelectedText(d);d?(a=d.innerText||d.textContent,h.url.val(c.dom.getAttrib(d,"href")),h.openInNewTab.prop("checked","_blank"===c.dom.getAttrib(d,"target")),h.submit.val(wpLinkL10n.update)):(a=c.selection.getContent({format:"text"}),this.setDefaultValues()),e?(h.text.val(a||""),h.wrap.addClass("has-text-field")):(h.text.val(""),h.wrap.removeClass("has-text-field"))},close:function(){a(document.body).removeClass("modal-open"),wpLink.isMCE()?c.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),h.backdrop.hide(),h.wrap.hide(),g=!1,a(document).trigger("wplink-close",h.wrap)},getAttrs:function(){return{href:a.trim(h.url.val()),target:h.openInNewTab.prop("checked")?"_blank":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,e,f,g,i=wpLink.textarea;i&&(a=wpLink.getAttrs(),b=h.text.val(),a.href&&(c='<a href="'+a.href+'"',a.target&&(c+=' target="'+a.target+'"'),c+=">",document.selection&&wpLink.range?(i.focus(),wpLink.range.text=c+(b||wpLink.range.text)+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof i.selectionStart&&(d=i.selectionStart,e=i.selectionEnd,g=b||i.value.substring(d,e),c=c+g+"</a>",f=d+c.length,d!==e||g||(f-=4),i.value=i.value.substring(0,d)+c+i.value.substring(e,i.value.length),i.selectionStart=i.selectionEnd=f),wpLink.close(),i.focus()))},mceUpdate:function(){var a,d,e=wpLink.getAttrs();return wpLink.close(),c.focus(),tinymce.isIE&&c.selection.moveToBookmark(c.windowManager.bookmark),e.href?(a=b(),d=h.text.val(),void(a?(d&&("innerText"in a?a.innerText=d:a.textContent=d),c.dom.setAttribs(a,e)):d?c.selection.setNode(c.dom.create("a",e,d)):c.execCommand("mceInsertLink",!1,e))):void c.execCommand("unlink")},updateFields:function(a,b){h.url.val(b.children(".item-permalink").val())},setDefaultValues:function(){var a,b=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,d=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;this.isMCE()?a=c.selection.getContent():document.selection&&wpLink.range?a=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)),h.url.val(a&&b.test(a)?"mailto:"+a:a&&d.test(a)?a.replace(/&|�?38;/gi,"&"):""),h.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var b,c=a(this),d=c.val();if(d.length>1){if(i.recent.hide(),i.search.show(),wpLink.lastSearch==d)return;wpLink.lastSearch=d,b=c.parent().find(".spinner").addClass("is-active"),i.search.change(d),i.search.ajax(function(){b.removeClass("is-active")})}else i.search.hide(),i.recent.show()},next:function(){i.search.next(),i.recent.next()},prev:function(){i.search.prev(),i.recent.prev()},keydown:function(b){var c,d,e=a.ui.keyCode;e.ESCAPE===b.keyCode?(wpLink.close(),b.stopImmediatePropagation()):e.TAB===b.keyCode&&(d=b.target.id,"wp-link-submit"!==d||b.shiftKey?"wp-link-close"===d&&b.shiftKey&&(h.submit.focus(),b.preventDefault()):(h.close.focus(),b.preventDefault())),(b.keyCode===e.UP||b.keyCode===e.DOWN)&&(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(c=b.keyCode===e.UP?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[c](),wpLink.keyInterval=setInterval(wpLink[c],wpLink.keySensitivity),b.preventDefault())},keyup:function(b){var c=a.ui.keyCode;(b.which===c.UP||b.which===c.DOWN)&&(clearInterval(wpLink.keyInterval),b.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a},toggleInternalLinking:function(a){var b=h.wrap.hasClass("search-panel-visible");h.wrap.toggleClass("search-panel-visible",!b),setUserSetting("wplink",b?"0":"1"),h[b?"url":"search"].focus(),a.preventDefault()}},e=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(e.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),0>e?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new f(a),this.element.scrollTop(0))},process:function(b,c){var d="",e=!0,f="",g=1==c.page;b?a.each(b,function(){f=e?"alternate":"",f+=this.title?"":" no-title",d+=f?'<li class="'+f+'">':"<li>",d+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',d+='<span class="item-title">',d+=this.title?this.title:wpLinkL10n.noTitle,d+='</span><span class="item-info">'+this.info+"</span></li>",e=!e}):g&&(d+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[g?"html":"append"](d)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var c=b.scrollTop(),d=c+b.height();!a.query.ready()||d<a.contentHeight.height()-wpLink.riverBottomThreshold||(a.waiting.addClass("is-active"),b.scrollTop(c+a.waiting.outerHeight()),a.ajax(function(){a.waiting.removeClass("is-active")}))},wpLink.timeToTriggerRiver)}}),f=function(a){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=a},a.extend(f.prototype,{ready:function(){return!(this.querying||this.allLoaded)},ajax:function(b){var c=this,d={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:h.nonce.val()};this.search&&(d.search=this.search),this.querying=!0,a.post(ajaxurl,d,function(a){c.page++,c.querying=!1,c.allLoaded=!a,b(a,d)},"json")}}),a(document).ready(wpLink.init)}(jQuery);
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== WP Multibyte Patch ===
|
2 |
Contributors: tenpura
|
3 |
Tags: multibyte,i18n,wp-multibyte-patch,Japanese
|
4 |
-
Requires at least: 4.
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 2.
|
7 |
|
8 |
Multibyte functionality enhancement for the WordPress Japanese package.
|
9 |
|
1 |
=== WP Multibyte Patch ===
|
2 |
Contributors: tenpura
|
3 |
Tags: multibyte,i18n,wp-multibyte-patch,Japanese
|
4 |
+
Requires at least: 4.1-RC1
|
5 |
+
Tested up to: 4.2
|
6 |
+
Stable tag: 2.3
|
7 |
|
8 |
Multibyte functionality enhancement for the WordPress Japanese package.
|
9 |
|
wp-multibyte-patch.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: WP Multibyte Patch
|
4 |
Description: Multibyte functionality enhancement for the WordPress Japanese package.
|
5 |
-
Version: 2.
|
6 |
Plugin URI: http://eastcoder.com/code/wp-multibyte-patch/
|
7 |
Author: Seisuke Kuraishi
|
8 |
Author URI: http://tinybit.co.jp/
|
@@ -15,9 +15,9 @@ Domain Path: /languages
|
|
15 |
* Multibyte functionality enhancement for the WordPress Japanese package.
|
16 |
*
|
17 |
* @package WP_Multibyte_Patch
|
18 |
-
* @version 2.
|
19 |
* @author Seisuke Kuraishi <210pura@gmail.com>
|
20 |
-
* @copyright Copyright (c)
|
21 |
* @license http://opensource.org/licenses/gpl-2.0.php GPLv2
|
22 |
* @link http://eastcoder.com/code/wp-multibyte-patch/
|
23 |
*/
|
@@ -62,7 +62,7 @@ class multibyte_patch {
|
|
62 |
var $debug_suffix = '';
|
63 |
var $textdomain = 'wp-multibyte-patch';
|
64 |
var $lang_dir = 'languages';
|
65 |
-
var $required_version = '4.
|
66 |
var $query_based_vars = array();
|
67 |
|
68 |
// For fallback purpose only. (1.6)
|
@@ -273,12 +273,12 @@ class multibyte_patch {
|
|
273 |
|
274 |
function wplink_js( &$scripts ) {
|
275 |
global $wp_version;
|
276 |
-
$script_required_version = '4.
|
277 |
|
278 |
if ( version_compare( substr( $wp_version, 0, strlen( $script_required_version ) ), $script_required_version, '<' ) )
|
279 |
-
$scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "js/
|
280 |
else
|
281 |
-
$scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "js/wplink{$this->debug_suffix}.js", array( 'jquery' ), '
|
282 |
}
|
283 |
|
284 |
function word_count_js( &$scripts ) {
|
2 |
/*
|
3 |
Plugin Name: WP Multibyte Patch
|
4 |
Description: Multibyte functionality enhancement for the WordPress Japanese package.
|
5 |
+
Version: 2.3
|
6 |
Plugin URI: http://eastcoder.com/code/wp-multibyte-patch/
|
7 |
Author: Seisuke Kuraishi
|
8 |
Author URI: http://tinybit.co.jp/
|
15 |
* Multibyte functionality enhancement for the WordPress Japanese package.
|
16 |
*
|
17 |
* @package WP_Multibyte_Patch
|
18 |
+
* @version 2.3
|
19 |
* @author Seisuke Kuraishi <210pura@gmail.com>
|
20 |
+
* @copyright Copyright (c) 2015 Seisuke Kuraishi, Tinybit Inc.
|
21 |
* @license http://opensource.org/licenses/gpl-2.0.php GPLv2
|
22 |
* @link http://eastcoder.com/code/wp-multibyte-patch/
|
23 |
*/
|
62 |
var $debug_suffix = '';
|
63 |
var $textdomain = 'wp-multibyte-patch';
|
64 |
var $lang_dir = 'languages';
|
65 |
+
var $required_version = '4.1-RC1';
|
66 |
var $query_based_vars = array();
|
67 |
|
68 |
// For fallback purpose only. (1.6)
|
273 |
|
274 |
function wplink_js( &$scripts ) {
|
275 |
global $wp_version;
|
276 |
+
$script_required_version = '4.2-RC1';
|
277 |
|
278 |
if ( version_compare( substr( $wp_version, 0, strlen( $script_required_version ) ), $script_required_version, '<' ) )
|
279 |
+
$scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "js/20141213/wplink{$this->debug_suffix}.js", array( 'jquery' ), '20141213', 1 );
|
280 |
else
|
281 |
+
$scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "js/wplink{$this->debug_suffix}.js", array( 'jquery' ), '20150419', 1 );
|
282 |
}
|
283 |
|
284 |
function word_count_js( &$scripts ) {
|