vsn 0.1.50 → 0.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/demo/demo.html CHANGED
@@ -2,199 +2,78 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="utf-8">
5
- <title>SEO Javascript Test</title>
6
-
7
- <style></style>
8
- <script type="text/javascript">
9
- var TestController = (function () {
10
- function TestController() {
11
- this.items = [];
12
- this.name = null;
13
- this.age = null;
14
- this.obj = null;
15
- this.array = null;
16
- }
17
-
18
- TestController.prototype.reset = function () {
19
- this.name = '';
20
- this.age = '';
21
- };
22
-
23
- TestController.prototype.add = function () {
24
- this.items.push(new TestItem(this.name, this.age));
25
- this.reset();
26
- };
27
-
28
- return TestController;
29
- }());
30
-
31
- var TestItem = (function () {
32
- function TestItem(name = null, age = null) {
33
- this.name = name;
34
- this.age = age;
35
- }
36
-
37
- TestItem.prototype.reset = function () {
38
- this.name = '';
39
- this.age = '';
40
- };
41
- return TestItem;
42
- }());
43
-
44
- var MVal = (function () {
45
- function MVal(v) {
46
- this.v = v;
47
- }
48
- return MVal;
49
- }());
50
-
51
- var Controller = (function () {
52
- function Controller() {
53
- this.on = false;
54
- }
55
-
56
- Controller.prototype.doSomething = function ($event, value) {
57
- $event.preventDefault();
58
- this.on = value;
59
- };
60
- return Controller;
61
- }());
62
- </script>
5
+ <title>SEO Javascript Demo</title>
6
+
7
+ <style>
8
+ .example {
9
+ border: 1px solid #ccc;
10
+ padding: 10px;
11
+ margin: 10px;
12
+ display: flex;
13
+ flex-direction: row;
14
+ flex-wrap: nowrap;
15
+ align-content: center;
16
+ justify-content: space-around;
17
+ align-items: center;
18
+ }
19
+ .code,
20
+ .result {
21
+ width: 50%;
22
+ padding: 10px;
23
+ }
63
24
 
