mirror of
https://github.com/sismics/docs.git
synced 2025-12-21 05:31:42 +00:00
Closes #79: UI: Change background and logo image
This commit is contained in:
@@ -18,5 +18,36 @@ angular.module('docs').controller('SettingsTheme', function($scope, $rootScope,
|
||||
stylesheet.href = stylesheet.href.replace(/\?.*|$/, '?' + new Date().getTime());
|
||||
$rootScope.appName = $scope.theme.name;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Send an image
|
||||
$scope.sendingImage = false;
|
||||
$scope.sendImage = function(type, image) {
|
||||
// Build the payload
|
||||
var formData = new FormData();
|
||||
formData.append('image', image);
|
||||
|
||||
// Send the file
|
||||
var done = function() {
|
||||
$scope.$apply(function() {
|
||||
$scope.sendingImage = false;
|
||||
$scope[type] = null;
|
||||
});
|
||||
};
|
||||
$scope.sendingImage = true;
|
||||
$.ajax({
|
||||
type: 'PUT',
|
||||
url: '../api/theme/image/' + type,
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function() {
|
||||
done();
|
||||
},
|
||||
error: function() {
|
||||
done();
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -10,12 +10,11 @@ angular.module('docs').directive('file', function() {
|
||||
replace: true,
|
||||
require: 'ngModel',
|
||||
link: function(scope, element, attr, ctrl) {
|
||||
var listener = function() {
|
||||
element.bind('change', function() {
|
||||
scope.$apply(function() {
|
||||
attr.multiple ? ctrl.$setViewValue(element[0].files) : ctrl.$setViewValue(element[0].files[0]);
|
||||
attr.multiple ? ctrl.$setViewValue(element[0].files) : ctrl.$setViewValue(element[0].files[0]);
|
||||
});
|
||||
}
|
||||
element.bind('change', listener);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -12,7 +12,7 @@
|
||||
<label class="col-sm-2 control-label" for="inputColor">Main color</label>
|
||||
<div class="col-sm-1">
|
||||
<span colorpicker class="btn btn-default" id="inputColor" on-hide="update()"
|
||||
data-color="" ng-model="theme.color" ng-style="{ 'background': theme.color }"> </span>
|
||||
data-color="" ng-model="theme.color" ng-style="{ 'background': theme.color }"> </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -23,4 +23,41 @@
|
||||
id="inputCss" ng-model="theme.css" ng-blur="update()"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="inputLogo">Logo</label>
|
||||
<div class="col-sm-2">
|
||||
<file accept="image/gif,image/png,image/jpg,image/jpeg"
|
||||
class="form-control" id="inputLogo" ng-model="logo" ng-disabled="sendingImage" />
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<button class="btn btn-default" ng-click="sendImage('logo', logo)" ng-disabled="sendingImage || !logo">
|
||||
<span class="glyphicon glyphicon-save"></span>
|
||||
Send
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="inputBackground">Background image</label>
|
||||
<div class="col-sm-2">
|
||||
<file accept="image/gif,image/png,image/jpg,image/jpeg"
|
||||
class="form-control" id="inputLogo" ng-model="background" ng-disabled="sendingImage" />
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<button class="btn btn-default" ng-click="sendImage('background', background)" ng-disabled="sendingImage || !background">
|
||||
<span class="glyphicon glyphicon-save"></span>
|
||||
Send
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-10">
|
||||
<p class="form-control-static text-info" ng-if="sendingImage">
|
||||
Uploading the image...
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
Reference in New Issue
Block a user