Skip to content

Commit 73da747

Browse files
author
Thierry Charbonnel
committed
download
1 parent 319a8c5 commit 73da747

2 files changed

Lines changed: 52 additions & 17 deletions

File tree

app/js/controllers.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,13 @@ function LessCtrl($scope, $http, ap_less) {
7878

7979
$scope.minified = false;
8080

81+
8182
$scope.saveCSS = function() {
82-
$scope.isViewLoading = true;
83-
var parser = new(less.Parser)({
84-
paths: ['../twitter-bootstrap/less/'], // Specify search paths for @import directives
85-
filename: 'bootstrap.less' // Specify a filename, for better error messages
86-
});
87-
$(document).load($('#twitterBootstrapLess').attr('href'), function (data) {
88-
parser.parse(data, function (err, tree) {
89-
if (err) { return console.error(err) }
90-
//tree.toCSS({ compress: true }); // Minify CSS output
91-
//console.log($scope.minified);
92-
console.log(tree.toCSS({ compress: $scope.minified }));
93-
//console.log(tree.toCSS({ compress: true })); // Minify CSS output
94-
});
95-
});
96-
$scope.isViewLoading = false;
83+
ap_less.saveCSS($scope);
9784
}
9885

9986
$scope.saveLessVariables = function () {
100-
console.log(ap_less.getVariablesToString($scope));
87+
ap_less.saveLessVar(ap_less.getVariablesToString($scope));
10188
};
10289

10390
$scope.resetLessVariables = function () {

app/js/services.js

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ angular.module('bootstrapVariablesEditor.services', []).
9191
lessEngine.getVariablesToString = function ($scope) {
9292
var string = "" +
9393
"/*\n"+
94-
"* pickok, autreplanete \n"+
94+
"* pikock, autreplanete \n"+
95+
"* \n"+
9596
"**/\n";
97+
9698
for (var i = 0; i < $scope.variables.length; i++ ) {
9799
string += '\n\n// ' + $scope.variables[i].name + "\n"
98100
for (var j = 0; j < $scope.variables[i].data.length; j++ ) {
@@ -102,5 +104,51 @@ angular.module('bootstrapVariablesEditor.services', []).
102104
return string;
103105
};
104106

107+
lessEngine.saveLessVar = function(data){
108+
var $form = $('<form>').attr('method', 'POST').attr('action', 'http://bootstrapmagic-pikock.dotcloud.com/').append(
109+
$('<input>')
110+
.attr('type', 'hidden')
111+
.attr('name', 'data')
112+
.attr('value', data)
113+
).
114+
append(
115+
$('<input>')
116+
.attr('type', 'hidden')
117+
.attr('name', 'type')
118+
.attr('value', 'less')
119+
);
120+
$('body').append($form);
121+
$form.submit();
122+
};
123+
124+
lessEngine.saveCSS = function($scope){
125+
var parser = new(less.Parser)({
126+
paths: ['../twitter-bootstrap/less/'], // Specify search paths for @import directives
127+
filename: 'bootstrap.less' // Specify a filename, for better error messages
128+
});
129+
$(document).load($('#twitterBootstrapLess').attr('href'), function (data) {
130+
parser.parse(data, function (err, tree) {
131+
if (err) { return console.error(err) }
132+
var type = ($scope.minified) ? 'mincss' : 'css';
133+
var css = tree.toCSS({ compress: $scope.minified });
134+
var $form = $('<form>').attr('method', 'POST').attr('action', 'http://bootstrapmagic-pikock.dotcloud.com/').
135+
append(
136+
$('<input>')
137+
.attr('type', 'hidden')
138+
.attr('name', 'data')
139+
.attr('value', css)
140+
).
141+
append(
142+
$('<input>')
143+
.attr('type', 'hidden')
144+
.attr('name', 'type')
145+
.attr('value', type)
146+
);
147+
$('body').append($form);
148+
$form.submit();
149+
});
150+
});
151+
};
152+
105153
return lessEngine;
106154
});

0 commit comments

Comments
 (0)