Browse Source

Presentation: now can list and switch presentation. Running example here: http://lolgzs.free.fr/iae-course/

Laurent Laffont 13 years ago
parent
commit
6fcb8bfce7

File diff suppressed because it is too large
+ 14 - 101
examples/presentation/js/Presentation.deploy.js


File diff suppressed because it is too large
+ 30 - 152
examples/presentation/js/Presentation.js


+ 176 - 93
examples/presentation/st/Presentation.st

@@ -70,7 +70,7 @@ Widget subclass: #Presentation
 !Presentation methodsFor: 'accessing'!
 
 title
-	^'Slides'
+	^ self class title.
 !
 
 author
@@ -117,24 +117,6 @@ style
 
 !Presentation methodsFor: 'actions'!
 
-reload
-	'#slides' asJQuery remove.
-	'#tools' asJQuery remove.
-	self initSlides.
-	self appendToJQuery: 'body' asJQuery.
-	self checkHash
-!
-
-setup
-	Presentation setCurrent: self.
-	(window jQuery: document) ready: [
-		self appendToJQuery: 'body' asJQuery.
-		self 
-			setKeybindings;
-			checkHashChange;
-			checkHash].
-!
-
 nextSlide
 	| next |
 	self currentSlide ifNotNil: [
@@ -161,18 +143,6 @@ previousSlide
 		next ifNotNil: [currentSlide := next. next show]]
 !
 
-setKeybindings
-	(window jQuery: document) keyup: [:e || node |
-		node := e target nodeName asLowercase.
-		(node = 'textarea' or: [node = 'input']) ifFalse: [
-			e keyCode = 39 ifTrue: [self nextSlide].
-			e keyCode = 37 ifTrue: [self previousSlide]]]
-!
-
-checkHashChange
-	(window jQuery: window) bind: 'hashchange' do: [self checkHash]
-!
-
 checkHash
 	| hash slide |
 	hash := document location hash  replace: '^#' with: ''.
@@ -195,9 +165,6 @@ renderOn: html
 	html style
 		type: 'text/css';
 		with: self style.
-	html div 
-		id: 'tools';
-		with: [self renderToolsOn: html].
 	html div 
 		id: 'slides';
 		with: [self renderSlidesOn: html]
@@ -208,41 +175,24 @@ renderSlidesOn: html
 		each renderOn: html].
 	currentSlide ifNil: [currentSlide := self slides first].
 	self showCurrentSlide
-!
-
-renderToolsOn: html
-	html a 
-		with: 'IDE';
-		onClick: [TabManager current open].
-	html a
-		with: 'Reload';
-		onClick: [self reload].
-	html a
-		with: '←';
-		onClick: [self previousSlide].
-	html a
-		with: '→';
-		onClick: [self nextSlide]
 ! !
 
 Presentation class instanceVariableNames: 'current'!
 
-!Presentation class methodsFor: 'initialization'!
+!Presentation class methodsFor: 'accessing'!
 
-initialize
-	self isConcrete ifTrue: [self setup]
+concretePresentations
+	^ self allSubclasses select: [:aPresentationClass| aPresentationClass isConcrete]
 !
 
-setup
-	self new setup
-!
+title
+	^ 'Slides'
+! !
 
-setCurrent: aSlides
-	current := aSlides
-!
+!Presentation class methodsFor: 'enumerating'!
 
-current
-	^current
+concretePresentationsDo: aBlockWithArg
+	self concretePresentations do: aBlockWithArg.
 ! !
 
 !Presentation class methodsFor: 'testing'!
@@ -257,10 +207,6 @@ Presentation subclass: #ESUG2011Presentation
 
 !ESUG2011Presentation methodsFor: 'accessing'!
 
-title
-	^'Jtalk'
-!
-
 description
 	^'ESUG 2011, Edinburgh'
 !
@@ -557,35 +503,6 @@ body {
     padding: 0 5px;
 }
 
-#tools {
-    z-index: 1;
-    position: fixed;
-    top: 0;
-    left: 50%;
-    margin-left: -150px;
-    width: 300px;
-    padding: 5px;
-    border-radius: 5px;
-    -moz-border-radius: 5px;
-    -webkit-border-radius: 5px;
-    background: #333;
-    opacity: 0.3;
-    color: #eee;
-}
-
-#tools a {
-    font-weight: bold;
-    color: #eee;
-    text-decoration: none;
-    cursor: pointer;
-    padding: 0 2px;
-    font-size: 14px;
-}
-
-#tools:hover {
-    opacity: 0.8;
-}
-
 .slide {
     
 }
@@ -594,6 +511,12 @@ body {
 
 ESUG2011Presentation class instanceVariableNames: 'current'!
 
+!ESUG2011Presentation class methodsFor: 'accessing'!
+
+title
+	^'Jtalk'
+! !
+
 !ESUG2011Presentation class methodsFor: 'testing'!
 
 isConcrete
@@ -1156,3 +1079,163 @@ renderSlideOn: html
 		html span class: 'blue'; with: 'Enyo'].
 ! !
 
