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.
16 (function( $, app, i18n ) {
18 var ui = app.ns("ui");
20 ui.SidebarSection = ui.AbstractWidget.extend({
29 this.el = $.joey( this._main_template() );
30 this.body = this.el.children(".uiSidebarSection-body");
31 this.config.open && ( this.el.addClass("shown") && this.body.css("display", "block") );
33 _showSection_handler: function( ev ) {
34 var shown = $( ev.target ).closest(".uiSidebarSection")
36 .children(".uiSidebarSection-body").slideToggle(200, function() { this.fire("animComplete", this); }.bind(this))
39 this.fire(shown ? "show" : "hide", this);
41 _showHelp_handler: function( ev ) {
42 new ui.HelpPanel({ref: this.config.help});
45 _main_template: function() { return (
46 { tag: "DIV", cls: "uiSidebarSection", children: [
47 (this.config.title && { tag: "DIV", cls: "uiSidebarSection-head", onclick: this._showSection_handler, children: [
49 ( this.config.help && { tag: "SPAN", cls: "uiSidebarSection-help pull-right", onclick: this._showHelp_handler, text: i18n.text("General.HelpGlyph") } )
51 { tag: "DIV", cls: "uiSidebarSection-body", children: [ this.config.body ] }
56 })( this.jQuery, this.app, this.i18n );