forked from pikock/bootstrap-magic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrollers.js
More file actions
executable file
·161 lines (128 loc) · 4.77 KB
/
Copy pathcontrollers.js
File metadata and controls
executable file
·161 lines (128 loc) · 4.77 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* Controllers */
function LessCtrl($scope, $http, ap_less, $timeout) {
$scope.variables = {};
$scope.fonts = {};
var initLessVariables = function () {
$http.get('less/variables.json').success(function(data) {
if (window.localStorage) {
for (var key in window.localStorage) {
var url = "http://pikock.github.io/bootstrap-magic/twitter-bootstrap/less/bootstrap.less:timestamp"
if (key == url) {
delete window.localStorage[key];
};
}
};
$scope.variables = data;
$timeout(function() {
$scope.applyLess(false);
},0);
$timeout(function() {
// move into a service
var keys = ap_less.getKeys($scope);
var icons = ap_less.getUrls();
var font = ap_less.getFonts();
$timeout(function() {
var $colorpicker = $('.colorpicker');
$colorpicker.colorpicker().on('changeColor', function(ev){
var scope = angular.element(this).scope();
scope.variable.value = ev.color.toHex();
$timeout(function() {
if ($scope.autoapplyless){
$scope.autoApplyLess();
}
}, 500);
});
$('.lessVariable').each( function(index){
var scope = angular.element(this).scope();
switch ( scope.variable.type ) {
case 'icons':
var src = icons;
break;
case 'font':
var src = font;
break;
case 'color':
default:
var src = keys;
}
$(this).typeahead({
source: src,
updater: function (item) {
scope.variable.value = item;
return item;
}
});
});
},0);
},0);
});
};
initLessVariables();
$scope.autoapplyless = false;
$scope.autoApplyLess = function (event) {
if ($scope.autoapplyless){
var vars = ap_less.getVariables($scope, false);
less.modifyVars(vars.variables);
WebFont.load({
google: {
families: vars.fonts
}
});
}
};
$scope.applyLess = function (applyAll) {
var vars = ap_less.getVariables($scope, applyAll);
less.modifyVars(vars.variables);
WebFont.load({
google: {
families: vars.fonts
}
});
};
$scope.colorpicker = function(type) {
return (type == 'color') ? true : false;
}
$scope.color = function(type, value) {
return (type == 'color' && /^#[0-9a-f]{3}([0-9a-f]{3})?$/i.test(value) ) ? value : '#ffffff';
}
$scope.$on('applyLess', function() {
$scope.applyLess();
});
$scope.setIsViewLoading = function(val) {
$scope.isViewLoading = val;
};
$scope.minified = false;
$scope.saveCSS = function() {
ap_less.saveCSS($scope);
}
$scope.saveLessVariables = function () {
ap_less.saveLessVar(ap_less.getVariablesToString($scope));
};
$scope.resetLessVariables = function () {
initLessVariables();
setTimeout(function() {
$scope.applyLess();
},0);
};
$scope.importLessVariables= function (string) {
$scope = ap_less.importVariables($scope, string);
$scope.applyLess();
};
$scope.upDateValue = function () {
};
$scope.isViewLoading = false;
$scope.$on('$routeChangeStart', function() {
$scope.isViewLoading = true;
});
$scope.$on('$routeChangeSuccess', function() {
$scope.isViewLoading = false;
});
$scope.getGroupUrl = function() {
return 'preview/' + angular.lowercase(this.group.name).replace(/[^\w ]+/g,'').replace(/ +/g,'-') + '.html';
};
}
LessCtrl.$inject = ['$scope', '$http', 'ap_less', '$timeout'];
function PageCtrl($scope, $http, ap_less) {
}
PageCtrl.$inject = ['$scope', '$http', 'ap_less'];