Skip to content

Commit

Permalink
Added jQuery-Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrichau committed Aug 23, 2023
1 parent b414e02 commit 86cadb9
Show file tree
Hide file tree
Showing 31 changed files with 198 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ baselinejquery: spec
spec requires: #('Javascript-Core' ) ];
package: 'JQuery-Tests-Core' with: [
spec requires: #('JQuery-Core' 'Javascript-Tests-Core' 'Seaside-Development' 'Seaside-Tests-Functional' 'Seaside-Ajaxifier-Core') ];
package: 'JQuery-Examples' with: [
spec requires: #('JQuery-Core') ];
package: 'JQuery-JSON' with: [
spec requires: #('JQuery-Core' 'Seaside-JSON-Core') ];
package: 'JQuery-Tests-JSON' with: [
Expand All @@ -16,4 +18,5 @@ baselinejquery: spec
spec
group: 'JQuery' with: #('JQuery-Core' 'JQuery-JSON');
group: 'JQuery Tests' with: #('JQuery-Tests-Core' 'JQuery-Tests-JSON');
group: 'Examples' with: #('JQuery-Examples');
group: 'Tests' with: #( 'JQuery Tests' ) ]
5 changes: 5 additions & 0 deletions repository/JQuery-Examples.package/.filetree
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"separateMethodMetaAndSource" : false,
"noMethodMetaData" : true,
"useCypressPropertiesFile" : true
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
initialization
initialize
(WAAdmin register: self asApplicationAt: '/examples/todo-jquery')
exceptionHandler: WADebugErrorHandler;
addLibrary: WAExamplesLibrary
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
actions
addTodo: aString
| newTodo |
newTodo := WATodoWithJQueryItem newWithDescription: aString in: todos.
todos add: newTodo.
^ newTodo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
children
^ self todos
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
initialization
initialize
super initialize.
todos := OrderedCollection new.
1 to: 5000 do: [ :index |
self addTodo: 'Task ', index greaseString ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rendering
renderAddNewTodoOn: html
| newTodo |
html header
id: #header;
with: [
html heading
level: 1;
with: 'todos'.
html textInput
id: #'new-todo';
autofocus;
attributeAt: 'autocomplete' put: 'off';
callback: [ :value | newTodo := self addTodo: value ];
onChange: (html jQuery ajax
serializeThis;
script: [ :s | s << ((s jQuery id: 'todo-list') append: newTodo) ];
onComplete: ((html jQuery id: #'new-todo') value: ''));
placeholder: 'What needs to be done?' ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rendering
renderContentOn: html
html section
id: #todoapp;
with: [
self renderAddNewTodoOn: html.
self renderTodosOn: html ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rendering
renderTodosOn: html

html section
id: 'main';
with: [
html checkbox
id: 'toggle-all'.
html label
for: 'toggle-all';
with: 'Mark all as complete'.
html unorderedList
id: 'todo-list';
script: (self scriptToTriggerCheckboxToggleOn: html);
script: (self scriptToTriggerRenameOn: html);
script: (self scriptToTriggerEditOn: html);
script: (self scriptToSerializeEditOn: html);
with: [
self todos do: [ :todoItem | todoItem renderOn: html ] ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rendering
scriptToSerializeEditOn: html

| currentItem itemId |
^ html jQuery this
on: 'change'
selector:'.edit'
do: ((
html jQuery ajax
serialize: (html jQuery expression: (JSStream on:'event.target'));
callback: [ :passengers | currentItem := passengers first ]
passengers: ((html jQuery expression: (JSStream on:'event.target')) closest:'li');
callback: [ :id | itemId := id ]
value: (JSStream on:'$(event.target).closest("li").get(0).id');
script: [ :s | s << (((s jQuery id: itemId) find: 'label') html: currentItem description) ];
onComplete: ((((html jQuery expression: (JSStream on: 'event.target')) closest:'li') find: '.edit') hide, (((html jQuery expression: (JSStream on: 'event.target')) closest:'li') find: 'label') show))
asFunction: #(event))
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rendering
scriptToTriggerCheckboxToggleOn: html

^ html jQuery this
on: 'click'
selector: '.toggle'
do: ((html jQuery ajax serializeWithHidden: (html jQuery expression: (JSStream on: 'event.target'))) asFunction: #(event))
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rendering
scriptToTriggerEditOn: html

^ html jQuery this
on: 'click'
selector: '.view>label'
do: (((((html jQuery expression: (JSStream on: 'event.target')) hide closest:'li') find: '.edit') show) asFunction:#(event))
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rendering
scriptToTriggerRenameOn: html

^ html jQuery this
on: 'click'
selector: '.destroy'
do: ((html jQuery ajax
callback: [ :passengers | passengers first remove ]
passengers: (((html jQuery expression: (JSStream on:'event.target')) closest: 'li'));
onComplete: (((html jQuery expression: (JSStream on:'event.target')) closest: 'li') remove)) asFunction: #(event))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
todos
^ todos
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rendering
updateRoot: aRoot

super updateRoot: aRoot.
aRoot stylesheet url: WAExamplesLibrary / #todoCss.
aRoot javascript url: JQDeploymentLibrary / #jQueryJs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"commentStamp" : "",
"super" : "WAExampleComponent",
"category" : "JQuery-Examples",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"todos"
],
"name" : "WATodoWithJQuery",
"type" : "normal"
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
newWithDescription: aString in: aCollection
^ self new initializeWithDescription: aString in: aCollection
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
description: anObject
description := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
description
^ description
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
done: anObject
done := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
done
^ done
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
initialization
initializeWithDescription: aString in: aCollection
self initialize.
self done: false.
self description: aString.
todos := aCollection
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
private
remove
todos remove: self
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
rendering
renderContentOn: html
html listItem
passenger: self;
with: [
html div
class: 'view';
with:[
html checkbox
class: 'toggle';
callback: [ :value | self done: value ];
value: done.
html label: description.
html button
class: 'destroy' ].
html textInput
class: 'edit';
style: 'display:none';
callback: [ :value | self description: value ];
value: description ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"commentStamp" : "",
"super" : "WAComponent",
"category" : "JQuery-Examples",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"todos",
"description",
"done"
],
"name" : "WATodoWithJQueryItem",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SystemOrganization addCategory: #'JQuery-Examples'!
Empty file.
1 change: 1 addition & 0 deletions repository/JQuery-Examples.package/monticello.meta/package
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(name 'JQuery-Examples')
1 change: 1 addition & 0 deletions repository/JQuery-Examples.package/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ }

0 comments on commit 86cadb9

Please sign in to comment.