1// SpryFadingPanels.js - version 0.5 - Spry Pre-Release 1.7 2// 3// Copyright (c) 2010. Adobe Systems Incorporated. 4// All rights reserved. 5// 6// Redistribution and use in source and binary forms, with or without 7// modification, are permitted provided that the following conditions are met: 8// 9// * Redistributions of source code must retain the above copyright notice, 10// this list of conditions and the following disclaimer. 11// * Redistributions in binary form must reproduce the above copyright notice, 12// this list of conditions and the following disclaimer in the documentation 13// and/or other materials provided with the distribution. 14// * Neither the name of Adobe Systems Incorporated nor the names of its 15// contributors may be used to endorse or promote products derived from this 16// software without specific prior written permission. 17// 18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28// POSSIBILITY OF SUCH DAMAGE. 29 30(function() { // BeginSpryComponent 31 32if (typeof Spry == "undefined" || !Spry.Widget || !Spry.Widget.PanelSet) 33{ 34 alert("SpryFadingPanels.js requires SpryPanelSet.js!"); 35 return; 36} 37 38Spry.Widget.FadingPanels = function(elements, opts) 39{ 40 // Override any of the global defaults with options passed into 41 // the constructor. 42 43 var mergedOpts = this.setOptions(this.setOptions({}, Spry.Widget.FadingPanels.config), opts); 44 45 Spry.Widget.PanelSet.call(this, Spry.$$(elements), mergedOpts); 46}; 47 48Spry.Widget.FadingPanels.prototype = new Spry.Widget.PanelSet(); 49Spry.Widget.FadingPanels.prototype.constructor = Spry.Widget.FadingPanels; 50 51Spry.Widget.FadingPanels.config = { 52 defaultPanel: 0, 53 minOpacity: 0, 54 maxOpacity: 1, 55 minDuration: 500, // msecs 56 maxDuration: 500, // msecs 57 stoppedMinDuration: 200, // msecs 58 stoppedMaxDuration: 200, // msecs 59 60 visibleClass: "FadingPanelVisible", 61 hiddenClass: "FadingPanelHidden", 62 63 autoPlay: false, 64 displayInterval: 4000, // msecs 65 parallelTransition:true 66}; 67 68Spry.Widget.FadingPanels.prototype.initialize = function() 69{ 70 var evt = new Spry.Widget.Event(this); 71 this.notifyObservers("onPreInitialize", evt); 72 if (!evt.performDefaultAction) 73 return; 74 75 this.disableNotifications(); 76 77 Spry.Widget.PanelSet.prototype.initialize.call(this); 78 79 var panels = this.getPanels(); 80 var cpanel = this.currentPanel; 81 82 for (var i = 0; i < panels.length; i++) 83 { 84 var p = panels[i]; 85 this.setOpacity(p, (p == cpanel) ? this.maxOpacity : this.minOpacity); 86 } 87 88 this.enableNotifications(); 89 90 this.notifyObservers("onPostInitialize", evt); 91}; 92 93Spry.Widget.FadingPanels.prototype.showPanel = function(eleOrIndex) 94{ 95 var ele = this.indexToElement(eleOrIndex); 96 if (ele && ele != this.currentPanel) 97 { 98 var evt = this.createEvent(ele, { currentPanel: this.currentPanel }); 99 this.notifyObservers("onPreShowPanel", evt); 100 if (!evt.performDefaultAction) 101 return; 102 103 if (this.showEffect && !this.parallelTransition) { 104 this.showEffect.stop(); 105 } 106 107 if (this.hideEffect && !this.parallelTransition) { 108 this.hideEffect.stop(); 109 } 110 111 var currentPanel = this.currentPanel; 112 this.currentPanel = ele; 113 114 var self = this; 115 var showPanelComplete = function() { 116 self.currentPanel = ele; 117 self.addClassName(ele, self.visibleClass); 118 self.removeClassName(ele, self.hiddenClass); 119 120 self.notifyObservers("onPreShowPanelEffect", evt); 121 self.showEffect = new Spry.Effect.CSSAnimator(ele, "opacity: " + self.maxOpacity, { duration: self.isPlaying()?self.maxDuration:self.stoppedMaxDuration }); 122 self.showEffect.addObserver({ 123 onAnimationComplete: function() { 124 self.showEffect = null; 125 self.notifyObservers("onPostShowPanelEffect", evt); 126 } 127 }); 128 self.showEffect.start(); 129 130 self.notifyObservers("onPostShowPanel", evt); 131 }; 132 133 if (currentPanel) 134 this.hidePanel(currentPanel, showPanelComplete); 135 else 136 showPanelComplete(); 137 138 } 139}; 140 141Spry.Widget.FadingPanels.prototype.hidePanel = function(eleOrIndex, callback) 142{ 143 var ele = this.indexToElement(eleOrIndex); 144 if (ele) { 145 var evt = this.createEvent(ele); 146 this.notifyObservers("onPreHidePanel", evt); 147 if (!evt.performDefaultAction) 148 return; 149 150 this.currentPanel = null; 151 152 var self = this; 153 var hidePanelComplete = function() { 154 self.addClassName(ele, self.hiddenClass); 155 self.removeClassName(ele, self.visibleClass); 156 self.notifyObservers("onPostHidePanel", evt); 157 158 if(callback) { 159 callback(); 160 } 161 }; 162 163 this.notifyObservers("onPreHidePanelEffect", evt); 164 this.hideEffect = new Spry.Effect.CSSAnimator(ele, "opacity: " + this.minOpacity, { duration: this.isPlaying()?this.minDuration:this.stoppedMinDuration }); 165 this.hideEffect.addObserver({ 166 onAnimationComplete: function() { 167 self.hideEffect = null; 168 self.notifyObservers("onPostHidePanelEffect", evt); 169 if (!self.parallelTransition) { 170 hidePanelComplete(); 171 } 172 } 173 }) 174 this.hideEffect.start(); 175 176 if (this.parallelTransition) { 177 hidePanelComplete(); 178 } 179 } 180}; 181 182})(); // EndSpryComponent
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.