r64446 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64445‎ | r64446 | r64447 >
Date:17:30, 31 March 2010
Author:neilk
Status:deferred
Tags:
Comment:
pass hover events better to interface elements behind file controls
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/css/uploadWizard.css (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js
@@ -2,7 +2,7 @@
33 "mwe-upwiz-tab-file": "1. Upload your files",
44 "mwe-upwiz-tab-details": "2. Add licenses and descriptions",
55 "mwe-upwiz-tab-thanks": "3. Use your files",
6 - "mwe-upwiz-intro": "Introductory text (short)",
 6+ "mwe-upwiz-intro": "Welcome to Wikimedia Commons, a repository of images, sounds, and movies that anyone can freely download and use. Add to humanity's knowledge by uploading files that could be used for an educational purpose.",
77 //"mwe-upwiz-select-files": "Select files:",
88 "mwe-upwiz-add-file-n": "Add another file",
99 "mwe-upwiz-add-file-0": "Click here to add a file for upload",
@@ -514,7 +514,13 @@
515515 // with this flow
516516 _this.filenameCtrl = $j('<input type="hidden" name="filename" value=""/>').get(0);
517517
 518+ // this file Ctrl container is placed over other interface elements, intercepts clicks and gives them to the file input control.
 519+ // however, we want to pass hover events to interface elements that we are over, hence the bindings.
 520+ // n.b. not using toggleClass because it often gets this event wrong -- relies on previous state to know what to do
518521 _this.fileCtrlContainer = $j('<div class="mwe-upwiz-file-ctrl-container">')
 522+ .bind( 'mouseenter', function(e) { _this.addFileCtrlHover(e) } )
 523+ .bind( 'mouseleave', function(e) { _this.removeFileCtrlHover(e) } );
 524+
519525 // the css trickery (along with css)
520526 // here creates a giant size file input control which is contained within a div and then
521527 // clipped for overflow. The effect is that we have a div (ctrl-container) we can position anywhere
@@ -651,14 +657,41 @@
652658 'margin-top' : '-' + ~~( $j( _this.fileInputCtrl).height() - $covered.outerHeight() - 10 ) + 'px'
653659 } );
654660
655 - // pass hover events to the thing we cover, for interface niceties
656 - $j( _this.fileCtrlContainer ).bind( 'mouseenter mouseleave', function() {
657 - $j( selector ).toggleClass( 'hover' );
658 - } );
 661+ // we may be passing the file ctrl's hover events to another covered interface element
 662+ // see toggleFileCtrlHover
 663+ if ( _this.fileCtrlCovered ) {
 664+ _this.fileCtrlCovered.removeClass( 'hover' );
 665+ }
 666+ _this.fileCtrlCovered = $covered;
659667
660668 },
661669
662670 /**
 671+ * add class to an interface element covered by the fileCtrlContainer
 672+ * we are not using jQuery.toggleClass because it seems to get this wrong too often -- dumbly activates when should deactivate &
 673+ * vice versa.
 674+ * @param jquery event
 675+ */
 676+ addFileCtrlHover: function(e) {
 677+ if ( this.fileCtrlCovered ) {
 678+ this.fileCtrlCovered.addClass( 'hover' );
 679+ }
 680+ },
 681+
 682+ /**
 683+ * remove class from an jquery-wrapped interface element covered by the fileCtrlContainer
 684+ * we are not using jQuery.toggleClass because it seems to get this wrong too often -- dumbly activates when should deactivate &
 685+ * vice versa.
 686+ * @param jquery event
 687+ */
 688+ removeFileCtrlHover: function(e) {
 689+ if ( this.fileCtrlCovered ) {
 690+ this.fileCtrlCovered.removeClass( 'hover' );
 691+ }
 692+ },
 693+
 694+
 695+ /**
663696 * this does two things:
664697 * 1 ) since the file input has been hidden with some clever CSS ( to avoid x-browser styling issues ),
665698 * update the visible filename
Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/css/uploadWizard.css
@@ -90,7 +90,6 @@
9191 }
9292
9393 #mwe-upwiz-add-file {
94 - padding-top: 16px;
9594 }
9695
9796 /* NOT a pseudoclass */
@@ -124,19 +123,34 @@
125124 }
126125
127126 .mwe-upwiz-file.filled {
 127+ padding: 4px;
128128 height: 24px;
129129 }
130130
131131 .mwe-upwiz-visible-file {
132132 width: 300px;
133133 height: 18px;
 134+ padding-left: 5px;
134135 float: left;
135136 white-space: nowrap;
136137 overflow: hidden;
137138
 139+ background: white;
 140+
 141+ border-style: solid;
 142+ border-top-width: 2px;
 143+ border-left-width: 2px;
 144+ border-right-width: 1px;
 145+ border-bottom-width: 1px;
 146+ border-color: white;
138147 /* border: 1px solid blue; XXX just to make it visible for now */
139148 }
140149
 150+.mwe-upwiz-visible-file.hover {
 151+ background: white;
 152+ border-color: #0645ad;
 153+}
 154+
141155 /* XXX we probably have a standard for this */
142156 .helper {
143157 color: #cccccc; /* or whatever we do for greyed out text */

Status & tagging log