|
@@ -2,18 +2,18 @@ define(["amber/boot", "amber_core/Kernel-Collections", "amber_core/Kernel-Infras
|
|
|
if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
|
|
|
var $core=$boot.api,nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
|
|
|
if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
|
|
|
-$core.addPackage('Silk');
|
|
|
+$core.addPackage("Silk");
|
|
|
$core.packages["Silk"].innerEval = function (expr) { return eval(expr); };
|
|
|
$core.packages["Silk"].transport = {"type":"amd","amdNamespace":"silk"};
|
|
|
|
|
|
-$core.addClass('Silk', $globals.Domite, [], 'Silk');
|
|
|
+$core.addClass("Silk", $globals.Domite, [], "Silk");
|
|
|
//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
$globals.Silk.comment="I am subclass of `Domite` with more convenient high-level API.\x0a\x0a##Rendering\x0a\x0a - `aSilk << anObject` uses double-dispatch via `renderOnSilk:`.\x0aThis allows to create widgets\x0a(no formal superclass, anything with `renderOnSilk:` is a widget),\x0aas well as incorporating magic on certain types of objects:\x0a - blocks: `aSilk << aBlock` runs the block, passing aSilk as a parameter.\x0a - associations: `aSilk << (key -> value)` set attribute key to value.\x0a\x0aWorthful to note is, rendering a collection has its magic\x0aalready built-in (via `putOn:`) -- if you `stream << aCollection`,\x0aits items are `<<`'d in sequence.\x0aSo, de facto, arrays are deeply flattened when put on a stream via `<<`.\x0a\x0a##Convenience\x0a\x0a - `aCssSelectorString asSilk` returns Silk wrapping an element at a selector.\x0a - `anObject inSilk` returns anObject rendered in a document fragment.\x0a\x0a##Element creation\x0a\x0aThese messages use DNU to dynamically create\x0aelements with any (letters-and-numbers) tag name,\x0aNext samples show this on an example of `<div>`.\x0a\x0a - `Silk DIV` is shortcut for `Silk newElement: 'div'`.\x0a - `aSilk DIV` is shortcut for\x0a`[ |tmp| tmp := Silk DIV. aSilk << tmp. tmp] value`.\x0aIOW, it not just creates the element and returns it,\x0abut also puts in on aSilk.\x0a - `aSilk DIV: anObject` is shortcut for\x0a`aSilk DIV << anObject; yourself`.\x0aIOW, it not just creates and inserts the element,\x0abut puts a content into it.\x0a\x0a##Conclusions\x0a\x0aTaken all this together, one can do pretty neat constructs:\x0a\x0a```\x0a aSilk P: { 'id'->'mission'. 'We are the champions.' }\x0a```\x0a\x0aadds `<p id=\x22mission\x22>We are the champions.</p>` into `aSilk`\x0aand returns the Silk-wrapped `<p>` with insertion cursor at the end.";
|
|
|
//>>excludeEnd("ide");
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "doesNotUnderstand:",
|
|
|
-protocol: 'writing',
|
|
|
+protocol: "writing",
|
|
|
fn: function (aMessage){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -54,7 +54,7 @@ $globals.Silk);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "nextPut:",
|
|
|
-protocol: 'writing',
|
|
|
+protocol: "writing",
|
|
|
fn: function (anObject){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -92,7 +92,7 @@ $globals.Silk);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "doesNotUnderstand:",
|
|
|
-protocol: 'message handling',
|
|
|
+protocol: "message handling",
|
|
|
fn: function (aMessage){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -128,7 +128,7 @@ $globals.Silk.klass);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "tryMakeDnuElement:",
|
|
|
-protocol: 'instance creation',
|
|
|
+protocol: "instance creation",
|
|
|
fn: function (aMessage){
|
|
|
var self=this;
|
|
|
var selector,newElement,useArg;
|
|
@@ -180,7 +180,7 @@ $globals.Silk.klass);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "renderOnSilk:",
|
|
|
-protocol: '*Silk',
|
|
|
+protocol: "*Silk",
|
|
|
fn: function (aSilk){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -204,7 +204,7 @@ $globals.Association);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "renderOnSilk:",
|
|
|
-protocol: '*Silk',
|
|
|
+protocol: "*Silk",
|
|
|
fn: function (aSilk){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -228,7 +228,7 @@ $globals.BlockClosure);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "asSilk",
|
|
|
-protocol: '*Silk',
|
|
|
+protocol: "*Silk",
|
|
|
fn: function (){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -251,7 +251,7 @@ $globals.CharacterArray);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "inSilk",
|
|
|
-protocol: '*Silk',
|
|
|
+protocol: "*Silk",
|
|
|
fn: function (){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -277,7 +277,7 @@ $globals.JSObjectProxy);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "renderOnSilk:",
|
|
|
-protocol: '*Silk',
|
|
|
+protocol: "*Silk",
|
|
|
fn: function (aSilk){
|
|
|
var self=this;
|
|
|
return nil;
|
|
@@ -295,7 +295,7 @@ $globals.JSObjectProxy);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "inSilk",
|
|
|
-protocol: '*Silk',
|
|
|
+protocol: "*Silk",
|
|
|
fn: function (){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -321,7 +321,7 @@ $globals.Object);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "renderOnSilk:",
|
|
|
-protocol: '*Silk',
|
|
|
+protocol: "*Silk",
|
|
|
fn: function (aSilk){
|
|
|
var self=this;
|
|
|
return nil;
|
|
@@ -339,7 +339,7 @@ $globals.Object);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "attrPut:on:",
|
|
|
-protocol: '*Silk',
|
|
|
+protocol: "*Silk",
|
|
|
fn: function (anObject,aSilk){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|