|
|
|
@ -35100,7 +35100,7 @@ function () {
|
|
|
|
|
err: err
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}); //(updated) ? resolve("UPDATED") : reject("NOT UPDATED");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
_this.db.postList.update(Number(id), {
|
|
|
|
@ -35121,100 +35121,6 @@ function () {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
key: "sync",
|
|
|
|
|
value: function sync(files) {
|
|
|
|
|
var self = this;
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
var syncData = new FormData();
|
|
|
|
|
var postList = '';
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
|
var file = files[i]; // Check the file type.
|
|
|
|
|
|
|
|
|
|
if (!file.type.match('image.*')) {
|
|
|
|
|
continue;
|
|
|
|
|
} // Add the file to the request.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
syncData.append('feature_image', file, file.name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var fipamoPosts = new _dexie.default("fipamo_posts");
|
|
|
|
|
fipamoPosts.version(1).stores({
|
|
|
|
|
postList: 'id,post'
|
|
|
|
|
});
|
|
|
|
|
fipamoPosts.postList.toArray(function (array) {
|
|
|
|
|
self.dataUtils.request('/api/post/sync', DataEvent.POSTS_SYNCED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_JSON, array).then(function (response) {
|
|
|
|
|
resolve({
|
|
|
|
|
response: response
|
|
|
|
|
});
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
reject({
|
|
|
|
|
err: err
|
|
|
|
|
});
|
|
|
|
|
}); //console.log("LIST", postList);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
key: "submitPost",
|
|
|
|
|
value: function submitPost(edit, uploadFiles) {
|
|
|
|
|
var self = this;
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
//collect form data
|
|
|
|
|
//if(!this.validateForm())
|
|
|
|
|
var postData = new FormData(); //let projectImages = document.getElementById('projectImages');
|
|
|
|
|
//var fileSelect = projectImages;
|
|
|
|
|
|
|
|
|
|
var files = uploadFiles;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
|
var file = files[i]; // Check the file type.
|
|
|
|
|
|
|
|
|
|
if (!file.type.match('image.*')) {
|
|
|
|
|
continue;
|
|
|
|
|
} // Add the file to the request.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
postData.append('feature_image', file, file.name);
|
|
|
|
|
} //var category = document.getElementById("content_category");
|
|
|
|
|
//let project_form = document.forms.namedItem("folio-project");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var txt = document.createElement("textarea");
|
|
|
|
|
txt.innerHTML = document.getElementById('edit-post-text').innerHTML;
|
|
|
|
|
postData.append("title", document.getElementById('post_title').value);
|
|
|
|
|
postData.append('slug', new _StringUtils.default().cleanString(document.getElementById('post_title').value));
|
|
|
|
|
postData.append("post_plaintext", txt.value);
|
|
|
|
|
postData.append("origin_date", document.getElementById('post-date').value);
|
|
|
|
|
postData.append("tags", document.getElementById('post_tags').value);
|
|
|
|
|
postData.append("status_page", document.getElementById('option-page').getAttribute('data-active'));
|
|
|
|
|
postData.append("status_feature", document.getElementById('option-feature').getAttribute('data-active'));
|
|
|
|
|
postData.append("status_published", document.getElementById('option-published').getAttribute('data-active'));
|
|
|
|
|
var postURL;
|
|
|
|
|
var postEventType;
|
|
|
|
|
|
|
|
|
|
if (edit) {
|
|
|
|
|
var postID = document.getElementById('edit-update').getAttribute('data-id');
|
|
|
|
|
postURL = "/api/post/update/" + postID;
|
|
|
|
|
postEventType = DataEvent.POST_UPDATED;
|
|
|
|
|
} else {
|
|
|
|
|
postURL = "/api/post/add";
|
|
|
|
|
postEventType = DataEvent.POST_ADDED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.dataUtils.request(postURL, postEventType, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_FORM, postData).then(function (response) {
|
|
|
|
|
resolve({
|
|
|
|
|
response: response
|
|
|
|
|
});
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
reject({
|
|
|
|
|
err: err
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
key: "deletePost",
|
|
|
|
|
value: function deletePost() {
|
|
|
|
@ -37287,8 +37193,8 @@ function () {
|
|
|
|
|
this.editor.addListener(EditorEvent.EDITOR_SAVE, function (f) {
|
|
|
|
|
return _this.handleEditorOptions(EditorEvent.EDITOR_SAVE);
|
|
|
|
|
}, false);
|
|
|
|
|
document.getElementById('post-image').addEventListener('change', function (e) {
|
|
|
|
|
return _this.handlePostImageAdd(e);
|
|
|
|
|
document.getElementById('post-image-upload').addEventListener('change', function (e) {
|
|
|
|
|
self.handleImageUpload(e.target.id, e.target.files);
|
|
|
|
|
}, false);
|
|
|
|
|
(0, _tinyDatePicker.default)(document.getElementById('post-date'), {
|
|
|
|
|
mode: 'dp-below',
|
|
|
|
@ -37323,15 +37229,15 @@ function () {
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
if (document.getElementById('featured-image-drop')) {
|
|
|
|
|
document.getElementById('featured-image-drop').addEventListener('dragover', this.handleDragOver, false);
|
|
|
|
|
document.getElementById('featured-image-drop').addEventListener('drop', this.handleDrop, false);
|
|
|
|
|
document.getElementById('featured-click').addEventListener('change', function (e) {
|
|
|
|
|
return _this2.handleFeatureImageAdd(e);
|
|
|
|
|
document.getElementById('featured-image-drop').addEventListener('dragover', this.handleImageActions, false);
|
|
|
|
|
document.getElementById('featured-image-drop').addEventListener('drop', this.handleImageActions, false);
|
|
|
|
|
document.getElementById('featured-image-upload').addEventListener('change', function (e) {
|
|
|
|
|
return _this2.handleImageActions(e);
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
if (document.getElementById('new-upload-link')) {
|
|
|
|
|
document.getElementById('new-upload-link').addEventListener('click', function (e) {
|
|
|
|
|
document.getElementById('featured-click').click();
|
|
|
|
|
if (document.getElementById('new-feature-upload')) {
|
|
|
|
|
document.getElementById('new-feature-upload').addEventListener('click', function (e) {
|
|
|
|
|
document.getElementById('featured-image-upload').click();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -37380,7 +37286,6 @@ function () {
|
|
|
|
|
switch (e) {
|
|
|
|
|
case EditorEvent.EDITOR_SAVE:
|
|
|
|
|
new _PostActions.default().update(this.postID, this.post, PostEditor.uploadFiles, this.postFinalKey).then(function (response) {
|
|
|
|
|
//console.log(response.bounce.newPost);
|
|
|
|
|
var freshDB = new _dexie.default("fipamo_posts");
|
|
|
|
|
freshDB.version(1).stores({
|
|
|
|
|
postList: 'id, post'
|
|
|
|
@ -37389,7 +37294,7 @@ function () {
|
|
|
|
|
freshDB.postList.get(Number(response.bounce.newPost)).then(function (obj) {
|
|
|
|
|
window.location = "/@/dashboard/posts/edit/" + obj.post.slug;
|
|
|
|
|
});
|
|
|
|
|
}, 200); //this.editor.notify(DataEvent.POST_UPDATED, this.postID);
|
|
|
|
|
}, 200);
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
console.log("ERROR", err);
|
|
|
|
|
});
|
|
|
|
@ -37417,47 +37322,84 @@ function () {
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EditorEvent.EDITOR_UPLOAD_POST_IMAGE:
|
|
|
|
|
document.getElementById('post-image').click();
|
|
|
|
|
document.getElementById('post-image-upload').click();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
key: "handleDragOver",
|
|
|
|
|
value: function handleDragOver(e) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
key: "handleDrop",
|
|
|
|
|
value: function handleDrop(e) {
|
|
|
|
|
key: "handleImageActions",
|
|
|
|
|
value: function handleImageActions(e) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
PostEditor.uploadFiles = e.dataTransfer.files; //console.log(MemberArea.uploadFiles.length);
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) {
|
|
|
|
|
// Only process image files.
|
|
|
|
|
if (!f.type.match('image.*')) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
switch (e.type) {
|
|
|
|
|
case "dragover":
|
|
|
|
|
e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
|
|
|
|
|
|
|
|
|
|
var reader = new FileReader(); // Closure to capture the file information.
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
reader.onload = function (theFile) {
|
|
|
|
|
return function (f) {
|
|
|
|
|
// Render thumbnail.
|
|
|
|
|
var span = document.createElement('span');
|
|
|
|
|
span.innerHTML = ['<img src="', f.target.result, '" title="', escape(theFile.name), '"/>'].join(''); //document.getElementById('featured-image-drop').insertBefore(span, null);
|
|
|
|
|
case "change":
|
|
|
|
|
case "drop":
|
|
|
|
|
e.type == "drop" ? PostEditor.uploadFiles = e.dataTransfer.files : PostEditor.uploadFiles = e.target.files;
|
|
|
|
|
|
|
|
|
|
document.getElementById('featured-image-drop').innerHTML = '';
|
|
|
|
|
document.getElementById('featured-image-drop').appendChild(span);
|
|
|
|
|
};
|
|
|
|
|
}(f); // Read in the image file as a data URL.
|
|
|
|
|
for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) {
|
|
|
|
|
// Only process image files.
|
|
|
|
|
if (!f.type.match('image.*')) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var reader = new FileReader(); // Closure to capture the file information.
|
|
|
|
|
|
|
|
|
|
reader.readAsDataURL(f);
|
|
|
|
|
reader.onload = function (theFile) {
|
|
|
|
|
return function (f) {
|
|
|
|
|
// Render thumbnail.
|
|
|
|
|
var image = document.createElement('img');
|
|
|
|
|
image.src = f.target.result;
|
|
|
|
|
image.title = escape(theFile.name);
|
|
|
|
|
var span = document.createElement('div');
|
|
|
|
|
span.innerHTML = ['<img src="', f.target.result, '" title="', escape(theFile.name), '"/>'].join(''); //document.getElementById('featured-image-drop').insertBefore(span, null);
|
|
|
|
|
|
|
|
|
|
document.getElementById('featured-image-drop').innerHTML = '';
|
|
|
|
|
document.getElementById('featured-image-drop').appendChild(image);
|
|
|
|
|
};
|
|
|
|
|
}(f); // Read in the image file as a data URL.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reader.readAsDataURL(f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e.target.id == "featured-image-upload") this.handleImageUpload(e.target.id, PostEditor.uploadFiles);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
key: "handleImageUpload",
|
|
|
|
|
value: function handleImageUpload(type, files) {
|
|
|
|
|
var url = "";
|
|
|
|
|
var eventType = "";
|
|
|
|
|
var self = this;
|
|
|
|
|
type == "featured-image-upload" ? url = "/api/post/add-feature-image" : url = "/api/post/add-post-image";
|
|
|
|
|
type == "featured-image-upload" ? eventType = DataEvent.FEATURE_IMAGE_ADDED : eventType = DataEvent.POST_IMAGE_ADDED;
|
|
|
|
|
var imageData = new FormData();
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
|
var file = files[i]; // Check the file type.
|
|
|
|
|
|
|
|
|
|
if (!file.type.match('image.*')) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type == "featured-image-upload" ? imageData.append('feature_image', file, file.name) : imageData.append('post_image', file, file.name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.dataUtils.request(url, eventType, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_FORM, imageData).then(function (response) {
|
|
|
|
|
var r = JSON.parse(response.request['response']);
|
|
|
|
|
if (r.message == DataEvent.POST_IMAGE_ADDED) self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, r.url);
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
console.log(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
key: "handleFeatureImageAdd",
|
|
|
|
|
value: function handleFeatureImageAdd(e) {
|
|
|
|
|