Created
September 28, 2011 14:12
-
-
Save D3f0/1248040 to your computer and use it in GitHub Desktop.
Mejora
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WAComponent subclass: #D3f0Index | |
instanceVariableNames: 'conardor1 contador2' | |
classVariableNames: '' | |
poolDictionaries: '' | |
category: 'nahuel'! | |
!D3f0Index methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/27/2011 19:36'! | |
canBeRoot | |
^ true.! ! | |
!D3f0Index methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/27/2011 20:06'! | |
children | |
" Esto hace que busque los estilos CSS de los subcompoenentes :) " | |
^ OrderedCollection new add: self conardor1; add: self contador2; yourself.! ! | |
!D3f0Index methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/27/2011 19:54'! | |
initialize | |
super initialize . | |
conardor1 := D3f0Contador new. | |
contador2 := D3f0Contador new.! ! | |
!D3f0Index methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/27/2011 20:15'! | |
library | |
^ D3f0Estatico ! ! | |
!D3f0Index methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/27/2011 19:59'! | |
renderContentOn: html | |
html div class: 'wrapper'; with: [ | |
self conardor1 renderContentOn: html. | |
self contador2 renderContentOn: html. | |
]! ! | |
!D3f0Index methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/27/2011 22:13'! | |
style | |
^ ' | |
BODY { | |
font-family: "Verdana"; | |
font-size: 13px; | |
} | |
'! ! | |
!D3f0Index methodsFor: 'accessing' stamp: 'NahuelDefosse 9/27/2011 19:37'! | |
conardor1 | |
^ conardor1! ! | |
!D3f0Index methodsFor: 'accessing' stamp: 'NahuelDefosse 9/27/2011 19:37'! | |
conardor1: anObject | |
conardor1 := anObject! ! | |
!D3f0Index methodsFor: 'accessing' stamp: 'NahuelDefosse 9/27/2011 19:37'! | |
contador2 | |
^ contador2! ! | |
!D3f0Index methodsFor: 'accessing' stamp: 'NahuelDefosse 9/27/2011 19:37'! | |
contador2: anObject | |
contador2 := anObject! ! | |
WAComponent subclass: #D3f0Contador | |
instanceVariableNames: 'contador' | |
classVariableNames: '' | |
poolDictionaries: '' | |
category: 'nahuel'! | |
!D3f0Contador commentStamp: 'NahuelDefosse 9/27/2011 18:16' prior: 0! | |
Probando el ejemplo de diógenes :) | |
Instance Variables: | |
contador <Number>! | |
!D3f0Contador methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/27/2011 16:30'! | |
canBeRoot | |
^ true.! ! | |
!D3f0Contador methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/27/2011 18:07'! | |
decrementarContador | |
contador := contador -1! ! | |
!D3f0Contador methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/28/2011 11:08'! | |
enableDecrease | |
^ contador > 0.! ! | |
!D3f0Contador methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/27/2011 17:00'! | |
hacerAlgo | |
contador := contador + 1.! ! | |
!D3f0Contador methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/27/2011 18:04'! | |
incrementarContador | |
contador := contador +1! ! | |
!D3f0Contador methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/28/2011 11:08'! | |
renderContentOn: html | |
" Renderiza el contenido del contador" | |
| i | | |
(html div) | |
class: 'contador-wrapper'; | |
with: [ | |
(html paragraph) | |
class: 'contador-titulo'; | |
with: 'Un Componente Contador'. | |
html text: 'El valor del contador es '. | |
html text: self contador asString. | |
html | |
unorderedList: [ | |
html | |
listItem: [ | |
(html anchor) | |
callback: [ self incrementarContador ]; | |
with: '+' ]. | |
self enableDecrease | |
ifTrue: [ | |
html | |
listItem: [ | |
(html anchor) | |
callback: [ self decrementarContador ]; | |
with: '-' ] ] | |
ifFalse: [ html listItem: [ html text: 'El contador no puede decremntarse por debajo de 0,' ] ] ]. "Ahora a poner unos cuadraditos" | |
self renderStarsOn: html ]! ! | |
!D3f0Contador methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/28/2011 11:06'! | |
renderStarsOn: html | |
" Renderiza estellitas" | |
| i | | |
i := 0. | |
html | |
table class: 'stars'; with: [ | |
html | |
tableRow: [ | |
[ i < contador ] | |
whileTrue: [ | |
html tableData: 'x'. | |
i := i + 1 ] ] ]! ! | |
!D3f0Contador methodsFor: 'as yet unclassified' stamp: 'NahuelDefosse 9/27/2011 22:14'! | |
style | |
^ ' | |
.contador-wrapper { | |
border: 1px solid #ccc; | |
width: 500px; | |
} | |
.contador-wrapper .contador-titulo { | |
padding: 0px; | |
margin: 0px; | |
background: #ccc; | |
color: red; | |
} | |
.contador-wrapper .p { | |
padding: 0px; | |
margin: 0px; | |
} | |
' ! ! | |
!D3f0Contador methodsFor: 'accessing' stamp: 'NahuelDefosse 9/27/2011 17:03'! | |
contador | |
^ contador! ! | |
!D3f0Contador methodsFor: 'accessing' stamp: 'NahuelDefosse 9/27/2011 17:03'! | |
contador: anObject | |
contador := anObject! ! | |
!D3f0Contador methodsFor: 'accessing' stamp: 'NahuelDefosse 9/27/2011 17:04'! | |
initialize | |
super initialize . | |
contador := 1.! ! | |
WAFileLibrary subclass: #D3f0Estatico | |
instanceVariableNames: '' | |
classVariableNames: '' | |
poolDictionaries: '' | |
category: 'nahuel'! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment