Changeset 114
- Timestamp:
- 03/02/07 17:33:48 (2 years ago)
- Files:
-
- trunk/lib/AkActionView/helpers/url_helper.php (modified) (1 diff)
- trunk/public/javascripts/builder.js (modified) (5 diffs)
- trunk/public/javascripts/controls.js (modified) (16 diffs)
- trunk/public/javascripts/dragdrop.js (modified) (30 diffs)
- trunk/public/javascripts/effects.js (modified) (45 diffs)
- trunk/public/javascripts/scriptaculous.js (modified) (2 diffs)
- trunk/public/javascripts/slider.js (modified) (6 diffs)
- trunk/public/javascripts/unittest.js (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/AkActionView/helpers/url_helper.php
r95 r114 292 292 } 293 293 294 $onclick = ''; 294 295 if ($popup && $post){ 295 296 trigger_error(Ak::t("You can't use popup and post in the same link"), E_USER_ERROR); 296 } 297 elseif($confirm && $popup){ 298 $html_options['onclick'] = 'if ('.$this->_confirm_javascript_function($confirm).') { '.$this->_popup_javascript_function($popup).' };return false;'; 299 } 300 elseif ($confirm && $post) { 301 $html_options['onclick'] = 'if ('.$this->_confirm_javascript_function($confirm).') { '.$this->_post_javascript_function().' };return false;'; 302 } 303 elseif ($confirm) { 304 $html_options['onclick'] = 'return '.$this->_confirm_javascript_function($confirm).';'; 305 } 306 elseif ($post) { 307 $html_options['onclick'] = $this->_post_javascript_function().'return false;'; 308 } 309 elseif ($popup) { 310 $html_options['onclick'] = $this->_popup_javascript_function($popup).'return false;'; 311 } 312 else{ 313 $html_options['onclick'] = null; 314 } 315 return; 297 298 }elseif($confirm && $popup){ 299 $onclick = 'if ('.$this->_confirm_javascript_function($confirm).') { '.$this->_popup_javascript_function($popup).' };return false;'; 300 301 }elseif ($confirm && $post) { 302 $onclick = 'if ('.$this->_confirm_javascript_function($confirm).') { '.$this->_post_javascript_function().' };return false;'; 303 304 }elseif ($confirm) { 305 $onclick = 'return '.$this->_confirm_javascript_function($confirm).';'; 306 307 }elseif ($post) { 308 $onclick = $this->_post_javascript_function().'return false;'; 309 310 }elseif ($popup) { 311 $onclick = $this->_popup_javascript_function($popup).'return false;'; 312 313 } 314 $html_options['onclick'] = empty($html_options['onclick']) ? $onclick : $html_options['onclick'].$onclick; 316 315 } 317 316 trunk/public/javascripts/builder.js
r2 r114 1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 1 // script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 2 3 // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 2 4 // 3 // See scriptaculous.js for full license. 5 // script.aculo.us is freely distributable under the terms of an MIT-style license. 6 // For details, see the script.aculo.us web site: http://script.aculo.us/ 4 7 5 8 var Builder = { … … 34 37 35 38 // see if browser added wrapping tags 36 if(element && (element.tagName != elementName))39 if(element && (element.tagName.toUpperCase() != elementName)) 37 40 element = element.getElementsByTagName(elementName)[0]; 38 41 … … 62 65 element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; 63 66 } 64 if(element.tagName != elementName)67 if(element.tagName.toUpperCase() != elementName) 65 68 element = parentElement.getElementsByTagName(elementName)[0]; 66 69 } … … 76 79 return document.createTextNode(text); 77 80 }, 81 82 ATTR_MAP: { 83 'className': 'class', 84 'htmlFor': 'for' 85 }, 86 78 87 _attributes: function(attributes) { 79 88 var attrs = []; 80 89 for(attribute in attributes) 81 attrs.push((attribute =='className' ? 'class': attribute) +90 attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) + 82 91 '="' + attributes[attribute].toString().escapeHTML() + '"'); 83 92 return attrs.join(" "); … … 98 107 _isStringOrNumber: function(param) { 99 108 return(typeof param=='string' || typeof param=='number'); 109 }, 110 build: function(html) { 111 var element = this.node('div'); 112 $(element).update(html.strip()); 113 return element.down(); 114 }, 115 dump: function(scope) { 116 if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope 117 118 var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " + 119 "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " + 120 "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+ 121 "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+ 122 "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+ 123 "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/); 124 125 tags.each( function(tag){ 126 scope[tag] = function() { 127 return Builder.node.apply(Builder, [tag].concat($A(arguments))); 128 } 129 }); 100 130 } 101 131 } trunk/public/javascripts/controls.js
r2 r114 1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 2 // (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) 3 // (c) 2005 Jon Tirsen (http://www.tirsen.com) 1 // script.aculo.us controls.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 2 3 // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 4 // (c) 2005, 2006 Ivan Krstic (http://blogs.law.harvard.edu/ivan) 5 // (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com) 4 6 // Contributors: 5 7 // Richard Livsey … … 7 9 // Rob Wills 8 10 // 9 // See scriptaculous.js for full license. 11 // script.aculo.us is freely distributable under the terms of an MIT-style license. 12 // For details, see the script.aculo.us web site: http://script.aculo.us/ 10 13 11 14 // Autocompleter.Base handles all the autocompletion functionality … … 33 36 // useful when one of the tokens is \n (a newline), as it 34 37 // allows smart autocompletion after linebreaks. 38 39 if(typeof Effect == 'undefined') 40 throw("controls.js requires including script.aculo.us' effects.js library"); 35 41 36 42 var Autocompleter = {} … … 46 52 this.entryCount = 0; 47 53 48 if (this.setOptions)54 if(this.setOptions) 49 55 this.setOptions(options); 50 56 else … … 56 62 this.options.minChars = this.options.minChars || 1; 57 63 this.options.onShow = this.options.onShow || 58 function(element, update){ 59 if(!update.style.position || update.style.position=='absolute') { 60 update.style.position = 'absolute'; 61 Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight}); 62 } 63 Effect.Appear(update,{duration:0.15}); 64 }; 64 function(element, update){ 65 if(!update.style.position || update.style.position=='absolute') { 66 update.style.position = 'absolute'; 67 Position.clone(element, update, { 68 setHeight: false, 69 offsetTop: element.offsetHeight 70 }); 71 } 72 Effect.Appear(update,{duration:0.15}); 73 }; 65 74 this.options.onHide = this.options.onHide || 66 function(element, update){ new Effect.Fade(update,{duration:0.15}) };67 68 if (typeof(this.options.tokens) == 'string')75 function(element, update){ new Effect.Fade(update,{duration:0.15}) }; 76 77 if(typeof(this.options.tokens) == 'string') 69 78 this.options.tokens = new Array(this.options.tokens); 70 79 … … 95 104 96 105 fixIEOverlapping: function() { 97 Position.clone(this.update, this.iefix );106 Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)}); 98 107 this.iefix.style.zIndex = 1; 99 108 this.update.style.zIndex = 2; … … 203 212 if(this.index > 0) this.index-- 204 213 else this.index = this.entryCount-1; 214 this.getEntry(this.index).scrollIntoView(true); 205 215 }, 206 216 … … 208 218 if(this.index < this.entryCount-1) this.index++ 209 219 else this.index = 0; 220 this.getEntry(this.index).scrollIntoView(false); 210 221 }, 211 222 … … 255 266 this.update.innerHTML = choices; 256 267 Element.cleanWhitespace(this.update); 257 Element.cleanWhitespace(this.update. firstChild);258 259 if(this.update.firstChild && this.update. firstChild.childNodes) {268 Element.cleanWhitespace(this.update.down()); 269 270 if(this.update.firstChild && this.update.down().childNodes) { 260 271 this.entryCount = 261 this.update. firstChild.childNodes.length;272 this.update.down().childNodes.length; 262 273 for (var i = 0; i < this.entryCount; i++) { 263 274 var entry = this.getEntry(i); … … 270 281 271 282 this.stopIndicator(); 272 273 283 this.index = 0; 274 this.render(); 284 285 if(this.entryCount==1 && this.options.autoSelect) { 286 this.selectEntry(); 287 this.hide(); 288 } else { 289 this.render(); 290 } 275 291 } 276 292 }, … … 460 476 461 477 this.options = Object.extend({ 478 paramName: "value", 462 479 okButton: true, 463 480 okText: "ok", … … 532 549 this.createForm(); 533 550 this.element.parentNode.insertBefore(this.form, this.element); 534 Field.scrollFreeActivate(this.editField);551 if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField); 535 552 // stop the event to avoid a page refresh in Safari 536 553 if (evt) { … … 591 608 textField.obj = this; 592 609 textField.type = "text"; 593 textField.name = "value";610 textField.name = this.options.paramName; 594 611 textField.value = text; 595 612 textField.style.backgroundColor = this.options.highlightcolor; … … 604 621 var textArea = document.createElement("textarea"); 605 622 textArea.obj = this; 606 textArea.name = "value";623 textArea.name = this.options.paramName; 607 624 textArea.value = this.convertHTMLLineBreaks(text); 608 625 textArea.rows = this.options.rows; … … 637 654 this.editField.disabled = false; 638 655 this.editField.value = transport.responseText.stripTags(); 656 Field.scrollFreeActivate(this.editField); 639 657 }, 640 658 onclickCancel: function() { … … 773 791 optionTag = document.createElement("option"); 774 792 optionTag.value = (e instanceof Array) ? e[0] : e; 793 if((typeof this.options.value == 'undefined') && 794 ((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true; 775 795 if(this.options.value==optionTag.value) optionTag.selected = true; 776 796 optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e)); trunk/public/javascripts/dragdrop.js
r2 r114 1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 2 // (c) 2005 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) 1 // script.aculo.us dragdrop.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 2 3 // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 4 // (c) 2005, 2006 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) 3 5 // 4 // See scriptaculous.js for full license. 5 6 /*--------------------------------------------------------------------------*/ 6 // script.aculo.us is freely distributable under the terms of an MIT-style license. 7 // For details, see the script.aculo.us web site: http://script.aculo.us/ 8 9 if(typeof Effect == 'undefined') 10 throw("dragdrop.js requires including script.aculo.us' effects.js library"); 7 11 8 12 var Droppables = { … … 146 150 147 151 activate: function(draggable) { 148 window.focus(); // allows keypress events if window isn't currently focused, fails for Safari 149 this.activeDraggable = draggable; 152 if(draggable.options.delay) { 153 this._timeout = setTimeout(function() { 154 Draggables._timeout = null; 155 window.focus(); 156 Draggables.activeDraggable = draggable; 157 }.bind(this), draggable.options.delay); 158 } else { 159 window.focus(); // allows keypress events if window isn't currently focused, fails for Safari 160 this.activeDraggable = draggable; 161 } 150 162 }, 151 163 … … 161 173 if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; 162 174 this._lastPointer = pointer; 175 163 176 this.activeDraggable.updateDrag(event, pointer); 164 177 }, 165 178 166 179 endDrag: function(event) { 180 if(this._timeout) { 181 clearTimeout(this._timeout); 182 this._timeout = null; 183 } 167 184 if(!this.activeDraggable) return; 168 185 this._lastPointer = null; … … 191 208 if(o[eventName]) o[eventName](eventName, draggable, event); 192 209 }); 210 if(draggable.options[eventName]) draggable.options[eventName](draggable, event); 193 211 }, 194 212 … … 205 223 206 224 var Draggable = Class.create(); 225 Draggable._dragging = {}; 226 207 227 Draggable.prototype = { 208 228 initialize: function(element) { 209 var options = Object.extend({229 var defaults = { 210 230 handle: false, 211 starteffect: function(element) {212 element._opacity = Element.getOpacity(element);213 new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});214 },215 231 reverteffect: function(element, top_offset, left_offset) { 216 232 var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; 217 element._revert = new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur}); 233 new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur, 234 queue: {scope:'_draggable', position:'end'} 235 }); 218 236 }, 219 237 endeffect: function(element) { 220 var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0 221 new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity}); 238 var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0; 239 new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, 240 queue: {scope:'_draggable', position:'end'}, 241 afterFinish: function(){ 242 Draggable._dragging[element] = false 243 } 244 }); 222 245 }, 223 246 zindex: 1000, … … 226 249 scrollSensitivity: 20, 227 250 scrollSpeed: 15, 228 snap: false // false, or xy or [x,y] or function(x,y){ return [x,y] } 229 }, arguments[1] || {}); 251 snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] } 252 delay: 0 253 }; 254 255 if(!arguments[1] || typeof arguments[1].endeffect == 'undefined') 256 Object.extend(defaults, { 257 starteffect: function(element) { 258 element._opacity = Element.getOpacity(element); 259 Draggable._dragging[element] = true; 260 new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7}); 261 } 262 }); 263 264 var options = Object.extend(defaults, arguments[1] || {}); 230 265 231 266 this.element = $(element); 232 267 233 if(options.handle && (typeof options.handle == 'string')) { 234 var h = Element.childrenWithClassName(this.element, options.handle, true); 235 if(h.length>0) this.handle = h[0]; 236 } 268 if(options.handle && (typeof options.handle == 'string')) 269 this.handle = this.element.down('.'+options.handle, 0); 270 237 271 if(!this.handle) this.handle = $(options.handle); 238 272 if(!this.handle) this.handle = this.element; 239 273 240 if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) 274 if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { 241 275 options.scroll = $(options.scroll); 276 this._isScrollChild = Element.childOf(this.element, options.scroll); 277 } 242 278 243 279 Element.makePositioned(this.element); // fix IE … … 265 301 266 302 initDrag: function(event) { 303 if(typeof Draggable._dragging[this.element] != 'undefined' && 304 Draggable._dragging[this.element]) return; 267 305 if(Event.isLeftClick(event)) { 268 306 // abort on form elements, fixes a Firefox issue 269 307 var src = Event.element(event); 270 if( src.tagName&& (271 src.tagName=='INPUT' ||272 src.tagName=='SELECT' ||273 src.tagName=='OPTION' ||274 src.tagName=='BUTTON' ||275 src.tagName=='TEXTAREA')) return;308 if((tag_name = src.tagName.toUpperCase()) && ( 309 tag_name=='INPUT' || 310 tag_name=='SELECT' || 311 tag_name=='OPTION' || 312 tag_name=='BUTTON' || 313 tag_name=='TEXTAREA')) return; 276 314 277 if(this.element._revert) {278 this.element._revert.cancel();279 this.element._revert = null;280 }281 282 315 var pointer = [Event.pointerX(event), Event.pointerY(event)]; 283 316 var pos = Position.cumulativeOffset(this.element); … … 315 348 316 349 Draggables.notify('onStart', this, event); 350 317 351 if(this.options.starteffect) this.options.starteffect(this.element); 318 352 }, … … 323 357 Droppables.show(pointer, this.element); 324 358 Draggables.notify('onDrag', this, event); 359 325 360 this.draw(pointer); 326 361 if(this.options.change) this.options.change(this); … … 334 369 } else { 335 370 p = Position.page(this.options.scroll); 336 p[0] += this.options.scroll.scrollLeft ;337 p[1] += this.options.scroll.scrollTop ;371 p[0] += this.options.scroll.scrollLeft + Position.deltaX; 372 p[1] += this.options.scroll.scrollTop + Position.deltaY; 338 373 p.push(p[0]+this.options.scroll.offsetWidth); 339 374 p.push(p[1]+this.options.scroll.offsetHeight); … … 381 416 if(this.options.endeffect) 382 417 this.options.endeffect(this.element); 383 418 384 419 Draggables.deactivate(this); 385 420 Droppables.reset(); … … 401 436 draw: function(point) { 402 437 var pos = Position.cumulativeOffset(this.element); 438 if(this.options.ghosting) { 439 var r = Position.realOffset(this.element); 440 pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY; 441 } 442 403 443 var d = this.currentDelta(); 404 444 pos[0] -= d[0]; pos[1] -= d[1]; 405 445 406 if(this.options.scroll && (this.options.scroll != window )) {446 if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { 407 447 pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; 408 448 pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; … … 431 471 if((!this.options.constraint) || (this.options.constraint=='vertical')) 432 472 style.top = p[1] + "px"; 473 433 474 if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering 434 475 }, … … 443 484 444 485 startScrolling: function(speed) { 486 if(!(speed[0] || speed[1])) return; 445 487 this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; 446 488 this.lastScrolled = new Date(); … … 467 509 Droppables.show(Draggables._lastPointer, this.element); 468 510 Draggables.notify('onDrag', this); 469 Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); 470 Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; 471 Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; 472 if (Draggables._lastScrollPointer[0] < 0) 473 Draggables._lastScrollPointer[0] = 0; 474 if (Draggables._lastScrollPointer[1] < 0) 475 Draggables._lastScrollPointer[1] = 0; 476 this.draw(Draggables._lastScrollPointer); 511 if (this._isScrollChild) { 512 Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); 513 Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; 514 Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; 515 if (Draggables._lastScrollPointer[0] < 0) 516 Draggables._lastScrollPointer[0] = 0; 517 if (Draggables._lastScrollPointer[1] < 0) 518 Draggables._lastScrollPointer[1] = 0; 519 this.draw(Draggables._lastScrollPointer); 520 } 477 521 478 522 if(this.options.change) this.options.change(this); … … 526 570 527 571 var Sortable = { 572 SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, 573 528 574 sortables: {}, 529 575 530 576 _findRootElement: function(element) { 531 while (element.tagName != "BODY") {577 while (element.tagName.toUpperCase() != "BODY") { 532 578 if(element.id && Sortable.sortables[element.id]) return element; 533 579 element = element.parentNode; … … 566 612 handle: false, // or a CSS class 567 613 only: false, 614 delay: 0, 568 615 hoverclass: null, 569 616 ghosting: false, … … 571 618 scrollSensitivity: 20, 572 619 scrollSpeed: 15, 573 format: /^[^_]*_(.*)$/,620 format: this.SERIALIZE_RULE, 574 621 onChange: Prototype.emptyFunction, 575 622 onUpdate: Prototype.emptyFunction … … 585 632 scrollSpeed: options.scrollSpeed, 586 633 scrollSensitivity: options.scrollSensitivity, 634 delay: options.delay, 587 635 ghosting: options.ghosting, 588 636 constraint: options.constraint, … … 613 661 hoverclass: options.hoverclass, 614 662 onHover: Sortable.onHover 615 //greedy: !options.dropOnEmpty616 663 } 617 664 … … 638 685 // handles are per-draggable 639 686 var handle = options.handle ? 640 Element.childrenWithClassName(e, options.handle)[0]: e;687 $(e).down('.'+options.handle,0) : e; 641 688 options.draggables.push( 642 689 new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); … … 709 756 var index; 710 757 711 var children = Sortable.findElements(dropon, {tag: droponOptions.tag });758 var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only}); 712 759 var child = null; 713 760 … … 736 783 737 784 unmark: function() { 738 if(Sortable._marker) Element.hide(Sortable._marker);785 if(Sortable._marker) Sortable._marker.hide(); 739 786 }, 740 787 … … 745 792 746 793 if(!Sortable._marker) { 747 Sortable._marker = $('dropmarker') || document.createElement('DIV'); 748 Element.hide(Sortable._marker); 749 Element.addClassName(Sortable._marker, 'dropmarker'); 750 Sortable._marker.style.position = 'absolute'; 794 Sortable._marker = 795 ($('dropmarker') || Element.extend(document.createElement('DIV'))). 796 hide().addClassName('dropmarker').setStyle({position:'absolute'}); 751 797 document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); 752 798 } 753 799 var offsets = Position.cumulativeOffset(dropon); 754 Sortable._marker.style.left = offsets[0] + 'px'; 755 Sortable._marker.style.top = offsets[1] + 'px'; 800 Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'}); 756 801 757 802 if(position=='after') 758 803 if(sortable.overlap == 'horizontal') 759 Sortable._marker.s tyle.left = (offsets[0]+dropon.clientWidth) + 'px';804 Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'}); 760 805 else 761 Sortable._marker.s tyle.top = (offsets[1]+dropon.clientHeight) + 'px';762 763 Element.show(Sortable._marker);806 Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'}); 807 808 Sortable._marker.show(); 764 809 }, 765 810 … … 776 821 element: element, 777 822 parent: parent, 778 children: new Array,823 children: [], 779 824 position: parent.children.length, 780 container: Sortable._findChildrenElement(children[i], options.treeTag.toUpperCase())825 container: $(children[i]).down(options.treeTag) 781 826 } 782 827 … … 789 834 790 835 return parent; 791 },792 793 /* Finds the first element of the given tag type within a parent element.794 Used for finding the first LI[ST] within a L[IST]I[TEM].*/795 _findChildrenElement: function (element, containerTag) {796 if (element && element.hasChildNodes)797 for (var i = 0; i < element.childNodes.length; ++i)798 if (element.childNodes[i].tagName == containerTag)799 return element.childNodes[i];800 801 return null;802 836 }, 803 837 … … 816 850 id: null, 817 851 parent: null, 818 children: new Array,852 children: [], 819 853 container: element, 820 854 position: 0 821 855 } 822 856 823 return Sortable._tree (element, options, root);857 return Sortable._tree(element, options, root); 824 858 }, 825 859 … … 870 904 if (options.tree) { 871 905 return Sortable.tree(element, arguments[1]).children.map( function (item) { 872 return [name + Sortable._constructIndex(item) + " =" +906 return [name + Sortable._constructIndex(item) + "[id]=" + 873 907 encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); 874 908 }).flatten().join('&'); … … 881 915 } 882 916 883 / * Returns true if child is contained within element */917 // Returns true if child is contained within element 884 918 Element.isParent = function(child, element) { 885 919 if (!child.parentNode || child == element) return false; 886 887 920 if (child.parentNode == element) return true; 888 889 921 return Element.isParent(child.parentNode, element); 890 922 } … … 909 941 910 942 Element.offsetSize = function (element, type) { 911 if (type == 'vertical' || type == 'height') 912 return element.offsetHeight; 913 else 914 return element.offsetWidth; 943 return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; 915 944 } trunk/public/javascripts/effects.js
r2 r114 1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 1 // script.aculo.us effects.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 2 3 // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 2 4 // Contributors: 3 5 // Justin Palmer (http://encytemedia.com/) … … 5 7 // Martin Bialasinki 6 8 // 7 // See scriptaculous.js for full license. 8 9 /* ------------- element ext -------------- */ 10 9 // script.aculo.us is freely distributable under the terms of an MIT-style license. 10 // For details, see the script.aculo.us web site: http://script.aculo.us/ 11 11 12 // converts rgb() and #xxx to #xxxxxx format, 12 13 // returns self (or first argument) if not convertable 13 14 String.prototype.parseColor = function() { 14 var color = '#'; 15 var color = '#'; 15 16 if(this.slice(0,4) == 'rgb(') { 16 17 var cols = this.slice(4,this.length-1).split(','); … … 25 26 } 26 27 28 /*--------------------------------------------------------------------------*/ 29 27 30 Element.collectTextNodes = function(element) { 28 31 return $A($(element).childNodes).collect( function(node) { … … 40 43 } 41 44 42 Element.setStyle = function(element, style) { 43 element = $(element); 44 for(k in style) element.style[k.camelize()] = style[k]; 45 } 46 47 Element.setContentZoom = function(element, percent) { 48 Element.setStyle(element, {fontSize: (percent/100) + 'em'}); 49 if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); 50 } 51 52 Element.getOpacity = function(element){ 53 var opacity; 54 if (opacity = Element.getStyle(element, 'opacity')) 55 return parseFloat(opacity); 56 if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/)) 57 if(opacity[1]) return parseFloat(opacity[1]) / 100; 58 return 1.0; 59 } 60 61 Element.setOpacity = function(element, value){ 62 element= $(element); 63 if (value == 1){ 64 Element.setStyle(element, { opacity: 65 (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 66 0.999999 : null }); 67 if(/MSIE/.test(navigator.userAgent)) 68 Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')}); 69 } else { 70 if(value < 0.00001) value = 0; 71 Element.setStyle(element, {opacity: value}); 72 if(/MSIE/.test(navigator.userAgent)) 73 Element.setStyle(element, 74 { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') + 75 'alpha(opacity='+value*100+')' }); 76 } 77 } 78 79 Element.getInlineOpacity = function(element){ 45 Element.setContentZoom = function(element, percent) { 46 element = $(element); 47 element.setStyle({fontSize: (percent/100) + 'em'}); 48 if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); 49 return element; 50 } 51 52 Element.getOpacity = function(element){ 53 return $(element).getStyle('opacity'); 54 } 55 56 Element.setOpacity = function(element, value){ 57 return $(element).setStyle({opacity:value}); 58 } 59 60 Element.getInlineOpacity = function(element){ 80 61 return $(element).style.opacity || ''; 81 }82 83 Element.childrenWithClassName = function(element, className) {84 return $A($(element).getElementsByTagName('*')).select(85 function(c) { return Element.hasClassName(c, className) });86 62 } 87 63 … … 92 68 element.appendChild(n); 93 69 element.removeChild(n); 94 } catch(e) {} 95 } 70 } catch(e) { } 71 }; 72 73 /*--------------------------------------------------------------------------*/ 96 74 97 75 Array.prototype.call = function() { … … 103 81 104 82 var Effect = { 83 _elementDoesNotExistError: { 84 name: 'ElementDoesNotExistError', 85 message: 'The specified DOM element does not exist, but is required for this effect to operate' 86 }, 105 87 tagifyText: function(element) { 88 if(typeof Builder == 'undefined') 89 throw("Effect.tagifyText requires including script.aculo.us' builder.js library"); 90 106 91 var tagifyStyle = 'position:relative'; 107 if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1'; 92 if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1'; 93 108 94 element = $(element); 109 95 $A(element.childNodes).each( function(child) { … … 149 135 queue: { position:'end', scope:(element.id || 'global'), limit: 1 } 150 136 }, arguments[2] || {}); 151 Effect[ Element.visible(element) ?137 Effect[element.visible() ? 152 138 Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); 153 139 } … … 158 144 /* ------------- transitions ------------- */ 159 145 160 Effect.Transitions = {} 161 162 Effect.Transitions.linear = function(pos) { 163 return pos; 164 } 165 Effect.Transitions.sinoidal = function(pos) { 166 return (-Math.cos(pos*Math.PI)/2) + 0.5; 167 } 168 Effect.Transitions.reverse = function(pos) { 169 return 1-pos; 170 } 171 Effect.Transitions.flicker = function(pos) { 172 return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; 173 } 174 Effect.Transitions.wobble = function(pos) { 175 return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; 176 } 177 Effect.Transitions.pulse = function(pos) { 178 return (Math.floor(pos*10) % 2 == 0 ? 179 (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10))); 180 } 181 Effect.Transitions.none = function(pos) { 182 return 0; 183 } 184 Effect.Transitions.full = function(pos) { 185 return 1; 186 } 146 Effect.Transitions = { 147 linear: Prototype.K, 148 sinoidal: function(pos) { 149 return (-Math.cos(pos*Math.PI)/2) + 0.5; 150 }, 151 reverse: function(pos) { 152 return 1-pos; 153 }, 154 flicker: function(pos) { 155 return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; 156 }, 157 wobble: function(pos) { 158 return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; 159 }, 160 pulse: function(pos, pulses) { 161 pulses = pulses || 5; 162 return ( 163 Math.round((pos % (1/pulses)) * pulses) == 0 ? 164 ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) : 165 1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) 166 ); 167 }, 168 none: function(pos) { 169 return 0; 170 }, 171 full: function(pos) { 172 return 1; 173 } 174 }; 187 175 188 176 /* ------------- core effects ------------- */ … … 211 199 }); 212 200 break; 201 case 'with-last': 202 timestamp = this.effects.pluck('startOn').max() || timestamp; 203 break; 213 204 case 'end': 214 205 // start effect after last queued effect has finished … … 224 215 225 216 if(!this.interval) 226 this.interval = setInterval(this.loop.bind(this), 40);217 this.interval = setInterval(this.loop.bind(this), 15); 227 218 }, 228 219 remove: function(effect) { … … 235 226 loop: function() { 236 227 var timePos = new Date().getTime(); 237 this.effects.invoke('loop', timePos); 228 for(var i=0, len=this.effects.length;i<len;i++) 229 if(this.effects[i]) this.effects[i].loop(timePos); 238 230 } 239 231 }); … … 255 247 transition: Effect.Transitions.sinoidal, 256 248 duration: 1.0, // seconds 257 fps: 25.0, // max. 25fps due to Effect.Queue implementation249 fps: 60.0, // max. 60fps due to Effect.Queue implementation 258 250 sync: false, // true for combining 259 251 from: 0.0, … … 323 315 }, 324 316 inspect: function() { 325 return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>'; 317 var data = $H(); 318 for(property in this) 319 if(typeof this[property] != 'function') data[property] = this[property]; 320 return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>'; 326 321 } 327 322 } … … 347 342 }); 348 343 344 Effect.Event = Class.create(); 345 Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), { 346 initialize: function() { 347 var options = Object.extend({ 348 duration: 0 349 }, arguments[0] || {}); 350 this.start(options); 351 }, 352 update: Prototype.emptyFunction 353 }); 354 349 355 Effect.Opacity = Class.create(); 350 356 Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), { 351 357 initialize: function(element) { 352 358 this.element = $(element); 359 if(!this.element) throw(Effect._elementDoesNotExistError); 353 360 // make this work on IE on elements without 'layout' 354 if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))355 Element.setStyle(this.element,{zoom: 1});361 if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout)) 362 this.element.setStyle({zoom: 1}); 356 363 var options = Object.extend({ 357 from: Element.getOpacity(this.element) || 0.0,364 from: this.element.getOpacity() || 0.0, 358 365 to: 1.0 359 366 }, arguments[1] || {}); … … 361 368 }, 362 369 update: function(position) { 363 Element.setOpacity(this.element,position);370 this.element.setOpacity(position); 364 371 } 365 372 }); … … 369 376 initialize: function(element) { 370 377 this.element = $(element); 378 if(!this.element) throw(Effect._elementDoesNotExistError); 371 379 var options = Object.extend({ 372 380 x: 0, … … 381 389 // ==> Always set top and left for position relative elements in your stylesheets 382 390 // (to 0 if you do not need them) 383 Element.makePositioned(this.element);384 this.originalLeft = parseFloat( Element.getStyle(this.element,'left') || '0');385 this.originalTop = parseFloat( Element.getStyle(this.element,'top') || '0');391 this.element.makePositioned(); 392 this.originalLeft = parseFloat(this.element.getStyle('left') || '0'); 393 this.originalTop = parseFloat(this.element.getStyle('top') || '0'); 386 394 if(this.options.mode == 'absolute') { 387 395 // absolute movement, so we need to calc deltaX and deltaY … … 391 399 }, 392 400 update: function(position) { 393 Element.setStyle(this.element,{394 left: this.options.x * position + this.originalLeft+ 'px',395 top: this.options.y * position + this.originalTop+ 'px'401 this.element.setStyle({ 402 left: Math.round(this.options.x * position + this.originalLeft) + 'px', 403 top: Math.round(this.options.y * position + this.originalTop) + 'px' 396 404 }); 397 405 } … … 407 415 Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { 408 416 initialize: function(element, percent) { 409 this.element = $(element) 417 this.element = $(element); 418 if(!this.element) throw(Effect._elementDoesNotExistError); 410 419 var options = Object.extend({ 411 420 scaleX: true, … … 421 430 setup: function() { 422 431 this.restoreAfterFinish = this.options.restoreAfterFinish || false; 423 this.elementPositioning = Element.getStyle(this.element,'position');432 this.elementPositioning = this.element.getStyle('position'); 424 433 425 434 this.originalStyle = {}; … … 431 440 this.originalLeft = this.element.offsetLeft; 432 441 433 var fontSize = Element.getStyle(this.element,'font-size') || '100%';434 ['em','px','%' ].each( function(fontSizeType) {442 var fontSize = this.element.getStyle('font-size') || '100%'; 443 ['em','px','%','pt'].each( function(fontSizeType) { 435 444 if(fontSize.indexOf(fontSizeType)>0) { 436 445 this.fontSize = parseFloat(fontSize); … … <
