Repository navigation
Expand file tree
/
Copy pathconfig.js
More file actions
82 lines (64 loc) · 2.01 KB
/
Copy pathconfig.js
File metadata and controls
82 lines (64 loc) · 2.01 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(function(){
sources = {
"1": {
icon: "https://d3oypxn00j2a10.cloudfront.net/0.15.4/favicon_whale.png",
url: "http://www.google.com.br"
},
"2": {
icon: "https://d3oypxn00j2a10.cloudfront.net/0.15.4/favicon_whale.png",
url: "http://www.techtudo.com.br"
},
"3":{
icon: "https://d3oypxn00j2a10.cloudfront.net/0.15.4/favicon_whale.png",
url: "http://www.kabum.com.br"
},
"4":{
icon: "https://d3oypxn00j2a10.cloudfront.net/0.15.4/favicon_whale.png",
url: "http://www.uol.com.br"
},
"5":{
icon: "https://d3oypxn00j2a10.cloudfront.net/0.15.4/favicon_whale.png",
url: "http://www.teste.com.br"
}};
var app = angular.module("postModule", []);
app.directive("configDirective", function(){
return {
restrict: "E",
templateUrl: "config-directive.html",
controller: ['$scope', function($scope){
this.sources = [];
this.loadSources = function(){
this.sources = sources;
this.new_source = {url: "", icon: ""};
this.sources["new"] = this.new_source;
this.dataLoaded = true;
} ;
this.limitStr = function(text, size){
if (!size)
size = 15;
if( text.length > size){
return text.slice(0, size) + " ...";
}
return text;
};
this.saveSource = function(){
this.new_source.icon = "http://cdn.sstatic.net/stackoverflow/img/favicon.ico?v=00a326f96f68";
this.sources["new"] = this.new_source;
this.new_source = {url: "", icon: ""};
console.log(this.sources);
};
this.removeSource = function(id){
delete this.sources[id]
};
this.isValid = function(source){
if (source.url){
return true;
}
return false;
};
this.loadSources();
}],
controllerAs: "cfgCtrl"
}//return
});//configDirective
})();