From ee8668e0623bfa4edd6544efadcaeb05ebc929ab Mon Sep 17 00:00:00 2001 From: GarrettS Date: Sat, 25 Jul 2009 10:43:32 -0700 Subject: [PATCH] Deleted Carousel only - carousel is replaced by Scroller. --- .project | 17 +++ build/timing/Lock-a-min.js | 1 + build/widget/HSVPicker/HSVPicker-min.js | 1 + build/widget/Panel-min.js | 1 + build/widget/Placeholder-min.js | 1 + build/widget/TableAccordian-min.js | 1 + build/widget/calendar/Calendar-min.js | 1 + build/widget/calendar/Calendar_en-min.js | 1 + build/widget/carousel/Carousel-min.js | 1 + build/widget/scroller/Scroller-min.js | 1 + src/widget/carousel/Carousel.js | 144 ----------------------- 11 files changed, 26 insertions(+), 144 deletions(-) create mode 100644 .project create mode 100644 build/timing/Lock-a-min.js create mode 100644 build/widget/HSVPicker/HSVPicker-min.js create mode 100644 build/widget/Panel-min.js create mode 100644 build/widget/Placeholder-min.js create mode 100644 build/widget/TableAccordian-min.js create mode 100644 build/widget/calendar/Calendar-min.js create mode 100644 build/widget/calendar/Calendar_en-min.js create mode 100644 build/widget/carousel/Carousel-min.js create mode 100644 build/widget/scroller/Scroller-min.js delete mode 100644 src/widget/carousel/Carousel.js diff --git a/.project b/.project new file mode 100644 index 0000000..f45a0d5 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + release + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/build/timing/Lock-a-min.js b/build/timing/Lock-a-min.js new file mode 100644 index 0000000..edb07ae --- /dev/null +++ b/build/timing/Lock-a-min.js @@ -0,0 +1 @@ +APE.Lock={getLock:function(){if(this.__ape_lock_has_lock){return false}return this.__ape_lock_has_lock=true},releaseLock:function(){this.__ape_lock_has_lock=false},isLocked:function(){return(true===this.__ape_lock_has_lock)}}; \ No newline at end of file diff --git a/build/widget/HSVPicker/HSVPicker-min.js b/build/widget/HSVPicker/HSVPicker-min.js new file mode 100644 index 0000000..67bf62e --- /dev/null +++ b/build/widget/HSVPicker/HSVPicker-min.js @@ -0,0 +1 @@ +APE.namespace("APE.widget");APE.widget.HsvPicker=function(E){var A=APE.drag.Draggable;this.id=E;var D=document.getElementById(this.id+"-hue-slider");var B=document.getElementById(this.id+"-saturation-value-selector");this.hueSlider=A.getByNode(D,APE.drag.Draggable.constraints.VERT);this.hueSlider.keepInContainer=true;this.bgSelector=A.getByNode(B);var C=B.parentNode.parentNode;C.onselectstart=function(){return false};this.bg=C;this.bgSelector.container=C;this.bgSelector.keepInContainer=true;this.textInput=document.getElementById(this.id+"-color-input");this.displayStyle=document.getElementById(this.id+"-color-preview").style;this.bgClipTop=12/2;this.bgClipLeft=12/2;this.enabled=true;this.prevValue=this.textInput.value};APE.widget.HsvPicker.getById=APE.getById;(function(){var B=APE.widget.HsvPicker;APE.mixin(B,{hueSlid:C,grabHueSlider:D,bgSelectorDrag:F,textInputBlur:J,checkEnabled:G,textInputKeyDown:I,backgroundMousedown:H,saveValue:A,transparentClicked:E});function C(L){var K=B.getById(this.id.split("-")[0]);if(!K.enabled){return}K.onbeforechange();K.h=360*K.hueSlider.el.offsetTop/128;K.bg.style.background=K.rgbForHue(K.h);K.updateDisplay();K.onchange(L)}function D(L){var K=B.getById(this.id.split("-")[0]);if(!K.enabled){return}K.hueSlider.grab(L);K.updateDisplay();K.onchange(L);K.onchangecomplete(L)}function J(L){var K=B.getById(this.id.split("-")[0]);if(!K.enabled){return}return K.trySetValue(this.value,L||event)}function G(){return B.getById(this.id.split("-")[0]).enabled}function I(M){M=M||window.event;var L=M.keyCode==9;var K=M.keyCode==13;if(L||K){B.getById(this.id.split("-")[0]).trySetValue(this.value,M||event)}if(K){this.focus()}}function H(L){var K=B.getById(this.id.split("-")[0]);if(!K.enabled){return}K.onbeforechange();K.bgSelector.grab(L);K.bg.style.background=K.rgbForHue(K.h);K.updateDisplay();K.onchange(L);K.onchangecomplete(L)}function F(L){var K=B.getById(this.id.split("-")[0]);if(!K.enabled){return}K.v=(127-(this.el.offsetTop+K.bgClipTop))/127;K.s=(this.el.offsetLeft+K.bgClipLeft)/127;K.updateDisplay();K.onchange(L)}function A(){if(this.textInput.value){this.prevValue=this.textInput.value}}function E(L){var K=B.getById(this.id.split("-")[0]);K.onbeforechange();if(this.checked){K.prevValue=K.textInput.value;K.setEnabled(false);K.setValue("transparent")}else{K.setValue(K.prevValue||new APE.color.ColorRGB(255,255,255).toString());K.prevValue="";K.setEnabled(true);K.hueSlider.ondrag(L);K.bgSelector.ondrag(L)}K.onchange(L);K.onchangecomplete(L)}})();APE.widget.HsvPicker.prototype={rgbForHue:APE.color.ColorHSV.rgbForHue,rgbFromString:APE.color.ColorRGB.fromString,init:function(){if(this.textInput.value){this.setValue(this.textInput.value)}else{this.setValue("#ff0000")}var A=APE.widget.HsvPicker;this.bgSelector.onbeforedragstart=A.bgSelectorDrag;this.bgSelector.ondrag=A.bgSelectorDrag;this.bgSelector.onglide=A.bgSelectorDrag;this.hueSlider.onbeforedragstart=A.hueSlid;this.hueSlider.ondrag=A.hueSlid;this.hueSlider.onglide=A.hueSlid;this.hueSlider.container.onmousedown=A.grabHueSlider;this.bgSelector.onglide=A.bgSelectorDrag;this.bgSelector.onfocus=A.checkEnabled;this.hueSlider.onfocus=A.checkEnabled;var C=APE.EventPublisher;C.add(this.textInput,"onblur",A.textInputBlur);C.add(this,"onbeforechange",A.saveValue);C.add(this.bgSelector.el.parentNode,"onmousedown",A.backgroundMousedown);C.add(this.bgSelector,"ondragend",function(D){this.onchangecomplete(D)},this);C.add(this.hueSlider,"ondragend",function(D){this.onchangecomplete(D)},this);var B=document.getElementById(this.id+"-transparent-checkbox");C.add(B,"onclick",A.transparentClicked);if(B.checked){A.transparentClicked.call(document.getElementById(this.id+"-transparent-checkbox"))}},getHexValue:function(){if(this.textInput.value==""){return""}return new APE.color.ColorHSV(this.h,this.s,this.v).toRGB().toHexString()},onbeforechange:function(){},onchange:function(A){},onchangecomplete:function(A){},setEnabled:function(A){this.enabled=A},setValue:function(D){if(D=="transparent"){this.displayStyle.background="transparent";this.hueSlider.el.parentNode.style.background="transparent";this.bgSelector.el.parentNode.style.visibility="hidden";this.bgSelector.el.parentNode.previousSibling.style.visibility="inherit";this.setEnabled(false);this.bg.style.backgroundColor="transparent";this.textInput.value="";document.getElementById(this.id+"-transparent-checkbox").checked=true;return}else{this.displayStyle.background="transparent";this.bgSelector.el.parentNode.style.visibility="inherit";this.bgSelector.el.parentNode.previousSibling.style.visibility="hidden";this.setEnabled(true);document.getElementById(this.id+"-transparent-checkbox").checked=false}var B=this.rgbFromString(D);var C=B.isValid();if(!C){B=this.rgbForHue(this.h=0,this.s=1,this.v=1)}var A=B.toHSV();this.h=A.h;this.s=A.s;this.v=A.v;this.hueSlider.el.style.top=(A.h/360*128)+"px";this.bgSelector.moveToX((A.s*127)-this.bgClipLeft);this.bgSelector.moveToY(127-(A.v*127)-this.bgClipTop);this.bg.style.backgroundColor=this.rgbForHue(A.h,1,1).toHexString();this.updateDisplay(B,C)},updateDisplay:function(B,C){var A=B||new APE.color.ColorHSV(this.h,this.s,this.v).toRGB();if(A.isValid()&&!(C==false)){this.displayStyle.backgroundColor=this.textInput.value=A.toHexString()}else{this.textInput.value=""}},trySetValue:function(A,B){if(this.rgbFromString(A).isValid()){this.setValue(A);this.onchange(B);this.onchangecomplete(B);return true}else{alert("Please enter a valid color value.");return false}}}; \ No newline at end of file diff --git a/build/widget/Panel-min.js b/build/widget/Panel-min.js new file mode 100644 index 0000000..d2d36af --- /dev/null +++ b/build/widget/Panel-min.js @@ -0,0 +1 @@ +APE.namespace("APE.widget");APE.widget.Panel=function(A){this.id=A};APE.widget.Panel.activeId="";APE.widget.Panel.prototype={show:function(){APE.widget.Panel.activeId=this.id;document.getElementById(this.id).style.display="block";var A=this.id.replace(/Panel$/,"Actuator"),B=document.getElementById(A);if(B){APE.dom.addClass(B,"actuatorActive")}},hide:function(){document.getElementById(this.id).style.display="none";APE.widget.Panel.activeId="";var A=this.id.replace(/Panel$/,"Actuator"),B=document.getElementById(A);if(typeof this.onhide=="function"){this.onhide()}if(B){APE.dom.removeClass(B,"actuatorActive")}}};APE.widget.Panel.getById=APE.getById;(function(){var E=APE.dom,B=document.body;E.Event.addCallback(B,"click",F);E.Event.addCallback(B,"mousedown",D);B=null;var A={};function F(I){var H=E.Event.getTarget(I),M=H.id,J=document,L,G=APE.widget.Panel,K=/Actuator$/;if(!M||!K.test(M)){return}M=M.replace(K,"Panel");I=I||event;if(I.preventDefault){I.preventDefault()}else{I.returnValue=false}D();L=J.getElementById(M);if(!(M in A)){A[M]=M;E.Event.addCallback(L,"mousedown",C)}G.getById(M).show()}function D(){var G=APE.widget.Panel;if(!G.activeId){return}G.getById(G.activeId).hide()}function C(H){H=H||window.event;if(H.stopPropagation){H.stopPropagation()}H.cancelBubble=true;var I=APE.dom,G=I.Event.getTarget(H);if(I.hasToken(G.className,"panelClose")){APE.widget.Panel.getById(this.id).hide()}}})(); \ No newline at end of file diff --git a/build/widget/Placeholder-min.js b/build/widget/Placeholder-min.js new file mode 100644 index 0000000..3ffbc46 --- /dev/null +++ b/build/widget/Placeholder-min.js @@ -0,0 +1 @@ +(function(){APE.namespace("APE.widget");APE.widget.Placeholder=C;C.getById=APE.getById;function C(G){this.id=G;this.labelId=G+"Label";var F=document.getElementById(this.labelId);this.placeholderText=F&&F.firstChild.data||"";this.init()}C.prototype={init:function(){var F=document.getElementById(this.id),G=APE.dom.Event.addCallback;G(F,"focus",D);G(F,"blur",E);G(F,"keydown",A);G(F,"keyup",B);G(F,"mouseup",B)},reset:function(){var F=document.getElementById(this.id);if(!F){return}F.value=F.defaultValue=this.placeholderText;APE.dom.addClass(F.form,"defaultState");this.onreset(true)},isEmpty:function(){var F=document.getElementById(this.id),H=/^\s+|\s+$/g,G=F.value.replace(H,""),I=this.placeholderText;return G===""||(!!I&&G===I.replace(H,""))},onreset:function(F){}};function E(){var G=APE.dom,F=C.getById(this.id);G.removeClass(this,"focus");if(F.isEmpty()){G.addClass(this.form,"defaultState");this.value=F.placeholderText}else{G.removeClass(this.form,"defaultState")}}function D(){var F=C.getById(this.id);APE.dom.addClass(this,"focus");if(this.value===F.placeholderText){this.value=""}}function A(G){G=G||event;if(G.keyCode===27){this.value=this.defaultValue;try{this.blur()}catch(F){}C.getById(this.id).onreset(false)}}function B(){var G=APE.dom,F=C.getById(this.id);if(F.isEmpty()){G.addClass(this.form,"defaultState")}else{G.removeClass(this.form,"defaultState")}}})(); \ No newline at end of file diff --git a/build/widget/TableAccordian-min.js b/build/widget/TableAccordian-min.js new file mode 100644 index 0000000..8e7ec52 --- /dev/null +++ b/build/widget/TableAccordian-min.js @@ -0,0 +1 @@ +function TableAccordian(B,A){this.id=B;this.duration=(A||300)/1000;this.rows=[];this.sheet=new APE.dom.StyleSheetAdapter(this.id+"Sheet")}TableAccordian.getById=APE.getById;TableAccordian.prototype={getRow:function(A){var B,C=this.rows[A];if(!C){B=document.getElementById(this.id);C=TableAccordian.Row.getByNode(B.rows[A],this);this.rows[A]=C}return C},toggleRow:function(A){this.getRow(A).toggle()},openRow:function(A){this.getRow(A).open()},closeRow:function(A){this.getRow(A).close()}};TableAccordian.Row=function(D,A){APE.anim.Animation.call(this,A.duration);this.transition=APE.anim.Transitions.accel;this.id=D.id;var B="#"+A.id+" #"+D.id+" .tableAccordian";var C=A.sheet.getRule(B);if(!C){C=A.sheet.addRule(B)}this.style=C.style;this.isExpanded=D.offsetHeight!=0;this.maxHeight=this.getRowHeight(D);this.isReversed=this.isExpanded;C.style.height="0";D.style.display=""};TableAccordian.Row.name="TableAccordianRow";TableAccordian.Row.getByNode=APE.getByNode;APE.extend(TableAccordian.Row,APE.anim.Animation,{run:function(A){var B=1-A;if("opacity" in this.style){this.style.opacity=String(B)}else{this.style.filter="alpha(opacity="+(0|B*100)+")"}this.style.height=B*this.maxHeight+"px"},onstart:function(){this.isExpanded=!this.isExpanded},toggle:function(){if(this.isExpanded){this.seekTo(1)}else{this.seekTo(0)}},open:function(){if(this.isExpanded){this.seekTo(0)}},close:function(){if(this.isExpanded){this.seekTo(1)}},getRowHeight:function(){var K=document.getElementById(this.id),J=K.cells[0],C=J.style,H=K.style,B=K.parentNode.style,A=C.cssText,D=H.cssText,I=B.cssText,G=J.currentStyle?"display: block;":"",E;C.cssText=G+"display: table-cell";H.cssText=G+"display: table-row;";B.cssText=G+"display: table-row-group";C.height=H.height=B.height="auto";E=J.clientHeight;C.height=E+"px";var F=J.clientHeight-E;C.cssText=A;H.cssText=D;B.cssText=I;return E-F}}); \ No newline at end of file diff --git a/build/widget/calendar/Calendar-min.js b/build/widget/calendar/Calendar-min.js new file mode 100644 index 0000000..b0e5ecc --- /dev/null +++ b/build/widget/calendar/Calendar-min.js @@ -0,0 +1 @@ +APE.namespace("APE.widget");APE.widget.Calendar=function(B){this.id=(typeof B=="string"?B:B.id);var A=document.getElementById(this.id);this.displayDate=new Date(A.value);if(isNaN(this.displayDate.valueOf())){this.displayDate=new Date}this.initEvents()};APE.widget.Calendar.getByNode=APE.getByNode;APE.widget.Calendar.getById=APE.getById;APE.widget.Calendar.focusHandler=function(A){APE.widget.Calendar.getById(this.id)._show(A)};APE.widget.Calendar.documentMouseDownHandler=function(C){var E=APE.dom,B=E.Event.getTarget(C),D=APE.widget.Calendar,F=D.activeCalendar,A;if(F){A=document.getElementById(F.calendarId);if(!A){D.activeCalendar=null;return}if(E.contains(A,B)||B===A){return}F._hasFocus=false;F._hide(C)}};APE.widget.Calendar.blurHandler=function(C){var B=APE.widget.Calendar.getByNode(this);B.hideTimer=setTimeout(function A(){B._hide(C||event)},10)};APE.widget.Calendar.mousedownHandler=function(D){D=D||event;var B=APE.dom,E=B.Event.getTarget(D),H,I,G;if(E.className=="ape-calendar"){H=E}else{H=B.findAncestorWithClass(E,"ape-calendar")}I=APE.widget.Calendar.getById(H.id.replace(/-calendar$/,""));G=I.id;I._hasFocus=true;clearTimeout(I.hideTimer);selectedId=G+"-selected-day";if(E.tagName.toLowerCase()=="b"){if(E.id===selectedId){return}var A=parseInt(E.firstChild.data);if(!A){return}var C=document.getElementById(selectedId);if(C){B.removeClass(C,"ape-calendar-selected-day");C.id=""}E.id=selectedId;B.addClass(E,"ape-calendar-selected-day");I.setDateOfMonth(A);I.onselect();if(I.hideOnSelect){setTimeout(function(){I._hide(D);I._hasFocus=false;I=null},115)}}else{var F=new Date(I.displayDate);if(E.id===G+"-next-year"){F.setYear(F.getFullYear()+1);I.setDate(F)}else{if(E.id===G+"-prev-year"){F.setYear(F.getFullYear()-1);I.setDate(F)}else{if(E.id===G+"-next-month"){F.setMonth(F.getMonth()+1);I.setDate(F)}else{if(E.id===G+"-prev-month"){F.setMonth(F.getMonth()-1);I.setDate(F)}}}}}};APE.widget.Calendar.prototype={days:[31,28,31,30,31,30,31,31,30,31,30,31],hideOnSelect:true,initEvents:function(){var D=document,A=D.getElementById(this.id),C=APE.widget.Calendar,B=APE.EventPublisher;B.add(A,"onfocus",C.focusHandler);B.add(A,"onblur",C.blurHandler);B.add(A,"onclick",C.focusHandler);B.add(D,"onmousedown",C.documentMouseDownHandler)},id:"",calendarId:"",hiddenDayClass:"ape-calendar-empty-day",calendarClass:"ape-calendar",_isHidden:undefined,_show:function(C){if(!this.calendarId){this.create()}var B=document.getElementById(this.calendarId),D=B.style,A=this.constructor.activeCalendar;this._isHidden=false;if(A){if(A===this){return}else{A._hide()}}this.position(D);this.constructor.activeCalendar=this;this.show(D);this.onshow(C);this.setDate(this.displayDate)},position:function(C){var A=document.getElementById(this.id),B=APE.dom.getOffsetCoords(A);C.left=B.x+"px";C.top=B.y+A.offsetHeight+"px"},show:function(A){A.visibility="visible"},_hide:function(A){if(this._isHidden){return}if(this._hasFocus){return}this.onhide(A);if(this.constructor.activeCalendar===this){this.constructor.activeCalendar=null}this.hide(document.getElementById(this.calendarId).style);this._isHidden=true},hide:function(A){A.visibility="hidden"},onshow:function(){},onhide:function(){},onselect:function(){},create:function(){if(this.calendarId){return}this.calendarId=this.id+"-calendar";var J=document;if(J.getElementById(this.calendarId)){return}var F=J.createElement("div"),C=Array.prototype.join,D=C.call({length:7+1}," "),H=C.call({length:6+1},""+D+"\n"),G=APE.widget,A=G.CalendarLocale,B=A.days.abbr,E=""+H+"",I="«‹
 
›»"+B.join("")+"";F.onselectstart=this.returnFalse;F.innerHTML=""+I+E+"
";F.id=this.calendarId;F.className=this.calendarClass;F.onmousedown=F.onfocus=G.Calendar.mousedownHandler;J.body.appendChild(F)},returnFalse:function(A){return false},setDateOfMonth:function(A){this.displayDate.setDate(A);var B=this.formatDate();document.getElementById(this.id).value=B},getDate:function(){return new Date(this.displayDate)},formatDate:function(){return APE.widget.CalendarLocale.months.abbr[this.displayDate.getMonth()]+" "+this.displayDate.getDate()+", "+this.displayDate.getFullYear()},setDate:function(U){if(!this.calendarId){this.create()}var M=window.APE,F=M.widget.CalendarLocale;if(!F){throw Error("Missing Resource: APE.widget.CalendarLocale")}var X=new Date,T=document,J=U.getFullYear(),V=U.getMonth(),I=F.months.full[V],B=this.days[V],N,R=0,O=0,G=(0==(J%4))&&((0!=(J%100))||(0==(J%400))),K=T.getElementById(this.calendarId),A=K.getElementsByTagName("table")[0].tBodies[0],E=A.getElementsByTagName("b"),W="textContent" in K?"textContent":"innerText",Q=T.getElementById(this.calendarId+"-header"),S=M.dom,D;N=new Date(U);N.setDate(1);N=N.getDay();Q.firstChild.data=J+", "+I;if(V===1&&G){B+=1}while(R=0){D=-this.pos;this.newPos=0;C.addClass(document.getElementById(this.id+"Prev"),"carouselButton-disabled")}}else{if(this.pos===0&&this.newPos){C.removeClass(document.getElementById(this.id+"Prev"),"carouselButton-disabled")}if(this.newPos<=this.frameSize-this.scrollDistance){C.addClass(document.getElementById(this.id+"Next"),"carouselButton-disabled");var A=this.scrollDistance+this.pos-this.frameSize;D=-A;this.newPos=this.pos-A}}this.startTime=new Date().valueOf();this.startPos=this.pos;this.dx=D;this.timerId=window.setInterval("shopping.widget.Carousel.instances['"+this.id+"'].move()",12)},move:function(){var A=new Date-this.startTime,C=A/this.timeDuration,B=(Math.atan(1.4*(2*C-1))/Math.atan(1.4)+1)/2;if(C>=1){return this.moveEnd()}this.style[this.stylePos]=(this.pos=0|this.startPos+this.dx*B)+"px"},moveEnd:function(){window.clearInterval(this.timerId);this.timerId=null;this.style[this.stylePos]=(this.pos=this.newPos)+"px";if(typeof this.onend=="function"){this.onend()}if(this._queue!==0){var A=this._queue>0;this._queue+=A?-1:1;this.moveStart(A)}}};shopping.widget.Carousel.getById=APE.getById;shopping.widget.Carousel.handleButtonClick=function(){var A=this.id.match(/(\w+)(Next|Prev)$/),B=shopping.widget.Carousel.getById(A[1]);B.moveStart(A[2]==="Next")}; \ No newline at end of file diff --git a/build/widget/scroller/Scroller-min.js b/build/widget/scroller/Scroller-min.js new file mode 100644 index 0000000..59e82a4 --- /dev/null +++ b/build/widget/scroller/Scroller-min.js @@ -0,0 +1 @@ +APE.namespace("APE.widget");APE.widget.Scroller=(function(){return APE.createFactory(B,{pos:0,init:function(){var E=document.getElementById(this.id),M,K=E.childNodes,H,J,L=APE.dom.Event.addCallback,G=this.isVertical?"offsetTop":"offsetLeft",N=this.isVertical?"offsetHeight":"offsetWidth";this.style=E.style;this.clientDimension=this.isVertical?"clientHeight":"clientWidth";this.stylePos=this.isVertical?"top":"left";for(H=0,J=K.length;H=0){G=-this.pos;this.newPos=0;F.addClass(document.getElementById(this.id+"Prev"),"scrollerButton-disabled")}}else{if(this.pos===0&&this.newPos){F.removeClass(document.getElementById(this.id+"Prev"),"scrollerButton-disabled")}if(this.newPos<=this.frameSize-this.scrollDistance){F.addClass(document.getElementById(this.id+"Next"),"scrollerButton-disabled");var D=this.scrollDistance+this.pos-this.frameSize;G=-D;this.newPos=this.pos-D}}this.startTime=new Date().valueOf();this.startPos=this.pos;this.dx=G;this.timerId=window.setInterval(A(this),12)},move:function(){var D=new Date-this.startTime,F=D/this.timeDuration,E=(Math.atan(1.4*(2*F-1))/Math.atan(1.4)+1)/2;if(F>=1){return this.moveEnd()}this.style[this.stylePos]=(this.pos=0|this.startPos+this.dx*E)+"px"},moveEnd:function(){window.clearInterval(this.timerId);this.timerId=null;this.style[this.stylePos]=(this.pos=this.newPos)+"px";if(typeof this.onend=="function"){this.onend()}if(this._queue!==0){var D=this._queue>0;this._queue+=D?-1:1;this.moveStart(D)}}});function B(F,E,D){this.id=F;this.timeDuration=E||250;this.isVertical=!!D;this._queue=0;this.init()}function A(E){return D;function D(){E.move()}}function C(){var D=this.id.match(/(\w+)(Next|Prev)$/),E=APE.widget.Scroller.getById(D[1]);E.moveStart(D[2]==="Next")}})(); \ No newline at end of file diff --git a/src/widget/carousel/Carousel.js b/src/widget/carousel/Carousel.js deleted file mode 100644 index 2c6c881..0000000 --- a/src/widget/carousel/Carousel.js +++ /dev/null @@ -1,144 +0,0 @@ -APE.namespace("shopping.widget"); -/** - * @constructor - * @param {string} id the id of the list. - * @param {number} [timeDuration] how much time to take to perform each scroll. - */ -shopping.widget.Carousel = function(id, timeDuration, vertical) { - this.id = id; - this.timeDuration = timeDuration || 250; - this.isVertical = !!vertical; - this._queue = 0; - this.init(); -}; - -shopping.widget.Carousel.prototype = { - pos : 0, - - init : function() { - var el = document.getElementById(this.id), - item, items = el.childNodes, - i, len, addCallback = APE.dom.Event.addCallback, - offsetPosition = this.isVertical ? "offsetTop" : "offsetLeft", - offsetDimension = this.isVertical ? "offsetHeight" : "offsetWidth", - Carousel = shopping.widget.Carousel; - - this.style = el.style; - this.clientDimension = this.isVertical ? "clientHeight" : "clientWidth"; - this.stylePos = this.isVertical ? "top" : "left"; - - // Remove text nodes. - for(i = 0, len = items.length; i < len; i++) { - item = items[i]; - if(!item) break; - if(!("tagName" in item)) item.parentNode.removeChild(item); - } - - this.scrollDistance = el.lastChild[offsetPosition] + el.lastChild[offsetDimension]; - this.frameSize = el.parentNode[this.clientDimension]; - - // Trim off extra pixels, but allow for a little margin-right. - var styleDim = this.isVertical ? "height" : "width"; - this.style[styleDim] = this.scrollDistance + 10 + "px"; - - // Add event callbacks for buttons. - var prev = document.getElementById(this.id + "Prev"), - next = document.getElementById(this.id + "Next"); - if(prev) { - addCallback(prev, "click", Carousel.handleButtonClick); - } - if(next) { - addCallback(next, "click", Carousel.handleButtonClick); - } - }, - - /** - * - * @param {boolean} [isNext] "next" or "prev" - */ - moveStart : function(isNext) { - // add to queue. - if(this.timerId) { - this._queue += isNext ? 1 : -1; - return; - } - - var d = document.getElementById(this.id + "Frame")[this.clientDimension], - dom = APE.dom; - - // If the carousel is not wide enough to scroll, exit. - if(this.scrollDistance <= d) return; - - if(isNext) { - d = -d; - } - this.newPos = this.pos + d; - - if(!isNext) { - dom.removeClass(document.getElementById(this.id + "Next"), "carouselButton-disabled"); - if(this.newPos >= 0) { - d = -this.pos; - this.newPos = 0; - dom.addClass(document.getElementById(this.id + "Prev"), "carouselButton-disabled"); - } - } else { - // disable the "Prev" button if we're at 0. - if(this.pos === 0 && this.newPos ) { - dom.removeClass(document.getElementById(this.id + "Prev"), "carouselButton-disabled"); - } - // disable the "Next" button if we're at end. - if(this.newPos <= this.frameSize - this.scrollDistance) { - dom.addClass(document.getElementById(this.id + "Next"), "carouselButton-disabled"); - - var r = this.scrollDistance + this.pos - this.frameSize; // Negative. - - d = -r; - this.newPos = this.pos - r; - } - } - // If the remainder is smaller than the distance, - // only move by that much. - - this.startTime = new Date().valueOf(); - this.startPos = this.pos; - this.dx = d; - this.timerId = window.setInterval("shopping.widget.Carousel.instances['"+this.id+"'].move()", 12); - }, - - move : function() { - var elapsed = new Date - this.startTime, - rationalValue = elapsed/this.timeDuration, - effectedValue = (Math.atan(1.4*(2*rationalValue-1))/Math.atan(1.4)+1)/2; - if(rationalValue >= 1) { - return this.moveEnd(); - } - // floor off the decimal ToInt32. - this.style[this.stylePos] = (this.pos = 0|this.startPos + this.dx * effectedValue) + "px"; - }, - - moveEnd : function() { - window.clearInterval(this.timerId); - this.timerId = null; - this.style[this.stylePos] = (this.pos = this.newPos) + "px"; - if(typeof this.onend == "function") { - this.onend(); - } - - // take out of cue. - if(this._queue !== 0) { - var isNext = this._queue > 0; - this._queue += isNext ? -1 : 1; - this.moveStart(isNext); - } - } -}; -shopping.widget.Carousel.getById = APE.getById; - -/** - * onclick callback for Left/Right buttons. - */ -shopping.widget.Carousel.handleButtonClick = function() { - var dir = this.id.match(/(\w+)(Next|Prev)$/), - c = shopping.widget.Carousel.getById(dir[1]); - c.moveStart(dir[2] === "Next"); -}; \ No newline at end of file