Browse Source

Merge pull request #35 from amber-smalltalk/silk

Add Silk as one of web manipulating possibilities
Herbert Vojčík 9 years ago
parent
commit
7384ffb0db
6 changed files with 67 additions and 7 deletions
  1. 1 0
      root/index.html
  2. 7 0
      root/parts.html
  3. 38 5
      root/src/name.js
  4. 6 1
      root/src/name.st
  5. 12 0
      root/uninstall.html
  6. 3 1
      template.js

+ 1 - 0
root/index.html

@@ -15,6 +15,7 @@
   <a href="uninstall.html">cleaned up</a>
   once you start developing your own  app / lib.</p>
   <button id="amber-with">Hello from TagBrush >> with:</button>
+  <button id="silk-tag">Hello from Silk >> TAG:</button>
   <button id="jquery-append">Hello from jQuery append</button>
   <ol id="output-list"></ol>
   <script type='text/javascript'>

+ 7 - 0
root/parts.html

@@ -18,6 +18,13 @@
           providing <code>Web</code> package
           that allows for DOM manipulation
           and is inspired by Seaside.</li>
+      <li><code>amber-contrib-domite</code> module,
+          providing Amber-native DOM wrapper.</li>
+      <li><code>silk</code> module,
+          providing <code>Silk</code> package
+          that allows for DOM manipulation,
+          is meant as alternative to <code>Web</code>
+          and is inspired by stream metaphor and mochikit.</li>
   </ul>
   </body>
 

+ 38 - 5
root/src/name.js

@@ -1,6 +1,6 @@
 define("{%= namespace %}/{%= name %}", ["amber/boot"
 //>>excludeStart("imports", pragmas.excludeImports);
-, "amber/web/Web", "amber/jquery/Wrappers-JQuery"
+, "amber/jquery/Wrappers-JQuery", "amber/web/Web", "silk/Silk"
 //>>excludeEnd("imports");
 , "amber_core/Kernel-Objects"], function($boot
 //>>excludeStart("imports", pragmas.excludeImports);
@@ -10,7 +10,7 @@ define("{%= namespace %}/{%= name %}", ["amber/boot"
 var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
 $core.addPackage('{%= name %}');
 $core.packages["{%= name %}"].innerEval = function (expr) { return eval(expr); };
-$core.packages["{%= name %}"].imports = ["amber/jquery/Wrappers-JQuery", "amber/web/Web"];
+$core.packages["{%= name %}"].imports = ["amber/jquery/Wrappers-JQuery", "amber/web/Web", "silk/Silk"];
 $core.packages["{%= name %}"].transport = {"type":"amd","amdNamespace":"{%= namespace %}"};
 
 $core.addClass('{%= name %}', $globals.Object, [], '{%= name %}');
@@ -40,13 +40,22 @@ return self._doAmberWith();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["click:"]=1;
 //>>excludeEnd("ctx");
+$recv("#silk-tag"._asSilk())._on_bind_("click",(function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return self._doSilkTAG();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
+//>>excludeEnd("ctx");
+}));
 $recv("#jquery-append"._asJQuery())._click_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
 return self._doJQueryAppend();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
 //>>excludeEnd("ctx");
 }));
 return self;
@@ -56,10 +65,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "augmentPage\x0a\x09'#amber-with' asJQuery click: [ self doAmberWith ].\x0a\x09'#jquery-append' asJQuery click: [ self doJQueryAppend ]",
+source: "augmentPage\x0a\x09'#amber-with' asJQuery click: [ self doAmberWith ].\x0a\x09'#silk-tag' asSilk on: #click bind: [ self doSilkTAG ].\x0a\x09'#jquery-append' asJQuery click: [ self doJQueryAppend ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["click:", "asJQuery", "doAmberWith", "doJQueryAppend"]
+messageSends: ["click:", "asJQuery", "doAmberWith", "on:bind:", "asSilk", "doSilkTAG", "doJQueryAppend"]
 }),
 $globals.{%= name %});
 
@@ -125,6 +134,30 @@ messageSends: ["append:", "asJQuery"]
 }),
 $globals.{%= name %});
 
+$core.addMethod(
+$core.method({
+selector: "doSilkTAG",
+protocol: 'action',
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$recv("#output-list"._asSilk())._LI_("Silk TAG: added me!");
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"doSilkTAG",{},$globals.{%= name %})});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "doSilkTAG\x0a\x09'#output-list' asSilk LI: 'Silk TAG: added me!'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["LI:", "asSilk"]
+}),
+$globals.{%= name %});
+
 
 $core.addMethod(
 $core.method({

+ 6 - 1
root/src/name.st

@@ -1,5 +1,5 @@
 Smalltalk createPackage: '{%= name %}'!
-(Smalltalk packageAt: '{%= name %}') imports: {'amber/jquery/Wrappers-JQuery'. 'amber/web/Web'}!
+(Smalltalk packageAt: '{%= name %}') imports: {'amber/jquery/Wrappers-JQuery'. 'amber/web/Web'. 'silk/Silk'}!
 Object subclass: #{%= name %}
 	instanceVariableNames: ''
 	package: '{%= name %}'!
@@ -14,12 +14,17 @@ doAmberWith
 
 doJQueryAppend
 	'#output-list' asJQuery append: '<li>jQuery append added me!!</li>'
+!
+
+doSilkTAG
+	'#output-list' asSilk LI: 'Silk TAG: added me!!'
 ! !
 
 !{%= name %} methodsFor: 'starting'!
 
 augmentPage
 	'#amber-with' asJQuery click: [ self doAmberWith ].
+	'#silk-tag' asSilk on: #click bind: [ self doSilkTAG ].
 	'#jquery-append' asJQuery click: [ self doJQueryAppend ]
 ! !
 

+ 12 - 0
root/uninstall.html

@@ -30,6 +30,18 @@
           from your CLI.</li>
       <li>You cannot remove just the jQuery wrapper and retain the Web package,
           as it depends on the jQuery wrapper.</li>
+      <li>If you aren't going to use <code>Silk</code>
+          package from <code>silk</code> module,
+          but want to retain <code>DOMite</code> DOM wrapper,
+          you should run <code>bower uninstall silk --save</code>
+          from your CLI.</li>
+      <li>If you aren't going to use the <code>Silk</code>
+          package from the <code>silk</code> module,
+          nor the DOM wrapper from <code>amber-contrib-domite</code>,
+          you should run <code>bower uninstall silk amber-contrib-domite --save</code>
+          from your CLI.</li>
+      <li>You cannot remove just the <code>DOMite</code> DOM wrapper
+          and retain the Silk package, as it depends on <code>domite</code>.</li>
       <li>As the last step, make sure the dependency tree is in a correct state
           by recreating it: first delete your <code>bower_components</code> folder,
           then run <code>bower install</code> from your CLI.</li>

+ 3 - 1
template.js

@@ -159,7 +159,9 @@ exports.template = function (grunt, init, done) {
             "dependencies": {
                 "amber": "^0.14.14",
                 "amber-contrib-jquery": ">=0.1.0",
-                "amber-contrib-web": ">=0.1.0"
+                "amber-contrib-web": ">=0.1.0",
+                "amber-contrib-domite": ">=0.3.1",
+                "silk": ">=0.1.3"
             },
             "devDependencies": {
                 "amber-ide-starter-dialog": "^0.1.0",