WP Multibyte Patch - Version 2.2

Version Description

Download this release

Release Info

Developer tenpura
Plugin Icon wp plugin WP Multibyte Patch
Version 2.2
Comparing to
See all releases

Code changes from version 2.1.1 to 2.2

ext/ja/class.php CHANGED
@@ -3,7 +3,7 @@
3
  * WP Multibyte Patch Japanese Locale Extension
4
  *
5
  * @package WP_Multibyte_Patch
6
- * @version 2.1.1
7
  * @author Seisuke Kuraishi <210pura@gmail.com>
8
  * @copyright Copyright (c) 2014 Seisuke Kuraishi, Tinybit Inc.
9
  * @license http://opensource.org/licenses/gpl-2.0.php GPLv2
3
  * WP Multibyte Patch Japanese Locale Extension
4
  *
5
  * @package WP_Multibyte_Patch
6
+ * @version 2.2
7
  * @author Seisuke Kuraishi <210pura@gmail.com>
8
  * @copyright Copyright (c) 2014 Seisuke Kuraishi, Tinybit Inc.
9
  * @license http://opensource.org/licenses/gpl-2.0.php GPLv2
js/20140410/wplink.min.js DELETED
@@ -1 +0,0 @@
1
- var wpLink;!function(a){var b,c,d,e,f={},g={};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.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").click(wpLink.toggleInternalLinking),g.elements.on("river-select",wpLink.updateFields),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())},isMCE:function(){return b&&!b.isHidden()},refresh:function(){g.search.refresh(),g.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():wpLink.setDefaultValues(),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()},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,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),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,c){f.url.val(b.children(".item-permalink").val()),f.title.val(b.hasClass("no-title")?"":b.children(".item-title").text()),c&&"click"==c.type&&f.url.focus()},setDefaultValues:function(){f.url.val("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)&&(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(){var a=f.wrap.hasClass("search-panel-visible");f.wrap.toggleClass("search-panel-visible",!a),setUserSetting("wplink",a?"0":"1"),f[a?"url":"search"].focus()}},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"><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/{20140410 → 20140817}/wplink.js RENAMED
@@ -2,7 +2,10 @@
2
  var wpLink;
3
 
