Hue.JFrameGallery.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Licensed to Cloudera, Inc. under one
  2. // or more contributor license agreements. See the NOTICE file
  3. // distributed with this work for additional information
  4. // regarding copyright ownership. Cloudera, Inc. licenses this file
  5. // to you under the Apache License, Version 2.0 (the
  6. // "License"); you may not use this file except in compliance
  7. // with the License. You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. /*
  17. ---
  18. description: JFrame Gallery window
  19. provides: [Hue.JFrameGallery]
  20. requires: [JFrame/JFrame.Browser, hue-shared/Hue.JFrame.Chooser]
  21. script: Hue.JFrameGallery.js
  22. ...
  23. */
  24. ART.Sheet.define('window.art.jframe-gallery', {
  25. 'footer-height': 28
  26. });
  27. Hue.JFrameGallery = new Class({
  28. Extends: Hue.JBrowser,
  29. options: {
  30. className: 'art jframe-gallery browser logo_header',
  31. jframeOptions: {
  32. clickRelays: 'a, .relays'
  33. }
  34. },
  35. initialize: function(path, options){
  36. this.parent(path || '/jframegallery/', options);
  37. this.addEvent('load', function(view){
  38. this.toolbar.adopt(
  39. new Element('a', {
  40. href: '/jframegallery/',
  41. 'class': 'jf-logo'
  42. })
  43. );
  44. /* Inject demo/source button bar */
  45. var currentPath = this.jframe.currentPath,
  46. path;
  47. if (currentPath.indexOf('/jframegallery/gallery') === 0) {
  48. /* This is the view of a demo */
  49. path = currentPath.replace('/jframegallery/gallery', '/jframegallery/source');
  50. } else if (currentPath.indexOf('/jframegallery/source') === 0) {
  51. /* This is the view of a demo source */
  52. path = currentPath.replace('/jframegallery/source', '/jframegallery/gallery');
  53. }
  54. if (path) {
  55. var button = new Element('a', {
  56. href: path,
  57. 'class': 'jf-button',
  58. 'data-filters': 'ArtButton',
  59. 'text': view == "source" ? "View Demo" : "View Source"
  60. });
  61. var buttonBar = new Element('ul', {
  62. 'class': 'jf-buttonbar',
  63. 'data-filters': 'ArtButtonBar'
  64. }).adopt(new Element('li').adopt(button));
  65. this.footerText.adopt(buttonBar);
  66. this.jframe.behavior.apply(this.footerText);
  67. }
  68. }.bind(this));
  69. }
  70. });