// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
parcelRequire = ( function ( modules , cache , entry , globalName ) {
// Save the require from previous bundle to this closure if any
var previousRequire = typeof parcelRequire === 'function' && parcelRequire ;
var nodeRequire = typeof require === 'function' && require ;
function newRequire ( name , jumped ) {
if ( ! cache [ name ] ) {
if ( ! modules [ name ] ) {
// if we cannot find the module within our internal map or
// cache jump to the current global require ie. the last bundle
// that was added to the page.
var currentRequire = typeof parcelRequire === 'function' && parcelRequire ;
if ( ! jumped && currentRequire ) {
return currentRequire ( name , true ) ;
}
// If there are other bundles on this page the require from the
// previous one is saved to 'previousRequire'. Repeat this as
// many times as there are bundles until the module is found or
// we exhaust the require chain.
if ( previousRequire ) {
return previousRequire ( name , true ) ;
}
// Try the node require function if it exists.
if ( nodeRequire && typeof name === 'string' ) {
return nodeRequire ( name ) ;
}
var err = new Error ( 'Cannot find module \'' + name + '\'' ) ;
err . code = 'MODULE_NOT_FOUND' ;
throw err ;
}
localRequire . resolve = resolve ;
localRequire . cache = { } ;
var module = cache [ name ] = new newRequire . Module ( name ) ;
modules [ name ] [ 0 ] . call ( module . exports , localRequire , module , module . exports , this ) ;
}
return cache [ name ] . exports ;
function localRequire ( x ) {
return newRequire ( localRequire . resolve ( x ) ) ;
}
function resolve ( x ) {
return modules [ name ] [ 1 ] [ x ] || x ;
}
}
function Module ( moduleName ) {
this . id = moduleName ;
this . bundle = newRequire ;
this . exports = { } ;
}
newRequire . isParcelRequire = true ;
newRequire . Module = Module ;
newRequire . modules = modules ;
newRequire . cache = cache ;
newRequire . parent = previousRequire ;
newRequire . register = function ( id , exports ) {
modules [ id ] = [ function ( require , module ) {
module . exports = exports ;
} , { } ] ;
} ;
var error ;
for ( var i = 0 ; i < entry . length ; i ++ ) {
try {
newRequire ( entry [ i ] ) ;
} catch ( e ) {
// Save first error but execute all entries
if ( ! error ) {
error = e ;
}
}
}
if ( entry . length ) {
// Expose entry point to Node, AMD or browser globals
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
var mainExports = newRequire ( entry [ entry . length - 1 ] ) ;
// CommonJS
if ( typeof exports === "object" && typeof module !== "undefined" ) {
module . exports = mainExports ;
// RequireJS
} else if ( typeof define === "function" && define . amd ) {
define ( function ( ) {
return mainExports ;
} ) ;
// <script>
} else if ( globalName ) {
this [ globalName ] = mainExports ;
}
}
// Override the current require with this new one
parcelRequire = newRequire ;
if ( error ) {
// throw error from earlier, _after updating parcelRequire_
throw error ;
}
return newRequire ;
} ) ( { "events/DataEvent.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = exports . SEND _MAIL = exports . API _INIT _LAME = exports . API _INIT _GOOD = exports . API _INIT = exports . API _RENDER _PAGES = exports . API _IMAGES _UPLOAD = exports . API _BACKUP _RESTORE = exports . API _BACKUP _DOWNLOAD = exports . API _BACKUP _CREATE = exports . API _SETTINGS _WRITE = exports . API _PAGE _DELETE = exports . API _PAGE _CREATE = exports . API _PAGE _WRITE = exports . UPLOAD _PROGRESS = exports . SITE _BACKGROUND _UPLOADED = exports . AVATAR _UPLOADED = exports . MENU _UPDATED = exports . MENU _DELETE _ITEM = exports . MENU _ADD _ITEM = exports . SETTINGS _NOT _UPDATED = exports . SETTINGS _UPDATED = exports . TAG _PAGES _NOT _RENDERED = exports . TAG _PAGES _RENDERED = exports . PAGES _NOT _RENDERED = exports . PAGES _RENDERED = exports . PAGE _DELETED = exports . PAGE _UPDATED = exports . PAGE _ADDED = exports . PAGE _ERROR = exports . FEATURE _IMAGE _ADDED = exports . POST _IMAGE _ADDED = exports . SETTINGS _LOADED = exports . IMG _REQUEST _LAME = exports . IMG _REQUEST _GOOD = exports . API _REQUEST _LAME = exports . API _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" ) ; } }
var REQUEST _GOOD = 'requestGood' ;
exports . REQUEST _GOOD = REQUEST _GOOD ;
var REQUEST _LAME = 'requestLame' ;
exports . REQUEST _LAME = REQUEST _LAME ;
var API _REQUEST _GOOD = 'apiUseAuthorized' ;
exports . API _REQUEST _GOOD = API _REQUEST _GOOD ;
var API _REQUEST _LAME = 'apiUseNotAuthorized' ;
exports . API _REQUEST _LAME = API _REQUEST _LAME ;
var IMG _REQUEST _GOOD = 'imgRequestGood' ;
exports . IMG _REQUEST _GOOD = IMG _REQUEST _GOOD ;
var IMG _REQUEST _LAME = 'imgRequestLame' ;
exports . IMG _REQUEST _LAME = IMG _REQUEST _LAME ;
var SETTINGS _LOADED = 'settingsLoaded' ;
exports . SETTINGS _LOADED = SETTINGS _LOADED ;
var POST _IMAGE _ADDED = 'postImageAdded' ;
exports . POST _IMAGE _ADDED = POST _IMAGE _ADDED ;
var FEATURE _IMAGE _ADDED = 'featureImageAdded' ;
exports . FEATURE _IMAGE _ADDED = FEATURE _IMAGE _ADDED ;
var PAGE _ERROR = 'postError' ;
exports . PAGE _ERROR = PAGE _ERROR ;
var PAGE _ADDED = 'postAdded' ;
exports . PAGE _ADDED = PAGE _ADDED ;
var PAGE _UPDATED = 'postUpdated' ;
exports . PAGE _UPDATED = PAGE _UPDATED ;
var PAGE _DELETED = 'postImageAdded' ;
exports . PAGE _DELETED = PAGE _DELETED ;
var PAGES _RENDERED = 'pagesRendered' ;
exports . PAGES _RENDERED = PAGES _RENDERED ;
var PAGES _NOT _RENDERED = 'pagesNotRendered' ;
exports . PAGES _NOT _RENDERED = PAGES _NOT _RENDERED ;
var TAG _PAGES _RENDERED = 'tagPagesRendered' ;
exports . TAG _PAGES _RENDERED = TAG _PAGES _RENDERED ;
var TAG _PAGES _NOT _RENDERED = 'tagPagesNotRendered' ;
exports . TAG _PAGES _NOT _RENDERED = TAG _PAGES _NOT _RENDERED ;
var SETTINGS _UPDATED = 'settingsUpdated' ;
exports . SETTINGS _UPDATED = SETTINGS _UPDATED ;
var SETTINGS _NOT _UPDATED = 'settingsNotUpdated' ;
exports . SETTINGS _NOT _UPDATED = SETTINGS _NOT _UPDATED ;
var MENU _ADD _ITEM = 'menuAddItem' ;
exports . MENU _ADD _ITEM = MENU _ADD _ITEM ;
var MENU _DELETE _ITEM = 'menuDeleteItem' ;
exports . MENU _DELETE _ITEM = MENU _DELETE _ITEM ;
var MENU _UPDATED = 'menuUpdated' ;
exports . MENU _UPDATED = MENU _UPDATED ;
var AVATAR _UPLOADED = 'avatarUploaded' ;
exports . AVATAR _UPLOADED = AVATAR _UPLOADED ;
var SITE _BACKGROUND _UPLOADED = 'siteBackgroundUploaded' ;
exports . SITE _BACKGROUND _UPLOADED = SITE _BACKGROUND _UPLOADED ;
var UPLOAD _PROGRESS = 'uploadProgress' ;
exports . UPLOAD _PROGRESS = UPLOAD _PROGRESS ;
var API _PAGE _WRITE = 'writingItDown' ;
exports . API _PAGE _WRITE = API _PAGE _WRITE ;
var API _PAGE _CREATE = 'writingNewEntry' ;
exports . API _PAGE _CREATE = API _PAGE _CREATE ;
var API _PAGE _DELETE = 'erasingPage' ;
exports . API _PAGE _DELETE = API _PAGE _DELETE ;
var API _SETTINGS _WRITE = 'savingSettings' ;
exports . API _SETTINGS _WRITE = API _SETTINGS _WRITE ;
var API _BACKUP _CREATE = 'createBackup' ;
exports . API _BACKUP _CREATE = API _BACKUP _CREATE ;
var API _BACKUP _DOWNLOAD = 'downloadBackup' ;
exports . API _BACKUP _DOWNLOAD = API _BACKUP _DOWNLOAD ;
var API _BACKUP _RESTORE = 'downloadBackup' ;
exports . API _BACKUP _RESTORE = API _BACKUP _RESTORE ;
var API _IMAGES _UPLOAD = 'uploadProfileImages' ;
exports . API _IMAGES _UPLOAD = API _IMAGES _UPLOAD ;
var API _RENDER _PAGES = 'renderPages' ;
exports . API _RENDER _PAGES = API _RENDER _PAGES ;
var API _INIT = 'blogInit' ;
exports . API _INIT = API _INIT ;
var API _INIT _GOOD = 'blogInitGood' ;
exports . API _INIT _GOOD = API _INIT _GOOD ;
var API _INIT _LAME = 'blogInitLame' ;
exports . API _INIT _LAME = API _INIT _LAME ;
var SEND _MAIL = 'sendMail' ;
exports . SEND _MAIL = SEND _MAIL ;
var DataEvent = function DataEvent ( ) {
_classCallCheck ( this , DataEvent ) ;
} ;
var _default = new DataEvent ( ) ;
exports . default = _default ;
} , { } ] , "../libraries/FipamoAPI.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = exports . API _GET _PAGE = exports . API _GET _PAGES = exports . API _LOGIN = exports . API _INIT = exports . API _STATUS = exports . CONTENT _TYPE _FORM = exports . CONTENT _TYPE _JSON = exports . REQUEST _TYPE _DELETE = exports . REQUEST _TYPE _PUT = exports . REQUEST _TYPE _GET = exports . REQUEST _TYPE _POST = void 0 ;
var DataEvent = _interopRequireWildcard ( require ( "../com/events/DataEvent" ) ) ;
function _getRequireWildcardCache ( ) { if ( typeof WeakMap !== "function" ) return null ; var cache = new WeakMap ( ) ; _getRequireWildcardCache = function ( ) { return cache ; } ; return cache ; }
function _interopRequireWildcard ( obj ) { if ( obj && obj . _ _esModule ) { return obj ; } if ( obj === null || typeof obj !== "object" && typeof obj !== "function" ) { return { default : obj } ; } var cache = _getRequireWildcardCache ( ) ; if ( cache && cache . has ( obj ) ) { return cache . get ( obj ) ; } var newObj = { } ; var hasPropertyDescriptor = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = hasPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : null ; if ( desc && ( desc . get || desc . set ) ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } newObj . default = obj ; if ( cache ) { cache . set ( obj , newObj ) ; } return newObj ; }
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 ; }
var REQUEST _TYPE _POST = 'POST' ;
exports . REQUEST _TYPE _POST = REQUEST _TYPE _POST ;
var REQUEST _TYPE _GET = 'GET' ;
exports . REQUEST _TYPE _GET = REQUEST _TYPE _GET ;
var REQUEST _TYPE _PUT = 'PUT' ;
exports . REQUEST _TYPE _PUT = REQUEST _TYPE _PUT ;
var REQUEST _TYPE _DELETE = 'DELETE' ;
exports . REQUEST _TYPE _DELETE = REQUEST _TYPE _DELETE ;
var CONTENT _TYPE _JSON = 'json' ;
exports . CONTENT _TYPE _JSON = CONTENT _TYPE _JSON ;
var CONTENT _TYPE _FORM = 'x-www-form-urlencoded' ;
exports . CONTENT _TYPE _FORM = CONTENT _TYPE _FORM ;
var API _STATUS = '/api/v1/auth/status' ;
exports . API _STATUS = API _STATUS ;
var API _INIT = '/api/v1/auth/init' ;
exports . API _INIT = API _INIT ;
var API _LOGIN = '/api/v1/auth/login' ;
exports . API _LOGIN = API _LOGIN ;
var API _GET _PAGES = '/api/v1/page/published' ;
exports . API _GET _PAGES = API _GET _PAGES ;
var API _GET _PAGE = '/api/v1/page/single' ;
exports . API _GET _PAGE = API _GET _PAGE ;
var APIUtils = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function APIUtils ( ) {
_classCallCheck ( this , APIUtils ) ;
} //--------------------------
// public
//--------------------------
_createClass ( APIUtils , [ {
key : "login" ,
value : function login ( data ) {
var _this = this ;
return new Promise ( function ( resolve , reject ) {
_this . _request ( API _LOGIN , DataEvent . AUTH _STATUS , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , data ) . then ( function ( result ) {
resolve ( result ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
}
} , {
key : "init" ,
value : function init ( data ) {
var _this2 = this ;
return new Promise ( function ( resolve , reject ) {
_this2 . _request ( API _INIT , DataEvent . API _INIT , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , data ) . then ( function ( result ) {
resolve ( result ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
}
} , {
key : "getPages" ,
value : function getPages ( num ) {
var _this3 = this ;
var pageNum = num ;
if ( pageNum === null || pageNum === '' || ! pageNum ) pageNum = 1 ;
return new Promise ( function ( resolve , reject ) {
_this3 . _request ( API _GET _PAGES + '/' + pageNum , DataEvent . API _GET _PAGES , REQUEST _TYPE _GET ) . then ( function ( result ) {
resolve ( result ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
}
} , {
key : "getPage" ,
value : function getPage ( id ) {
var _this4 = this ;
return new Promise ( function ( resolve , reject ) {
_this4 . _request ( API _GET _PAGE + '/' + id , DataEvent . API _GET _PAGES , REQUEST _TYPE _GET ) . then ( function ( result ) {
resolve ( result ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
} //--------------------------
// private
//--------------------------
} , {
key : "_request" ,
value : function _request ( requestURL , eventType ) {
var requestType = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : REQUEST _TYPE _GET ;
var contentType = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : CONTENT _TYPE _JSON ;
var requestData = arguments . length > 4 && arguments [ 4 ] !== undefined ? arguments [ 4 ] : null ;
var self = this ;
return new Promise ( function ( resolve , reject ) {
var request = new XMLHttpRequest ( ) ;
request . upload . onprogress = self . handleLoadProgress ;
request . open ( requestType , requestURL , true ) ;
request . onload = function ( ) {
if ( request . status == 200 ) {
var response = JSON . parse ( request [ 'response' ] ) ;
resolve ( response ) ;
} else {
var error = JSON . parse ( request [ 'response' ] ) ;
reject ( error ) ;
}
} ;
if ( requestType == REQUEST _TYPE _PUT || requestType == REQUEST _TYPE _POST ) {
switch ( contentType ) {
case CONTENT _TYPE _JSON :
request . setRequestHeader ( 'Content-type' , 'application/' + contentType ) ;
request . send ( JSON . stringify ( requestData ) ) ;
break ;
case CONTENT _TYPE _FORM :
request . send ( requestData ) ;
break ;
}
} else {
request . send ( ) ;
}
} ) ;
} //--------------------------
// event handlers
//--------------------------
} , {
key : "handleLoadProgress" ,
value : function handleLoadProgress ( e ) {
this . percentComplete = Math . ceil ( e . loaded / e . total * 100 ) ; //pass element to display request progress
}
} ] ) ;
return APIUtils ;
} ( ) ;
exports . default = APIUtils ;
} , { "../com/events/DataEvent" : "events/DataEvent.js" } ] , "../libraries/FipamoAdminAPI.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = exports . API _SEND _MAIL = exports . API _INIT _RESTORE _BACKUP = exports . API _RESTORE _BACKUP = exports . API _DOWNLOAD _BACKUP = exports . API _CREATE _BACKUP = exports . API _NAV _SYNC = exports . API _PUBLISH _PAGES = exports . API _UPLOAD _BACKGROUND = exports . API _UPLOAD _AVATAR = exports . API _SETTINGS _SYNC = exports . API _IMAGE _UPLOAD = exports . API _DELETE _PAGE = exports . API _EDIT _PAGE = exports . API _NEW _PAGE = exports . API _GET _NAV = exports . API _STATUS = exports . CONTENT _TYPE _FORM = exports . CONTENT _TYPE _JSON = exports . TASK _PAGE _DELETE = exports . TASK _PAGE _EDIT = exports . TASK _PAGE _CREATE = exports . REQUEST _TYPE _DELETE = exports . REQUEST _TYPE _PUT = exports . REQUEST _TYPE _GET = exports . REQUEST _TYPE _POST = void 0 ;
var DataEvent = _interopRequireWildcard ( require ( "../com/events/DataEvent" ) ) ;
function _getRequireWildcardCache ( ) { if ( typeof WeakMap !== "function" ) return null ; var cache = new WeakMap ( ) ; _getRequireWildcardCache = function ( ) { return cache ; } ; return cache ; }
function _interopRequireWildcard ( obj ) { if ( obj && obj . _ _esModule ) { return obj ; } if ( obj === null || typeof obj !== "object" && typeof obj !== "function" ) { return { default : obj } ; } var cache = _getRequireWildcardCache ( ) ; if ( cache && cache . has ( obj ) ) { return cache . get ( obj ) ; } var newObj = { } ; var hasPropertyDescriptor = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = hasPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : null ; if ( desc && ( desc . get || desc . set ) ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } newObj . default = obj ; if ( cache ) { cache . set ( obj , newObj ) ; } return newObj ; }
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 ; }
var REQUEST _TYPE _POST = 'POST' ;
exports . REQUEST _TYPE _POST = REQUEST _TYPE _POST ;
var REQUEST _TYPE _GET = 'GET' ;
exports . REQUEST _TYPE _GET = REQUEST _TYPE _GET ;
var REQUEST _TYPE _PUT = 'PUT' ;
exports . REQUEST _TYPE _PUT = REQUEST _TYPE _PUT ;
var REQUEST _TYPE _DELETE = 'DELETE' ;
exports . REQUEST _TYPE _DELETE = REQUEST _TYPE _DELETE ;
var TASK _PAGE _CREATE = 'createNewPage' ;
exports . TASK _PAGE _CREATE = TASK _PAGE _CREATE ;
var TASK _PAGE _EDIT = 'editPage' ;
exports . TASK _PAGE _EDIT = TASK _PAGE _EDIT ;
var TASK _PAGE _DELETE = 'deletePage' ;
exports . TASK _PAGE _DELETE = TASK _PAGE _DELETE ;
var CONTENT _TYPE _JSON = 'json' ;
exports . CONTENT _TYPE _JSON = CONTENT _TYPE _JSON ;
var CONTENT _TYPE _FORM = 'x-www-form-urlencoded' ;
exports . CONTENT _TYPE _FORM = CONTENT _TYPE _FORM ;
var API _STATUS = '/api/v1/auth/status' ;
exports . API _STATUS = API _STATUS ;
var API _GET _NAV = '/api/settings/nav' ;
exports . API _GET _NAV = API _GET _NAV ;
var API _NEW _PAGE = '/api/v1/page/write/new' ;
exports . API _NEW _PAGE = API _NEW _PAGE ;
var API _EDIT _PAGE = '/api/v1/page/write' ;
exports . API _EDIT _PAGE = API _EDIT _PAGE ;
var API _DELETE _PAGE = '/api/v1/page/delete' ;
exports . API _DELETE _PAGE = API _DELETE _PAGE ;
var API _IMAGE _UPLOAD = '/api/v1/page/add-post-image' ;
exports . API _IMAGE _UPLOAD = API _IMAGE _UPLOAD ;
var API _SETTINGS _SYNC = '/api/v1/settings/sync' ;
exports . API _SETTINGS _SYNC = API _SETTINGS _SYNC ;
var API _UPLOAD _AVATAR = '/api/v1/settings/add-avatar' ;
exports . API _UPLOAD _AVATAR = API _UPLOAD _AVATAR ;
var API _UPLOAD _BACKGROUND = '/api/v1/settings/add-feature-background' ;
exports . API _UPLOAD _BACKGROUND = API _UPLOAD _BACKGROUND ;
var API _PUBLISH _PAGES = '/api/v1/settings/publish-pages' ;
exports . API _PUBLISH _PAGES = API _PUBLISH _PAGES ;
var API _NAV _SYNC = '/api/v1/settings/nav-sync' ;
exports . API _NAV _SYNC = API _NAV _SYNC ;
var API _CREATE _BACKUP = '/api/v1/backup/create' ;
exports . API _CREATE _BACKUP = API _CREATE _BACKUP ;
var API _DOWNLOAD _BACKUP = '/api/v1/backup/download' ;
exports . API _DOWNLOAD _BACKUP = API _DOWNLOAD _BACKUP ;
var API _RESTORE _BACKUP = '/api/v1/backup/restore' ;
exports . API _RESTORE _BACKUP = API _RESTORE _BACKUP ;
var API _INIT _RESTORE _BACKUP = '/api/v1/backup/init-restore' ;
exports . API _INIT _RESTORE _BACKUP = API _INIT _RESTORE _BACKUP ;
var API _SEND _MAIL = '/api/v1/mailer' ;
exports . API _SEND _MAIL = API _SEND _MAIL ;
var APIUtils = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function APIUtils ( ) {
var _this = this ;
_classCallCheck ( this , APIUtils ) ;
this . percentComplete = 0 ;
this . token = null ; //checks backend to see if user is logged in
//and requests encrypted token for api calls
this . _request ( API _STATUS ) . then ( function ( response ) {
if ( response . type === DataEvent . API _REQUEST _GOOD ) {
_this . token = response . token ;
} else { //don't set token
}
} ) ;
} //--------------------------
// public
//--------------------------
_createClass ( APIUtils , [ {
key : "syncSettings" ,
value : function syncSettings ( data ) {
var _this2 = this ;
return new Promise ( function ( resolve , reject ) {
_this2 . _request ( API _SETTINGS _SYNC , DataEvent . API _SETTINGS _WRITE , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , data ) . then ( function ( result ) {
resolve ( result ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
}
} , {
key : "imageUpload" ,
value : function imageUpload ( type , files ) {
var _this3 = this ;
return new Promise ( function ( resolve , reject ) {
var url = '' ;
switch ( type ) {
case 'avatar-upload' :
url = API _UPLOAD _AVATAR ;
break ;
case 'background-upload' :
url = API _UPLOAD _BACKGROUND ;
break ;
default :
url = API _IMAGE _UPLOAD ;
break ;
}
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 ;
}
if ( type === 'avatar-upload' ) {
imageData . append ( 'avatar_upload' , file , file . name ) ;
} else if ( type === 'background-upload' ) {
imageData . append ( 'background_upload' , file , file . name ) ;
} else {
imageData . append ( 'post_image' , file , file . name ) ;
}
}
_this3 . _request ( url , DataEvent . API _IMAGES _UPLOAD , REQUEST _TYPE _POST , CONTENT _TYPE _FORM , imageData ) . then ( function ( r ) {
resolve ( r ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
}
} , {
key : "publishSite" ,
value : function publishSite ( data ) {
var _this4 = this ;
return new Promise ( function ( resolve , reject ) {
_this4 . _request ( API _PUBLISH _PAGES , DataEvent . API _RENDER _PAGES , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , data ) . then ( function ( result ) {
resolve ( result ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
}
} , {
key : "pageActions" ,
value : function pageActions ( task , data ) {
var _this5 = this ;
var url , event , content ;
switch ( task ) {
case TASK _PAGE _CREATE :
url = API _NEW _PAGE ;
event = DataEvent . API _PAGE _WRITE ;
content = CONTENT _TYPE _FORM ;
break ;
case TASK _PAGE _EDIT :
url = API _EDIT _PAGE ;
event = DataEvent . API _PAGE _WRITE ;
content = CONTENT _TYPE _FORM ;
break ;
case TASK _PAGE _DELETE :
url = API _DELETE _PAGE ;
event = DataEvent . API _PAGE _DELETE ;
content = CONTENT _TYPE _JSON ;
break ;
default :
break ;
}
return new Promise ( function ( resolve , reject ) {
_this5 . _request ( url , event , REQUEST _TYPE _POST , content , data ) . then ( function ( result ) {
resolve ( result ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
}
} , {
key : "syncNav" ,
value : function syncNav ( data ) {
var _this6 = this ;
return new Promise ( function ( resolve , reject ) {
_this6 . _request ( API _NAV _SYNC , DataEvent . API _SETTINGS _WRITE , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , data ) . then ( function ( result ) {
resolve ( result ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
}
} , {
key : "sendMail" ,
value : function sendMail ( message ) {
var _this7 = this ;
return new Promise ( function ( resolve , reject ) {
_this7 . _request ( API _SEND _MAIL , DataEvent . SEND _MAIL , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , message ) . then ( function ( result ) {
resolve ( result ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
}
} , {
key : "handleBackup" ,
value : function handleBackup ( id , files ) {
var _this8 = this ;
return new Promise ( function ( resolve , reject ) {
var url , event , method , type , data ;
if ( id === 'create-backup' ) {
url = API _CREATE _BACKUP ;
event = DataEvent . API _BACKUP _CREATE ;
method = REQUEST _TYPE _POST ;
type = CONTENT _TYPE _JSON ;
data = {
task : 'create_backup'
} ;
} else {
url = API _RESTORE _BACKUP ;
event = DataEvent . API _BACKUP _RESTORE ;
method = REQUEST _TYPE _POST ;
type = CONTENT _TYPE _FORM ;
data = new FormData ( ) ;
for ( var i = 0 ; i < files . length ; i ++ ) {
var file = files [ i ] ; // Check the file type.
if ( ! file . type . match ( 'application.zip' ) ) {
continue ;
}
data . append ( 'backup_upload' , file , file . name ) ;
}
}
_this8 . _request ( url , event , method , type , data ) . then ( function ( result ) {
resolve ( result ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
}
} , {
key : "handleInitRestore" ,
value : function handleInitRestore ( form ) {
var _this9 = this ;
return new Promise ( function ( resolve , reject ) {
var url , event , method , type , data ;
url = API _INIT _RESTORE _BACKUP ;
event = DataEvent . API _BACKUP _RESTORE ;
method = REQUEST _TYPE _POST ;
type = CONTENT _TYPE _FORM ;
data = new FormData ( form ) ;
_this9 . _request ( url , event , method , type , data ) . then ( function ( result ) {
resolve ( result ) ;
} ) . catch ( function ( err ) {
reject ( err ) ;
} ) ;
} ) ;
} //--------------------------
// private
//--------------------------
} , {
key : "_request" ,
value : function _request ( requestURL , eventType ) {
var requestType = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : REQUEST _TYPE _GET ;
var contentType = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : CONTENT _TYPE _JSON ;
var requestData = arguments . length > 4 && arguments [ 4 ] !== undefined ? arguments [ 4 ] : null ;
var self = this ;
return new Promise ( function ( resolve , reject ) {
var request = new XMLHttpRequest ( ) ;
request . upload . onprogress = self . handleLoadProgress ;
request . open ( requestType , requestURL , true ) ;
request . onload = function ( ) {
if ( request . status == 200 ) {
var response = JSON . parse ( request [ 'response' ] ) ;
resolve ( response ) ;
} else {
var error = JSON . parse ( request [ 'response' ] ) ;
reject ( error ) ;
}
} ;
if ( requestType == REQUEST _TYPE _PUT || requestType == REQUEST _TYPE _POST ) {
if ( eventType === DataEvent . API _PAGE _WRITE || eventType === DataEvent . API _IMAGES _UPLOAD || eventType === DataEvent . API _SETTINGS _WRITE || eventType === DataEvent . API _PAGE _DELETE || eventType === DataEvent . API _RENDER _PAGES || eventType === DataEvent . API _BACKUP _CREATE || eventType === DataEvent . API _BACKUP _RESTORE ) request . setRequestHeader ( 'x-access-token' , self . token ) ;
switch ( contentType ) {
case CONTENT _TYPE _JSON :
request . setRequestHeader ( 'Content-type' , 'application/' + contentType ) ;
request . send ( JSON . stringify ( requestData ) ) ;
break ;
case CONTENT _TYPE _FORM :
request . send ( requestData ) ;
break ;
}
} else {
request . send ( ) ;
}
} ) ;
} //--------------------------
// event handlers
//--------------------------
} , {
key : "handleLoadProgress" ,
value : function handleLoadProgress ( e ) {
this . percentComplete = Math . ceil ( e . loaded / e . total * 100 ) ; //pass element to display request progress
}
} ] ) ;
return APIUtils ;
} ( ) ;
exports . default = APIUtils ;
} , { "../com/events/DataEvent" : "events/DataEvent.js" } ] , "utils/DataUtils.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
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 ; }
var DataUtils = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function DataUtils ( ) {
_classCallCheck ( this , DataUtils ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( DataUtils , [ {
key : "imgLoad" ,
value : function imgLoad ( url ) {
'use strict' ; // Create new promise with the Promise() constructor;
// This has as its argument a function with two parameters, resolve and reject
return new Promise ( function ( resolve , reject ) {
// Standard XHR to load an image
var request = new XMLHttpRequest ( ) ;
request . open ( 'GET' , url ) ;
request . responseType = 'blob' ; // When the request loads, check whether it was successful
request . onload = function ( ) {
if ( request . status === 200 ) {
// If successful, resolve the promise by passing back the request response
resolve ( request . response ) ;
} else {
// If it fails, reject the promise with a error message
reject ( new Error ( "Image didn't load successfully; error code:" + request . statusText ) ) ;
}
} ;
request . onerror = function ( ) {
// Also deal with the case when the entire request fails to begin with
// This is probably a network error, so reject the promise with an appropriate message
reject ( new Error ( 'There was a network error.' ) ) ;
} ; // Send the request
request . send ( ) ;
} ) ;
}
} , {
key : "loadImage" ,
value : function loadImage ( src ) {
'use strict' ;
var self = this ;
return new Promise ( function ( resolve , reject ) {
// Get a reference to the body element, and create a new image object
var myImage = new Image ( ) ;
myImage . crossOrigin = '' ; // or "anonymous"
// Call the function with the URL we want to load, but then chain the
// promise then() method on to the end of it. This contains two callbacks
self . imgLoad ( src ) . then ( function ( response ) {
// The first runs when the promise resolves, with the request.reponse specified within the resolve() method.
var imageURL = window . URL . createObjectURL ( response ) ;
resolve ( imageURL ) ; //$('background-content').setStyle('background-image', 'url('+imageURL+')') //myImage.src = imageURL;
//console.log(imageURL);
//body.appendChild(myImage);
// The second runs when the promise is rejected, and logs the Error specified with the reject() method.
} , function ( Error ) {
reject ( Error ) ;
} ) ;
} ) ;
}
/ * *
* Create a function to convert the serialize and convert the form data to JSON
* @ param : $ ( '#form_example' ) ;
* @ return a JSON Stringify
* /
} , {
key : "formDataToJSON" ,
value : function formDataToJSON ( form ) {
var object = { } ;
var formData = new FormData ( form ) ;
formData . forEach ( function ( value , key ) {
if ( ! object . hasOwnProperty ( key ) ) {
object [ key ] = value ;
return ;
}
if ( ! Array . isArray ( object [ key ] ) ) {
object [ key ] = [ object [ key ] ] ;
}
object [ key ] . push ( value ) ;
} ) ; //let json = JSON.stringify(object);
return object ;
} //--------------------------
// event handlers
//--------------------------
} ] ) ;
return DataUtils ;
} ( ) ;
exports . default = DataUtils ;
} , { } ] , "utils/StringUtils.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
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 ; }
var StringUtils = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function StringUtils ( ) {
_classCallCheck ( this , StringUtils ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( StringUtils , [ {
key : "cleanString" ,
value : function cleanString ( string ) {
var clean = string . replace ( /(^\-+|[^a-zA-Z0-9\/_| -]+|\-+$)/g , '' ) . toLowerCase ( ) . replace ( /[\/_| -]+/g , '-' ) ;
return clean ;
}
} , {
key : "decodeHTML" ,
value : function decodeHTML ( string , quote _style ) {
var optTemp = 0 ,
i = 0 ,
noquotes = false ;
if ( typeof quote _style === 'undefined' ) {
quote _style = 2 ;
}
string = string . toString ( ) . replace ( /</g , '<' ) . replace ( />/g , '>' ) ;
var OPTS = {
ENT _NOQUOTES : 0 ,
ENT _HTML _QUOTE _SINGLE : 1 ,
ENT _HTML _QUOTE _DOUBLE : 2 ,
ENT _COMPAT : 2 ,
ENT _QUOTES : 3 ,
ENT _IGNORE : 4
} ;
if ( quote _style === 0 ) {
noquotes = true ;
}
if ( typeof quote _style !== 'number' ) {
// Allow for a single string or an array of string flags
quote _style = [ ] . concat ( quote _style ) ;
for ( i = 0 ; i < quote _style . length ; i ++ ) {
// Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
if ( OPTS [ quote _style [ i ] ] === 0 ) {
noquotes = true ;
} else if ( OPTS [ quote _style [ i ] ] ) {
optTemp = optTemp | OPTS [ quote _style [ i ] ] ;
}
}
quote _style = optTemp ;
}
if ( quote _style & OPTS . ENT _HTML _QUOTE _SINGLE ) {
string = string . replace ( /�*39;/g , "'" ) ; // PHP doesn't currently escape if more than one 0, but it should
// string = string.replace(/'|�*27;/g, "'"); // This would also be useful here, but not a part of PHP
}
if ( ! noquotes ) {
string = string . replace ( /"/g , '"' ) ;
} // Put this in last place to avoid escape being double-decoded
string = string . replace ( /&/g , '&' ) ;
return string ;
} //--------------------------
// event handlers
//--------------------------
} ] ) ;
return StringUtils ;
} ( ) ;
var _default = StringUtils ;
exports . default = _default ;
} , { } ] , "actions/PageActions.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _StringUtils = _interopRequireDefault ( require ( "../utils/StringUtils" ) ) ;
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" ) ; } }
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 ; }
var PostActions = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function PostActions ( ) {
_classCallCheck ( this , PostActions ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( PostActions , [ {
key : "collectInfo" ,
value : function collectInfo ( image ) {
return new Promise ( function ( resolve , reject ) {
var pageInfo = new FormData ( ) ;
var txt = document . createElement ( 'textarea' ) ;
txt . innerHTML = document . getElementById ( 'edit-post-text' ) . innerHTML ;
var html = txt . value ; //html = html.replace(/<\/?span[^>]*>/g, ''); //removes highightjs styling
html = html . replace ( /<\/?br[^>]*>/g , '\n' ) ; //convert back to encoded line break for storage
pageInfo . append ( 'id' , document . getElementById ( 'post-edit-index' ) . getAttribute ( 'data-index' ) ) ;
pageInfo . append ( 'uuid' , document . getElementById ( 'post-edit-index' ) . getAttribute ( 'data-uuid' ) ) ;
pageInfo . append ( 'layout' , document . getElementById ( 'post-edit-index' ) . getAttribute ( 'data-layout' ) ) ;
pageInfo . append ( 'current_title' , document . getElementById ( 'post-edit-index' ) . getAttribute ( 'data-slug' ) ) ;
pageInfo . append ( 'content' , html ) ;
pageInfo . append ( 'title' , document . getElementById ( 'post_title' ) . value ) ;
pageInfo . append ( 'created' , document . getElementById ( 'post-date' ) . getAttribute ( 'data-raw' ) ) ;
pageInfo . append ( 'slug' , new _StringUtils . default ( ) . cleanString ( document . getElementById ( 'post_title' ) . value ) ) ;
pageInfo . append ( 'tags' , document . getElementById ( 'post_tags' ) . value ) ;
pageInfo . append ( 'menu' , document . getElementById ( 'option-menu-pin' ) . getAttribute ( 'data-active' ) ) ;
pageInfo . append ( 'featured' , document . getElementById ( 'option-feature' ) . getAttribute ( 'data-active' ) ) ;
pageInfo . append ( 'published' , document . getElementById ( 'option-published' ) . getAttribute ( 'data-active' ) ) ;
if ( image != null || image != undefined ) {
if ( image . type . match ( 'image.*' ) ) {
pageInfo . append ( 'feature_image' , image , image . name ) ;
} else {
reject ( 'Not an image file' ) ;
}
} else {
//check to see if image exists
var imageURL = document . getElementById ( 'featured-image' ) . src ;
imageURL != null || imageURL != undefined ? pageInfo . append ( 'feature_image' , imageURL ) : pageInfo . append ( 'feature_image' , null ) ;
}
resolve ( pageInfo ) ;
} ) ;
} //--------------------------
// event handlers
//--------------------------
} ] ) ;
return PostActions ;
} ( ) ;
exports . default = PostActions ;
} , { "../utils/StringUtils" : "utils/StringUtils.js" } ] , "events/EditorEvent.js" : [ 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 ;
} , { } ] , "../../node_modules/caret-pos/lib/esm2015/main.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . getOffset = exports . offset = exports . position = void 0 ;
var attributes = [ 'borderBottomWidth' , 'borderLeftWidth' , 'borderRightWidth' , 'borderTopStyle' , 'borderRightStyle' , 'borderBottomStyle' , 'borderLeftStyle' , 'borderTopWidth' , 'boxSizing' , 'fontFamily' , 'fontSize' , 'fontWeight' , 'height' , 'letterSpacing' , 'lineHeight' , 'marginBottom' , 'marginLeft' , 'marginRight' , 'marginTop' , 'outlineWidth' , 'overflow' , 'overflowX' , 'overflowY' , 'paddingBottom' , 'paddingLeft' , 'paddingRight' , 'paddingTop' , 'textAlign' , 'textOverflow' , 'textTransform' , 'whiteSpace' , 'wordBreak' , 'wordWrap' ] ;
/ * *
* Create a mirror
*
* @ param { Element } element The element
* @ param { string } html The html
*
* @ return { object } The mirror object
* /
var createMirror = function createMirror ( element , html ) {
/ * *
* The mirror element
* /
var mirror = document . createElement ( 'div' ) ;
/ * *
* Create the CSS for the mirror object
*
* @ return { object } The style object
* /
var mirrorCss = function mirrorCss ( ) {
var css = {
position : 'absolute' ,
left : - 9999 ,
top : 0 ,
zIndex : - 2000
} ;
if ( element . tagName === 'TEXTAREA' ) {
attributes . push ( 'width' ) ;
}
attributes . forEach ( function ( attr ) {
css [ attr ] = getComputedStyle ( element ) [ attr ] ;
} ) ;
return css ;
} ;
/ * *
* Initialize the mirror
*
* @ param { string } html The html
*
* @ return { void }
* /
var initialize = function initialize ( html ) {
var styles = mirrorCss ( ) ;
Object . keys ( styles ) . forEach ( function ( key ) {
mirror . style [ key ] = styles [ key ] ;
} ) ;
mirror . innerHTML = html ;
element . parentNode . insertBefore ( mirror , element . nextSibling ) ;
} ;
/ * *
* Get the rect
*
* @ return { Rect } The bounding rect
* /
var rect = function rect ( ) {
var marker = mirror . ownerDocument . getElementById ( 'caret-position-marker' ) ;
var boundingRect = {
left : marker . offsetLeft ,
top : marker . offsetTop ,
height : marker . offsetHeight
} ;
mirror . parentNode . removeChild ( mirror ) ;
return boundingRect ;
} ;
initialize ( html ) ;
return {
rect : rect
} ;
} ;
var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) {
return typeof obj ;
} : function ( obj ) {
return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ;
} ;
/ * *
* Check if a DOM Element is content editable
*
* @ param { Element } element The DOM element
*
* @ return { bool } If it is content editable
* /
var isContentEditable = function isContentEditable ( element ) {
return ! ! ( element . contentEditable ? element . contentEditable === 'true' : element . getAttribute ( 'contenteditable' ) === 'true' ) ;
} ;
/ * *
* Get the context from settings passed in
*
* @ param { object } settings The settings object
*
* @ return { object } window and document
* /
var getContext = function getContext ( ) {
var settings = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
var customPos = settings . customPos ,
iframe = settings . iframe ,
noShadowCaret = settings . noShadowCaret ;
if ( iframe ) {
return {
iframe : iframe ,
window : iframe . contentWindow ,
document : iframe . contentDocument || iframe . contentWindow . document ,
noShadowCaret : noShadowCaret ,
customPos : customPos
} ;
}
return {
window : window ,
document : document ,
noShadowCaret : noShadowCaret ,
customPos : customPos
} ;
} ;
/ * *
* Get the offset of an element
*
* @ param { Element } element The DOM element
* @ param { object } ctx The context
*
* @ return { object } top and left
* /
var getOffset = function getOffset ( element , ctx ) {
var win = ctx && ctx . window || window ;
var doc = ctx && ctx . document || document ;
var rect = element . getBoundingClientRect ( ) ;
var docEl = doc . documentElement ;
var scrollLeft = win . pageXOffset || docEl . scrollLeft ;
var scrollTop = win . pageYOffset || docEl . scrollTop ;
return {
top : rect . top + scrollTop ,
left : rect . left + scrollLeft
} ;
} ;
/ * *
* Check if a value is an object
*
* @ param { any } value The value to check
*
* @ return { bool } If it is an object
* /
exports . getOffset = getOffset ;
var isObject = function isObject ( value ) {
return ( typeof value === 'undefined' ? 'undefined' : _typeof ( value ) ) === 'object' && value !== null ;
} ;
/ * *
* Create a Input caret object .
*
* @ param { Element } element The element
* @ param { Object } ctx The context
* /
var createInputCaret = function createInputCaret ( element , ctx ) {
/ * *
* Get the current position
*
* @ returns { int } The caret position
* /
var getPos = function getPos ( ) {
return element . selectionStart ;
} ;
/ * *
* Set the position
*
* @ param { int } pos The position
*
* @ return { Element } The element
* /
var setPos = function setPos ( pos ) {
element . setSelectionRange ( pos , pos ) ;
return element ;
} ;
/ * *
* The offset
*
* @ param { int } pos The position
*
* @ return { object } The offset
* /
var getOffset$$1 = function getOffset$$1 ( pos ) {
var rect = getOffset ( element ) ;
var position = getPosition ( pos ) ;
return {
top : rect . top + position . top + ctx . document . body . scrollTop ,
left : rect . left + position . left + ctx . document . body . scrollLeft ,
height : position . height
} ;
} ;
/ * *
* Get the current position
*
* @ param { int } pos The position
*
* @ return { object } The position
* /
var getPosition = function getPosition ( pos ) {
var format = function format ( val ) {
var value = val . replace ( /<|>|`|"|&/g , '?' ) . replace ( /\r\n|\r|\n/g , '<br/>' ) ;
return value ;
} ;
if ( ctx . customPos || ctx . customPos === 0 ) {
pos = ctx . customPos ;
}
var position = pos === undefined ? getPos ( ) : pos ;
var startRange = element . value . slice ( 0 , position ) ;
var endRange = element . value . slice ( position ) ;
var html = '<span style="position: relative; display: inline;">' + format ( startRange ) + '</span>' ;
html += '<span id="caret-position-marker" style="position: relative; display: inline;">|</span>' ;
html += '<span style="position: relative; display: inline;">' + format ( endRange ) + '</span>' ;
var mirror = createMirror ( element , html ) ;
var rect = mirror . rect ( ) ;
rect . pos = getPos ( ) ;
return rect ;
} ;
return {
getPos : getPos ,
setPos : setPos ,
getOffset : getOffset$$1 ,
getPosition : getPosition
} ;
} ;
/ * *
* Create an Editable Caret
* @ param { Element } element The editable element
* @ param { object | null } ctx The context
*
* @ return { EditableCaret }
* /
var createEditableCaret = function createEditableCaret ( element , ctx ) {
/ * *
* Set the caret position
*
* @ param { int } pos The position to se
*
* @ return { Element } The element
* /
var setPos = function setPos ( pos ) {
var sel = ctx . window . getSelection ( ) ;
if ( sel ) {
var offset = 0 ;
var found = false ;
var find = function find ( position , parent ) {
for ( var i = 0 ; i < parent . childNodes . length ; i ++ ) {
var node = parent . childNodes [ i ] ;
if ( found ) {
break ;
}
if ( node . nodeType === 3 ) {
if ( offset + node . length >= position ) {
found = true ;
var range = ctx . document . createRange ( ) ;
range . setStart ( node , position - offset ) ;
sel . removeAllRanges ( ) ;
sel . addRange ( range ) ;
break ;
} else {
offset += node . length ;
}
} else {
find ( pos , node ) ;
}
}
} ;
find ( pos , element ) ;
}
return element ;
} ;
/ * *
* Get the offset
*
* @ return { object } The offset
* /
var getOffset = function getOffset ( ) {
var range = getRange ( ) ;
var offset = {
height : 0 ,
left : 0 ,
right : 0
} ;
if ( ! range ) {
return offset ;
}
var hasCustomPos = ctx . customPos || ctx . customPos === 0 ; // endContainer in Firefox would be the element at the start of
// the line
if ( range . endOffset - 1 > 0 && range . endContainer !== element || hasCustomPos ) {
var clonedRange = range . cloneRange ( ) ;
var fixedPosition = hasCustomPos ? ctx . customPos : range . endOffset ;
clonedRange . setStart ( range . endContainer , fixedPosition - 1 < 0 ? 0 : fixedPosition - 1 ) ;
clonedRange . setEnd ( range . endContainer , fixedPosition ) ;
var rect = clonedRange . getBoundingClientRect ( ) ;
offset = {
height : rect . height ,
left : rect . left + rect . width ,
top : rect . top
} ;
clonedRange . detach ( ) ;
}
if ( ( ! offset || offset && offset . height === 0 ) && ! ctx . noShadowCaret ) {
var _clonedRange = range . cloneRange ( ) ;
var shadowCaret = ctx . document . createTextNode ( '|' ) ;
_clonedRange . insertNode ( shadowCaret ) ;
_clonedRange . selectNode ( shadowCaret ) ;
var _rect = _clonedRange . getBoundingClientRect ( ) ;
offset = {
height : _rect . height ,
left : _rect . left ,
top : _rect . top
} ;
shadowCaret . parentNode . removeChild ( shadowCaret ) ;
_clonedRange . detach ( ) ;
}
if ( offset ) {
var doc = ctx . document . documentElement ;
offset . top += ctx . window . pageYOffset - ( doc . clientTop || 0 ) ;
offset . left += ctx . window . pageXOffset - ( doc . clientLeft || 0 ) ;
}
return offset ;
} ;
/ * *
* Get the position
*
* @ return { object } The position
* /
var getPosition = function getPosition ( ) {
var offset = getOffset ( ) ;
var pos = getPos ( ) ;
var rect = element . getBoundingClientRect ( ) ;
var inputOffset = {
top : rect . top + ctx . document . body . scrollTop ,
left : rect . left + ctx . document . body . scrollLeft
} ;
offset . left -= inputOffset . left ;
offset . top -= inputOffset . top ;
offset . pos = pos ;
return offset ;
} ;
/ * *
* Get the range
*
* @ return { Range | null }
* /
var getRange = function getRange ( ) {
if ( ! ctx . window . getSelection ) {
return ;
}
var sel = ctx . window . getSelection ( ) ;
return sel . rangeCount > 0 ? sel . getRangeAt ( 0 ) : null ;
} ;
/ * *
* Get the caret position
*
* @ return { int } The position
* /
var getPos = function getPos ( ) {
var range = getRange ( ) ;
var clonedRange = range . cloneRange ( ) ;
clonedRange . selectNodeContents ( element ) ;
clonedRange . setEnd ( range . endContainer , range . endOffset ) ;
var pos = clonedRange . toString ( ) . length ;
clonedRange . detach ( ) ;
return pos ;
} ;
return {
getPos : getPos ,
setPos : setPos ,
getPosition : getPosition ,
getOffset : getOffset ,
getRange : getRange
} ;
} ;
var createCaret = function createCaret ( element , ctx ) {
if ( isContentEditable ( element ) ) {
return createEditableCaret ( element , ctx ) ;
}
return createInputCaret ( element , ctx ) ;
} ;
var position = function position ( element , value ) {
var settings = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
var options = settings ;
if ( isObject ( value ) ) {
options = value ;
value = null ;
}
var ctx = getContext ( options ) ;
var caret = createCaret ( element , ctx ) ;
if ( value || value === 0 ) {
return caret . setPos ( value ) ;
}
return caret . getPosition ( ) ;
} ;
/ * *
*
* @ param { Element } element The DOM element
* @ param { number | undefined } value The value to set
* @ param { object } settings Any settings for context
* /
exports . position = position ;
var offset = function offset ( element , value ) {
var settings = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
var options = settings ;
if ( isObject ( value ) ) {
options = value ;
value = null ;
}
var ctx = getContext ( options ) ;
var caret = createCaret ( element , ctx ) ;
return caret . getOffset ( value ) ;
} ;
exports . offset = offset ;
} , { } ] , "events/EventEmitter.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
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 ; }
var EventEmitter = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function EventEmitter ( ) {
_classCallCheck ( this , EventEmitter ) ;
this . listeners = new Map ( ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( EventEmitter , [ {
key : "addListener" ,
value : function addListener ( label , callback ) {
this . listeners . has ( label ) || this . listeners . set ( label , [ ] ) ;
this . listeners . get ( label ) . push ( callback ) ;
}
} , {
key : "removeListener" ,
value : function removeListener ( label , callback ) {
var isFunction = function isFunction ( obj ) {
return typeof obj == 'function' || false ;
} ;
var listeners = this . listeners . get ( label ) ,
index ;
if ( listeners && listeners . length ) {
index = listeners . reduce ( function ( i , listener , index ) {
return isFunction ( listener ) && listener === callback ? i = index : i ;
} , - 1 ) ;
if ( index > - 1 ) {
listeners . splice ( index , 1 ) ;
this . listeners . set ( label , listeners ) ;
return true ;
}
}
return false ;
}
} , {
key : "emitEvent" ,
value : function emitEvent ( label ) {
for ( var _len = arguments . length , args = new Array ( _len > 1 ? _len - 1 : 0 ) , _key = 1 ; _key < _len ; _key ++ ) {
args [ _key - 1 ] = arguments [ _key ] ;
}
var listeners = this . listeners . get ( label ) ;
if ( listeners && listeners . length ) {
listeners . forEach ( function ( listener ) {
listener . apply ( void 0 , args ) ;
} ) ;
return true ;
}
return false ;
} //--------------------------
// event handlers
//--------------------------
} ] ) ;
return EventEmitter ;
} ( ) ;
var _default = EventEmitter ;
exports . default = _default ;
} , { } ] , "ui/TextEditor.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var DataEvent = _interopRequireWildcard ( require ( "../events/DataEvent" ) ) ;
var _caretPos = require ( "caret-pos" ) ;
var _EventEmitter2 = _interopRequireDefault ( require ( "../events/EventEmitter" ) ) ;
var EditorEvent = _interopRequireWildcard ( require ( "../events/EditorEvent" ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
function _getRequireWildcardCache ( ) { if ( typeof WeakMap !== "function" ) return null ; var cache = new WeakMap ( ) ; _getRequireWildcardCache = function ( ) { return cache ; } ; return cache ; }
function _interopRequireWildcard ( obj ) { if ( obj && obj . _ _esModule ) { return obj ; } if ( obj === null || typeof obj !== "object" && typeof obj !== "function" ) { return { default : obj } ; } var cache = _getRequireWildcardCache ( ) ; if ( cache && cache . has ( obj ) ) { return cache . get ( obj ) ; } var newObj = { } ; var hasPropertyDescriptor = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = hasPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : null ; if ( desc && ( desc . get || desc . set ) ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } newObj . default = obj ; if ( cache ) { cache . set ( obj , newObj ) ; } return newObj ; }
function _typeof ( obj ) { "@babel/helpers - typeof" ; 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 _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 _createSuper ( Derived ) { var hasNativeReflectConstruct = _isNativeReflectConstruct ( ) ; return function _createSuperInternal ( ) { var Super = _getPrototypeOf ( Derived ) , result ; if ( hasNativeReflectConstruct ) { var NewTarget = _getPrototypeOf ( this ) . constructor ; result = Reflect . construct ( Super , arguments , NewTarget ) ; } else { result = Super . apply ( this , arguments ) ; } return _possibleConstructorReturn ( this , result ) ; } ; }
function _possibleConstructorReturn ( self , call ) { if ( call && ( _typeof ( call ) === "object" || typeof call === "function" ) ) { return call ; } return _assertThisInitialized ( self ) ; }
function _assertThisInitialized ( self ) { if ( self === void 0 ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return self ; }
function _isNativeReflectConstruct ( ) { if ( typeof Reflect === "undefined" || ! Reflect . construct ) return false ; if ( Reflect . construct . sham ) return false ; if ( typeof Proxy === "function" ) return true ; try { Date . prototype . toString . call ( Reflect . construct ( Date , [ ] , function ( ) { } ) ) ; return true ; } catch ( e ) { return false ; } }
function _getPrototypeOf ( o ) { _getPrototypeOf = Object . setPrototypeOf ? Object . getPrototypeOf : function _getPrototypeOf ( o ) { return o . _ _proto _ _ || Object . getPrototypeOf ( o ) ; } ; return _getPrototypeOf ( o ) ; }
var TextEditor = /*#__PURE__*/ function ( _EventEmitter ) {
_inherits ( TextEditor , _EventEmitter ) ;
var _super = _createSuper ( TextEditor ) ;
/ * *
* Text Editor UI Component
* @ constructor
* @ param { object } textEditor - Text area that will edit text
* @ param { number } scrollLimit - YPos where editor position will become fixed
* /
//--------------------------
// constructor
//--------------------------
function TextEditor ( textEditor , scrollLimit ) {
var _this ;
_classCallCheck ( this , TextEditor ) ;
_this = _super . call ( this ) ; //hljs.initHighlightingOnLoad();
_this . textEditor = textEditor ;
_this . fixLimit = scrollLimit ;
_this . caretPos = null ;
_this . url = '' ;
_this . setInputs ( ) ;
window . addEventListener ( 'scroll' , function ( ) { //var fixLimit = this.fixLimit;
/ * *
* edit scroller needs work
if ( window . pageYOffset >= fixLimit ) {
document . getElementById ( 'edit-control' ) . style . position = 'fixed' ;
} else {
document . getElementById ( 'edit-control' ) . style . position = 'relative' ;
}
* /
} ) ;
_this . refresh ( ) ;
return _this ;
} //--------------------------
// methods
//--------------------------
_createClass ( TextEditor , [ {
key : "setInputs" ,
value : function setInputs ( ) {
var _this2 = 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 _this2 . handleEditorOption ( e ) ;
} , false ) ;
}
this . textEditor . addEventListener ( 'input' , function ( e ) {
var htmlTagRe = /<[a-z][\s\S]*>/g ;
var text = _this2 . textEditor . innerText ;
if ( e . inputType == 'insertParagraph' ) return ; //cursor setting gets weird on return, so just back out
if ( text . search ( htmlTagRe ) > - 1 ) {
var caret = ( 0 , _caretPos . position ) ( _this2 . textEditor ) . pos ;
self . refresh ( ) ;
( 0 , _caretPos . position ) ( _this2 . textEditor , caret ) ;
}
} ) ;
}
} , {
key : "refresh" ,
value : function refresh ( ) {
//var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value;
var spiffed = this . textEditor . innerText ;
spiffed = spiffed . replace ( new RegExp ( '\r?\n' , 'g' ) , '<br>' ) ;
var temp = document . createElement ( 'div' ) ;
temp . innerText = spiffed ;
this . textEditor . innerHTML = temp . innerText ;
this . textEditor . style . maxWidth = '900px' ;
}
} , {
key : "notify" ,
value : function notify ( type , data ) {
switch ( type ) {
case DataEvent . POST _UPDATED :
document . getElementById ( 'submit-update' ) . classList . add ( 'icon-hide' ) ;
document . getElementById ( 'submit-good' ) . classList . remove ( 'icon-hide' ) ;
document . getElementById ( 'edit-update' ) . classList . remove ( 'submit-start' ) ;
document . getElementById ( 'edit-update' ) . classList . add ( 'submit-cool' ) ;
setTimeout ( function ( ) {
document . getElementById ( 'submit-update' ) . classList . remove ( 'icon-hide' ) ;
document . getElementById ( 'submit-good' ) . classList . add ( 'icon-hide' ) ;
document . getElementById ( 'edit-update' ) . classList . add ( 'submit-start' ) ;
document . getElementById ( 'edit-update' ) . classList . remove ( 'submit-cool' ) ;
} , 2000 ) ;
break ;
case DataEvent . POST _ADDED :
// do nothing
break ;
case EditorEvent . EDITOR _UPLOAD _POST _IMAGE :
( 0 , _caretPos . position ) ( this . textEditor , this . caretPos ) ;
var sel , range ; //var 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
//--------------------------
} , {
key : "handleEditorOption" ,
value : function handleEditorOption ( e ) {
e . preventDefault ( ) ;
var sel , range , pulled ;
sel = window . getSelection ( ) ; //console.log(sel)
if ( sel . rangeCount ) {
range = sel . getRangeAt ( 0 ) ;
pulled = sel . getRangeAt ( 0 ) . toString ( ) ;
range . deleteContents ( ) ;
switch ( e . target . id ) {
case 'edit-bold' :
range . insertNode ( document . createTextNode ( '**' + pulled + '**' ) ) ;
break ;
case 'edit-italic' :
range . insertNode ( document . createTextNode ( '*' + pulled + '*' ) ) ;
break ;
case 'edit-strikethrough' :
range . insertNode ( document . createTextNode ( '<del>' + pulled + '</del>' ) ) ;
break ;
case 'edit-header1' :
range . insertNode ( document . createTextNode ( '# ' + pulled ) ) ;
break ;
case 'edit-header2' :
range . insertNode ( document . createTextNode ( '## ' + pulled ) ) ;
break ;
case 'edit-header3' :
range . insertNode ( document . createTextNode ( '### ' + pulled ) ) ;
break ;
case 'edit-image' :
this . caretPos = ( 0 , _caretPos . position ) ( this . textEditor ) . pos ;
this . emitEvent ( EditorEvent . EDITOR _UPLOAD _POST _IMAGE ) ;
break ;
case 'submit-save' :
case 'edit-save' :
this . emitEvent ( EditorEvent . EDITOR _SAVE ) ;
break ;
case 'submit-update' :
case 'edit-update' :
this . emitEvent ( EditorEvent . EDITOR _UPDATE ) ;
break ;
case 'edit-link' :
range . insertNode ( document . createTextNode ( '[' + pulled + '](PASTE URL HERE)' ) ) ;
break ;
case 'edit-delete' :
this . emitEvent ( EditorEvent . EDITOR _DELETE ) ;
break ;
default :
//range.insertNode(document.createTextNode("[" + self.url + "](PASTE URL HERE)"));
break ;
}
}
this . refresh ( ) ;
}
} ] ) ;
return TextEditor ;
} ( _EventEmitter2 . default ) ;
var _default = TextEditor ;
exports . default = _default ;
} , { "../events/DataEvent" : "events/DataEvent.js" , "caret-pos" : "../../node_modules/caret-pos/lib/esm2015/main.js" , "../events/EventEmitter" : "events/EventEmitter.js" , "../events/EditorEvent" : "events/EditorEvent.js" } ] , "../../node_modules/animejs/lib/anime.es.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
/ *
* anime . js v3 . 2.0
* ( c ) 2020 Julian Garnier
* Released under the MIT license
* animejs . com
* /
// Defaults
var defaultInstanceSettings = {
update : null ,
begin : null ,
loopBegin : null ,
changeBegin : null ,
change : null ,
changeComplete : null ,
loopComplete : null ,
complete : null ,
loop : 1 ,
direction : 'normal' ,
autoplay : true ,
timelineOffset : 0
} ;
var defaultTweenSettings = {
duration : 1000 ,
delay : 0 ,
endDelay : 0 ,
easing : 'easeOutElastic(1, .5)' ,
round : 0
} ;
var validTransforms = [ 'translateX' , 'translateY' , 'translateZ' , 'rotate' , 'rotateX' , 'rotateY' , 'rotateZ' , 'scale' , 'scaleX' , 'scaleY' , 'scaleZ' , 'skew' , 'skewX' , 'skewY' , 'perspective' , 'matrix' , 'matrix3d' ] ; // Caching
var cache = {
CSS : { } ,
springs : { }
} ; // Utils
function minMax ( val , min , max ) {
return Math . min ( Math . max ( val , min ) , max ) ;
}
function stringContains ( str , text ) {
return str . indexOf ( text ) > - 1 ;
}
function applyArguments ( func , args ) {
return func . apply ( null , args ) ;
}
var is = {
arr : function ( a ) {
return Array . isArray ( a ) ;
} ,
obj : function ( a ) {
return stringContains ( Object . prototype . toString . call ( a ) , 'Object' ) ;
} ,
pth : function ( a ) {
return is . obj ( a ) && a . hasOwnProperty ( 'totalLength' ) ;
} ,
svg : function ( a ) {
return a instanceof SVGElement ;
} ,
inp : function ( a ) {
return a instanceof HTMLInputElement ;
} ,
dom : function ( a ) {
return a . nodeType || is . svg ( a ) ;
} ,
str : function ( a ) {
return typeof a === 'string' ;
} ,
fnc : function ( a ) {
return typeof a === 'function' ;
} ,
und : function ( a ) {
return typeof a === 'undefined' ;
} ,
hex : function ( a ) {
return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i . test ( a ) ;
} ,
rgb : function ( a ) {
return /^rgb/ . test ( a ) ;
} ,
hsl : function ( a ) {
return /^hsl/ . test ( a ) ;
} ,
col : function ( a ) {
return is . hex ( a ) || is . rgb ( a ) || is . hsl ( a ) ;
} ,
key : function ( a ) {
return ! defaultInstanceSettings . hasOwnProperty ( a ) && ! defaultTweenSettings . hasOwnProperty ( a ) && a !== 'targets' && a !== 'keyframes' ;
}
} ; // Easings
function parseEasingParameters ( string ) {
var match = /\(([^)]+)\)/ . exec ( string ) ;
return match ? match [ 1 ] . split ( ',' ) . map ( function ( p ) {
return parseFloat ( p ) ;
} ) : [ ] ;
} // Spring solver inspired by Webkit Copyright © 2016 Apple Inc. All rights reserved. https://webkit.org/demos/spring/spring.js
function spring ( string , duration ) {
var params = parseEasingParameters ( string ) ;
var mass = minMax ( is . und ( params [ 0 ] ) ? 1 : params [ 0 ] , . 1 , 100 ) ;
var stiffness = minMax ( is . und ( params [ 1 ] ) ? 100 : params [ 1 ] , . 1 , 100 ) ;
var damping = minMax ( is . und ( params [ 2 ] ) ? 10 : params [ 2 ] , . 1 , 100 ) ;
var velocity = minMax ( is . und ( params [ 3 ] ) ? 0 : params [ 3 ] , . 1 , 100 ) ;
var w0 = Math . sqrt ( stiffness / mass ) ;
var zeta = damping / ( 2 * Math . sqrt ( stiffness * mass ) ) ;
var wd = zeta < 1 ? w0 * Math . sqrt ( 1 - zeta * zeta ) : 0 ;
var a = 1 ;
var b = zeta < 1 ? ( zeta * w0 + - velocity ) / wd : - velocity + w0 ;
function solver ( t ) {
var progress = duration ? duration * t / 1000 : t ;
if ( zeta < 1 ) {
progress = Math . exp ( - progress * zeta * w0 ) * ( a * Math . cos ( wd * progress ) + b * Math . sin ( wd * progress ) ) ;
} else {
progress = ( a + b * progress ) * Math . exp ( - progress * w0 ) ;
}
if ( t === 0 || t === 1 ) {
return t ;
}
return 1 - progress ;
}
function getDuration ( ) {
var cached = cache . springs [ string ] ;
if ( cached ) {
return cached ;
}
var frame = 1 / 6 ;
var elapsed = 0 ;
var rest = 0 ;
while ( true ) {
elapsed += frame ;
if ( solver ( elapsed ) === 1 ) {
rest ++ ;
if ( rest >= 16 ) {
break ;
}
} else {
rest = 0 ;
}
}
var duration = elapsed * frame * 1000 ;
cache . springs [ string ] = duration ;
return duration ;
}
return duration ? solver : getDuration ;
} // Basic steps easing implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
function steps ( steps ) {
if ( steps === void 0 ) steps = 10 ;
return function ( t ) {
return Math . ceil ( minMax ( t , 0.000001 , 1 ) * steps ) * ( 1 / steps ) ;
} ;
} // BezierEasing https://github.com/gre/bezier-easing
var bezier = function ( ) {
var kSplineTableSize = 11 ;
var kSampleStepSize = 1.0 / ( kSplineTableSize - 1.0 ) ;
function A ( aA1 , aA2 ) {
return 1.0 - 3.0 * aA2 + 3.0 * aA1 ;
}
function B ( aA1 , aA2 ) {
return 3.0 * aA2 - 6.0 * aA1 ;
}
function C ( aA1 ) {
return 3.0 * aA1 ;
}
function calcBezier ( aT , aA1 , aA2 ) {
return ( ( A ( aA1 , aA2 ) * aT + B ( aA1 , aA2 ) ) * aT + C ( aA1 ) ) * aT ;
}
function getSlope ( aT , aA1 , aA2 ) {
return 3.0 * A ( aA1 , aA2 ) * aT * aT + 2.0 * B ( aA1 , aA2 ) * aT + C ( aA1 ) ;
}
function binarySubdivide ( aX , aA , aB , mX1 , mX2 ) {
var currentX ,
currentT ,
i = 0 ;
do {
currentT = aA + ( aB - aA ) / 2.0 ;
currentX = calcBezier ( currentT , mX1 , mX2 ) - aX ;
if ( currentX > 0.0 ) {
aB = currentT ;
} else {
aA = currentT ;
}
} while ( Math . abs ( currentX ) > 0.0000001 && ++ i < 10 ) ;
return currentT ;
}
function newtonRaphsonIterate ( aX , aGuessT , mX1 , mX2 ) {
for ( var i = 0 ; i < 4 ; ++ i ) {
var currentSlope = getSlope ( aGuessT , mX1 , mX2 ) ;
if ( currentSlope === 0.0 ) {
return aGuessT ;
}
var currentX = calcBezier ( aGuessT , mX1 , mX2 ) - aX ;
aGuessT -= currentX / currentSlope ;
}
return aGuessT ;
}
function bezier ( mX1 , mY1 , mX2 , mY2 ) {
if ( ! ( 0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1 ) ) {
return ;
}
var sampleValues = new Float32Array ( kSplineTableSize ) ;
if ( mX1 !== mY1 || mX2 !== mY2 ) {
for ( var i = 0 ; i < kSplineTableSize ; ++ i ) {
sampleValues [ i ] = calcBezier ( i * kSampleStepSize , mX1 , mX2 ) ;
}
}
function getTForX ( aX ) {
var intervalStart = 0 ;
var currentSample = 1 ;
var lastSample = kSplineTableSize - 1 ;
for ( ; currentSample !== lastSample && sampleValues [ currentSample ] <= aX ; ++ currentSample ) {
intervalStart += kSampleStepSize ;
}
-- currentSample ;
var dist = ( aX - sampleValues [ currentSample ] ) / ( sampleValues [ currentSample + 1 ] - sampleValues [ currentSample ] ) ;
var guessForT = intervalStart + dist * kSampleStepSize ;
var initialSlope = getSlope ( guessForT , mX1 , mX2 ) ;
if ( initialSlope >= 0.001 ) {
return newtonRaphsonIterate ( aX , guessForT , mX1 , mX2 ) ;
} else if ( initialSlope === 0.0 ) {
return guessForT ;
} else {
return binarySubdivide ( aX , intervalStart , intervalStart + kSampleStepSize , mX1 , mX2 ) ;
}
}
return function ( x ) {
if ( mX1 === mY1 && mX2 === mY2 ) {
return x ;
}
if ( x === 0 || x === 1 ) {
return x ;
}
return calcBezier ( getTForX ( x ) , mY1 , mY2 ) ;
} ;
}
return bezier ;
} ( ) ;
var penner = function ( ) {
// Based on jQuery UI's implemenation of easing equations from Robert Penner (http://www.robertpenner.com/easing)
var eases = {
linear : function ( ) {
return function ( t ) {
return t ;
} ;
}
} ;
var functionEasings = {
Sine : function ( ) {
return function ( t ) {
return 1 - Math . cos ( t * Math . PI / 2 ) ;
} ;
} ,
Circ : function ( ) {
return function ( t ) {
return 1 - Math . sqrt ( 1 - t * t ) ;
} ;
} ,
Back : function ( ) {
return function ( t ) {
return t * t * ( 3 * t - 2 ) ;
} ;
} ,
Bounce : function ( ) {
return function ( t ) {
var pow2 ,
b = 4 ;
while ( t < ( ( pow2 = Math . pow ( 2 , -- b ) ) - 1 ) / 11 ) { }
return 1 / Math . pow ( 4 , 3 - b ) - 7.5625 * Math . pow ( ( pow2 * 3 - 2 ) / 22 - t , 2 ) ;
} ;
} ,
Elastic : function ( amplitude , period ) {
if ( amplitude === void 0 ) amplitude = 1 ;
if ( period === void 0 ) period = . 5 ;
var a = minMax ( amplitude , 1 , 10 ) ;
var p = minMax ( period , . 1 , 2 ) ;
return function ( t ) {
return t === 0 || t === 1 ? t : - a * Math . pow ( 2 , 10 * ( t - 1 ) ) * Math . sin ( ( t - 1 - p / ( Math . PI * 2 ) * Math . asin ( 1 / a ) ) * ( Math . PI * 2 ) / p ) ;
} ;
}
} ;
var baseEasings = [ 'Quad' , 'Cubic' , 'Quart' , 'Quint' , 'Expo' ] ;
baseEasings . forEach ( function ( name , i ) {
functionEasings [ name ] = function ( ) {
return function ( t ) {
return Math . pow ( t , i + 2 ) ;
} ;
} ;
} ) ;
Object . keys ( functionEasings ) . forEach ( function ( name ) {
var easeIn = functionEasings [ name ] ;
eases [ 'easeIn' + name ] = easeIn ;
eases [ 'easeOut' + name ] = function ( a , b ) {
return function ( t ) {
return 1 - easeIn ( a , b ) ( 1 - t ) ;
} ;
} ;
eases [ 'easeInOut' + name ] = function ( a , b ) {
return function ( t ) {
return t < 0.5 ? easeIn ( a , b ) ( t * 2 ) / 2 : 1 - easeIn ( a , b ) ( t * - 2 + 2 ) / 2 ;
} ;
} ;
} ) ;
return eases ;
} ( ) ;
function parseEasings ( easing , duration ) {
if ( is . fnc ( easing ) ) {
return easing ;
}
var name = easing . split ( '(' ) [ 0 ] ;
var ease = penner [ name ] ;
var args = parseEasingParameters ( easing ) ;
switch ( name ) {
case 'spring' :
return spring ( easing , duration ) ;
case 'cubicBezier' :
return applyArguments ( bezier , args ) ;
case 'steps' :
return applyArguments ( steps , args ) ;
default :
return applyArguments ( ease , args ) ;
}
} // Strings
function selectString ( str ) {
try {
var nodes = document . querySelectorAll ( str ) ;
return nodes ;
} catch ( e ) {
return ;
}
} // Arrays
function filterArray ( arr , callback ) {
var len = arr . length ;
var thisArg = arguments . length >= 2 ? arguments [ 1 ] : void 0 ;
var result = [ ] ;
for ( var i = 0 ; i < len ; i ++ ) {
if ( i in arr ) {
var val = arr [ i ] ;
if ( callback . call ( thisArg , val , i , arr ) ) {
result . push ( val ) ;
}
}
}
return result ;
}
function flattenArray ( arr ) {
return arr . reduce ( function ( a , b ) {
return a . concat ( is . arr ( b ) ? flattenArray ( b ) : b ) ;
} , [ ] ) ;
}
function toArray ( o ) {
if ( is . arr ( o ) ) {
return o ;
}
if ( is . str ( o ) ) {
o = selectString ( o ) || o ;
}
if ( o instanceof NodeList || o instanceof HTMLCollection ) {
return [ ] . slice . call ( o ) ;
}
return [ o ] ;
}
function arrayContains ( arr , val ) {
return arr . some ( function ( a ) {
return a === val ;
} ) ;
} // Objects
function cloneObject ( o ) {
var clone = { } ;
for ( var p in o ) {
clone [ p ] = o [ p ] ;
}
return clone ;
}
function replaceObjectProps ( o1 , o2 ) {
var o = cloneObject ( o1 ) ;
for ( var p in o1 ) {
o [ p ] = o2 . hasOwnProperty ( p ) ? o2 [ p ] : o1 [ p ] ;
}
return o ;
}
function mergeObjects ( o1 , o2 ) {
var o = cloneObject ( o1 ) ;
for ( var p in o2 ) {
o [ p ] = is . und ( o1 [ p ] ) ? o2 [ p ] : o1 [ p ] ;
}
return o ;
} // Colors
function rgbToRgba ( rgbValue ) {
var rgb = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g . exec ( rgbValue ) ;
return rgb ? "rgba(" + rgb [ 1 ] + ",1)" : rgbValue ;
}
function hexToRgba ( hexValue ) {
var rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i ;
var hex = hexValue . replace ( rgx , function ( m , r , g , b ) {
return r + r + g + g + b + b ;
} ) ;
var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i . exec ( hex ) ;
var r = parseInt ( rgb [ 1 ] , 16 ) ;
var g = parseInt ( rgb [ 2 ] , 16 ) ;
var b = parseInt ( rgb [ 3 ] , 16 ) ;
return "rgba(" + r + "," + g + "," + b + ",1)" ;
}
function hslToRgba ( hslValue ) {
var hsl = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g . exec ( hslValue ) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g . exec ( hslValue ) ;
var h = parseInt ( hsl [ 1 ] , 10 ) / 360 ;
var s = parseInt ( hsl [ 2 ] , 10 ) / 100 ;
var l = parseInt ( hsl [ 3 ] , 10 ) / 100 ;
var a = hsl [ 4 ] || 1 ;
function hue2rgb ( p , q , t ) {
if ( t < 0 ) {
t += 1 ;
}
if ( t > 1 ) {
t -= 1 ;
}
if ( t < 1 / 6 ) {
return p + ( q - p ) * 6 * t ;
}
if ( t < 1 / 2 ) {
return q ;
}
if ( t < 2 / 3 ) {
return p + ( q - p ) * ( 2 / 3 - t ) * 6 ;
}
return p ;
}
var r , g , b ;
if ( s == 0 ) {
r = g = b = l ;
} else {
var q = l < 0.5 ? l * ( 1 + s ) : l + s - l * s ;
var p = 2 * l - q ;
r = hue2rgb ( p , q , h + 1 / 3 ) ;
g = hue2rgb ( p , q , h ) ;
b = hue2rgb ( p , q , h - 1 / 3 ) ;
}
return "rgba(" + r * 255 + "," + g * 255 + "," + b * 255 + "," + a + ")" ;
}
function colorToRgb ( val ) {
if ( is . rgb ( val ) ) {
return rgbToRgba ( val ) ;
}
if ( is . hex ( val ) ) {
return hexToRgba ( val ) ;
}
if ( is . hsl ( val ) ) {
return hslToRgba ( val ) ;
}
} // Units
function getUnit ( val ) {
var split = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/ . exec ( val ) ;
if ( split ) {
return split [ 1 ] ;
}
}
function getTransformUnit ( propName ) {
if ( stringContains ( propName , 'translate' ) || propName === 'perspective' ) {
return 'px' ;
}
if ( stringContains ( propName , 'rotate' ) || stringContains ( propName , 'skew' ) ) {
return 'deg' ;
}
} // Values
function getFunctionValue ( val , animatable ) {
if ( ! is . fnc ( val ) ) {
return val ;
}
return val ( animatable . target , animatable . id , animatable . total ) ;
}
function getAttribute ( el , prop ) {
return el . getAttribute ( prop ) ;
}
function convertPxToUnit ( el , value , unit ) {
var valueUnit = getUnit ( value ) ;
if ( arrayContains ( [ unit , 'deg' , 'rad' , 'turn' ] , valueUnit ) ) {
return value ;
}
var cached = cache . CSS [ value + unit ] ;
if ( ! is . und ( cached ) ) {
return cached ;
}
var baseline = 100 ;
var tempEl = document . createElement ( el . tagName ) ;
var parentEl = el . parentNode && el . parentNode !== document ? el . parentNode : document . body ;
parentEl . appendChild ( tempEl ) ;
tempEl . style . position = 'absolute' ;
tempEl . style . width = baseline + unit ;
var factor = baseline / tempEl . offsetWidth ;
parentEl . removeChild ( tempEl ) ;
var convertedUnit = factor * parseFloat ( value ) ;
cache . CSS [ value + unit ] = convertedUnit ;
return convertedUnit ;
}
function getCSSValue ( el , prop , unit ) {
if ( prop in el . style ) {
var uppercasePropName = prop . replace ( /([a-z])([A-Z])/g , '$1-$2' ) . toLowerCase ( ) ;
var value = el . style [ prop ] || getComputedStyle ( el ) . getPropertyValue ( uppercasePropName ) || '0' ;
return unit ? convertPxToUnit ( el , value , unit ) : value ;
}
}
function getAnimationType ( el , prop ) {
if ( is . dom ( el ) && ! is . inp ( el ) && ( getAttribute ( el , prop ) || is . svg ( el ) && el [ prop ] ) ) {
return 'attribute' ;
}
if ( is . dom ( el ) && arrayContains ( validTransforms , prop ) ) {
return 'transform' ;
}
if ( is . dom ( el ) && prop !== 'transform' && getCSSValue ( el , prop ) ) {
return 'css' ;
}
if ( el [ prop ] != null ) {
return 'object' ;
}
}
function getElementTransforms ( el ) {
if ( ! is . dom ( el ) ) {
return ;
}
var str = el . style . transform || '' ;
var reg = /(\w+)\(([^)]*)\)/g ;
var transforms = new Map ( ) ;
var m ;
while ( m = reg . exec ( str ) ) {
transforms . set ( m [ 1 ] , m [ 2 ] ) ;
}
return transforms ;
}
function getTransformValue ( el , propName , animatable , unit ) {
var defaultVal = stringContains ( propName , 'scale' ) ? 1 : 0 + getTransformUnit ( propName ) ;
var value = getElementTransforms ( el ) . get ( propName ) || defaultVal ;
if ( animatable ) {
animatable . transforms . list . set ( propName , value ) ;
animatable . transforms [ 'last' ] = propName ;
}
return unit ? convertPxToUnit ( el , value , unit ) : value ;
}
function getOriginalTargetValue ( target , propName , unit , animatable ) {
switch ( getAnimationType ( target , propName ) ) {
case 'transform' :
return getTransformValue ( target , propName , animatable , unit ) ;
case 'css' :
return getCSSValue ( target , propName , unit ) ;
case 'attribute' :
return getAttribute ( target , propName ) ;
default :
return target [ propName ] || 0 ;
}
}
function getRelativeValue ( to , from ) {
var operator = /^(\*=|\+=|-=)/ . exec ( to ) ;
if ( ! operator ) {
return to ;
}
var u = getUnit ( to ) || 0 ;
var x = parseFloat ( from ) ;
var y = parseFloat ( to . replace ( operator [ 0 ] , '' ) ) ;
switch ( operator [ 0 ] [ 0 ] ) {
case '+' :
return x + y + u ;
case '-' :
return x - y + u ;
case '*' :
return x * y + u ;
}
}
function validateValue ( val , unit ) {
if ( is . col ( val ) ) {
return colorToRgb ( val ) ;
}
if ( /\s/g . test ( val ) ) {
return val ;
}
var originalUnit = getUnit ( val ) ;
var unitLess = originalUnit ? val . substr ( 0 , val . length - originalUnit . length ) : val ;
if ( unit ) {
return unitLess + unit ;
}
return unitLess ;
} // getTotalLength() equivalent for circle, rect, polyline, polygon and line shapes
// adapted from https://gist.github.com/SebLambla/3e0550c496c236709744
function getDistance ( p1 , p2 ) {
return Math . sqrt ( Math . pow ( p2 . x - p1 . x , 2 ) + Math . pow ( p2 . y - p1 . y , 2 ) ) ;
}
function getCircleLength ( el ) {
return Math . PI * 2 * getAttribute ( el , 'r' ) ;
}
function getRectLength ( el ) {
return getAttribute ( el , 'width' ) * 2 + getAttribute ( el , 'height' ) * 2 ;
}
function getLineLength ( el ) {
return getDistance ( {
x : getAttribute ( el , 'x1' ) ,
y : getAttribute ( el , 'y1' )
} , {
x : getAttribute ( el , 'x2' ) ,
y : getAttribute ( el , 'y2' )
} ) ;
}
function getPolylineLength ( el ) {
var points = el . points ;
var totalLength = 0 ;
var previousPos ;
for ( var i = 0 ; i < points . numberOfItems ; i ++ ) {
var currentPos = points . getItem ( i ) ;
if ( i > 0 ) {
totalLength += getDistance ( previousPos , currentPos ) ;
}
previousPos = currentPos ;
}
return totalLength ;
}
function getPolygonLength ( el ) {
var points = el . points ;
return getPolylineLength ( el ) + getDistance ( points . getItem ( points . numberOfItems - 1 ) , points . getItem ( 0 ) ) ;
} // Path animation
function getTotalLength ( el ) {
if ( el . getTotalLength ) {
return el . getTotalLength ( ) ;
}
switch ( el . tagName . toLowerCase ( ) ) {
case 'circle' :
return getCircleLength ( el ) ;
case 'rect' :
return getRectLength ( el ) ;
case 'line' :
return getLineLength ( el ) ;
case 'polyline' :
return getPolylineLength ( el ) ;
case 'polygon' :
return getPolygonLength ( el ) ;
}
}
function setDashoffset ( el ) {
var pathLength = getTotalLength ( el ) ;
el . setAttribute ( 'stroke-dasharray' , pathLength ) ;
return pathLength ;
} // Motion path
function getParentSvgEl ( el ) {
var parentEl = el . parentNode ;
while ( is . svg ( parentEl ) ) {
if ( ! is . svg ( parentEl . parentNode ) ) {
break ;
}
parentEl = parentEl . parentNode ;
}
return parentEl ;
}
function getParentSvg ( pathEl , svgData ) {
var svg = svgData || { } ;
var parentSvgEl = svg . el || getParentSvgEl ( pathEl ) ;
var rect = parentSvgEl . getBoundingClientRect ( ) ;
var viewBoxAttr = getAttribute ( parentSvgEl , 'viewBox' ) ;
var width = rect . width ;
var height = rect . height ;
var viewBox = svg . viewBox || ( viewBoxAttr ? viewBoxAttr . split ( ' ' ) : [ 0 , 0 , width , height ] ) ;
return {
el : parentSvgEl ,
viewBox : viewBox ,
x : viewBox [ 0 ] / 1 ,
y : viewBox [ 1 ] / 1 ,
w : width / viewBox [ 2 ] ,
h : height / viewBox [ 3 ]
} ;
}
function getPath ( path , percent ) {
var pathEl = is . str ( path ) ? selectString ( path ) [ 0 ] : path ;
var p = percent || 100 ;
return function ( property ) {
return {
property : property ,
el : pathEl ,
svg : getParentSvg ( pathEl ) ,
totalLength : getTotalLength ( pathEl ) * ( p / 100 )
} ;
} ;
}
function getPathProgress ( path , progress ) {
function point ( offset ) {
if ( offset === void 0 ) offset = 0 ;
var l = progress + offset >= 1 ? progress + offset : 0 ;
return path . el . getPointAtLength ( l ) ;
}
var svg = getParentSvg ( path . el , path . svg ) ;
var p = point ( ) ;
var p0 = point ( - 1 ) ;
var p1 = point ( + 1 ) ;
switch ( path . property ) {
case 'x' :
return ( p . x - svg . x ) * svg . w ;
case 'y' :
return ( p . y - svg . y ) * svg . h ;
case 'angle' :
return Math . atan2 ( p1 . y - p0 . y , p1 . x - p0 . x ) * 180 / Math . PI ;
}
} // Decompose value
function decomposeValue ( val , unit ) {
// const rgx = /-?\d*\.?\d+/g; // handles basic numbers
// const rgx = /[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g; // handles exponents notation
var rgx = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g ; // handles exponents notation
var value = validateValue ( is . pth ( val ) ? val . totalLength : val , unit ) + '' ;
return {
original : value ,
numbers : value . match ( rgx ) ? value . match ( rgx ) . map ( Number ) : [ 0 ] ,
strings : is . str ( val ) || unit ? value . split ( rgx ) : [ ]
} ;
} // Animatables
function parseTargets ( targets ) {
var targetsArray = targets ? flattenArray ( is . arr ( targets ) ? targets . map ( toArray ) : toArray ( targets ) ) : [ ] ;
return filterArray ( targetsArray , function ( item , pos , self ) {
return self . indexOf ( item ) === pos ;
} ) ;
}
function getAnimatables ( targets ) {
var parsed = parseTargets ( targets ) ;
return parsed . map ( function ( t , i ) {
return {
target : t ,
id : i ,
total : parsed . length ,
transforms : {
list : getElementTransforms ( t )
}
} ;
} ) ;
} // Properties
function normalizePropertyTweens ( prop , tweenSettings ) {
var settings = cloneObject ( tweenSettings ) ; // Override duration if easing is a spring
if ( /^spring/ . test ( settings . easing ) ) {
settings . duration = spring ( settings . easing ) ;
}
if ( is . arr ( prop ) ) {
var l = prop . length ;
var isFromTo = l === 2 && ! is . obj ( prop [ 0 ] ) ;
if ( ! isFromTo ) {
// Duration divided by the number of tweens
if ( ! is . fnc ( tweenSettings . duration ) ) {
settings . duration = tweenSettings . duration / l ;
}
} else {
// Transform [from, to] values shorthand to a valid tween value
prop = {
value : prop
} ;
}
}
var propArray = is . arr ( prop ) ? prop : [ prop ] ;
return propArray . map ( function ( v , i ) {
var obj = is . obj ( v ) && ! is . pth ( v ) ? v : {
value : v
} ; // Default delay value should only be applied to the first tween
if ( is . und ( obj . delay ) ) {
obj . delay = ! i ? tweenSettings . delay : 0 ;
} // Default endDelay value should only be applied to the last tween
if ( is . und ( obj . endDelay ) ) {
obj . endDelay = i === propArray . length - 1 ? tweenSettings . endDelay : 0 ;
}
return obj ;
} ) . map ( function ( k ) {
return mergeObjects ( k , settings ) ;
} ) ;
}
function flattenKeyframes ( keyframes ) {
var propertyNames = filterArray ( flattenArray ( keyframes . map ( function ( key ) {
return Object . keys ( key ) ;
} ) ) , function ( p ) {
return is . key ( p ) ;
} ) . reduce ( function ( a , b ) {
if ( a . indexOf ( b ) < 0 ) {
a . push ( b ) ;
}
return a ;
} , [ ] ) ;
var properties = { } ;
var loop = function ( i ) {
var propName = propertyNames [ i ] ;
properties [ propName ] = keyframes . map ( function ( key ) {
var newKey = { } ;
for ( var p in key ) {
if ( is . key ( p ) ) {
if ( p == propName ) {
newKey . value = key [ p ] ;
}
} else {
newKey [ p ] = key [ p ] ;
}
}
return newKey ;
} ) ;
} ;
for ( var i = 0 ; i < propertyNames . length ; i ++ ) loop ( i ) ;
return properties ;
}
function getProperties ( tweenSettings , params ) {
var properties = [ ] ;
var keyframes = params . keyframes ;
if ( keyframes ) {
params = mergeObjects ( flattenKeyframes ( keyframes ) , params ) ;
}
for ( var p in params ) {
if ( is . key ( p ) ) {
properties . push ( {
name : p ,
tweens : normalizePropertyTweens ( params [ p ] , tweenSettings )
} ) ;
}
}
return properties ;
} // Tweens
function normalizeTweenValues ( tween , animatable ) {
var t = { } ;
for ( var p in tween ) {
var value = getFunctionValue ( tween [ p ] , animatable ) ;
if ( is . arr ( value ) ) {
value = value . map ( function ( v ) {
return getFunctionValue ( v , animatable ) ;
} ) ;
if ( value . length === 1 ) {
value = value [ 0 ] ;
}
}
t [ p ] = value ;
}
t . duration = parseFloat ( t . duration ) ;
t . delay = parseFloat ( t . delay ) ;
return t ;
}
function normalizeTweens ( prop , animatable ) {
var previousTween ;
return prop . tweens . map ( function ( t ) {
var tween = normalizeTweenValues ( t , animatable ) ;
var tweenValue = tween . value ;
var to = is . arr ( tweenValue ) ? tweenValue [ 1 ] : tweenValue ;
var toUnit = getUnit ( to ) ;
var originalValue = getOriginalTargetValue ( animatable . target , prop . name , toUnit , animatable ) ;
var previousValue = previousTween ? previousTween . to . original : originalValue ;
var from = is . arr ( tweenValue ) ? tweenValue [ 0 ] : previousValue ;
var fromUnit = getUnit ( from ) || getUnit ( originalValue ) ;
var unit = toUnit || fromUnit ;
if ( is . und ( to ) ) {
to = previousValue ;
}
tween . from = decomposeValue ( from , unit ) ;
tween . to = decomposeValue ( getRelativeValue ( to , from ) , unit ) ;
tween . start = previousTween ? previousTween . end : 0 ;
tween . end = tween . start + tween . delay + tween . duration + tween . endDelay ;
tween . easing = parseEasings ( tween . easing , tween . duration ) ;
tween . isPath = is . pth ( tweenValue ) ;
tween . isColor = is . col ( tween . from . original ) ;
if ( tween . isColor ) {
tween . round = 1 ;
}
previousTween = tween ;
return tween ;
} ) ;
} // Tween progress
var setProgressValue = {
css : function ( t , p , v ) {
return t . style [ p ] = v ;
} ,
attribute : function ( t , p , v ) {
return t . setAttribute ( p , v ) ;
} ,
object : function ( t , p , v ) {
return t [ p ] = v ;
} ,
transform : function ( t , p , v , transforms , manual ) {
transforms . list . set ( p , v ) ;
if ( p === transforms . last || manual ) {
var str = '' ;
transforms . list . forEach ( function ( value , prop ) {
str += prop + "(" + value + ") " ;
} ) ;
t . style . transform = str ;
}
}
} ; // Set Value helper
function setTargetsValue ( targets , properties ) {
var animatables = getAnimatables ( targets ) ;
animatables . forEach ( function ( animatable ) {
for ( var property in properties ) {
var value = getFunctionValue ( properties [ property ] , animatable ) ;
var target = animatable . target ;
var valueUnit = getUnit ( value ) ;
var originalValue = getOriginalTargetValue ( target , property , valueUnit , animatable ) ;
var unit = valueUnit || getUnit ( originalValue ) ;
var to = getRelativeValue ( validateValue ( value , unit ) , originalValue ) ;
var animType = getAnimationType ( target , property ) ;
setProgressValue [ animType ] ( target , property , to , animatable . transforms , true ) ;
}
} ) ;
} // Animations
function createAnimation ( animatable , prop ) {
var animType = getAnimationType ( animatable . target , prop . name ) ;
if ( animType ) {
var tweens = normalizeTweens ( prop , animatable ) ;
var lastTween = tweens [ tweens . length - 1 ] ;
return {
type : animType ,
property : prop . name ,
animatable : animatable ,
tweens : tweens ,
duration : lastTween . end ,
delay : tweens [ 0 ] . delay ,
endDelay : lastTween . endDelay
} ;
}
}
function getAnimations ( animatables , properties ) {
return filterArray ( flattenArray ( animatables . map ( function ( animatable ) {
return properties . map ( function ( prop ) {
return createAnimation ( animatable , prop ) ;
} ) ;
} ) ) , function ( a ) {
return ! is . und ( a ) ;
} ) ;
} // Create Instance
function getInstanceTimings ( animations , tweenSettings ) {
var animLength = animations . length ;
var getTlOffset = function ( anim ) {
return anim . timelineOffset ? anim . timelineOffset : 0 ;
} ;
var timings = { } ;
timings . duration = animLength ? Math . max . apply ( Math , animations . map ( function ( anim ) {
return getTlOffset ( anim ) + anim . duration ;
} ) ) : tweenSettings . duration ;
timings . delay = animLength ? Math . min . apply ( Math , animations . map ( function ( anim ) {
return getTlOffset ( anim ) + anim . delay ;
} ) ) : tweenSettings . delay ;
timings . endDelay = animLength ? timings . duration - Math . max . apply ( Math , animations . map ( function ( anim ) {
return getTlOffset ( anim ) + anim . duration - anim . endDelay ;
} ) ) : tweenSettings . endDelay ;
return timings ;
}
var instanceID = 0 ;
function createNewInstance ( params ) {
var instanceSettings = replaceObjectProps ( defaultInstanceSettings , params ) ;
var tweenSettings = replaceObjectProps ( defaultTweenSettings , params ) ;
var properties = getProperties ( tweenSettings , params ) ;
var animatables = getAnimatables ( params . targets ) ;
var animations = getAnimations ( animatables , properties ) ;
var timings = getInstanceTimings ( animations , tweenSettings ) ;
var id = instanceID ;
instanceID ++ ;
return mergeObjects ( instanceSettings , {
id : id ,
children : [ ] ,
animatables : animatables ,
animations : animations ,
duration : timings . duration ,
delay : timings . delay ,
endDelay : timings . endDelay
} ) ;
} // Core
var activeInstances = [ ] ;
var pausedInstances = [ ] ;
var raf ;
var engine = function ( ) {
function play ( ) {
raf = requestAnimationFrame ( step ) ;
}
function step ( t ) {
var activeInstancesLength = activeInstances . length ;
if ( activeInstancesLength ) {
var i = 0 ;
while ( i < activeInstancesLength ) {
var activeInstance = activeInstances [ i ] ;
if ( ! activeInstance . paused ) {
activeInstance . tick ( t ) ;
} else {
var instanceIndex = activeInstances . indexOf ( activeInstance ) ;
if ( instanceIndex > - 1 ) {
activeInstances . splice ( instanceIndex , 1 ) ;
activeInstancesLength = activeInstances . length ;
}
}
i ++ ;
}
play ( ) ;
} else {
raf = cancelAnimationFrame ( raf ) ;
}
}
return play ;
} ( ) ;
function handleVisibilityChange ( ) {
if ( document . hidden ) {
activeInstances . forEach ( function ( ins ) {
return ins . pause ( ) ;
} ) ;
pausedInstances = activeInstances . slice ( 0 ) ;
anime . running = activeInstances = [ ] ;
} else {
pausedInstances . forEach ( function ( ins ) {
return ins . play ( ) ;
} ) ;
}
}
if ( typeof document !== 'undefined' ) {
document . addEventListener ( 'visibilitychange' , handleVisibilityChange ) ;
} // Public Instance
function anime ( params ) {
if ( params === void 0 ) params = { } ;
var startTime = 0 ,
lastTime = 0 ,
now = 0 ;
var children ,
childrenLength = 0 ;
var resolve = null ;
function makePromise ( instance ) {
var promise = window . Promise && new Promise ( function ( _resolve ) {
return resolve = _resolve ;
} ) ;
instance . finished = promise ;
return promise ;
}
var instance = createNewInstance ( params ) ;
var promise = makePromise ( instance ) ;
function toggleInstanceDirection ( ) {
var direction = instance . direction ;
if ( direction !== 'alternate' ) {
instance . direction = direction !== 'normal' ? 'normal' : 'reverse' ;
}
instance . reversed = ! instance . reversed ;
children . forEach ( function ( child ) {
return child . reversed = instance . reversed ;
} ) ;
}
function adjustTime ( time ) {
return instance . reversed ? instance . duration - time : time ;
}
function resetTime ( ) {
startTime = 0 ;
lastTime = adjustTime ( instance . currentTime ) * ( 1 / anime . speed ) ;
}
function seekChild ( time , child ) {
if ( child ) {
child . seek ( time - child . timelineOffset ) ;
}
}
function syncInstanceChildren ( time ) {
if ( ! instance . reversePlayback ) {
for ( var i = 0 ; i < childrenLength ; i ++ ) {
seekChild ( time , children [ i ] ) ;
}
} else {
for ( var i$1 = childrenLength ; i$1 -- ; ) {
seekChild ( time , children [ i$1 ] ) ;
}
}
}
function setAnimationsProgress ( insTime ) {
var i = 0 ;
var animations = instance . animations ;
var animationsLength = animations . length ;
while ( i < animationsLength ) {
var anim = animations [ i ] ;
var animatable = anim . animatable ;
var tweens = anim . tweens ;
var tweenLength = tweens . length - 1 ;
var tween = tweens [ tweenLength ] ; // Only check for keyframes if there is more than one tween
if ( tweenLength ) {
tween = filterArray ( tweens , function ( t ) {
return insTime < t . end ;
} ) [ 0 ] || tween ;
}
var elapsed = minMax ( insTime - tween . start - tween . delay , 0 , tween . duration ) / tween . duration ;
var eased = isNaN ( elapsed ) ? 1 : tween . easing ( elapsed ) ;
var strings = tween . to . strings ;
var round = tween . round ;
var numbers = [ ] ;
var toNumbersLength = tween . to . numbers . length ;
var progress = void 0 ;
for ( var n = 0 ; n < toNumbersLength ; n ++ ) {
var value = void 0 ;
var toNumber = tween . to . numbers [ n ] ;
var fromNumber = tween . from . numbers [ n ] || 0 ;
if ( ! tween . isPath ) {
value = fromNumber + eased * ( toNumber - fromNumber ) ;
} else {
value = getPathProgress ( tween . value , eased * toNumber ) ;
}
if ( round ) {
if ( ! ( tween . isColor && n > 2 ) ) {
value = Math . round ( value * round ) / round ;
}
}
numbers . push ( value ) ;
} // Manual Array.reduce for better performances
var stringsLength = strings . length ;
if ( ! stringsLength ) {
progress = numbers [ 0 ] ;
} else {
progress = strings [ 0 ] ;
for ( var s = 0 ; s < stringsLength ; s ++ ) {
var a = strings [ s ] ;
var b = strings [ s + 1 ] ;
var n$1 = numbers [ s ] ;
if ( ! isNaN ( n$1 ) ) {
if ( ! b ) {
progress += n$1 + ' ' ;
} else {
progress += n$1 + b ;
}
}
}
}
setProgressValue [ anim . type ] ( animatable . target , anim . property , progress , animatable . transforms ) ;
anim . currentValue = progress ;
i ++ ;
}
}
function setCallback ( cb ) {
if ( instance [ cb ] && ! instance . passThrough ) {
instance [ cb ] ( instance ) ;
}
}
function countIteration ( ) {
if ( instance . remaining && instance . remaining !== true ) {
instance . remaining -- ;
}
}
function setInstanceProgress ( engineTime ) {
var insDuration = instance . duration ;
var insDelay = instance . delay ;
var insEndDelay = insDuration - instance . endDelay ;
var insTime = adjustTime ( engineTime ) ;
instance . progress = minMax ( insTime / insDuration * 100 , 0 , 100 ) ;
instance . reversePlayback = insTime < instance . currentTime ;
if ( children ) {
syncInstanceChildren ( insTime ) ;
}
if ( ! instance . began && instance . currentTime > 0 ) {
instance . began = true ;
setCallback ( 'begin' ) ;
}
if ( ! instance . loopBegan && instance . currentTime > 0 ) {
instance . loopBegan = true ;
setCallback ( 'loopBegin' ) ;
}
if ( insTime <= insDelay && instance . currentTime !== 0 ) {
setAnimationsProgress ( 0 ) ;
}
if ( insTime >= insEndDelay && instance . currentTime !== insDuration || ! insDuration ) {
setAnimationsProgress ( insDuration ) ;
}
if ( insTime > insDelay && insTime < insEndDelay ) {
if ( ! instance . changeBegan ) {
instance . changeBegan = true ;
instance . changeCompleted = false ;
setCallback ( 'changeBegin' ) ;
}
setCallback ( 'change' ) ;
setAnimationsProgress ( insTime ) ;
} else {
if ( instance . changeBegan ) {
instance . changeCompleted = true ;
instance . changeBegan = false ;
setCallback ( 'changeComplete' ) ;
}
}
instance . currentTime = minMax ( insTime , 0 , insDuration ) ;
if ( instance . began ) {
setCallback ( 'update' ) ;
}
if ( engineTime >= insDuration ) {
lastTime = 0 ;
countIteration ( ) ;
if ( ! instance . remaining ) {
instance . paused = true ;
if ( ! instance . completed ) {
instance . completed = true ;
setCallback ( 'loopComplete' ) ;
setCallback ( 'complete' ) ;
if ( ! instance . passThrough && 'Promise' in window ) {
resolve ( ) ;
promise = makePromise ( instance ) ;
}
}
} else {
startTime = now ;
setCallback ( 'loopComplete' ) ;
instance . loopBegan = false ;
if ( instance . direction === 'alternate' ) {
toggleInstanceDirection ( ) ;
}
}
}
}
instance . reset = function ( ) {
var direction = instance . direction ;
instance . passThrough = false ;
instance . currentTime = 0 ;
instance . progress = 0 ;
instance . paused = true ;
instance . began = false ;
instance . loopBegan = false ;
instance . changeBegan = false ;
instance . completed = false ;
instance . changeCompleted = false ;
instance . reversePlayback = false ;
instance . reversed = direction === 'reverse' ;
instance . remaining = instance . loop ;
children = instance . children ;
childrenLength = children . length ;
for ( var i = childrenLength ; i -- ; ) {
instance . children [ i ] . reset ( ) ;
}
if ( instance . reversed && instance . loop !== true || direction === 'alternate' && instance . loop === 1 ) {
instance . remaining ++ ;
}
setAnimationsProgress ( instance . reversed ? instance . duration : 0 ) ;
} ; // Set Value helper
instance . set = function ( targets , properties ) {
setTargetsValue ( targets , properties ) ;
return instance ;
} ;
instance . tick = function ( t ) {
now = t ;
if ( ! startTime ) {
startTime = now ;
}
setInstanceProgress ( ( now + ( lastTime - startTime ) ) * anime . speed ) ;
} ;
instance . seek = function ( time ) {
setInstanceProgress ( adjustTime ( time ) ) ;
} ;
instance . pause = function ( ) {
instance . paused = true ;
resetTime ( ) ;
} ;
instance . play = function ( ) {
if ( ! instance . paused ) {
return ;
}
if ( instance . completed ) {
instance . reset ( ) ;
}
instance . paused = false ;
activeInstances . push ( instance ) ;
resetTime ( ) ;
if ( ! raf ) {
engine ( ) ;
}
} ;
instance . reverse = function ( ) {
toggleInstanceDirection ( ) ;
instance . completed = instance . reversed ? false : true ;
resetTime ( ) ;
} ;
instance . restart = function ( ) {
instance . reset ( ) ;
instance . play ( ) ;
} ;
instance . reset ( ) ;
if ( instance . autoplay ) {
instance . play ( ) ;
}
return instance ;
} // Remove targets from animation
function removeTargetsFromAnimations ( targetsArray , animations ) {
for ( var a = animations . length ; a -- ; ) {
if ( arrayContains ( targetsArray , animations [ a ] . animatable . target ) ) {
animations . splice ( a , 1 ) ;
}
}
}
function removeTargets ( targets ) {
var targetsArray = parseTargets ( targets ) ;
for ( var i = activeInstances . length ; i -- ; ) {
var instance = activeInstances [ i ] ;
var animations = instance . animations ;
var children = instance . children ;
removeTargetsFromAnimations ( targetsArray , animations ) ;
for ( var c = children . length ; c -- ; ) {
var child = children [ c ] ;
var childAnimations = child . animations ;
removeTargetsFromAnimations ( targetsArray , childAnimations ) ;
if ( ! childAnimations . length && ! child . children . length ) {
children . splice ( c , 1 ) ;
}
}
if ( ! animations . length && ! children . length ) {
instance . pause ( ) ;
}
}
} // Stagger helpers
function stagger ( val , params ) {
if ( params === void 0 ) params = { } ;
var direction = params . direction || 'normal' ;
var easing = params . easing ? parseEasings ( params . easing ) : null ;
var grid = params . grid ;
var axis = params . axis ;
var fromIndex = params . from || 0 ;
var fromFirst = fromIndex === 'first' ;
var fromCenter = fromIndex === 'center' ;
var fromLast = fromIndex === 'last' ;
var isRange = is . arr ( val ) ;
var val1 = isRange ? parseFloat ( val [ 0 ] ) : parseFloat ( val ) ;
var val2 = isRange ? parseFloat ( val [ 1 ] ) : 0 ;
var unit = getUnit ( isRange ? val [ 1 ] : val ) || 0 ;
var start = params . start || 0 + ( isRange ? val1 : 0 ) ;
var values = [ ] ;
var maxValue = 0 ;
return function ( el , i , t ) {
if ( fromFirst ) {
fromIndex = 0 ;
}
if ( fromCenter ) {
fromIndex = ( t - 1 ) / 2 ;
}
if ( fromLast ) {
fromIndex = t - 1 ;
}
if ( ! values . length ) {
for ( var index = 0 ; index < t ; index ++ ) {
if ( ! grid ) {
values . push ( Math . abs ( fromIndex - index ) ) ;
} else {
var fromX = ! fromCenter ? fromIndex % grid [ 0 ] : ( grid [ 0 ] - 1 ) / 2 ;
var fromY = ! fromCenter ? Math . floor ( fromIndex / grid [ 0 ] ) : ( grid [ 1 ] - 1 ) / 2 ;
var toX = index % grid [ 0 ] ;
var toY = Math . floor ( index / grid [ 0 ] ) ;
var distanceX = fromX - toX ;
var distanceY = fromY - toY ;
var value = Math . sqrt ( distanceX * distanceX + distanceY * distanceY ) ;
if ( axis === 'x' ) {
value = - distanceX ;
}
if ( axis === 'y' ) {
value = - distanceY ;
}
values . push ( value ) ;
}
maxValue = Math . max . apply ( Math , values ) ;
}
if ( easing ) {
values = values . map ( function ( val ) {
return easing ( val / maxValue ) * maxValue ;
} ) ;
}
if ( direction === 'reverse' ) {
values = values . map ( function ( val ) {
return axis ? val < 0 ? val * - 1 : - val : Math . abs ( maxValue - val ) ;
} ) ;
}
}
var spacing = isRange ? ( val2 - val1 ) / maxValue : val1 ;
return start + spacing * ( Math . round ( values [ i ] * 100 ) / 100 ) + unit ;
} ;
} // Timeline
function timeline ( params ) {
if ( params === void 0 ) params = { } ;
var tl = anime ( params ) ;
tl . duration = 0 ;
tl . add = function ( instanceParams , timelineOffset ) {
var tlIndex = activeInstances . indexOf ( tl ) ;
var children = tl . children ;
if ( tlIndex > - 1 ) {
activeInstances . splice ( tlIndex , 1 ) ;
}
function passThrough ( ins ) {
ins . passThrough = true ;
}
for ( var i = 0 ; i < children . length ; i ++ ) {
passThrough ( children [ i ] ) ;
}
var insParams = mergeObjects ( instanceParams , replaceObjectProps ( defaultTweenSettings , params ) ) ;
insParams . targets = insParams . targets || params . targets ;
var tlDuration = tl . duration ;
insParams . autoplay = false ;
insParams . direction = tl . direction ;
insParams . timelineOffset = is . und ( timelineOffset ) ? tlDuration : getRelativeValue ( timelineOffset , tlDuration ) ;
passThrough ( tl ) ;
tl . seek ( insParams . timelineOffset ) ;
var ins = anime ( insParams ) ;
passThrough ( ins ) ;
children . push ( ins ) ;
var timings = getInstanceTimings ( children , params ) ;
tl . delay = timings . delay ;
tl . endDelay = timings . endDelay ;
tl . duration = timings . duration ;
tl . seek ( 0 ) ;
tl . reset ( ) ;
if ( tl . autoplay ) {
tl . play ( ) ;
}
return tl ;
} ;
return tl ;
}
anime . version = '3.2.0' ;
anime . speed = 1 ;
anime . running = activeInstances ;
anime . remove = removeTargets ;
anime . get = getOriginalTargetValue ;
anime . set = setTargetsValue ;
anime . convertPx = convertPxToUnit ;
anime . path = getPath ;
anime . setDashoffset = setDashoffset ;
anime . stagger = stagger ;
anime . timeline = timeline ;
anime . easing = parseEasings ;
anime . penner = penner ;
anime . random = function ( min , max ) {
return Math . floor ( Math . random ( ) * ( max - min + 1 ) ) + min ;
} ;
var _default = anime ;
exports . default = _default ;
} , { } ] , "ui/Notifications.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _animeEs = _interopRequireDefault ( require ( "animejs/lib/anime.es.js" ) ) ;
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" ) ; } }
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 ; }
var notifcation = document . getElementById ( 'notifications' ) ;
var messageText = document . getElementById ( 'message-text' ) ;
var iconGood = document . getElementById ( 'notify-good' ) ;
var iconLame = document . getElementById ( 'notify-lame' ) ;
var iconWorking = document . getElementById ( 'notify-working' ) ;
var Notfications = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function Notfications ( ) {
_classCallCheck ( this , Notfications ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( Notfications , [ {
key : "alert" ,
value : function alert ( text , status ) {
//notifcation.style.display = 'flex';
iconWorking . style . display = 'none' ;
iconGood . style . display = 'none' ;
iconLame . style . display = 'none' ;
var color = '' ;
if ( status !== null ) {
if ( status ) {
color = '#32cd32' ;
iconWorking . style . display = 'none' ;
iconGood . style . display = 'block' ;
} else {
color = '#F64747' ;
iconWorking . style . display = 'none' ;
iconLame . style . display = 'block' ;
}
} else {
color = '#200317' ;
iconWorking . style . display = 'block' ;
}
notifcation . classList . remove ( 'notify-close' ) ;
notifcation . classList . add ( 'notify-open' ) ;
messageText . innerHTML = text ;
( 0 , _animeEs . default ) ( {
targets : messageText ,
backgroundColor : color ,
easing : 'easeInOutQuint' ,
duration : 700 ,
complete : function complete ( ) {
if ( status !== null ) {
setTimeout ( function ( ) {
notifcation . classList . add ( 'notify-close' ) ;
notifcation . classList . remove ( 'notify-open' ) ;
} , 1000 ) ;
}
}
} ) ;
/ *
anime ( {
targets : message ,
marginTop : '-20px' ,
easing : 'easeInOutQuint' ,
duration : 500 ,
opacity : 1 ,
complete : ( ) => {
setTimeout ( ( ) => {
anime ( {
targets : message ,
marginTop : '-125px' ,
easing : 'easeOutQuint' ,
duration : 500 ,
opacity : 0 ,
complete : ( ) => {
notifcation . style . display = 'none' ;
}
} ) ;
} , 1000 ) ;
}
} ) ;
* /
} //--------------------------
// event handlers
//--------------------------
} ] ) ;
return Notfications ;
} ( ) ;
exports . default = Notfications ;
} , { "animejs/lib/anime.es.js" : "../../node_modules/animejs/lib/anime.es.js" } ] , "controllers/PageEditor.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _FipamoAdminAPI = _interopRequireWildcard ( require ( "../../libraries/FipamoAdminAPI" ) ) ;
var DataEvent = _interopRequireWildcard ( require ( "../events/DataEvent" ) ) ;
var _PageActions = _interopRequireDefault ( require ( "../actions/PageActions" ) ) ;
var EditorEvent = _interopRequireWildcard ( require ( "../events/EditorEvent" ) ) ;
var _TextEditor = _interopRequireDefault ( require ( "../ui/TextEditor" ) ) ;
var _Notifications = _interopRequireDefault ( require ( "../ui/Notifications" ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
function _getRequireWildcardCache ( ) { if ( typeof WeakMap !== "function" ) return null ; var cache = new WeakMap ( ) ; _getRequireWildcardCache = function ( ) { return cache ; } ; return cache ; }
function _interopRequireWildcard ( obj ) { if ( obj && obj . _ _esModule ) { return obj ; } if ( obj === null || typeof obj !== "object" && typeof obj !== "function" ) { return { default : obj } ; } var cache = _getRequireWildcardCache ( ) ; if ( cache && cache . has ( obj ) ) { return cache . get ( obj ) ; } var newObj = { } ; var hasPropertyDescriptor = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = hasPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : null ; if ( desc && ( desc . get || desc . set ) ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } newObj . default = obj ; if ( cache ) { cache . set ( obj , newObj ) ; } return newObj ; }
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 ; }
var admin = new _FipamoAdminAPI . default ( ) ;
var notify = new _Notifications . default ( ) ;
var PostEditor = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function PostEditor ( ) {
var _this = this ;
_classCallCheck ( this , PostEditor ) ;
var self = this ;
this . urlPieces = document . URL . split ( '/' ) ;
this . post = [ ] ;
this . postID = null ;
this . postUUID = null ;
this . postLayout = null ;
if ( document . getElementById ( 'post-edit-index' ) . getAttribute ( 'data-index' ) ) {
this . postID = document . getElementById ( 'post-edit-index' ) . getAttribute ( 'data-index' ) ;
this . postUUID = document . getElementById ( 'post-edit-index' ) . getAttribute ( 'data-uuid' ) ;
this . postLayout = document . getElementById ( 'post-edit-index' ) . getAttribute ( 'data-layout' ) ;
}
if ( document . getElementById ( 'edit-post-text' ) ) {
this . editor = new _TextEditor . default ( document . getElementById ( 'edit-post-text' ) , document . getElementById ( 'header' ) . offsetHeight + document . getElementById ( 'post-header' ) . offsetHeight + document . getElementById ( 'post-feature' ) . offsetHeight ) ;
this . editor . addListener ( EditorEvent . EDITOR _DELETE , function ( ) {
return _this . handleEditorOptions ( EditorEvent . EDITOR _DELETE ) ;
} , false ) ;
this . editor . addListener ( EditorEvent . EDITOR _UPLOAD _POST _IMAGE , function ( ) {
return _this . handleEditorOptions ( EditorEvent . EDITOR _UPLOAD _POST _IMAGE ) ;
} , false ) ;
this . editor . addListener ( EditorEvent . EDITOR _UPDATE , function ( ) {
return _this . handleEditorOptions ( EditorEvent . EDITOR _UPDATE ) ;
} , false ) ;
this . editor . addListener ( EditorEvent . EDITOR _SAVE , function ( ) {
return _this . handleEditorOptions ( EditorEvent . EDITOR _SAVE ) ;
} , false ) ;
document . getElementById ( 'post-image-upload' ) . addEventListener ( 'change' , function ( e ) {
self . handleImageUpload ( e . target . id , e . target . files ) ;
} , false ) ;
/ *
TinyDatePicker ( document . getElementById ( 'post-date' ) , {
mode : 'dp-below' ,
format ( ) {
//return self.dateUtils.getDate('origin', date);
}
} ) ;
* /
this . start ( ) ;
}
} //--------------------------
// methods
//--------------------------
_createClass ( PostEditor , [ {
key : "start" ,
value : function start ( ) {
var _this2 = this ;
if ( document . getElementById ( 'featured-image-drop' ) ) {
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-feature-upload' ) ) {
document . getElementById ( 'new-feature-upload' ) . addEventListener ( 'click' , function ( ) {
document . getElementById ( 'featured-image-upload' ) . click ( ) ;
} ) ;
}
var optionButtons = document . querySelectorAll ( '.post-option-btn' ) ;
for ( var i = 0 , length = optionButtons . length ; i < length ; i ++ ) {
optionButtons [ i ] . addEventListener ( 'click' , function ( e ) {
return _this2 . handlePostOptions ( e ) ;
} , false ) ;
}
}
} //--------------------------
// event handlers
//--------------------------
} , {
key : "handlePostOptions" ,
value : function handlePostOptions ( e ) {
var currentOption ;
switch ( e . target . id ) {
case 'option-page-icon' :
case 'option-menu-pin' :
currentOption = document . getElementById ( 'option-menu-pin' ) ;
break ;
case 'option-feature-icon' :
case 'option-feature' :
currentOption = document . getElementById ( 'option-feature' ) ;
break ;
case 'option-published-icon' :
case 'option-published' :
currentOption = document . getElementById ( 'option-published' ) ;
break ;
}
var active = currentOption . getAttribute ( 'data-active' ) ;
active == 'false' ? currentOption . setAttribute ( 'data-active' , 'true' ) : currentOption . setAttribute ( 'data-active' , 'false' ) ;
}
} , {
key : "handleEditorOptions" ,
value : function handleEditorOptions ( e ) {
switch ( e ) {
case EditorEvent . EDITOR _SAVE :
case EditorEvent . EDITOR _UPDATE :
var task = '' ;
e === EditorEvent . EDITOR _SAVE ? task = _FipamoAdminAPI . TASK _PAGE _CREATE : task = _FipamoAdminAPI . TASK _PAGE _EDIT ;
new _PageActions . default ( ) . collectInfo ( document . getElementById ( 'featured-image-upload' ) . files [ 0 ] ) . then ( function ( page ) {
notify . alert ( 'Writing down changes' , null ) ;
admin . pageActions ( task , page ) . then ( function ( r ) {
if ( r . type === DataEvent . PAGE _ERROR || r . type === DataEvent . API _REQUEST _LAME ) {
notify . alert ( r . message , false ) ;
} else {
if ( r . type === DataEvent . PAGE _UPDATED ) {
notify . alert ( r . message , true ) ;
} else {
notify . alert ( r . message , true ) ;
window . location = '/@/dashboard/page/edit/' + r . id ;
}
}
} ) . catch ( function ( err ) {
notify . alert ( err , false ) ;
} ) ;
} ) ;
break ;
case EditorEvent . EDITOR _DELETE :
if ( this . postLayout === 'index' ) {
notify . alert ( 'Index cannot be deleted' , false ) ;
return ;
}
if ( confirm ( "AYE! You know you're deleting this post, right?" ) ) {
var id = {
id : this . postUUID
} ;
admin . pageActions ( _FipamoAdminAPI . TASK _PAGE _DELETE , id ) . then ( function ( ) {
window . location = '/@/dashboard/page/list/' ;
} ) . catch ( function ( err ) {
notify . alert ( err , false ) ;
} ) ;
} else { // Do nothing!
}
break ;
case EditorEvent . EDITOR _UPLOAD _POST _IMAGE :
document . getElementById ( 'post-image-upload' ) . click ( ) ;
break ;
}
}
} , {
key : "handleImageActions" ,
value : function handleImageActions ( e ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
switch ( e . type ) {
case 'dragover' :
e . dataTransfer . dropEffect = 'copy' ; // Explicitly show this is a copy.
break ;
case 'change' :
case 'drop' :
e . type == 'drop' ? PostEditor . uploadFiles = e . dataTransfer . files : PostEditor . uploadFiles = e . target . files ;
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 . 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' ) . innerHTML = '' ;
document . getElementById ( 'featured-image-drop' ) . appendChild ( image ) ;
} ;
} ( f ) ; // Read in the image file as a data URL.
reader . readAsDataURL ( f ) ;
}
}
}
} , {
key : "handleImageUpload" ,
value : function handleImageUpload ( type , files ) {
var self = this ;
admin . imageUpload ( type , files ) . then ( function ( r ) {
if ( r . type == DataEvent . POST _IMAGE _ADDED ) self . editor . notify ( EditorEvent . EDITOR _UPLOAD _POST _IMAGE , r . url ) ;
} ) . catch ( function ( ) { //console.log('ERROR', err);
} ) ;
}
} ] ) ;
return PostEditor ;
} ( ) ;
exports . default = PostEditor ;
PostEditor . uploadFiles = [ ] ;
} , { "../../libraries/FipamoAdminAPI" : "../libraries/FipamoAdminAPI.js" , "../events/DataEvent" : "events/DataEvent.js" , "../actions/PageActions" : "actions/PageActions.js" , "../events/EditorEvent" : "events/EditorEvent.js" , "../ui/TextEditor" : "ui/TextEditor.js" , "../ui/Notifications" : "ui/Notifications.js" } ] , "controllers/PostIndex.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _PageEditor = _interopRequireDefault ( require ( "./PageEditor" ) ) ;
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" ) ; } }
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 ; }
var PostIndex = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function PostIndex ( page ) {
_classCallCheck ( this , PostIndex ) ;
this . currentPage = null ;
this . choosePage ( page ) ;
this . start ( ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( PostIndex , [ {
key : "start" ,
value : function start ( ) { }
} , {
key : "choosePage" ,
value : function choosePage ( page ) {
this . currentPage = '' ;
switch ( page ) {
case 'edit' :
case 'add' :
this . currentPage = new _PageEditor . default ( ) ;
break ;
default :
//just chill
break ;
}
} //--------------------------
// event handlers
//--------------------------
} ] ) ;
return PostIndex ;
} ( ) ;
exports . default = PostIndex ;
} , { "./PageEditor" : "controllers/PageEditor.js" } ] , "actions/SettingsActions.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
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 ; }
var SettingsActions = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function SettingsActions ( ) {
_classCallCheck ( this , SettingsActions ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( SettingsActions , [ {
key : "getInfo" ,
value : function getInfo ( ) {
var handle = document . getElementById ( 'settings-handle' ) . value ;
var email = document . getElementById ( 'settings-email' ) . value ;
var url = document . getElementById ( 'settings-url' ) . value ;
var title = document . getElementById ( 'settings-title' ) . value ;
var desc = document . getElementById ( 'settings-desc' ) . value ; //let privacy = document.getElementById('privacy-toggle').getAttribute('data-private');
var render = document . getElementById ( 'render-toggle' ) . getAttribute ( 'data-render' ) ;
var background = document . getElementById ( 'background' ) . src ;
var selected = '' ;
var selects = document . querySelectorAll ( '.theme-select' ) ;
var smtpDomain = document . getElementById ( 'smtp-domain' ) . value ;
var smtpEmail = document . getElementById ( 'smtp-email' ) . value ;
var smtpPass = document . getElementById ( 'smtp-pass' ) . value ;
var mgDomain = document . getElementById ( 'mg-domain' ) . value ;
var mgKey = document . getElementById ( 'mg-key' ) . value ;
var mailActive = '' ;
var mailOptions = document . querySelectorAll ( '.mail-option' ) ;
var i , count ;
for ( i = 0 , count = selects . length ; i < count ; i ++ ) {
if ( selects [ i ] . getAttribute ( 'data-enabled' ) == 'true' ) selected = selects [ i ] . id ;
}
for ( i = 0 , count = mailOptions . length ; i < count ; i ++ ) {
if ( mailOptions [ i ] . getAttribute ( 'data-enabled' ) == 'true' ) mailActive = mailOptions [ i ] . id ;
}
var settingsData = {
global : {
base _url : url ,
title : title ,
descriptions : desc ,
background : background ,
private : false ,
renderOnSave : render ,
theme : selected
} ,
member : {
handle : handle ,
email : email
} ,
email : {
active : mailActive ,
smtp : {
domain : smtpDomain ,
email : smtpEmail ,
password : smtpPass
} ,
mailgun : {
domain : mgDomain ,
key : mgKey
}
}
} ;
return new Promise ( function ( resolve ) {
resolve ( settingsData ) ;
} ) ;
} //--------------------------
// event handlers
//--------------------------
} ] ) ;
return SettingsActions ;
} ( ) ;
exports . default = SettingsActions ;
} , { } ] , "actions/Mailer.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _FipamoAdminAPI = _interopRequireDefault ( require ( "../../libraries/FipamoAdminAPI" ) ) ;
var _Notifications = _interopRequireDefault ( require ( "../ui/Notifications" ) ) ;
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" ) ; } }
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 ; }
var admin = new _FipamoAdminAPI . default ( ) ;
var notify = new _Notifications . default ( ) ;
var Mailer = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function Mailer ( ) {
_classCallCheck ( this , Mailer ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( Mailer , [ {
key : "sendMail" ,
value : function sendMail ( ) {
var mailData = {
content : 'This is a test email'
} ;
admin . sendMail ( mailData ) . then ( function ( result ) {
notify . alert ( result . message , true ) ;
} ) . catch ( function ( err ) {
notify . alert ( err . message , false ) ;
} ) ;
} //--------------------------
// event handlers
//--------------------------
} ] ) ;
return Mailer ;
} ( ) ;
exports . default = Mailer ;
} , { "../../libraries/FipamoAdminAPI" : "../libraries/FipamoAdminAPI.js" , "../ui/Notifications" : "ui/Notifications.js" } ] , "controllers/SettingsIndex.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _SettingsActions = _interopRequireDefault ( require ( "../actions/SettingsActions" ) ) ;
var _FipamoAdminAPI = _interopRequireDefault ( require ( "../../libraries/FipamoAdminAPI" ) ) ;
var DataEvent = _interopRequireWildcard ( require ( "../../../src/com/events/DataEvent" ) ) ;
var _Mailer = _interopRequireDefault ( require ( "../actions/Mailer" ) ) ;
var _Notifications = _interopRequireDefault ( require ( "../ui/Notifications" ) ) ;
function _getRequireWildcardCache ( ) { if ( typeof WeakMap !== "function" ) return null ; var cache = new WeakMap ( ) ; _getRequireWildcardCache = function ( ) { return cache ; } ; return cache ; }
function _interopRequireWildcard ( obj ) { if ( obj && obj . _ _esModule ) { return obj ; } if ( obj === null || typeof obj !== "object" && typeof obj !== "function" ) { return { default : obj } ; } var cache = _getRequireWildcardCache ( ) ; if ( cache && cache . has ( obj ) ) { return cache . get ( obj ) ; } var newObj = { } ; var hasPropertyDescriptor = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = hasPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : null ; if ( desc && ( desc . get || desc . set ) ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } newObj . default = obj ; if ( cache ) { cache . set ( obj , newObj ) ; } 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" ) ; } }
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 ; }
var admin = new _FipamoAdminAPI . default ( ) ;
var notify = new _Notifications . default ( ) ;
var mailer = new _Mailer . default ( ) ;
var SettingsIndex = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function SettingsIndex ( ) {
_classCallCheck ( this , SettingsIndex ) ;
this . start ( ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( SettingsIndex , [ {
key : "start" ,
value : function start ( ) {
var _this = this ;
var self = this ; //handle save button
document . getElementById ( 'save-toggle' ) . addEventListener ( 'click' , function ( ) {
return new _SettingsActions . default ( ) . getInfo ( ) . then ( function ( data ) {
notify . alert ( 'Saving Settings' , null ) ;
admin . syncSettings ( data ) . then ( function ( r ) {
if ( r . type == DataEvent . SETTINGS _UPDATED ) {
notify . alert ( r . message , true ) ;
} else {
notify . alert ( r . message , true ) ;
}
} ) ;
} ) . catch ( function ( ) { //console.log(err);
} ) ;
} ) ; //handle set up image uploads
document . getElementById ( 'avatar' ) . addEventListener ( 'click' , function ( ) {
document . getElementById ( 'avatar-upload' ) . click ( ) ;
} ) ;
document . getElementById ( 'background' ) . addEventListener ( 'click' , function ( ) {
document . getElementById ( 'background-upload' ) . click ( ) ;
} ) ;
document . getElementById ( 'restore-backup' ) . addEventListener ( 'click' , function ( ) {
document . getElementById ( 'backup-upload' ) . click ( ) ;
} ) ;
document . getElementById ( 'avatar-upload' ) . addEventListener ( 'change' , function ( e ) {
self . handleImageUpload ( e . target . id , e . target . files ) ;
} , false ) ;
document . getElementById ( 'background-upload' ) . addEventListener ( 'change' , function ( e ) {
self . handleImageUpload ( e . target . id , e . target . files ) ;
} , false ) ;
document . getElementById ( 'backup-upload' ) . addEventListener ( 'change' , function ( e ) {
self . handleBackup ( e ) ;
} , false ) ; //handle privacy toggle
//document
//.getElementById('privacy-toggle')
//.addEventListener('click', e => this.togglePrivacy(e));
document . getElementById ( 'render-toggle' ) . addEventListener ( 'click' , function ( e ) {
return _this . toggleRender ( e ) ;
} ) ;
document . getElementById ( 'send-mail' ) . addEventListener ( 'click' , function ( e ) {
return _this . handleMailer ( e ) ;
} ) ;
document . getElementById ( 'publish-pages' ) . addEventListener ( 'click' , function ( e ) {
return _this . handlePublished ( e ) ;
} ) ; //handle theme toggle
var themeBtns = document . querySelectorAll ( '.theme-select' ) ;
for ( var i = 0 , length = themeBtns . length ; i < length ; i ++ ) {
themeBtns [ i ] . addEventListener ( 'click' , function ( e ) {
return _this . handleThemes ( e ) ;
} ) ;
} //handle mail options
var mailBtn = document . querySelectorAll ( '.mail-option' ) ;
for ( i = 0 , length = mailBtn . length ; i < length ; i ++ ) {
mailBtn [ i ] . addEventListener ( 'click' , function ( e ) {
return _this . handleMailOptions ( e ) ;
} ) ;
} //handle backup
document . getElementById ( 'create-backup' ) . addEventListener ( 'click' , function ( e ) {
return _this . handleBackup ( e ) ;
} ) ;
} //--------------------------
// event handlers
//--------------------------
} , {
key : "togglePrivacy" ,
value : function togglePrivacy ( e ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
if ( e . target . getAttribute ( 'data-private' ) == 'false' ) {
e . target . setAttribute ( 'data-private' , 'true' ) ;
e . target . innerHTML = 'SITE IS PUBLIC' ;
} else {
e . target . setAttribute ( 'data-private' , 'false' ) ;
e . target . innerHTML = 'SITE IS PRIVATE' ;
}
}
} , {
key : "toggleRender" ,
value : function toggleRender ( e ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
if ( e . target . getAttribute ( 'data-render' ) == 'false' ) {
e . target . setAttribute ( 'data-render' , 'true' ) ; //e.target.innerHTML = 'RENDER PAGES ON SAVE';
} else {
e . target . setAttribute ( 'data-render' , 'false' ) ; //e.target.innerHTML = "DON'T RENDER PAGES ON SAVE";
}
}
} , {
key : "handleMailer" ,
value : function handleMailer ( ) {
mailer . sendMail ( ) ;
}
} , {
key : "handleThemes" ,
value : function handleThemes ( e ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
var themes = document . querySelectorAll ( '.theme-select' ) ;
for ( var i = 0 , length = themes . length ; i < length ; i ++ ) {
e . target . id == themes [ i ] . id ? themes [ i ] . setAttribute ( 'data-enabled' , 'true' ) : themes [ i ] . setAttribute ( 'data-enabled' , 'false' ) ;
}
}
} , {
key : "handleMailOptions" ,
value : function handleMailOptions ( e ) {
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
var smtp = document . getElementById ( 'mail-smtp' ) ;
var mailgun = document . getElementById ( 'mail-mg' ) ;
var mail = document . querySelectorAll ( '.mail-option' ) ;
for ( var i = 0 , length = mail . length ; i < length ; i ++ ) {
if ( e . target . id == mail [ i ] . id ) {
mail [ i ] . setAttribute ( 'data-enabled' , 'true' ) ;
if ( e . target . id == 'option-smtp' ) {
smtp . setAttribute ( 'data-enabled' , 'true' ) ;
mailgun . setAttribute ( 'data-enabled' , 'false' ) ;
} else if ( e . target . id == 'option-none' ) {
smtp . setAttribute ( 'data-enabled' , 'false' ) ;
mailgun . setAttribute ( 'data-enabled' , 'false' ) ;
} else {
smtp . setAttribute ( 'data-enabled' , 'false' ) ;
mailgun . setAttribute ( 'data-enabled' , 'true' ) ;
}
} else {
mail [ i ] . setAttribute ( 'data-enabled' , 'false' ) ;
}
}
}
} , {
key : "handleImageUpload" ,
value : function handleImageUpload ( type , files ) {
notify . alert ( 'Uploading Image... ' , null ) ;
admin . imageUpload ( type , files ) . then ( function ( r ) {
if ( r . type == DataEvent . AVATAR _UPLOADED ) {
notify . alert ( r . message , true ) ;
document . getElementById ( 'avatar' ) . src = r . url ;
} else {
notify . alert ( r . message , true ) ;
document . getElementById ( 'background' ) . src = r . url ;
}
} ) . catch ( function ( ) { //console.log(err)
} ) ;
}
} , {
key : "handlePublished" ,
value : function handlePublished ( e ) {
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
var task = {
task : 'publish all pages'
} ;
notify . alert ( 'Publishing site...' , null ) ;
admin . publishSite ( task ) . then ( function ( r ) {
notify . alert ( r . message , true ) ;
} ) . catch ( function ( err ) {
notify . alert ( err , false ) ;
} ) ;
}
} , {
key : "handleBackup" ,
value : function handleBackup ( e ) {
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
notify . alert ( 'Creating backup' , null ) ;
admin . handleBackup ( e . target . id , e . target . files ) . then ( function ( r ) {
notify . alert ( r . message , true ) ;
} ) . catch ( function ( err ) {
notify . alert ( err , false ) ;
} ) ;
}
} ] ) ;
return SettingsIndex ;
} ( ) ;
exports . default = SettingsIndex ;
} , { "../actions/SettingsActions" : "actions/SettingsActions.js" , "../../libraries/FipamoAdminAPI" : "../libraries/FipamoAdminAPI.js" , "../../../src/com/events/DataEvent" : "events/DataEvent.js" , "../actions/Mailer" : "actions/Mailer.js" , "../ui/Notifications" : "ui/Notifications.js" } ] , "actions/NavActions.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
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 ; }
var NavActions = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function NavActions ( ) {
_classCallCheck ( this , NavActions ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( NavActions , [ {
key : "syncMenu" ,
value : function syncMenu ( ) {
var navData = [ ] ;
var items = document . getElementById ( 'nav-pages' ) . children ;
for ( var index = 0 ; index < items . length ; index ++ ) {
navData . push ( {
title : items [ index ] . getElementsByTagName ( 'label' ) [ 0 ] . innerHTML ,
id : items [ index ] . id ,
slug : items [ index ] . getAttribute ( 'data-slug' ) ,
uuid : items [ index ] . getAttribute ( 'data-uuid' ) ,
path : items [ index ] . getAttribute ( 'data-path' )
} ) ;
}
var data = {
nav : navData ,
remove : null
} ;
return new Promise ( function ( resolve ) {
resolve ( data ) ;
} ) ;
}
} , {
key : "removeItem" ,
value : function removeItem ( id ) {
document . getElementById ( 'nav-pages' ) . removeChild ( document . getElementById ( id ) ) ;
} //--------------------------
// event handlers
//--------------------------
} ] ) ;
return NavActions ;
} ( ) ;
exports . default = NavActions ;
} , { } ] , "../../node_modules/sortablejs/modular/sortable.esm.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . MultiDrag = MultiDragPlugin ;
exports . Sortable = Sortable ;
exports . Swap = SwapPlugin ;
exports . default = void 0 ;
/ * * !
* Sortable 1.10 . 2
* @ author RubaXa < trash @ rubaxa . org >
* @ author owenm < owen23355 @ gmail . com >
* @ license MIT
* /
function _typeof ( obj ) {
if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) {
_typeof = function ( obj ) {
return typeof obj ;
} ;
} else {
_typeof = function ( obj ) {
return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ;
} ;
}
return _typeof ( obj ) ;
}
function _defineProperty ( obj , key , value ) {
if ( key in obj ) {
Object . defineProperty ( obj , key , {
value : value ,
enumerable : true ,
configurable : true ,
writable : true
} ) ;
} else {
obj [ key ] = value ;
}
return obj ;
}
function _extends ( ) {
_extends = Object . assign || function ( target ) {
for ( var i = 1 ; i < arguments . length ; i ++ ) {
var source = arguments [ i ] ;
for ( var key in source ) {
if ( Object . prototype . hasOwnProperty . call ( source , key ) ) {
target [ key ] = source [ key ] ;
}
}
}
return target ;
} ;
return _extends . apply ( this , arguments ) ;
}
function _objectSpread ( target ) {
for ( var i = 1 ; i < arguments . length ; i ++ ) {
var source = arguments [ i ] != null ? arguments [ i ] : { } ;
var ownKeys = Object . keys ( source ) ;
if ( typeof Object . getOwnPropertySymbols === 'function' ) {
ownKeys = ownKeys . concat ( Object . getOwnPropertySymbols ( source ) . filter ( function ( sym ) {
return Object . getOwnPropertyDescriptor ( source , sym ) . enumerable ;
} ) ) ;
}
ownKeys . forEach ( function ( key ) {
_defineProperty ( target , key , source [ key ] ) ;
} ) ;
}
return target ;
}
function _objectWithoutPropertiesLoose ( source , excluded ) {
if ( source == null ) return { } ;
var target = { } ;
var sourceKeys = Object . keys ( source ) ;
var key , i ;
for ( i = 0 ; i < sourceKeys . length ; i ++ ) {
key = sourceKeys [ i ] ;
if ( excluded . indexOf ( key ) >= 0 ) continue ;
target [ key ] = source [ key ] ;
}
return target ;
}
function _objectWithoutProperties ( source , excluded ) {
if ( source == null ) return { } ;
var target = _objectWithoutPropertiesLoose ( source , excluded ) ;
var key , i ;
if ( Object . getOwnPropertySymbols ) {
var sourceSymbolKeys = Object . getOwnPropertySymbols ( source ) ;
for ( i = 0 ; i < sourceSymbolKeys . length ; i ++ ) {
key = sourceSymbolKeys [ i ] ;
if ( excluded . indexOf ( key ) >= 0 ) continue ;
if ( ! Object . prototype . propertyIsEnumerable . call ( source , key ) ) continue ;
target [ key ] = source [ key ] ;
}
}
return target ;
}
function _toConsumableArray ( arr ) {
return _arrayWithoutHoles ( arr ) || _iterableToArray ( arr ) || _nonIterableSpread ( ) ;
}
function _arrayWithoutHoles ( arr ) {
if ( Array . isArray ( arr ) ) {
for ( var i = 0 , arr2 = new Array ( arr . length ) ; i < arr . length ; i ++ ) arr2 [ i ] = arr [ i ] ;
return arr2 ;
}
}
function _iterableToArray ( iter ) {
if ( Symbol . iterator in Object ( iter ) || Object . prototype . toString . call ( iter ) === "[object Arguments]" ) return Array . from ( iter ) ;
}
function _nonIterableSpread ( ) {
throw new TypeError ( "Invalid attempt to spread non-iterable instance" ) ;
}
var version = "1.10.2" ;
function userAgent ( pattern ) {
if ( typeof window !== 'undefined' && window . navigator ) {
return ! ! /*@__PURE__*/ navigator . userAgent . match ( pattern ) ;
}
}
var IE11OrLess = userAgent ( /(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i ) ;
var Edge = userAgent ( /Edge/i ) ;
var FireFox = userAgent ( /firefox/i ) ;
var Safari = userAgent ( /safari/i ) && ! userAgent ( /chrome/i ) && ! userAgent ( /android/i ) ;
var IOS = userAgent ( /iP(ad|od|hone)/i ) ;
var ChromeForAndroid = userAgent ( /chrome/i ) && userAgent ( /android/i ) ;
var captureMode = {
capture : false ,
passive : false
} ;
function on ( el , event , fn ) {
el . addEventListener ( event , fn , ! IE11OrLess && captureMode ) ;
}
function off ( el , event , fn ) {
el . removeEventListener ( event , fn , ! IE11OrLess && captureMode ) ;
}
function matches (
/**HTMLElement*/
el ,
/**String*/
selector ) {
if ( ! selector ) return ;
selector [ 0 ] === '>' && ( selector = selector . substring ( 1 ) ) ;
if ( el ) {
try {
if ( el . matches ) {
return el . matches ( selector ) ;
} else if ( el . msMatchesSelector ) {
return el . msMatchesSelector ( selector ) ;
} else if ( el . webkitMatchesSelector ) {
return el . webkitMatchesSelector ( selector ) ;
}
} catch ( _ ) {
return false ;
}
}
return false ;
}
function getParentOrHost ( el ) {
return el . host && el !== document && el . host . nodeType ? el . host : el . parentNode ;
}
function closest (
/**HTMLElement*/
el ,
/**String*/
selector ,
/**HTMLElement*/
ctx , includeCTX ) {
if ( el ) {
ctx = ctx || document ;
do {
if ( selector != null && ( selector [ 0 ] === '>' ? el . parentNode === ctx && matches ( el , selector ) : matches ( el , selector ) ) || includeCTX && el === ctx ) {
return el ;
}
if ( el === ctx ) break ;
/* jshint boss:true */
} while ( el = getParentOrHost ( el ) ) ;
}
return null ;
}
var R _SPACE = /\s+/g ;
function toggleClass ( el , name , state ) {
if ( el && name ) {
if ( el . classList ) {
el . classList [ state ? 'add' : 'remove' ] ( name ) ;
} else {
var className = ( ' ' + el . className + ' ' ) . replace ( R _SPACE , ' ' ) . replace ( ' ' + name + ' ' , ' ' ) ;
el . className = ( className + ( state ? ' ' + name : '' ) ) . replace ( R _SPACE , ' ' ) ;
}
}
}
function css ( el , prop , val ) {
var style = el && el . style ;
if ( style ) {
if ( val === void 0 ) {
if ( document . defaultView && document . defaultView . getComputedStyle ) {
val = document . defaultView . getComputedStyle ( el , '' ) ;
} else if ( el . currentStyle ) {
val = el . currentStyle ;
}
return prop === void 0 ? val : val [ prop ] ;
} else {
if ( ! ( prop in style ) && prop . indexOf ( 'webkit' ) === - 1 ) {
prop = '-webkit-' + prop ;
}
style [ prop ] = val + ( typeof val === 'string' ? '' : 'px' ) ;
}
}
}
function matrix ( el , selfOnly ) {
var appliedTransforms = '' ;
if ( typeof el === 'string' ) {
appliedTransforms = el ;
} else {
do {
var transform = css ( el , 'transform' ) ;
if ( transform && transform !== 'none' ) {
appliedTransforms = transform + ' ' + appliedTransforms ;
}
/* jshint boss:true */
} while ( ! selfOnly && ( el = el . parentNode ) ) ;
}
var matrixFn = window . DOMMatrix || window . WebKitCSSMatrix || window . CSSMatrix || window . MSCSSMatrix ;
/*jshint -W056 */
return matrixFn && new matrixFn ( appliedTransforms ) ;
}
function find ( ctx , tagName , iterator ) {
if ( ctx ) {
var list = ctx . getElementsByTagName ( tagName ) ,
i = 0 ,
n = list . length ;
if ( iterator ) {
for ( ; i < n ; i ++ ) {
iterator ( list [ i ] , i ) ;
}
}
return list ;
}
return [ ] ;
}
function getWindowScrollingElement ( ) {
var scrollingElement = document . scrollingElement ;
if ( scrollingElement ) {
return scrollingElement ;
} else {
return document . documentElement ;
}
}
/ * *
* Returns the "bounding client rect" of given element
* @ param { HTMLElement } el The element whose boundingClientRect is wanted
* @ param { [ Boolean ] } relativeToContainingBlock Whether the rect should be relative to the containing block of ( including ) the container
* @ param { [ Boolean ] } relativeToNonStaticParent Whether the rect should be relative to the relative parent of ( including ) the contaienr
* @ param { [ Boolean ] } undoScale Whether the container ' s scale ( ) should be undone
* @ param { [ HTMLElement ] } container The parent the element will be placed in
* @ return { Object } The boundingClientRect of el , with specified adjustments
* /
function getRect ( el , relativeToContainingBlock , relativeToNonStaticParent , undoScale , container ) {
if ( ! el . getBoundingClientRect && el !== window ) return ;
var elRect , top , left , bottom , right , height , width ;
if ( el !== window && el !== getWindowScrollingElement ( ) ) {
elRect = el . getBoundingClientRect ( ) ;
top = elRect . top ;
left = elRect . left ;
bottom = elRect . bottom ;
right = elRect . right ;
height = elRect . height ;
width = elRect . width ;
} else {
top = 0 ;
left = 0 ;
bottom = window . innerHeight ;
right = window . innerWidth ;
height = window . innerHeight ;
width = window . innerWidth ;
}
if ( ( relativeToContainingBlock || relativeToNonStaticParent ) && el !== window ) {
// Adjust for translate()
container = container || el . parentNode ; // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
// Not needed on <= IE11
if ( ! IE11OrLess ) {
do {
if ( container && container . getBoundingClientRect && ( css ( container , 'transform' ) !== 'none' || relativeToNonStaticParent && css ( container , 'position' ) !== 'static' ) ) {
var containerRect = container . getBoundingClientRect ( ) ; // Set relative to edges of padding box of container
top -= containerRect . top + parseInt ( css ( container , 'border-top-width' ) ) ;
left -= containerRect . left + parseInt ( css ( container , 'border-left-width' ) ) ;
bottom = top + elRect . height ;
right = left + elRect . width ;
break ;
}
/* jshint boss:true */
} while ( container = container . parentNode ) ;
}
}
if ( undoScale && el !== window ) {
// Adjust for scale()
var elMatrix = matrix ( container || el ) ,
scaleX = elMatrix && elMatrix . a ,
scaleY = elMatrix && elMatrix . d ;
if ( elMatrix ) {
top /= scaleY ;
left /= scaleX ;
width /= scaleX ;
height /= scaleY ;
bottom = top + height ;
right = left + width ;
}
}
return {
top : top ,
left : left ,
bottom : bottom ,
right : right ,
width : width ,
height : height
} ;
}
/ * *
* Checks if a side of an element is scrolled past a side of its parents
* @ param { HTMLElement } el The element who ' s side being scrolled out of view is in question
* @ param { String } elSide Side of the element in question ( 'top' , 'left' , 'right' , 'bottom' )
* @ param { String } parentSide Side of the parent in question ( 'top' , 'left' , 'right' , 'bottom' )
* @ return { HTMLElement } The parent scroll element that the el ' s side is scrolled past , or null if there is no such element
* /
function isScrolledPast ( el , elSide , parentSide ) {
var parent = getParentAutoScrollElement ( el , true ) ,
elSideVal = getRect ( el ) [ elSide ] ;
/* jshint boss:true */
while ( parent ) {
var parentSideVal = getRect ( parent ) [ parentSide ] ,
visible = void 0 ;
if ( parentSide === 'top' || parentSide === 'left' ) {
visible = elSideVal >= parentSideVal ;
} else {
visible = elSideVal <= parentSideVal ;
}
if ( ! visible ) return parent ;
if ( parent === getWindowScrollingElement ( ) ) break ;
parent = getParentAutoScrollElement ( parent , false ) ;
}
return false ;
}
/ * *
* Gets nth child of el , ignoring hidden children , sortable 's elements (does not ignore clone if it' s visible )
* and non - draggable elements
* @ param { HTMLElement } el The parent element
* @ param { Number } childNum The index of the child
* @ param { Object } options Parent Sortable ' s options
* @ return { HTMLElement } The child at index childNum , or null if not found
* /
function getChild ( el , childNum , options ) {
var currentChild = 0 ,
i = 0 ,
children = el . children ;
while ( i < children . length ) {
if ( children [ i ] . style . display !== 'none' && children [ i ] !== Sortable . ghost && children [ i ] !== Sortable . dragged && closest ( children [ i ] , options . draggable , el , false ) ) {
if ( currentChild === childNum ) {
return children [ i ] ;
}
currentChild ++ ;
}
i ++ ;
}
return null ;
}
/ * *
* Gets the last child in the el , ignoring ghostEl or invisible elements ( clones )
* @ param { HTMLElement } el Parent element
* @ param { selector } selector Any other elements that should be ignored
* @ return { HTMLElement } The last child , ignoring ghostEl
* /
function lastChild ( el , selector ) {
var last = el . lastElementChild ;
while ( last && ( last === Sortable . ghost || css ( last , 'display' ) === 'none' || selector && ! matches ( last , selector ) ) ) {
last = last . previousElementSibling ;
}
return last || null ;
}
/ * *
* Returns the index of an element within its parent for a selected set of
* elements
* @ param { HTMLElement } el
* @ param { selector } selector
* @ return { number }
* /
function index ( el , selector ) {
var index = 0 ;
if ( ! el || ! el . parentNode ) {
return - 1 ;
}
/* jshint boss:true */
while ( el = el . previousElementSibling ) {
if ( el . nodeName . toUpperCase ( ) !== 'TEMPLATE' && el !== Sortable . clone && ( ! selector || matches ( el , selector ) ) ) {
index ++ ;
}
}
return index ;
}
/ * *
* Returns the scroll offset of the given element , added with all the scroll offsets of parent elements .
* The value is returned in real pixels .
* @ param { HTMLElement } el
* @ return { Array } Offsets in the format of [ left , top ]
* /
function getRelativeScrollOffset ( el ) {
var offsetLeft = 0 ,
offsetTop = 0 ,
winScroller = getWindowScrollingElement ( ) ;
if ( el ) {
do {
var elMatrix = matrix ( el ) ,
scaleX = elMatrix . a ,
scaleY = elMatrix . d ;
offsetLeft += el . scrollLeft * scaleX ;
offsetTop += el . scrollTop * scaleY ;
} while ( el !== winScroller && ( el = el . parentNode ) ) ;
}
return [ offsetLeft , offsetTop ] ;
}
/ * *
* Returns the index of the object within the given array
* @ param { Array } arr Array that may or may not hold the object
* @ param { Object } obj An object that has a key - value pair unique to and identical to a key - value pair in the object you want to find
* @ return { Number } The index of the object in the array , or - 1
* /
function indexOfObject ( arr , obj ) {
for ( var i in arr ) {
if ( ! arr . hasOwnProperty ( i ) ) continue ;
for ( var key in obj ) {
if ( obj . hasOwnProperty ( key ) && obj [ key ] === arr [ i ] [ key ] ) return Number ( i ) ;
}
}
return - 1 ;
}
function getParentAutoScrollElement ( el , includeSelf ) {
// skip to window
if ( ! el || ! el . getBoundingClientRect ) return getWindowScrollingElement ( ) ;
var elem = el ;
var gotSelf = false ;
do {
// we don't need to get elem css if it isn't even overflowing in the first place (performance)
if ( elem . clientWidth < elem . scrollWidth || elem . clientHeight < elem . scrollHeight ) {
var elemCSS = css ( elem ) ;
if ( elem . clientWidth < elem . scrollWidth && ( elemCSS . overflowX == 'auto' || elemCSS . overflowX == 'scroll' ) || elem . clientHeight < elem . scrollHeight && ( elemCSS . overflowY == 'auto' || elemCSS . overflowY == 'scroll' ) ) {
if ( ! elem . getBoundingClientRect || elem === document . body ) return getWindowScrollingElement ( ) ;
if ( gotSelf || includeSelf ) return elem ;
gotSelf = true ;
}
}
/* jshint boss:true */
} while ( elem = elem . parentNode ) ;
return getWindowScrollingElement ( ) ;
}
function extend ( dst , src ) {
if ( dst && src ) {
for ( var key in src ) {
if ( src . hasOwnProperty ( key ) ) {
dst [ key ] = src [ key ] ;
}
}
}
return dst ;
}
function isRectEqual ( rect1 , rect2 ) {
return Math . round ( rect1 . top ) === Math . round ( rect2 . top ) && Math . round ( rect1 . left ) === Math . round ( rect2 . left ) && Math . round ( rect1 . height ) === Math . round ( rect2 . height ) && Math . round ( rect1 . width ) === Math . round ( rect2 . width ) ;
}
var _throttleTimeout ;
function throttle ( callback , ms ) {
return function ( ) {
if ( ! _throttleTimeout ) {
var args = arguments ,
_this = this ;
if ( args . length === 1 ) {
callback . call ( _this , args [ 0 ] ) ;
} else {
callback . apply ( _this , args ) ;
}
_throttleTimeout = setTimeout ( function ( ) {
_throttleTimeout = void 0 ;
} , ms ) ;
}
} ;
}
function cancelThrottle ( ) {
clearTimeout ( _throttleTimeout ) ;
_throttleTimeout = void 0 ;
}
function scrollBy ( el , x , y ) {
el . scrollLeft += x ;
el . scrollTop += y ;
}
function clone ( el ) {
var Polymer = window . Polymer ;
var $ = window . jQuery || window . Zepto ;
if ( Polymer && Polymer . dom ) {
return Polymer . dom ( el ) . cloneNode ( true ) ;
} else if ( $ ) {
return $ ( el ) . clone ( true ) [ 0 ] ;
} else {
return el . cloneNode ( true ) ;
}
}
function setRect ( el , rect ) {
css ( el , 'position' , 'absolute' ) ;
css ( el , 'top' , rect . top ) ;
css ( el , 'left' , rect . left ) ;
css ( el , 'width' , rect . width ) ;
css ( el , 'height' , rect . height ) ;
}
function unsetRect ( el ) {
css ( el , 'position' , '' ) ;
css ( el , 'top' , '' ) ;
css ( el , 'left' , '' ) ;
css ( el , 'width' , '' ) ;
css ( el , 'height' , '' ) ;
}
var expando = 'Sortable' + new Date ( ) . getTime ( ) ;
function AnimationStateManager ( ) {
var animationStates = [ ] ,
animationCallbackId ;
return {
captureAnimationState : function captureAnimationState ( ) {
animationStates = [ ] ;
if ( ! this . options . animation ) return ;
var children = [ ] . slice . call ( this . el . children ) ;
children . forEach ( function ( child ) {
if ( css ( child , 'display' ) === 'none' || child === Sortable . ghost ) return ;
animationStates . push ( {
target : child ,
rect : getRect ( child )
} ) ;
var fromRect = _objectSpread ( { } , animationStates [ animationStates . length - 1 ] . rect ) ; // If animating: compensate for current animation
if ( child . thisAnimationDuration ) {
var childMatrix = matrix ( child , true ) ;
if ( childMatrix ) {
fromRect . top -= childMatrix . f ;
fromRect . left -= childMatrix . e ;
}
}
child . fromRect = fromRect ;
} ) ;
} ,
addAnimationState : function addAnimationState ( state ) {
animationStates . push ( state ) ;
} ,
removeAnimationState : function removeAnimationState ( target ) {
animationStates . splice ( indexOfObject ( animationStates , {
target : target
} ) , 1 ) ;
} ,
animateAll : function animateAll ( callback ) {
var _this = this ;
if ( ! this . options . animation ) {
clearTimeout ( animationCallbackId ) ;
if ( typeof callback === 'function' ) callback ( ) ;
return ;
}
var animating = false ,
animationTime = 0 ;
animationStates . forEach ( function ( state ) {
var time = 0 ,
target = state . target ,
fromRect = target . fromRect ,
toRect = getRect ( target ) ,
prevFromRect = target . prevFromRect ,
prevToRect = target . prevToRect ,
animatingRect = state . rect ,
targetMatrix = matrix ( target , true ) ;
if ( targetMatrix ) {
// Compensate for current animation
toRect . top -= targetMatrix . f ;
toRect . left -= targetMatrix . e ;
}
target . toRect = toRect ;
if ( target . thisAnimationDuration ) {
// Could also check if animatingRect is between fromRect and toRect
if ( isRectEqual ( prevFromRect , toRect ) && ! isRectEqual ( fromRect , toRect ) && // Make sure animatingRect is on line between toRect & fromRect
( animatingRect . top - toRect . top ) / ( animatingRect . left - toRect . left ) === ( fromRect . top - toRect . top ) / ( fromRect . left - toRect . left ) ) {
// If returning to same place as started from animation and on same axis
time = calculateRealTime ( animatingRect , prevFromRect , prevToRect , _this . options ) ;
}
} // if fromRect != toRect: animate
if ( ! isRectEqual ( toRect , fromRect ) ) {
target . prevFromRect = fromRect ;
target . prevToRect = toRect ;
if ( ! time ) {
time = _this . options . animation ;
}
_this . animate ( target , animatingRect , toRect , time ) ;
}
if ( time ) {
animating = true ;
animationTime = Math . max ( animationTime , time ) ;
clearTimeout ( target . animationResetTimer ) ;
target . animationResetTimer = setTimeout ( function ( ) {
target . animationTime = 0 ;
target . prevFromRect = null ;
target . fromRect = null ;
target . prevToRect = null ;
target . thisAnimationDuration = null ;
} , time ) ;
target . thisAnimationDuration = time ;
}
} ) ;
clearTimeout ( animationCallbackId ) ;
if ( ! animating ) {
if ( typeof callback === 'function' ) callback ( ) ;
} else {
animationCallbackId = setTimeout ( function ( ) {
if ( typeof callback === 'function' ) callback ( ) ;
} , animationTime ) ;
}
animationStates = [ ] ;
} ,
animate : function animate ( target , currentRect , toRect , duration ) {
if ( duration ) {
css ( target , 'transition' , '' ) ;
css ( target , 'transform' , '' ) ;
var elMatrix = matrix ( this . el ) ,
scaleX = elMatrix && elMatrix . a ,
scaleY = elMatrix && elMatrix . d ,
translateX = ( currentRect . left - toRect . left ) / ( scaleX || 1 ) ,
translateY = ( currentRect . top - toRect . top ) / ( scaleY || 1 ) ;
target . animatingX = ! ! translateX ;
target . animatingY = ! ! translateY ;
css ( target , 'transform' , 'translate3d(' + translateX + 'px,' + translateY + 'px,0)' ) ;
repaint ( target ) ; // repaint
css ( target , 'transition' , 'transform ' + duration + 'ms' + ( this . options . easing ? ' ' + this . options . easing : '' ) ) ;
css ( target , 'transform' , 'translate3d(0,0,0)' ) ;
typeof target . animated === 'number' && clearTimeout ( target . animated ) ;
target . animated = setTimeout ( function ( ) {
css ( target , 'transition' , '' ) ;
css ( target , 'transform' , '' ) ;
target . animated = false ;
target . animatingX = false ;
target . animatingY = false ;
} , duration ) ;
}
}
} ;
}
function repaint ( target ) {
return target . offsetWidth ;
}
function calculateRealTime ( animatingRect , fromRect , toRect , options ) {
return Math . sqrt ( Math . pow ( fromRect . top - animatingRect . top , 2 ) + Math . pow ( fromRect . left - animatingRect . left , 2 ) ) / Math . sqrt ( Math . pow ( fromRect . top - toRect . top , 2 ) + Math . pow ( fromRect . left - toRect . left , 2 ) ) * options . animation ;
}
var plugins = [ ] ;
var defaults = {
initializeByDefault : true
} ;
var PluginManager = {
mount : function mount ( plugin ) {
// Set default static properties
for ( var option in defaults ) {
if ( defaults . hasOwnProperty ( option ) && ! ( option in plugin ) ) {
plugin [ option ] = defaults [ option ] ;
}
}
plugins . push ( plugin ) ;
} ,
pluginEvent : function pluginEvent ( eventName , sortable , evt ) {
var _this = this ;
this . eventCanceled = false ;
evt . cancel = function ( ) {
_this . eventCanceled = true ;
} ;
var eventNameGlobal = eventName + 'Global' ;
plugins . forEach ( function ( plugin ) {
if ( ! sortable [ plugin . pluginName ] ) return ; // Fire global events if it exists in this sortable
if ( sortable [ plugin . pluginName ] [ eventNameGlobal ] ) {
sortable [ plugin . pluginName ] [ eventNameGlobal ] ( _objectSpread ( {
sortable : sortable
} , evt ) ) ;
} // Only fire plugin event if plugin is enabled in this sortable,
// and plugin has event defined
if ( sortable . options [ plugin . pluginName ] && sortable [ plugin . pluginName ] [ eventName ] ) {
sortable [ plugin . pluginName ] [ eventName ] ( _objectSpread ( {
sortable : sortable
} , evt ) ) ;
}
} ) ;
} ,
initializePlugins : function initializePlugins ( sortable , el , defaults , options ) {
plugins . forEach ( function ( plugin ) {
var pluginName = plugin . pluginName ;
if ( ! sortable . options [ pluginName ] && ! plugin . initializeByDefault ) return ;
var initialized = new plugin ( sortable , el , sortable . options ) ;
initialized . sortable = sortable ;
initialized . options = sortable . options ;
sortable [ pluginName ] = initialized ; // Add default options from plugin
_extends ( defaults , initialized . defaults ) ;
} ) ;
for ( var option in sortable . options ) {
if ( ! sortable . options . hasOwnProperty ( option ) ) continue ;
var modified = this . modifyOption ( sortable , option , sortable . options [ option ] ) ;
if ( typeof modified !== 'undefined' ) {
sortable . options [ option ] = modified ;
}
}
} ,
getEventProperties : function getEventProperties ( name , sortable ) {
var eventProperties = { } ;
plugins . forEach ( function ( plugin ) {
if ( typeof plugin . eventProperties !== 'function' ) return ;
_extends ( eventProperties , plugin . eventProperties . call ( sortable [ plugin . pluginName ] , name ) ) ;
} ) ;
return eventProperties ;
} ,
modifyOption : function modifyOption ( sortable , name , value ) {
var modifiedValue ;
plugins . forEach ( function ( plugin ) {
// Plugin must exist on the Sortable
if ( ! sortable [ plugin . pluginName ] ) return ; // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
if ( plugin . optionListeners && typeof plugin . optionListeners [ name ] === 'function' ) {
modifiedValue = plugin . optionListeners [ name ] . call ( sortable [ plugin . pluginName ] , value ) ;
}
} ) ;
return modifiedValue ;
}
} ;
function dispatchEvent ( _ref ) {
var sortable = _ref . sortable ,
rootEl = _ref . rootEl ,
name = _ref . name ,
targetEl = _ref . targetEl ,
cloneEl = _ref . cloneEl ,
toEl = _ref . toEl ,
fromEl = _ref . fromEl ,
oldIndex = _ref . oldIndex ,
newIndex = _ref . newIndex ,
oldDraggableIndex = _ref . oldDraggableIndex ,
newDraggableIndex = _ref . newDraggableIndex ,
originalEvent = _ref . originalEvent ,
putSortable = _ref . putSortable ,
extraEventProperties = _ref . extraEventProperties ;
sortable = sortable || rootEl && rootEl [ expando ] ;
if ( ! sortable ) return ;
var evt ,
options = sortable . options ,
onName = 'on' + name . charAt ( 0 ) . toUpperCase ( ) + name . substr ( 1 ) ; // Support for new CustomEvent feature
if ( window . CustomEvent && ! IE11OrLess && ! Edge ) {
evt = new CustomEvent ( name , {
bubbles : true ,
cancelable : true
} ) ;
} else {
evt = document . createEvent ( 'Event' ) ;
evt . initEvent ( name , true , true ) ;
}
evt . to = toEl || rootEl ;
evt . from = fromEl || rootEl ;
evt . item = targetEl || rootEl ;
evt . clone = cloneEl ;
evt . oldIndex = oldIndex ;
evt . newIndex = newIndex ;
evt . oldDraggableIndex = oldDraggableIndex ;
evt . newDraggableIndex = newDraggableIndex ;
evt . originalEvent = originalEvent ;
evt . pullMode = putSortable ? putSortable . lastPutMode : undefined ;
var allEventProperties = _objectSpread ( { } , extraEventProperties , PluginManager . getEventProperties ( name , sortable ) ) ;
for ( var option in allEventProperties ) {
evt [ option ] = allEventProperties [ option ] ;
}
if ( rootEl ) {
rootEl . dispatchEvent ( evt ) ;
}
if ( options [ onName ] ) {
options [ onName ] . call ( sortable , evt ) ;
}
}
var pluginEvent = function pluginEvent ( eventName , sortable ) {
var _ref = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ,
originalEvent = _ref . evt ,
data = _objectWithoutProperties ( _ref , [ "evt" ] ) ;
PluginManager . pluginEvent . bind ( Sortable ) ( eventName , sortable , _objectSpread ( {
dragEl : dragEl ,
parentEl : parentEl ,
ghostEl : ghostEl ,
rootEl : rootEl ,
nextEl : nextEl ,
lastDownEl : lastDownEl ,
cloneEl : cloneEl ,
cloneHidden : cloneHidden ,
dragStarted : moved ,
putSortable : putSortable ,
activeSortable : Sortable . active ,
originalEvent : originalEvent ,
oldIndex : oldIndex ,
oldDraggableIndex : oldDraggableIndex ,
newIndex : newIndex ,
newDraggableIndex : newDraggableIndex ,
hideGhostForTarget : _hideGhostForTarget ,
unhideGhostForTarget : _unhideGhostForTarget ,
cloneNowHidden : function cloneNowHidden ( ) {
cloneHidden = true ;
} ,
cloneNowShown : function cloneNowShown ( ) {
cloneHidden = false ;
} ,
dispatchSortableEvent : function dispatchSortableEvent ( name ) {
_dispatchEvent ( {
sortable : sortable ,
name : name ,
originalEvent : originalEvent
} ) ;
}
} , data ) ) ;
} ;
function _dispatchEvent ( info ) {
dispatchEvent ( _objectSpread ( {
putSortable : putSortable ,
cloneEl : cloneEl ,
targetEl : dragEl ,
rootEl : rootEl ,
oldIndex : oldIndex ,
oldDraggableIndex : oldDraggableIndex ,
newIndex : newIndex ,
newDraggableIndex : newDraggableIndex
} , info ) ) ;
}
var dragEl ,
parentEl ,
ghostEl ,
rootEl ,
nextEl ,
lastDownEl ,
cloneEl ,
cloneHidden ,
oldIndex ,
newIndex ,
oldDraggableIndex ,
newDraggableIndex ,
activeGroup ,
putSortable ,
awaitingDragStarted = false ,
ignoreNextClick = false ,
sortables = [ ] ,
tapEvt ,
touchEvt ,
lastDx ,
lastDy ,
tapDistanceLeft ,
tapDistanceTop ,
moved ,
lastTarget ,
lastDirection ,
pastFirstInvertThresh = false ,
isCircumstantialInvert = false ,
targetMoveDistance ,
// For positioning ghost absolutely
ghostRelativeParent ,
ghostRelativeParentInitialScroll = [ ] ,
// (left, top)
_silent = false ,
savedInputChecked = [ ] ;
/** @const */
var documentExists = typeof document !== 'undefined' ,
PositionGhostAbsolutely = IOS ,
CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float' ,
// This will not pass for IE9, because IE9 DnD only works on anchors
supportDraggable = documentExists && ! ChromeForAndroid && ! IOS && 'draggable' in document . createElement ( 'div' ) ,
supportCssPointerEvents = function ( ) {
if ( ! documentExists ) return ; // false when <= IE11
if ( IE11OrLess ) {
return false ;
}
var el = document . createElement ( 'x' ) ;
el . style . cssText = 'pointer-events:auto' ;
return el . style . pointerEvents === 'auto' ;
} ( ) ,
_detectDirection = function _detectDirection ( el , options ) {
var elCSS = css ( el ) ,
elWidth = parseInt ( elCSS . width ) - parseInt ( elCSS . paddingLeft ) - parseInt ( elCSS . paddingRight ) - parseInt ( elCSS . borderLeftWidth ) - parseInt ( elCSS . borderRightWidth ) ,
child1 = getChild ( el , 0 , options ) ,
child2 = getChild ( el , 1 , options ) ,
firstChildCSS = child1 && css ( child1 ) ,
secondChildCSS = child2 && css ( child2 ) ,
firstChildWidth = firstChildCSS && parseInt ( firstChildCSS . marginLeft ) + parseInt ( firstChildCSS . marginRight ) + getRect ( child1 ) . width ,
secondChildWidth = secondChildCSS && parseInt ( secondChildCSS . marginLeft ) + parseInt ( secondChildCSS . marginRight ) + getRect ( child2 ) . width ;
if ( elCSS . display === 'flex' ) {
return elCSS . flexDirection === 'column' || elCSS . flexDirection === 'column-reverse' ? 'vertical' : 'horizontal' ;
}
if ( elCSS . display === 'grid' ) {
return elCSS . gridTemplateColumns . split ( ' ' ) . length <= 1 ? 'vertical' : 'horizontal' ;
}
if ( child1 && firstChildCSS [ "float" ] && firstChildCSS [ "float" ] !== 'none' ) {
var touchingSideChild2 = firstChildCSS [ "float" ] === 'left' ? 'left' : 'right' ;
return child2 && ( secondChildCSS . clear === 'both' || secondChildCSS . clear === touchingSideChild2 ) ? 'vertical' : 'horizontal' ;
}
return child1 && ( firstChildCSS . display === 'block' || firstChildCSS . display === 'flex' || firstChildCSS . display === 'table' || firstChildCSS . display === 'grid' || firstChildWidth >= elWidth && elCSS [ CSSFloatProperty ] === 'none' || child2 && elCSS [ CSSFloatProperty ] === 'none' && firstChildWidth + secondChildWidth > elWidth ) ? 'vertical' : 'horizontal' ;
} ,
_dragElInRowColumn = function _dragElInRowColumn ( dragRect , targetRect , vertical ) {
var dragElS1Opp = vertical ? dragRect . left : dragRect . top ,
dragElS2Opp = vertical ? dragRect . right : dragRect . bottom ,
dragElOppLength = vertical ? dragRect . width : dragRect . height ,
targetS1Opp = vertical ? targetRect . left : targetRect . top ,
targetS2Opp = vertical ? targetRect . right : targetRect . bottom ,
targetOppLength = vertical ? targetRect . width : targetRect . height ;
return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2 ;
} ,
/ * *
* Detects first nearest empty sortable to X and Y position using emptyInsertThreshold .
* @ param { Number } x X position
* @ param { Number } y Y position
* @ return { HTMLElement } Element of the first found nearest Sortable
* /
_detectNearestEmptySortable = function _detectNearestEmptySortable ( x , y ) {
var ret ;
sortables . some ( function ( sortable ) {
if ( lastChild ( sortable ) ) return ;
var rect = getRect ( sortable ) ,
threshold = sortable [ expando ] . options . emptyInsertThreshold ,
insideHorizontally = x >= rect . left - threshold && x <= rect . right + threshold ,
insideVertically = y >= rect . top - threshold && y <= rect . bottom + threshold ;
if ( threshold && insideHorizontally && insideVertically ) {
return ret = sortable ;
}
} ) ;
return ret ;
} ,
_prepareGroup = function _prepareGroup ( options ) {
function toFn ( value , pull ) {
return function ( to , from , dragEl , evt ) {
var sameGroup = to . options . group . name && from . options . group . name && to . options . group . name === from . options . group . name ;
if ( value == null && ( pull || sameGroup ) ) {
// Default pull value
// Default pull and put value if same group
return true ;
} else if ( value == null || value === false ) {
return false ;
} else if ( pull && value === 'clone' ) {
return value ;
} else if ( typeof value === 'function' ) {
return toFn ( value ( to , from , dragEl , evt ) , pull ) ( to , from , dragEl , evt ) ;
} else {
var otherGroup = ( pull ? to : from ) . options . group . name ;
return value === true || typeof value === 'string' && value === otherGroup || value . join && value . indexOf ( otherGroup ) > - 1 ;
}
} ;
}
var group = { } ;
var originalGroup = options . group ;
if ( ! originalGroup || _typeof ( originalGroup ) != 'object' ) {
originalGroup = {
name : originalGroup
} ;
}
group . name = originalGroup . name ;
group . checkPull = toFn ( originalGroup . pull , true ) ;
group . checkPut = toFn ( originalGroup . put ) ;
group . revertClone = originalGroup . revertClone ;
options . group = group ;
} ,
_hideGhostForTarget = function _hideGhostForTarget ( ) {
if ( ! supportCssPointerEvents && ghostEl ) {
css ( ghostEl , 'display' , 'none' ) ;
}
} ,
_unhideGhostForTarget = function _unhideGhostForTarget ( ) {
if ( ! supportCssPointerEvents && ghostEl ) {
css ( ghostEl , 'display' , '' ) ;
}
} ; // #1184 fix - Prevent click event on fallback if dragged but item not changed position
if ( documentExists ) {
document . addEventListener ( 'click' , function ( evt ) {
if ( ignoreNextClick ) {
evt . preventDefault ( ) ;
evt . stopPropagation && evt . stopPropagation ( ) ;
evt . stopImmediatePropagation && evt . stopImmediatePropagation ( ) ;
ignoreNextClick = false ;
return false ;
}
} , true ) ;
}
var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent ( evt ) {
if ( dragEl ) {
evt = evt . touches ? evt . touches [ 0 ] : evt ;
var nearest = _detectNearestEmptySortable ( evt . clientX , evt . clientY ) ;
if ( nearest ) {
// Create imitation event
var event = { } ;
for ( var i in evt ) {
if ( evt . hasOwnProperty ( i ) ) {
event [ i ] = evt [ i ] ;
}
}
event . target = event . rootEl = nearest ;
event . preventDefault = void 0 ;
event . stopPropagation = void 0 ;
nearest [ expando ] . _onDragOver ( event ) ;
}
}
} ;
var _checkOutsideTargetEl = function _checkOutsideTargetEl ( evt ) {
if ( dragEl ) {
dragEl . parentNode [ expando ] . _isOutsideThisEl ( evt . target ) ;
}
} ;
/ * *
* @ class Sortable
* @ param { HTMLElement } el
* @ param { Object } [ options ]
* /
function Sortable ( el , options ) {
if ( ! ( el && el . nodeType && el . nodeType === 1 ) ) {
throw "Sortable: `el` must be an HTMLElement, not " . concat ( { } . toString . call ( el ) ) ;
}
this . el = el ; // root element
this . options = options = _extends ( { } , options ) ; // Export instance
el [ expando ] = this ;
var defaults = {
group : null ,
sort : true ,
disabled : false ,
store : null ,
handle : null ,
draggable : /^[uo]l$/i . test ( el . nodeName ) ? '>li' : '>*' ,
swapThreshold : 1 ,
// percentage; 0 <= x <= 1
invertSwap : false ,
// invert always
invertedSwapThreshold : null ,
// will be set to same as swapThreshold if default
removeCloneOnHide : true ,
direction : function direction ( ) {
return _detectDirection ( el , this . options ) ;
} ,
ghostClass : 'sortable-ghost' ,
chosenClass : 'sortable-chosen' ,
dragClass : 'sortable-drag' ,
ignore : 'a, img' ,
filter : null ,
preventOnFilter : true ,
animation : 0 ,
easing : null ,
setData : function setData ( dataTransfer , dragEl ) {
dataTransfer . setData ( 'Text' , dragEl . textContent ) ;
} ,
dropBubble : false ,
dragoverBubble : false ,
dataIdAttr : 'data-id' ,
delay : 0 ,
delayOnTouchOnly : false ,
touchStartThreshold : ( Number . parseInt ? Number : window ) . parseInt ( window . devicePixelRatio , 10 ) || 1 ,
forceFallback : false ,
fallbackClass : 'sortable-fallback' ,
fallbackOnBody : false ,
fallbackTolerance : 0 ,
fallbackOffset : {
x : 0 ,
y : 0
} ,
supportPointer : Sortable . supportPointer !== false && 'PointerEvent' in window ,
emptyInsertThreshold : 5
} ;
PluginManager . initializePlugins ( this , el , defaults ) ; // Set default options
for ( var name in defaults ) {
! ( name in options ) && ( options [ name ] = defaults [ name ] ) ;
}
_prepareGroup ( options ) ; // Bind all private methods
for ( var fn in this ) {
if ( fn . charAt ( 0 ) === '_' && typeof this [ fn ] === 'function' ) {
this [ fn ] = this [ fn ] . bind ( this ) ;
}
} // Setup drag mode
this . nativeDraggable = options . forceFallback ? false : supportDraggable ;
if ( this . nativeDraggable ) {
// Touch start threshold cannot be greater than the native dragstart threshold
this . options . touchStartThreshold = 1 ;
} // Bind events
if ( options . supportPointer ) {
on ( el , 'pointerdown' , this . _onTapStart ) ;
} else {
on ( el , 'mousedown' , this . _onTapStart ) ;
on ( el , 'touchstart' , this . _onTapStart ) ;
}
if ( this . nativeDraggable ) {
on ( el , 'dragover' , this ) ;
on ( el , 'dragenter' , this ) ;
}
sortables . push ( this . el ) ; // Restore sorting
options . store && options . store . get && this . sort ( options . store . get ( this ) || [ ] ) ; // Add animation state manager
_extends ( this , AnimationStateManager ( ) ) ;
}
Sortable . prototype =
/** @lends Sortable.prototype */
{
constructor : Sortable ,
_isOutsideThisEl : function _isOutsideThisEl ( target ) {
if ( ! this . el . contains ( target ) && target !== this . el ) {
lastTarget = null ;
}
} ,
_getDirection : function _getDirection ( evt , target ) {
return typeof this . options . direction === 'function' ? this . options . direction . call ( this , evt , target , dragEl ) : this . options . direction ;
} ,
_onTapStart : function _onTapStart (
/** Event|TouchEvent */
evt ) {
if ( ! evt . cancelable ) return ;
var _this = this ,
el = this . el ,
options = this . options ,
preventOnFilter = options . preventOnFilter ,
type = evt . type ,
touch = evt . touches && evt . touches [ 0 ] || evt . pointerType && evt . pointerType === 'touch' && evt ,
target = ( touch || evt ) . target ,
originalTarget = evt . target . shadowRoot && ( evt . path && evt . path [ 0 ] || evt . composedPath && evt . composedPath ( ) [ 0 ] ) || target ,
filter = options . filter ;
_saveInputCheckedState ( el ) ; // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
if ( dragEl ) {
return ;
}
if ( /mousedown|pointerdown/ . test ( type ) && evt . button !== 0 || options . disabled ) {
return ; // only left button and enabled
} // cancel dnd if original target is content editable
if ( originalTarget . isContentEditable ) {
return ;
}
target = closest ( target , options . draggable , el , false ) ;
if ( target && target . animated ) {
return ;
}
if ( lastDownEl === target ) {
// Ignoring duplicate `down`
return ;
} // Get the index of the dragged element within its parent
oldIndex = index ( target ) ;
oldDraggableIndex = index ( target , options . draggable ) ; // Check filter
if ( typeof filter === 'function' ) {
if ( filter . call ( this , evt , target , this ) ) {
_dispatchEvent ( {
sortable : _this ,
rootEl : originalTarget ,
name : 'filter' ,
targetEl : target ,
toEl : el ,
fromEl : el
} ) ;
pluginEvent ( 'filter' , _this , {
evt : evt
} ) ;
preventOnFilter && evt . cancelable && evt . preventDefault ( ) ;
return ; // cancel dnd
}
} else if ( filter ) {
filter = filter . split ( ',' ) . some ( function ( criteria ) {
criteria = closest ( originalTarget , criteria . trim ( ) , el , false ) ;
if ( criteria ) {
_dispatchEvent ( {
sortable : _this ,
rootEl : criteria ,
name : 'filter' ,
targetEl : target ,
fromEl : el ,
toEl : el
} ) ;
pluginEvent ( 'filter' , _this , {
evt : evt
} ) ;
return true ;
}
} ) ;
if ( filter ) {
preventOnFilter && evt . cancelable && evt . preventDefault ( ) ;
return ; // cancel dnd
}
}
if ( options . handle && ! closest ( originalTarget , options . handle , el , false ) ) {
return ;
} // Prepare `dragstart`
this . _prepareDragStart ( evt , touch , target ) ;
} ,
_prepareDragStart : function _prepareDragStart (
/** Event */
evt ,
/** Touch */
touch ,
/** HTMLElement */
target ) {
var _this = this ,
el = _this . el ,
options = _this . options ,
ownerDocument = el . ownerDocument ,
dragStartFn ;
if ( target && ! dragEl && target . parentNode === el ) {
var dragRect = getRect ( target ) ;
rootEl = el ;
dragEl = target ;
parentEl = dragEl . parentNode ;
nextEl = dragEl . nextSibling ;
lastDownEl = target ;
activeGroup = options . group ;
Sortable . dragged = dragEl ;
tapEvt = {
target : dragEl ,
clientX : ( touch || evt ) . clientX ,
clientY : ( touch || evt ) . clientY
} ;
tapDistanceLeft = tapEvt . clientX - dragRect . left ;
tapDistanceTop = tapEvt . clientY - dragRect . top ;
this . _lastX = ( touch || evt ) . clientX ;
this . _lastY = ( touch || evt ) . clientY ;
dragEl . style [ 'will-change' ] = 'all' ;
dragStartFn = function dragStartFn ( ) {
pluginEvent ( 'delayEnded' , _this , {
evt : evt
} ) ;
if ( Sortable . eventCanceled ) {
_this . _onDrop ( ) ;
return ;
} // Delayed drag has been triggered
// we can re-enable the events: touchmove/mousemove
_this . _disableDelayedDragEvents ( ) ;
if ( ! FireFox && _this . nativeDraggable ) {
dragEl . draggable = true ;
} // Bind the events: dragstart/dragend
_this . _triggerDragStart ( evt , touch ) ; // Drag start event
_dispatchEvent ( {
sortable : _this ,
name : 'choose' ,
originalEvent : evt
} ) ; // Chosen item
toggleClass ( dragEl , options . chosenClass , true ) ;
} ; // Disable "draggable"
options . ignore . split ( ',' ) . forEach ( function ( criteria ) {
find ( dragEl , criteria . trim ( ) , _disableDraggable ) ;
} ) ;
on ( ownerDocument , 'dragover' , nearestEmptyInsertDetectEvent ) ;
on ( ownerDocument , 'mousemove' , nearestEmptyInsertDetectEvent ) ;
on ( ownerDocument , 'touchmove' , nearestEmptyInsertDetectEvent ) ;
on ( ownerDocument , 'mouseup' , _this . _onDrop ) ;
on ( ownerDocument , 'touchend' , _this . _onDrop ) ;
on ( ownerDocument , 'touchcancel' , _this . _onDrop ) ; // Make dragEl draggable (must be before delay for FireFox)
if ( FireFox && this . nativeDraggable ) {
this . options . touchStartThreshold = 4 ;
dragEl . draggable = true ;
}
pluginEvent ( 'delayStart' , this , {
evt : evt
} ) ; // Delay is impossible for native DnD in Edge or IE
if ( options . delay && ( ! options . delayOnTouchOnly || touch ) && ( ! this . nativeDraggable || ! ( Edge || IE11OrLess ) ) ) {
if ( Sortable . eventCanceled ) {
this . _onDrop ( ) ;
return ;
} // If the user moves the pointer or let go the click or touch
// before the delay has been reached:
// disable the delayed drag
on ( ownerDocument , 'mouseup' , _this . _disableDelayedDrag ) ;
on ( ownerDocument , 'touchend' , _this . _disableDelayedDrag ) ;
on ( ownerDocument , 'touchcancel' , _this . _disableDelayedDrag ) ;
on ( ownerDocument , 'mousemove' , _this . _delayedDragTouchMoveHandler ) ;
on ( ownerDocument , 'touchmove' , _this . _delayedDragTouchMoveHandler ) ;
options . supportPointer && on ( ownerDocument , 'pointermove' , _this . _delayedDragTouchMoveHandler ) ;
_this . _dragStartTimer = setTimeout ( dragStartFn , options . delay ) ;
} else {
dragStartFn ( ) ;
}
}
} ,
_delayedDragTouchMoveHandler : function _delayedDragTouchMoveHandler (
/** TouchEvent|PointerEvent **/
e ) {
var touch = e . touches ? e . touches [ 0 ] : e ;
if ( Math . max ( Math . abs ( touch . clientX - this . _lastX ) , Math . abs ( touch . clientY - this . _lastY ) ) >= Math . floor ( this . options . touchStartThreshold / ( this . nativeDraggable && window . devicePixelRatio || 1 ) ) ) {
this . _disableDelayedDrag ( ) ;
}
} ,
_disableDelayedDrag : function _disableDelayedDrag ( ) {
dragEl && _disableDraggable ( dragEl ) ;
clearTimeout ( this . _dragStartTimer ) ;
this . _disableDelayedDragEvents ( ) ;
} ,
_disableDelayedDragEvents : function _disableDelayedDragEvents ( ) {
var ownerDocument = this . el . ownerDocument ;
off ( ownerDocument , 'mouseup' , this . _disableDelayedDrag ) ;
off ( ownerDocument , 'touchend' , this . _disableDelayedDrag ) ;
off ( ownerDocument , 'touchcancel' , this . _disableDelayedDrag ) ;
off ( ownerDocument , 'mousemove' , this . _delayedDragTouchMoveHandler ) ;
off ( ownerDocument , 'touchmove' , this . _delayedDragTouchMoveHandler ) ;
off ( ownerDocument , 'pointermove' , this . _delayedDragTouchMoveHandler ) ;
} ,
_triggerDragStart : function _triggerDragStart (
/** Event */
evt ,
/** Touch */
touch ) {
touch = touch || evt . pointerType == 'touch' && evt ;
if ( ! this . nativeDraggable || touch ) {
if ( this . options . supportPointer ) {
on ( document , 'pointermove' , this . _onTouchMove ) ;
} else if ( touch ) {
on ( document , 'touchmove' , this . _onTouchMove ) ;
} else {
on ( document , 'mousemove' , this . _onTouchMove ) ;
}
} else {
on ( dragEl , 'dragend' , this ) ;
on ( rootEl , 'dragstart' , this . _onDragStart ) ;
}
try {
if ( document . selection ) {
// Timeout neccessary for IE9
_nextTick ( function ( ) {
document . selection . empty ( ) ;
} ) ;
} else {
window . getSelection ( ) . removeAllRanges ( ) ;
}
} catch ( err ) { }
} ,
_dragStarted : function _dragStarted ( fallback , evt ) {
awaitingDragStarted = false ;
if ( rootEl && dragEl ) {
pluginEvent ( 'dragStarted' , this , {
evt : evt
} ) ;
if ( this . nativeDraggable ) {
on ( document , 'dragover' , _checkOutsideTargetEl ) ;
}
var options = this . options ; // Apply effect
! fallback && toggleClass ( dragEl , options . dragClass , false ) ;
toggleClass ( dragEl , options . ghostClass , true ) ;
Sortable . active = this ;
fallback && this . _appendGhost ( ) ; // Drag start event
_dispatchEvent ( {
sortable : this ,
name : 'start' ,
originalEvent : evt
} ) ;
} else {
this . _nulling ( ) ;
}
} ,
_emulateDragOver : function _emulateDragOver ( ) {
if ( touchEvt ) {
this . _lastX = touchEvt . clientX ;
this . _lastY = touchEvt . clientY ;
_hideGhostForTarget ( ) ;
var target = document . elementFromPoint ( touchEvt . clientX , touchEvt . clientY ) ;
var parent = target ;
while ( target && target . shadowRoot ) {
target = target . shadowRoot . elementFromPoint ( touchEvt . clientX , touchEvt . clientY ) ;
if ( target === parent ) break ;
parent = target ;
}
dragEl . parentNode [ expando ] . _isOutsideThisEl ( target ) ;
if ( parent ) {
do {
if ( parent [ expando ] ) {
var inserted = void 0 ;
inserted = parent [ expando ] . _onDragOver ( {
clientX : touchEvt . clientX ,
clientY : touchEvt . clientY ,
target : target ,
rootEl : parent
} ) ;
if ( inserted && ! this . options . dragoverBubble ) {
break ;
}
}
target = parent ; // store last element
}
/* jshint boss:true */
while ( parent = parent . parentNode ) ;
}
_unhideGhostForTarget ( ) ;
}
} ,
_onTouchMove : function _onTouchMove (
/**TouchEvent*/
evt ) {
if ( tapEvt ) {
var options = this . options ,
fallbackTolerance = options . fallbackTolerance ,
fallbackOffset = options . fallbackOffset ,
touch = evt . touches ? evt . touches [ 0 ] : evt ,
ghostMatrix = ghostEl && matrix ( ghostEl , true ) ,
scaleX = ghostEl && ghostMatrix && ghostMatrix . a ,
scaleY = ghostEl && ghostMatrix && ghostMatrix . d ,
relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset ( ghostRelativeParent ) ,
dx = ( touch . clientX - tapEvt . clientX + fallbackOffset . x ) / ( scaleX || 1 ) + ( relativeScrollOffset ? relativeScrollOffset [ 0 ] - ghostRelativeParentInitialScroll [ 0 ] : 0 ) / ( scaleX || 1 ) ,
dy = ( touch . clientY - tapEvt . clientY + fallbackOffset . y ) / ( scaleY || 1 ) + ( relativeScrollOffset ? relativeScrollOffset [ 1 ] - ghostRelativeParentInitialScroll [ 1 ] : 0 ) / ( scaleY || 1 ) ; // only set the status to dragging, when we are actually dragging
if ( ! Sortable . active && ! awaitingDragStarted ) {
if ( fallbackTolerance && Math . max ( Math . abs ( touch . clientX - this . _lastX ) , Math . abs ( touch . clientY - this . _lastY ) ) < fallbackTolerance ) {
return ;
}
this . _onDragStart ( evt , true ) ;
}
if ( ghostEl ) {
if ( ghostMatrix ) {
ghostMatrix . e += dx - ( lastDx || 0 ) ;
ghostMatrix . f += dy - ( lastDy || 0 ) ;
} else {
ghostMatrix = {
a : 1 ,
b : 0 ,
c : 0 ,
d : 1 ,
e : dx ,
f : dy
} ;
}
var cssMatrix = "matrix(" . concat ( ghostMatrix . a , "," ) . concat ( ghostMatrix . b , "," ) . concat ( ghostMatrix . c , "," ) . concat ( ghostMatrix . d , "," ) . concat ( ghostMatrix . e , "," ) . concat ( ghostMatrix . f , ")" ) ;
css ( ghostEl , 'webkitTransform' , cssMatrix ) ;
css ( ghostEl , 'mozTransform' , cssMatrix ) ;
css ( ghostEl , 'msTransform' , cssMatrix ) ;
css ( ghostEl , 'transform' , cssMatrix ) ;
lastDx = dx ;
lastDy = dy ;
touchEvt = touch ;
}
evt . cancelable && evt . preventDefault ( ) ;
}
} ,
_appendGhost : function _appendGhost ( ) {
// Bug if using scale(): https://stackoverflow.com/questions/2637058
// Not being adjusted for
if ( ! ghostEl ) {
var container = this . options . fallbackOnBody ? document . body : rootEl ,
rect = getRect ( dragEl , true , PositionGhostAbsolutely , true , container ) ,
options = this . options ; // Position absolutely
if ( PositionGhostAbsolutely ) {
// Get relatively positioned parent
ghostRelativeParent = container ;
while ( css ( ghostRelativeParent , 'position' ) === 'static' && css ( ghostRelativeParent , 'transform' ) === 'none' && ghostRelativeParent !== document ) {
ghostRelativeParent = ghostRelativeParent . parentNode ;
}
if ( ghostRelativeParent !== document . body && ghostRelativeParent !== document . documentElement ) {
if ( ghostRelativeParent === document ) ghostRelativeParent = getWindowScrollingElement ( ) ;
rect . top += ghostRelativeParent . scrollTop ;
rect . left += ghostRelativeParent . scrollLeft ;
} else {
ghostRelativeParent = getWindowScrollingElement ( ) ;
}
ghostRelativeParentInitialScroll = getRelativeScrollOffset ( ghostRelativeParent ) ;
}
ghostEl = dragEl . cloneNode ( true ) ;
toggleClass ( ghostEl , options . ghostClass , false ) ;
toggleClass ( ghostEl , options . fallbackClass , true ) ;
toggleClass ( ghostEl , options . dragClass , true ) ;
css ( ghostEl , 'transition' , '' ) ;
css ( ghostEl , 'transform' , '' ) ;
css ( ghostEl , 'box-sizing' , 'border-box' ) ;
css ( ghostEl , 'margin' , 0 ) ;
css ( ghostEl , 'top' , rect . top ) ;
css ( ghostEl , 'left' , rect . left ) ;
css ( ghostEl , 'width' , rect . width ) ;
css ( ghostEl , 'height' , rect . height ) ;
css ( ghostEl , 'opacity' , '0.8' ) ;
css ( ghostEl , 'position' , PositionGhostAbsolutely ? 'absolute' : 'fixed' ) ;
css ( ghostEl , 'zIndex' , '100000' ) ;
css ( ghostEl , 'pointerEvents' , 'none' ) ;
Sortable . ghost = ghostEl ;
container . appendChild ( ghostEl ) ; // Set transform-origin
css ( ghostEl , 'transform-origin' , tapDistanceLeft / parseInt ( ghostEl . style . width ) * 100 + '% ' + tapDistanceTop / parseInt ( ghostEl . style . height ) * 100 + '%' ) ;
}
} ,
_onDragStart : function _onDragStart (
/**Event*/
evt ,
/**boolean*/
fallback ) {
var _this = this ;
var dataTransfer = evt . dataTransfer ;
var options = _this . options ;
pluginEvent ( 'dragStart' , this , {
evt : evt
} ) ;
if ( Sortable . eventCanceled ) {
this . _onDrop ( ) ;
return ;
}
pluginEvent ( 'setupClone' , this ) ;
if ( ! Sortable . eventCanceled ) {
cloneEl = clone ( dragEl ) ;
cloneEl . draggable = false ;
cloneEl . style [ 'will-change' ] = '' ;
this . _hideClone ( ) ;
toggleClass ( cloneEl , this . options . chosenClass , false ) ;
Sortable . clone = cloneEl ;
} // #1143: IFrame support workaround
_this . cloneId = _nextTick ( function ( ) {
pluginEvent ( 'clone' , _this ) ;
if ( Sortable . eventCanceled ) return ;
if ( ! _this . options . removeCloneOnHide ) {
rootEl . insertBefore ( cloneEl , dragEl ) ;
}
_this . _hideClone ( ) ;
_dispatchEvent ( {
sortable : _this ,
name : 'clone'
} ) ;
} ) ;
! fallback && toggleClass ( dragEl , options . dragClass , true ) ; // Set proper drop events
if ( fallback ) {
ignoreNextClick = true ;
_this . _loopId = setInterval ( _this . _emulateDragOver , 50 ) ;
} else {
// Undo what was set in _prepareDragStart before drag started
off ( document , 'mouseup' , _this . _onDrop ) ;
off ( document , 'touchend' , _this . _onDrop ) ;
off ( document , 'touchcancel' , _this . _onDrop ) ;
if ( dataTransfer ) {
dataTransfer . effectAllowed = 'move' ;
options . setData && options . setData . call ( _this , dataTransfer , dragEl ) ;
}
on ( document , 'drop' , _this ) ; // #1276 fix:
css ( dragEl , 'transform' , 'translateZ(0)' ) ;
}
awaitingDragStarted = true ;
_this . _dragStartId = _nextTick ( _this . _dragStarted . bind ( _this , fallback , evt ) ) ;
on ( document , 'selectstart' , _this ) ;
moved = true ;
if ( Safari ) {
css ( document . body , 'user-select' , 'none' ) ;
}
} ,
// Returns true - if no further action is needed (either inserted or another condition)
_onDragOver : function _onDragOver (
/**Event*/
evt ) {
var el = this . el ,
target = evt . target ,
dragRect ,
targetRect ,
revert ,
options = this . options ,
group = options . group ,
activeSortable = Sortable . active ,
isOwner = activeGroup === group ,
canSort = options . sort ,
fromSortable = putSortable || activeSortable ,
vertical ,
_this = this ,
completedFired = false ;
if ( _silent ) return ;
function dragOverEvent ( name , extra ) {
pluginEvent ( name , _this , _objectSpread ( {
evt : evt ,
isOwner : isOwner ,
axis : vertical ? 'vertical' : 'horizontal' ,
revert : revert ,
dragRect : dragRect ,
targetRect : targetRect ,
canSort : canSort ,
fromSortable : fromSortable ,
target : target ,
completed : completed ,
onMove : function onMove ( target , after ) {
return _onMove ( rootEl , el , dragEl , dragRect , target , getRect ( target ) , evt , after ) ;
} ,
changed : changed
} , extra ) ) ;
} // Capture animation state
function capture ( ) {
dragOverEvent ( 'dragOverAnimationCapture' ) ;
_this . captureAnimationState ( ) ;
if ( _this !== fromSortable ) {
fromSortable . captureAnimationState ( ) ;
}
} // Return invocation when dragEl is inserted (or completed)
function completed ( insertion ) {
dragOverEvent ( 'dragOverCompleted' , {
insertion : insertion
} ) ;
if ( insertion ) {
// Clones must be hidden before folding animation to capture dragRectAbsolute properly
if ( isOwner ) {
activeSortable . _hideClone ( ) ;
} else {
activeSortable . _showClone ( _this ) ;
}
if ( _this !== fromSortable ) {
// Set ghost class to new sortable's ghost class
toggleClass ( dragEl , putSortable ? putSortable . options . ghostClass : activeSortable . options . ghostClass , false ) ;
toggleClass ( dragEl , options . ghostClass , true ) ;
}
if ( putSortable !== _this && _this !== Sortable . active ) {
putSortable = _this ;
} else if ( _this === Sortable . active && putSortable ) {
putSortable = null ;
} // Animation
if ( fromSortable === _this ) {
_this . _ignoreWhileAnimating = target ;
}
_this . animateAll ( function ( ) {
dragOverEvent ( 'dragOverAnimationComplete' ) ;
_this . _ignoreWhileAnimating = null ;
} ) ;
if ( _this !== fromSortable ) {
fromSortable . animateAll ( ) ;
fromSortable . _ignoreWhileAnimating = null ;
}
} // Null lastTarget if it is not inside a previously swapped element
if ( target === dragEl && ! dragEl . animated || target === el && ! target . animated ) {
lastTarget = null ;
} // no bubbling and not fallback
if ( ! options . dragoverBubble && ! evt . rootEl && target !== document ) {
dragEl . parentNode [ expando ] . _isOutsideThisEl ( evt . target ) ; // Do not detect for empty insert if already inserted
! insertion && nearestEmptyInsertDetectEvent ( evt ) ;
}
! options . dragoverBubble && evt . stopPropagation && evt . stopPropagation ( ) ;
return completedFired = true ;
} // Call when dragEl has been inserted
function changed ( ) {
newIndex = index ( dragEl ) ;
newDraggableIndex = index ( dragEl , options . draggable ) ;
_dispatchEvent ( {
sortable : _this ,
name : 'change' ,
toEl : el ,
newIndex : newIndex ,
newDraggableIndex : newDraggableIndex ,
originalEvent : evt
} ) ;
}
if ( evt . preventDefault !== void 0 ) {
evt . cancelable && evt . preventDefault ( ) ;
}
target = closest ( target , options . draggable , el , true ) ;
dragOverEvent ( 'dragOver' ) ;
if ( Sortable . eventCanceled ) return completedFired ;
if ( dragEl . contains ( evt . target ) || target . animated && target . animatingX && target . animatingY || _this . _ignoreWhileAnimating === target ) {
return completed ( false ) ;
}
ignoreNextClick = false ;
if ( activeSortable && ! options . disabled && ( isOwner ? canSort || ( revert = ! rootEl . contains ( dragEl ) ) // Reverting item into the original list
: putSortable === this || ( this . lastPutMode = activeGroup . checkPull ( this , activeSortable , dragEl , evt ) ) && group . checkPut ( this , activeSortable , dragEl , evt ) ) ) {
vertical = this . _getDirection ( evt , target ) === 'vertical' ;
dragRect = getRect ( dragEl ) ;
dragOverEvent ( 'dragOverValid' ) ;
if ( Sortable . eventCanceled ) return completedFired ;
if ( revert ) {
parentEl = rootEl ; // actualization
capture ( ) ;
this . _hideClone ( ) ;
dragOverEvent ( 'revert' ) ;
if ( ! Sortable . eventCanceled ) {
if ( nextEl ) {
rootEl . insertBefore ( dragEl , nextEl ) ;
} else {
rootEl . appendChild ( dragEl ) ;
}
}
return completed ( true ) ;
}
var elLastChild = lastChild ( el , options . draggable ) ;
if ( ! elLastChild || _ghostIsLast ( evt , vertical , this ) && ! elLastChild . animated ) {
// If already at end of list: Do not insert
if ( elLastChild === dragEl ) {
return completed ( false ) ;
} // assign target only if condition is true
if ( elLastChild && el === evt . target ) {
target = elLastChild ;
}
if ( target ) {
targetRect = getRect ( target ) ;
}
if ( _onMove ( rootEl , el , dragEl , dragRect , target , targetRect , evt , ! ! target ) !== false ) {
capture ( ) ;
el . appendChild ( dragEl ) ;
parentEl = el ; // actualization
changed ( ) ;
return completed ( true ) ;
}
} else if ( target . parentNode === el ) {
targetRect = getRect ( target ) ;
var direction = 0 ,
targetBeforeFirstSwap ,
differentLevel = dragEl . parentNode !== el ,
differentRowCol = ! _dragElInRowColumn ( dragEl . animated && dragEl . toRect || dragRect , target . animated && target . toRect || targetRect , vertical ) ,
side1 = vertical ? 'top' : 'left' ,
scrolledPastTop = isScrolledPast ( target , 'top' , 'top' ) || isScrolledPast ( dragEl , 'top' , 'top' ) ,
scrollBefore = scrolledPastTop ? scrolledPastTop . scrollTop : void 0 ;
if ( lastTarget !== target ) {
targetBeforeFirstSwap = targetRect [ side1 ] ;
pastFirstInvertThresh = false ;
isCircumstantialInvert = ! differentRowCol && options . invertSwap || differentLevel ;
}
direction = _getSwapDirection ( evt , target , targetRect , vertical , differentRowCol ? 1 : options . swapThreshold , options . invertedSwapThreshold == null ? options . swapThreshold : options . invertedSwapThreshold , isCircumstantialInvert , lastTarget === target ) ;
var sibling ;
if ( direction !== 0 ) {
// Check if target is beside dragEl in respective direction (ignoring hidden elements)
var dragIndex = index ( dragEl ) ;
do {
dragIndex -= direction ;
sibling = parentEl . children [ dragIndex ] ;
} while ( sibling && ( css ( sibling , 'display' ) === 'none' || sibling === ghostEl ) ) ;
} // If dragEl is already beside target: Do not insert
if ( direction === 0 || sibling === target ) {
return completed ( false ) ;
}
lastTarget = target ;
lastDirection = direction ;
var nextSibling = target . nextElementSibling ,
after = false ;
after = direction === 1 ;
var moveVector = _onMove ( rootEl , el , dragEl , dragRect , target , targetRect , evt , after ) ;
if ( moveVector !== false ) {
if ( moveVector === 1 || moveVector === - 1 ) {
after = moveVector === 1 ;
}
_silent = true ;
setTimeout ( _unsilent , 30 ) ;
capture ( ) ;
if ( after && ! nextSibling ) {
el . appendChild ( dragEl ) ;
} else {
target . parentNode . insertBefore ( dragEl , after ? nextSibling : target ) ;
} // Undo chrome's scroll adjustment (has no effect on other browsers)
if ( scrolledPastTop ) {
scrollBy ( scrolledPastTop , 0 , scrollBefore - scrolledPastTop . scrollTop ) ;
}
parentEl = dragEl . parentNode ; // actualization
// must be done before animation
if ( targetBeforeFirstSwap !== undefined && ! isCircumstantialInvert ) {
targetMoveDistance = Math . abs ( targetBeforeFirstSwap - getRect ( target ) [ side1 ] ) ;
}
changed ( ) ;
return completed ( true ) ;
}
}
if ( el . contains ( dragEl ) ) {
return completed ( false ) ;
}
}
return false ;
} ,
_ignoreWhileAnimating : null ,
_offMoveEvents : function _offMoveEvents ( ) {
off ( document , 'mousemove' , this . _onTouchMove ) ;
off ( document , 'touchmove' , this . _onTouchMove ) ;
off ( document , 'pointermove' , this . _onTouchMove ) ;
off ( document , 'dragover' , nearestEmptyInsertDetectEvent ) ;
off ( document , 'mousemove' , nearestEmptyInsertDetectEvent ) ;
off ( document , 'touchmove' , nearestEmptyInsertDetectEvent ) ;
} ,
_offUpEvents : function _offUpEvents ( ) {
var ownerDocument = this . el . ownerDocument ;
off ( ownerDocument , 'mouseup' , this . _onDrop ) ;
off ( ownerDocument , 'touchend' , this . _onDrop ) ;
off ( ownerDocument , 'pointerup' , this . _onDrop ) ;
off ( ownerDocument , 'touchcancel' , this . _onDrop ) ;
off ( document , 'selectstart' , this ) ;
} ,
_onDrop : function _onDrop (
/**Event*/
evt ) {
var el = this . el ,
options = this . options ; // Get the index of the dragged element within its parent
newIndex = index ( dragEl ) ;
newDraggableIndex = index ( dragEl , options . draggable ) ;
pluginEvent ( 'drop' , this , {
evt : evt
} ) ;
parentEl = dragEl && dragEl . parentNode ; // Get again after plugin event
newIndex = index ( dragEl ) ;
newDraggableIndex = index ( dragEl , options . draggable ) ;
if ( Sortable . eventCanceled ) {
this . _nulling ( ) ;
return ;
}
awaitingDragStarted = false ;
isCircumstantialInvert = false ;
pastFirstInvertThresh = false ;
clearInterval ( this . _loopId ) ;
clearTimeout ( this . _dragStartTimer ) ;
_cancelNextTick ( this . cloneId ) ;
_cancelNextTick ( this . _dragStartId ) ; // Unbind events
if ( this . nativeDraggable ) {
off ( document , 'drop' , this ) ;
off ( el , 'dragstart' , this . _onDragStart ) ;
}
this . _offMoveEvents ( ) ;
this . _offUpEvents ( ) ;
if ( Safari ) {
css ( document . body , 'user-select' , '' ) ;
}
css ( dragEl , 'transform' , '' ) ;
if ( evt ) {
if ( moved ) {
evt . cancelable && evt . preventDefault ( ) ;
! options . dropBubble && evt . stopPropagation ( ) ;
}
ghostEl && ghostEl . parentNode && ghostEl . parentNode . removeChild ( ghostEl ) ;
if ( rootEl === parentEl || putSortable && putSortable . lastPutMode !== 'clone' ) {
// Remove clone(s)
cloneEl && cloneEl . parentNode && cloneEl . parentNode . removeChild ( cloneEl ) ;
}
if ( dragEl ) {
if ( this . nativeDraggable ) {
off ( dragEl , 'dragend' , this ) ;
}
_disableDraggable ( dragEl ) ;
dragEl . style [ 'will-change' ] = '' ; // Remove classes
// ghostClass is added in dragStarted
if ( moved && ! awaitingDragStarted ) {
toggleClass ( dragEl , putSortable ? putSortable . options . ghostClass : this . options . ghostClass , false ) ;
}
toggleClass ( dragEl , this . options . chosenClass , false ) ; // Drag stop event
_dispatchEvent ( {
sortable : this ,
name : 'unchoose' ,
toEl : parentEl ,
newIndex : null ,
newDraggableIndex : null ,
originalEvent : evt
} ) ;
if ( rootEl !== parentEl ) {
if ( newIndex >= 0 ) {
// Add event
_dispatchEvent ( {
rootEl : parentEl ,
name : 'add' ,
toEl : parentEl ,
fromEl : rootEl ,
originalEvent : evt
} ) ; // Remove event
_dispatchEvent ( {
sortable : this ,
name : 'remove' ,
toEl : parentEl ,
originalEvent : evt
} ) ; // drag from one list and drop into another
_dispatchEvent ( {
rootEl : parentEl ,
name : 'sort' ,
toEl : parentEl ,
fromEl : rootEl ,
originalEvent : evt
} ) ;
_dispatchEvent ( {
sortable : this ,
name : 'sort' ,
toEl : parentEl ,
originalEvent : evt
} ) ;
}
putSortable && putSortable . save ( ) ;
} else {
if ( newIndex !== oldIndex ) {
if ( newIndex >= 0 ) {
// drag & drop within the same list
_dispatchEvent ( {
sortable : this ,
name : 'update' ,
toEl : parentEl ,
originalEvent : evt
} ) ;
_dispatchEvent ( {
sortable : this ,
name : 'sort' ,
toEl : parentEl ,
originalEvent : evt
} ) ;
}
}
}
if ( Sortable . active ) {
/* jshint eqnull:true */
if ( newIndex == null || newIndex === - 1 ) {
newIndex = oldIndex ;
newDraggableIndex = oldDraggableIndex ;
}
_dispatchEvent ( {
sortable : this ,
name : 'end' ,
toEl : parentEl ,
originalEvent : evt
} ) ; // Save sorting
this . save ( ) ;
}
}
}
this . _nulling ( ) ;
} ,
_nulling : function _nulling ( ) {
pluginEvent ( 'nulling' , this ) ;
rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable . dragged = Sortable . ghost = Sortable . clone = Sortable . active = null ;
savedInputChecked . forEach ( function ( el ) {
el . checked = true ;
} ) ;
savedInputChecked . length = lastDx = lastDy = 0 ;
} ,
handleEvent : function handleEvent (
/**Event*/
evt ) {
switch ( evt . type ) {
case 'drop' :
case 'dragend' :
this . _onDrop ( evt ) ;
break ;
case 'dragenter' :
case 'dragover' :
if ( dragEl ) {
this . _onDragOver ( evt ) ;
_globalDragOver ( evt ) ;
}
break ;
case 'selectstart' :
evt . preventDefault ( ) ;
break ;
}
} ,
/ * *
* Serializes the item into an array of string .
* @ returns { String [ ] }
* /
toArray : function toArray ( ) {
var order = [ ] ,
el ,
children = this . el . children ,
i = 0 ,
n = children . length ,
options = this . options ;
for ( ; i < n ; i ++ ) {
el = children [ i ] ;
if ( closest ( el , options . draggable , this . el , false ) ) {
order . push ( el . getAttribute ( options . dataIdAttr ) || _generateId ( el ) ) ;
}
}
return order ;
} ,
/ * *
* Sorts the elements according to the array .
* @ param { String [ ] } order order of the items
* /
sort : function sort ( order ) {
var items = { } ,
rootEl = this . el ;
this . toArray ( ) . forEach ( function ( id , i ) {
var el = rootEl . children [ i ] ;
if ( closest ( el , this . options . draggable , rootEl , false ) ) {
items [ id ] = el ;
}
} , this ) ;
order . forEach ( function ( id ) {
if ( items [ id ] ) {
rootEl . removeChild ( items [ id ] ) ;
rootEl . appendChild ( items [ id ] ) ;
}
} ) ;
} ,
/ * *
* Save the current sorting
* /
save : function save ( ) {
var store = this . options . store ;
store && store . set && store . set ( this ) ;
} ,
/ * *
* For each element in the set , get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree .
* @ param { HTMLElement } el
* @ param { String } [ selector ] default : ` options.draggable `
* @ returns { HTMLElement | null }
* /
closest : function closest$1 ( el , selector ) {
return closest ( el , selector || this . options . draggable , this . el , false ) ;
} ,
/ * *
* Set / get option
* @ param { string } name
* @ param { * } [ value ]
* @ returns { * }
* /
option : function option ( name , value ) {
var options = this . options ;
if ( value === void 0 ) {
return options [ name ] ;
} else {
var modifiedValue = PluginManager . modifyOption ( this , name , value ) ;
if ( typeof modifiedValue !== 'undefined' ) {
options [ name ] = modifiedValue ;
} else {
options [ name ] = value ;
}
if ( name === 'group' ) {
_prepareGroup ( options ) ;
}
}
} ,
/ * *
* Destroy
* /
destroy : function destroy ( ) {
pluginEvent ( 'destroy' , this ) ;
var el = this . el ;
el [ expando ] = null ;
off ( el , 'mousedown' , this . _onTapStart ) ;
off ( el , 'touchstart' , this . _onTapStart ) ;
off ( el , 'pointerdown' , this . _onTapStart ) ;
if ( this . nativeDraggable ) {
off ( el , 'dragover' , this ) ;
off ( el , 'dragenter' , this ) ;
} // Remove draggable attributes
Array . prototype . forEach . call ( el . querySelectorAll ( '[draggable]' ) , function ( el ) {
el . removeAttribute ( 'draggable' ) ;
} ) ;
this . _onDrop ( ) ;
this . _disableDelayedDragEvents ( ) ;
sortables . splice ( sortables . indexOf ( this . el ) , 1 ) ;
this . el = el = null ;
} ,
_hideClone : function _hideClone ( ) {
if ( ! cloneHidden ) {
pluginEvent ( 'hideClone' , this ) ;
if ( Sortable . eventCanceled ) return ;
css ( cloneEl , 'display' , 'none' ) ;
if ( this . options . removeCloneOnHide && cloneEl . parentNode ) {
cloneEl . parentNode . removeChild ( cloneEl ) ;
}
cloneHidden = true ;
}
} ,
_showClone : function _showClone ( putSortable ) {
if ( putSortable . lastPutMode !== 'clone' ) {
this . _hideClone ( ) ;
return ;
}
if ( cloneHidden ) {
pluginEvent ( 'showClone' , this ) ;
if ( Sortable . eventCanceled ) return ; // show clone at dragEl or original position
if ( rootEl . contains ( dragEl ) && ! this . options . group . revertClone ) {
rootEl . insertBefore ( cloneEl , dragEl ) ;
} else if ( nextEl ) {
rootEl . insertBefore ( cloneEl , nextEl ) ;
} else {
rootEl . appendChild ( cloneEl ) ;
}
if ( this . options . group . revertClone ) {
this . animate ( dragEl , cloneEl ) ;
}
css ( cloneEl , 'display' , '' ) ;
cloneHidden = false ;
}
}
} ;
function _globalDragOver (
/**Event*/
evt ) {
if ( evt . dataTransfer ) {
evt . dataTransfer . dropEffect = 'move' ;
}
evt . cancelable && evt . preventDefault ( ) ;
}
function _onMove ( fromEl , toEl , dragEl , dragRect , targetEl , targetRect , originalEvent , willInsertAfter ) {
var evt ,
sortable = fromEl [ expando ] ,
onMoveFn = sortable . options . onMove ,
retVal ; // Support for new CustomEvent feature
if ( window . CustomEvent && ! IE11OrLess && ! Edge ) {
evt = new CustomEvent ( 'move' , {
bubbles : true ,
cancelable : true
} ) ;
} else {
evt = document . createEvent ( 'Event' ) ;
evt . initEvent ( 'move' , true , true ) ;
}
evt . to = toEl ;
evt . from = fromEl ;
evt . dragged = dragEl ;
evt . draggedRect = dragRect ;
evt . related = targetEl || toEl ;
evt . relatedRect = targetRect || getRect ( toEl ) ;
evt . willInsertAfter = willInsertAfter ;
evt . originalEvent = originalEvent ;
fromEl . dispatchEvent ( evt ) ;
if ( onMoveFn ) {
retVal = onMoveFn . call ( sortable , evt , originalEvent ) ;
}
return retVal ;
}
function _disableDraggable ( el ) {
el . draggable = false ;
}
function _unsilent ( ) {
_silent = false ;
}
function _ghostIsLast ( evt , vertical , sortable ) {
var rect = getRect ( lastChild ( sortable . el , sortable . options . draggable ) ) ;
var spacer = 10 ;
return vertical ? evt . clientX > rect . right + spacer || evt . clientX <= rect . right && evt . clientY > rect . bottom && evt . clientX >= rect . left : evt . clientX > rect . right && evt . clientY > rect . top || evt . clientX <= rect . right && evt . clientY > rect . bottom + spacer ;
}
function _getSwapDirection ( evt , target , targetRect , vertical , swapThreshold , invertedSwapThreshold , invertSwap , isLastTarget ) {
var mouseOnAxis = vertical ? evt . clientY : evt . clientX ,
targetLength = vertical ? targetRect . height : targetRect . width ,
targetS1 = vertical ? targetRect . top : targetRect . left ,
targetS2 = vertical ? targetRect . bottom : targetRect . right ,
invert = false ;
if ( ! invertSwap ) {
// Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
if ( isLastTarget && targetMoveDistance < targetLength * swapThreshold ) {
// multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
// check if past first invert threshold on side opposite of lastDirection
if ( ! pastFirstInvertThresh && ( lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2 ) ) {
// past first invert threshold, do not restrict inverted threshold to dragEl shadow
pastFirstInvertThresh = true ;
}
if ( ! pastFirstInvertThresh ) {
// dragEl shadow (target move distance shadow)
if ( lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
: mouseOnAxis > targetS2 - targetMoveDistance ) {
return - lastDirection ;
}
} else {
invert = true ;
}
} else {
// Regular
if ( mouseOnAxis > targetS1 + targetLength * ( 1 - swapThreshold ) / 2 && mouseOnAxis < targetS2 - targetLength * ( 1 - swapThreshold ) / 2 ) {
return _getInsertDirection ( target ) ;
}
}
}
invert = invert || invertSwap ;
if ( invert ) {
// Invert of regular
if ( mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2 ) {
return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : - 1 ;
}
}
return 0 ;
}
/ * *
* Gets the direction dragEl must be swapped relative to target in order to make it
* seem that dragEl has been "inserted" into that element ' s position
* @ param { HTMLElement } target The target whose position dragEl is being inserted at
* @ return { Number } Direction dragEl must be swapped
* /
function _getInsertDirection ( target ) {
if ( index ( dragEl ) < index ( target ) ) {
return 1 ;
} else {
return - 1 ;
}
}
/ * *
* Generate id
* @ param { HTMLElement } el
* @ returns { String }
* @ private
* /
function _generateId ( el ) {
var str = el . tagName + el . className + el . src + el . href + el . textContent ,
i = str . length ,
sum = 0 ;
while ( i -- ) {
sum += str . charCodeAt ( i ) ;
}
return sum . toString ( 36 ) ;
}
function _saveInputCheckedState ( root ) {
savedInputChecked . length = 0 ;
var inputs = root . getElementsByTagName ( 'input' ) ;
var idx = inputs . length ;
while ( idx -- ) {
var el = inputs [ idx ] ;
el . checked && savedInputChecked . push ( el ) ;
}
}
function _nextTick ( fn ) {
return setTimeout ( fn , 0 ) ;
}
function _cancelNextTick ( id ) {
return clearTimeout ( id ) ;
} // Fixed #973:
if ( documentExists ) {
on ( document , 'touchmove' , function ( evt ) {
if ( ( Sortable . active || awaitingDragStarted ) && evt . cancelable ) {
evt . preventDefault ( ) ;
}
} ) ;
} // Export utils
Sortable . utils = {
on : on ,
off : off ,
css : css ,
find : find ,
is : function is ( el , selector ) {
return ! ! closest ( el , selector , el , false ) ;
} ,
extend : extend ,
throttle : throttle ,
closest : closest ,
toggleClass : toggleClass ,
clone : clone ,
index : index ,
nextTick : _nextTick ,
cancelNextTick : _cancelNextTick ,
detectDirection : _detectDirection ,
getChild : getChild
} ;
/ * *
* Get the Sortable instance of an element
* @ param { HTMLElement } element The element
* @ return { Sortable | undefined } The instance of Sortable
* /
Sortable . get = function ( element ) {
return element [ expando ] ;
} ;
/ * *
* Mount a plugin to Sortable
* @ param { ... SortablePlugin | SortablePlugin [ ] } plugins Plugins being mounted
* /
Sortable . mount = function ( ) {
for ( var _len = arguments . length , plugins = new Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) {
plugins [ _key ] = arguments [ _key ] ;
}
if ( plugins [ 0 ] . constructor === Array ) plugins = plugins [ 0 ] ;
plugins . forEach ( function ( plugin ) {
if ( ! plugin . prototype || ! plugin . prototype . constructor ) {
throw "Sortable: Mounted plugin must be a constructor function, not " . concat ( { } . toString . call ( plugin ) ) ;
}
if ( plugin . utils ) Sortable . utils = _objectSpread ( { } , Sortable . utils , plugin . utils ) ;
PluginManager . mount ( plugin ) ;
} ) ;
} ;
/ * *
* Create sortable instance
* @ param { HTMLElement } el
* @ param { Object } [ options ]
* /
Sortable . create = function ( el , options ) {
return new Sortable ( el , options ) ;
} ; // Export
Sortable . version = version ;
var autoScrolls = [ ] ,
scrollEl ,
scrollRootEl ,
scrolling = false ,
lastAutoScrollX ,
lastAutoScrollY ,
touchEvt$1 ,
pointerElemChangedInterval ;
function AutoScrollPlugin ( ) {
function AutoScroll ( ) {
this . defaults = {
scroll : true ,
scrollSensitivity : 30 ,
scrollSpeed : 10 ,
bubbleScroll : true
} ; // Bind all private methods
for ( var fn in this ) {
if ( fn . charAt ( 0 ) === '_' && typeof this [ fn ] === 'function' ) {
this [ fn ] = this [ fn ] . bind ( this ) ;
}
}
}
AutoScroll . prototype = {
dragStarted : function dragStarted ( _ref ) {
var originalEvent = _ref . originalEvent ;
if ( this . sortable . nativeDraggable ) {
on ( document , 'dragover' , this . _handleAutoScroll ) ;
} else {
if ( this . options . supportPointer ) {
on ( document , 'pointermove' , this . _handleFallbackAutoScroll ) ;
} else if ( originalEvent . touches ) {
on ( document , 'touchmove' , this . _handleFallbackAutoScroll ) ;
} else {
on ( document , 'mousemove' , this . _handleFallbackAutoScroll ) ;
}
}
} ,
dragOverCompleted : function dragOverCompleted ( _ref2 ) {
var originalEvent = _ref2 . originalEvent ; // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
if ( ! this . options . dragOverBubble && ! originalEvent . rootEl ) {
this . _handleAutoScroll ( originalEvent ) ;
}
} ,
drop : function drop ( ) {
if ( this . sortable . nativeDraggable ) {
off ( document , 'dragover' , this . _handleAutoScroll ) ;
} else {
off ( document , 'pointermove' , this . _handleFallbackAutoScroll ) ;
off ( document , 'touchmove' , this . _handleFallbackAutoScroll ) ;
off ( document , 'mousemove' , this . _handleFallbackAutoScroll ) ;
}
clearPointerElemChangedInterval ( ) ;
clearAutoScrolls ( ) ;
cancelThrottle ( ) ;
} ,
nulling : function nulling ( ) {
touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null ;
autoScrolls . length = 0 ;
} ,
_handleFallbackAutoScroll : function _handleFallbackAutoScroll ( evt ) {
this . _handleAutoScroll ( evt , true ) ;
} ,
_handleAutoScroll : function _handleAutoScroll ( evt , fallback ) {
var _this = this ;
var x = ( evt . touches ? evt . touches [ 0 ] : evt ) . clientX ,
y = ( evt . touches ? evt . touches [ 0 ] : evt ) . clientY ,
elem = document . elementFromPoint ( x , y ) ;
touchEvt$1 = evt ; // IE does not seem to have native autoscroll,
// Edge's autoscroll seems too conditional,
// MACOS Safari does not have autoscroll,
// Firefox and Chrome are good
if ( fallback || Edge || IE11OrLess || Safari ) {
autoScroll ( evt , this . options , elem , fallback ) ; // Listener for pointer element change
var ogElemScroller = getParentAutoScrollElement ( elem , true ) ;
if ( scrolling && ( ! pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY ) ) {
pointerElemChangedInterval && clearPointerElemChangedInterval ( ) ; // Detect for pointer elem change, emulating native DnD behaviour
pointerElemChangedInterval = setInterval ( function ( ) {
var newElem = getParentAutoScrollElement ( document . elementFromPoint ( x , y ) , true ) ;
if ( newElem !== ogElemScroller ) {
ogElemScroller = newElem ;
clearAutoScrolls ( ) ;
}
autoScroll ( evt , _this . options , newElem , fallback ) ;
} , 10 ) ;
lastAutoScrollX = x ;
lastAutoScrollY = y ;
}
} else {
// if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
if ( ! this . options . bubbleScroll || getParentAutoScrollElement ( elem , true ) === getWindowScrollingElement ( ) ) {
clearAutoScrolls ( ) ;
return ;
}
autoScroll ( evt , this . options , getParentAutoScrollElement ( elem , false ) , false ) ;
}
}
} ;
return _extends ( AutoScroll , {
pluginName : 'scroll' ,
initializeByDefault : true
} ) ;
}
function clearAutoScrolls ( ) {
autoScrolls . forEach ( function ( autoScroll ) {
clearInterval ( autoScroll . pid ) ;
} ) ;
autoScrolls = [ ] ;
}
function clearPointerElemChangedInterval ( ) {
clearInterval ( pointerElemChangedInterval ) ;
}
var autoScroll = throttle ( function ( evt , options , rootEl , isFallback ) {
// Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
if ( ! options . scroll ) return ;
var x = ( evt . touches ? evt . touches [ 0 ] : evt ) . clientX ,
y = ( evt . touches ? evt . touches [ 0 ] : evt ) . clientY ,
sens = options . scrollSensitivity ,
speed = options . scrollSpeed ,
winScroller = getWindowScrollingElement ( ) ;
var scrollThisInstance = false ,
scrollCustomFn ; // New scroll root, set scrollEl
if ( scrollRootEl !== rootEl ) {
scrollRootEl = rootEl ;
clearAutoScrolls ( ) ;
scrollEl = options . scroll ;
scrollCustomFn = options . scrollFn ;
if ( scrollEl === true ) {
scrollEl = getParentAutoScrollElement ( rootEl , true ) ;
}
}
var layersOut = 0 ;
var currentParent = scrollEl ;
do {
var el = currentParent ,
rect = getRect ( el ) ,
top = rect . top ,
bottom = rect . bottom ,
left = rect . left ,
right = rect . right ,
width = rect . width ,
height = rect . height ,
canScrollX = void 0 ,
canScrollY = void 0 ,
scrollWidth = el . scrollWidth ,
scrollHeight = el . scrollHeight ,
elCSS = css ( el ) ,
scrollPosX = el . scrollLeft ,
scrollPosY = el . scrollTop ;
if ( el === winScroller ) {
canScrollX = width < scrollWidth && ( elCSS . overflowX === 'auto' || elCSS . overflowX === 'scroll' || elCSS . overflowX === 'visible' ) ;
canScrollY = height < scrollHeight && ( elCSS . overflowY === 'auto' || elCSS . overflowY === 'scroll' || elCSS . overflowY === 'visible' ) ;
} else {
canScrollX = width < scrollWidth && ( elCSS . overflowX === 'auto' || elCSS . overflowX === 'scroll' ) ;
canScrollY = height < scrollHeight && ( elCSS . overflowY === 'auto' || elCSS . overflowY === 'scroll' ) ;
}
var vx = canScrollX && ( Math . abs ( right - x ) <= sens && scrollPosX + width < scrollWidth ) - ( Math . abs ( left - x ) <= sens && ! ! scrollPosX ) ;
var vy = canScrollY && ( Math . abs ( bottom - y ) <= sens && scrollPosY + height < scrollHeight ) - ( Math . abs ( top - y ) <= sens && ! ! scrollPosY ) ;
if ( ! autoScrolls [ layersOut ] ) {
for ( var i = 0 ; i <= layersOut ; i ++ ) {
if ( ! autoScrolls [ i ] ) {
autoScrolls [ i ] = { } ;
}
}
}
if ( autoScrolls [ layersOut ] . vx != vx || autoScrolls [ layersOut ] . vy != vy || autoScrolls [ layersOut ] . el !== el ) {
autoScrolls [ layersOut ] . el = el ;
autoScrolls [ layersOut ] . vx = vx ;
autoScrolls [ layersOut ] . vy = vy ;
clearInterval ( autoScrolls [ layersOut ] . pid ) ;
if ( vx != 0 || vy != 0 ) {
scrollThisInstance = true ;
/* jshint loopfunc:true */
autoScrolls [ layersOut ] . pid = setInterval ( function ( ) {
// emulate drag over during autoscroll (fallback), emulating native DnD behaviour
if ( isFallback && this . layer === 0 ) {
Sortable . active . _onTouchMove ( touchEvt$1 ) ; // To move ghost if it is positioned absolutely
}
var scrollOffsetY = autoScrolls [ this . layer ] . vy ? autoScrolls [ this . layer ] . vy * speed : 0 ;
var scrollOffsetX = autoScrolls [ this . layer ] . vx ? autoScrolls [ this . layer ] . vx * speed : 0 ;
if ( typeof scrollCustomFn === 'function' ) {
if ( scrollCustomFn . call ( Sortable . dragged . parentNode [ expando ] , scrollOffsetX , scrollOffsetY , evt , touchEvt$1 , autoScrolls [ this . layer ] . el ) !== 'continue' ) {
return ;
}
}
scrollBy ( autoScrolls [ this . layer ] . el , scrollOffsetX , scrollOffsetY ) ;
} . bind ( {
layer : layersOut
} ) , 24 ) ;
}
}
layersOut ++ ;
} while ( options . bubbleScroll && currentParent !== winScroller && ( currentParent = getParentAutoScrollElement ( currentParent , false ) ) ) ;
scrolling = scrollThisInstance ; // in case another function catches scrolling as false in between when it is not
} , 30 ) ;
var drop = function drop ( _ref ) {
var originalEvent = _ref . originalEvent ,
putSortable = _ref . putSortable ,
dragEl = _ref . dragEl ,
activeSortable = _ref . activeSortable ,
dispatchSortableEvent = _ref . dispatchSortableEvent ,
hideGhostForTarget = _ref . hideGhostForTarget ,
unhideGhostForTarget = _ref . unhideGhostForTarget ;
if ( ! originalEvent ) return ;
var toSortable = putSortable || activeSortable ;
hideGhostForTarget ( ) ;
var touch = originalEvent . changedTouches && originalEvent . changedTouches . length ? originalEvent . changedTouches [ 0 ] : originalEvent ;
var target = document . elementFromPoint ( touch . clientX , touch . clientY ) ;
unhideGhostForTarget ( ) ;
if ( toSortable && ! toSortable . el . contains ( target ) ) {
dispatchSortableEvent ( 'spill' ) ;
this . onSpill ( {
dragEl : dragEl ,
putSortable : putSortable
} ) ;
}
} ;
function Revert ( ) { }
Revert . prototype = {
startIndex : null ,
dragStart : function dragStart ( _ref2 ) {
var oldDraggableIndex = _ref2 . oldDraggableIndex ;
this . startIndex = oldDraggableIndex ;
} ,
onSpill : function onSpill ( _ref3 ) {
var dragEl = _ref3 . dragEl ,
putSortable = _ref3 . putSortable ;
this . sortable . captureAnimationState ( ) ;
if ( putSortable ) {
putSortable . captureAnimationState ( ) ;
}
var nextSibling = getChild ( this . sortable . el , this . startIndex , this . options ) ;
if ( nextSibling ) {
this . sortable . el . insertBefore ( dragEl , nextSibling ) ;
} else {
this . sortable . el . appendChild ( dragEl ) ;
}
this . sortable . animateAll ( ) ;
if ( putSortable ) {
putSortable . animateAll ( ) ;
}
} ,
drop : drop
} ;
_extends ( Revert , {
pluginName : 'revertOnSpill'
} ) ;
function Remove ( ) { }
Remove . prototype = {
onSpill : function onSpill ( _ref4 ) {
var dragEl = _ref4 . dragEl ,
putSortable = _ref4 . putSortable ;
var parentSortable = putSortable || this . sortable ;
parentSortable . captureAnimationState ( ) ;
dragEl . parentNode && dragEl . parentNode . removeChild ( dragEl ) ;
parentSortable . animateAll ( ) ;
} ,
drop : drop
} ;
_extends ( Remove , {
pluginName : 'removeOnSpill'
} ) ;
var lastSwapEl ;
function SwapPlugin ( ) {
function Swap ( ) {
this . defaults = {
swapClass : 'sortable-swap-highlight'
} ;
}
Swap . prototype = {
dragStart : function dragStart ( _ref ) {
var dragEl = _ref . dragEl ;
lastSwapEl = dragEl ;
} ,
dragOverValid : function dragOverValid ( _ref2 ) {
var completed = _ref2 . completed ,
target = _ref2 . target ,
onMove = _ref2 . onMove ,
activeSortable = _ref2 . activeSortable ,
changed = _ref2 . changed ,
cancel = _ref2 . cancel ;
if ( ! activeSortable . options . swap ) return ;
var el = this . sortable . el ,
options = this . options ;
if ( target && target !== el ) {
var prevSwapEl = lastSwapEl ;
if ( onMove ( target ) !== false ) {
toggleClass ( target , options . swapClass , true ) ;
lastSwapEl = target ;
} else {
lastSwapEl = null ;
}
if ( prevSwapEl && prevSwapEl !== lastSwapEl ) {
toggleClass ( prevSwapEl , options . swapClass , false ) ;
}
}
changed ( ) ;
completed ( true ) ;
cancel ( ) ;
} ,
drop : function drop ( _ref3 ) {
var activeSortable = _ref3 . activeSortable ,
putSortable = _ref3 . putSortable ,
dragEl = _ref3 . dragEl ;
var toSortable = putSortable || this . sortable ;
var options = this . options ;
lastSwapEl && toggleClass ( lastSwapEl , options . swapClass , false ) ;
if ( lastSwapEl && ( options . swap || putSortable && putSortable . options . swap ) ) {
if ( dragEl !== lastSwapEl ) {
toSortable . captureAnimationState ( ) ;
if ( toSortable !== activeSortable ) activeSortable . captureAnimationState ( ) ;
swapNodes ( dragEl , lastSwapEl ) ;
toSortable . animateAll ( ) ;
if ( toSortable !== activeSortable ) activeSortable . animateAll ( ) ;
}
}
} ,
nulling : function nulling ( ) {
lastSwapEl = null ;
}
} ;
return _extends ( Swap , {
pluginName : 'swap' ,
eventProperties : function eventProperties ( ) {
return {
swapItem : lastSwapEl
} ;
}
} ) ;
}
function swapNodes ( n1 , n2 ) {
var p1 = n1 . parentNode ,
p2 = n2 . parentNode ,
i1 ,
i2 ;
if ( ! p1 || ! p2 || p1 . isEqualNode ( n2 ) || p2 . isEqualNode ( n1 ) ) return ;
i1 = index ( n1 ) ;
i2 = index ( n2 ) ;
if ( p1 . isEqualNode ( p2 ) && i1 < i2 ) {
i2 ++ ;
}
p1 . insertBefore ( n2 , p1 . children [ i1 ] ) ;
p2 . insertBefore ( n1 , p2 . children [ i2 ] ) ;
}
var multiDragElements = [ ] ,
multiDragClones = [ ] ,
lastMultiDragSelect ,
// for selection with modifier key down (SHIFT)
multiDragSortable ,
initialFolding = false ,
// Initial multi-drag fold when drag started
folding = false ,
// Folding any other time
dragStarted = false ,
dragEl$1 ,
clonesFromRect ,
clonesHidden ;
function MultiDragPlugin ( ) {
function MultiDrag ( sortable ) {
// Bind all private methods
for ( var fn in this ) {
if ( fn . charAt ( 0 ) === '_' && typeof this [ fn ] === 'function' ) {
this [ fn ] = this [ fn ] . bind ( this ) ;
}
}
if ( sortable . options . supportPointer ) {
on ( document , 'pointerup' , this . _deselectMultiDrag ) ;
} else {
on ( document , 'mouseup' , this . _deselectMultiDrag ) ;
on ( document , 'touchend' , this . _deselectMultiDrag ) ;
}
on ( document , 'keydown' , this . _checkKeyDown ) ;
on ( document , 'keyup' , this . _checkKeyUp ) ;
this . defaults = {
selectedClass : 'sortable-selected' ,
multiDragKey : null ,
setData : function setData ( dataTransfer , dragEl ) {
var data = '' ;
if ( multiDragElements . length && multiDragSortable === sortable ) {
multiDragElements . forEach ( function ( multiDragElement , i ) {
data += ( ! i ? '' : ', ' ) + multiDragElement . textContent ;
} ) ;
} else {
data = dragEl . textContent ;
}
dataTransfer . setData ( 'Text' , data ) ;
}
} ;
}
MultiDrag . prototype = {
multiDragKeyDown : false ,
isMultiDrag : false ,
delayStartGlobal : function delayStartGlobal ( _ref ) {
var dragged = _ref . dragEl ;
dragEl$1 = dragged ;
} ,
delayEnded : function delayEnded ( ) {
this . isMultiDrag = ~ multiDragElements . indexOf ( dragEl$1 ) ;
} ,
setupClone : function setupClone ( _ref2 ) {
var sortable = _ref2 . sortable ,
cancel = _ref2 . cancel ;
if ( ! this . isMultiDrag ) return ;
for ( var i = 0 ; i < multiDragElements . length ; i ++ ) {
multiDragClones . push ( clone ( multiDragElements [ i ] ) ) ;
multiDragClones [ i ] . sortableIndex = multiDragElements [ i ] . sortableIndex ;
multiDragClones [ i ] . draggable = false ;
multiDragClones [ i ] . style [ 'will-change' ] = '' ;
toggleClass ( multiDragClones [ i ] , this . options . selectedClass , false ) ;
multiDragElements [ i ] === dragEl$1 && toggleClass ( multiDragClones [ i ] , this . options . chosenClass , false ) ;
}
sortable . _hideClone ( ) ;
cancel ( ) ;
} ,
clone : function clone ( _ref3 ) {
var sortable = _ref3 . sortable ,
rootEl = _ref3 . rootEl ,
dispatchSortableEvent = _ref3 . dispatchSortableEvent ,
cancel = _ref3 . cancel ;
if ( ! this . isMultiDrag ) return ;
if ( ! this . options . removeCloneOnHide ) {
if ( multiDragElements . length && multiDragSortable === sortable ) {
insertMultiDragClones ( true , rootEl ) ;
dispatchSortableEvent ( 'clone' ) ;
cancel ( ) ;
}
}
} ,
showClone : function showClone ( _ref4 ) {
var cloneNowShown = _ref4 . cloneNowShown ,
rootEl = _ref4 . rootEl ,
cancel = _ref4 . cancel ;
if ( ! this . isMultiDrag ) return ;
insertMultiDragClones ( false , rootEl ) ;
multiDragClones . forEach ( function ( clone ) {
css ( clone , 'display' , '' ) ;
} ) ;
cloneNowShown ( ) ;
clonesHidden = false ;
cancel ( ) ;
} ,
hideClone : function hideClone ( _ref5 ) {
var _this = this ;
var sortable = _ref5 . sortable ,
cloneNowHidden = _ref5 . cloneNowHidden ,
cancel = _ref5 . cancel ;
if ( ! this . isMultiDrag ) return ;
multiDragClones . forEach ( function ( clone ) {
css ( clone , 'display' , 'none' ) ;
if ( _this . options . removeCloneOnHide && clone . parentNode ) {
clone . parentNode . removeChild ( clone ) ;
}
} ) ;
cloneNowHidden ( ) ;
clonesHidden = true ;
cancel ( ) ;
} ,
dragStartGlobal : function dragStartGlobal ( _ref6 ) {
var sortable = _ref6 . sortable ;
if ( ! this . isMultiDrag && multiDragSortable ) {
multiDragSortable . multiDrag . _deselectMultiDrag ( ) ;
}
multiDragElements . forEach ( function ( multiDragElement ) {
multiDragElement . sortableIndex = index ( multiDragElement ) ;
} ) ; // Sort multi-drag elements
multiDragElements = multiDragElements . sort ( function ( a , b ) {
return a . sortableIndex - b . sortableIndex ;
} ) ;
dragStarted = true ;
} ,
dragStarted : function dragStarted ( _ref7 ) {
var _this2 = this ;
var sortable = _ref7 . sortable ;
if ( ! this . isMultiDrag ) return ;
if ( this . options . sort ) {
// Capture rects,
// hide multi drag elements (by positioning them absolute),
// set multi drag elements rects to dragRect,
// show multi drag elements,
// animate to rects,
// unset rects & remove from DOM
sortable . captureAnimationState ( ) ;
if ( this . options . animation ) {
multiDragElements . forEach ( function ( multiDragElement ) {
if ( multiDragElement === dragEl$1 ) return ;
css ( multiDragElement , 'position' , 'absolute' ) ;
} ) ;
var dragRect = getRect ( dragEl$1 , false , true , true ) ;
multiDragElements . forEach ( function ( multiDragElement ) {
if ( multiDragElement === dragEl$1 ) return ;
setRect ( multiDragElement , dragRect ) ;
} ) ;
folding = true ;
initialFolding = true ;
}
}
sortable . animateAll ( function ( ) {
folding = false ;
initialFolding = false ;
if ( _this2 . options . animation ) {
multiDragElements . forEach ( function ( multiDragElement ) {
unsetRect ( multiDragElement ) ;
} ) ;
} // Remove all auxiliary multidrag items from el, if sorting enabled
if ( _this2 . options . sort ) {
removeMultiDragElements ( ) ;
}
} ) ;
} ,
dragOver : function dragOver ( _ref8 ) {
var target = _ref8 . target ,
completed = _ref8 . completed ,
cancel = _ref8 . cancel ;
if ( folding && ~ multiDragElements . indexOf ( target ) ) {
completed ( false ) ;
cancel ( ) ;
}
} ,
revert : function revert ( _ref9 ) {
var fromSortable = _ref9 . fromSortable ,
rootEl = _ref9 . rootEl ,
sortable = _ref9 . sortable ,
dragRect = _ref9 . dragRect ;
if ( multiDragElements . length > 1 ) {
// Setup unfold animation
multiDragElements . forEach ( function ( multiDragElement ) {
sortable . addAnimationState ( {
target : multiDragElement ,
rect : folding ? getRect ( multiDragElement ) : dragRect
} ) ;
unsetRect ( multiDragElement ) ;
multiDragElement . fromRect = dragRect ;
fromSortable . removeAnimationState ( multiDragElement ) ;
} ) ;
folding = false ;
insertMultiDragElements ( ! this . options . removeCloneOnHide , rootEl ) ;
}
} ,
dragOverCompleted : function dragOverCompleted ( _ref10 ) {
var sortable = _ref10 . sortable ,
isOwner = _ref10 . isOwner ,
insertion = _ref10 . insertion ,
activeSortable = _ref10 . activeSortable ,
parentEl = _ref10 . parentEl ,
putSortable = _ref10 . putSortable ;
var options = this . options ;
if ( insertion ) {
// Clones must be hidden before folding animation to capture dragRectAbsolute properly
if ( isOwner ) {
activeSortable . _hideClone ( ) ;
}
initialFolding = false ; // If leaving sort:false root, or already folding - Fold to new location
if ( options . animation && multiDragElements . length > 1 && ( folding || ! isOwner && ! activeSortable . options . sort && ! putSortable ) ) {
// Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible
var dragRectAbsolute = getRect ( dragEl$1 , false , true , true ) ;
multiDragElements . forEach ( function ( multiDragElement ) {
if ( multiDragElement === dragEl$1 ) return ;
setRect ( multiDragElement , dragRectAbsolute ) ; // Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted
// while folding, and so that we can capture them again because old sortable will no longer be fromSortable
parentEl . appendChild ( multiDragElement ) ;
} ) ;
folding = true ;
} // Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out
if ( ! isOwner ) {
// Only remove if not folding (folding will remove them anyways)
if ( ! folding ) {
removeMultiDragElements ( ) ;
}
if ( multiDragElements . length > 1 ) {
var clonesHiddenBefore = clonesHidden ;
activeSortable . _showClone ( sortable ) ; // Unfold animation for clones if showing from hidden
if ( activeSortable . options . animation && ! clonesHidden && clonesHiddenBefore ) {
multiDragClones . forEach ( function ( clone ) {
activeSortable . addAnimationState ( {
target : clone ,
rect : clonesFromRect
} ) ;
clone . fromRect = clonesFromRect ;
clone . thisAnimationDuration = null ;
} ) ;
}
} else {
activeSortable . _showClone ( sortable ) ;
}
}
}
} ,
dragOverAnimationCapture : function dragOverAnimationCapture ( _ref11 ) {
var dragRect = _ref11 . dragRect ,
isOwner = _ref11 . isOwner ,
activeSortable = _ref11 . activeSortable ;
multiDragElements . forEach ( function ( multiDragElement ) {
multiDragElement . thisAnimationDuration = null ;
} ) ;
if ( activeSortable . options . animation && ! isOwner && activeSortable . multiDrag . isMultiDrag ) {
clonesFromRect = _extends ( { } , dragRect ) ;
var dragMatrix = matrix ( dragEl$1 , true ) ;
clonesFromRect . top -= dragMatrix . f ;
clonesFromRect . left -= dragMatrix . e ;
}
} ,
dragOverAnimationComplete : function dragOverAnimationComplete ( ) {
if ( folding ) {
folding = false ;
removeMultiDragElements ( ) ;
}
} ,
drop : function drop ( _ref12 ) {
var evt = _ref12 . originalEvent ,
rootEl = _ref12 . rootEl ,
parentEl = _ref12 . parentEl ,
sortable = _ref12 . sortable ,
dispatchSortableEvent = _ref12 . dispatchSortableEvent ,
oldIndex = _ref12 . oldIndex ,
putSortable = _ref12 . putSortable ;
var toSortable = putSortable || this . sortable ;
if ( ! evt ) return ;
var options = this . options ,
children = parentEl . children ; // Multi-drag selection
if ( ! dragStarted ) {
if ( options . multiDragKey && ! this . multiDragKeyDown ) {
this . _deselectMultiDrag ( ) ;
}
toggleClass ( dragEl$1 , options . selectedClass , ! ~ multiDragElements . indexOf ( dragEl$1 ) ) ;
if ( ! ~ multiDragElements . indexOf ( dragEl$1 ) ) {
multiDragElements . push ( dragEl$1 ) ;
dispatchEvent ( {
sortable : sortable ,
rootEl : rootEl ,
name : 'select' ,
targetEl : dragEl$1 ,
originalEvt : evt
} ) ; // Modifier activated, select from last to dragEl
if ( evt . shiftKey && lastMultiDragSelect && sortable . el . contains ( lastMultiDragSelect ) ) {
var lastIndex = index ( lastMultiDragSelect ) ,
currentIndex = index ( dragEl$1 ) ;
if ( ~ lastIndex && ~ currentIndex && lastIndex !== currentIndex ) {
// Must include lastMultiDragSelect (select it), in case modified selection from no selection
// (but previous selection existed)
var n , i ;
if ( currentIndex > lastIndex ) {
i = lastIndex ;
n = currentIndex ;
} else {
i = currentIndex ;
n = lastIndex + 1 ;
}
for ( ; i < n ; i ++ ) {
if ( ~ multiDragElements . indexOf ( children [ i ] ) ) continue ;
toggleClass ( children [ i ] , options . selectedClass , true ) ;
multiDragElements . push ( children [ i ] ) ;
dispatchEvent ( {
sortable : sortable ,
rootEl : rootEl ,
name : 'select' ,
targetEl : children [ i ] ,
originalEvt : evt
} ) ;
}
}
} else {
lastMultiDragSelect = dragEl$1 ;
}
multiDragSortable = toSortable ;
} else {
multiDragElements . splice ( multiDragElements . indexOf ( dragEl$1 ) , 1 ) ;
lastMultiDragSelect = null ;
dispatchEvent ( {
sortable : sortable ,
rootEl : rootEl ,
name : 'deselect' ,
targetEl : dragEl$1 ,
originalEvt : evt
} ) ;
}
} // Multi-drag drop
if ( dragStarted && this . isMultiDrag ) {
// Do not "unfold" after around dragEl if reverted
if ( ( parentEl [ expando ] . options . sort || parentEl !== rootEl ) && multiDragElements . length > 1 ) {
var dragRect = getRect ( dragEl$1 ) ,
multiDragIndex = index ( dragEl$1 , ':not(.' + this . options . selectedClass + ')' ) ;
if ( ! initialFolding && options . animation ) dragEl$1 . thisAnimationDuration = null ;
toSortable . captureAnimationState ( ) ;
if ( ! initialFolding ) {
if ( options . animation ) {
dragEl$1 . fromRect = dragRect ;
multiDragElements . forEach ( function ( multiDragElement ) {
multiDragElement . thisAnimationDuration = null ;
if ( multiDragElement !== dragEl$1 ) {
var rect = folding ? getRect ( multiDragElement ) : dragRect ;
multiDragElement . fromRect = rect ; // Prepare unfold animation
toSortable . addAnimationState ( {
target : multiDragElement ,
rect : rect
} ) ;
}
} ) ;
} // Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert
// properly they must all be removed
removeMultiDragElements ( ) ;
multiDragElements . forEach ( function ( multiDragElement ) {
if ( children [ multiDragIndex ] ) {
parentEl . insertBefore ( multiDragElement , children [ multiDragIndex ] ) ;
} else {
parentEl . appendChild ( multiDragElement ) ;
}
multiDragIndex ++ ;
} ) ; // If initial folding is done, the elements may have changed position because they are now
// unfolding around dragEl, even though dragEl may not have his index changed, so update event
// must be fired here as Sortable will not.
if ( oldIndex === index ( dragEl$1 ) ) {
var update = false ;
multiDragElements . forEach ( function ( multiDragElement ) {
if ( multiDragElement . sortableIndex !== index ( multiDragElement ) ) {
update = true ;
return ;
}
} ) ;
if ( update ) {
dispatchSortableEvent ( 'update' ) ;
}
}
} // Must be done after capturing individual rects (scroll bar)
multiDragElements . forEach ( function ( multiDragElement ) {
unsetRect ( multiDragElement ) ;
} ) ;
toSortable . animateAll ( ) ;
}
multiDragSortable = toSortable ;
} // Remove clones if necessary
if ( rootEl === parentEl || putSortable && putSortable . lastPutMode !== 'clone' ) {
multiDragClones . forEach ( function ( clone ) {
clone . parentNode && clone . parentNode . removeChild ( clone ) ;
} ) ;
}
} ,
nullingGlobal : function nullingGlobal ( ) {
this . isMultiDrag = dragStarted = false ;
multiDragClones . length = 0 ;
} ,
destroyGlobal : function destroyGlobal ( ) {
this . _deselectMultiDrag ( ) ;
off ( document , 'pointerup' , this . _deselectMultiDrag ) ;
off ( document , 'mouseup' , this . _deselectMultiDrag ) ;
off ( document , 'touchend' , this . _deselectMultiDrag ) ;
off ( document , 'keydown' , this . _checkKeyDown ) ;
off ( document , 'keyup' , this . _checkKeyUp ) ;
} ,
_deselectMultiDrag : function _deselectMultiDrag ( evt ) {
if ( typeof dragStarted !== "undefined" && dragStarted ) return ; // Only deselect if selection is in this sortable
if ( multiDragSortable !== this . sortable ) return ; // Only deselect if target is not item in this sortable
if ( evt && closest ( evt . target , this . options . draggable , this . sortable . el , false ) ) return ; // Only deselect if left click
if ( evt && evt . button !== 0 ) return ;
while ( multiDragElements . length ) {
var el = multiDragElements [ 0 ] ;
toggleClass ( el , this . options . selectedClass , false ) ;
multiDragElements . shift ( ) ;
dispatchEvent ( {
sortable : this . sortable ,
rootEl : this . sortable . el ,
name : 'deselect' ,
targetEl : el ,
originalEvt : evt
} ) ;
}
} ,
_checkKeyDown : function _checkKeyDown ( evt ) {
if ( evt . key === this . options . multiDragKey ) {
this . multiDragKeyDown = true ;
}
} ,
_checkKeyUp : function _checkKeyUp ( evt ) {
if ( evt . key === this . options . multiDragKey ) {
this . multiDragKeyDown = false ;
}
}
} ;
return _extends ( MultiDrag , {
// Static methods & properties
pluginName : 'multiDrag' ,
utils : {
/ * *
* Selects the provided multi - drag item
* @ param { HTMLElement } el The element to be selected
* /
select : function select ( el ) {
var sortable = el . parentNode [ expando ] ;
if ( ! sortable || ! sortable . options . multiDrag || ~ multiDragElements . indexOf ( el ) ) return ;
if ( multiDragSortable && multiDragSortable !== sortable ) {
multiDragSortable . multiDrag . _deselectMultiDrag ( ) ;
multiDragSortable = sortable ;
}
toggleClass ( el , sortable . options . selectedClass , true ) ;
multiDragElements . push ( el ) ;
} ,
/ * *
* Deselects the provided multi - drag item
* @ param { HTMLElement } el The element to be deselected
* /
deselect : function deselect ( el ) {
var sortable = el . parentNode [ expando ] ,
index = multiDragElements . indexOf ( el ) ;
if ( ! sortable || ! sortable . options . multiDrag || ! ~ index ) return ;
toggleClass ( el , sortable . options . selectedClass , false ) ;
multiDragElements . splice ( index , 1 ) ;
}
} ,
eventProperties : function eventProperties ( ) {
var _this3 = this ;
var oldIndicies = [ ] ,
newIndicies = [ ] ;
multiDragElements . forEach ( function ( multiDragElement ) {
oldIndicies . push ( {
multiDragElement : multiDragElement ,
index : multiDragElement . sortableIndex
} ) ; // multiDragElements will already be sorted if folding
var newIndex ;
if ( folding && multiDragElement !== dragEl$1 ) {
newIndex = - 1 ;
} else if ( folding ) {
newIndex = index ( multiDragElement , ':not(.' + _this3 . options . selectedClass + ')' ) ;
} else {
newIndex = index ( multiDragElement ) ;
}
newIndicies . push ( {
multiDragElement : multiDragElement ,
index : newIndex
} ) ;
} ) ;
return {
items : _toConsumableArray ( multiDragElements ) ,
clones : [ ] . concat ( multiDragClones ) ,
oldIndicies : oldIndicies ,
newIndicies : newIndicies
} ;
} ,
optionListeners : {
multiDragKey : function multiDragKey ( key ) {
key = key . toLowerCase ( ) ;
if ( key === 'ctrl' ) {
key = 'Control' ;
} else if ( key . length > 1 ) {
key = key . charAt ( 0 ) . toUpperCase ( ) + key . substr ( 1 ) ;
}
return key ;
}
}
} ) ;
}
function insertMultiDragElements ( clonesInserted , rootEl ) {
multiDragElements . forEach ( function ( multiDragElement , i ) {
var target = rootEl . children [ multiDragElement . sortableIndex + ( clonesInserted ? Number ( i ) : 0 ) ] ;
if ( target ) {
rootEl . insertBefore ( multiDragElement , target ) ;
} else {
rootEl . appendChild ( multiDragElement ) ;
}
} ) ;
}
/ * *
* Insert multi - drag clones
* @ param { [ Boolean ] } elementsInserted Whether the multi - drag elements are inserted
* @ param { HTMLElement } rootEl
* /
function insertMultiDragClones ( elementsInserted , rootEl ) {
multiDragClones . forEach ( function ( clone , i ) {
var target = rootEl . children [ clone . sortableIndex + ( elementsInserted ? Number ( i ) : 0 ) ] ;
if ( target ) {
rootEl . insertBefore ( clone , target ) ;
} else {
rootEl . appendChild ( clone ) ;
}
} ) ;
}
function removeMultiDragElements ( ) {
multiDragElements . forEach ( function ( multiDragElement ) {
if ( multiDragElement === dragEl$1 ) return ;
multiDragElement . parentNode && multiDragElement . parentNode . removeChild ( multiDragElement ) ;
} ) ;
}
Sortable . mount ( new AutoScrollPlugin ( ) ) ;
Sortable . mount ( Remove , Revert ) ;
var _default = Sortable ;
exports . default = _default ;
} , { } ] , "controllers/NavIndex.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _FipamoAdminAPI = _interopRequireDefault ( require ( "../../libraries/FipamoAdminAPI" ) ) ;
var _NavActions = _interopRequireDefault ( require ( "../actions/NavActions" ) ) ;
var DataEvent = _interopRequireWildcard ( require ( "../events/DataEvent" ) ) ;
var _Notifications = _interopRequireDefault ( require ( "../ui/Notifications" ) ) ;
var _sortablejs = _interopRequireDefault ( require ( "sortablejs" ) ) ;
function _getRequireWildcardCache ( ) { if ( typeof WeakMap !== "function" ) return null ; var cache = new WeakMap ( ) ; _getRequireWildcardCache = function ( ) { return cache ; } ; return cache ; }
function _interopRequireWildcard ( obj ) { if ( obj && obj . _ _esModule ) { return obj ; } if ( obj === null || typeof obj !== "object" && typeof obj !== "function" ) { return { default : obj } ; } var cache = _getRequireWildcardCache ( ) ; if ( cache && cache . has ( obj ) ) { return cache . get ( obj ) ; } var newObj = { } ; var hasPropertyDescriptor = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = hasPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : null ; if ( desc && ( desc . get || desc . set ) ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } newObj . default = obj ; if ( cache ) { cache . set ( obj , newObj ) ; } 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" ) ; } }
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 ; }
var notify = new _Notifications . default ( ) ;
var admin = new _FipamoAdminAPI . default ( ) ;
var NavIndex = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function NavIndex ( ) {
_classCallCheck ( this , NavIndex ) ;
this . start ( ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( NavIndex , [ {
key : "start" ,
value : function start ( ) {
var _this = this ;
_sortablejs . default . create ( document . getElementById ( 'nav-pages' ) , {
onUpdate : function onUpdate ( ) {
new _NavActions . default ( ) . syncMenu ( ) . then ( function ( data ) {
notify . alert ( 'Updating Menu' , null ) ;
admin . syncNav ( data ) . then ( function ( r ) {
if ( r . type == DataEvent . MENU _UPDATED ) {
notify . alert ( r . message , true ) ;
} else {
notify . alert ( r . message , true ) ;
}
} ) ;
} ) ;
}
} ) ;
var nav = document . querySelectorAll ( '.nav-btn' ) ;
for ( var i = 0 , length = nav . length ; i < length ; i ++ ) {
nav [ i ] . addEventListener ( 'click' , function ( e ) {
return _this . handleNavButton ( e ) ;
} , false ) ;
}
} //--------------------------
// event handlers
//--------------------------
} , {
key : "handleNavButton" ,
value : function handleNavButton ( e ) {
var id = '' ;
switch ( e . target . id ) {
case 'remove-item' :
id = e . target . getAttribute ( 'data-id' ) ;
new _NavActions . default ( ) . removeItem ( id ) ;
new _NavActions . default ( ) . syncMenu ( ) . then ( function ( data ) {
data . remove = e . target . getAttribute ( 'data-uuid' ) ;
notify . alert ( 'Editing Menu' , null ) ;
admin . syncNav ( data ) . then ( function ( r ) {
if ( r . type == DataEvent . MENU _UPDATED ) {
notify . alert ( r . message , true ) ;
} else {
notify . alert ( r . message , true ) ;
}
} ) ;
} ) ;
break ;
case 'edit-item' :
window . location = '/@/dashboard/page/edit/' + e . target . getAttribute ( 'data-id' ) ;
break ;
}
}
} ] ) ;
return NavIndex ;
} ( ) ;
exports . default = NavIndex ;
} , { "../../libraries/FipamoAdminAPI" : "../libraries/FipamoAdminAPI.js" , "../actions/NavActions" : "actions/NavActions.js" , "../events/DataEvent" : "events/DataEvent.js" , "../ui/Notifications" : "ui/Notifications.js" , "sortablejs" : "../../node_modules/sortablejs/modular/sortable.esm.js" } ] , "controllers/DashManager.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _PostIndex = _interopRequireDefault ( require ( "./PostIndex" ) ) ;
var _SettingsIndex = _interopRequireDefault ( require ( "./SettingsIndex" ) ) ;
var _NavIndex = _interopRequireDefault ( require ( "./NavIndex" ) ) ;
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" ) ; } }
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 ; }
var DashManager = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function DashManager ( ) {
_classCallCheck ( this , DashManager ) ;
this . currentDisplay = '' ;
this . urlPieces = document . URL . split ( '/' ) ;
this . chooseDisplay ( this . urlPieces [ 5 ] , this . urlPieces [ 6 ] ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( DashManager , [ {
key : "start" ,
value : function start ( ) { }
} , {
key : "chooseDisplay" ,
value : function chooseDisplay ( section , page ) {
this . currentDisplay = '' ;
switch ( section ) {
case 'page' :
this . currentDisplay = new _PostIndex . default ( page ) ;
break ;
case 'settings' :
this . currentDisplay = new _SettingsIndex . default ( ) ;
break ;
case 'navigation' :
this . currentDisplay = new _NavIndex . default ( ) ;
break ;
default :
//just chill
break ;
}
this . start ( ) ;
} //--------------------------
// event handlers
//--------------------------
} ] ) ;
return DashManager ;
} ( ) ;
exports . default = DashManager ;
} , { "./PostIndex" : "controllers/PostIndex.js" , "./SettingsIndex" : "controllers/SettingsIndex.js" , "./NavIndex" : "controllers/NavIndex.js" } ] , "Base.js" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _FipamoAPI = _interopRequireDefault ( require ( "../libraries/FipamoAPI" ) ) ;
var _FipamoAdminAPI = _interopRequireDefault ( require ( "../libraries/FipamoAdminAPI" ) ) ;
var _DataUtils = _interopRequireDefault ( require ( "./utils/DataUtils" ) ) ;
var DataEvent = _interopRequireWildcard ( require ( "./events/DataEvent" ) ) ;
var _DashManager = _interopRequireDefault ( require ( "./controllers/DashManager" ) ) ;
var _Notifications = _interopRequireDefault ( require ( "./ui/Notifications" ) ) ;
function _getRequireWildcardCache ( ) { if ( typeof WeakMap !== "function" ) return null ; var cache = new WeakMap ( ) ; _getRequireWildcardCache = function ( ) { return cache ; } ; return cache ; }
function _interopRequireWildcard ( obj ) { if ( obj && obj . _ _esModule ) { return obj ; } if ( obj === null || typeof obj !== "object" && typeof obj !== "function" ) { return { default : obj } ; } var cache = _getRequireWildcardCache ( ) ; if ( cache && cache . has ( obj ) ) { return cache . get ( obj ) ; } var newObj = { } ; var hasPropertyDescriptor = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = hasPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : null ; if ( desc && ( desc . get || desc . set ) ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } newObj . default = obj ; if ( cache ) { cache . set ( obj , newObj ) ; } 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" ) ; } }
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 ; }
var api = new _FipamoAPI . default ( ) ;
var admin = new _FipamoAdminAPI . default ( ) ;
var data = new _DataUtils . default ( ) ;
var notify = new _Notifications . default ( ) ;
var Base = /*#__PURE__*/ function ( ) {
//--------------------------
// constructor
//--------------------------
function Base ( ) {
_classCallCheck ( this , Base ) ;
this . start ( ) ;
} //--------------------------
// methods
//--------------------------
_createClass ( Base , [ {
key : "start" ,
value : function start ( ) {
var _this = this ;
if ( document . getElementById ( 'dash-form' ) || document . getElementById ( 'dash-init' ) ) {
var options = document . getElementsByClassName ( 'init-option' ) ;
for ( var index = 0 ; index < options . length ; index ++ ) {
options [ index ] . addEventListener ( 'click' , function ( e ) {
return _this . handleOptions ( e ) ;
} ) ;
}
if ( document . getElementById ( 'dash-form' ) ) {
document . getElementById ( 'login-btn' ) . addEventListener ( 'click' , function ( e ) {
return _this . handleLogin ( e ) ;
} ) ;
} else {
document . getElementById ( 'init-blog' ) . addEventListener ( 'click' , function ( e ) {
return _this . handleSetup ( e ) ;
} ) ;
document . getElementById ( 'blog-restore' ) . addEventListener ( 'click' , function ( e ) {
return _this . handleRestore ( e ) ;
} ) ;
}
} else {
new _DashManager . default ( ) ;
}
} //--------------------------
// event handlers
//--------------------------
} , {
key : "handleLogin" ,
value : function handleLogin ( e ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
var authForm = data . formDataToJSON ( document . getElementById ( 'login' ) ) ;
notify . alert ( 'Looking, hold up' , null ) ;
api . login ( authForm ) . then ( function ( response ) {
if ( response . type === DataEvent . REQUEST _LAME ) {
notify . alert ( response . message , false ) ;
} else {
notify . alert ( response . message , true ) ;
e . target . innerHTML = response . message ;
setTimeout ( function ( ) {
window . location = '/@/dashboard' ;
} , 500 ) ;
}
} ) . catch ( function ( err ) {
notify . alert ( err , false ) ;
} ) ;
}
} , {
key : "handleSetup" ,
value : function handleSetup ( e ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
var setUpForm = data . formDataToJSON ( document . getElementById ( 'init-form' ) ) ;
api . init ( setUpForm ) . then ( function ( response ) {
if ( response . type === DataEvent . API _INIT _LAME ) {
notify . alert ( response . message , false ) ;
} else {
notify . alert ( response . message , true ) ;
setTimeout ( function ( ) {
window . location = '/@/dashboard' ;
} , 700 ) ;
}
} ) . catch ( function ( err ) {
notify . alert ( err , false ) ;
} ) ;
}
} , {
key : "handleRestore" ,
value : function handleRestore ( e ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
var form = document . getElementById ( 'init-restore' ) ;
admin . handleInitRestore ( form ) . then ( function ( response ) {
if ( response . type === DataEvent . REQUEST _LAME ) {
notify . alert ( response . message , false ) ;
} else {
notify . alert ( response . message , true ) ;
setTimeout ( function ( ) { //window.location = '/@/dashboard';
} , 700 ) ;
}
} ) . catch ( function ( err ) {
notify . alert ( err , false ) ;
} ) ;
}
} , {
key : "handleOptions" ,
value : function handleOptions ( e ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
var init = document . getElementById ( 'dash-init' ) ;
var restore = document . getElementById ( 'dash-restore' ) ;
if ( e . target . id === 'init-switch-restore' ) {
init . style . display = 'none' ;
init . style . visibility = 'hidden' ;
restore . style . display = 'block' ;
restore . style . visibility = 'visible' ;
} else {
init . style . display = 'block' ;
init . style . visibility = 'visible' ;
restore . style . display = 'none' ;
restore . style . visibility = 'hidden' ;
}
}
} ] ) ;
return Base ;
} ( ) ;
exports . default = Base ;
} , { "../libraries/FipamoAPI" : "../libraries/FipamoAPI.js" , "../libraries/FipamoAdminAPI" : "../libraries/FipamoAdminAPI.js" , "./utils/DataUtils" : "utils/DataUtils.js" , "./events/DataEvent" : "events/DataEvent.js" , "./controllers/DashManager" : "controllers/DashManager.js" , "./ui/Notifications" : "ui/Notifications.js" } ] , "Start.js" : [ function ( require , module , exports ) {
"use strict" ;
var _Base = _interopRequireDefault ( require ( "./Base" ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
document . addEventListener ( 'DOMContentLoaded' , function ( ) {
new _Base . default ( ) ;
} , false ) ;
} , { "./Base" : "Base.js" } ] , "../../node_modules/parcel/src/builtins/hmr-runtime.js" : [ function ( require , module , exports ) {
var global = arguments [ 3 ] ;
var OVERLAY _ID = '__parcel__error__overlay__' ;
var OldModule = module . bundle . Module ;
function Module ( moduleName ) {
OldModule . call ( this , moduleName ) ;
this . hot = {
data : module . bundle . hotData ,
_acceptCallbacks : [ ] ,
_disposeCallbacks : [ ] ,
accept : function ( fn ) {
this . _acceptCallbacks . push ( fn || function ( ) { } ) ;
} ,
dispose : function ( fn ) {
this . _disposeCallbacks . push ( fn ) ;
}
} ;
module . bundle . hotData = null ;
}
module . bundle . Module = Module ;
var checkedAssets , assetsToAccept ;
var parent = module . bundle . parent ;
if ( ( ! parent || ! parent . isParcelRequire ) && typeof WebSocket !== 'undefined' ) {
var hostname = "" || location . hostname ;
var protocol = location . protocol === 'https:' ? 'wss' : 'ws' ;
var ws = new WebSocket ( protocol + '://' + hostname + ':' + "53859" + '/' ) ;
ws . onmessage = function ( event ) {
checkedAssets = { } ;
assetsToAccept = [ ] ;
var data = JSON . parse ( event . data ) ;
if ( data . type === 'update' ) {
var handled = false ;
data . assets . forEach ( function ( asset ) {
if ( ! asset . isNew ) {
var didAccept = hmrAcceptCheck ( global . parcelRequire , asset . id ) ;
if ( didAccept ) {
handled = true ;
}
}
} ) ; // Enable HMR for CSS by default.
handled = handled || data . assets . every ( function ( asset ) {
return asset . type === 'css' && asset . generated . js ;
} ) ;
if ( handled ) {
console . clear ( ) ;
data . assets . forEach ( function ( asset ) {
hmrApply ( global . parcelRequire , asset ) ;
} ) ;
assetsToAccept . forEach ( function ( v ) {
hmrAcceptRun ( v [ 0 ] , v [ 1 ] ) ;
} ) ;
} else if ( location . reload ) {
// `location` global exists in a web worker context but lacks `.reload()` function.
location . reload ( ) ;
}
}
if ( data . type === 'reload' ) {
ws . close ( ) ;
ws . onclose = function ( ) {
location . reload ( ) ;
} ;
}
if ( data . type === 'error-resolved' ) {
console . log ( '[parcel] ✨ Error resolved' ) ;
removeErrorOverlay ( ) ;
}
if ( data . type === 'error' ) {
console . error ( '[parcel] 🚨 ' + data . error . message + '\n' + data . error . stack ) ;
removeErrorOverlay ( ) ;
var overlay = createErrorOverlay ( data ) ;
document . body . appendChild ( overlay ) ;
}
} ;
}
function removeErrorOverlay ( ) {
var overlay = document . getElementById ( OVERLAY _ID ) ;
if ( overlay ) {
overlay . remove ( ) ;
}
}
function createErrorOverlay ( data ) {
var overlay = document . createElement ( 'div' ) ;
overlay . id = OVERLAY _ID ; // html encode message and stack trace
var message = document . createElement ( 'div' ) ;
var stackTrace = document . createElement ( 'pre' ) ;
message . innerText = data . error . message ;
stackTrace . innerText = data . error . stack ;
overlay . innerHTML = '<div style="background: black; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; opacity: 0.85; font-family: Menlo, Consolas, monospace; z-index: 9999;">' + '<span style="background: red; padding: 2px 4px; border-radius: 2px;">ERROR</span>' + '<span style="top: 2px; margin-left: 5px; position: relative;">🚨</span>' + '<div style="font-size: 18px; font-weight: bold; margin-top: 20px;">' + message . innerHTML + '</div>' + '<pre>' + stackTrace . innerHTML + '</pre>' + '</div>' ;
return overlay ;
}
function getParents ( bundle , id ) {
var modules = bundle . modules ;
if ( ! modules ) {
return [ ] ;
}
var parents = [ ] ;
var k , d , dep ;
for ( k in modules ) {
for ( d in modules [ k ] [ 1 ] ) {
dep = modules [ k ] [ 1 ] [ d ] ;
if ( dep === id || Array . isArray ( dep ) && dep [ dep . length - 1 ] === id ) {
parents . push ( k ) ;
}
}
}
if ( bundle . parent ) {
parents = parents . concat ( getParents ( bundle . parent , id ) ) ;
}
return parents ;
}
function hmrApply ( bundle , asset ) {
var modules = bundle . modules ;
if ( ! modules ) {
return ;
}
if ( modules [ asset . id ] || ! bundle . parent ) {
var fn = new Function ( 'require' , 'module' , 'exports' , asset . generated . js ) ;
asset . isNew = ! modules [ asset . id ] ;
modules [ asset . id ] = [ fn , asset . deps ] ;
} else if ( bundle . parent ) {
hmrApply ( bundle . parent , asset ) ;
}
}
function hmrAcceptCheck ( bundle , id ) {
var modules = bundle . modules ;
if ( ! modules ) {
return ;
}
if ( ! modules [ id ] && bundle . parent ) {
return hmrAcceptCheck ( bundle . parent , id ) ;
}
if ( checkedAssets [ id ] ) {
return ;
}
checkedAssets [ id ] = true ;
var cached = bundle . cache [ id ] ;
assetsToAccept . push ( [ bundle , id ] ) ;
if ( cached && cached . hot && cached . hot . _acceptCallbacks . length ) {
return true ;
}
return getParents ( global . parcelRequire , id ) . some ( function ( id ) {
return hmrAcceptCheck ( global . parcelRequire , id ) ;
} ) ;
}
function hmrAcceptRun ( bundle , id ) {
var cached = bundle . cache [ id ] ;
bundle . hotData = { } ;
if ( cached ) {
cached . hot . data = bundle . hotData ;
}
if ( cached && cached . hot && cached . hot . _disposeCallbacks . length ) {
cached . hot . _disposeCallbacks . forEach ( function ( cb ) {
cb ( bundle . hotData ) ;
} ) ;
}
delete bundle . cache [ id ] ;
bundle ( id ) ;
cached = bundle . cache [ id ] ;
if ( cached && cached . hot && cached . hot . _acceptCallbacks . length ) {
cached . hot . _acceptCallbacks . forEach ( function ( cb ) {
cb ( ) ;
} ) ;
return true ;
}
}
} , { } ] } , { } , [ "../../node_modules/parcel/src/builtins/hmr-runtime.js" , "Start.js" ] , null )
//# sourceMappingURL=/assets/scripts/dash.min.js.map