- /**
- * DropZone
- * Used for uploading images
- */
- ngApp.directive('dropZone', [function () {
- return {
- restrict: 'E',
- template: dropZoneTemplate,
- scope: {
- uploadUrl: '@',
- eventSuccess: '=',
- eventError: '=',
- uploadedTo: '@'
- },
- link: function (scope, element, attrs) {
- var dropZone = new DropZone(element[0].querySelector('.dropzone-container'), {
- url: scope.uploadUrl,
- init: function () {
- var dz = this;
- dz.on('sending', function (file, xhr, data) {
- var token = window.document.querySelector('meta[name=token]').getAttribute('content');
- data.append('_token', token);
- var uploadedTo = typeof scope.uploadedTo === 'undefined' ? 0 : scope.uploadedTo;
- data.append('uploaded_to', uploadedTo);
- });
- if (typeof scope.eventSuccess !== 'undefined') dz.on('success', scope.eventSuccess);
- dz.on('success', function (file, data) {
- $(file.previewElement).fadeOut(400, function () {
- dz.removeFile(file);
- });
- });
- if (typeof scope.eventError !== 'undefined') dz.on('error', scope.eventError);
- dz.on('error', function (file, errorMessage, xhr) {
- console.log(errorMessage);
- console.log(xhr);
- function setMessage(message) {
- $(file.previewElement).find('[data-dz-errormessage]').text(message);
- }
+ if (lineContent.indexOf(start) === 0 && lineContent.slice(-end.length) === end) {
+ newLineContent = lineContent.slice(start.length, lineContent.length - end.length);
+ } else {
+ newLineContent = `${start}${lineContent}${end}`;
+ }