Fix JSHint errors in wplink.js.
props jorbin. fixes #25914. git-svn-id: https://develop.svn.wordpress.org/trunk@26193 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c4e0aa63d9
commit
61eedb9d34
@ -1,3 +1,4 @@
|
|||||||
|
/* global ajaxurl, tinymce, wpLinkL10n, tinyMCEPopup, setUserSetting, wpActiveEditor */
|
||||||
var wpLink;
|
var wpLink;
|
||||||
|
|
||||||
(function($){
|
(function($){
|
||||||
@ -113,7 +114,7 @@ var wpLink;
|
|||||||
inputs.url.val( ed.dom.getAttrib(e, 'href') );
|
inputs.url.val( ed.dom.getAttrib(e, 'href') );
|
||||||
inputs.title.val( ed.dom.getAttrib(e, 'title') );
|
inputs.title.val( ed.dom.getAttrib(e, 'title') );
|
||||||
// Set open in new tab.
|
// Set open in new tab.
|
||||||
inputs.openInNewTab.prop('checked', ( "_blank" == ed.dom.getAttrib( e, 'target' ) ) );
|
inputs.openInNewTab.prop('checked', ( '_blank' == ed.dom.getAttrib( e, 'target' ) ) );
|
||||||
// Update save prompt.
|
// Update save prompt.
|
||||||
inputs.submit.val( wpLinkL10n.update );
|
inputs.submit.val( wpLinkL10n.update );
|
||||||
|
|
||||||
@ -156,7 +157,7 @@ var wpLink;
|
|||||||
},
|
},
|
||||||
|
|
||||||
htmlUpdate : function() {
|
htmlUpdate : function() {
|
||||||
var attrs, html, begin, end, cursor,
|
var attrs, html, begin, end, cursor, selection,
|
||||||
textarea = wpLink.textarea;
|
textarea = wpLink.textarea;
|
||||||
|
|
||||||
if ( ! textarea )
|
if ( ! textarea )
|
||||||
@ -201,9 +202,8 @@ var wpLink;
|
|||||||
if ( begin == end )
|
if ( begin == end )
|
||||||
cursor -= '</a>'.length;
|
cursor -= '</a>'.length;
|
||||||
|
|
||||||
textarea.value = textarea.value.substring( 0, begin )
|
textarea.value = textarea.value.substring( 0, begin ) + html +
|
||||||
+ html
|
textarea.value.substring( end, textarea.value.length );
|
||||||
+ textarea.value.substring( end, textarea.value.length );
|
|
||||||
|
|
||||||
// Update cursor position
|
// Update cursor position
|
||||||
textarea.selectionStart = textarea.selectionEnd = cursor;
|
textarea.selectionStart = textarea.selectionEnd = cursor;
|
||||||
@ -227,17 +227,17 @@ var wpLink;
|
|||||||
b = ed.selection.getBookmark();
|
b = ed.selection.getBookmark();
|
||||||
ed.dom.remove(e, 1);
|
ed.dom.remove(e, 1);
|
||||||
ed.selection.moveToBookmark(b);
|
ed.selection.moveToBookmark(b);
|
||||||
tinyMCEPopup.execCommand("mceEndUndoLevel");
|
tinyMCEPopup.execCommand('mceEndUndoLevel');
|
||||||
wpLink.close();
|
wpLink.close();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
ed.getDoc().execCommand("unlink", false, null);
|
ed.getDoc().execCommand('unlink', false, null);
|
||||||
tinyMCEPopup.execCommand("mceInsertLink", false, "#mce_temp_url#", {skip_undo : 1});
|
tinyMCEPopup.execCommand('mceInsertLink', false, '#mce_temp_url#', {skip_undo : 1});
|
||||||
|
|
||||||
tinymce.each(ed.dom.select("a"), function(n) {
|
tinymce.each(ed.dom.select('a'), function(n) {
|
||||||
if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
|
if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
|
||||||
e = n;
|
e = n;
|
||||||
ed.dom.setAttribs(e, attrs);
|
ed.dom.setAttribs(e, attrs);
|
||||||
@ -262,7 +262,7 @@ var wpLink;
|
|||||||
tinyMCEPopup.storeSelection();
|
tinyMCEPopup.storeSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
ed.execCommand("mceEndUndoLevel");
|
ed.execCommand('mceEndUndoLevel');
|
||||||
wpLink.close();
|
wpLink.close();
|
||||||
ed.focus();
|
ed.focus();
|
||||||
},
|
},
|
||||||
@ -270,7 +270,7 @@ var wpLink;
|
|||||||
updateFields : function( e, li, originalEvent ) {
|
updateFields : function( e, li, originalEvent ) {
|
||||||
inputs.url.val( li.children('.item-permalink').val() );
|
inputs.url.val( li.children('.item-permalink').val() );
|
||||||
inputs.title.val( li.hasClass('no-title') ? '' : li.children('.item-title').text() );
|
inputs.title.val( li.hasClass('no-title') ? '' : li.children('.item-title').text() );
|
||||||
if ( originalEvent && originalEvent.type == "click" )
|
if ( originalEvent && originalEvent.type == 'click' )
|
||||||
inputs.url.focus();
|
inputs.url.focus();
|
||||||
},
|
},
|
||||||
setDefaultValues : function() {
|
setDefaultValues : function() {
|
||||||
@ -318,39 +318,31 @@ var wpLink;
|
|||||||
keydown : function( event ) {
|
keydown : function( event ) {
|
||||||
var fn, key = $.ui.keyCode;
|
var fn, key = $.ui.keyCode;
|
||||||
|
|
||||||
switch( event.which ) {
|
if ( event.which !== key.UP && event.which !== key.DOWN ) {
|
||||||
case key.UP:
|
return;
|
||||||
fn = 'prev';
|
|
||||||
case key.DOWN:
|
|
||||||
fn = fn || 'next';
|
|
||||||
clearInterval( wpLink.keyInterval );
|
|
||||||
wpLink[ fn ]();
|
|
||||||
wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn = event.which === key.UP ? 'prev' : 'next';
|
||||||
|
clearInterval( wpLink.keyInterval );
|
||||||
|
wpLink[ fn ]();
|
||||||
|
wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
},
|
},
|
||||||
|
|
||||||
keyup: function( event ) {
|
keyup: function( event ) {
|
||||||
var key = $.ui.keyCode;
|
var key = $.ui.keyCode;
|
||||||
|
|
||||||
switch( event.which ) {
|
if ( event.which === key.ESCAPE ) {
|
||||||
case key.ESCAPE:
|
event.stopImmediatePropagation();
|
||||||
event.stopImmediatePropagation();
|
if ( ! $(document).triggerHandler( 'wp_CloseOnEscape', [{ event: event, what: 'wplink', cb: wpLink.close }] ) )
|
||||||
if ( ! $(document).triggerHandler( 'wp_CloseOnEscape', [{ event: event, what: 'wplink', cb: wpLink.close }] ) )
|
wpLink.close();
|
||||||
wpLink.close();
|
return false;
|
||||||
|
}
|
||||||
return false;
|
|
||||||
break;
|
if ( event.which === key.UP || event.which === key.DOWN ) {
|
||||||
case key.UP:
|
clearInterval( wpLink.keyInterval );
|
||||||
case key.DOWN:
|
event.preventDefault();
|
||||||
clearInterval( wpLink.keyInterval );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
delayedCallback : function( func, delay ) {
|
delayedCallback : function( func, delay ) {
|
||||||
@ -507,19 +499,18 @@ var wpLink;
|
|||||||
|
|
||||||
if ( !results ) {
|
if ( !results ) {
|
||||||
if ( firstPage ) {
|
if ( firstPage ) {
|
||||||
list += '<li class="unselectable"><span class="item-title"><em>'
|
list += '<li class="unselectable"><span class="item-title"><em>' +
|
||||||
+ wpLinkL10n.noMatchesFound
|
wpLinkL10n.noMatchesFound + '</em></span></li>';
|
||||||
+ '</em></span></li>';
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$.each( results, function() {
|
$.each( results, function() {
|
||||||
classes = alt ? 'alternate' : '';
|
classes = alt ? 'alternate' : '';
|
||||||
classes += this['title'] ? '' : ' no-title';
|
classes += this.title ? '' : ' no-title';
|
||||||
list += classes ? '<li class="' + classes + '">' : '<li>';
|
list += classes ? '<li class="' + classes + '">' : '<li>';
|
||||||
list += '<input type="hidden" class="item-permalink" value="' + this['permalink'] + '" />';
|
list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />';
|
||||||
list += '<span class="item-title">';
|
list += '<span class="item-title">';
|
||||||
list += this['title'] ? this['title'] : wpLinkL10n.noTitle;
|
list += this.title ? this.title : wpLinkL10n.noTitle;
|
||||||
list += '</span><span class="item-info">' + this['info'] + '</span></li>';
|
list += '</span><span class="item-info">' + this.info + '</span></li>';
|
||||||
alt = ! alt;
|
alt = ! alt;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -578,7 +569,7 @@ var wpLink;
|
|||||||
self.querying = false;
|
self.querying = false;
|
||||||
self.allLoaded = !r;
|
self.allLoaded = !r;
|
||||||
callback( r, query );
|
callback( r, query );
|
||||||
}, "json" );
|
}, 'json' );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user