38cc0d6f8806b5d1630e4272690da21f4b44fd7b
[ccsdk/features.git] /
1 /**
2  * Copyright 2010-2013 Ben Birch
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this software 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( $, app ) {
17
18         var ui = app.ns("ui");
19
20         ui.DraggablePanel = ui.AbstractPanel.extend({
21                 defaults: {
22         //              title: ""   // (required) text for the panel title
23                 },
24
25                 _baseCls: "uiPanel",
26
27                 init: function() {
28                         this._super();
29                         this.body = $(this._body_template());
30                         this.title = $(this._title_template());
31                         this.el = $.joey( this._main_template() );
32                         this.el.css( { width: this.config.width } );
33                         this.dd = new app.ux.DragDrop({
34                                 pickupSelector: this.el.find(".uiPanel-titleBar"),
35                                 dragObj: this.el
36                         });
37                         // open the panel if set in configuration
38                         this.config.open && this.open();
39                 },
40
41                 setBody: function(body) {
42                                 this.body.empty().append(body);
43                 },
44                 _body_template: function() { return { tag: "DIV", cls: "uiPanel-body", css: { height: this.config.height + (this.config.height === 'auto' ? "" : "px" ) }, children: [ this.config.body ] }; },
45                 _title_template: function() { return { tag: "SPAN", cls: "uiPanel-title", text: this.config.title }; },
46                 _main_template: function() { return (
47                         { tag: "DIV", id: this.id(), cls: this._baseCls, children: [
48                                 { tag: "DIV", cls: "uiPanel-titleBar", children: [
49                                         { tag: "DIV", cls: "uiPanel-close", onclick: this._close_handler, text: "x" },
50                                         this.title
51                                 ]},
52                                 this.body
53                         ] }
54                 ); }
55         });
56
57 })( this.jQuery, this.app );