Ticket #24425: 24425.draft.42.diff
File 24425.draft.42.diff, 5.2 KB (added by , 12 years ago) |
---|
-
wp-admin/js/revisions.js
280 280 }, 281 281 282 282 updateCompareTwoMode: function() { 283 this.$el.toggleClass( 'comparing-two-revisions' ); 283 if ( this.model.get( 'compareTwoMode' ) ) 284 this.$el.addClass( 'comparing-two-revisions' ); 285 else 286 this.$el.removeClass( 'comparing-two-revisions' ); 284 287 } 285 288 }); 286 289 … … 307 310 }); 308 311 this.views.add( tooltip ); 309 312 313 // Add the Tickmarks view 314 this.views.add( new revisions.view.Tickmarks({ 315 model: this.model 316 })); 317 310 318 // Add the Slider view with a reference to the tooltip view 311 319 this.views.add( new revisions.view.Slider({ 312 320 model: this.model, … … 317 325 this.views.add( new revisions.view.Meta({ 318 326 model: this.model 319 327 }) ); 328 320 329 } 321 330 }); 322 331 332 // The tickmarks view 333 // This contains the slider tickmarks. 334 revisions.view.Tickmarks = wp.Backbone.View.extend({ 335 tagName: 'div', 336 className: 'revisions-tickmarks', 337 template: wp.template('revisions-tickmarks'), 338 339 numberOfTickmarksSet: function() { 340 var tickCount = this.model.revisions.length - 1, // One tickmark per model 341 sliderWidth = $( '.wp-slider' ).parent().width() * 0.7, // Width of slider is 70% of container (reset on resize) 342 tickWidth = Math.floor( sliderWidth / tickCount ), // Divide width by # of tickmarks, round down 343 newSiderWidth = ( ( tickWidth + 1 ) * tickCount ) + 1, // Calculate the actual width 344 tickNumber; 345 346 $( '.wp-slider' ).css( 'width', newSiderWidth ); // Reset the slider width to match the calculated tick size 347 this.$el.css( 'width', newSiderWidth ); // Match the tickmark div width 348 349 for ( tickNumber = 0; tickNumber <= tickCount; tickNumber++ ){ 350 this.$el.append( '<div class="atickmark" style="left:' + ( tickWidth * tickNumber ) + 'px;"></div>' ); 351 } 352 }, 353 354 ready: function() { 355 var self = this; 356 self.numberOfTickmarksSet(); 357 $( window ).on( 'resize', _.debounce( function() { 358 self.$el.html( '' ); 359 self.numberOfTickmarksSet(); 360 }, 250 ) ); 361 } 362 }); 363 323 364 // The meta view. 324 365 // This contains the revision meta, and the restore button. 325 366 revisions.view.Meta = wp.Backbone.View.extend({ … … 511 552 512 553 events: { 513 554 'mousemove' : 'mousemove', 514 'mouseenter' : 'mouseenter',515 555 'mouseleave' : 'mouseleave' 516 556 }, 517 557 … … 559 599 }, 560 600 561 601 mousemove: function( e ) { 562 var sliderLeft = Math.ceil( this.$el.offset().left ), 563 sliderWidth = Math.ceil( this.$el.width() ) + 2, 564 tickWidth = Math.ceil( ( sliderWidth ) / this.model.revisions.length ), 602 var tickCount = this.model.revisions.length - 1, // One tickmark per model 603 sliderLeft = Math.ceil( this.$el.offset().left ), 604 sliderWidth = this.$el.width(), 605 tickWidth = Math.floor( sliderWidth / tickCount ), 565 606 actualX = e.clientX - sliderLeft, 566 607 hoveringAt = Math.floor( actualX / tickWidth ); 567 608 609 // Check to see if mouse is hovering near a tickmark 610 if ( actualX % tickWidth < 8 ) { 611 this.tooltip.show(); 612 } else { 613 this.tooltip.hide(); 614 } 615 568 616 // Reverse direction in RTL mode. 569 617 if ( isRtl ) 570 618 hoveringAt = this.model.revisions.length - hoveringAt - 1; … … 580 628 this.tooltip.model.set( 'position', e.clientX ); 581 629 }, 582 630 583 mouseenter: function( e ) {584 this.tooltip.show();585 },586 587 631 mouseleave: function( e ) { 588 632 this.tooltip.hide(); 589 633 }, -
wp-admin/revision.php
152 152 </div> 153 153 </script> 154 154 155 <script id="tmpl-revisions-tickmarks" type="text/html"> 156 </script> 157 155 158 <script id="tmpl-revisions-meta" type="text/html"> 156 159 <div id="diff-header"> 157 160 <div id="diff-header-from" class="diff-header"> -
wp-admin/css/colors-fresh.css
1385 1385 background-color: #fff; 1386 1386 } 1387 1387 1388 1389 .revisions-tickmarks { 1390 background-color: #f7f7f7; 1391 } 1392 1393 1394 .revisions-tickmarks 1395 .atickmark { 1396 background-color: #ccc; 1397 } 1398 1399 1388 1400 #diff-title-to strong { 1389 1401 color: #08a; 1390 1402 } … … 1392 1404 /* jQuery UI Slider */ 1393 1405 .wp-slider.ui-slider { 1394 1406 border-color: #d7d7d7; 1395 background: #f7f7f7;1407 background: transparent; 1396 1408 } 1397 1409 1398 1410 .wp-slider .ui-slider-handle { -
wp-admin/css/wp-admin.css
3505 3505 height: 100px; 3506 3506 } 3507 3507 3508 .revisions-tickmarks { 3509 position: relative; 3510 margin: 0 auto 0; 3511 height: 0.8em; 3512 z-index: 2; 3513 top: 7px; 3514 } 3515 3516 .revisions-tickmarks .atickmark { 3517 height: 0.8em; 3518 width: 1px; 3519 float: left; 3520 position: relative; 3521 z-index: 10002; 3522 } 3523 3524 .atickmark { 3525 display: block; 3526 } 3527 3508 3528 .comparing-two-revisions .revisions-controls { 3509 3529 height: 140px; 3510 3530 } … … 3534 3554 3535 3555 .wp-slider { 3536 3556 width: 70%; 3537 margin: 6px auto 0; 3557 margin: 0 auto 0; 3558 top: -3px; 3538 3559 } 3539 3560 3540 3561 /* Revision meta box */