/[drupal]/contributions/modules/spajax/spajax.js
ViewVC logotype

Contents of /contributions/modules/spajax/spajax.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Jan 31 20:58:22 2006 UTC (3 years, 9 months ago) by jjeff
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/javascript
Initial commit of the Scriptaculous/Prototype Ajax module.
1 function float_menu(menu_id, pos, top_pos, left_pos, callback){
2 menu = $(menu_id);
3 if(pos != 'normal'){
4 // set up positioning and draggability
5 Element.addClassName(menu, 'floatmenu');
6 menu.style.position = pos;
7 document.body.appendChild(menu);
8 handle = document.getElementsByClassName('title', menu_id)[0];
9 new Draggable(menu_id, {handle:handle});
10 Element.addClassName(handle, 'draggable');
11 Event.observe(handle, 'mouseup', function(){
12 new Ajax.Request(callback, { method: "post", postBody: 'vars['+menu_id+'][left]='+ $(menu_id).style.left +'&vars['+menu_id+'][top]='+ $(menu_id).style.top });
13 });
14 $(menu_id).style.top = top_pos;
15 $(menu_id).style.left = left_pos;
16 }
17 expandeds = document.getElementsByClassName('expanded', menu_id);
18 for (i=0; i<expandeds.length; i++) {
19 subul = expandeds[i].getElementsByTagName('ul')[0];
20 firsta = expandeds[i].getElementsByTagName('a')[0];
21 firsta.myli = expandeds[i];
22 firstaclone = firsta.cloneNode(true);
23 subactive = document.getElementsByClassName('active', expandeds[i]).length;
24 if (!subactive) {
25 Element.hide(subul);
26 Element.addClassName(firsta, 'collapsed');
27 Element.removeClassName(expandeds[i], 'expanded');
28 Element.addClassName(expandeds[i], 'collapsed');
29 }
30 else {
31 Element.addClassName(firsta, 'expanded');
32 }
33 liclone = expandeds[i].cloneNode(false);
34 Element.removeClassName(firsta, 'active');
35 firsta.setAttribute('onclick', 'this.blur(); return false;');
36 liclone.className = 'leaf';
37 liclone.appendChild(firstaclone);
38 lis = subul.getElementsByTagName('li');
39 subul.insertBefore(liclone, lis[0]);
40 Element.addClassName(lis[lis.length - 1], 'last');
41 firsta.flip = function() {
42 myul = this.parentNode.getElementsByTagName('ul')[0];
43 vis = Element.visible(myul);
44 Element.removeClassName(this, vis ? 'expanded' : 'collapsed');
45 Element.addClassName(this, vis ? 'collapsed' : 'expanded');
46 Element.removeClassName(this.myli, vis ? 'expanded' : 'collapsed');
47 Element.addClassName(this.myli, vis ? 'collapsed' : 'expanded');
48 new Effect.toggle(this.parentNode.getElementsByTagName('ul')[0], 'blind');
49 }
50 Event.observe(firsta, 'click', firsta.flip);}
51 }
52
53 function change_ops(){
54
55 }
56
57 function op_click(){
58 //$(this.myForm).change_ops();
59 // set name attribute
60
61 }
62
63 function use_ajax(form_id, callback, div_id){
64 $(form_id).onsubmit = function() {
65 var cdiv = document.getElementsByClassName('comment')[0];
66 new Ajax.Updater(cdiv, callback, {evalScripts:true, method:'post', postBody:Form.serialize(this)});
67 return false;
68 }
69 var ops = Form.getInputs(form_id, 'submit', 'op');
70 for(op in ops){
71 op.onclick = op_click;
72 op.myForm = form_id;
73 }
74 }

  ViewVC Help
Powered by ViewVC 1.1.2