-
Notifications
You must be signed in to change notification settings - Fork 1
/
telas.js
66 lines (59 loc) · 2.1 KB
/
telas.js
1
2
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
define([
'angular',
'modules/telas/config/routes',
'modules/telas/factory/pages',
'modules/telas/controller/lista',
'modules/telas/controller/show',
'modules/telas/directive/page',
'twbs/dropdown',
'twbs/modal'
], function(angular, Routes, PagesApiService, ListaController, ShowController, Page) {
'use strict';
var telas = angular.module('telas', []);
telas
.config(Routes)
.factory('PagesApiService', PagesApiService)
.controller('ListaController', ListaController)
.controller('ShowController', ShowController)
.directive('page', Page);
// Tela inicial
// Remove os informativos
$(document)
.on('click.informativo', '[data-remove="informativo"]', function(event) {
var $el = $(event.currentTarget);
$el.parent().remove();
})
.on('click.dropdown', '.dropdown-menu', function(event) {
var $el = $(event.currentTarget);
if ($el.hasClass('dropdown-menu-form')) {
event.stopPropagation();
}
})
.on('click.atalho', '[data-toggle="atalhos"]', function(event) {
var $el = $(event.currentTarget);
var method = ($el[0].checked) ? 'removeClass' : 'addClass';
$($el.data('target'))[method]('hidden');
// update || save
var atalhos = [];
var $checkboxes = $('[data-toggle="atalhos"]');
for (var i = 0, len = $checkboxes.length; i < len; i++) {
atalhos.push({
target: $checkboxes[i].getAttribute('data-target'),
enable: $checkboxes[i].checked
});
}
$.ajax({
url: '/data/save.json',
data: {
'userId': 123,
'atalhos': atalhos
}
}).done(function(res) {
if (res.success)
console.log('atualizado', res, atalhos);
}).fail(function() {
console.log('fail');
});
});
return telas;
});