PageRenderTime 22ms CodeModel.GetById 11ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/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
17(function() {
18    
19    function DockContainer() {
20        DockContainer.$super.call(this);
21        this.items = [];
22        this.init();
23    }
24
25    Global.Utils.extend(DockContainer).from(Global.EventDispatcher);
26
27    $.extend(DockContainer.prototype, {
28        init: function() {
29            this.el = $("<div />")
30                .addClass("panel-container")
31                .data("item", this);
32
33            this.tabListEl = $("<div />")
34                .addClass("panel-tab-list")
35                .appendTo(this.el);
36        },
37
38        add: function(panel) {
39            this.items.push(panel);
40            this.tabListEl.append(panel.tabEl);
41            this.el.append(panel.el);
42            panel.setContainer(this);
43            if (this.items.length == 1)
44                panel.setActive(true);
45            return this;
46        },
47
48        setHeight: function(height) {
49            this.el.css("-webkit-box-flex", "0")
50                   .css("-webkit-flex", 1)
51                   .css("height", height);
52            return this;
53        },
54        
55        setActiveTab: function(tab) {
56            $.each(this.items, function(i, item) {
57                if (item == tab)
58                    return;
59                item.setActive(false);
60            });
61        },
62
63        setIsDocumentArea: function() {
64            this.isDocumentArea = true;
65            return this;
66        },
67        
68        addClass: function(className) {
69            this.el.addClass(className)
70            return this;
71        },
72        
73        removeTabs: function() {
74            this.tabListEl.remove()
75            return this;
76        },
77
78        setFixed: function() {
79            this.isFixed = true;
80            return this;
81        }
82    });
83
84    Global.DockContainer = DockContainer;
85
86})();