/
admintheme.form.angular.js
107 lines (87 loc) · 3.28 KB
/
admintheme.form.angular.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
services.factory('IClickToCallFormFactory', ['$http','$q',function ($http, $q) {
this.getHash = function(){
var deferred = $q.defer();
$http.get(WWW_DIR_JAVASCRIPT + 'theme/gethash').then(function(data) {
deferred.resolve(data.data);
},function(){
deferred.reject('error');
});
return deferred.promise;
};
this.deleteResource = function(id, resource, itemId){
var deferred = $q.defer();
$http.get(WWW_DIR_JAVASCRIPT + 'theme/deleteresource/'+id+'/'+resource+'/'+itemId).then(function(data) {
deferred.resolve(data.data);
},function(){
deferred.reject('error');
});
return deferred.promise;
};
return this;
}]);
lhcAppControllers.controller('IClickToCallFormGenerator',['$scope','$http','$location','$rootScope', '$log','IClickToCallFormFactory', function($scope, $http, $location, $rootScope, $log,IClickToCallFormFactory) {
this.staticResources = {};
this.staticJSResources = {};
this.staticCSSResources = {};
// Resource name in static resource
this.static_content_name = '';
this.static_js_content_name = '';
this.static_css_content_name = '';
var that = this;
this.addStaticResource = function() {
IClickToCallFormFactory.getHash().then(function(data){
that.staticResources[data.hash] = {
'name' : that.static_content_name,
'hash' : data.hash
};
that.static_content_name = '';
});
}
this.addStaticJSResource = function() {
IClickToCallFormFactory.getHash().then(function(data){
that.staticJSResources[data.hash] = {
'name' : that.static_js_content_name,
'hash' : data.hash
};
that.static_js_content_name = '';
});
}
this.addStaticCSSResource = function() {
IClickToCallFormFactory.getHash().then(function(data){
that.staticCSSResources[data.hash] = {
'name' : that.static_css_content_name,
'hash' : data.hash
};
that.static_css_content_name = '';
});
}
this.deleteStaticResource = function(id,field) {
var removedItem = that.staticResources[field.hash];
IClickToCallFormFactory.deleteResource(id,'static_content',removedItem.hash).then(function(data){
});
delete that.staticResources[field.hash];
};
this.deleteStaticJSResource = function(id,field) {
var removedItem = that.staticJSResources[field.hash];
IClickToCallFormFactory.deleteResource(id,'static_js_content',removedItem.hash).then(function(data){
});
delete that.staticJSResources[field.hash];
};
this.deleteStaticCSSResource = function(id,field) {
var removedItem = that.staticCSSResources[field.hash];
IClickToCallFormFactory.deleteResource(id,'static_css_content',removedItem.hash).then(function(data){
});
delete that.staticCSSResources[field.hash];
};
this.initVariables = function () {
if (window.PersonalTheme.staticResources) {
this.staticResources = window.PersonalTheme.staticResources;
}
if (window.PersonalTheme.staticJSResources) {
this.staticJSResources = window.PersonalTheme.staticJSResources;
}
if (window.PersonalTheme.staticCSSResources) {
this.staticCSSResources = window.PersonalTheme.staticCSSResources;
}
}
}]);