Ver Fonte

Merge pull request #64 from lolgzs/master

Nicer examples list + Presentation navigator
Nicolas Petton há 12 anos atrás
pai
commit
143abe8217

+ 18 - 0
css/style.css

@@ -267,6 +267,24 @@ h1 {
 	border: 1px solid #919293; 
 }
 
+
+.examples li {
+	list-style: none;
+	float: left;
+}
+
+.examples li img {
+		border-radius: 5px;
+		border: 5px solid rgba(0,0,0,0.4);
+		margin: 5px;
+}
+
+.examples a:hover img {
+		border-color: rgba(0,0,0,0.8);
+}
+
+
+
 #footer {
 	height: 200px;
 	border: 1px solid #ccc;

Diff do ficheiro suprimidas por serem muito extensas
+ 14 - 101
examples/presentation/js/Presentation.deploy.js


Diff do ficheiro suprimidas por serem muito extensas
+ 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
+! !
+

BIN
images/presentation.png


BIN
images/profstef.png


BIN
images/twitterwall.png


+ 103 - 90
index.html

@@ -8,95 +8,108 @@
     <link rel="stylesheet" type="text/css" href='css/style.css' /> 
     <link type="image/x-icon" rel="shortcut icon" href="/favicon.ico"/> 
     <link href='http://fonts.googleapis.com/css?family=Istok+Web' rel='stylesheet' type='text/css'> 
