On Wed, Jul 18, 2012 at 6:30 AM, Gusts Kaksis <gusts.kak...@gmail.com>wrote:

>  Hi, Bob!
>
>
> On 2012.07.18. 6:52, Robert Hanson wrote:
>
>  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.
>

yes, set hoverLabel -- same syntax as any label. Also set
defaultDistanceLabel, set defaultAngleLabel, set defaultTorsionLabel, and I
think there are other ways as well of changing measurement labels.



>
>
>
>>
>>  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" class="jmol-load">Perform some actions</a>
>
>
please make that "jmol-scriptfile" because the load command is different
from the script command.


> 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);
>

make that:

Jmol.addScript('.jmol-button', [callbackFunction, param1, param2, ....])

and you have it!

With check boxes, how are you planning to assign different scripts to on
and off?


>
> 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;
> }
>
>
the function callback needs to have (1) the first parameter a "this" from
the calling HTML element and (2) the full  bracketed object being called.



> 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.
>

Sorry,  I meant <select> elements.



>
> 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.
>

I totally agree. jQuery is pure genius.


>
>
> 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.
>

That's too specific. The way it "used" to be done is

form.reset()

This is what Jmol does right now automatically if you have included your
objects in a <form> wrapper. I know that sounds terribly antiquated, but
form.reset() is particularly useful.

Sounding better and better,

If you could work with JmolApi.js and just (for now) create new jQuery
implementations of those, it would be great. Then we could make sure they
have the same functionality and not have to go through all this again this
way. Could you do that? Any reason not to? Why  not just have the very
basic essence in the page:


<a id="link1" class="jmol-link">Perform some actions</a>


and then in the onload event one of the following?

Jmol.setScript(jmolApplet0, "link1", "wireframe 0")
Jmol.setScript(jmolApplet0, "link1", "script myscript.spt")
Jmol.setScript(jmolApplet0, "link1", [myfunc, myparam1, myparam2,...])

Still not sure how that would work for selects or check boxes...

Q: Is it pretty simple to set up checkbox groups in jQuery? JmolApi makes
that relatively easy.

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

Reply via email to