4
  ( function( $ ) {
5
- var inputs = {}, rivers = {}, editor, searchTimer, River, Query;
 
 
 
6
 
7
  wpLink = {
8
  timeToTriggerRiver: 150,
@@ -31,6 +34,11 @@ var wpLink;
31
  rivers.recent = new River( $( '#most-recent-results' ) );
32
  rivers.elements = inputs.dialog.find( '.query-results' );
33
 
 
 
 
 
 
34
  // Bind event handlers
35
  inputs.dialog.keydown( wpLink.keydown );
36
  inputs.dialog.keyup( wpLink.keyup );
@@ -43,10 +51,19 @@ var wpLink;
43
  wpLink.close();
44
  });
45
 
46
- $( '#wp-link-search-toggle' ).click( wpLink.toggleInternalLinking );
47
 
48
  rivers.elements.on( 'river-select', wpLink.updateFields );
49
 
 
 
 
 
 
 
 
 
 
50
  inputs.search.keyup( function() {
51
  var self = this;
52
 
@@ -59,7 +76,7 @@ var wpLink;
59
 
60
  open: function( editorId ) {
61
  var ed;
62
-
63
  wpLink.range = null;
64
 
65
  if ( editorId ) {
@@ -95,6 +112,7 @@ var wpLink;
95
  inputs.backdrop.show();
96
 
97
  wpLink.refresh();
 
98
  },
99
 
100
  isMCE: function() {
@@ -106,18 +124,26 @@ var wpLink;
106
  rivers.search.refresh();
107
  rivers.recent.refresh();
108
 
109
- if ( wpLink.isMCE() )
110
  wpLink.mceRefresh();
111
- else
112
  wpLink.setDefaultValues();
 
 
 
 
 
 
 
 
 
 
 
113
 
114
- // Focus the URL field and highlight its contents.
115
- // If this is moved above the selection changes,
116
- // IE will show a flashing cursor over the dialog.
117
- inputs.url.focus()[0].select();
118
  // Load the most recent results if this is the first time opening the panel.
119
- if ( ! rivers.recent.ul.children().length )
120
  rivers.recent.ajax();
 
121
  },
122
 
123
  mceRefresh: function() {
@@ -153,6 +179,7 @@ var wpLink;
153
 
154
  inputs.backdrop.hide();
155
  inputs.wrap.hide();
 
156
  },
157
 
158
  getAttrs: function() {
@@ -260,17 +287,28 @@ var wpLink;
260
  editor.selection.collapse();
261
  },
262
 
263
- updateFields: function( e, li, originalEvent ) {
264
  inputs.url.val( li.children( '.item-permalink' ).val() );
265
  inputs.title.val( li.hasClass( 'no-title' ) ? '' : li.children( '.item-title' ).text() );
266
- if ( originalEvent && originalEvent.type == 'click' )
267
- inputs.url.focus();
268
  },
269
 
270
  setDefaultValues: function() {
271
- // Set URL and description to defaults.
272
- // Leave the new tab setting as-is.
273
- inputs.url.val( 'http://' );
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  inputs.title.val( '' );
275
 
276
  // Update save prompt.
@@ -322,6 +360,8 @@ var wpLink;
322
  } else if ( key.TAB === event.keyCode ) {
323
  id = event.target.id;
324
 
 
 
325
  if ( id === 'wp-link-submit' && ! event.shiftKey ) {
326
  inputs.close.focus();
327
  event.preventDefault();
@@ -335,6 +375,11 @@ var wpLink;
335
  return;
336
  }
337
 
 
 
 
 
 
338
  fn = event.keyCode === key.UP ? 'prev' : 'next';
339
  clearInterval( wpLink.keyInterval );
340
  wpLink[ fn ]();
@@ -374,12 +419,13 @@ var wpLink;
374
  };
375
  },
376
 
377
- toggleInternalLinking: function() {
378
  var visible = inputs.wrap.hasClass( 'search-panel-visible' );
379
 
380
  inputs.wrap.toggleClass( 'search-panel-visible', ! visible );
381
  setUserSetting( 'wplink', visible ? '0' : '1' );
382
  inputs[ ! visible ? 'search' : 'url' ].focus();
 
383
  }
384
  };
385
 
@@ -489,7 +535,7 @@ var wpLink;
489
 
490
  if ( ! results ) {
491
  if ( firstPage ) {
492
- list += '<li class="unselectable"><span class="item-title"><em>' +
493
  wpLinkL10n.noMatchesFound + '</em></span></li>';
494
  }
495
  } else {
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,
34
  rivers.recent = new River( $( '#most-recent-results' ) );
35
  rivers.elements = inputs.dialog.find( '.query-results' );
36
 
37
+ // Get search notice text
38
+ inputs.queryNotice = $( '#query-notice-message' );
39
+ inputs.queryNoticeTextDefault = inputs.queryNotice.find( '.query-notice-default' );
40
+ inputs.queryNoticeTextHint = inputs.queryNotice.find( '.query-notice-hint' );
41
+
42
  // Bind event handlers
43
  inputs.dialog.keydown( wpLink.keydown );
44
  inputs.dialog.keyup( wpLink.keyup );
51
  wpLink.close();
52
  });
53
 
54
+ $( '#wp-link-search-toggle' ).on( 'click', wpLink.toggleInternalLinking );
55
 
56
  rivers.elements.on( 'river-select', wpLink.updateFields );
57
 
58
+ // Display 'hint' message when search field or 'query-results' box are focused
59
+ inputs.search.on( 'focus.wplink', function() {
60
+ inputs.queryNoticeTextDefault.hide();
61
+ inputs.queryNoticeTextHint.removeClass( 'screen-reader-text' ).show();
62
+ } ).on( 'blur.wplink', function() {
63
+ inputs.queryNoticeTextDefault.show();
64
+ inputs.queryNoticeTextHint.addClass( 'screen-reader-text' ).hide();
65
+ } );
66
+
67
  inputs.search.keyup( function() {
68
  var self = this;
69
 
76
 
77
  open: function( editorId ) {
78
  var ed;
79
+
80
  wpLink.range = null;
81
 
82
  if ( editorId ) {
112
  inputs.backdrop.show();
113
 
114
  wpLink.refresh();
115
+ $( document ).trigger( 'wplink-open', inputs.wrap );
116
  },
117
 
118
  isMCE: function() {
124
  rivers.search.refresh();
125
  rivers.recent.refresh();
126
 
127
+ if ( wpLink.isMCE() ) {
128
  wpLink.mceRefresh();
129
+ } else {
130
  wpLink.setDefaultValues();
131
+ }
132
+
133
+ if ( isTouch ) {
134
+ // Close the onscreen keyboard
135
+ inputs.url.focus().blur();
136
+ } else {
137
+ // Focus the URL field and highlight its contents.
138
+ // If this is moved above the selection changes,
139
+ // IE will show a flashing cursor over the dialog.
140
+ inputs.url.focus()[0].select();
141
+ }
142
 
 
 
 
 
143
  // Load the most recent results if this is the first time opening the panel.
144
+ if ( ! rivers.recent.ul.children().length ) {
145
  rivers.recent.ajax();
146
+ }
147
  },
148
 
149
  mceRefresh: function() {
179
 
180
  inputs.backdrop.hide();
181
  inputs.wrap.hide();
182
+ $( document ).trigger( 'wplink-close', inputs.wrap );
183
  },
184
 
185
  getAttrs: function() {
287
  editor.selection.collapse();
288
  },
289
 
290
+ updateFields: function( e, li ) {
291
  inputs.url.val( li.children( '.item-permalink' ).val() );
292
  inputs.title.val( li.hasClass( 'no-title' ) ? '' : li.children( '.item-title' ).text() );
 
 
293
  },
294
 
295
  setDefaultValues: function() {
296
+ var selection = editor && editor.selection.getContent(),
297
+ emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
298
+ urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;
299
+
300
+ if ( selection && emailRegexp.test( selection ) ) {
301
+ // Selection is email address
302
+ inputs.url.val( 'mailto:' + selection );
303
+ } else if ( selection && urlRegexp.test( selection ) ) {
304
+ // Selection is URL
305
+ inputs.url.val( selection.replace( /&amp;|&#0?38;/gi, '&' ) );
306
+ } else {
307
+ // Set URL to default.
308
+ inputs.url.val( 'http://' );
309
+ }
310
+
311
+ // Set description to default.
312
  inputs.title.val( '' );
313
 
314
  // Update save prompt.
360
  } else if ( key.TAB === event.keyCode ) {
361
  id = event.target.id;
362
 
363
+ // wp-link-submit must always be the last focusable element in the dialog.
364
+ // following focusable elements will be skipped on keyboard navigation.
365
  if ( id === 'wp-link-submit' && ! event.shiftKey ) {
366
  inputs.close.focus();
367
  event.preventDefault();
375
  return;
376
  }
377
 
378
+ if ( document.activeElement &&
379
+ ( document.activeElement.id === 'link-title-field' || document.activeElement.id === 'url-field' ) ) {
380
+ return;
381
+ }
382
+
383
  fn = event.keyCode === key.UP ? 'prev' : 'next';
384
  clearInterval( wpLink.keyInterval );
385
  wpLink[ fn ]();
419
  };
420
  },
421
 
422
+ toggleInternalLinking: function( event ) {
423
  var visible = inputs.wrap.hasClass( 'search-panel-visible' );
424
 
425
  inputs.wrap.toggleClass( 'search-panel-visible', ! visible );
426
  setUserSetting( 'wplink', visible ? '0' : '1' );
427
  inputs[ ! visible ? 'search' : 'url' ].focus();
428
+ event.preventDefault();
429
  }
430
  };
431
 
535
 
536
  if ( ! results ) {
537
  if ( firstPage ) {
538
+ list += '<li class="unselectable no-matches-found"><span class="item-title"><em>' +
539
  wpLinkL10n.noMatchesFound + '</em></span></li>';
540
  }
541
  } else {
js/20140817/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;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,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),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(/&amp;|&#0?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
@@ -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/wplink.min.js CHANGED
@@ -1 +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;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,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),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(/&amp;|&#0?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);
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,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),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(/&amp;|&#0?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);
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: 3.9-RC1
5
- Tested up to: 4.0
6
- Stable tag: 2.1.1
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.0-beta4
5
+ Tested up to: 4.1
6
+ Stable tag: 2.2
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.1.1
6
  Plugin URI: http://eastcoder.com/code/wp-multibyte-patch/
7
  Author: Seisuke Kuraishi
8
  Author URI: http://tinybit.co.jp/
@@ -15,7 +15,7 @@ Domain Path: /languages
15
  * Multibyte functionality enhancement for the WordPress Japanese package.
16
  *
17
  * @package WP_Multibyte_Patch
18
- * @version 2.1.1
19
  * @author Seisuke Kuraishi <210pura@gmail.com>
20
  * @copyright Copyright (c) 2014 Seisuke Kuraishi, Tinybit Inc.
21
  * @license http://opensource.org/licenses/gpl-2.0.php GPLv2
@@ -48,6 +48,7 @@ class multibyte_patch {
48
  'patch_force_twentytwelve_open_sans_off' => false,
49
  'patch_force_twentythirteen_google_fonts_off' => false,
50
  'patch_force_twentyfourteen_google_fonts_off' => false,
 
51
  'patch_sanitize_file_name' => true,
52
  'patch_bp_create_excerpt' => false,
53
  'bp_excerpt_mblength' => 110,
@@ -61,7 +62,7 @@ class multibyte_patch {
61
  var $debug_suffix = '';
62
  var $textdomain = 'wp-multibyte-patch';
63
  var $lang_dir = 'languages';
64
- var $required_version = '3.9-RC1';
65
  var $query_based_vars = array();
66
 
67
  // For fallback purpose only. (1.6)
@@ -233,7 +234,8 @@ class multibyte_patch {
233
  return preg_replace( "/<a [^<>]+>([^<>]+)<\/a>(" . preg_quote( $this->conf['bp_excerpt_more'], '/' ) . "<\/p>)$/", "$1$2", $content );
234
  }
235
 
236
- // param $excerpt could already be truncated to 20 words or less by the original get_comment_excerpt() function.
 
237
  function get_comment_excerpt( $excerpt = '' ) {
238
  $excerpt = preg_replace( "/\.\.\.$/", '', $excerpt );
239
  $blog_encoding = $this->blog_encoding;
@@ -271,12 +273,12 @@ class multibyte_patch {
271
 
272
  function wplink_js( &$scripts ) {
273
  global $wp_version;
274
- $script_required_version = '4.0-beta4';
275
 
276
  if ( version_compare( substr( $wp_version, 0, strlen( $script_required_version ) ), $script_required_version, '<' ) )
277
- $scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "js/20140410/wplink{$this->debug_suffix}.js", array( 'jquery' ), '20140410', 1 );
278
  else
279
- $scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "js/wplink{$this->debug_suffix}.js", array( 'jquery' ), '20140817', 1 );
280
  }
281
 
282
  function word_count_js( &$scripts ) {
@@ -301,6 +303,19 @@ class multibyte_patch {
301
  wp_dequeue_style( 'twentyfourteen-lato' );
302
  }
303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  function query_based_settings() {
305
  $is_query_funcs = array( 'is_feed', 'is_404', 'is_search', 'is_tax', 'is_front_page', 'is_home', 'is_attachment', 'is_single', 'is_page', 'is_category', 'is_tag', 'is_author', 'is_date', 'is_archive', 'is_paged' );
306
 
@@ -340,6 +355,10 @@ class multibyte_patch {
340
  add_action( 'wp_enqueue_scripts', array( $this, 'force_twentyfourteen_google_fonts_off' ), 99 );
341
  add_action( 'admin_print_scripts-appearance_page_custom-header', array( $this, 'force_twentyfourteen_google_fonts_off' ), 99 );
342
  }
 
 
 
 
343
  }
344
 
345
  function filters() {
@@ -433,6 +452,8 @@ class multibyte_patch {
433
  function __construct() {
434
  $this->load_conf();
435
  $this->blog_encoding = get_option( 'blog_charset' );
 
 
436
 
437
  // mbstring functions are required for non UTF-8 blog.
438
  if ( !preg_match( "/^utf-?8$/i", $this->blog_encoding ) )
2
  /*
3
  Plugin Name: WP Multibyte Patch
4
  Description: Multibyte functionality enhancement for the WordPress Japanese package.
5
+ Version: 2.2
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.2
19
  * @author Seisuke Kuraishi <210pura@gmail.com>
20
  * @copyright Copyright (c) 2014 Seisuke Kuraishi, Tinybit Inc.
21
  * @license http://opensource.org/licenses/gpl-2.0.php GPLv2
48
  'patch_force_twentytwelve_open_sans_off' => false,
49
  'patch_force_twentythirteen_google_fonts_off' => false,
50
  'patch_force_twentyfourteen_google_fonts_off' => false,
51
+ 'patch_force_twentyfifteen_google_fonts_off' => false,
52
  'patch_sanitize_file_name' => true,
53
  'patch_bp_create_excerpt' => false,
54
  'bp_excerpt_mblength' => 110,
62
  var $debug_suffix = '';
63
  var $textdomain = 'wp-multibyte-patch';
64
  var $lang_dir = 'languages';
65
+ var $required_version = '4.0-beta4';
66
  var $query_based_vars = array();
67
 
68
  // For fallback purpose only. (1.6)
234
  return preg_replace( "/<a [^<>]+>([^<>]+)<\/a>(" . preg_quote( $this->conf['bp_excerpt_more'], '/' ) . "<\/p>)$/", "$1$2", $content );
235
  }
236
 
237
+ // $excerpt param could already be truncated to 20 words or less by the original get_comment_excerpt() function.
238
+ // $comment param (introduced in WP 4.1) should be used instead.
239
  function get_comment_excerpt( $excerpt = '' ) {
240
  $excerpt = preg_replace( "/\.\.\.$/", '', $excerpt );
241
  $blog_encoding = $this->blog_encoding;
273
 
274
  function wplink_js( &$scripts ) {
275
  global $wp_version;
276
+ $script_required_version = '4.1-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/20140817/wplink{$this->debug_suffix}.js", array( 'jquery' ), '20140817', 1 );
280
  else
281
+ $scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "js/wplink{$this->debug_suffix}.js", array( 'jquery' ), '20141214', 1 );
282
  }
283
 
284
  function word_count_js( &$scripts ) {
303
  wp_dequeue_style( 'twentyfourteen-lato' );
304
  }
305
 
306
+ function force_twentyfifteen_google_fonts_off() {
307
+ global $wp_styles;
308
+
309
+ wp_dequeue_style( 'twentyfifteen-fonts' );
310
+
311
+ $styles = $wp_styles->query( 'twentyfifteen-style' );
312
+
313
+ if ( !empty( $styles->deps ) && is_array( $styles->deps ) ) {
314
+ if ( false !== $key = array_search( 'twentyfifteen-fonts', $styles->deps ) )
315
+ unset( $styles->deps[$key] );
316
+ }
317
+ }
318
+
319
  function query_based_settings() {
320
  $is_query_funcs = array( 'is_feed', 'is_404', 'is_search', 'is_tax', 'is_front_page', 'is_home', 'is_attachment', 'is_single', 'is_page', 'is_category', 'is_tag', 'is_author', 'is_date', 'is_archive', 'is_paged' );
321
 
355
  add_action( 'wp_enqueue_scripts', array( $this, 'force_twentyfourteen_google_fonts_off' ), 99 );
356
  add_action( 'admin_print_scripts-appearance_page_custom-header', array( $this, 'force_twentyfourteen_google_fonts_off' ), 99 );
357
  }
358
+
359
+ if ( false !== $this->conf['patch_force_twentyfifteen_google_fonts_off'] && 'twentyfifteen' == get_template() ) {
360
+ add_action( 'wp_enqueue_scripts', array( $this, 'force_twentyfifteen_google_fonts_off' ), 99 );
361
+ }
362
  }
363
 
364
  function filters() {
452
  function __construct() {
453
  $this->load_conf();
454
  $this->blog_encoding = get_option( 'blog_charset' );
455
+ if ( empty( $this->blog_encoding ) )
456
+ $this->blog_encoding = 'UTF-8';
457
 
458
  // mbstring functions are required for non UTF-8 blog.
459
  if ( !preg_match( "/^utf-?8$/i", $this->blog_encoding ) )
wpmp-config-sample-ja.php CHANGED
@@ -99,5 +99,6 @@ $wpmp_conf['patch_force_character_count'] = true;
99
  $wpmp_conf['patch_force_twentytwelve_open_sans_off'] = true;
100
  $wpmp_conf['patch_force_twentythirteen_google_fonts_off'] = false;
101
  $wpmp_conf['patch_force_twentyfourteen_google_fonts_off'] = false;
 
102
  $wpmp_conf['patch_sanitize_file_name'] = true;
103
  $wpmp_conf['patch_bp_create_excerpt'] = false;
99
  $wpmp_conf['patch_force_twentytwelve_open_sans_off'] = true;
100
  $wpmp_conf['patch_force_twentythirteen_google_fonts_off'] = false;
101
  $wpmp_conf['patch_force_twentyfourteen_google_fonts_off'] = false;
102
+ $wpmp_conf['patch_force_twentyfifteen_google_fonts_off'] = false;
103
  $wpmp_conf['patch_sanitize_file_name'] = true;
104
  $wpmp_conf['patch_bp_create_excerpt'] = false;