|
@@ -6,7 +6,7 @@ $core.packages["Silk"].transport = {"type":"amd","amdNamespace":"silk"};
|
|
|
|
|
|
$core.addClass('Silk', $globals.Domite, [], 'Silk');
|
|
|
|
|
|
-$globals.Silk.comment="I am adding convenience APIs to my subclass, `Domite`.\x0a\x0a##Rendering\x0a\x0a - `aSilk << anObject` uses double-dispatch via `renderOnSilk:`. This allows creating widgets (no formal superclass, anything with `renderOnSilk:` is a widget), as well as incorporating blocks: `aSilk << aBlock` runs the block, passing aSilk as a parameter.\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.";
|
|
|
+$globals.Silk.comment="I am adding convenience APIs to my subclass, `Domite`.\x0a\x0a##Rendering\x0a\x0a - `aSilk << anObject` uses double-dispatch via `renderOnSilk:`. This allows creating widgets (no formal superclass, anything with `renderOnSilk:` is a widget), as well as incorporating blocks: `aSilk << aBlock` runs the block, passing aSilk as a parameter.\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'`.";
|
|
|
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
@@ -46,6 +46,60 @@ messageSends: ["ifNil:", "renderOnSilk:", "nextPut:"]
|
|
|
$globals.Silk);
|
|
|
|
|
|
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "doesNotUnderstand:",
|
|
|
+protocol: 'message handling',
|
|
|
+fn: function (aMessage){
|
|
|
+var self=this;
|
|
|
+var selector;
|
|
|
+
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
+
|
|
|
+var $1,$2,$3,$4,$5;
|
|
|
+selector=$recv(aMessage)._selector();
|
|
|
+$1=$recv($recv(selector)._asUppercase()).__eq(selector);
|
|
|
+if(!$core.assert($1)){
|
|
|
+$2=(
|
|
|
+
|
|
|
+$ctx1.supercall = true,
|
|
|
+
|
|
|
+$globals.Silk.klass.superclass.fn.prototype._doesNotUnderstand_.apply($recv(self), [aMessage]));
|
|
|
+
|
|
|
+$ctx1.supercall = false;
|
|
|
+
|
|
|
+
|
|
|
+$ctx1.sendIdx["doesNotUnderstand:"]=1;
|
|
|
+
|
|
|
+return $2;
|
|
|
+};
|
|
|
+$3=$recv(selector)._includes_(":");
|
|
|
+if($core.assert($3)){
|
|
|
+$4=(
|
|
|
+
|
|
|
+$ctx1.supercall = true,
|
|
|
+
|
|
|
+$globals.Silk.klass.superclass.fn.prototype._doesNotUnderstand_.apply($recv(self), [aMessage]));
|
|
|
+
|
|
|
+$ctx1.supercall = false;
|
|
|
+
|
|
|
+return $4;
|
|
|
+};
|
|
|
+$5=self._newElement_($recv(selector)._asLowercase());
|
|
|
+return $5;
|
|
|
+
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"doesNotUnderstand:",{aMessage:aMessage,selector:selector},$globals.Silk.klass)});
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+args: ["aMessage"],
|
|
|
+source: "doesNotUnderstand: aMessage\x0a\x09\x22`Silk DIV` creates a div element\x22\x0a\x09| selector |\x0a\x09selector := aMessage selector.\x0a\x09selector asUppercase = selector\x0a\x09\x09ifFalse: [ ^ super doesNotUnderstand: aMessage ].\x0a\x09(selector includes: ':')\x0a\x09\x09ifTrue: [ ^ super doesNotUnderstand: aMessage ].\x0a\x09^ self newElement: selector asLowercase",
|
|
|
+referencedClasses: [],
|
|
|
+
|
|
|
+messageSends: ["selector", "ifFalse:", "=", "asUppercase", "doesNotUnderstand:", "ifTrue:", "includes:", "newElement:", "asLowercase"]
|
|
|
+}),
|
|
|
+$globals.Silk.klass);
|
|
|
+
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "renderOnSilk:",
|