| 168 | | # sub attr { |
|---|
| | 161 | sub attr { # (name, value, type) |
|---|
| | 162 | # TODO - Get/set a named attribute |
|---|
| | 163 | } |
|---|
| | 164 | |
|---|
| | 165 | sub css { # (key, value) |
|---|
| | 166 | # TODO - Get/set a css attribute |
|---|
| | 167 | } |
|---|
| | 168 | |
|---|
| | 169 | # TODO/XXX Made up. Not ported yet. |
|---|
| | 170 | sub text { |
|---|
| | 171 | # TODO - Get/set text value |
|---|
| | 172 | my $this = shift; |
|---|
| | 173 | my $text = ''; |
|---|
| | 174 | |
|---|
| | 175 | $this->each(sub { |
|---|
| | 176 | _to_text($_, \$text); |
|---|
| | 177 | }); |
|---|
| | 178 | |
|---|
| | 179 | $text =~ s/\s+/ /g; |
|---|
| | 180 | $text =~ s/\s$//; |
|---|
| | 181 | |
|---|
| | 182 | return $text; |
|---|
| | 183 | } |
|---|
| | 184 | |
|---|
| | 185 | sub wrapAll { # (html) |
|---|
| | 186 | # TODO - Wrap element with HTML |
|---|
| | 187 | } |
|---|
| | 188 | |
|---|
| | 189 | sub wrapInner { # (html) |
|---|
| | 190 | # TODO - Wrap sub elements with HTML |
|---|
| | 191 | } |
|---|
| | 192 | |
|---|
| | 193 | sub wrap { # (html) |
|---|
| | 194 | # TODO - Wrap current objects with HTML |
|---|
| | 195 | } |
|---|
| | 196 | |
|---|
| | 197 | sub append { # (@_) |
|---|
| | 198 | # TODO - Append arguments to current objects |
|---|
| | 199 | } |
|---|
| | 200 | |
|---|
| | 201 | sub prepend { # (@_) |
|---|
| | 202 | # TODO - Prepend arguments to current objects |
|---|
| | 203 | } |
|---|
| | 204 | |
|---|
| | 205 | sub before { # (@_) |
|---|
| | 206 | # TODO - Insert arguments before current objects |
|---|
| | 207 | } |
|---|
| | 208 | |
|---|
| | 209 | sub after { # (@_) |
|---|
| | 210 | # TODO - Insert arguments after current objects |
|---|
| | 211 | } |
|---|
| | 212 | |
|---|
| | 213 | sub end { |
|---|
| | 214 | my $this = shift; |
|---|
| | 215 | return $this->_prevObject || pQuery([]); |
|---|
| | 216 | } |
|---|
| | 217 | |
|---|
| | 218 | # XXX - Not really ported yet. |
|---|
| | 219 | # sub find { |
|---|
| | 220 | # my $this = shift; |
|---|
| | 221 | # my $selector = shift or return; |
|---|
| | 222 | # my $elems = []; |
|---|
| | 223 | # $this->each(sub { |
|---|
| | 224 | # _find_elems($_, $selector, $elems); |
|---|
| | 225 | # }); |
|---|
| | 226 | # return $this->pushStack($elems); |
|---|
| | 229 | # sub find { |
|---|
| | 230 | # my ($this, $selector) = @_; |
|---|
| | 231 | # my $elems = pQuery::map($this, sub { |
|---|
| | 232 | |
|---|
| | 233 | |
|---|
| | 234 | |
|---|
| | 235 | sub clone { # (events) |
|---|
| | 236 | # TODO - Not sure if we need this one. |
|---|
| | 237 | } |
|---|
| | 238 | |
|---|
| | 239 | sub filter { # (selector) |
|---|
| | 240 | # TODO - A kind of grep |
|---|
| | 241 | } |
|---|
| | 242 | |
|---|
| | 243 | sub not { # (selector) |
|---|
| | 244 | # TODO - An anti-grep?? |
|---|
| | 245 | } |
|---|
| | 246 | |
|---|
| | 247 | sub add { # (selector) |
|---|
| | 248 | # TODO - Some kind of merge |
|---|
| | 249 | } |
|---|
| | 250 | |
|---|
| | 251 | sub is { # (selector) |
|---|
| | 252 | # TODO - One element matches the selector |
|---|
| | 253 | } |
|---|
| | 254 | |
|---|
| | 255 | sub hasClass { |
|---|
| | 256 | my ($this, $selector) = @_; |
|---|
| | 257 | $this.is(".$selector"); |
|---|
| | 258 | } |
|---|
| | 259 | |
|---|
| | 260 | sub val { # (value) |
|---|
| | 261 | # TODO Get/set |
|---|
| | 262 | } |
|---|
| | 263 | |
|---|
| | 264 | # XXX - Not really ported yet. |
|---|
| 190 | | sub text { |
|---|
| 191 | | my $this = shift; |
|---|
| 192 | | my $text = ''; |
|---|
| 193 | | |
|---|
| 194 | | $this->each(sub { |
|---|
| 195 | | _to_text($_, \$text); |
|---|
| | 285 | # TODO - Not tested |
|---|
| | 286 | sub replaceWith { # (value) |
|---|
| | 287 | my ($this, $value) = @_; |
|---|
| | 288 | return $this->after($value)->remove; |
|---|
| | 289 | } |
|---|
| | 290 | |
|---|
| | 291 | # TODO - Not tested |
|---|
| | 292 | sub eq { |
|---|
| | 293 | my ($this, $i) = @_; |
|---|
| | 294 | return $this->pushStack($this->[$i]); |
|---|
| | 295 | } |
|---|
| | 296 | |
|---|
| | 297 | sub slice { #(i, j) |
|---|
| | 298 | # TODO - Behave like JS slice() |
|---|
| | 299 | } |
|---|
| | 300 | |
|---|
| | 301 | sub map { |
|---|
| | 302 | my ($this, $callback) = @_; |
|---|
| | 303 | return $this->pushStack(__map($this, sub { |
|---|
| | 304 | my ($elem, $i) = @_; |
|---|
| | 305 | return $callback->($elem, $i, $elem); |
|---|
| | 306 | })); |
|---|
| | 307 | } |
|---|
| | 308 | |
|---|
| | 309 | # TODO - Not tested |
|---|
| | 310 | sub andSelf { |
|---|
| | 311 | my $this = shift; |
|---|
| | 312 | return $this.add($this->prevObject); |
|---|
| | 313 | } |
|---|
| | 314 | |
|---|
| | 315 | sub data { # (key, value) |
|---|
| | 316 | # TODO - Not sure |
|---|
| | 317 | } |
|---|
| | 318 | |
|---|
| | 319 | sub removeData { # (key) |
|---|
| | 320 | # TODO - Not Sure |
|---|
| | 321 | } |
|---|
| | 322 | |
|---|
| | 323 | sub domManip { |
|---|
| | 324 | my ($this, $args, $table, $reverse, $callback) = @_; |
|---|
| | 325 | my $elems; |
|---|
| | 326 | return $this->each(sub { |
|---|
| | 327 | if (! defined $elems) { |
|---|
| | 328 | $elems = $args; |
|---|
| | 329 | @$elems = reverse @$elems |
|---|
| | 330 | if $reverse; |
|---|
| | 331 | } |
|---|
| | 332 | pQuery::each($elems, sub { |
|---|
| | 333 | $callback->($this, $_); |
|---|
| | 334 | }); |
|---|
| 197 | | |
|---|
| 198 | | $text =~ s/\s+/ /g; |
|---|
| 199 | | $text =~ s/\s$//; |
|---|
| 200 | | |
|---|
| 201 | | return $text; |
|---|
| 202 | | } |
|---|
| 203 | | |
|---|
| 204 | | sub find { |
|---|
| 205 | | my $this = shift; |
|---|
| 206 | | my $selector = shift or return; |
|---|
| 207 | | my $elems = []; |
|---|
| 208 | | $this->each(sub { |
|---|
| 209 | | _find_elems($_, $selector, $elems); |
|---|
| 210 | | }); |
|---|
| 211 | | return $this->_pushStack($elems); |
|---|
| 212 | | } |
|---|
| 213 | | |
|---|
| 214 | | sub end { |
|---|
| 215 | | my $this = shift; |
|---|
| 216 | | return $this->_prevObject; |
|---|
| 217 | | } |
|---|
| | 336 | } |
|---|
| | 337 | |
|---|
| | 338 | ################################################################################ |
|---|
| | 339 | # "Class" methods |
|---|
| | 340 | ################################################################################ |
|---|
| | 341 | # sub noConflict {} |
|---|
| | 342 | # sub isFunction {} |
|---|
| | 343 | # sub isXMLdoc {} |
|---|
| | 344 | # sub globalEval {} |
|---|
| | 345 | # sub nodeName {} |
|---|
| | 346 | # sub cache {} |
|---|
| | 347 | # sub data {} |
|---|
| | 348 | # sub removeData {} |
|---|
| | 349 | # sub each {} |
|---|
| | 350 | # sub prop {} |
|---|
| | 351 | # sub className {} |
|---|
| | 352 | # sub swap {} |
|---|
| | 353 | # sub css {} |
|---|
| | 354 | # sub curCSS {} |
|---|
| | 355 | # sub clean {} |
|---|
| | 356 | # sub attr {} |
|---|
| | 357 | # sub trim {} |
|---|
| | 358 | # sub makeArray {} |
|---|
| | 359 | # sub inArray {} |
|---|
| | 360 | # sub merge {} |
|---|
| | 361 | # sub unique {} |
|---|
| | 362 | # sub grep {} |
|---|
| | 363 | # sub map {} |
|---|
| | 364 | # sub unique {} |
|---|
| | 365 | |
|---|
| | 366 | ################################################################################ |
|---|
| | 367 | # Selector functions |
|---|
| | 368 | ################################################################################ |
|---|
| | 369 | |
|---|