-    <script type='text/javascript' src='js/amber.js'></script> 
-  </head> 
-  <body> 
-    
-    <a href="http://github.com/NicolasPetton/amber"><img style="position: absolute; top: 0; lef
-								t: 0; border: 0;" src="https://assets.github.com/img/bec6c51521dcc8148146135149fe06a9cc737577?repo=&url=http%3A%2F%2Fs3.amazonaws.com%2Fgithub%2Fribbons%2Fforkme_left_darkblue_121621.png&path=" alt="Fork me on GitHub"></a> 
-    
-    <div id="wrapper"> 
-      
-      <div id="header"> 
-	<div class="main"> 
-	  <div class="logo"> 
-	    <img src="images/amber.png"/> 
-	  </div> 
-	  
-	  <ul id="tabs"> 
-	    <li><a target="_blank" href="http://amber-lang.net/index.html">Overview</a></li> · 
-	    <li><a target="_blank" href="http://amber-lang.net/index.html#download">Download</a></li> · 
-	    <li><a target="_blank" href="http://amber-lang.net/learn.html">Learn</a></li> ·
-	    <li><a target="_blank" href="http://amber-lang.net/documentation.html">Documentation</a></li> ·
-	    <li><a target="_blank" target="_blank" href="https://github.com/NicolasPetton/amber">Source</a></li> 
-	  </ul> 
-	  
-	  <div class="clear"></div> 
-	  
-	</div> 
-      </div> 
-      
-      <div class="teaser"> 
-	<div class="main"> 
-	  <h1>Welcome aboard!</h1> 
-	  <div class="column">
-	    <h2>What is Amber?</h2>
-	    <p>Amber, formerly known as Jtalk, is an implementation of the Smalltalk-80 language. It is designed to make client-side development faster and easier. It allows developers to write client-side heavy web applications in Smalltalk. </p> 
-	    <p>Amber includes an integrated development environment with a class browser, workspace, transcript, object inspector and debugger.</p> 
-	    <p>Amber is written in itself, including the compiler, and compiles into efficient JavaScript, mapping one-to-one with the JS equivalent.</p> 
-	    <h2>Give it a try!</h2>
-	    <p><b>Try a <button onClick="smalltalk.Browser._open()"> Class browser</button> right now!</b></p> 
-	  </div> 
-	  <div class="column">
-	    <h2>Getting started</h2>
-	    <p>The <a href="https://github.com/NicolasPetton/amber/wiki">Wiki on GitHub</a> includes a <a href="https://github.com/NicolasPetton/amber/wiki/Getting-started">Getting started</a> tutorial for OSX, Linux and Windows.</p>
-	    <p>If you're new to Smalltalk, You can learn it online with <a href="http://amber-lang.net/learn.html">ProfStef</a>.</p>
-	    <h2>Join the community</h2>
-	    <ul>
-	      <li><a href="http://amber-lang.net">Amber's website</a></li>
-	      <li><a href="https://github.com/NicolasPetton/amber/wiki">Wiki on GitHub</a></li>
-	      <li><a href="http://groups.google.com/group/amber-lang">Mailing list</a></li>
-	      <li>Join us on IRC at #amber-lang on Freenode</li>
-	    </ul>
-	  </div>
-	  <div class="clear"></div> 
-	</div> 
-	
-	
-      </div> 
-      
-      <div id="content"> 
-	<div class="main"> 
-	  <div class="box"> 
-	    <h2>Client-side usage</h2> 
-	    <div class="content"> 
-	      <p>Load the full Amber Smalltalk environment with the IDE in your page:</p> 
-	      
-	      <code><pre>&lt;script src="js/amber.js" type="text/javascript"&gt;&lt;/script&gt;
+			<script type='text/javascript' src='js/amber.js'></script> 
+		</head> 
+		<body> 
+			
+			<a href="http://github.com/NicolasPetton/amber"><img style="position: absolute; top: 0; lef
+			t: 0; border: 0;" src="https://assets.github.com/img/bec6c51521dcc8148146135149fe06a9cc737577?repo=&url=http%3A%2F%2Fs3.amazonaws.com%2Fgithub%2Fribbons%2Fforkme_left_darkblue_121621.png&path=" alt="Fork me on GitHub"></a> 
+			
+			<div id="wrapper"> 
+				
+				<div id="header"> 
+					<div class="main"> 
+						<div class="logo"> 
+							<img src="images/amber.png"/> 
+						</div> 
+						
+						<ul id="tabs"> 
+							<li><a target="_blank" href="http://amber-lang.net/index.html">Overview</a></li> · 
+							<li><a target="_blank" href="http://amber-lang.net/index.html#download">Download</a></li> · 
+							<li><a target="_blank" href="http://amber-lang.net/learn.html">Learn</a></li> ·
+							<li><a target="_blank" href="http://amber-lang.net/documentation.html">Documentation</a></li> ·
+							<li><a target="_blank" target="_blank" href="https://github.com/NicolasPetton/amber">Source</a></li> 
+						</ul> 
+						
+						<div class="clear"></div> 
+						
+					</div> 
+				</div> 
+				
+				<div class="teaser"> 
+					<div class="main"> 
+						<h1>Welcome aboard!</h1> 
+						<div class="column">
+							<h2>What is Amber?</h2>
+							<p>Amber, formerly known as Jtalk, is an implementation of the Smalltalk-80 language. It is designed to make client-side development faster and easier. It allows developers to write client-side heavy web applications in Smalltalk. </p> 
+							<p>Amber includes an integrated development environment with a class browser, workspace, transcript, object inspector and debugger.</p> 
+							<p>Amber is written in itself, including the compiler, and compiles into efficient JavaScript, mapping one-to-one with the JS equivalent.</p> 
+							<h2>Give it a try!</h2>
+							<p><b>Try a <button onClick="smalltalk.Browser._open()"> Class browser</button> right now!</b></p> 
+						</div> 
+						<div class="column">
+							<h2>Getting started</h2>
+							<p>The <a href="https://github.com/NicolasPetton/amber/wiki">Wiki on GitHub</a> includes a <a href="https://github.com/NicolasPetton/amber/wiki/Getting-started">Getting started</a> tutorial for OSX, Linux and Windows.</p>
+							<p>If you're new to Smalltalk, You can learn it online with <a href="http://amber-lang.net/learn.html">ProfStef</a>.</p>
+							<h2>Join the community</h2>
+							<ul>
+								<li><a href="http://amber-lang.net">Amber's website</a></li>
+								<li><a href="https://github.com/NicolasPetton/amber/wiki">Wiki on GitHub</a></li>
+								<li><a href="http://groups.google.com/group/amber-lang">Mailing list</a></li>
+								<li>Join us on IRC at #amber-lang on Freenode</li>
+							</ul>
+						</div>
+						<div class="clear"></div> 
+					</div> 
+					
+					
+				</div> 
+				
+				<div id="content"> 
+					<div class="main"> 
+						<div class="box"> 
+							<h2>Client-side usage</h2> 
+							<div class="content"> 
+								<p>Load the full Amber Smalltalk environment with the IDE in your page:</p> 
+								
+								<code><pre>&lt;script src="js/amber.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script type="text/javascript"&gt; loadAmber()&lt;/script&gt;</pre></code>
-	    </div> 
-	    
-	    
-	    <p>Or the deployment JavaScript file only (without the Smalltalk sources, parser, compiler and IDE):</p>
-	    <code><pre>&lt;script src="js/amber.js" type="text/javascript"&gt;&lt;/script&gt;
+							</div> 
+							
+							
+							<p>Or the deployment JavaScript file only (without the Smalltalk sources, parser, compiler and IDE):</p>
+							<code><pre>&lt;script src="js/amber.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script type="text/javascript"&gt; loadAmber({deploy: true})&lt;/script&gt;</pre></code>
-	  </div> 
-	  
-	  <div class="box last"> 
-	    <h2 id="download">Examples</h2> 
-	    <div class="content"> 
-	      <ul>
-		<li><a href="examples/trysmalltalk/index.html">ProfStef tutorial</a></li>
-		<li><a href="examples/presentation/index.html">Presentation at ESUG 2011</a></li>
-	      </ul>
-	    </div> 
-	  </div> 
-	  
-	</div> 
-      </div> 
-    </div> 
-    
-    <script type='text/javascript'> loadAmber() </script> 
-    
-  </body> 
-</html> 
+						</div> 
+						
+						<div class="box last examples"> 
+							<h2>Examples</h2> 
+							<div class="content"> 
+								<ul>
+									<li>
+										<a href="examples/trysmalltalk/index.html">
+											<img src="images/profstef.png" alt="Learn Smalltalk with ProfStef"/>
+										</a>
+									</li>
+									<li>
+										<a href="examples/presentation/index.html">
+											<img src="images/presentation.png" alt="ESUG 2011 presentation"/>
+										</a>
+									</li>
+									<li>
+										<a href="examples/twitterwall/index.html">
+											<img src="images/twitterwall.png" alt="Twitter Wall"/>
+										</a>
+									</li>
+								</ul>
+							</div> 
+						</div> 
+						
+					</div> 
+				</div> 
+			</div> 
+			
+			<script type='text/javascript'> loadAmber() </script> 
+			
+		</body> 
+	</html> 

+ 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'!

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff