diff options
| author | LV-426 <lv-426@taproot.org.il> | 2015-05-21 19:06:12 +0300 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2015-05-22 01:56:10 +0300 |
| commit | 23e9ce58406570c53a13effac1e83f3245f8f285 (patch) | |
| tree | 7a0b2686107962d7e400847645812ccc43e6007c /src/client | |
| parent | febb2b2c4a3383794913e652ec318d476281df3b (diff) | |
view/cmd_bar.js: cmd-bar view widget useful for new/open/search commands
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/view/cmd_bar.js | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/client/view/cmd_bar.js b/src/client/view/cmd_bar.js new file mode 100644 index 00000000..31690850 --- /dev/null +++ b/src/client/view/cmd_bar.js @@ -0,0 +1,79 @@ +"use strict" + +define(['jquery'], +function($) { + + function Cmd_bar(cmdbar_name) { + + var close_btn, + cmdbar_name, + root_div, + body_div, + footer_bar; + + this.cmdbar_name = cmdbar_name; + + close_btn = $('<div>x</div>'); + close_btn.addClass('toolbar__close_btn'); + + body_div = $('<div>'); + body_div.attr('id', this.id_str() + '__body">'); + body_div.addClass('cmd-bar__body'); + + root_div = $('<div>'); + root_div.attr('id', this.id_str()); + root_div.addClass('cmd-bar'); + root_div.css('display', 'none'); + + footer_bar = $('<div>Create new Rhizi</div>') + footer_bar.addClass('cmd-bar__close_bar'); + + root_div.append(close_btn); + root_div.append(body_div); + root_div.append(footer_bar); + + close_btn.click(function() { + root_div.hide(); + }); + + this.body_div = body_div; + this.root_div = root_div; + } + + Cmd_bar.prototype.append_to_body = function(e) { + this.body_div.append(e); + } + + Cmd_bar.prototype.clear = function() { + this.body_div.children().remove(); + } + + Cmd_bar.prototype.hide = function() { + this.root_div.fadeToggle(400); + } + + Cmd_bar.prototype.id_str = function(e) { + return 'cmd-bar__' + this.cmdbar_name; + } + + Cmd_bar.prototype.insert = function(remove_other_cmd_bars) { + this.root_div.insertAfter('#top-bar'); + } + + Cmd_bar.prototype.remove = function(remove_other_cmd_bars) { + this.root_div.insertAfter('#top-bar'); + } + + Cmd_bar.prototype.show = function() { + this.root_div.fadeToggle(400); + } + + function new_cmdbar(cmdbar_name) { + return new Cmd_bar(cmdbar_name); + } + + return { + new_cmdbar: new_cmdbar, + }; + +}); |
