From 8403b715e5b5c9cd51fcdc9fd704635fbae84feb Mon Sep 17 00:00:00 2001 From: John Foerch Date: Sun, 21 Feb 2010 21:16:57 -0500 Subject: [PATCH] mode-line.js: whitespace --- modules/mode-line.js | 63 ++++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/modules/mode-line.js b/modules/mode-line.js index 53e607a..2ebe854 100644 --- a/modules/mode-line.js +++ b/modules/mode-line.js @@ -10,14 +10,13 @@ require("mode.js"); define_window_local_hook("mode_line_hook"); -function generic_element_widget_container(window, container) -{ +define_keywords("$flex", "$align", "$class", "$crop"); +function generic_element_widget_container (window, container) { this.window = window; this.container = container; } -define_keywords("$flex", "$align", "$class", "$crop"); generic_element_widget_container.prototype = { - add_text_widget : function (widget) { + add_text_widget: function (widget) { keywords(arguments, $flex = widget.flex, $class = widget.class_name, $crop = widget.crop); var flex = arguments.$flex; @@ -35,20 +34,19 @@ generic_element_widget_container.prototype = { element.setAttribute("crop", crop); return this.add_widget(widget, element); }, - add_widget : function (widget, element) { + add_widget: function (widget, element) { element.conkeror_widget = new generic_widget_element(element, widget); this.container.appendChild(element); return element.conkeror_widget; }, - destroy : function() { + destroy: function () { var children = this.container.childNodes; for (var i = 0, nchildren = children.length; i < nchildren; ++i) children.item(i).conkeror_widget.destroy(); } }; -function mode_line(window) -{ +function mode_line (window) { var element = create_XUL(window, "hbox"); element.setAttribute("class", "mode-line"); /* FIXME: this will need to changed to be buffer-local */ @@ -68,13 +66,11 @@ mode_line.prototype = { }; -function generic_widget_element(element, widget) -{ +function generic_widget_element (element, widget) { this.element = element; this.widget = widget; widget.attach(this); } - generic_widget_element.prototype = { get text () { return this.element.getAttribute("value"); @@ -84,57 +80,53 @@ generic_widget_element.prototype = { this.element.setAttribute("value", v); }, - destroy : function () { + destroy: function () { this.widget.destroy(); }, - remove : function () { + remove: function () { this.element.parentNode.removeChild(this.element); this.destroy(); } }; -function text_widget(window) -{ +function text_widget (window) { this.window_hooks = []; this.window = window; } text_widget.prototype = { - add_hook : function (hook_name, handler) - { + add_hook: function (hook_name, handler) { var obj = this; if (handler == null) handler = function () { obj.update(); } add_hook.call(this.window, hook_name, handler); this.window_hooks.push([hook_name, handler]); }, - view : null, + view: null, - attach : function (view) { + attach: function (view) { this.view = view; this.update(); }, - update : function () { - }, + update: function () {}, - destroy : function () - { + destroy: function () { for each (let i in this.window_hooks) { remove_hook.call(this.window, i[0], i[1]); } }, - remove : function () - { + remove: function () { this.view.remove(); } }; + define_global_window_mode("mode_line", "window_initialize_early_hook"); -function current_buffer_name_widget(window) { +function current_buffer_name_widget (window) { this.class_name = "current-buffer-name-widget"; text_widget.call(this, window); this.flex = "1"; @@ -147,7 +139,7 @@ current_buffer_name_widget.prototype.update = function () { this.view.text = this.window.buffers.current.description; }; -function current_buffer_scroll_position_widget(window) { +function current_buffer_scroll_position_widget (window) { this.class_name = "current-buffer-scroll-position-widget"; text_widget.call(this, window); this.add_hook("current_buffer_scroll_hook"); @@ -159,15 +151,13 @@ current_buffer_scroll_position_widget.prototype.__proto__ = text_widget.prototyp current_buffer_scroll_position_widget.prototype.update = function () { var b = this.window.buffers.current; var scrollX, scrollY, scrollMaxX, scrollMaxY; - if (b instanceof content_buffer) - { + if (b instanceof content_buffer) { var w = b.focused_frame; scrollX = w.scrollX; scrollY = w.scrollY; scrollMaxX = w.scrollMaxX; scrollMaxY = w.scrollMaxY; - } else - { + } else { scrollX = b.scrollX; scrollY = b.scrollY; scrollMaxX = b.scrollMaxX; @@ -178,8 +168,7 @@ current_buffer_scroll_position_widget.prototype.update = function () { this.view.text = "(" + x + ", " + y + ")"; }; -function clock_widget(window) -{ +function clock_widget (window) { this.class_name = "clock-widget"; text_widget.call(this, window); var obj = this; @@ -210,7 +199,7 @@ clock_widget.prototype.destroy = function () { this.window.clearTimeout(this.timer_ID); }; -function buffer_count_widget(window) { +function buffer_count_widget (window) { this.class_name = "buffer-count-widget"; text_widget.call(this, window); this.add_hook("select_buffer_hook"); @@ -223,7 +212,7 @@ buffer_count_widget.prototype.update = function () { this.window.buffers.count + "]"); }; -function loading_count_widget(window) { +function loading_count_widget (window) { this.class_name = "loading-count-widget"; text_widget.call(this, window); var obj = this; @@ -234,14 +223,14 @@ function loading_count_widget(window) { loading_count_widget.prototype.__proto__ = text_widget.prototype; loading_count_widget.prototype.update = function () { var count = 0; - for_each_buffer(function(b) {if (b.loading) count++;}); + for_each_buffer(function (b) { if (b.loading) count++; }); if (count) this.view.text = "(" + count + " loading)"; else this.view.text = ""; }; -function mode_line_adder(widget_constructor) { +function mode_line_adder (widget_constructor) { if (!('mode_line_adder' in widget_constructor)) widget_constructor.mode_line_adder = function (window) { window.mode_line.add_text_widget(new widget_constructor(window)); -- 2.11.4.GIT