d5ab984498535d9336def1e98df85324a1a3ff89
[ccsdk/features.git] /
1 (function( $, app, i18n ) {
2
3         var ui = app.ns("ui");
4
5         ui.SidebarSection = ui.AbstractWidget.extend({
6                 defaults: {
7                         title: "",
8                         help: null,
9                         body: null,
10                         open: false
11                 },
12                 init: function() {
13                         this._super();
14                         this.el = $.joey( this._main_template() );
15                         this.body = this.el.children(".uiSidebarSection-body");
16                         this.config.open && ( this.el.addClass("shown") && this.body.css("display", "block") );
17                 },
18                 _showSection_handler: function( ev ) {
19                         var shown = $( ev.target ).closest(".uiSidebarSection")
20                                 .toggleClass("shown")
21                                         .children(".uiSidebarSection-body").slideToggle(200, function() { this.fire("animComplete", this); }.bind(this))
22                                 .end()
23                                 .hasClass("shown");
24                         this.fire(shown ? "show" : "hide", this);
25                 },
26                 _showHelp_handler: function( ev ) {
27                         new ui.HelpPanel({ref: this.config.help});
28                         ev.stopPropagation();
29                 },
30                 _main_template: function() { return (
31                         { tag: "DIV", cls: "uiSidebarSection", children: [
32                                 (this.config.title && { tag: "DIV", cls: "uiSidebarSection-head", onclick: this._showSection_handler, children: [
33                                         this.config.title,
34                                         ( this.config.help && { tag: "SPAN", cls: "uiSidebarSection-help pull-right", onclick: this._showHelp_handler, text: i18n.text("General.HelpGlyph") } )
35                                 ] }),
36                                 { tag: "DIV", cls: "uiSidebarSection-body", children: [ this.config.body ] }
37                         ] }
38                 ); }
39         });
40
41 })( this.jQuery, this.app, this.i18n );