Completed
Pull Request — master (#9)
by Anton
02:24
created

bluz.categories.js ➔ ... ➔ loadTree   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
/**
2
 * @author   Viacheslav Nogin
3
 * @created  11.09.12 10:30
4
 */
5
/* global define,require */
6
define(['jquery', 'bluz', 'bluz.notify', 'bluz.tools', 'bluz.ajax'], function ($, bluz, notify, tools) {
7
  'use strict';
8
9
  function loadTree() {
10
    $('.tree-wrapper').load('/categories/tree .tree-container', {id: $('.select-tree select').val()});
11
  }
12
13
  function reload() {
14
    window.location = window.location.href;
15
  }
16
17
  $(function () {
18
    $('.category-page-wrapper').on('change', '.select-tree select', loadTree);
19
20
    $('body')
21
      .on('success.bluz.dialog', '.create', loadTree)
22
      .on('success.bluz.dialog', '.create-root', reload)
23
      .on('success.bluz.dialog', '.edit', loadTree)
24
      .on('success.bluz.ajax', '.delete', loadTree)
25
      .on('success.bluz.ajax', '.delete-root', reload)
26
      .on('blur', '#name', function () {
27
        let $alias = $('#alias');
28
        if ($alias.val() === '') {
29
          let title = tools.alias($(this).val());
30
          $alias.val(title);
31
        }
32
      });
33
  });
34
35
  return {};
36
});
37