Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | array( 'src' => 'js/plugins/jquery.collapsibleTabs.js', 'version' => 1 ), |
66 | 66 | array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ), |
67 | 67 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
68 | | - array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 4 ), |
| 68 | + array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 5 ), |
69 | 69 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 16 ), |
70 | 70 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 12 ), |
71 | 71 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 12 ), |
— | — | @@ -72,10 +72,10 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 20 ), |
74 | 74 | ), |
75 | 75 | 'combined' => array( |
76 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 44 ), |
| 76 | + array( 'src' => 'js/plugins.combined.js', 'version' => 45 ), |
77 | 77 | ), |
78 | 78 | 'minified' => array( |
79 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 44 ), |
| 79 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 45 ), |
80 | 80 | ), |
81 | 81 | ), |
82 | 82 | ); |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php |
— | — | @@ -59,7 +59,6 @@ |
60 | 60 | 'edittoolbar-tool-link-int-target-status-invalid', |
61 | 61 | 'edittoolbar-tool-link-int-target-status-loading', |
62 | 62 | 'edittoolbar-tool-link-int-invalid', |
63 | | - 'edittoolbar-tool-link-ext-invalid', |
64 | 63 | 'edittoolbar-tool-file', |
65 | 64 | 'edittoolbar-tool-file-pre', |
66 | 65 | 'edittoolbar-tool-file-example', |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -752,30 +752,39 @@ |
753 | 753 | titleMsg: 'edittoolbar-tool-link-title', |
754 | 754 | id: 'edittoolbar-link-dialog', |
755 | 755 | html: '\ |
756 | | - <div id="edittoolbar-link-tabs">\ |
757 | | - <ul>\ |
758 | | - <li><a href="#edittoolbar-link-dialog-tab-int" rel="edittoolbar-tool-link-int"></a></li>\ |
759 | | - <li><a href="#edittoolbar-link-dialog-tab-ext" rel="edittoolbar-tool-link-ext"></a></li>\ |
760 | | - </ul>\ |
761 | | - <div id="edittoolbar-link-dialog-tab-int"><fieldset><table><tr>\ |
762 | | - <td><label for="edittoolbar-link-int-target" rel="edittoolbar-tool-link-int-target"></label></td>\ |
763 | | - <td>\ |
764 | | - <input type="text" id="edittoolbar-link-int-target" size="50" />\ |
765 | | - <div id="edittoolbar-link-int-target-status" style="display: inline;"></div>\ |
766 | | - </td>\ |
767 | | - </tr><tr>\ |
768 | | - <td><label for="edittoolbar-link-int-text" rel="edittoolbar-tool-link-int-text"></label></td>\ |
769 | | - <td><input type="text" id="edittoolbar-link-int-text" size="50" /></td>\ |
770 | | - </table></fieldset></div>\ |
771 | | - <div id="edittoolbar-link-dialog-tab-ext"><fieldset><table><tr>\ |
772 | | - <td><label for="edittoolbar-link-ext-target" rel="edittoolbar-tool-link-ext-target"></label></td>\ |
773 | | - <td><input type="text" id="edittoolbar-link-ext-target" size="50" /></td>\ |
774 | | - </tr><tr>\ |
775 | | - <td><label for="edittoolbar-link-ext-text" rel="edittoolbar-tool-link-ext-text"></label></td>\ |
776 | | - <td><input type="text" id="edittoolbar-link-ext-text" size="50" /></td>\ |
777 | | - </table></fieldset></div>\ |
778 | | - </div>', |
| 756 | + <fieldset><table style="width: 100%;"><tr>\ |
| 757 | + <td>\ |
| 758 | + <label for="edittoolbar-link-int-target" rel="edittoolbar-tool-link-int-target"></label><br />\ |
| 759 | + <input type="text" id="edittoolbar-link-int-target" style="width: 100%;" />\ |
| 760 | + </td><td style="width: 48px;">\ |
| 761 | + <div id="edittoolbar-link-int-target-status" style="display: inline;"></div>\ |
| 762 | + </td>\ |
| 763 | + </tr><tr>\ |
| 764 | + <td>\ |
| 765 | + <label for="edittoolbar-link-int-text" rel="edittoolbar-tool-link-int-text"></label><br />\ |
| 766 | + <input type="text" id="edittoolbar-link-int-text" style="width: 100%;" />\ |
| 767 | + </td>\ |
| 768 | + </tr><tr>\ |
| 769 | + <td colspan="2">\ |
| 770 | + <div style="float: left; margin-right: 2em;">\ |
| 771 | + <input type="radio" id="edittoolbar-link-type-int" name="edittoolbar-link-type" selected />\ |
| 772 | + <label for="edittoolbar-link-type-int" rel="edittoolbar-tool-link-int"></label>\ |
| 773 | + </div><div style="float: left;">\ |
| 774 | + <input type="radio" id="edittoolbar-link-type-ext" name="edittoolbar-link-type" />\ |
| 775 | + <label for="edittoolbar-link-type-ext" rel="edittoolbar-tool-link-ext"></label>\ |
| 776 | + </div>\ |
| 777 | + </td>\ |
| 778 | + </tr>\ |
| 779 | + </table></fieldset>', |
779 | 780 | init: function() { |
| 781 | + function isExternalLink( s ) { |
| 782 | + // The following things are considered to be external links: |
| 783 | + // * Starts with one or more letters followed by :// |
| 784 | + // * Starts with www. |
| 785 | + // * Ends with a . followed by two or more letters |
| 786 | + // * Contains a . followed by two or more letters followed by / |
| 787 | + return s.match( /(^[a-z]+:\/\/)|(^www\.)|([^.]\.[a-z]{2,}($|\/))/i ); |
| 788 | + } |
780 | 789 | // Updates the UI to show if the page title being inputed by the user exists or not |
781 | 790 | function updateExistence() { |
782 | 791 | function updateWidget( status ) { |
— | — | @@ -799,6 +808,10 @@ |
800 | 809 | $j( '#edittoolbar-link-int-target-status' ).children().hide(); |
801 | 810 | return; |
802 | 811 | } |
| 812 | + if ( isExternalLink( target ) ) { |
| 813 | + updateWidget( 'external' ); |
| 814 | + return; |
| 815 | + } |
803 | 816 | if ( target.indexOf( '|' ) != -1 ) { |
804 | 817 | // Title contains | , which means it's invalid |
805 | 818 | // but confuses the API. Show invalid and bypass API |
— | — | @@ -838,31 +851,32 @@ |
839 | 852 | $j(this).find( '[rel]' ).each( function() { |
840 | 853 | $j(this).text( gM( $j(this).attr( 'rel' ) ) ); |
841 | 854 | }); |
842 | | - // Build tabs |
843 | | - mvJsLoader.doLoad( [ '$j.ui', '$j.ui.tabs' ], function() { |
844 | | - $j( '#edittoolbar-link-tabs' ).tabs(); |
845 | | - }); |
846 | 855 | // Automatically copy the value of the internal link page title field to the link text field unless the user |
847 | 856 | // has changed the link text field - this is a convience thing since most link texts are going to be the |
848 | 857 | // the same as the page title |
| 858 | + // Also change the internal/external radio button accordingly |
849 | 859 | $j( '#edittoolbar-link-int-target' ).bind( 'change keypress paste cut', function() { |
850 | 860 | // $j(this).val() is the old value, before the keypress |
851 | | - if ( $j( '#edittoolbar-link-int-text' ).data( 'untouched' ) ) |
852 | | - // Defer this until $j(this).val() has been updated |
853 | | - setTimeout( function() { |
| 861 | + // Defer this until $j(this).val() has been updated |
| 862 | + setTimeout( function() { |
| 863 | + if ( isExternalLink( $j( '#edittoolbar-link-int-target' ).val() ) ) |
| 864 | + $j( '#edittoolbar-link-type-ext' ).attr( 'checked', 'checked' ); |
| 865 | + else |
| 866 | + $j( '#edittoolbar-link-type-int' ).attr( 'checked', 'checked' ); |
| 867 | + |
| 868 | + if ( $j( '#edittoolbar-link-int-text' ).data( 'untouched' ) ) |
854 | 869 | $j( '#edittoolbar-link-int-text' ).val( $j( '#edittoolbar-link-int-target' ).val() ); |
855 | | - }, 0 ); |
| 870 | + }, 0 ); |
856 | 871 | }); |
857 | 872 | $j( '#edittoolbar-link-int-text' ).bind( 'change keypress paste cut', function() { |
858 | 873 | $j(this).data( 'untouched', false ); |
859 | 874 | }); |
860 | | - // Set the initial value of the external link field to start out as a real URL |
861 | | - $j( '#edittoolbar-link-ext-target' ).val( 'http://' ); |
862 | 875 | // Add images to the page existence widget, which will be shown mutually exclusively to communicate if the |
863 | 876 | // page exists, does not exist or the title is invalid (like if it contains a | character) |
864 | 877 | var existsMsg = gM( 'edittoolbar-tool-link-int-target-status-exists' ); |
865 | 878 | var notexistsMsg = gM( 'edittoolbar-tool-link-int-target-status-notexists' ); |
866 | 879 | var invalidMsg = gM( 'edittoolbar-tool-link-int-target-status-invalid' ); |
| 880 | + var externalMsg = gM( 'edittoolbar-tool-link-int-target-status-external' ); |
867 | 881 | var loadingMsg = gM( 'edittoolbar-tool-link-int-target-status-loading' ); |
868 | 882 | $j( '#edittoolbar-link-int-target-status' ) |
869 | 883 | .append( $j( '<img />' ).attr( { |
— | — | @@ -884,6 +898,12 @@ |
885 | 899 | 'title': invalidMsg |
886 | 900 | } ) ) |
887 | 901 | .append( $j( '<img />' ).attr( { |
| 902 | + 'id': 'edittoolbar-link-int-target-status-external', |
| 903 | + 'src': $j.wikiEditor.imgPath + 'dialogs/' + 'insert-link-external.png', |
| 904 | + 'alt': externalMsg, |
| 905 | + 'title': externalMsg |
| 906 | + } ) ) |
| 907 | + .append( $j( '<img />' ).attr( { |
888 | 908 | 'id': 'edittoolbar-link-int-target-status-loading', |
889 | 909 | 'src': $j.wikiEditor.imgPath + 'dialogs/loading.gif', |
890 | 910 | 'alt': loadingMsg, |
— | — | @@ -899,8 +919,8 @@ |
900 | 920 | clearTimeout( $j(this).data( 'timerID' ) ); |
901 | 921 | } |
902 | 922 | // Delay fetch for a while |
903 | | - // FIXME: Make 250 configurable elsewhere |
904 | | - var timerID = setTimeout( updateExistence, 250 ); |
| 923 | + // FIXME: Make 120 configurable elsewhere |
| 924 | + var timerID = setTimeout( updateExistence, 120 ); |
905 | 925 | $j(this).data( 'timerID', timerID ); |
906 | 926 | } ) |
907 | 927 | .change( function() { |
— | — | @@ -918,6 +938,11 @@ |
919 | 939 | var that = this; |
920 | 940 | var title = $j(this).val(); |
921 | 941 | |
| 942 | + if ( isExternalLink( title ) || title.indexOf( '|' ) != -1 || title == '') { |
| 943 | + $j(this).suggestions( 'suggestions', [] ); |
| 944 | + return; |
| 945 | + } |
| 946 | + |
922 | 947 | var cache = $j(this).data( 'suggcache' ); |
923 | 948 | if ( typeof cache[title] != 'undefined' ) { |
924 | 949 | $j(this).suggestions( 'suggestions', cache[title] ); |
— | — | @@ -935,6 +960,7 @@ |
936 | 961 | }, |
937 | 962 | dataType: 'json', |
938 | 963 | success: function( data ) { |
| 964 | + cache[title] = data[1]; |
939 | 965 | $j(that).suggestions( 'suggestions', data[1] ); |
940 | 966 | } |
941 | 967 | }); |
— | — | @@ -948,6 +974,7 @@ |
949 | 975 | }); |
950 | 976 | }, |
951 | 977 | dialog: { |
| 978 | + width: 500, |
952 | 979 | buttons: { |
953 | 980 | 'edittoolbar-tool-link-insert': function() { |
954 | 981 | function escapeInternalText( s ) { |
— | — | @@ -961,42 +988,35 @@ |
962 | 989 | return s.replace( /(]+)/g, '<nowiki>$1</nowiki>' ); |
963 | 990 | } |
964 | 991 | var insertText = ''; |
965 | | - var whitespace = [ '', '' ]; |
966 | | - switch ( $j( '#edittoolbar-link-tabs' ).tabs( 'option', 'selected' ) ) { |
967 | | - case 0: // Internal link |
968 | | - var target = $j( '#edittoolbar-link-int-target' ).val(); |
969 | | - var text = $j( '#edittoolbar-link-int-text' ).val(); |
970 | | - // FIXME: Exactly how fragile is this? |
971 | | - if ( $j( '#edittoolbar-link-int-target-status-invalid' ).is( ':visible' ) || |
972 | | - target == '' ) { |
973 | | - // Refuse to add links to invalid titles |
974 | | - alert( gM( 'edittoolbar-tool-link-int-invalid' ) ); |
975 | | - return; |
976 | | - } |
977 | | - whitespace = $j( '#edittoolbar-link-dialog-tab-int' ).data( 'whitespace' ); |
978 | | - if ( target == text ) |
979 | | - insertText = '[[' + target + ']]'; |
980 | | - else |
981 | | - insertText = '[[' + target + '|' + escapeInternalText( text ) + ']]'; |
982 | | - break; |
983 | | - case 1: |
984 | | - var target = $j( '#edittoolbar-link-ext-target' ).val(); |
985 | | - var text = $j( '#edittoolbar-link-ext-text' ).val(); |
986 | | - var escTarget = escapeExternalTarget( target ); |
987 | | - var escText = escapeExternalText( text ); |
988 | | - whitespace = $j( '#edittoolbar-link-dialog-tab-ext' ).data( 'whitespace' ); |
989 | | - if ( !target.match( /^[a-z]+:\/\/./ ) ) { |
990 | | - // Refuse to add links to invalid URLs |
991 | | - alert( gM( 'edittoolbar-tool-link-ext-invalid' ) ); |
992 | | - return; |
993 | | - } |
994 | | - if ( escTarget == escText ) |
995 | | - insertText = escTarget; |
996 | | - else if ( text == '' ) |
997 | | - insertText = '[' + escTarget + ']'; |
998 | | - else |
999 | | - insertText = '[' + escTarget + ' ' + escText + ']'; |
1000 | | - break; |
| 992 | + var whitespace = $j( '#edittoolbar-link-dialog' ).data( 'whitespace' ); |
| 993 | + var target = $j( '#edittoolbar-link-int-target' ).val(); |
| 994 | + var text = $j( '#edittoolbar-link-int-text' ).val(); |
| 995 | + if ( $j( '#edittoolbar-link-type-int' ).is( ':checked' ) ) { |
| 996 | + // FIXME: Exactly how fragile is this? |
| 997 | + if ( $j( '#edittoolbar-link-int-target-status-invalid' ).is( ':visible' ) || |
| 998 | + target == '' ) { |
| 999 | + // Refuse to add links to invalid titles |
| 1000 | + alert( gM( 'edittoolbar-tool-link-int-invalid' ) ); |
| 1001 | + return; |
| 1002 | + } |
| 1003 | + |
| 1004 | + if ( target == text ) |
| 1005 | + insertText = '[[' + target + ']]'; |
| 1006 | + else |
| 1007 | + insertText = '[[' + target + '|' + escapeInternalText( text ) + ']]'; |
| 1008 | + } else { |
| 1009 | + var escTarget = escapeExternalTarget( target ); |
| 1010 | + var escText = escapeExternalText( text ); |
| 1011 | + // Prepend http:// if there is no protocol |
| 1012 | + if ( !escTarget.match( /^[a-z]+:\/\/./ ) ) { |
| 1013 | + escTarget = 'http://' + escTarget; |
| 1014 | + } |
| 1015 | + if ( escTarget == escText ) |
| 1016 | + insertText = escTarget; |
| 1017 | + else if ( text == '' ) |
| 1018 | + insertText = '[' + escTarget + ']'; |
| 1019 | + else |
| 1020 | + insertText = '[' + escTarget + ' ' + escText + ']'; |
1001 | 1021 | } |
1002 | 1022 | // Preserve whitespace in selection when replacing |
1003 | 1023 | insertText = whitespace[0] + insertText + whitespace[1]; |
— | — | @@ -1013,46 +1033,37 @@ |
1014 | 1034 | } |
1015 | 1035 | }, |
1016 | 1036 | open: function() { |
1017 | | - $j( '#edittoolbar-link-int-target, #edittoolbar-link-ext-target' ) |
1018 | | - .filter( ':visible' ) |
1019 | | - .focus(); |
| 1037 | + $j( '#edittoolbar-link-int-target' ).focus(); |
1020 | 1038 | // Pre-fill the text fields based on the current selection |
1021 | 1039 | var selection = $j(this).data( 'context' ).$textarea.getSelection(); |
1022 | | - $j( '#edittoolbar-link-dialog-tab-int' ).data( 'whitespace', [ '', '' ] ); |
1023 | | - $j( '#edittoolbar-link-dialog-tab-ext' ).data( 'whitespace', [ '', '' ] ); |
| 1040 | + $j( '#edittoolbar-link-dialog' ).data( 'whitespace', [ '', '' ] ); |
1024 | 1041 | if ( selection != '' ) { |
1025 | | - var intText, intTarget, extText, extTarget; |
| 1042 | + var target, text, type; |
1026 | 1043 | var matches; |
1027 | | - var tab = -1; |
1028 | 1044 | if ( ( matches = selection.match( /^(\s*)\[\[([^\]\|]+)(\|([^\]\|]*))?\]\](\s*)$/ ) ) ) { |
1029 | 1045 | // [[foo|bar]] or [[foo]] |
1030 | | - intTarget = matches[2]; |
1031 | | - intText = ( matches[4] ? matches[4] : matches[2] ); |
1032 | | - tab = 0; |
| 1046 | + target = matches[2]; |
| 1047 | + text = ( matches[4] ? matches[4] : matches[2] ); |
| 1048 | + type = 'int'; |
1033 | 1049 | // Preserve whitespace when replacing |
1034 | | - $j( '#edittoolbar-link-dialog-tab-int' ).data( 'whitespace', [ matches[1], matches[5] ] ); |
| 1050 | + $j( '#edittoolbar-link-dialog' ).data( 'whitespace', [ matches[1], matches[5] ] ); |
1035 | 1051 | } else if ( ( matches = selection.match( /^(\s*)\[([^\] ]+)( ([^\]]+))?\](\s*)$/ ) ) ) { |
1036 | 1052 | // [http://www.example.com foo] or [http://www.example.com] |
1037 | | - extTarget = matches[2]; |
1038 | | - extText = ( matches[4] ? matches[4] : '' ); |
1039 | | - tab = 1; |
| 1053 | + target = matches[2]; |
| 1054 | + text = ( matches[4] ? matches[4] : '' ); |
| 1055 | + type = 'ext'; |
1040 | 1056 | // Preserve whitespace when replacing |
1041 | | - $j( '#edittoolbar-link-dialog-tab-ext' ).data( 'whitespace', [ matches[1], matches[5] ] ); |
| 1057 | + $j( '#edittoolbar-link-dialog' ).data( 'whitespace', [ matches[1], matches[5] ] ); |
1042 | 1058 | } else { |
1043 | | - intTarget = intText = extText = selection; |
1044 | | - extTarget = 'http://'; |
| 1059 | + target = text = selection; |
1045 | 1060 | } |
1046 | 1061 | // Change the value by calling val() doesn't trigger the change event, so let's do that ourselves |
1047 | | - if ( typeof intText != 'undefined' ) |
1048 | | - $j( '#edittoolbar-link-int-text' ).val( intText ).change(); |
1049 | | - if ( typeof intTarget != 'undefined' ) |
1050 | | - $j( '#edittoolbar-link-int-target' ).val( intTarget ).change(); |
1051 | | - if ( typeof extText != 'undefined' ) |
1052 | | - $j( '#edittoolbar-link-ext-text' ).val( extText ).change(); |
1053 | | - if ( typeof extTarget != 'undefined' ) |
1054 | | - $j( '#edittoolbar-link-ext-target' ).val( extTarget ).change(); |
1055 | | - if ( tab != -1 ) |
1056 | | - $j( '#edittoolbar-link-tabs' ).tabs( 'select', tab ); |
| 1062 | + if ( typeof text != 'undefined' ) |
| 1063 | + $j( '#edittoolbar-link-int-text' ).val( text ).change(); |
| 1064 | + if ( typeof target != 'undefined' ) |
| 1065 | + $j( '#edittoolbar-link-int-target' ).val( target ).change(); |
| 1066 | + if ( typeof type != 'undefined' ) |
| 1067 | + $j( '#edittoolbar-link-' + type ).attr( 'checked', 'checked' ); |
1057 | 1068 | } |
1058 | 1069 | $j( '#edittoolbar-link-int-text' ).data( 'untouched', |
1059 | 1070 | $j( '#edittoolbar-link-int-text' ).val() == $j( '#edittoolbar-link-int-target' ).val() |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.i18n.php |
— | — | @@ -41,7 +41,6 @@ |
42 | 42 | 'edittoolbar-tool-link-int-target-status-invalid' => 'Invalid title', |
43 | 43 | 'edittoolbar-tool-link-int-target-status-loading' => 'Checking page existence...', |
44 | 44 | 'edittoolbar-tool-link-int-invalid' => 'The title you specified is invalid.', |
45 | | - 'edittoolbar-tool-link-ext-invalid' => 'The URL you specified is invalid.', |
46 | 45 | 'edittoolbar-tool-file' => 'Embedded file', |
47 | 46 | 'edittoolbar-tool-file-pre' => '$1{{ns:file}}:', |
48 | 47 | 'edittoolbar-tool-file-example' => 'Example.jpg', |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | /* Configuration */ |
21 | 21 | |
22 | 22 | // Bump the version number every time you change any of the .css/.js files |
23 | | -$wgEditToolbarStyleVersion = 58; |
| 23 | +$wgEditToolbarStyleVersion = 59; |
24 | 24 | |
25 | 25 | // Set this to true to simply override the stock toolbar for everyone |
26 | 26 | $wgEditToolbarGlobalEnable = false; |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | * @param {Mixed} value Value to set property with |
102 | 102 | */ |
103 | 103 | configure: function( context, property, value ) { |
104 | | - // Validate ccontextration using fallback values |
| 104 | + // Validate creation using fallback values |
105 | 105 | switch( property ) { |
106 | 106 | case 'fetch': |
107 | 107 | case 'cancel': |
— | — | @@ -113,8 +113,9 @@ |
114 | 114 | context.config[property] = value; |
115 | 115 | // Update suggestions |
116 | 116 | if ( typeof context.data !== 'undefined' ) { |
117 | | - if ( context.config.suggestions.length == 0 ) { |
118 | | - // Hide the dive when no suggestion exist |
| 117 | + if ( typeof context.config.suggestions == 'undefined' || |
| 118 | + context.config.suggestions.length == 0 ) { |
| 119 | + // Hide the div when no suggestion exist |
119 | 120 | context.data.$container.hide(); |
120 | 121 | } else { |
121 | 122 | // Rebuild the suggestions list |
— | — | @@ -150,7 +151,7 @@ |
151 | 152 | context.config[property] = Math.max( 1, Math.min( 100, value ) ); |
152 | 153 | break; |
153 | 154 | case 'delay': |
154 | | - context.config[property] = Math.max( 0, Math.min( 12000, value ) ); |
| 155 | + context.config[property] = Math.max( 0, Math.min( 1200, value ) ); |
155 | 156 | break; |
156 | 157 | case 'submitOnClick': |
157 | 158 | context.config[property] = value ? true : false; |
— | — | @@ -264,7 +265,7 @@ |
265 | 266 | '$region': $(this), |
266 | 267 | 'suggestions': [], |
267 | 268 | 'maxRows': 7, |
268 | | - 'delay': 1200, |
| 269 | + 'delay': 120, |
269 | 270 | 'submitOnClick': false |
270 | 271 | } |
271 | 272 | }; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -508,7 +508,7 @@ |
509 | 509 | * @param {Mixed} value Value to set property with |
510 | 510 | */ |
511 | 511 | configure: function( context, property, value ) { |
512 | | - // Validate ccontextration using fallback values |
| 512 | + // Validate creation using fallback values |
513 | 513 | switch( property ) { |
514 | 514 | case 'fetch': |
515 | 515 | case 'cancel': |
— | — | @@ -521,8 +521,9 @@ |
522 | 522 | context.config[property] = value; |
523 | 523 | // Update suggestions |
524 | 524 | if ( typeof context.data !== 'undefined' ) { |
525 | | - if ( context.config.suggestions.length == 0 ) { |
526 | | - // Hide the dive when no suggestion exist |
| 525 | + if ( typeof context.config.suggestions == 'undefined' || |
| 526 | + context.config.suggestions.length == 0 ) { |
| 527 | + // Hide the div when no suggestion exist |
527 | 528 | context.data.$container.hide(); |
528 | 529 | } else { |
529 | 530 | // Rebuild the suggestions list |
— | — | @@ -558,7 +559,7 @@ |
559 | 560 | context.config[property] = Math.max( 1, Math.min( 100, value ) ); |
560 | 561 | break; |
561 | 562 | case 'delay': |
562 | | - context.config[property] = Math.max( 0, Math.min( 12000, value ) ); |
| 563 | + context.config[property] = Math.max( 0, Math.min( 1200, value ) ); |
563 | 564 | break; |
564 | 565 | case 'submitOnClick': |
565 | 566 | context.config[property] = value ? true : false; |
— | — | @@ -672,7 +673,7 @@ |
673 | 674 | '$region': $(this), |
674 | 675 | 'suggestions': [], |
675 | 676 | 'maxRows': 7, |
676 | | - 'delay': 1200, |
| 677 | + 'delay': 120, |
677 | 678 | 'submitOnClick': false |
678 | 679 | } |
679 | 680 | }; |
— | — | @@ -1846,25 +1847,23 @@ |
1847 | 1848 | .text( label ) |
1848 | 1849 | .attr( 'rel', id ) |
1849 | 1850 | .data( 'context', context ) |
1850 | | - .click( |
1851 | | - function() { |
1852 | | - |
1853 | | - $(this).parent().parent().find( '.page' ).hide(); |
1854 | | - $(this).parent().parent().find( '.page-' + $(this).attr( 'rel' ) ).show(); |
1855 | | - $(this).siblings().removeClass( 'current' ); |
1856 | | - $(this).addClass( 'current' ); |
1857 | | - var section = $(this).parent().parent().attr( 'rel' ); |
1858 | | - |
1859 | | - //click tracking |
1860 | | - if($.trackAction != undefined){ |
1861 | | - $.trackAction(section + '.' + $(this).attr('rel')); |
1862 | | - } |
1863 | | - |
1864 | | - $.cookie( |
1865 | | - 'wikiEditor-' + $(this).data( 'context' ).instance + '-booklet-' + section + '-page', |
1866 | | - $(this).attr( 'rel' ) |
1867 | | - ); |
1868 | | - } ); |
| 1851 | + .bind( 'mousedown', function() { |
| 1852 | + $(this).parent().parent().find( '.page' ).hide(); |
| 1853 | + $(this).parent().parent().find( '.page-' + $(this).attr( 'rel' ) ).show(); |
| 1854 | + $(this).siblings().removeClass( 'current' ); |
| 1855 | + $(this).addClass( 'current' ); |
| 1856 | + var section = $(this).parent().parent().attr( 'rel' ); |
| 1857 | + |
| 1858 | + //click tracking |
| 1859 | + if($.trackAction != undefined){ |
| 1860 | + $.trackAction(section + '.' + $(this).attr('rel')); |
| 1861 | + } |
| 1862 | + |
| 1863 | + $.cookie( |
| 1864 | + 'wikiEditor-' + $(this).data( 'context' ).instance + '-booklet-' + section + '-page', |
| 1865 | + $(this).attr( 'rel' ) |
| 1866 | + ); |
| 1867 | + } ); |
1869 | 1868 | }, |
1870 | 1869 | buildPage : function( context, id, page ) { |
1871 | 1870 | var $page = $( '<div />' ).attr( { |
— | — | @@ -1971,7 +1970,7 @@ |
1972 | 1971 | .attr( 'href', '#' ) |
1973 | 1972 | .text( $.wikiEditor.autoMsg( section, 'label' ) ) |
1974 | 1973 | .data( 'context', context ) |
1975 | | - .click( function() { |
| 1974 | + .bind( 'mousedown', function() { |
1976 | 1975 | var $sections = $(this).data( 'context' ).$ui.find( '.sections' ); |
1977 | 1976 | var $section = |
1978 | 1977 | $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -32,8 +32,8 @@ |
33 | 33 | if(typeof context.config.cancel=='function'){context.config.cancel.call(context.data.$textbox);}},restore:function(context){context.data.$textbox.val(context.data.prevText);},update:function(context,delayed){function maybeFetch(){if(context.data.$textbox.val()!==context.data.prevText){context.data.prevText=context.data.$textbox.val();if(typeof context.config.fetch=='function'){context.config.fetch.call(context.data.$textbox,context.data.$textbox.val());}}} |
34 | 34 | if(context.data.timerID!=null){clearTimeout(context.data.timerID);} |
35 | 35 | if(delayed){context.data.timerID=setTimeout(maybeFetch,context.config.delay);}else{maybeFetch();} |
36 | | -$.suggestions.special(context);},special:function(context){if(typeof context.config.special.render=='function'){setTimeout(function(){$special=context.data.$container.find('.suggestions-special');context.config.special.render.call($special,context.data.$textbox.val());},1);}},configure:function(context,property,value){switch(property){case'fetch':case'cancel':case'special':case'result':case'$region':context.config[property]=value;break;case'suggestions':context.config[property]=value;if(typeof context.data!=='undefined'){if(context.config.suggestions.length==0){context.data.$container.hide();}else{context.data.$container.show();context.data.$container.css({'top':context.config.$region.offset().top+context.config.$region.outerHeight(),'bottom':'auto','width':context.config.$region.outerWidth(),'height':'auto','left':context.config.$region.offset().left,'right':'auto'});var $results=context.data.$container.children('.suggestions-results');$results.empty();for(var i=0;i<context.config.suggestions.length;i++){$result=$('<div />').addClass('suggestions-result').attr('rel',i).data('text',context.config.suggestions[i]).appendTo($results);if(typeof context.config.result.render=='function'){context.config.result.render.call($result,context.config.suggestions[i]);}else{$result.text(context.config.suggestions[i]).autoEllipse();}}}} |
37 | | -break;case'maxRows':context.config[property]=Math.max(1,Math.min(100,value));break;case'delay':context.config[property]=Math.max(0,Math.min(12000,value));break;case'submitOnClick':context.config[property]=value?true:false;break;}},highlight:function(context,result,updateTextbox){var selected=context.data.$container.find('.suggestions-result-current') |
| 36 | +$.suggestions.special(context);},special:function(context){if(typeof context.config.special.render=='function'){setTimeout(function(){$special=context.data.$container.find('.suggestions-special');context.config.special.render.call($special,context.data.$textbox.val());},1);}},configure:function(context,property,value){switch(property){case'fetch':case'cancel':case'special':case'result':case'$region':context.config[property]=value;break;case'suggestions':context.config[property]=value;if(typeof context.data!=='undefined'){if(typeof context.config.suggestions=='undefined'||context.config.suggestions.length==0){context.data.$container.hide();}else{context.data.$container.show();context.data.$container.css({'top':context.config.$region.offset().top+context.config.$region.outerHeight(),'bottom':'auto','width':context.config.$region.outerWidth(),'height':'auto','left':context.config.$region.offset().left,'right':'auto'});var $results=context.data.$container.children('.suggestions-results');$results.empty();for(var i=0;i<context.config.suggestions.length;i++){$result=$('<div />').addClass('suggestions-result').attr('rel',i).data('text',context.config.suggestions[i]).appendTo($results);if(typeof context.config.result.render=='function'){context.config.result.render.call($result,context.config.suggestions[i]);}else{$result.text(context.config.suggestions[i]).autoEllipse();}}}} |
| 37 | +break;case'maxRows':context.config[property]=Math.max(1,Math.min(100,value));break;case'delay':context.config[property]=Math.max(0,Math.min(1200,value));break;case'submitOnClick':context.config[property]=value?true:false;break;}},highlight:function(context,result,updateTextbox){var selected=context.data.$container.find('.suggestions-result-current') |
38 | 38 | if(!result.get||selected.get(0)!=result.get(0)){if(result=='prev'){result=selected.prev();}else if(result=='next'){if(selected.size()==0) |
39 | 39 | result=context.data.$container.find('.suggestions-results div:first');else{result=selected.next();if(result.size()==0) |
40 | 40 | result=selected;}} |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | $.suggestions.special(context);},keypress:function(e,context,key){var wasVisible=context.data.$container.is(':visible');var preventDefault=false;switch(key){case 40:if(wasVisible){$.suggestions.highlight(context,'next',true);}else{$.suggestions.update(context,false);} |
44 | 44 | context.data.$textbox.trigger('change');preventDefault=true;break;case 38:if(wasVisible){$.suggestions.highlight(context,'prev',true);} |
45 | 45 | context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 27:context.data.$container.hide();$.suggestions.restore(context);$.suggestions.cancel(context);context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 13:context.data.$container.hide();preventDefault=wasVisible;break;default:$.suggestions.update(context,true);break;} |
46 | | -if(preventDefault){e.preventDefault();e.stopImmediatePropagation();}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':1200,'submitOnClick':false}};} |
| 46 | +if(preventDefault){e.preventDefault();e.stopImmediatePropagation();}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':120,'submitOnClick':false}};} |
47 | 47 | if(args.length>0){if(typeof args[0]=='object'){for(key in args[0]){$.suggestions.configure(context,key,args[0][key]);}}else if(typeof args[0]=='string'){if(args.length>1){$.suggestions.configure(context,args[0],args[1]);}else if(returnValue==null){returnValue=(args[0]in context.config?undefined:context.config[args[0]]);}}} |
48 | 48 | if(typeof context.data=='undefined'){context.data={'timerID':null,'prevText':null,'visibleResults':0,'mouseDownOn':$([]),'$textbox':$(this)};context.data.$container=$('<div />').css({'top':Math.round(context.data.$textbox.offset().top+context.data.$textbox.outerHeight()),'left':Math.round(context.data.$textbox.offset().left),'width':context.data.$textbox.outerWidth(),'display':'none'}).mouseover(function(e){$.suggestions.highlight(context,$(e.target).closest('.suggestions-results div'),false);}).addClass('suggestions').append($('<div />').addClass('suggestions-results').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-results div');}).mouseup(function(e){var $result=$(e.target).closest('.suggestions-results div');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($result.get(0)!=$other.get(0)){return;} |
49 | 49 | $.suggestions.highlight(context,$result,true);context.data.$container.hide();if(typeof context.config.result.select=='function'){context.config.result.select.call($result,context.data.$textbox);} |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | var label=$.wikiEditor.autoMsg(tool,'label');switch(tool.type){case'button':var src=tool.icon;if(src.indexOf('http://')!==0&&src.indexOf('https://')!==0){src=$.wikiEditor.imgPath+'toolbar/'+src;} |
120 | 120 | $button=$('<img />').attr({'src':src,'width':22,'height':22,'alt':label,'title':label,'rel':id,'class':'tool tool-button'});if('action'in tool){$button.data('action',tool.action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));return false;});} |
121 | 121 | return $button;case'select':var $select=$('<div />').attr({'rel':id,'class':'tool tool-select'}).click(function(){var $options=$(this).find('.options');$options.animate({'opacity':'toggle'},'fast');});$options=$('<div />').addClass('options');if('list'in tool){for(option in tool.list){var optionLabel=$.wikiEditor.autoMsg(tool.list[option],'label');$options.append($('<a />').data('action',tool.list[option].action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));}).text(optionLabel).addClass('option').attr('rel',option));}} |
122 | | -$select.append($('<div />').addClass('menu').append($options));$select.append($('<div />').addClass('label').text(label));return $select;default:return null;}},buildBookmark:function(context,id,page){var label=$.wikiEditor.autoMsg(page,'label');return $('<div />').text(label).attr('rel',id).data('context',context).click(function(){$(this).parent().parent().find('.page').hide();$(this).parent().parent().find('.page-'+$(this).attr('rel')).show();$(this).siblings().removeClass('current');$(this).addClass('current');var section=$(this).parent().parent().attr('rel');if($.trackAction!=undefined){$.trackAction(section+'.'+$(this).attr('rel'));} |
| 122 | +$select.append($('<div />').addClass('menu').append($options));$select.append($('<div />').addClass('label').text(label));return $select;default:return null;}},buildBookmark:function(context,id,page){var label=$.wikiEditor.autoMsg(page,'label');return $('<div />').text(label).attr('rel',id).data('context',context).bind('mousedown',function(){$(this).parent().parent().find('.page').hide();$(this).parent().parent().find('.page-'+$(this).attr('rel')).show();$(this).siblings().removeClass('current');$(this).addClass('current');var section=$(this).parent().parent().attr('rel');if($.trackAction!=undefined){$.trackAction(section+'.'+$(this).attr('rel'));} |
123 | 123 | $.cookie('wikiEditor-'+$(this).data('context').instance+'-booklet-'+section+'-page',$(this).attr('rel'));});},buildPage:function(context,id,page){var $page=$('<div />').attr({'class':'page page-'+id,'rel':id});switch(page.layout){case'table':$page.addClass('page-table');var html='<table cellpadding=0 cellspacing=0 '+'border=0 width="100%" class="table table-"'+id+'">';if('headings'in page){html+=$.wikiEditor.modules.toolbar.fn.buildHeading(context,page.headings)} |
124 | 124 | if('rows'in page){for(row in page.rows){html+=$.wikiEditor.modules.toolbar.fn.buildRow(context,page.rows[row])}} |
125 | 125 | $page.html(html);break;case'characters':$page.addClass('page-characters');$characters=$('<div />').data('context',context).data('actions',{});var actions=$characters.data('actions');if('language'in page){$characters.attr('lang',page.language);} |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | return html;},buildRow:function(context,row){var html='<tr>';for(cell in row){html+='<td class="cell cell-'+cell+'" valign="top"><span>'+ |
132 | 132 | $.wikiEditor.autoMsg(row[cell],['html','text'])+'</span></td>';} |
133 | 133 | html+='</tr>';return html;},buildCharacter:function(character,actions){if(typeof character=='string'){character={'label':character,'action':{'type':'encapsulate','options':{'pre':character}}};}else if(0 in character&&1 in character){character={'label':character[0],'action':{'type':'encapsulate','options':{'pre':character[1]}}};} |
134 | | -if('action'in character&&'label'in character){actions[character.label]=character.action;return'<a rel="'+character.label+'" href="#">'+character.label+'</a>';}},buildTab:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');return $('<span />').attr({'class':'tab tab-'+id,'rel':id}).append($('<a />').addClass(selected==id?'current':null).attr('href','#').text($.wikiEditor.autoMsg(section,'label')).data('context',context).click(function(){var $sections=$(this).data('context').$ui.find('.sections');var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));$(this).blur();var show=$section.css('display')=='none';$previousSections=$section.parent().find('.section:visible');$previousSections.css('position','absolute');$previousSections.fadeOut('fast',function(){$(this).css('position','relative');});$(this).parent().parent().find('a').removeClass('current');if(show){$section.fadeIn('fast');$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2);$(this).addClass('current');}else{$sections.animate({'height':0},$section.outerHeight()*2);} |
| 134 | +if('action'in character&&'label'in character){actions[character.label]=character.action;return'<a rel="'+character.label+'" href="#">'+character.label+'</a>';}},buildTab:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');return $('<span />').attr({'class':'tab tab-'+id,'rel':id}).append($('<a />').addClass(selected==id?'current':null).attr('href','#').text($.wikiEditor.autoMsg(section,'label')).data('context',context).bind('mousedown',function(){var $sections=$(this).data('context').$ui.find('.sections');var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));$(this).blur();var show=$section.css('display')=='none';$previousSections=$section.parent().find('.section:visible');$previousSections.css('position','absolute');$previousSections.fadeOut('fast',function(){$(this).css('position','relative');});$(this).parent().parent().find('a').removeClass('current');if(show){$section.fadeIn('fast');$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2);$(this).addClass('current');}else{$sections.animate({'height':0},$section.outerHeight()*2);} |
135 | 135 | if($.trackAction!=undefined){$.trackAction($section.attr('rel')+'.'+(show?'show':'hide'));} |
136 | 136 | $.cookie('wikiEditor-'+$(this).data('context').instance+'-toolbar-section',show?$section.attr('rel'):null);return false;}));},buildSection:function(context,id,section){context.$textarea.trigger('wikiEditor-toolbar-buildSection-'+id,[section]);var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');var $section;switch(section.type){case'toolbar':var $section=$('<div />').attr({'class':'toolbar section section-'+id,'rel':id});if('groups'in section){for(group in section.groups){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,section.groups[group]));}} |
137 | 137 | break;case'booklet':var $pages=$('<div />').addClass('pages');var $index=$('<div />').addClass('index');if('pages'in section){for(page in section.pages){$pages.append($.wikiEditor.modules.toolbar.fn.buildPage(context,page,section.pages[page]));$index.append($.wikiEditor.modules.toolbar.fn.buildBookmark(context,page,section.pages[page]));}} |