| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 | 
							- Object subclass: #JQuery
 
- 	instanceVariableNames: 'jquery'
 
- 	category: 'JQuery'!
 
- !JQuery methodsFor: 'DOM insertion'!
 
- append: anObject
 
-     "Append anObject at the end of the element."
 
-     anObject appendToJQuery: self
 
- !
 
- appendElement: anElement
 
-     "Append anElement at the end of the element.
 
-      Dont't call this method directly, use #append: instead"
 
-     self call: 'append' withArgument: anElement
 
- !
 
- appendToJQuery: aJQuery
 
-     aJQuery appendElement: jquery
 
- !
 
- contents: anObject
 
-     self empty.
 
-     self append: anObject
 
- !
 
- empty
 
-     ^self call: 'empty'
 
- ! !
 
- !JQuery methodsFor: 'accessing'!
 
- jquery
 
- 	^jquery
 
- ! !
 
- !JQuery methodsFor: 'attributes'!
 
- removeAttribute: aString
 
-     "Remove an attribute from each element in the set of matched elements."
 
-     ^self call: 'removeAttribute' withArgument: aString
 
- !
 
- attr: aString
 
-     "Get the value of an attribute for the first element in the set of matched elements."
 
-     ^self call: 'attr' withArgument: aString
 
- !
 
- val
 
-     "Get the current value of the first element in the set of matched elements."
 
-     ^self call: 'val'
 
- !
 
- val: aString
 
-     self call: 'val' withArgument: aString
 
- !
 
- attrAt: aString put: anotherString
 
-     "Set the value of an attribute for the first element in the set of matched elements."
 
-     <self['@jquery'].attr(aString, anotherString)>
 
- ! !
 
- !JQuery methodsFor: 'css'!
 
- cssAt: aString
 
- 	<return self['@jquery'].css(aString)>
 
- !
 
- cssAt: aString put: anotherString
 
-     <self['@jquery'].css(aString, anotherString)>
 
- !
 
- addClass: aString
 
-     "Adds the specified class(es) to each of the set of matched elements."
 
-     self call: 'addClass' withArgument: aString
 
- !
 
- removeClass: aString
 
-     "Remove a single class, multiple classes, or all classes from each element in the set of matched elements."
 
-     self call: 'removeClass' withArgument: aString
 
- !
 
- toggleClass: aString
 
-     "Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument."
 
-     self call: 'toggleClass' withArgument: aString
 
- !
 
- height 
 
-     "Get the current computed height for the first element in the set of matched elements."
 
-     ^self call: 'height'
 
- !
 
- height: anInteger
 
-     self call: 'height' withArgument: anInteger
 
- !
 
- width: anInteger
 
-     self call: 'width' withArgument: anInteger
 
- !
 
- width
 
-     "Get the current computed width for the first element in the set of matched elements."
 
-     ^self call: 'width'
 
- !
 
- innerHeight
 
-     "Get the current computed height for the first element in the set of matched elements, including padding but not border."
 
-     ^self call: 'innerHeight'
 
- !
 
- innerWidth
 
-     "Get the current computed width for the first element in the set of matched elements, including padding but not border."
 
-     ^self call: 'innerWidth'
 
- !
 
- outerHeight
 
-     "Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin."
 
-     ^self call: 'outerHeight'
 
- !
 
- outerWidth
 
-     "Get the current computed width for the first element in the set of matched elements, including padding and border."
 
-     ^self call: 'outerWidth'
 
- !
 
- top
 
-     "Get the current y coordinate of the first element in the set of matched elements, relative to the offset parent."
 
-     ^(self call: 'position') basicAt: 'top'
 
- !
 
- left
 
-     "Get the current x coordinate of the first element in the set of matched elements, relative to the offset parent."
 
-     ^(self call: 'position') basicAt: 'left'
 
- !
 
- offsetLeft
 
-     "Get the current coordinates of the first element in the set of matched elements, relative to the document."
 
-     ^(self call: 'offset') basicAt: 'left'
 
- !
 
- offsetTop
 
-     "Get the current coordinates of the first element in the set of matched elements, relative to the document."
 
-     ^(self call: 'offset') basicAt: 'top'
 
- !
 
- scrollLeft
 
-     "Get the current horizontal position of the scroll bar for the first element in the set of matched elements."
 
-     ^self call: 'scrollLeft'
 
- !
 
- scrollTop
 
-     "Get the current vertical position of the scroll bar for the first element in the set of matched elements."
 
-     ^self call: 'scrollTop'
 
- !
 
- scrollLeft: anInteger
 
-     self call: 'scrollLeft' withArgument: anInteger
 
- !
 
- scrollTop: anInteger
 
-     self call: 'scrollTop' withArgument: anInteger
 
- ! !
 
- !JQuery methodsFor: 'enumerating'!
 
- do: aBlock
 
-     self elementsDo: [:anElement|  aBlock value: (JQuery fromElement: anElement)]
 
- ! !
 
- !JQuery methodsFor: 'events'!
 
- focus
 
