From 606ae7ee4d1b077a488081d4dc3533c18a0f4a36 Mon Sep 17 00:00:00 2001 From: nacin Date: Tue, 2 Nov 2010 23:25:24 +0000 Subject: [PATCH] Tabs for internal linking. props koopersmith, see #11420. git-svn-id: http://svn.automattic.com/wordpress/trunk@16159 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../js/tinymce/plugins/wplink/js/wplink.js | 38 +++++------------ .../js/tinymce/wp-mce-link-includes.php | 7 ++- wp-includes/js/tinymce/wp-mce-link.php | 40 ++++++++++++------ wp-includes/js/tinymce/wp-tinymce.js.gz | Bin 85264 -> 87614 bytes 4 files changed, 43 insertions(+), 42 deletions(-) diff --git a/wp-includes/js/tinymce/plugins/wplink/js/wplink.js b/wp-includes/js/tinymce/plugins/wplink/js/wplink.js index fab3eb5bcc..c744cdf21a 100644 --- a/wp-includes/js/tinymce/plugins/wplink/js/wplink.js +++ b/wp-includes/js/tinymce/plugins/wplink/js/wplink.js @@ -66,23 +66,20 @@ inputs.title = $('#link-title-field'); // Advanced Options inputs.openInNewTab = $('#link-target-checkbox'); - // Types - inputs.typeDropdown = $('#link-type'); - inputs.typeOptions = inputs.typeDropdown.find('option'); panels = $('.link-panel'); active = $('.link-panel-active'); + $('#link-panel-tab-bar').wpTabs({ + show: function(e, widget) { + active = widget.panel; + active.addClass('link-panel-active'); + wpLink.maybeLoadPanel(); + }, + hide: function(e, widget) { + active.removeClass('link-panel-active'); + } + }) - // Extract type names - inputs.typeOptions.each( function(){ - var linkType = this.id.replace(/^link-option-id-/,''), - parts = linkType.split('-'); - $(this).data( 'link-type', { - full : linkType, - type : parts[0], - name : parts[1] || '' - }); - }); panels.each( function(){ var linkType = this.id.replace(/^link-panel-id-/,''), parts = linkType.split('-'); @@ -94,7 +91,6 @@ }); // Bind event handlers - inputs.typeDropdown.change( wpLink.selectPanel ); $('#wp-update').click( wpLink.update ); $('#wp-cancel').click( function() { tinyMCEPopup.close(); } ); $('.link-panel .wp-tab-bar').wpTabs('option', 'show', wpLink.maybeLoadPanel ); @@ -107,7 +103,6 @@ if ( ! e ) return; - // @TODO: select proper panel/fill values when a link is edited active.find('input.url-field').val( e.href ); inputs.title.val( ed.dom.getAttrib(e, 'title') ); // Advanced Options @@ -193,19 +188,6 @@ tinyMCEPopup.close(); }, - selectPanel : function( option ) { - var sel = inputs.typeOptions.filter(':selected'); - - if ( option.jquery ) { - sel.removeAttr('selected'); - sel = option.attr('selected', 'selected'); - } - - active.removeClass('link-panel-active'); - active = $('#link-panel-id-' + sel.data('link-type').full ).addClass('link-panel-active'); - wpLink.maybeLoadPanel(); - }, - maybeLoadPanel : function() { var panel = active.find('.wp-tab-panel:visible'); if ( panel.length && panel.find('.wp-tab-panel-loading').length ) diff --git a/wp-includes/js/tinymce/wp-mce-link-includes.php b/wp-includes/js/tinymce/wp-mce-link-includes.php index c818b3996f..87a81fb142 100644 --- a/wp-includes/js/tinymce/wp-mce-link-includes.php +++ b/wp-includes/js/tinymce/wp-mce-link-includes.php @@ -3,6 +3,9 @@ class WP_Tab_Bar { var $tabs = array(); + var $id = ''; + var $classes = array(); + var $selected = ''; function add( $id, $label, $url='' ) { @@ -21,7 +24,9 @@ class WP_Tab_Bar { if ( empty( $this->selected ) ) $this->selected = $this->tabs[0]['for']; - $out = "