Blame view

frontend/web/js/script.js 11.9 KB
3bc9af21   Yarik   Layout
1
2
3
4
  $(document).ready(function(){

      footer();

      cabinet();

      formsHome();

f1b535e4   Yarik   Datepicker
5
      initDatePicker();

3bc9af21   Yarik   Layout
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
  

      function footer(){

          footerBottom();

          resizeFooterBottom();

  

          function footerBottom(){

              var heightHeader = $('.section-box-header').height()

              var heightFooter = $('.section-box-footer').height()

              var windowHeight = $(window).height()

              $('.section-box-content').css({minHeight:windowHeight-heightHeader-heightFooter})

          }

  

          function resizeFooterBottom(){

              $(window).resize(function(){

                  footerBottom();

              })

          }

      }

      

      function cabinet() {

          sidebar();

          forms();

          tabsContentOiv();

  

          function sidebar() {

7f0970a7   Yarik   Layout
31
32
33
              $('.second-list a').click(function(e) {

                  e.stopPropagation();

              });

3bc9af21   Yarik   Layout
34
              $('.list-cab li').click(function (e) {

7f0970a7   Yarik   Layout
35
36
37
                  if($(this).hasClass('disabled')) {

                      e.preventDefault();

                      return false;

3bc9af21   Yarik   Layout
38
                  }

7f0970a7   Yarik   Layout
39
40
41
42
43
44
45
                  var dropDownList = $(this).find('ul').length;

                  if(dropDownList){

                      e.preventDefault();

                      $('.list-cab li').removeClass('active-li');

                      $(this).addClass('active-li');

                  }

              });

3bc9af21   Yarik   Layout
46
  

3bc9af21   Yarik   Layout
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
          }

          function forms() {

              if($('.phone-input input').length){

                  $('.phone-input input').mask('+38 (000) 000 00 00');

              }

          }

          function tabsContentOiv() {

              $('.oiv-list li').click(function (e) {

                  e.preventDefault()

                  if($(this).hasClass('active-list-oiv')){

  

                  } else {

                      $('.table-wrapp-2').after('<div id="preload-cab"><div></div></div>')

                      $('.oiv-list li').removeClass('active-list-oiv')

                      $(this).addClass('active-list-oiv')

  

                      var thisNum = $(this).index()

                      var cabContent = $('.hidden-tables-oiv')

  

  

                      setTimeout(function () {

                          cabContent.removeClass('active-tab-oiv')

                          $(cabContent[thisNum]).addClass('active-tab-oiv')

                          $('#preload-cab').remove()

                      },800)

                  }

              })

          }

      }

  

      function formsHome() {

          $('.btn_login, .btn_login_2').click(function (e) {

b6741a94   Yarik   Login
79
80
81
              if($(this).hasClass('login_user')) {

                  return true;

              }

3bc9af21   Yarik   Layout
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
              e.preventDefault()

              var pos = ($(window).scrollTop())+20

              $('#overlay').fadeIn(400,

                  function(){

                      $('#login_form')

                          .css('display', 'block')

                          .animate({opacity: 1, top: pos}, 200);

                  });

          })

  

          $('#modal_close, #overlay').click( function(){

              $('.forms_').animate({opacity: 0, top: '0'}, 200,function(){

                  $(this).css('display', 'none');

                  $('#overlay').fadeOut(400);

              });

          });

  

          $('.btn_register').click( function(e){

              e.preventDefault()

              var pos = ($(window).scrollTop())+20

              $('#login_form').animate({opacity: 0, top: '-50px'}, 200,function(){

                  $('#register_form')

                      .css('display', 'block')

                      .animate({opacity: 1, top: pos}, 200);

              });

          });

  

  

  

          $('#login_form form button').click(function (e) {

              if($('#input-1').val().length<1){

                  e.preventDefault()

                  $('#input-1').addClass('errors')

              } else {

                  $('#input-1').removeClass('errors')

              }

              if($('#input-2').val().length<1){

                  e.preventDefault()

                  $('#input-2').addClass('errors')

              } else {

                  $('#input-2').removeClass('errors')

              }

          })

  

          $('#register_form form button').click(function (e) {

              if($('#input-3').val().length<1){

                  e.preventDefault()

                  $('#input-3').addClass('errors')

              } else {

                  $('#input-3').removeClass('errors')

              }

              if($('#input-4').val().length<1){

                  e.preventDefault()

                  $('#input-4').addClass('errors')

              } else {

                  $('#input-4').removeClass('errors')

              }

              if($('#input-5').val().length<1){

                  e.preventDefault()

                  $('#input-5').addClass('errors')

              } else {

                  $('#input-5').removeClass('errors')

              }

          })

      }

30e3d244   Yarik   Forms
147
148
149
150
151
152
  

      $(document).on('beforeSubmit', '#personal-form', function(e) {

          postForm(this);

          return false;

      });

  

3533e4e9   Yarik   Forms
153
154
155
156
157
      $(document).on('beforeSubmit', '#users-add-form', function(e) {

          postForm(this, true, 'users-table', true, true);

          return false;

      });

  

30e3d244   Yarik   Forms
158
159
160
161
162
      $(document).on('beforeSubmit', '#passport-form', function(e) {

          postForm(this);

          return false;

      });

  

43cb22d0   Yarik   Property
163
164
165
166
167
      $(document).on('beforeSubmit', '#property-form', function(e) {

          postForm(this);

          return false;

      });

  

f1b535e4   Yarik   Datepicker
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
      $(document).on('pjax:complete', function() {

          initDatePicker();

      });

  

      function initDatePicker() {

          $('._datepicer, ._datepicker')

              .datepicker(

                  {

                      changeMonth: true,

                      changeYear: true,

                      dateFormat: 'dd.mm.yy',

                      closeText: 'Закрыть',

                      prevText: 'Пред',

                      nextText: 'След',

                      monthNames: [

                          'Январь',

                          'Февраль',

                          'Март',

                          'Апрель',

                          'Май',

                          'Июнь',

                          'Июль',

                          'Август',

                          'Сентябрь',

                          'Октябрь',

                          'Ноябрь',

                          'Декабрь'

                      ],

                      monthNamesShort: [

                          'Январь',

                          'Февраль',

                          'Март',

                          'Апрель',

                          'Май',

                          'Июнь',

                          'Июль',

                          'Август',

                          'Сентябрь',

                          'Октябрь',

                          'Ноябрь',

                          'Декабрь'

                      ],

                      dayNames: [

                          'воскресенье',

                          'понедельник',

                          'вторник',

                          'среда',

                          'четверг',

                          'пятница',

                          'суббота'

                      ],

                      dayNamesShort: [

                          'вск',

                          'пнд',

                          'втр',

                          'срд',

                          'чтв',

                          'птн',

                          'сбт'

                      ],

                      dayNamesMin: [

                          'Вс',

                          'Пн',

                          'Вт',

                          'Ср',

                          'Чт',

                          'Пт',

                          'Сб'

                      ],

                      firstDay: 1

                  }

              );

      }

  

3533e4e9   Yarik   Forms
242
      function postForm(context, reload_pjax, pjax, close, reset) {

30e3d244   Yarik   Forms
243
244
245
246
247
248
          $.post($(context).attr('action'), $(context).serialize(), function(data) {

              var type;

              if(data.error) {

                  type = 'danger';

              } else {

                  type = 'success';

3533e4e9   Yarik   Forms
249
250
251
252
253
254
                  if(close) {

                      tryClose(context);

                  }

                  if(reset) {

                      context.reset();

                  }

30e3d244   Yarik   Forms
255
256
              }

              showStatus(data.message, type);

3533e4e9   Yarik   Forms
257
258
259
260
261
262
263
              if(reload_pjax) {

                  if(pjax) {

                      reload(pjax);

                  } else {

                      reload($(context).parents('.pjax_container').attr('id'));

                  }

              }

30e3d244   Yarik   Forms
264
265
266
          }.bind(this));

      }

  

3533e4e9   Yarik   Forms
267
268
269
270
      function tryClose(context) {

          $(context).parents('.modal').modal('hide');

      }

  

30e3d244   Yarik   Forms
271
272
273
274
275
276
277
278
279
280
281
282
      function showStatus(txt, type) {

          $.notify({

              message: txt

          }, {

              type: type

          });

      }

  

      function reload(id) {

          $('#'+id).prepend('<div class="preloader"></div>');

          $.pjax.reload('#'+id);

      }

dcfb3d5c   Alexey Boroda   -Form ajax ready
283
284
285
286
287
288
289
290
291
292
293
  

      $(document).on('beforeSubmit', '#add-int-prop-form', function() {

          $.post($(this).attr('action'), $(this).serialize(), function(data) {

              var type;

              if(data.error) {

                  type = 'danger';

              } else {

                  type = 'success';

              }

              $('#add-composition-modal').modal('hide');

              showStatus(data.message, type);

fb0f9630   Alexey Boroda   -Greed ready
294
              $.pjax.reload('#int-prop-greed');

dcfb3d5c   Alexey Boroda   -Form ajax ready
295
296
297
298
299
              document.getElementById('add-int-prop-form').reset();

          });

  

          return false;

      });

0d91ef5d   Alexey Boroda   -Delete action added
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
  

      $(document).on('beforeSubmit', '#add-role-form', function() {

          $.post($(this).attr('action'), $(this).serialize(), function(data) {

              var type;

              if(data.error) {

                  type = 'danger';

              } else {

                  type = 'success';

              }

              $('#add-role-modal').modal('hide');

              showStatus(data.message, type);

              $.pjax.reload('#roles-table');

              document.getElementById('add-role-form').reset();

          });

  

          return false;

      });

  

9e523ea9   Alexey Boroda   -Update ready
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
      $(document).on('submit', '#update-role-form', function() {

          $.post($(this).attr('action'), $(this).serialize(), function(data) {

              var type;

              if(data.error) {

                  type = 'danger';

              } else {

                  type = 'success';

              }

              $('#update-role-modal').modal('hide');

              showStatus(data.message, type);

              $.pjax.reload('#roles-table');

              $('#update-role-modal').html('');

          });

  

          return false;

      });

  

0d91ef5d   Alexey Boroda   -Delete action added
335
336
      $(document).on('click', '.delete-role', function(e) {

          e.preventDefault();

aebb725c   Alexey Boroda   -List ready
337
          confirm('Удалить роль?');

0d91ef5d   Alexey Boroda   -Delete action added
338
339
340
          $.post('delete-role', {

              id:$(this).attr('data-id')

          }, function(data) {

aebb725c   Alexey Boroda   -List ready
341
342
343
344
345
346
347
348
349
350
              var type;

              if(data.error) {

                  type = 'danger';

              } else {

                  type = 'success';

              }

              showStatus(data.message, type);

              $.pjax.reload('#roles-table');

          });

      });

0d91ef5d   Alexey Boroda   -Delete action added
351
  

9e523ea9   Alexey Boroda   -Update ready
352
353
354
355
356
357
358
359
360
361
      $(document).on('click', '.update-role', function(e) {

          e.preventDefault();

          $.post('get-role-form', {

              id:$(this).attr('data-id')

          }, function(data) {

              $('#update-role-modal').html(data.answer);

              $('#update-role-modal').modal('show');

          });

      });

  

aebb725c   Alexey Boroda   -List ready
362
363
364
365
366
367
368
369
370
371
372
373
374
375
      $(document).on('click', '.remove-int-prop', function(e) {

          e.preventDefault();

          confirm('Удалить элемент?');

          $.post('delete-int-property', {

              id:$(this).attr('data-id')

          }, function(data) {

              var type;

              if(data.error) {

                  type = 'danger';

              } else {

                  type = 'success';

              }

              showStatus(data.message, type);

              $.pjax.reload('#int-property-table');

0d91ef5d   Alexey Boroda   -Delete action added
376
377
          });

      });

3bc9af21   Yarik   Layout
378
379
380
381
382
  });