-     self call: 'focus'
 
- !
 
- show
 
-     self call: 'show'
 
- !
 
- hide
 
-     self call: 'hide'
 
- !
 
- remove
 
-     self call: 'remove'
 
- !
 
- on: anEventString do: aBlock
 
-     "Attach aBlock for anEventString on the element"
 
-     <self['@jquery'].bind(anEventString, function(e){aBlock(e, self)})>
 
- !
 
- removeEvents: aString
 
-     "Unbind all handlers attached to the event aString"
 
-     self call: 'unbind' withArgument: aString
 
- ! !
 
- !JQuery methodsFor: 'initialization'!
 
- initializeWithJQueryObject: anObject
 
-     jquery := anObject
 
- ! !
 
- !JQuery methodsFor: 'private'!
 
- call: aString
 
- 	<return self['@jquery'][aString]()>
 
- !
 
- call: aString withArgument: anObject
 
-     <return self['@jquery'][aString](anObject)>
 
- !
 
- elementsDo: aBlock
 
-     "Iterate over a jQuery object, executing a function for each matched element."
 
-     <self['@jquery'].each(function(index, element){aBlock(element, self)})>
 
- ! !
 
- !JQuery methodsFor: 'testing'!
 
- hasClass: aString
 
-     "Determine whether any of the matched elements are assigned the given class."
 
-     ^self call: 'hasClass' withArgument: aString
 
- ! !
 
- !JQuery methodsFor: 'traversing'!
 
- find: aSelector
 
-     "Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element."
 
-     ^ self call: 'find' withArgument: aSelector
 
- ! !
 
- !JQuery class methodsFor: 'instance creation'!
 
- fromString: aString
 
-     | newJQuery |
 
-     <newJQuery = jQuery(String(aString))>.
 
-     ^self from: newJQuery
 
- !
 
- from: anObject
 
-     ^self new
 
- 	initializeWithJQueryObject: anObject;
 
- 	yourself
 
- !
 
- window
 
- 	<return self._from_(jQuery(window))>
 
- !
 
- body
 
- 	<return self._from_(jQuery('body'))>
 
- !
 
- document
 
- 	<return self._from_(jQuery(document))>
 
- !
 
- fromElement: anElement
 
-     | newJQuery |
 
-     <newJQuery = jQuery(anElement)>.
 
-     ^self from: newJQuery
 
- !
 
- documentReady: aBlock
 
- 	<jQuery(document).ready(aBlock)>
 
- ! !
 
- Object subclass: #Ajax
 
- 	instanceVariableNames: 'settings'
 
- 	category: 'JQuery'!
 
- !Ajax commentStamp!
 
- instance variable names:
 
- - settings  A set of key/value pairs that configure the Ajax request. All settings are optional.
 
- Full list of settings options at http://api.jquery.com/jQuery.ajax/!
 
- !Ajax methodsFor: 'accessing'!
 
- at: aKey
 
-     ^settings at: aKey ifAbsent: [nil]
 
- !
 
- at: aKey put: aValue
 
-     settings at: aKey put: aValue
 
- !
 
- url
 
-     ^self at: 'url'
 
- !
 
- url: aString
 
-     self at: 'url' put: aString
 
- ! !
 
- !Ajax methodsFor: 'actions'!
 
- send
 
-     <jQuery.ajax(self['@settings'])>
 
- ! !
 
- !Ajax methodsFor: 'callbacks'!
 
- onSuccessDo: aBlock
 
- 	"Set action to execute when Ajax request is successful. Pass received data as block argument. Block arguments: data, textStatus, jqXHR"
 
- 	self at: 'success' put: aBlock
 
- !
 
- onCompleteDo: aBlock
 
- 	"A block to be called when the request finishes (after success and error callbacks are executed). Block arguments: jqXHR, textStatus"
 
- 	self at: 'complete' put: aBlock
 
- !
 
- onErrorDo: aBlock
 
- 	"A block to be called if the request fails.Block arguments: jqXHR, textStatus, errorThrown"
 
- 	self at: 'error' put: aBlock
 
- ! !
 
- !Ajax methodsFor: 'initialization'!
 
- initialize
 
-     super initialize.
 
-     settings := Dictionary new
 
- ! !
 
- !Ajax class methodsFor: 'instance creation'!
 
- url: aString
 
-     ^self new
 
- 	url: aString;
 
- 	yourself
 
- ! !
 
- !BlockClosure methodsFor: '*JQuery'!
 
- appendToJQuery: aJQuery
 
- 	self value: (HTMLCanvas onJQuery: aJQuery)
 
- ! !
 
- !String methodsFor: '*JQuery'!
 
- asJQuery
 
-     ^JQuery fromString: self
 
- !
 
- appendToJQuery: aJQuery
 
-     <aJQuery._appendElement_(String(self))>
 
- ! !
 
- !HTMLCanvas methodsFor: '*JQuery'!
 
- appendToJQuery: aJQuery
 
-     aJQuery appendElement: root element
 
- ! !
 
 
  |