From b2512234ddcb6b1fa196c21ae1aba1397ff35ffd Mon Sep 17 00:00:00 2001 From: hallgren Date: Thu, 11 Aug 2011 16:28:49 +0000 Subject: [PATCH] minibar: documentation and API work --- src/runtime/javascript/minibar/about.html | 4 +++- .../javascript/minibar/minibar-api.html | 23 +++++++++++-------- src/runtime/javascript/minibar/minibar.js | 16 +++++-------- .../javascript/minibar/minibar_input.js | 16 ++++++++++--- .../javascript/minibar/minibar_online.js | 2 +- .../minibar/minibar_translations.js | 13 +++++++++-- 6 files changed, 48 insertions(+), 26 deletions(-) diff --git a/src/runtime/javascript/minibar/about.html b/src/runtime/javascript/minibar/about.html index 05fba4aef..372d85f19 100644 --- a/src/runtime/javascript/minibar/about.html +++ b/src/runtime/javascript/minibar/about.html @@ -160,11 +160,13 @@ Some implementation details: minibar_translations.js. Some common auxiliary functions have also been moved to a separate file: minibar_support.js. +
  • [Added 2011-08-09] Added some Minibar API + documentation.
    - Last modified: Mon Aug 8 19:27:14 CEST 2011 + Last modified: Thu Aug 11 17:07:13 CEST 2011
    TH diff --git a/src/runtime/javascript/minibar/minibar-api.html b/src/runtime/javascript/minibar/minibar-api.html index 758080815..8899117e2 100644 --- a/src/runtime/javascript/minibar/minibar-api.html +++ b/src/runtime/javascript/minibar/minibar-api.html @@ -29,7 +29,7 @@ div.modtime { float: right; }

    Minibar API

    -The minibar is structured as three object: +The Minibar web app consists of the following objects:
    • Minibar @@ -42,10 +42,10 @@ They are described below.

      The Minibar object

      -This is the complete Minibar web app. It is defined in +This object implements the complete Minibar web app. It is defined in minibar.js. It also uses the Input -and Translations objects, and some auxiliary functions defined -in minibar_support.js +and Translations objects described below, and some auxiliary +functions defined in minibar_support.js and support.js, so to use it in an HTML file, you would normally include at least the following: @@ -116,7 +116,7 @@ HTML file, you would normally include at least the following:

      Constructor

      -var input=new Input(server,options,translations) +var input=new Input(server,translations,options)
      • server is the PGF service object @@ -134,17 +134,22 @@ HTML file, you would normally include at least the following:
      • translations is the object that is notified when the input - has changed. In the minibar, this is the object that display translations. + has changed. In the minibar, this is the object that display translations, but + other apps might of course use the entered text for other purposes. The following methods will be called:
          -
        • translations.clear() +
        • translations.clear() is called when there no entered + text.
        • translations.translateFrom({from:conc,input:string}) + is called when the user has entered some text. The from + property is the name of the concrete syntax and the input + property is the entered text.

      Properties and user interface

      -The input object created by the Inputconstructor +The input object created by the Input constructor contains two field that the caller should add to the user interface:
      • input.main is the main user interface where the current @@ -221,7 +226,7 @@ should add to the user interface:
        -HTML Last modified: Tue Aug 9 17:55:19 CEST 2011 +HTML Last modified: Thu Aug 11 17:14:37 CEST 2011
        diff --git a/src/runtime/javascript/minibar/minibar.js b/src/runtime/javascript/minibar/minibar.js index efd36fee2..9c12099de 100644 --- a/src/runtime/javascript/minibar/minibar.js +++ b/src/runtime/javascript/minibar/minibar.js @@ -18,25 +18,21 @@ show_completions(complete_output) // For backward compatibility: function start_minibar(server,opts,target) { - return new Minibar(server,opts,target); + if(target) opts.target=target; + return new Minibar(server,opts); } /* --- Main Minibar object -------------------------------------------------- */ -function Minibar(server,opts,target) { +function Minibar(server,opts) { // Contructor, typically called when the HTML document is loaded /* --- Configuration ---------------------------------------------------- */ // default values for options: this.options={ - show_abstract: false, - show_trees: false, - show_grouped_translations: true, - delete_button_text: "⌫", - default_source_language: null, + target: "minibar", try_google: true, feedback_url: null, - random_button: true, help_url: null } @@ -45,14 +41,14 @@ function Minibar(server,opts,target) { /* --- Creating the components of the minibar --------------------------- */ this.translations=new Translations(server,this.options) - this.input=new Input(server,this.options,this.translations) + this.input=new Input(server,this.translations,this.options) /* --- Creating user interface elements --------------------------------- */ this.menubar=empty("div"); this.extra=div_id("extra"); - this.minibar=element(target || "minibar"); + this.minibar=element(this.options.target); this.minibar.innerHTML=""; with(this) { appendChildren(menubar,[input.menus,translations.menus,input.buttons]) diff --git a/src/runtime/javascript/minibar/minibar_input.js b/src/runtime/javascript/minibar/minibar_input.js index 098c88bba..3269712e3 100644 --- a/src/runtime/javascript/minibar/minibar_input.js +++ b/src/runtime/javascript/minibar/minibar_input.js @@ -1,11 +1,21 @@ /* --- Input object --------------------------------------------------------- */ -function Input(server,options,translations) { - // Input object constructor - this.options=options; +function Input(server,translations,opts) { // Input object constructor this.server=server; this.translations=translations; + + // Default values for options: + this.options={ + delete_button_text: "⌫", + default_source_language: null, + random_button: true, + } + + // Apply supplied options + if(opts) for(var o in opts) this.options[o]=opts[o]; + + // User interface elements this.main=empty("div"); this.menus=empty("span"); this.buttons=empty("span"); diff --git a/src/runtime/javascript/minibar/minibar_online.js b/src/runtime/javascript/minibar/minibar_online.js index 6d15a306b..1c15e87bf 100644 --- a/src/runtime/javascript/minibar/minibar_online.js +++ b/src/runtime/javascript/minibar/minibar_online.js @@ -22,4 +22,4 @@ var minibar_options= { //feedback_url: "feedback.html", try_google: true } -var minibar=new Minibar(server,minibar_options,"minibar"); +var minibar=new Minibar(server,minibar_options); diff --git a/src/runtime/javascript/minibar/minibar_translations.js b/src/runtime/javascript/minibar/minibar_translations.js index 3a9fb1fee..c9164a6a9 100644 --- a/src/runtime/javascript/minibar/minibar_translations.js +++ b/src/runtime/javascript/minibar/minibar_translations.js @@ -1,8 +1,17 @@ /* --- Translations object -------------------------------------------------- */ -function Translations(server,options) { +function Translations(server,opts) { this.server=server; - this.options=options; + + // Default values for options: + this.options={ + show_abstract: false, + show_trees: false, + show_grouped_translations: true, + } + + // Apply supplied options + if(opts) for(var o in opts) this.options[o]=opts[o]; this.main=empty("div"); this.menus=empty("span");