+Widget subclass: #PresentationNavigator
+	instanceVariableNames: 'presentationBrush currentPresentation'
+	category: 'Presentation'!
+
+!PresentationNavigator methodsFor: 'accessing'!
+
+currentPresentation: aPresentation
+	currentPresentation := aPresentation.
+!
+
+currentPresentation
+	^  currentPresentation ifNil: [currentPresentation := Presentation concretePresentations first new].
+!
+
+style
+	^ '
+#navigator {
+    z-index: 1;
+    position: fixed;
+    top: 0;
+    left: 50%;
+    margin-left: -150px;
+    padding: 5px;
+    border-radius: 5px;
+    -moz-border-radius: 5px;
+    -webkit-border-radius: 5px;
+    background: #333;
+    opacity: 0.3;
+    color: #eee;
+}
+
+#navigator a {
+    font-weight: bold;
+    color: #eee;
+    text-decoration: none;
+    cursor: pointer;
+    padding: 0 2px;
+    font-size: 14px;
+}
+
+#navigator:hover {
+    opacity: 0.8;
+}
+'
+! !
+
+!PresentationNavigator methodsFor: 'callbacks'!
+
+selectPresentation: aPresentationClass
+	self currentPresentation: aPresentationClass new.
+	self renderCurrentPresentation.
+!
+
+selectPresentationNamed: aString
+	self selectPresentation: (Smalltalk current at: aString)
+!
+
+previousSlide
+	self currentPresentation previousSlide
+!
+
+nextSlide
+	self currentPresentation nextSlide
+!
+
+reload
+	self currentPresentation: self currentPresentation class new.
+	self renderCurrentPresentation.
+! !
+
+!PresentationNavigator methodsFor: 'hash'!
+
+checkHash
+	self currentPresentation checkHash
+!
+
+checkHashChange
+	(window jQuery: window) bind: 'hashchange' do: [self checkHash]
+! !
+
+!PresentationNavigator methodsFor: 'keybindings'!
+
+setKeybindings
+	(window jQuery: document) keyup: [:e || node |
+		node := e target nodeName asLowercase.
+		(node = 'textarea' or: [node = 'input']) ifFalse: [
+			e keyCode = 39 ifTrue: [self nextSlide].
+			e keyCode = 37 ifTrue: [self previousSlide]]]
+! !
+
+!PresentationNavigator methodsFor: 'rendering'!
+
+renderToolsOn: html
+	html a 
+		with: 'IDE';
+		onClick: [TabManager current open].
+	html a
+		with: 'Reload';
+		onClick: [self reload].
+	html a
+		with: '←';
+		onClick: [self previousSlide].
+	html a
+		with: '→';
+		onClick: [self nextSlide].
+!
+
+renderPresentationSelectOn: html
+	html select
+		onChange: [:anEvent | self  selectPresentationNamed:  anEvent target value];
+		with: [	Presentation concretePresentationsDo: [:aPresentationClass |   
+                                                              							html option
+                                                              								value: aPresentationClass name;
+                                                              								with: aPresentationClass title ] ].
+!
+
+open
+	(window jQuery: document)  ready: [
+          	self 
+          		appendToJQuery: 'body' asJQuery;
+          		setKeybindings;
+          		checkHashChange.
+        ].
+!
+
+renderOn: html
+	html style
+		type: 'text/css';
+		with: self style.
+	html div
+		id: 'navigator';
+		with: [	self
+					renderToolsOn: html;
+					renderPresentationSelectOn: html	].
+
+	presentationBrush := html div 
+							id: 'presentation';
+							yourself.
+
+	self renderCurrentPresentation.
+!
+
+renderCurrentPresentation
+	presentationBrush contents: [:html |
+        	self currentPresentation
+                                     	renderOn: html;
+                                     	checkHash.
+        ].
+! !
+
+!PresentationNavigator class methodsFor: 'initialize'!
+
+initialize
+	^ self open
+!
+
+open
+	^ self new open
+! !
+

+ 11 - 0
js/Canvas.deploy.js

@@ -972,6 +972,17 @@ return self;}
 }),
 smalltalk.TagBrush);
 
+smalltalk.addMethod(
+'_value_',
+smalltalk.method({
+selector: 'value:',
+fn: function (aString){
+var self=this;
+smalltalk.send(self, "_at_put_", ["value", aString]);
+return self;}
+}),
+smalltalk.TagBrush);
+
 
 smalltalk.addMethod(
 '_fromString_canvas_',

+ 16 - 0
js/Canvas.js

@@ -1407,6 +1407,22 @@ referencedClasses: []
 }),
 smalltalk.TagBrush);
 
+smalltalk.addMethod(
+unescape('_value_'),
+smalltalk.method({
+selector: unescape('value%3A'),
+category: 'attributes',
+fn: function (aString){
+var self=this;
+smalltalk.send(self, "_at_put_", ["value", aString]);
+return self;},
+args: ["aString"],
+source: unescape('value%3A%20aString%0A%20%20%20%20self%20%20at%3A%20%27value%27%20put%3A%20aString'),
+messageSends: ["at:put:"],
+referencedClasses: []
+}),
+smalltalk.TagBrush);
+
 
 smalltalk.addMethod(
 unescape('_fromString_canvas_'),

+ 4 - 0
st/Canvas.st

@@ -337,6 +337,10 @@ width: aString
 
 height: aString
     self  at: 'height' put: aString
+!
+
+value: aString
+    self  at: 'value' put: aString
 ! !
 
 !TagBrush methodsFor: 'converting'!

Some files were not shown because too many files changed in this diff