| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 
 | <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xf="http://www.w3.org/2002/xforms">
    <head>
        <title>Shopping cart</title>
    <!--
    ~ Copyright (c) 2012. betterFORM Project - http://www.betterform.de
    ~ Licensed under the terms of BSD License
    -->
        <meta name="author" content="joernt at users.sourceforge.net"/>
        <meta name="author" content="lars.windauer at chiba-project.org"/>
        <meta name="author" content="tobias.krebs at betterform.de"/>
        <meta name="author" content="fabian.otto at betterform.de"/>
        <meta name="description" content="XForms demo of a simple order list"/>
 
 
    <!--<link rel="stylesheet" type="text/css" href="bfResources/styles/dashboard.css" />-->
        <link rel="stylesheet" type="text/css" href="styles/demo.css"/>
        <style type="text/css">
        .soria #xforms {
            overflow: hidden;
        }
        .xfFullGroup .xfControl .xfLabel {
            width: 55px;
        }
    </style>
    </head>
    <body class="soria" style="margin:30px;">
        <div id="xforms">
            <div style="display:none">
                <xf:model>
                    <xf:instance xmlns="" id="orderlist" src="orderlist.xml"/>
                    <xf:bind id="items" nodeset="item[position()!=last()]">
                        <xf:bind id="article" nodeset="." required="true()"/>
                        <xf:bind id="amount" nodeset="@amount" type="integer" required="true()" constraint=". < 100"/>
                        <xf:bind id="price" nodeset="@price" type="float"/>
                        <xf:bind id="taxValue" nodeset="@taxValue" calculate="../@amount * ../@price * instance('shippingAndTaxes')/region/tax" type="float"/>
                        <xf:bind id="sum" nodeset="@sum" calculate="../@amount * ../@price * ( 1 + instance('shippingAndTaxes')/region/tax)" type="float"/>
                    </xf:bind>
                    <xf:instance id="shippingAndTaxes">
                        <order xmlns="">
                            <region>
                                <name>Region 7</name>
                                <shipping>4.40</shipping>
                                <tax>0.19</tax>
                            </region>
                        </order>
                    </xf:instance>
                    <xf:bind nodeset="instance('shippingAndTaxes')/region/tax" type="float"/>
                    <xf:instance id="template">
                        <order xmlns="">
                            <item amount="1" price="1.50" taxValue="0" sum="0">pencil</item>
                        </order>
                    </xf:instance>
 
        <!--
        <xf:instance id="items">
            <items xmlns="">
                <item price="0.50">Eraser</item>
                <item price="1.50">Pencil</item>
                <item price="2.49">Ballpoint pen</item>
                <item price="3.99">Spiral notebook</item>
                <item price="50.00">Fountain pen</item>
                <item price="69.98">Shredder</item>
                <template>Eraser</template>
            </items>
        </xf:instance>
 
        <xf:bind id="articles" nodeset="instance('items')"/>
 
        <xf:instance id="userItem">
            <order xmlns="">
                <item price="0"/>
            </order>
        </xf:instance>
 
        <xf:bind nodeset="instance('userItem')/item">
            <xf:bind nodeset="." type="normalizedString" constraint="string-length(.) > 1"/>
            <xf:bind nodeset="@price" type="float" constraint=". > 0"/>
        </xf:bind>
        -->
                    <xf:instance id="countries">
                        <contries xmlns="">
                            <region>
                                <name/>
                                <shipping>0.0</shipping>
                                <tax>0.0</tax>
                            </region>
                            <region>
                                <name>Region 1</name>
                                <shipping>12.50</shipping>
                                <tax>0.1</tax>
                            </region>
                            <region>
                                <name>Region 2</name>
                                <shipping>8.00</shipping>
                                <tax>0.2</tax>
                            </region>
                            <region>
                                <name>Region 3</name>
                                <shipping>30.00</shipping>
                                <tax>0.0</tax>
                            </region>
                            <region>
                                <name>Region 4</name>
                                <shipping>10.00</shipping>
                                <tax>0.21</tax>
                            </region>
                            <region>
                                <name>Region 5</name>
                                <shipping>15.00</shipping>
                                <tax>0.07</tax>
                            </region>
                            <region>
                                <name>Region 6</name>
                                <shipping>8.50</shipping>
                                <tax>0.16</tax>
                            </region>
                            <region>
                                <name>Region 7</name>
                                <shipping>4.40</shipping>
                                <tax>0.19</tax>
                            </region>
                            <region>
                                <name>Region 8</name>
                                <shipping>13.25</shipping>
                                <tax>0.125</tax>
                            </region>
                            <region>
                                <name>Region 9</name>
                                <shipping>14.00</shipping>
                                <tax>0.062</tax>
                            </region>
                            <region>
                                <name>Region 10</name>
                                <shipping>0.08</shipping>
                                <tax>0.16</tax>
                            </region>
                            <region>
                                <name>Region 11</name>
                                <shipping>40.00</shipping>
                                <tax>0.215</tax>
                            </region>
                            <region>
                                <name>Region 12</name>
                                <shipping>9.00</shipping>
                                <tax>0.14</tax>
                            </region>
                        </contries>
                    </xf:instance>
                    <xf:instance id="result">
                        <data xmlns="">
                            <taxtotal/>
                            <netpricetotal/>
                            <sumtotal/>
                        </data>
                    </xf:instance>
                    <xf:bind nodeset="instance('result')">
                        <xf:bind nodeset="taxtotal" calculate="sum(instance('orderlist')/item/@sum) * instance('shippingAndTaxes')/region/tax" type="float"/>
                        <xf:bind nodeset="netpricetotal" calculate="sum(instance('orderlist')/item/@sum) - (sum(instance('orderlist')/item/@sum) * instance('shippingAndTaxes')/region/tax)" type="float"/>
                        <xf:bind nodeset="sumtotal" calculate="sum(instance('orderlist')/item/@sum) + instance('shippingAndTaxes')/region/shipping" type="float"/>
                    </xf:bind>
                </xf:model>
            </div>
            <div class="Section" dojotype="dijit.layout.ContentPane">
                <xf:group appearance="full" class="contactsFullGroup">
                    <div class="Headline">Shopping cart:</div>
                    <div class="description">
        A simple calculated shopping cart with slightly formatted output.<br/>
        Tax and shipping costs get calculated dependent on the region you choose.
    </div>
                    <br/>
 
    <!--<div class="orderListRegionSelect">-->
                    <xf:select1 appearance="minimal" ref="instance('shippingAndTaxes')">
                        <xf:label id="region">Ship to:</xf:label>
                        <xf:hint>Choose your region for correct tax and shipping cost calculation</xf:hint>
                        <xf:itemset nodeset="instance('countries')/region">
                            <xf:label ref="name"/>
                            <xf:copy ref="."/>
                        </xf:itemset>
                    </xf:select1>
    <!--</div>-->
                    <xf:group appearance="minimal">
                        <xf:repeat id="repeatid" bind="items" appearance="compact" class="orderListRepeat">
                            <xf:select1 bind="article">
                                <xf:label class="contactsRepeatHeader">Article</xf:label>
                                <xf:hint>Choose the article you wish to add to the shopping cart</xf:hint>
                                <xf:choices>
                                    <xf:item>
                                        <xf:label>Eraser</xf:label>
                                        <xf:value>eraser</xf:value>
                                        <xf:setvalue ev:event="xforms-select" bind="price">0.50</xf:setvalue>
                                    </xf:item>
                                    <xf:item>
                                        <xf:label>Pencil</xf:label>
                                        <xf:value>pencil</xf:value>
                                        <xf:setvalue ev:event="xforms-select" bind="price">1.50</xf:setvalue>
                                    </xf:item>
                                    <xf:item>
                                        <xf:label>Ballpoint pen</xf:label>
                                        <xf:value>ballpoint_pen</xf:value>
                                        <xf:setvalue ev:event="xforms-select" bind="price">2.49</xf:setvalue>
                                    </xf:item>
                                    <xf:item>
                                        <xf:label>Spiral notebook</xf:label>
                                        <xf:value>spiral_notebook</xf:value>
                                        <xf:setvalue ev:event="xforms-select" bind="price">3.99</xf:setvalue>
                                    </xf:item>
                                    <xf:item>
                                        <xf:label>Fountain pen</xf:label>
                                        <xf:value>fountain_pen</xf:value>
                                        <xf:setvalue ev:event="xforms-select" bind="price">50.00</xf:setvalue>
                                    </xf:item>
                                    <xf:item>
                                        <xf:label>Shredder</xf:label>
                                        <xf:value>shredder</xf:value>
                                        <xf:setvalue ev:event="xforms-select" bind="price">69.98</xf:setvalue>
                                    </xf:item>
                                </xf:choices>
                            </xf:select1>
            <!--
            <xf:select1 bind="article">
                <xf:label class="contactsRepeatHeader">Article</xf:label>
                <xf:hint>Choose the article you wish to add to the orderlist</xf:hint>
                <xf:itemset nodeset="instance('items')/item">
                    <xf:label ref="."/>
                    <xf:value ref="."/>
 
                </xf:itemset>
            </xf:select1>
            -->
                            <xf:input bind="amount" incremental="true">
                                <xf:label class="contactsRepeatHeader orderlistAmount">Amount</xf:label>
                                <xf:hint>Enter the amount of articles you would like to buy (99 items max)</xf:hint>
                                <xf:alert>You can order a maximum of 99 articles in one order</xf:alert>
                            </xf:input>
                            <xf:output value="format-number(@price, '⬠0.00')" class="text-right">
                                <xf:label class="contactsRepeatHeader">Price</xf:label>
                            </xf:output>
                            <xf:output value="format-number(instance('shippingAndTaxes')/region/tax , '0.00%')" class="text-right">
                                <xf:label class="contactsRepeatHeader">Tax %</xf:label>
                            </xf:output>
                            <xf:output value="format-number(@taxValue, '⬠0.00')" class="text-right">
                                <xf:label class="contactsRepeatHeader">Tax Value</xf:label>
                            </xf:output>
                            <xf:output value="format-number(@sum, '⬠0.00')" class="text-right">
                                <xf:label class="contactsRepeatHeader">Sum</xf:label>
                            </xf:output>
                        </xf:repeat>
                        <div class="orderlistRepeatFooter">
                            <xf:output id="totalSum" value="format-number(instance('result')/netpricetotal, '⬠0.00')">
                                <xf:label>Net price:</xf:label>
                            </xf:output>
                            <xf:output id="totalTax" value="format-number(instance('result')/taxtotal, '⬠0.00')">
                                <xf:label>+ Total tax:</xf:label>
                            </xf:output>
                            <xf:output id="shipping" value="format-number(instance('shippingAndTaxes')/region/shipping, '⬠0.00')">
                                <xf:label class="orderlistRepeatFooter">+ Shipping:</xf:label>
                            </xf:output>
                            <xf:output id="total" value="format-number(instance('result')/sumtotal, '⬠0.00')">
                                <xf:label>= Total:</xf:label>
                            </xf:output>
                        </div>
                    </xf:group>
                </xf:group>
                <xf:group appearance="minimal" class="orderListTriggerGroup">
    <!--
    <xf:trigger class="orderListNewTrigger">
        <xf:label>New item</xf:label>
        <xf:hint>Create new article for articlelist</xf:hint>
        <xf:action>
            <script type="text/javascript">
                dijit.byId("itemDialog").show();
            </script>
        </xf:action>
    </xf:trigger>
    -->
                    <table>
                        <tr>
                            <td class="orderListSpacerLeft"/>
                            <td>
                                <xf:trigger class="orderListAddTrigger">
                                    <xf:label>Add item</xf:label>
                                    <xf:hint>Adds a new article to the shopping cart</xf:hint>
                                    <xf:action>
                                        <xf:insert bind="items" at="last()" position="after" origin="instance('template')/item" if="exists(instance()/item)"/>
                                        <xf:insert context="/order" at="last()" position="after" origin="instance('template')/item" if="count(instance()/item) = 1"/>
                                    </xf:action>
                                </xf:trigger>
                            </td>
                            <td>
                                <xf:trigger class="orderListDelTrigger">
                                    <xf:label>Delete item</xf:label>
                                    <xf:hint>Deletes selected article from shopping cart</xf:hint>
                                    <xf:action>
                                        <xf:delete bind="items" at="index('repeatid')"/>
                                    </xf:action>
                                </xf:trigger>
                            </td>
                            <td>
                                <xf:trigger class="orderListResetTrigger">
                                    <xf:label>Reset</xf:label>
                                    <xf:hint>Resets demo to inital state</xf:hint>
                                    <xf:action>
                                        <xf:reset/>
                                    </xf:action>
                                </xf:trigger>
                            </td>
                            <td class="orderListSpacerRight"/>
                        </tr>
                    </table>
    <!--
    <div id="itemDialog" dojoType="dijit.Dialog" title="Insert new article into articlelist">
        <xf:group appearance="full" ref="instance('userItem')/item">
            <xf:input ref=".">
                <xf:label>Article name:</xf:label>
                <xf:hint>Enter the name of the new article</xf:hint>
                <xf:alert>Please enter an article name</xf:alert>
            </xf:input>
            <xf:input ref="@price">
                <xf:label>Article price:</xf:label>
                <xf:hint>Enter the price of the new article</xf:hint>
            </xf:input>
 
            <xf:group appearance="minimal" class="orderListTriggerGroup">
                <xf:trigger class="orderListOKTrigger">
                    <xf:label>Add new article</xf:label>
                    <xf:hint>Add the article to the articlelist</xf:hint>
                    <xf:action>
                        <script type="text/javascript">
                            dijit.byId("itemDialog").hide();
                        </script>
                        <xf:insert context="instance('items')" origin="instance('userItem')/item"/>
                        <xf:setvalue ref="instance('userItem')/item"></xf:setvalue>
                        <xf:setvalue ref="instance('userItem')/item/@price" value="'0'"/>
                    </xf:action>
                </xf:trigger>
                <xf:trigger class="orderListAbortTrigger">
                    <xf:label>Abort</xf:label>
                    <xf:hint>Close dialog</xf:hint>
                    <xf:action>
                        <script type="text/javascript">
                            dijit.byId("itemDialog").hide();
                        </script>
                    </xf:action>
                </xf:trigger>
            </xf:group>
        </xf:group>
    </div>
    -->
                </xf:group>
            </div>
        </div>
    </body>
</html> | 
Partager