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");
19 var services = app.ns("services");
21 ui.ClusterConnect = ui.AbstractWidget.extend({
27 this.prefs = services.Preferences.instance();
28 this.cluster = this.config.cluster;
29 this.el = $.joey(this._main_template());
30 this.cluster.get( "", this._node_handler );
33 _node_handler: function(data) {
35 this.prefs.set("app-base_uri", this.cluster.base_uri);
39 _reconnect_handler: function() {
40 var base_uri = this.el.find(".uiClusterConnect-uri").val();
41 $("body").empty().append(new app.App("body", { id: "es", base_uri: base_uri }));
44 _main_template: function() {
45 return { tag: "SPAN", cls: "uiClusterConnect", children: [
46 { tag: "INPUT", type: "text", cls: "uiClusterConnect-uri", onkeyup: function( ev ) {
49 this._reconnect_handler();
51 }.bind(this), id: this.id("baseUri"), value: this.cluster.base_uri },
52 { tag: "BUTTON", type: "button", text: i18n.text("Header.Connect"), onclick: this._reconnect_handler }
57 })( this.jQuery, this.app, this.i18n );