|
355 | 355 | color: #0b140f; |
356 | 356 | border-color: #53d88f; |
357 | 357 | transition: 0.2s ease-in-out; |
| 358 | + min-width: 3.125rem; |
358 | 359 | } |
359 | 360 | .btn-primary:active, .btn-primary:focus, .btn-primary:hover, .btn-primary:active:hover, .btn-primary:active:focus { |
360 | 361 | background-color: #61fea8; |
|
390 | 391 | } |
391 | 392 |
|
392 | 393 | .try-coffeescript .CodeMirror { |
393 | | - height: calc(100vh - 3.5rem); |
| 394 | + height: calc(100vh - 7rem); |
394 | 395 | cursor: text; |
395 | 396 | } |
396 | 397 |
|
|
402 | 403 | color: #2f2625; |
403 | 404 | } |
404 | 405 |
|
405 | | -.try-coffeescript coffeescript-input-column, |
406 | | -.try-coffeescript coffeescript-input, |
407 | | -.try-coffeescript javascript-output-column, |
408 | | -.try-coffeescript javascript-output { |
409 | | - height: 100%; |
| 406 | +.try-coffeescript button svg { |
| 407 | + height: 1em; |
| 408 | + transform: scale(1.3) translateY(0.1em); |
| 409 | + fill: #0b140f; |
410 | 410 | } |
411 | 411 |
|
412 | 412 | /* Adapted from https://github.com/FarhadG/code-mirror-themes/blob/master/themes/twilight.css */ |
|
456 | 456 | <body> |
457 | 457 |
|
458 | 458 | <nav class="navbar navbar-dark navbar-fixed-top bg-inverse bg-ribbed-dark"> |
459 | | - <a class="navbar-brand" href="#"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-22 347 566 100"> |
| 459 | + <a class="navbar-brand" href="#" data-close="try"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-22 347 566 100"> |
460 | 460 | <title> |
461 | 461 | CoffeeScript Logo |
462 | 462 | </title> |
|
465 | 465 | </a> |
466 | 466 | <nav class="nav navbar-nav float-xs-left hidden-md-down"> |
467 | 467 | <a href="#try" id="try-link" class="nav-item nav-link" data-toggle="try">Try CoffeeScript</a> |
468 | | - <a href="#language" class="nav-item nav-link">Language Reference</a> |
469 | | - <a href="#resources" class="nav-item nav-link">Resources</a> |
470 | | - <a href="http://github.com/jashkenas/coffeescript/" class="nav-item nav-link">GitHub</a> |
| 468 | + <a href="#language" class="nav-item nav-link" data-close="try">Language Reference</a> |
| 469 | + <a href="#resources" class="nav-item nav-link" data-close="try">Resources</a> |
| 470 | + <a href="http://github.com/jashkenas/coffeescript/" class="nav-item nav-link" data-close="try">GitHub</a> |
471 | 471 | </nav> |
472 | 472 | <button type="button" class="navbar-menu-button hidden-lg-up" data-toggle="offcanvas" aria-label="Toggle sidebar"> |
473 | 473 | <div class="menu-button"> |
|
480 | 480 | </nav> |
481 | 481 |
|
482 | 482 |
|
483 | | -<aside id="try" class="try-coffeescript container-fluid"> |
| 483 | +<aside id="try" class="try-coffeescript container-fluid" data-example="try"> |
484 | 484 | <div class="row"> |
485 | 485 | <div class="col-md-6 code-column bg-ribbed-dark coffeescript-input-column"> |
486 | | - <textarea class="coffeescript-input">alert 'Hello CoffeeScript!'</textarea> |
| 486 | + <textarea class="coffeescript-input" id="try-coffeescript-coffee">alert 'Hello CoffeeScript!'</textarea> |
487 | 487 | </div> |
488 | 488 | <div class="col-md-6 code-column bg-ribbed-dark javascript-output-column"> |
489 | | - <textarea class="javascript-output">alert('Hello CoffeeScript!');</textarea> |
| 489 | + <textarea class="javascript-output" id="try-coffeescript-js">alert('Hello CoffeeScript!');</textarea> |
| 490 | + </div> |
| 491 | + </div> |
| 492 | + <div class="row"> |
| 493 | + <div class="col-xs-12 text-xs-right"> |
| 494 | + <button type="button" class="btn btn-primary" data-action="run-code-example" data-example="try-coffeescript" data-run="true">▶</button>  |
| 495 | + <button type="button" class="btn btn-primary" data-action="link" data-example="try-coffeescript"><svg aria-hidden="true" version="1.1" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg> |
| 496 | +</button> |
490 | 497 | </div> |
491 | 498 | </div> |
492 | 499 | </aside> |
@@ -3621,8 +3628,11 @@ <h2 class="header"> |
3621 | 3628 | # Try CoffeeScript |
3622 | 3629 | toggleTry = -> |
3623 | 3630 | $('#try, #try-link').toggleClass 'active' |
| 3631 | + closeTry = -> |
| 3632 | + $('#try, #try-link').removeClass 'active' |
3624 | 3633 |
|
3625 | 3634 | $('[data-toggle="try"]').click toggleTry |
| 3635 | + $('[data-close="try"]').click closeTry |
3626 | 3636 |
|
3627 | 3637 |
|
3628 | 3638 | # Initialize Scrollspy for sidebar navigation; http://v4-alpha.getbootstrap.com/components/scrollspy/ |
@@ -3684,11 +3694,20 @@ <h2 class="header"> |
3684 | 3694 | js = "#{js}\nalert(#{unescape run});" unless run is yes |
3685 | 3695 | eval js |
3686 | 3696 |
|
| 3697 | + $('[data-action="link"]').click -> |
| 3698 | + index = $("##{$(@).data('example')}-coffee").data 'index' |
| 3699 | + coffee = editors[index].getValue() |
| 3700 | + link = "try:#{encodeURIComponent coffee}" |
| 3701 | + window.history.pushState {}, 'CoffeeScript', "#{location.href.split('#')[0]}##{link}" |
| 3702 | + |
3687 | 3703 |
|
3688 | 3704 | # Configure the initial state |
3689 | 3705 | if window.location.hash? |
3690 | 3706 | if window.location.hash is '#try' |
3691 | 3707 | toggleTry() |
| 3708 | + else if window.location.hash.indexOf('#try') is 0 |
| 3709 | + editors[0].setValue decodeURIComponent window.location.hash[5..] |
| 3710 | + toggleTry() |
3692 | 3711 | else |
3693 | 3712 | initializeScrollspyFromHash window.location.hash |
3694 | 3713 |
|
|
0 commit comments