Subversion-Projekte lars-tiefland.cienc

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
8 lars 1
 
2
$(document).ready(function()
3
{
4
 
5
    var name = $( "#vorname" ),
6
        lname = $( "#nachname" ),
7
        company = $( "#firma" ),
8
        street1 = $( "#street1" ),
9
        str_nr1 = $( "#str_nr1" ),
10
        postal = $( "#plz" ),
11
        city = $( "#ort" ),
12
        email=$('#email'),
13
        phone=$('#telefon'),
14
        allFields = $( [] ).add( name ).add( lname ).add( company ).add( street1 ).add( str_nr1 ).add( postal ).add( city ).add(email).add(phone),
15
        tips = $( "#validateTips" );
16
 
17
    $(".changeBillingAddressDialogAlt").delegate("input:button", "click", function(){
18
        $('#edit_addr_dialog_bill').dialog("open");
19
    });
20
    $(".changeShippingAddressDialogAlt").delegate("input:button", "click", function(){
21
        $('#edit_addr_dialog_ship').dialog("open");
22
    });
23
    $(".changeBillingAddressDialog, .changeShippingAddressDialog").delegate("input:button", "click", function(){
24
        $('#new_addr_dialog').dialog("open");
25
        $(".changeBillingAddressDialog, .changeShippingAddressDialog").dialog("close");
26
    });
27
 
28
    $(".addr_defaultBilling").click(function(){
29
        var addr_id = $(this).val();
30
        $('.addresses').load('/module/addr_saveDefault.php?type=billing&addr_id='+addr_id);
31
    });
32
    $(".addr_defaultShipping").click(function(){
33
        var addr_id = $(this).val();
34
        $('.addresses').load('/module/addr_saveDefault.php?type=shipping&addr_id='+addr_id);
35
    });
36
    $(".addr_defaultAccount").click(function(){
37
        var addr_id = $(this).val();
38
        $.ajax({
39
            url: "/get_land_id.php?a_id="+addr_id,
40
            success:function(land_id){
41
                $.ajax({
42
                    url: "/change_currency.php?l_id="+land_id
43
                });
44
            }
45
       });
46
       $('.addresses').load('/module/addr_saveDefault.php?type=account&addr_id='+addr_id);
47
    });
48
 
49
 
50
 
51
    function updateTips( t )
52
    {
53
        tips
54
            .html( t )
55
            .addClass( "ui-state-highlight" );
56
        setTimeout(function()
57
        {
58
            tips.removeClass( "ui-state-highlight", 1500 );
59
        }, 500 );
60
    }
61
 
62
    function checkLength( o, n, min, max )
63
    {
64
        if ( o.val().length > max || o.val().length < min )
65
        {
66
            o.addClass( "ui-state-error" ).focus();
67
            updateTips( "Length of " + n + " must be between " + min + " and " + max + "." );
68
            return false;
69
        }
70
        else
71
        {
72
            return true;
73
        }
74
    }
75
    function checkMinLength( o, n )
76
    {
77
        if ( o.val().length < 1 )
78
        {
79
            o.addClass( "ui-state-error" ).focus();
80
            updateTips( n + " darf nicht leer sein." );
81
            return false;
82
        }
83
        else
84
        {
85
            return true;
86
        }
87
    }
88
 
89
    function checkRegexp( o, regexp, n )
90
    {
91
        if ( !( regexp.test( o.val() ) ) )
92
        {
93
            o.addClass( "ui-state-error" ).focus();
94
            updateTips( n );
95
            return false;
96
        }
97
        else
98
        {
99
            return true;
100
        }
101
    }
102
    $('#new_addr_dialog,#new_shipping_addr_dialog,#new_billing_addr_dialog').dialog(
103
    {
104
        autoOpen:false,
105
        height: "auto",
106
        width: "auto",
107
        modal:true,
108
        resizable:false,
109
        show:"fade",
110
        hide:"fade",
111
        buttons:
112
        {
113
            'Abbrechen':function(){
114
                $(this).dialog("close");
115
            },
116
 
117
            'Adresse speichern': function()
118
            {
119
                var bValid = true;
120
//                allFields.removeClass( "ui-state-error" );
121
//                tips.text("");
122
//
123
//                bValid = bValid && checkMinLength(name,"First name");
124
//                bValid = bValid && checkMinLength(lname,"Last name");
125
//                bValid = bValid && checkMinLength(street1,"Street");
126
//                bValid = bValid && checkMinLength(str_nr1,"Street No");
127
//                bValid = bValid && checkMinLength(postal,"Postalcode");
128
//                bValid = bValid && checkMinLength(city,"City");
129
                //bValid = bValid && checkMinLength(email,"E-Mail");
130
 
131
 
132
                if ( bValid )
133
                {
134
                    daten=$('.edit_address').serializeArray();
135
                    //Shows which address was choosen true/false
136
                    $.ajax({
137
                        type: "POST",
138
                        url: "/edit_address.php?mode=save",
139
                        data: daten
140
                    }).done(function( html ){
141
                        resultArr=html.split("|");
142
                        resultCode=resultArr[0];
143
                        resultText=resultArr[1];
144
                        tips.html(resultText);
145
                        if(resultCode!=1)
146
                        {
147
                            $("#new_addr_dialog").dialog("close");
148
                            window.location.reload();
149
                        }
150
                    });
151
                }
152
            },
153
        }
154
    });
155
    $('#edit_addr_dialog_bill').dialog(
156
    {
157
        autoOpen:false,
158
        height: "auto",
159
        width: "auto",
160
        modal:true,
161
        resizable:false,
162
        show:"fade",
163
        hide:"fade",
164
        buttons:
165
        {
166
            'Adresse speichern': function()
167
            {
168
 
169
                daten=$('#edit_address').serializeArray();
170
                //Shows which address was choosen true/false
171
                $.ajax({
172
                    type: "POST",
173
                    url: "/edit_address.php?mode=save",
174
                    data: daten
175
                }).done(function( html ){
176
                    $(".changeBillingAddressDialogAlt").load("/edit_address.php?mode=showAdress");
177
                    $("#edit_addr_dialog_bill").dialog("close");
178
                });
179
 
180
            },
181
            'Abbrechen':function(){
182
                $(this).dialog("close");
183
            }
184
        }
185
    });
186
 
187
    $('#edit_addr_dialog_ship').dialog(
188
    {
189
        autoOpen:false,
190
        height: "auto",
191
        width: "auto",
192
        modal:true,
193
        resizable:false,
194
        show:"fade",
195
        hide:"fade",
196
        buttons:
197
        {
198
            'Adresse speichern': function()
199
            {
200
 
201
                daten=$('#edit_address').serializeArray();
202
                //Shows which address was choosen true/false
203
                $.ajax({
204
                    type: "POST",
205
                    url: "/edit_address.php?mode=save",
206
                    data: daten
207
                }).done(function( html ){
208
 
209
                    $(".changeShippingAddressDialogAlt").load("/edit_address.php?mode=showAdress&type=ship");
210
                    $("#edit_addr_dialog_ship").dialog("close");
211
                });
212
 
213
            },
214
            'Abbrechen':function(){
215
                $(this).dialog("close");
216
            }
217
        }
218
    });
219
 
220
    $('#del_address_dialog,.del_address_dialog').dialog({
221
        autoOpen: false,
222
        height: "auto",
223
        width: "auto",
224
        modal: true,
225
        resizable: false,
226
        show:"fade",
227
        hide:"fade",
228
        title: 'Adresse löschen',
229
        open: function() {
230
            $(this).html("Möchten Sie diese Adresse wirklich löschen?");
231
        },
232
        buttons:
233
        {
234
            'Nein': function(){
235
                $(this).dialog('close');
236
            },
237
            'Ja': function(){
238
                $('.addresses').load("/del_address.php", data);
239
                $(this).dialog('close');
240
            }
241
        }
242
    });
243
 
244
    $('.new_addr_basket').click(new_address);
245
 
246
    $('#edit_addr_basket').click(function(){
247
        idArray = $(this).attr("id").split("_");
248
        adressID = idArray[0];
249
 
250
        edit_address(adressID);
251
    });
252
 
253
    $('#my_address_book').click(function(){
254
        $(location).attr('href','/?mode=addresses&type=buy');
255
    });
256
    $('#continue_buy').click(function(){
257
        $(location).attr("href","bestellen_seite_1.html");
258
    });
259
 
260
 
261
    $('#change_address_billing').click(function(){
262
        $(location).attr("href","bestellen_seite_1.html");
263
    });
264
    $('#change_address_shipping').click(function(){
265
        $(location).attr("href","bestellen_seite_1.html");
266
    });
267
 
268
 
269
    //$('#list_billing_addr').change(upd_land);
270
    $('#list_shipping_addr').change(upd_land).change();
271
 
272
    $( "button",".new"  ).button({
273
        icons: {
274
            primary: "ui-icon-plus"
275
        }
276
    });
277
    $( "input:button" ).button();
278
 
279
    $( "#tabsBasket .trash" ).click(function(event){
280
        event.stopImmediatePropagation();
281
        event.preventDefault();
282
        var id = $(this).attr("id");
283
        var idsplit = id.split("_");
284
        var adressID = idsplit[1];
285
 
286
        del_address(adressID);
287
    });
288
 
289
    $( "#accordionBasket .trash" ).click(function(event){
290
        event.stopImmediatePropagation();
291
        event.preventDefault();
292
        var id = $(this).attr("id");
293
        var idsplit = id.split("_");
294
        var adressID = idsplit[1];
295
 
296
        del_address(adressID);
297
    });
298
 
299
 
300
    $( "#tabsBasket .edit" ).click(function(event){
301
        event.stopImmediatePropagation();
302
        event.preventDefault();
303
        var id = $(this).attr("id");
304
        var idsplit = id.split("_");
305
        var adressID = idsplit[1];
306
 
307
        edit_address(adressID);
308
    });
309
 
310
    $( "#accordionBasket .edit" ).click(function(event){
311
        event.stopImmediatePropagation();
312
        event.preventDefault();
313
        var id = $(this).attr("id");
314
        var idsplit = id.split("_");
315
        var adressID = idsplit[1];
316
 
317
        edit_address(adressID);
318
    });
319
 
320
 
321
});
322
function add_to_list(data)
323
{
324
    ret=data.split("|");
325
    code=ret[0];
326
    adresse=ret[1];
327
 
328
    if(code==0)
329
    {
330
        $('#list_billing_addr').append(adresse);
331
        $('#list_shipping_addr').append(adresse);
332
 
333
        $('#new_addr_dialog').dialog("close");
334
    }
335
    else
336
    {
337
        $( "#validateTips" ).html(adresse);
338
    }
339
}
340
function del_address(adressID)
341
{
342
    data = new Array();
343
 
344
    data.push({ name: "mode", value: "delete" });
345
    data.push({ name: "id", value: adressID });
346
 
347
    $('#del_address_dialog').dialog("open");
348
}
349
function edit_address(adressID)
350
{
351
    var data = new Array();
352
    data.push({ name: "mode", value: "edit" });
353
    data.push({ name: "id", value: adressID });
354
 
355
    $('.addresses').load("/edit_address.php",data);
356
}
357
function new_address()
358
{
359
    var data = new Array();
360
    data.push({ name: "mode", value: "edit" });
361
    data.push({ name: "id", value: '' });
362
 
363
    $('.addresses').load("edit_address.php",data);
364
}
365
 
366
function upd_land()
367
{
368
    addr_id=$(this).val();
369
    $.ajax({
370
        url: "/get_land_id.php?a_id="+addr_id,
371
        success:function(land_id){
372
            $('#liefer_Land').val(land_id).change();
373
            $.ajax({
374
                url: "/change_currency.php?l_id="+land_id
375
            });
376
        }
377
    });
378
}
379