64
- <script type="vsn">
65
- class Test {
66
- helloWorld() {
67
- print('Hello, world!');
68
- }
25
+ .code textarea {
26
+ width: 100%;
69
27
  }
70
- </script>
28
+ </style>
71
29
  </head>
72
30
  <body>
73
- <template vsn-template id="vsn-template">
74
- <span>Hello, world!</span>
75
- </template>
76
-
77
- <div>
78
- <textarea id="example-code" rows="10" cols="50"></textarea>
79
- <div id="example-output" vsn-bind:@html="#example-code.@value"></div>
31
+ <h2>Input Binding</h2>
32
+ <div class="example">
33
+ <div class="code">
34
+ <textarea id="input-binding" rows="1"><input id="test" value="initial" /><span vsn-bind="#test.@value"></span></textarea>
35
+ </div>
36
+ <div class="result"><div vsn-bind:@html="#input-binding.@value"></div></div>
80
37
  </div>
81
38
 
82
- <template vsn-template id="query-operator-example-item">
83
- <li vsn-list-item>
84
- <span vsn-if="'active' in ?>(:parent).@class">active</span>
85
- <span vsn-if:not="'active' not in ?>(:parent).@class">inactive</span>
86
- <button vsn-on:click="?>(:parent).@class += 'active'">+</button>
87
- <button vsn-on:click="?>(:parent).@class -= 'active'">-</button>
88
- <button vsn-on:click="?>(:parent).@class ~ 'active'">~</button>
89
- </li>
90
- </template>
91
-
92
- <div id="test-container"></div>
93
- <a href="./markup.html" vsn-on:click|preventdefault="#test-container.@html = << @href">Fill Container</a>
94
- <a vsn-on:click|preventdefault="#test-container.@html = ''">Clear Container</a>
95
-
96
- <h2>On Click</h2>
97
- <button vsn-on:click="show = !show" vsn-set:show="false|boolean">Toggle</button>
98
- <span vsn-bind="show"></span>
99
-
100
- <a vsn-on:click="if(@text != @clicktext){@text=@clicktext}else{@text='Click Me'}" clicktext="Clicked!">Click Me</a>
101
-
102
- <h2>? Operator</h2>
103
- <p>Add/remove class to list of elements on click.</p>
104
- <p id="toggle-container" vsn-exec="toggles = ?(#list-add-remove-class-example li)">
105
- <button vsn-on:click="?(#list-add-remove-class-example li).@class += 'active'">Add</button> <button vsn-on:click="?(#list-add-remove-class-example li).@class -= 'active'">Remove</button> <button vsn-on:click="?(#list-add-remove-class-example li).@class ~ 'active'">Toggle</button>
106
- <ul id="list-add-remove-class-example" vsn-list initial-items="5" template="?(#query-operator-example-item)"></ul>
107
- </p>
108
-
109
- <h2>@ Operator</h2>
110
- <p></p>
111
- <p>
112
- <input type="text" value="testing" id="at-attribute" /> <input type="button" vsn-on:click="?(#at-attribute).@type = 'password'" value="Button" /> <input type="button" vsn-on:click="?(#at-attribute).@type = 'text'" value="Button" />
113
- </p>
114
-
115
- <p>Bind to window attributes. </p>
116
- <p>window.scrollX,Y <span vsn-bind="?(window).@scrollX"></span>, <span vsn-bind="?(window).@scrollY"></span></p>
117
-
118
- <h2>Attribute Binding</h2>
119
- <a href="/index.html" id="link" vsn-name="link_test">Home</a>
120
- <input type="text" vsn-bind="#link.@text"/>
121
- <input type="text" vsn-bind="#link.@href"/>
122
-
123
- <h2>Attribute Formatters</h2>
124
- <h3>Currency</h3>
125
- <span vsn-bind="currency_format" vsn-type:currency_format="float" vsn-format="currency" id="formatter">1.5</span>
126
- <input type="text" vsn-bind="#formatter.currency_format" />
127
- <br />
128
- <h3>Date</h3>
129
- <span vsn-bind="date_format" vsn-type:date_format="date" vsn-format="date" id="date-formatter">Aug 11, 2021 01:03:00 PM PDT</span>
130
- <input type="text" vsn-bind:|to="?(#date-formatter).date_format" />
131
- <input type="text" vsn-on:keyup="?(#date-formatter).date_format = $value" value="Aug 11, 2021 01:03:00 PM PDT" />
39
+ <h2>DOM Events</h2>
40
+ <div class="example">
41
+ <div class="code">
42
+ <textarea id="dom-events" rows="3">
43
+ <button vsn-on:click="counter.v -= 1">-</button>
44
+ <span vsn-name="counter" vsn-set:v="0|integer" vsn-bind="v"></span>
45
+ <button vsn-on:click="counter.v += 1">+</button>
46
+ </textarea>
47
+ </div>
48
+ <div class="result"><div vsn-bind:@html="#dom-events.@value"></div></div>
49
+ </div>
132
50
 
133
- <h2>$ Operator</h2>
134
- <p></p>
135
- <p>
136
- <input type="text" vsn-bind="$marginTop" id="style-attribute" /> <input type="button" vsn-on:click="?(#style-attribute).$marginTop = $padding;$padding += 1px" vsn-on:contextmenu|preventdefault="$padding -= 1px" value="Button" /> <input type="button" vsn-on:click="?(#style-attribute).$marginTop = '0'" value="Button" />
137
- </p>
51
+ <h2>Query Operators & Conditionals</h2>
52
+ <div class="example">
53
+ <div class="code">
54
+ <textarea id="query-operator" rows="7">
55
+ <div class="active">
56
+ <button vsn-on:click="?>(:parent).@class -= 'active'">-</button>
57
+ <button vsn-on:click="?>(:parent).@class ~ 'active'">~</button>
58
+ <button vsn-on:click="?>(:parent).@class += 'active'">+</button>
59
+ <span vsn-if="'active' not in ?>(:parent).@class">Inactive</span>
60
+ <span vsn-if="'active' in ?>(:parent).@class">Active</span>
61
+ </div>
62
+ </textarea>
63
+ </div>
64
+ <div class="result"><div vsn-bind:@html="#query-operator.@value"></div></div>
65
+ </div>
138
66
 
139
- <h2>Conditional Elements</h2>
140
- <button vsn-on:click="show = !show">Toggle</button>
141
- <span vsn-if="show">Show is true</span>
142
- <span vsn-if="!show">Show is false</span>
67
+ <p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p>
143
68
 
144
- <h2>Controllers</h2>
145
- <div vsn-controller:controller="Controller">
146
- <span vsn-if="controller.on">It's on!</span>
147
- <span vsn-if="!controller.on">It's off...</span>
148
- <a href="/" vsn-on:click="controller.doSomething($event, !controller.on)">Click Me</a>
69
+ <h2>Lazy Execution</h2>
70
+ <div class="example">
71
+ <div class="code">
72
+ <textarea id="lazy-loading" rows="1"><div vsn-lazy="$background = 'url(./logo.png) no-repeat';$minHeight = 150px;"></div></textarea>
73
+ </div>
74
+ <div class="result"><div vsn-bind:@html="#lazy-loading.@value"></div></div>
149
75
  </div>
150
76
 
151
- <h2>Lists</h2>
152
- <div vsn-controller:test="TestController" id="testing">
153
- <h3>Value: <span vsn-bind="test.name">Testing</span> <span vsn-bind="test.age">32</span></h3>
154
- <input type="text" vsn-bind="test.name"/>
155
- <input type="text" vsn-bind="test.age"/>
156
- <button vsn-on:click="test.reset()" vsn-if="test.name">Reset</button>
157
- <button vsn-on:click="test.add();">Add New List Item</button>
158
- <ul vsn-list:test.items vsn-list-item-model="TestItem" vsn-name="list">
159
- <li vsn-list-item>
160
- <span vsn-bind="item.name">Tom</span>, <span vsn-bind="item.age">22</span> Years Old <input type="text"
161
- vsn-bind="item.name"/>
162
- <input type="text" vsn-bind="item.age"/>
163
- <button vsn-on:click="item.reset()">R</button>
164
- <button vsn-on:click="list.remove(item)">X</button>
165
- </li>
166
- <li vsn-list-item>
167
- <span vsn-bind="item.name">Steve</span>, <span vsn-bind="item.age">46</span> Years Old <input type="text"
168
- vsn-bind="item.name"/>
169
- <input type="text" vsn-bind="item.age"/>
170
- <button vsn-on:click="item.reset()">R</button>
171
- <button vsn-on:click="list.remove(item)">X</button>
172
- </li>
173
- <li vsn-list-item>
174
- <span vsn-bind="item.name">Frank</span>, <span vsn-bind="item.age">31</span> Years Old <input type="text"
175
- vsn-bind="item.name"/>
176
- <input type="text" vsn-bind="item.age"/>
177
- <button vsn-on:click="item.reset()">R</button>
178
- <button vsn-on:click="list.remove(item)">X</button>
179
- </li>
180
- <li vsn-list-item>
181
- <span vsn-name="wut" vsn-set:wut.test="1">Wut</span>
182
- <span vsn-bind="item.name">Joe</span>, <span vsn-bind="item.age">91</span> Years Old <input type="text"
183
- vsn-bind="item.name"/>
184
- <input type="text" vsn-bind="item.age"/>
185
- <button vsn-on:click="item.reset()">R</button>
186
- <button vsn-on:click="list.remove(item)">X</button>
187
- </li>
188
- </ul>
189
- </div>
190
- <script type="text/javascript">
191
- window.addEventListener('vsn', function () {
192
- vision.registry.classes.register('TestController', TestController);
193
- vision.registry.classes.register('TestItem', TestItem);
194
- vision.registry.classes.register('Controller', Controller);
195
- vision.registry.classes.register('MVal', MVal);
196
- });
197
- </script>
198
77
  <script type="text/javascript" src="vsn.js"></script>
199
78
  </body>
200
79
  </html>
@@ -0,0 +1,2 @@
1
+ <h1>Default Markup Test</h1>
2
+ <p vsn-on:click="@text = 'This is a clicked paragraph.'">This is the default paragraph.</p>