Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -710,7 +710,6 @@ |
711 | 711 | <div id="edittoolbar-link-dialog-tab-int"><form><fieldset><table><tr>\ |
712 | 712 | <td><label for="edittoolbar-link-int-target" rel="edittoolbar-tool-link-int-target"></label></td>\ |
713 | 713 | <td>\ |
714 | | - <select id="edittoolbar-link-int-target-ns" />\ |
715 | 714 | <input type="text" id="edittoolbar-link-int-target" />\ |
716 | 715 | <div id="edittoolbar-link-int-target-status" style="display: inline;"></div>\ |
717 | 716 | </td>\ |
— | — | @@ -739,24 +738,13 @@ |
740 | 739 | request.abort(); |
741 | 740 | } |
742 | 741 | |
743 | | - var targetNSID = $j( '#edittoolbar-link-int-target-ns' ).val(); |
744 | | - if ( targetNSID < 0 ) { |
745 | | - // Can't check existence for Special: or Media: titles |
746 | | - updateWidget( 'exists' ); |
747 | | - return; |
748 | | - } |
749 | | - |
750 | | - var targetNS = $j( '#edittoolbar-link-int-target-ns option:selected' ).text(); |
751 | | - if ( targetNS != '' ) |
752 | | - targetNS += ':'; |
753 | | - var targetTitle = $j( '#edittoolbar-link-int-target' ).val(); |
754 | | - var target = targetNS + targetTitle; |
| 742 | + var target = $j( '#edittoolbar-link-int-target' ).val(); |
755 | 743 | var cache = $j( '#edittoolbar-link-int-target-status' ).data( 'existencecache' ); |
756 | 744 | if ( cache[target] ) { |
757 | 745 | updateWidget( cache[target] ); |
758 | 746 | return; |
759 | 747 | } |
760 | | - if ( targetTitle == '' ) { |
| 748 | + if ( target == '' ) { |
761 | 749 | // Hide the widget when the textbox is empty |
762 | 750 | $j( '#edittoolbar-link-int-target-status' ).children().hide(); |
763 | 751 | return; |
— | — | @@ -802,8 +790,6 @@ |
803 | 791 | }); |
804 | 792 | // Build tabs |
805 | 793 | $j( '#edittoolbar-link-tabs' ).tabs(); |
806 | | - // Set up the namespace selector |
807 | | - $j( '#edittoolbar-link-int-target-ns' ).namespaceSelector(); |
808 | 794 | // Automatically copy the value of the internal link page title field to the link text field unless the user |
809 | 795 | // has changed the link text field - this is a convience thing since most link texts are going to be the |
810 | 796 | // the same as the page title |
— | — | @@ -812,20 +798,12 @@ |
813 | 799 | if ( $j( '#edittoolbar-link-int-text' ).data( 'untouched' ) ) |
814 | 800 | // Defer this until $j(this).val() has been updated |
815 | 801 | setTimeout( function() { |
816 | | - var ns = $j( '#edittoolbar-link-int-target-ns option:selected' ).text(); |
817 | | - if ( ns != '' ) |
818 | | - ns += ':'; |
819 | | - $j( '#edittoolbar-link-int-text' ).val( ns + $j( '#edittoolbar-link-int-target' ).val() ); |
| 802 | + $j( '#edittoolbar-link-int-text' ).val( $j( '#edittoolbar-link-int-target' ).val() ); |
820 | 803 | }, 0 ); |
821 | 804 | }); |
822 | 805 | $j( '#edittoolbar-link-int-text' ).bind( 'change keypress paste cut', function() { |
823 | 806 | $j(this).data( 'untouched', false ); |
824 | 807 | }); |
825 | | - // Make sure changes to the namespace selector also trigger value copying and AJAX stuff |
826 | | - // This is ugly |
827 | | - $j( '#edittoolbar-link-int-target-ns' ).change( function() { |
828 | | - $j( '#edittoolbar-link-int-target' ).keydown().keypress().keyup(); |
829 | | - }); |
830 | 808 | // Set the initial value of the external link field to start out as a real URL |
831 | 809 | $j( '#edittoolbar-link-ext-target' ).val( 'http://' ); |
832 | 810 | // Add images to the page existence widget, which will be shown mutually exclusively to communicate if the |
— | — | @@ -886,44 +864,26 @@ |
887 | 865 | $j( '#edittoolbar-link-int-target' ).data( 'suggcache', {} ).suggestions( { |
888 | 866 | fetch: function( query ) { |
889 | 867 | var that = this; |
890 | | - var ns = $j( '#edittoolbar-link-int-target-ns' ).val(); |
891 | 868 | var title = $j(this).val(); |
892 | | - if ( ns < 0 ) { |
893 | | - // Can't search for Special: or Media: titles |
894 | | - $j(this).suggestions( 'suggestions', [] ); |
895 | | - return; |
896 | | - } |
897 | 869 | |
898 | 870 | var cache = $j(this).data( 'suggcache' ); |
899 | | - if ( typeof cache[ns] != 'undefined' && |
900 | | - typeof cache[ns][title] != 'undefined' ) { |
901 | | - $j(this).suggestions( 'suggestions', cache[ns][title] ); |
| 871 | + if ( typeof cache[title] != 'undefined' ) { |
| 872 | + $j(this).suggestions( 'suggestions', cache[title] ); |
902 | 873 | return; |
903 | 874 | } |
904 | 875 | |
905 | 876 | var request = $j.ajax( { |
906 | 877 | url: wgScriptPath + '/api.php', |
907 | 878 | data: { |
908 | | - 'action': 'query', |
909 | | - 'list': 'allpages', |
910 | | - 'apnamespace': ns, |
911 | | - 'apprefix': title, |
912 | | - 'aplimit': '10', |
| 879 | + 'action': 'opensearch', |
| 880 | + 'search': title, |
| 881 | + 'namespace': 0, |
| 882 | + 'suggest': '', |
913 | 883 | 'format': 'json' |
914 | 884 | }, |
915 | 885 | dataType: 'json', |
916 | 886 | success: function( data ) { |
917 | | - var titles = []; |
918 | | - for ( var i = 0; i < data.query.allpages.length; i++ ) { |
919 | | - titles[i] = data.query.allpages[i].title; |
920 | | - if ( ns != 0 ) |
921 | | - titles[i] = titles[i].substr( |
922 | | - titles[i].indexOf( ':' ) + 1 ); |
923 | | - } |
924 | | - if ( typeof cache[ns] == 'undefined' ) |
925 | | - cache[ns] = {}; |
926 | | - cache[ns][title] = titles; |
927 | | - $j(that).suggestions( 'suggestions', titles ); |
| 887 | + $j(that).suggestions( 'suggestions', data[1] ); |
928 | 888 | } |
929 | 889 | }); |
930 | 890 | $j(this).data( 'request', request ); |
— | — | @@ -958,11 +918,7 @@ |
959 | 919 | alert( gM( 'edittoolbar-tool-link-int-invalid' ) ); |
960 | 920 | return; |
961 | 921 | } |
962 | | - var targetNS = $j( '#edittoolbar-link-int-target-ns option:selected' ).text(); |
963 | | - if ( targetNS != '' ) |
964 | | - targetNS += ':'; |
965 | | - var targetTitle = $j( '#edittoolbar-link-int-target' ).val(); |
966 | | - var target = targetNS + targetTitle; |
| 922 | + var target = $j( '#edittoolbar-link-int-target' ).val(); |
967 | 923 | var text = $j( '#edittoolbar-link-int-text' ).val(); |
968 | 924 | whitespace = $j( '#edittoolbar-link-dialog-tab-int' ).data( 'whitespace' ); |
969 | 925 | if ( target == text ) |