@ -670,7 +670,7 @@ function () {
var postEventType ;
if ( edit ) {
var postID = document . getElementById ( ' post-sumbit-btn ') . getAttribute ( 'data-id' ) ;
var postID = document . getElementById ( ' option-update ') . getAttribute ( 'data-id' ) ;
postURL = "/api/blog/update/" + postID ;
postEventType = DataEvent . POST _UPDATED ;
} else {
@ -689,6 +689,24 @@ function () {
} ) ;
} ) ;
}
} , {
key : "deletePost" ,
value : function deletePost ( ) {
var self = this ;
var postID = document . getElementById ( 'option-update' ) . getAttribute ( 'data-id' ) ;
return new Promise ( function ( resolve , reject ) {
self . dataUtils . request ( "/api/blog/delete/" + postID , DataEvent . POST _DELETED , _DataUtils . REQUEST _TYPE _POST , _DataUtils . CONTENT _TYPE _FORM ) . then ( function ( response ) {
resolve ( {
response : response
} ) ;
} ) . catch ( function ( err ) {
reject ( {
err : err
} ) ;
} ) ;
} ) ;
this . dataUtils . re ;
}
} , {
key : "validateForm" ,
value : function validateForm ( ) {
@ -710,7 +728,33 @@ function () {
} ( ) ;
exports . default = EntryTasks ;
} , { "../tools/utilities/DataUtils" : "tools/utilities/DataUtils.jsx" , "../tools/events/DataEvent" : "tools/events/DataEvent.jsx" , "../tools/utilities/StringUtils" : "tools/utilities/StringUtils.jsx" } ] , "tools/utilities/DateUtils.jsx" : [ function ( require , module , exports ) {
} , { "../tools/utilities/DataUtils" : "tools/utilities/DataUtils.jsx" , "../tools/events/DataEvent" : "tools/events/DataEvent.jsx" , "../tools/utilities/StringUtils" : "tools/utilities/StringUtils.jsx" } ] , "tools/events/EditorEvent.jsx" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = exports . EDITOR _UPDATE = exports . EDITOR _SAVE = exports . EDITOR _UPLOAD _POST _IMAGE = exports . EDITOR _DELETE = void 0 ;
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
var EDITOR _DELETE = 'editorDelete' ;
exports . EDITOR _DELETE = EDITOR _DELETE ;
var EDITOR _UPLOAD _POST _IMAGE = 'editorUploadImage' ;
exports . EDITOR _UPLOAD _POST _IMAGE = EDITOR _UPLOAD _POST _IMAGE ;
var EDITOR _SAVE = 'editorSave' ;
exports . EDITOR _SAVE = EDITOR _SAVE ;
var EDITOR _UPDATE = 'editorUpdate' ;
exports . EDITOR _UPDATE = EDITOR _UPDATE ;
var EditorEvent = function EditorEvent ( ) {
_classCallCheck ( this , EditorEvent ) ;
} ;
var _default = new EditorEvent ( ) ;
exports . default = _default ;
} , { } ] , "tools/utilities/DateUtils.jsx" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
@ -1293,43 +1337,66 @@ Object.defineProperty(exports, "__esModule", {
} ) ;
exports . default = void 0 ;
var _DataUtils = _interopRequireWildcard ( require ( "./DataUtils" ) ) ;
var DataEvent = _interopRequireWildcard ( require ( "../events/DataEvent" ) ) ;
var _DateUtils = _interopRequireDefault ( require ( "./DateUtils" ) ) ;
var _caretPos = require ( "caret-pos" ) ;
var _Animate = _interopRequireDefault ( require ( "../effects/Animate" ) ) ;
var _EventEmitter2 = _interopRequireDefault ( require ( "../events/EventEmitter" ) ) ;
var EditorEvent = _interopRequireWildcard ( require ( "../events/EditorEvent" ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
function _interopRequireWildcard ( obj ) { if ( obj && obj . _ _esModule ) { return obj ; } else { var newObj = { } ; if ( obj != null ) { for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = Object . defineProperty && Object . getOwnPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : { } ; if ( desc . get || desc . set ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } } newObj . default = obj ; return newObj ; } }
function _typeof ( obj ) { if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) { _typeof = function _typeof ( obj ) { return typeof obj ; } ; } else { _typeof = function _typeof ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ; } return _typeof ( obj ) ; }
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
function _defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } }
function _createClass ( Constructor , protoProps , staticProps ) { if ( protoProps ) _defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) _defineProperties ( Constructor , staticProps ) ; return Constructor ; }
function _possibleConstructorReturn ( self , call ) { if ( call && ( _typeof ( call ) === "object" || typeof call === "function" ) ) { return call ; } return _assertThisInitialized ( self ) ; }
function _getPrototypeOf ( o ) { _getPrototypeOf = Object . setPrototypeOf ? Object . getPrototypeOf : function _getPrototypeOf ( o ) { return o . _ _proto _ _ || Object . getPrototypeOf ( o ) ; } ; return _getPrototypeOf ( o ) ; }
function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function" ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , writable : true , configurable : true } } ) ; if ( superClass ) _setPrototypeOf ( subClass , superClass ) ; }
function _setPrototypeOf ( o , p ) { _setPrototypeOf = Object . setPrototypeOf || function _setPrototypeOf ( o , p ) { o . _ _proto _ _ = p ; return o ; } ; return _setPrototypeOf ( o , p ) ; }
function _assertThisInitialized ( self ) { if ( self === void 0 ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return self ; }
var TextEditor =
/*#__PURE__*/
function ( ) {
function ( _EventEmitter ) {
_inherits ( TextEditor , _EventEmitter ) ;
//--------------------------
// constructor
//--------------------------
function TextEditor ( ) {
function TextEditor ( textEditor , scrollLimit ) {
var _this ;
_classCallCheck ( this , TextEditor ) ;
this . setInputs ( ) ;
hljs . initHighlightingOnLoad ( ) ;
this . dataUtils = new _DataUtils . default ( ) ;
this . dateUtils = new _DateUtils . default ( ) ;
this . url = '' ;
var self = this ;
_this = _possibleConstructorReturn ( this , _getPrototypeOf ( TextEditor ) . call ( this ) ) ;
hljs . initHighlightingOnLoad ( ) ; //this.dataUtils = new DataUtils();
_this . dateUtils = new _DateUtils . default ( ) ;
_this . textEditor = textEditor ;
_this . fixLimit = scrollLimit ;
_this . caretPos = null ;
_this . url = '' ;
var self = _assertThisInitialized ( _assertThisInitialized ( _this ) ) ;
_this . setInputs ( ) ;
window . addEventListener ( "scroll" , function ( f ) {
var fixLimit = document . getElementById ( 'header' ) . offsetHeight + document . getElementById ( 'entry-header' ) . offsetHeight + document . getElementById ( 'entry-feature' ) . offsetHeight ;
var fixLimit = _this . fixLimi t;
if ( window . pageYOffset >= fixLimit ) {
document . getElementById ( 'edit-control' ) . style . position = "fixed" ;
@ -1337,7 +1404,10 @@ function () {
document . getElementById ( 'edit-control' ) . style . position = "relative" ;
}
} ) ;
this . refresh ( ) ;
_this . refresh ( ) ;
return _this ;
} //--------------------------
// methods
//--------------------------
@ -1346,53 +1416,67 @@ function () {
_createClass ( TextEditor , [ {
key : "setInputs" ,
value : function setInputs ( ) {
var _this = this ;
var _this 2 = this ;
var self = this ;
var editorButtons = document . querySelectorAll ( '.editor-button' ) ;
for ( var i = 0 , length = editorButtons . length ; i < length ; i ++ ) {
editorButtons [ i ] . addEventListener ( 'click' , function ( e ) {
return _this . handleEditorOption ( e ) ;
return _this 2 . handleEditorOption ( e ) ;
} , false ) ;
}
document . getElementById ( 'edit-text-code' ) . addEventListener ( 'input' , function ( f ) {
this . textEditor . addEventListener ( 'input' , function ( f ) {
self . refresh ( ) ;
} ) ;
document . getElementById ( 'post-image' ) . addEventListener ( 'change' , function ( e ) {
return _this . handlePostImageAdd ( e ) ;
} , false ) ;
document . getElementById ( 'option-image' ) . addEventListener ( 'click' , function ( e ) {
document . getElementById ( 'post-image' ) . click ( ) ;
} ) ;
}
} , {
key : "refresh" ,
value : function refresh ( ) {
var caret = ( 0 , _caretPos . position ) ( document . getElementById ( 'edit-text-code' ) ) . pos ;
var spiffed = hljs . highlight ( 'markdown' , document . getElementById ( 'edit-text-code' ) . innerText ) . value ;
var caret = ( 0 , _caretPos . position ) ( this . textEditor ) . pos ;
var spiffed = hljs . highlight ( 'markdown' , this . textEditor . innerText ) . value ;
var temp = document . createElement ( "div" ) ;
temp . innerText = spiffed ;
document . getElementById ( 'edit-text-code' ) . innerHTML = temp . innerText ;
( 0 , _caretPos . position ) ( document . getElementById ( 'edit-text-code' ) , caret ) ;
this . textEditor . innerHTML = temp . innerText ;
( 0 , _caretPos . position ) ( this . textEditor , caret ) ;
}
} , {
key : "notify" ,
value : function notify ( type ) {
value : function notify ( type , data ) {
switch ( type ) {
case DataEvent . POST _UPDATED :
document . getElementById ( 'submit- sav e') . classList . add ( 'icon-hide' ) ;
document . getElementById ( 'submit- updat e') . classList . add ( 'icon-hide' ) ;
document . getElementById ( 'submit-good' ) . classList . remove ( 'icon-hide' ) ;
document . getElementById ( ' post-sumbit-btn ') . classList . remove ( 'submit-start' ) ;
document . getElementById ( ' post-sumbit-btn ') . classList . add ( 'submit-cool' ) ;
document . getElementById ( ' option-update ') . classList . remove ( 'submit-start' ) ;
document . getElementById ( ' option-update ') . classList . add ( 'submit-cool' ) ;
setTimeout ( function ( f ) {
document . getElementById ( 'submit- sav e') . classList . remove ( 'icon-hide' ) ;
document . getElementById ( 'submit- updat e') . classList . remove ( 'icon-hide' ) ;
document . getElementById ( 'submit-good' ) . classList . add ( 'icon-hide' ) ;
document . getElementById ( ' post-sumbit-btn ') . classList . add ( 'submit-start' ) ;
document . getElementById ( ' post-sumbit-btn ') . classList . remove ( 'submit-cool' ) ;
document . getElementById ( ' option-update ') . classList . add ( 'submit-start' ) ;
document . getElementById ( ' option-update ') . classList . remove ( 'submit-cool' ) ;
} , 2000 ) ;
break ;
case DataEvent . POST _ADDED :
window . location = "/@/dashboard/entries/edit/" + data ;
break ;
case EditorEvent . EDITOR _UPLOAD _POST _IMAGE :
( 0 , _caretPos . position ) ( this . textEditor , this . caretPos ) ;
var sel , range , pulled ;
sel = window . getSelection ( ) ; //console.log(sel)
//console.log(note.message)
if ( sel . rangeCount ) {
range = sel . getRangeAt ( 0 ) ;
pulled = sel . getRangeAt ( 0 ) . toString ( ) ;
range . deleteContents ( ) ;
range . insertNode ( document . createTextNode ( "![image alt text](" + data + " 'image title')" ) ) ;
}
this . refresh ( ) ;
break ;
}
} //--------------------------
// event handlers
@ -1436,12 +1520,27 @@ function () {
range . insertNode ( document . createTextNode ( "### " + pulled ) ) ;
break ;
case "option-image" :
this . caretPos = ( 0 , _caretPos . position ) ( this . textEditor ) . pos ;
this . emitEvent ( EditorEvent . EDITOR _UPLOAD _POST _IMAGE ) ;
break ;
case "submit-save" :
case "option-save" :
this . emitEvent ( EditorEvent . EDITOR _SAVE ) ;
break ;
case "submit-update" :
case "option-update" :
this . emitEvent ( EditorEvent . EDITOR _UPDATE ) ;
break ;
case "option-link" :
range . insertNode ( document . createTextNode ( "[" + pulled + "](PASTE URL HERE)" ) ) ;
break ;
case "option-date" :
console . log ( "DATE UPDATE" ) ;
case "option-d ele te":
this . emitEvent ( EditorEvent . EDITOR _DELETE ) ;
break ;
default :
@ -1452,53 +1551,14 @@ function () {
this . refresh ( ) ;
}
} , {
key : "handlePostImageAdd" ,
value : function handlePostImageAdd ( e ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
var self = this ;
var postData = new FormData ( ) ;
var files = e . target . files ;
for ( var i = 0 ; i < files . length ; i ++ ) {
var file = files [ i ] ; // Check the file type.
if ( ! file . type . match ( 'image.*' ) ) {
continue ;
}
postData . append ( 'post_image' , file , file . name ) ;
}
var caret = ( 0 , _caretPos . position ) ( document . getElementById ( 'edit-text-code' ) ) . pos ;
self . dataUtils . request ( "/api/blog/add-post-image" , DataEvent . POST _IMAGE _ADDED , _DataUtils . REQUEST _TYPE _POST , _DataUtils . CONTENT _TYPE _FORM , postData ) . then ( function ( response ) {
//console.log("01 "+response.request['response']);
( 0 , _caretPos . position ) ( document . getElementById ( 'edit-text-code' ) , caret ) ;
var sel , range , pulled ;
sel = window . getSelection ( ) ; //console.log(sel)
//console.log(note.message)
if ( sel . rangeCount ) {
range = sel . getRangeAt ( 0 ) ;
pulled = sel . getRangeAt ( 0 ) . toString ( ) ;
range . deleteContents ( ) ;
range . insertNode ( document . createTextNode ( "![image alt text](" + JSON . parse ( response . request [ 'response' ] ) . url + " 'image title')" ) ) ;
}
self . refresh ( ) ;
} ) . catch ( function ( err ) {
console . log ( err ) ;
} ) ;
}
} ] ) ;
return TextEditor ;
} ( ) ;
} ( _EventEmitter2 . default ) ;
var _default = TextEditor ;
exports . default = _default ;
} , { ". /DataUtils": "tools/utilities/DataUtils.jsx" , ". ./events/DataEvent": "tools/events/DataEvent.jsx" , "./DateUtils" : "tools/utilities/DateUtils.jsx" , "caret-pos" : "../../../../node_modules/caret-pos/lib/esm2015/main.js" , "../e ffects/Animate": "tools/effects/Animate .jsx"} ] , "../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js" : [ function ( require , module , exports ) {
} , { "../events/DataEvent" : "tools/events/DataEvent.jsx" , "./DateUtils" : "tools/utilities/DateUtils.jsx" , "caret-pos" : "../../../../node_modules/caret-pos/lib/esm2015/main.js" , "../events/EventEmitter" : "tools/events/EventEmitter.jsx" , "../events/EditorEvent" : "tools/events/EditorEvent.jsx" } ] , "../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js" : [ function ( require , module , exports ) {
var define ;
var global = arguments [ 3 ] ;
( function ( global , factory ) {
@ -2719,6 +2779,8 @@ var Ease = _interopRequireWildcard(require("../tools/effects/Animate"));
var _EntryTasks = _interopRequireDefault ( require ( "../tasks/EntryTasks" ) ) ;
var EditorEvent = _interopRequireWildcard ( require ( "../tools/events/EditorEvent" ) ) ;
var _TextEditor = _interopRequireDefault ( require ( "../tools/utilities/TextEditor" ) ) ;
var _tinyDatePicker = _interopRequireDefault ( require ( "tiny-date-picker" ) ) ;
@ -2742,14 +2804,33 @@ function () {
// constructor
//--------------------------
function Entry ( ) {
var _this = this ;
_classCallCheck ( this , Entry ) ;
reframe ( 'iframe' ) ;
var self = this ;
this . uploadFiles ;
this . start ( ) ;
this . editor = new _TextEditor . default ( ) ;
this . dataUtils = new _DataUtils . default ( ) ;
this . dateUtils = new _DateUtils . default ( ) ;
if ( document . getElementById ( 'edit-text-code' ) ) {
this . editor = new _TextEditor . default ( document . getElementById ( 'edit-text-code' ) , document . getElementById ( 'header' ) . offsetHeight + document . getElementById ( 'entry-header' ) . offsetHeight + document . getElementById ( 'entry-feature' ) . offsetHeight ) ;
this . editor . addListener ( EditorEvent . EDITOR _DELETE , function ( f ) {
return _this . handleEditorOptions ( EditorEvent . EDITOR _DELETE ) ;
} , false ) ;
this . editor . addListener ( EditorEvent . EDITOR _UPLOAD _POST _IMAGE , function ( f ) {
return _this . handleEditorOptions ( EditorEvent . EDITOR _UPLOAD _POST _IMAGE ) ;
} , false ) ;
this . editor . addListener ( EditorEvent . EDITOR _UPDATE , function ( f ) {
return _this . handleEditorOptions ( EditorEvent . EDITOR _UPDATE ) ;
} , false ) ;
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 ) ;
} , false ) ;
( 0 , _tinyDatePicker . default ) ( document . getElementById ( 'entry-date' ) , {
mode : 'dp-below' ,
format : function format ( date ) {
@ -2757,6 +2838,9 @@ function () {
return self . dateUtils . getDate ( 'origin' , date ) ;
}
} ) ;
}
this . start ( ) ;
} //--------------------------
// methods
//--------------------------
@ -2797,23 +2881,48 @@ function () {
document . getElementById ( 'featured-click' ) . click ( ) ;
} ) ;
}
}
} //--------------------------
// event handlers
//--------------------------
} , {
key : "handleEditorOptions" ,
value : function handleEditorOptions ( e ) {
var _this2 = this ;
document . getElementById ( "post-sumbit-btn" ) . addEventListener ( 'click' , function ( f ) {
f . preventDefault ( ) ;
switch ( e ) {
case EditorEvent . EDITOR _SAVE :
case EditorEvent . EDITOR _UPDATE :
var edit = false ;
if ( f . target . getAttribute ( 'data-action' ) == 'blog-update' ) edit = true ;
if ( e == EditorEvent . EDITOR _UPDATE ) edit = true ;
new _EntryTasks . default ( ) . submitPost ( edit , Entry . uploadFiles ) . then ( function ( response ) {
var note = JSON . parse ( response [ 'response' ] [ 'request' ] . response ) ;
self . editor . notify ( note . message ) ;
_this2 . editor . notify ( note . message , note . postID ) ;
} ) . catch ( function ( err ) {
console . log ( err ) ;
} ) ;
break ;
case EditorEvent . EDITOR _DELETE :
if ( confirm ( 'Aye! You know you\'re deleting this post, right?' ) ) {
new _EntryTasks . default ( ) . deletePost ( ) . then ( function ( response ) {
var note = JSON . parse ( response [ 'response' ] [ 'request' ] . response ) ;
window . location = "/@/dashboard/entries/" ; //console.log(note);
} ) . catch ( function ( err ) {
console . log ( err ) ;
} ) ;
} else { // Do nothing!
}
} //--------------------------
// event handlers
//--------------------------
break ;
case EditorEvent . EDITOR _UPLOAD _POST _IMAGE :
document . getElementById ( 'post-image' ) . click ( ) ;
break ;
}
}
} , {
key : "handleDragOver" ,
value : function handleDragOver ( e ) {
@ -2882,6 +2991,31 @@ function () {
reader . readAsDataURL ( f ) ;
}
}
} , {
key : "handlePostImageAdd" ,
value : function handlePostImageAdd ( e ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
var self = this ;
var postData = new FormData ( ) ;
var files = e . target . files ;
for ( var i = 0 ; i < files . length ; i ++ ) {
var file = files [ i ] ; // Check the file type.
if ( ! file . type . match ( 'image.*' ) ) {
continue ;
}
postData . append ( 'post_image' , file , file . name ) ;
}
this . dataUtils . request ( "/api/blog/add-post-image" , DataEvent . POST _IMAGE _ADDED , _DataUtils . REQUEST _TYPE _POST , _DataUtils . CONTENT _TYPE _FORM , postData ) . then ( function ( response ) {
self . editor . notify ( EditorEvent . EDITOR _UPLOAD _POST _IMAGE , JSON . parse ( response . request [ 'response' ] ) . url ) ;
} ) . catch ( function ( err ) {
console . log ( err ) ;
} ) ;
}
} ] ) ;
return Entry ;
@ -2889,7 +3023,7 @@ function () {
exports . default = Entry ;
Entry . uploadFiles = [ ] ;
} , { "../tools/utilities/DataUtils" : "tools/utilities/DataUtils.jsx" , "../tools/events/DataEvent" : "tools/events/DataEvent.jsx" , "../tools/effects/Animate" : "tools/effects/Animate.jsx" , "../tasks/EntryTasks" : "tasks/EntryTasks.jsx" , "../tools/ utilities/TextEditor": "tools/utilities/TextEditor.jsx" , "tiny-date-picker" : "../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js" , "../tools/utilities/DateUtils" : "tools/utilities/DateUtils.jsx" } ] , "controllers/DisplayManager.jsx" : [ function ( require , module , exports ) {
} , { "../tools/utilities/DataUtils" : "tools/utilities/DataUtils.jsx" , "../tools/events/DataEvent" : "tools/events/DataEvent.jsx" , "../tools/effects/Animate" : "tools/effects/Animate.jsx" , "../tasks/EntryTasks" : "tasks/EntryTasks.jsx" , "../tools/ events/EditorEvent": "tools/events/EditorEvent.jsx" , "../tools/ utilities/TextEditor": "tools/utilities/TextEditor.jsx" , "tiny-date-picker" : "../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js" , "../tools/utilities/DateUtils" : "tools/utilities/DateUtils.jsx" } ] , "controllers/DisplayManager.jsx" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {