Hi, Bob!

On 2012.07.18. 6:52, Robert Hanson wrote:
Comments below...


    Yes, then I'd have to turn of my parser. And you didn't answer my
    question about output formatting. So I'll repeat it here:

    I'm more intereseted weather the syntax of hover's 1st parameter
    will allways be "atom atom_num x y z"?

Sorry, thought I had answered that. It's totally up to the page designer. They can set the hover to just about anything, and there is a callback that lets them set it from JavaScript on the fly.


    And what about those parameters of measurement?
    "Angle H #2 - C #1 - H #3 : 109.477165", 3, "measurePicked",
    109.47716522216797
    1st - a string representation of a mesurement
    2nd - ?
    3rd - action name?
    4th - the angle as a float, right?


Same deal. That's just the default. Honestly, I wouldn't touch it. It's in the category of "let the page developer decide what they want."

    I think it would be easier for a developer if thease values would
    be presented in a nice and documented structure, so that they can
    create whatever output they wish from it.


Pretty sure that's all discussed on the Jmol JsLibrary page referred to earlier. If not, that's an omission. Take a look at http://chemapps.stolaf.edu/jmol/docs/#setcallback and http://jmol.sourceforge.net/jslibrary/#jmolSetCallback
I agree, if it's customizable through Jmol, then it definitely should be left as is, but I can not find what setting is it, that configures the output string. Is it "set hoverLabel" (documentation does not say much about it)? And what's the syntax for it? I just thought that the default output is the only output, so then it would be helpful to pre-parse that string for a developer, otherwise, the string is useful only for some log console output.


    Well, then for very complicated script I see a solution, right in
    that spt file. And why not? It's the same as a js file for the
    browser.


Yes, that's what people do, provided it's a static script that is needed. But it's not always static. Sometimes the script itself is created dynamically depending upon events on the page. That's why we have the option for direct JavaScript function calls instead of actual scripts with all the controls:

Jmol.jmolButton(jmol, [funcName, param1, params2, ....], "press me")
Then there are 3 separate options to think about:
1. data attribute for simple scripts (few commands);

<a href="#" class="jmol-script" data-script="wireframe on">Wireframe</a>

initialized by: Jmol.bindScriptable('.jmol-script');

which inside API looks like this:

bindScriptable = function(jquery_selector){
  $(jquery_selector).click(function(e){
    e.preventDefault();
    $jquery_jmol_object.jmol($(this).data('script'));
  });
};

all the links with class jmol-script will be made Jmol script buttons

2. spt file for complex static scripts

<a href="some_script.spt" calss="jmol-load">Perform some actions</a>

initialized by: Jmol.bindLoadable('.jmol-load');

which is:

bindLoadable = function(jquery_selector){
  $(jquery_selector).click(function(e){
    e.preventDefault();
    $jquery_jmol_object.jmol('load "' + $(this).data('script') + '"');
  });
};

3. callback function for complex and dynamic scripts like this:

Jmol.addScript('.jmol-button', callbackFunction);

whereas in Jmol API  source:

addScript = function(jquery_selector, cbFunction){
  $(jquery_selector).click(function(e){
    e.preventDefault();
    $jquery_jmol_object.jmol(cbFunction());
  });
};

and callback funciton provided by developer:

function callbackFunction(){
  var script = '';
  // generate the script here
  return script;
}

One core feature that could have been made different in the new API is that for multiple instances you could use good ol' new keyword, not just pass jmol object around to every method. Like this:

var jmol1 = new Jmol(selector, settings);
jmol1.addButton(...);
etc.

But that's just my thought.

for example. It think that's basically what you are implementing with your click events.

In menus, how does jQuery handle use of the up/down arrows?
Umm, what menus? I think jQuery has nothing to do with them.

jQuery is a neat and thin layer over DOM and events + some AJAX functionality. Basically the 5 things I love about jQuery are: 1. CSS selectors to query DOM elements - even for browsers that still don't support the native querySelector() methods; 2. AJAX wrapper - and as I showed you before, if some browser, has some problems with default XHR, you can implement your own AJAX backend; 3. Events - not just DOM events, also custom events, like the ones I made for Jmol.
4. Shorthand syntax for DOM manipulation;
5. Method chaining.

One thing I can see useful with jQuery is that we often have use for form resets. Very annoying when a page is reloaded and the controls are not reset.
Umm ... $('input, select, textarea').val(''); should do the trick.





Bob


--
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Chemistry Department
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers


--
Gusts Kaksis

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to