Hue.JFrameGallery.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. Hue.JFrameGallery = new Class({
  25. Extends: Hue.JBrowser,
  26. options: {
  27. className: 'art jframe-gallery browser logo_header',
  28. jframeOptions: {
  29. clickRelays: 'a, .relays'
  30. }
  31. },
  32. initialize: function(path, options){
  33. this.parent(path || '/jframegallery/', options);
  34. this.addEvent('load', function(){
  35. this.toolbar.adopt(
  36. new Element('a', {
  37. href: '/jframegallery/',
  38. 'class': 'jf-logo'
  39. })
  40. );
  41. /* Inject demo/source button bar */
  42. var path = this.jframe.currentPath;
  43. var do_inject = false;
  44. var demopath;
  45. var sourcepath;
  46. if (path.indexOf('/jframegallery/gallery') === 0) {
  47. /* This is the view of a demo */
  48. demopath = path;
  49. sourcepath = path.replace('/jframegallery/gallery', '/jframegallery/source');
  50. do_inject = true;
  51. } else if (path.indexOf('/jframegallery/source') === 0) {
  52. /* This is the view of a demo source */
  53. demopath = path.replace('/jframegallery/source', '/jframegallery/gallery');
  54. sourcepath = path;
  55. do_inject = true;
  56. }
  57. if (do_inject) {
  58. var buttonBar = new Element('ul', {
  59. 'class': 'jf-buttonbar',
  60. 'data-filters': 'ArtButtonBar'
  61. });
  62. var demoLink = new Element('a', {
  63. href: demopath,
  64. 'class': 'jf-button',
  65. 'data-filters': 'ArtButton',
  66. 'text': "View Demo"
  67. });
  68. var sourceLink = new Element('a', {
  69. href: sourcepath,
  70. 'class': 'jf-button',
  71. 'data-filters': 'ArtButton',
  72. 'text': "View Source"
  73. });
  74. buttonBar.adopt(new Element('li').adopt(demoLink));
  75. buttonBar.adopt(new Element('li').adopt(sourceLink));
  76. this.toolbar.adopt(buttonBar);
  77. this.jframe.behavior.apply(this.toolbar);
  78. }
  79. sourcepath = "foo";
  80. }.bind(this));
  81. }
  82. });