ac08c77813
Began the process of removing all invalid role attributes starting with the header, login, and notifications components. Updated the corresponding scripts as well. Made a few structural changes to the header to simply it and then tested it to ensure notification still worked.
7431 lines
356 KiB
JavaScript
7431 lines
356 KiB
JavaScript
function $parcel$interopDefault(a) {
|
||
return a && a.__esModule ? a.default : a;
|
||
}
|
||
var $parcel$global =
|
||
typeof globalThis !== 'undefined'
|
||
? globalThis
|
||
: typeof self !== 'undefined'
|
||
? self
|
||
: typeof window !== 'undefined'
|
||
? window
|
||
: typeof global !== 'undefined'
|
||
? global
|
||
: {};
|
||
//** REQUEST TYPES **//
|
||
const $cbea55afea03b976$export$1470a914435ca933 = "POST";
|
||
const $cbea55afea03b976$export$40a64a78065efa15 = "GET";
|
||
const $cbea55afea03b976$export$d7fd7a62023314c5 = "PUT";
|
||
const $cbea55afea03b976$export$664fc1dd454ea59a = "DELETE";
|
||
const $cbea55afea03b976$export$e133232680a85c80 = "json";
|
||
const $cbea55afea03b976$export$d1a86f208bdcebe5 = "x-www-form-urlencoded";
|
||
const $cbea55afea03b976$export$353cfe44191e6ed0 = "/api/v1/status";
|
||
const $cbea55afea03b976$export$a5dc8f3c1ec8d90e = "/api/v1/settings/site";
|
||
const $cbea55afea03b976$export$12171301ab2e754b = "/api/v1/settings/member";
|
||
const $cbea55afea03b976$export$bcee0afc6bcb3973 = "/api/v1/page/create";
|
||
const $cbea55afea03b976$export$56305c0c25c10608 = "/api/v1/page/write";
|
||
const $cbea55afea03b976$export$af6f91c104f9c4c0 = "/api/v1/page/delete";
|
||
const $cbea55afea03b976$export$1541f55cb44e7d14 = "/api/v1/settings/sync";
|
||
const $cbea55afea03b976$export$42d16aa2cb1126e1 = "/api/v1/settings/publish";
|
||
const $cbea55afea03b976$export$96c65021a69fd85 = "/api/v1/settings/nav-sync";
|
||
const $cbea55afea03b976$export$94ef9ea0ce35d9d2 = "/api/v1/settings/reindex";
|
||
const $cbea55afea03b976$export$8d81f3b3a5b91cea = "/api/v1/mailer";
|
||
const $cbea55afea03b976$export$7193f1fd9d4c1e50 = "/api/v1/login";
|
||
const $cbea55afea03b976$export$5a2be2bfb8c6b601 = "getAuthStatus";
|
||
const $cbea55afea03b976$export$cf68b0779f5f031f = "writeSettings";
|
||
const $cbea55afea03b976$export$6ddd598aa59a7ae3 = "publishSite";
|
||
const $cbea55afea03b976$export$f06e28eb004ce525 = "createNewPage";
|
||
const $cbea55afea03b976$export$a01fefcc831953fa = "editPage";
|
||
const $cbea55afea03b976$export$f9aea0c55bfa15c9 = "deletePage";
|
||
const $cbea55afea03b976$export$835e061c7098d585 = "sendMail";
|
||
const $cbea55afea03b976$export$99e8e9f4661c0fb8 = "reIndexPages";
|
||
const $cbea55afea03b976$export$ff4a0df6152bf850 = "syncSite";
|
||
const $cbea55afea03b976$export$67799ce3e3352ee1 = "syncNav";
|
||
const $cbea55afea03b976$export$303f528a8cb6a0ec = "getSiteSettings";
|
||
const $cbea55afea03b976$export$497a6cff1b996002 = "getMemberInfo";
|
||
const $cbea55afea03b976$export$67f2179ab94be531 = "apiUseAuthorized";
|
||
const $cbea55afea03b976$export$d46ee33f41c7e43d = "apiUseNotAuthorized";
|
||
/**
|
||
* A can of methods used to edit install settings, navigation pages and content pages
|
||
*/ class $cbea55afea03b976$export$2e2bcd8739ae039 {
|
||
/**
|
||
* @constructor
|
||
* @param {string} baseURL - url of site; uses local when empty
|
||
* @param {object} progressBar - element to be used to display upload progress
|
||
*/ constructor(baseURL = null, progressBar = null){
|
||
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 + $cbea55afea03b976$export$353cfe44191e6ed0 : $cbea55afea03b976$export$353cfe44191e6ed0).then((response)=>{
|
||
if (response.type === $cbea55afea03b976$export$67f2179ab94be531) 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",
|
||
}
|
||
```
|
||
*/ login(data) {
|
||
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 + $cbea55afea03b976$export$7193f1fd9d4c1e50 : $cbea55afea03b976$export$7193f1fd9d4c1e50, $cbea55afea03b976$export$5a2be2bfb8c6b601, $cbea55afea03b976$export$1470a914435ca933, $cbea55afea03b976$export$e133232680a85c80, 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",
|
||
}
|
||
```
|
||
*/ sync(task, data) {
|
||
return new Promise((resolve, reject)=>{
|
||
let url = "";
|
||
switch(task){
|
||
case "syncSite":
|
||
url = $cbea55afea03b976$export$1541f55cb44e7d14;
|
||
break;
|
||
case "syncNav":
|
||
url = $cbea55afea03b976$export$96c65021a69fd85;
|
||
break;
|
||
}
|
||
this._request(this.baseURL ? this.baseURL + url : url, $cbea55afea03b976$export$cf68b0779f5f031f, $cbea55afea03b976$export$1470a914435ca933, $cbea55afea03b976$export$e133232680a85c80, data).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",
|
||
}
|
||
* ```
|
||
*/ publish(data) {
|
||
return new Promise((resolve, reject)=>{
|
||
this._request(//API_PUBLISH_PAGES,
|
||
this.baseURL ? this.baseURL + $cbea55afea03b976$export$42d16aa2cb1126e1 : $cbea55afea03b976$export$42d16aa2cb1126e1, $cbea55afea03b976$export$6ddd598aa59a7ae3, $cbea55afea03b976$export$1470a914435ca933, $cbea55afea03b976$export$e133232680a85c80, data).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",
|
||
}
|
||
```
|
||
*/ pageActions(task, data) {
|
||
let url, event, content;
|
||
switch(task){
|
||
case $cbea55afea03b976$export$f06e28eb004ce525:
|
||
url = $cbea55afea03b976$export$bcee0afc6bcb3973;
|
||
event = $cbea55afea03b976$export$f06e28eb004ce525;
|
||
content = $cbea55afea03b976$export$e133232680a85c80;
|
||
break;
|
||
case $cbea55afea03b976$export$a01fefcc831953fa:
|
||
url = $cbea55afea03b976$export$56305c0c25c10608;
|
||
event = $cbea55afea03b976$export$a01fefcc831953fa;
|
||
content = $cbea55afea03b976$export$e133232680a85c80;
|
||
break;
|
||
case $cbea55afea03b976$export$f9aea0c55bfa15c9:
|
||
url = $cbea55afea03b976$export$af6f91c104f9c4c0;
|
||
event = $cbea55afea03b976$export$f9aea0c55bfa15c9;
|
||
content = $cbea55afea03b976$export$e133232680a85c80;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
if (this.baseURL) //data.key = this.key;
|
||
data.remote = true;
|
||
else data.remote = false;
|
||
return new Promise((resolve, reject)=>{
|
||
this._request(this.baseURL ? this.baseURL + url : url, event, $cbea55afea03b976$export$1470a914435ca933, content, data).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"
|
||
}
|
||
```
|
||
*/ sendMail(message) {
|
||
return new Promise((resolve, reject)=>{
|
||
this._request(this.baseURL ? this.baseURL + $cbea55afea03b976$export$8d81f3b3a5b91cea : $cbea55afea03b976$export$8d81f3b3a5b91cea, $cbea55afea03b976$export$835e061c7098d585, $cbea55afea03b976$export$1470a914435ca933, $cbea55afea03b976$export$e133232680a85c80, 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,
|
||
}
|
||
* ```
|
||
*/ getInfo(type) {
|
||
let url, task;
|
||
if (type == "site") {
|
||
url = $cbea55afea03b976$export$a5dc8f3c1ec8d90e;
|
||
task = $cbea55afea03b976$export$303f528a8cb6a0ec;
|
||
} else {
|
||
url = $cbea55afea03b976$export$12171301ab2e754b;
|
||
task = $cbea55afea03b976$export$497a6cff1b996002;
|
||
}
|
||
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 = $cbea55afea03b976$export$40a64a78065efa15, contentType = $cbea55afea03b976$export$e133232680a85c80, 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 == $cbea55afea03b976$export$d7fd7a62023314c5 || requestType == $cbea55afea03b976$export$1470a914435ca933) {
|
||
if (eventType === $cbea55afea03b976$export$cf68b0779f5f031f || eventType === $cbea55afea03b976$export$a01fefcc831953fa || eventType === $cbea55afea03b976$export$f06e28eb004ce525 || eventType === $cbea55afea03b976$export$f9aea0c55bfa15c9 || eventType === $cbea55afea03b976$export$6ddd598aa59a7ae3 || eventType === $cbea55afea03b976$export$99e8e9f4661c0fb8) request.setRequestHeader("fipamo-access-token", self.token);
|
||
switch(contentType){
|
||
case $cbea55afea03b976$export$e133232680a85c80:
|
||
request.setRequestHeader("Content-type", "application/" + contentType);
|
||
request.send(JSON.stringify(requestData));
|
||
break;
|
||
case $cbea55afea03b976$export$d1a86f208bdcebe5:
|
||
request.send(requestData);
|
||
break;
|
||
}
|
||
} else {
|
||
if (eventType === $cbea55afea03b976$export$303f528a8cb6a0ec || eventType === $cbea55afea03b976$export$497a6cff1b996002) request.setRequestHeader("fipamo-access-token", self.token);
|
||
request.send();
|
||
}
|
||
});
|
||
}
|
||
//--------------------------
|
||
// event handlers
|
||
//--------------------------
|
||
handleLoadProgress(e, progressBar) {
|
||
let percent = Math.ceil(e.loaded / e.total * 100);
|
||
//if a progress bar element is present, talk to it
|
||
if (progressBar != null) progressBar.style.width = percent + "%";
|
||
}
|
||
}
|
||
|
||
|
||
//** REQUEST TYPES **//
|
||
const $7e781a188206b2b3$export$1470a914435ca933 = "POST";
|
||
const $7e781a188206b2b3$export$40a64a78065efa15 = "GET";
|
||
const $7e781a188206b2b3$export$d7fd7a62023314c5 = "PUT";
|
||
const $7e781a188206b2b3$export$664fc1dd454ea59a = "DELETE";
|
||
const $7e781a188206b2b3$export$e133232680a85c80 = "json";
|
||
const $7e781a188206b2b3$export$d1a86f208bdcebe5 = "x-www-form-urlencoded";
|
||
const $7e781a188206b2b3$export$353cfe44191e6ed0 = "/api/v1/status";
|
||
const $7e781a188206b2b3$export$6010ab8005eea11c = "/api/v1/init";
|
||
const $7e781a188206b2b3$export$52ab125bf6b9623c = "/api/v1/restore";
|
||
const $7e781a188206b2b3$export$dbda7dc2e1902943 = "/api/v1/get-secret";
|
||
const $7e781a188206b2b3$export$6cb20b6a23a06e47 = "/api/v1/reset-password";
|
||
const $7e781a188206b2b3$export$7d346f7b882235dd = "/api/v1/backup";
|
||
const $7e781a188206b2b3$export$55b2e84262898562 = "/api/v1/backup/download";
|
||
const $7e781a188206b2b3$export$32b079f7fc0b26ca = "/api/v1/backup/restore";
|
||
const $7e781a188206b2b3$export$359fb9097c578f21 = "/api/v1/settings/add-avatar";
|
||
const $7e781a188206b2b3$export$739eebbd7d1f81a2 = "/api/v1/settings/add-feature-background";
|
||
const $7e781a188206b2b3$export$ee6257de8f8b01a2 = "/api/v1/page/add-entry-image";
|
||
const $7e781a188206b2b3$export$4d4b481c07056150 = "/api/v1/files";
|
||
const $7e781a188206b2b3$export$2fb4d35b5b0eebb2 = "blogInit";
|
||
const $7e781a188206b2b3$export$525ebf8030c3a323 = "restoreBackup";
|
||
const $7e781a188206b2b3$export$fc0aff5026df5452 = "createBackup";
|
||
const $7e781a188206b2b3$export$adaa11ae547fcbcc = "retrieveSecret";
|
||
const $7e781a188206b2b3$export$8305e7d16f23e8bc = "resetPassword";
|
||
const $7e781a188206b2b3$export$f90c0f4ad2c7ac2b = "uploadFiles";
|
||
const $7e781a188206b2b3$export$67f2179ab94be531 = "apiUseAuthorized";
|
||
const $7e781a188206b2b3$export$d46ee33f41c7e43d = "apiUseNotAuthorized";
|
||
/**
|
||
* A tub of methods for creating/restoring installs, resetting passwords and uploading images.
|
||
*/ class $7e781a188206b2b3$export$2e2bcd8739ae039 {
|
||
/**
|
||
* @constructor
|
||
* @param {string} baseURL - url of site; uses local when empty
|
||
* @param {string} key - user api key
|
||
*/ constructor(baseURL = null, key = null){
|
||
this.accetableFiles = [
|
||
"image/jpeg",
|
||
"image/gif",
|
||
"image/png",
|
||
"image/svg",
|
||
"audio/mpeg",
|
||
"video/mp4",
|
||
"application/pdf",
|
||
"text/plain",
|
||
"text/rtf"
|
||
];
|
||
this.percentComplete = 0; //for later
|
||
this.token = null;
|
||
this.baseURL = null;
|
||
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 + $7e781a188206b2b3$export$353cfe44191e6ed0 + "?key=" + this.key : $7e781a188206b2b3$export$353cfe44191e6ed0 + "?key=" + this.key).then((response)=>{
|
||
if (response.type === $7e781a188206b2b3$export$67f2179ab94be531) 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
|
||
*/ create(data) {
|
||
return new Promise((resolve, reject)=>{
|
||
this._request($7e781a188206b2b3$export$6010ab8005eea11c, null, $7e781a188206b2b3$export$2fb4d35b5b0eebb2, $7e781a188206b2b3$export$1470a914435ca933, $7e781a188206b2b3$export$e133232680a85c80, data).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
|
||
*/ restore(form) {
|
||
return new Promise((resolve, reject)=>{
|
||
var url, event, method, type, data;
|
||
url = $7e781a188206b2b3$export$52ab125bf6b9623c;
|
||
event = $7e781a188206b2b3$export$525ebf8030c3a323;
|
||
method = $7e781a188206b2b3$export$1470a914435ca933;
|
||
type = $7e781a188206b2b3$export$d1a86f208bdcebe5;
|
||
data = new FormData(form);
|
||
this._request(url, null, 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.
|
||
*/ backup() {
|
||
return new Promise((resolve, reject)=>{
|
||
var url, event, method, type, data;
|
||
url = $7e781a188206b2b3$export$7d346f7b882235dd;
|
||
event = $7e781a188206b2b3$export$fc0aff5026df5452;
|
||
method = $7e781a188206b2b3$export$1470a914435ca933;
|
||
type = $7e781a188206b2b3$export$e133232680a85c80;
|
||
data = {
|
||
task: "create_backup"
|
||
};
|
||
this._request(url, null, 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
|
||
*/ secret(data) {
|
||
return new Promise((resolve, reject)=>{
|
||
this._request($7e781a188206b2b3$export$dbda7dc2e1902943, $7e781a188206b2b3$export$adaa11ae547fcbcc, $7e781a188206b2b3$export$1470a914435ca933, $7e781a188206b2b3$export$e133232680a85c80, 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
|
||
*/ newPass(data) {
|
||
return new Promise((resolve, reject)=>{
|
||
this._request($7e781a188206b2b3$export$6cb20b6a23a06e47, $7e781a188206b2b3$export$8305e7d16f23e8bc, $7e781a188206b2b3$export$1470a914435ca933, $7e781a188206b2b3$export$e133232680a85c80, data).then((result)=>{
|
||
resolve(result);
|
||
}).catch((err)=>{
|
||
reject(err);
|
||
});
|
||
});
|
||
}
|
||
/**
|
||
* Promise method for uploading files [todo: change to uploading files]
|
||
* @param {string} type - type of upload
|
||
* @param {input} files - form input containing files
|
||
*/ filesUpload(type, files, progress = null) {
|
||
return new Promise((resolve, reject)=>{
|
||
let url = $7e781a188206b2b3$export$4d4b481c07056150;
|
||
if (this.baseURL) {
|
||
files.append("key", this.key);
|
||
files.append("remote", true);
|
||
} else files.append("remote", false);
|
||
this._request(url, progress, $7e781a188206b2b3$export$f90c0f4ad2c7ac2b, $7e781a188206b2b3$export$1470a914435ca933, $7e781a188206b2b3$export$d1a86f208bdcebe5, files).then((r)=>{
|
||
resolve(r);
|
||
}).catch((err)=>{
|
||
reject(err);
|
||
});
|
||
});
|
||
}
|
||
//--------------------------
|
||
// private
|
||
//--------------------------
|
||
_request(requestURL, progressBar = null, eventType, requestType = $7e781a188206b2b3$export$40a64a78065efa15, contentType = $7e781a188206b2b3$export$e133232680a85c80, requestData = null) {
|
||
var self = this;
|
||
return new Promise(function(resolve, reject) {
|
||
var request = new XMLHttpRequest();
|
||
request.upload.addEventListener("progress", (e)=>self.handleLoadProgress(e, 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 == $7e781a188206b2b3$export$d7fd7a62023314c5 || requestType == $7e781a188206b2b3$export$1470a914435ca933) {
|
||
if (eventType === $7e781a188206b2b3$export$f90c0f4ad2c7ac2b) request.setRequestHeader("fipamo-access-token", self.token);
|
||
switch(contentType){
|
||
case $7e781a188206b2b3$export$e133232680a85c80:
|
||
request.setRequestHeader("Content-type", "application/" + contentType);
|
||
request.send(JSON.stringify(requestData));
|
||
break;
|
||
case $7e781a188206b2b3$export$d1a86f208bdcebe5:
|
||
request.send(requestData);
|
||
break;
|
||
}
|
||
} else request.send();
|
||
});
|
||
}
|
||
//--------------------------
|
||
// event handlers
|
||
//--------------------------
|
||
handleLoadProgress(e, progressBar) {
|
||
let percent = Math.ceil(e.loaded / e.total * 100);
|
||
//if a progress bar element is present, talk to it
|
||
if (progressBar != null) progressBar.style.width = percent + "%";
|
||
}
|
||
}
|
||
|
||
|
||
class $f177b50aa405d296$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// 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.status + " " + 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(Error1) {
|
||
reject(Error1);
|
||
});
|
||
});
|
||
}
|
||
/**
|
||
* Create a function to convert the serialize and convert the form data to JSON
|
||
* @param : $('#form_example');
|
||
* @return a JSON Stringify
|
||
*/ formDataToJSON(form) {
|
||
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;
|
||
}
|
||
}
|
||
|
||
|
||
const $995f55a4eccd256d$export$5a2be2bfb8c6b601 = "getAuthStatus";
|
||
const $995f55a4eccd256d$export$844339d01bfceea4 = "requestGood";
|
||
const $995f55a4eccd256d$export$f99ec790401d28da = "requestLame";
|
||
const $995f55a4eccd256d$export$5fb39232fef0eeff = "apiUseAuthorized";
|
||
const $995f55a4eccd256d$export$8829e15ac416fcee = "apiUseNotAuthorized";
|
||
const $995f55a4eccd256d$export$4bfe4aeac5ca1c9b = "imgRequestGood";
|
||
const $995f55a4eccd256d$export$b678e0874d52df91 = "imgRequestLame";
|
||
const $995f55a4eccd256d$export$f78d3105e9d98a5d = "settingsLoaded";
|
||
const $995f55a4eccd256d$export$c58a4ce4b93c5925 = "postImageAdded";
|
||
const $995f55a4eccd256d$export$26bdbac97359953d = "featureImageAdded";
|
||
const $995f55a4eccd256d$export$a9707c9559ca4612 = "postError";
|
||
const $995f55a4eccd256d$export$a2d54b707b6e22e1 = "postAdded";
|
||
const $995f55a4eccd256d$export$f88aea22a746eab = "postUpdated";
|
||
const $995f55a4eccd256d$export$92d3c9e452b188cc = "postImageAdded";
|
||
const $995f55a4eccd256d$export$9ab81161d8ad3297 = "pagesRendered";
|
||
const $995f55a4eccd256d$export$a447f8a3982d1ca8 = "pagesNotRendered";
|
||
const $995f55a4eccd256d$export$b47ada4663816e48 = "tagPagesRendered";
|
||
const $995f55a4eccd256d$export$14f1954724290577 = "tagPagesNotRendered";
|
||
const $995f55a4eccd256d$export$5dd76fd38bbe7841 = "settingsUpdated";
|
||
const $995f55a4eccd256d$export$5082b4f0403769e9 = "settingsNotUpdated";
|
||
const $995f55a4eccd256d$export$bd3b33ec4de8bf3 = "menuAddItem";
|
||
const $995f55a4eccd256d$export$dbd640577c4e5d0d = "menuDeleteItem";
|
||
const $995f55a4eccd256d$export$d4fd546d3456ff85 = "menuUpdated";
|
||
const $995f55a4eccd256d$export$9b65f586914397ef = "avatarUploaded";
|
||
const $995f55a4eccd256d$export$c3b6b85989e4a0a8 = "siteBackgroundUploaded";
|
||
const $995f55a4eccd256d$export$c51d011f6ede1aa5 = "uploadProgress";
|
||
const $995f55a4eccd256d$export$e0e6bcdbaa787779 = "writingItDown";
|
||
const $995f55a4eccd256d$export$ac8c24f9b72727c3 = "writingNewEntry";
|
||
const $995f55a4eccd256d$export$8ae3e28253adc030 = "erasingPage";
|
||
const $995f55a4eccd256d$export$16cc4df8146e89ab = "savingSettings";
|
||
const $995f55a4eccd256d$export$524c7f283d44a2c3 = "createBackup";
|
||
const $995f55a4eccd256d$export$ef2d8441bb01121d = "downloadBackup";
|
||
const $995f55a4eccd256d$export$8020812a0ef5b01d = "downloadBackup";
|
||
const $995f55a4eccd256d$export$bd723636cbbfa9dd = "uploadProfileImages";
|
||
const $995f55a4eccd256d$export$a5f1510cea1ffff9 = "renderPages";
|
||
const $995f55a4eccd256d$export$94ef9ea0ce35d9d2 = "reindexPages";
|
||
const $995f55a4eccd256d$export$6010ab8005eea11c = "blogInit";
|
||
const $995f55a4eccd256d$export$57f3dcd64790c65 = "blogInitGood";
|
||
const $995f55a4eccd256d$export$74a5c30fa9753d80 = "blogInitLame";
|
||
const $995f55a4eccd256d$export$dbda7dc2e1902943 = "retrieveSecret";
|
||
const $995f55a4eccd256d$export$6cb20b6a23a06e47 = "resetPassword";
|
||
const $995f55a4eccd256d$export$eeb056b4f9e6ce71 = "sendMail";
|
||
class $995f55a4eccd256d$var$DataEvent {
|
||
}
|
||
var $995f55a4eccd256d$export$2e2bcd8739ae039 = new $995f55a4eccd256d$var$DataEvent();
|
||
|
||
|
||
//TOOLS
|
||
|
||
|
||
|
||
class $224e88b348829f3a$var$StringUtils {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(){}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
cleanString(string) {
|
||
var clean = string.replace(/(^\-+|[^a-zA-Z0-9\/_| -]+|\-+$)/g, "").toLowerCase().replace(/[\/_| -]+/g, "-");
|
||
return clean;
|
||
}
|
||
decodeHTML(string, quote_style) {
|
||
var optTemp = 0, i = 0, noquotes = false;
|
||
if (typeof quote_style === "undefined") quote_style = 2;
|
||
string = string.toString().replace(/</g, "<").replace(/>/g, ">");
|
||
var OPTS = {
|
||
ENT_NOQUOTES: 0,
|
||
ENT_HTML_QUOTE_SINGLE: 1,
|
||
ENT_HTML_QUOTE_DOUBLE: 2,
|
||
ENT_COMPAT: 2,
|
||
ENT_QUOTES: 3,
|
||
ENT_IGNORE: 4
|
||
};
|
||
if (quote_style === 0) noquotes = true;
|
||
if (typeof quote_style !== "number") {
|
||
// Allow for a single string or an array of string flags
|
||
quote_style = [].concat(quote_style);
|
||
for(i = 0; i < quote_style.length; i++){
|
||
// Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
|
||
if (OPTS[quote_style[i]] === 0) noquotes = true;
|
||
else if (OPTS[quote_style[i]]) optTemp = optTemp | OPTS[quote_style[i]];
|
||
}
|
||
quote_style = optTemp;
|
||
}
|
||
if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) string = string.replace(/�*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
|
||
if (!noquotes) string = string.replace(/"/g, '"');
|
||
// Put this in last place to avoid escape being double-decoded
|
||
string = string.replace(/&/g, "&");
|
||
return string;
|
||
}
|
||
}
|
||
var $224e88b348829f3a$export$2e2bcd8739ae039 = $224e88b348829f3a$var$StringUtils;
|
||
|
||
|
||
class $de01a7e5b1773530$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(){}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
collectInfo(files) {
|
||
return new Promise((resolve, reject)=>{
|
||
let pageInfo = [];
|
||
let pageRef = document.querySelector('[role="file-manager"]');
|
||
//process html content for storage
|
||
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
|
||
//build data object
|
||
pageInfo = {
|
||
id: pageRef.getAttribute("data-index"),
|
||
uuid: pageRef.getAttribute("data-uuid"),
|
||
layout: document.getElementById("page-templates").value,
|
||
current_title: pageRef.getAttribute("data-slug"),
|
||
content: html,
|
||
title: document.getElementById("post-title-text").value,
|
||
created: document.getElementById("post-date").getAttribute("data-raw"),
|
||
slug: new (0, $224e88b348829f3a$export$2e2bcd8739ae039)().cleanString(document.getElementById("post-title-text").value),
|
||
tags: document.getElementById("post-tags").value,
|
||
menu: document.getElementById("option-menu-pin").getAttribute("data-active"),
|
||
featured: document.getElementById("option-feature").getAttribute("data-active"),
|
||
published: document.getElementById("option-published").getAttribute("data-active"),
|
||
form_token: document.getElementById("form_token").value,
|
||
imageList: files.images,
|
||
fileList: files.files
|
||
};
|
||
resolve(pageInfo);
|
||
});
|
||
}
|
||
}
|
||
|
||
|
||
const $0d6abf40542266b3$export$e0c06b1ddd9992cc = "editorDelete";
|
||
const $0d6abf40542266b3$export$80082ca64f03d0e9 = "editorUploadImage";
|
||
const $0d6abf40542266b3$export$1844db352cf5aef3 = "editorSave";
|
||
const $0d6abf40542266b3$export$14580fc61246740 = "editorUpdate";
|
||
class $0d6abf40542266b3$var$EditorEvent {
|
||
}
|
||
var $0d6abf40542266b3$export$2e2bcd8739ae039 = new $0d6abf40542266b3$var$EditorEvent();
|
||
|
||
|
||
|
||
class $68b475f2a0292491$var$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(label, callback) {
|
||
var isFunction = function(obj) {
|
||
return typeof obj == "function" || false;
|
||
};
|
||
var listeners = this.listeners.get(label), index;
|
||
if (listeners && listeners.length) {
|
||
index = listeners.reduce((i, listener, index)=>{
|
||
return isFunction(listener) && listener === callback ? i = index : i;
|
||
}, -1);
|
||
if (index > -1) {
|
||
listeners.splice(index, 1);
|
||
this.listeners.set(label, listeners);
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
emitEvent(label, ...args) {
|
||
var listeners = this.listeners.get(label);
|
||
if (listeners && listeners.length) {
|
||
listeners.forEach((listener)=>{
|
||
listener(...args);
|
||
});
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
var $68b475f2a0292491$export$2e2bcd8739ae039 = $68b475f2a0292491$var$EventEmitter;
|
||
|
||
|
||
|
||
var $4b862aa2466a294d$exports = {};
|
||
/// <reference lib="WebWorker"/>
|
||
var $4b862aa2466a294d$var$_self = 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
|
||
*/ var $4b862aa2466a294d$var$Prism = function(_self) {
|
||
// Private helper vars
|
||
var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/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
|
||
*/ manual: _self.Prism && _self.Prism.manual,
|
||
/**
|
||
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
|
||
* `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
|
||
* own worker, you don't want it to do this.
|
||
*
|
||
* By setting this value to `true`, Prism will not add its own listeners to the worker.
|
||
*
|
||
* You obviously have to change this value before Prism executes. 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.disableWorkerMessageHandler = true;
|
||
* // Load Prism's script
|
||
* ```
|
||
*
|
||
* @default false
|
||
* @type {boolean}
|
||
* @memberof Prism
|
||
* @public
|
||
*/ 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
|
||
*/ util: {
|
||
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'
|
||
*/ type: function(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}
|
||
*/ objId: function(obj) {
|
||
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
|
||
*/ clone: function deepClone(o, visited) {
|
||
visited = visited || {};
|
||
var clone;
|
||
var id;
|
||
switch(_.util.type(o)){
|
||
case "Object":
|
||
id = _.util.objId(o);
|
||
if (visited[id]) return visited[id];
|
||
clone = /** @type {Record<string, any>} */ {};
|
||
visited[id] = clone;
|
||
for(var key in o)if (o.hasOwnProperty(key)) clone[key] = deepClone(o[key], visited);
|
||
return /** @type {any} */ clone;
|
||
case "Array":
|
||
id = _.util.objId(o);
|
||
if (visited[id]) return visited[id];
|
||
clone = [];
|
||
visited[id] = clone;
|
||
/** @type {Array} */ /** @type {any} */ o.forEach(function(v, i) {
|
||
clone[i] = deepClone(v, visited);
|
||
});
|
||
return /** @type {any} */ 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}
|
||
*/ getLanguage: function(element) {
|
||
while(element){
|
||
var m = lang.exec(element.className);
|
||
if (m) return m[1].toLowerCase();
|
||
element = element.parentElement;
|
||
}
|
||
return "none";
|
||
},
|
||
/**
|
||
* Sets the Prism `language-xxxx` class of the given element.
|
||
*
|
||
* @param {Element} element
|
||
* @param {string} language
|
||
* @returns {void}
|
||
*/ setLanguage: function(element, language) {
|
||
// remove all `language-xxxx` classes
|
||
// (this might leave behind a leading space)
|
||
element.className = element.className.replace(RegExp(lang, "gi"), "");
|
||
// add the new `language-xxxx` class
|
||
// (using `classList` will automatically clean up spaces for us)
|
||
element.classList.add("language-" + language);
|
||
},
|
||
/**
|
||
* Returns the script element that is currently executing.
|
||
*
|
||
* This does __not__ work for line script element.
|
||
*
|
||
* @returns {HTMLScriptElement | null}
|
||
*/ currentScript: function() {
|
||
if (typeof document === "undefined") return null;
|
||
if ("currentScript" in document && true /* hack to trip TS' flow analysis */ ) return /** @type {any} */ 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}
|
||
*/ isActive: function(element, className, defaultActivation) {
|
||
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
|
||
*/ languages: {
|
||
/**
|
||
* The grammar for plain, unformatted text.
|
||
*/ plain: plainTextGrammar,
|
||
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/
|
||
* });
|
||
*/ extend: function(id, redef) {
|
||
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
|
||
*/ insertBefore: function(inside, before, insert, root) {
|
||
root = root || /** @type {any} */ _.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
|
||
*/ highlightAll: function(async, callback) {
|
||
_.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
|
||
*/ highlightAllUnder: function(container, async, callback) {
|
||
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
|
||
*/ highlightElement: function(element, async, callback) {
|
||
// Find language
|
||
var language = _.util.getLanguage(element);
|
||
var grammar = _.languages[language];
|
||
// Set language on the element, if not present
|
||
_.util.setLanguage(element, language);
|
||
// Set language on the parent, for styling
|
||
var parent = element.parentElement;
|
||
if (parent && parent.nodeName.toLowerCase() === "pre") _.util.setLanguage(parent, 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');
|
||
*/ highlight: function(text, grammar, language) {
|
||
var env = {
|
||
code: text,
|
||
grammar: grammar,
|
||
language: language
|
||
};
|
||
_.hooks.run("before-tokenize", env);
|
||
if (!env.grammar) throw new Error('The language "' + env.language + '" has no grammar.');
|
||
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}`);
|
||
* }
|
||
* });
|
||
*/ tokenize: function(text, grammar) {
|
||
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
|
||
*/ hooks: {
|
||
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
|
||
*/ add: function(name, callback) {
|
||
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
|
||
*/ run: function(name, env) {
|
||
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
|
||
*/ function Token(type, content, alias, matchedStr) {
|
||
/**
|
||
* The type of the token.
|
||
*
|
||
* This is usually the key of a pattern in a {@link Grammar}.
|
||
*
|
||
* @type {string}
|
||
* @see GrammarToken
|
||
* @public
|
||
*/ this.type = type;
|
||
/**
|
||
* 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
|
||
*/ this.content = content;
|
||
/**
|
||
* The alias(es) of the token.
|
||
*
|
||
* @type {string|string[]}
|
||
* @see GrammarToken
|
||
* @public
|
||
*/ this.alias = alias;
|
||
// 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
|
||
*/ Token.stringify = function stringify(o, language) {
|
||
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}
|
||
*/ function matchPattern(pattern, pos, text, lookbehind) {
|
||
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
|
||
*/ function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
|
||
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 || match.index >= text.length) 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
|
||
*/ function LinkedList() {
|
||
/** @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
|
||
*/ function addAfter(list, node, value) {
|
||
// 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
|
||
*/ function removeRange(list, node, count) {
|
||
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
|
||
*/ function toArray(list) {
|
||
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 _;
|
||
}($4b862aa2466a294d$var$_self);
|
||
if (0, $4b862aa2466a294d$exports) $4b862aa2466a294d$exports = $4b862aa2466a294d$var$Prism;
|
||
// hack for components to work correctly in node.js
|
||
if (typeof $parcel$global !== "undefined") $parcel$global.Prism = $4b862aa2466a294d$var$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
|
||
*/
|
||
|
||
|
||
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"
|
||
},
|
||
{
|
||
pattern: /^(\s*)["']|["']$/,
|
||
lookbehind: true
|
||
}
|
||
]
|
||
}
|
||
},
|
||
"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');
|
||
*/ value: function addInlined(tagName, lang) {
|
||
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');
|
||
*/ value: function(attrName, lang) {
|
||
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;
|
||
|
||
|
||
(function(Prism1) {
|
||
// 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}
|
||
*/ function createInline(pattern) {
|
||
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;
|
||
Prism1.languages.markdown = Prism1.languages.extend("markup", {});
|
||
Prism1.languages.insertBefore("markdown", "prolog", {
|
||
"front-matter-block": {
|
||
pattern: /(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,
|
||
lookbehind: true,
|
||
greedy: true,
|
||
inside: {
|
||
"punctuation": /^---|---$/,
|
||
"front-matter": {
|
||
pattern: /\S+(?:\s+\S+)*/,
|
||
alias: [
|
||
"yaml",
|
||
"language-yaml"
|
||
],
|
||
inside: Prism1.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: Prism1.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: Prism1.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) Prism1.languages.markdown[token].inside.content.inside[inside] = Prism1.languages.markdown[inside];
|
||
});
|
||
});
|
||
Prism1.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</span>,
|
||
* '\n', // exactly one new lines (\r or \n or \r\n)
|
||
* <span class="code-block">...</span>,
|
||
* '\n', // exactly one new lines again
|
||
* <span class="punctuation">```</span>
|
||
* ];
|
||
*/ var codeLang = token.content[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);
|
||
});
|
||
Prism1.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 = Prism1.languages[codeLang];
|
||
if (!grammar) {
|
||
if (codeLang && codeLang !== "none" && Prism1.plugins.autoloader) {
|
||
var id = "md-" + new Date().valueOf() + "-" + Math.floor(Math.random() * 1e16);
|
||
env.attributes["id"] = id;
|
||
Prism1.plugins.autoloader.loadLanguages(codeLang, function() {
|
||
var ele = document.getElementById(id);
|
||
if (ele) ele.innerHTML = Prism1.highlight(ele.textContent, Prism1.languages[codeLang], codeLang);
|
||
});
|
||
}
|
||
} else env.content = Prism1.highlight(textContent(env.content), grammar, codeLang);
|
||
});
|
||
var tagPattern = RegExp(Prism1.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}
|
||
*/ var KNOWN_ENTITY_NAMES = {
|
||
"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}
|
||
*/ function textContent(html) {
|
||
// 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;
|
||
}
|
||
Prism1.languages.md = Prism1.languages.markdown;
|
||
})(Prism);
|
||
|
||
|
||
class $e6c02983873e6cdf$var$TextEditor extends (0, $68b475f2a0292491$export$2e2bcd8739ae039) {
|
||
/**
|
||
* 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.querySelector('[role="text-editor-control"]').addEventListener("scroll", (e)=>{
|
||
console.log("HERE");
|
||
});
|
||
document.body.addEventListener("scroll", (e)=>{
|
||
var fixLimit = scrollLimit;
|
||
console.log("POSITION", document.body.scrollTop + " : " + fixLimit);
|
||
if (document.body.scrollTop + 5 >= fixLimit) document.querySelector('[role="text-editor-control"]').classList.add("control-freeze");
|
||
else document.querySelector('[role="text-editor-control"]').classList.remove("control-freeze");
|
||
});
|
||
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.querySelector('[role="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
|
||
(0, (/*@__PURE__*/$parcel$interopDefault($4b862aa2466a294d$exports))).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
|
||
}
|
||
//--------------------------
|
||
// 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 $995f55a4eccd256d$export$f88aea22a746eab:
|
||
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 $995f55a4eccd256d$export$a2d54b707b6e22e1:
|
||
break;
|
||
case $0d6abf40542266b3$export$80082ca64f03d0e9:
|
||
{
|
||
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 = position(this.textEditor).pos;
|
||
this.emitEvent($0d6abf40542266b3$export$80082ca64f03d0e9);
|
||
break;
|
||
case "submit-save":
|
||
case "edit-save":
|
||
this.emitEvent($0d6abf40542266b3$export$1844db352cf5aef3);
|
||
break;
|
||
case "submit-update":
|
||
case "edit-update":
|
||
this.emitEvent($0d6abf40542266b3$export$14580fc61246740);
|
||
break;
|
||
case "edit-delete":
|
||
this.emitEvent($0d6abf40542266b3$export$e0c06b1ddd9992cc);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
document.getElementById("edit").dispatchEvent(new Event("input"));
|
||
}
|
||
}
|
||
var $e6c02983873e6cdf$export$2e2bcd8739ae039 = $e6c02983873e6cdf$var$TextEditor;
|
||
|
||
|
||
/*
|
||
* anime.js v3.2.1
|
||
* (c) 2020 Julian Garnier
|
||
* Released under the MIT license
|
||
* animejs.com
|
||
*/ // Defaults
|
||
var $8b9e2899b2e82f52$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 $8b9e2899b2e82f52$var$defaultTweenSettings = {
|
||
duration: 1000,
|
||
delay: 0,
|
||
endDelay: 0,
|
||
easing: "easeOutElastic(1, .5)",
|
||
round: 0
|
||
};
|
||
var $8b9e2899b2e82f52$var$validTransforms = [
|
||
"translateX",
|
||
"translateY",
|
||
"translateZ",
|
||
"rotate",
|
||
"rotateX",
|
||
"rotateY",
|
||
"rotateZ",
|
||
"scale",
|
||
"scaleX",
|
||
"scaleY",
|
||
"scaleZ",
|
||
"skew",
|
||
"skewX",
|
||
"skewY",
|
||
"perspective",
|
||
"matrix",
|
||
"matrix3d"
|
||
];
|
||
// Caching
|
||
var $8b9e2899b2e82f52$var$cache = {
|
||
CSS: {},
|
||
springs: {}
|
||
};
|
||
// Utils
|
||
function $8b9e2899b2e82f52$var$minMax(val, min, max) {
|
||
return Math.min(Math.max(val, min), max);
|
||
}
|
||
function $8b9e2899b2e82f52$var$stringContains(str, text) {
|
||
return str.indexOf(text) > -1;
|
||
}
|
||
function $8b9e2899b2e82f52$var$applyArguments(func, args) {
|
||
return func.apply(null, args);
|
||
}
|
||
var $8b9e2899b2e82f52$var$is = {
|
||
arr: function(a) {
|
||
return Array.isArray(a);
|
||
},
|
||
obj: function(a) {
|
||
return $8b9e2899b2e82f52$var$stringContains(Object.prototype.toString.call(a), "Object");
|
||
},
|
||
pth: function(a) {
|
||
return $8b9e2899b2e82f52$var$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 || $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$is.hex(a) || $8b9e2899b2e82f52$var$is.rgb(a) || $8b9e2899b2e82f52$var$is.hsl(a);
|
||
},
|
||
key: function(a) {
|
||
return !$8b9e2899b2e82f52$var$defaultInstanceSettings.hasOwnProperty(a) && !$8b9e2899b2e82f52$var$defaultTweenSettings.hasOwnProperty(a) && a !== "targets" && a !== "keyframes";
|
||
}
|
||
};
|
||
// Easings
|
||
function $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$spring(string, duration) {
|
||
var params = $8b9e2899b2e82f52$var$parseEasingParameters(string);
|
||
var mass = $8b9e2899b2e82f52$var$minMax($8b9e2899b2e82f52$var$is.und(params[0]) ? 1 : params[0], .1, 100);
|
||
var stiffness = $8b9e2899b2e82f52$var$minMax($8b9e2899b2e82f52$var$is.und(params[1]) ? 100 : params[1], .1, 100);
|
||
var damping = $8b9e2899b2e82f52$var$minMax($8b9e2899b2e82f52$var$is.und(params[2]) ? 10 : params[2], .1, 100);
|
||
var velocity = $8b9e2899b2e82f52$var$minMax($8b9e2899b2e82f52$var$is.und(params[3]) ? 0 : params[3], .1, 100);
|
||
var w0 = Math.sqrt(stiffness / mass);
|
||
var zeta = damping / (2 * Math.sqrt(stiffness * mass));
|
||
var wd = zeta < 1 ? w0 * Math.sqrt(1 - zeta * zeta) : 0;
|
||
var a = 1;
|
||
var b = zeta < 1 ? (zeta * w0 + -velocity) / wd : -velocity + w0;
|
||
function solver(t) {
|
||
var progress = duration ? duration * t / 1000 : t;
|
||
if (zeta < 1) progress = Math.exp(-progress * zeta * w0) * (a * Math.cos(wd * progress) + b * Math.sin(wd * progress));
|
||
else progress = (a + b * progress) * Math.exp(-progress * w0);
|
||
if (t === 0 || t === 1) return t;
|
||
return 1 - progress;
|
||
}
|
||
function getDuration() {
|
||
var cached = $8b9e2899b2e82f52$var$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;
|
||
$8b9e2899b2e82f52$var$cache.springs[string] = duration;
|
||
return duration;
|
||
}
|
||
return duration ? solver : getDuration;
|
||
}
|
||
// Basic steps easing implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
|
||
function $8b9e2899b2e82f52$var$steps(steps) {
|
||
if (steps === void 0) steps = 10;
|
||
return function(t) {
|
||
return Math.ceil($8b9e2899b2e82f52$var$minMax(t, 0.000001, 1) * steps) * (1 / steps);
|
||
};
|
||
}
|
||
// BezierEasing https://github.com/gre/bezier-easing
|
||
var $8b9e2899b2e82f52$var$bezier = function() {
|
||
var kSplineTableSize = 11;
|
||
var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
|
||
function A(aA1, aA2) {
|
||
return 1.0 - 3.0 * aA2 + 3.0 * aA1;
|
||
}
|
||
function B(aA1, aA2) {
|
||
return 3.0 * aA2 - 6.0 * aA1;
|
||
}
|
||
function C(aA1) {
|
||
return 3.0 * aA1;
|
||
}
|
||
function calcBezier(aT, aA1, aA2) {
|
||
return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;
|
||
}
|
||
function getSlope(aT, aA1, aA2) {
|
||
return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1);
|
||
}
|
||
function binarySubdivide(aX, aA, aB, mX1, mX2) {
|
||
var currentX, currentT, i = 0;
|
||
do {
|
||
currentT = aA + (aB - aA) / 2.0;
|
||
currentX = calcBezier(currentT, mX1, mX2) - aX;
|
||
if (currentX > 0.0) aB = currentT;
|
||
else aA = currentT;
|
||
}while (Math.abs(currentX) > 0.0000001 && ++i < 10);
|
||
return currentT;
|
||
}
|
||
function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
|
||
for(var i = 0; i < 4; ++i){
|
||
var currentSlope = getSlope(aGuessT, mX1, mX2);
|
||
if (currentSlope === 0.0) return aGuessT;
|
||
var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
|
||
aGuessT -= currentX / currentSlope;
|
||
}
|
||
return aGuessT;
|
||
}
|
||
function bezier(mX1, mY1, mX2, mY2) {
|
||
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) return;
|
||
var sampleValues = new Float32Array(kSplineTableSize);
|
||
if (mX1 !== mY1 || mX2 !== mY2) for(var i = 0; i < kSplineTableSize; ++i)sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
|
||
function getTForX(aX) {
|
||
var intervalStart = 0;
|
||
var currentSample = 1;
|
||
var lastSample = kSplineTableSize - 1;
|
||
for(; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample)intervalStart += kSampleStepSize;
|
||
--currentSample;
|
||
var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
|
||
var guessForT = intervalStart + dist * kSampleStepSize;
|
||
var initialSlope = getSlope(guessForT, mX1, mX2);
|
||
if (initialSlope >= 0.001) return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
|
||
else if (initialSlope === 0.0) return guessForT;
|
||
else return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
|
||
}
|
||
return function(x) {
|
||
if (mX1 === mY1 && mX2 === mY2) return x;
|
||
if (x === 0 || x === 1) return x;
|
||
return calcBezier(getTForX(x), mY1, mY2);
|
||
};
|
||
}
|
||
return bezier;
|
||
}();
|
||
var $8b9e2899b2e82f52$var$penner = function() {
|
||
// Based on jQuery UI's implemenation of easing equations from Robert Penner (http://www.robertpenner.com/easing)
|
||
var eases = {
|
||
linear: function() {
|
||
return function(t) {
|
||
return t;
|
||
};
|
||
}
|
||
};
|
||
var functionEasings = {
|
||
Sine: function() {
|
||
return function(t) {
|
||
return 1 - Math.cos(t * Math.PI / 2);
|
||
};
|
||
},
|
||
Circ: function() {
|
||
return function(t) {
|
||
return 1 - Math.sqrt(1 - t * t);
|
||
};
|
||
},
|
||
Back: function() {
|
||
return function(t) {
|
||
return t * t * (3 * t - 2);
|
||
};
|
||
},
|
||
Bounce: function() {
|
||
return function(t) {
|
||
var pow2, b = 4;
|
||
while(t < ((pow2 = Math.pow(2, --b)) - 1) / 11);
|
||
return 1 / Math.pow(4, 3 - b) - 7.5625 * Math.pow((pow2 * 3 - 2) / 22 - t, 2);
|
||
};
|
||
},
|
||
Elastic: function(amplitude, period) {
|
||
if (amplitude === void 0) amplitude = 1;
|
||
if (period === void 0) period = .5;
|
||
var a = $8b9e2899b2e82f52$var$minMax(amplitude, 1, 10);
|
||
var p = $8b9e2899b2e82f52$var$minMax(period, .1, 2);
|
||
return function(t) {
|
||
return t === 0 || t === 1 ? t : -a * Math.pow(2, 10 * (t - 1)) * Math.sin((t - 1 - p / (Math.PI * 2) * Math.asin(1 / a)) * (Math.PI * 2) / p);
|
||
};
|
||
}
|
||
};
|
||
var baseEasings = [
|
||
"Quad",
|
||
"Cubic",
|
||
"Quart",
|
||
"Quint",
|
||
"Expo"
|
||
];
|
||
baseEasings.forEach(function(name, i) {
|
||
functionEasings[name] = function() {
|
||
return function(t) {
|
||
return Math.pow(t, i + 2);
|
||
};
|
||
};
|
||
});
|
||
Object.keys(functionEasings).forEach(function(name) {
|
||
var easeIn = functionEasings[name];
|
||
eases["easeIn" + name] = easeIn;
|
||
eases["easeOut" + name] = function(a, b) {
|
||
return function(t) {
|
||
return 1 - easeIn(a, b)(1 - t);
|
||
};
|
||
};
|
||
eases["easeInOut" + name] = function(a, b) {
|
||
return function(t) {
|
||
return t < 0.5 ? easeIn(a, b)(t * 2) / 2 : 1 - easeIn(a, b)(t * -2 + 2) / 2;
|
||
};
|
||
};
|
||
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 $8b9e2899b2e82f52$var$parseEasings(easing, duration) {
|
||
if ($8b9e2899b2e82f52$var$is.fnc(easing)) return easing;
|
||
var name = easing.split("(")[0];
|
||
var ease = $8b9e2899b2e82f52$var$penner[name];
|
||
var args = $8b9e2899b2e82f52$var$parseEasingParameters(easing);
|
||
switch(name){
|
||
case "spring":
|
||
return $8b9e2899b2e82f52$var$spring(easing, duration);
|
||
case "cubicBezier":
|
||
return $8b9e2899b2e82f52$var$applyArguments($8b9e2899b2e82f52$var$bezier, args);
|
||
case "steps":
|
||
return $8b9e2899b2e82f52$var$applyArguments($8b9e2899b2e82f52$var$steps, args);
|
||
default:
|
||
return $8b9e2899b2e82f52$var$applyArguments(ease, args);
|
||
}
|
||
}
|
||
// Strings
|
||
function $8b9e2899b2e82f52$var$selectString(str) {
|
||
try {
|
||
var nodes = document.querySelectorAll(str);
|
||
return nodes;
|
||
} catch (e) {
|
||
return;
|
||
}
|
||
}
|
||
// Arrays
|
||
function $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$flattenArray(arr) {
|
||
return arr.reduce(function(a, b) {
|
||
return a.concat($8b9e2899b2e82f52$var$is.arr(b) ? $8b9e2899b2e82f52$var$flattenArray(b) : b);
|
||
}, []);
|
||
}
|
||
function $8b9e2899b2e82f52$var$toArray(o) {
|
||
if ($8b9e2899b2e82f52$var$is.arr(o)) return o;
|
||
if ($8b9e2899b2e82f52$var$is.str(o)) o = $8b9e2899b2e82f52$var$selectString(o) || o;
|
||
if (o instanceof NodeList || o instanceof HTMLCollection) return [].slice.call(o);
|
||
return [
|
||
o
|
||
];
|
||
}
|
||
function $8b9e2899b2e82f52$var$arrayContains(arr, val) {
|
||
return arr.some(function(a) {
|
||
return a === val;
|
||
});
|
||
}
|
||
// Objects
|
||
function $8b9e2899b2e82f52$var$cloneObject(o) {
|
||
var clone = {};
|
||
for(var p in o)clone[p] = o[p];
|
||
return clone;
|
||
}
|
||
function $8b9e2899b2e82f52$var$replaceObjectProps(o1, o2) {
|
||
var o = $8b9e2899b2e82f52$var$cloneObject(o1);
|
||
for(var p in o1)o[p] = o2.hasOwnProperty(p) ? o2[p] : o1[p];
|
||
return o;
|
||
}
|
||
function $8b9e2899b2e82f52$var$mergeObjects(o1, o2) {
|
||
var o = $8b9e2899b2e82f52$var$cloneObject(o1);
|
||
for(var p in o2)o[p] = $8b9e2899b2e82f52$var$is.und(o1[p]) ? o2[p] : o1[p];
|
||
return o;
|
||
}
|
||
// Colors
|
||
function $8b9e2899b2e82f52$var$rgbToRgba(rgbValue) {
|
||
var rgb = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(rgbValue);
|
||
return rgb ? "rgba(" + rgb[1] + ",1)" : rgbValue;
|
||
}
|
||
function $8b9e2899b2e82f52$var$hexToRgba(hexValue) {
|
||
var rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
||
var hex = hexValue.replace(rgx, function(m, r, g, b) {
|
||
return r + r + g + g + b + b;
|
||
});
|
||
var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||
var r = parseInt(rgb[1], 16);
|
||
var g = parseInt(rgb[2], 16);
|
||
var b = parseInt(rgb[3], 16);
|
||
return "rgba(" + r + "," + g + "," + b + ",1)";
|
||
}
|
||
function $8b9e2899b2e82f52$var$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 q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
||
var p = 2 * l - q;
|
||
r = hue2rgb(p, q, h + 1 / 3);
|
||
g = hue2rgb(p, q, h);
|
||
b = hue2rgb(p, q, h - 1 / 3);
|
||
}
|
||
return "rgba(" + r * 255 + "," + g * 255 + "," + b * 255 + "," + a + ")";
|
||
}
|
||
function $8b9e2899b2e82f52$var$colorToRgb(val) {
|
||
if ($8b9e2899b2e82f52$var$is.rgb(val)) return $8b9e2899b2e82f52$var$rgbToRgba(val);
|
||
if ($8b9e2899b2e82f52$var$is.hex(val)) return $8b9e2899b2e82f52$var$hexToRgba(val);
|
||
if ($8b9e2899b2e82f52$var$is.hsl(val)) return $8b9e2899b2e82f52$var$hslToRgba(val);
|
||
}
|
||
// Units
|
||
function $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$getTransformUnit(propName) {
|
||
if ($8b9e2899b2e82f52$var$stringContains(propName, "translate") || propName === "perspective") return "px";
|
||
if ($8b9e2899b2e82f52$var$stringContains(propName, "rotate") || $8b9e2899b2e82f52$var$stringContains(propName, "skew")) return "deg";
|
||
}
|
||
// Values
|
||
function $8b9e2899b2e82f52$var$getFunctionValue(val, animatable) {
|
||
if (!$8b9e2899b2e82f52$var$is.fnc(val)) return val;
|
||
return val(animatable.target, animatable.id, animatable.total);
|
||
}
|
||
function $8b9e2899b2e82f52$var$getAttribute(el, prop) {
|
||
return el.getAttribute(prop);
|
||
}
|
||
function $8b9e2899b2e82f52$var$convertPxToUnit(el, value, unit) {
|
||
var valueUnit = $8b9e2899b2e82f52$var$getUnit(value);
|
||
if ($8b9e2899b2e82f52$var$arrayContains([
|
||
unit,
|
||
"deg",
|
||
"rad",
|
||
"turn"
|
||
], valueUnit)) return value;
|
||
var cached = $8b9e2899b2e82f52$var$cache.CSS[value + unit];
|
||
if (!$8b9e2899b2e82f52$var$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);
|
||
$8b9e2899b2e82f52$var$cache.CSS[value + unit] = convertedUnit;
|
||
return convertedUnit;
|
||
}
|
||
function $8b9e2899b2e82f52$var$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 ? $8b9e2899b2e82f52$var$convertPxToUnit(el, value, unit) : value;
|
||
}
|
||
}
|
||
function $8b9e2899b2e82f52$var$getAnimationType(el, prop) {
|
||
if ($8b9e2899b2e82f52$var$is.dom(el) && !$8b9e2899b2e82f52$var$is.inp(el) && (!$8b9e2899b2e82f52$var$is.nil($8b9e2899b2e82f52$var$getAttribute(el, prop)) || $8b9e2899b2e82f52$var$is.svg(el) && el[prop])) return "attribute";
|
||
if ($8b9e2899b2e82f52$var$is.dom(el) && $8b9e2899b2e82f52$var$arrayContains($8b9e2899b2e82f52$var$validTransforms, prop)) return "transform";
|
||
if ($8b9e2899b2e82f52$var$is.dom(el) && prop !== "transform" && $8b9e2899b2e82f52$var$getCSSValue(el, prop)) return "css";
|
||
if (el[prop] != null) return "object";
|
||
}
|
||
function $8b9e2899b2e82f52$var$getElementTransforms(el) {
|
||
if (!$8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$getTransformValue(el, propName, animatable, unit) {
|
||
var defaultVal = $8b9e2899b2e82f52$var$stringContains(propName, "scale") ? 1 : 0 + $8b9e2899b2e82f52$var$getTransformUnit(propName);
|
||
var value = $8b9e2899b2e82f52$var$getElementTransforms(el).get(propName) || defaultVal;
|
||
if (animatable) {
|
||
animatable.transforms.list.set(propName, value);
|
||
animatable.transforms["last"] = propName;
|
||
}
|
||
return unit ? $8b9e2899b2e82f52$var$convertPxToUnit(el, value, unit) : value;
|
||
}
|
||
function $8b9e2899b2e82f52$var$getOriginalTargetValue(target, propName, unit, animatable) {
|
||
switch($8b9e2899b2e82f52$var$getAnimationType(target, propName)){
|
||
case "transform":
|
||
return $8b9e2899b2e82f52$var$getTransformValue(target, propName, animatable, unit);
|
||
case "css":
|
||
return $8b9e2899b2e82f52$var$getCSSValue(target, propName, unit);
|
||
case "attribute":
|
||
return $8b9e2899b2e82f52$var$getAttribute(target, propName);
|
||
default:
|
||
return target[propName] || 0;
|
||
}
|
||
}
|
||
function $8b9e2899b2e82f52$var$getRelativeValue(to, from) {
|
||
var operator = /^(\*=|\+=|-=)/.exec(to);
|
||
if (!operator) return to;
|
||
var u = $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$validateValue(val, unit) {
|
||
if ($8b9e2899b2e82f52$var$is.col(val)) return $8b9e2899b2e82f52$var$colorToRgb(val);
|
||
if (/\s/g.test(val)) return val;
|
||
var originalUnit = $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$getDistance(p1, p2) {
|
||
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
|
||
}
|
||
function $8b9e2899b2e82f52$var$getCircleLength(el) {
|
||
return Math.PI * 2 * $8b9e2899b2e82f52$var$getAttribute(el, "r");
|
||
}
|
||
function $8b9e2899b2e82f52$var$getRectLength(el) {
|
||
return $8b9e2899b2e82f52$var$getAttribute(el, "width") * 2 + $8b9e2899b2e82f52$var$getAttribute(el, "height") * 2;
|
||
}
|
||
function $8b9e2899b2e82f52$var$getLineLength(el) {
|
||
return $8b9e2899b2e82f52$var$getDistance({
|
||
x: $8b9e2899b2e82f52$var$getAttribute(el, "x1"),
|
||
y: $8b9e2899b2e82f52$var$getAttribute(el, "y1")
|
||
}, {
|
||
x: $8b9e2899b2e82f52$var$getAttribute(el, "x2"),
|
||
y: $8b9e2899b2e82f52$var$getAttribute(el, "y2")
|
||
});
|
||
}
|
||
function $8b9e2899b2e82f52$var$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 += $8b9e2899b2e82f52$var$getDistance(previousPos, currentPos);
|
||
previousPos = currentPos;
|
||
}
|
||
return totalLength;
|
||
}
|
||
function $8b9e2899b2e82f52$var$getPolygonLength(el) {
|
||
var points = el.points;
|
||
return $8b9e2899b2e82f52$var$getPolylineLength(el) + $8b9e2899b2e82f52$var$getDistance(points.getItem(points.numberOfItems - 1), points.getItem(0));
|
||
}
|
||
// Path animation
|
||
function $8b9e2899b2e82f52$var$getTotalLength(el) {
|
||
if (el.getTotalLength) return el.getTotalLength();
|
||
switch(el.tagName.toLowerCase()){
|
||
case "circle":
|
||
return $8b9e2899b2e82f52$var$getCircleLength(el);
|
||
case "rect":
|
||
return $8b9e2899b2e82f52$var$getRectLength(el);
|
||
case "line":
|
||
return $8b9e2899b2e82f52$var$getLineLength(el);
|
||
case "polyline":
|
||
return $8b9e2899b2e82f52$var$getPolylineLength(el);
|
||
case "polygon":
|
||
return $8b9e2899b2e82f52$var$getPolygonLength(el);
|
||
}
|
||
}
|
||
function $8b9e2899b2e82f52$var$setDashoffset(el) {
|
||
var pathLength = $8b9e2899b2e82f52$var$getTotalLength(el);
|
||
el.setAttribute("stroke-dasharray", pathLength);
|
||
return pathLength;
|
||
}
|
||
// Motion path
|
||
function $8b9e2899b2e82f52$var$getParentSvgEl(el) {
|
||
var parentEl = el.parentNode;
|
||
while($8b9e2899b2e82f52$var$is.svg(parentEl)){
|
||
if (!$8b9e2899b2e82f52$var$is.svg(parentEl.parentNode)) break;
|
||
parentEl = parentEl.parentNode;
|
||
}
|
||
return parentEl;
|
||
}
|
||
function $8b9e2899b2e82f52$var$getParentSvg(pathEl, svgData) {
|
||
var svg = svgData || {};
|
||
var parentSvgEl = svg.el || $8b9e2899b2e82f52$var$getParentSvgEl(pathEl);
|
||
var rect = parentSvgEl.getBoundingClientRect();
|
||
var viewBoxAttr = $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$getPath(path, percent) {
|
||
var pathEl = $8b9e2899b2e82f52$var$is.str(path) ? $8b9e2899b2e82f52$var$selectString(path)[0] : path;
|
||
var p = percent || 100;
|
||
return function(property) {
|
||
return {
|
||
property: property,
|
||
el: pathEl,
|
||
svg: $8b9e2899b2e82f52$var$getParentSvg(pathEl),
|
||
totalLength: $8b9e2899b2e82f52$var$getTotalLength(pathEl) * (p / 100)
|
||
};
|
||
};
|
||
}
|
||
function $8b9e2899b2e82f52$var$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 = $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$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 = $8b9e2899b2e82f52$var$validateValue($8b9e2899b2e82f52$var$is.pth(val) ? val.totalLength : val, unit) + "";
|
||
return {
|
||
original: value,
|
||
numbers: value.match(rgx) ? value.match(rgx).map(Number) : [
|
||
0
|
||
],
|
||
strings: $8b9e2899b2e82f52$var$is.str(val) || unit ? value.split(rgx) : []
|
||
};
|
||
}
|
||
// Animatables
|
||
function $8b9e2899b2e82f52$var$parseTargets(targets) {
|
||
var targetsArray = targets ? $8b9e2899b2e82f52$var$flattenArray($8b9e2899b2e82f52$var$is.arr(targets) ? targets.map($8b9e2899b2e82f52$var$toArray) : $8b9e2899b2e82f52$var$toArray(targets)) : [];
|
||
return $8b9e2899b2e82f52$var$filterArray(targetsArray, function(item, pos, self) {
|
||
return self.indexOf(item) === pos;
|
||
});
|
||
}
|
||
function $8b9e2899b2e82f52$var$getAnimatables(targets) {
|
||
var parsed = $8b9e2899b2e82f52$var$parseTargets(targets);
|
||
return parsed.map(function(t, i) {
|
||
return {
|
||
target: t,
|
||
id: i,
|
||
total: parsed.length,
|
||
transforms: {
|
||
list: $8b9e2899b2e82f52$var$getElementTransforms(t)
|
||
}
|
||
};
|
||
});
|
||
}
|
||
// Properties
|
||
function $8b9e2899b2e82f52$var$normalizePropertyTweens(prop, tweenSettings) {
|
||
var settings = $8b9e2899b2e82f52$var$cloneObject(tweenSettings);
|
||
// Override duration if easing is a spring
|
||
if (/^spring/.test(settings.easing)) settings.duration = $8b9e2899b2e82f52$var$spring(settings.easing);
|
||
if ($8b9e2899b2e82f52$var$is.arr(prop)) {
|
||
var l = prop.length;
|
||
var isFromTo = l === 2 && !$8b9e2899b2e82f52$var$is.obj(prop[0]);
|
||
if (!isFromTo) // Duration divided by the number of tweens
|
||
{
|
||
if (!$8b9e2899b2e82f52$var$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 = $8b9e2899b2e82f52$var$is.arr(prop) ? prop : [
|
||
prop
|
||
];
|
||
return propArray.map(function(v, i) {
|
||
var obj = $8b9e2899b2e82f52$var$is.obj(v) && !$8b9e2899b2e82f52$var$is.pth(v) ? v : {
|
||
value: v
|
||
};
|
||
// Default delay value should only be applied to the first tween
|
||
if ($8b9e2899b2e82f52$var$is.und(obj.delay)) obj.delay = !i ? tweenSettings.delay : 0;
|
||
// Default endDelay value should only be applied to the last tween
|
||
if ($8b9e2899b2e82f52$var$is.und(obj.endDelay)) obj.endDelay = i === propArray.length - 1 ? tweenSettings.endDelay : 0;
|
||
return obj;
|
||
}).map(function(k) {
|
||
return $8b9e2899b2e82f52$var$mergeObjects(k, settings);
|
||
});
|
||
}
|
||
function $8b9e2899b2e82f52$var$flattenKeyframes(keyframes) {
|
||
var propertyNames = $8b9e2899b2e82f52$var$filterArray($8b9e2899b2e82f52$var$flattenArray(keyframes.map(function(key) {
|
||
return Object.keys(key);
|
||
})), function(p) {
|
||
return $8b9e2899b2e82f52$var$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 ($8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$getProperties(tweenSettings, params) {
|
||
var properties = [];
|
||
var keyframes = params.keyframes;
|
||
if (keyframes) params = $8b9e2899b2e82f52$var$mergeObjects($8b9e2899b2e82f52$var$flattenKeyframes(keyframes), params);
|
||
for(var p in params)if ($8b9e2899b2e82f52$var$is.key(p)) properties.push({
|
||
name: p,
|
||
tweens: $8b9e2899b2e82f52$var$normalizePropertyTweens(params[p], tweenSettings)
|
||
});
|
||
return properties;
|
||
}
|
||
// Tweens
|
||
function $8b9e2899b2e82f52$var$normalizeTweenValues(tween, animatable) {
|
||
var t = {};
|
||
for(var p in tween){
|
||
var value = $8b9e2899b2e82f52$var$getFunctionValue(tween[p], animatable);
|
||
if ($8b9e2899b2e82f52$var$is.arr(value)) {
|
||
value = value.map(function(v) {
|
||
return $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$normalizeTweens(prop, animatable) {
|
||
var previousTween;
|
||
return prop.tweens.map(function(t) {
|
||
var tween = $8b9e2899b2e82f52$var$normalizeTweenValues(t, animatable);
|
||
var tweenValue = tween.value;
|
||
var to = $8b9e2899b2e82f52$var$is.arr(tweenValue) ? tweenValue[1] : tweenValue;
|
||
var toUnit = $8b9e2899b2e82f52$var$getUnit(to);
|
||
var originalValue = $8b9e2899b2e82f52$var$getOriginalTargetValue(animatable.target, prop.name, toUnit, animatable);
|
||
var previousValue = previousTween ? previousTween.to.original : originalValue;
|
||
var from = $8b9e2899b2e82f52$var$is.arr(tweenValue) ? tweenValue[0] : previousValue;
|
||
var fromUnit = $8b9e2899b2e82f52$var$getUnit(from) || $8b9e2899b2e82f52$var$getUnit(originalValue);
|
||
var unit = toUnit || fromUnit;
|
||
if ($8b9e2899b2e82f52$var$is.und(to)) to = previousValue;
|
||
tween.from = $8b9e2899b2e82f52$var$decomposeValue(from, unit);
|
||
tween.to = $8b9e2899b2e82f52$var$decomposeValue($8b9e2899b2e82f52$var$getRelativeValue(to, from), unit);
|
||
tween.start = previousTween ? previousTween.end : 0;
|
||
tween.end = tween.start + tween.delay + tween.duration + tween.endDelay;
|
||
tween.easing = $8b9e2899b2e82f52$var$parseEasings(tween.easing, tween.duration);
|
||
tween.isPath = $8b9e2899b2e82f52$var$is.pth(tweenValue);
|
||
tween.isPathTargetInsideSVG = tween.isPath && $8b9e2899b2e82f52$var$is.svg(animatable.target);
|
||
tween.isColor = $8b9e2899b2e82f52$var$is.col(tween.from.original);
|
||
if (tween.isColor) tween.round = 1;
|
||
previousTween = tween;
|
||
return tween;
|
||
});
|
||
}
|
||
// Tween progress
|
||
var $8b9e2899b2e82f52$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 $8b9e2899b2e82f52$var$setTargetsValue(targets, properties) {
|
||
var animatables = $8b9e2899b2e82f52$var$getAnimatables(targets);
|
||
animatables.forEach(function(animatable) {
|
||
for(var property in properties){
|
||
var value = $8b9e2899b2e82f52$var$getFunctionValue(properties[property], animatable);
|
||
var target = animatable.target;
|
||
var valueUnit = $8b9e2899b2e82f52$var$getUnit(value);
|
||
var originalValue = $8b9e2899b2e82f52$var$getOriginalTargetValue(target, property, valueUnit, animatable);
|
||
var unit = valueUnit || $8b9e2899b2e82f52$var$getUnit(originalValue);
|
||
var to = $8b9e2899b2e82f52$var$getRelativeValue($8b9e2899b2e82f52$var$validateValue(value, unit), originalValue);
|
||
var animType = $8b9e2899b2e82f52$var$getAnimationType(target, property);
|
||
$8b9e2899b2e82f52$var$setProgressValue[animType](target, property, to, animatable.transforms, true);
|
||
}
|
||
});
|
||
}
|
||
// Animations
|
||
function $8b9e2899b2e82f52$var$createAnimation(animatable, prop) {
|
||
var animType = $8b9e2899b2e82f52$var$getAnimationType(animatable.target, prop.name);
|
||
if (animType) {
|
||
var tweens = $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$getAnimations(animatables, properties) {
|
||
return $8b9e2899b2e82f52$var$filterArray($8b9e2899b2e82f52$var$flattenArray(animatables.map(function(animatable) {
|
||
return properties.map(function(prop) {
|
||
return $8b9e2899b2e82f52$var$createAnimation(animatable, prop);
|
||
});
|
||
})), function(a) {
|
||
return !$8b9e2899b2e82f52$var$is.und(a);
|
||
});
|
||
}
|
||
// Create Instance
|
||
function $8b9e2899b2e82f52$var$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 $8b9e2899b2e82f52$var$instanceID = 0;
|
||
function $8b9e2899b2e82f52$var$createNewInstance(params) {
|
||
var instanceSettings = $8b9e2899b2e82f52$var$replaceObjectProps($8b9e2899b2e82f52$var$defaultInstanceSettings, params);
|
||
var tweenSettings = $8b9e2899b2e82f52$var$replaceObjectProps($8b9e2899b2e82f52$var$defaultTweenSettings, params);
|
||
var properties = $8b9e2899b2e82f52$var$getProperties(tweenSettings, params);
|
||
var animatables = $8b9e2899b2e82f52$var$getAnimatables(params.targets);
|
||
var animations = $8b9e2899b2e82f52$var$getAnimations(animatables, properties);
|
||
var timings = $8b9e2899b2e82f52$var$getInstanceTimings(animations, tweenSettings);
|
||
var id = $8b9e2899b2e82f52$var$instanceID;
|
||
$8b9e2899b2e82f52$var$instanceID++;
|
||
return $8b9e2899b2e82f52$var$mergeObjects(instanceSettings, {
|
||
id: id,
|
||
children: [],
|
||
animatables: animatables,
|
||
animations: animations,
|
||
duration: timings.duration,
|
||
delay: timings.delay,
|
||
endDelay: timings.endDelay
|
||
});
|
||
}
|
||
// Core
|
||
var $8b9e2899b2e82f52$var$activeInstances = [];
|
||
var $8b9e2899b2e82f52$var$engine = function() {
|
||
var raf;
|
||
function play() {
|
||
if (!raf && (!$8b9e2899b2e82f52$var$isDocumentHidden() || !$8b9e2899b2e82f52$var$anime.suspendWhenDocumentHidden) && $8b9e2899b2e82f52$var$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 = $8b9e2899b2e82f52$var$activeInstances.length;
|
||
var i = 0;
|
||
while(i < activeInstancesLength){
|
||
var activeInstance = $8b9e2899b2e82f52$var$activeInstances[i];
|
||
if (!activeInstance.paused) {
|
||
activeInstance.tick(t);
|
||
i++;
|
||
} else {
|
||
$8b9e2899b2e82f52$var$activeInstances.splice(i, 1);
|
||
activeInstancesLength--;
|
||
}
|
||
}
|
||
raf = i > 0 ? requestAnimationFrame(step) : undefined;
|
||
}
|
||
function handleVisibilityChange() {
|
||
if (!$8b9e2899b2e82f52$var$anime.suspendWhenDocumentHidden) return;
|
||
if ($8b9e2899b2e82f52$var$isDocumentHidden()) // suspend ticks
|
||
raf = cancelAnimationFrame(raf);
|
||
else {
|
||
// first adjust animations to consider the time that ticks were suspended
|
||
$8b9e2899b2e82f52$var$activeInstances.forEach(function(instance) {
|
||
return instance._onDocumentVisibility();
|
||
});
|
||
$8b9e2899b2e82f52$var$engine();
|
||
}
|
||
}
|
||
if (typeof document !== "undefined") document.addEventListener("visibilitychange", handleVisibilityChange);
|
||
return play;
|
||
}();
|
||
function $8b9e2899b2e82f52$var$isDocumentHidden() {
|
||
return !!document && document.hidden;
|
||
}
|
||
// Public Instance
|
||
function $8b9e2899b2e82f52$var$anime(params) {
|
||
if (params === void 0) params = {};
|
||
var startTime = 0, lastTime = 0, now = 0;
|
||
var children, childrenLength = 0;
|
||
var resolve = null;
|
||
function makePromise(instance) {
|
||
var promise = window.Promise && new Promise(function(_resolve) {
|
||
return resolve = _resolve;
|
||
});
|
||
instance.finished = promise;
|
||
return promise;
|
||
}
|
||
var instance = $8b9e2899b2e82f52$var$createNewInstance(params);
|
||
var promise = makePromise(instance);
|
||
function toggleInstanceDirection() {
|
||
var direction = instance.direction;
|
||
if (direction !== "alternate") instance.direction = direction !== "normal" ? "normal" : "reverse";
|
||
instance.reversed = !instance.reversed;
|
||
children.forEach(function(child) {
|
||
return child.reversed = instance.reversed;
|
||
});
|
||
}
|
||
function adjustTime(time) {
|
||
return instance.reversed ? instance.duration - time : time;
|
||
}
|
||
function resetTime() {
|
||
startTime = 0;
|
||
lastTime = adjustTime(instance.currentTime) * (1 / $8b9e2899b2e82f52$var$anime.speed);
|
||
}
|
||
function seekChild(time, child) {
|
||
if (child) child.seek(time - child.timelineOffset);
|
||
}
|
||
function syncInstanceChildren(time) {
|
||
if (!instance.reversePlayback) for(var i = 0; i < childrenLength; i++)seekChild(time, children[i]);
|
||
else for(var i$1 = childrenLength; i$1--;)seekChild(time, children[i$1]);
|
||
}
|
||
function setAnimationsProgress(insTime) {
|
||
var i = 0;
|
||
var animations = instance.animations;
|
||
var animationsLength = animations.length;
|
||
while(i < animationsLength){
|
||
var anim = animations[i];
|
||
var animatable = anim.animatable;
|
||
var tweens = anim.tweens;
|
||
var tweenLength = tweens.length - 1;
|
||
var tween = tweens[tweenLength];
|
||
// Only check for keyframes if there is more than one tween
|
||
if (tweenLength) tween = $8b9e2899b2e82f52$var$filterArray(tweens, function(t) {
|
||
return insTime < t.end;
|
||
})[0] || tween;
|
||
var elapsed = $8b9e2899b2e82f52$var$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 = $8b9e2899b2e82f52$var$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;
|
||
}
|
||
}
|
||
}
|
||
$8b9e2899b2e82f52$var$setProgressValue[anim.type](animatable.target, anim.property, progress, animatable.transforms);
|
||
anim.currentValue = progress;
|
||
i++;
|
||
}
|
||
}
|
||
function setCallback(cb) {
|
||
if (instance[cb] && !instance.passThrough) instance[cb](instance);
|
||
}
|
||
function countIteration() {
|
||
if (instance.remaining && instance.remaining !== true) instance.remaining--;
|
||
}
|
||
function setInstanceProgress(engineTime) {
|
||
var insDuration = instance.duration;
|
||
var insDelay = instance.delay;
|
||
var insEndDelay = insDuration - instance.endDelay;
|
||
var insTime = adjustTime(engineTime);
|
||
instance.progress = $8b9e2899b2e82f52$var$minMax(insTime / insDuration * 100, 0, 100);
|
||
instance.reversePlayback = insTime < instance.currentTime;
|
||
if (children) syncInstanceChildren(insTime);
|
||
if (!instance.began && instance.currentTime > 0) {
|
||
instance.began = true;
|
||
setCallback("begin");
|
||
}
|
||
if (!instance.loopBegan && instance.currentTime > 0) {
|
||
instance.loopBegan = true;
|
||
setCallback("loopBegin");
|
||
}
|
||
if (insTime <= insDelay && instance.currentTime !== 0) setAnimationsProgress(0);
|
||
if (insTime >= insEndDelay && instance.currentTime !== insDuration || !insDuration) setAnimationsProgress(insDuration);
|
||
if (insTime > insDelay && insTime < insEndDelay) {
|
||
if (!instance.changeBegan) {
|
||
instance.changeBegan = true;
|
||
instance.changeCompleted = false;
|
||
setCallback("changeBegin");
|
||
}
|
||
setCallback("change");
|
||
setAnimationsProgress(insTime);
|
||
} else if (instance.changeBegan) {
|
||
instance.changeCompleted = true;
|
||
instance.changeBegan = false;
|
||
setCallback("changeComplete");
|
||
}
|
||
instance.currentTime = $8b9e2899b2e82f52$var$minMax(insTime, 0, insDuration);
|
||
if (instance.began) setCallback("update");
|
||
if (engineTime >= insDuration) {
|
||
lastTime = 0;
|
||
countIteration();
|
||
if (!instance.remaining) {
|
||
instance.paused = true;
|
||
if (!instance.completed) {
|
||
instance.completed = true;
|
||
setCallback("loopComplete");
|
||
setCallback("complete");
|
||
if (!instance.passThrough && "Promise" in window) {
|
||
resolve();
|
||
promise = makePromise(instance);
|
||
}
|
||
}
|
||
} else {
|
||
startTime = now;
|
||
setCallback("loopComplete");
|
||
instance.loopBegan = false;
|
||
if (instance.direction === "alternate") toggleInstanceDirection();
|
||
}
|
||
}
|
||
}
|
||
instance.reset = function() {
|
||
var direction = instance.direction;
|
||
instance.passThrough = false;
|
||
instance.currentTime = 0;
|
||
instance.progress = 0;
|
||
instance.paused = true;
|
||
instance.began = false;
|
||
instance.loopBegan = false;
|
||
instance.changeBegan = false;
|
||
instance.completed = false;
|
||
instance.changeCompleted = false;
|
||
instance.reversePlayback = false;
|
||
instance.reversed = direction === "reverse";
|
||
instance.remaining = instance.loop;
|
||
children = instance.children;
|
||
childrenLength = children.length;
|
||
for(var i = childrenLength; i--;)instance.children[i].reset();
|
||
if (instance.reversed && instance.loop !== true || direction === "alternate" && instance.loop === 1) instance.remaining++;
|
||
setAnimationsProgress(instance.reversed ? instance.duration : 0);
|
||
};
|
||
// internal method (for engine) to adjust animation timings before restoring engine ticks (rAF)
|
||
instance._onDocumentVisibility = resetTime;
|
||
// Set Value helper
|
||
instance.set = function(targets, properties) {
|
||
$8b9e2899b2e82f52$var$setTargetsValue(targets, properties);
|
||
return instance;
|
||
};
|
||
instance.tick = function(t) {
|
||
now = t;
|
||
if (!startTime) startTime = now;
|
||
setInstanceProgress((now + (lastTime - startTime)) * $8b9e2899b2e82f52$var$anime.speed);
|
||
};
|
||
instance.seek = function(time) {
|
||
setInstanceProgress(adjustTime(time));
|
||
};
|
||
instance.pause = function() {
|
||
instance.paused = true;
|
||
resetTime();
|
||
};
|
||
instance.play = function() {
|
||
if (!instance.paused) return;
|
||
if (instance.completed) instance.reset();
|
||
instance.paused = false;
|
||
$8b9e2899b2e82f52$var$activeInstances.push(instance);
|
||
resetTime();
|
||
$8b9e2899b2e82f52$var$engine();
|
||
};
|
||
instance.reverse = function() {
|
||
toggleInstanceDirection();
|
||
instance.completed = instance.reversed ? false : true;
|
||
resetTime();
|
||
};
|
||
instance.restart = function() {
|
||
instance.reset();
|
||
instance.play();
|
||
};
|
||
instance.remove = function(targets) {
|
||
var targetsArray = $8b9e2899b2e82f52$var$parseTargets(targets);
|
||
$8b9e2899b2e82f52$var$removeTargetsFromInstance(targetsArray, instance);
|
||
};
|
||
instance.reset();
|
||
if (instance.autoplay) instance.play();
|
||
return instance;
|
||
}
|
||
// Remove targets from animation
|
||
function $8b9e2899b2e82f52$var$removeTargetsFromAnimations(targetsArray, animations) {
|
||
for(var a = animations.length; a--;)if ($8b9e2899b2e82f52$var$arrayContains(targetsArray, animations[a].animatable.target)) animations.splice(a, 1);
|
||
}
|
||
function $8b9e2899b2e82f52$var$removeTargetsFromInstance(targetsArray, instance) {
|
||
var animations = instance.animations;
|
||
var children = instance.children;
|
||
$8b9e2899b2e82f52$var$removeTargetsFromAnimations(targetsArray, animations);
|
||
for(var c = children.length; c--;){
|
||
var child = children[c];
|
||
var childAnimations = child.animations;
|
||
$8b9e2899b2e82f52$var$removeTargetsFromAnimations(targetsArray, childAnimations);
|
||
if (!childAnimations.length && !child.children.length) children.splice(c, 1);
|
||
}
|
||
if (!animations.length && !children.length) instance.pause();
|
||
}
|
||
function $8b9e2899b2e82f52$var$removeTargetsFromActiveInstances(targets) {
|
||
var targetsArray = $8b9e2899b2e82f52$var$parseTargets(targets);
|
||
for(var i = $8b9e2899b2e82f52$var$activeInstances.length; i--;){
|
||
var instance = $8b9e2899b2e82f52$var$activeInstances[i];
|
||
$8b9e2899b2e82f52$var$removeTargetsFromInstance(targetsArray, instance);
|
||
}
|
||
}
|
||
// Stagger helpers
|
||
function $8b9e2899b2e82f52$var$stagger(val, params) {
|
||
if (params === void 0) params = {};
|
||
var direction = params.direction || "normal";
|
||
var easing = params.easing ? $8b9e2899b2e82f52$var$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 = $8b9e2899b2e82f52$var$is.arr(val);
|
||
var val1 = isRange ? parseFloat(val[0]) : parseFloat(val);
|
||
var val2 = isRange ? parseFloat(val[1]) : 0;
|
||
var unit = $8b9e2899b2e82f52$var$getUnit(isRange ? val[1] : val) || 0;
|
||
var start = params.start || 0 + (isRange ? val1 : 0);
|
||
var values = [];
|
||
var maxValue = 0;
|
||
return function(el, i, t) {
|
||
if (fromFirst) fromIndex = 0;
|
||
if (fromCenter) fromIndex = (t - 1) / 2;
|
||
if (fromLast) fromIndex = t - 1;
|
||
if (!values.length) {
|
||
for(var index = 0; index < t; index++){
|
||
if (!grid) values.push(Math.abs(fromIndex - index));
|
||
else {
|
||
var fromX = !fromCenter ? fromIndex % grid[0] : (grid[0] - 1) / 2;
|
||
var fromY = !fromCenter ? Math.floor(fromIndex / grid[0]) : (grid[1] - 1) / 2;
|
||
var toX = index % grid[0];
|
||
var toY = Math.floor(index / grid[0]);
|
||
var distanceX = fromX - toX;
|
||
var distanceY = fromY - toY;
|
||
var value = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
|
||
if (axis === "x") value = -distanceX;
|
||
if (axis === "y") value = -distanceY;
|
||
values.push(value);
|
||
}
|
||
maxValue = Math.max.apply(Math, values);
|
||
}
|
||
if (easing) values = values.map(function(val) {
|
||
return easing(val / maxValue) * maxValue;
|
||
});
|
||
if (direction === "reverse") values = values.map(function(val) {
|
||
return axis ? val < 0 ? val * -1 : -val : Math.abs(maxValue - val);
|
||
});
|
||
}
|
||
var spacing = isRange ? (val2 - val1) / maxValue : val1;
|
||
return start + spacing * (Math.round(values[i] * 100) / 100) + unit;
|
||
};
|
||
}
|
||
// Timeline
|
||
function $8b9e2899b2e82f52$var$timeline(params) {
|
||
if (params === void 0) params = {};
|
||
var tl = $8b9e2899b2e82f52$var$anime(params);
|
||
tl.duration = 0;
|
||
tl.add = function(instanceParams, timelineOffset) {
|
||
var tlIndex = $8b9e2899b2e82f52$var$activeInstances.indexOf(tl);
|
||
var children = tl.children;
|
||
if (tlIndex > -1) $8b9e2899b2e82f52$var$activeInstances.splice(tlIndex, 1);
|
||
function passThrough(ins) {
|
||
ins.passThrough = true;
|
||
}
|
||
for(var i = 0; i < children.length; i++)passThrough(children[i]);
|
||
var insParams = $8b9e2899b2e82f52$var$mergeObjects(instanceParams, $8b9e2899b2e82f52$var$replaceObjectProps($8b9e2899b2e82f52$var$defaultTweenSettings, params));
|
||
insParams.targets = insParams.targets || params.targets;
|
||
var tlDuration = tl.duration;
|
||
insParams.autoplay = false;
|
||
insParams.direction = tl.direction;
|
||
insParams.timelineOffset = $8b9e2899b2e82f52$var$is.und(timelineOffset) ? tlDuration : $8b9e2899b2e82f52$var$getRelativeValue(timelineOffset, tlDuration);
|
||
passThrough(tl);
|
||
tl.seek(insParams.timelineOffset);
|
||
var ins = $8b9e2899b2e82f52$var$anime(insParams);
|
||
passThrough(ins);
|
||
children.push(ins);
|
||
var timings = $8b9e2899b2e82f52$var$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;
|
||
}
|
||
$8b9e2899b2e82f52$var$anime.version = "3.2.1";
|
||
$8b9e2899b2e82f52$var$anime.speed = 1;
|
||
// TODO:#review: naming, documentation
|
||
$8b9e2899b2e82f52$var$anime.suspendWhenDocumentHidden = true;
|
||
$8b9e2899b2e82f52$var$anime.running = $8b9e2899b2e82f52$var$activeInstances;
|
||
$8b9e2899b2e82f52$var$anime.remove = $8b9e2899b2e82f52$var$removeTargetsFromActiveInstances;
|
||
$8b9e2899b2e82f52$var$anime.get = $8b9e2899b2e82f52$var$getOriginalTargetValue;
|
||
$8b9e2899b2e82f52$var$anime.set = $8b9e2899b2e82f52$var$setTargetsValue;
|
||
$8b9e2899b2e82f52$var$anime.convertPx = $8b9e2899b2e82f52$var$convertPxToUnit;
|
||
$8b9e2899b2e82f52$var$anime.path = $8b9e2899b2e82f52$var$getPath;
|
||
$8b9e2899b2e82f52$var$anime.setDashoffset = $8b9e2899b2e82f52$var$setDashoffset;
|
||
$8b9e2899b2e82f52$var$anime.stagger = $8b9e2899b2e82f52$var$stagger;
|
||
$8b9e2899b2e82f52$var$anime.timeline = $8b9e2899b2e82f52$var$timeline;
|
||
$8b9e2899b2e82f52$var$anime.easing = $8b9e2899b2e82f52$var$parseEasings;
|
||
$8b9e2899b2e82f52$var$anime.penner = $8b9e2899b2e82f52$var$penner;
|
||
$8b9e2899b2e82f52$var$anime.random = function(min, max) {
|
||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||
};
|
||
var $8b9e2899b2e82f52$export$2e2bcd8739ae039 = $8b9e2899b2e82f52$var$anime;
|
||
|
||
|
||
const $accfb6154319a04b$var$notifcation = document.querySelector(".notify-message");
|
||
const $accfb6154319a04b$var$notify = document.getElementById("notify-message");
|
||
const $accfb6154319a04b$var$responseText = document.querySelector(".response-text");
|
||
const $accfb6154319a04b$var$notifyText = document.querySelector(".notify-text");
|
||
const $accfb6154319a04b$var$notifyIcons = document.querySelector(".notify-icons");
|
||
//const notifyProgress = document.getElementById('notify-progress');
|
||
const $accfb6154319a04b$var$iconGood = document.querySelector(".notify-good");
|
||
const $accfb6154319a04b$var$iconNotGood = document.querySelector(".notify-notgood");
|
||
const $accfb6154319a04b$var$iconWorking = document.querySelector(".notify-working");
|
||
class $accfb6154319a04b$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(){}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
alert(text, status) {
|
||
$accfb6154319a04b$var$iconWorking.style.display = "none";
|
||
$accfb6154319a04b$var$iconGood.style.display = "none";
|
||
$accfb6154319a04b$var$iconNotGood.style.display = "none";
|
||
var color = "";
|
||
$accfb6154319a04b$var$responseText.innerHTML = text;
|
||
if (status !== null) {
|
||
if (status) {
|
||
color = "#32cd32";
|
||
$accfb6154319a04b$var$iconWorking.style.display = "none";
|
||
$accfb6154319a04b$var$iconGood.style.display = "block";
|
||
} else {
|
||
color = "#F64747";
|
||
$accfb6154319a04b$var$iconWorking.style.display = "none";
|
||
$accfb6154319a04b$var$iconNotGood.style.display = "block";
|
||
}
|
||
} else {
|
||
color = "#200317";
|
||
$accfb6154319a04b$var$iconWorking.style.display = "block";
|
||
}
|
||
new (0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: document.querySelector(".top-nav"),
|
||
rotateX: "180deg",
|
||
easing: "easeOutQuint"
|
||
});
|
||
new (0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: document.querySelector(".notify"),
|
||
rotateX: "10deg",
|
||
easing: "easeOutQuint",
|
||
complete: ()=>{
|
||
new (0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: $accfb6154319a04b$var$notifyIcons,
|
||
width: 39,
|
||
opacity: 1,
|
||
easing: "easeInQuint",
|
||
duration: 300
|
||
});
|
||
new (0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: $accfb6154319a04b$var$notifyText,
|
||
backgroundColor: color,
|
||
opacity: 1,
|
||
easing: "easeInOutQuad",
|
||
duration: 400,
|
||
complete: ()=>{
|
||
setTimeout(()=>{
|
||
if (status !== null) {
|
||
(0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: $accfb6154319a04b$var$notifyText,
|
||
backgroundColor: color,
|
||
opacity: 0,
|
||
easing: "easeInOutQuad",
|
||
duration: 400
|
||
});
|
||
(0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: $accfb6154319a04b$var$notifyIcons,
|
||
width: 0,
|
||
opacity: 0,
|
||
easing: "easeOutQuint",
|
||
duration: 350
|
||
});
|
||
new (0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: document.querySelector(".top-nav"),
|
||
rotateX: "0deg",
|
||
easing: "easeOutQuint"
|
||
});
|
||
new (0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: document.querySelector(".notify"),
|
||
rotateX: "180deg",
|
||
easing: "easeOutQuint"
|
||
});
|
||
}
|
||
}, 2500);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
|
||
/**!
|
||
* Sortable 1.15.0
|
||
* @author RubaXa <trash@rubaxa.org>
|
||
* @author owenm <owen23355@gmail.com>
|
||
* @license MIT
|
||
*/ function $64afbd09cd65a300$var$ownKeys(object, enumerableOnly) {
|
||
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 $64afbd09cd65a300$var$_objectSpread2(target) {
|
||
for(var i = 1; i < arguments.length; i++){
|
||
var source = arguments[i] != null ? arguments[i] : {};
|
||
if (i % 2) $64afbd09cd65a300$var$ownKeys(Object(source), true).forEach(function(key) {
|
||
$64afbd09cd65a300$var$_defineProperty(target, key, source[key]);
|
||
});
|
||
else if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||
else $64afbd09cd65a300$var$ownKeys(Object(source)).forEach(function(key) {
|
||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
||
});
|
||
}
|
||
return target;
|
||
}
|
||
function $64afbd09cd65a300$var$_typeof(obj) {
|
||
"@babel/helpers - typeof";
|
||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") $64afbd09cd65a300$var$_typeof = function(obj) {
|
||
return typeof obj;
|
||
};
|
||
else $64afbd09cd65a300$var$_typeof = function(obj) {
|
||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||
};
|
||
return $64afbd09cd65a300$var$_typeof(obj);
|
||
}
|
||
function $64afbd09cd65a300$var$_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 $64afbd09cd65a300$var$_extends() {
|
||
$64afbd09cd65a300$var$_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 $64afbd09cd65a300$var$_extends.apply(this, arguments);
|
||
}
|
||
function $64afbd09cd65a300$var$_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 $64afbd09cd65a300$var$_objectWithoutProperties(source, excluded) {
|
||
if (source == null) return {};
|
||
var target = $64afbd09cd65a300$var$_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 $64afbd09cd65a300$var$_toConsumableArray(arr) {
|
||
return $64afbd09cd65a300$var$_arrayWithoutHoles(arr) || $64afbd09cd65a300$var$_iterableToArray(arr) || $64afbd09cd65a300$var$_unsupportedIterableToArray(arr) || $64afbd09cd65a300$var$_nonIterableSpread();
|
||
}
|
||
function $64afbd09cd65a300$var$_arrayWithoutHoles(arr) {
|
||
if (Array.isArray(arr)) return $64afbd09cd65a300$var$_arrayLikeToArray(arr);
|
||
}
|
||
function $64afbd09cd65a300$var$_iterableToArray(iter) {
|
||
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
||
}
|
||
function $64afbd09cd65a300$var$_unsupportedIterableToArray(o, minLen) {
|
||
if (!o) return;
|
||
if (typeof o === "string") return $64afbd09cd65a300$var$_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 $64afbd09cd65a300$var$_arrayLikeToArray(o, minLen);
|
||
}
|
||
function $64afbd09cd65a300$var$_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 $64afbd09cd65a300$var$_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 $64afbd09cd65a300$var$version = "1.15.0";
|
||
function $64afbd09cd65a300$var$userAgent(pattern) {
|
||
if (typeof window !== "undefined" && window.navigator) return !!/*@__PURE__*/ navigator.userAgent.match(pattern);
|
||
}
|
||
var $64afbd09cd65a300$var$IE11OrLess = $64afbd09cd65a300$var$userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
|
||
var $64afbd09cd65a300$var$Edge = $64afbd09cd65a300$var$userAgent(/Edge/i);
|
||
var $64afbd09cd65a300$var$FireFox = $64afbd09cd65a300$var$userAgent(/firefox/i);
|
||
var $64afbd09cd65a300$var$Safari = $64afbd09cd65a300$var$userAgent(/safari/i) && !$64afbd09cd65a300$var$userAgent(/chrome/i) && !$64afbd09cd65a300$var$userAgent(/android/i);
|
||
var $64afbd09cd65a300$var$IOS = $64afbd09cd65a300$var$userAgent(/iP(ad|od|hone)/i);
|
||
var $64afbd09cd65a300$var$ChromeForAndroid = $64afbd09cd65a300$var$userAgent(/chrome/i) && $64afbd09cd65a300$var$userAgent(/android/i);
|
||
var $64afbd09cd65a300$var$captureMode = {
|
||
capture: false,
|
||
passive: false
|
||
};
|
||
function $64afbd09cd65a300$var$on(el, event, fn) {
|
||
el.addEventListener(event, fn, !$64afbd09cd65a300$var$IE11OrLess && $64afbd09cd65a300$var$captureMode);
|
||
}
|
||
function $64afbd09cd65a300$var$off(el, event, fn) {
|
||
el.removeEventListener(event, fn, !$64afbd09cd65a300$var$IE11OrLess && $64afbd09cd65a300$var$captureMode);
|
||
}
|
||
function $64afbd09cd65a300$var$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 $64afbd09cd65a300$var$getParentOrHost(el) {
|
||
return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
|
||
}
|
||
function $64afbd09cd65a300$var$closest(/**HTMLElement*/ el, /**String*/ selector, /**HTMLElement*/ ctx, includeCTX) {
|
||
if (el) {
|
||
ctx = ctx || document;
|
||
do {
|
||
if (selector != null && (selector[0] === ">" ? el.parentNode === ctx && $64afbd09cd65a300$var$matches(el, selector) : $64afbd09cd65a300$var$matches(el, selector)) || includeCTX && el === ctx) return el;
|
||
if (el === ctx) break;
|
||
/* jshint boss:true */ }while (el = $64afbd09cd65a300$var$getParentOrHost(el));
|
||
}
|
||
return null;
|
||
}
|
||
var $64afbd09cd65a300$var$R_SPACE = /\s+/g;
|
||
function $64afbd09cd65a300$var$toggleClass(el, name, state) {
|
||
if (el && name) {
|
||
if (el.classList) el.classList[state ? "add" : "remove"](name);
|
||
else {
|
||
var className = (" " + el.className + " ").replace($64afbd09cd65a300$var$R_SPACE, " ").replace(" " + name + " ", " ");
|
||
el.className = (className + (state ? " " + name : "")).replace($64afbd09cd65a300$var$R_SPACE, " ");
|
||
}
|
||
}
|
||
}
|
||
function $64afbd09cd65a300$var$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 $64afbd09cd65a300$var$matrix(el, selfOnly) {
|
||
var appliedTransforms = "";
|
||
if (typeof el === "string") appliedTransforms = el;
|
||
else do {
|
||
var transform = $64afbd09cd65a300$var$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 $64afbd09cd65a300$var$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 $64afbd09cd65a300$var$getWindowScrollingElement() {
|
||
var scrollingElement = document.scrollingElement;
|
||
if (scrollingElement) return scrollingElement;
|
||
else return document.documentElement;
|
||
}
|
||
/**
|
||
* Returns the "bounding client rect" of given element
|
||
* @param {HTMLElement} el The element whose boundingClientRect is wanted
|
||
* @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
|
||
* @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
|
||
* @param {[Boolean]} undoScale Whether the container's scale() should be undone
|
||
* @param {[HTMLElement]} container The parent the element will be placed in
|
||
* @return {Object} The boundingClientRect of el, with specified adjustments
|
||
*/ function $64afbd09cd65a300$var$getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
|
||
if (!el.getBoundingClientRect && el !== window) return;
|
||
var elRect, top, left, bottom, right, height, width;
|
||
if (el !== window && el.parentNode && el !== $64afbd09cd65a300$var$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 (!$64afbd09cd65a300$var$IE11OrLess) {
|
||
do if (container && container.getBoundingClientRect && ($64afbd09cd65a300$var$css(container, "transform") !== "none" || relativeToNonStaticParent && $64afbd09cd65a300$var$css(container, "position") !== "static")) {
|
||
var containerRect = container.getBoundingClientRect(); // Set relative to edges of padding box of container
|
||
top -= containerRect.top + parseInt($64afbd09cd65a300$var$css(container, "border-top-width"));
|
||
left -= containerRect.left + parseInt($64afbd09cd65a300$var$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 = $64afbd09cd65a300$var$matrix(container || el), scaleX = elMatrix && elMatrix.a, scaleY = elMatrix && elMatrix.d;
|
||
if (elMatrix) {
|
||
top /= scaleY;
|
||
left /= scaleX;
|
||
width /= scaleX;
|
||
height /= scaleY;
|
||
bottom = top + height;
|
||
right = left + width;
|
||
}
|
||
}
|
||
return {
|
||
top: top,
|
||
left: left,
|
||
bottom: bottom,
|
||
right: right,
|
||
width: width,
|
||
height: height
|
||
};
|
||
}
|
||
/**
|
||
* Checks if a side of an element is scrolled past a side of its parents
|
||
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
|
||
* @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
|
||
* @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
|
||
* @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
|
||
*/ function $64afbd09cd65a300$var$isScrolledPast(el, elSide, parentSide) {
|
||
var parent = $64afbd09cd65a300$var$getParentAutoScrollElement(el, true), elSideVal = $64afbd09cd65a300$var$getRect(el)[elSide];
|
||
/* jshint boss:true */ while(parent){
|
||
var parentSideVal = $64afbd09cd65a300$var$getRect(parent)[parentSide], visible = void 0;
|
||
if (parentSide === "top" || parentSide === "left") visible = elSideVal >= parentSideVal;
|
||
else visible = elSideVal <= parentSideVal;
|
||
if (!visible) return parent;
|
||
if (parent === $64afbd09cd65a300$var$getWindowScrollingElement()) break;
|
||
parent = $64afbd09cd65a300$var$getParentAutoScrollElement(parent, false);
|
||
}
|
||
return false;
|
||
}
|
||
/**
|
||
* Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
|
||
* and non-draggable elements
|
||
* @param {HTMLElement} el The parent element
|
||
* @param {Number} childNum The index of the child
|
||
* @param {Object} options Parent Sortable's options
|
||
* @return {HTMLElement} The child at index childNum, or null if not found
|
||
*/ function $64afbd09cd65a300$var$getChild(el, childNum, options, includeDragEl) {
|
||
var currentChild = 0, i = 0, children = el.children;
|
||
while(i < children.length){
|
||
if (children[i].style.display !== "none" && children[i] !== $64afbd09cd65a300$export$31b3ca70d8f57423.ghost && (includeDragEl || children[i] !== $64afbd09cd65a300$export$31b3ca70d8f57423.dragged) && $64afbd09cd65a300$var$closest(children[i], options.draggable, el, false)) {
|
||
if (currentChild === childNum) return children[i];
|
||
currentChild++;
|
||
}
|
||
i++;
|
||
}
|
||
return null;
|
||
}
|
||
/**
|
||
* Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
|
||
* @param {HTMLElement} el Parent element
|
||
* @param {selector} selector Any other elements that should be ignored
|
||
* @return {HTMLElement} The last child, ignoring ghostEl
|
||
*/ function $64afbd09cd65a300$var$lastChild(el, selector) {
|
||
var last = el.lastElementChild;
|
||
while(last && (last === $64afbd09cd65a300$export$31b3ca70d8f57423.ghost || $64afbd09cd65a300$var$css(last, "display") === "none" || selector && !$64afbd09cd65a300$var$matches(last, selector)))last = last.previousElementSibling;
|
||
return last || null;
|
||
}
|
||
/**
|
||
* Returns the index of an element within its parent for a selected set of
|
||
* elements
|
||
* @param {HTMLElement} el
|
||
* @param {selector} selector
|
||
* @return {number}
|
||
*/ function $64afbd09cd65a300$var$index(el, selector) {
|
||
var index = 0;
|
||
if (!el || !el.parentNode) return -1;
|
||
/* jshint boss:true */ while(el = el.previousElementSibling)if (el.nodeName.toUpperCase() !== "TEMPLATE" && el !== $64afbd09cd65a300$export$31b3ca70d8f57423.clone && (!selector || $64afbd09cd65a300$var$matches(el, selector))) index++;
|
||
return index;
|
||
}
|
||
/**
|
||
* Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
|
||
* The value is returned in real pixels.
|
||
* @param {HTMLElement} el
|
||
* @return {Array} Offsets in the format of [left, top]
|
||
*/ function $64afbd09cd65a300$var$getRelativeScrollOffset(el) {
|
||
var offsetLeft = 0, offsetTop = 0, winScroller = $64afbd09cd65a300$var$getWindowScrollingElement();
|
||
if (el) do {
|
||
var elMatrix = $64afbd09cd65a300$var$matrix(el), scaleX = elMatrix.a, scaleY = elMatrix.d;
|
||
offsetLeft += el.scrollLeft * scaleX;
|
||
offsetTop += el.scrollTop * scaleY;
|
||
}while (el !== winScroller && (el = el.parentNode));
|
||
return [
|
||
offsetLeft,
|
||
offsetTop
|
||
];
|
||
}
|
||
/**
|
||
* Returns the index of the object within the given array
|
||
* @param {Array} arr Array that may or may not hold the object
|
||
* @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
|
||
* @return {Number} The index of the object in the array, or -1
|
||
*/ function $64afbd09cd65a300$var$indexOfObject(arr, obj) {
|
||
for(var i in arr){
|
||
if (!arr.hasOwnProperty(i)) continue;
|
||
for(var key in obj){
|
||
if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
function $64afbd09cd65a300$var$getParentAutoScrollElement(el, includeSelf) {
|
||
// skip to window
|
||
if (!el || !el.getBoundingClientRect) return $64afbd09cd65a300$var$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 = $64afbd09cd65a300$var$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 $64afbd09cd65a300$var$getWindowScrollingElement();
|
||
if (gotSelf || includeSelf) return elem;
|
||
gotSelf = true;
|
||
}
|
||
}
|
||
while (elem = elem.parentNode);
|
||
return $64afbd09cd65a300$var$getWindowScrollingElement();
|
||
}
|
||
function $64afbd09cd65a300$var$extend(dst, src) {
|
||
if (dst && src) {
|
||
for(var key in src)if (src.hasOwnProperty(key)) dst[key] = src[key];
|
||
}
|
||
return dst;
|
||
}
|
||
function $64afbd09cd65a300$var$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 $64afbd09cd65a300$var$_throttleTimeout;
|
||
function $64afbd09cd65a300$var$throttle(callback, ms) {
|
||
return function() {
|
||
if (!$64afbd09cd65a300$var$_throttleTimeout) {
|
||
var args = arguments, _this = this;
|
||
if (args.length === 1) callback.call(_this, args[0]);
|
||
else callback.apply(_this, args);
|
||
$64afbd09cd65a300$var$_throttleTimeout = setTimeout(function() {
|
||
$64afbd09cd65a300$var$_throttleTimeout = void 0;
|
||
}, ms);
|
||
}
|
||
};
|
||
}
|
||
function $64afbd09cd65a300$var$cancelThrottle() {
|
||
clearTimeout($64afbd09cd65a300$var$_throttleTimeout);
|
||
$64afbd09cd65a300$var$_throttleTimeout = void 0;
|
||
}
|
||
function $64afbd09cd65a300$var$scrollBy(el, x, y) {
|
||
el.scrollLeft += x;
|
||
el.scrollTop += y;
|
||
}
|
||
function $64afbd09cd65a300$var$clone(el) {
|
||
var Polymer = window.Polymer;
|
||
var $ = window.jQuery || window.Zepto;
|
||
if (Polymer && Polymer.dom) return Polymer.dom(el).cloneNode(true);
|
||
else if ($) return $(el).clone(true)[0];
|
||
else return el.cloneNode(true);
|
||
}
|
||
function $64afbd09cd65a300$var$setRect(el, rect) {
|
||
$64afbd09cd65a300$var$css(el, "position", "absolute");
|
||
$64afbd09cd65a300$var$css(el, "top", rect.top);
|
||
$64afbd09cd65a300$var$css(el, "left", rect.left);
|
||
$64afbd09cd65a300$var$css(el, "width", rect.width);
|
||
$64afbd09cd65a300$var$css(el, "height", rect.height);
|
||
}
|
||
function $64afbd09cd65a300$var$unsetRect(el) {
|
||
$64afbd09cd65a300$var$css(el, "position", "");
|
||
$64afbd09cd65a300$var$css(el, "top", "");
|
||
$64afbd09cd65a300$var$css(el, "left", "");
|
||
$64afbd09cd65a300$var$css(el, "width", "");
|
||
$64afbd09cd65a300$var$css(el, "height", "");
|
||
}
|
||
var $64afbd09cd65a300$var$expando = "Sortable" + new Date().getTime();
|
||
function $64afbd09cd65a300$var$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 ($64afbd09cd65a300$var$css(child, "display") === "none" || child === $64afbd09cd65a300$export$31b3ca70d8f57423.ghost) return;
|
||
animationStates.push({
|
||
target: child,
|
||
rect: $64afbd09cd65a300$var$getRect(child)
|
||
});
|
||
var fromRect = $64afbd09cd65a300$var$_objectSpread2({}, animationStates[animationStates.length - 1].rect); // If animating: compensate for current animation
|
||
if (child.thisAnimationDuration) {
|
||
var childMatrix = $64afbd09cd65a300$var$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($64afbd09cd65a300$var$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 = $64afbd09cd65a300$var$getRect(target), prevFromRect = target.prevFromRect, prevToRect = target.prevToRect, animatingRect = state.rect, targetMatrix = $64afbd09cd65a300$var$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 ($64afbd09cd65a300$var$isRectEqual(prevFromRect, toRect) && !$64afbd09cd65a300$var$isRectEqual(fromRect, toRect) && // Make sure animatingRect is on line between toRect & fromRect
|
||
(animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) // If returning to same place as started from animation and on same axis
|
||
time = $64afbd09cd65a300$var$calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
|
||
} // if fromRect != toRect: animate
|
||
if (!$64afbd09cd65a300$var$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) {
|
||
$64afbd09cd65a300$var$css(target, "transition", "");
|
||
$64afbd09cd65a300$var$css(target, "transform", "");
|
||
var elMatrix = $64afbd09cd65a300$var$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;
|
||
$64afbd09cd65a300$var$css(target, "transform", "translate3d(" + translateX + "px," + translateY + "px,0)");
|
||
this.forRepaintDummy = $64afbd09cd65a300$var$repaint(target); // repaint
|
||
$64afbd09cd65a300$var$css(target, "transition", "transform " + duration + "ms" + (this.options.easing ? " " + this.options.easing : ""));
|
||
$64afbd09cd65a300$var$css(target, "transform", "translate3d(0,0,0)");
|
||
typeof target.animated === "number" && clearTimeout(target.animated);
|
||
target.animated = setTimeout(function() {
|
||
$64afbd09cd65a300$var$css(target, "transition", "");
|
||
$64afbd09cd65a300$var$css(target, "transform", "");
|
||
target.animated = false;
|
||
target.animatingX = false;
|
||
target.animatingY = false;
|
||
}, duration);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function $64afbd09cd65a300$var$repaint(target) {
|
||
return target.offsetWidth;
|
||
}
|
||
function $64afbd09cd65a300$var$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 $64afbd09cd65a300$var$plugins = [];
|
||
var $64afbd09cd65a300$var$defaults = {
|
||
initializeByDefault: true
|
||
};
|
||
var $64afbd09cd65a300$var$PluginManager = {
|
||
mount: function mount(plugin) {
|
||
// Set default static properties
|
||
for(var option in $64afbd09cd65a300$var$defaults)if ($64afbd09cd65a300$var$defaults.hasOwnProperty(option) && !(option in plugin)) plugin[option] = $64afbd09cd65a300$var$defaults[option];
|
||
$64afbd09cd65a300$var$plugins.forEach(function(p) {
|
||
if (p.pluginName === plugin.pluginName) throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
|
||
});
|
||
$64afbd09cd65a300$var$plugins.push(plugin);
|
||
},
|
||
pluginEvent: function pluginEvent(eventName, sortable, evt) {
|
||
var _this = this;
|
||
this.eventCanceled = false;
|
||
evt.cancel = function() {
|
||
_this.eventCanceled = true;
|
||
};
|
||
var eventNameGlobal = eventName + "Global";
|
||
$64afbd09cd65a300$var$plugins.forEach(function(plugin) {
|
||
if (!sortable[plugin.pluginName]) return; // Fire global events if it exists in this sortable
|
||
if (sortable[plugin.pluginName][eventNameGlobal]) sortable[plugin.pluginName][eventNameGlobal]($64afbd09cd65a300$var$_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]($64afbd09cd65a300$var$_objectSpread2({
|
||
sortable: sortable
|
||
}, evt));
|
||
});
|
||
},
|
||
initializePlugins: function initializePlugins(sortable, el, defaults, options) {
|
||
$64afbd09cd65a300$var$plugins.forEach(function(plugin) {
|
||
var pluginName = plugin.pluginName;
|
||
if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
|
||
var initialized = new plugin(sortable, el, sortable.options);
|
||
initialized.sortable = sortable;
|
||
initialized.options = sortable.options;
|
||
sortable[pluginName] = initialized; // Add default options from plugin
|
||
$64afbd09cd65a300$var$_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 = {};
|
||
$64afbd09cd65a300$var$plugins.forEach(function(plugin) {
|
||
if (typeof plugin.eventProperties !== "function") return;
|
||
$64afbd09cd65a300$var$_extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
|
||
});
|
||
return eventProperties;
|
||
},
|
||
modifyOption: function modifyOption(sortable, name, value) {
|
||
var modifiedValue;
|
||
$64afbd09cd65a300$var$plugins.forEach(function(plugin) {
|
||
// Plugin must exist on the Sortable
|
||
if (!sortable[plugin.pluginName]) return; // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
|
||
if (plugin.optionListeners && typeof plugin.optionListeners[name] === "function") modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
|
||
});
|
||
return modifiedValue;
|
||
}
|
||
};
|
||
function $64afbd09cd65a300$var$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[$64afbd09cd65a300$var$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 && !$64afbd09cd65a300$var$IE11OrLess && !$64afbd09cd65a300$var$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 = $64afbd09cd65a300$var$_objectSpread2($64afbd09cd65a300$var$_objectSpread2({}, extraEventProperties), $64afbd09cd65a300$var$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 $64afbd09cd65a300$var$_excluded = [
|
||
"evt"
|
||
];
|
||
var $64afbd09cd65a300$var$pluginEvent = function pluginEvent(eventName, sortable) {
|
||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, originalEvent = _ref.evt, data = $64afbd09cd65a300$var$_objectWithoutProperties(_ref, $64afbd09cd65a300$var$_excluded);
|
||
$64afbd09cd65a300$var$PluginManager.pluginEvent.bind($64afbd09cd65a300$export$31b3ca70d8f57423)(eventName, sortable, $64afbd09cd65a300$var$_objectSpread2({
|
||
dragEl: $64afbd09cd65a300$var$dragEl,
|
||
parentEl: $64afbd09cd65a300$var$parentEl,
|
||
ghostEl: $64afbd09cd65a300$var$ghostEl,
|
||
rootEl: $64afbd09cd65a300$var$rootEl,
|
||
nextEl: $64afbd09cd65a300$var$nextEl,
|
||
lastDownEl: $64afbd09cd65a300$var$lastDownEl,
|
||
cloneEl: $64afbd09cd65a300$var$cloneEl,
|
||
cloneHidden: $64afbd09cd65a300$var$cloneHidden,
|
||
dragStarted: $64afbd09cd65a300$var$moved,
|
||
putSortable: $64afbd09cd65a300$var$putSortable,
|
||
activeSortable: $64afbd09cd65a300$export$31b3ca70d8f57423.active,
|
||
originalEvent: originalEvent,
|
||
oldIndex: $64afbd09cd65a300$var$oldIndex,
|
||
oldDraggableIndex: $64afbd09cd65a300$var$oldDraggableIndex,
|
||
newIndex: $64afbd09cd65a300$var$newIndex,
|
||
newDraggableIndex: $64afbd09cd65a300$var$newDraggableIndex,
|
||
hideGhostForTarget: $64afbd09cd65a300$var$_hideGhostForTarget,
|
||
unhideGhostForTarget: $64afbd09cd65a300$var$_unhideGhostForTarget,
|
||
cloneNowHidden: function cloneNowHidden() {
|
||
$64afbd09cd65a300$var$cloneHidden = true;
|
||
},
|
||
cloneNowShown: function cloneNowShown() {
|
||
$64afbd09cd65a300$var$cloneHidden = false;
|
||
},
|
||
dispatchSortableEvent: function dispatchSortableEvent(name) {
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: sortable,
|
||
name: name,
|
||
originalEvent: originalEvent
|
||
});
|
||
}
|
||
}, data));
|
||
};
|
||
function $64afbd09cd65a300$var$_dispatchEvent(info) {
|
||
$64afbd09cd65a300$var$dispatchEvent($64afbd09cd65a300$var$_objectSpread2({
|
||
putSortable: $64afbd09cd65a300$var$putSortable,
|
||
cloneEl: $64afbd09cd65a300$var$cloneEl,
|
||
targetEl: $64afbd09cd65a300$var$dragEl,
|
||
rootEl: $64afbd09cd65a300$var$rootEl,
|
||
oldIndex: $64afbd09cd65a300$var$oldIndex,
|
||
oldDraggableIndex: $64afbd09cd65a300$var$oldDraggableIndex,
|
||
newIndex: $64afbd09cd65a300$var$newIndex,
|
||
newDraggableIndex: $64afbd09cd65a300$var$newDraggableIndex
|
||
}, info));
|
||
}
|
||
var $64afbd09cd65a300$var$dragEl, $64afbd09cd65a300$var$parentEl, $64afbd09cd65a300$var$ghostEl, $64afbd09cd65a300$var$rootEl, $64afbd09cd65a300$var$nextEl, $64afbd09cd65a300$var$lastDownEl, $64afbd09cd65a300$var$cloneEl, $64afbd09cd65a300$var$cloneHidden, $64afbd09cd65a300$var$oldIndex, $64afbd09cd65a300$var$newIndex, $64afbd09cd65a300$var$oldDraggableIndex, $64afbd09cd65a300$var$newDraggableIndex, $64afbd09cd65a300$var$activeGroup, $64afbd09cd65a300$var$putSortable, $64afbd09cd65a300$var$awaitingDragStarted = false, $64afbd09cd65a300$var$ignoreNextClick = false, $64afbd09cd65a300$var$sortables = [], $64afbd09cd65a300$var$tapEvt, $64afbd09cd65a300$var$touchEvt, $64afbd09cd65a300$var$lastDx, $64afbd09cd65a300$var$lastDy, $64afbd09cd65a300$var$tapDistanceLeft, $64afbd09cd65a300$var$tapDistanceTop, $64afbd09cd65a300$var$moved, $64afbd09cd65a300$var$lastTarget, $64afbd09cd65a300$var$lastDirection, $64afbd09cd65a300$var$pastFirstInvertThresh = false, $64afbd09cd65a300$var$isCircumstantialInvert = false, $64afbd09cd65a300$var$targetMoveDistance, // For positioning ghost absolutely
|
||
$64afbd09cd65a300$var$ghostRelativeParent, $64afbd09cd65a300$var$ghostRelativeParentInitialScroll = [], // (left, top)
|
||
$64afbd09cd65a300$var$_silent = false, $64afbd09cd65a300$var$savedInputChecked = [];
|
||
/** @const */ var $64afbd09cd65a300$var$documentExists = typeof document !== "undefined", $64afbd09cd65a300$var$PositionGhostAbsolutely = $64afbd09cd65a300$var$IOS, $64afbd09cd65a300$var$CSSFloatProperty = $64afbd09cd65a300$var$Edge || $64afbd09cd65a300$var$IE11OrLess ? "cssFloat" : "float", // This will not pass for IE9, because IE9 DnD only works on anchors
|
||
$64afbd09cd65a300$var$supportDraggable = $64afbd09cd65a300$var$documentExists && !$64afbd09cd65a300$var$ChromeForAndroid && !$64afbd09cd65a300$var$IOS && "draggable" in document.createElement("div"), $64afbd09cd65a300$var$supportCssPointerEvents = function() {
|
||
if (!$64afbd09cd65a300$var$documentExists) return; // false when <= IE11
|
||
if ($64afbd09cd65a300$var$IE11OrLess) return false;
|
||
var el = document.createElement("x");
|
||
el.style.cssText = "pointer-events:auto";
|
||
return el.style.pointerEvents === "auto";
|
||
}(), $64afbd09cd65a300$var$_detectDirection = function _detectDirection(el, options) {
|
||
var elCSS = $64afbd09cd65a300$var$css(el), elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth), child1 = $64afbd09cd65a300$var$getChild(el, 0, options), child2 = $64afbd09cd65a300$var$getChild(el, 1, options), firstChildCSS = child1 && $64afbd09cd65a300$var$css(child1), secondChildCSS = child2 && $64afbd09cd65a300$var$css(child2), firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + $64afbd09cd65a300$var$getRect(child1).width, secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + $64afbd09cd65a300$var$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[$64afbd09cd65a300$var$CSSFloatProperty] === "none" || child2 && elCSS[$64afbd09cd65a300$var$CSSFloatProperty] === "none" && firstChildWidth + secondChildWidth > elWidth) ? "vertical" : "horizontal";
|
||
}, $64afbd09cd65a300$var$_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
|
||
*/ $64afbd09cd65a300$var$_detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
|
||
var ret;
|
||
$64afbd09cd65a300$var$sortables.some(function(sortable) {
|
||
var threshold = sortable[$64afbd09cd65a300$var$expando].options.emptyInsertThreshold;
|
||
if (!threshold || $64afbd09cd65a300$var$lastChild(sortable)) return;
|
||
var rect = $64afbd09cd65a300$var$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;
|
||
}, $64afbd09cd65a300$var$_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 || $64afbd09cd65a300$var$_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;
|
||
}, $64afbd09cd65a300$var$_hideGhostForTarget = function _hideGhostForTarget() {
|
||
if (!$64afbd09cd65a300$var$supportCssPointerEvents && $64afbd09cd65a300$var$ghostEl) $64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "display", "none");
|
||
}, $64afbd09cd65a300$var$_unhideGhostForTarget = function _unhideGhostForTarget() {
|
||
if (!$64afbd09cd65a300$var$supportCssPointerEvents && $64afbd09cd65a300$var$ghostEl) $64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "display", "");
|
||
}; // #1184 fix - Prevent click event on fallback if dragged but item not changed position
|
||
if ($64afbd09cd65a300$var$documentExists && !$64afbd09cd65a300$var$ChromeForAndroid) document.addEventListener("click", function(evt) {
|
||
if ($64afbd09cd65a300$var$ignoreNextClick) {
|
||
evt.preventDefault();
|
||
evt.stopPropagation && evt.stopPropagation();
|
||
evt.stopImmediatePropagation && evt.stopImmediatePropagation();
|
||
$64afbd09cd65a300$var$ignoreNextClick = false;
|
||
return false;
|
||
}
|
||
}, true);
|
||
var $64afbd09cd65a300$var$nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
|
||
if ($64afbd09cd65a300$var$dragEl) {
|
||
evt = evt.touches ? evt.touches[0] : evt;
|
||
var nearest = $64afbd09cd65a300$var$_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[$64afbd09cd65a300$var$expando]._onDragOver(event);
|
||
}
|
||
}
|
||
};
|
||
var $64afbd09cd65a300$var$_checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
|
||
if ($64afbd09cd65a300$var$dragEl) $64afbd09cd65a300$var$dragEl.parentNode[$64afbd09cd65a300$var$expando]._isOutsideThisEl(evt.target);
|
||
};
|
||
/**
|
||
* @class Sortable
|
||
* @param {HTMLElement} el
|
||
* @param {Object} [options]
|
||
*/ function $64afbd09cd65a300$export$31b3ca70d8f57423(el, options) {
|
||
if (!(el && el.nodeType && el.nodeType === 1)) throw "Sortable: `el` must be an HTMLElement, not ".concat(({}).toString.call(el));
|
||
this.el = el; // root element
|
||
this.options = options = $64afbd09cd65a300$var$_extends({}, options); // Export instance
|
||
el[$64afbd09cd65a300$var$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 $64afbd09cd65a300$var$_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: $64afbd09cd65a300$export$31b3ca70d8f57423.supportPointer !== false && "PointerEvent" in window && !$64afbd09cd65a300$var$Safari,
|
||
emptyInsertThreshold: 5
|
||
};
|
||
$64afbd09cd65a300$var$PluginManager.initializePlugins(this, el, defaults); // Set default options
|
||
for(var name in defaults)!(name in options) && (options[name] = defaults[name]);
|
||
$64afbd09cd65a300$var$_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 : $64afbd09cd65a300$var$supportDraggable;
|
||
if (this.nativeDraggable) // Touch start threshold cannot be greater than the native dragstart threshold
|
||
this.options.touchStartThreshold = 1;
|
||
// Bind events
|
||
if (options.supportPointer) $64afbd09cd65a300$var$on(el, "pointerdown", this._onTapStart);
|
||
else {
|
||
$64afbd09cd65a300$var$on(el, "mousedown", this._onTapStart);
|
||
$64afbd09cd65a300$var$on(el, "touchstart", this._onTapStart);
|
||
}
|
||
if (this.nativeDraggable) {
|
||
$64afbd09cd65a300$var$on(el, "dragover", this);
|
||
$64afbd09cd65a300$var$on(el, "dragenter", this);
|
||
}
|
||
$64afbd09cd65a300$var$sortables.push(this.el); // Restore sorting
|
||
options.store && options.store.get && this.sort(options.store.get(this) || []); // Add animation state manager
|
||
$64afbd09cd65a300$var$_extends(this, $64afbd09cd65a300$var$AnimationStateManager());
|
||
}
|
||
$64afbd09cd65a300$export$31b3ca70d8f57423.prototype = /** @lends Sortable.prototype */ {
|
||
constructor: $64afbd09cd65a300$export$31b3ca70d8f57423,
|
||
_isOutsideThisEl: function _isOutsideThisEl(target) {
|
||
if (!this.el.contains(target) && target !== this.el) $64afbd09cd65a300$var$lastTarget = null;
|
||
},
|
||
_getDirection: function _getDirection(evt, target) {
|
||
return typeof this.options.direction === "function" ? this.options.direction.call(this, evt, target, $64afbd09cd65a300$var$dragEl) : this.options.direction;
|
||
},
|
||
_onTapStart: function _onTapStart(/** Event|TouchEvent */ evt) {
|
||
if (!evt.cancelable) return;
|
||
var _this = this, el = this.el, options = this.options, preventOnFilter = options.preventOnFilter, type = evt.type, touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === "touch" && evt, target = (touch || evt).target, originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target, filter = options.filter;
|
||
$64afbd09cd65a300$var$_saveInputCheckedState(el); // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
|
||
if ($64afbd09cd65a300$var$dragEl) return;
|
||
if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) return; // only left button and enabled
|
||
// cancel dnd if original target is content editable
|
||
if (originalTarget.isContentEditable) return;
|
||
// Safari ignores further event handling after mousedown
|
||
if (!this.nativeDraggable && $64afbd09cd65a300$var$Safari && target && target.tagName.toUpperCase() === "SELECT") return;
|
||
target = $64afbd09cd65a300$var$closest(target, options.draggable, el, false);
|
||
if (target && target.animated) return;
|
||
if ($64afbd09cd65a300$var$lastDownEl === target) // Ignoring duplicate `down`
|
||
return;
|
||
// Get the index of the dragged element within its parent
|
||
$64afbd09cd65a300$var$oldIndex = $64afbd09cd65a300$var$index(target);
|
||
$64afbd09cd65a300$var$oldDraggableIndex = $64afbd09cd65a300$var$index(target, options.draggable); // Check filter
|
||
if (typeof filter === "function") {
|
||
if (filter.call(this, evt, target, this)) {
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: _this,
|
||
rootEl: originalTarget,
|
||
name: "filter",
|
||
targetEl: target,
|
||
toEl: el,
|
||
fromEl: el
|
||
});
|
||
$64afbd09cd65a300$var$pluginEvent("filter", _this, {
|
||
evt: evt
|
||
});
|
||
preventOnFilter && evt.cancelable && evt.preventDefault();
|
||
return; // cancel dnd
|
||
}
|
||
} else if (filter) {
|
||
filter = filter.split(",").some(function(criteria) {
|
||
criteria = $64afbd09cd65a300$var$closest(originalTarget, criteria.trim(), el, false);
|
||
if (criteria) {
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: _this,
|
||
rootEl: criteria,
|
||
name: "filter",
|
||
targetEl: target,
|
||
fromEl: el,
|
||
toEl: el
|
||
});
|
||
$64afbd09cd65a300$var$pluginEvent("filter", _this, {
|
||
evt: evt
|
||
});
|
||
return true;
|
||
}
|
||
});
|
||
if (filter) {
|
||
preventOnFilter && evt.cancelable && evt.preventDefault();
|
||
return; // cancel dnd
|
||
}
|
||
}
|
||
if (options.handle && !$64afbd09cd65a300$var$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 && !$64afbd09cd65a300$var$dragEl && target.parentNode === el) {
|
||
var dragRect = $64afbd09cd65a300$var$getRect(target);
|
||
$64afbd09cd65a300$var$rootEl = el;
|
||
$64afbd09cd65a300$var$dragEl = target;
|
||
$64afbd09cd65a300$var$parentEl = $64afbd09cd65a300$var$dragEl.parentNode;
|
||
$64afbd09cd65a300$var$nextEl = $64afbd09cd65a300$var$dragEl.nextSibling;
|
||
$64afbd09cd65a300$var$lastDownEl = target;
|
||
$64afbd09cd65a300$var$activeGroup = options.group;
|
||
$64afbd09cd65a300$export$31b3ca70d8f57423.dragged = $64afbd09cd65a300$var$dragEl;
|
||
$64afbd09cd65a300$var$tapEvt = {
|
||
target: $64afbd09cd65a300$var$dragEl,
|
||
clientX: (touch || evt).clientX,
|
||
clientY: (touch || evt).clientY
|
||
};
|
||
$64afbd09cd65a300$var$tapDistanceLeft = $64afbd09cd65a300$var$tapEvt.clientX - dragRect.left;
|
||
$64afbd09cd65a300$var$tapDistanceTop = $64afbd09cd65a300$var$tapEvt.clientY - dragRect.top;
|
||
this._lastX = (touch || evt).clientX;
|
||
this._lastY = (touch || evt).clientY;
|
||
$64afbd09cd65a300$var$dragEl.style["will-change"] = "all";
|
||
dragStartFn = function dragStartFn() {
|
||
$64afbd09cd65a300$var$pluginEvent("delayEnded", _this, {
|
||
evt: evt
|
||
});
|
||
if ($64afbd09cd65a300$export$31b3ca70d8f57423.eventCanceled) {
|
||
_this._onDrop();
|
||
return;
|
||
} // Delayed drag has been triggered
|
||
// we can re-enable the events: touchmove/mousemove
|
||
_this._disableDelayedDragEvents();
|
||
if (!$64afbd09cd65a300$var$FireFox && _this.nativeDraggable) $64afbd09cd65a300$var$dragEl.draggable = true;
|
||
// Bind the events: dragstart/dragend
|
||
_this._triggerDragStart(evt, touch); // Drag start event
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: _this,
|
||
name: "choose",
|
||
originalEvent: evt
|
||
}); // Chosen item
|
||
$64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$dragEl, options.chosenClass, true);
|
||
}; // Disable "draggable"
|
||
options.ignore.split(",").forEach(function(criteria) {
|
||
$64afbd09cd65a300$var$find($64afbd09cd65a300$var$dragEl, criteria.trim(), $64afbd09cd65a300$var$_disableDraggable);
|
||
});
|
||
$64afbd09cd65a300$var$on(ownerDocument, "dragover", $64afbd09cd65a300$var$nearestEmptyInsertDetectEvent);
|
||
$64afbd09cd65a300$var$on(ownerDocument, "mousemove", $64afbd09cd65a300$var$nearestEmptyInsertDetectEvent);
|
||
$64afbd09cd65a300$var$on(ownerDocument, "touchmove", $64afbd09cd65a300$var$nearestEmptyInsertDetectEvent);
|
||
$64afbd09cd65a300$var$on(ownerDocument, "mouseup", _this._onDrop);
|
||
$64afbd09cd65a300$var$on(ownerDocument, "touchend", _this._onDrop);
|
||
$64afbd09cd65a300$var$on(ownerDocument, "touchcancel", _this._onDrop); // Make dragEl draggable (must be before delay for FireFox)
|
||
if ($64afbd09cd65a300$var$FireFox && this.nativeDraggable) {
|
||
this.options.touchStartThreshold = 4;
|
||
$64afbd09cd65a300$var$dragEl.draggable = true;
|
||
}
|
||
$64afbd09cd65a300$var$pluginEvent("delayStart", this, {
|
||
evt: evt
|
||
}); // Delay is impossible for native DnD in Edge or IE
|
||
if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !($64afbd09cd65a300$var$Edge || $64afbd09cd65a300$var$IE11OrLess))) {
|
||
if ($64afbd09cd65a300$export$31b3ca70d8f57423.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
|
||
$64afbd09cd65a300$var$on(ownerDocument, "mouseup", _this._disableDelayedDrag);
|
||
$64afbd09cd65a300$var$on(ownerDocument, "touchend", _this._disableDelayedDrag);
|
||
$64afbd09cd65a300$var$on(ownerDocument, "touchcancel", _this._disableDelayedDrag);
|
||
$64afbd09cd65a300$var$on(ownerDocument, "mousemove", _this._delayedDragTouchMoveHandler);
|
||
$64afbd09cd65a300$var$on(ownerDocument, "touchmove", _this._delayedDragTouchMoveHandler);
|
||
options.supportPointer && $64afbd09cd65a300$var$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() {
|
||
$64afbd09cd65a300$var$dragEl && $64afbd09cd65a300$var$_disableDraggable($64afbd09cd65a300$var$dragEl);
|
||
clearTimeout(this._dragStartTimer);
|
||
this._disableDelayedDragEvents();
|
||
},
|
||
_disableDelayedDragEvents: function _disableDelayedDragEvents() {
|
||
var ownerDocument = this.el.ownerDocument;
|
||
$64afbd09cd65a300$var$off(ownerDocument, "mouseup", this._disableDelayedDrag);
|
||
$64afbd09cd65a300$var$off(ownerDocument, "touchend", this._disableDelayedDrag);
|
||
$64afbd09cd65a300$var$off(ownerDocument, "touchcancel", this._disableDelayedDrag);
|
||
$64afbd09cd65a300$var$off(ownerDocument, "mousemove", this._delayedDragTouchMoveHandler);
|
||
$64afbd09cd65a300$var$off(ownerDocument, "touchmove", this._delayedDragTouchMoveHandler);
|
||
$64afbd09cd65a300$var$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) $64afbd09cd65a300$var$on(document, "pointermove", this._onTouchMove);
|
||
else if (touch) $64afbd09cd65a300$var$on(document, "touchmove", this._onTouchMove);
|
||
else $64afbd09cd65a300$var$on(document, "mousemove", this._onTouchMove);
|
||
} else {
|
||
$64afbd09cd65a300$var$on($64afbd09cd65a300$var$dragEl, "dragend", this);
|
||
$64afbd09cd65a300$var$on($64afbd09cd65a300$var$rootEl, "dragstart", this._onDragStart);
|
||
}
|
||
try {
|
||
if (document.selection) // Timeout neccessary for IE9
|
||
$64afbd09cd65a300$var$_nextTick(function() {
|
||
document.selection.empty();
|
||
});
|
||
else window.getSelection().removeAllRanges();
|
||
} catch (err) {}
|
||
},
|
||
_dragStarted: function _dragStarted(fallback, evt) {
|
||
$64afbd09cd65a300$var$awaitingDragStarted = false;
|
||
if ($64afbd09cd65a300$var$rootEl && $64afbd09cd65a300$var$dragEl) {
|
||
$64afbd09cd65a300$var$pluginEvent("dragStarted", this, {
|
||
evt: evt
|
||
});
|
||
if (this.nativeDraggable) $64afbd09cd65a300$var$on(document, "dragover", $64afbd09cd65a300$var$_checkOutsideTargetEl);
|
||
var options = this.options; // Apply effect
|
||
!fallback && $64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$dragEl, options.dragClass, false);
|
||
$64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$dragEl, options.ghostClass, true);
|
||
$64afbd09cd65a300$export$31b3ca70d8f57423.active = this;
|
||
fallback && this._appendGhost(); // Drag start event
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: this,
|
||
name: "start",
|
||
originalEvent: evt
|
||
});
|
||
} else this._nulling();
|
||
},
|
||
_emulateDragOver: function _emulateDragOver() {
|
||
if ($64afbd09cd65a300$var$touchEvt) {
|
||
this._lastX = $64afbd09cd65a300$var$touchEvt.clientX;
|
||
this._lastY = $64afbd09cd65a300$var$touchEvt.clientY;
|
||
$64afbd09cd65a300$var$_hideGhostForTarget();
|
||
var target = document.elementFromPoint($64afbd09cd65a300$var$touchEvt.clientX, $64afbd09cd65a300$var$touchEvt.clientY);
|
||
var parent = target;
|
||
while(target && target.shadowRoot){
|
||
target = target.shadowRoot.elementFromPoint($64afbd09cd65a300$var$touchEvt.clientX, $64afbd09cd65a300$var$touchEvt.clientY);
|
||
if (target === parent) break;
|
||
parent = target;
|
||
}
|
||
$64afbd09cd65a300$var$dragEl.parentNode[$64afbd09cd65a300$var$expando]._isOutsideThisEl(target);
|
||
if (parent) do {
|
||
if (parent[$64afbd09cd65a300$var$expando]) {
|
||
var inserted = void 0;
|
||
inserted = parent[$64afbd09cd65a300$var$expando]._onDragOver({
|
||
clientX: $64afbd09cd65a300$var$touchEvt.clientX,
|
||
clientY: $64afbd09cd65a300$var$touchEvt.clientY,
|
||
target: target,
|
||
rootEl: parent
|
||
});
|
||
if (inserted && !this.options.dragoverBubble) break;
|
||
}
|
||
target = parent; // store last element
|
||
}while (parent = parent.parentNode);
|
||
$64afbd09cd65a300$var$_unhideGhostForTarget();
|
||
}
|
||
},
|
||
_onTouchMove: function _onTouchMove(/**TouchEvent*/ evt) {
|
||
if ($64afbd09cd65a300$var$tapEvt) {
|
||
var options = this.options, fallbackTolerance = options.fallbackTolerance, fallbackOffset = options.fallbackOffset, touch = evt.touches ? evt.touches[0] : evt, ghostMatrix = $64afbd09cd65a300$var$ghostEl && $64afbd09cd65a300$var$matrix($64afbd09cd65a300$var$ghostEl, true), scaleX = $64afbd09cd65a300$var$ghostEl && ghostMatrix && ghostMatrix.a, scaleY = $64afbd09cd65a300$var$ghostEl && ghostMatrix && ghostMatrix.d, relativeScrollOffset = $64afbd09cd65a300$var$PositionGhostAbsolutely && $64afbd09cd65a300$var$ghostRelativeParent && $64afbd09cd65a300$var$getRelativeScrollOffset($64afbd09cd65a300$var$ghostRelativeParent), dx = (touch.clientX - $64afbd09cd65a300$var$tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - $64afbd09cd65a300$var$ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1), dy = (touch.clientY - $64afbd09cd65a300$var$tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - $64afbd09cd65a300$var$ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1); // only set the status to dragging, when we are actually dragging
|
||
if (!$64afbd09cd65a300$export$31b3ca70d8f57423.active && !$64afbd09cd65a300$var$awaitingDragStarted) {
|
||
if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) return;
|
||
this._onDragStart(evt, true);
|
||
}
|
||
if ($64afbd09cd65a300$var$ghostEl) {
|
||
if (ghostMatrix) {
|
||
ghostMatrix.e += dx - ($64afbd09cd65a300$var$lastDx || 0);
|
||
ghostMatrix.f += dy - ($64afbd09cd65a300$var$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, ")");
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "webkitTransform", cssMatrix);
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "mozTransform", cssMatrix);
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "msTransform", cssMatrix);
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "transform", cssMatrix);
|
||
$64afbd09cd65a300$var$lastDx = dx;
|
||
$64afbd09cd65a300$var$lastDy = dy;
|
||
$64afbd09cd65a300$var$touchEvt = touch;
|
||
}
|
||
evt.cancelable && evt.preventDefault();
|
||
}
|
||
},
|
||
_appendGhost: function _appendGhost() {
|
||
// Bug if using scale(): https://stackoverflow.com/questions/2637058
|
||
// Not being adjusted for
|
||
if (!$64afbd09cd65a300$var$ghostEl) {
|
||
var container = this.options.fallbackOnBody ? document.body : $64afbd09cd65a300$var$rootEl, rect = $64afbd09cd65a300$var$getRect($64afbd09cd65a300$var$dragEl, true, $64afbd09cd65a300$var$PositionGhostAbsolutely, true, container), options = this.options; // Position absolutely
|
||
if ($64afbd09cd65a300$var$PositionGhostAbsolutely) {
|
||
// Get relatively positioned parent
|
||
$64afbd09cd65a300$var$ghostRelativeParent = container;
|
||
while($64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostRelativeParent, "position") === "static" && $64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostRelativeParent, "transform") === "none" && $64afbd09cd65a300$var$ghostRelativeParent !== document)$64afbd09cd65a300$var$ghostRelativeParent = $64afbd09cd65a300$var$ghostRelativeParent.parentNode;
|
||
if ($64afbd09cd65a300$var$ghostRelativeParent !== document.body && $64afbd09cd65a300$var$ghostRelativeParent !== document.documentElement) {
|
||
if ($64afbd09cd65a300$var$ghostRelativeParent === document) $64afbd09cd65a300$var$ghostRelativeParent = $64afbd09cd65a300$var$getWindowScrollingElement();
|
||
rect.top += $64afbd09cd65a300$var$ghostRelativeParent.scrollTop;
|
||
rect.left += $64afbd09cd65a300$var$ghostRelativeParent.scrollLeft;
|
||
} else $64afbd09cd65a300$var$ghostRelativeParent = $64afbd09cd65a300$var$getWindowScrollingElement();
|
||
$64afbd09cd65a300$var$ghostRelativeParentInitialScroll = $64afbd09cd65a300$var$getRelativeScrollOffset($64afbd09cd65a300$var$ghostRelativeParent);
|
||
}
|
||
$64afbd09cd65a300$var$ghostEl = $64afbd09cd65a300$var$dragEl.cloneNode(true);
|
||
$64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$ghostEl, options.ghostClass, false);
|
||
$64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$ghostEl, options.fallbackClass, true);
|
||
$64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$ghostEl, options.dragClass, true);
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "transition", "");
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "transform", "");
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "box-sizing", "border-box");
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "margin", 0);
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "top", rect.top);
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "left", rect.left);
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "width", rect.width);
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "height", rect.height);
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "opacity", "0.8");
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "position", $64afbd09cd65a300$var$PositionGhostAbsolutely ? "absolute" : "fixed");
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "zIndex", "100000");
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "pointerEvents", "none");
|
||
$64afbd09cd65a300$export$31b3ca70d8f57423.ghost = $64afbd09cd65a300$var$ghostEl;
|
||
container.appendChild($64afbd09cd65a300$var$ghostEl); // Set transform-origin
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$ghostEl, "transform-origin", $64afbd09cd65a300$var$tapDistanceLeft / parseInt($64afbd09cd65a300$var$ghostEl.style.width) * 100 + "% " + $64afbd09cd65a300$var$tapDistanceTop / parseInt($64afbd09cd65a300$var$ghostEl.style.height) * 100 + "%");
|
||
}
|
||
},
|
||
_onDragStart: function _onDragStart(/**Event*/ evt, /**boolean*/ fallback) {
|
||
var _this = this;
|
||
var dataTransfer = evt.dataTransfer;
|
||
var options = _this.options;
|
||
$64afbd09cd65a300$var$pluginEvent("dragStart", this, {
|
||
evt: evt
|
||
});
|
||
if ($64afbd09cd65a300$export$31b3ca70d8f57423.eventCanceled) {
|
||
this._onDrop();
|
||
return;
|
||
}
|
||
$64afbd09cd65a300$var$pluginEvent("setupClone", this);
|
||
if (!$64afbd09cd65a300$export$31b3ca70d8f57423.eventCanceled) {
|
||
$64afbd09cd65a300$var$cloneEl = $64afbd09cd65a300$var$clone($64afbd09cd65a300$var$dragEl);
|
||
$64afbd09cd65a300$var$cloneEl.removeAttribute("id");
|
||
$64afbd09cd65a300$var$cloneEl.draggable = false;
|
||
$64afbd09cd65a300$var$cloneEl.style["will-change"] = "";
|
||
this._hideClone();
|
||
$64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$cloneEl, this.options.chosenClass, false);
|
||
$64afbd09cd65a300$export$31b3ca70d8f57423.clone = $64afbd09cd65a300$var$cloneEl;
|
||
} // #1143: IFrame support workaround
|
||
_this.cloneId = $64afbd09cd65a300$var$_nextTick(function() {
|
||
$64afbd09cd65a300$var$pluginEvent("clone", _this);
|
||
if ($64afbd09cd65a300$export$31b3ca70d8f57423.eventCanceled) return;
|
||
if (!_this.options.removeCloneOnHide) $64afbd09cd65a300$var$rootEl.insertBefore($64afbd09cd65a300$var$cloneEl, $64afbd09cd65a300$var$dragEl);
|
||
_this._hideClone();
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: _this,
|
||
name: "clone"
|
||
});
|
||
});
|
||
!fallback && $64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$dragEl, options.dragClass, true); // Set proper drop events
|
||
if (fallback) {
|
||
$64afbd09cd65a300$var$ignoreNextClick = true;
|
||
_this._loopId = setInterval(_this._emulateDragOver, 50);
|
||
} else {
|
||
// Undo what was set in _prepareDragStart before drag started
|
||
$64afbd09cd65a300$var$off(document, "mouseup", _this._onDrop);
|
||
$64afbd09cd65a300$var$off(document, "touchend", _this._onDrop);
|
||
$64afbd09cd65a300$var$off(document, "touchcancel", _this._onDrop);
|
||
if (dataTransfer) {
|
||
dataTransfer.effectAllowed = "move";
|
||
options.setData && options.setData.call(_this, dataTransfer, $64afbd09cd65a300$var$dragEl);
|
||
}
|
||
$64afbd09cd65a300$var$on(document, "drop", _this); // #1276 fix:
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$dragEl, "transform", "translateZ(0)");
|
||
}
|
||
$64afbd09cd65a300$var$awaitingDragStarted = true;
|
||
_this._dragStartId = $64afbd09cd65a300$var$_nextTick(_this._dragStarted.bind(_this, fallback, evt));
|
||
$64afbd09cd65a300$var$on(document, "selectstart", _this);
|
||
$64afbd09cd65a300$var$moved = true;
|
||
if ($64afbd09cd65a300$var$Safari) $64afbd09cd65a300$var$css(document.body, "user-select", "none");
|
||
},
|
||
// Returns true - if no further action is needed (either inserted or another condition)
|
||
_onDragOver: function _onDragOver(/**Event*/ evt) {
|
||
var el = this.el, target = evt.target, dragRect, targetRect, revert, options = this.options, group = options.group, activeSortable = $64afbd09cd65a300$export$31b3ca70d8f57423.active, isOwner = $64afbd09cd65a300$var$activeGroup === group, canSort = options.sort, fromSortable = $64afbd09cd65a300$var$putSortable || activeSortable, vertical, _this = this, completedFired = false;
|
||
if ($64afbd09cd65a300$var$_silent) return;
|
||
function dragOverEvent(name, extra) {
|
||
$64afbd09cd65a300$var$pluginEvent(name, _this, $64afbd09cd65a300$var$_objectSpread2({
|
||
evt: evt,
|
||
isOwner: isOwner,
|
||
axis: vertical ? "vertical" : "horizontal",
|
||
revert: revert,
|
||
dragRect: dragRect,
|
||
targetRect: targetRect,
|
||
canSort: canSort,
|
||
fromSortable: fromSortable,
|
||
target: target,
|
||
completed: completed,
|
||
onMove: function onMove(target, after) {
|
||
return $64afbd09cd65a300$var$_onMove($64afbd09cd65a300$var$rootEl, el, $64afbd09cd65a300$var$dragEl, dragRect, target, $64afbd09cd65a300$var$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
|
||
$64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$dragEl, $64afbd09cd65a300$var$putSortable ? $64afbd09cd65a300$var$putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
|
||
$64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$dragEl, options.ghostClass, true);
|
||
}
|
||
if ($64afbd09cd65a300$var$putSortable !== _this && _this !== $64afbd09cd65a300$export$31b3ca70d8f57423.active) $64afbd09cd65a300$var$putSortable = _this;
|
||
else if (_this === $64afbd09cd65a300$export$31b3ca70d8f57423.active && $64afbd09cd65a300$var$putSortable) $64afbd09cd65a300$var$putSortable = null;
|
||
// Animation
|
||
if (fromSortable === _this) _this._ignoreWhileAnimating = target;
|
||
_this.animateAll(function() {
|
||
dragOverEvent("dragOverAnimationComplete");
|
||
_this._ignoreWhileAnimating = null;
|
||
});
|
||
if (_this !== fromSortable) {
|
||
fromSortable.animateAll();
|
||
fromSortable._ignoreWhileAnimating = null;
|
||
}
|
||
} // Null lastTarget if it is not inside a previously swapped element
|
||
if (target === $64afbd09cd65a300$var$dragEl && !$64afbd09cd65a300$var$dragEl.animated || target === el && !target.animated) $64afbd09cd65a300$var$lastTarget = null;
|
||
// no bubbling and not fallback
|
||
if (!options.dragoverBubble && !evt.rootEl && target !== document) {
|
||
$64afbd09cd65a300$var$dragEl.parentNode[$64afbd09cd65a300$var$expando]._isOutsideThisEl(evt.target); // Do not detect for empty insert if already inserted
|
||
!insertion && $64afbd09cd65a300$var$nearestEmptyInsertDetectEvent(evt);
|
||
}
|
||
!options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
|
||
return completedFired = true;
|
||
} // Call when dragEl has been inserted
|
||
function changed() {
|
||
$64afbd09cd65a300$var$newIndex = $64afbd09cd65a300$var$index($64afbd09cd65a300$var$dragEl);
|
||
$64afbd09cd65a300$var$newDraggableIndex = $64afbd09cd65a300$var$index($64afbd09cd65a300$var$dragEl, options.draggable);
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: _this,
|
||
name: "change",
|
||
toEl: el,
|
||
newIndex: $64afbd09cd65a300$var$newIndex,
|
||
newDraggableIndex: $64afbd09cd65a300$var$newDraggableIndex,
|
||
originalEvent: evt
|
||
});
|
||
}
|
||
if (evt.preventDefault !== void 0) evt.cancelable && evt.preventDefault();
|
||
target = $64afbd09cd65a300$var$closest(target, options.draggable, el, true);
|
||
dragOverEvent("dragOver");
|
||
if ($64afbd09cd65a300$export$31b3ca70d8f57423.eventCanceled) return completedFired;
|
||
if ($64afbd09cd65a300$var$dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) return completed(false);
|
||
$64afbd09cd65a300$var$ignoreNextClick = false;
|
||
if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = $64afbd09cd65a300$var$parentEl !== $64afbd09cd65a300$var$rootEl // Reverting item into the original list
|
||
) : $64afbd09cd65a300$var$putSortable === this || (this.lastPutMode = $64afbd09cd65a300$var$activeGroup.checkPull(this, activeSortable, $64afbd09cd65a300$var$dragEl, evt)) && group.checkPut(this, activeSortable, $64afbd09cd65a300$var$dragEl, evt))) {
|
||
vertical = this._getDirection(evt, target) === "vertical";
|
||
dragRect = $64afbd09cd65a300$var$getRect($64afbd09cd65a300$var$dragEl);
|
||
dragOverEvent("dragOverValid");
|
||
if ($64afbd09cd65a300$export$31b3ca70d8f57423.eventCanceled) return completedFired;
|
||
if (revert) {
|
||
$64afbd09cd65a300$var$parentEl = $64afbd09cd65a300$var$rootEl; // actualization
|
||
capture();
|
||
this._hideClone();
|
||
dragOverEvent("revert");
|
||
if (!$64afbd09cd65a300$export$31b3ca70d8f57423.eventCanceled) {
|
||
if ($64afbd09cd65a300$var$nextEl) $64afbd09cd65a300$var$rootEl.insertBefore($64afbd09cd65a300$var$dragEl, $64afbd09cd65a300$var$nextEl);
|
||
else $64afbd09cd65a300$var$rootEl.appendChild($64afbd09cd65a300$var$dragEl);
|
||
}
|
||
return completed(true);
|
||
}
|
||
var elLastChild = $64afbd09cd65a300$var$lastChild(el, options.draggable);
|
||
if (!elLastChild || $64afbd09cd65a300$var$_ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
|
||
// Insert to end of list
|
||
// If already at end of list: Do not insert
|
||
if (elLastChild === $64afbd09cd65a300$var$dragEl) return completed(false);
|
||
// if there is a last element, it is the target
|
||
if (elLastChild && el === evt.target) target = elLastChild;
|
||
if (target) targetRect = $64afbd09cd65a300$var$getRect(target);
|
||
if ($64afbd09cd65a300$var$_onMove($64afbd09cd65a300$var$rootEl, el, $64afbd09cd65a300$var$dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
|
||
capture();
|
||
if (elLastChild && elLastChild.nextSibling) // the last draggable element is not the last node
|
||
el.insertBefore($64afbd09cd65a300$var$dragEl, elLastChild.nextSibling);
|
||
else el.appendChild($64afbd09cd65a300$var$dragEl);
|
||
$64afbd09cd65a300$var$parentEl = el; // actualization
|
||
changed();
|
||
return completed(true);
|
||
}
|
||
} else if (elLastChild && $64afbd09cd65a300$var$_ghostIsFirst(evt, vertical, this)) {
|
||
// Insert to start of list
|
||
var firstChild = $64afbd09cd65a300$var$getChild(el, 0, options, true);
|
||
if (firstChild === $64afbd09cd65a300$var$dragEl) return completed(false);
|
||
target = firstChild;
|
||
targetRect = $64afbd09cd65a300$var$getRect(target);
|
||
if ($64afbd09cd65a300$var$_onMove($64afbd09cd65a300$var$rootEl, el, $64afbd09cd65a300$var$dragEl, dragRect, target, targetRect, evt, false) !== false) {
|
||
capture();
|
||
el.insertBefore($64afbd09cd65a300$var$dragEl, firstChild);
|
||
$64afbd09cd65a300$var$parentEl = el; // actualization
|
||
changed();
|
||
return completed(true);
|
||
}
|
||
} else if (target.parentNode === el) {
|
||
targetRect = $64afbd09cd65a300$var$getRect(target);
|
||
var direction = 0, targetBeforeFirstSwap, differentLevel = $64afbd09cd65a300$var$dragEl.parentNode !== el, differentRowCol = !$64afbd09cd65a300$var$_dragElInRowColumn($64afbd09cd65a300$var$dragEl.animated && $64afbd09cd65a300$var$dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical), side1 = vertical ? "top" : "left", scrolledPastTop = $64afbd09cd65a300$var$isScrolledPast(target, "top", "top") || $64afbd09cd65a300$var$isScrolledPast($64afbd09cd65a300$var$dragEl, "top", "top"), scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
|
||
if ($64afbd09cd65a300$var$lastTarget !== target) {
|
||
targetBeforeFirstSwap = targetRect[side1];
|
||
$64afbd09cd65a300$var$pastFirstInvertThresh = false;
|
||
$64afbd09cd65a300$var$isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
|
||
}
|
||
direction = $64afbd09cd65a300$var$_getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, $64afbd09cd65a300$var$isCircumstantialInvert, $64afbd09cd65a300$var$lastTarget === target);
|
||
var sibling;
|
||
if (direction !== 0) {
|
||
// Check if target is beside dragEl in respective direction (ignoring hidden elements)
|
||
var dragIndex = $64afbd09cd65a300$var$index($64afbd09cd65a300$var$dragEl);
|
||
do {
|
||
dragIndex -= direction;
|
||
sibling = $64afbd09cd65a300$var$parentEl.children[dragIndex];
|
||
}while (sibling && ($64afbd09cd65a300$var$css(sibling, "display") === "none" || sibling === $64afbd09cd65a300$var$ghostEl));
|
||
} // If dragEl is already beside target: Do not insert
|
||
if (direction === 0 || sibling === target) return completed(false);
|
||
$64afbd09cd65a300$var$lastTarget = target;
|
||
$64afbd09cd65a300$var$lastDirection = direction;
|
||
var nextSibling = target.nextElementSibling, after = false;
|
||
after = direction === 1;
|
||
var moveVector = $64afbd09cd65a300$var$_onMove($64afbd09cd65a300$var$rootEl, el, $64afbd09cd65a300$var$dragEl, dragRect, target, targetRect, evt, after);
|
||
if (moveVector !== false) {
|
||
if (moveVector === 1 || moveVector === -1) after = moveVector === 1;
|
||
$64afbd09cd65a300$var$_silent = true;
|
||
setTimeout($64afbd09cd65a300$var$_unsilent, 30);
|
||
capture();
|
||
if (after && !nextSibling) el.appendChild($64afbd09cd65a300$var$dragEl);
|
||
else target.parentNode.insertBefore($64afbd09cd65a300$var$dragEl, after ? nextSibling : target);
|
||
// Undo chrome's scroll adjustment (has no effect on other browsers)
|
||
if (scrolledPastTop) $64afbd09cd65a300$var$scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
|
||
$64afbd09cd65a300$var$parentEl = $64afbd09cd65a300$var$dragEl.parentNode; // actualization
|
||
// must be done before animation
|
||
if (targetBeforeFirstSwap !== undefined && !$64afbd09cd65a300$var$isCircumstantialInvert) $64afbd09cd65a300$var$targetMoveDistance = Math.abs(targetBeforeFirstSwap - $64afbd09cd65a300$var$getRect(target)[side1]);
|
||
changed();
|
||
return completed(true);
|
||
}
|
||
}
|
||
if (el.contains($64afbd09cd65a300$var$dragEl)) return completed(false);
|
||
}
|
||
return false;
|
||
},
|
||
_ignoreWhileAnimating: null,
|
||
_offMoveEvents: function _offMoveEvents() {
|
||
$64afbd09cd65a300$var$off(document, "mousemove", this._onTouchMove);
|
||
$64afbd09cd65a300$var$off(document, "touchmove", this._onTouchMove);
|
||
$64afbd09cd65a300$var$off(document, "pointermove", this._onTouchMove);
|
||
$64afbd09cd65a300$var$off(document, "dragover", $64afbd09cd65a300$var$nearestEmptyInsertDetectEvent);
|
||
$64afbd09cd65a300$var$off(document, "mousemove", $64afbd09cd65a300$var$nearestEmptyInsertDetectEvent);
|
||
$64afbd09cd65a300$var$off(document, "touchmove", $64afbd09cd65a300$var$nearestEmptyInsertDetectEvent);
|
||
},
|
||
_offUpEvents: function _offUpEvents() {
|
||
var ownerDocument = this.el.ownerDocument;
|
||
$64afbd09cd65a300$var$off(ownerDocument, "mouseup", this._onDrop);
|
||
$64afbd09cd65a300$var$off(ownerDocument, "touchend", this._onDrop);
|
||
$64afbd09cd65a300$var$off(ownerDocument, "pointerup", this._onDrop);
|
||
$64afbd09cd65a300$var$off(ownerDocument, "touchcancel", this._onDrop);
|
||
$64afbd09cd65a300$var$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
|
||
$64afbd09cd65a300$var$newIndex = $64afbd09cd65a300$var$index($64afbd09cd65a300$var$dragEl);
|
||
$64afbd09cd65a300$var$newDraggableIndex = $64afbd09cd65a300$var$index($64afbd09cd65a300$var$dragEl, options.draggable);
|
||
$64afbd09cd65a300$var$pluginEvent("drop", this, {
|
||
evt: evt
|
||
});
|
||
$64afbd09cd65a300$var$parentEl = $64afbd09cd65a300$var$dragEl && $64afbd09cd65a300$var$dragEl.parentNode; // Get again after plugin event
|
||
$64afbd09cd65a300$var$newIndex = $64afbd09cd65a300$var$index($64afbd09cd65a300$var$dragEl);
|
||
$64afbd09cd65a300$var$newDraggableIndex = $64afbd09cd65a300$var$index($64afbd09cd65a300$var$dragEl, options.draggable);
|
||
if ($64afbd09cd65a300$export$31b3ca70d8f57423.eventCanceled) {
|
||
this._nulling();
|
||
return;
|
||
}
|
||
$64afbd09cd65a300$var$awaitingDragStarted = false;
|
||
$64afbd09cd65a300$var$isCircumstantialInvert = false;
|
||
$64afbd09cd65a300$var$pastFirstInvertThresh = false;
|
||
clearInterval(this._loopId);
|
||
clearTimeout(this._dragStartTimer);
|
||
$64afbd09cd65a300$var$_cancelNextTick(this.cloneId);
|
||
$64afbd09cd65a300$var$_cancelNextTick(this._dragStartId); // Unbind events
|
||
if (this.nativeDraggable) {
|
||
$64afbd09cd65a300$var$off(document, "drop", this);
|
||
$64afbd09cd65a300$var$off(el, "dragstart", this._onDragStart);
|
||
}
|
||
this._offMoveEvents();
|
||
this._offUpEvents();
|
||
if ($64afbd09cd65a300$var$Safari) $64afbd09cd65a300$var$css(document.body, "user-select", "");
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$dragEl, "transform", "");
|
||
if (evt) {
|
||
if ($64afbd09cd65a300$var$moved) {
|
||
evt.cancelable && evt.preventDefault();
|
||
!options.dropBubble && evt.stopPropagation();
|
||
}
|
||
$64afbd09cd65a300$var$ghostEl && $64afbd09cd65a300$var$ghostEl.parentNode && $64afbd09cd65a300$var$ghostEl.parentNode.removeChild($64afbd09cd65a300$var$ghostEl);
|
||
if ($64afbd09cd65a300$var$rootEl === $64afbd09cd65a300$var$parentEl || $64afbd09cd65a300$var$putSortable && $64afbd09cd65a300$var$putSortable.lastPutMode !== "clone") // Remove clone(s)
|
||
$64afbd09cd65a300$var$cloneEl && $64afbd09cd65a300$var$cloneEl.parentNode && $64afbd09cd65a300$var$cloneEl.parentNode.removeChild($64afbd09cd65a300$var$cloneEl);
|
||
if ($64afbd09cd65a300$var$dragEl) {
|
||
if (this.nativeDraggable) $64afbd09cd65a300$var$off($64afbd09cd65a300$var$dragEl, "dragend", this);
|
||
$64afbd09cd65a300$var$_disableDraggable($64afbd09cd65a300$var$dragEl);
|
||
$64afbd09cd65a300$var$dragEl.style["will-change"] = ""; // Remove classes
|
||
// ghostClass is added in dragStarted
|
||
if ($64afbd09cd65a300$var$moved && !$64afbd09cd65a300$var$awaitingDragStarted) $64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$dragEl, $64afbd09cd65a300$var$putSortable ? $64afbd09cd65a300$var$putSortable.options.ghostClass : this.options.ghostClass, false);
|
||
$64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$dragEl, this.options.chosenClass, false); // Drag stop event
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: this,
|
||
name: "unchoose",
|
||
toEl: $64afbd09cd65a300$var$parentEl,
|
||
newIndex: null,
|
||
newDraggableIndex: null,
|
||
originalEvent: evt
|
||
});
|
||
if ($64afbd09cd65a300$var$rootEl !== $64afbd09cd65a300$var$parentEl) {
|
||
if ($64afbd09cd65a300$var$newIndex >= 0) {
|
||
// Add event
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
rootEl: $64afbd09cd65a300$var$parentEl,
|
||
name: "add",
|
||
toEl: $64afbd09cd65a300$var$parentEl,
|
||
fromEl: $64afbd09cd65a300$var$rootEl,
|
||
originalEvent: evt
|
||
}); // Remove event
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: this,
|
||
name: "remove",
|
||
toEl: $64afbd09cd65a300$var$parentEl,
|
||
originalEvent: evt
|
||
}); // drag from one list and drop into another
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
rootEl: $64afbd09cd65a300$var$parentEl,
|
||
name: "sort",
|
||
toEl: $64afbd09cd65a300$var$parentEl,
|
||
fromEl: $64afbd09cd65a300$var$rootEl,
|
||
originalEvent: evt
|
||
});
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: this,
|
||
name: "sort",
|
||
toEl: $64afbd09cd65a300$var$parentEl,
|
||
originalEvent: evt
|
||
});
|
||
}
|
||
$64afbd09cd65a300$var$putSortable && $64afbd09cd65a300$var$putSortable.save();
|
||
} else {
|
||
if ($64afbd09cd65a300$var$newIndex !== $64afbd09cd65a300$var$oldIndex) {
|
||
if ($64afbd09cd65a300$var$newIndex >= 0) {
|
||
// drag & drop within the same list
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: this,
|
||
name: "update",
|
||
toEl: $64afbd09cd65a300$var$parentEl,
|
||
originalEvent: evt
|
||
});
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: this,
|
||
name: "sort",
|
||
toEl: $64afbd09cd65a300$var$parentEl,
|
||
originalEvent: evt
|
||
});
|
||
}
|
||
}
|
||
}
|
||
if ($64afbd09cd65a300$export$31b3ca70d8f57423.active) {
|
||
/* jshint eqnull:true */ if ($64afbd09cd65a300$var$newIndex == null || $64afbd09cd65a300$var$newIndex === -1) {
|
||
$64afbd09cd65a300$var$newIndex = $64afbd09cd65a300$var$oldIndex;
|
||
$64afbd09cd65a300$var$newDraggableIndex = $64afbd09cd65a300$var$oldDraggableIndex;
|
||
}
|
||
$64afbd09cd65a300$var$_dispatchEvent({
|
||
sortable: this,
|
||
name: "end",
|
||
toEl: $64afbd09cd65a300$var$parentEl,
|
||
originalEvent: evt
|
||
}); // Save sorting
|
||
this.save();
|
||
}
|
||
}
|
||
}
|
||
this._nulling();
|
||
},
|
||
_nulling: function _nulling() {
|
||
$64afbd09cd65a300$var$pluginEvent("nulling", this);
|
||
$64afbd09cd65a300$var$rootEl = $64afbd09cd65a300$var$dragEl = $64afbd09cd65a300$var$parentEl = $64afbd09cd65a300$var$ghostEl = $64afbd09cd65a300$var$nextEl = $64afbd09cd65a300$var$cloneEl = $64afbd09cd65a300$var$lastDownEl = $64afbd09cd65a300$var$cloneHidden = $64afbd09cd65a300$var$tapEvt = $64afbd09cd65a300$var$touchEvt = $64afbd09cd65a300$var$moved = $64afbd09cd65a300$var$newIndex = $64afbd09cd65a300$var$newDraggableIndex = $64afbd09cd65a300$var$oldIndex = $64afbd09cd65a300$var$oldDraggableIndex = $64afbd09cd65a300$var$lastTarget = $64afbd09cd65a300$var$lastDirection = $64afbd09cd65a300$var$putSortable = $64afbd09cd65a300$var$activeGroup = $64afbd09cd65a300$export$31b3ca70d8f57423.dragged = $64afbd09cd65a300$export$31b3ca70d8f57423.ghost = $64afbd09cd65a300$export$31b3ca70d8f57423.clone = $64afbd09cd65a300$export$31b3ca70d8f57423.active = null;
|
||
$64afbd09cd65a300$var$savedInputChecked.forEach(function(el) {
|
||
el.checked = true;
|
||
});
|
||
$64afbd09cd65a300$var$savedInputChecked.length = $64afbd09cd65a300$var$lastDx = $64afbd09cd65a300$var$lastDy = 0;
|
||
},
|
||
handleEvent: function handleEvent(/**Event*/ evt) {
|
||
switch(evt.type){
|
||
case "drop":
|
||
case "dragend":
|
||
this._onDrop(evt);
|
||
break;
|
||
case "dragenter":
|
||
case "dragover":
|
||
if ($64afbd09cd65a300$var$dragEl) {
|
||
this._onDragOver(evt);
|
||
$64afbd09cd65a300$var$_globalDragOver(evt);
|
||
}
|
||
break;
|
||
case "selectstart":
|
||
evt.preventDefault();
|
||
break;
|
||
}
|
||
},
|
||
/**
|
||
* Serializes the item into an array of string.
|
||
* @returns {String[]}
|
||
*/ toArray: function toArray() {
|
||
var order = [], el, children = this.el.children, i = 0, n = children.length, options = this.options;
|
||
for(; i < n; i++){
|
||
el = children[i];
|
||
if ($64afbd09cd65a300$var$closest(el, options.draggable, this.el, false)) order.push(el.getAttribute(options.dataIdAttr) || $64afbd09cd65a300$var$_generateId(el));
|
||
}
|
||
return order;
|
||
},
|
||
/**
|
||
* Sorts the elements according to the array.
|
||
* @param {String[]} order order of the items
|
||
*/ sort: function sort(order, useAnimation) {
|
||
var items = {}, rootEl = this.el;
|
||
this.toArray().forEach(function(id, i) {
|
||
var el = rootEl.children[i];
|
||
if ($64afbd09cd65a300$var$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
|
||
*/ save: function save() {
|
||
var store = this.options.store;
|
||
store && store.set && store.set(this);
|
||
},
|
||
/**
|
||
* For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
|
||
* @param {HTMLElement} el
|
||
* @param {String} [selector] default: `options.draggable`
|
||
* @returns {HTMLElement|null}
|
||
*/ closest: function closest$1(el, selector) {
|
||
return $64afbd09cd65a300$var$closest(el, selector || this.options.draggable, this.el, false);
|
||
},
|
||
/**
|
||
* Set/get option
|
||
* @param {string} name
|
||
* @param {*} [value]
|
||
* @returns {*}
|
||
*/ option: function option(name, value) {
|
||
var options = this.options;
|
||
if (value === void 0) return options[name];
|
||
else {
|
||
var modifiedValue = $64afbd09cd65a300$var$PluginManager.modifyOption(this, name, value);
|
||
if (typeof modifiedValue !== "undefined") options[name] = modifiedValue;
|
||
else options[name] = value;
|
||
if (name === "group") $64afbd09cd65a300$var$_prepareGroup(options);
|
||
}
|
||
},
|
||
/**
|
||
* Destroy
|
||
*/ destroy: function destroy() {
|
||
$64afbd09cd65a300$var$pluginEvent("destroy", this);
|
||
var el = this.el;
|
||
el[$64afbd09cd65a300$var$expando] = null;
|
||
$64afbd09cd65a300$var$off(el, "mousedown", this._onTapStart);
|
||
$64afbd09cd65a300$var$off(el, "touchstart", this._onTapStart);
|
||
$64afbd09cd65a300$var$off(el, "pointerdown", this._onTapStart);
|
||
if (this.nativeDraggable) {
|
||
$64afbd09cd65a300$var$off(el, "dragover", this);
|
||
$64afbd09cd65a300$var$off(el, "dragenter", this);
|
||
} // Remove draggable attributes
|
||
Array.prototype.forEach.call(el.querySelectorAll("[draggable]"), function(el) {
|
||
el.removeAttribute("draggable");
|
||
});
|
||
this._onDrop();
|
||
this._disableDelayedDragEvents();
|
||
$64afbd09cd65a300$var$sortables.splice($64afbd09cd65a300$var$sortables.indexOf(this.el), 1);
|
||
this.el = el = null;
|
||
},
|
||
_hideClone: function _hideClone() {
|
||
if (!$64afbd09cd65a300$var$cloneHidden) {
|
||
$64afbd09cd65a300$var$pluginEvent("hideClone", this);
|
||
if ($64afbd09cd65a300$export$31b3ca70d8f57423.eventCanceled) return;
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$cloneEl, "display", "none");
|
||
if (this.options.removeCloneOnHide && $64afbd09cd65a300$var$cloneEl.parentNode) $64afbd09cd65a300$var$cloneEl.parentNode.removeChild($64afbd09cd65a300$var$cloneEl);
|
||
$64afbd09cd65a300$var$cloneHidden = true;
|
||
}
|
||
},
|
||
_showClone: function _showClone(putSortable) {
|
||
if (putSortable.lastPutMode !== "clone") {
|
||
this._hideClone();
|
||
return;
|
||
}
|
||
if ($64afbd09cd65a300$var$cloneHidden) {
|
||
$64afbd09cd65a300$var$pluginEvent("showClone", this);
|
||
if ($64afbd09cd65a300$export$31b3ca70d8f57423.eventCanceled) return; // show clone at dragEl or original position
|
||
if ($64afbd09cd65a300$var$dragEl.parentNode == $64afbd09cd65a300$var$rootEl && !this.options.group.revertClone) $64afbd09cd65a300$var$rootEl.insertBefore($64afbd09cd65a300$var$cloneEl, $64afbd09cd65a300$var$dragEl);
|
||
else if ($64afbd09cd65a300$var$nextEl) $64afbd09cd65a300$var$rootEl.insertBefore($64afbd09cd65a300$var$cloneEl, $64afbd09cd65a300$var$nextEl);
|
||
else $64afbd09cd65a300$var$rootEl.appendChild($64afbd09cd65a300$var$cloneEl);
|
||
if (this.options.group.revertClone) this.animate($64afbd09cd65a300$var$dragEl, $64afbd09cd65a300$var$cloneEl);
|
||
$64afbd09cd65a300$var$css($64afbd09cd65a300$var$cloneEl, "display", "");
|
||
$64afbd09cd65a300$var$cloneHidden = false;
|
||
}
|
||
}
|
||
};
|
||
function $64afbd09cd65a300$var$_globalDragOver(/**Event*/ evt) {
|
||
if (evt.dataTransfer) evt.dataTransfer.dropEffect = "move";
|
||
evt.cancelable && evt.preventDefault();
|
||
}
|
||
function $64afbd09cd65a300$var$_onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
|
||
var evt, sortable = fromEl[$64afbd09cd65a300$var$expando], onMoveFn = sortable.options.onMove, retVal; // Support for new CustomEvent feature
|
||
if (window.CustomEvent && !$64afbd09cd65a300$var$IE11OrLess && !$64afbd09cd65a300$var$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 || $64afbd09cd65a300$var$getRect(toEl);
|
||
evt.willInsertAfter = willInsertAfter;
|
||
evt.originalEvent = originalEvent;
|
||
fromEl.dispatchEvent(evt);
|
||
if (onMoveFn) retVal = onMoveFn.call(sortable, evt, originalEvent);
|
||
return retVal;
|
||
}
|
||
function $64afbd09cd65a300$var$_disableDraggable(el) {
|
||
el.draggable = false;
|
||
}
|
||
function $64afbd09cd65a300$var$_unsilent() {
|
||
$64afbd09cd65a300$var$_silent = false;
|
||
}
|
||
function $64afbd09cd65a300$var$_ghostIsFirst(evt, vertical, sortable) {
|
||
var rect = $64afbd09cd65a300$var$getRect($64afbd09cd65a300$var$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 $64afbd09cd65a300$var$_ghostIsLast(evt, vertical, sortable) {
|
||
var rect = $64afbd09cd65a300$var$getRect($64afbd09cd65a300$var$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 $64afbd09cd65a300$var$_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 && $64afbd09cd65a300$var$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 (!$64afbd09cd65a300$var$pastFirstInvertThresh && ($64afbd09cd65a300$var$lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) // past first invert threshold, do not restrict inverted threshold to dragEl shadow
|
||
$64afbd09cd65a300$var$pastFirstInvertThresh = true;
|
||
if (!$64afbd09cd65a300$var$pastFirstInvertThresh) {
|
||
// dragEl shadow (target move distance shadow)
|
||
if ($64afbd09cd65a300$var$lastDirection === 1 ? mouseOnAxis < targetS1 + $64afbd09cd65a300$var$targetMoveDistance // over dragEl shadow
|
||
: mouseOnAxis > targetS2 - $64afbd09cd65a300$var$targetMoveDistance) return -$64afbd09cd65a300$var$lastDirection;
|
||
} else invert = true;
|
||
} else {
|
||
// Regular
|
||
if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) return $64afbd09cd65a300$var$_getInsertDirection(target);
|
||
}
|
||
}
|
||
invert = invert || invertSwap;
|
||
if (invert) {
|
||
// Invert of regular
|
||
if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
|
||
}
|
||
return 0;
|
||
}
|
||
/**
|
||
* Gets the direction dragEl must be swapped relative to target in order to make it
|
||
* seem that dragEl has been "inserted" into that element's position
|
||
* @param {HTMLElement} target The target whose position dragEl is being inserted at
|
||
* @return {Number} Direction dragEl must be swapped
|
||
*/ function $64afbd09cd65a300$var$_getInsertDirection(target) {
|
||
if ($64afbd09cd65a300$var$index($64afbd09cd65a300$var$dragEl) < $64afbd09cd65a300$var$index(target)) return 1;
|
||
else return -1;
|
||
}
|
||
/**
|
||
* Generate id
|
||
* @param {HTMLElement} el
|
||
* @returns {String}
|
||
* @private
|
||
*/ function $64afbd09cd65a300$var$_generateId(el) {
|
||
var str = el.tagName + el.className + el.src + el.href + el.textContent, i = str.length, sum = 0;
|
||
while(i--)sum += str.charCodeAt(i);
|
||
return sum.toString(36);
|
||
}
|
||
function $64afbd09cd65a300$var$_saveInputCheckedState(root) {
|
||
$64afbd09cd65a300$var$savedInputChecked.length = 0;
|
||
var inputs = root.getElementsByTagName("input");
|
||
var idx = inputs.length;
|
||
while(idx--){
|
||
var el = inputs[idx];
|
||
el.checked && $64afbd09cd65a300$var$savedInputChecked.push(el);
|
||
}
|
||
}
|
||
function $64afbd09cd65a300$var$_nextTick(fn) {
|
||
return setTimeout(fn, 0);
|
||
}
|
||
function $64afbd09cd65a300$var$_cancelNextTick(id) {
|
||
return clearTimeout(id);
|
||
} // Fixed #973:
|
||
if ($64afbd09cd65a300$var$documentExists) $64afbd09cd65a300$var$on(document, "touchmove", function(evt) {
|
||
if (($64afbd09cd65a300$export$31b3ca70d8f57423.active || $64afbd09cd65a300$var$awaitingDragStarted) && evt.cancelable) evt.preventDefault();
|
||
});
|
||
// Export utils
|
||
$64afbd09cd65a300$export$31b3ca70d8f57423.utils = {
|
||
on: $64afbd09cd65a300$var$on,
|
||
off: $64afbd09cd65a300$var$off,
|
||
css: $64afbd09cd65a300$var$css,
|
||
find: $64afbd09cd65a300$var$find,
|
||
is: function is(el, selector) {
|
||
return !!$64afbd09cd65a300$var$closest(el, selector, el, false);
|
||
},
|
||
extend: $64afbd09cd65a300$var$extend,
|
||
throttle: $64afbd09cd65a300$var$throttle,
|
||
closest: $64afbd09cd65a300$var$closest,
|
||
toggleClass: $64afbd09cd65a300$var$toggleClass,
|
||
clone: $64afbd09cd65a300$var$clone,
|
||
index: $64afbd09cd65a300$var$index,
|
||
nextTick: $64afbd09cd65a300$var$_nextTick,
|
||
cancelNextTick: $64afbd09cd65a300$var$_cancelNextTick,
|
||
detectDirection: $64afbd09cd65a300$var$_detectDirection,
|
||
getChild: $64afbd09cd65a300$var$getChild
|
||
};
|
||
/**
|
||
* Get the Sortable instance of an element
|
||
* @param {HTMLElement} element The element
|
||
* @return {Sortable|undefined} The instance of Sortable
|
||
*/ $64afbd09cd65a300$export$31b3ca70d8f57423.get = function(element) {
|
||
return element[$64afbd09cd65a300$var$expando];
|
||
};
|
||
/**
|
||
* Mount a plugin to Sortable
|
||
* @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
|
||
*/ $64afbd09cd65a300$export$31b3ca70d8f57423.mount = function() {
|
||
for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++)plugins[_key] = arguments[_key];
|
||
if (plugins[0].constructor === Array) plugins = plugins[0];
|
||
plugins.forEach(function(plugin) {
|
||
if (!plugin.prototype || !plugin.prototype.constructor) throw "Sortable: Mounted plugin must be a constructor function, not ".concat(({}).toString.call(plugin));
|
||
if (plugin.utils) $64afbd09cd65a300$export$31b3ca70d8f57423.utils = $64afbd09cd65a300$var$_objectSpread2($64afbd09cd65a300$var$_objectSpread2({}, $64afbd09cd65a300$export$31b3ca70d8f57423.utils), plugin.utils);
|
||
$64afbd09cd65a300$var$PluginManager.mount(plugin);
|
||
});
|
||
};
|
||
/**
|
||
* Create sortable instance
|
||
* @param {HTMLElement} el
|
||
* @param {Object} [options]
|
||
*/ $64afbd09cd65a300$export$31b3ca70d8f57423.create = function(el, options) {
|
||
return new $64afbd09cd65a300$export$31b3ca70d8f57423(el, options);
|
||
}; // Export
|
||
$64afbd09cd65a300$export$31b3ca70d8f57423.version = $64afbd09cd65a300$var$version;
|
||
var $64afbd09cd65a300$var$autoScrolls = [], $64afbd09cd65a300$var$scrollEl, $64afbd09cd65a300$var$scrollRootEl, $64afbd09cd65a300$var$scrolling = false, $64afbd09cd65a300$var$lastAutoScrollX, $64afbd09cd65a300$var$lastAutoScrollY, $64afbd09cd65a300$var$touchEvt$1, $64afbd09cd65a300$var$pointerElemChangedInterval;
|
||
function $64afbd09cd65a300$var$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) $64afbd09cd65a300$var$on(document, "dragover", this._handleAutoScroll);
|
||
else {
|
||
if (this.options.supportPointer) $64afbd09cd65a300$var$on(document, "pointermove", this._handleFallbackAutoScroll);
|
||
else if (originalEvent.touches) $64afbd09cd65a300$var$on(document, "touchmove", this._handleFallbackAutoScroll);
|
||
else $64afbd09cd65a300$var$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) $64afbd09cd65a300$var$off(document, "dragover", this._handleAutoScroll);
|
||
else {
|
||
$64afbd09cd65a300$var$off(document, "pointermove", this._handleFallbackAutoScroll);
|
||
$64afbd09cd65a300$var$off(document, "touchmove", this._handleFallbackAutoScroll);
|
||
$64afbd09cd65a300$var$off(document, "mousemove", this._handleFallbackAutoScroll);
|
||
}
|
||
$64afbd09cd65a300$var$clearPointerElemChangedInterval();
|
||
$64afbd09cd65a300$var$clearAutoScrolls();
|
||
$64afbd09cd65a300$var$cancelThrottle();
|
||
},
|
||
nulling: function nulling() {
|
||
$64afbd09cd65a300$var$touchEvt$1 = $64afbd09cd65a300$var$scrollRootEl = $64afbd09cd65a300$var$scrollEl = $64afbd09cd65a300$var$scrolling = $64afbd09cd65a300$var$pointerElemChangedInterval = $64afbd09cd65a300$var$lastAutoScrollX = $64afbd09cd65a300$var$lastAutoScrollY = null;
|
||
$64afbd09cd65a300$var$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);
|
||
$64afbd09cd65a300$var$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 || $64afbd09cd65a300$var$Edge || $64afbd09cd65a300$var$IE11OrLess || $64afbd09cd65a300$var$Safari) {
|
||
$64afbd09cd65a300$var$autoScroll(evt, this.options, elem, fallback); // Listener for pointer element change
|
||
var ogElemScroller = $64afbd09cd65a300$var$getParentAutoScrollElement(elem, true);
|
||
if ($64afbd09cd65a300$var$scrolling && (!$64afbd09cd65a300$var$pointerElemChangedInterval || x !== $64afbd09cd65a300$var$lastAutoScrollX || y !== $64afbd09cd65a300$var$lastAutoScrollY)) {
|
||
$64afbd09cd65a300$var$pointerElemChangedInterval && $64afbd09cd65a300$var$clearPointerElemChangedInterval(); // Detect for pointer elem change, emulating native DnD behaviour
|
||
$64afbd09cd65a300$var$pointerElemChangedInterval = setInterval(function() {
|
||
var newElem = $64afbd09cd65a300$var$getParentAutoScrollElement(document.elementFromPoint(x, y), true);
|
||
if (newElem !== ogElemScroller) {
|
||
ogElemScroller = newElem;
|
||
$64afbd09cd65a300$var$clearAutoScrolls();
|
||
}
|
||
$64afbd09cd65a300$var$autoScroll(evt, _this.options, newElem, fallback);
|
||
}, 10);
|
||
$64afbd09cd65a300$var$lastAutoScrollX = x;
|
||
$64afbd09cd65a300$var$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 || $64afbd09cd65a300$var$getParentAutoScrollElement(elem, true) === $64afbd09cd65a300$var$getWindowScrollingElement()) {
|
||
$64afbd09cd65a300$var$clearAutoScrolls();
|
||
return;
|
||
}
|
||
$64afbd09cd65a300$var$autoScroll(evt, this.options, $64afbd09cd65a300$var$getParentAutoScrollElement(elem, false), false);
|
||
}
|
||
}
|
||
};
|
||
return $64afbd09cd65a300$var$_extends(AutoScroll, {
|
||
pluginName: "scroll",
|
||
initializeByDefault: true
|
||
});
|
||
}
|
||
function $64afbd09cd65a300$var$clearAutoScrolls() {
|
||
$64afbd09cd65a300$var$autoScrolls.forEach(function(autoScroll) {
|
||
clearInterval(autoScroll.pid);
|
||
});
|
||
$64afbd09cd65a300$var$autoScrolls = [];
|
||
}
|
||
function $64afbd09cd65a300$var$clearPointerElemChangedInterval() {
|
||
clearInterval($64afbd09cd65a300$var$pointerElemChangedInterval);
|
||
}
|
||
var $64afbd09cd65a300$var$autoScroll = $64afbd09cd65a300$var$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 = $64afbd09cd65a300$var$getWindowScrollingElement();
|
||
var scrollThisInstance = false, scrollCustomFn; // New scroll root, set scrollEl
|
||
if ($64afbd09cd65a300$var$scrollRootEl !== rootEl) {
|
||
$64afbd09cd65a300$var$scrollRootEl = rootEl;
|
||
$64afbd09cd65a300$var$clearAutoScrolls();
|
||
$64afbd09cd65a300$var$scrollEl = options.scroll;
|
||
scrollCustomFn = options.scrollFn;
|
||
if ($64afbd09cd65a300$var$scrollEl === true) $64afbd09cd65a300$var$scrollEl = $64afbd09cd65a300$var$getParentAutoScrollElement(rootEl, true);
|
||
}
|
||
var layersOut = 0;
|
||
var currentParent = $64afbd09cd65a300$var$scrollEl;
|
||
do {
|
||
var el = currentParent, rect = $64afbd09cd65a300$var$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 = $64afbd09cd65a300$var$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 (!$64afbd09cd65a300$var$autoScrolls[layersOut]) {
|
||
for(var i = 0; i <= layersOut; i++)if (!$64afbd09cd65a300$var$autoScrolls[i]) $64afbd09cd65a300$var$autoScrolls[i] = {};
|
||
}
|
||
if ($64afbd09cd65a300$var$autoScrolls[layersOut].vx != vx || $64afbd09cd65a300$var$autoScrolls[layersOut].vy != vy || $64afbd09cd65a300$var$autoScrolls[layersOut].el !== el) {
|
||
$64afbd09cd65a300$var$autoScrolls[layersOut].el = el;
|
||
$64afbd09cd65a300$var$autoScrolls[layersOut].vx = vx;
|
||
$64afbd09cd65a300$var$autoScrolls[layersOut].vy = vy;
|
||
clearInterval($64afbd09cd65a300$var$autoScrolls[layersOut].pid);
|
||
if (vx != 0 || vy != 0) {
|
||
scrollThisInstance = true;
|
||
/* jshint loopfunc:true */ $64afbd09cd65a300$var$autoScrolls[layersOut].pid = setInterval((function() {
|
||
// emulate drag over during autoscroll (fallback), emulating native DnD behaviour
|
||
if (isFallback && this.layer === 0) $64afbd09cd65a300$export$31b3ca70d8f57423.active._onTouchMove($64afbd09cd65a300$var$touchEvt$1); // To move ghost if it is positioned absolutely
|
||
var scrollOffsetY = $64afbd09cd65a300$var$autoScrolls[this.layer].vy ? $64afbd09cd65a300$var$autoScrolls[this.layer].vy * speed : 0;
|
||
var scrollOffsetX = $64afbd09cd65a300$var$autoScrolls[this.layer].vx ? $64afbd09cd65a300$var$autoScrolls[this.layer].vx * speed : 0;
|
||
if (typeof scrollCustomFn === "function") {
|
||
if (scrollCustomFn.call($64afbd09cd65a300$export$31b3ca70d8f57423.dragged.parentNode[$64afbd09cd65a300$var$expando], scrollOffsetX, scrollOffsetY, evt, $64afbd09cd65a300$var$touchEvt$1, $64afbd09cd65a300$var$autoScrolls[this.layer].el) !== "continue") return;
|
||
}
|
||
$64afbd09cd65a300$var$scrollBy($64afbd09cd65a300$var$autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
|
||
}).bind({
|
||
layer: layersOut
|
||
}), 24);
|
||
}
|
||
}
|
||
layersOut++;
|
||
}while (options.bubbleScroll && currentParent !== winScroller && (currentParent = $64afbd09cd65a300$var$getParentAutoScrollElement(currentParent, false)));
|
||
$64afbd09cd65a300$var$scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
|
||
}, 30);
|
||
var $64afbd09cd65a300$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 $64afbd09cd65a300$var$Revert() {}
|
||
$64afbd09cd65a300$var$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 = $64afbd09cd65a300$var$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: $64afbd09cd65a300$var$drop
|
||
};
|
||
$64afbd09cd65a300$var$_extends($64afbd09cd65a300$var$Revert, {
|
||
pluginName: "revertOnSpill"
|
||
});
|
||
function $64afbd09cd65a300$var$Remove() {}
|
||
$64afbd09cd65a300$var$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: $64afbd09cd65a300$var$drop
|
||
};
|
||
$64afbd09cd65a300$var$_extends($64afbd09cd65a300$var$Remove, {
|
||
pluginName: "removeOnSpill"
|
||
});
|
||
var $64afbd09cd65a300$var$lastSwapEl;
|
||
function $64afbd09cd65a300$export$bdb5f0a1b77546f4() {
|
||
function Swap() {
|
||
this.defaults = {
|
||
swapClass: "sortable-swap-highlight"
|
||
};
|
||
}
|
||
Swap.prototype = {
|
||
dragStart: function dragStart(_ref) {
|
||
var dragEl = _ref.dragEl;
|
||
$64afbd09cd65a300$var$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 = $64afbd09cd65a300$var$lastSwapEl;
|
||
if (onMove(target) !== false) {
|
||
$64afbd09cd65a300$var$toggleClass(target, options.swapClass, true);
|
||
$64afbd09cd65a300$var$lastSwapEl = target;
|
||
} else $64afbd09cd65a300$var$lastSwapEl = null;
|
||
if (prevSwapEl && prevSwapEl !== $64afbd09cd65a300$var$lastSwapEl) $64afbd09cd65a300$var$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;
|
||
$64afbd09cd65a300$var$lastSwapEl && $64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$lastSwapEl, options.swapClass, false);
|
||
if ($64afbd09cd65a300$var$lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) {
|
||
if (dragEl !== $64afbd09cd65a300$var$lastSwapEl) {
|
||
toSortable.captureAnimationState();
|
||
if (toSortable !== activeSortable) activeSortable.captureAnimationState();
|
||
$64afbd09cd65a300$var$swapNodes(dragEl, $64afbd09cd65a300$var$lastSwapEl);
|
||
toSortable.animateAll();
|
||
if (toSortable !== activeSortable) activeSortable.animateAll();
|
||
}
|
||
}
|
||
},
|
||
nulling: function nulling() {
|
||
$64afbd09cd65a300$var$lastSwapEl = null;
|
||
}
|
||
};
|
||
return $64afbd09cd65a300$var$_extends(Swap, {
|
||
pluginName: "swap",
|
||
eventProperties: function eventProperties() {
|
||
return {
|
||
swapItem: $64afbd09cd65a300$var$lastSwapEl
|
||
};
|
||
}
|
||
});
|
||
}
|
||
function $64afbd09cd65a300$var$swapNodes(n1, n2) {
|
||
var p1 = n1.parentNode, p2 = n2.parentNode, i1, i2;
|
||
if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return;
|
||
i1 = $64afbd09cd65a300$var$index(n1);
|
||
i2 = $64afbd09cd65a300$var$index(n2);
|
||
if (p1.isEqualNode(p2) && i1 < i2) i2++;
|
||
p1.insertBefore(n2, p1.children[i1]);
|
||
p2.insertBefore(n1, p2.children[i2]);
|
||
}
|
||
var $64afbd09cd65a300$var$multiDragElements = [], $64afbd09cd65a300$var$multiDragClones = [], $64afbd09cd65a300$var$lastMultiDragSelect, // for selection with modifier key down (SHIFT)
|
||
$64afbd09cd65a300$var$multiDragSortable, $64afbd09cd65a300$var$initialFolding = false, // Initial multi-drag fold when drag started
|
||
$64afbd09cd65a300$var$folding = false, // Folding any other time
|
||
$64afbd09cd65a300$var$dragStarted = false, $64afbd09cd65a300$var$dragEl$1, $64afbd09cd65a300$var$clonesFromRect, $64afbd09cd65a300$var$clonesHidden;
|
||
function $64afbd09cd65a300$export$18e5d2a5d1df842d() {
|
||
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.avoidImplicitDeselect) {
|
||
if (sortable.options.supportPointer) $64afbd09cd65a300$var$on(document, "pointerup", this._deselectMultiDrag);
|
||
else {
|
||
$64afbd09cd65a300$var$on(document, "mouseup", this._deselectMultiDrag);
|
||
$64afbd09cd65a300$var$on(document, "touchend", this._deselectMultiDrag);
|
||
}
|
||
}
|
||
$64afbd09cd65a300$var$on(document, "keydown", this._checkKeyDown);
|
||
$64afbd09cd65a300$var$on(document, "keyup", this._checkKeyUp);
|
||
this.defaults = {
|
||
selectedClass: "sortable-selected",
|
||
multiDragKey: null,
|
||
avoidImplicitDeselect: false,
|
||
setData: function setData(dataTransfer, dragEl) {
|
||
var data = "";
|
||
if ($64afbd09cd65a300$var$multiDragElements.length && $64afbd09cd65a300$var$multiDragSortable === sortable) $64afbd09cd65a300$var$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;
|
||
$64afbd09cd65a300$var$dragEl$1 = dragged;
|
||
},
|
||
delayEnded: function delayEnded() {
|
||
this.isMultiDrag = ~$64afbd09cd65a300$var$multiDragElements.indexOf($64afbd09cd65a300$var$dragEl$1);
|
||
},
|
||
setupClone: function setupClone(_ref2) {
|
||
var sortable = _ref2.sortable, cancel = _ref2.cancel;
|
||
if (!this.isMultiDrag) return;
|
||
for(var i = 0; i < $64afbd09cd65a300$var$multiDragElements.length; i++){
|
||
$64afbd09cd65a300$var$multiDragClones.push($64afbd09cd65a300$var$clone($64afbd09cd65a300$var$multiDragElements[i]));
|
||
$64afbd09cd65a300$var$multiDragClones[i].sortableIndex = $64afbd09cd65a300$var$multiDragElements[i].sortableIndex;
|
||
$64afbd09cd65a300$var$multiDragClones[i].draggable = false;
|
||
$64afbd09cd65a300$var$multiDragClones[i].style["will-change"] = "";
|
||
$64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$multiDragClones[i], this.options.selectedClass, false);
|
||
$64afbd09cd65a300$var$multiDragElements[i] === $64afbd09cd65a300$var$dragEl$1 && $64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$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 ($64afbd09cd65a300$var$multiDragElements.length && $64afbd09cd65a300$var$multiDragSortable === sortable) {
|
||
$64afbd09cd65a300$var$insertMultiDragClones(true, rootEl);
|
||
dispatchSortableEvent("clone");
|
||
cancel();
|
||
}
|
||
}
|
||
},
|
||
showClone: function showClone(_ref4) {
|
||
var cloneNowShown = _ref4.cloneNowShown, rootEl = _ref4.rootEl, cancel = _ref4.cancel;
|
||
if (!this.isMultiDrag) return;
|
||
$64afbd09cd65a300$var$insertMultiDragClones(false, rootEl);
|
||
$64afbd09cd65a300$var$multiDragClones.forEach(function(clone) {
|
||
$64afbd09cd65a300$var$css(clone, "display", "");
|
||
});
|
||
cloneNowShown();
|
||
$64afbd09cd65a300$var$clonesHidden = false;
|
||
cancel();
|
||
},
|
||
hideClone: function hideClone(_ref5) {
|
||
var _this = this;
|
||
var sortable = _ref5.sortable, cloneNowHidden = _ref5.cloneNowHidden, cancel = _ref5.cancel;
|
||
if (!this.isMultiDrag) return;
|
||
$64afbd09cd65a300$var$multiDragClones.forEach(function(clone) {
|
||
$64afbd09cd65a300$var$css(clone, "display", "none");
|
||
if (_this.options.removeCloneOnHide && clone.parentNode) clone.parentNode.removeChild(clone);
|
||
});
|
||
cloneNowHidden();
|
||
$64afbd09cd65a300$var$clonesHidden = true;
|
||
cancel();
|
||
},
|
||
dragStartGlobal: function dragStartGlobal(_ref6) {
|
||
var sortable = _ref6.sortable;
|
||
if (!this.isMultiDrag && $64afbd09cd65a300$var$multiDragSortable) $64afbd09cd65a300$var$multiDragSortable.multiDrag._deselectMultiDrag();
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
multiDragElement.sortableIndex = $64afbd09cd65a300$var$index(multiDragElement);
|
||
}); // Sort multi-drag elements
|
||
$64afbd09cd65a300$var$multiDragElements = $64afbd09cd65a300$var$multiDragElements.sort(function(a, b) {
|
||
return a.sortableIndex - b.sortableIndex;
|
||
});
|
||
$64afbd09cd65a300$var$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) {
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
if (multiDragElement === $64afbd09cd65a300$var$dragEl$1) return;
|
||
$64afbd09cd65a300$var$css(multiDragElement, "position", "absolute");
|
||
});
|
||
var dragRect = $64afbd09cd65a300$var$getRect($64afbd09cd65a300$var$dragEl$1, false, true, true);
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
if (multiDragElement === $64afbd09cd65a300$var$dragEl$1) return;
|
||
$64afbd09cd65a300$var$setRect(multiDragElement, dragRect);
|
||
});
|
||
$64afbd09cd65a300$var$folding = true;
|
||
$64afbd09cd65a300$var$initialFolding = true;
|
||
}
|
||
}
|
||
sortable.animateAll(function() {
|
||
$64afbd09cd65a300$var$folding = false;
|
||
$64afbd09cd65a300$var$initialFolding = false;
|
||
if (_this2.options.animation) $64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
$64afbd09cd65a300$var$unsetRect(multiDragElement);
|
||
});
|
||
// Remove all auxiliary multidrag items from el, if sorting enabled
|
||
if (_this2.options.sort) $64afbd09cd65a300$var$removeMultiDragElements();
|
||
});
|
||
},
|
||
dragOver: function dragOver(_ref8) {
|
||
var target = _ref8.target, completed = _ref8.completed, cancel = _ref8.cancel;
|
||
if ($64afbd09cd65a300$var$folding && ~$64afbd09cd65a300$var$multiDragElements.indexOf(target)) {
|
||
completed(false);
|
||
cancel();
|
||
}
|
||
},
|
||
revert: function revert(_ref9) {
|
||
var fromSortable = _ref9.fromSortable, rootEl = _ref9.rootEl, sortable = _ref9.sortable, dragRect = _ref9.dragRect;
|
||
if ($64afbd09cd65a300$var$multiDragElements.length > 1) {
|
||
// Setup unfold animation
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
sortable.addAnimationState({
|
||
target: multiDragElement,
|
||
rect: $64afbd09cd65a300$var$folding ? $64afbd09cd65a300$var$getRect(multiDragElement) : dragRect
|
||
});
|
||
$64afbd09cd65a300$var$unsetRect(multiDragElement);
|
||
multiDragElement.fromRect = dragRect;
|
||
fromSortable.removeAnimationState(multiDragElement);
|
||
});
|
||
$64afbd09cd65a300$var$folding = false;
|
||
$64afbd09cd65a300$var$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();
|
||
$64afbd09cd65a300$var$initialFolding = false; // If leaving sort:false root, or already folding - Fold to new location
|
||
if (options.animation && $64afbd09cd65a300$var$multiDragElements.length > 1 && ($64afbd09cd65a300$var$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 = $64afbd09cd65a300$var$getRect($64afbd09cd65a300$var$dragEl$1, false, true, true);
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
if (multiDragElement === $64afbd09cd65a300$var$dragEl$1) return;
|
||
$64afbd09cd65a300$var$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);
|
||
});
|
||
$64afbd09cd65a300$var$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 (!$64afbd09cd65a300$var$folding) $64afbd09cd65a300$var$removeMultiDragElements();
|
||
if ($64afbd09cd65a300$var$multiDragElements.length > 1) {
|
||
var clonesHiddenBefore = $64afbd09cd65a300$var$clonesHidden;
|
||
activeSortable._showClone(sortable); // Unfold animation for clones if showing from hidden
|
||
if (activeSortable.options.animation && !$64afbd09cd65a300$var$clonesHidden && clonesHiddenBefore) $64afbd09cd65a300$var$multiDragClones.forEach(function(clone) {
|
||
activeSortable.addAnimationState({
|
||
target: clone,
|
||
rect: $64afbd09cd65a300$var$clonesFromRect
|
||
});
|
||
clone.fromRect = $64afbd09cd65a300$var$clonesFromRect;
|
||
clone.thisAnimationDuration = null;
|
||
});
|
||
} else activeSortable._showClone(sortable);
|
||
}
|
||
}
|
||
},
|
||
dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
|
||
var dragRect = _ref11.dragRect, isOwner = _ref11.isOwner, activeSortable = _ref11.activeSortable;
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
multiDragElement.thisAnimationDuration = null;
|
||
});
|
||
if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
|
||
$64afbd09cd65a300$var$clonesFromRect = $64afbd09cd65a300$var$_extends({}, dragRect);
|
||
var dragMatrix = $64afbd09cd65a300$var$matrix($64afbd09cd65a300$var$dragEl$1, true);
|
||
$64afbd09cd65a300$var$clonesFromRect.top -= dragMatrix.f;
|
||
$64afbd09cd65a300$var$clonesFromRect.left -= dragMatrix.e;
|
||
}
|
||
},
|
||
dragOverAnimationComplete: function dragOverAnimationComplete() {
|
||
if ($64afbd09cd65a300$var$folding) {
|
||
$64afbd09cd65a300$var$folding = false;
|
||
$64afbd09cd65a300$var$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 (!$64afbd09cd65a300$var$dragStarted) {
|
||
if (options.multiDragKey && !this.multiDragKeyDown) this._deselectMultiDrag();
|
||
$64afbd09cd65a300$var$toggleClass($64afbd09cd65a300$var$dragEl$1, options.selectedClass, !~$64afbd09cd65a300$var$multiDragElements.indexOf($64afbd09cd65a300$var$dragEl$1));
|
||
if (!~$64afbd09cd65a300$var$multiDragElements.indexOf($64afbd09cd65a300$var$dragEl$1)) {
|
||
$64afbd09cd65a300$var$multiDragElements.push($64afbd09cd65a300$var$dragEl$1);
|
||
$64afbd09cd65a300$var$dispatchEvent({
|
||
sortable: sortable,
|
||
rootEl: rootEl,
|
||
name: "select",
|
||
targetEl: $64afbd09cd65a300$var$dragEl$1,
|
||
originalEvent: evt
|
||
}); // Modifier activated, select from last to dragEl
|
||
if (evt.shiftKey && $64afbd09cd65a300$var$lastMultiDragSelect && sortable.el.contains($64afbd09cd65a300$var$lastMultiDragSelect)) {
|
||
var lastIndex = $64afbd09cd65a300$var$index($64afbd09cd65a300$var$lastMultiDragSelect), currentIndex = $64afbd09cd65a300$var$index($64afbd09cd65a300$var$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 (~$64afbd09cd65a300$var$multiDragElements.indexOf(children[i])) continue;
|
||
$64afbd09cd65a300$var$toggleClass(children[i], options.selectedClass, true);
|
||
$64afbd09cd65a300$var$multiDragElements.push(children[i]);
|
||
$64afbd09cd65a300$var$dispatchEvent({
|
||
sortable: sortable,
|
||
rootEl: rootEl,
|
||
name: "select",
|
||
targetEl: children[i],
|
||
originalEvent: evt
|
||
});
|
||
}
|
||
}
|
||
} else $64afbd09cd65a300$var$lastMultiDragSelect = $64afbd09cd65a300$var$dragEl$1;
|
||
$64afbd09cd65a300$var$multiDragSortable = toSortable;
|
||
} else {
|
||
$64afbd09cd65a300$var$multiDragElements.splice($64afbd09cd65a300$var$multiDragElements.indexOf($64afbd09cd65a300$var$dragEl$1), 1);
|
||
$64afbd09cd65a300$var$lastMultiDragSelect = null;
|
||
$64afbd09cd65a300$var$dispatchEvent({
|
||
sortable: sortable,
|
||
rootEl: rootEl,
|
||
name: "deselect",
|
||
targetEl: $64afbd09cd65a300$var$dragEl$1,
|
||
originalEvent: evt
|
||
});
|
||
}
|
||
} // Multi-drag drop
|
||
if ($64afbd09cd65a300$var$dragStarted && this.isMultiDrag) {
|
||
$64afbd09cd65a300$var$folding = false; // Do not "unfold" after around dragEl if reverted
|
||
if ((parentEl[$64afbd09cd65a300$var$expando].options.sort || parentEl !== rootEl) && $64afbd09cd65a300$var$multiDragElements.length > 1) {
|
||
var dragRect = $64afbd09cd65a300$var$getRect($64afbd09cd65a300$var$dragEl$1), multiDragIndex = $64afbd09cd65a300$var$index($64afbd09cd65a300$var$dragEl$1, ":not(." + this.options.selectedClass + ")");
|
||
if (!$64afbd09cd65a300$var$initialFolding && options.animation) $64afbd09cd65a300$var$dragEl$1.thisAnimationDuration = null;
|
||
toSortable.captureAnimationState();
|
||
if (!$64afbd09cd65a300$var$initialFolding) {
|
||
if (options.animation) {
|
||
$64afbd09cd65a300$var$dragEl$1.fromRect = dragRect;
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
multiDragElement.thisAnimationDuration = null;
|
||
if (multiDragElement !== $64afbd09cd65a300$var$dragEl$1) {
|
||
var rect = $64afbd09cd65a300$var$folding ? $64afbd09cd65a300$var$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
|
||
$64afbd09cd65a300$var$removeMultiDragElements();
|
||
$64afbd09cd65a300$var$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 === $64afbd09cd65a300$var$index($64afbd09cd65a300$var$dragEl$1)) {
|
||
var update = false;
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
if (multiDragElement.sortableIndex !== $64afbd09cd65a300$var$index(multiDragElement)) {
|
||
update = true;
|
||
return;
|
||
}
|
||
});
|
||
if (update) dispatchSortableEvent("update");
|
||
}
|
||
} // Must be done after capturing individual rects (scroll bar)
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
$64afbd09cd65a300$var$unsetRect(multiDragElement);
|
||
});
|
||
toSortable.animateAll();
|
||
}
|
||
$64afbd09cd65a300$var$multiDragSortable = toSortable;
|
||
} // Remove clones if necessary
|
||
if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== "clone") $64afbd09cd65a300$var$multiDragClones.forEach(function(clone) {
|
||
clone.parentNode && clone.parentNode.removeChild(clone);
|
||
});
|
||
},
|
||
nullingGlobal: function nullingGlobal() {
|
||
this.isMultiDrag = $64afbd09cd65a300$var$dragStarted = false;
|
||
$64afbd09cd65a300$var$multiDragClones.length = 0;
|
||
},
|
||
destroyGlobal: function destroyGlobal() {
|
||
this._deselectMultiDrag();
|
||
$64afbd09cd65a300$var$off(document, "pointerup", this._deselectMultiDrag);
|
||
$64afbd09cd65a300$var$off(document, "mouseup", this._deselectMultiDrag);
|
||
$64afbd09cd65a300$var$off(document, "touchend", this._deselectMultiDrag);
|
||
$64afbd09cd65a300$var$off(document, "keydown", this._checkKeyDown);
|
||
$64afbd09cd65a300$var$off(document, "keyup", this._checkKeyUp);
|
||
},
|
||
_deselectMultiDrag: function _deselectMultiDrag(evt) {
|
||
if (typeof $64afbd09cd65a300$var$dragStarted !== "undefined" && $64afbd09cd65a300$var$dragStarted) return; // Only deselect if selection is in this sortable
|
||
if ($64afbd09cd65a300$var$multiDragSortable !== this.sortable) return; // Only deselect if target is not item in this sortable
|
||
if (evt && $64afbd09cd65a300$var$closest(evt.target, this.options.draggable, this.sortable.el, false)) return; // Only deselect if left click
|
||
if (evt && evt.button !== 0) return;
|
||
while($64afbd09cd65a300$var$multiDragElements.length){
|
||
var el = $64afbd09cd65a300$var$multiDragElements[0];
|
||
$64afbd09cd65a300$var$toggleClass(el, this.options.selectedClass, false);
|
||
$64afbd09cd65a300$var$multiDragElements.shift();
|
||
$64afbd09cd65a300$var$dispatchEvent({
|
||
sortable: this.sortable,
|
||
rootEl: this.sortable.el,
|
||
name: "deselect",
|
||
targetEl: el,
|
||
originalEvent: 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 $64afbd09cd65a300$var$_extends(MultiDrag, {
|
||
// Static methods & properties
|
||
pluginName: "multiDrag",
|
||
utils: {
|
||
/**
|
||
* Selects the provided multi-drag item
|
||
* @param {HTMLElement} el The element to be selected
|
||
*/ select: function select(el) {
|
||
var sortable = el.parentNode[$64afbd09cd65a300$var$expando];
|
||
if (!sortable || !sortable.options.multiDrag || ~$64afbd09cd65a300$var$multiDragElements.indexOf(el)) return;
|
||
if ($64afbd09cd65a300$var$multiDragSortable && $64afbd09cd65a300$var$multiDragSortable !== sortable) {
|
||
$64afbd09cd65a300$var$multiDragSortable.multiDrag._deselectMultiDrag();
|
||
$64afbd09cd65a300$var$multiDragSortable = sortable;
|
||
}
|
||
$64afbd09cd65a300$var$toggleClass(el, sortable.options.selectedClass, true);
|
||
$64afbd09cd65a300$var$multiDragElements.push(el);
|
||
},
|
||
/**
|
||
* Deselects the provided multi-drag item
|
||
* @param {HTMLElement} el The element to be deselected
|
||
*/ deselect: function deselect(el) {
|
||
var sortable = el.parentNode[$64afbd09cd65a300$var$expando], index = $64afbd09cd65a300$var$multiDragElements.indexOf(el);
|
||
if (!sortable || !sortable.options.multiDrag || !~index) return;
|
||
$64afbd09cd65a300$var$toggleClass(el, sortable.options.selectedClass, false);
|
||
$64afbd09cd65a300$var$multiDragElements.splice(index, 1);
|
||
}
|
||
},
|
||
eventProperties: function eventProperties() {
|
||
var _this3 = this;
|
||
var oldIndicies = [], newIndicies = [];
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
oldIndicies.push({
|
||
multiDragElement: multiDragElement,
|
||
index: multiDragElement.sortableIndex
|
||
}); // multiDragElements will already be sorted if folding
|
||
var newIndex;
|
||
if ($64afbd09cd65a300$var$folding && multiDragElement !== $64afbd09cd65a300$var$dragEl$1) newIndex = -1;
|
||
else if ($64afbd09cd65a300$var$folding) newIndex = $64afbd09cd65a300$var$index(multiDragElement, ":not(." + _this3.options.selectedClass + ")");
|
||
else newIndex = $64afbd09cd65a300$var$index(multiDragElement);
|
||
newIndicies.push({
|
||
multiDragElement: multiDragElement,
|
||
index: newIndex
|
||
});
|
||
});
|
||
return {
|
||
items: $64afbd09cd65a300$var$_toConsumableArray($64afbd09cd65a300$var$multiDragElements),
|
||
clones: [].concat($64afbd09cd65a300$var$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 $64afbd09cd65a300$var$insertMultiDragElements(clonesInserted, rootEl) {
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement, i) {
|
||
var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
|
||
if (target) rootEl.insertBefore(multiDragElement, target);
|
||
else rootEl.appendChild(multiDragElement);
|
||
});
|
||
}
|
||
/**
|
||
* Insert multi-drag clones
|
||
* @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
|
||
* @param {HTMLElement} rootEl
|
||
*/ function $64afbd09cd65a300$var$insertMultiDragClones(elementsInserted, rootEl) {
|
||
$64afbd09cd65a300$var$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 $64afbd09cd65a300$var$removeMultiDragElements() {
|
||
$64afbd09cd65a300$var$multiDragElements.forEach(function(multiDragElement) {
|
||
if (multiDragElement === $64afbd09cd65a300$var$dragEl$1) return;
|
||
multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
|
||
});
|
||
}
|
||
$64afbd09cd65a300$export$31b3ca70d8f57423.mount(new $64afbd09cd65a300$var$AutoScrollPlugin());
|
||
$64afbd09cd65a300$export$31b3ca70d8f57423.mount($64afbd09cd65a300$var$Remove, $64afbd09cd65a300$var$Revert);
|
||
var $64afbd09cd65a300$export$2e2bcd8739ae039 = $64afbd09cd65a300$export$31b3ca70d8f57423;
|
||
|
||
|
||
|
||
|
||
|
||
|
||
const $832f4be7bc001332$var$notify = new (0, $accfb6154319a04b$export$2e2bcd8739ae039)();
|
||
class $832f4be7bc001332$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(upload, input, imageList, fileList){
|
||
this.mm = new (0, $7e781a188206b2b3$export$2e2bcd8739ae039)(null, null, document.getElementById("notify-progress"));
|
||
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.mediaSort = (0, $64afbd09cd65a300$export$2e2bcd8739ae039).create(this.imageList, {
|
||
animation: 150,
|
||
onUpdate: ()=>{
|
||
//notify.alert('REINDEXING MEDIA', null);
|
||
//this.updateFiles();
|
||
}
|
||
});
|
||
this.fileSort = (0, $64afbd09cd65a300$export$2e2bcd8739ae039).create(this.fileList, {
|
||
animation: 150,
|
||
onUpdate: ()=>{
|
||
//notify.alert('REINDEXING FILES', null);
|
||
//this.updateFiles();
|
||
}
|
||
});
|
||
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);
|
||
var removeMedia = document.querySelectorAll(".media-remove");
|
||
for(var i = 0, length = removeMedia.length; i < length; i++)removeMedia[i].addEventListener("click", (e)=>this.removeFile(e, "media"), false);
|
||
}
|
||
getFileOrder() {
|
||
let imgList = "";
|
||
let fileList = "";
|
||
for(var i = 0, length = this.imageList.childNodes.length; i < length; i++){
|
||
let div = this.imageList.childNodes[i];
|
||
imgList = imgList + div.getAttribute("data-source") + ",";
|
||
}
|
||
for(var i = 0, length = this.fileList.childNodes.length; i < length; i++){
|
||
let div = this.fileList.childNodes[i];
|
||
fileList = fileList + div.getAttribute("data-source") + ",";
|
||
}
|
||
let media = {
|
||
images: imgList,
|
||
files: fileList
|
||
};
|
||
return media;
|
||
}
|
||
sortFiles(files) {
|
||
var self = this;
|
||
for(var i = 0, file; file = files[i]; i++){
|
||
var reader = new FileReader();
|
||
// Closure to capture the file information
|
||
reader.onload = ((theFile)=>{
|
||
return function(f) {
|
||
//create remove button object
|
||
var remove = document.createElement("button");
|
||
var removeIcon = document.createElement("i");
|
||
removeIcon.classList.add("ti", "ti-x");
|
||
remove.className = "media-remove";
|
||
remove.appendChild(removeIcon);
|
||
//remove.setAttribute('id', mediaCount);
|
||
remove.addEventListener("click", (e)=>self.removeFile(e, "media"), false);
|
||
//upload the file
|
||
let upload = new FormData();
|
||
upload.enctype = "multipart/form-data";
|
||
upload.append("upload_files[]", theFile, theFile.name);
|
||
let item = null;
|
||
let progress = null;
|
||
// sort files
|
||
switch(theFile.type){
|
||
case "image/jpg":
|
||
case "image/jpeg":
|
||
case "image/gif":
|
||
case "image/svg":
|
||
case "image/png":
|
||
item = self.itemFactory("img-item");
|
||
progress = document.getElementById("pgs" + item.getAttribute("id"));
|
||
self.mm.filesUpload(theFile.type, upload, progress).then((result)=>{
|
||
item.setAttribute("data-source", result.filePath);
|
||
item.style.background = "url(" + f.target.result + ") no-repeat center center / cover";
|
||
(0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: progress,
|
||
width: 0,
|
||
easing: "easeInOutQuint",
|
||
duration: 1000,
|
||
complete: ()=>{
|
||
item.removeChild(progress);
|
||
item.appendChild(remove);
|
||
}
|
||
});
|
||
});
|
||
break;
|
||
case "video/mp4":
|
||
item = self.itemFactory("video-item");
|
||
progress = document.getElementById("pgs" + item.getAttribute("id"));
|
||
self.mm.filesUpload(theFile.type, upload, progress).then((result)=>{
|
||
item.setAttribute("data-source", result.filePath);
|
||
let video = document.createElement("video");
|
||
let source = document.createElement("source");
|
||
source.src = f.target.result;
|
||
video.appendChild(source);
|
||
item.appendChild(video);
|
||
(0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: progress,
|
||
width: 0,
|
||
easing: "easeInOutQuint",
|
||
duration: 1000,
|
||
complete: ()=>{
|
||
item.removeChild(progress);
|
||
item.appendChild(remove);
|
||
}
|
||
});
|
||
});
|
||
break;
|
||
case "audio/mpeg":
|
||
item = self.itemFactory("audio-item");
|
||
progress = document.getElementById("pgs" + item.getAttribute("id"));
|
||
self.mm.filesUpload(theFile.type, upload, progress).then((result)=>{
|
||
item.setAttribute("data-source", result.filePath);
|
||
let audio = document.createElement("audio");
|
||
audio.setAttribute("controls", true);
|
||
let source = document.createElement("source");
|
||
source.src = f.target.result;
|
||
audio.appendChild(source);
|
||
item.appendChild(audio);
|
||
(0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: progress,
|
||
width: 0,
|
||
easing: "easeInOutQuint",
|
||
duration: 1000,
|
||
complete: ()=>{
|
||
item.removeChild(progress);
|
||
item.appendChild(remove);
|
||
}
|
||
});
|
||
});
|
||
break;
|
||
case "application/pdf":
|
||
case "text/plain":
|
||
case "text/rtf":
|
||
item = self.itemFactory("file-item");
|
||
progress = document.getElementById("pgs" + item.getAttribute("id"));
|
||
self.mm.filesUpload(theFile.type, upload, progress).then((result)=>{
|
||
item.setAttribute("data-source", result.filePath);
|
||
let link = document.createElement("a");
|
||
link.href = result.filePath;
|
||
link.innerHTML = result.fileName;
|
||
item.appendChild(link);
|
||
(0, $8b9e2899b2e82f52$export$2e2bcd8739ae039)({
|
||
targets: progress,
|
||
width: 0,
|
||
easing: "easeInOutQuint",
|
||
duration: 1000,
|
||
complete: ()=>{
|
||
item.removeChild(progress);
|
||
item.appendChild(remove);
|
||
}
|
||
});
|
||
});
|
||
break;
|
||
}
|
||
};
|
||
})(file);
|
||
// Read in the image file as a data URL.
|
||
reader.readAsDataURL(file);
|
||
}
|
||
}
|
||
itemFactory(type = null) {
|
||
//get counts for lists
|
||
var mediaCount = this.imageList.childNodes.length;
|
||
var fileCount = this.fileList.childNodes.length;
|
||
if (mediaCount < 0) mediaCount = 0;
|
||
if (fileCount < 0) fileCount = 0;
|
||
var item = document.createElement("div");
|
||
item.className = type;
|
||
var progress = document.createElement("div");
|
||
progress.className = "item-progress";
|
||
item.appendChild(progress);
|
||
if (type == "img-item" || type == "video-item") {
|
||
this.imageList.appendChild(item);
|
||
progress.setAttribute("id", "pgs" + mediaCount);
|
||
item.setAttribute("id", mediaCount);
|
||
} else {
|
||
this.fileList.appendChild(item);
|
||
progress.setAttribute("id", "pgs" + fileCount);
|
||
item.setAttribute("id", fileCount);
|
||
}
|
||
return item;
|
||
}
|
||
//--------------------------
|
||
// event handlers
|
||
//--------------------------
|
||
removeFile(e) {
|
||
var item = e.target.parentNode.parentNode;
|
||
switch(item.className){
|
||
case "img-item":
|
||
case "video-item":
|
||
this.imageList.removeChild(item);
|
||
break;
|
||
case "audio-item":
|
||
case "file-item":
|
||
this.fileList.removeChild(item);
|
||
break;
|
||
}
|
||
$832f4be7bc001332$var$notify.alert("File Removed!", true);
|
||
}
|
||
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;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
const $371d2518d50c1748$var$notify = new (0, $accfb6154319a04b$export$2e2bcd8739ae039)();
|
||
class $371d2518d50c1748$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(){
|
||
this.processing = false;
|
||
let self = "this";
|
||
this.admin = new (0, $cbea55afea03b976$export$2e2bcd8739ae039)(null, document.getElementById("notify-progress"));
|
||
this.mm = new (0, $7e781a188206b2b3$export$2e2bcd8739ae039)(null, null);
|
||
this.urlPieces = document.URL.split("/");
|
||
this.post = [];
|
||
this.postID = null;
|
||
this.postUUID = null;
|
||
this.postLayout = null;
|
||
this.fm = null;
|
||
if (document.querySelector('[role="file-manager"]').getAttribute("data-index")) {
|
||
this.postID = document.querySelector('[role="file-manager"]').getAttribute("data-index");
|
||
this.postUUID = document.querySelector('[role="file-manager"]').getAttribute("data-uuid");
|
||
this.postLayout = document.querySelector('[role="file-manager"]').getAttribute("data-layout");
|
||
}
|
||
if (document.getElementById("edit")) {
|
||
this.editor = new (0, $e6c02983873e6cdf$export$2e2bcd8739ae039)(document.getElementById("edit"), document.querySelector('[role="file-manager"]').offsetHeight + document.querySelector('[role="page-meta"]').offsetHeight + document.querySelector('[role="text-editor"]').offsetHeight);
|
||
this.editor.addListener($0d6abf40542266b3$export$e0c06b1ddd9992cc, ()=>this.handleEditorOptions($0d6abf40542266b3$export$e0c06b1ddd9992cc), false);
|
||
this.editor.addListener($0d6abf40542266b3$export$80082ca64f03d0e9, ()=>this.handleEditorOptions($0d6abf40542266b3$export$80082ca64f03d0e9), false);
|
||
this.editor.addListener($0d6abf40542266b3$export$14580fc61246740, ()=>this.handleEditorOptions($0d6abf40542266b3$export$14580fc61246740), false);
|
||
this.editor.addListener($0d6abf40542266b3$export$1844db352cf5aef3, ()=>this.handleEditorOptions($0d6abf40542266b3$export$1844db352cf5aef3), 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);
|
||
}
|
||
});
|
||
*/ this.start();
|
||
}
|
||
}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
start() {
|
||
if (document.querySelector('[role="file-drop"]')) {
|
||
//insert fileManager here
|
||
this.fm = new (0, $832f4be7bc001332$export$2e2bcd8739ae039)(document.querySelector('[role="file-drop"]'), document.getElementById("page-files-upload"), document.querySelector('[role="page-images-list"]'), document.querySelector('[role="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(e) {
|
||
if (this.processing) return;
|
||
let self = this;
|
||
switch(e){
|
||
case $0d6abf40542266b3$export$1844db352cf5aef3:
|
||
case $0d6abf40542266b3$export$14580fc61246740:
|
||
var task = "";
|
||
e === $0d6abf40542266b3$export$1844db352cf5aef3 ? task = (0, $cbea55afea03b976$export$f06e28eb004ce525) : task = (0, $cbea55afea03b976$export$a01fefcc831953fa);
|
||
new (0, $de01a7e5b1773530$export$2e2bcd8739ae039)().collectInfo(this.fm.getFileOrder()).then((page)=>{
|
||
self.processing = true;
|
||
$371d2518d50c1748$var$notify.alert("Writing down changes", null);
|
||
self.admin.pageActions(task, page).then((r)=>{
|
||
self.processing = false;
|
||
if (r.type === $995f55a4eccd256d$export$a9707c9559ca4612 || r.type === $995f55a4eccd256d$export$8829e15ac416fcee) $371d2518d50c1748$var$notify.alert(r.message, false);
|
||
else if (r.type === $995f55a4eccd256d$export$f88aea22a746eab) $371d2518d50c1748$var$notify.alert(r.message, true);
|
||
else {
|
||
$371d2518d50c1748$var$notify.alert(r.message, true);
|
||
window.location = "/dashboard/page/edit/" + r.id;
|
||
}
|
||
}).catch((err)=>{
|
||
self.processing = false;
|
||
$371d2518d50c1748$var$notify.alert(err, false);
|
||
});
|
||
});
|
||
break;
|
||
case $0d6abf40542266b3$export$e0c06b1ddd9992cc:
|
||
if (this.postLayout === "index") {
|
||
$371d2518d50c1748$var$notify.alert("Index cannot be deleted", false);
|
||
return;
|
||
}
|
||
if (confirm("AYE! You know you're deleting this post, right?")) new (0, $de01a7e5b1773530$export$2e2bcd8739ae039)().collectInfo(this.fm.getFileOrder()).then((page)=>{
|
||
self.processing = true;
|
||
this.admin.pageActions((0, $cbea55afea03b976$export$f9aea0c55bfa15c9), page).then(()=>{
|
||
self.processing = false;
|
||
window.location = "/dashboard/pages";
|
||
}).catch((err)=>{
|
||
self.processing = false;
|
||
$371d2518d50c1748$var$notify.alert(err, false);
|
||
});
|
||
}).catch(()=>{});
|
||
break;
|
||
case $0d6abf40542266b3$export$80082ca64f03d0e9:
|
||
document.getElementById("post-image-upload").click();
|
||
break;
|
||
}
|
||
}
|
||
handleImageUpload(type, files) {
|
||
let self = this;
|
||
$371d2518d50c1748$var$notify.alert("Uploading Image", null);
|
||
let upload = new FormData();
|
||
upload.enctype = "multipart/form-data";
|
||
upload.append("upload_files[]", files[0], files[0].name);
|
||
this.mm.filesUpload(files[0].type, upload).then((result)=>{
|
||
if (result.message == "File Uploaded. Great!") {
|
||
self.editor.notify($0d6abf40542266b3$export$80082ca64f03d0e9, result.filePath);
|
||
$371d2518d50c1748$var$notify.alert("Image Added to Entry", true);
|
||
} else $371d2518d50c1748$var$notify.alert("Uh oh. Image not added", false);
|
||
}).catch(()=>{
|
||
$371d2518d50c1748$var$notify.alert("Uh oh. Image not added", false);
|
||
});
|
||
}
|
||
}
|
||
|
||
|
||
class $00028bbb7da2e80b$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(page){
|
||
this.currentPage = null;
|
||
this.choosePage(page);
|
||
this.start();
|
||
}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
start() {}
|
||
choosePage(page) {
|
||
this.currentPage = "";
|
||
switch(page){
|
||
case "edit":
|
||
case "add":
|
||
this.currentPage = new (0, $371d2518d50c1748$export$2e2bcd8739ae039)();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
class $8a9e11caee7219b1$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// 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.querySelector('[role="background"]').style.backgroundImage.slice(4, -1).replace(/"/g, "");
|
||
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);
|
||
});
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
const $18b11b34820682a5$var$notify = new (0, $accfb6154319a04b$export$2e2bcd8739ae039)();
|
||
class $18b11b34820682a5$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(){}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
sendMail() {
|
||
let mailData = {
|
||
content: "This is a test email"
|
||
};
|
||
let admin = new (0, $cbea55afea03b976$export$2e2bcd8739ae039)();
|
||
admin.sendMail(mailData).then((result)=>{
|
||
$18b11b34820682a5$var$notify.alert(result.message, true);
|
||
}).catch((err)=>{
|
||
$18b11b34820682a5$var$notify.alert(err.message, false);
|
||
});
|
||
}
|
||
testMail() {
|
||
let mailData = {
|
||
content: "This is a test email",
|
||
mail_task: "TESTING"
|
||
};
|
||
let admin = new (0, $cbea55afea03b976$export$2e2bcd8739ae039)();
|
||
admin.sendMail(mailData).then((result)=>{
|
||
$18b11b34820682a5$var$notify.alert(result.message, true);
|
||
}).catch((err)=>{
|
||
$18b11b34820682a5$var$notify.alert(err.message, false);
|
||
});
|
||
}
|
||
}
|
||
|
||
|
||
|
||
const $b33d1a942dce8554$var$notify = new (0, $accfb6154319a04b$export$2e2bcd8739ae039)();
|
||
class $b33d1a942dce8554$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(){
|
||
this.processing = false;
|
||
this.start();
|
||
this.admin = new (0, $cbea55afea03b976$export$2e2bcd8739ae039)(null);
|
||
this.mm = new (0, $7e781a188206b2b3$export$2e2bcd8739ae039)(null, null);
|
||
}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
start() {
|
||
let self = this;
|
||
//handle save button
|
||
document.getElementById("save-toggle").addEventListener("click", ()=>new (0, $8a9e11caee7219b1$export$2e2bcd8739ae039)().getInfo().then((data)=>{
|
||
$b33d1a942dce8554$var$notify.alert("Saving Settings", null);
|
||
self.admin.sync((0, $cbea55afea03b976$export$ff4a0df6152bf850), data).then((r)=>{
|
||
if (r.type == $995f55a4eccd256d$export$5dd76fd38bbe7841) $b33d1a942dce8554$var$notify.alert(r.message, true);
|
||
else $b33d1a942dce8554$var$notify.alert(r.message, true);
|
||
});
|
||
}).catch(()=>{
|
||
//console.log(err);
|
||
}));
|
||
//handle set up image uploads
|
||
document.querySelector('[role="avatar"]').addEventListener("click", ()=>{
|
||
document.getElementById("avatar-upload").click();
|
||
});
|
||
document.querySelector('[role="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 = "API ACCESS IS ENABLED";
|
||
} else {
|
||
apiButton.setAttribute("data-enabled", "false");
|
||
apiStatus.innerHTML = "API ACCESS IS DISABLED";
|
||
}
|
||
});
|
||
//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));
|
||
//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(e) {
|
||
e.stopPropagation();
|
||
e.preventDefault();
|
||
let button = document.getElementById("render-toggle");
|
||
if (button.getAttribute("data-render") == "false") button.setAttribute("data-render", "true");
|
||
else button.setAttribute("data-render", "false");
|
||
}
|
||
handleMailer() {
|
||
let mailer = new (0, $18b11b34820682a5$export$2e2bcd8739ae039)();
|
||
mailer.testMail();
|
||
//mailer.sendMail();
|
||
}
|
||
handleThemes(e) {
|
||
e.stopPropagation();
|
||
e.preventDefault();
|
||
let themes = document.querySelectorAll(".theme-select");
|
||
for(var i = 0, length = themes.length; i < length; i++)e.target.id == themes[i].id ? themes[i].setAttribute("data-enabled", "true") : themes[i].setAttribute("data-enabled", "false");
|
||
}
|
||
handleMailOptions(e) {
|
||
e.preventDefault();
|
||
e.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 (e.target.id == mail[i].id) {
|
||
mail[i].setAttribute("data-enabled", "true");
|
||
if (e.target.id == "option-smtp") {
|
||
smtp.setAttribute("data-enabled", "true");
|
||
mailgun.setAttribute("data-enabled", "false");
|
||
} else if (e.target.id == "option-none") {
|
||
smtp.setAttribute("data-enabled", "false");
|
||
mailgun.setAttribute("data-enabled", "false");
|
||
} else {
|
||
smtp.setAttribute("data-enabled", "false");
|
||
mailgun.setAttribute("data-enabled", "true");
|
||
}
|
||
} else mail[i].setAttribute("data-enabled", "false");
|
||
}
|
||
handleImageUpload(type, files) {
|
||
$b33d1a942dce8554$var$notify.alert("Uploading Image... ", null);
|
||
let self = this;
|
||
$b33d1a942dce8554$var$notify.alert("Uploading Image", null);
|
||
let upload = new FormData();
|
||
upload.enctype = "multipart/form-data";
|
||
upload.append("source", type);
|
||
upload.append("upload_files[]", files[0], files[0].name);
|
||
this.mm.filesUpload(files[0].type, upload).then((r)=>{
|
||
if (type == "avatar-upload") {
|
||
$b33d1a942dce8554$var$notify.alert(r.message, true);
|
||
document.querySelector('[role="avatar"]').style.background = "url(" + r.filePath + ") no-repeat center center / cover";
|
||
} else {
|
||
$b33d1a942dce8554$var$notify.alert(r.message, true);
|
||
document.querySelector('[role="background"]').style.background = "url(" + r.filePath + ") no-repeat center center / cover";
|
||
}
|
||
}).catch(()=>{
|
||
//console.log(err)
|
||
});
|
||
}
|
||
handlePublished(e) {
|
||
if (this.processing) return;
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
let self = this;
|
||
let task = {
|
||
task: "PUBLISH_ALL"
|
||
};
|
||
this.processing = true;
|
||
$b33d1a942dce8554$var$notify.alert("Publishing site...", null);
|
||
this.admin.publish(task).then((r)=>{
|
||
self.processing = false;
|
||
$b33d1a942dce8554$var$notify.alert(r.message, true);
|
||
}).catch((err)=>{
|
||
self.processing = false;
|
||
$b33d1a942dce8554$var$notify.alert(err, false);
|
||
});
|
||
}
|
||
handleBackup(e) {
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
$b33d1a942dce8554$var$notify.alert("Creating backup", null);
|
||
this.mm.backup().then((r)=>{
|
||
$b33d1a942dce8554$var$notify.alert(r.message, true);
|
||
}).catch((err)=>{
|
||
$b33d1a942dce8554$var$notify.alert(err, false);
|
||
});
|
||
}
|
||
handleReindex(e) {
|
||
if (this.processing) return;
|
||
let self = this;
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
let task = {
|
||
task: "cleanup pages indexes"
|
||
};
|
||
this.processing = true;
|
||
$b33d1a942dce8554$var$notify.alert("Cleaning up page indexes", null);
|
||
this.admin.handleReindex(task).then((r)=>{
|
||
self.processing = false;
|
||
$b33d1a942dce8554$var$notify.alert(r.message, true);
|
||
}).catch((err)=>{
|
||
self.processing = false;
|
||
$b33d1a942dce8554$var$notify.alert(err, false);
|
||
});
|
||
}
|
||
}
|
||
|
||
|
||
|
||
class $24d614592ba94b67$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(){}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
syncMenu() {
|
||
let navData = [];
|
||
let items = document.getElementById("nav-items").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-items").removeChild(document.getElementById(id));
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
const $18c0afb4f3b7cd5c$var$notify = new (0, $accfb6154319a04b$export$2e2bcd8739ae039)();
|
||
class $18c0afb4f3b7cd5c$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(){
|
||
this.processing = false;
|
||
this.admin = new (0, $cbea55afea03b976$export$2e2bcd8739ae039)(null);
|
||
this.start();
|
||
}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
start() {
|
||
//grabs elements and makes them sortables
|
||
let self = this;
|
||
(0, $64afbd09cd65a300$export$2e2bcd8739ae039).create(document.getElementById("nav-items"), {
|
||
onUpdate: ()=>{
|
||
new (0, $24d614592ba94b67$export$2e2bcd8739ae039)().syncMenu().then((data)=>{
|
||
$18c0afb4f3b7cd5c$var$notify.alert("Updating Menu", null);
|
||
self.admin.sync((0, $cbea55afea03b976$export$67799ce3e3352ee1), data).then((r)=>{
|
||
if (r.type == $995f55a4eccd256d$export$d4fd546d3456ff85) $18c0afb4f3b7cd5c$var$notify.alert(r.message, true);
|
||
else $18c0afb4f3b7cd5c$var$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 (0, $24d614592ba94b67$export$2e2bcd8739ae039)().removeItem(id);
|
||
new (0, $24d614592ba94b67$export$2e2bcd8739ae039)().syncMenu().then((data)=>{
|
||
data.remove = e.target.getAttribute("data-uuid");
|
||
$18c0afb4f3b7cd5c$var$notify.alert("Editing Menu", null);
|
||
self.processing = true;
|
||
self.admin.sync((0, $cbea55afea03b976$export$67799ce3e3352ee1), data).then((r)=>{
|
||
self.processing = false;
|
||
if (r.type == $995f55a4eccd256d$export$d4fd546d3456ff85) $18c0afb4f3b7cd5c$var$notify.alert(r.message, true);
|
||
else $18c0afb4f3b7cd5c$var$notify.alert(r.message, true);
|
||
});
|
||
});
|
||
break;
|
||
case "edit-item":
|
||
self.processing = false;
|
||
window.location = "/dashboard/page/edit/" + e.target.getAttribute("data-id");
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
class $f32c20539eb29606$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(){
|
||
this.mobile = false;
|
||
this.mobileMenu = document.querySelector(".mobile-menu");
|
||
document.querySelector(".menu-toggle").addEventListener("click", (e)=>this.handleMobile(e));
|
||
}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
start() {}
|
||
//--------------------------
|
||
// event handlers
|
||
//--------------------------
|
||
handleMobile(e) {
|
||
if (this.mobile) {
|
||
this.mobile = false;
|
||
this.mobileMenu.style.display = "none";
|
||
} else {
|
||
this.mobile = true;
|
||
this.mobileMenu.style.display = "inline";
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
class $129a4dc28afb9101$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(){
|
||
this.currentDisplay = "";
|
||
this.urlPieces = document.URL.split("/");
|
||
this.chooseDisplay(this.urlPieces[4], this.urlPieces[5]);
|
||
//start main menu handler
|
||
new (0, $f32c20539eb29606$export$2e2bcd8739ae039)();
|
||
}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
start() {}
|
||
chooseDisplay(section, page) {
|
||
this.currentDisplay = "";
|
||
switch(section){
|
||
case "page":
|
||
this.currentDisplay = new (0, $00028bbb7da2e80b$export$2e2bcd8739ae039)(page);
|
||
break;
|
||
case "settings":
|
||
this.currentDisplay = new (0, $b33d1a942dce8554$export$2e2bcd8739ae039)();
|
||
break;
|
||
case "navigation":
|
||
this.currentDisplay = new (0, $18c0afb4f3b7cd5c$export$2e2bcd8739ae039)();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
this.start();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
const $5ec7c34d3cbf8bc6$var$data = new (0, $f177b50aa405d296$export$2e2bcd8739ae039)();
|
||
const $5ec7c34d3cbf8bc6$var$notify = new (0, $accfb6154319a04b$export$2e2bcd8739ae039)();
|
||
class $5ec7c34d3cbf8bc6$export$2e2bcd8739ae039 {
|
||
//--------------------------
|
||
// constructor
|
||
//--------------------------
|
||
constructor(){
|
||
this.processing = false;
|
||
this.start();
|
||
}
|
||
//--------------------------
|
||
// methods
|
||
//--------------------------
|
||
//TODO: Move init functions and set up to their own class
|
||
start() {
|
||
if (document.getElementById("login") || document.querySelector('[role="site-restore"]')) {
|
||
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("login")) 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 (0, $129a4dc28afb9101$export$2e2bcd8739ae039)();
|
||
}
|
||
//--------------------------
|
||
// event handlers
|
||
//--------------------------
|
||
handleLogin(e) {
|
||
if (this.processing) return;
|
||
let self = this;
|
||
e.preventDefault();
|
||
let authForm = $5ec7c34d3cbf8bc6$var$data.formDataToJSON(document.getElementById("login"));
|
||
//notify.alert('Looking, hold up', null);
|
||
let api = new (0, $cbea55afea03b976$export$2e2bcd8739ae039)();
|
||
this.processing = true;
|
||
api.login(authForm).then((response)=>{
|
||
self.processing = false;
|
||
if (response.type === $995f55a4eccd256d$export$f99ec790401d28da) e.target.innerHTML = response.message;
|
||
else {
|
||
e.target.innerHTML = response.message;
|
||
setTimeout(()=>{
|
||
window.location = "/dashboard";
|
||
}, 500);
|
||
}
|
||
}).catch((err)=>{
|
||
self.processing = false;
|
||
});
|
||
}
|
||
handleSetup(e) {
|
||
if (this.processing) return;
|
||
let self = this;
|
||
e.stopPropagation();
|
||
e.preventDefault();
|
||
let setUpForm = $5ec7c34d3cbf8bc6$var$data.formDataToJSON(document.getElementById("init-form"));
|
||
let mm = new (0, $7e781a188206b2b3$export$2e2bcd8739ae039)();
|
||
this.processing = true;
|
||
mm.create(setUpForm).then((response)=>{
|
||
if (response.type === $995f55a4eccd256d$export$74a5c30fa9753d80) {
|
||
self.processing = false;
|
||
e.target.innerHTML = response.message;
|
||
} else {
|
||
self.processing = false;
|
||
e.target.innerHTML = response.message;
|
||
setTimeout(()=>{
|
||
window.location = "/dashboard";
|
||
}, 700);
|
||
}
|
||
}).catch((err)=>{
|
||
self.processing = false;
|
||
//notify.alert(err, false);
|
||
});
|
||
}
|
||
handleRestore(e) {
|
||
if (this.processing) return;
|
||
let self = this;
|
||
e.stopPropagation();
|
||
e.preventDefault();
|
||
let mm = new (0, $7e781a188206b2b3$export$2e2bcd8739ae039)();
|
||
var form = document.getElementById("init-restore");
|
||
this.processing = true;
|
||
mm.restore(form).then((response)=>{
|
||
if (response.type === $995f55a4eccd256d$export$f99ec790401d28da) {
|
||
self.processing = false;
|
||
e.target.innerHTML = response.message;
|
||
} else {
|
||
self.processing = false;
|
||
e.target.innerHTML = response.message;
|
||
setTimeout(()=>{
|
||
window.location = "/dashboard";
|
||
}, 1500);
|
||
}
|
||
}).catch((err)=>{
|
||
self.processing = false;
|
||
e.target.innerHTML = err;
|
||
});
|
||
}
|
||
handleReset(e) {
|
||
e.stopPropagation();
|
||
e.preventDefault();
|
||
let self = this;
|
||
let mm = new (0, $7e781a188206b2b3$export$2e2bcd8739ae039)();
|
||
if (e.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;
|
||
$5ec7c34d3cbf8bc6$var$notify.alert(response.message, true);
|
||
} else if (response.type == "mailSent") $5ec7c34d3cbf8bc6$var$notify.alert(response.message, true);
|
||
else $5ec7c34d3cbf8bc6$var$notify.alert(response.message, false);
|
||
}).catch((err)=>{
|
||
self.processing = false;
|
||
$5ec7c34d3cbf8bc6$var$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") $5ec7c34d3cbf8bc6$var$notify.alert(response.message, false);
|
||
else {
|
||
$5ec7c34d3cbf8bc6$var$notify.alert(response.message, true);
|
||
setTimeout(()=>{
|
||
window.location = "/dashboard";
|
||
}, 1000);
|
||
}
|
||
}).catch((err)=>{
|
||
self.processing = false;
|
||
$5ec7c34d3cbf8bc6$var$notify.alert(err, false);
|
||
});
|
||
}
|
||
}
|
||
handleOptions(e) {
|
||
e.stopPropagation();
|
||
e.preventDefault();
|
||
let init = document.querySelector('[role="restore-fresh"]');
|
||
let restore = document.querySelector('[role="restore-backup"]');
|
||
if (e.target.id === "init-switch-restore") {
|
||
init.style.display = "none";
|
||
init.style.visibility = "hidden";
|
||
restore.style.display = "grid";
|
||
restore.style.visibility = "visible";
|
||
} else {
|
||
init.style.display = "grid";
|
||
init.style.visibility = "visible";
|
||
restore.style.display = "none";
|
||
restore.style.visibility = "hidden";
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
document.addEventListener("DOMContentLoaded", function() {
|
||
new (0, $5ec7c34d3cbf8bc6$export$2e2bcd8739ae039)();
|
||
}, false);
|
||
|
||
|
||
//# sourceMappingURL=dash.js.map
|