Changeset 9974
- Timestamp:
- 11/18/08 21:29:29 (2 months ago)
- Files:
-
- branches/0.8/jaws/html/libraries/prototype/scriptaculous.js (deleted)
- branches/0.8/jaws/html/libraries/prototype/scriptaculous.src.js (modified) (168 diffs)
- branches/0.8/jaws/html/libraries/prototype/scriptaculous/builder.js (modified) (8 diffs)
- branches/0.8/jaws/html/libraries/prototype/scriptaculous/controls.js (modified) (32 diffs)
- branches/0.8/jaws/html/libraries/prototype/scriptaculous/dragdrop.js (modified) (62 diffs)
- branches/0.8/jaws/html/libraries/prototype/scriptaculous/effects.js (modified) (57 diffs)
- branches/0.8/jaws/html/libraries/prototype/scriptaculous/scriptaculous.js (modified) (3 diffs)
- branches/0.8/jaws/html/libraries/prototype/scriptaculous/slider.js (modified) (15 diffs)
- branches/0.8/jaws/html/libraries/prototype/scriptaculous/sound.js (modified) (3 diffs)
- branches/0.8/jaws/html/libraries/prototype/scriptaculous/unittest.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/0.8/jaws/html/libraries/prototype/scriptaculous.src.js
r9135 r9974 28 28 document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>'); 29 29 }, 30 REQUIRED_PROTOTYPE: '1.6.0. 2',30 REQUIRED_PROTOTYPE: '1.6.0.3', 31 31 load: function() { 32 32 function convertVersionString(versionString) { … … 83 83 node: function(elementName) { 84 84 elementName = elementName.toUpperCase(); 85 85 86 86 // try innerHTML approach 87 87 var parentTag = this.NODEMAP[elementName] || 'div'; … … 91 91 } catch(e) {} 92 92 var element = parentElement.firstChild || null; 93 93 94 94 // see if browser added wrapping tags 95 95 if(element && (element.tagName.toUpperCase() != elementName)) 96 96 element = element.getElementsByTagName(elementName)[0]; 97 97 98 98 // fallback to createElement approach 99 99 if(!element) element = document.createElement(elementName); 100 100 101 101 // abort if nothing could be created 102 102 if(!element) return; … … 119 119 if(!element) { 120 120 element = document.createElement(elementName); 121 for(attr in arguments[1]) 121 for(attr in arguments[1]) 122 122 element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; 123 123 } … … 125 125 element = parentElement.getElementsByTagName(elementName)[0]; 126 126 } 127 } 127 } 128 128 129 129 // text, or array of children … … 131 131 this._children(element, arguments[2]); 132 132 133 return element;133 return $(element); 134 134 }, 135 135 _text: function(text) { … … 174 174 return element.down(); 175 175 }, 176 dump: function(scope) { 177 if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope 178 176 dump: function(scope) { 177 if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope 178 179 179 var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " + 180 180 "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " + … … 183 183 "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+ 184 184 "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/); 185 186 tags.each( function(tag){ 187 scope[tag] = function() { 188 return Builder.node.apply(Builder, [tag].concat($A(arguments))); 185 186 tags.each( function(tag){ 187 scope[tag] = function() { 188 return Builder.node.apply(Builder, [tag].concat($A(arguments))); 189 189 }; 190 190 }); … … 204 204 // converts rgb() and #xxx to #xxxxxx format, 205 205 // returns self (or first argument) if not convertable 206 String.prototype.parseColor = function() { 206 String.prototype.parseColor = function() { 207 207 var color = '#'; 208 if (this.slice(0,4) == 'rgb(') { 209 var cols = this.slice(4,this.length-1).split(','); 210 var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); 211 } else { 212 if (this.slice(0,1) == '#') { 213 if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); 214 if (this.length==7) color = this.toLowerCase(); 215 } 216 } 217 return (color.length==7 ? color : (arguments[0] || this)); 208 if (this.slice(0,4) == 'rgb(') { 209 var cols = this.slice(4,this.length-1).split(','); 210 var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); 211 } else { 212 if (this.slice(0,1) == '#') { 213 if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); 214 if (this.length==7) color = this.toLowerCase(); 215 } 216 } 217 return (color.length==7 ? color : (arguments[0] || this)); 218 218 }; 219 219 220 220 /*--------------------------------------------------------------------------*/ 221 221 222 Element.collectTextNodes = function(element) { 222 Element.collectTextNodes = function(element) { 223 223 return $A($(element).childNodes).collect( function(node) { 224 return (node.nodeType==3 ? node.nodeValue : 224 return (node.nodeType==3 ? node.nodeValue : 225 225 (node.hasChildNodes() ? Element.collectTextNodes(node) : '')); 226 226 }).flatten().join(''); 227 227 }; 228 228 229 Element.collectTextNodesIgnoreClass = function(element, className) { 229 Element.collectTextNodesIgnoreClass = function(element, className) { 230 230 return $A($(element).childNodes).collect( function(node) { 231 return (node.nodeType==3 ? node.nodeValue : 232 ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? 231 return (node.nodeType==3 ? node.nodeValue : 232 ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? 233 233 Element.collectTextNodesIgnoreClass(node, className) : '')); 234 234 }).flatten().join(''); … … 236 236 237 237 Element.setContentZoom = function(element, percent) { 238 element = $(element); 239 element.setStyle({fontSize: (percent/100) + 'em'}); 238 element = $(element); 239 element.setStyle({fontSize: (percent/100) + 'em'}); 240 240 if (Prototype.Browser.WebKit) window.scrollBy(0,0); 241 241 return element; … … 277 277 return (-Math.cos(pos*Math.PI*(9*pos))/2) + .5; 278 278 }, 279 pulse: function(pos, pulses) { 279 pulse: function(pos, pulses) { 280 280 return (-Math.cos((pos*((pulses||5)-.5)*2)*Math.PI)/2) + .5; 281 281 }, 282 spring: function(pos) { 282 spring: function(pos) { 283 283 return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6)); 284 284 }, … … 302 302 var tagifyStyle = 'position:relative'; 303 303 if (Prototype.Browser.IE) tagifyStyle += ';zoom:1'; 304 304 305 305 element = $(element); 306 306 $A(element.childNodes).each( function(child) { … … 309 309 element.insertBefore( 310 310 new Element('span', {style: tagifyStyle}).update( 311 character == ' ' ? String.fromCharCode(160) : character), 311 character == ' ' ? String.fromCharCode(160) : character), 312 312 child); 313 313 }); … … 318 318 multiple: function(element, effect) { 319 319 var elements; 320 if (((typeof element == 'object') || 321 Object.isFunction(element)) && 320 if (((typeof element == 'object') || 321 Object.isFunction(element)) && 322 322 (element.length)) 323 323 elements = element; 324 324 else 325 325 elements = $(element).childNodes; 326 326 327 327 var options = Object.extend({ 328 328 speed: 0.1, … … 346 346 queue: { position:'end', scope:(element.id || 'global'), limit: 1 } 347 347 }, arguments[2] || { }); 348 Effect[element.visible() ? 348 Effect[element.visible() ? 349 349 Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); 350 350 } … … 358 358 initialize: function() { 359 359 this.effects = []; 360 this.interval = null; 360 this.interval = null; 361 361 }, 362 362 _each: function(iterator) { … … 365 365 add: function(effect) { 366 366 var timestamp = new Date().getTime(); 367 368 var position = Object.isString(effect.options.queue) ? 367 368 var position = Object.isString(effect.options.queue) ? 369 369 effect.options.queue : effect.options.queue.position; 370 370 371 371 switch(position) { 372 372 case 'front': 373 // move unstarted effects after this effect 373 // move unstarted effects after this effect 374 374 this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { 375 375 e.startOn += effect.finishOn; … … 385 385 break; 386 386 } 387 387 388 388 effect.startOn += timestamp; 389 389 effect.finishOn += timestamp; … … 391 391 if (!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit)) 392 392 this.effects.push(effect); 393 393 394 394 if (!this.interval) 395 395 this.interval = setInterval(this.loop.bind(this), 15); … … 404 404 loop: function() { 405 405 var timePos = new Date().getTime(); 406 for(var i=0, len=this.effects.length;i<len;i++) 406 for(var i=0, len=this.effects.length;i<len;i++) 407 407 this.effects[i] && this.effects[i].loop(timePos); 408 408 } … … 413 413 get: function(queueName) { 414 414 if (!Object.isString(queueName)) return queueName; 415 415 416 416 return this.instances.get(queueName) || 417 417 this.instances.set(queueName, new Effect.ScopedQueue()); … … 438 438 this.totalTime = this.finishOn-this.startOn; 439 439 this.totalFrames = this.options.fps*this.options.duration; 440 440 441 441 this.render = (function() { 442 442 function dispatch(effect, eventName) { … … 461 461 dispatch(this, 'afterUpdate'); 462 462 } 463 } 463 }; 464 464 })(); 465 465 466 466 this.event('beforeStart'); 467 467 if (!this.options.sync) 468 Effect.Queues.get(Object.isString(this.options.queue) ? 468 Effect.Queues.get(Object.isString(this.options.queue) ? 469 469 'global' : this.options.queue.scope).add(this); 470 470 }, … … 475 475 this.cancel(); 476 476 this.event('beforeFinish'); 477 if (this.finish) this.finish(); 477 if (this.finish) this.finish(); 478 478 this.event('afterFinish'); 479 return; 479 return; 480 480 } 481 481 var pos = (timePos - this.startOn) / this.totalTime, … … 489 489 cancel: function() { 490 490 if (!this.options.sync) 491 Effect.Queues.get(Object.isString(this.options.queue) ? 491 Effect.Queues.get(Object.isString(this.options.queue) ? 492 492 'global' : this.options.queue.scope).remove(this); 493 493 this.state = 'finished'; … … 527 527 initialize: function(object, from, to) { 528 528 object = Object.isString(object) ? $(object) : object; 529 var args = $A(arguments), method = args.last(), 529 var args = $A(arguments), method = args.last(), 530 530 options = args.length == 5 ? args[3] : null; 531 531 this.method = Object.isFunction(method) ? method.bind(object) : 532 Object.isFunction(object[method]) ? object[method].bind(object) : 532 Object.isFunction(object[method]) ? object[method].bind(object) : 533 533 function(value) { object[method] = value }; 534 534 this.start(Object.extend({ from: from, to: to }, options || { })); … … 594 594 // for backwards compatibility 595 595 Effect.MoveBy = function(element, toTop, toLeft) { 596 return new Effect.Move(element, 596 return new Effect.Move(element, 597 597 Object.extend({ x: toLeft, y: toTop }, arguments[3] || { })); 598 598 }; … … 616 616 this.restoreAfterFinish = this.options.restoreAfterFinish || false; 617 617 this.elementPositioning = this.element.getStyle('position'); 618 618 619 619 this.originalStyle = { }; 620 620 ['top','left','width','height','fontSize'].each( function(k) { 621 621 this.originalStyle[k] = this.element.style[k]; 622 622 }.bind(this)); 623 623 624 624 this.originalTop = this.element.offsetTop; 625 625 this.originalLeft = this.element.offsetLeft; 626 626 627 627 var fontSize = this.element.getStyle('font-size') || '100%'; 628 628 ['em','px','%','pt'].each( function(fontSizeType) { … … 632 632 } 633 633 }.bind(this)); 634 634 635 635 this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; 636 636 637 637 this.dims = null; 638 638 if (this.options.scaleMode=='box') … … 718 718 elementOffsets[1], 719 719 options, 720 function(p){ scrollTo(scrollOffsets.left, p.round()) }720 function(p){ scrollTo(scrollOffsets.left, p.round()); } 721 721 ); 722 722 }; … … 730 730 from: element.getOpacity() || 1.0, 731 731 to: 0.0, 732 afterFinishInternal: function(effect) { 732 afterFinishInternal: function(effect) { 733 733 if (effect.options.to!=0) return; 734 effect.element.hide().setStyle({opacity: oldOpacity}); 734 effect.element.hide().setStyle({opacity: oldOpacity}); 735 735 } 736 736 }, arguments[1] || { }); … … 748 748 }, 749 749 beforeSetup: function(effect) { 750 effect.element.setOpacity(effect.options.from).show(); 750 effect.element.setOpacity(effect.options.from).show(); 751 751 }}, arguments[1] || { }); 752 752 return new Effect.Opacity(element,options); … … 755 755 Effect.Puff = function(element) { 756 756 element = $(element); 757 var oldStyle = { 758 opacity: element.getInlineOpacity(), 757 var oldStyle = { 758 opacity: element.getInlineOpacity(), 759 759 position: element.getStyle('position'), 760 760 top: element.style.top, … … 764 764 }; 765 765 return new Effect.Parallel( 766 [ new Effect.Scale(element, 200, 767 { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), 768 new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], 769 Object.extend({ duration: 1.0, 766 [ new Effect.Scale(element, 200, 767 { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), 768 new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], 769 Object.extend({ duration: 1.0, 770 770 beforeSetupInternal: function(effect) { 771 Position.absolutize(effect.effects[0].element) 771 Position.absolutize(effect.effects[0].element); 772 772 }, 773 773 afterFinishInternal: function(effect) { … … 781 781 element.makeClipping(); 782 782 return new Effect.Scale(element, 0, 783 Object.extend({ scaleContent: false, 784 scaleX: false, 783 Object.extend({ scaleContent: false, 784 scaleX: false, 785 785 restoreAfterFinish: true, 786 786 afterFinishInternal: function(effect) { 787 787 effect.element.hide().undoClipping(); 788 } 788 } 789 789 }, arguments[1] || { }) 790 790 ); … … 794 794 element = $(element); 795 795 var elementDimensions = element.getDimensions(); 796 return new Effect.Scale(element, 100, Object.extend({ 797 scaleContent: false, 796 return new Effect.Scale(element, 100, Object.extend({ 797 scaleContent: false, 798 798 scaleX: false, 799 799 scaleFrom: 0, … … 801 801 restoreAfterFinish: true, 802 802 afterSetup: function(effect) { 803 effect.element.makeClipping().setStyle({height: '0px'}).show(); 804 }, 803 effect.element.makeClipping().setStyle({height: '0px'}).show(); 804 }, 805 805 afterFinishInternal: function(effect) { 806 806 effect.element.undoClipping(); … … 817 817 transition: Effect.Transitions.flicker, 818 818 afterFinishInternal: function(effect) { 819 new Effect.Scale(effect.element, 1, { 819 new Effect.Scale(effect.element, 1, { 820 820 duration: 0.3, scaleFromCenter: true, 821 821 scaleX: false, scaleContent: false, restoreAfterFinish: true, 822 beforeSetup: function(effect) { 822 beforeSetup: function(effect) { 823 823 effect.element.makePositioned().makeClipping(); 824 824 }, … … 826 826 effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity}); 827 827 } 828 }) 828 }); 829 829 } 830 830 }, arguments[1] || { })); … … 838 838 opacity: element.getInlineOpacity() }; 839 839 return new Effect.Parallel( 840 [ new Effect.Move(element, {x: 0, y: 100, sync: true }), 840 [ new Effect.Move(element, {x: 0, y: 100, sync: true }), 841 841 new Effect.Opacity(element, { sync: true, to: 0.0 }) ], 842 842 Object.extend( 843 843 { duration: 0.5, 844 844 beforeSetup: function(effect) { 845 effect.effects[0].element.makePositioned(); 845 effect.effects[0].element.makePositioned(); 846 846 }, 847 847 afterFinishInternal: function(effect) { 848 848 effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle); 849 } 849 } 850 850 }, arguments[1] || { })); 851 851 }; … … 875 875 { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) { 876 876 effect.element.undoPositioned().setStyle(oldStyle); 877 }}) }}) }}) }}) }})}});877 }}); }}); }}); }}); }}); }}); 878 878 }; 879 879 … … 883 883 var oldInnerBottom = element.down().getStyle('bottom'); 884 884 var elementDimensions = element.getDimensions(); 885 return new Effect.Scale(element, 100, Object.extend({ 886 scaleContent: false, 887 scaleX: false, 885 return new Effect.Scale(element, 100, Object.extend({ 886 scaleContent: false, 887 scaleX: false, 888 888 scaleFrom: window.opera ? 0 : 1, 889 889 scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, … … 893 893 effect.element.down().makePositioned(); 894 894 if (window.opera) effect.element.setStyle({top: ''}); 895 effect.element.makeClipping().setStyle({height: '0px'}).show(); 895 effect.element.makeClipping().setStyle({height: '0px'}).show(); 896 896 }, 897 897 afterUpdateInternal: function(effect) { 898 898 effect.element.down().setStyle({bottom: 899 (effect.dims[0] - effect.element.clientHeight) + 'px' }); 899 (effect.dims[0] - effect.element.clientHeight) + 'px' }); 900 900 }, 901 901 afterFinishInternal: function(effect) { … … 911 911 var elementDimensions = element.getDimensions(); 912 912 return new Effect.Scale(element, window.opera ? 0 : 1, 913 Object.extend({ scaleContent: false, 914 scaleX: false, 913 Object.extend({ scaleContent: false, 914 scaleX: false, 915 915 scaleMode: 'box', 916 916 scaleFrom: 100, … … 922 922 if (window.opera) effect.element.setStyle({top: ''}); 923 923 effect.element.makeClipping().show(); 924 }, 924 }, 925 925 afterUpdateInternal: function(effect) { 926 926 effect.element.down().setStyle({bottom: … … 935 935 }; 936 936 937 // Bug in opera makes the TD containing this element expand for a instance after finish 937 // Bug in opera makes the TD containing this element expand for a instance after finish 938 938 Effect.Squish = function(element) { 939 return new Effect.Scale(element, window.opera ? 1 : 0, { 939 return new Effect.Scale(element, window.opera ? 1 : 0, { 940 940 restoreAfterFinish: true, 941 941 beforeSetup: function(effect) { 942 effect.element.makeClipping(); 943 }, 942 effect.element.makeClipping(); 943 }, 944 944 afterFinishInternal: function(effect) { 945 effect.element.hide().undoClipping(); 945 effect.element.hide().undoClipping(); 946 946 } 947 947 }); … … 963 963 opacity: element.getInlineOpacity() }; 964 964 965 var dims = element.getDimensions(); 965 var dims = element.getDimensions(); 966 966 var initialMoveX, initialMoveY; 967 967 var moveX, moveY; 968 968 969 969 switch (options.direction) { 970 970 case 'top-left': 971 initialMoveX = initialMoveY = moveX = moveY = 0; 971 initialMoveX = initialMoveY = moveX = moveY = 0; 972 972 break; 973 973 case 'top-right': … … 994 994 break; 995 995 } 996 996 997 997 return new Effect.Move(element, { 998 998 x: initialMoveX, 999 999 y: initialMoveY, 1000 duration: 0.01, 1000 duration: 0.01, 1001 1001 beforeSetup: function(effect) { 1002 1002 effect.element.hide().makeClipping().makePositioned(); … … 1007 1007 new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }), 1008 1008 new Effect.Scale(effect.element, 100, { 1009 scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, 1009 scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, 1010 1010 sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) 1011 1011 ], Object.extend({ 1012 1012 beforeSetup: function(effect) { 1013 effect.effects[0].element.setStyle({height: '0px'}).show(); 1013 effect.effects[0].element.setStyle({height: '0px'}).show(); 1014 1014 }, 1015 1015 afterFinishInternal: function(effect) { 1016 effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); 1016 effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); 1017 1017 } 1018 1018 }, options) 1019 ) 1019 ); 1020 1020 } 1021 1021 }); … … 1039 1039 var dims = element.getDimensions(); 1040 1040 var moveX, moveY; 1041 1041 1042 1042 switch (options.direction) { 1043 1043 case 'top-left': … … 1056 1056 moveY = dims.height; 1057 1057 break; 1058 case 'center': 1058 case 'center': 1059 1059 moveX = dims.width / 2; 1060 1060 moveY = dims.height / 2; 1061 1061 break; 1062 1062 } 1063 1063 1064 1064 return new Effect.Parallel( 1065 1065 [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), 1066 1066 new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), 1067 1067 new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) 1068 ], Object.extend({ 1068 ], Object.extend({ 1069 1069 beforeStartInternal: function(effect) { 1070 effect.effects[0].element.makePositioned().makeClipping(); 1070 effect.effects[0].element.makePositioned().makeClipping(); 1071 1071 }, 1072 1072 afterFinishInternal: function(effect) { … … 1081 1081 oldOpacity = element.getInlineOpacity(), 1082 1082 transition = options.transition || Effect.Transitions.linear, 1083 reverser = function(pos){ 1083 reverser = function(pos){ 1084 1084 return 1 - transition((-Math.cos((pos*(options.pulses||5)*2)*Math.PI)/2) + .5); 1085 1085 }; 1086 1087 return new Effect.Opacity(element, 1086 1087 return new Effect.Opacity(element, 1088 1088 Object.extend(Object.extend({ duration: 2.0, from: 0, 1089 1089 afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); } … … 1099 1099 height: element.style.height }; 1100 1100 element.makeClipping(); 1101 return new Effect.Scale(element, 5, Object.extend({ 1101 return new Effect.Scale(element, 5, Object.extend({ 1102 1102 scaleContent: false, 1103 1103 scaleX: false, 1104 1104 afterFinishInternal: function(effect) { 1105 new Effect.Scale(element, 1, { 1106 scaleContent: false, 1105 new Effect.Scale(element, 1, { 1106 scaleContent: false, 1107 1107 scaleY: false, 1108 1108 afterFinishInternal: function(effect) { … … 1119 1119 style: { } 1120 1120 }, arguments[1] || { }); 1121 1121 1122 1122 if (!Object.isString(options.style)) this.style = $H(options.style); 1123 1123 else { … … 1142 1142 this.start(options); 1143 1143 }, 1144 1144 1145 1145 setup: function(){ 1146 1146 function parseColor(color){ … … 1148 1148 color = color.parseColor(); 1149 1149 return $R(0,2).map(function(i){ 1150 return parseInt( color.slice(i*2+1,i*2+3), 16 ) 1150 return parseInt( color.slice(i*2+1,i*2+3), 16 ); 1151 1151 }); 1152 1152 } … … 1168 1168 1169 1169 var originalValue = this.element.getStyle(property); 1170 return { 1171 style: property.camelize(), 1172 originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0), 1170 return { 1171 style: property.camelize(), 1172 originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0), 1173 1173 targetValue: unit=='color' ? parseColor(value) : value, 1174 1174 unit: unit … … 1181 1181 (isNaN(transform.originalValue) || isNaN(transform.targetValue)) 1182 1182 ) 1183 ) 1183 ); 1184 1184 }); 1185 1185 }, … … 1187 1187 var style = { }, transform, i = this.transforms.length; 1188 1188 while(i--) 1189 style[(transform = this.transforms[i]).style] = 1189 style[(transform = this.transforms[i]).style] = 1190 1190 transform.unit=='color' ? '#'+ 1191 1191 (Math.round(transform.originalValue[0]+ … … 1196 1196 (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() : 1197 1197 (transform.originalValue + 1198 (transform.targetValue - transform.originalValue) * position).toFixed(3) + 1198 (transform.targetValue - transform.originalValue) * position).toFixed(3) + 1199 1199 (transform.unit === null ? '' : transform.unit); 1200 1200 this.element.setStyle(style, true); … … 1233 1233 1234 1234 Element.CSS_PROPERTIES = $w( 1235 'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' + 1235 'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' + 1236 1236 'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' + 1237 1237 'borderRightColor borderRightStyle borderRightWidth borderSpacing ' + … … 1242 1242 'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' + 1243 1243 'right textIndent top width wordSpacing zIndex'); 1244 1244 1245 1245 Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; 1246 1246 … … 1254 1254 style = String.__parseStyleElement.childNodes[0].style; 1255 1255 } 1256 1256 1257 1257 Element.CSS_PROPERTIES.each(function(property){ 1258 if (style[property]) styleRules.set(property, style[property]); 1258 if (style[property]) styleRules.set(property, style[property]); 1259 1259 }); 1260 1260 1261 1261 if (Prototype.Browser.IE && this.include('opacity')) 1262 1262 styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]); … … 1307 1307 $w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+ 1308 1308 'pulsate shake puff squish switchOff dropOut').each( 1309 function(effect) { 1309 function(effect) { 1310 1310 Effect.Methods[effect] = function(element, options){ 1311 1311 element = $(element); 1312 1312 Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options); 1313 1313 return element; 1314 } 1314 }; 1315 1315 } 1316 1316 ); 1317 1317 1318 $w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each( 1318 $w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each( 1319 1319 function(f) { Effect.Methods[f] = Element[f]; } 1320 1320 ); … … 1357 1357 } 1358 1358 } 1359 1359 1360 1360 if(options.accept) options.accept = [options.accept].flatten(); 1361 1361 … … 1365 1365 this.drops.push(options); 1366 1366 }, 1367 1367 1368 1368 findDeepestChild: function(drops) { 1369 1369 deepest = drops[0]; 1370 1370 1371 1371 for (i = 1; i < drops.length; ++i) 1372 1372 if (Element.isParent(drops[i].element, deepest.element)) 1373 1373 deepest = drops[i]; 1374 1374 1375 1375 return deepest; 1376 1376 }, … … 1379 1379 var containmentNode; 1380 1380 if(drop.tree) { 1381 containmentNode = element.treeNode; 1381 containmentNode = element.treeNode; 1382 1382 } else { 1383 1383 containmentNode = element.parentNode; … … 1385 1385 return drop._containers.detect(function(c) { return containmentNode == c }); 1386 1386 }, 1387 1387 1388 1388 isAffected: function(point, element, drop) { 1389 1389 return ( … … 1392 1392 this.isContained(element, drop)) && 1393 1393 ((!drop.accept) || 1394 (Element.classNames(element).detect( 1394 (Element.classNames(element).detect( 1395 1395 function(v) { return drop.accept.include(v) } ) )) && 1396 1396 Position.within(drop.element, point[0], point[1]) ); … … 1412 1412 if(!this.drops.length) return; 1413 1413 var drop, affected = []; 1414 1414 1415 1415 this.drops.each( function(drop) { 1416 1416 if(Droppables.isAffected(point, element, drop)) 1417 1417 affected.push(drop); 1418 1418 }); 1419 1419 1420 1420 if(affected.length>0) 1421 1421 drop = Droppables.findDeepestChild(affected); … … 1426 1426 if(drop.onHover) 1427 1427 drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); 1428 1428 1429 1429 if (drop != this.last_active) Droppables.activate(drop); 1430 1430 } … … 1437 1437 if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active)) 1438 1438 if (this.last_active.onDrop) { 1439 this.last_active.onDrop(element, this.last_active.element, event); 1440 return true; 1439 this.last_active.onDrop(element, this.last_active.element, event); 1440 return true; 1441 1441 } 1442 1442 }, … … 1451 1451 drags: [], 1452 1452 observers: [], 1453 1453 1454 1454 register: function(draggable) { 1455 1455 if(this.drags.length == 0) { … … 1457 1457 this.eventMouseMove = this.updateDrag.bindAsEventListener(this); 1458 1458 this.eventKeypress = this.keyPress.bindAsEventListener(this); 1459 1459 1460 1460 Event.observe(document, "mouseup", this.eventMouseUp); 1461 1461 Event.observe(document, "mousemove", this.eventMouseMove); … … 1464 1464 this.drags.push(draggable); 1465 1465 }, 1466 1466 1467 1467 unregister: function(draggable) { 1468 1468 this.drags = this.drags.reject(function(d) { return d==draggable }); … … 1473 1473 } 1474 1474 }, 1475 1475 1476 1476 activate: function(draggable) { 1477 if(draggable.options.delay) { 1478 this._timeout = setTimeout(function() { 1479 Draggables._timeout = null; 1480 window.focus(); 1481 Draggables.activeDraggable = draggable; 1482 }.bind(this), draggable.options.delay); 1477 if(draggable.options.delay) { 1478 this._timeout = setTimeout(function() { 1479 Draggables._timeout = null; 1480 window.focus(); 1481 Draggables.activeDraggable = draggable; 1482 }.bind(this), draggable.options.delay); 1483 1483 } else { 1484 1484 window.focus(); // allows keypress events if window isn't currently focused, fails for Safari … … 1486 1486 } 1487 1487 }, 1488 1488 1489 1489 deactivate: function() { 1490 1490 this.activeDraggable = null; 1491 1491 }, 1492 1492 1493 1493 updateDrag: function(event) { 1494 1494 if(!this.activeDraggable) return; … … 1498 1498 if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; 1499 1499 this._lastPointer = pointer; 1500 1500 1501 1501 this.activeDraggable.updateDrag(event, pointer); 1502 1502 }, 1503 1503 1504 1504 endDrag: function(event) { 1505 if(this._timeout) { 1506 clearTimeout(this._timeout); 1507 this._timeout = null; 1505 if(this._timeout) { 1506 clearTimeout(this._timeout); 1507 this._timeout = null; 1508 1508 } 1509 1509 if(!this.activeDraggable) return; … … 1512 1512 this.activeDraggable = null; 1513 1513 }, 1514 1514 1515 1515 keyPress: function(event) { 1516 1516 if(this.activeDraggable) 1517 1517 this.activeDraggable.keyPress(event); 1518 1518 }, 1519 1519 1520 1520 addObserver: function(observer) { 1521 1521 this.observers.push(observer); 1522 1522 this._cacheObserverCallbacks(); 1523 1523 }, 1524 1524 1525 1525 removeObserver: function(element) { // element instead of observer fixes mem leaks 1526 1526 this.observers = this.observers.reject( function(o) { return o.element==element }); 1527 1527 this._cacheObserverCallbacks(); 1528 1528 }, 1529 1529 1530 1530 notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag' 1531 1531 if(this[eventName+'Count'] > 0) … … 1535 1535 if(draggable.options[eventName]) draggable.options[eventName](draggable, event); 1536 1536 }, 1537 1537 1538 1538 _cacheObserverCallbacks: function() { 1539 1539 ['onStart','onEnd','onDrag'].each( function(eventName) { … … 1559 1559 endeffect: function(element) { 1560 1560 var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0; 1561 new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, 1561 new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, 1562 1562 queue: {scope:'_draggable', position:'end'}, 1563 afterFinish: function(){ 1564 Draggable._dragging[element] = false 1563 afterFinish: function(){ 1564 Draggable._dragging[element] = false 1565 1565 } 1566 }); 1566 }); 1567 1567 }, 1568 1568 zindex: 1000, … … 1575 1575 delay: 0 1576 1576 }; 1577 1577 1578 1578 if(!arguments[1] || Object.isUndefined(arguments[1].endeffect)) 1579 1579 Object.extend(defaults, { … … 1581 1581 element._opacity = Element.getOpacity(element); 1582 1582 Draggable._dragging[element] = true; 1583 new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7}); 1583 new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7}); 1584 1584 } 1585 1585 }); 1586 1586 1587 1587 var options = Object.extend(defaults, arguments[1] || { }); 1588 1588 1589 1589 this.element = $(element); 1590 1590 1591 1591 if(options.handle && Object.isString(options.handle)) 1592 1592 this.handle = this.element.down('.'+options.handle, 0); 1593 1593 1594 1594 if(!this.handle) this.handle = $(options.handle); 1595 1595 if(!this.handle) this.handle = this.element; 1596 1596 1597 1597 if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { 1598 1598 options.scroll = $(options.scroll); … … 1600 1600 } 1601 1601 1602 Element.makePositioned(this.element); // fix IE 1602 Element.makePositioned(this.element); // fix IE 1603 1603 1604 1604 this.options = options; 1605 this.dragging = false; 1605 this.dragging = false; 1606 1606 1607 1607 this.eventMouseDown = this.initDrag.bindAsEventListener(this); 1608 1608 Event.observe(this.handle, "mousedown", this.eventMouseDown); 1609 1609 1610 1610 Draggables.register(this); 1611 1611 }, 1612 1612 1613 1613 destroy: function() { 1614 1614 Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); 1615 1615 Draggables.unregister(this); 1616 1616 }, 1617 1617 1618 1618 currentDelta: function() { 1619 1619 return([ … … 1621 1621 parseInt(Element.getStyle(this.element,'top') || '0')]); 1622 1622 }, 1623 1623 1624 1624 initDrag: function(event) { 1625 1625 if(!Object.isUndefined(Draggable._dragging[this.element]) && 1626 1626 Draggable._dragging[this.element]) return; 1627 if(Event.isLeftClick(event)) { 1627 if(Event.isLeftClick(event)) { 1628 1628 // abort on form elements, fixes a Firefox issue 1629 1629 var src = Event.element(event); … … 1634 1634 tag_name=='BUTTON' || 1635 1635 tag_name=='TEXTAREA')) return; 1636
