2 * Copyright 2010-2013 Ben Birch
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 var ui = app.ns("ui");
20 ui.DraggablePanel = ui.AbstractPanel.extend({
22 // title: "" // (required) text for the panel title
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"),
37 // open the panel if set in configuration
38 this.config.open && this.open();
41 setBody: function(body) {
42 this.body.empty().append(body);
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" },
57 })( this.jQuery, this.app );