|
@@ -10,19 +10,19 @@ define(["amber/boot"
|
|
if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
|
|
if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
|
|
var $core=$boot.api,nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
|
|
var $core=$boot.api,nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
|
|
if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
|
|
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"].innerEval = function (expr) { return eval(expr); };
|
|
$core.packages["Web-Snippets"].imports = ["amber/jquery/Wrappers-JQuery", "amber_core/Platform-DOM"];
|
|
$core.packages["Web-Snippets"].imports = ["amber/jquery/Wrappers-JQuery", "amber_core/Platform-DOM"];
|
|
$core.packages["Web-Snippets"].transport = {"type":"amd","amdNamespace":"amber/web"};
|
|
$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);
|
|
//>>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>`";
|
|
$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");
|
|
//>>excludeEnd("ide");
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "initializeFromJQuery:",
|
|
selector: "initializeFromJQuery:",
|
|
-protocol: 'initialization',
|
|
|
|
|
|
+protocol: "initialization",
|
|
fn: function (aJQuery){
|
|
fn: function (aJQuery){
|
|
var self=this;
|
|
var self=this;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -54,7 +54,7 @@ $globals.HTMLSnippet);
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "installSnippetFromJQuery:",
|
|
selector: "installSnippetFromJQuery:",
|
|
-protocol: 'snippet installation',
|
|
|
|
|
|
+protocol: "snippet installation",
|
|
fn: function (element){
|
|
fn: function (element){
|
|
var self=this;
|
|
var self=this;
|
|
var name;
|
|
var name;
|
|
@@ -92,7 +92,7 @@ $globals.HTMLSnippet);
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "snippetAt:",
|
|
selector: "snippetAt:",
|
|
-protocol: 'accessing',
|
|
|
|
|
|
+protocol: "accessing",
|
|
fn: function (aString){
|
|
fn: function (aString){
|
|
var self=this;
|
|
var self=this;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -115,7 +115,7 @@ $globals.HTMLSnippet);
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "snippetAt:compile:",
|
|
selector: "snippetAt:compile:",
|
|
-protocol: 'method generation',
|
|
|
|
|
|
+protocol: "method generation",
|
|
fn: function (aString,anElement){
|
|
fn: function (aString,anElement){
|
|
var self=this;
|
|
var self=this;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -147,7 +147,7 @@ $globals.HTMLSnippet);
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "snippetAt:install:",
|
|
selector: "snippetAt:install:",
|
|
-protocol: 'snippet installation',
|
|
|
|
|
|
+protocol: "snippet installation",
|
|
fn: function (aString,anElement){
|
|
fn: function (aString,anElement){
|
|
var self=this;
|
|
var self=this;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -172,7 +172,7 @@ $globals.HTMLSnippet);
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "snippets",
|
|
selector: "snippets",
|
|
-protocol: 'accessing',
|
|
|
|
|
|
+protocol: "accessing",
|
|
fn: function (){
|
|
fn: function (){
|
|
var self=this;
|
|
var self=this;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -202,7 +202,7 @@ $globals.HTMLSnippet);
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "snippetsFromJQuery:",
|
|
selector: "snippetsFromJQuery:",
|
|
-protocol: 'private',
|
|
|
|
|
|
+protocol: "private",
|
|
fn: function (aJQuery){
|
|
fn: function (aJQuery){
|
|
var self=this;
|
|
var self=this;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -223,11 +223,11 @@ messageSends: ["toArray", "find:"]
|
|
$globals.HTMLSnippet);
|
|
$globals.HTMLSnippet);
|
|
|
|
|
|
|
|
|
|
-$globals.HTMLSnippet.klass.iVarNames = ['current'];
|
|
|
|
|
|
+$globals.HTMLSnippet.klass.iVarNames = ["current"];
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "current",
|
|
selector: "current",
|
|
-protocol: 'instance creation',
|
|
|
|
|
|
+protocol: "instance creation",
|
|
fn: function (){
|
|
fn: function (){
|
|
var self=this;
|
|
var self=this;
|
|
return self["@current"];
|
|
return self["@current"];
|
|
@@ -245,7 +245,7 @@ $globals.HTMLSnippet.klass);
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "ensureCurrent",
|
|
selector: "ensureCurrent",
|
|
-protocol: 'initialization',
|
|
|
|
|
|
+protocol: "initialization",
|
|
fn: function (){
|
|
fn: function (){
|
|
var self=this;
|
|
var self=this;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -285,7 +285,7 @@ $globals.HTMLSnippet.klass);
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "initialize",
|
|
selector: "initialize",
|
|
-protocol: 'initialization',
|
|
|
|
|
|
+protocol: "initialization",
|
|
fn: function (){
|
|
fn: function (){
|
|
var self=this;
|
|
var self=this;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -321,7 +321,7 @@ $globals.HTMLSnippet.klass);
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "new",
|
|
selector: "new",
|
|
-protocol: 'instance creation',
|
|
|
|
|
|
+protocol: "instance creation",
|
|
fn: function (){
|
|
fn: function (){
|
|
var self=this;
|
|
var self=this;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -345,7 +345,7 @@ $globals.HTMLSnippet.klass);
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "asSnippet",
|
|
selector: "asSnippet",
|
|
-protocol: '*Web-Snippets',
|
|
|
|
|
|
+protocol: "*Web-Snippets",
|
|
fn: function (){
|
|
fn: function (){
|
|
var self=this;
|
|
var self=this;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
@@ -368,7 +368,7 @@ $globals.CharacterArray);
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "snippet:",
|
|
selector: "snippet:",
|
|
-protocol: '*Web-Snippets',
|
|
|
|
|
|
+protocol: "*Web-Snippets",
|
|
fn: function (anElement){
|
|
fn: function (anElement){
|
|
var self=this;
|
|
var self=this;
|
|
var clone,caret;
|
|
var clone,caret;
|