vsn 0.1.89 → 0.1.90

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
@@ -5,27 +5,91 @@
5
5
  <title>SEO Javascript Test</title>
6
6
 
7
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>
63
+
64
+ <script vsn-script type="text/vsn">
65
+ class test-class {
66
+ func construct() {
67
+ $color = "#ff00ff";
68
+ }
69
+
70
+ func deconstruct() {
71
+ $color = '#000000';
72
+ }
73
+
74
+ on click() {
75
+ log(@class);
76
+ @class -= 'test-class';
77
+ @class ~ 'huh';
78
+ log(@class);
79
+ }
80
+ }
81
+ </script>
8
82
  </head>
9
83
  <body>
10
84
 
11
85
  <template vsn-component:test-component>
12
86
  <script vsn-script type="text/vsn">
13
87
  class test-component {
14
- class > button {
15
- func construct() {
16
- $color = 'green';
17
- }
18
-
19
- on click() {
20
- $color = 'red';
21
- }
22
- }
23
88
  class .test-class {
24
89
  func construct() {
25
90
  log('hmm?');
26
- $color = "#ff0000";
91
+ $color = "#ff00ff";
27
92
  }
28
-
29
93
  class button {
30
94
  func construct() {
31
95
  $color = "#ff00ff";
@@ -41,20 +105,164 @@
41
105
  }
42
106
  }
43
107
  </script>
44
- <button>Don't Click Me</button>
45
108
  <div class="test-class">
46
109
  <h1>Test Component</h1>
47
110
  <p>
48
111
  <button>Click Me</button>
49
112
  </p>
50
113
  </div>
51
- <slot name="testing"></slot>
52
114
  </template>
53
115
 
54
- <test-component>
55
- <span slot="testing" vsn-name="slot">asdf</span>
56
- <span slot="testing" vsn-name="slot2">asd</span>
57
- </test-component>
116
+ <test-component></test-component>
117
+
118
+ <template vsn-template id="vsn-template">
119
+ <span>Hello, world!</span>
120
+ </template>
121
+
122
+ <div>
123
+ <textarea id="example-code" rows="10" cols="50"></textarea>
124
+ <div id="example-output" vsn-bind:@html="#example-code.@value"></div>
125
+ </div>
126
+
127
+ <template vsn-template id="query-operator-example-item">
128
+ <li vsn-list-item>
129
+ <span vsn-if="'active' in ?>(:parent).@class">active</span>
130
+ <span vsn-if:not="'active' not in ?>(:parent).@class">inactive</span>
131
+ <button vsn-on:click="?>(:parent).@class += 'active'">+</button>
132
+ <button vsn-on:click="?>(:parent).@class -= 'active'">-</button>
133
+ <button vsn-on:click="?>(:parent).@class ~ 'active'">~</button>
134
+ </li>
135
+ </template>
136
+
137
+ <div id="test-container"></div>
138
+ <a href="./markup.html" vsn-on:click|preventdefault="#test-container.@html = << @href">Fill Container</a>
139
+ <a vsn-on:click|preventdefault="#test-container.@html = ''">Clear Container</a>
140
+
141
+ <h2>On Click</h2>
142
+ <div vsn-name="toggle" vsn-set:show|boolean="false">
143
+ <button class="test-class" vsn-on:click="toggle.show = !toggle.show" vsn-exec="on click() {@class -= 'test-class';log('uh', @class);}">Toggle</button>
144
+ <span vsn-bind="toggle.show"></span>
145
+ </div>
146
+ <a id="click-test" vsn-on:click="if(@text != @clicktext){@text=@clicktext}else{@text='Click Me'}" clicktext="Clicked!">Click Me</a>
147
+
148
+ <h2>? Operator</h2>
149
+ <p>Add/remove class to list of elements on click.</p>
150
+ <p id="toggle-container" vsn-exec="toggles = ?(#list-add-remove-class-example li)">
151
+ <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>
152
+ <ul id="list-add-remove-class-example" vsn-list initial-items="5" template="?(#query-operator-example-item)"></ul>
153
+ </p>
154
+
155
+ <h2>@ Operator</h2>
156
+ <p></p>
157
+ <p>
158
+ <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" />
159
+ </p>
160
+
161
+ <p>Bind to window attributes. </p>
162
+ <p>window.scrollX,Y <span vsn-bind="?(window).@scrollX"></span>, <span vsn-bind="?(window).@scrollY"></span></p>
163
+
164
+ <h2>Attribute Binding</h2>
165
+ <a href="/index.html" id="link" vsn-name="link_test">Home</a>
166
+ <input type="text" vsn-bind="#link.@text"/>
167
+ <input type="text" vsn-bind="#link.@href"/>
168
+
169
+ <h2>Attribute Formatters</h2>
170
+ <h3>Currency</h3>
171
+ <span vsn-bind="currency_format" vsn-type:currency_format="float" vsn-format="currency" id="formatter">1.5</span>
172
+ <input type="text" vsn-bind="#formatter.currency_format" />
173
+ <br />
174
+ <h3>Date</h3>
175
+ <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>
176
+ <input type="text" vsn-bind:|to="?(#date-formatter).date_format" />
177
+ <input type="text" vsn-on:keyup="?(#date-formatter).date_format = $value" value="Aug 11, 2021 01:03:00 PM PDT" />
178
+
179
+ <h2>$ Operator</h2>
180
+ <p></p>
181
+ <p>
182
+ <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" />
183
+ </p>
184
+
185
+ <h2>Conditional Elements</h2>
186
+ <button vsn-on:click="show = !show">Toggle</button>
187
+ <span vsn-if="show">Show is true</span>
188
+ <span vsn-if="!show">Show is false</span>
189
+
190
+ <h2>Controllers</h2>
191
+ <div vsn-controller:controller="Controller">
192
+ <span vsn-if="controller.on">It's on!</span>
193
+ <span vsn-if="!controller.on">It's off...</span>
194
+ <a href="/" vsn-on:click="controller.doSomething($event, !controller.on)">Click Me</a>
195
+ </div>
196
+
197
+ <h2>Lists</h2>
198
+ <div vsn-controller:test="TestController" id="testing">
199
+ <h3>Value: <span vsn-bind="test.name">Testing</span> <span vsn-bind="test.age">32</span></h3>
200
+ <input type="text" vsn-bind="test.name"/>
201
+ <input type="text" vsn-bind="test.age"/>
202
+ <button vsn-on:click="test.reset()" vsn-if="test.name">Reset</button>
203
+ <button vsn-on:click="test.add();">Add New List Item</button>
204
+ <ul vsn-list:test.items vsn-list-item-model="TestItem" vsn-name="list">
205
+ <li vsn-list-item>
206
+ <span vsn-bind="item.name">Tom</span>, <span vsn-bind="item.age">22</span> Years Old <input type="text"
207
+ vsn-bind="item.name"/>
208
+ <input type="text" vsn-bind="item.age"/>
209
+ <button vsn-on:click="item.reset()">R</button>
210
+ <button vsn-on:click="list.remove(item)">X</button>
211
+ </li>
212
+ <li vsn-list-item>
213
+ <span vsn-bind="item.name">Steve</span>, <span vsn-bind="item.age">46</span> Years Old <input type="text"
214
+ vsn-bind="item.name"/>
215
+ <input type="text" vsn-bind="item.age"/>
216
+ <button vsn-on:click="item.reset()">R</button>
217
+ <button vsn-on:click="list.remove(item)">X</button>
218
+ </li>
219
+ <li vsn-list-item>
220
+ <span vsn-bind="item.name">Frank</span>, <span vsn-bind="item.age">31</span> Years Old <input type="text"
221
+ vsn-bind="item.name"/>
222
+ <input type="text" vsn-bind="item.age"/>
223
+ <button vsn-on:click="item.reset()">R</button>
224
+ <button vsn-on:click="list.remove(item)">X</button>
225
+ </li>
226
+ <li vsn-list-item>
227
+ <span vsn-name="wut" vsn-set:wut.test="1">Wut</span>
228
+ <span vsn-bind="item.name">Joe</span>, <span vsn-bind="item.age">91</span> Years Old <input type="text"
229
+ vsn-bind="item.name"/>
230
+ <input type="text" vsn-bind="item.age"/>
231
+ <button vsn-on:click="item.reset()">R</button>
232
+ <button vsn-on:click="list.remove(item)">X</button>
233
+ </li>
234
+ </ul>
235
+ </div>
236
+
237
+ <h2>Lazy XHR Component</h2>
238
+ <div vsn-lazy="@html = << './xhr.html'"></div>
239
+
240
+ <script type="text/javascript">
241
+ window.addEventListener('vsn', function () {
242
+ vision.registry.controllers.register('TestController', TestController);
243
+ vision.registry.models.register('TestItem', TestItem);
244
+ vision.registry.controllers.register('Controller', Controller);
245
+ vision.registry.controllers.register('MVal', MVal);
246
+ });
247
+ </script>
248
+
249
+ <script vsn-script type="text/vsn">
250
+ class .testing-class {
251
+ on click() {
252
+ @text = 'Clicked';
253
+ }
254
+
255
+ on mouseenter() {
256
+ @text = 'Hovered!';
257
+ }
258
+
259
+ on mouseleave() {
260
+ @text = 'Mouse left';
261
+ }
262
+ }
263
+ </script>
264
+
265
+ <button class="testing-class" test="1">Click me</button>
58
266
 
59
267
  <script type="text/javascript" src="vsn.js"></script>
60
268
  </body>