alpheios-project / morphlib

Morphological Lookup Library
GNU General Public License v3.0
3 stars 0 forks source link

should the popup widget extend an existing UI library (such as jQuery) #1

Closed balmas closed 8 years ago

balmas commented 8 years ago

@PonteIneptique suggests that the final UI plugin (i.e. HTML representation of the lookup results) is expressed as an implementation of a broader JS library (e.g. as a jQuery plugin). There are pros and cons to this. I want the design of these libraries to be as lightweight as possible with as few external dependencies as possible, but I can also see the value in using an established paradigm. Would like to have a dialogue about this before deciding.

balmas commented 8 years ago

I reworded the title of this, because I think I misunderstood the recommendation from @PonteIneptique . The requirement is that both the JSON object and HTML Widget implement an abstract model of the morphological representation they express. i.e. we should have something like a MorphObj class which provides accessors to the various properties (lemma, infl, pofs, etc) and the HTML and JSON objects are format-specific representations.

(I think this is actually an extension and clarification of the following requirement: "do not tightly couple the lookup functionality with the service API. (Abstract the functionality from the provider).")

@PonteIneptique have I understood correctly?

PonteIneptique commented 8 years ago

It could be but let it phrase it like that :

The core JS library should offer all functionality the same way controller and models work in MVC based development. They should be as decoupled as possible from the view (UI Plugin) so that its reusability is expanded. ie

Main javascript build


MorphLib= function() {
    this.models = {

   };
   this.controllers = {
   };
   this.async = function(url, param, method, success, failure) {}
}

morphlib.jquery.js (this could be also vanilla js...)

(function ($, morphlib){
    $.plugins.morphlib = function(options) {
        // Init...
        this.retrieve = function(word) {
            morphlib.controllers.getWord({
                word: word,
                success: function(data) {
                    console.log(data);
                    // do something in the UI
                }
            }
        }
})(jQuery, Morphlib)
balmas commented 8 years ago

thanks. added to the requirements doc.