|
@@ -10,19 +10,19 @@ define(["amber/boot"
|
|
|
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('Web-Snippets');
|
|
|
+$core.addPackage("Web-Snippets");
|
|
|
$core.packages["Web-Snippets"].innerEval = function (expr) { return eval(expr); };
|
|
|
$core.packages["Web-Snippets"].imports = ["amber/jquery/Wrappers-JQuery", "amber_core/Platform-DOM"];
|
|
|
$core.packages["Web-Snippets"].transport = {"type":"amd","amdNamespace":"amber/web"};
|
|
|
|
|
|
-$core.addClass('HTMLSnippet', $globals.Object, ['snippets'], 'Web-Snippets');
|
|
|
+$core.addClass("HTMLSnippet", $globals.Object, ["snippets"], "Web-Snippets");
|
|
|
//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
$globals.HTMLSnippet.comment="My sole instance is the registry of html snippets.\x0a`HTMLSnippet current` is the public singleton instance.\x0a\x0aOn startup, it scans the document for any html elements\x0awith `'data-snippet=\x22foo\x22'` attribute and takes them off the document,\x0aremembering them in the store under the specified name.\x0aIt also install method #foo into HTMLCanvas dynamically.\x0a\x0aEvery html snippet should mark a 'caret', a place where contents\x0acan be inserted, by 'data-snippet=\x22*\x22' (a special name for caret).\x0aFor example:\x0a\x0a`<li data-snippet='menuelement' class='...'><a data-snippet='*'></a></li>`\x0a\x0adefines a list element with a link inside; the link itself is marked as a caret.\x0a\x0aYou can later issue\x0a\x0a`html menuelement href: '/foo'; with: 'A foo'`\x0a\x0ato insert the whole snippet and directly manipulate the caret, so it renders:\x0a\x0a`<li class='...'><a href='/foo'>A foo</a></li>`\x0a\x0aFor a self-careting tags (not very useful, but you do not need to fill class etc.\x0ayou can use\x0a\x0a`<div class='lots of classes' attr1='one' attr2='two' data-snippet='*bar'></div>`\x0a\x0aand in code later do:\x0a\x0a`html bar with: [ xxx ]`\x0a\x0ato render\x0a\x0a`<div class='lots of classes' attr1='one' attr2='two'>...added by xxx...</div>`";
|
|
|
//>>excludeEnd("ide");
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "initializeFromJQuery:",
|
|
|
-protocol: 'initialization',
|
|
|
+protocol: "initialization",
|
|
|
fn: function (aJQuery){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -54,7 +54,7 @@ $globals.HTMLSnippet);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "installSnippetFromJQuery:",
|
|
|
-protocol: 'snippet installation',
|
|
|
+protocol: "snippet installation",
|
|
|
fn: function (element){
|
|
|
var self=this;
|
|
|
var name;
|
|
@@ -92,7 +92,7 @@ $globals.HTMLSnippet);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "snippetAt:",
|
|
|
-protocol: 'accessing',
|
|
|
+protocol: "accessing",
|
|
|
fn: function (aString){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -115,7 +115,7 @@ $globals.HTMLSnippet);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "snippetAt:compile:",
|
|
|
-protocol: 'method generation',
|
|
|
+protocol: "method generation",
|
|
|
fn: function (aString,anElement){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -147,7 +147,7 @@ $globals.HTMLSnippet);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "snippetAt:install:",
|
|
|
-protocol: 'snippet installation',
|
|
|
+protocol: "snippet installation",
|
|
|
fn: function (aString,anElement){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -172,7 +172,7 @@ $globals.HTMLSnippet);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "snippets",
|
|
|
-protocol: 'accessing',
|
|
|
+protocol: "accessing",
|
|
|
fn: function (){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -202,7 +202,7 @@ $globals.HTMLSnippet);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "snippetsFromJQuery:",
|
|
|
-protocol: 'private',
|
|
|
+protocol: "private",
|
|
|
fn: function (aJQuery){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -223,11 +223,11 @@ messageSends: ["toArray", "find:"]
|
|
|
$globals.HTMLSnippet);
|
|
|
|
|
|
|
|
|
-$globals.HTMLSnippet.klass.iVarNames = ['current'];
|
|
|
+$globals.HTMLSnippet.klass.iVarNames = ["current"];
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "current",
|
|
|
-protocol: 'instance creation',
|
|
|
+protocol: "instance creation",
|
|
|
fn: function (){
|
|
|
var self=this;
|
|
|
return self["@current"];
|
|
@@ -245,7 +245,7 @@ $globals.HTMLSnippet.klass);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "ensureCurrent",
|
|
|
-protocol: 'initialization',
|
|
|
+protocol: "initialization",
|
|
|
fn: function (){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -285,7 +285,7 @@ $globals.HTMLSnippet.klass);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "initialize",
|
|
|
-protocol: 'initialization',
|
|
|
+protocol: "initialization",
|
|
|
fn: function (){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -321,7 +321,7 @@ $globals.HTMLSnippet.klass);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "new",
|
|
|
-protocol: 'instance creation',
|
|
|
+protocol: "instance creation",
|
|
|
fn: function (){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -345,7 +345,7 @@ $globals.HTMLSnippet.klass);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "asSnippet",
|
|
|
-protocol: '*Web-Snippets',
|
|
|
+protocol: "*Web-Snippets",
|
|
|
fn: function (){
|
|
|
var self=this;
|
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -368,7 +368,7 @@ $globals.CharacterArray);
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "snippet:",
|
|
|
-protocol: '*Web-Snippets',
|
|
|
+protocol: "*Web-Snippets",
|
|
|
fn: function (anElement){
|
|
|
var self=this;
|
|
|
var clone,caret;
|