From Squeak3.9 on 22 September 2007 at 2:46:27 pm <version>StarRater-mb.12.mcz 13 September 2007 5:11:52 pm</version> <class> <name>SRDemo</name> <environment>Seaside</environment> <super>Seaside.WAComponent</super> <private>false</private> none rater1 rater2 <imports></imports> <category>StarRater-Demo</category> <attributes> <package>StarRater-Demo</package> </attributes> </class> <class> <name>SRFileLibrary</name> <environment>Seaside</environment> <super>Seaside.WAFileLibrary</super> <private>false</private> none <imports></imports> <category>StarRater-Core</category> <attributes> <package>StarRater-Core</package> </attributes> </class> <class> <name>SRStarRater</name> <environment>Seaside</environment> <super>Seaside.WAComponent</super> <private>false</private> none callback clickable numberOfStars image imageWidth imageHeight rating titles imageUrl <imports></imports> <category>StarRater-Core</category> <attributes> <package>StarRater-Core</package> </attributes> </class> <comment> Seaside.SRStarRater
http://komodomedia.com/blog/index.php/2005/08/24/creating-a-star-rater-using-css/ http://komodomedia.com/blog/index.php/2006/01/09/
</comment> <class> <name>SRStyles</name> <environment>Seaside</environment> <super>Seaside.WAFileLibrary</super> <private>false</private> none <imports></imports> <category>StarRater-Core</category> <attributes> <package>StarRater-Core</package> </attributes> </class> <methods> Seaside.SRDemo <category>initialize-release</category>
initialize super initialize. self rater1: (SRStarRater default clickable: false ; rating: 3.6 ; yourself). self rater2: (SRStarRater alternative: 4).
</methods> <methods> Seaside.SRDemo <category>rendering</category>
rendererClass ^WARenderCanvas
</methods> <methods> Seaside.SRDemo <category>accessing</category>
rater2 ^rater2
</methods> <methods> Seaside.SRDemo <category>accessing</category>
rater2: anObject rater2 := anObject
</methods> <methods> Seaside.SRDemo <category>accessing</category>
children ^Array with: self rater1 with: self rater2
</methods> <methods> Seaside.SRDemo <category>accessing</category>
rater1: anObject rater1 := anObject
</methods> <methods> Seaside.SRDemo <category>updating</category>
updateRoot: anHtmlRoot super updateRoot: anHtmlRoot. anHtmlRoot title: 'Star Rater Demo'.
</methods> <methods> Seaside.SRDemo <category>rendering</category>
style ^ 'div {font-family: Tahoma; margin: 2em}'
</methods> <methods> Seaside.SRDemo <category>rendering</category>
renderContentOn: html html div: [html text: 'The star rater below is for display only'. html render: self rater1. html render: self rater1 rating]. html div: [html text: 'The one below is live'. html render: self rater2. html render: self rater2 rating]
</methods> <methods> Seaside.SRDemo <category>accessing</category>
rater1 ^rater1
</methods> <methods> Seaside.SRFileLibrary <category>uploaded</category>
altStarGif | xxxCache | xxxCache := #(nil) beMutable. (xxxCache at: 1) isNil ifTrue: [ xxxCache at: 1 put: #(71 73 70 56 57 97 25 0 75 0 247 0 0 249 170 72 248 157 65 254 234 91 233 232 232 254 209 69 232 230 230 230 229 230 254 225 78 254 201 62 254 249 232 219 216 217 238 236 237 236 235 235 249 168 71 237 235 236 254 217 76 226 224 226 254 222 76 248 164 69 221 219 220 217 214 215 214 212 212 232 231 232 254 252 245 254 253 243 254 237 166 234 233 233 229 228 229 254 223 81 253 206 94 246 143 57 254 231 113 253 198 89 252 195 87 254 228 82 253 194 57 253 208 95 254 216 69 212 209 209 255 251 243 254 214 74 249 166 70 238 237 237 247 153 63 254 243 98 249 170 81 254 226 106 254 226 80 254 212 72 254 213 65 254 208 67 254 207 67 254 199 60 254 197 59 250 178 76 250 176 76 250 174 74 249 181 130 254 250 244 254 248 243 246 146 58 246 144 58 254 220 73 254 218 71 251 183 79 251 180 78 245 139 55 251 251 251 249 249 249 253 253 253 252 252 252 250 250 250 248 248 248 253 252 252 244 244 244 245 245 245 243 243 243 235 234 234 248 247 247 237 236 236 246 246 246 252 251 251 246 245 246 242 241 241 241 240 240 240 239 239 247 247 247 249 248 248 228 227 227 224 222 222 231 230 230 220 218 218 242 242 242 243 242 242 244 243 243 240 239 240 230 229 229 241 241 241 224 222 223 229 227 227 236 236 236 224 223 223 239 238 238 239 239 239 244 243 244 247 246 247 222 220 221 225 224 224 254 244 99 254 210 96 221 219 219 249 248 249 254 249 177 242 241 242 228 226 226 250 249 250 231 229 230 218 215 216 246 245 245 223 221 222 223 222 222 228 226 227 250 249 249 220 218 219 237 237 237 226 224 225 227 225 226 254 252 225 231 230 231 254 247 242 227 226 226 240 238 239 235 234 235 245 244 244 251 185 81 227 224 225 254 221 74 254 222 75 254 254 245 243 242 243 248 161 67 254 247 147 225 223 223 226 225 225 254 243 231 230 228 229 254 226 155 240 238 238 222 219 219 234 233 234 249 173 74 254 212 105 223 220 221 245 136 54 229 227 228 254 247 211 245 134 53 254 233 141 221 218 218 254 225 83 255 223 121 215 213 213 254 224 77 254 252 234 254 203 53 251 250 250 247 163 94 251 190 109 248 168 88 254 248 220 248 247 248 250 176 75 248 165 78 253 226 196 248 160 66 254 238 195 254 244 108 214 211 212 253 228 206 254 222 152 248 162 68 250 191 117 255 208 59 254 228 118 254 227 85 254 215 67 254 215 115 254 232 89 254 219 72 249 192 153 248 168 79 251 203 158 254 239 95 221 220 220 251 213 172 254 250 196 254 240 205 254 231 130 254 230 137 254 239 148 255 231 156 252 198 114 237 236 237 254 242 97 254 247 156 254 221 135 254 212 81 253 239 229 220 219 220 221 218 219 253 200 90 225 223 224 240 240 240 253 192 54 251 203 150 252 188 83 252 191 84 254 217 121 254 221 125 248 165 69 226 224 224 254 250 186 238 238 238 239 238 239 230 228 228 254 240 221 254 245 216 217 215 215 254 239 184 254 242 171 254 229 87 249 175 83 252 216 166 254 225 101 254 220 78 254 238 191 253 224 79 254 234 151 247 151 62 249 172 73 250 173 74 250 185 105 253 224 186 253 228 189 254 212 63 253 212 70 254 241 97 254 246 128 254 236 93 254 237 94 223 221 221 254 204 65 246 148 60 253 203 92 254 254 254 255 255 255 33 249 4 0 0 0 0 0 44 0 0 0 0 25 0 75 0 0 8 255 0 255 9 28 72 240 159 191 130 8 19 18 44 50 199 14 146 36 7 21 74 244 71 68 197 128 2 74 146 72 148 152 68 201 33 35 74 252 32 137 184 177 224 16 6 22 4 26 80 49 132 100 73 131 82 212 28 17 56 4 83 28 34 73 146 20 241 231 146 160 191 34 71 24 136 33 104 6 26 25 37 74 150 88 57 178 115 224 79 35 68 164 240 169 163 162 96 22 5 227 234 108 225 214 100 73 17 129 69 136 48 33 179 38 148 155 148 27 141 208 105 162 71 224 27 7 135 24 44 121 57 208 66 147 33 2 211 68 66 67 119 160 50 60 74 140 8 60 66 40 15 94 186 118 252 48 105 9 214 201 19 63 87 94 94 217 195 133 177 192 159 71 166 236 153 82 210 141 6 203 62 141 132 137 22 102 163 167 51 26 19 250 59 162 193 204 70 48 149 14 39 52 82 133 179 68 42 125 136 244 28 56 228 137 109 133 81 182 140 84 77 196 192 92 129 81 180 80 98 64 100 96 158 225 8 253 65 89 227 69 160 6 55 149 168 12 152 32 167 186 5 39 187 13 58 255 25 179 132 200 152 13 74 134 36 25 226 228 11 32 58 131 74 73 28 242 133 14 157 42 78 32 26 244 7 149 8 211 137 115 88 65 132 17 187 241 68 151 129 125 189 20 94 130 12 217 129 211 130 27 81 164 130 28 22 72 145 90 130 255 116 148 5 19 88 108 0 93 130 39 165 52 68 40 84 128 166 160 20 152 28 177 142 56 42 220 177 68 75 16 94 182 218 19 89 36 64 202 12 39 244 129 30 17 234 237 228 18 79 69 12 129 68 21 10 168 128 140 45 182 128 114 68 44 91 128 241 196 23 113 44 113 68 68 97 45 17 134 6 101 152 80 193 9 40 208 67 79 12 228 32 193 197 18 84 48 176 128 22 42 204 244 143 30 42 168 161 6 29 42 16 145 128 49 185 148 96 231 15 46 220 210 73 6 24 252 227 64 19 106 66 177 193 76 169 180 227 194 15 188 248 224 3 34 137 68 16 129 40 162 28 176 73 20 142 112 33 216 63 72 88 144 198 63 197 48 250 104 164 7 188 32 194 168 34 28 19 5 56 149 69 148 4 26 130 124 129 193 7 236 212 255 35 3 13 8 84 51 194 8 52 200 240 193 63 88 84 1 154 63 67 48 145 197 24 24 100 83 67 13 180 34 176 207 12 50 56 115 66 30 211 124 120 153 17 82 148 225 71 20 218 16 64 0 12 40 160 240 128 58 233 252 99 2 31 151 22 196 95 23 208 52 145 129 58 28 112 240 9 46 230 236 34 192 40 126 160 166 16 69 22 48 81 142 188 248 228 3 140 61 203 176 48 204 19 159 221 139 4 24 133 48 19 48 44 112 116 115 15 27 108 192 33 172 110 170 65 129 7 19 141 176 209 136 34 93 152 17 197 31 112 252 241 207 29 20 71 39 5 37 87 40 242 71 114 148 200 161 134 22 205 253 211 132 180 78 57 129 133 64 83 224 81 5 18 71 88 113 134 22 79 160 49 137 108 8 13 49 201 18 79 88 176 8 140 69 64 165 74 26 111 124 117 111 84 2 18 232 19 130 17 242 20 35 134 92 79 212 245 66 87 64 241 95 215 254 92 193 0 22 79 128 215 245 16 223 116 65 132 2 103 152 168 160 19 125 124 101 134 24 78 72 125 160 17 124 208 255 241 76 47 129 40 240 196 128 58 53 117 175 17 86 220 81 72 14 153 228 128 68 29 12 32 181 132 216 134 95 214 52 17 74 88 64 193 14 30 244 192 131 44 116 152 80 135 2 123 148 65 6 20 122 135 53 86 89 227 132 241 139 59 43 172 128 10 36 255 12 49 69 28 94 16 210 68 204 255 188 53 134 92 70 64 34 12 43 174 48 66 139 4 219 164 16 79 45 242 252 99 133 5 122 28 36 93 21 2 89 227 139 4 41 164 208 0 0 0 188 3 207 42 55 216 128 78 20 154 88 58 16 18 26 108 122 14 0 150 224 176 138 13 239 104 15 64 16 134 36 163 67 175 160 173 218 106 56 167 4 224 129 16 156 200 132 16 58 199 131 22 156 0 11 143 144 22 176 132 53 134 64 152 130 7 252 128 93 0 138 39 129 86 52 129 2 97 40 151 83 168 165 15 71 236 192 23 219 216 158 37 194 7 132 121 68 2 2 80 8 15 176 188 97 130 127 4 1 8 134 184 6 54 66 16 2 16 204 130 10 98 72 225 189 152 64 129 127 128 64 26 253 232 64 7 120 72 208 134 54 232 226 31 91 88 194 130 252 17 146 127 20 241 18 175 248 7 49 36 209 134 75 252 3 12 94 88 162 18 192 240 143 102 72 226 2 212 216 2 29 136 112 129 4 252 195 11 93 88 34 19 180 128 156 71 100 161 9 77 8 70 25 170 210 5 38 44 81 10 84 240 147 24 158 128 132 33 176 71 59 128 24 68 100 36 146 153 38 12 96 17 37 227 15 17 252 163 183 132 132 5 9 3 234 9 214 74 50 201 175 89 242 146 255 8 8 0 59) asByteArray ]. ^ xxxCache at: 1
</methods> <methods> Seaside.SRFileLibrary <category>uploaded</category>
starRatingGif | xxxCache | xxxCache := #(nil) beMutable. (xxxCache at: 1) isNil ifTrue: [ xxxCache at: 1 put: #(71 73 70 56 57 97 30 0 90 0 230 0 0 0 125 0 247 247 247 214 214 214 208 162 24 101 212 101 204 204 204 234 198 74 35 171 35 239 239 239 171 224 171 235 193 42 0 173 0 254 252 244 246 227 159 230 230 230 247 213 86 76 200 76 250 242 213 0 181 0 223 179 34 0 165 0 222 222 222 132 217 132 242 217 131 0 190 0 249 236 191 0 153 0 213 238 213 202 234 202 34 191 34 245 204 49 229 185 38 254 249 230 190 232 190 239 212 116 216 171 30 249 238 201 26 171 26 25 181 25 238 205 89 230 249 230 116 200 116 34 201 34 0 140 0 52 173 52 240 198 46 0 204 0 66 217 66 240 249 240 239 214 107 142 216 142 13 164 13 247 222 132 248 232 174 232 192 51 252 235 176 227 183 36 254 252 241 224 249 224 243 205 63 253 245 216 184 230 184 46 190 46 215 170 28 197 242 197 220 175 32 246 224 147 255 255 255 247 253 247 248 221 116 39 208 39 38 177 38 80 196 80 246 229 168 237 195 43 0 153 0 133 231 133 114 213 114 150 219 150 7 169 7 8 206 8 250 241 207 242 207 75 231 189 40 212 167 26 243 209 81 76 219 76 248 219 110 0 132 0 249 227 140 39 189 39 253 246 220 238 252 238 243 203 56 237 197 54 253 249 235 207 239 207 213 244 213 34 183 34 73 202 73 189 237 189 52 183 52 245 216 107 255 230 165 97 224 97 236 201 77 171 230 171 247 213 87 130 220 130 252 242 201 116 202 116 30 204 30 141 224 141 247 224 141 228 189 57 247 206 66 181 240 181 248 222 121 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 33 249 4 0 7 0 255 0 44 0 0 0 0 30 0 90 0 0 7 255 128 67 130 131 132 131 1 135 135 133 138 139 138 1 8 143 8 137 140 147 132 142 14 130 14 145 148 155 67 1 14 151 67 159 146 156 141 8 21 1 130 1 21 154 164 141 159 132 162 173 133 142 171 67 143 182 171 168 178 157 158 21 68 68 2 2 130 21 14 163 140 136 135 8 14 181 1 5 5 168 203 153 145 200 134 142 202 159 21 193 152 193 151 1 193 196 159 210 168 135 203 21 196 144 186 230 230 68 188 143 229 196 136 172 139 202 238 8 147 142 228 186 237 215 153 201 225 232 186 240 89 18 132 192 89 129 115 211 146 41 203 230 76 87 63 114 167 4 113 155 86 201 82 176 116 253 58 93 99 167 42 87 41 115 169 206 233 179 84 12 83 201 89 177 134 136 212 167 113 153 67 121 45 67 102 252 40 44 20 76 107 18 61 50 82 86 19 30 50 79 160 4 156 60 246 106 136 80 72 144 28 244 28 58 47 83 39 1 234 30 169 19 0 141 169 34 83 246 28 56 139 216 73 105 1 123 88 217 45 162 133 170 194 215 171 7 59 233 252 136 73 23 130 96 246 255 48 13 131 89 73 89 165 119 240 8 173 157 117 11 19 66 119 196 6 61 98 89 104 112 199 135 136 202 41 36 92 247 26 197 198 159 232 54 162 54 246 231 174 84 136 46 31 67 202 248 178 37 114 146 119 1 53 217 185 21 217 144 161 73 245 210 107 85 150 169 75 27 116 224 74 77 201 19 213 33 110 220 72 44 86 186 98 98 98 68 80 148 152 1 67 229 202 204 141 249 9 120 54 196 9 5 10 9 58 21 16 26 217 112 170 133 234 206 9 18 179 96 65 153 95 225 178 35 182 174 72 77 247 238 61 54 79 27 250 11 69 24 50 108 58 72 56 239 67 70 136 216 197 13 77 235 75 198 136 11 12 243 45 32 193 128 1 46 240 220 115 7 112 64 208 126 159 252 50 134 129 20 104 160 193 10 20 16 120 94 119 71 40 24 202 120 32 13 1 1 132 19 174 176 130 128 22 154 0 70 87 185 4 244 154 32 4 128 56 33 22 35 14 232 131 108 198 61 118 157 57 168 192 209 93 132 47 194 168 197 137 53 118 102 91 77 42 236 40 161 136 0 176 32 145 255 0 180 41 83 128 32 111 12 248 220 145 43 28 32 72 1 153 136 53 150 82 67 16 241 31 6 70 78 168 193 110 189 117 117 137 14 46 124 25 166 6 40 108 88 38 86 67 208 145 166 11 70 128 1 134 15 83 2 49 155 150 87 69 132 134 11 80 48 65 136 5 79 104 208 132 90 169 57 82 211 11 86 112 161 86 68 92 32 1 129 68 137 154 34 136 163 161 4 195 13 59 109 170 84 41 40 184 128 131 13 87 54 149 134 83 40 199 89 18 152 45 180 145 36 78 69 252 216 88 25 101 179 88 230 25 173 154 233 7 80 174 250 129 50 19 175 215 144 86 102 109 166 4 180 151 104 203 176 54 236 102 181 144 64 194 108 203 214 234 210 16 34 136 64 230 176 63 241 116 9 8 94 120 1 66 166 226 208 170 80 120 203 177 35 132 18 74 52 32 29 84 225 188 10 145 57 213 233 210 69 11 45 72 145 131 70 215 168 195 27 62 147 156 225 193 191 45 212 112 207 122 186 48 0 2 15 109 220 144 197 3 255 54 188 131 25 66 212 144 65 4 32 48 112 157 236 63 130 240 32 69 11 10 76 129 3 14 74 52 220 48 189 232 158 240 5 38 9 77 155 196 7 31 76 48 193 8 35 76 208 130 200 244 182 112 194 183 42 101 164 42 59 13 120 140 67 16 65 252 64 5 14 51 55 108 70 72 107 169 138 74 6 83 180 252 242 8 84 80 241 193 191 87 156 108 212 67 117 77 27 69 211 31 0 45 244 0 3 164 97 177 55 191 214 101 22 59 85 112 61 65 208 81 159 144 83 147 92 14 177 131 2 10 176 188 54 212 114 92 217 218 93 21 12 145 131 7 45 40 49 133 199 119 79 64 38 37 193 110 1 48 186 54 224 176 118 16 39 167 180 83 45 55 52 28 71 14 57 92 240 113 16 25 236 201 44 42 69 120 176 70 4 132 68 96 192 4 23 32 106 170 165 67 212 113 6 65 112 9 146 132 181 70 125 202 119 118 44 29 219 235 32 229 32 165 20 168 101 23 54 13 188 9 169 122 138 53 189 89 19 153 49 248 46 191 137 173 147 225 58 68 32 0 59) asByteArray ]. ^ xxxCache at: 1
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
imageUrl: aString imageUrl := aString
</methods> <methods> Seaside.SRStarRater <category>initialize-release</category>
initialize super initialize. self clickable: true. self rating: 0
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
clickable: aBoolean clickable := aBoolean
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
imageHeight: anInteger imageHeight := anInteger
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
imageHeight ^imageHeight
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
titles ^titles
</methods> <methods> Seaside.SRStarRater <category>accessing-style</category>
currentRatingStyle ^ String streamContents: [:stream | stream nextPutAll: 'width: '; nextPutAll: self ratingWidth displayString; nextPutAll: 'px; height: '; nextPutAll: self imageHeight displayString; nextPutAll: 'px; background: url('; nextPutAll: self imageUrl displayString; nextPutAll: ') left bottom;']
</methods> <methods> Seaside.SRStarRater <category>accessing-dimensions</category>
ratingWidth ^(self width * self rating / self numberOfStars) asFloat
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
id ^'sr' , self hash displayString
</methods> <methods> Seaside.SRStarRater <category>rendering</category>
renderContentOn: html html unorderedList id: self id; style: self listStyle; class: 'star-rating'; with: [ self renderCurrentRatringOn: html. self renderStarsOn: html ]
</methods> <methods> Seaside.SRStarRater <category>accessing-dimensions</category>
width ^self imageWidth * self numberOfStars
</methods> <methods> Seaside.SRStarRater <category>accessing-style</category>
personalStyle ^String streamContents: [ :stream | self printAnchorStyleOn: stream. self starsDo: [ :each | self printIndividualAnchorStyleFor: each on: stream ] ]
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
imageWidth ^imageWidth
</methods> <methods> Seaside.SRStarRater <category>enumerating</category>
starsDo: aBlock 1 to: self numberOfStars do: aBlock
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
titles: aCollection titles := aCollection
</methods> <methods> Seaside.SRStarRater <category>updating</category>
updateRoot: anHtmlRoot super updateRoot: anHtmlRoot. anHtmlRoot addStyle: self personalStyle
</methods> <methods> Seaside.SRStarRater <category>accessing-content</category>
starContent: anInteger ^String streamContents: [ :stream | stream nextPutAll: anInteger displayString; nextPutAll: ' star'. anInteger > 1 ifTrue: [ stream nextPut: $s ] ]
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
rating: aFloat "aFloat is between 0 and numberOfStars inclusive" rating := aFloat
</methods> <methods> Seaside.SRStarRater <category>accessing-style</category>
printAnchorStyleOn: aStream aStream nextPut: $#; nextPutAll: self id; nextPutAll: ' li a { width: '; nextPutAll: self imageWidth displayString; nextPutAll: 'px; height: '; nextPutAll: self imageWidth displayString; nextPutAll: 'px; } '. self clickable ifTrue: [aStream nextPut: $#; nextPutAll: self id; nextPutAll: ' li a:hover { /* left: 0px; */ background: url('; nextPutAll: self imageUrl displayString; nextPutAll: ') left center; } ']
</methods> <methods> Seaside.SRStarRater <category>actions</category>
rate: anInteger self clickable ifTrue: [ self rating: anInteger ]. callback isNil ifFalse: [ callback numArgs = 0 ifTrue: [ callback value ] ifFalse: [ callback value: anInteger ] ]
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
clickable ^clickable
</methods> <methods> Seaside.SRStarRater <category>rendering</category>
renderStar: anInteger on: html html listItem: [ html anchor "style: (self individualAnchorStyleFor: anInteger);" class: (self classnameFor: anInteger); title: (self titles at: anInteger); callback: [ self rate: anInteger ]; with: (self starContent: anInteger) ]
</methods> <methods> Seaside.SRStarRater <category>accessing-content</category>
currentRatingContent ^String streamContents: [ :stream | stream nextPutAll: 'Currently '; nextPutAll: self rating displayString; nextPut: $/; nextPutAll: self numberOfStars displayString; nextPutAll: ' Stars.' ]
</methods> <methods> Seaside.SRStarRater <category>accessing-style</category>
listStyle ^ String streamContents: [:stream | stream nextPutAll: 'width: '; nextPutAll: self width displayString; nextPutAll: 'px; height: '; nextPutAll: self imageHeight displayString; nextPutAll: 'px; background: url('; nextPutAll: self imageUrl displayString; nextPutAll: ') top left repeat-x;']
</methods> <methods> Seaside.SRStarRater <category>rendering</category>
renderCurrentRatringOn: html html listItem style: self currentRatingStyle; class: 'current-rating'; with: self currentRatingContent
</methods> <methods> Seaside.SRStarRater <category>rendering</category>
rendererClass ^WARenderCanvas
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
numberOfStars ^numberOfStars
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
callback: aZeroOrOneArgumentBlock "the callback will be evalutated when a star is clicked the possible block argument is the one based index of the star a star can only be clicked when clickable: is set to true (default is true)" callback := aZeroOrOneArgumentBlock
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
numberOfStars: anInteger numberOfStars := anInteger
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
imageWidth: anInteger imageWidth := anInteger
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
rating ^rating
</methods> <methods> Seaside.SRStarRater <category>rendering</category>
renderStarsOn: html self starsDo: [ :each | self renderStar: each on: html ]
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
classnameFor: anInteger ^anInteger = 1 ifTrue: [ (self numberTitles at: anInteger) , '-star' ] ifFalse: [ (self numberTitles at: anInteger) , '-stars' ]
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
imageUrl ^ imageUrl
</methods> <methods> Seaside.SRStarRater <category>accessing-style</category>
individualAnchorStyleFor: anInteger "http://www.w3.org/TR/css-style-attr" ^ String streamContents: [:stream | stream nextPutAll: '{width: '; nextPutAll: self imageWidth displayString; nextPutAll: 'px; height: '; nextPutAll: self imageWidth displayString; nextPutAll: 'px; left: '; nextPutAll: (anInteger - 1 * self imageWidth) displayString; nextPutAll: 'px;} '; nextPutAll: ':hover { '. "yeah, it has to be image height" self clickable ifTrue: [stream nextPutAll: '/* left: 0px; */ background: url('; nextPutAll: self imageUrl displayString; nextPutAll: ') left center;']. stream nextPutAll: 'z-index: 2; left: 0px; width: '; nextPutAll: (anInteger * self imageWidth) displayString; nextPutAll: 'px;}']
</methods> <methods> Seaside.SRStarRater <category>accessing-style</category>
printIndividualAnchorStyleFor: anInteger on: aStream aStream nextPut: $#; nextPutAll: self id; nextPutAll: ' li a.'; nextPutAll: (self classnameFor: anInteger); nextPutAll: ' { left: '; nextPutAll: (anInteger - 1 * self imageWidth) displayString; nextPutAll: 'px; } '; nextPut: $#; nextPutAll: self id; nextPutAll: ' li a.'; nextPutAll: (self classnameFor: anInteger); nextPutAll: ':hover { z-index: 2; left: 0px; width: '; nextPutAll: (anInteger * self imageWidth) displayString; nextPutAll: 'px; } '
</methods> <methods> Seaside.SRStarRater <category>accessing</category>
numberTitles ^#( 'one' 'two' 'three' 'four' 'five' 'six' 'seven' 'eight' 'nine' 'ten' 'eleven' 'twelve' 'thirteen' 'fourteen' 'fifteen' 'sixteen' 'seventeen' 'eighteen' 'nineteen' 'twenty' )
</methods> <methods> Seaside.SRStyles <category>styles</category>
starRatingCss ^ ' .star-rating { list-style:none; margin: 0px; padding:0px; position: relative; } .star-rating li{ padding:0px; margin:0px; /*\*/ float: left; /* */ } .star-rating li a { display:block; text-decoration: none; text-indent: -9000px; z-index: 20; position: absolute; padding: 0px; } .star-rating li a:hover { z-index: 2; left: 0px; } .star-rating li.current-rating { position: absolute; display: block; text-indent: -9000px; z-index: 1; }'
</methods> <methods> Seaside.SRStyles <category>accessing</category>
selectorsToInclude ^ #(#starRatingCss )
</methods> <methods> Seaside.SRDemo class <category>accessing</category>
description ^'A star rater made just of CSS and no JavaScript. Based on CSS Star Rating Part Deux.'
</methods> <methods> Seaside.SRDemo class <category>registration</category>
registerAsApplication: aString ^(super registerAsApplication: aString) addLibrary: SRStyles; yourself
</methods> <methods> Seaside.SRDemo class <category>class initialization</category>
initialize self registerAsApplication: 'examples/starrater'
</methods> <methods> Seaside.SRDemo class <category>testing</category>
canBeRoot ^true
</methods> <methods> Seaside.SRFileLibrary class <category>class initialization</category>
initialize self register
</methods> <methods> Seaside.SRStarRater class <category>accessing-images</category>
alternativeImage "http://komodomedia.com/blog/samples/star_rating/alt_star.gif" ^'altStar.gif'
</methods> <methods> Seaside.SRStarRater class <category>accessing-images</category>
alternativeHeight ^25
</methods> <methods> Seaside.SRStarRater class <category>private</category>
defaultTitlesFor: anInteger ^(1 to: anInteger) collect: [ :each | String streamContents: [ :stream | stream nextPutAll: each displayString; nextPutAll: ' star'. anInteger > 1 ifTrue: [ stream nextPut: $s ]. stream nextPutAll: ' out of '; nextPutAll: anInteger displayString ] ]
</methods> <methods> Seaside.SRStarRater class <category>instance creation</category>
default: anInteger ^ self new imageUrl: (self resources addToPath: self defaultImage); imageWidth: self defaultWidth; imageHeight: self defaultHeight; numberOfStars: anInteger; titles: (self defaultTitlesFor: anInteger); yourself
</methods> <methods> Seaside.SRStarRater class <category>instance creation</category>
alternative: anInteger ^ self new imageUrl: (self resources addToPath: self alternativeImage); imageWidth: self alternativeWidth; imageHeight: self alternativeHeight; numberOfStars: anInteger; titles: (self defaultTitlesFor: anInteger); yourself
</methods> <methods> Seaside.SRStarRater class <category>accessing-images</category>
defaultHeight ^30
</methods> <methods> Seaside.SRStarRater class <category>instance creation</category>
default ^self default: 5
</methods> <methods> Seaside.SRStarRater class <category>accessing-images</category>
alternativeWidth ^25
</methods> <methods> Seaside.SRStarRater class <category>instance creation</category>
alternative ^self alternative: 5
</methods> <methods> Seaside.SRStarRater class <category>accessing-images</category>
defaultImage "http://komodomedia.com/blog/samples/star_rating/star_rating.gif" ^'starRating.gif'
</methods> <methods> Seaside.SRStarRater class <category>accessing-images</category>
defaultWidth ^30
</methods> <methods> Seaside.SRStarRater class <category>accessing</category>
resources ^ WAUrl new addToPath: WADispatcher default basePath; addToPath: 'files/SRFileLibrary'; yourself
</methods> <initialize> Seaside.SRDemo </initialize> <initialize> Seaside.SRFileLibrary </initialize>