// 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
( function ( modules , entry , mainEntry , parcelRequireName , globalName ) {
/* eslint-disable no-undef */
var globalObject =
typeof globalThis !== 'undefined'
? globalThis
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global
: { } ;
/* eslint-enable no-undef */
// Save the require from previous bundle to this closure if any
var previousRequire =
typeof globalObject [ parcelRequireName ] === 'function' &&
globalObject [ parcelRequireName ] ;
var cache = previousRequire . cache || { } ;
// Do not use `require` to prevent Webpack from trying to bundle this call
var nodeRequire =
typeof module !== 'undefined' &&
typeof module . require === 'function' &&
module . require . bind ( module ) ;
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 globalObject [ parcelRequireName ] === 'function' &&
globalObject [ parcelRequireName ] ;
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 ;
} ,
{ } ,
] ;
} ;
Object . defineProperty ( newRequire , 'root' , {
get : function ( ) {
return globalObject [ parcelRequireName ] ;
} ,
} ) ;
globalObject [ parcelRequireName ] = newRequire ;
for ( var i = 0 ; i < entry . length ; i ++ ) {
newRequire ( entry [ i ] ) ;
}
if ( mainEntry ) {
// Expose entry point to Node, AMD or browser globals
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
var mainExports = newRequire ( mainEntry ) ;
// 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 ;
}
}
} ) ( { "jRsG2" : [ function ( require , module , exports ) {
var HMR _HOST = null ;
var HMR _PORT = 1234 ;
var HMR _SECURE = false ;
var HMR _ENV _HASH = "4a236f9275d0a351" ;
module . bundle . HMR _BUNDLE _ID = "770375bf412ba982" ;
"use strict" ;
function _createForOfIteratorHelper ( o , allowArrayLike ) {
var it ;
if ( typeof Symbol === "undefined" || o [ Symbol . iterator ] == null ) {
if ( Array . isArray ( o ) || ( it = _unsupportedIterableToArray ( o ) ) || allowArrayLike && o && typeof o . length === "number" ) {
if ( it ) o = it ;
var i = 0 ;
var F = function F ( ) {
} ;
return {
s : F ,
n : function n ( ) {
if ( i >= o . length ) return {
done : true
} ;
return {
done : false ,
value : o [ i ++ ]
} ;
} ,
e : function e ( _e ) {
throw _e ;
} ,
f : F
} ;
}
throw new TypeError ( "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ) ;
}
var normalCompletion = true , didErr = false , err ;
return {
s : function s ( ) {
it = o [ Symbol . iterator ] ( ) ;
} ,
n : function n ( ) {
var step = it . next ( ) ;
normalCompletion = step . done ;
return step ;
} ,
e : function e ( _e2 ) {
didErr = true ;
err = _e2 ;
} ,
f : function f ( ) {
try {
if ( ! normalCompletion && it . return != null ) it . return ( ) ;
} finally {
if ( didErr ) throw err ;
}
}
} ;
}
function _unsupportedIterableToArray ( o , minLen ) {
if ( ! o ) return ;
if ( typeof o === "string" ) return _arrayLikeToArray ( o , minLen ) ;
var n = Object . prototype . toString . call ( o ) . slice ( 8 , - 1 ) ;
if ( n === "Object" && o . constructor ) n = o . constructor . name ;
if ( n === "Map" || n === "Set" ) return Array . from ( o ) ;
if ( n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/ . test ( n ) ) return _arrayLikeToArray ( o , minLen ) ;
}
function _arrayLikeToArray ( arr , len ) {
if ( len == null || len > arr . length ) len = arr . length ;
for ( var i = 0 , arr2 = new Array ( len ) ; i < len ; i ++ ) arr2 [ i ] = arr [ i ] ;
return arr2 ;
}
/* global HMR_HOST, HMR_PORT, HMR_ENV_HASH, HMR_SECURE */ / * : :
import type {
HMRAsset ,
HMRMessage ,
} from '@parcel/reporter-dev-server/src/HMRServer.js' ;
interface ParcelRequire {
( string ) : mixed ;
cache : { | [ string ] : ParcelModule | } ;
hotData : mixed ;
Module : any ;
parent : ? ParcelRequire ;
isParcelRequire : true ;
modules : { | [ string ] : [ Function , { | [ string ] : string | } ] | } ;
HMR _BUNDLE _ID : string ;
root : ParcelRequire ;
}
interface ParcelModule {
hot : { |
data : mixed ,
accept ( cb : ( Function ) => void ) : void ,
dispose ( cb : ( mixed ) => void ) : void ,
// accept(deps: Array<string> | string, cb: (Function) => void): void,
// decline(): void,
_acceptCallbacks : Array < ( Function ) => void > ,
_disposeCallbacks : Array < ( mixed ) => void > ,
| } ;
}
declare var module : { bundle : ParcelRequire , ... } ;
declare var HMR _HOST : string ;
declare var HMR _PORT : string ;
declare var HMR _ENV _HASH : string ;
declare var HMR _SECURE : boolean ;
* / v a r O V E R L A Y _ I D = ' _ _ p a r c e l _ _ e r r o r _ _ o v e r l a y _ _ ' ;
var OldModule = module . bundle . Module ;
function Module ( moduleName ) {
OldModule . call ( this , moduleName ) ;
this . hot = {
data : module . bundle . hotData ,
_acceptCallbacks : [ ] ,
_disposeCallbacks : [ ] ,
accept : function accept ( fn ) {
this . _acceptCallbacks . push ( fn || function ( ) {
} ) ;
} ,
dispose : function dispose ( fn ) {
this . _disposeCallbacks . push ( fn ) ;
}
} ;
module . bundle . hotData = undefined ;
}
module . bundle . Module = Module ;
var checkedAssets , acceptedAssets , assetsToAccept ;
function getHostname ( ) {
return HMR _HOST || ( location . protocol . indexOf ( 'http' ) === 0 ? location . hostname : 'localhost' ) ;
}
function getPort ( ) {
return HMR _PORT || location . port ;
} // eslint-disable-next-line no-redeclare
var parent = module . bundle . parent ;
if ( ( ! parent || ! parent . isParcelRequire ) && typeof WebSocket !== 'undefined' ) {
var hostname = getHostname ( ) ;
var port = getPort ( ) ;
var protocol = HMR _SECURE || location . protocol == 'https:' && ! /localhost|127.0.0.1|0.0.0.0/ . test ( hostname ) ? 'wss' : 'ws' ;
var ws = new WebSocket ( protocol + '://' + hostname + ( port ? ':' + port : '' ) + '/' ) ; // $FlowFixMe
ws . onmessage = function ( event ) {
checkedAssets = {
} ;
acceptedAssets = {
} ;
assetsToAccept = [ ] ;
var data = JSON . parse ( event . data ) ;
if ( data . type === 'update' ) {
// Remove error overlay if there is one
if ( typeof document !== 'undefined' ) removeErrorOverlay ( ) ;
var assets = data . assets . filter ( function ( asset ) {
return asset . envHash === HMR _ENV _HASH ;
} ) ; // Handle HMR Update
var handled = assets . every ( function ( asset ) {
return asset . type === 'css' || asset . type === 'js' && hmrAcceptCheck ( module . bundle . root , asset . id , asset . depsByBundle ) ;
} ) ;
if ( handled ) {
console . clear ( ) ;
assets . forEach ( function ( asset ) {
hmrApply ( module . bundle . root , asset ) ;
} ) ;
for ( var i = 0 ; i < assetsToAccept . length ; i ++ ) {
var id = assetsToAccept [ i ] [ 1 ] ;
if ( ! acceptedAssets [ id ] ) hmrAcceptRun ( assetsToAccept [ i ] [ 0 ] , id ) ;
}
} else window . location . reload ( ) ;
}
if ( data . type === 'error' ) {
// Log parcel errors to console
var _iterator = _createForOfIteratorHelper ( data . diagnostics . ansi ) , _step ;
try {
for ( _iterator . s ( ) ; ! ( _step = _iterator . n ( ) ) . done ; ) {
var ansiDiagnostic = _step . value ;
var stack = ansiDiagnostic . codeframe ? ansiDiagnostic . codeframe : ansiDiagnostic . stack ;
console . error ( '🚨 [parcel]: ' + ansiDiagnostic . message + '\n' + stack + '\n\n' + ansiDiagnostic . hints . join ( '\n' ) ) ;
}
} catch ( err ) {
_iterator . e ( err ) ;
} finally {
_iterator . f ( ) ;
}
if ( typeof document !== 'undefined' ) {
// Render the fancy html overlay
removeErrorOverlay ( ) ;
var overlay = createErrorOverlay ( data . diagnostics . html ) ; // $FlowFixMe
document . body . appendChild ( overlay ) ;
}
}
} ;
ws . onerror = function ( e ) {
console . error ( e . message ) ;
} ;
ws . onclose = function ( ) {
console . warn ( '[parcel] 🚨 Connection to the HMR server was lost' ) ;
} ;
}
function removeErrorOverlay ( ) {
var overlay = document . getElementById ( OVERLAY _ID ) ;
if ( overlay ) {
overlay . remove ( ) ;
console . log ( '[parcel] ✨ Error resolved' ) ;
}
}
function createErrorOverlay ( diagnostics ) {
var overlay = document . createElement ( 'div' ) ;
overlay . id = OVERLAY _ID ;
var errorHTML = '<div style="background: black; opacity: 0.85; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; font-family: Menlo, Consolas, monospace; z-index: 9999;">' ;
var _iterator2 = _createForOfIteratorHelper ( diagnostics ) , _step2 ;
try {
for ( _iterator2 . s ( ) ; ! ( _step2 = _iterator2 . n ( ) ) . done ; ) {
var diagnostic = _step2 . value ;
var stack = diagnostic . codeframe ? diagnostic . codeframe : diagnostic . stack ;
errorHTML += "\n <div>\n <div style=\"font-size: 18px; font-weight: bold; margin-top: 20px;\">\n \uD83D\uDEA8 " . concat ( diagnostic . message , "\n </div>\n <pre>" ) . concat ( stack , "</pre>\n <div>\n " ) . concat ( diagnostic . hints . map ( function ( hint ) {
return '<div>💡 ' + hint + '</div>' ;
} ) . join ( '' ) , "\n </div>\n " ) . concat ( diagnostic . documentation ? "<div>\uD83D\uDCDD <a style=\"color: violet\" href=\"" . concat ( diagnostic . documentation , "\" target=\"_blank\">Learn more</a></div>" ) : '' , "\n </div>\n " ) ;
}
} catch ( err ) {
_iterator2 . e ( err ) ;
} finally {
_iterator2 . f ( ) ;
}
errorHTML += '</div>' ;
overlay . innerHTML = errorHTML ;
return overlay ;
}
function getParents ( bundle , id ) /*: Array<[ParcelRequire, string]> */ {
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 ( [
bundle ,
k
] ) ;
}
if ( bundle . parent ) parents = parents . concat ( getParents ( bundle . parent , id ) ) ;
return parents ;
}
function updateLink ( link ) {
var newLink = link . cloneNode ( ) ;
newLink . onload = function ( ) {
if ( link . parentNode !== null ) // $FlowFixMe
link . parentNode . removeChild ( link ) ;
} ;
newLink . setAttribute ( 'href' , link . getAttribute ( 'href' ) . split ( '?' ) [ 0 ] + '?' + Date . now ( ) ) ; // $FlowFixMe
link . parentNode . insertBefore ( newLink , link . nextSibling ) ;
}
var cssTimeout = null ;
function reloadCSS ( ) {
if ( cssTimeout ) return ;
cssTimeout = setTimeout ( function ( ) {
var links = document . querySelectorAll ( 'link[rel="stylesheet"]' ) ;
for ( var i = 0 ; i < links . length ; i ++ ) {
// $FlowFixMe[incompatible-type]
var href = links [ i ] . getAttribute ( 'href' ) ;
var hostname = getHostname ( ) ;
var servedFromHMRServer = hostname === 'localhost' ? new RegExp ( '^(https?:\\/\\/(0.0.0.0|127.0.0.1)|localhost):' + getPort ( ) ) . test ( href ) : href . indexOf ( hostname + ':' + getPort ( ) ) ;
var absolute = /^https?:\/\//i . test ( href ) && href . indexOf ( window . location . origin ) !== 0 && ! servedFromHMRServer ;
if ( ! absolute ) updateLink ( links [ i ] ) ;
}
cssTimeout = null ;
} , 50 ) ;
}
function hmrApply ( bundle , asset ) {
var modules = bundle . modules ;
if ( ! modules ) return ;
if ( asset . type === 'css' ) reloadCSS ( ) ;
else if ( asset . type === 'js' ) {
var deps = asset . depsByBundle [ bundle . HMR _BUNDLE _ID ] ;
if ( deps ) {
var fn = new Function ( 'require' , 'module' , 'exports' , asset . output ) ;
modules [ asset . id ] = [
fn ,
deps
] ;
} else if ( bundle . parent ) hmrApply ( bundle . parent , asset ) ;
}
}
function hmrAcceptCheck ( bundle , id , depsByBundle ) {
var modules = bundle . modules ;
if ( ! modules ) return ;
if ( depsByBundle && ! depsByBundle [ bundle . HMR _BUNDLE _ID ] ) {
// If we reached the root bundle without finding where the asset should go,
// there's nothing to do. Mark as "accepted" so we don't reload the page.
if ( ! bundle . parent ) return true ;
return hmrAcceptCheck ( bundle . parent , id , depsByBundle ) ;
}
if ( checkedAssets [ id ] ) return true ;
checkedAssets [ id ] = true ;
var cached = bundle . cache [ id ] ;
assetsToAccept . push ( [
bundle ,
id
] ) ;
if ( cached && cached . hot && cached . hot . _acceptCallbacks . length ) return true ;
var parents = getParents ( module . bundle . root , id ) ; // If no parents, the asset is new. Prevent reloading the page.
if ( ! parents . length ) return true ;
return parents . some ( function ( v ) {
return hmrAcceptCheck ( v [ 0 ] , v [ 1 ] , null ) ;
} ) ;
}
function hmrAcceptRun ( bundle , id ) {
var cached = bundle . cache [ id ] ;
bundle . hotData = {
} ;
if ( cached && cached . hot ) 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 ) {
var assetsToAlsoAccept = cb ( function ( ) {
return getParents ( module . bundle . root , id ) ;
} ) ;
if ( assetsToAlsoAccept && assetsToAccept . length ) // $FlowFixMe[method-unbinding]
assetsToAccept . push . apply ( assetsToAccept , assetsToAlsoAccept ) ;
} ) ;
acceptedAssets [ id ] = true ;
}
} , { } ] , "bEyX8" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
var _base = require ( "./Base" ) ;
var _baseDefault = parcelHelpers . interopDefault ( _base ) ;
document . addEventListener ( "DOMContentLoaded" , function ( ) {
new _baseDefault . default ( ) ;
} , false ) ;
} , { "./Base" : "kvSpR" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "kvSpR" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
var _fipamoAdminAPI = require ( "../libraries/FipamoAdminAPI" ) ;
var _fipamoAdminAPIDefault = parcelHelpers . interopDefault ( _fipamoAdminAPI ) ;
var _maintenanceManager = require ( "./controllers/MaintenanceManager" ) ;
var _maintenanceManagerDefault = parcelHelpers . interopDefault ( _maintenanceManager ) ;
var _dataUtils = require ( "./utils/DataUtils" ) ;
var _dataUtilsDefault = parcelHelpers . interopDefault ( _dataUtils ) ;
var _dataEvent = require ( "./events/DataEvent" ) ;
var _dashManager = require ( "./controllers/DashManager" ) ;
var _dashManagerDefault = parcelHelpers . interopDefault ( _dashManager ) ;
var _notifications = require ( "./ui/Notifications" ) ;
var _notificationsDefault = parcelHelpers . interopDefault ( _notifications ) ;
const data = new _dataUtilsDefault . default ( ) ;
const notify = new _notificationsDefault . default ( ) ;
class Base {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
this . processing = false ;
this . start ( ) ;
}
// methods
//--------------------------
start ( ) {
if ( document . getElementById ( 'dash-form' ) || document . getElementById ( 'dash-init' ) ) {
var options = document . getElementsByClassName ( 'init-option' ) ;
for ( let index = 0 ; index < options . length ; index ++ ) options [ index ] . addEventListener ( 'click' , ( e ) => this . handleOptions ( e )
) ;
if ( document . getElementById ( 'dash-form' ) ) document . getElementById ( 'login-btn' ) . addEventListener ( 'click' , ( e ) => this . handleLogin ( e )
) ;
else {
document . getElementById ( 'init-blog' ) . addEventListener ( 'click' , ( e ) => this . handleSetup ( e )
) ;
document . getElementById ( 'blog-restore' ) . addEventListener ( 'click' , ( e ) => this . handleRestore ( e )
) ;
}
} else if ( document . getElementById ( 'dash-reset' ) ) {
document . getElementById ( 'get-secret-btn' ) . addEventListener ( 'click' , ( e ) => this . handleReset ( e )
) ;
document . getElementById ( 'reset-btn' ) . addEventListener ( 'click' , ( e ) => this . handleReset ( e )
) ;
} else new _dashManagerDefault . default ( ) ;
}
// event handlers
//--------------------------
handleLogin ( e ) {
if ( this . processing ) return ;
let self = this ;
e . preventDefault ( ) ;
let authForm = data . formDataToJSON ( document . getElementById ( 'login' ) ) ;
notify . alert ( 'Looking, hold up' , null ) ;
let api = new _fipamoAdminAPIDefault . default ( ) ;
this . processing = true ;
api . login ( authForm ) . then ( ( response ) => {
self . processing = false ;
if ( response . type === _dataEvent . REQUEST _LAME ) notify . alert ( response . message , false ) ;
else {
notify . alert ( response . message , true ) ;
e . target . innerHTML = response . message ;
setTimeout ( ( ) => {
window . location = '/dashboard' ;
} , 500 ) ;
}
} ) . catch ( ( err ) => {
self . processing = false ;
notify . alert ( err , false ) ;
} ) ;
}
handleSetup ( e1 ) {
if ( this . processing ) return ;
let self = this ;
e1 . stopPropagation ( ) ;
e1 . preventDefault ( ) ;
let setUpForm = data . formDataToJSON ( document . getElementById ( 'init-form' ) ) ;
let mm = new _maintenanceManagerDefault . default ( ) ;
this . processing = true ;
mm . create ( setUpForm ) . then ( ( response ) => {
if ( response . type === _dataEvent . API _INIT _LAME ) {
self . processing = false ;
notify . alert ( response . message , false ) ;
} else {
self . processing = false ;
notify . alert ( response . message , true ) ;
setTimeout ( ( ) => {
window . location = '/dashboard' ;
} , 700 ) ;
}
} ) . catch ( ( err ) => {
self . processing = false ;
notify . alert ( err , false ) ;
} ) ;
}
handleRestore ( e2 ) {
if ( this . processing ) return ;
let self = this ;
e2 . stopPropagation ( ) ;
e2 . preventDefault ( ) ;
let mm = new _maintenanceManagerDefault . default ( ) ;
var form = document . getElementById ( 'init-restore' ) ;
this . processing = true ;
mm . restore ( form ) . then ( ( response ) => {
if ( response . type === _dataEvent . REQUEST _LAME ) {
self . processing = false ;
notify . alert ( response . message , false ) ;
} else {
self . processing = false ;
notify . alert ( response . message , true ) ;
setTimeout ( ( ) => {
window . location = '/dashboard' ;
} , 1500 ) ;
}
} ) . catch ( ( err ) => {
self . processing = false ;
notify . alert ( err , false ) ;
} ) ;
}
handleReset ( e3 ) {
e3 . stopPropagation ( ) ;
e3 . preventDefault ( ) ;
let self = this ;
let mm = new _maintenanceManagerDefault . default ( ) ;
if ( e3 . target . id == 'get-secret-btn' ) {
let data = {
email : document . getElementById ( 'email' ) . value ,
task : 'retrieveSecret'
} ;
this . processing = true ;
mm . secret ( data ) . then ( ( response ) => {
self . processing = false ;
if ( response . secret ) {
document . getElementById ( 'secret' ) . value = response . secret ;
notify . alert ( response . message , true ) ;
} else if ( response . type == 'mailSent' ) notify . alert ( response . message , true ) ;
else notify . alert ( response . message , false ) ;
} ) . catch ( ( err ) => {
self . processing = false ;
notify . alert ( err , false ) ;
} ) ;
} else {
let data = {
newPass : document . getElementById ( 'new_password' ) . value ,
newPassConfirm : document . getElementById ( 'new_password2' ) . value ,
secret : document . getElementById ( 'secret' ) . value
} ;
mm . newPass ( data ) . then ( ( response ) => {
self . processing = false ;
if ( response . type == 'passNotCreated' ) notify . alert ( response . message , false ) ;
else {
notify . alert ( response . message , true ) ;
setTimeout ( ( ) => {
window . location = '/dashboard' ;
} , 1000 ) ;
}
} ) . catch ( ( err ) => {
self . processing = false ;
notify . alert ( err , false ) ;
} ) ;
}
}
handleOptions ( e4 ) {
e4 . stopPropagation ( ) ;
e4 . preventDefault ( ) ;
let init = document . getElementById ( 'dash-init' ) ;
let restore = document . getElementById ( 'dash-restore' ) ;
if ( e4 . target . id === 'init-switch-restore' ) {
init . style . display = 'none' ;
init . style . visibility = 'hidden' ;
restore . style . display = 'flex' ;
restore . style . visibility = 'visible' ;
} else {
init . style . display = 'flex' ;
init . style . visibility = 'visible' ;
restore . style . display = 'none' ;
restore . style . visibility = 'hidden' ;
}
}
}
exports . default = Base ;
} , { "../libraries/FipamoAdminAPI" : "6M96o" , "./controllers/MaintenanceManager" : "kY7L1" , "./utils/DataUtils" : "lpIyf" , "./events/DataEvent" : "edzJV" , "./controllers/DashManager" : "7hyn2" , "./ui/Notifications" : "fmUxI" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "6M96o" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
parcelHelpers . export ( exports , "REQUEST_TYPE_POST" , ( ) => REQUEST _TYPE _POST
) ;
parcelHelpers . export ( exports , "REQUEST_TYPE_GET" , ( ) => REQUEST _TYPE _GET
) ;
parcelHelpers . export ( exports , "REQUEST_TYPE_PUT" , ( ) => REQUEST _TYPE _PUT
) ;
parcelHelpers . export ( exports , "REQUEST_TYPE_DELETE" , ( ) => REQUEST _TYPE _DELETE
) ;
parcelHelpers . export ( exports , "CONTENT_TYPE_JSON" , ( ) => CONTENT _TYPE _JSON
) ;
parcelHelpers . export ( exports , "CONTENT_TYPE_FORM" , ( ) => CONTENT _TYPE _FORM
) ;
parcelHelpers . export ( exports , "API_STATUS" , ( ) => API _STATUS
) ;
parcelHelpers . export ( exports , "API_GET_SETTINGS" , ( ) => API _GET _SETTINGS
) ;
parcelHelpers . export ( exports , "API_GET_MEMBER_INFO" , ( ) => API _GET _MEMBER _INFO
) ;
parcelHelpers . export ( exports , "API_NEW_PAGE" , ( ) => API _NEW _PAGE
) ;
parcelHelpers . export ( exports , "API_EDIT_PAGE" , ( ) => API _EDIT _PAGE
) ;
parcelHelpers . export ( exports , "API_DELETE_PAGE" , ( ) => API _DELETE _PAGE
) ;
parcelHelpers . export ( exports , "API_SETTINGS_SYNC" , ( ) => API _SETTINGS _SYNC
) ;
parcelHelpers . export ( exports , "API_PUBLISH_PAGES" , ( ) => API _PUBLISH _PAGES
) ;
parcelHelpers . export ( exports , "API_NAV_SYNC" , ( ) => API _NAV _SYNC
) ;
parcelHelpers . export ( exports , "API_REINDEX_PAGES" , ( ) => API _REINDEX _PAGES
) ;
parcelHelpers . export ( exports , "API_SEND_MAIL" , ( ) => API _SEND _MAIL
) ;
parcelHelpers . export ( exports , "API_LOGIN" , ( ) => API _LOGIN
) ;
parcelHelpers . export ( exports , "AUTH_STATUS" , ( ) => AUTH _STATUS
) ;
parcelHelpers . export ( exports , "TASK_SETTINGS_WRITE" , ( ) => TASK _SETTINGS _WRITE
) ;
parcelHelpers . export ( exports , "TASK_PUBLISH_SITE" , ( ) => TASK _PUBLISH _SITE
) ;
parcelHelpers . export ( exports , "TASK_PAGE_CREATE" , ( ) => TASK _PAGE _CREATE
) ;
parcelHelpers . export ( exports , "TASK_PAGE_EDIT" , ( ) => TASK _PAGE _EDIT
) ;
parcelHelpers . export ( exports , "TASK_PAGE_DELETE" , ( ) => TASK _PAGE _DELETE
) ;
parcelHelpers . export ( exports , "TASK_SEND_MAIL" , ( ) => TASK _SEND _MAIL
) ;
parcelHelpers . export ( exports , "TASK_REINDEX_PAGE" , ( ) => TASK _REINDEX _PAGE
) ;
parcelHelpers . export ( exports , "TASK_SYNC_SETTNIGS" , ( ) => TASK _SYNC _SETTNIGS
) ;
parcelHelpers . export ( exports , "TASK_SYNC_NAV" , ( ) => TASK _SYNC _NAV
) ;
parcelHelpers . export ( exports , "TASK_GET_SETTINGS" , ( ) => TASK _GET _SETTINGS
) ;
parcelHelpers . export ( exports , "TASK_GET_MEMBER_INFO" , ( ) => TASK _GET _MEMBER _INFO
) ;
parcelHelpers . export ( exports , "API_ACCESS_GOOD" , ( ) => API _ACCESS _GOOD
) ;
parcelHelpers . export ( exports , "API_ACCESS_BAD" , ( ) => API _ACCESS _BAD
) ;
parcelHelpers . export ( exports , "default" , ( ) => FipamoAdminAPI
) ;
const REQUEST _TYPE _POST = "POST" ;
const REQUEST _TYPE _GET = "GET" ;
const REQUEST _TYPE _PUT = "PUT" ;
const REQUEST _TYPE _DELETE = "DELETE" ; //** POST CONTENT TYPES **//
const CONTENT _TYPE _JSON = "json" ;
const CONTENT _TYPE _FORM = "x-www-form-urlencoded" ; //** API URLS **//
const API _STATUS = "/api/v1/status" ;
const API _GET _SETTINGS = "/api/v1/settings/site" ;
const API _GET _MEMBER _INFO = "/api/v1/settings/member" ;
const API _NEW _PAGE = "/api/v1/page/create" ;
const API _EDIT _PAGE = "/api/v1/page/write" ;
const API _DELETE _PAGE = "/api/v1/page/delete" ;
const API _SETTINGS _SYNC = "/api/v1/settings/sync" ;
const API _PUBLISH _PAGES = "/api/v1/settings/publish" ;
const API _NAV _SYNC = "/api/v1/settings/nav-sync" ;
const API _REINDEX _PAGES = "/api/v1/settings/reindex" ;
const API _SEND _MAIL = "/api/v1/mailer" ;
const API _LOGIN = "/api/v1/login" ; //** API TASKS **//
const AUTH _STATUS = "getAuthStatus" ;
const TASK _SETTINGS _WRITE = "writeSettings" ;
const TASK _PUBLISH _SITE = "publishSite" ;
const TASK _PAGE _CREATE = "createNewPage" ;
const TASK _PAGE _EDIT = "editPage" ;
const TASK _PAGE _DELETE = "deletePage" ;
const TASK _SEND _MAIL = "sendMail" ;
const TASK _REINDEX _PAGE = "reIndexPages" ;
const TASK _SYNC _SETTNIGS = "syncSite" ;
const TASK _SYNC _NAV = "syncNav" ;
const TASK _GET _SETTINGS = "getSiteSettings" ;
const TASK _GET _MEMBER _INFO = "getMemberInfo" ; //** API STATUS **//
const API _ACCESS _GOOD = "apiUseAuthorized" ;
const API _ACCESS _BAD = "apiUseNotAuthorized" ;
/ * *
* A can of methods used to edit install settings , navigation pages and content pages
* / c l a s s F i p a m o A d m i n A P I {
/ * *
* @ constructor
* @ param { string } baseURL - url of site ; uses local when empty
* @ param { object } progressBar - element to be used to display upload progress
* / c o n s t r u c t o r ( b a s e U R L = n u l l , p r o g r e s s B a r = n u l l ) {
this . percentComplete = 0 ; //for later
this . baseURL = null ;
this . progressBar = progressBar ;
this . status = false ;
if ( baseURL ) this . baseURL = baseURL ; //asks server if a session is active
this . _request ( this . baseURL ? this . baseURL + API _STATUS : API _STATUS ) . then ( ( response ) => {
if ( response . type === API _ACCESS _GOOD ) this . token = response . token ;
} ) ;
}
/ * *
* Promise method for authenticating and starting a session \
* * * POST * * ` /api/v1/login `
* @ param { Object [ ] } data - json object that contains data for set up
* @ param { string } data [ ] . handle - handle for site user
* @ param { string } data [ ] . password - password for site user
* @ example
* api . login ( data ) . then ( response => {
* console . log ( "RESPONSE" , response ) ;
* } )
* @ returns { object } json object that contains type and status of login request
` ` `
{
"message" : "Example Message of Affirmation or what you're missing!" ,
"type" : "exampleType" ,
}
` ` `
* / l o g i n ( d a t a ) {
return new Promise ( ( resolve , reject ) => {
this . baseURL ? data . remote = true : data . remote = false ;
this . key ? data . key = this . key : data . key = null ;
this . _request ( this . baseURL ? this . baseURL + API _LOGIN : API _LOGIN , AUTH _STATUS , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , data ) . then ( ( result ) => {
resolve ( result ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
/ * *
* Method for saving site and navigation settings \
* * * POST * * ` /api/v1/settings/:task `
* @ param { string } task - settings being synced ` config | navigation `
* @ param { object [ ] } data - json object that contains settings data for [ site ] or [ nav ]
* @ param { string } data [ ] . global . base _url - base url for site [ site ]
* @ param { string } data [ ] . global . title - site title [ site ]
* @ param { string } data [ ] . global . descriptions - brief site summary [ site ]
* @ param { string } data [ ] . global . background - url for site feature image for header [ site ]
* @ param { boolean } data [ ] . global . private - privacy state for site [ disabled ] [ site ]
* @ param { boolean } data [ ] . global . renderOnSave - property for publishing site when page saved [ disabled ] [ site ]
* @ param { string } data [ ] . global . theme - current theme for site [ site ]
* @ param { boolean } data [ ] . global . externalAPI - toggle for external API access [ site ]
* @ param { string } data [ ] . member . handle - current member handle [ site ]
* @ param { string } data [ ] . member . email - current member email [ site ]
* @ param { string } data [ ] . email . active - current email protocol being used [ site ]
* @ param { string } data [ ] . email . smtp . domain - url of smtp service being [ site ]
* @ param { string } data [ ] . email . smtp . email - email account of smtp service [ site ]
* @ param { string } data [ ] . email . smtp . password - password for email of smtp service [ site ]
* @ param { string } data [ ] . email . mailgun . domain - mailgun domain url [ site ]
* @ param { string } data [ ] . email . mailgun . key - mailgun key [ site ]
*
* @ param { string } data [ ] . item . title - page title [ nav ]
* @ param { string } data [ ] . item . slug - url safe title [ nav ]
* @ param { string } data [ ] . item . uuid - unique identifier [ nav ]
* @ param { string } data [ ] . item . path - directory path to associated markdown file [ nav ]
* @ example
* api . sync ( TASK , data ) . then ( response => {
* console . log ( "RESPONSE" , response ) ;
* } )
* @ returns { object } json object that contains type and status of sync request
` ` `
*
{
"message" : "Example Message of Affirmation!" ,
"type" : "exampleType" ,
}
` ` `
* / s y n c ( t a s k , d a t a 1 ) {
return new Promise ( ( resolve , reject ) => {
let url = "" ;
switch ( task ) {
case "syncSite" :
url = API _SETTINGS _SYNC ;
break ;
case "syncNav" :
url = API _NAV _SYNC ;
break ;
}
this . _request ( this . baseURL ? this . baseURL + url : url , TASK _SETTINGS _WRITE , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , data1 ) . then ( ( result ) => {
resolve ( result ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
/ * *
* Method for retrieving user authorizing user login
* @ param { object [ ] } data - json object that contains task
* @ param { string } data [ ] . task - publishing task
* @ example
* api . publish ( TASK ) . then ( response => {
* console . log ( "RESPONSE" , response ) ;
* } )
* @ returns { object } json object that contains type and status of publis request
* ` ` `
{
"message" : "Example Message of Affirmation!" ,
"type" : "exampleType" ,
}
* ` ` `
* / p u b l i s h ( d a t a 2 ) {
return new Promise ( ( resolve , reject ) => {
this . _request ( this . baseURL ? this . baseURL + API _PUBLISH _PAGES : API _PUBLISH _PAGES , TASK _PUBLISH _SITE , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , data2 ) . then ( ( result ) => {
resolve ( result ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
/ * *
* Method for handling page creating and editing \
* * * POST * * ` /api/v1/page/:task `
* @ param { string } task - current page action
* @ param { object [ ] } form - form object that contains info for current page being edited / created
* @ param { string } form [ ] . id - sequence id for page , leave empty for new page
* @ param { string } form [ ] . uuid - unique identifier for page , leave empty for new page
* @ param { string } form [ ] . layout - current page layout
* @ param { string } form [ ] . current _title - saved url save title for persistence when changing title , leave empty for new page
* @ param { string } form [ ] . content - markdown body of page
* @ param { string } form [ ] . title - current title of page
* @ param { string } form [ ] . created - date page was created , leave empty for new page
* @ param { string } form [ ] . slug - url safe string of page title
* @ param { string } form [ ] . tags - comma separated list of tags
* @ param { boolean } form [ ] . menu - property that indicates page is included in site menu
* @ param { boolean } form [ ] . featured - property that indicates page is featured
* @ param { boolean } form [ ] . published - property that indicates page is public
* @ param { string } form [ ] . form _token - hidden property to authenticate form submission
* @ param { input } form [ ] . feature _image - main image for page
* @ example
* api . pageActions ( TASK , data ) . then ( response => {
* console . log ( "RESPONSE" , response ) ;
* } )
* @ returns { object } json object that contains type and status of page edit request
` ` `
{
"message" : "Example Message of Affirmation!" ,
"type" : "exampleType" ,
}
` ` `
* / p a g e A c t i o n s ( t a s k 1 , d a t a 3 ) {
let url , event , content ;
switch ( task1 ) {
case TASK _PAGE _CREATE :
url = API _NEW _PAGE ;
event = TASK _PAGE _CREATE ;
content = CONTENT _TYPE _FORM ;
break ;
case TASK _PAGE _EDIT :
url = API _EDIT _PAGE ;
event = TASK _PAGE _EDIT ;
content = CONTENT _TYPE _FORM ;
break ;
case TASK _PAGE _DELETE :
url = API _DELETE _PAGE ;
event = TASK _PAGE _DELETE ;
content = CONTENT _TYPE _FORM ;
break ;
default :
break ;
}
if ( this . baseURL ) //data.key = this.key;
data3 . remote = true ;
else data3 . remote = false ;
return new Promise ( ( resolve , reject ) => {
this . _request ( this . baseURL ? this . baseURL + url : url , event , REQUEST _TYPE _POST , content , data3 ) . then ( ( result ) => {
resolve ( result ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
/ * *
* Method for sending mail ( if completed in settings ) \
* * * POST * * ` /api/v1/mailer `
* @ param { object [ ] } message - json object that contains items to be included in main site navigation
* @ param { string } message [ ] . content - message to send
* @ example
* api . sendMail ( message ) . then ( response => {
* console . log ( "RESPONSE" , response ) ;
* } )
* @ returns { object } json object that contains type and status of page edit request
` ` `
{
"message" : "Example Message of Affirmation!" ,
"type" : "exampleType"
}
` ` `
* / s e n d M a i l ( m e s s a g e ) {
return new Promise ( ( resolve , reject ) => {
this . _request ( this . baseURL ? this . baseURL + API _SEND _MAIL : API _SEND _MAIL , TASK _SEND _MAIL , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , message ) . then ( ( result ) => {
resolve ( result ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
/ * *
* * Promise method for retrieving site and member info * \
* * * GET * * ` /api/v1/settings/:type `
* @ param { string } type - type of info requested [ 'site' | 'member' ] ;
* @ example
* api . getInfo ( "type" ) . then ( data => {
console . log ( "Info Object" , data ) ;
* } )
* @ returns { object } json object that contains data for requested information
*
* * info object example *
* ` ` `
{
"message" : "message of affirmation!" ,
"task" : "type of info request" ,
"data" : json - data - object ,
}
* ` ` `
* / g e t I n f o ( t y p e ) {
let url , task ;
if ( type == "site" ) {
url = API _GET _SETTINGS ;
task = TASK _GET _SETTINGS ;
} else {
url = API _GET _MEMBER _INFO ;
task = TASK _GET _MEMBER _INFO ;
}
return new Promise ( ( resolve , reject ) => {
this . _request ( this . baseURL ? this . baseURL + url : url , task ) . then ( ( result ) => {
resolve ( result ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
// private
//--------------------------
_request ( requestURL , eventType , requestType = REQUEST _TYPE _GET , contentType = CONTENT _TYPE _JSON , requestData = null ) {
var self = this ;
return new Promise ( function ( resolve , reject ) {
var request = new XMLHttpRequest ( ) ;
request . upload . addEventListener ( "progress" , ( e ) => self . handleLoadProgress ( e , self . progressBar )
) ;
request . open ( requestType , requestURL , true ) ;
request . onload = ( ) => {
if ( request . status == 200 ) {
let response = JSON . parse ( request [ "response" ] ) ;
resolve ( response ) ;
} else {
let error = JSON . parse ( request [ "response" ] ) ;
reject ( error ) ;
}
} ;
if ( requestType == REQUEST _TYPE _PUT || requestType == REQUEST _TYPE _POST ) {
if ( eventType === TASK _SETTINGS _WRITE || eventType === TASK _PAGE _EDIT || eventType === TASK _PAGE _CREATE || eventType === TASK _PAGE _DELETE || eventType === TASK _PUBLISH _SITE || eventType === TASK _REINDEX _PAGE ) request . setRequestHeader ( "fipamo-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 {
if ( eventType === TASK _GET _SETTINGS || eventType === TASK _GET _MEMBER _INFO ) request . setRequestHeader ( "fipamo-access-token" , self . token ) ;
request . send ( ) ;
}
} ) ;
}
// event handlers
//--------------------------
handleLoadProgress ( e , progressBar1 ) {
let percent = Math . ceil ( e . loaded / e . total * 100 ) ; //if a progress bar element is present, talk to it
if ( progressBar1 != null ) progressBar1 . style . width = percent + "%" ;
}
}
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "ciiiV" : [ function ( require , module , exports ) {
exports . interopDefault = function ( a ) {
return a && a . _ _esModule ? a : {
default : a
} ;
} ;
exports . defineInteropFlag = function ( a ) {
Object . defineProperty ( a , '__esModule' , {
value : true
} ) ;
} ;
exports . exportAll = function ( source , dest ) {
Object . keys ( source ) . forEach ( function ( key ) {
if ( key === 'default' || key === '__esModule' || dest . hasOwnProperty ( key ) ) return ;
Object . defineProperty ( dest , key , {
enumerable : true ,
get : function ( ) {
return source [ key ] ;
}
} ) ;
} ) ;
return dest ;
} ;
exports . export = function ( dest , destName , get ) {
Object . defineProperty ( dest , destName , {
enumerable : true ,
get : get
} ) ;
} ;
} , { } ] , "kY7L1" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
parcelHelpers . export ( exports , "REQUEST_TYPE_POST" , ( ) => REQUEST _TYPE _POST
) ;
parcelHelpers . export ( exports , "REQUEST_TYPE_GET" , ( ) => REQUEST _TYPE _GET
) ;
parcelHelpers . export ( exports , "REQUEST_TYPE_PUT" , ( ) => REQUEST _TYPE _PUT
) ;
parcelHelpers . export ( exports , "REQUEST_TYPE_DELETE" , ( ) => REQUEST _TYPE _DELETE
) ;
parcelHelpers . export ( exports , "CONTENT_TYPE_JSON" , ( ) => CONTENT _TYPE _JSON
) ;
parcelHelpers . export ( exports , "CONTENT_TYPE_FORM" , ( ) => CONTENT _TYPE _FORM
) ;
parcelHelpers . export ( exports , "API_STATUS" , ( ) => API _STATUS
) ;
parcelHelpers . export ( exports , "API_INIT" , ( ) => API _INIT
) ;
parcelHelpers . export ( exports , "API_RESTORE" , ( ) => API _RESTORE
) ;
parcelHelpers . export ( exports , "API_GET_SECRET" , ( ) => API _GET _SECRET
) ;
parcelHelpers . export ( exports , "API_RESET_PASS" , ( ) => API _RESET _PASS
) ;
parcelHelpers . export ( exports , "API_CREATE_BACKUP" , ( ) => API _CREATE _BACKUP
) ;
parcelHelpers . export ( exports , "API_DOWNLOAD_BACKUP" , ( ) => API _DOWNLOAD _BACKUP
) ;
parcelHelpers . export ( exports , "API_RESTORE_BACKUP" , ( ) => API _RESTORE _BACKUP
) ;
parcelHelpers . export ( exports , "API_UPLOAD_AVATAR" , ( ) => API _UPLOAD _AVATAR
) ;
parcelHelpers . export ( exports , "API_UPLOAD_BACKGROUND" , ( ) => API _UPLOAD _BACKGROUND
) ;
parcelHelpers . export ( exports , "API_IMAGE_UPLOAD" , ( ) => API _IMAGE _UPLOAD
) ;
parcelHelpers . export ( exports , "TASK_SITE_INIT" , ( ) => TASK _SITE _INIT
) ;
parcelHelpers . export ( exports , "TASK_BACKUP_RESTORE" , ( ) => TASK _BACKUP _RESTORE
) ;
parcelHelpers . export ( exports , "TASK_BACKUP_CREATE" , ( ) => TASK _BACKUP _CREATE
) ;
parcelHelpers . export ( exports , "TASK_GET_SECRET" , ( ) => TASK _GET _SECRET
) ;
parcelHelpers . export ( exports , "TASK_RESET_PASS" , ( ) => TASK _RESET _PASS
) ;
parcelHelpers . export ( exports , "TASK_UPLOAD_FILES" , ( ) => TASK _UPLOAD _FILES
) ;
parcelHelpers . export ( exports , "API_ACCESS_GOOD" , ( ) => API _ACCESS _GOOD
) ;
parcelHelpers . export ( exports , "API_ACCESS_BAD" , ( ) => API _ACCESS _BAD
) ;
parcelHelpers . export ( exports , "default" , ( ) => MaintenanceManager
) ;
const REQUEST _TYPE _POST = 'POST' ;
const REQUEST _TYPE _GET = 'GET' ;
const REQUEST _TYPE _PUT = 'PUT' ;
const REQUEST _TYPE _DELETE = 'DELETE' ; //** POST CONTENT TYPES **//
const CONTENT _TYPE _JSON = 'json' ;
const CONTENT _TYPE _FORM = 'x-www-form-urlencoded' ; //** API URLS **//
const API _STATUS = '/api/v1/status' ;
const API _INIT = '/api/v1/init' ;
const API _RESTORE = '/api/v1/restore' ;
const API _GET _SECRET = '/api/v1/get-secret' ;
const API _RESET _PASS = '/api/v1/reset-password' ;
const API _CREATE _BACKUP = '/api/v1/backup' ;
const API _DOWNLOAD _BACKUP = '/api/v1/backup/download' ;
const API _RESTORE _BACKUP = '/api/v1/backup/restore' ;
const API _UPLOAD _AVATAR = '/api/v1/settings/add-avatar' ;
const API _UPLOAD _BACKGROUND = '/api/v1/settings/add-feature-background' ;
const API _IMAGE _UPLOAD = '/api/v1/page/add-entry-image' ; //** API TASKS **//
const TASK _SITE _INIT = 'blogInit' ;
const TASK _BACKUP _RESTORE = 'restoreBackup' ;
const TASK _BACKUP _CREATE = 'createBackup' ;
const TASK _GET _SECRET = 'retrieveSecret' ;
const TASK _RESET _PASS = 'resetPassword' ;
const TASK _UPLOAD _FILES = 'uploadFiles' ; //** API STATUS **//
const API _ACCESS _GOOD = 'apiUseAuthorized' ;
const API _ACCESS _BAD = 'apiUseNotAuthorized' ;
/ * *
* A tub of methods for creating / restoring installs , resetting passwords and uploading images .
* / c l a s s M a i n t e n a n c e M a n a g e r {
/ * *
* @ constructor
* @ param { string } baseURL - url of site ; uses local when empty
* @ param { string } key - user api key
* / c o n s t r u c t o r ( b a s e U R L = n u l l , k e y = n u l l , p r o g r e s s B a r = n u l l ) {
this . percentComplete = 0 ; //for later
this . token = null ;
this . baseURL = null ;
this . progressBar = progressBar ;
this . key = null ;
if ( key ) this . key = key ;
if ( baseURL ) this . baseURL = baseURL ; //if key is valid, checks to see if a session is active and returns
this . _request ( this . baseURL ? this . baseURL + API _STATUS + '?key=' + this . key : API _STATUS + '?key=' + this . key ) . then ( ( response ) => {
if ( response . type === API _ACCESS _GOOD ) this . token = response . token ;
} ) ;
}
/ * *
* Promise method used create new site from scratch . For local use only .
* @ param { object } data - json object that contains data for set up
* @ property { string } new _member _handle - handle for new user
* @ property { string } new _member _email - email for new user
* @ property { string } new _member _pass - password for new user
* @ property { string } new _member _title - title for new user
* / c r e a t e ( d a t a 1 ) {
return new Promise ( ( resolve , reject ) => {
this . _request ( API _INIT , TASK _SITE _INIT , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , data1 ) . then ( ( result ) => {
resolve ( result ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
/ * *
* Promise method for restoring site from a previous back up . For local use only .
* @ param { object } form - form object that contains restore data and files
* @ property { string } restore _member _handle - handle for site user
* @ property { string } restore _member _pass - password for site user
* @ property { file } backup - upload - backup zip file
* / r e s t o r e ( f o r m ) {
return new Promise ( ( resolve , reject ) => {
var url , event , method , type , data ;
url = API _RESTORE ;
event = TASK _BACKUP _RESTORE ;
method = REQUEST _TYPE _POST ;
type = CONTENT _TYPE _FORM ;
data = new FormData ( form ) ;
this . _request ( url , event , method , type , data ) . then ( ( result ) => {
resolve ( result ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
/ * *
* Promise method for creating a zip back up of current site . For local use only .
* / b a c k u p ( ) {
return new Promise ( ( resolve , reject ) => {
var url , event , method , type , data ;
url = API _CREATE _BACKUP ;
event = TASK _BACKUP _CREATE ;
method = REQUEST _TYPE _POST ;
type = CONTENT _TYPE _JSON ;
data = {
task : 'create_backup'
} ;
this . _request ( url , event , method , type , data ) . then ( ( result ) => {
resolve ( result ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
/ * *
* Promise method for retrieving user secret key . For local use only .
* @ param { object } data - json object that contains data for set up
* @ property { string } email - email for site user
* / s e c r e t ( d a t a ) {
return new Promise ( ( resolve , reject ) => {
this . _request ( API _GET _SECRET , TASK _GET _SECRET , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , data ) . then ( ( result ) => {
resolve ( result ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
/ * *
* Promise method for resetting password for user . For local use only .
* @ param { object } data - json object that contains data for set up
* @ property { string } new _password - password for user
* @ property { string } new _password2 - confirm password for user
* @ property { string } secret - secret key for user
* / n e w P a s s ( d a t a 2 ) {
return new Promise ( ( resolve , reject ) => {
this . _request ( API _RESET _PASS , TASK _RESET _PASS , REQUEST _TYPE _POST , CONTENT _TYPE _JSON , data2 ) . then ( ( result ) => {
resolve ( result ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
/ * *
* Promise method for uploading images [ todo : change to uploading files ]
* @ param { string } type - type of upload
* @ param { input } files - form input containing files
* / i m a g e U p l o a d ( t y p e , f i l e s ) {
return new Promise ( ( resolve , reject ) => {
let 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 ( ) ;
if ( this . baseURL ) {
imageData . append ( 'key' , this . key ) ;
imageData . append ( 'remote' , true ) ;
} else imageData . append ( 'remote' , false ) ;
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 ) ;
}
this . _request ( url , TASK _UPLOAD _FILES , REQUEST _TYPE _POST , CONTENT _TYPE _FORM , imageData ) . then ( ( r ) => {
resolve ( r ) ;
} ) . catch ( ( err ) => {
reject ( err ) ;
} ) ;
} ) ;
}
// private
//--------------------------
_request ( requestURL , eventType , requestType = REQUEST _TYPE _GET , contentType = CONTENT _TYPE _JSON , requestData = null ) {
var self = this ;
return new Promise ( function ( resolve , reject ) {
var request = new XMLHttpRequest ( ) ;
request . upload . addEventListener ( 'progress' , ( e ) => self . handleLoadProgress ( e , self . progressBar )
) ;
request . open ( requestType , requestURL , true ) ;
request . onload = ( ) => {
if ( request . status == 200 ) {
let response = JSON . parse ( request [ 'response' ] ) ;
resolve ( response ) ;
} else {
let error = JSON . parse ( request [ 'response' ] ) ;
reject ( error ) ;
}
} ;
if ( requestType == REQUEST _TYPE _PUT || requestType == REQUEST _TYPE _POST ) {
if ( eventType === TASK _UPLOAD _FILES ) request . setRequestHeader ( 'fipamo-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
//--------------------------
handleLoadProgress ( e , progressBar1 ) {
let percent = Math . ceil ( e . loaded / e . total * 100 ) ; //if a progress bar element is present, talk to it
if ( progressBar1 != null ) progressBar1 . style . width = percent + '%' ;
}
}
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "lpIyf" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
class DataUtils {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
}
// methods
//--------------------------
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 ( ) ;
} ) ;
}
loadImage ( src ) {
'use strict' ;
let 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
* / f o r m D a t a T o J S O N ( f o r m ) {
let object = {
} ;
let formData = new FormData ( form ) ;
formData . forEach ( ( 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 ;
}
}
exports . default = DataUtils ;
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "edzJV" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
parcelHelpers . export ( exports , "AUTH_STATUS" , ( ) => AUTH _STATUS
) ;
parcelHelpers . export ( exports , "REQUEST_GOOD" , ( ) => REQUEST _GOOD
) ;
parcelHelpers . export ( exports , "REQUEST_LAME" , ( ) => REQUEST _LAME
) ;
parcelHelpers . export ( exports , "API_REQUEST_GOOD" , ( ) => API _REQUEST _GOOD
) ;
parcelHelpers . export ( exports , "API_REQUEST_LAME" , ( ) => API _REQUEST _LAME
) ;
parcelHelpers . export ( exports , "IMG_REQUEST_GOOD" , ( ) => IMG _REQUEST _GOOD
) ;
parcelHelpers . export ( exports , "IMG_REQUEST_LAME" , ( ) => IMG _REQUEST _LAME
) ;
parcelHelpers . export ( exports , "SETTINGS_LOADED" , ( ) => SETTINGS _LOADED
) ;
parcelHelpers . export ( exports , "POST_IMAGE_ADDED" , ( ) => POST _IMAGE _ADDED
) ;
parcelHelpers . export ( exports , "FEATURE_IMAGE_ADDED" , ( ) => FEATURE _IMAGE _ADDED
) ;
parcelHelpers . export ( exports , "PAGE_ERROR" , ( ) => PAGE _ERROR
) ;
parcelHelpers . export ( exports , "PAGE_ADDED" , ( ) => PAGE _ADDED
) ;
parcelHelpers . export ( exports , "PAGE_UPDATED" , ( ) => PAGE _UPDATED
) ;
parcelHelpers . export ( exports , "PAGE_DELETED" , ( ) => PAGE _DELETED
) ;
parcelHelpers . export ( exports , "PAGES_RENDERED" , ( ) => PAGES _RENDERED
) ;
parcelHelpers . export ( exports , "PAGES_NOT_RENDERED" , ( ) => PAGES _NOT _RENDERED
) ;
parcelHelpers . export ( exports , "TAG_PAGES_RENDERED" , ( ) => TAG _PAGES _RENDERED
) ;
parcelHelpers . export ( exports , "TAG_PAGES_NOT_RENDERED" , ( ) => TAG _PAGES _NOT _RENDERED
) ;
parcelHelpers . export ( exports , "SETTINGS_UPDATED" , ( ) => SETTINGS _UPDATED
) ;
parcelHelpers . export ( exports , "SETTINGS_NOT_UPDATED" , ( ) => SETTINGS _NOT _UPDATED
) ;
parcelHelpers . export ( exports , "MENU_ADD_ITEM" , ( ) => MENU _ADD _ITEM
) ;
parcelHelpers . export ( exports , "MENU_DELETE_ITEM" , ( ) => MENU _DELETE _ITEM
) ;
parcelHelpers . export ( exports , "MENU_UPDATED" , ( ) => MENU _UPDATED
) ;
parcelHelpers . export ( exports , "AVATAR_UPLOADED" , ( ) => AVATAR _UPLOADED
) ;
parcelHelpers . export ( exports , "SITE_BACKGROUND_UPLOADED" , ( ) => SITE _BACKGROUND _UPLOADED
) ;
parcelHelpers . export ( exports , "UPLOAD_PROGRESS" , ( ) => UPLOAD _PROGRESS
) ;
parcelHelpers . export ( exports , "API_PAGE_WRITE" , ( ) => API _PAGE _WRITE
) ;
parcelHelpers . export ( exports , "API_PAGE_CREATE" , ( ) => API _PAGE _CREATE
) ;
parcelHelpers . export ( exports , "API_PAGE_DELETE" , ( ) => API _PAGE _DELETE
) ;
parcelHelpers . export ( exports , "API_SETTINGS_WRITE" , ( ) => API _SETTINGS _WRITE
) ;
parcelHelpers . export ( exports , "API_BACKUP_CREATE" , ( ) => API _BACKUP _CREATE
) ;
parcelHelpers . export ( exports , "API_BACKUP_DOWNLOAD" , ( ) => API _BACKUP _DOWNLOAD
) ;
parcelHelpers . export ( exports , "API_BACKUP_RESTORE" , ( ) => API _BACKUP _RESTORE
) ;
parcelHelpers . export ( exports , "API_IMAGES_UPLOAD" , ( ) => API _IMAGES _UPLOAD
) ;
parcelHelpers . export ( exports , "API_RENDER_PAGES" , ( ) => API _RENDER _PAGES
) ;
parcelHelpers . export ( exports , "API_REINDEX_PAGES" , ( ) => API _REINDEX _PAGES
) ;
parcelHelpers . export ( exports , "API_INIT" , ( ) => API _INIT
) ;
parcelHelpers . export ( exports , "API_INIT_GOOD" , ( ) => API _INIT _GOOD
) ;
parcelHelpers . export ( exports , "API_INIT_LAME" , ( ) => API _INIT _LAME
) ;
parcelHelpers . export ( exports , "API_GET_SECRET" , ( ) => API _GET _SECRET
) ;
parcelHelpers . export ( exports , "API_RESET_PASS" , ( ) => API _RESET _PASS
) ;
parcelHelpers . export ( exports , "SEND_MAIL" , ( ) => SEND _MAIL
) ;
const AUTH _STATUS = "getAuthStatus" ;
const REQUEST _GOOD = "requestGood" ;
const REQUEST _LAME = "requestLame" ;
const API _REQUEST _GOOD = "apiUseAuthorized" ;
const API _REQUEST _LAME = "apiUseNotAuthorized" ;
const IMG _REQUEST _GOOD = "imgRequestGood" ;
const IMG _REQUEST _LAME = "imgRequestLame" ;
const SETTINGS _LOADED = "settingsLoaded" ;
const POST _IMAGE _ADDED = "postImageAdded" ;
const FEATURE _IMAGE _ADDED = "featureImageAdded" ;
const PAGE _ERROR = "postError" ;
const PAGE _ADDED = "postAdded" ;
const PAGE _UPDATED = "postUpdated" ;
const PAGE _DELETED = "postImageAdded" ;
const PAGES _RENDERED = "pagesRendered" ;
const PAGES _NOT _RENDERED = "pagesNotRendered" ;
const TAG _PAGES _RENDERED = "tagPagesRendered" ;
const TAG _PAGES _NOT _RENDERED = "tagPagesNotRendered" ;
const SETTINGS _UPDATED = "settingsUpdated" ;
const SETTINGS _NOT _UPDATED = "settingsNotUpdated" ;
const MENU _ADD _ITEM = "menuAddItem" ;
const MENU _DELETE _ITEM = "menuDeleteItem" ;
const MENU _UPDATED = "menuUpdated" ;
const AVATAR _UPLOADED = "avatarUploaded" ;
const SITE _BACKGROUND _UPLOADED = "siteBackgroundUploaded" ;
const UPLOAD _PROGRESS = "uploadProgress" ;
const API _PAGE _WRITE = "writingItDown" ;
const API _PAGE _CREATE = "writingNewEntry" ;
const API _PAGE _DELETE = "erasingPage" ;
const API _SETTINGS _WRITE = "savingSettings" ;
const API _BACKUP _CREATE = "createBackup" ;
const API _BACKUP _DOWNLOAD = "downloadBackup" ;
const API _BACKUP _RESTORE = "downloadBackup" ;
const API _IMAGES _UPLOAD = "uploadProfileImages" ;
const API _RENDER _PAGES = "renderPages" ;
const API _REINDEX _PAGES = "reindexPages" ;
const API _INIT = "blogInit" ;
const API _INIT _GOOD = "blogInitGood" ;
const API _INIT _LAME = "blogInitLame" ;
const API _GET _SECRET = "retrieveSecret" ;
const API _RESET _PASS = "resetPassword" ;
const SEND _MAIL = "sendMail" ;
class DataEvent {
}
exports . default = new DataEvent ( ) ;
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "7hyn2" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
var _postIndex = require ( "./PostIndex" ) ;
var _postIndexDefault = parcelHelpers . interopDefault ( _postIndex ) ;
var _settingsIndex = require ( "./SettingsIndex" ) ;
var _settingsIndexDefault = parcelHelpers . interopDefault ( _settingsIndex ) ;
var _navIndex = require ( "./NavIndex" ) ;
var _navIndexDefault = parcelHelpers . interopDefault ( _navIndex ) ;
class DashManager {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
this . currentDisplay = '' ;
this . urlPieces = document . URL . split ( '/' ) ;
this . chooseDisplay ( this . urlPieces [ 4 ] , this . urlPieces [ 5 ] ) ;
}
// methods
//--------------------------
start ( ) {
}
chooseDisplay ( section , page ) {
this . currentDisplay = '' ;
switch ( section ) {
case 'page' :
this . currentDisplay = new _postIndexDefault . default ( page ) ;
break ;
case 'settings' :
this . currentDisplay = new _settingsIndexDefault . default ( ) ;
break ;
case 'navigation' :
this . currentDisplay = new _navIndexDefault . default ( ) ;
break ;
default :
break ;
}
this . start ( ) ;
}
}
exports . default = DashManager ;
} , { "./PostIndex" : "k5HNa" , "./SettingsIndex" : "js2Fi" , "./NavIndex" : "9sqHb" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "k5HNa" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
var _pageEditor = require ( "./PageEditor" ) ;
var _pageEditorDefault = parcelHelpers . interopDefault ( _pageEditor ) ;
class PostIndex {
//--------------------------
// constructor
//--------------------------
constructor ( page ) {
this . currentPage = null ;
this . choosePage ( page ) ;
this . start ( ) ;
}
// methods
//--------------------------
start ( ) {
}
choosePage ( page1 ) {
this . currentPage = "" ;
switch ( page1 ) {
case "edit" :
case "add" :
this . currentPage = new _pageEditorDefault . default ( ) ;
break ;
default :
break ;
}
}
}
exports . default = PostIndex ;
} , { "./PageEditor" : "dJ1gj" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "dJ1gj" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
//TOOLS
var _fipamoAdminAPI = require ( "../../libraries/FipamoAdminAPI" ) ;
var _fipamoAdminAPIDefault = parcelHelpers . interopDefault ( _fipamoAdminAPI ) ;
var _maintenanceManager = require ( "./MaintenanceManager" ) ;
var _maintenanceManagerDefault = parcelHelpers . interopDefault ( _maintenanceManager ) ;
var _dataEvent = require ( "../events/DataEvent" ) ;
var _pageActions = require ( "../actions/PageActions" ) ;
var _pageActionsDefault = parcelHelpers . interopDefault ( _pageActions ) ;
var _editorEvent = require ( "../events/EditorEvent" ) ; //import TinyDatePicker from 'tiny-date-picker'; TODO: Reactivate for scheduled publishing
var _textEditor = require ( "../ui/TextEditor" ) ;
var _textEditorDefault = parcelHelpers . interopDefault ( _textEditor ) ;
var _notifications = require ( "../ui/Notifications" ) ;
var _notificationsDefault = parcelHelpers . interopDefault ( _notifications ) ;
var _fileManager = require ( "../ui/FileManager" ) ;
var _fileManagerDefault = parcelHelpers . interopDefault ( _fileManager ) ;
const notify = new _notificationsDefault . default ( ) ;
class PostEditor {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
this . processing = false ;
let self = 'this' ;
this . admin = new _fipamoAdminAPIDefault . default ( null , document . getElementById ( 'notify-progress' ) ) ;
this . mm = new _maintenanceManagerDefault . default ( null , null , document . getElementById ( 'notify-progress' ) ) ;
this . urlPieces = document . URL . split ( '/' ) ;
this . post = [ ] ;
this . postID = null ;
this . postUUID = null ;
this . postLayout = null ;
this . fm = 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' ) ) {
this . editor = new _textEditorDefault . default ( document . getElementById ( 'edit' ) , document . getElementById ( 'header' ) . offsetHeight + document . getElementById ( 'post-header' ) . offsetHeight + document . getElementById ( 'post-feature' ) . offsetHeight ) ;
this . editor . addListener ( _editorEvent . EDITOR _DELETE , ( ) => this . handleEditorOptions ( _editorEvent . EDITOR _DELETE )
, false ) ;
this . editor . addListener ( _editorEvent . EDITOR _UPLOAD _POST _IMAGE , ( ) => this . handleEditorOptions ( _editorEvent . EDITOR _UPLOAD _POST _IMAGE )
, false ) ;
this . editor . addListener ( _editorEvent . EDITOR _UPDATE , ( ) => this . handleEditorOptions ( _editorEvent . EDITOR _UPDATE )
, false ) ;
this . editor . addListener ( _editorEvent . EDITOR _SAVE , ( ) => this . handleEditorOptions ( _editorEvent . EDITOR _SAVE )
, false ) ;
document . getElementById ( 'post-image-upload' ) . addEventListener ( 'change' , ( e ) => {
this . handleImageUpload ( e . target . id , e . target . files ) ;
} , false ) ;
/ *
TinyDatePicker ( document . getElementById ( 'post-date' ) , {
mode : 'dp-below' ,
format ( ) {
//return self.dateUtils.getDate('origin', date);
}
} ) ;
* / t h i s . s t a r t ( ) ;
}
}
// methods
//--------------------------
start ( ) {
if ( document . getElementById ( 'page-file-drop' ) ) {
//insert fileManager here
this . fm = new _fileManagerDefault . default ( document . getElementById ( 'page-file-drop' ) , document . getElementById ( 'page-files-upload' ) , document . getElementById ( 'page-images-list' ) , document . getElementById ( 'page-files-list' ) ) ;
var optionButtons = document . querySelectorAll ( '.post-option-btn' ) ;
for ( var i = 0 , length = optionButtons . length ; i < length ; i ++ ) optionButtons [ i ] . addEventListener ( 'click' , ( e ) => this . handlePostOptions ( e )
, false ) ;
}
}
// event handlers
//--------------------------
handlePostOptions ( e ) {
let currentOption = null ;
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 ;
}
if ( currentOption != null ) {
let active = currentOption . getAttribute ( 'data-active' ) ;
active == 'false' ? currentOption . setAttribute ( 'data-active' , 'true' ) : currentOption . setAttribute ( 'data-active' , 'false' ) ;
}
}
handleEditorOptions ( e1 ) {
if ( this . processing ) return ;
let self = this ;
switch ( e1 ) {
case _editorEvent . EDITOR _SAVE :
case _editorEvent . EDITOR _UPDATE :
var task = '' ;
e1 === _editorEvent . EDITOR _SAVE ? task = _fipamoAdminAPI . TASK _PAGE _CREATE : task = _fipamoAdminAPI . TASK _PAGE _EDIT ;
new _pageActionsDefault . default ( ) . collectInfo ( this . fm . getFiles ( ) ) . then ( ( page ) => {
self . processing = true ;
notify . alert ( 'Writing down changes' , null ) ;
self . admin . pageActions ( task , page ) . then ( ( r ) => {
self . processing = false ;
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 ( ( err ) => {
self . processing = false ;
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?" ) ) new _pageActionsDefault . default ( ) . collectInfo ( document . getElementById ( 'featured-image-upload' ) . files [ 0 ] ) . then ( ( page ) => {
self . processing = true ;
this . admin . pageActions ( _fipamoAdminAPI . TASK _PAGE _DELETE , page ) . then ( ( ) => {
self . processing = false ;
window . location = '/dashboard/pages' ;
} ) . catch ( ( err ) => {
self . processing = false ;
notify . alert ( err , false ) ;
} ) ;
} ) . catch ( ( ) => {
} ) ;
break ;
case _editorEvent . EDITOR _UPLOAD _POST _IMAGE :
document . getElementById ( 'post-image-upload' ) . click ( ) ;
break ;
}
}
handleImageUpload ( type , files ) {
let self = this ;
notify . alert ( 'Uploading Image' , null ) ;
self . mm . imageUpload ( type , files ) . then ( ( r ) => {
if ( r . type == _dataEvent . POST _IMAGE _ADDED ) {
self . editor . notify ( _editorEvent . EDITOR _UPLOAD _POST _IMAGE , r . url ) ;
notify . alert ( 'Image Added to Entry' , true ) ;
} else notify . alert ( 'Uh oh. Image not added' , false ) ;
} ) . catch ( ( ) => {
notify . alert ( 'Uh oh. Image not added' , false ) ; //console.log('ERROR', err);
} ) ;
}
}
exports . default = PostEditor ;
PostEditor . uploadFiles = [ ] ;
} , { "../../libraries/FipamoAdminAPI" : "6M96o" , "./MaintenanceManager" : "kY7L1" , "../events/DataEvent" : "edzJV" , "../actions/PageActions" : "5t6eY" , "../events/EditorEvent" : "dW8iq" , "../ui/TextEditor" : "bMFpA" , "../ui/Notifications" : "fmUxI" , "../ui/FileManager" : "kp4D5" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "5t6eY" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
var _stringUtils = require ( "../utils/StringUtils" ) ;
var _stringUtilsDefault = parcelHelpers . interopDefault ( _stringUtils ) ;
class PostActions {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
}
// methods
//--------------------------
collectInfo ( files ) {
return new Promise ( ( resolve , reject ) => {
let pageInfo = new FormData ( ) ;
let txt = document . createElement ( 'textarea' ) ;
txt . innerHTML = document . getElementById ( 'highlight-content' ) . innerHTML ;
let html = txt . value ;
html = html . replace ( /<\/?span[^>]*>/g , '' ) ; //removes prism 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 _stringUtilsDefault . 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' ) ) ;
pageInfo . append ( 'layout' , document . getElementById ( 'page-templates' ) . value ) ;
pageInfo . append ( 'form_token' , document . getElementById ( 'form_token' ) . value ) ;
if ( files . length > 0 && files != null ) for ( var i = 0 ; i < files . length ; i ++ ) {
var file = files [ i ] ;
if ( file . type . match ( 'image.*' ) || file . type . match ( 'video.mp4' ) || file . type . match ( 'audio.mpeg' ) || file . type . match ( 'application.pdf' ) || file . type . match ( 'text.plain' ) || file . type . match ( 'text.rtf' ) ) pageInfo . append ( 'page_files[]' , file , file . name ) ;
else reject ( 'Not an image file' ) ;
}
else //check to see if image exists
if ( document . getElementById ( 'featured-image' ) ) {
var imageURL = document . getElementById ( 'featured-image' ) . src ;
imageURL != null || imageURL != undefined ? pageInfo . append ( 'feature_image' , imageURL ) : pageInfo . append ( 'feature_image' , null ) ;
}
//console.log("FILES", files);
resolve ( pageInfo ) ;
} ) ;
}
}
exports . default = PostActions ;
} , { "../utils/StringUtils" : "firFv" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "firFv" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
class StringUtils {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
}
// methods
//--------------------------
cleanString ( string ) {
var clean = string . replace ( /(^\-+|[^a-zA-Z0-9\/_| -]+|\-+$)/g , '' ) . toLowerCase ( ) . replace ( /[\/_| -]+/g , '-' ) ;
return clean ;
}
decodeHTML ( string1 , quote _style ) {
var optTemp = 0 , i = 0 , noquotes = false ;
if ( typeof quote _style === 'undefined' ) quote _style = 2 ;
string1 = string1 . 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 ) string1 = string1 . replace ( /�*39;/g , "'" ) ; // PHP doesn't currently escape if more than one 0, but it should
if ( ! noquotes ) string1 = string1 . replace ( /"/g , '"' ) ;
// Put this in last place to avoid escape being double-decoded
string1 = string1 . replace ( /&/g , '&' ) ;
return string1 ;
}
}
exports . default = StringUtils ;
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "dW8iq" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
parcelHelpers . export ( exports , "EDITOR_DELETE" , ( ) => EDITOR _DELETE
) ;
parcelHelpers . export ( exports , "EDITOR_UPLOAD_POST_IMAGE" , ( ) => EDITOR _UPLOAD _POST _IMAGE
) ;
parcelHelpers . export ( exports , "EDITOR_SAVE" , ( ) => EDITOR _SAVE
) ;
parcelHelpers . export ( exports , "EDITOR_UPDATE" , ( ) => EDITOR _UPDATE
) ;
const EDITOR _DELETE = 'editorDelete' ;
const EDITOR _UPLOAD _POST _IMAGE = 'editorUploadImage' ;
const EDITOR _SAVE = 'editorSave' ;
const EDITOR _UPDATE = 'editorUpdate' ;
class EditorEvent {
}
exports . default = new EditorEvent ( ) ;
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "bMFpA" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
var _dataEvent = require ( "../events/DataEvent" ) ;
var _caretPos = require ( "caret-pos" ) ;
var _eventEmitter = require ( "../events/EventEmitter" ) ;
var _eventEmitterDefault = parcelHelpers . interopDefault ( _eventEmitter ) ;
var _editorEvent = require ( "../events/EditorEvent" ) ;
var _prismCore = require ( "prismjs/components/prism-core" ) ;
var _prismCoreDefault = parcelHelpers . interopDefault ( _prismCore ) ;
var _prismMarkup = require ( "prismjs/components/prism-markup" ) ;
var _prismMarkdown = require ( "prismjs/components/prism-markdown" ) ;
class TextEditor extends _eventEmitterDefault . default {
/ * *
* 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
//--------------------------
constructor ( textEditor , scrollLimit ) {
super ( ) ;
document . getElementById ( "edit" ) . addEventListener ( "input" , ( e ) => {
let result _element = document . querySelector ( "#highlight-content" ) ;
this . textEditor = textEditor ; // Update code
let text = e . target . value ;
result _element . innerHTML = text . replace ( new RegExp ( "&" , "g" ) , "&" ) . replace ( new RegExp ( "<" , "g" ) , "<" ) ;
let editorHeight = document . getElementById ( "highlight" ) . offsetHeight ;
document . getElementById ( "edit-post-wrapper" ) . style . height = editorHeight + "px" ;
e . target . style . height = editorHeight + 30 + "px" ; //TODO: yeah, it's ugly but it works for now, fix soon
// Syntax Highlight
_prismCoreDefault . default . highlightElement ( result _element ) ;
} ) ;
document . getElementById ( "edit" ) . addEventListener ( "scroll" , ( e ) => {
/* Scroll result to scroll coords of event - sync with textarea */ let result _element = document . querySelector ( "#highlight" ) ; // Get and set x and y
result _element . scrollTop = e . scrollTop ;
result _element . scrollLeft = e . scrollLeft ;
} ) ;
document . getElementById ( "edit" ) . dispatchEvent ( new Event ( "input" ) ) ;
this . setInputs ( ) ; //freeze editor formatting so it doesn't scroll off screen
window . addEventListener ( "scroll" , ( ) => {
var fixLimit = scrollLimit ;
if ( window . pageYOffset + 5 >= fixLimit ) document . getElementById ( "edit-control" ) . style . position = "fixed" ;
else document . getElementById ( "edit-control" ) . style . position = "relative" ;
} ) ;
}
// methods
//--------------------------
setInputs ( ) {
var editorButtons = document . querySelectorAll ( ".editor-button" ) ;
for ( var i = 0 , length = editorButtons . length ; i < length ; i ++ ) editorButtons [ i ] . addEventListener ( "click" , ( e ) => this . handleEditorOption ( e )
, false ) ;
}
notify ( type , data ) {
switch ( type ) {
case _dataEvent . PAGE _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 ( ( ) => {
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 . PAGE _ADDED :
break ;
case _editorEvent . EDITOR _UPLOAD _POST _IMAGE :
{
let len = this . textEditor . value . length ;
let start = this . textEditor . selectionStart ;
let end = this . textEditor . selectionEnd ;
let insert = "![image alt text](" + data + ")" ;
this . textEditor . value = this . textEditor . value . substring ( 0 , start ) + insert + this . textEditor . value . substring ( end , len ) ;
document . getElementById ( "edit" ) . dispatchEvent ( new Event ( "input" ) ) ;
break ;
}
}
}
// event handlers
//--------------------------
handleEditorOption ( e ) {
e . preventDefault ( ) ;
let len = this . textEditor . value . length ;
let start = this . textEditor . selectionStart ;
let end = this . textEditor . selectionEnd ;
let selectedText = this . textEditor . value . substring ( start , end ) ;
let insert = "" ;
switch ( e . target . id ) {
case "edit-bold" :
insert = "**" + selectedText + "**" ;
this . textEditor . value = this . textEditor . value . substring ( 0 , start ) + insert + this . textEditor . value . substring ( end , len ) ;
break ;
case "edit-italic" :
insert = "*" + selectedText + "*" ; //console.log(this.textEditor);
this . textEditor . value = this . textEditor . value . substring ( 0 , start ) + insert + this . textEditor . value . substring ( end , len ) ;
break ;
case "edit-strikethrough" :
insert = "~~" + selectedText + "~~" ;
this . textEditor . value = this . textEditor . value . substring ( 0 , start ) + insert + this . textEditor . value . substring ( end , len ) ;
break ;
case "edit-header1" :
insert = "# " + selectedText + "\n" ;
this . textEditor . value = this . textEditor . value . substring ( 0 , start ) + insert + this . textEditor . value . substring ( end , len ) ;
break ;
case "edit-header2" :
insert = "## " + selectedText + "\n" ;
this . textEditor . value = this . textEditor . value . substring ( 0 , start ) + insert + this . textEditor . value . substring ( end , len ) ;
break ;
case "edit-header3" :
insert = "### " + selectedText + "\n" ;
this . textEditor . value = this . textEditor . value . substring ( 0 , start ) + insert + this . textEditor . value . substring ( end , len ) ;
break ;
case "edit-link" :
{
let url = prompt ( "Let's get that url, boss" ) ;
let link = url . toLowerCase ( ) ;
insert = "[" + selectedText + "](" + link + ")" ;
this . textEditor . value = this . textEditor . value . substring ( 0 , start ) + insert + this . textEditor . value . substring ( end , len ) ;
}
break ;
case "edit-image" :
this . caretPos = _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-delete" :
this . emitEvent ( _editorEvent . EDITOR _DELETE ) ;
break ;
default :
break ;
}
document . getElementById ( "edit" ) . dispatchEvent ( new Event ( "input" ) ) ;
}
}
exports . default = TextEditor ;
} , { "../events/DataEvent" : "edzJV" , "caret-pos" : "9lzNv" , "../events/EventEmitter" : "cbFNs" , "../events/EditorEvent" : "dW8iq" , "prismjs/components/prism-core" : "cps8h" , "prismjs/components/prism-markup" : "dIns2" , "prismjs/components/prism-markdown" : "gqRFx" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "9lzNv" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
parcelHelpers . export ( exports , "getOffset" , ( ) => getOffset1
) ;
parcelHelpers . export ( exports , "offset" , ( ) => offset1
) ;
parcelHelpers . export ( exports , "position" , ( ) => position1
) ;
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
* / v a r c r e a t e M i r r o r = f u n c t i o n c r e a t e M i r r o r ( e l e m e n t , h t m l 1 ) {
/ * *
* The mirror element
* / v a r m i r r o r = d o c u m e n t . c r e a t e E l e m e n t ( ' d i v ' ) ;
/ * *
* Create the CSS for the mirror object
*
* @ return { object } The style object
* / v a r m i r r o r C s s = f u n c t i o n m i r r o r C s s ( ) {
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 }
* / v a r i n i t i a l i z e = f u n c t i o n i n i t i a l i z e ( h t m l ) {
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
* / v a r r e c t = f u n c t i o n r e c t ( ) {
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 ( html1 ) ;
return {
rect : rect
} ;
} ;
function _typeof ( obj1 ) {
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 ( obj1 ) ;
}
/ * *
* Check if a DOM Element is content editable
*
* @ param { Element } element The DOM element
*
* @ return { bool } If it is content editable
* / v a r i s C o n t e n t E d i t a b l e = f u n c t i o n i s C o n t e n t E d i t a b l e ( e l e m e n t ) {
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
* / v a r g e t C o n t e x t = f u n c t i o n g e t C o n t e x t ( ) {
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
* / v a r g e t O f f s e t 1 = f u n c t i o n g e t O f f s e t ( e l e m e n t , c t x ) {
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
* / v a r i s O b j e c t = f u n c t i o n i s O b j e c t ( v a l u e ) {
return _typeof ( value ) === 'object' && value !== null ;
} ;
/ * *
* Create a Input caret object .
*
* @ param { Element } element The element
* @ param { Object } ctx The context
* / v a r c r e a t e I n p u t C a r e t = f u n c t i o n c r e a t e I n p u t C a r e t ( e l e m e n t , c t x ) {
/ * *
* Get the current position
*
* @ returns { int } The caret position
* / v a r g e t P o s = f u n c t i o n g e t P o s ( ) {
return element . selectionStart ;
} ;
/ * *
* Set the position
*
* @ param { int } pos The position
*
* @ return { Element } The element
* / v a r s e t P o s = f u n c t i o n s e t P o s ( p o s ) {
element . setSelectionRange ( pos , pos ) ;
return element ;
} ;
/ * *
* The offset
*
* @ param { int } pos The position
*
* @ return { object } The offset
* / v a r g e t O f f s e t $ 1 = f u n c t i o n g e t O f f s e t $ 1 ( p o s ) {
var rect = getOffset1 ( 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
* / v a r g e t P o s i t i o n = f u n c t i o n g e t P o s i t i o n ( p o s ) {
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;\">" . concat ( format ( startRange ) , "</span>" ) ;
html += '<span id="caret-position-marker" style="position: relative; display: inline;">|</span>' ;
html += "<span style=\"position: relative; display: inline;\">" . concat ( 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 }
* / v a r c r e a t e E d i t a b l e C a r e t = f u n c t i o n c r e a t e E d i t a b l e C a r e t ( e l e m e n t , c t x ) {
/ * *
* Set the caret position
*
* @ param { int } pos The position to se
*
* @ return { Element } The element
* / v a r s e t P o s = f u n c t i o n s e t P o s ( p o s ) {
var sel = ctx . window . getSelection ( ) ;
if ( sel ) {
var offset = 0 ;
var found = false ;
var find1 = 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 ) ;
}
} ;
find1 ( pos , element ) ;
}
return element ;
} ;
/ * *
* Get the offset
*
* @ return { object } The offset
* / v a r g e t O f f s e t = f u n c t i o n g e t O f f s e t ( ) {
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
* / v a r g e t P o s i t i o n = f u n c t i o n g e t P o s i t i o n ( ) {
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 }
* / v a r g e t R a n g e = f u n c t i o n g e t R a n g e ( ) {
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
* / v a r g e t P o s = f u n c t i o n g e t P o s ( ) {
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 position1 = 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
* / v a r o f f s e t 1 = f u n c t i o n o f f s e t ( e l e m e n t , v a l u e ) {
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 ) ;
} ;
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "cbFNs" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
class EventEmitter {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
this . listeners = new Map ( ) ;
}
// methods
//--------------------------
addListener ( label , callback ) {
this . listeners . has ( label ) || this . listeners . set ( label , [ ] ) ;
this . listeners . get ( label ) . push ( callback ) ;
}
removeListener ( label1 , callback1 ) {
var isFunction = function ( obj ) {
return typeof obj == 'function' || false ;
} ;
var listeners = this . listeners . get ( label1 ) , index1 ;
if ( listeners && listeners . length ) {
index1 = listeners . reduce ( ( i , listener , index ) => {
return isFunction ( listener ) && listener === callback1 ? i = index : i ;
} , - 1 ) ;
if ( index1 > - 1 ) {
listeners . splice ( index1 , 1 ) ;
this . listeners . set ( label1 , listeners ) ;
return true ;
}
}
return false ;
}
emitEvent ( label2 , ... args ) {
var listeners = this . listeners . get ( label2 ) ;
if ( listeners && listeners . length ) {
listeners . forEach ( ( listener ) => {
listener ( ... args ) ;
} ) ;
return true ;
}
return false ;
}
}
exports . default = EventEmitter ;
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "cps8h" : [ function ( require , module , exports ) {
var global = arguments [ 3 ] ;
/// <reference lib="WebWorker"/>
var _self1 = typeof window !== 'undefined' ? window // if in browser
: typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope ? self // if in worker
: {
} // if in node js
;
/ * *
* Prism : Lightweight , robust , elegant syntax highlighting
*
* @ license MIT < https : //opensource.org/licenses/MIT>
* @ author Lea Verou < https : //lea.verou.me>
* @ namespace
* @ public
* / v a r P r i s m = f u n c t i o n ( _ s e l f ) {
// Private helper vars
var lang1 = /\blang(?:uage)?-([\w-]+)\b/i ;
var uniqueId = 0 ;
// The grammar object for plaintext
var plainTextGrammar = {
} ;
var _ = {
/ * *
* By default , Prism will attempt to highlight all code elements ( by calling { @ link Prism . highlightAll } ) on the
* current page after the page finished loading . This might be a problem if e . g . you wanted to asynchronously load
* additional languages or plugins yourself .
*
* By setting this value to ` true ` , Prism will not automatically highlight all code elements on the page .
*
* You obviously have to change this value before the automatic highlighting started . To do this , you can add an
* empty Prism object into the global scope before loading the Prism script like this :
*
* ` ` ` js
* window . Prism = window . Prism || { } ;
* Prism . manual = true ;
* // add a new <script> to load Prism's script
* ` ` `
*
* @ default false
* @ type { boolean }
* @ memberof Prism
* @ public
* / m a n u a l : _ s e l f . P r i s m & & _ s e l f . P r i s m . m a n u a l ,
disableWorkerMessageHandler : _self . Prism && _self . Prism . disableWorkerMessageHandler ,
/ * *
* A namespace for utility methods .
*
* All function in this namespace that are not explicitly marked as _public _ are for _ _internal use only _ _ and may
* change or disappear at any time .
*
* @ namespace
* @ memberof Prism
* / u t i l : {
encode : function encode ( tokens ) {
if ( tokens instanceof Token ) return new Token ( tokens . type , encode ( tokens . content ) , tokens . alias ) ;
else if ( Array . isArray ( tokens ) ) return tokens . map ( encode ) ;
else return tokens . replace ( /&/g , '&' ) . replace ( /</g , '<' ) . replace ( /\u00a0/g , ' ' ) ;
} ,
/ * *
* Returns the name of the type of the given value .
*
* @ param { any } o
* @ returns { string }
* @ example
* type ( null ) === 'Null'
* type ( undefined ) === 'Undefined'
* type ( 123 ) === 'Number'
* type ( 'foo' ) === 'String'
* type ( true ) === 'Boolean'
* type ( [ 1 , 2 ] ) === 'Array'
* type ( { } ) === 'Object'
* type ( String ) === 'Function'
* type ( /abc+/ ) === 'RegExp'
* / t y p e : f u n c t i o n ( o ) {
return Object . prototype . toString . call ( o ) . slice ( 8 , - 1 ) ;
} ,
/ * *
* Returns a unique number for the given object . Later calls will still return the same number .
*
* @ param { Object } obj
* @ returns { number }
* / o b j I d : f u n c t i o n ( o b j ) {
if ( ! obj [ '__id' ] ) Object . defineProperty ( obj , '__id' , {
value : ++ uniqueId
} ) ;
return obj [ '__id' ] ;
} ,
/ * *
* Creates a deep clone of the given object .
*
* The main intended use of this function is to clone language definitions .
*
* @ param { T } o
* @ param { Record < number , any > } [ visited ]
* @ returns { T }
* @ template T
* / c l o n e : f u n c t i o n d e e p C l o n e ( o , v i s i t e d ) {
visited = visited || {
} ;
var clone ;
var id ;
switch ( _ . util . type ( o ) ) {
case 'Object' :
id = _ . util . objId ( o ) ;
if ( visited [ id ] ) return visited [ id ] ;
clone = {
} ;
visited [ id ] = clone ;
for ( var key in o ) if ( o . hasOwnProperty ( key ) ) clone [ key ] = deepClone ( o [ key ] , visited ) ;
return clone ;
case 'Array' :
id = _ . util . objId ( o ) ;
if ( visited [ id ] ) return visited [ id ] ;
clone = [ ] ;
visited [ id ] = clone ;
o . forEach ( function ( v , i ) {
clone [ i ] = deepClone ( v , visited ) ;
} ) ;
return clone ;
default :
return o ;
}
} ,
/ * *
* Returns the Prism language of the given element set by a ` language-xxxx ` or ` lang-xxxx ` class .
*
* If no language is set for the element or the element is ` null ` or ` undefined ` , ` none ` will be returned .
*
* @ param { Element } element
* @ returns { string }
* / g e t L a n g u a g e : f u n c t i o n ( e l e m e n t ) {
while ( element && ! lang1 . test ( element . className ) ) element = element . parentElement ;
if ( element ) return ( element . className . match ( lang1 ) || [
,
'none'
] ) [ 1 ] . toLowerCase ( ) ;
return 'none' ;
} ,
/ * *
* Returns the script element that is currently executing .
*
* This does _ _not _ _ work for line script element .
*
* @ returns { HTMLScriptElement | null }
* / c u r r e n t S c r i p t : f u n c t i o n ( ) {
if ( typeof document === 'undefined' ) return null ;
if ( 'currentScript' in document && true /* hack to trip TS' flow analysis */ ) return document . currentScript ;
// IE11 workaround
// we'll get the src of the current script by parsing IE11's error stack trace
// this will not work for inline scripts
try {
throw new Error ( ) ;
} catch ( err ) {
// Get file src url from stack. Specifically works with the format of stack traces in IE.
// A stack will look like this:
//
// Error
// at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
// at Global code (http://localhost/components/prism-core.js:606:1)
var src = ( /at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i . exec ( err . stack ) || [ ] ) [ 1 ] ;
if ( src ) {
var scripts = document . getElementsByTagName ( 'script' ) ;
for ( var i in scripts ) {
if ( scripts [ i ] . src == src ) return scripts [ i ] ;
}
}
return null ;
}
} ,
/ * *
* Returns whether a given class is active for ` element ` .
*
* The class can be activated if ` element ` or one of its ancestors has the given class and it can be deactivated
* if ` element ` or one of its ancestors has the negated version of the given class . The _negated version _ of the
* given class is just the given class with a ` no- ` prefix .
*
* Whether the class is active is determined by the closest ancestor of ` element ` ( where ` element ` itself is
* closest ancestor ) that has the given class or the negated version of it . If neither ` element ` nor any of its
* ancestors have the given class or the negated version of it , then the default activation will be returned .
*
* In the paradoxical situation where the closest ancestor contains _ _both _ _ the given class and the negated
* version of it , the class is considered active .
*
* @ param { Element } element
* @ param { string } className
* @ param { boolean } [ defaultActivation = false ]
* @ returns { boolean }
* / i s A c t i v e : f u n c t i o n ( e l e m e n t , c l a s s N a m e , d e f a u l t A c t i v a t i o n ) {
var no = 'no-' + className ;
while ( element ) {
var classList = element . classList ;
if ( classList . contains ( className ) ) return true ;
if ( classList . contains ( no ) ) return false ;
element = element . parentElement ;
}
return ! ! defaultActivation ;
}
} ,
/ * *
* This namespace contains all currently loaded languages and the some helper functions to create and modify languages .
*
* @ namespace
* @ memberof Prism
* @ public
* / l a n g u a g e s : {
/ * *
* The grammar for plain , unformatted text .
* / p l a i n : p l a i n T e x t G r a m m a r ,
plaintext : plainTextGrammar ,
text : plainTextGrammar ,
txt : plainTextGrammar ,
/ * *
* Creates a deep copy of the language with the given id and appends the given tokens .
*
* If a token in ` redef ` also appears in the copied language , then the existing token in the copied language
* will be overwritten at its original position .
*
* # # Best practices
*
* Since the position of overwriting tokens ( token in ` redef ` that overwrite tokens in the copied language )
* doesn ' t matter , they can technically be in any order . However , this can be confusing to others that trying to
* understand the language definition because , normally , the order of tokens matters in Prism grammars .
*
* Therefore , it is encouraged to order overwriting tokens according to the positions of the overwritten tokens .
* Furthermore , all non - overwriting tokens should be placed after the overwriting ones .
*
* @ param { string } id The id of the language to extend . This has to be a key in ` Prism.languages ` .
* @ param { Grammar } redef The new tokens to append .
* @ returns { Grammar } The new language created .
* @ public
* @ example
* Prism . languages [ 'css-with-colors' ] = Prism . languages . extend ( 'css' , {
* // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
* // at its original position
* 'comment' : { ... } ,
* // CSS doesn't have a 'color' token, so this token will be appended
* 'color' : /\b(?:red|green|blue)\b/
* } ) ;
* / e x t e n d : f u n c t i o n ( i d , r e d e f ) {
var lang = _ . util . clone ( _ . languages [ id ] ) ;
for ( var key in redef ) lang [ key ] = redef [ key ] ;
return lang ;
} ,
/ * *
* Inserts tokens _before _ another token in a language definition or any other grammar .
*
* # # Usage
*
* This helper method makes it easy to modify existing languages . For example , the CSS language definition
* not only defines CSS highlighting for CSS documents , but also needs to define highlighting for CSS embedded
* in HTML through ` <style> ` elements . To do this , it needs to modify ` Prism.languages.markup ` and add the
* appropriate tokens . However , ` Prism.languages.markup ` is a regular JavaScript object literal , so if you do
* this :
*
* ` ` ` js
* Prism . languages . markup . style = {
* // token
* } ;
* ` ` `
*
* then the ` style ` token will be added ( and processed ) at the end . ` insertBefore ` allows you to insert tokens
* before existing tokens . For the CSS example above , you would use it like this :
*
* ` ` ` js
* Prism . languages . insertBefore ( 'markup' , 'cdata' , {
* 'style' : {
* // token
* }
* } ) ;
* ` ` `
*
* # # Special cases
*
* If the grammars of ` inside ` and ` insert ` have tokens with the same name , the tokens in ` inside ` ' s grammar
* will be ignored .
*
* This behavior can be used to insert tokens after ` before ` :
*
* ` ` ` js
* Prism . languages . insertBefore ( 'markup' , 'comment' , {
* 'comment' : Prism . languages . markup . comment ,
* // tokens after 'comment'
* } ) ;
* ` ` `
*
* # # Limitations
*
* The main problem ` insertBefore ` has to solve is iteration order . Since ES2015 , the iteration order for object
* properties is guaranteed to be the insertion order ( except for integer keys ) but some browsers behave
* differently when keys are deleted and re - inserted . So ` insertBefore ` can ' t be implemented by temporarily
* deleting properties which is necessary to insert at arbitrary positions .
*
* To solve this problem , ` insertBefore ` doesn ' t actually insert the given tokens into the target object .
* Instead , it will create a new object and replace all references to the target object with the new one . This
* can be done without temporarily deleting properties , so the iteration order is well - defined .
*
* However , only references that can be reached from ` Prism.languages ` or ` insert ` will be replaced . I . e . if
* you hold the target object in a variable , then the value of the variable will not change .
*
* ` ` ` js
* var oldMarkup = Prism . languages . markup ;
* var newMarkup = Prism . languages . insertBefore ( 'markup' , 'comment' , { ... } ) ;
*
* assert ( oldMarkup !== Prism . languages . markup ) ;
* assert ( newMarkup === Prism . languages . markup ) ;
* ` ` `
*
* @ param { string } inside The property of ` root ` ( e . g . a language id in ` Prism.languages ` ) that contains the
* object to be modified .
* @ param { string } before The key to insert before .
* @ param { Grammar } insert An object containing the key - value pairs to be inserted .
* @ param { Object < string , any > } [ root ] The object containing ` inside ` , i . e . the object that contains the
* object to be modified .
*
* Defaults to ` Prism.languages ` .
* @ returns { Grammar } The new grammar object .
* @ public
* / i n s e r t B e f o r e : f u n c t i o n ( i n s i d e , b e f o r e , i n s e r t , r o o t ) {
root = root || _ . languages ;
var grammar = root [ inside ] ;
/** @type {Grammar} */ var ret = {
} ;
for ( var token in grammar ) if ( grammar . hasOwnProperty ( token ) ) {
if ( token == before ) {
for ( var newToken in insert ) if ( insert . hasOwnProperty ( newToken ) ) ret [ newToken ] = insert [ newToken ] ;
}
// Do not insert token which also occur in insert. See #1525
if ( ! insert . hasOwnProperty ( token ) ) ret [ token ] = grammar [ token ] ;
}
var old = root [ inside ] ;
root [ inside ] = ret ;
// Update references in other language definitions
_ . languages . DFS ( _ . languages , function ( key , value ) {
if ( value === old && key != inside ) this [ key ] = ret ;
} ) ;
return ret ;
} ,
// Traverse a language definition with Depth First Search
DFS : function DFS ( o , callback , type , visited ) {
visited = visited || {
} ;
var objId = _ . util . objId ;
for ( var i in o ) if ( o . hasOwnProperty ( i ) ) {
callback . call ( o , i , o [ i ] , type || i ) ;
var property = o [ i ] ;
var propertyType = _ . util . type ( property ) ;
if ( propertyType === 'Object' && ! visited [ objId ( property ) ] ) {
visited [ objId ( property ) ] = true ;
DFS ( property , callback , null , visited ) ;
} else if ( propertyType === 'Array' && ! visited [ objId ( property ) ] ) {
visited [ objId ( property ) ] = true ;
DFS ( property , callback , i , visited ) ;
}
}
}
} ,
plugins : {
} ,
/ * *
* This is the most high - level function in Prism ’ s API .
* It fetches all the elements that have a ` .language-xxxx ` class and then calls { @ link Prism . highlightElement } on
* each one of them .
*
* This is equivalent to ` Prism.highlightAllUnder(document, async, callback) ` .
*
* @ param { boolean } [ async = false ] Same as in { @ link Prism . highlightAllUnder } .
* @ param { HighlightCallback } [ callback ] Same as in { @ link Prism . highlightAllUnder } .
* @ memberof Prism
* @ public
* / h i g h l i g h t A l l : f u n c t i o n ( a s y n c , c a l l b a c k ) {
_ . highlightAllUnder ( document , async , callback ) ;
} ,
/ * *
* Fetches all the descendants of ` container ` that have a ` .language-xxxx ` class and then calls
* { @ link Prism . highlightElement } on each one of them .
*
* The following hooks will be run :
* 1. ` before-highlightall `
* 2. ` before-all-elements-highlight `
* 3. All hooks of { @ link Prism . highlightElement } for each element .
*
* @ param { ParentNode } container The root element , whose descendants that have a ` .language-xxxx ` class will be highlighted .
* @ param { boolean } [ async = false ] Whether each element is to be highlighted asynchronously using Web Workers .
* @ param { HighlightCallback } [ callback ] An optional callback to be invoked on each element after its highlighting is done .
* @ memberof Prism
* @ public
* / h i g h l i g h t A l l U n d e r : f u n c t i o n ( c o n t a i n e r , a s y n c , c a l l b a c k ) {
var env = {
callback : callback ,
container : container ,
selector : 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
} ;
_ . hooks . run ( 'before-highlightall' , env ) ;
env . elements = Array . prototype . slice . apply ( env . container . querySelectorAll ( env . selector ) ) ;
_ . hooks . run ( 'before-all-elements-highlight' , env ) ;
for ( var i = 0 , element ; element = env . elements [ i ++ ] ; ) _ . highlightElement ( element , async === true , env . callback ) ;
} ,
/ * *
* Highlights the code inside a single element .
*
* The following hooks will be run :
* 1. ` before-sanity-check `
* 2. ` before-highlight `
* 3. All hooks of { @ link Prism . highlight } . These hooks will be run by an asynchronous worker if ` async ` is ` true ` .
* 4. ` before-insert `
* 5. ` after-highlight `
* 6. ` complete `
*
* Some the above hooks will be skipped if the element doesn ' t contain any text or there is no grammar loaded for
* the element ' s language .
*
* @ param { Element } element The element containing the code .
* It must have a class of ` language-xxxx ` to be processed , where ` xxxx ` is a valid language identifier .
* @ param { boolean } [ async = false ] Whether the element is to be highlighted asynchronously using Web Workers
* to improve performance and avoid blocking the UI when highlighting very large chunks of code . This option is
* [ disabled by default ] ( https : //prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
*
* Note : All language definitions required to highlight the code must be included in the main ` prism.js ` file for
* asynchronous highlighting to work . You can build your own bundle on the
* [ Download page ] ( https : //prismjs.com/download.html).
* @ param { HighlightCallback } [ callback ] An optional callback to be invoked after the highlighting is done .
* Mostly useful when ` async ` is ` true ` , since in that case , the highlighting is done asynchronously .
* @ memberof Prism
* @ public
* / h i g h l i g h t E l e m e n t : f u n c t i o n ( e l e m e n t , a s y n c , c a l l b a c k ) {
// Find language
var language = _ . util . getLanguage ( element ) ;
var grammar = _ . languages [ language ] ;
// Set language on the element, if not present
element . className = element . className . replace ( lang1 , '' ) . replace ( /\s+/g , ' ' ) + ' language-' + language ;
// Set language on the parent, for styling
var parent = element . parentElement ;
if ( parent && parent . nodeName . toLowerCase ( ) === 'pre' ) parent . className = parent . className . replace ( lang1 , '' ) . replace ( /\s+/g , ' ' ) + ' language-' + language ;
var code = element . textContent ;
var env = {
element : element ,
language : language ,
grammar : grammar ,
code : code
} ;
function insertHighlightedCode ( highlightedCode ) {
env . highlightedCode = highlightedCode ;
_ . hooks . run ( 'before-insert' , env ) ;
env . element . innerHTML = env . highlightedCode ;
_ . hooks . run ( 'after-highlight' , env ) ;
_ . hooks . run ( 'complete' , env ) ;
callback && callback . call ( env . element ) ;
}
_ . hooks . run ( 'before-sanity-check' , env ) ;
// plugins may change/add the parent/element
parent = env . element . parentElement ;
if ( parent && parent . nodeName . toLowerCase ( ) === 'pre' && ! parent . hasAttribute ( 'tabindex' ) ) parent . setAttribute ( 'tabindex' , '0' ) ;
if ( ! env . code ) {
_ . hooks . run ( 'complete' , env ) ;
callback && callback . call ( env . element ) ;
return ;
}
_ . hooks . run ( 'before-highlight' , env ) ;
if ( ! env . grammar ) {
insertHighlightedCode ( _ . util . encode ( env . code ) ) ;
return ;
}
if ( async && _self . Worker ) {
var worker = new Worker ( _ . filename ) ;
worker . onmessage = function ( evt ) {
insertHighlightedCode ( evt . data ) ;
} ;
worker . postMessage ( JSON . stringify ( {
language : env . language ,
code : env . code ,
immediateClose : true
} ) ) ;
} else insertHighlightedCode ( _ . highlight ( env . code , env . grammar , env . language ) ) ;
} ,
/ * *
* Low - level function , only use if you know what you ’ re doing . It accepts a string of text as input
* and the language definitions to use , and returns a string with the HTML produced .
*
* The following hooks will be run :
* 1. ` before-tokenize `
* 2. ` after-tokenize `
* 3. ` wrap ` : On each { @ link Token } .
*
* @ param { string } text A string with the code to be highlighted .
* @ param { Grammar } grammar An object containing the tokens to use .
*
* Usually a language definition like ` Prism.languages.markup ` .
* @ param { string } language The name of the language definition passed to ` grammar ` .
* @ returns { string } The highlighted HTML .
* @ memberof Prism
* @ public
* @ example
* Prism . highlight ( 'var foo = true;' , Prism . languages . javascript , 'javascript' ) ;
* / h i g h l i g h t : f u n c t i o n ( t e x t , g r a m m a r , l a n g u a g e ) {
var env = {
code : text ,
grammar : grammar ,
language : language
} ;
_ . hooks . run ( 'before-tokenize' , env ) ;
env . tokens = _ . tokenize ( env . code , env . grammar ) ;
_ . hooks . run ( 'after-tokenize' , env ) ;
return Token . stringify ( _ . util . encode ( env . tokens ) , env . language ) ;
} ,
/ * *
* This is the heart of Prism , and the most low - level function you can use . It accepts a string of text as input
* and the language definitions to use , and returns an array with the tokenized code .
*
* When the language definition includes nested tokens , the function is called recursively on each of these tokens .
*
* This method could be useful in other contexts as well , as a very crude parser .
*
* @ param { string } text A string with the code to be highlighted .
* @ param { Grammar } grammar An object containing the tokens to use .
*
* Usually a language definition like ` Prism.languages.markup ` .
* @ returns { TokenStream } An array of strings and tokens , a token stream .
* @ memberof Prism
* @ public
* @ example
* let code = ` var foo = 0; ` ;
* let tokens = Prism . tokenize ( code , Prism . languages . javascript ) ;
* tokens . forEach ( token => {
* if ( token instanceof Prism . Token && token . type === 'number' ) {
* console . log ( ` Found numeric literal: ${ token . content } ` ) ;
* }
* } ) ;
* / t o k e n i z e : f u n c t i o n ( t e x t , g r a m m a r ) {
var rest = grammar . rest ;
if ( rest ) {
for ( var token in rest ) grammar [ token ] = rest [ token ] ;
delete grammar . rest ;
}
var tokenList = new LinkedList ( ) ;
addAfter ( tokenList , tokenList . head , text ) ;
matchGrammar ( text , tokenList , grammar , tokenList . head , 0 ) ;
return toArray ( tokenList ) ;
} ,
/ * *
* @ namespace
* @ memberof Prism
* @ public
* / h o o k s : {
all : {
} ,
/ * *
* Adds the given callback to the list of callbacks for the given hook .
*
* The callback will be invoked when the hook it is registered for is run .
* Hooks are usually directly run by a highlight function but you can also run hooks yourself .
*
* One callback function can be registered to multiple hooks and the same hook multiple times .
*
* @ param { string } name The name of the hook .
* @ param { HookCallback } callback The callback function which is given environment variables .
* @ public
* / a d d : f u n c t i o n ( n a m e , c a l l b a c k ) {
var hooks = _ . hooks . all ;
hooks [ name ] = hooks [ name ] || [ ] ;
hooks [ name ] . push ( callback ) ;
} ,
/ * *
* Runs a hook invoking all registered callbacks with the given environment variables .
*
* Callbacks will be invoked synchronously and in the order in which they were registered .
*
* @ param { string } name The name of the hook .
* @ param { Object < string , any > } env The environment variables of the hook passed to all callbacks registered .
* @ public
* / r u n : f u n c t i o n ( n a m e , e n v ) {
var callbacks = _ . hooks . all [ name ] ;
if ( ! callbacks || ! callbacks . length ) return ;
for ( var i = 0 , callback ; callback = callbacks [ i ++ ] ; ) callback ( env ) ;
}
} ,
Token : Token
} ;
_self . Prism = _ ;
// Typescript note:
// The following can be used to import the Token type in JSDoc:
//
// @typedef {InstanceType<import("./prism-core")["Token"]>} Token
/ * *
* Creates a new token .
*
* @ param { string } type See { @ link Token # type type }
* @ param { string | TokenStream } content See { @ link Token # content content }
* @ param { string | string [ ] } [ alias ] The alias ( es ) of the token .
* @ param { string } [ matchedStr = "" ] A copy of the full string this token was created from .
* @ class
* @ global
* @ public
* / f u n c t i o n T o k e n ( t y p e , c o n t e n t , a l i a s , m a t c h e d S t r ) {
/ * *
* The type of the token .
*
* This is usually the key of a pattern in a { @ link Grammar } .
*
* @ type { string }
* @ see GrammarToken
* @ public
* / t h i s . t y p e = t y p e ;
/ * *
* The strings or tokens contained by this token .
*
* This will be a token stream if the pattern matched also defined an ` inside ` grammar .
*
* @ type { string | TokenStream }
* @ public
* / t h i s . c o n t e n t = c o n t e n t ;
/ * *
* The alias ( es ) of the token .
*
* @ type { string | string [ ] }
* @ see GrammarToken
* @ public
* / t h i s . a l i a s = a l i a s ;
// Copy of the full string this token was created from
this . length = ( matchedStr || '' ) . length | 0 ;
}
/ * *
* A token stream is an array of strings and { @ link Token Token } objects .
*
* Token streams have to fulfill a few properties that are assumed by most functions ( mostly internal ones ) that process
* them .
*
* 1. No adjacent strings .
* 2. No empty strings .
*
* The only exception here is the token stream that only contains the empty string and nothing else .
*
* @ typedef { Array < string | Token > } TokenStream
* @ global
* @ public
* / / * *
* Converts the given token or token stream to an HTML representation .
*
* The following hooks will be run :
* 1. ` wrap ` : On each { @ link Token } .
*
* @ param { string | Token | TokenStream } o The token or token stream to be converted .
* @ param { string } language The name of current language .
* @ returns { string } The HTML representation of the token or token stream .
* @ memberof Token
* @ static
* / T o k e n . s t r i n g i f y = f u n c t i o n s t r i n g i f y ( o , l a n g u a g e ) {
if ( typeof o == 'string' ) return o ;
if ( Array . isArray ( o ) ) {
var s = '' ;
o . forEach ( function ( e ) {
s += stringify ( e , language ) ;
} ) ;
return s ;
}
var env = {
type : o . type ,
content : stringify ( o . content , language ) ,
tag : 'span' ,
classes : [
'token' ,
o . type
] ,
attributes : {
} ,
language : language
} ;
var aliases = o . alias ;
if ( aliases ) {
if ( Array . isArray ( aliases ) ) Array . prototype . push . apply ( env . classes , aliases ) ;
else env . classes . push ( aliases ) ;
}
_ . hooks . run ( 'wrap' , env ) ;
var attributes = '' ;
for ( var name in env . attributes ) attributes += ' ' + name + '="' + ( env . attributes [ name ] || '' ) . replace ( /"/g , '"' ) + '"' ;
return '<' + env . tag + ' class="' + env . classes . join ( ' ' ) + '"' + attributes + '>' + env . content + '</' + env . tag + '>' ;
} ;
/ * *
* @ param { RegExp } pattern
* @ param { number } pos
* @ param { string } text
* @ param { boolean } lookbehind
* @ returns { RegExpExecArray | null }
* / f u n c t i o n m a t c h P a t t e r n ( p a t t e r n , p o s , t e x t , l o o k b e h i n d ) {
pattern . lastIndex = pos ;
var match = pattern . exec ( text ) ;
if ( match && lookbehind && match [ 1 ] ) {
// change the match to remove the text matched by the Prism lookbehind group
var lookbehindLength = match [ 1 ] . length ;
match . index += lookbehindLength ;
match [ 0 ] = match [ 0 ] . slice ( lookbehindLength ) ;
}
return match ;
}
/ * *
* @ param { string } text
* @ param { LinkedList < string | Token > } tokenList
* @ param { any } grammar
* @ param { LinkedListNode < string | Token > } startNode
* @ param { number } startPos
* @ param { RematchOptions } [ rematch ]
* @ returns { void }
* @ private
*
* @ typedef RematchOptions
* @ property { string } cause
* @ property { number } reach
* / f u n c t i o n m a t c h G r a m m a r ( t e x t , t o k e n L i s t , g r a m m a r , s t a r t N o d e , s t a r t P o s , r e m a t c h ) {
for ( var token in grammar ) {
if ( ! grammar . hasOwnProperty ( token ) || ! grammar [ token ] ) continue ;
var patterns = grammar [ token ] ;
patterns = Array . isArray ( patterns ) ? patterns : [
patterns
] ;
for ( var j = 0 ; j < patterns . length ; ++ j ) {
if ( rematch && rematch . cause == token + ',' + j ) return ;
var patternObj = patterns [ j ] ;
var inside = patternObj . inside ;
var lookbehind = ! ! patternObj . lookbehind ;
var greedy = ! ! patternObj . greedy ;
var alias = patternObj . alias ;
if ( greedy && ! patternObj . pattern . global ) {
// Without the global flag, lastIndex won't work
var flags = patternObj . pattern . toString ( ) . match ( /[imsuy]*$/ ) [ 0 ] ;
patternObj . pattern = RegExp ( patternObj . pattern . source , flags + 'g' ) ;
}
/** @type {RegExp} */ var pattern = patternObj . pattern || patternObj ;
for ( var currentNode = startNode . next , pos = startPos ; currentNode !== tokenList . tail ; pos += currentNode . value . length , currentNode = currentNode . next ) {
if ( rematch && pos >= rematch . reach ) break ;
var str = currentNode . value ;
if ( tokenList . length > text . length ) // Something went terribly wrong, ABORT, ABORT!
return ;
if ( str instanceof Token ) continue ;
var removeCount = 1 ; // this is the to parameter of removeBetween
var match ;
if ( greedy ) {
match = matchPattern ( pattern , pos , text , lookbehind ) ;
if ( ! match ) break ;
var from = match . index ;
var to = match . index + match [ 0 ] . length ;
var p = pos ;
// find the node that contains the match
p += currentNode . value . length ;
while ( from >= p ) {
currentNode = currentNode . next ;
p += currentNode . value . length ;
}
// adjust pos (and p)
p -= currentNode . value . length ;
pos = p ;
// the current node is a Token, then the match starts inside another Token, which is invalid
if ( currentNode . value instanceof Token ) continue ;
// find the last node which is affected by this match
for ( var k = currentNode ; k !== tokenList . tail && ( p < to || typeof k . value === 'string' ) ; k = k . next ) {
removeCount ++ ;
p += k . value . length ;
}
removeCount -- ;
// replace with the new match
str = text . slice ( pos , p ) ;
match . index -= pos ;
} else {
match = matchPattern ( pattern , 0 , str , lookbehind ) ;
if ( ! match ) continue ;
}
// eslint-disable-next-line no-redeclare
var from = match . index ;
var matchStr = match [ 0 ] ;
var before = str . slice ( 0 , from ) ;
var after = str . slice ( from + matchStr . length ) ;
var reach = pos + str . length ;
if ( rematch && reach > rematch . reach ) rematch . reach = reach ;
var removeFrom = currentNode . prev ;
if ( before ) {
removeFrom = addAfter ( tokenList , removeFrom , before ) ;
pos += before . length ;
}
removeRange ( tokenList , removeFrom , removeCount ) ;
var wrapped = new Token ( token , inside ? _ . tokenize ( matchStr , inside ) : matchStr , alias , matchStr ) ;
currentNode = addAfter ( tokenList , removeFrom , wrapped ) ;
if ( after ) addAfter ( tokenList , currentNode , after ) ;
if ( removeCount > 1 ) {
// at least one Token object was removed, so we have to do some rematching
// this can only happen if the current pattern is greedy
/** @type {RematchOptions} */ var nestedRematch = {
cause : token + ',' + j ,
reach : reach
} ;
matchGrammar ( text , tokenList , grammar , currentNode . prev , pos , nestedRematch ) ;
// the reach might have been extended because of the rematching
if ( rematch && nestedRematch . reach > rematch . reach ) rematch . reach = nestedRematch . reach ;
}
}
}
}
}
/ * *
* @ typedef LinkedListNode
* @ property { T } value
* @ property { LinkedListNode < T > | null } prev The previous node .
* @ property { LinkedListNode < T > | null } next The next node .
* @ template T
* @ private
* / / * *
* @ template T
* @ private
* / f u n c t i o n L i n k e d L i s t ( ) {
/** @type {LinkedListNode<T>} */ var head = {
value : null ,
prev : null ,
next : null
} ;
/** @type {LinkedListNode<T>} */ var tail = {
value : null ,
prev : head ,
next : null
} ;
head . next = tail ;
/** @type {LinkedListNode<T>} */ this . head = head ;
/** @type {LinkedListNode<T>} */ this . tail = tail ;
this . length = 0 ;
}
/ * *
* Adds a new node with the given value to the list .
*
* @ param { LinkedList < T > } list
* @ param { LinkedListNode < T > } node
* @ param { T } value
* @ returns { LinkedListNode < T > } The added node .
* @ template T
* / f u n c t i o n a d d A f t e r ( l i s t , n o d e , v a l u e ) {
// assumes that node != list.tail && values.length >= 0
var next = node . next ;
var newNode = {
value : value ,
prev : node ,
next : next
} ;
node . next = newNode ;
next . prev = newNode ;
list . length ++ ;
return newNode ;
}
/ * *
* Removes ` count ` nodes after the given node . The given node will not be removed .
*
* @ param { LinkedList < T > } list
* @ param { LinkedListNode < T > } node
* @ param { number } count
* @ template T
* / f u n c t i o n r e m o v e R a n g e ( l i s t , n o d e , c o u n t ) {
var next = node . next ;
for ( var i = 0 ; i < count && next !== list . tail ; i ++ ) next = next . next ;
node . next = next ;
next . prev = node ;
list . length -= i ;
}
/ * *
* @ param { LinkedList < T > } list
* @ returns { T [ ] }
* @ template T
* / f u n c t i o n t o A r r a y ( l i s t ) {
var array = [ ] ;
var node = list . head . next ;
while ( node !== list . tail ) {
array . push ( node . value ) ;
node = node . next ;
}
return array ;
}
if ( ! _self . document ) {
if ( ! _self . addEventListener ) // in Node.js
return _ ;
if ( ! _ . disableWorkerMessageHandler ) // In worker
_self . addEventListener ( 'message' , function ( evt ) {
var message = JSON . parse ( evt . data ) ;
var lang = message . language ;
var code = message . code ;
var immediateClose = message . immediateClose ;
_self . postMessage ( _ . highlight ( code , _ . languages [ lang ] , lang ) ) ;
if ( immediateClose ) _self . close ( ) ;
} , false ) ;
return _ ;
}
// Get current script and highlight
var script = _ . util . currentScript ( ) ;
if ( script ) {
_ . filename = script . src ;
if ( script . hasAttribute ( 'data-manual' ) ) _ . manual = true ;
}
function highlightAutomaticallyCallback ( ) {
if ( ! _ . manual ) _ . highlightAll ( ) ;
}
if ( ! _ . manual ) {
// If the document state is "loading", then we'll use DOMContentLoaded.
// If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
// DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
// might take longer one animation frame to execute which can create a race condition where only some plugins have
// been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
// See https://github.com/PrismJS/prism/issues/2102
var readyState = document . readyState ;
if ( readyState === 'loading' || readyState === 'interactive' && script && script . defer ) document . addEventListener ( 'DOMContentLoaded' , highlightAutomaticallyCallback ) ;
else if ( window . requestAnimationFrame ) window . requestAnimationFrame ( highlightAutomaticallyCallback ) ;
else window . setTimeout ( highlightAutomaticallyCallback , 16 ) ;
}
return _ ;
} ( _self1 ) ;
if ( typeof module !== 'undefined' && module . exports ) module . exports = Prism ;
// hack for components to work correctly in node.js
if ( typeof global !== 'undefined' ) global . Prism = Prism ;
// some additional documentation/types
/ * *
* The expansion of a simple ` RegExp ` literal to support additional properties .
*
* @ typedef GrammarToken
* @ property { RegExp } pattern The regular expression of the token .
* @ property { boolean } [ lookbehind = false ] If ` true ` , then the first capturing group of ` pattern ` will ( effectively )
* behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token .
* @ property { boolean } [ greedy = false ] Whether the token is greedy .
* @ property { string | string [ ] } [ alias ] An optional alias or list of aliases .
* @ property { Grammar } [ inside ] The nested grammar of this token .
*
* The ` inside ` grammar will be used to tokenize the text value of each token of this kind .
*
* This can be used to make nested and even recursive language definitions .
*
* Note : This can cause infinite recursion . Be careful when you embed different languages or even the same language into
* each another .
* @ global
* @ public
* / / * *
* @ typedef Grammar
* @ type { Object < string , RegExp | GrammarToken | Array < RegExp | GrammarToken >> }
* @ property { Grammar } [ rest ] An optional grammar object that will be appended to this grammar .
* @ global
* @ public
* / / * *
* A function which will invoked after an element was successfully highlighted .
*
* @ callback HighlightCallback
* @ param { Element } element The element successfully highlighted .
* @ returns { void }
* @ global
* @ public
* / / * *
* @ callback HookCallback
* @ param { Object < string , any > } env The environment variables of the hook .
* @ returns { void }
* @ global
* @ public
* /
} , { } ] , "dIns2" : [ function ( require , module , exports ) {
Prism . languages . markup = {
'comment' : {
pattern : /<!--(?:(?!<!--)[\s\S])*?-->/ ,
greedy : true
} ,
'prolog' : {
pattern : /<\?[\s\S]+?\?>/ ,
greedy : true
} ,
'doctype' : {
// https://www.w3.org/TR/xml/#NT-doctypedecl
pattern : /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i ,
greedy : true ,
inside : {
'internal-subset' : {
pattern : /(^[^\[]*\[)[\s\S]+(?=\]>$)/ ,
lookbehind : true ,
greedy : true ,
inside : null // see below
} ,
'string' : {
pattern : /"[^"]*"|'[^']*'/ ,
greedy : true
} ,
'punctuation' : /^<!|>$|[[\]]/ ,
'doctype-tag' : /^DOCTYPE/i ,
'name' : /[^\s<>'"]+/
}
} ,
'cdata' : {
pattern : /<!\[CDATA\[[\s\S]*?\]\]>/i ,
greedy : true
} ,
'tag' : {
pattern : /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/ ,
greedy : true ,
inside : {
'tag' : {
pattern : /^<\/?[^\s>\/]+/ ,
inside : {
'punctuation' : /^<\/?/ ,
'namespace' : /^[^\s>\/:]+:/
}
} ,
'special-attr' : [ ] ,
'attr-value' : {
pattern : /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/ ,
inside : {
'punctuation' : [
{
pattern : /^=/ ,
alias : 'attr-equals'
} ,
/"|'/
]
}
} ,
'punctuation' : /\/?>/ ,
'attr-name' : {
pattern : /[^\s>\/]+/ ,
inside : {
'namespace' : /^[^\s>\/:]+:/
}
}
}
} ,
'entity' : [
{
pattern : /&[\da-z]{1,8};/i ,
alias : 'named-entity'
} ,
/&#x?[\da-f]{1,8};/i
]
} ;
Prism . languages . markup [ 'tag' ] . inside [ 'attr-value' ] . inside [ 'entity' ] = Prism . languages . markup [ 'entity' ] ;
Prism . languages . markup [ 'doctype' ] . inside [ 'internal-subset' ] . inside = Prism . languages . markup ;
// Plugin to make entity title show the real entity, idea by Roman Komarov
Prism . hooks . add ( 'wrap' , function ( env ) {
if ( env . type === 'entity' ) env . attributes [ 'title' ] = env . content . replace ( /&/ , '&' ) ;
} ) ;
Object . defineProperty ( Prism . languages . markup . tag , 'addInlined' , {
/ * *
* Adds an inlined language to markup .
*
* An example of an inlined language is CSS with ` <style> ` tags .
*
* @ param { string } tagName The name of the tag that contains the inlined language . This name will be treated as
* case insensitive .
* @ param { string } lang The language key .
* @ example
* addInlined ( 'style' , 'css' ) ;
* / v a l u e : f u n c t i o n a d d I n l i n e d ( t a g N a m e , l a n g ) {
var includedCdataInside = {
} ;
includedCdataInside [ 'language-' + lang ] = {
pattern : /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i ,
lookbehind : true ,
inside : Prism . languages [ lang ]
} ;
includedCdataInside [ 'cdata' ] = /^<!\[CDATA\[|\]\]>$/i ;
var inside = {
'included-cdata' : {
pattern : /<!\[CDATA\[[\s\S]*?\]\]>/i ,
inside : includedCdataInside
}
} ;
inside [ 'language-' + lang ] = {
pattern : /[\s\S]+/ ,
inside : Prism . languages [ lang ]
} ;
var def = {
} ;
def [ tagName ] = {
pattern : RegExp ( /(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/ . source . replace ( /__/g , function ( ) {
return tagName ;
} ) , 'i' ) ,
lookbehind : true ,
greedy : true ,
inside : inside
} ;
Prism . languages . insertBefore ( 'markup' , 'cdata' , def ) ;
}
} ) ;
Object . defineProperty ( Prism . languages . markup . tag , 'addAttribute' , {
/ * *
* Adds an pattern to highlight languages embedded in HTML attributes .
*
* An example of an inlined language is CSS with ` style ` attributes .
*
* @ param { string } attrName The name of the tag that contains the inlined language . This name will be treated as
* case insensitive .
* @ param { string } lang The language key .
* @ example
* addAttribute ( 'style' , 'css' ) ;
* / v a l u e : f u n c t i o n ( a t t r N a m e , l a n g ) {
Prism . languages . markup . tag . inside [ 'special-attr' ] . push ( {
pattern : RegExp ( /(^|["'\s])/ . source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/ . source , 'i' ) ,
lookbehind : true ,
inside : {
'attr-name' : /^[^\s=]+/ ,
'attr-value' : {
pattern : /=[\s\S]+/ ,
inside : {
'value' : {
pattern : /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/ ,
lookbehind : true ,
alias : [
lang ,
'language-' + lang
] ,
inside : Prism . languages [ lang ]
} ,
'punctuation' : [
{
pattern : /^=/ ,
alias : 'attr-equals'
} ,
/"|'/
]
}
}
}
} ) ;
}
} ) ;
Prism . languages . html = Prism . languages . markup ;
Prism . languages . mathml = Prism . languages . markup ;
Prism . languages . svg = Prism . languages . markup ;
Prism . languages . xml = Prism . languages . extend ( 'markup' , {
} ) ;
Prism . languages . ssml = Prism . languages . xml ;
Prism . languages . atom = Prism . languages . xml ;
Prism . languages . rss = Prism . languages . xml ;
} , { } ] , "gqRFx" : [ function ( require , module , exports ) {
( function ( Prism ) {
// Allow only one line break
var inner = /(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/ . source ;
/ * *
* This function is intended for the creation of the bold or italic pattern .
*
* This also adds a lookbehind group to the given pattern to ensure that the pattern is not backslash - escaped .
*
* _Note : _ Keep in mind that this adds a capturing group .
*
* @ param { string } pattern
* @ returns { RegExp }
* / f u n c t i o n c r e a t e I n l i n e ( p a t t e r n ) {
pattern = pattern . replace ( /<inner>/g , function ( ) {
return inner ;
} ) ;
return RegExp ( /((?:^|[^\\])(?:\\{2})*)/ . source + '(?:' + pattern + ')' ) ;
}
var tableCell = /(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/ . source ;
var tableRow = /\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/ . source . replace ( /__/g , function ( ) {
return tableCell ;
} ) ;
var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/ . source ;
Prism . languages . markdown = Prism . languages . extend ( 'markup' , {
} ) ;
Prism . languages . insertBefore ( 'markdown' , 'prolog' , {
'front-matter-block' : {
pattern : /(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/ ,
lookbehind : true ,
greedy : true ,
inside : {
'punctuation' : /^---|---$/ ,
'font-matter' : {
pattern : /\S+(?:\s+\S+)*/ ,
alias : [
'yaml' ,
'language-yaml'
] ,
inside : Prism . languages . yaml
}
}
} ,
'blockquote' : {
// > ...
pattern : /^>(?:[\t ]*>)*/m ,
alias : 'punctuation'
} ,
'table' : {
pattern : RegExp ( '^' + tableRow + tableLine + '(?:' + tableRow + ')*' , 'm' ) ,
inside : {
'table-data-rows' : {
pattern : RegExp ( '^(' + tableRow + tableLine + ')(?:' + tableRow + ')*$' ) ,
lookbehind : true ,
inside : {
'table-data' : {
pattern : RegExp ( tableCell ) ,
inside : Prism . languages . markdown
} ,
'punctuation' : /\|/
}
} ,
'table-line' : {
pattern : RegExp ( '^(' + tableRow + ')' + tableLine + '$' ) ,
lookbehind : true ,
inside : {
'punctuation' : /\||:?-{3,}:?/
}
} ,
'table-header-row' : {
pattern : RegExp ( '^' + tableRow + '$' ) ,
inside : {
'table-header' : {
pattern : RegExp ( tableCell ) ,
alias : 'important' ,
inside : Prism . languages . markdown
} ,
'punctuation' : /\|/
}
}
}
} ,
'code' : [
{
// Prefixed by 4 spaces or 1 tab and preceded by an empty line
pattern : /((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/ ,
lookbehind : true ,
alias : 'keyword'
} ,
{
// ```optional language
// code block
// ```
pattern : /^```[\s\S]*?^```$/m ,
greedy : true ,
inside : {
'code-block' : {
pattern : /^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m ,
lookbehind : true
} ,
'code-language' : {
pattern : /^(```).+/ ,
lookbehind : true
} ,
'punctuation' : /```/
}
}
] ,
'title' : [
{
// title 1
// =======
// title 2
// -------
pattern : /\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m ,
alias : 'important' ,
inside : {
punctuation : /==+$|--+$/
}
} ,
{
// # title 1
// ###### title 6
pattern : /(^\s*)#.+/m ,
lookbehind : true ,
alias : 'important' ,
inside : {
punctuation : /^#+|#+$/
}
}
] ,
'hr' : {
// ***
// ---
// * * *
// -----------
pattern : /(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m ,
lookbehind : true ,
alias : 'punctuation'
} ,
'list' : {
// * item
// + item
// - item
// 1. item
pattern : /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m ,
lookbehind : true ,
alias : 'punctuation'
} ,
'url-reference' : {
// [id]: http://example.com "Optional title"
// [id]: http://example.com 'Optional title'
// [id]: http://example.com (Optional title)
// [id]: <http://example.com> "Optional title"
pattern : /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/ ,
inside : {
'variable' : {
pattern : /^(!?\[)[^\]]+/ ,
lookbehind : true
} ,
'string' : /(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/ ,
'punctuation' : /^[\[\]!:]|[<>]/
} ,
alias : 'url'
} ,
'bold' : {
// **strong**
// __strong__
// allow one nested instance of italic text using the same delimiter
pattern : createInline ( /\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/ . source ) ,
lookbehind : true ,
greedy : true ,
inside : {
'content' : {
pattern : /(^..)[\s\S]+(?=..$)/ ,
lookbehind : true ,
inside : {
} // see below
} ,
'punctuation' : /\*\*|__/
}
} ,
'italic' : {
// *em*
// _em_
// allow one nested instance of bold text using the same delimiter
pattern : createInline ( /\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/ . source ) ,
lookbehind : true ,
greedy : true ,
inside : {
'content' : {
pattern : /(^.)[\s\S]+(?=.$)/ ,
lookbehind : true ,
inside : {
} // see below
} ,
'punctuation' : /[*_]/
}
} ,
'strike' : {
// ~~strike through~~
// ~strike~
// eslint-disable-next-line regexp/strict
pattern : createInline ( /(~~?)(?:(?!~)<inner>)+\2/ . source ) ,
lookbehind : true ,
greedy : true ,
inside : {
'content' : {
pattern : /(^~~?)[\s\S]+(?=\1$)/ ,
lookbehind : true ,
inside : {
} // see below
} ,
'punctuation' : /~~?/
}
} ,
'code-snippet' : {
// `code`
// ``code``
pattern : /(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/ ,
lookbehind : true ,
greedy : true ,
alias : [
'code' ,
'keyword'
]
} ,
'url' : {
// [example](http://example.com "Optional title")
// [example][id]
// [example] [id]
pattern : createInline ( /!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/ . source ) ,
lookbehind : true ,
greedy : true ,
inside : {
'operator' : /^!/ ,
'content' : {
pattern : /(^\[)[^\]]+(?=\])/ ,
lookbehind : true ,
inside : {
} // see below
} ,
'variable' : {
pattern : /(^\][ \t]?\[)[^\]]+(?=\]$)/ ,
lookbehind : true
} ,
'url' : {
pattern : /(^\]\()[^\s)]+/ ,
lookbehind : true
} ,
'string' : {
pattern : /(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/ ,
lookbehind : true
}
}
}
} ) ;
[
'url' ,
'bold' ,
'italic' ,
'strike'
] . forEach ( function ( token ) {
[
'url' ,
'bold' ,
'italic' ,
'strike' ,
'code-snippet'
] . forEach ( function ( inside ) {
if ( token !== inside ) Prism . languages . markdown [ token ] . inside . content . inside [ inside ] = Prism . languages . markdown [ inside ] ;
} ) ;
} ) ;
Prism . hooks . add ( 'after-tokenize' , function ( env ) {
if ( env . language !== 'markdown' && env . language !== 'md' ) return ;
function walkTokens ( tokens ) {
if ( ! tokens || typeof tokens === 'string' ) return ;
for ( var i = 0 , l = tokens . length ; i < l ; i ++ ) {
var token = tokens [ i ] ;
if ( token . type !== 'code' ) {
walkTokens ( token . content ) ;
continue ;
}
/ *
* Add the correct ` language-xxxx ` class to this code block . Keep in mind that the ` code-language ` token
* is optional . But the grammar is defined so that there is only one case we have to handle :
*
* token . content = [
* < span class = "punctuation" > ` ` ` </span>,
* < span class = "code-language" > xxxx < / s p a n > ,
* '\n' , // exactly one new lines (\r or \n or \r\n)
* < span class = "code-block" > ... < / s p a n > ,
* '\n' , // exactly one new lines again
* < span class = "punctuation" > ` ` ` </span>
* ] ;
* / v a r c o d e L a n g = t o k e n . c o n t e n t [ 1 ] ;
var codeBlock = token . content [ 3 ] ;
if ( codeLang && codeBlock && codeLang . type === 'code-language' && codeBlock . type === 'code-block' && typeof codeLang . content === 'string' ) {
// this might be a language that Prism does not support
// do some replacements to support C++, C#, and F#
var lang = codeLang . content . replace ( /\b#/g , 'sharp' ) . replace ( /\b\+\+/g , 'pp' ) ;
// only use the first word
lang = ( /[a-z][\w-]*/i . exec ( lang ) || [
''
] ) [ 0 ] . toLowerCase ( ) ;
var alias = 'language-' + lang ;
// add alias
if ( ! codeBlock . alias ) codeBlock . alias = [
alias
] ;
else if ( typeof codeBlock . alias === 'string' ) codeBlock . alias = [
codeBlock . alias ,
alias
] ;
else codeBlock . alias . push ( alias ) ;
}
}
}
walkTokens ( env . tokens ) ;
} ) ;
Prism . hooks . add ( 'wrap' , function ( env ) {
if ( env . type !== 'code-block' ) return ;
var codeLang = '' ;
for ( var i = 0 , l = env . classes . length ; i < l ; i ++ ) {
var cls = env . classes [ i ] ;
var match = /language-(.+)/ . exec ( cls ) ;
if ( match ) {
codeLang = match [ 1 ] ;
break ;
}
}
var grammar = Prism . languages [ codeLang ] ;
if ( ! grammar ) {
if ( codeLang && codeLang !== 'none' && Prism . plugins . autoloader ) {
var id = 'md-' + new Date ( ) . valueOf ( ) + '-' + Math . floor ( Math . random ( ) * 10000000000000000 ) ;
env . attributes [ 'id' ] = id ;
Prism . plugins . autoloader . loadLanguages ( codeLang , function ( ) {
var ele = document . getElementById ( id ) ;
if ( ele ) ele . innerHTML = Prism . highlight ( ele . textContent , Prism . languages [ codeLang ] , codeLang ) ;
} ) ;
}
} else env . content = Prism . highlight ( textContent ( env . content ) , grammar , codeLang ) ;
} ) ;
var tagPattern = RegExp ( Prism . languages . markup . tag . pattern . source , 'gi' ) ;
/ * *
* A list of known entity names .
*
* This will always be incomplete to save space . The current list is the one used by lowdash ' s unescape function .
*
* @ see { @ link https : //github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/unescape.js#L2}
* / v a r K N O W N _ E N T I T Y _ N A M E S = {
'amp' : '&' ,
'lt' : '<' ,
'gt' : '>' ,
'quot' : '"'
} ;
// IE 11 doesn't support `String.fromCodePoint`
var fromCodePoint = String . fromCodePoint || String . fromCharCode ;
/ * *
* Returns the text content of a given HTML source code string .
*
* @ param { string } html
* @ returns { string }
* / f u n c t i o n t e x t C o n t e n t ( h t m l ) {
// remove all tags
var text = html . replace ( tagPattern , '' ) ;
// decode known entities
text = text . replace ( /&(\w{1,8}|#x?[\da-f]{1,8});/gi , function ( m , code ) {
code = code . toLowerCase ( ) ;
if ( code [ 0 ] === '#' ) {
var value ;
if ( code [ 1 ] === 'x' ) value = parseInt ( code . slice ( 2 ) , 16 ) ;
else value = Number ( code . slice ( 1 ) ) ;
return fromCodePoint ( value ) ;
} else {
var known = KNOWN _ENTITY _NAMES [ code ] ;
if ( known ) return known ;
// unable to decode
return m ;
}
} ) ;
return text ;
}
Prism . languages . md = Prism . languages . markdown ;
} ) ( Prism ) ;
} , { } ] , "fmUxI" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
var _animeEsJs = require ( "animejs/lib/anime.es.js" ) ;
var _animeEsJsDefault = parcelHelpers . interopDefault ( _animeEsJs ) ;
const notifcation = document . getElementById ( "notifications" ) ;
const notify = document . getElementById ( "notifyMessage" ) ;
const messageText = document . getElementById ( "message-text" ) ;
const notifyText = document . getElementById ( "notify-text" ) ;
const notifyProgress = document . getElementById ( "notify-progress" ) ;
const iconGood = document . getElementById ( "notify-good" ) ;
const iconLame = document . getElementById ( "notify-lame" ) ;
const iconWorking = document . getElementById ( "notify-working" ) ;
class Notfications {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
}
// methods
//--------------------------
alert ( text , status ) {
iconWorking . style . display = "none" ;
iconGood . style . display = "none" ;
iconLame . style . display = "none" ;
var color = "" ;
if ( status !== null ) {
_animeEsJsDefault . default ( {
targets : notifyProgress ,
opacity : 0 ,
easing : "easeInOutQuint" ,
duration : 500
} ) ;
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" ;
_animeEsJsDefault . default ( {
targets : notifyProgress ,
opacity : 1 ,
easing : "easeInOutQuint" ,
duration : 500
} ) ;
}
messageText . innerHTML = text ;
_animeEsJsDefault . default ( {
targets : notifcation ,
marginTop : "-10" ,
easing : "easeInOutQuint" ,
duration : 10 ,
complete : ( ) => {
_animeEsJsDefault . default ( {
targets : notify ,
rotateX : "0" ,
easing : "easeInOutQuint" ,
duration : 700
} ) ;
_animeEsJsDefault . default ( {
targets : notifyText ,
backgroundColor : color ,
easing : "easeInOutQuint" ,
duration : 700 ,
complete : ( ) => {
setTimeout ( ( ) => {
if ( status !== null ) _animeEsJsDefault . default ( {
targets : notify ,
rotateX : "-120" ,
easing : "easeInOutQuint" ,
duration : 700 ,
complete : ( ) => {
_animeEsJsDefault . default ( {
targets : notifcation ,
marginTop : "-55" ,
easing : "easeInOutQuint" ,
delay : 700 ,
duration : 50
} ) ; //notifcation.style.display = 'none';
}
} ) ;
} , 1000 ) ;
}
} ) ;
}
} ) ;
}
}
exports . default = Notfications ;
} , { "animejs/lib/anime.es.js" : "bfYip" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "bfYip" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
/ *
* anime . js v3 . 2.1
* ( 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' ;
} ,
nil : function ( a ) {
return is . und ( a ) || a === null ;
} ,
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 , duration1 ) {
var params = parseEasingParameters ( string ) ;
var mass = minMax ( is . und ( params [ 0 ] ) ? 1 : params [ 0 ] , 0.1 , 100 ) ;
var stiffness = minMax ( is . und ( params [ 1 ] ) ? 100 : params [ 1 ] , 0.1 , 100 ) ;
var damping = minMax ( is . und ( params [ 2 ] ) ? 10 : params [ 2 ] , 0.1 , 100 ) ;
var velocity = minMax ( is . und ( params [ 3 ] ) ? 0 : params [ 3 ] , 0.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 = duration1 ? duration1 * 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 duration1 ? solver : getDuration ;
}
// Basic steps easing implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
function steps1 ( 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 bezier1 = function ( ) {
var kSplineTableSize = 11 ;
var kSampleStepSize = 1 / ( kSplineTableSize - 1 ) ;
function A ( aA1 , aA2 ) {
return 1 - 3 * aA2 + 3 * aA1 ;
}
function B ( aA1 , aA2 ) {
return 3 * aA2 - 6 * aA1 ;
}
function C ( aA1 ) {
return 3 * 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 * A ( aA1 , aA2 ) * aT * aT + 2 * B ( aA1 , aA2 ) * aT + C ( aA1 ) ;
}
function binarySubdivide ( aX , aA , aB , mX1 , mX2 ) {
var currentX , currentT , i = 0 ;
do {
currentT = aA + ( aB - aA ) / 2 ;
currentX = calcBezier ( currentT , mX1 , mX2 ) - aX ;
if ( currentX > 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 ) 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 ) 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 = 0.5 ;
var a = minMax ( amplitude , 1 , 10 ) ;
var p = minMax ( period , 0.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 ;
} ;
} ;
eases [ 'easeOutIn' + name ] = function ( a , b ) {
return function ( t ) {
return t < 0.5 ? ( 1 - easeIn ( a , b ) ( 1 - t * 2 ) ) / 2 : ( easeIn ( a , b ) ( t * 2 - 1 ) + 1 ) / 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 ( bezier1 , args ) ;
case 'steps' :
return applyArguments ( steps1 , 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 r1 = parseInt ( rgb [ 1 ] , 16 ) ;
var g1 = parseInt ( rgb [ 2 ] , 16 ) ;
var b1 = parseInt ( rgb [ 3 ] , 16 ) ;
return "rgba(" + r1 + "," + g1 + "," + b1 + ",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 < 0.5 ) 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 q1 = l < 0.5 ? l * ( 1 + s ) : l + s - l * s ;
var p1 = 2 * l - q1 ;
r = hue2rgb ( p1 , q1 , h + 1 / 3 ) ;
g = hue2rgb ( p1 , q1 , h ) ;
b = hue2rgb ( p1 , q1 , 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 ) && ( ! is . nil ( 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 ,
h : height ,
vW : viewBox [ 2 ] ,
vH : 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 , isPathTargetInsideSVG ) {
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 ) ;
var scaleX = isPathTargetInsideSVG ? 1 : svg . w / svg . vW ;
var scaleY = isPathTargetInsideSVG ? 1 : svg . h / svg . vH ;
switch ( path . property ) {
case 'x' :
return ( p . x - svg . x ) * scaleX ;
case 'y' :
return ( p . y - svg . y ) * scaleY ;
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 . isPathTargetInsideSVG = tween . isPath && is . svg ( animatable . target ) ;
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 engine = function ( ) {
var raf ;
function play ( ) {
if ( ! raf && ( ! isDocumentHidden ( ) || ! anime . suspendWhenDocumentHidden ) && activeInstances . length > 0 ) raf = requestAnimationFrame ( step ) ;
}
function step ( t ) {
// memo on algorithm issue:
// dangerous iteration over mutable `activeInstances`
// (that collection may be updated from within callbacks of `tick`-ed animation instances)
var activeInstancesLength = activeInstances . length ;
var i = 0 ;
while ( i < activeInstancesLength ) {
var activeInstance = activeInstances [ i ] ;
if ( ! activeInstance . paused ) {
activeInstance . tick ( t ) ;
i ++ ;
} else {
activeInstances . splice ( i , 1 ) ;
activeInstancesLength -- ;
}
}
raf = i > 0 ? requestAnimationFrame ( step ) : undefined ;
}
function handleVisibilityChange ( ) {
if ( ! anime . suspendWhenDocumentHidden ) return ;
if ( isDocumentHidden ( ) ) // suspend ticks
raf = cancelAnimationFrame ( raf ) ;
else {
// first adjust animations to consider the time that ticks were suspended
activeInstances . forEach ( function ( instance ) {
return instance . _onDocumentVisibility ( ) ;
} ) ;
engine ( ) ;
}
}
if ( typeof document !== 'undefined' ) document . addEventListener ( 'visibilitychange' , handleVisibilityChange ) ;
return play ;
} ( ) ;
function isDocumentHidden ( ) {
return ! ! document && document . hidden ;
}
// 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 instance1 = createNewInstance ( params ) ;
var promise1 = makePromise ( instance1 ) ;
function toggleInstanceDirection ( ) {
var direction = instance1 . direction ;
if ( direction !== 'alternate' ) instance1 . direction = direction !== 'normal' ? 'normal' : 'reverse' ;
instance1 . reversed = ! instance1 . reversed ;
children . forEach ( function ( child ) {
return child . reversed = instance1 . reversed ;
} ) ;
}
function adjustTime ( time ) {
return instance1 . reversed ? instance1 . duration - time : time ;
}
function resetTime ( ) {
startTime = 0 ;
lastTime = adjustTime ( instance1 . currentTime ) * ( 1 / anime . speed ) ;
}
function seekChild ( time , child ) {
if ( child ) child . seek ( time - child . timelineOffset ) ;
}
function syncInstanceChildren ( time ) {
if ( ! instance1 . 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 = instance1 . 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 , tween . isPathTargetInsideSVG ) ;
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 ( instance1 [ cb ] && ! instance1 . passThrough ) instance1 [ cb ] ( instance1 ) ;
}
function countIteration ( ) {
if ( instance1 . remaining && instance1 . remaining !== true ) instance1 . remaining -- ;
}
function setInstanceProgress ( engineTime ) {
var insDuration = instance1 . duration ;
var insDelay = instance1 . delay ;
var insEndDelay = insDuration - instance1 . endDelay ;
var insTime = adjustTime ( engineTime ) ;
instance1 . progress = minMax ( insTime / insDuration * 100 , 0 , 100 ) ;
instance1 . reversePlayback = insTime < instance1 . currentTime ;
if ( children ) syncInstanceChildren ( insTime ) ;
if ( ! instance1 . began && instance1 . currentTime > 0 ) {
instance1 . began = true ;
setCallback ( 'begin' ) ;
}
if ( ! instance1 . loopBegan && instance1 . currentTime > 0 ) {
instance1 . loopBegan = true ;
setCallback ( 'loopBegin' ) ;
}
if ( insTime <= insDelay && instance1 . currentTime !== 0 ) setAnimationsProgress ( 0 ) ;
if ( insTime >= insEndDelay && instance1 . currentTime !== insDuration || ! insDuration ) setAnimationsProgress ( insDuration ) ;
if ( insTime > insDelay && insTime < insEndDelay ) {
if ( ! instance1 . changeBegan ) {
instance1 . changeBegan = true ;
instance1 . changeCompleted = false ;
setCallback ( 'changeBegin' ) ;
}
setCallback ( 'change' ) ;
setAnimationsProgress ( insTime ) ;
} else if ( instance1 . changeBegan ) {
instance1 . changeCompleted = true ;
instance1 . changeBegan = false ;
setCallback ( 'changeComplete' ) ;
}
instance1 . currentTime = minMax ( insTime , 0 , insDuration ) ;
if ( instance1 . began ) setCallback ( 'update' ) ;
if ( engineTime >= insDuration ) {
lastTime = 0 ;
countIteration ( ) ;
if ( ! instance1 . remaining ) {
instance1 . paused = true ;
if ( ! instance1 . completed ) {
instance1 . completed = true ;
setCallback ( 'loopComplete' ) ;
setCallback ( 'complete' ) ;
if ( ! instance1 . passThrough && 'Promise' in window ) {
resolve ( ) ;
promise1 = makePromise ( instance1 ) ;
}
}
} else {
startTime = now ;
setCallback ( 'loopComplete' ) ;
instance1 . loopBegan = false ;
if ( instance1 . direction === 'alternate' ) toggleInstanceDirection ( ) ;
}
}
}
instance1 . reset = function ( ) {
var direction = instance1 . direction ;
instance1 . passThrough = false ;
instance1 . currentTime = 0 ;
instance1 . progress = 0 ;
instance1 . paused = true ;
instance1 . began = false ;
instance1 . loopBegan = false ;
instance1 . changeBegan = false ;
instance1 . completed = false ;
instance1 . changeCompleted = false ;
instance1 . reversePlayback = false ;
instance1 . reversed = direction === 'reverse' ;
instance1 . remaining = instance1 . loop ;
children = instance1 . children ;
childrenLength = children . length ;
for ( var i = childrenLength ; i -- ; ) instance1 . children [ i ] . reset ( ) ;
if ( instance1 . reversed && instance1 . loop !== true || direction === 'alternate' && instance1 . loop === 1 ) instance1 . remaining ++ ;
setAnimationsProgress ( instance1 . reversed ? instance1 . duration : 0 ) ;
} ;
// internal method (for engine) to adjust animation timings before restoring engine ticks (rAF)
instance1 . _onDocumentVisibility = resetTime ;
// Set Value helper
instance1 . set = function ( targets , properties ) {
setTargetsValue ( targets , properties ) ;
return instance1 ;
} ;
instance1 . tick = function ( t ) {
now = t ;
if ( ! startTime ) startTime = now ;
setInstanceProgress ( ( now + ( lastTime - startTime ) ) * anime . speed ) ;
} ;
instance1 . seek = function ( time ) {
setInstanceProgress ( adjustTime ( time ) ) ;
} ;
instance1 . pause = function ( ) {
instance1 . paused = true ;
resetTime ( ) ;
} ;
instance1 . play = function ( ) {
if ( ! instance1 . paused ) return ;
if ( instance1 . completed ) instance1 . reset ( ) ;
instance1 . paused = false ;
activeInstances . push ( instance1 ) ;
resetTime ( ) ;
engine ( ) ;
} ;
instance1 . reverse = function ( ) {
toggleInstanceDirection ( ) ;
instance1 . completed = instance1 . reversed ? false : true ;
resetTime ( ) ;
} ;
instance1 . restart = function ( ) {
instance1 . reset ( ) ;
instance1 . play ( ) ;
} ;
instance1 . remove = function ( targets ) {
var targetsArray = parseTargets ( targets ) ;
removeTargetsFromInstance ( targetsArray , instance1 ) ;
} ;
instance1 . reset ( ) ;
if ( instance1 . autoplay ) instance1 . play ( ) ;
return instance1 ;
}
// 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 removeTargetsFromInstance ( targetsArray , instance ) {
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 ( ) ;
}
function removeTargetsFromActiveInstances ( targets ) {
var targetsArray = parseTargets ( targets ) ;
for ( var i = activeInstances . length ; i -- ; ) {
var instance = activeInstances [ i ] ;
removeTargetsFromInstance ( targetsArray , instance ) ;
}
}
// Stagger helpers
function stagger ( val3 , 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 ( val3 ) ;
var val1 = isRange ? parseFloat ( val3 [ 0 ] ) : parseFloat ( val3 ) ;
var val2 = isRange ? parseFloat ( val3 [ 1 ] ) : 0 ;
var unit = getUnit ( isRange ? val3 [ 1 ] : val3 ) || 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 ins1 = anime ( insParams ) ;
passThrough ( ins1 ) ;
children . push ( ins1 ) ;
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.1' ;
anime . speed = 1 ;
// TODO:#review: naming, documentation
anime . suspendWhenDocumentHidden = true ;
anime . running = activeInstances ;
anime . remove = removeTargetsFromActiveInstances ;
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 ;
} ;
exports . default = anime ;
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "kp4D5" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
var _sortablejs = require ( "sortablejs" ) ;
var _sortablejsDefault = parcelHelpers . interopDefault ( _sortablejs ) ;
var _dataUtils = require ( "../utils/DataUtils" ) ;
var _dataUtilsDefault = parcelHelpers . interopDefault ( _dataUtils ) ;
var _notificationsJs = require ( "./Notifications.js" ) ;
var _notificationsJsDefault = parcelHelpers . interopDefault ( _notificationsJs ) ;
const notify = new _notificationsJsDefault . default ( ) ;
class FileManager {
//--------------------------
// constructor
//--------------------------
constructor ( upload , input , imageList , fileList ) {
this . upload = upload ;
this . input = input ;
this . imageList = imageList ;
this . fileList = fileList ;
this . accetableFiles = [
'image/jpeg' ,
'image/gif' ,
'image/png' ,
'image/svg' ,
'audio/mpeg' ,
'video/mp4' ,
'application/pdf' ,
'text/plain' ,
'text/rtf'
] ;
this . files = [ ] ;
this . sortedFiles = [ ] ;
this . storage = [ ] ;
this . start ( ) ;
}
// methods
//--------------------------
start ( ) {
this . upload . addEventListener ( 'dragover' , ( e ) => this . handleFileActions ( e )
, false ) ;
this . upload . addEventListener ( 'drop' , ( e ) => this . handleFileActions ( e )
, false ) ;
this . input . addEventListener ( 'change' , ( e ) => this . handleFileActions ( e )
, false ) ;
_sortablejsDefault . default . create ( this . imageList , {
onUpdate : ( e ) => {
notify . alert ( 'REINDEXING FILES' , null ) ;
let currentFiles = [ ] ; //store current list
let items = e . target . children ;
for ( let index = 0 ; index < items . length ; index ++ ) {
var item = items [ index ] ;
let url = '' ;
if ( item . className == 'img-item' ) url = item . style . backgroundImage . slice ( 4 , - 1 ) . replace ( /"/g , '' ) ;
else url = item . getAttribute ( 'data-source' ) ;
currentFiles . push ( {
earl : url
} ) ;
}
this . reindexFiles ( currentFiles , 0 ) ;
}
} ) ;
_sortablejsDefault . default . create ( this . fileList , {
onUpdate : ( e ) => {
notify . alert ( 'REINDEXING FILES' , null ) ;
let currentFiles = [ ] ;
let items = e . target . children ;
for ( let index = 0 ; index < items . length ; index ++ ) {
var item = items [ index ] ;
let url = item . getAttribute ( 'data-source' ) ;
currentFiles . push ( {
earl : url
} ) ;
}
this . reindexFiles ( currentFiles , 0 ) ;
}
} ) ;
}
getFiles ( ) {
return this . files ;
}
reindexFiles ( sortOrder , step ) {
let count = sortOrder . length ;
if ( step == 0 ) this . files = [ ] ;
var utils = new _dataUtilsDefault . default ( ) ;
var path = sortOrder [ step ] . earl . split ( '/' ) ;
utils . imgLoad ( sortOrder [ step ] . earl ) . then ( ( blob ) => {
var fresh = new File ( [
blob
] , path [ 6 ] , {
type : blob . type
} ) ;
this . files . push ( fresh ) ;
if ( this . files . length <= count - 1 ) this . reindexFiles ( sortOrder , ++ step ) ;
else notify . alert ( 'FILES READY TO UPLOAD' , true ) ;
} ) ;
}
sortFiles ( files ) {
var self = this ;
this . files = [ ] ; //clear files array
this . imageList . innerHTML = '' ;
this . fileList . innerHTML = '' ;
for ( var i = 0 , file1 ; file1 = files [ i ] ; i ++ ) {
var reader = new FileReader ( ) ; // Closure to capture the file information
reader . onload = ( ( theFile ) => {
return function ( f ) {
// sort files
switch ( theFile . type ) {
case 'image/jpg' :
case 'image/jpeg' :
case 'image/gif' :
case 'image/svg' :
case 'image/png' :
//create element and add to list
var image = document . createElement ( 'img' ) ;
image . src = f . target . result ;
image . title = escape ( theFile . name ) ;
var span = document . createElement ( 'div' ) ;
span . style . background = 'url(' + f . target . result + ') no-repeat center center / cover' ;
span . className = 'img-item' ;
image . setAttribute ( 'id' , i ) ;
self . storage . push ( [
{
id : 'page_image' + i ,
data : f . target . result ,
type : theFile . type ,
name : escape ( theFile . name )
}
] ) ;
self . imageList . appendChild ( span ) ; //add to files list
self . files . push ( theFile ) ;
break ;
case 'video/mp4' :
var video = document . createElement ( 'div' ) ;
video . className = 'video-item' ;
video . setAttribute ( 'data-source' , f . target . result ) ;
self . imageList . appendChild ( video ) ;
self . files . push ( theFile ) ;
break ;
case 'audio/mpeg' :
var sound = document . createElement ( 'div' ) ;
sound . className = 'audio-item' ;
sound . setAttribute ( 'data-source' , f . target . result ) ;
self . fileList . appendChild ( sound ) ;
self . files . push ( theFile ) ;
break ;
case 'application/pdf' :
case 'text/plain' :
case 'text/rtf' :
var file = document . createElement ( 'div' ) ;
file . className = 'file-item' ;
file . setAttribute ( 'data-source' , f . target . result ) ;
self . fileList . appendChild ( file ) ;
self . files . push ( theFile ) ;
break ;
}
} ;
} ) ( file1 ) ; // Read in the image file as a data URL.
reader . readAsDataURL ( file1 ) ;
}
}
// event handlers
//--------------------------
handleFileActions ( e ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
let self = this ;
let rawList = [ ] ;
let sortedList = [ ] ;
let notOnTheList = [ ] ;
switch ( e . type ) {
case 'dragover' :
e . dataTransfer . dropEffect = 'copy' ; // Explicitly show this is a copy.
break ;
case 'change' :
case 'drop' :
e . type == 'drop' ? rawList = e . dataTransfer . files : rawList = e . target . files ;
for ( var i = 0 , f ; f = rawList [ i ] ; i ++ ) // check witch files are cool to upload
if ( this . accetableFiles . includes ( f . type ) ) sortedList . push ( f ) ;
else notOnTheList . push ( f ) ;
//send for sorting
self . sortFiles ( sortedList ) ;
break ;
}
}
}
exports . default = FileManager ;
} , { "sortablejs" : "fLJM6" , "../utils/DataUtils" : "lpIyf" , "./Notifications.js" : "fmUxI" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "fLJM6" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
parcelHelpers . export ( exports , "MultiDrag" , ( ) => MultiDragPlugin
) ;
parcelHelpers . export ( exports , "Sortable" , ( ) => Sortable
) ;
parcelHelpers . export ( exports , "Swap" , ( ) => SwapPlugin
) ;
/ * * !
* Sortable 1.14 . 0
* @ author RubaXa < trash @ rubaxa . org >
* @ author owenm < owen23355 @ gmail . com >
* @ license MIT
* / f u n c t i o n o w n K e y s ( o b j e c t , e n u m e r a b l e O n l y ) {
var keys = Object . keys ( object ) ;
if ( Object . getOwnPropertySymbols ) {
var symbols = Object . getOwnPropertySymbols ( object ) ;
if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) {
return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ;
} ) ;
keys . push . apply ( keys , symbols ) ;
}
return keys ;
}
function _objectSpread2 ( target ) {
for ( var i = 1 ; i < arguments . length ; i ++ ) {
var source = arguments [ i ] != null ? arguments [ i ] : {
} ;
if ( i % 2 ) ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) {
_defineProperty ( target , key , source [ key ] ) ;
} ) ;
else if ( Object . getOwnPropertyDescriptors ) Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ;
else ownKeys ( Object ( source ) ) . forEach ( function ( key ) {
Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ;
} ) ;
}
return target ;
}
function _typeof ( obj1 ) {
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 ( obj1 ) ;
}
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 _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 ) || _unsupportedIterableToArray ( arr ) || _nonIterableSpread ( ) ;
}
function _arrayWithoutHoles ( arr ) {
if ( Array . isArray ( arr ) ) return _arrayLikeToArray ( arr ) ;
}
function _iterableToArray ( iter ) {
if ( typeof Symbol !== "undefined" && iter [ Symbol . iterator ] != null || iter [ "@@iterator" ] != null ) return Array . from ( iter ) ;
}
function _unsupportedIterableToArray ( o , minLen ) {
if ( ! o ) return ;
if ( typeof o === "string" ) return _arrayLikeToArray ( o , minLen ) ;
var n = Object . prototype . toString . call ( o ) . slice ( 8 , - 1 ) ;
if ( n === "Object" && o . constructor ) n = o . constructor . name ;
if ( n === "Map" || n === "Set" ) return Array . from ( o ) ;
if ( n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/ . test ( n ) ) return _arrayLikeToArray ( o , minLen ) ;
}
function _arrayLikeToArray ( arr , len ) {
if ( len == null || len > arr . length ) len = arr . length ;
for ( var i = 0 , arr2 = new Array ( len ) ; i < len ; i ++ ) arr2 [ i ] = arr [ i ] ;
return arr2 ;
}
function _nonIterableSpread ( ) {
throw new TypeError ( "Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ) ;
}
var version = "1.14.0" ;
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
* / f u n c t i o n g e t R e c t ( e l , r e l a t i v e T o C o n t a i n i n g B l o c k , r e l a t i v e T o N o n S t a t i c P a r e n t , u n d o S c a l e , c o n t a i n e r ) {
if ( ! el . getBoundingClientRect && el !== window ) return ;
var elRect , top , left , bottom , right , height , width ;
if ( el !== window && el . parentNode && 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 ;
}
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
* / f u n c t i o n i s S c r o l l e d P a s t ( e l , e l S i d e , p a r e n t S i d e ) {
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
* / f u n c t i o n g e t C h i l d ( e l , c h i l d N u m , o p t i o n s , i n c l u d e D r a g E l ) {
var currentChild = 0 , i = 0 , children = el . children ;
while ( i < children . length ) {
if ( children [ i ] . style . display !== 'none' && children [ i ] !== Sortable . ghost && ( includeDragEl || 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
* / f u n c t i o n l a s t C h i l d ( e l , s e l e c t o r ) {
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 }
* / f u n c t i o n i n d e x 1 ( e l , s e l e c t o r ) {
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 ]
* / f u n c t i o n g e t R e l a t i v e S c r o l l O f f s e t ( e l ) {
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
* / f u n c t i o n i n d e x O f O b j e c t ( a r r , o b j ) {
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 ;
}
}
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 clone1 ( 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 = _objectSpread2 ( {
} , 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 ) && ( 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)' ) ;
this . forRepaintDummy = 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 plugins1 = [ ] ;
var defaults1 = {
initializeByDefault : true
} ;
var PluginManager = {
mount : function mount ( plugin ) {
// Set default static properties
for ( var option in defaults1 ) if ( defaults1 . hasOwnProperty ( option ) && ! ( option in plugin ) ) plugin [ option ] = defaults1 [ option ] ;
plugins1 . forEach ( function ( p ) {
if ( p . pluginName === plugin . pluginName ) throw "Sortable: Cannot mount plugin " . concat ( plugin . pluginName , " more than once" ) ;
} ) ;
plugins1 . push ( plugin ) ;
} ,
pluginEvent : function pluginEvent ( eventName , sortable , evt ) {
var _this = this ;
this . eventCanceled = false ;
evt . cancel = function ( ) {
_this . eventCanceled = true ;
} ;
var eventNameGlobal = eventName + 'Global' ;
plugins1 . 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 ] ( _objectSpread2 ( {
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 ] ( _objectSpread2 ( {
sortable : sortable
} , evt ) ) ;
} ) ;
} ,
initializePlugins : function initializePlugins ( sortable , el , defaults , options ) {
plugins1 . 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 = {
} ;
plugins1 . 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 ;
plugins1 . 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 = _objectSpread2 ( _objectSpread2 ( {
} , 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 _excluded = [
"evt"
] ;
var pluginEvent = function pluginEvent ( eventName , sortable ) {
var _ref = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : {
} , originalEvent = _ref . evt , data = _objectWithoutProperties ( _ref , _excluded ) ;
PluginManager . pluginEvent . bind ( Sortable ) ( eventName , sortable , _objectSpread2 ( {
dragEl : dragEl1 ,
parentEl : parentEl1 ,
ghostEl : ghostEl ,
rootEl : rootEl1 ,
nextEl : nextEl ,
lastDownEl : lastDownEl ,
cloneEl : cloneEl1 ,
cloneHidden : cloneHidden ,
dragStarted : moved ,
putSortable : putSortable1 ,
activeSortable : Sortable . active ,
originalEvent : originalEvent ,
oldIndex : oldIndex1 ,
oldDraggableIndex : oldDraggableIndex1 ,
newIndex : newIndex1 ,
newDraggableIndex : newDraggableIndex1 ,
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 ( _objectSpread2 ( {
putSortable : putSortable1 ,
cloneEl : cloneEl1 ,
targetEl : dragEl1 ,
rootEl : rootEl1 ,
oldIndex : oldIndex1 ,
oldDraggableIndex : oldDraggableIndex1 ,
newIndex : newIndex1 ,
newDraggableIndex : newDraggableIndex1
} , info ) ) ;
}
var dragEl1 , parentEl1 , ghostEl , rootEl1 , nextEl , lastDownEl , cloneEl1 , cloneHidden , oldIndex1 , newIndex1 , oldDraggableIndex1 , newDraggableIndex1 , activeGroup , putSortable1 , 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
* / _ d e t e c t N e a r e s t E m p t y S o r t a b l e = f u n c t i o n _ d e t e c t N e a r e s t E m p t y S o r t a b l e ( x , y ) {
var ret ;
sortables . some ( function ( sortable ) {
var threshold = sortable [ expando ] . options . emptyInsertThreshold ;
if ( ! threshold || lastChild ( sortable ) ) return ;
var rect = getRect ( sortable ) , insideHorizontally = x >= rect . left - threshold && x <= rect . right + threshold , insideVertically = y >= rect . top - threshold && y <= rect . bottom + threshold ;
if ( 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 ( dragEl1 ) {
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 ( dragEl1 ) dragEl1 . parentNode [ expando ] . _isOutsideThisEl ( evt . target ) ;
} ;
/ * *
* @ class Sortable
* @ param { HTMLElement } el
* @ param { Object } [ options ]
* / f u n c t i o n S o r t a b l e ( e l , o p t i o n s ) {
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 && ! Safari ,
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 , dragEl1 ) : 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 ( dragEl1 ) 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 ;
// Safari ignores further event handling after mousedown
if ( ! this . nativeDraggable && Safari && target && target . tagName . toUpperCase ( ) === 'SELECT' ) 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
oldIndex1 = index1 ( target ) ;
oldDraggableIndex1 = index1 ( 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 && ! dragEl1 && target . parentNode === el ) {
var dragRect = getRect ( target ) ;
rootEl1 = el ;
dragEl1 = target ;
parentEl1 = dragEl1 . parentNode ;
nextEl = dragEl1 . nextSibling ;
lastDownEl = target ;
activeGroup = options . group ;
Sortable . dragged = dragEl1 ;
tapEvt = {
target : dragEl1 ,
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 ;
dragEl1 . 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 ) dragEl1 . draggable = true ;
// Bind the events: dragstart/dragend
_this . _triggerDragStart ( evt , touch ) ; // Drag start event
_dispatchEvent ( {
sortable : _this ,
name : 'choose' ,
originalEvent : evt
} ) ; // Chosen item
toggleClass ( dragEl1 , options . chosenClass , true ) ;
} ; // Disable "draggable"
options . ignore . split ( ',' ) . forEach ( function ( criteria ) {
find ( dragEl1 , 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 ;
dragEl1 . 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 ( ) {
dragEl1 && _disableDraggable ( dragEl1 ) ;
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 ( dragEl1 , 'dragend' , this ) ;
on ( rootEl1 , '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 ( rootEl1 && dragEl1 ) {
pluginEvent ( 'dragStarted' , this , {
evt : evt
} ) ;
if ( this . nativeDraggable ) on ( document , 'dragover' , _checkOutsideTargetEl ) ;
var options = this . options ; // Apply effect
! fallback && toggleClass ( dragEl1 , options . dragClass , false ) ;
toggleClass ( dragEl1 , 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 ;
}
dragEl1 . 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
} 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 : rootEl1 , rect = getRect ( dragEl1 , 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 = dragEl1 . 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 ) {
cloneEl1 = clone1 ( dragEl1 ) ;
cloneEl1 . draggable = false ;
cloneEl1 . style [ 'will-change' ] = '' ;
this . _hideClone ( ) ;
toggleClass ( cloneEl1 , this . options . chosenClass , false ) ;
Sortable . clone = cloneEl1 ;
} // #1143: IFrame support workaround
_this . cloneId = _nextTick ( function ( ) {
pluginEvent ( 'clone' , _this ) ;
if ( Sortable . eventCanceled ) return ;
if ( ! _this . options . removeCloneOnHide ) rootEl1 . insertBefore ( cloneEl1 , dragEl1 ) ;
_this . _hideClone ( ) ;
_dispatchEvent ( {
sortable : _this ,
name : 'clone'
} ) ;
} ) ;
! fallback && toggleClass ( dragEl1 , 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 , dragEl1 ) ;
}
on ( document , 'drop' , _this ) ; // #1276 fix:
css ( dragEl1 , '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 , target1 = evt . target , dragRect , targetRect , revert , options = this . options , group = options . group , activeSortable = Sortable . active , isOwner = activeGroup === group , canSort = options . sort , fromSortable = putSortable1 || activeSortable , vertical , _this = this , completedFired = false ;
if ( _silent ) return ;
function dragOverEvent ( name , extra ) {
pluginEvent ( name , _this , _objectSpread2 ( {
evt : evt ,
isOwner : isOwner ,
axis : vertical ? 'vertical' : 'horizontal' ,
revert : revert ,
dragRect : dragRect ,
targetRect : targetRect ,
canSort : canSort ,
fromSortable : fromSortable ,
target : target1 ,
completed : completed ,
onMove : function onMove ( target , after ) {
return _onMove ( rootEl1 , el , dragEl1 , 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 ( dragEl1 , putSortable1 ? putSortable1 . options . ghostClass : activeSortable . options . ghostClass , false ) ;
toggleClass ( dragEl1 , options . ghostClass , true ) ;
}
if ( putSortable1 !== _this && _this !== Sortable . active ) putSortable1 = _this ;
else if ( _this === Sortable . active && putSortable1 ) putSortable1 = null ;
// Animation
if ( fromSortable === _this ) _this . _ignoreWhileAnimating = target1 ;
_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 ( target1 === dragEl1 && ! dragEl1 . animated || target1 === el && ! target1 . animated ) lastTarget = null ;
// no bubbling and not fallback
if ( ! options . dragoverBubble && ! evt . rootEl && target1 !== document ) {
dragEl1 . 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 ( ) {
newIndex1 = index1 ( dragEl1 ) ;
newDraggableIndex1 = index1 ( dragEl1 , options . draggable ) ;
_dispatchEvent ( {
sortable : _this ,
name : 'change' ,
toEl : el ,
newIndex : newIndex1 ,
newDraggableIndex : newDraggableIndex1 ,
originalEvent : evt
} ) ;
}
if ( evt . preventDefault !== void 0 ) evt . cancelable && evt . preventDefault ( ) ;
target1 = closest ( target1 , options . draggable , el , true ) ;
dragOverEvent ( 'dragOver' ) ;
if ( Sortable . eventCanceled ) return completedFired ;
if ( dragEl1 . contains ( evt . target ) || target1 . animated && target1 . animatingX && target1 . animatingY || _this . _ignoreWhileAnimating === target1 ) return completed ( false ) ;
ignoreNextClick = false ;
if ( activeSortable && ! options . disabled && ( isOwner ? canSort || ( revert = parentEl1 !== rootEl1 ) // Reverting item into the original list
: putSortable1 === this || ( this . lastPutMode = activeGroup . checkPull ( this , activeSortable , dragEl1 , evt ) ) && group . checkPut ( this , activeSortable , dragEl1 , evt ) ) ) {
vertical = this . _getDirection ( evt , target1 ) === 'vertical' ;
dragRect = getRect ( dragEl1 ) ;
dragOverEvent ( 'dragOverValid' ) ;
if ( Sortable . eventCanceled ) return completedFired ;
if ( revert ) {
parentEl1 = rootEl1 ; // actualization
capture ( ) ;
this . _hideClone ( ) ;
dragOverEvent ( 'revert' ) ;
if ( ! Sortable . eventCanceled ) {
if ( nextEl ) rootEl1 . insertBefore ( dragEl1 , nextEl ) ;
else rootEl1 . appendChild ( dragEl1 ) ;
}
return completed ( true ) ;
}
var elLastChild = lastChild ( el , options . draggable ) ;
if ( ! elLastChild || _ghostIsLast ( evt , vertical , this ) && ! elLastChild . animated ) {
// Insert to end of list
// If already at end of list: Do not insert
if ( elLastChild === dragEl1 ) return completed ( false ) ;
// if there is a last element, it is the target
if ( elLastChild && el === evt . target ) target1 = elLastChild ;
if ( target1 ) targetRect = getRect ( target1 ) ;
if ( _onMove ( rootEl1 , el , dragEl1 , dragRect , target1 , targetRect , evt , ! ! target1 ) !== false ) {
capture ( ) ;
el . appendChild ( dragEl1 ) ;
parentEl1 = el ; // actualization
changed ( ) ;
return completed ( true ) ;
}
} else if ( elLastChild && _ghostIsFirst ( evt , vertical , this ) ) {
// Insert to start of list
var firstChild = getChild ( el , 0 , options , true ) ;
if ( firstChild === dragEl1 ) return completed ( false ) ;
target1 = firstChild ;
targetRect = getRect ( target1 ) ;
if ( _onMove ( rootEl1 , el , dragEl1 , dragRect , target1 , targetRect , evt , false ) !== false ) {
capture ( ) ;
el . insertBefore ( dragEl1 , firstChild ) ;
parentEl1 = el ; // actualization
changed ( ) ;
return completed ( true ) ;
}
} else if ( target1 . parentNode === el ) {
targetRect = getRect ( target1 ) ;
var direction = 0 , targetBeforeFirstSwap , differentLevel = dragEl1 . parentNode !== el , differentRowCol = ! _dragElInRowColumn ( dragEl1 . animated && dragEl1 . toRect || dragRect , target1 . animated && target1 . toRect || targetRect , vertical ) , side1 = vertical ? 'top' : 'left' , scrolledPastTop = isScrolledPast ( target1 , 'top' , 'top' ) || isScrolledPast ( dragEl1 , 'top' , 'top' ) , scrollBefore = scrolledPastTop ? scrolledPastTop . scrollTop : void 0 ;
if ( lastTarget !== target1 ) {
targetBeforeFirstSwap = targetRect [ side1 ] ;
pastFirstInvertThresh = false ;
isCircumstantialInvert = ! differentRowCol && options . invertSwap || differentLevel ;
}
direction = _getSwapDirection ( evt , target1 , targetRect , vertical , differentRowCol ? 1 : options . swapThreshold , options . invertedSwapThreshold == null ? options . swapThreshold : options . invertedSwapThreshold , isCircumstantialInvert , lastTarget === target1 ) ;
var sibling ;
if ( direction !== 0 ) {
// Check if target is beside dragEl in respective direction (ignoring hidden elements)
var dragIndex = index1 ( dragEl1 ) ;
do {
dragIndex -= direction ;
sibling = parentEl1 . children [ dragIndex ] ;
} while ( sibling && ( css ( sibling , 'display' ) === 'none' || sibling === ghostEl ) )
} // If dragEl is already beside target: Do not insert
if ( direction === 0 || sibling === target1 ) return completed ( false ) ;
lastTarget = target1 ;
lastDirection = direction ;
var nextSibling = target1 . nextElementSibling , after1 = false ;
after1 = direction === 1 ;
var moveVector = _onMove ( rootEl1 , el , dragEl1 , dragRect , target1 , targetRect , evt , after1 ) ;
if ( moveVector !== false ) {
if ( moveVector === 1 || moveVector === - 1 ) after1 = moveVector === 1 ;
_silent = true ;
setTimeout ( _unsilent , 30 ) ;
capture ( ) ;
if ( after1 && ! nextSibling ) el . appendChild ( dragEl1 ) ;
else target1 . parentNode . insertBefore ( dragEl1 , after1 ? nextSibling : target1 ) ;
// Undo chrome's scroll adjustment (has no effect on other browsers)
if ( scrolledPastTop ) scrollBy ( scrolledPastTop , 0 , scrollBefore - scrolledPastTop . scrollTop ) ;
parentEl1 = dragEl1 . parentNode ; // actualization
// must be done before animation
if ( targetBeforeFirstSwap !== undefined && ! isCircumstantialInvert ) targetMoveDistance = Math . abs ( targetBeforeFirstSwap - getRect ( target1 ) [ side1 ] ) ;
changed ( ) ;
return completed ( true ) ;
}
}
if ( el . contains ( dragEl1 ) ) 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
newIndex1 = index1 ( dragEl1 ) ;
newDraggableIndex1 = index1 ( dragEl1 , options . draggable ) ;
pluginEvent ( 'drop' , this , {
evt : evt
} ) ;
parentEl1 = dragEl1 && dragEl1 . parentNode ; // Get again after plugin event
newIndex1 = index1 ( dragEl1 ) ;
newDraggableIndex1 = index1 ( dragEl1 , 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 ( dragEl1 , 'transform' , '' ) ;
if ( evt ) {
if ( moved ) {
evt . cancelable && evt . preventDefault ( ) ;
! options . dropBubble && evt . stopPropagation ( ) ;
}
ghostEl && ghostEl . parentNode && ghostEl . parentNode . removeChild ( ghostEl ) ;
if ( rootEl1 === parentEl1 || putSortable1 && putSortable1 . lastPutMode !== 'clone' ) // Remove clone(s)
cloneEl1 && cloneEl1 . parentNode && cloneEl1 . parentNode . removeChild ( cloneEl1 ) ;
if ( dragEl1 ) {
if ( this . nativeDraggable ) off ( dragEl1 , 'dragend' , this ) ;
_disableDraggable ( dragEl1 ) ;
dragEl1 . style [ 'will-change' ] = '' ; // Remove classes
// ghostClass is added in dragStarted
if ( moved && ! awaitingDragStarted ) toggleClass ( dragEl1 , putSortable1 ? putSortable1 . options . ghostClass : this . options . ghostClass , false ) ;
toggleClass ( dragEl1 , this . options . chosenClass , false ) ; // Drag stop event
_dispatchEvent ( {
sortable : this ,
name : 'unchoose' ,
toEl : parentEl1 ,
newIndex : null ,
newDraggableIndex : null ,
originalEvent : evt
} ) ;
if ( rootEl1 !== parentEl1 ) {
if ( newIndex1 >= 0 ) {
// Add event
_dispatchEvent ( {
rootEl : parentEl1 ,
name : 'add' ,
toEl : parentEl1 ,
fromEl : rootEl1 ,
originalEvent : evt
} ) ; // Remove event
_dispatchEvent ( {
sortable : this ,
name : 'remove' ,
toEl : parentEl1 ,
originalEvent : evt
} ) ; // drag from one list and drop into another
_dispatchEvent ( {
rootEl : parentEl1 ,
name : 'sort' ,
toEl : parentEl1 ,
fromEl : rootEl1 ,
originalEvent : evt
} ) ;
_dispatchEvent ( {
sortable : this ,
name : 'sort' ,
toEl : parentEl1 ,
originalEvent : evt
} ) ;
}
putSortable1 && putSortable1 . save ( ) ;
} else {
if ( newIndex1 !== oldIndex1 ) {
if ( newIndex1 >= 0 ) {
// drag & drop within the same list
_dispatchEvent ( {
sortable : this ,
name : 'update' ,
toEl : parentEl1 ,
originalEvent : evt
} ) ;
_dispatchEvent ( {
sortable : this ,
name : 'sort' ,
toEl : parentEl1 ,
originalEvent : evt
} ) ;
}
}
}
if ( Sortable . active ) {
/* jshint eqnull:true */ if ( newIndex1 == null || newIndex1 === - 1 ) {
newIndex1 = oldIndex1 ;
newDraggableIndex1 = oldDraggableIndex1 ;
}
_dispatchEvent ( {
sortable : this ,
name : 'end' ,
toEl : parentEl1 ,
originalEvent : evt
} ) ; // Save sorting
this . save ( ) ;
}
}
}
this . _nulling ( ) ;
} ,
_nulling : function _nulling ( ) {
pluginEvent ( 'nulling' , this ) ;
rootEl1 = dragEl1 = parentEl1 = ghostEl = nextEl = cloneEl1 = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex1 = newDraggableIndex1 = oldIndex1 = oldDraggableIndex1 = lastTarget = lastDirection = putSortable1 = 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 ( dragEl1 ) {
this . _onDragOver ( evt ) ;
_globalDragOver ( evt ) ;
}
break ;
case 'selectstart' :
evt . preventDefault ( ) ;
break ;
}
} ,
/ * *
* Serializes the item into an array of string .
* @ returns { String [ ] }
* / t o A r r a y : f u n c t i o n t o A r r a y ( ) {
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
* / s o r t : f u n c t i o n s o r t ( o r d e r , u s e A n i m a t i o n ) {
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 ) ;
useAnimation && this . captureAnimationState ( ) ;
order . forEach ( function ( id ) {
if ( items [ id ] ) {
rootEl . removeChild ( items [ id ] ) ;
rootEl . appendChild ( items [ id ] ) ;
}
} ) ;
useAnimation && this . animateAll ( ) ;
} ,
/ * *
* Save the current sorting
* / s a v e : f u n c t i o n s a v e ( ) {
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 }
* / c l o s e s t : f u n c t i o n c l o s e s t $ 1 ( e l , s e l e c t o r ) {
return closest ( el , selector || this . options . draggable , this . el , false ) ;
} ,
/ * *
* Set / get option
* @ param { string } name
* @ param { * } [ value ]
* @ returns { * }
* / o p t i o n : f u n c t i o n o p t i o n ( n a m e , v a l u e ) {
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
* / d e s t r o y : f u n c t i o n d e s t r o y ( ) {
pluginEvent ( 'destroy' , this ) ;
var el1 = this . el ;
el1 [ expando ] = null ;
off ( el1 , 'mousedown' , this . _onTapStart ) ;
off ( el1 , 'touchstart' , this . _onTapStart ) ;
off ( el1 , 'pointerdown' , this . _onTapStart ) ;
if ( this . nativeDraggable ) {
off ( el1 , 'dragover' , this ) ;
off ( el1 , 'dragenter' , this ) ;
} // Remove draggable attributes
Array . prototype . forEach . call ( el1 . querySelectorAll ( '[draggable]' ) , function ( el ) {
el . removeAttribute ( 'draggable' ) ;
} ) ;
this . _onDrop ( ) ;
this . _disableDelayedDragEvents ( ) ;
sortables . splice ( sortables . indexOf ( this . el ) , 1 ) ;
this . el = el1 = null ;
} ,
_hideClone : function _hideClone ( ) {
if ( ! cloneHidden ) {
pluginEvent ( 'hideClone' , this ) ;
if ( Sortable . eventCanceled ) return ;
css ( cloneEl1 , 'display' , 'none' ) ;
if ( this . options . removeCloneOnHide && cloneEl1 . parentNode ) cloneEl1 . parentNode . removeChild ( cloneEl1 ) ;
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 ( dragEl1 . parentNode == rootEl1 && ! this . options . group . revertClone ) rootEl1 . insertBefore ( cloneEl1 , dragEl1 ) ;
else if ( nextEl ) rootEl1 . insertBefore ( cloneEl1 , nextEl ) ;
else rootEl1 . appendChild ( cloneEl1 ) ;
if ( this . options . group . revertClone ) this . animate ( dragEl1 , cloneEl1 ) ;
css ( cloneEl1 , '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 _ghostIsFirst ( evt , vertical , sortable ) {
var rect = getRect ( getChild ( sortable . el , 0 , sortable . options , true ) ) ;
var spacer = 10 ;
return vertical ? evt . clientX < rect . left - spacer || evt . clientY < rect . top && evt . clientX < rect . right : evt . clientY < rect . top - spacer || evt . clientY < rect . bottom && evt . clientX < rect . left ;
}
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
* / f u n c t i o n _ g e t I n s e r t D i r e c t i o n ( t a r g e t ) {
if ( index1 ( dragEl1 ) < index1 ( target ) ) return 1 ;
else return - 1 ;
}
/ * *
* Generate id
* @ param { HTMLElement } el
* @ returns { String }
* @ private
* / f u n c t i o n _ g e n e r a t e I d ( e l ) {
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 : clone1 ,
index : index1 ,
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
* / S o r t a b l e . g e t = f u n c t i o n ( e l e m e n t ) {
return element [ expando ] ;
} ;
/ * *
* Mount a plugin to Sortable
* @ param { ... SortablePlugin | SortablePlugin [ ] } plugins Plugins being mounted
* / S o r t a b l e . m o u n t = f u n c t i o n ( ) {
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 = _objectSpread2 ( _objectSpread2 ( {
} , Sortable . utils ) , plugin . utils ) ;
PluginManager . mount ( plugin ) ;
} ) ;
} ;
/ * *
* Create sortable instance
* @ param { HTMLElement } el
* @ param { Object } [ options ]
* / S o r t a b l e . c r e a t e = f u n c t i o n ( e l , o p t i o n s ) {
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 ,
forceAutoScrollFallback : false ,
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 || this . options . forceAutoScrollFallback || Edge || IE11OrLess || Safari ) {
autoScroll1 ( 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 ( ) ;
}
autoScroll1 ( 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 ;
}
autoScroll1 ( 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 autoScroll1 = 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 = index1 ( n1 ) ;
i2 = index1 ( 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 ( clone1 ( 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 = index1 ( 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 = index1 ( lastMultiDragSelect ) , currentIndex = index1 ( 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 ) {
folding = false ; // Do not "unfold" after around dragEl if reverted
if ( ( parentEl [ expando ] . options . sort || parentEl !== rootEl ) && multiDragElements . length > 1 ) {
var dragRect = getRect ( dragEl$1 ) , multiDragIndex = index1 ( 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 === index1 ( dragEl$1 ) ) {
var update = false ;
multiDragElements . forEach ( function ( multiDragElement ) {
if ( multiDragElement . sortableIndex !== index1 ( 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
* / s e l e c t : f u n c t i o n s e l e c t ( e l ) {
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
* / d e s e l e c t : f u n c t i o n d e s e l e c t ( e l ) {
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 = index1 ( multiDragElement , ':not(.' + _this3 . options . selectedClass + ')' ) ;
else newIndex = index1 ( 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
* / f u n c t i o n i n s e r t M u l t i D r a g C l o n e s ( e l e m e n t s I n s e r t e d , r o o t E l ) {
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 ) ;
exports . default = Sortable ;
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "js2Fi" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
var _settingsActions = require ( "../actions/SettingsActions" ) ;
var _settingsActionsDefault = parcelHelpers . interopDefault ( _settingsActions ) ;
var _maintenanceManager = require ( "./MaintenanceManager" ) ;
var _maintenanceManagerDefault = parcelHelpers . interopDefault ( _maintenanceManager ) ;
var _fipamoAdminAPI = require ( "../../libraries/FipamoAdminAPI" ) ;
var _fipamoAdminAPIDefault = parcelHelpers . interopDefault ( _fipamoAdminAPI ) ;
var _dataEvent = require ( "../../../src/com/events/DataEvent" ) ;
var _mailer = require ( "../actions/Mailer" ) ;
var _mailerDefault = parcelHelpers . interopDefault ( _mailer ) ;
var _notifications = require ( "../ui/Notifications" ) ;
var _notificationsDefault = parcelHelpers . interopDefault ( _notifications ) ;
const notify = new _notificationsDefault . default ( ) ;
class SettingsIndex {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
this . processing = false ;
this . start ( ) ;
this . admin = new _fipamoAdminAPIDefault . default ( null ) ;
this . mm = new _maintenanceManagerDefault . default ( null , null ) ;
}
// methods
//--------------------------
start ( ) {
let self = this ; //handle save button
document . getElementById ( "save-toggle" ) . addEventListener ( "click" , ( ) => new _settingsActionsDefault . default ( ) . getInfo ( ) . then ( ( data ) => {
notify . alert ( "Saving Settings" , null ) ;
self . admin . sync ( _fipamoAdminAPI . TASK _SYNC _SETTNIGS , data ) . then ( ( r ) => {
if ( r . type == _dataEvent . SETTINGS _UPDATED ) notify . alert ( r . message , true ) ;
else notify . alert ( r . message , true ) ;
} ) ;
} ) . catch ( ( ) => {
} )
) ; //handle set up image uploads
document . getElementById ( "avatar" ) . addEventListener ( "click" , ( ) => {
document . getElementById ( "avatar-upload" ) . click ( ) ;
} ) ;
document . getElementById ( "background" ) . addEventListener ( "click" , ( ) => {
document . getElementById ( "background-upload" ) . click ( ) ;
} ) ;
document . getElementById ( "avatar-upload" ) . addEventListener ( "change" , ( e ) => {
self . handleImageUpload ( e . target . id , e . target . files ) ;
} , false ) ;
document . getElementById ( "background-upload" ) . addEventListener ( "change" , ( e ) => {
self . handleImageUpload ( e . target . id , e . target . files ) ;
} , false ) ; //handle api access toggle
var apiButton = document . getElementById ( "api-access-toggle" ) ;
var apiStatus = document . getElementById ( "api-status" ) ;
apiButton . addEventListener ( "click" , ( e ) => {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
if ( apiButton . getAttribute ( "data-enabled" ) == "false" ) {
apiButton . setAttribute ( "data-enabled" , "true" ) ;
apiStatus . innerHTML = "EXTERNAL API ACCESS IS ENABLED" ;
} else {
apiButton . setAttribute ( "data-enabled" , "false" ) ;
apiStatus . innerHTML = "EXTERNAL API ACCESS IS NOT ENABLED" ;
}
} ) ; //handle dynamic page rendering
var dynamicRenderButton = document . getElementById ( "dynamic-render-toggle" ) ;
var dynamicRenderStatus = document . getElementById ( "dynamic-render-status" ) ;
dynamicRenderButton . addEventListener ( "click" , ( e ) => {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
if ( dynamicRenderButton . getAttribute ( "data-enabled" ) == "false" ) {
dynamicRenderButton . setAttribute ( "data-enabled" , "true" ) ;
dynamicRenderStatus . innerHTML = "DYNAMIC PAGE RENDERING" ;
} else {
dynamicRenderButton . setAttribute ( "data-enabled" , "false" ) ;
dynamicRenderStatus . innerHTML = "STATIC PAGE RENDERING" ;
}
} ) ;
document . getElementById ( "send-mail" ) . addEventListener ( "click" , ( e ) => this . handleMailer ( e )
) ;
document . getElementById ( "publish-pages" ) . addEventListener ( "click" , ( e ) => this . handlePublished ( e )
) ; //handle page render on save toggle
document . getElementById ( "render-toggle" ) . addEventListener ( "click" , ( e ) => this . toggleRender ( e )
) ;
document . getElementById ( "render-toggle-icon" ) . addEventListener ( "click" , ( e ) => this . toggleRender ( e )
) ; //handle theme toggle
let themeBtns = document . querySelectorAll ( ".theme-select" ) ;
for ( var i = 0 , length = themeBtns . length ; i < length ; i ++ ) themeBtns [ i ] . addEventListener ( "click" , ( e ) => this . handleThemes ( e )
) ;
//handle mail options
let mailBtn = document . querySelectorAll ( ".mail-option" ) ;
for ( i = 0 , length = mailBtn . length ; i < length ; i ++ ) mailBtn [ i ] . addEventListener ( "click" , ( e ) => this . handleMailOptions ( e )
) ;
//handle backup from settings [disabled]
document . getElementById ( "create-backup" ) . addEventListener ( "click" , ( e ) => this . handleBackup ( e )
) ;
/ *
document
. getElementById ( "reindex-pages" )
. addEventListener ( "click" , ( e ) => this . handleReindex ( e ) ) ;
* / }
// event handlers
//--------------------------
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" ;
}
}
toggleRender ( e1 ) {
e1 . stopPropagation ( ) ;
e1 . preventDefault ( ) ;
let button = document . getElementById ( "render-toggle" ) ;
if ( button . getAttribute ( "data-render" ) == "false" ) button . setAttribute ( "data-render" , "true" ) ; //e.target.innerHTML = 'RENDER PAGES ON SAVE';
else button . setAttribute ( "data-render" , "false" ) ; //e.target.innerHTML = "DON'T RENDER PAGES ON SAVE";
}
handleMailer ( ) {
let mailer = new _mailerDefault . default ( ) ;
mailer . testMail ( ) ; //mailer.sendMail();
}
handleThemes ( e2 ) {
e2 . stopPropagation ( ) ;
e2 . preventDefault ( ) ;
let themes = document . querySelectorAll ( ".theme-select" ) ;
for ( var i = 0 , length = themes . length ; i < length ; i ++ ) e2 . target . id == themes [ i ] . id ? themes [ i ] . setAttribute ( "data-enabled" , "true" ) : themes [ i ] . setAttribute ( "data-enabled" , "false" ) ;
}
handleMailOptions ( e3 ) {
e3 . preventDefault ( ) ;
e3 . stopPropagation ( ) ;
let smtp = document . getElementById ( "mail-smtp" ) ;
let mailgun = document . getElementById ( "mail-mg" ) ;
let mail = document . querySelectorAll ( ".mail-option" ) ;
for ( var i = 0 , length = mail . length ; i < length ; i ++ ) if ( e3 . target . id == mail [ i ] . id ) {
mail [ i ] . setAttribute ( "data-enabled" , "true" ) ;
if ( e3 . target . id == "option-smtp" ) {
smtp . setAttribute ( "data-enabled" , "true" ) ;
mailgun . setAttribute ( "data-enabled" , "false" ) ;
} else if ( e3 . 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" ) ;
}
handleImageUpload ( type , files ) {
notify . alert ( "Uploading Image... " , null ) ;
this . mm . imageUpload ( type , files ) . then ( ( 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 ( ( ) => {
} ) ;
}
handlePublished ( e4 ) {
if ( this . processing ) return ;
e4 . preventDefault ( ) ;
e4 . stopPropagation ( ) ;
let self = this ;
let task = {
task : "PUBLISH_ALL"
} ;
this . processing = true ;
notify . alert ( "Publishing site..." , null ) ;
this . admin . publish ( task ) . then ( ( r ) => {
self . processing = false ;
notify . alert ( r . message , true ) ;
} ) . catch ( ( err ) => {
self . processing = false ;
notify . alert ( err , false ) ;
} ) ;
}
handleBackup ( e5 ) {
e5 . preventDefault ( ) ;
e5 . stopPropagation ( ) ;
notify . alert ( "Creating backup" , null ) ;
this . mm . backup ( ) . then ( ( r ) => {
notify . alert ( r . message , true ) ;
} ) . catch ( ( err ) => {
notify . alert ( err , false ) ;
} ) ;
}
handleReindex ( e6 ) {
if ( this . processing ) return ;
let self = this ;
e6 . preventDefault ( ) ;
e6 . stopPropagation ( ) ;
let task = {
task : "cleanup pages indexes"
} ;
this . processing = true ;
notify . alert ( "Cleaning up page indexes" , null ) ;
this . admin . handleReindex ( task ) . then ( ( r ) => {
self . processing = false ;
notify . alert ( r . message , true ) ;
} ) . catch ( ( err ) => {
self . processing = false ;
notify . alert ( err , false ) ;
} ) ;
}
}
exports . default = SettingsIndex ;
} , { "../actions/SettingsActions" : "1wxe0" , "./MaintenanceManager" : "kY7L1" , "../../libraries/FipamoAdminAPI" : "6M96o" , "../../../src/com/events/DataEvent" : "edzJV" , "../actions/Mailer" : "hoAIx" , "../ui/Notifications" : "fmUxI" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "1wxe0" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
class SettingsActions {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
}
// methods
//--------------------------
getInfo ( ) {
let handle = document . getElementById ( "settings-handle" ) . value ;
let email = document . getElementById ( "settings-email" ) . value ;
let url = document . getElementById ( "settings-url" ) . value ;
let title = document . getElementById ( "settings-title" ) . value ;
let desc = document . getElementById ( "settings-desc" ) . value ; //let privacy = document.getElementById('privacy-toggle').getAttribute('data-private');
let render = document . getElementById ( "render-toggle" ) . getAttribute ( "data-render" ) ;
let background = document . getElementById ( "background" ) . src ;
let selected = "" ;
let selects = document . querySelectorAll ( ".theme-select" ) ;
let smtpDomain = document . getElementById ( "smtp-domain" ) . value ;
let smtpEmail = document . getElementById ( "smtp-email" ) . value ;
let smtpPass = document . getElementById ( "smtp-pass" ) . value ;
let mgDomain = document . getElementById ( "mg-domain" ) . value ;
let mgKey = document . getElementById ( "mg-key" ) . value ;
let mailActive = "" ;
let mailOptions = document . querySelectorAll ( ".mail-option" ) ;
let apiStatus = document . getElementById ( "api-access-toggle" ) . getAttribute ( "data-enabled" ) ;
let dynamicRenderStatus = document . getElementById ( "dynamic-render-toggle" ) . getAttribute ( "data-enabled" ) ;
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 ;
let settingsData = {
global : {
base _url : url ,
title : title ,
descriptions : desc ,
background : background ,
private : false ,
renderOnSave : render ,
theme : selected ,
externalAPI : apiStatus ,
dynamicRender : dynamicRenderStatus
} ,
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 ) ;
} ) ;
}
}
exports . default = SettingsActions ;
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "hoAIx" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
var _fipamoAdminAPI = require ( "../../libraries/FipamoAdminAPI" ) ;
var _fipamoAdminAPIDefault = parcelHelpers . interopDefault ( _fipamoAdminAPI ) ;
var _notifications = require ( "../ui/Notifications" ) ;
var _notificationsDefault = parcelHelpers . interopDefault ( _notifications ) ;
const notify = new _notificationsDefault . default ( ) ;
class Mailer {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
}
// methods
//--------------------------
sendMail ( ) {
let mailData = {
content : "This is a test email"
} ;
let admin = new _fipamoAdminAPIDefault . default ( ) ;
admin . sendMail ( mailData ) . then ( ( result ) => {
notify . alert ( result . message , true ) ;
} ) . catch ( ( err ) => {
notify . alert ( err . message , false ) ;
} ) ;
}
testMail ( ) {
let mailData = {
content : "This is a test email" ,
mail _task : "TESTING"
} ;
let admin = new _fipamoAdminAPIDefault . default ( ) ;
admin . sendMail ( mailData ) . then ( ( result ) => {
notify . alert ( result . message , true ) ;
} ) . catch ( ( err ) => {
notify . alert ( err . message , false ) ;
} ) ;
}
}
exports . default = Mailer ;
} , { "../../libraries/FipamoAdminAPI" : "6M96o" , "../ui/Notifications" : "fmUxI" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "9sqHb" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
var _fipamoAdminAPI = require ( "../../libraries/FipamoAdminAPI" ) ;
var _fipamoAdminAPIDefault = parcelHelpers . interopDefault ( _fipamoAdminAPI ) ;
var _navActions = require ( "../actions/NavActions" ) ;
var _navActionsDefault = parcelHelpers . interopDefault ( _navActions ) ;
var _dataEvent = require ( "../events/DataEvent" ) ;
var _notifications = require ( "../ui/Notifications" ) ;
var _notificationsDefault = parcelHelpers . interopDefault ( _notifications ) ;
var _sortablejs = require ( "sortablejs" ) ;
var _sortablejsDefault = parcelHelpers . interopDefault ( _sortablejs ) ;
const notify = new _notificationsDefault . default ( ) ;
class NavIndex {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
this . processing = false ;
this . admin = new _fipamoAdminAPIDefault . default ( null ) ;
this . start ( ) ;
}
// methods
//--------------------------
start ( ) {
//grabs elements and makes them sortables
let self = this ;
_sortablejsDefault . default . create ( document . getElementById ( 'nav-pages' ) , {
onUpdate : ( ) => {
new _navActionsDefault . default ( ) . syncMenu ( ) . then ( ( data ) => {
notify . alert ( 'Updating Menu' , null ) ;
self . admin . sync ( _fipamoAdminAPI . TASK _SYNC _NAV , data ) . then ( ( 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' , ( e ) => this . handleNavButton ( e )
, false ) ;
}
// event handlers
//--------------------------
handleNavButton ( e ) {
if ( this . processing ) return ;
let id = '' ;
let self = this ;
switch ( e . target . id ) {
case 'remove-item' :
id = e . target . getAttribute ( 'data-id' ) ;
new _navActionsDefault . default ( ) . removeItem ( id ) ;
new _navActionsDefault . default ( ) . syncMenu ( ) . then ( ( data ) => {
data . remove = e . target . getAttribute ( 'data-uuid' ) ;
notify . alert ( 'Editing Menu' , null ) ;
self . processing = true ;
self . admin . sync ( _fipamoAdminAPI . TASK _SYNC _NAV , data ) . then ( ( r ) => {
self . processing = false ;
if ( r . type == _dataEvent . MENU _UPDATED ) notify . alert ( r . message , true ) ;
else notify . alert ( r . message , true ) ;
} ) ;
} ) ;
break ;
case 'edit-item' :
self . processing = false ;
window . location = '/dashboard/page/edit/' + e . target . getAttribute ( 'data-id' ) ;
break ;
}
}
}
exports . default = NavIndex ;
} , { "../../libraries/FipamoAdminAPI" : "6M96o" , "../actions/NavActions" : "3Mi5a" , "../events/DataEvent" : "edzJV" , "../ui/Notifications" : "fmUxI" , "sortablejs" : "fLJM6" , "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] , "3Mi5a" : [ function ( require , module , exports ) {
var parcelHelpers = require ( "@parcel/transformer-js/src/esmodule-helpers.js" ) ;
parcelHelpers . defineInteropFlag ( exports ) ;
class NavActions {
//--------------------------
// constructor
//--------------------------
constructor ( ) {
}
// methods
//--------------------------
syncMenu ( ) {
let navData = [ ] ;
let items = document . getElementById ( "nav-pages" ) . children ;
for ( let 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" )
} ) ;
let data = {
menu : navData ,
remove : null
} ;
return new Promise ( function ( resolve ) {
resolve ( data ) ;
} ) ;
}
removeItem ( id ) {
document . getElementById ( "nav-pages" ) . removeChild ( document . getElementById ( id ) ) ;
}
}
exports . default = NavActions ;
} , { "@parcel/transformer-js/src/esmodule-helpers.js" : "ciiiV" } ] } , [ "jRsG2" , "bEyX8" ] , "bEyX8" , "parcelRequiredac0" )
//# sourceMappingURL=Start.js.map