/lib/views/dock_container.js

https://github.com/ajanthanm/cssfilterlab · JavaScript · 86 lines · 57 code · 14 blank · 15 comment · 4 complexity · e8724b6b7cab4290b0d3ee45de67b0fb MD5 · raw file

  1. /*
  2. * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. (function() {
  17. function DockContainer() {
  18. DockContainer.$super.call(this);
  19. this.items = [];
  20. this.init();
  21. }
  22. Global.Utils.extend(DockContainer).from(Global.EventDispatcher);
  23. $.extend(DockContainer.prototype, {
  24. init: function() {
  25. this.el = $("<div />")
  26. .addClass("panel-container")
  27. .data("item", this);
  28. this.tabListEl = $("<div />")
  29. .addClass("panel-tab-list")
  30. .appendTo(this.el);
  31. },
  32. add: function(panel) {
  33. this.items.push(panel);
  34. this.tabListEl.append(panel.tabEl);
  35. this.el.append(panel.el);
  36. panel.setContainer(this);
  37. if (this.items.length == 1)
  38. panel.setActive(true);
  39. return this;
  40. },
  41. setHeight: function(height) {
  42. this.el.css("-webkit-box-flex", "0")
  43. .css("-webkit-flex", 1)
  44. .css("height", height);
  45. return this;
  46. },
  47. setActiveTab: function(tab) {
  48. $.each(this.items, function(i, item) {
  49. if (item == tab)
  50. return;
  51. item.setActive(false);
  52. });
  53. },
  54. setIsDocumentArea: function() {
  55. this.isDocumentArea = true;
  56. return this;
  57. },
  58. addClass: function(className) {
  59. this.el.addClass(className)
  60. return this;
  61. },
  62. removeTabs: function() {
  63. this.tabListEl.remove()
  64. return this;
  65. },
  66. setFixed: function() {
  67. this.isFixed = true;
  68. return this;
  69. }
  70. });
  71. Global.DockContainer = DockContainer;
  72. })();