@ -197,7 +197,7 @@ exports.default = _default;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = exports . SETTINGS_UPDATED = exports . LOCAL _DB _READY = exports . POSTS _SYNCED = exports . POST _DELETED = exports . POST _UPDATED = exports . POST _ADDED = exports . POST _ERROR = exports . FEATURE _IMAGE _ADDED = exports . POST _IMAGE _ADDED = exports . PROJECTS _SORTED = exports . PROJECT _ADDED = exports . PROJECT _UPDATED = exports . ARCHIVES _ENTRY _LOADED = exports . ARCHIVES _PAGE _LOADED = exports . ARCHIVES _JSON _LOADED = exports . HTML _LOADED = exports . SETTINGS _LOADED = exports . IMG _REQUEST _LAME = exports . IMG _REQUEST _GOOD = exports . REQUEST _LAME = exports . REQUEST _GOOD = void 0 ;
exports . default = exports . AVATAR_UPLOADED = exports . SETTINGS_UPDATED = exports . LOCAL _DB _READY = exports . POSTS _SYNCED = exports . POST _DELETED = exports . POST _UPDATED = exports . POST _ADDED = exports . POST _ERROR = exports . FEATURE _IMAGE _ADDED = exports . POST _IMAGE _ADDED = exports . PROJECTS _SORTED = exports . PROJECT _ADDED = exports . PROJECT _UPDATED = exports . ARCHIVES _ENTRY _LOADED = exports . ARCHIVES _PAGE _LOADED = exports . ARCHIVES _JSON _LOADED = exports . HTML _LOADED = exports . SETTINGS _LOADED = exports . IMG _REQUEST _LAME = exports . IMG _REQUEST _GOOD = exports . REQUEST _LAME = exports . REQUEST _GOOD = void 0 ;
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
@ -243,6 +243,8 @@ var LOCAL_DB_READY = 'localDBReady';
exports . LOCAL _DB _READY = LOCAL _DB _READY ;
var SETTINGS _UPDATED = 'settingsUpdated' ;
exports . SETTINGS _UPDATED = SETTINGS _UPDATED ;
var AVATAR _UPLOADED = 'avatarUploaded' ;
exports . AVATAR _UPLOADED = AVATAR _UPLOADED ;
var DataEvent = function DataEvent ( ) {
_classCallCheck ( this , DataEvent ) ;
@ -8388,6 +8390,12 @@ exports.default = void 0;
var _SettingsActions = _interopRequireDefault ( require ( "../actions/SettingsActions" ) ) ;
var _DataUtils = _interopRequireWildcard ( require ( "../../../../../brain/tools/utilities/DataUtils" ) ) ;
var DataEvent = _interopRequireWildcard ( require ( "../../../../../brain/tools/events/DataEvent" ) ) ;
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 _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
@ -8406,6 +8414,7 @@ function () {
_classCallCheck ( this , SettingsIndex ) ;
this . start ( ) ;
this . dataUtils = new _DataUtils . default ( ) ;
} //--------------------------
// methods
//--------------------------
@ -8414,6 +8423,7 @@ function () {
_createClass ( SettingsIndex , [ {
key : "start" ,
value : function start ( ) {
var self = this ;
document . getElementById ( 'save-toggle' ) . addEventListener ( 'click' , function ( f ) {
return new _SettingsActions . default ( ) . save ( ) . then ( function ( response ) {
console . log ( response ) ;
@ -8421,17 +8431,52 @@ function () {
console . log ( err ) ;
} ) ;
} ) ;
document . getElementById ( 'avatar' ) . addEventListener ( 'click' , function ( e ) {
document . getElementById ( 'avatar-upload' ) . click ( ) ;
} ) ;
document . getElementById ( 'avatar-upload' ) . addEventListener ( 'change' , function ( e ) {
self . handleImageUpload ( e . target . id , e . target . files ) ;
} , false ) ;
} //--------------------------
// event handlers
//--------------------------
} , {
key : "handleImageUpload" ,
value : function handleImageUpload ( type , files ) {
var url = "" ;
var eventType = "" ;
var self = this ;
type == "avatar-upload" ? url = "/api/settings/add-avatar" : url = "/api/settings/add-feature-background" ; //(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 == "avatar-upload" ? imageData . append ( 'avatar_upload' , file , file . name ) : imageData . append ( 'background_upload' , 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 . AVATAR _UPLOADED ) {
document . getElementById ( 'avatar' ) . src = r . url ;
}
} ) . catch ( function ( err ) { //console.log(err)
} ) ;
}
} ] ) ;
return SettingsIndex ;
} ( ) ;
exports . default = SettingsIndex ;
} , { "../actions/SettingsActions" : "actions/SettingsActions.js" } ] , "controllers/DashManager.js" : [ function ( require , module , exports ) {
} , { "../actions/SettingsActions" : "actions/SettingsActions.js" ,"../../../../../brain/tools/utilities/DataUtils" : "../../../../brain/tools/utilities/DataUtils.js" , "../../../../../brain/tools/events/DataEvent" : "../../../../brain/tools/events/DataEvent.js" }] , "controllers/DashManager.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {