vsn 0.1.84 → 0.1.85

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
@@ -82,47 +82,187 @@
82
82
  </head>
83
83
  <body>
84
84
 
85
- <template vsn-component:form-control-errors>
86
- <span>Errors</span>
87
- <ul></ul>
88
- </template>
89
-
90
- <template vsn-component:product-option>
91
- <script type="text/vsn" vsn-script>
92
- class product-option {
85
+ <template vsn-component:test-component>
86
+ <script vsn-script type="text/vsn">
87
+ class test-component {
88
+ class .test-class {
89
+ func construct() {
90
+ log('hmm?');
91
+ $color = "#ff00ff";
92
+ }
93
+ class button {
93
94
  func construct() {
94
- option = ?>([name])[0].@name;
95
- log('option', option);
96
- ?>(form-control-errors).@for = option;
97
- log('errors', ?>(form-control-errors));
95
+ $color = "#ff00ff";
98
96
  }
99
97
 
100
- class [slot=option] {
101
- func construct() {
102
-
103
- }
98
+ on click() {
99
+ log(@class);
100
+ @class -= 'test-class';
101
+ @class ~ 'huh';
102
+ log(@class);
104
103
  }
105
104
  }
106
- </script>
107
- <form-control-errors></form-control-errors>
108
- <slot name="option"></slot>
109
- </template>
110
-
111
- <product-option>
112
- <div slot="option">
113
-
114
- <label><input type="radio" name="test"
115
- value="{{ option_value.option_type_id }">asd</label>
116
- </div>
117
- </product-option>
118
-
119
- <product-option>
120
- <div slot="option">
121
-
122
- <label><input type="radio" name="testing"
123
- value="{{ option_value.option_type_id }">wut</label>
124
- </div>
125
- </product-option>
105
+ }
106
+ }
107
+ </script>
108
+ <div class="test-class">
109
+ <h1>Test Component</h1>
110
+ <p>
111
+ <button>Click Me</button>
112
+ </p>
113
+ </div>
114
+ </template>
115
+
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>
126
266
 
127
267
  <script type="text/javascript" src="vsn.js"></script>
128
268
  </body>