From 99db0dde71bed530c91fcd3165a4caa97d541f92 Mon Sep 17 00:00:00 2001 From: Ro Date: Sun, 11 Nov 2018 14:49:26 -0500 Subject: [PATCH] moved custom tools to brain, got rid of react extensions, converted custom tools to es6 --- .gitignore | 4 +- brain/api/content/bookmarks.js | 168 ++ brain/api/content/folio.js | 235 +++ brain/api/content/mailer.js | 41 + brain/api/content/posts.js | 345 ++++ brain/api/content/project.js | 180 ++ brain/routes/back/index.js | 11 +- .../tools/effects/Animate.js | 0 .../tools/effects/TextEffects.js | 0 .../tools/events/AuthEvent.js | 0 .../tools/events/DataEvent.js | 0 .../tools/events/EditorEvent.js | 0 .../tools/events/EventEmitter.js | 0 .../tools/ui/Slideshow.js | 0 .../tools/ui/TextEditor.js | 2 +- .../tools/utilities/DOMUtils.js | 0 .../tools/utilities/DataUtils.js | 0 .../tools/utilities/DateUtils.js | 0 brain/tools/utilities/RightsManager.js | 154 ++ .../tools/utilities/StringUtils.js | 0 brain/utils/DateUtils.js | 100 - brain/utils/RightsManager.js | 112 -- package-lock.json | 5 + package.json | 5 +- themes/dash/assets/js/dash.min.js | 1779 +++++++++-------- themes/dash/assets/js/dash.min.map | 2 +- themes/dash/post-edit.pug | 2 +- themes/dash/src/com/{Base.jsx => Base.js} | 19 +- themes/dash/src/com/{Start.jsx => Start.js} | 0 .../src/com/actions/{Mailer.jsx => Mailer.js} | 0 .../{PostActions.jsx => PostActions.js} | 49 +- .../{ProjectFolio.jsx => ProjectFolio.js} | 0 .../actions/{TaskFipamo.jsx => TaskFipamo.js} | 0 ...thentication.jsx => UserAuthentication.js} | 0 ...yAdminFipamo.jsx => DisplayAdminFipamo.js} | 0 ...layAdminFolio.jsx => DisplayAdminFolio.js} | 0 .../{DisplayBlog.jsx => DisplayBlog.js} | 0 .../{DisplayClient.jsx => DisplayClient.js} | 0 .../{DisplayFi.jsx => DisplayFi.js} | 0 .../{DisplayIndex.jsx => DisplayIndex.js} | 0 .../{DisplayManager.jsx => DisplayManager.js} | 10 +- .../{DisplayWork.jsx => DisplayWork.js} | 0 themes/dash/src/com/controllers/PostEditor.js | 274 +++ .../dash/src/com/controllers/PostEditor.jsx | 263 --- .../{PostIndex.jsx => PostIndex.js} | 0 45 files changed, 2400 insertions(+), 1360 deletions(-) create mode 100644 brain/api/content/bookmarks.js create mode 100644 brain/api/content/folio.js create mode 100644 brain/api/content/mailer.js create mode 100644 brain/api/content/posts.js create mode 100644 brain/api/content/project.js rename themes/dash/src/com/tools/effects/Animate.jsx => brain/tools/effects/Animate.js (100%) rename themes/dash/src/com/tools/effects/TextEffects.jsx => brain/tools/effects/TextEffects.js (100%) rename themes/dash/src/com/tools/events/AuthEvent.jsx => brain/tools/events/AuthEvent.js (100%) rename themes/dash/src/com/tools/events/DataEvent.jsx => brain/tools/events/DataEvent.js (100%) rename themes/dash/src/com/tools/events/EditorEvent.jsx => brain/tools/events/EditorEvent.js (100%) rename themes/dash/src/com/tools/events/EventEmitter.jsx => brain/tools/events/EventEmitter.js (100%) rename themes/dash/src/com/tools/ui/Slideshow.jsx => brain/tools/ui/Slideshow.js (100%) rename themes/dash/src/com/tools/utilities/TextEditor.jsx => brain/tools/ui/TextEditor.js (98%) rename themes/dash/src/com/tools/utilities/DOMUtils.jsx => brain/tools/utilities/DOMUtils.js (100%) rename themes/dash/src/com/tools/utilities/DataUtils.jsx => brain/tools/utilities/DataUtils.js (100%) rename themes/dash/src/com/tools/utilities/DateUtils.jsx => brain/tools/utilities/DateUtils.js (100%) create mode 100644 brain/tools/utilities/RightsManager.js rename themes/dash/src/com/tools/utilities/StringUtils.jsx => brain/tools/utilities/StringUtils.js (100%) delete mode 100644 brain/utils/DateUtils.js delete mode 100644 brain/utils/RightsManager.js rename themes/dash/src/com/{Base.jsx => Base.js} (77%) rename themes/dash/src/com/{Start.jsx => Start.js} (100%) rename themes/dash/src/com/actions/{Mailer.jsx => Mailer.js} (100%) rename themes/dash/src/com/actions/{PostActions.jsx => PostActions.js} (79%) rename themes/dash/src/com/actions/{ProjectFolio.jsx => ProjectFolio.js} (100%) rename themes/dash/src/com/actions/{TaskFipamo.jsx => TaskFipamo.js} (100%) rename themes/dash/src/com/actions/{UserAuthentication.jsx => UserAuthentication.js} (100%) rename themes/dash/src/com/controllers/{DisplayAdminFipamo.jsx => DisplayAdminFipamo.js} (100%) rename themes/dash/src/com/controllers/{DisplayAdminFolio.jsx => DisplayAdminFolio.js} (100%) rename themes/dash/src/com/controllers/{DisplayBlog.jsx => DisplayBlog.js} (100%) rename themes/dash/src/com/controllers/{DisplayClient.jsx => DisplayClient.js} (100%) rename themes/dash/src/com/controllers/{DisplayFi.jsx => DisplayFi.js} (100%) rename themes/dash/src/com/controllers/{DisplayIndex.jsx => DisplayIndex.js} (100%) rename themes/dash/src/com/controllers/{DisplayManager.jsx => DisplayManager.js} (90%) rename themes/dash/src/com/controllers/{DisplayWork.jsx => DisplayWork.js} (100%) create mode 100644 themes/dash/src/com/controllers/PostEditor.js delete mode 100644 themes/dash/src/com/controllers/PostEditor.jsx rename themes/dash/src/com/controllers/{PostIndex.jsx => PostIndex.js} (100%) diff --git a/.gitignore b/.gitignore index 56a26b7..ac0c86b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ -content/ node_modules/ .sass-cache/ .cache/ content/folio-images +content/client-images +content/blog-images +content/user-images .ftpconfig .vscode/ config.development.json diff --git a/brain/api/content/bookmarks.js b/brain/api/content/bookmarks.js new file mode 100644 index 0000000..e18acdf --- /dev/null +++ b/brain/api/content/bookmarks.js @@ -0,0 +1,168 @@ +import StringUtils from '../../tools/utilities/StringUtils'; +import RightsManager, { + + TASK_CREATE, + TASK_UPDATE, + TASK_READ, + TASK_DELETE, + OBJECT_CLIENT_ADMIN, + OBJECT_CLIENT_USER, + OBJECT_PROJECT_CLIENT, + OBJECT_PROJECT_FOLIO, + OBJECT_BOOKMARK, + OBJECT_POST + +} from '../../tools/utilities/RightsManager'; + +var express = require('express'); +var router = express.Router(); +var Models = require('../../models'); + +var Models = require('../../models'); +const scrape = require('scrape-metadata') + +/* + + +Get Bookmark Listzz + +*/ + +router.get('/archive', function (req, res, next) { + BMArchive.find() + .then((bookmarks) => { + console.log(bookmarks[1]) + res.json(bookmarks) + }) + .catch((err) => { + console.log(err) + }) +}); + +/* + + +Get Bookmark List + +*/ +router.get('/', function (req, res, next) { + Bookmark.find().sort({ + created: -1 + }) + .then((bookmarks) => { + res.json(bookmarks) + }) + .catch((err) => { + console.log(err) + }) +}); + +/* + + Get Bookmark by ID + +*/ +router.get('/:id', function (req, res, next) { + +}); + + + +/* + + Create New BookMark + +*/ +router.post('/add', function (req, res, next) { + if (!req.session.user) + return res.json({ + message: "You need to be logged in, champ." + }); + + var link = req.body.url; + Models.User.findById(req.session.user.id).then((user) => { + if (rightsManager.check(user.role, OBJECT_BOOKMARK, TASK_CREATE)) { + scrape(link, (err, meta) => { + var urlPieces = link.split("/"); + Models.Bookmark.sync().then(f => { + Models.Bookmark.create({ + source: urlPieces[0] + urlPieces[1] + '//' + urlPieces[2], + url: link, + image: meta.ogImage, + title: meta.title, + author: user.id, + listed: true + }).then(saved => { + + res.json({ + message: "link added" + }); + }).catch(err => { + res.json({ + message: "post error", + error: err + }); + }) + }) + }) + } else { + res.json({ + message: "Nah. You can't do that. Talk to the admin, sport." + }); + } + }); + +}); + +/* + + Update Bookmark by ID + +*/ +router.post('/update/:id', function (req, res, next) { + if (!req.session.user) + return res.json({ + message: "You need to be logged in, champ." + }); + console.log("ID: "+req.params.id); + let title = req.body.title; + let tags = req.body.tags; + let image = req.body.image; + + Models.User.findById(req.session.user.id).then((user) => { + if (rightsManager.check(user.role, OBJECT_BOOKMARK, TASK_UPDATE)) { + Models.Bookmark.findOne({ + where: { + id: req.params.id + } + }).then(saved => { + console.log('SAVED: '+req.body.title); + saved.update({ + title: title, + image: image + }).then(updated => { + res.json({ + message: "bookmark updated" + }); + }).catch(err => { + console.log(err) + }) + }).catch(err => { + console.log(err) + }) + } else { + res.json({ + message: "Nah. You can't do that. Talk to the admin, sport." + }); + } + }); +}); +/* + + Delete Bookmark by ID + +*/ +router.delete('/:id', function (req, res, next) { + +}); +module.exports = router; diff --git a/brain/api/content/folio.js b/brain/api/content/folio.js new file mode 100644 index 0000000..418dd1a --- /dev/null +++ b/brain/api/content/folio.js @@ -0,0 +1,235 @@ + +import DateUtils from '../../tools/utilities/DateUtils'; +import RightsManager, { + + TASK_CREATE, + TASK_UPDATE, + TASK_READ, + TASK_DELETE, + OBJECT_CLIENT_ADMIN, + OBJECT_CLIENT_USER, + OBJECT_PROJECT_CLIENT, + OBJECT_PROJECT_FOLIO, + OBJECT_BOOKMARK, + OBJECT_POST + +} from '../../tools/utilities/RightsManager'; +var express = require('express'); +var router = express.Router(); +var multer = require('multer'); +var fs = require('fs-extra'); +var Models = require('../../models'); +var User = require('../../models/User.js'); + +const dateUtil = new DateUtils() +var uploadPath = "./content/folio-images/" + dateUtil.getDate('year', new Date()) + "/" + dateUtil.getDate('month', new Date()); +fs.ensureDir(uploadPath, function (err) { + //console.log(err) // => null + // dir has now been created, including the directory it is to be placed in +}) +var storage = multer.diskStorage({ + destination: function (req, file, cb) { + cb(null, uploadPath) + }, + filename: function (req, file, cb) { + var splice = file.originalname.split(':'); + cb(null, splice[0]); + } +}); +var upload = multer({ + storage: storage +}).array('folioImages'); +/* + + Create New Folio Project + +*/ +router.post('/add', function (req, res, next) { + if (!req.user) + return res.json({ + message: "You need to be logged in, champ." + }) + User.findById(req.user._id).then((user) => { + upload(req, res, function (err) { + if (err) { + //console.log('Error in Saving Entry: ' + err); + res.json({ + message: err + }); + throw err; + } else { + if (RightsManager.check(user.role, [RightsManager.OBJECT_PROJECT_FOLIO], RightsManager.TASK_CREATE)) { + var project = new Project(req.body); + if (req.files != "") { + project.images = req.files; + } else { + console.log("NOTHING TO SAVE"); + } + project.save().then((project) => { + res.json({ + message: "new client project added" + }); + }).catch((err) => { + console.log(err); + }) + } else { + res.json({ + message: "Nah. You can't do that. Talk to the admin, sport." + }); + } + } + }); + }).catch((err) => { + console.log(err); + }) +}); +/* + + Get Folio Project List + +*/ +router.get('/', function (req, res, next) { + Project.find({}).then((projects) => { + var folioArray = []; + for (var i = 0; i < projects.length; i++) { + var imgURL = null; + if (projects[i].images.length != 0) + imgURL = String(projects[i].images[0].path).substring(8, String(projects[i].images[0].path).length); + var folioItem = { + id: projects[i]._id, + title: projects[i].title, + url: projects[i].url, + tools: projects[i].tools, + description: projects[i].description, + type: projects[i].type, + img_url: imgURL, + img_full_url: "http://formless.local/" + imgURL + } + folioArray[i] = folioItem; + } + res.json(folioArray); + }) +}); +/* + + Get Folio Project by ID + +*/ +router.get('/:id', function (req, res, next) { + Project.findById(req.params.id).then((project) => { + res.json(project); + }).catch((err) => { + console.log(err); + }); +}); +/* + + Update Folio Project by ID + +*/ +router.post('/update/:id', function (req, res, next) { + if (!req.session.user) + return res.json({ + message: "You need to be logged in, champ." + }); + Models.User.findById(req.session.user.id).then((user) => { + if (RightsManager.check(user.role, [RightsManager.OBJECT_PROJECT_FOLIO], RightsManager.TASK_UPDATE)) { + upload(req, res, function (err) { + if (err) { + //console.log('Error in Saving Entry: ' + err); + res.json({ + message: err + }); + throw err; + } else { + Models.FolioProject.findOne({where:{id: req.params.id}}).then((project) => { + if (req.files != "") { + project.images = req.files; + } else { + console.log("NOTHING TO SAVE"); + } + + console.log(req.body); + + project.update(req.body).then(updated => { + res.json({ + message: "project updated" + }); + }).catch(err => { + console.log(err) + }); + + /** + project.save().then((saved) => { + res.json({ + message: "project updated" + }); + }).catch((err) => { + console.log(err); + }) + **/ + }).catch((err) => { + console.log(err); + }) + } + }); + } else { + res.json({ + message: "Nah. You can't do that. Talk to the admin, sport." + }); + } + }); +}); +/* + + Delete Folio Project by ID + +*/ +router.delete('/:id', function (req, res, next) { + if (!req.user) + return res.json({ + message: "users only, yo. you're not that" + }); + User.findById(req.user._id).then((user) => { + if (RightsManager.check(user.role, [RightsManager.OBJECT_PROJECT_FOLIO], RightsManager.TASK_DELETE)) { + Project.findByIdAndRemove(req.params.id).then((project) => { + res.json({ + message: 'project has been removed' + }); + }).catch((err) => { + console.log(err); + }) + } else { + res.json({ + message: "Nah. You can't do that. Talk to the admin, sport." + }); + } + }); +}); + +router.post('/sort', function (req, res, next) { + var sortList = req.body; + var self = this; + User.findById(req.user._id).then((user) => { + if (RightsManager.check(user.role, [RightsManager.OBJECT_PROJECT_FOLIO], RightsManager.TASK_UPDATE)) { + var clean = true; + for (var i = 0; i < sortList.length; i++) { + Project.findByIdAndUpdate(sortList[i].sortID, { + sortIndex: sortList[i].sortIndex + }).then((project) => { + //console.log("SORTED") + //res.json({message: "sorted"}) + }).catch((err) => { + //res.json({message: "sorted", error:err}) + }) + //res.json({message:'projects updated'}) + } + } else { + res.json({ + message: "Nah. You can't do that. Talk to the admin, sport." + }); + } + }); +}); + +module.exports = router; diff --git a/brain/api/content/mailer.js b/brain/api/content/mailer.js new file mode 100644 index 0000000..b15c164 --- /dev/null +++ b/brain/api/content/mailer.js @@ -0,0 +1,41 @@ +var express = require('express'); +var router = express.Router(); +var api_key = 'key-4ef13da32fb39b9d9f0370c9efba7f06'; +var domain = 'communique.playvicio.us'; +var mailgun = require('mailgun-js')({ + apiKey: api_key, + domain: domain +}); + +router.post('/', function (req, res, next) { + + + // create reusable transporter object using the default SMTP transport + + // setup e-mail data with unicode symbols + var mailOptions = { + from: req.body.email, // sender address + to: 'ro@playvicio.us', // list of receivers + subject: 'Availability Inquiry', // Subject line + text: "Message from: " + req.body.client + " <" + req.body.email + "> - " + req.body.description + " - " + req.body.type + }; + + mailgun.messages().send(mailOptions, function (error, body) { + + if (error) { + res.json({ + error: error + }); + } + console.log(body); + res.json({ + message: "message sent" + }); + }); + + +}); + + + +module.exports = router; diff --git a/brain/api/content/posts.js b/brain/api/content/posts.js new file mode 100644 index 0000000..4779435 --- /dev/null +++ b/brain/api/content/posts.js @@ -0,0 +1,345 @@ +var express = require('express'); +import DateUtils from '../../tools/utilities/DateUtils'; +import StringUtils from '../../tools/utilities/StringUtils'; +import RightsManager, +{ + TASK_CREATE, + TASK_UPDATE, + TASK_READ, + TASK_DELETE, + OBJECT_CLIENT_ADMIN, + OBJECT_CLIENT_USER, + OBJECT_PROJECT_CLIENT, + OBJECT_PROJECT_FOLIO, + OBJECT_BOOKMARK, + OBJECT_POST +} +from '../../tools/utilities/RightsManager'; +var router = express.Router(); +var multer = require('multer'); +var fs = require('fs-extra'); +var Models = require('../../models'); +var uuidv4 = require('uuid/v4'); +var md = require('markdown-it')('commonmark'); +var sanitize = require('sanitize-html'); +const dateUtils = new DateUtils(); +const stringUtils = new StringUtils(); +const rightsManager = new RightsManager(); +var uploadPath = "./content/blog-images/" + dateUtils.getDate('year', new Date()) + "/" + dateUtils.getDate('month', new Date()); +fs.ensureDir(uploadPath, function(err) +{ + //console.log(err) // => null + // dir has now been created, including the directory it is to be placed in +}) +var storage = multer.diskStorage( +{ + destination: function(req, file, cb) + { + cb(null, uploadPath) + }, + filename: function(req, file, cb) + { + var splice = file.originalname.split(':'); + cb(null, splice[0]); + } +}); +var feature_upload = multer( +{ + storage: storage +}).array('feature_image'); +var post_upload = multer( +{ + storage: storage +}).array('post_image'); +/*** + ADD POST +*/ +router.post('/add', function(req, res, next) +{ + if (!req.session.user) return res.json( + { + message: "You need to be logged in, champ." + }); + Models.User.findById(req.session.user.id).then((user) => + { + if (rightsManager.check(user.role, OBJECT_POST, TASK_CREATE)) + { + feature_upload(req, res, function(err) + { + if (err) + { + res.json( + { + message: err + }); + throw err; + } + else + { + var postImages = []; + if (req.files != "") + { + for (let i = 0; i < req.files.length; i++) + { + postImages.push(req.files[i].path); + } + } + else + { + console.log("NOTHING TO SAVE"); + } + Models.Post.sync().then(f => + { + var html = req.body.post_plaintext; + html = html.replace(/<\/?span[^>]*>/g, ""); //removes highightjs styling + console.log("REGULAR: " + html); + let buffed = sanitize(html, + { + allowedTags: ['del', 'a', 'iframe', 'img'], + allowedAttributes: + { + a: ['href', 'name', 'target'], + img: ['src'], + iframe: ['height', 'width', 'src', 'frameborder', 'allow', 'allowfullscreen'] + } + }) + buffed = stringUtils.decodeHTML(buffed) + Models.Post.create( + { + uuid: uuidv4(), + title: req.body.title, + slug: req.body.slug, + plaintext: buffed, + tags: req.body.tags, + page: req.body.status_page, + featured: req.body.status_feature, + published: req.body.status_published, + author_id: req.session.user.id, + origin_date: new Date(req.body.origin_date), + html: md.render(buffed, + { + html: true, + xhtmlOut: true, + }), + feature_image: JSON.stringify(postImages) + }).then(saved => + { + res.json( + { + message: "postAdded", + postID: saved.slug + }); + }).catch(err => + { + console.log(err) + }) + }) + } + }); + } + else + { + res.json( + { + message: "Nah. You can't do that. Talk to the admin, sport." + }); + } + }); +}); +/*** + UPDATE POST +*/ +router.post('/update/:id', function(req, res, next) +{ + //console.log(req.body); + if (!req.session.user) return res.json( + { + message: "You need to be logged in, champ." + }); + Models.User.findById(req.session.user.id).then((user) => + { + if (rightsManager.check(user.role, OBJECT_POST, TASK_UPDATE)) + { + feature_upload(req, res, function(err) + { + if (err) + { + res.json( + { + message: err + }); + throw err; + } + else + { + var postImages = []; + if (req.files != "") + { + for (let i = 0; i < req.files.length; i++) + { + postImages.push(req.files[i].path); + } + } + else + { + console.log("NOTHING TO SAVE"); + } + Models.Post.findOne( + { + where: + { + id: req.params.id + } + }).then(post => + { + if (postImages.length == 0) postImages = JSON.parse(post.feature_image); + var html = req.body.post_plaintext; + html = html.replace(/<\/?span[^>]*>/g, ""); //removes highightjs styling + let cleaned = sanitize(html, + { + allowedTags: ['del', 'a', 'iframe', 'img'], + allowedAttributes: + { + a: ['href', 'name', 'target'], + img: ['src'], + iframe: ['height', 'width', 'src', 'frameborder', 'allow', 'allowfullscreen'] + } + }) + cleaned = stringUtils.decodeHTML(cleaned) + post.update( + { + title: req.body.title, + slug: req.body.slug, + plaintext: cleaned, + origin_date: new Date(req.body.origin_date), + tags: req.body.tags, + page: req.body.status_page, + featured: req.body.status_feature, + published: req.body.status_published, + html: md.render(cleaned, + { + html: true, + xhtmlOut: true + }), + feature_image: JSON.stringify(postImages) + }).then(updated => + { + res.json( + { + message: "postUpdated" + }); + }).catch(err => + { + console.log(err) + res.json( + { + message: "postError", + error: err + }); + }) + }).catch(err => + { + //console.log(err) + res.json( + { + message: "postError", + error: err + }); + }) + } + }); + } + else + { + res.json( + { + message: "Nah. You can't do that. Talk to the admin, sport." + }); + } + }); +}); +/*** + POST IMAGE +*/ +router.post('/add-post-image', function(req, res, next) +{ + //console.log(req.body); + if (!req.session.user) return res.json( + { + message: "You need to be logged in, champ." + }); + Models.User.findById(req.session.user.id).then((user) => + { + if (rightsManager.check(user.role, OBJECT_POST, TASK_CREATE)) + { + post_upload(req, res, function(err) + { + if (err) + { + //console.log('Error in Saving Entry: ' + err); + res.json( + { + message: err + }); + throw err; + } + else + { + var postImage = req.files[0].path; + return res.json( + { + message: "post image added", + url: postImage.substr(7, postImage.length) + }); + } + }); + } + else + { + res.json( + { + message: "Nah. You can't do that. Talk to the admin, sport." + }); + } + }); +}); +router.post('/delete/:id', function(req, res, next) +{ + if (!req.session.user) return res.json( + { + message: "You need to be logged in, champ." + }); + Models.User.findById(req.session.user.id).then((user) => + { + if (rightsManager.check(user.role, OBJECT_POST, TASK_DELETE)) + { + Models.Post.findOne( + { + where: + { + id: req.params.id + } + }).then(post => + { + post.destroy().then(deleted => + { + res.json( + { + message: "postDeleted" + }); + }) + }).catch(err => + { + console.log(err); + }) + } + else + { + res.json( + { + message: "Nah. You can't do that. Talk to the admin, sport." + }); + } + }); +}); +module.exports = router; \ No newline at end of file diff --git a/brain/api/content/project.js b/brain/api/content/project.js new file mode 100644 index 0000000..b5cac9b --- /dev/null +++ b/brain/api/content/project.js @@ -0,0 +1,180 @@ +import RightsManager, { + + TASK_CREATE, + TASK_UPDATE, + TASK_READ, + TASK_DELETE, + OBJECT_CLIENT_ADMIN, + OBJECT_CLIENT_USER, + OBJECT_PROJECT_CLIENT, + OBJECT_PROJECT_FOLIO, + OBJECT_BOOKMARK, + OBJECT_POST + +} from '../../tools/utilities/RightsManager'; + +var express = require('express'); +var router = express.Router(); +var multer = require('multer'); +var fs = require('fs-extra'); +var Models = require('../../models'); +var User = require('../../models/User.js'); +var uploadPath = "./content/client-images/"; +fs.ensureDir(uploadPath, function(err) { + //console.log(err) // => null + // dir has now been created, including the directory it is to be placed in +}) +var storage = multer.diskStorage({ + destination: function(req, file, cb) { + cb(null, uploadPath) + }, + filename: function(req, file, cb) { + var splice = file.originalname.split(':'); + cb(null, splice[0]); + } +}); +var upload = multer({storage: storage}).array('projectImages'); +var rightsManager = new RightsManager(); +/* + + Create New Client Project + +*/ +router.post('/add', function(req, res, next) { + if (!req.user) + return res.json({message: "You need to be logged in, champ."}) + User.findById(req.user._id).then((user) => { + upload(req, res, function(err) { + if (err) { + //console.log('Error in Saving Entry: ' + err); + res.json({message: err}); + throw err; + } else { + if (rightsManager.check(user.role, OBJECT_PROJECT_FOLIO, TASK_CREATE)) { + var project = new Project(req.body); + project.owner = user._id; + project.user = []; + project.comments = []; + project.tasks = []; + project.created = new Date().getTime(); + project.edited = new Date().getTime(); + if (req.files != "") { + project.images = req.files; + } else { + console.log("NOTHING TO SAVE"); + } + project.save().then((project) => { + res.json({message: "new client project added"}); + }).catch((err) => { + console.log(err); + }) + } else { + res.json({message: "Nah. You can't do that. Talk to the admin, sport."}); + } + } + }); + }).catch((err) => { + console.log(err); + }) +}); +/* + + Get Client Project List + +*/ +router.get('/', function(req, res, next) { + if (!req.user) + return res.json({message: "You need to be logged in, champ."}) + User.findById(req.user._id).then((user) => { + if ( rightsManager.check(user.role, OBJECT_POST, TASK_READ )) { + Project.find({}).then((projects) => { + res.json(projects); + }).then((users) => { + //res.json({message: "got user list"}); + }).catch((err) => { + console.log(err); + }); + } else { + res.json({message: "Nah. You can't do that. Talk to the admin, sport."}); + } + }).catch((err) => { + console.log(err); + }) +}); +/* + + Get Client Project by ID + +*/ +router.get('/:id', function(req, res, next) { + if (!req.user) + return res.json({message: "You need to be logged in, champ."}); + User.findById(req.user._id).then((user) => { + if (RightsManager.check(user.role, [RightsManager.OBJECT_PROJECT_CLIENT], RightsManager.TASK_READ)) { + Project.findById(req.params.id).then((project) => { + res.json(project); + }).catch((err) => { + console.log(err); + }); + } + }) +}); +/* + + Update Client Project by ID + +*/ +router.post('/update/:id', function(req, res, next) { + if (!req.user) + return res.json({message: "You need to be logged in, champ."}); + User.findById(req.user._id).then((user) => { + if ( rightsManager.check(user.role, OBJECT_POST, TASK_UPDATE) ) { + upload(req, res, function(err) { + if (err) { + //console.log('Error in Saving Entry: ' + err); + res.json({message: err}); + throw err; + } else { + Project.findByIdAndUpdate(req.params.id, req.body).then((project) => { + if (req.files != "") { + project.images = req.files; + } else { + console.log("NOTHING TO SAVE"); + } + project.edited = new Date().getTime(); + project.save().then((saved) => { + res.json({message: "project updated"}); + }).catch((err) => { + console.log(err); + }) + }).catch((err) => { + console.log(err); + }) + } + }); + } else { + res.json({message: "Nah. You can't do that. Talk to the admin, sport."}); + } + }); +}); +/* + + Delete Client Project by ID + +*/ +router.delete('/:id', function(req, res, next) { + if (!req.user) + return res.json({message: "users only, yo. you're not that"}); + User.findById(req.user._id).then((user) => { + if ( rightsManager.check(user.role, OBJECT_POST, TASK_DELETE) ) { + Project.findByIdAndRemove(req.params.id).then((project) => { + res.json({message: 'project has been removed'}); + }).catch((err) => { + console.log(err); + }) + } else { + res.json({message: "Nah. You can't do that. Talk to the admin, sport."}); + } + }); +}); +module.exports = router; diff --git a/brain/routes/back/index.js b/brain/routes/back/index.js index 7f92e1a..3cef99b 100644 --- a/brain/routes/back/index.js +++ b/brain/routes/back/index.js @@ -1,11 +1,14 @@ + +import DateUtils from '../../tools/utilities/DateUtils'; var express = require('express'); var router = express.Router(); var Models = require('../../models'); -var DateUtils = require('../../utils/DateUtils'); var hljs = require('highlight.js/lib/highlight'); var hljs_md = require('highlight.js/lib/languages/markdown'); hljs.registerLanguage('markdown', hljs_md); +const dateUtils = new DateUtils(); + //-------------------------- // Index //-------------------------- @@ -14,7 +17,6 @@ router.get('/', function (req, res) { if (req.session.user) loggedIn = true; - console.log('SYNCING'); Models.Post.sync().then(f => { Models.Post.findAll({ order: [ @@ -107,7 +109,8 @@ router.get('/posts/add/new', function (req, res) { res.render('dash/post-edit', { title: 'Make New Post', mode: 'admin', - date: DateUtils.getDate('year', new Date()) + "-" + DateUtils.getDate('month', new Date()) + "-" + DateUtils.getDate('day', new Date()), + date: dateUtils.getDate('year', new Date()) + "-" + dateUtils.getDate('month', new Date()) + "-" + dateUtils.getDate('day', new Date()), + status:['false', 'false', 'false'], edit: false }); } else { @@ -132,7 +135,7 @@ router.get('/posts/edit/:id', function (req, res) { let sexydate if (post.origin_date == "" || post.origin_date == null) - sexydate = DateUtils.getDate('year', post.created_at) + "-" + DateUtils.getDate('month', post.created_at) + "-" + DateUtils.getDate('day', post.created_at) + sexydate = dateUtils.getDate('year', post.created_at) + "-" + dateUtils.getDate('month', post.created_at) + "-" + dateUtils.getDate('day', post.created_at) else sexydate = post.origin_date res.render('dash/post-edit', { diff --git a/themes/dash/src/com/tools/effects/Animate.jsx b/brain/tools/effects/Animate.js similarity index 100% rename from themes/dash/src/com/tools/effects/Animate.jsx rename to brain/tools/effects/Animate.js diff --git a/themes/dash/src/com/tools/effects/TextEffects.jsx b/brain/tools/effects/TextEffects.js similarity index 100% rename from themes/dash/src/com/tools/effects/TextEffects.jsx rename to brain/tools/effects/TextEffects.js diff --git a/themes/dash/src/com/tools/events/AuthEvent.jsx b/brain/tools/events/AuthEvent.js similarity index 100% rename from themes/dash/src/com/tools/events/AuthEvent.jsx rename to brain/tools/events/AuthEvent.js diff --git a/themes/dash/src/com/tools/events/DataEvent.jsx b/brain/tools/events/DataEvent.js similarity index 100% rename from themes/dash/src/com/tools/events/DataEvent.jsx rename to brain/tools/events/DataEvent.js diff --git a/themes/dash/src/com/tools/events/EditorEvent.jsx b/brain/tools/events/EditorEvent.js similarity index 100% rename from themes/dash/src/com/tools/events/EditorEvent.jsx rename to brain/tools/events/EditorEvent.js diff --git a/themes/dash/src/com/tools/events/EventEmitter.jsx b/brain/tools/events/EventEmitter.js similarity index 100% rename from themes/dash/src/com/tools/events/EventEmitter.jsx rename to brain/tools/events/EventEmitter.js diff --git a/themes/dash/src/com/tools/ui/Slideshow.jsx b/brain/tools/ui/Slideshow.js similarity index 100% rename from themes/dash/src/com/tools/ui/Slideshow.jsx rename to brain/tools/ui/Slideshow.js diff --git a/themes/dash/src/com/tools/utilities/TextEditor.jsx b/brain/tools/ui/TextEditor.js similarity index 98% rename from themes/dash/src/com/tools/utilities/TextEditor.jsx rename to brain/tools/ui/TextEditor.js index a190485..11326d7 100644 --- a/themes/dash/src/com/tools/utilities/TextEditor.jsx +++ b/brain/tools/ui/TextEditor.js @@ -1,5 +1,5 @@ import * as DataEvent from '../events/DataEvent'; -import DateUtils from './DateUtils'; +import DateUtils from '../utilities/DateUtils'; import { position, offset diff --git a/themes/dash/src/com/tools/utilities/DOMUtils.jsx b/brain/tools/utilities/DOMUtils.js similarity index 100% rename from themes/dash/src/com/tools/utilities/DOMUtils.jsx rename to brain/tools/utilities/DOMUtils.js diff --git a/themes/dash/src/com/tools/utilities/DataUtils.jsx b/brain/tools/utilities/DataUtils.js similarity index 100% rename from themes/dash/src/com/tools/utilities/DataUtils.jsx rename to brain/tools/utilities/DataUtils.js diff --git a/themes/dash/src/com/tools/utilities/DateUtils.jsx b/brain/tools/utilities/DateUtils.js similarity index 100% rename from themes/dash/src/com/tools/utilities/DateUtils.jsx rename to brain/tools/utilities/DateUtils.js diff --git a/brain/tools/utilities/RightsManager.js b/brain/tools/utilities/RightsManager.js new file mode 100644 index 0000000..ecf43fb --- /dev/null +++ b/brain/tools/utilities/RightsManager.js @@ -0,0 +1,154 @@ +export const roles = { + hnic: + { + "client_admin": + { + "create": true, + "read": true, + "update": true, + "delete": true + }, + "client_user": + { + "create": true, + "read": true, + "update": true, + "delete": true + }, + "client_project": + { + "create": true, + "read": true, + "update": true, + "delete": true + }, + "folio_project": + { + "create": true, + "read": true, + "update": true, + "delete": true + }, + "bookmark": + { + "create": true, + "read": true, + "update": true, + "delete": true + }, + "post": + { + "create": true, + "read": true, + "update": true, + "delete": true + } + }, + client: + { + "client_admin": + { + "create": false, + "read": true, + "update": false, + "delete": false + }, + "client_user": + { + "create": true, + "read": true, + "update": true, + "delete": true + }, + "client_project": + { + "create": true, + "read": true, + "update": true, + "delete": false + }, + "folio_project": + { + "create": false, + "read": false, + "update": false, + "delete": false + } + }, + user: + { + "client_admin": + { + "create": false, + "read": false, + "update": false, + "delete": false + }, + "client_user": + { + "create": false, + "read": true, + "update": false, + "delete": false + }, + "client_project": + { + "create": false, + "read": true, + "update": true, + "delete": false + }, + "folio_project": + { + "create": false, + "read": false, + "update": false, + "delete": false + }, + "bookmark": + { + "create": true, + "read": true, + "update": true, + "delete": true + }, + "post": + { + "create": false, + "read": false, + "update": false, + "delete": false + } + } +}; +export const TASK_CREATE = 'create' +export const TASK_UPDATE = 'update' +export const TASK_READ = 'read' +export const TASK_DELETE = 'delete' +export const OBJECT_CLIENT_ADMIN = 'client_admin' +export const OBJECT_CLIENT_USER = 'client_user' +export const OBJECT_PROJECT_CLIENT = 'client_project' +export const OBJECT_PROJECT_FOLIO = 'folio_project' +export const OBJECT_BOOKMARK = 'bookmark' +export const OBJECT_POST = 'post' +export default class RightsManager +{ + //-------------------------- + // constructor + //-------------------------- + constructor() + { + var self = this; + } + //-------------------------- + // methods + //-------------------------- + check(role, object, task) + { + console.log(role + " *** " + object + " *** " + task); + return roles[role][object][task]; + } + //-------------------------- + // event handlers + //-------------------------- +} \ No newline at end of file diff --git a/themes/dash/src/com/tools/utilities/StringUtils.jsx b/brain/tools/utilities/StringUtils.js similarity index 100% rename from themes/dash/src/com/tools/utilities/StringUtils.jsx rename to brain/tools/utilities/StringUtils.js diff --git a/brain/utils/DateUtils.js b/brain/utils/DateUtils.js deleted file mode 100644 index 650bcec..0000000 --- a/brain/utils/DateUtils.js +++ /dev/null @@ -1,100 +0,0 @@ -module.exports = { - decodeHTML: function (string, quote_style) { - var optTemp = 0, - i = 0, - noquotes = false; - if (typeof quote_style === 'undefined') { - quote_style = 2; - } - string = string.toString().replace(/</g, '<').replace(/>/g, '>'); - var OPTS = { - 'ENT_NOQUOTES': 0, - 'ENT_HTML_QUOTE_SINGLE': 1, - 'ENT_HTML_QUOTE_DOUBLE': 2, - 'ENT_COMPAT': 2, - 'ENT_QUOTES': 3, - 'ENT_IGNORE': 4 - }; - if (quote_style === 0) { - noquotes = true; - } - if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags - quote_style = [].concat(quote_style); - for (i = 0; i < quote_style.length; i++) { - // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4 - if (OPTS[quote_style[i]] === 0) { - noquotes = true; - } else if (OPTS[quote_style[i]]) { - optTemp = optTemp | OPTS[quote_style[i]]; - } - } - quote_style = optTemp; - } - if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) { - string = string.replace(/�*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should - // string = string.replace(/'|�*27;/g, "'"); // This would also be useful here, but not a part of PHP - } - if (!noquotes) { - string = string.replace(/"/g, '"'); - } - // Put this in last place to avoid escape being double-decoded - string = string.replace(/&/g, '&'); - return string; - }, - cleanString: function (str) { - return (str + '').replace(/\\(.?)/g, function (s, n1) { - switch (n1) { - case '\\': - return '\\'; - case '0': - return '\u0000'; - case '': - return ''; - default: - return n1; - } - }); - }, - - cleanString: function (string) { - var clean = string.replace(/(^\-+|[^a-zA-Z0-9\/_| -]+|\-+$)/g, '').toLowerCase().replace(/[\/_| -]+/g, '-'); - return clean; - }, - - - getDate: function (type, rawdate) { - var day = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCDate()) : String(new Date().getUTCDate())); - var month = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMonth() + 1) : String(new Date().getUTCMonth() + 1)); - var year = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCFullYear()) : String(new Date().getUTCFullYear())); - var hour = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCHours()) : String(new Date().getUTCHours())); - var minute = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMinutes()) : String(new Date().getUTCMinutes())); - var seconds = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCSeconds()) : String(new Date().getUTCSeconds())); - var millisecond = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMilliseconds()) : String(new Date().getUTCMilliseconds())); - var offset = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getTimezoneOffset()) : String(new Date().getTimezoneOffset())); - if (day.length == 1) - day = String("0" + day); - if (month.length == 1) - month = String("0" + month); - offset = String(offset / 60); - if (offset.length == 1) - offset = String("0" + offset); - - switch (type) { - case "day": - return day; - break; - case "month": - return month; - break; - case "year": - return year; - break; - case "stamp": - return String(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + seconds + "." + millisecond + "-" + (offset)); - break - default: - return String(year + "-" + month + "-" + day + " : " + hour + "-" + minute + "-" + seconds); - break; - } - } -}; \ No newline at end of file diff --git a/brain/utils/RightsManager.js b/brain/utils/RightsManager.js deleted file mode 100644 index e29a270..0000000 --- a/brain/utils/RightsManager.js +++ /dev/null @@ -1,112 +0,0 @@ -var roles = { - hnic: { - "client_admin": { - "create": true, - "read": true, - "update": true, - "delete": true - }, - "client_user": { - "create": true, - "read": true, - "update": true, - "delete": true - }, - "client_project": { - "create": true, - "read": true, - "update": true, - "delete": true - }, - "folio_project": { - "create": true, - "read": true, - "update": true, - "delete": true - }, - "bookmark": { - "create": true, - "read": true, - "update": true, - "delete": true - } - - }, - client: { - "client_admin": { - "create": false, - "read": true, - "update": false, - "delete": false - }, - "client_user": { - "create": true, - "read": true, - "update": true, - "delete": true - }, - "client_project": { - "create": true, - "read": true, - "update": true, - "delete": false - }, - "folio_project": { - "create": false, - "read": false, - "update": false, - "delete": false - } - }, - user: { - "client_admin": { - "create": false, - "read": false, - "update": false, - "delete": false - }, - "client_user": { - "create": false, - "read": true, - "update": false, - "delete": false - }, - "client_project": { - "create": false, - "read": true, - "update": true, - "delete": false - }, - "folio_project": { - "create": false, - "read": false, - "update": false, - "delete": false - }, - "bookmark": { - "create": true, - "read": true, - "update": true, - "delete": true - } - } -}; -module.exports = { - TASK_CREATE: 'create', - TASK_UPDATE: 'update', - TASK_READ: 'read', - TASK_DELETE: 'delete', - OBJECT_CLIENT_ADMIN: 'client_admin', - OBJECT_CLIENT_USER: 'client_user', - OBJECT_PROJECT_CLIENT: 'client_project', - OBJECT_PROJECT_FOLIO: 'folio_project', - OBJECT_BOOKMARK: 'bookmark', - check: function(role, object, task) { - for (var i = 0; i < object.length; i++) { - if(!roles[role][object[i]][task]) - return false - } - return true; - }, - hey: function() {} -}; diff --git a/package-lock.json b/package-lock.json index 0823f0a..fc18fea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2708,6 +2708,11 @@ "source-map": "~0.6.1" } }, + "esm": { + "version": "3.0.84", + "resolved": "https://registry.npmjs.org/esm/-/esm-3.0.84.tgz", + "integrity": "sha512-SzSGoZc17S7P+12R9cg21Bdb7eybX25RnIeRZ80xZs+VZ3kdQKzqTp2k4hZJjR7p9l0186TTXSgrxzlMDBktlw==" + }, "esprima": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", diff --git a/package.json b/package.json index 83c21a6..5a2ca4d 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "repository": "https://code.playvicio.us/Are0h/Fipamo", "theme": "default", "scripts": { - "start": "forever start init.js", + "start": "forever start -r esm init.js", "stop": "forever stop init.js", - "dev": "nodemon init.js", + "dev": "nodemon -r esm init.js", "watch-front-scripts": "parcel watch themes/$npm_package_theme/src/com/Start.jsx --out-dir themes/$npm_package_theme/assets/js --out-file start.min.js --public-url /$npm_package_theme/assets/js", "watch-front-styles": "stylus -w -m -o themes/$npm_package_theme/assets/css themes/$npm_package_theme/src/styles/base.styl", "build-front-kit": "uglifyjs node_modules/scramble-text/dist/ScrambleText.min.js node_modules/animejs/anime.min.js node_modules/reframe.js/dist/reframe.min.js -c -o themes/$npm_package_theme/assets/js/toolkit.min.js", @@ -28,6 +28,7 @@ "cookie-parser": "~1.3.3", "debug": "^4.1.0", "entypo": "^2.1.0", + "esm": "^3.0.84", "express": "^4.16.4", "express-session": "^1.15.6", "fs-extra": "latest", diff --git a/themes/dash/assets/js/dash.min.js b/themes/dash/assets/js/dash.min.js index 1fd1d5a..6bec31b 100644 --- a/themes/dash/assets/js/dash.min.js +++ b/themes/dash/assets/js/dash.min.js @@ -104,7 +104,7 @@ parcelRequire = (function (modules, cache, entry, globalName) { // Override the current require with this new one return newRequire; -})({"tools/events/EventEmitter.jsx":[function(require,module,exports) { +})({"../../../../brain/tools/events/EventEmitter.jsx":[function(require,module,exports) { "use strict"; Object.defineProperty(exports, "__esModule", { @@ -191,7 +191,7 @@ function () { var _default = EventEmitter; exports.default = _default; -},{}],"tools/events/DataEvent.jsx":[function(require,module,exports) { +},{}],"../../../../brain/tools/events/DataEvent.jsx":[function(require,module,exports) { "use strict"; Object.defineProperty(exports, "__esModule", { @@ -243,7 +243,7 @@ var DataEvent = function DataEvent() { var _default = new DataEvent(); exports.default = _default; -},{}],"tools/utilities/DataUtils.jsx":[function(require,module,exports) { +},{}],"../../../../brain/tools/utilities/DataUtils.jsx":[function(require,module,exports) { "use strict"; Object.defineProperty(exports, "__esModule", { @@ -430,7 +430,7 @@ function (_EventEmitter) { var _default = DataUtils; exports.default = _default; -},{"../events/EventEmitter.jsx":"tools/events/EventEmitter.jsx","../events/DataEvent.jsx":"tools/events/DataEvent.jsx"}],"tools/effects/Animate.jsx":[function(require,module,exports) { +},{"../events/EventEmitter.jsx":"../../../../brain/tools/events/EventEmitter.jsx","../events/DataEvent.jsx":"../../../../brain/tools/events/DataEvent.jsx"}],"../../../../brain/tools/effects/Animate.jsx":[function(require,module,exports) { "use strict"; Object.defineProperty(exports, "__esModule", { @@ -494,7 +494,7 @@ function (_EventEmitter) { var _default = Animate; exports.default = _default; -},{"../events/EventEmitter.jsx":"tools/events/EventEmitter.jsx"}],"tools/utilities/StringUtils.jsx":[function(require,module,exports) { +},{"../events/EventEmitter.jsx":"../../../../brain/tools/events/EventEmitter.jsx"}],"../../../../brain/tools/utilities/StringUtils.jsx":[function(require,module,exports) { "use strict"; Object.defineProperty(exports, "__esModule", { @@ -599,11 +599,11 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -var _DataUtils = _interopRequireWildcard(require("../tools/utilities/DataUtils")); +var _DataUtils = _interopRequireWildcard(require("../../../../../brain//tools/utilities/DataUtils")); -var DataEvent = _interopRequireWildcard(require("../tools/events/DataEvent")); +var DataEvent = _interopRequireWildcard(require("../../../../../brain//tools/events/DataEvent")); -var _StringUtils = _interopRequireDefault(require("../tools/utilities/StringUtils")); +var _StringUtils = _interopRequireDefault(require("../../../../../brain//tools/utilities/StringUtils")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -718,7 +718,7 @@ function () { }(); exports.default = PostActions; -},{"../tools/utilities/DataUtils":"tools/utilities/DataUtils.jsx","../tools/events/DataEvent":"tools/events/DataEvent.jsx","../tools/utilities/StringUtils":"tools/utilities/StringUtils.jsx"}],"tools/events/EditorEvent.jsx":[function(require,module,exports) { +},{"../../../../../brain//tools/utilities/DataUtils":"../../../../brain/tools/utilities/DataUtils.jsx","../../../../../brain//tools/events/DataEvent":"../../../../brain/tools/events/DataEvent.jsx","../../../../../brain//tools/utilities/StringUtils":"../../../../brain/tools/utilities/StringUtils.jsx"}],"../../../../brain/tools/events/EditorEvent.jsx":[function(require,module,exports) { "use strict"; Object.defineProperty(exports, "__esModule", { @@ -744,820 +744,7 @@ var EditorEvent = function EditorEvent() { var _default = new EditorEvent(); exports.default = _default; -},{}],"tools/utilities/DateUtils.jsx":[function(require,module,exports) { -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } - -var DateUtils = -/*#__PURE__*/ -function () { - //-------------------------- - // constructor - //-------------------------- - function DateUtils() { - _classCallCheck(this, DateUtils); - } //-------------------------- - // methods - //-------------------------- - - - _createClass(DateUtils, [{ - key: "getMKtime", - value: function getMKtime() { - var time = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), new Date().getMinutes(), new Date().getSeconds(), 0).getTime() / 1000; - return time; - } - }, { - key: "convertMKtime", - value: function convertMKtime(seconds) { - var date = new Date(seconds * 1000); - return date; - } - }, { - key: "getDate", - value: function getDate(type, rawdate) { - var day = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCDate()) : String(new Date().getUTCDate()); - var month = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMonth() + 1) : String(new Date().getUTCMonth() + 1); - var year = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCFullYear()) : String(new Date().getUTCFullYear()); - var hour = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCHours()) : String(new Date().getUTCHours()); - var minute = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMinutes()) : String(new Date().getUTCMinutes()); - var seconds = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCSeconds()) : String(new Date().getUTCSeconds()); - var millisecond = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMilliseconds()) : String(new Date().getUTCMilliseconds()); - var offset = rawdate != null || rawdate != '' ? String(new Date(rawdate).getTimezoneOffset()) : String(new Date().getTimezoneOffset()); - if (day.length == 1) day = String("0" + day); - if (month.length == 1) month = String("0" + month); - offset = String(offset / 60); - if (offset.length == 1) offset = String("0" + offset); - - switch (type) { - case "day": - return day; - break; - - case "month": - return month; - break; - - case "year": - return year; - break; - - case "stamp": - return String(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + seconds + "." + millisecond + "-" + offset); - break; - - default: - return String(year + "-" + month + "-" + day); - break; - } - } //-------------------------- - // event handlers - //-------------------------- - - }]); - - return DateUtils; -}(); - -var _default = DateUtils; -exports.default = _default; -},{}],"../../../../node_modules/caret-pos/lib/esm2015/main.js":[function(require,module,exports) { -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getOffset = exports.offset = exports.position = void 0; -var attributes = ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle', 'borderTopWidth', 'boxSizing', 'fontFamily', 'fontSize', 'fontWeight', 'height', 'letterSpacing', 'lineHeight', 'marginBottom', 'marginLeft', 'marginRight', 'marginTop', 'outlineWidth', 'overflow', 'overflowX', 'overflowY', 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', 'textAlign', 'textOverflow', 'textTransform', 'whiteSpace', 'wordBreak', 'wordWrap']; -/** - * Create a mirror - * - * @param {Element} element The element - * @param {string} html The html - * - * @return {object} The mirror object - */ - -var createMirror = function createMirror(element, html) { - /** - * The mirror element - */ - var mirror = document.createElement('div'); - /** - * Create the CSS for the mirror object - * - * @return {object} The style object - */ - - var mirrorCss = function mirrorCss() { - var css = { - position: 'absolute', - left: -9999, - top: 0, - zIndex: -2000 - }; - - if (element.tagName === 'TEXTAREA') { - attributes.push('width'); - } - - attributes.forEach(function (attr) { - css[attr] = getComputedStyle(element)[attr]; - }); - return css; - }; - /** - * Initialize the mirror - * - * @param {string} html The html - * - * @return {void} - */ - - - var initialize = function initialize(html) { - var styles = mirrorCss(); - Object.keys(styles).forEach(function (key) { - mirror.style[key] = styles[key]; - }); - mirror.innerHTML = html; - element.parentNode.insertBefore(mirror, element.nextSibling); - }; - /** - * Get the rect - * - * @return {Rect} The bounding rect - */ - - - var rect = function rect() { - var marker = mirror.ownerDocument.getElementById('caret-position-marker'); - var boundingRect = { - left: marker.offsetLeft, - top: marker.offsetTop, - height: marker.offsetHeight - }; - mirror.parentNode.removeChild(mirror); - return boundingRect; - }; - - initialize(html); - return { - rect: rect - }; -}; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; -} : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; -}; -/** - * Check if a DOM Element is content editable - * - * @param {Element} element The DOM element - * - * @return {bool} If it is content editable - */ - - -var isContentEditable = function isContentEditable(element) { - return !!(element.contentEditable && element.contentEditable === 'true'); -}; -/** - * Get the context from settings passed in - * - * @param {object} settings The settings object - * - * @return {object} window and document - */ - - -var getContext = function getContext() { - var settings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var customPos = settings.customPos, - iframe = settings.iframe, - noShadowCaret = settings.noShadowCaret; - - if (iframe) { - return { - iframe: iframe, - window: iframe.contentWindow, - document: iframe.contentDocument || iframe.contentWindow.document, - noShadowCaret: noShadowCaret, - customPos: customPos - }; - } - - return { - window: window, - document: document, - noShadowCaret: noShadowCaret, - customPos: customPos - }; -}; -/** - * Get the offset of an element - * - * @param {Element} element The DOM element - * @param {object} ctx The context - * - * @return {object} top and left - */ - - -var getOffset = function getOffset(element, ctx) { - var win = ctx && ctx.window || window; - var doc = ctx && ctx.document || document; - var rect = element.getBoundingClientRect(); - var docEl = doc.documentElement; - var scrollLeft = win.pageXOffset || docEl.scrollLeft; - var scrollTop = win.pageYOffset || docEl.scrollTop; - return { - top: rect.top + scrollTop, - left: rect.left + scrollLeft - }; -}; -/** - * Check if a value is an object - * - * @param {any} value The value to check - * - * @return {bool} If it is an object - */ - - -exports.getOffset = getOffset; - -var isObject = function isObject(value) { - return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null; -}; -/** - * Create a Input caret object. - * - * @param {Element} element The element - * @param {Object} ctx The context - */ - - -var createInputCaret = function createInputCaret(element, ctx) { - /** - * Get the current position - * - * @returns {int} The caret position - */ - var getPos = function getPos() { - return element.selectionStart; - }; - /** - * Set the position - * - * @param {int} pos The position - * - * @return {Element} The element - */ - - - var setPos = function setPos(pos) { - element.setSelectionRange(pos, pos); - return element; - }; - /** - * The offset - * - * @param {int} pos The position - * - * @return {object} The offset - */ - - - var getOffset$$1 = function getOffset$$1(pos) { - var rect = getOffset(element); - var position = getPosition(pos); - return { - top: rect.top + position.top + ctx.document.body.scrollTop, - left: rect.left + position.left + ctx.document.body.scrollLeft, - height: position.height - }; - }; - /** - * Get the current position - * - * @param {int} pos The position - * - * @return {object} The position - */ - - - var getPosition = function getPosition(pos) { - var format = function format(val) { - var value = val.replace(/<|>|`|"|&/g, '?').replace(/\r\n|\r|\n/g, '
'); - return value; - }; - - if (ctx.customPos || ctx.customPos === 0) { - pos = ctx.customPos; - } - - var position = pos === undefined ? getPos() : pos; - var startRange = element.value.slice(0, position); - var endRange = element.value.slice(position); - var html = '' + format(startRange) + ''; - html += '|'; - html += '' + format(endRange) + ''; - var mirror = createMirror(element, html); - var rect = mirror.rect(); - rect.pos = getPos(); - return rect; - }; - - return { - getPos: getPos, - setPos: setPos, - getOffset: getOffset$$1, - getPosition: getPosition - }; -}; -/** - * Create an Editable Caret - * @param {Element} element The editable element - * @param {object|null} ctx The context - * - * @return {EditableCaret} - */ - - -var createEditableCaret = function createEditableCaret(element, ctx) { - /** - * Set the caret position - * - * @param {int} pos The position to se - * - * @return {Element} The element - */ - var setPos = function setPos(pos) { - var sel = ctx.window.getSelection(); - - if (sel) { - var offset = 0; - var found = false; - - var find = function find(position, parent) { - for (var i = 0; i < parent.childNodes.length; i++) { - var node = parent.childNodes[i]; - - if (found) { - break; - } - - if (node.nodeType === 3) { - if (offset + node.length >= position) { - found = true; - var range = ctx.document.createRange(); - range.setStart(node, position - offset); - sel.removeAllRanges(); - sel.addRange(range); - break; - } else { - offset += node.length; - } - } else { - find(pos, node); - } - } - }; - - find(pos, element); - } - - return element; - }; - /** - * Get the offset - * - * @return {object} The offset - */ - - - var getOffset = function getOffset() { - var range = getRange(); - var offset = { - height: 0, - left: 0, - right: 0 - }; - - if (!range) { - return offset; - } - - var hasCustomPos = ctx.customPos || ctx.customPos === 0; // endContainer in Firefox would be the element at the start of - // the line - - if (range.endOffset - 1 > 0 && range.endContainer !== element || hasCustomPos) { - var clonedRange = range.cloneRange(); - var fixedPosition = hasCustomPos ? ctx.customPos : range.endOffset; - clonedRange.setStart(range.endContainer, fixedPosition - 1 < 0 ? 0 : fixedPosition - 1); - clonedRange.setEnd(range.endContainer, fixedPosition); - var rect = clonedRange.getBoundingClientRect(); - offset = { - height: rect.height, - left: rect.left + rect.width, - top: rect.top - }; - clonedRange.detach(); - } - - if ((!offset || offset && offset.height === 0) && !ctx.noShadowCaret) { - var _clonedRange = range.cloneRange(); - - var shadowCaret = ctx.document.createTextNode('|'); - - _clonedRange.insertNode(shadowCaret); - - _clonedRange.selectNode(shadowCaret); - - var _rect = _clonedRange.getBoundingClientRect(); - - offset = { - height: _rect.height, - left: _rect.left, - top: _rect.top - }; - shadowCaret.parentNode.removeChild(shadowCaret); - - _clonedRange.detach(); - } - - if (offset) { - var doc = ctx.document.documentElement; - offset.top += ctx.window.pageYOffset - (doc.clientTop || 0); - offset.left += ctx.window.pageXOffset - (doc.clientLeft || 0); - } - - return offset; - }; - /** - * Get the position - * - * @return {object} The position - */ - - - var getPosition = function getPosition() { - var offset = getOffset(); - var pos = getPos(); - var rect = element.getBoundingClientRect(); - var inputOffset = { - top: rect.top + ctx.document.body.scrollTop, - left: rect.left + ctx.document.body.scrollLeft - }; - offset.left -= inputOffset.left; - offset.top -= inputOffset.top; - offset.pos = pos; - return offset; - }; - /** - * Get the range - * - * @return {Range|null} - */ - - - var getRange = function getRange() { - if (!ctx.window.getSelection) { - return; - } - - var sel = ctx.window.getSelection(); - return sel.rangeCount > 0 ? sel.getRangeAt(0) : null; - }; - /** - * Get the caret position - * - * @return {int} The position - */ - - - var getPos = function getPos() { - var range = getRange(); - var clonedRange = range.cloneRange(); - clonedRange.selectNodeContents(element); - clonedRange.setEnd(range.endContainer, range.endOffset); - var pos = clonedRange.toString().length; - clonedRange.detach(); - return pos; - }; - - return { - getPos: getPos, - setPos: setPos, - getPosition: getPosition, - getOffset: getOffset, - getRange: getRange - }; -}; - -var createCaret = function createCaret(element, ctx) { - if (isContentEditable(element)) { - return createEditableCaret(element, ctx); - } - - return createInputCaret(element, ctx); -}; - -var position = function position(element, value) { - var settings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - var options = settings; - - if (isObject(value)) { - options = value; - value = null; - } - - var ctx = getContext(options); - var caret = createCaret(element, ctx); - - if (value || value === 0) { - return caret.setPos(value); - } - - return caret.getPosition(); -}; -/** - * - * @param {Element} element The DOM element - * @param {number|undefined} value The value to set - * @param {object} settings Any settings for context - */ - - -exports.position = position; - -var offset = function offset(element, value) { - var settings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - var options = settings; - - if (isObject(value)) { - options = value; - value = null; - } - - var ctx = getContext(options); - var caret = createCaret(element, ctx); - return caret.getOffset(value); -}; - -exports.offset = offset; -},{}],"tools/utilities/TextEditor.jsx":[function(require,module,exports) { -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; - -var DataEvent = _interopRequireWildcard(require("../events/DataEvent")); - -var _DateUtils = _interopRequireDefault(require("./DateUtils")); - -var _caretPos = require("caret-pos"); - -var _EventEmitter2 = _interopRequireDefault(require("../events/EventEmitter")); - -var EditorEvent = _interopRequireWildcard(require("../events/EditorEvent")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } - -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } - -function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } - -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } - -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } - -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } - -var TextEditor = -/*#__PURE__*/ -function (_EventEmitter) { - _inherits(TextEditor, _EventEmitter); - - //-------------------------- - // constructor - //-------------------------- - function TextEditor(textEditor, scrollLimit) { - var _this; - - _classCallCheck(this, TextEditor); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(TextEditor).call(this)); - hljs.initHighlightingOnLoad(); //this.dataUtils = new DataUtils(); - - _this.dateUtils = new _DateUtils.default(); - _this.textEditor = textEditor; - _this.fixLimit = scrollLimit; - _this.caretPos = null; - _this.url = ''; - - var self = _assertThisInitialized(_assertThisInitialized(_this)); - - _this.setInputs(); - - window.addEventListener("scroll", function (f) { - var fixLimit = _this.fixLimit; - - if (window.pageYOffset >= fixLimit) { - document.getElementById('edit-control').style.position = "fixed"; - } else { - document.getElementById('edit-control').style.position = "relative"; - } - }); - - _this.refresh(); - - return _this; - } //-------------------------- - // methods - //-------------------------- - - - _createClass(TextEditor, [{ - key: "setInputs", - value: function setInputs() { - var _this2 = this; - - var self = this; - var editorButtons = document.querySelectorAll('.editor-button'); - - for (var i = 0, length = editorButtons.length; i < length; i++) { - editorButtons[i].addEventListener('click', function (e) { - return _this2.handleEditorOption(e); - }, false); - } - - this.textEditor.addEventListener('input', function (f) { - if (f.inputType == "insertParagraph") { - var caret = (0, _caretPos.position)(self.textEditor).pos + 1; - var spiffed = hljs.highlight('markdown', self.textEditor.innerText).value; - var temp = document.createElement("div"); - temp.innerText = spiffed; - self.textEditor.innerHTML = temp.innerText; - (0, _caretPos.position)(self.textEditor, caret); - } else { - self.refresh(); - } - }); - } - }, { - key: "refresh", - value: function refresh() { - var caret = (0, _caretPos.position)(this.textEditor).pos; - var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value; - var temp = document.createElement("div"); - temp.innerText = spiffed; - this.textEditor.innerHTML = temp.innerText; - (0, _caretPos.position)(this.textEditor, caret); - } - }, { - key: "notify", - value: function notify(type, data) { - switch (type) { - case DataEvent.POST_UPDATED: - document.getElementById('submit-update').classList.add('icon-hide'); - document.getElementById('submit-good').classList.remove('icon-hide'); - document.getElementById('edit-update').classList.remove('submit-start'); - document.getElementById('edit-update').classList.add('submit-cool'); - setTimeout(function (f) { - document.getElementById('submit-update').classList.remove('icon-hide'); - document.getElementById('submit-good').classList.add('icon-hide'); - document.getElementById('edit-update').classList.add('submit-start'); - document.getElementById('edit-update').classList.remove('submit-cool'); - }, 2000); - break; - - case DataEvent.POST_ADDED: - // do nothing - break; - - case EditorEvent.EDITOR_UPLOAD_POST_IMAGE: - (0, _caretPos.position)(this.textEditor, this.caretPos); - var sel, range, pulled; - sel = window.getSelection(); //console.log(sel) - //console.log(note.message) - - if (sel.rangeCount) { - range = sel.getRangeAt(0); - pulled = sel.getRangeAt(0).toString(); - range.deleteContents(); - range.insertNode(document.createTextNode("![image alt text](" + data + " 'image title')")); - } - - this.refresh(); - break; - } - } //-------------------------- - // event handlers - //-------------------------- - - }, { - key: "handleEditorOption", - value: function handleEditorOption(e) { - e.preventDefault(); - var self = this; - var sel, range, pulled; - sel = window.getSelection(); //console.log(sel) - - if (sel.rangeCount) { - range = sel.getRangeAt(0); - pulled = sel.getRangeAt(0).toString(); - range.deleteContents(); - - switch (e.target.id) { - case "edit-bold": - range.insertNode(document.createTextNode("**" + pulled + "**")); - break; - - case "edit-italic": - range.insertNode(document.createTextNode("*" + pulled + "*")); - break; - - case "edit-strikethrough": - range.insertNode(document.createTextNode("" + pulled + "")); - break; - - case "edit-header1": - range.insertNode(document.createTextNode("# " + pulled)); - break; - - case "edit-header2": - range.insertNode(document.createTextNode("## " + pulled)); - break; - - case "edit-header3": - range.insertNode(document.createTextNode("### " + pulled)); - break; - - case "edit-image": - this.caretPos = (0, _caretPos.position)(this.textEditor).pos; - this.emitEvent(EditorEvent.EDITOR_UPLOAD_POST_IMAGE); - break; - - case "submit-save": - case "edit-save": - this.emitEvent(EditorEvent.EDITOR_SAVE); - break; - - case "submit-update": - case "edit-update": - this.emitEvent(EditorEvent.EDITOR_UPDATE); - break; - - case "edit-link": - range.insertNode(document.createTextNode("[" + pulled + "](PASTE URL HERE)")); - break; - - case "edit-delete": - this.emitEvent(EditorEvent.EDITOR_DELETE); - break; - - default: - //range.insertNode(document.createTextNode("[" + self.url + "](PASTE URL HERE)")); - break; - } - } - - this.refresh(); - } - }]); - - return TextEditor; -}(_EventEmitter2.default); - -var _default = TextEditor; -exports.default = _default; -},{"../events/DataEvent":"tools/events/DataEvent.jsx","./DateUtils":"tools/utilities/DateUtils.jsx","caret-pos":"../../../../node_modules/caret-pos/lib/esm2015/main.js","../events/EventEmitter":"tools/events/EventEmitter.jsx","../events/EditorEvent":"tools/events/EditorEvent.jsx"}],"../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js":[function(require,module,exports) { +},{}],"../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js":[function(require,module,exports) { var define; var global = arguments[3]; (function (global, factory) { @@ -2762,7 +1949,7 @@ var global = arguments[3]; }))); -},{}],"controllers/PostEditor.jsx":[function(require,module,exports) { +},{}],"../../../../brain/tools/utilities/DateUtils.jsx":[function(require,module,exports) { "use strict"; Object.defineProperty(exports, "__esModule", { @@ -2770,21 +1957,921 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -var _DataUtils = _interopRequireWildcard(require("../tools/utilities/DataUtils")); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var DataEvent = _interopRequireWildcard(require("../tools/events/DataEvent")); +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } -var Ease = _interopRequireWildcard(require("../tools/effects/Animate")); +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var DateUtils = +/*#__PURE__*/ +function () { + //-------------------------- + // constructor + //-------------------------- + function DateUtils() { + _classCallCheck(this, DateUtils); + } //-------------------------- + // methods + //-------------------------- + + + _createClass(DateUtils, [{ + key: "getMKtime", + value: function getMKtime() { + var time = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), new Date().getMinutes(), new Date().getSeconds(), 0).getTime() / 1000; + return time; + } + }, { + key: "convertMKtime", + value: function convertMKtime(seconds) { + var date = new Date(seconds * 1000); + return date; + } + }, { + key: "getDate", + value: function getDate(type, rawdate) { + var day = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCDate()) : String(new Date().getUTCDate()); + var month = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMonth() + 1) : String(new Date().getUTCMonth() + 1); + var year = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCFullYear()) : String(new Date().getUTCFullYear()); + var hour = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCHours()) : String(new Date().getUTCHours()); + var minute = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMinutes()) : String(new Date().getUTCMinutes()); + var seconds = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCSeconds()) : String(new Date().getUTCSeconds()); + var millisecond = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMilliseconds()) : String(new Date().getUTCMilliseconds()); + var offset = rawdate != null || rawdate != '' ? String(new Date(rawdate).getTimezoneOffset()) : String(new Date().getTimezoneOffset()); + if (day.length == 1) day = String("0" + day); + if (month.length == 1) month = String("0" + month); + offset = String(offset / 60); + if (offset.length == 1) offset = String("0" + offset); + + switch (type) { + case "day": + return day; + break; + + case "month": + return month; + break; + + case "year": + return year; + break; + + case "stamp": + return String(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + seconds + "." + millisecond + "-" + offset); + break; + + default: + return String(year + "-" + month + "-" + day); + break; + } + } //-------------------------- + // event handlers + //-------------------------- + + }]); + + return DateUtils; +}(); + +var _default = DateUtils; +exports.default = _default; +},{}],"../../../../brain/tools/utilities/DateUtils.js":[function(require,module,exports) { +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var DateUtils = +/*#__PURE__*/ +function () { + //-------------------------- + // constructor + //-------------------------- + function DateUtils() { + _classCallCheck(this, DateUtils); + } //-------------------------- + // methods + //-------------------------- + + + _createClass(DateUtils, [{ + key: "getMKtime", + value: function getMKtime() { + var time = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), new Date().getMinutes(), new Date().getSeconds(), 0).getTime() / 1000; + return time; + } + }, { + key: "convertMKtime", + value: function convertMKtime(seconds) { + var date = new Date(seconds * 1000); + return date; + } + }, { + key: "getDate", + value: function getDate(type, rawdate) { + var day = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCDate()) : String(new Date().getUTCDate()); + var month = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMonth() + 1) : String(new Date().getUTCMonth() + 1); + var year = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCFullYear()) : String(new Date().getUTCFullYear()); + var hour = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCHours()) : String(new Date().getUTCHours()); + var minute = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMinutes()) : String(new Date().getUTCMinutes()); + var seconds = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCSeconds()) : String(new Date().getUTCSeconds()); + var millisecond = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMilliseconds()) : String(new Date().getUTCMilliseconds()); + var offset = rawdate != null || rawdate != '' ? String(new Date(rawdate).getTimezoneOffset()) : String(new Date().getTimezoneOffset()); + if (day.length == 1) day = String("0" + day); + if (month.length == 1) month = String("0" + month); + offset = String(offset / 60); + if (offset.length == 1) offset = String("0" + offset); + + switch (type) { + case "day": + return day; + break; + + case "month": + return month; + break; + + case "year": + return year; + break; + + case "stamp": + return String(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + seconds + "." + millisecond + "-" + offset); + break; + + default: + return String(year + "-" + month + "-" + day); + break; + } + } //-------------------------- + // event handlers + //-------------------------- + + }]); + + return DateUtils; +}(); + +var _default = DateUtils; +exports.default = _default; +},{}],"../../../../node_modules/caret-pos/lib/esm2015/main.js":[function(require,module,exports) { +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getOffset = exports.offset = exports.position = void 0; +var attributes = ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle', 'borderTopWidth', 'boxSizing', 'fontFamily', 'fontSize', 'fontWeight', 'height', 'letterSpacing', 'lineHeight', 'marginBottom', 'marginLeft', 'marginRight', 'marginTop', 'outlineWidth', 'overflow', 'overflowX', 'overflowY', 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', 'textAlign', 'textOverflow', 'textTransform', 'whiteSpace', 'wordBreak', 'wordWrap']; +/** + * Create a mirror + * + * @param {Element} element The element + * @param {string} html The html + * + * @return {object} The mirror object + */ + +var createMirror = function createMirror(element, html) { + /** + * The mirror element + */ + var mirror = document.createElement('div'); + /** + * Create the CSS for the mirror object + * + * @return {object} The style object + */ + + var mirrorCss = function mirrorCss() { + var css = { + position: 'absolute', + left: -9999, + top: 0, + zIndex: -2000 + }; + + if (element.tagName === 'TEXTAREA') { + attributes.push('width'); + } + + attributes.forEach(function (attr) { + css[attr] = getComputedStyle(element)[attr]; + }); + return css; + }; + /** + * Initialize the mirror + * + * @param {string} html The html + * + * @return {void} + */ + + + var initialize = function initialize(html) { + var styles = mirrorCss(); + Object.keys(styles).forEach(function (key) { + mirror.style[key] = styles[key]; + }); + mirror.innerHTML = html; + element.parentNode.insertBefore(mirror, element.nextSibling); + }; + /** + * Get the rect + * + * @return {Rect} The bounding rect + */ + + + var rect = function rect() { + var marker = mirror.ownerDocument.getElementById('caret-position-marker'); + var boundingRect = { + left: marker.offsetLeft, + top: marker.offsetTop, + height: marker.offsetHeight + }; + mirror.parentNode.removeChild(mirror); + return boundingRect; + }; + + initialize(html); + return { + rect: rect + }; +}; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; +} : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; +}; +/** + * Check if a DOM Element is content editable + * + * @param {Element} element The DOM element + * + * @return {bool} If it is content editable + */ + + +var isContentEditable = function isContentEditable(element) { + return !!(element.contentEditable && element.contentEditable === 'true'); +}; +/** + * Get the context from settings passed in + * + * @param {object} settings The settings object + * + * @return {object} window and document + */ + + +var getContext = function getContext() { + var settings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var customPos = settings.customPos, + iframe = settings.iframe, + noShadowCaret = settings.noShadowCaret; + + if (iframe) { + return { + iframe: iframe, + window: iframe.contentWindow, + document: iframe.contentDocument || iframe.contentWindow.document, + noShadowCaret: noShadowCaret, + customPos: customPos + }; + } + + return { + window: window, + document: document, + noShadowCaret: noShadowCaret, + customPos: customPos + }; +}; +/** + * Get the offset of an element + * + * @param {Element} element The DOM element + * @param {object} ctx The context + * + * @return {object} top and left + */ + + +var getOffset = function getOffset(element, ctx) { + var win = ctx && ctx.window || window; + var doc = ctx && ctx.document || document; + var rect = element.getBoundingClientRect(); + var docEl = doc.documentElement; + var scrollLeft = win.pageXOffset || docEl.scrollLeft; + var scrollTop = win.pageYOffset || docEl.scrollTop; + return { + top: rect.top + scrollTop, + left: rect.left + scrollLeft + }; +}; +/** + * Check if a value is an object + * + * @param {any} value The value to check + * + * @return {bool} If it is an object + */ + + +exports.getOffset = getOffset; + +var isObject = function isObject(value) { + return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null; +}; +/** + * Create a Input caret object. + * + * @param {Element} element The element + * @param {Object} ctx The context + */ + + +var createInputCaret = function createInputCaret(element, ctx) { + /** + * Get the current position + * + * @returns {int} The caret position + */ + var getPos = function getPos() { + return element.selectionStart; + }; + /** + * Set the position + * + * @param {int} pos The position + * + * @return {Element} The element + */ + + + var setPos = function setPos(pos) { + element.setSelectionRange(pos, pos); + return element; + }; + /** + * The offset + * + * @param {int} pos The position + * + * @return {object} The offset + */ + + + var getOffset$$1 = function getOffset$$1(pos) { + var rect = getOffset(element); + var position = getPosition(pos); + return { + top: rect.top + position.top + ctx.document.body.scrollTop, + left: rect.left + position.left + ctx.document.body.scrollLeft, + height: position.height + }; + }; + /** + * Get the current position + * + * @param {int} pos The position + * + * @return {object} The position + */ + + + var getPosition = function getPosition(pos) { + var format = function format(val) { + var value = val.replace(/<|>|`|"|&/g, '?').replace(/\r\n|\r|\n/g, '
'); + return value; + }; + + if (ctx.customPos || ctx.customPos === 0) { + pos = ctx.customPos; + } + + var position = pos === undefined ? getPos() : pos; + var startRange = element.value.slice(0, position); + var endRange = element.value.slice(position); + var html = '' + format(startRange) + ''; + html += '|'; + html += '' + format(endRange) + ''; + var mirror = createMirror(element, html); + var rect = mirror.rect(); + rect.pos = getPos(); + return rect; + }; + + return { + getPos: getPos, + setPos: setPos, + getOffset: getOffset$$1, + getPosition: getPosition + }; +}; +/** + * Create an Editable Caret + * @param {Element} element The editable element + * @param {object|null} ctx The context + * + * @return {EditableCaret} + */ + + +var createEditableCaret = function createEditableCaret(element, ctx) { + /** + * Set the caret position + * + * @param {int} pos The position to se + * + * @return {Element} The element + */ + var setPos = function setPos(pos) { + var sel = ctx.window.getSelection(); + + if (sel) { + var offset = 0; + var found = false; + + var find = function find(position, parent) { + for (var i = 0; i < parent.childNodes.length; i++) { + var node = parent.childNodes[i]; + + if (found) { + break; + } + + if (node.nodeType === 3) { + if (offset + node.length >= position) { + found = true; + var range = ctx.document.createRange(); + range.setStart(node, position - offset); + sel.removeAllRanges(); + sel.addRange(range); + break; + } else { + offset += node.length; + } + } else { + find(pos, node); + } + } + }; + + find(pos, element); + } + + return element; + }; + /** + * Get the offset + * + * @return {object} The offset + */ + + + var getOffset = function getOffset() { + var range = getRange(); + var offset = { + height: 0, + left: 0, + right: 0 + }; + + if (!range) { + return offset; + } + + var hasCustomPos = ctx.customPos || ctx.customPos === 0; // endContainer in Firefox would be the element at the start of + // the line + + if (range.endOffset - 1 > 0 && range.endContainer !== element || hasCustomPos) { + var clonedRange = range.cloneRange(); + var fixedPosition = hasCustomPos ? ctx.customPos : range.endOffset; + clonedRange.setStart(range.endContainer, fixedPosition - 1 < 0 ? 0 : fixedPosition - 1); + clonedRange.setEnd(range.endContainer, fixedPosition); + var rect = clonedRange.getBoundingClientRect(); + offset = { + height: rect.height, + left: rect.left + rect.width, + top: rect.top + }; + clonedRange.detach(); + } + + if ((!offset || offset && offset.height === 0) && !ctx.noShadowCaret) { + var _clonedRange = range.cloneRange(); + + var shadowCaret = ctx.document.createTextNode('|'); + + _clonedRange.insertNode(shadowCaret); + + _clonedRange.selectNode(shadowCaret); + + var _rect = _clonedRange.getBoundingClientRect(); + + offset = { + height: _rect.height, + left: _rect.left, + top: _rect.top + }; + shadowCaret.parentNode.removeChild(shadowCaret); + + _clonedRange.detach(); + } + + if (offset) { + var doc = ctx.document.documentElement; + offset.top += ctx.window.pageYOffset - (doc.clientTop || 0); + offset.left += ctx.window.pageXOffset - (doc.clientLeft || 0); + } + + return offset; + }; + /** + * Get the position + * + * @return {object} The position + */ + + + var getPosition = function getPosition() { + var offset = getOffset(); + var pos = getPos(); + var rect = element.getBoundingClientRect(); + var inputOffset = { + top: rect.top + ctx.document.body.scrollTop, + left: rect.left + ctx.document.body.scrollLeft + }; + offset.left -= inputOffset.left; + offset.top -= inputOffset.top; + offset.pos = pos; + return offset; + }; + /** + * Get the range + * + * @return {Range|null} + */ + + + var getRange = function getRange() { + if (!ctx.window.getSelection) { + return; + } + + var sel = ctx.window.getSelection(); + return sel.rangeCount > 0 ? sel.getRangeAt(0) : null; + }; + /** + * Get the caret position + * + * @return {int} The position + */ + + + var getPos = function getPos() { + var range = getRange(); + var clonedRange = range.cloneRange(); + clonedRange.selectNodeContents(element); + clonedRange.setEnd(range.endContainer, range.endOffset); + var pos = clonedRange.toString().length; + clonedRange.detach(); + return pos; + }; + + return { + getPos: getPos, + setPos: setPos, + getPosition: getPosition, + getOffset: getOffset, + getRange: getRange + }; +}; + +var createCaret = function createCaret(element, ctx) { + if (isContentEditable(element)) { + return createEditableCaret(element, ctx); + } + + return createInputCaret(element, ctx); +}; + +var position = function position(element, value) { + var settings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + var options = settings; + + if (isObject(value)) { + options = value; + value = null; + } + + var ctx = getContext(options); + var caret = createCaret(element, ctx); + + if (value || value === 0) { + return caret.setPos(value); + } + + return caret.getPosition(); +}; +/** + * + * @param {Element} element The DOM element + * @param {number|undefined} value The value to set + * @param {object} settings Any settings for context + */ + + +exports.position = position; + +var offset = function offset(element, value) { + var settings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + var options = settings; + + if (isObject(value)) { + options = value; + value = null; + } + + var ctx = getContext(options); + var caret = createCaret(element, ctx); + return caret.getOffset(value); +}; + +exports.offset = offset; +},{}],"../../../../brain/tools/ui/TextEditor.jsx":[function(require,module,exports) { +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var DataEvent = _interopRequireWildcard(require("../events/DataEvent")); + +var _DateUtils = _interopRequireDefault(require("../utilities/DateUtils")); + +var _caretPos = require("caret-pos"); + +var _EventEmitter2 = _interopRequireDefault(require("../events/EventEmitter")); + +var EditorEvent = _interopRequireWildcard(require("../events/EditorEvent")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +var TextEditor = +/*#__PURE__*/ +function (_EventEmitter) { + _inherits(TextEditor, _EventEmitter); + + //-------------------------- + // constructor + //-------------------------- + function TextEditor(textEditor, scrollLimit) { + var _this; + + _classCallCheck(this, TextEditor); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(TextEditor).call(this)); + hljs.initHighlightingOnLoad(); //this.dataUtils = new DataUtils(); + + _this.dateUtils = new _DateUtils.default(); + _this.textEditor = textEditor; + _this.fixLimit = scrollLimit; + _this.caretPos = null; + _this.url = ''; + + var self = _assertThisInitialized(_assertThisInitialized(_this)); + + _this.setInputs(); + + window.addEventListener("scroll", function (f) { + var fixLimit = _this.fixLimit; + + if (window.pageYOffset >= fixLimit) { + document.getElementById('edit-control').style.position = "fixed"; + } else { + document.getElementById('edit-control').style.position = "relative"; + } + }); + + _this.refresh(); + + return _this; + } //-------------------------- + // methods + //-------------------------- + + + _createClass(TextEditor, [{ + key: "setInputs", + value: function setInputs() { + var _this2 = this; + + var self = this; + var editorButtons = document.querySelectorAll('.editor-button'); + + for (var i = 0, length = editorButtons.length; i < length; i++) { + editorButtons[i].addEventListener('click', function (e) { + return _this2.handleEditorOption(e); + }, false); + } + + this.textEditor.addEventListener('input', function (f) { + if (f.inputType == "insertParagraph") { + var caret = (0, _caretPos.position)(self.textEditor).pos + 1; + var spiffed = hljs.highlight('markdown', self.textEditor.innerText).value; + var temp = document.createElement("div"); + temp.innerText = spiffed; + self.textEditor.innerHTML = temp.innerText; + (0, _caretPos.position)(self.textEditor, caret); + } else { + self.refresh(); + } + }); + } + }, { + key: "refresh", + value: function refresh() { + var caret = (0, _caretPos.position)(this.textEditor).pos; + var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value; + var temp = document.createElement("div"); + temp.innerText = spiffed; + this.textEditor.innerHTML = temp.innerText; + (0, _caretPos.position)(this.textEditor, caret); + } + }, { + key: "notify", + value: function notify(type, data) { + switch (type) { + case DataEvent.POST_UPDATED: + document.getElementById('submit-update').classList.add('icon-hide'); + document.getElementById('submit-good').classList.remove('icon-hide'); + document.getElementById('edit-update').classList.remove('submit-start'); + document.getElementById('edit-update').classList.add('submit-cool'); + setTimeout(function (f) { + document.getElementById('submit-update').classList.remove('icon-hide'); + document.getElementById('submit-good').classList.add('icon-hide'); + document.getElementById('edit-update').classList.add('submit-start'); + document.getElementById('edit-update').classList.remove('submit-cool'); + }, 2000); + break; + + case DataEvent.POST_ADDED: + // do nothing + break; + + case EditorEvent.EDITOR_UPLOAD_POST_IMAGE: + (0, _caretPos.position)(this.textEditor, this.caretPos); + var sel, range, pulled; + sel = window.getSelection(); //console.log(sel) + //console.log(note.message) + + if (sel.rangeCount) { + range = sel.getRangeAt(0); + pulled = sel.getRangeAt(0).toString(); + range.deleteContents(); + range.insertNode(document.createTextNode("![image alt text](" + data + " 'image title')")); + } + + this.refresh(); + break; + } + } //-------------------------- + // event handlers + //-------------------------- + + }, { + key: "handleEditorOption", + value: function handleEditorOption(e) { + e.preventDefault(); + var self = this; + var sel, range, pulled; + sel = window.getSelection(); //console.log(sel) + + if (sel.rangeCount) { + range = sel.getRangeAt(0); + pulled = sel.getRangeAt(0).toString(); + range.deleteContents(); + + switch (e.target.id) { + case "edit-bold": + range.insertNode(document.createTextNode("**" + pulled + "**")); + break; + + case "edit-italic": + range.insertNode(document.createTextNode("*" + pulled + "*")); + break; + + case "edit-strikethrough": + range.insertNode(document.createTextNode("" + pulled + "")); + break; + + case "edit-header1": + range.insertNode(document.createTextNode("# " + pulled)); + break; + + case "edit-header2": + range.insertNode(document.createTextNode("## " + pulled)); + break; + + case "edit-header3": + range.insertNode(document.createTextNode("### " + pulled)); + break; + + case "edit-image": + this.caretPos = (0, _caretPos.position)(this.textEditor).pos; + this.emitEvent(EditorEvent.EDITOR_UPLOAD_POST_IMAGE); + break; + + case "submit-save": + case "edit-save": + this.emitEvent(EditorEvent.EDITOR_SAVE); + break; + + case "submit-update": + case "edit-update": + this.emitEvent(EditorEvent.EDITOR_UPDATE); + break; + + case "edit-link": + range.insertNode(document.createTextNode("[" + pulled + "](PASTE URL HERE)")); + break; + + case "edit-delete": + this.emitEvent(EditorEvent.EDITOR_DELETE); + break; + + default: + //range.insertNode(document.createTextNode("[" + self.url + "](PASTE URL HERE)")); + break; + } + } + + this.refresh(); + } + }]); + + return TextEditor; +}(_EventEmitter2.default); + +var _default = TextEditor; +exports.default = _default; +},{"../events/DataEvent":"../../../../brain/tools/events/DataEvent.jsx","../utilities/DateUtils":"../../../../brain/tools/utilities/DateUtils.js","caret-pos":"../../../../node_modules/caret-pos/lib/esm2015/main.js","../events/EventEmitter":"../../../../brain/tools/events/EventEmitter.jsx","../events/EditorEvent":"../../../../brain/tools/events/EditorEvent.jsx"}],"controllers/PostEditor.jsx":[function(require,module,exports) { +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _DataUtils = _interopRequireWildcard(require("../../../../../brain/tools/utilities/DataUtils")); + +var DataEvent = _interopRequireWildcard(require("../../../../../brain/tools/events/DataEvent")); + +var _Animate = _interopRequireDefault(require("../../../../../brain/tools/effects/Animate")); var _PostActions = _interopRequireDefault(require("../actions/PostActions")); -var EditorEvent = _interopRequireWildcard(require("../tools/events/EditorEvent")); - -var _TextEditor = _interopRequireDefault(require("../tools/utilities/TextEditor")); +var EditorEvent = _interopRequireWildcard(require("../../../../../brain/tools/events/EditorEvent")); var _tinyDatePicker = _interopRequireDefault(require("tiny-date-picker")); -var _DateUtils = _interopRequireDefault(require("../tools/utilities/DateUtils")); +var _DateUtils = _interopRequireDefault(require("../../../../../brain/tools/utilities/DateUtils")); + +var _TextEditor = _interopRequireDefault(require("../../../../../brain/tools/ui/TextEditor")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -2807,9 +2894,10 @@ function () { _classCallCheck(this, PostEditor); - reframe('iframe'); + //reframe('iframe'); var self = this; this.uploadFiles; + this.anim = new _Animate.default(); this.dataUtils = new _DataUtils.default(); this.dateUtils = new _DateUtils.default(); @@ -2851,7 +2939,7 @@ function () { var _this2 = this; var self = this; - new Ease.default().object({ + new _Animate.default().object({ targets: document.getElementById('loader'), duration: 300, opacity: 0, @@ -2859,7 +2947,7 @@ function () { complete: function complete() { document.getElementById('loader').style.display = 'none'; document.getElementById('loader').style.visibility = 'hidden'; - new Ease.default().object({ + new _Animate.default().object({ targets: document.getElementById('header'), duration: 10, opacity: 1, @@ -3062,7 +3150,7 @@ function () { exports.default = PostEditor; PostEditor.uploadFiles = []; -},{"../tools/utilities/DataUtils":"tools/utilities/DataUtils.jsx","../tools/events/DataEvent":"tools/events/DataEvent.jsx","../tools/effects/Animate":"tools/effects/Animate.jsx","../actions/PostActions":"actions/PostActions.jsx","../tools/events/EditorEvent":"tools/events/EditorEvent.jsx","../tools/utilities/TextEditor":"tools/utilities/TextEditor.jsx","tiny-date-picker":"../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js","../tools/utilities/DateUtils":"tools/utilities/DateUtils.jsx"}],"controllers/DisplayManager.jsx":[function(require,module,exports) { +},{"../../../../../brain/tools/utilities/DataUtils":"../../../../brain/tools/utilities/DataUtils.jsx","../../../../../brain/tools/events/DataEvent":"../../../../brain/tools/events/DataEvent.jsx","../../../../../brain/tools/effects/Animate":"../../../../brain/tools/effects/Animate.jsx","../actions/PostActions":"actions/PostActions.jsx","../../../../../brain/tools/events/EditorEvent":"../../../../brain/tools/events/EditorEvent.jsx","tiny-date-picker":"../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js","../../../../../brain/tools/utilities/DateUtils":"../../../../brain/tools/utilities/DateUtils.jsx","../../../../../brain/tools/ui/TextEditor":"../../../../brain/tools/ui/TextEditor.jsx"}],"controllers/DisplayManager.jsx":[function(require,module,exports) { "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3070,11 +3158,11 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -var _DataUtils = _interopRequireWildcard(require("../tools/utilities/DataUtils.jsx")); +var _DataUtils = _interopRequireWildcard(require("../../../../../brain/tools/utilities/DataUtils")); var _PostEditor = _interopRequireDefault(require("./PostEditor")); -var _Animate = _interopRequireDefault(require("../tools/effects/Animate.jsx")); +var _Animate = _interopRequireDefault(require("../../../../../brain/tools/effects/Animate.jsx")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -3097,7 +3185,7 @@ function () { this.dataUtils = new _DataUtils.default(); this.currentDisplay = ''; - this.urlPieces = document.URL.split("/"); //grab url so system knows what to display + this.urlPieces = document.URL.split("/"); //grab url so system knows what to display this.chooseDisplay(this.urlPieces[5], this.urlPieces[6]); } //-------------------------- @@ -3108,7 +3196,8 @@ function () { _createClass(DisplayManager, [{ key: "start", value: function start() { - var self = this; + var self = this; // new stuff + new _Animate.default().object({ targets: document.getElementById('loader'), duration: 300, @@ -3133,7 +3222,7 @@ function () { }, { key: "chooseDisplay", value: function chooseDisplay(section, page) { - this.currentDisplay = ''; //console.log(section+" "+page) + this.currentDisplay = ''; switch (section) { case 'posts': @@ -3156,7 +3245,7 @@ function () { }(); exports.default = DisplayManager; -},{"../tools/utilities/DataUtils.jsx":"tools/utilities/DataUtils.jsx","./PostEditor":"controllers/PostEditor.jsx","../tools/effects/Animate.jsx":"tools/effects/Animate.jsx"}],"Base.jsx":[function(require,module,exports) { +},{"../../../../../brain/tools/utilities/DataUtils":"../../../../brain/tools/utilities/DataUtils.jsx","./PostEditor":"controllers/PostEditor.jsx","../../../../../brain/tools/effects/Animate.jsx":"../../../../brain/tools/effects/Animate.jsx"}],"Base.jsx":[function(require,module,exports) { "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3164,9 +3253,9 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -var _DataUtils = _interopRequireWildcard(require("./tools/utilities/DataUtils.jsx")); +var _DataUtils = _interopRequireWildcard(require("../../../../brain/tools/utilities/DataUtils")); -var DataEvent = _interopRequireWildcard(require("./tools/events/DataEvent.jsx")); +var DataEvent = _interopRequireWildcard(require("../../../../brain/tools/events/DataEvent.jsx")); var _DisplayManager = _interopRequireDefault(require("./controllers/DisplayManager.jsx")); @@ -3230,7 +3319,7 @@ function () { }(); exports.default = Base; -},{"./tools/utilities/DataUtils.jsx":"tools/utilities/DataUtils.jsx","./tools/events/DataEvent.jsx":"tools/events/DataEvent.jsx","./controllers/DisplayManager.jsx":"controllers/DisplayManager.jsx"}],"Start.jsx":[function(require,module,exports) { +},{"../../../../brain/tools/utilities/DataUtils":"../../../../brain/tools/utilities/DataUtils.jsx","../../../../brain/tools/events/DataEvent.jsx":"../../../../brain/tools/events/DataEvent.jsx","./controllers/DisplayManager.jsx":"controllers/DisplayManager.jsx"}],"Start.jsx":[function(require,module,exports) { "use strict"; var _Base = _interopRequireDefault(require("./Base.jsx")); @@ -3267,7 +3356,7 @@ var parent = module.bundle.parent; if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') { var hostname = "" || location.hostname; var protocol = location.protocol === 'https:' ? 'wss' : 'ws'; - var ws = new WebSocket(protocol + '://' + hostname + ':' + "57869" + '/'); + var ws = new WebSocket(protocol + '://' + hostname + ':' + "50421" + '/'); ws.onmessage = function (event) { var data = JSON.parse(event.data); diff --git a/themes/dash/assets/js/dash.min.map b/themes/dash/assets/js/dash.min.map index e018f1c..aa02d3e 100644 --- a/themes/dash/assets/js/dash.min.map +++ b/themes/dash/assets/js/dash.min.map @@ -1 +1 @@ -{"version":3,"sources":["tools/events/EventEmitter.jsx","tools/events/DataEvent.jsx","tools/utilities/DataUtils.jsx","tools/effects/Animate.jsx","tools/utilities/StringUtils.jsx","actions/PostActions.jsx","tools/events/EditorEvent.jsx","tools/utilities/DateUtils.jsx","../../src/mirror.js","../../src/utils.js","../../src/input.js","../../src/editable.js","../../src/main.js","tools/utilities/TextEditor.jsx","../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js","controllers/PostEditor.jsx","controllers/DisplayManager.jsx","Base.jsx","Start.jsx"],"names":["EventEmitter","listeners","Map","label","callback","has","set","get","push","isFunction","obj","index","length","reduce","i","listener","splice","args","forEach","REQUEST_GOOD","REQUEST_LAME","IMG_REQUEST_GOOD","IMG_REQUEST_LAME","SETTINGS_LOADED","HTML_LOADED","ARCHIVES_JSON_LOADED","ARCHIVES_PAGE_LOADED","ARCHIVES_ENTRY_LOADED","PROJECT_UPDATED","PROJECT_ADDED","PROJECTS_SORTED","POST_IMAGE_ADDED","POST_ERROR","POST_ADDED","POST_UPDATED","POST_DELETED","DataEvent","REQUEST_TYPE_POST","REQUEST_TYPE_GET","REQUEST_TYPE_PUT","REQUEST_TYPE_DELETE","CONTENT_TYPE_JSON","CONTENT_TYPE_FORM","DataUtils","self","requestURL","eventType","requestType","contentType","requestData","Promise","resolve","reject","request","XMLHttpRequest","upload","onprogress","handleLoadProgress","open","onload","e","status","setRequestHeader","send","JSON","stringify","url","responseType","response","Error","statusText","onerror","src","body","document","querySelector","myImage","Image","crossOrigin","imgLoad","then","imageURL","window","URL","createObjectURL","percentComplete","Math","ceil","loaded","total","Animate","properties","animation","anime","StringUtils","string","clean","replace","toLowerCase","quote_style","optTemp","noquotes","toString","OPTS","concat","ENT_HTML_QUOTE_SINGLE","PostActions","folio","dataUtils","edit","uploadFiles","postData","FormData","files","file","type","match","append","name","txt","createElement","innerHTML","getElementById","value","cleanString","getAttribute","postURL","postEventType","postID","catch","err","EDITOR_DELETE","EDITOR_UPLOAD_POST_IMAGE","EDITOR_SAVE","EDITOR_UPDATE","EditorEvent","DateUtils","time","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","getTime","seconds","date","rawdate","day","String","getUTCDate","month","getUTCMonth","year","getUTCFullYear","hour","getUTCHours","minute","getUTCMinutes","getUTCSeconds","millisecond","getUTCMilliseconds","offset","getTimezoneOffset","attributes","createMirror","element","html","mirror","mirrorCss","css","tagName","attr","getComputedStyle","initialize","styles","keys","style","key","parentNode","insertBefore","nextSibling","rect","marker","ownerDocument","boundingRect","offsetLeft","offsetTop","offsetHeight","removeChild","isContentEditable","contentEditable","getContext","settings","customPos","iframe","noShadowCaret","contentWindow","contentDocument","getOffset","ctx","win","doc","getBoundingClientRect","docEl","documentElement","scrollLeft","pageXOffset","scrollTop","pageYOffset","top","left","isObject","createInputCaret","getPos","selectionStart","setPos","pos","setSelectionRange","elementOffset","position","getPosition","height","format","val","undefined","startRange","slice","endRange","createEditableCaret","sel","getSelection","found","find","parent","childNodes","node","nodeType","range","createRange","setStart","removeAllRanges","addRange","getRange","hasCustomPos","endOffset","endContainer","clonedRange","cloneRange","fixedPosition","setEnd","width","detach","shadowCaret","createTextNode","insertNode","selectNode","clientTop","clientLeft","inputOffset","rangeCount","getRangeAt","selectNodeContents","createCaret","options","caret","TextEditor","textEditor","scrollLimit","hljs","initHighlightingOnLoad","dateUtils","fixLimit","caretPos","setInputs","addEventListener","f","refresh","editorButtons","querySelectorAll","handleEditorOption","inputType","spiffed","highlight","innerText","temp","data","classList","add","remove","setTimeout","pulled","deleteContents","preventDefault","target","id","emitEvent","PostEditor","reframe","editor","addListener","handleEditorOptions","handlePostImageAdd","mode","start","object","targets","duration","opacity","easing","complete","display","visibility","handleDragOver","handleDrop","handleClicked","click","optionButtons","handlePostOptions","currentOption","active","setAttribute","submitPost","note","parse","notify","message","location","console","log","confirm","deletePost","stopPropagation","dataTransfer","dropEffect","reader","FileReader","theFile","image","result","title","escape","span","join","appendChild","readAsDataURL","DisplayManager","currentDisplay","urlPieces","split","chooseDisplay","section","page","Base","admin","displayManager","base"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAMA;;;AA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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;AChrCA;;AAQA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;IAGM+B;;;AACF;AACA;AACA;AACA,wBAAc;AAAA;;AAAA;;AACVC,IAAAA,OAAO,CAAC,QAAD,CAAP;AACA,QAAI/P,IAAI,GAAG,IAAX;AACA,SAAKkE,WAAL;AACA,SAAKF,SAAL,GAAiB,IAAIjE,kBAAJ,EAAjB;AACA,SAAKqO,SAAL,GAAiB,IAAIxI,kBAAJ,EAAjB;;AACA,QAAI9D,QAAQ,CAACgD,cAAT,CAAwB,gBAAxB,CAAJ,EAA+C;AAC3C,WAAKkL,MAAL,GAAc,IAAIjC,mBAAJ,CAAejM,QAAQ,CAACgD,cAAT,CAAwB,gBAAxB,CAAf,EACVhD,QAAQ,CAACgD,cAAT,CAAwB,QAAxB,EAAkCmE,YAAlC,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;AACA;AAEA;AACA,kBAAc;AAAA;;AACV,QAAItT,IAAI,GAAG,IAAX;AACA,QAAIuT,KAAK,GAAG,EAAZ;AACA,QAAIxP,KAAK,GAAG,EAAZ;AACA,QAAIyP,cAAc,GAAG,EAArB;AACA,SAAKxP,SAAL,GAAiB,IAAIjE,kBAAJ,EAAjB;AACA,SAAKuJ,QAAL,GAAgB,EAAhB;AACA,SAAK+G,KAAL;AACH;;;;4BACO;AACJ,WAAKmD,cAAL,GAAsB,IAAIT,uBAAJ,EAAtB;AACH,MACD;AACA;AACA;;;;mCACe;AAAA;;AACX,UAAI/S,IAAI,GAAG,IAAX;AACA,WAAKgE,SAAL,CAAevD,OAAf,CAAuB,iCAAvB,EAA0DjB,SAAS,CAACb,eAApE,EACKyD,IADL,CACU,UAACZ,QAAD,EAAc;AAChB,QAAA,KAAI,CAAC8H,QAAL,GAAgBlI,IAAI,CAACqQ,KAAL,CAAWjQ,QAAQ,CAAC,SAAD,CAAR,CAAoBA,QAA/B,CAAhB;;AACA,QAAA,KAAI,CAAC6O,KAAL,GAFgB,CAGhB;;AAEH,OANL,EAOKhL,KAPL,CAOW,UAACC,GAAD,EAAS,CACZ;AACH,OATL;AAUH,MAED;AACA;AACA;;;;;;;;;;;ACzCJ;;;;AAEAxD,QAAQ,CAAC0M,gBAAT,CAA0B,kBAA1B,EAA8C,YAAW;AAErD,MAAIiF,IAAI,GAAG,IAAIH,aAAJ,EAAX;AACH,CAHD,EAGG,KAHH","file":"dash.min.map","sourceRoot":"../../src/com","sourcesContent":["class EventEmitter\n{\n\n //--------------------------\n // constructor\n //--------------------------\n constructor()\n {\n this.listeners = new Map();\n }\n //--------------------------\n // methods\n //--------------------------\n addListener(label, callback) {\n this.listeners.has(label) || this.listeners.set(label, []);\n this.listeners.get(label).push(callback);\n }\n\n removeListener(label, callback) {\n var isFunction = function(obj) {\n return typeof obj == 'function' || false;\n };\n\n var listeners = this.listeners.get(label),\n index;\n\n if (listeners && listeners.length) {\n index = listeners.reduce((i, listener, index) => {\n return (isFunction(listener) && listener === callback)\n ? i = index\n : i;\n }, -1);\n\n if (index > -1) {\n listeners.splice(index, 1);\n this.listeners.set(label, listeners);\n return true;\n }\n }\n return false;\n }\n\n emitEvent(label, ...args) {\n var listeners = this.listeners.get(label);\n if (listeners && listeners.length) {\n listeners.forEach((listener) => {\n listener(...args);\n });\n return true;\n }\n return false;\n }\n //--------------------------\n // event handlers\n //--------------------------\n}\nexport default EventEmitter\n","export const REQUEST_GOOD = 'requestGood';\nexport const REQUEST_LAME = 'requestLame';\nexport const IMG_REQUEST_GOOD = 'imgRequestGood';\nexport const IMG_REQUEST_LAME = 'imgRequestLame';\nexport const SETTINGS_LOADED = 'dataLoaded';\nexport const HTML_LOADED = 'htmlLoaded';\nexport const ARCHIVES_JSON_LOADED = 'archivesJSONLoaded';\nexport const ARCHIVES_PAGE_LOADED = 'archivesPAGELoaded';\nexport const ARCHIVES_ENTRY_LOADED = 'archivesEntryLoaded';\nexport const PROJECT_UPDATED = 'projectUpdated';\nexport const PROJECT_ADDED = 'projectAdded';\nexport const PROJECTS_SORTED = 'projectsSorted';\nexport const POST_IMAGE_ADDED = 'postImageAdded';\nexport const POST_ERROR = 'postError';\nexport const POST_ADDED = 'postAdded';\nexport const POST_UPDATED = 'postUpdated';\nexport const POST_DELETED = 'postImageAdded';\n\nclass DataEvent\n{\n\n //--------------------------\n // methods\n //--------------------------\n\n\n\n //--------------------------\n // event handlers\n //--------------------------\n}\nexport default new DataEvent\n","export const REQUEST_TYPE_POST = \"POST\";\nexport const REQUEST_TYPE_GET = \"GET\";\nexport const REQUEST_TYPE_PUT = \"PUT\";\nexport const REQUEST_TYPE_DELETE = \"DELETE\";\nexport const CONTENT_TYPE_JSON = 'json';\nexport const CONTENT_TYPE_FORM = 'x-www-form-urlencoded';\nimport EventEmitter from '../events/EventEmitter.jsx';\nimport * as DataEvent from '../events/DataEvent.jsx';\nclass DataUtils extends EventEmitter {\n //--------------------------\n // constructor\n //--------------------------\n constructor() {\n super();\n var self = this;\n }\n //--------------------------\n // methods\n //--------------------------\n request(requestURL, eventType, requestType = REQUEST_TYPE_GET, contentType = CONTENT_TYPE_JSON, requestData = null) {\n var self = this;\n return new Promise(function(resolve, reject) {\n var request = new XMLHttpRequest();\n request.upload.onprogress = self.handleLoadProgress;\n request.open(requestType, requestURL, true);\n request.onload = function(e) {\n if (request.status == 200) {\n resolve({\n request,\n eventType\n });\n } else {\n reject({\n request,\n eventType\n });\n }\n ;\n };\n if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {\n switch (contentType) {\n case CONTENT_TYPE_JSON:\n request.setRequestHeader(\"Content-type\", \"application/\" + contentType);\n request.send(JSON.stringify(requestData));\n break;\n case CONTENT_TYPE_FORM:\n request.send(requestData);\n break;\n }\n } else {\n request.send();\n }\n })\n }\n imgLoad(url) {\n 'use strict';\n // Create new promise with the Promise() constructor;\n // This has as its argument a function with two parameters, resolve and reject\n return new Promise(function(resolve, reject) {\n // Standard XHR to load an image\n var request = new XMLHttpRequest();\n request.open('GET', url);\n request.responseType = 'blob';\n // When the request loads, check whether it was successful\n request.onload = function() {\n if (request.status === 200) {\n // If successful, resolve the promise by passing back the request response\n resolve(request.response);\n } else {\n // If it fails, reject the promise with a error message\n reject(new Error('Image didn\\'t load successfully; error code:' + request.statusText));\n }\n };\n request.onerror = function() {\n // Also deal with the case when the entire request fails to begin with\n // This is probably a network error, so reject the promise with an appropriate message\n reject(new Error('There was a network error.'));\n };\n // Send the request\n request.send();\n });\n }\n loadImage(src) {\n 'use strict';\n let self = this;\n return new Promise(function(resolve, reject) {\n // Get a reference to the body element, and create a new image object\n var body = document.querySelector('body'),\n myImage = new Image();\n myImage.crossOrigin = \"\"; // or \"anonymous\"\n // Call the function with the URL we want to load, but then chain the\n // promise then() method on to the end of it. This contains two callbacks\n self.imgLoad(src).then(function(response) {\n // The first runs when the promise resolves, with the request.reponse specified within the resolve() method.\n var imageURL = window.URL.createObjectURL(response);\n resolve(imageURL);\n //$('background-content').setStyle('background-image', 'url('+imageURL+')') //myImage.src = imageURL;\n //console.log(imageURL);\n //body.appendChild(myImage);\n // The second runs when the promise is rejected, and logs the Error specified with the reject() method.\n }, function(Error) {\n reject(Error)\n });\n });\n }\n //--------------------------\n // event handlers\n //--------------------------\n handleLoadProgress(e) {\n var percentComplete = Math.ceil((e.loaded / e.total) * 100);\n //console.log(percentComplete);\n }\n}\nexport default DataUtils;\n","import EventEmitter from '../events/EventEmitter.jsx';;\n\nclass Animate extends EventEmitter {\n //--------------------------\n // constructor\n //--------------------------\n constructor() {\n super();\n }\n //--------------------------\n // methods\n //--------------------------\n object(properties) {\n var animation = anime(\n properties\n );\n //animation.start(properties);\n }\n //--------------------------\n // event handlers\n //--------------------------\n}\nexport default Animate\n","class StringUtils\n{\n\n //--------------------------\n // constructor\n //--------------------------\n constructor()\n {}\n //--------------------------\n // methods\n //--------------------------\n cleanString(string)\n {\n var clean = string.replace(/(^\\-+|[^a-zA-Z0-9\\/_| -]+|\\-+$)/g, '').toLowerCase().replace(/[\\/_| -]+/g, '-');\n return clean;\n }\n\n decodeHTML(string, quote_style) {\n var optTemp = 0,\n i = 0,\n noquotes = false;\n if (typeof quote_style === 'undefined') {\n quote_style = 2;\n }\n string = string.toString().replace(/</g, '<').replace(/>/g, '>');\n var OPTS = {\n 'ENT_NOQUOTES': 0,\n 'ENT_HTML_QUOTE_SINGLE': 1,\n 'ENT_HTML_QUOTE_DOUBLE': 2,\n 'ENT_COMPAT': 2,\n 'ENT_QUOTES': 3,\n 'ENT_IGNORE': 4\n };\n if (quote_style === 0) {\n noquotes = true;\n }\n if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags\n quote_style = [].concat(quote_style);\n for (i = 0; i < quote_style.length; i++) {\n // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4\n if (OPTS[quote_style[i]] === 0) {\n noquotes = true;\n } else if (OPTS[quote_style[i]]) {\n optTemp = optTemp | OPTS[quote_style[i]];\n }\n }\n quote_style = optTemp;\n }\n if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {\n string = string.replace(/�*39;/g, \"'\"); // PHP doesn't currently escape if more than one 0, but it should\n // string = string.replace(/'|�*27;/g, \"'\"); // This would also be useful here, but not a part of PHP\n }\n if (!noquotes) {\n string = string.replace(/"/g, '\"');\n }\n // Put this in last place to avoid escape being double-decoded\n string = string.replace(/&/g, '&');\n return string;\n }\n\n //--------------------------\n // event handlers\n //--------------------------\n}\nexport default StringUtils\n","import DataUtils, { REQUEST_TYPE_GET, REQUEST_TYPE_PUT, REQUEST_TYPE_POST, REQUEST_TYPE_DELETE, CONTENT_TYPE_JSON, CONTENT_TYPE_FORM } from '../tools/utilities/DataUtils';\nimport * as DataEvent from '../tools/events/DataEvent';\nimport StringUtils from '../tools/utilities/StringUtils';\nclass PostActions {\n //--------------------------\n // constructor\n //--------------------------\n constructor() {\n var folio = [];\n this.dataUtils = new DataUtils();\n }\n //--------------------------\n // methods\n //--------------------------\n start() {}\n\n submitPost(edit, uploadFiles) {\n let self = this;\n return new Promise(function(resolve, reject) {\n //collect form data\n //if(!this.validateForm())\n var postData = new FormData();\n //let projectImages = document.getElementById('projectImages');\n //var fileSelect = projectImages;\n var files = uploadFiles;\n for (var i = 0; i < files.length; i++) {\n var file = files[i];\n // Check the file type.\n if (!file.type.match('image.*')) {\n continue;\n }\n // Add the file to the request.\n postData.append('feature_image', file, file.name);\n }\n //var category = document.getElementById(\"content_category\");\n //let project_form = document.forms.namedItem(\"folio-project\");\n var txt = document.createElement(\"textarea\");\n txt.innerHTML = document.getElementById('edit-post-text').innerHTML;\n postData.append(\"title\", document.getElementById('post_title').value);\n postData.append('slug', new StringUtils().cleanString(document.getElementById('post_title').value));\n postData.append(\"post_plaintext\", txt.value);\n postData.append(\"origin_date\", document.getElementById('post-date').value);\n postData.append(\"tags\", document.getElementById('post_tags').value);\n postData.append(\"status_page\", document.getElementById('option-page').getAttribute('data-active'));\n postData.append(\"status_feature\", document.getElementById('option-feature').getAttribute('data-active'));\n postData.append(\"status_published\", document.getElementById('option-published').getAttribute('data-active'));\n\n let postURL;\n let postEventType;\n if (edit) {\n let postID = document.getElementById('edit-update').getAttribute('data-id');\n postURL = \"/api/post/update/\" + postID;\n postEventType = DataEvent.POST_UPDATED;\n \n } else {\n postURL = \"/api/post/add\";\n postEventType = DataEvent.POST_ADDED;\n }\n self.dataUtils.request(postURL, postEventType, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, postData)\n .then((response) => {\n resolve({\n response\n })\n }).catch((err) => {\n reject({\n err\n });\n })\n });\n }\n\n deletePost(){\n let self = this;\n let postID = document.getElementById('edit-update').getAttribute('data-id');\n return new Promise(function(resolve, reject){\n self.dataUtils.request(\"/api/post/delete/\" + postID, DataEvent.POST_DELETED, REQUEST_TYPE_POST, CONTENT_TYPE_FORM)\n .then((response) => {\n resolve({\n response\n })\n }).catch((err) => {\n reject({\n err\n });\n })\n })\n //this.dataUtils.re\n }\n//--------------------------\n// event handlers\n//--------------------------\n}\nexport { PostActions as default }\n","export const EDITOR_DELETE = 'editorDelete';\nexport const EDITOR_UPLOAD_POST_IMAGE = 'editorUploadImage';\nexport const EDITOR_SAVE = 'editorSave';\nexport const EDITOR_UPDATE = 'editorUpdate';\n\nclass EditorEvent\n{\n\n //--------------------------\n // methods\n //--------------------------\n\n\n\n //--------------------------\n // event handlers\n //--------------------------\n}\nexport default new EditorEvent\n","class DateUtils {\n\n //--------------------------\n // constructor\n //--------------------------\n constructor() {}\n\n //--------------------------\n // methods\n //--------------------------\n getMKtime() {\n var time = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), new Date().getMinutes(), new Date().getSeconds(), 0).getTime() / 1000;\n return time;\n }\n\n convertMKtime(seconds) {\n var date = new Date(seconds * 1000);\n return date;\n }\n\n getDate(type, rawdate) {\n var day = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCDate()) : String(new Date().getUTCDate()));\n var month = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMonth() + 1) : String(new Date().getUTCMonth() + 1));\n var year = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCFullYear()) : String(new Date().getUTCFullYear()));\n var hour = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCHours()) : String(new Date().getUTCHours()));\n var minute = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMinutes()) : String(new Date().getUTCMinutes()));\n var seconds = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCSeconds()) : String(new Date().getUTCSeconds()));\n var millisecond = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMilliseconds()) : String(new Date().getUTCMilliseconds()));\n var offset = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getTimezoneOffset()) : String(new Date().getTimezoneOffset()));\n if (day.length == 1)\n day = String(\"0\" + day);\n if (month.length == 1)\n month = String(\"0\" + month);\n offset = String(offset / 60);\n if (offset.length == 1)\n offset = String(\"0\" + offset);\n switch (type) {\n case \"day\":\n return day;\n break;\n case \"month\":\n return month;\n break;\n case \"year\":\n return year;\n break;\n case \"stamp\":\n return String(year + \"-\" + month + \"-\" + day + \" \" + hour + \":\" + minute + \":\" + seconds + \".\" + millisecond + \"-\" + (offset));\n break\n default:\n return String(year + \"-\" + month + \"-\" + day);\n break;\n }\n }\n\n //--------------------------\n // event handlers\n //--------------------------\n}\n\nexport default DateUtils","const attributes = [\n 'borderBottomWidth',\n 'borderLeftWidth',\n 'borderRightWidth',\n 'borderTopStyle',\n 'borderRightStyle',\n 'borderBottomStyle',\n 'borderLeftStyle',\n 'borderTopWidth',\n 'boxSizing',\n 'fontFamily',\n 'fontSize',\n 'fontWeight',\n 'height',\n 'letterSpacing',\n 'lineHeight',\n 'marginBottom',\n 'marginLeft',\n 'marginRight',\n 'marginTop',\n 'outlineWidth',\n 'overflow',\n 'overflowX',\n 'overflowY',\n 'paddingBottom',\n 'paddingLeft',\n 'paddingRight',\n 'paddingTop',\n 'textAlign',\n 'textOverflow',\n 'textTransform',\n 'whiteSpace',\n 'wordBreak',\n 'wordWrap',\n];\n\n/**\n * Create a mirror\n *\n * @param {Element} element The element\n * @param {string} html The html\n *\n * @return {object} The mirror object\n */\nconst createMirror = (element, html) => {\n\n /**\n * The mirror element\n */\n const mirror = document.createElement('div');\n\n /**\n * Create the CSS for the mirror object\n *\n * @return {object} The style object\n */\n const mirrorCss = () => {\n const css = {\n position: 'absolute',\n left: -9999,\n top: 0,\n zIndex: -2000\n };\n\n if (element.tagName === 'TEXTAREA') {\n attributes.push('width');\n }\n\n attributes.forEach((attr) => {\n css[attr] = getComputedStyle(element)[attr];\n });\n\n return css;\n };\n\n /**\n * Initialize the mirror\n *\n * @param {string} html The html\n *\n * @return {void}\n */\n const initialize = (html) => {\n const styles = mirrorCss();\n Object.keys(styles).forEach(key => {\n mirror.style[key] = styles[key];\n });\n mirror.innerHTML = html;\n element.parentNode.insertBefore(mirror, element.nextSibling);\n };\n\n /**\n * Get the rect\n *\n * @return {Rect} The bounding rect\n */\n const rect = () => {\n const marker = mirror.ownerDocument.getElementById('caret-position-marker');\n const boundingRect = {\n left: marker.offsetLeft,\n top: marker.offsetTop,\n height: marker.offsetHeight\n };\n mirror.parentNode.removeChild(mirror);\n\n return boundingRect;\n };\n\n initialize(html);\n\n return {\n rect,\n };\n};\n\nexport default createMirror;\n","/**\n * Check if a DOM Element is content editable\n *\n * @param {Element} element The DOM element\n *\n * @return {bool} If it is content editable\n */\nexport const isContentEditable = (element) => !!(\n element.contentEditable &&\n element.contentEditable === 'true'\n);\n\n/**\n * Get the context from settings passed in\n *\n * @param {object} settings The settings object\n *\n * @return {object} window and document\n */\nexport const getContext = (settings = {}) => {\n const { customPos, iframe, noShadowCaret } = settings;\n if (iframe) {\n return {\n iframe,\n window: iframe.contentWindow,\n document: iframe.contentDocument || iframe.contentWindow.document,\n noShadowCaret,\n customPos,\n };\n }\n\n return {\n window,\n document,\n noShadowCaret,\n customPos,\n };\n};\n\n/**\n * Get the offset of an element\n *\n * @param {Element} element The DOM element\n * @param {object} ctx The context\n *\n * @return {object} top and left\n */\nexport const getOffset = (element, ctx) => {\n const win = ctx && ctx.window || window;\n const doc = ctx && ctx.document || document;\n const rect = element.getBoundingClientRect();\n const docEl = doc.documentElement;\n const scrollLeft = win.pageXOffset || docEl.scrollLeft;\n const scrollTop = win.pageYOffset || docEl.scrollTop;\n\n return {\n top: rect.top + scrollTop,\n left: rect.left + scrollLeft\n };\n};\n\n/**\n * Check if a value is an object\n *\n * @param {any} value The value to check\n *\n * @return {bool} If it is an object\n */\nexport const isObject = (value) => typeof value === 'object' && value !== null;\n","import createMirror from './mirror';\nimport { getOffset as elementOffset } from './utils';\n\n/**\n * Create a Input caret object.\n *\n * @param {Element} element The element\n * @param {Object} ctx The context\n */\nconst createInputCaret = (element, ctx) => {\n\n /**\n * Get the current position\n *\n * @returns {int} The caret position\n */\n const getPos = () => {\n return element.selectionStart;\n };\n\n /**\n * Set the position\n *\n * @param {int} pos The position\n *\n * @return {Element} The element\n */\n const setPos = (pos) => {\n element.setSelectionRange(pos, pos);\n\n return element;\n };\n\n /**\n * The offset\n *\n * @param {int} pos The position\n *\n * @return {object} The offset\n */\n const getOffset = (pos) => {\n const rect = elementOffset(element);\n const position = getPosition(pos);\n\n return {\n top: rect.top + position.top + ctx.document.body.scrollTop,\n left: rect.left + position.left + ctx.document.body.scrollLeft,\n height: position.height,\n };\n };\n\n /**\n * Get the current position\n *\n * @param {int} pos The position\n *\n * @return {object} The position\n */\n const getPosition = (pos) => {\n const format = (val) => {\n let value = val.replace(/<|>|`|\"|&/g, '?')\n .replace(/\\r\\n|\\r|\\n/g,'
');\n return value;\n };\n\n if (ctx.customPos || ctx.customPos === 0) {\n pos = ctx.customPos;\n }\n\n const position = pos === undefined ? getPos() : pos;\n const startRange = element.value.slice(0, position);\n const endRange = element.value.slice(position);\n let html = `${format(startRange)}`;\n html += '|';\n html += `${format(endRange)}`;\n\n const mirror = createMirror(element, html);\n const rect = mirror.rect();\n rect.pos = getPos();\n\n return rect;\n };\n\n return {\n getPos,\n setPos,\n getOffset,\n getPosition,\n };\n};\n\nexport default createInputCaret;\n","/**\n * Create an Editable Caret\n * @param {Element} element The editable element\n * @param {object|null} ctx The context\n *\n * @return {EditableCaret}\n */\nconst createEditableCaret = (element, ctx) => {\n\n /**\n * Set the caret position\n *\n * @param {int} pos The position to se\n *\n * @return {Element} The element\n */\n const setPos = (pos) => {\n const sel = ctx.window.getSelection();\n if (sel) {\n let offset = 0;\n let found = false;\n const find = (position, parent) => {\n for (let i = 0; i < parent.childNodes.length; i++) {\n const node = parent.childNodes[i];\n if (found) {\n break;\n }\n if (node.nodeType === 3) {\n if (offset + node.length >= position) {\n found = true;\n const range = ctx.document.createRange();\n range.setStart(node, position - offset);\n sel.removeAllRanges();\n sel.addRange(range);\n break;\n } else {\n offset += node.length;\n }\n } else {\n find(pos, node);\n }\n }\n };\n find(pos, element);\n }\n\n return element;\n };\n\n /**\n * Get the offset\n *\n * @return {object} The offset\n */\n const getOffset = () => {\n const range = getRange();\n let offset = {\n height: 0,\n left: 0,\n right: 0,\n };\n\n if (!range) {\n return offset;\n }\n\n const hasCustomPos = ctx.customPos || ctx.customPos === 0;\n\n // endContainer in Firefox would be the element at the start of\n // the line\n if ((range.endOffset - 1 > 0 && range.endContainer !== element) || hasCustomPos) {\n const clonedRange = range.cloneRange();\n const fixedPosition = hasCustomPos ? ctx.customPos : range.endOffset;\n clonedRange.setStart(range.endContainer, fixedPosition - 1 < 0 ? 0 : fixedPosition - 1);\n clonedRange.setEnd(range.endContainer, fixedPosition);\n const rect = clonedRange.getBoundingClientRect();\n offset = {\n height: rect.height,\n left: rect.left + rect.width,\n top: rect.top,\n };\n clonedRange.detach();\n }\n\n if ((!offset || (offset && offset.height === 0)) && !ctx.noShadowCaret) {\n const clonedRange = range.cloneRange();\n const shadowCaret = ctx.document.createTextNode('|');\n clonedRange.insertNode(shadowCaret);\n clonedRange.selectNode(shadowCaret);\n const rect = clonedRange.getBoundingClientRect();\n offset = {\n height: rect.height,\n left: rect.left,\n top: rect.top,\n };\n shadowCaret.parentNode.removeChild(shadowCaret);\n clonedRange.detach();\n }\n\n if (offset) {\n const doc = ctx.document.documentElement;\n offset.top += ctx.window.pageYOffset - (doc.clientTop || 0);\n offset.left += ctx.window.pageXOffset - (doc.clientLeft || 0);\n }\n\n return offset;\n };\n\n /**\n * Get the position\n *\n * @return {object} The position\n */\n const getPosition = () => {\n const offset = getOffset();\n const pos = getPos();\n const rect = element.getBoundingClientRect();\n const inputOffset = {\n top: rect.top + ctx.document.body.scrollTop,\n left: rect.left + ctx.document.body.scrollLeft\n };\n offset.left -= inputOffset.left;\n offset.top -= inputOffset.top;\n offset.pos = pos;\n\n return offset;\n };\n\n /**\n * Get the range\n *\n * @return {Range|null}\n */\n const getRange = () => {\n if (!ctx.window.getSelection) {\n return;\n }\n const sel = ctx.window.getSelection();\n\n return sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n };\n\n /**\n * Get the caret position\n *\n * @return {int} The position\n */\n const getPos = () => {\n const range = getRange();\n const clonedRange = range.cloneRange();\n clonedRange.selectNodeContents(element);\n clonedRange.setEnd(range.endContainer, range.endOffset);\n const pos = clonedRange.toString().length;\n clonedRange.detach();\n\n return pos;\n };\n\n return {\n getPos,\n setPos,\n getPosition,\n getOffset,\n getRange,\n };\n};\n\nexport default createEditableCaret;\n","import createInputCaret from './input';\nimport createEditableCaret from './editable';\nimport {\n isContentEditable,\n getContext,\n isObject,\n} from './utils';\n\nexport { getOffset } from './utils';\n\nconst createCaret = (element, ctx) => {\n if (isContentEditable(element)) {\n return createEditableCaret(element, ctx);\n }\n\n return createInputCaret(element, ctx);\n};\n\nexport const position = (element, value, settings = {}) => {\n let options = settings;\n if (isObject(value)) {\n options = value;\n value = null;\n }\n const ctx = getContext(options);\n const caret = createCaret(element, ctx);\n\n if (value || value === 0) {\n return caret.setPos(value);\n }\n\n return caret.getPosition();\n};\n\n/**\n *\n * @param {Element} element The DOM element\n * @param {number|undefined} value The value to set\n * @param {object} settings Any settings for context\n */\nexport const offset = (element, value, settings = {}) => {\n let options = settings;\n if (isObject(value)) {\n options = value;\n value = null;\n }\n\n const ctx = getContext(options);\n const caret = createCaret(element, ctx);\n return caret.getOffset(value);\n};\n","import * as DataEvent from '../events/DataEvent';\nimport DateUtils from './DateUtils';\nimport {\n position,\n offset\n} from 'caret-pos';\n\nimport EventEmitter from '../events/EventEmitter';\nimport * as EditorEvent from '../events/EditorEvent';\n\nclass TextEditor extends EventEmitter {\n\n //--------------------------\n // constructor\n //--------------------------\n constructor(textEditor, scrollLimit) {\n super();\n hljs.initHighlightingOnLoad();\n //this.dataUtils = new DataUtils();\n this.dateUtils = new DateUtils();\n this.textEditor = textEditor;\n this.fixLimit = scrollLimit;\n this.caretPos = null;\n this.url = '';\n let self = this;\n this.setInputs();\n\n window.addEventListener(\"scroll\", f => {\n var fixLimit = this.fixLimit;\n if (window.pageYOffset >= fixLimit) {\n document.getElementById('edit-control').style.position = \"fixed\"\n } else {\n document.getElementById('edit-control').style.position = \"relative\"\n }\n });\n this.refresh();\n }\n //--------------------------\n // methods\n //--------------------------\n setInputs() {\n let self = this;\n var editorButtons = document.querySelectorAll('.editor-button');\n for (var i = 0, length = editorButtons.length; i < length; i++) {\n editorButtons[i].addEventListener('click', e => this.handleEditorOption(e), false);\n }\n this.textEditor.addEventListener('input', f => {\n if(f.inputType == \"insertParagraph\")\n {\n var caret = position(self.textEditor).pos+1;\n var spiffed = hljs.highlight('markdown', self.textEditor.innerText).value;\n var temp = document.createElement(\"div\");\n temp.innerText = spiffed;\n self.textEditor.innerHTML = temp.innerText;\n position(self.textEditor, caret)\n }else{\n self.refresh()\n }\n })\n }\n refresh() {\n var caret = position(this.textEditor).pos;\n var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value;\n var temp = document.createElement(\"div\");\n temp.innerText = spiffed;\n this.textEditor.innerHTML = temp.innerText;\n position(this.textEditor, caret)\n }\n\n notify(type, data) {\n switch (type) {\n case DataEvent.POST_UPDATED:\n document.getElementById('submit-update').classList.add('icon-hide');\n document.getElementById('submit-good').classList.remove('icon-hide');\n document.getElementById('edit-update').classList.remove('submit-start');\n document.getElementById('edit-update').classList.add('submit-cool');\n setTimeout(f => {\n document.getElementById('submit-update').classList.remove('icon-hide');\n document.getElementById('submit-good').classList.add('icon-hide');\n document.getElementById('edit-update').classList.add('submit-start');\n document.getElementById('edit-update').classList.remove('submit-cool');\n }, 2000);\n\n break;\n case DataEvent.POST_ADDED:\n // do nothing\n break;\n case EditorEvent.EDITOR_UPLOAD_POST_IMAGE:\n position(this.textEditor, this.caretPos);\n var sel, range, pulled;\n sel = window.getSelection(); //console.log(sel)\n //console.log(note.message)\n if (sel.rangeCount) {\n range = sel.getRangeAt(0);\n pulled = sel.getRangeAt(0).toString();\n range.deleteContents();\n range.insertNode(document.createTextNode(\"![image alt text](\" + data + \" 'image title')\"));\n }\n this.refresh();\n break;\n }\n }\n\n //--------------------------\n // event handlers\n //--------------------------\n handleEditorOption(e) {\n e.preventDefault();\n var self = this;\n var sel, range, pulled;\n sel = window.getSelection(); //console.log(sel)\n if (sel.rangeCount) {\n range = sel.getRangeAt(0);\n pulled = sel.getRangeAt(0).toString();\n range.deleteContents();\n switch (e.target.id) {\n case \"edit-bold\":\n range.insertNode(document.createTextNode(\"**\" + pulled + \"**\"));\n break;\n case \"edit-italic\":\n range.insertNode(document.createTextNode(\"*\" + pulled + \"*\"));\n break;\n case \"edit-strikethrough\":\n range.insertNode(document.createTextNode(\"\" + pulled + \"\"));\n break;\n case \"edit-header1\":\n range.insertNode(document.createTextNode(\"# \" + pulled));\n break;\n case \"edit-header2\":\n range.insertNode(document.createTextNode(\"## \" + pulled));\n break;\n case \"edit-header3\":\n range.insertNode(document.createTextNode(\"### \" + pulled));\n break;\n case \"edit-image\":\n this.caretPos = position(this.textEditor).pos;\n this.emitEvent(EditorEvent.EDITOR_UPLOAD_POST_IMAGE);\n break;\n case \"submit-save\":\n case \"edit-save\":\n this.emitEvent(EditorEvent.EDITOR_SAVE);\n break;\n case \"submit-update\":\n case \"edit-update\":\n this.emitEvent(EditorEvent.EDITOR_UPDATE);\n break\n case \"edit-link\":\n range.insertNode(document.createTextNode(\"[\" + pulled + \"](PASTE URL HERE)\"));\n break;\n case \"edit-delete\":\n this.emitEvent(EditorEvent.EDITOR_DELETE);\n break\n default:\n //range.insertNode(document.createTextNode(\"[\" + self.url + \"](PASTE URL HERE)\"));\n break;\n }\n }\n this.refresh()\n }\n}\nexport default TextEditor","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global.TinyDatePicker = factory());\n}(this, (function () { 'use strict';\n\n /**\n * @file A generic set of mutation-free date functions.\n */\n\n /**\n * now returns the current date without any time values\n *\n * @returns {Date}\n */\n function now() {\n var dt = new Date();\n dt.setHours(0, 0, 0, 0);\n return dt;\n }\n\n /**\n * dateEq compares two dates\n *\n * @param {Date} date1 the first date\n * @param {Date} date2 the second date\n * @returns {boolean}\n */\n function datesEq(date1, date2) {\n return (date1 && date1.toDateString()) === (date2 && date2.toDateString());\n }\n\n /**\n * shiftDay shifts the specified date by n days\n *\n * @param {Date} dt\n * @param {number} n\n * @returns {Date}\n */\n function shiftDay(dt, n) {\n dt = new Date(dt);\n dt.setDate(dt.getDate() + n);\n return dt;\n }\n\n /**\n * shiftMonth shifts the specified date by a specified number of months\n *\n * @param {Date} dt\n * @param {number} n\n * @param {boolean} wrap optional, if true, does not change year\n * value, defaults to false\n * @returns {Date}\n */\n function shiftMonth(dt, n, wrap) {\n dt = new Date(dt);\n\n var dayOfMonth = dt.getDate();\n var month = dt.getMonth() + n;\n\n dt.setDate(1);\n dt.setMonth(wrap ? (12 + month) % 12 : month);\n dt.setDate(dayOfMonth);\n\n // If dayOfMonth = 31, but the target month only has 30 or 29 or whatever...\n // head back to the max of the target month\n if (dt.getDate() < dayOfMonth) {\n dt.setDate(0);\n }\n\n return dt;\n }\n\n /**\n * shiftYear shifts the specified date by n years\n *\n * @param {Date} dt\n * @param {number} n\n * @returns {Date}\n */\n function shiftYear(dt, n) {\n dt = new Date(dt);\n dt.setFullYear(dt.getFullYear() + n);\n return dt;\n }\n\n /**\n * setYear changes the specified date to the specified year\n *\n * @param {Date} dt\n * @param {number} year\n */\n function setYear(dt, year) {\n dt = new Date(dt);\n dt.setFullYear(year);\n return dt;\n }\n\n /**\n * setMonth changes the specified date to the specified month\n *\n * @param {Date} dt\n * @param {number} month\n */\n function setMonth(dt, month) {\n return shiftMonth(dt, month - dt.getMonth());\n }\n\n /**\n * dateOrParse creates a function which, given a date or string, returns a date\n *\n * @param {function} parse the function used to parse strings\n * @returns {function}\n */\n function dateOrParse(parse) {\n return function (dt) {\n return dropTime(typeof dt === 'string' ? parse(dt) : dt);\n };\n }\n\n /**\n * constrainDate returns dt or min/max depending on whether dt is out of bounds (inclusive)\n *\n * @export\n * @param {Date} dt\n * @param {Date} min\n * @param {Date} max\n * @returns {Date}\n */\n function constrainDate(dt, min, max) {\n return (dt < min) ? min :\n (dt > max) ? max :\n dt;\n }\n\n function dropTime(dt) {\n dt = new Date(dt);\n dt.setHours(0, 0, 0, 0);\n return dt;\n }\n\n /**\n * @file Utility functions for function manipulation.\n */\n\n /**\n * bufferFn buffers calls to fn so they only happen every ms milliseconds\n *\n * @param {number} ms number of milliseconds\n * @param {function} fn the function to be buffered\n * @returns {function}\n */\n function bufferFn(ms, fn) {\n var timeout = undefined;\n return function () {\n clearTimeout(timeout);\n timeout = setTimeout(fn, ms);\n };\n }\n\n /**\n * noop is a function which does nothing at all.\n */\n function noop() { }\n\n /**\n * copy properties from object o2 to object o1.\n *\n * @params {Object} o1\n * @params {Object} o2\n * @returns {Object}\n */\n function cp() {\n var args = arguments;\n var o1 = args[0];\n for (var i = 1; i < args.length; ++i) {\n var o2 = args[i] || {};\n for (var key in o2) {\n o1[key] = o2[key];\n }\n }\n return o1;\n }\n\n /**\n * @file Responsible for sanitizing and creating date picker options.\n */\n\n var english = {\n days: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n months: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ],\n today: 'Today',\n clear: 'Clear',\n close: 'Close',\n };\n\n /**\n * DatePickerOptions constructs a new date picker options object, overriding\n * default values with any values specified in opts.\n *\n * @param {DatePickerOptions} opts\n * @returns {DatePickerOptions}\n */\n function DatePickerOptions(opts) {\n opts = opts || {};\n opts = cp(defaults(), opts);\n var parse = dateOrParse(opts.parse);\n opts.lang = cp(english, opts.lang);\n opts.parse = parse;\n opts.inRange = makeInRangeFn(opts);\n opts.min = parse(opts.min || shiftYear(now(), -100));\n opts.max = parse(opts.max || shiftYear(now(), 100));\n opts.hilightedDate = opts.parse(opts.hilightedDate);\n\n return opts;\n }\n\n function defaults() {\n return {\n lang: english,\n\n // Possible values: dp-modal, dp-below, dp-permanent\n mode: 'dp-modal',\n\n // The date to hilight initially if the date picker has no\n // initial value.\n hilightedDate: now(),\n\n format: function (dt) {\n return (dt.getMonth() + 1) + '/' + dt.getDate() + '/' + dt.getFullYear();\n },\n\n parse: function (str) {\n var date = new Date(str);\n return isNaN(date) ? now() : date;\n },\n\n dateClass: function () { },\n\n inRange: function () {\n return true;\n }\n };\n }\n\n function makeInRangeFn(opts) {\n var inRange = opts.inRange; // Cache this version, and return a variant\n\n return function (dt, dp) {\n return inRange(dt, dp) && opts.min <= dt && opts.max >= dt;\n };\n }\n\n /**\n * @file Helper functions for dealing with dom elements.\n */\n\n var Key = {\n left: 37,\n up: 38,\n right: 39,\n down: 40,\n enter: 13,\n esc: 27,\n };\n\n /**\n * on attaches an event handler to the specified element, and returns an\n * off function which can be used to remove the handler.\n *\n * @param {string} evt the name of the event to handle\n * @param {HTMLElement} el the element to attach to\n * @param {function} handler the event handler\n * @returns {function} the off function\n */\n function on(evt, el, handler) {\n el.addEventListener(evt, handler, true);\n\n return function () {\n el.removeEventListener(evt, handler, true);\n };\n }\n\n var CustomEvent = shimCustomEvent();\n\n function shimCustomEvent() {\n var CustomEvent = window.CustomEvent;\n\n if (typeof CustomEvent !== 'function') {\n CustomEvent = function (event, params) {\n params = params || {bubbles: false, cancelable: false, detail: undefined};\n var evt = document.createEvent('CustomEvent');\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n return evt;\n };\n\n CustomEvent.prototype = window.Event.prototype;\n }\n\n return CustomEvent;\n }\n\n /**\n * @file Manages the calendar / day-picker view.\n */\n\n var dayPicker = {\n onKeyDown: keyDown,\n onClick: {\n 'dp-day': selectDay,\n 'dp-next': gotoNextMonth,\n 'dp-prev': gotoPrevMonth,\n 'dp-today': selectToday,\n 'dp-clear': clear,\n 'dp-close': close,\n 'dp-cal-month': showMonthPicker,\n 'dp-cal-year': showYearPicker,\n },\n render: render\n };\n\n /**\n * view renders the calendar (day picker) as an HTML string.\n *\n * @param {DatePickerContext} context the date picker being rendered\n * @returns {string}\n */\n function render(dp) {\n var opts = dp.opts;\n var lang = opts.lang;\n var state = dp.state;\n var dayNames = lang.days;\n var dayOffset = opts.dayOffset || 0;\n var selectedDate = state.selectedDate;\n var hilightedDate = state.hilightedDate;\n var hilightedMonth = hilightedDate.getMonth();\n var today = now().getTime();\n\n return (\n '
' +\n '
' +\n '' +\n '' +\n '' +\n '' +\n '
' +\n '
' +\n dayNames.map(function (name, i) {\n return (\n '' + dayNames[(i + dayOffset) % dayNames.length] + ''\n );\n }).join('') +\n mapDays(hilightedDate, dayOffset, function (date) {\n var isNotInMonth = date.getMonth() !== hilightedMonth;\n var isDisabled = !opts.inRange(date);\n var isToday = date.getTime() === today;\n var className = 'dp-day';\n className += (isNotInMonth ? ' dp-edge-day' : '');\n className += (datesEq(date, hilightedDate) ? ' dp-current' : '');\n className += (datesEq(date, selectedDate) ? ' dp-selected' : '');\n className += (isDisabled ? ' dp-day-disabled' : '');\n className += (isToday ? ' dp-day-today' : '');\n className += ' ' + opts.dateClass(date, dp);\n\n return (\n ''\n );\n }) +\n '
' +\n '
' +\n '' +\n '' +\n '' +\n '
' +\n '
'\n );\n }\n\n /**\n * keyDown handles the key down event for the day-picker\n *\n * @param {Event} e\n * @param {DatePickerContext} dp\n */\n function keyDown(e, dp) {\n var key = e.keyCode;\n var shiftBy =\n (key === Key.left) ? -1 :\n (key === Key.right) ? 1 :\n (key === Key.up) ? -7 :\n (key === Key.down) ? 7 :\n 0;\n\n if (key === Key.esc) {\n dp.close();\n } else if (shiftBy) {\n e.preventDefault();\n dp.setState({\n hilightedDate: shiftDay(dp.state.hilightedDate, shiftBy)\n });\n }\n }\n\n function selectToday(e, dp) {\n dp.setState({\n selectedDate: now(),\n });\n }\n\n function clear(e, dp) {\n dp.setState({\n selectedDate: null,\n });\n }\n\n function close(e, dp) {\n dp.close();\n }\n\n function showMonthPicker(e, dp) {\n dp.setState({\n view: 'month'\n });\n }\n\n function showYearPicker(e, dp) {\n dp.setState({\n view: 'year'\n });\n }\n\n function gotoNextMonth(e, dp) {\n var hilightedDate = dp.state.hilightedDate;\n dp.setState({\n hilightedDate: shiftMonth(hilightedDate, 1)\n });\n }\n\n function gotoPrevMonth(e, dp) {\n var hilightedDate = dp.state.hilightedDate;\n dp.setState({\n hilightedDate: shiftMonth(hilightedDate, -1)\n });\n }\n\n function selectDay(e, dp) {\n dp.setState({\n selectedDate: new Date(parseInt(e.target.getAttribute('data-date'))),\n });\n }\n\n function mapDays(currentDate, dayOffset, fn) {\n var result = '';\n var iter = new Date(currentDate);\n iter.setDate(1);\n iter.setDate(1 - iter.getDay() + dayOffset);\n\n // If we are showing monday as the 1st of the week,\n // and the monday is the 2nd of the month, the sunday won't\n // show, so we need to shift backwards\n if (dayOffset && iter.getDate() === dayOffset + 1) {\n iter.setDate(dayOffset - 6);\n }\n\n // We are going to have 6 weeks always displayed to keep a consistent\n // calendar size\n for (var day = 0; day < (6 * 7); ++day) {\n result += fn(iter);\n iter.setDate(iter.getDate() + 1);\n }\n\n return result;\n }\n\n /**\n * @file Manages the month-picker view.\n */\n\n var monthPicker = {\n onKeyDown: keyDown$1,\n onClick: {\n 'dp-month': onChooseMonth\n },\n render: render$1\n };\n\n function onChooseMonth(e, dp) {\n dp.setState({\n hilightedDate: setMonth(dp.state.hilightedDate, parseInt(e.target.getAttribute('data-month'))),\n view: 'day',\n });\n }\n\n /**\n * render renders the month picker as an HTML string\n *\n * @param {DatePickerContext} dp the date picker context\n * @returns {string}\n */\n function render$1(dp) {\n var opts = dp.opts;\n var lang = opts.lang;\n var months = lang.months;\n var currentDate = dp.state.hilightedDate;\n var currentMonth = currentDate.getMonth();\n\n return (\n '
' +\n months.map(function (month, i) {\n var className = 'dp-month';\n className += (currentMonth === i ? ' dp-current' : '');\n\n return (\n ''\n );\n }).join('') +\n '
'\n );\n }\n\n /**\n * keyDown handles keydown events that occur in the month picker\n *\n * @param {Event} e\n * @param {DatePickerContext} dp\n */\n function keyDown$1(e, dp) {\n var key = e.keyCode;\n var shiftBy =\n (key === Key.left) ? -1 :\n (key === Key.right) ? 1 :\n (key === Key.up) ? -3 :\n (key === Key.down) ? 3 :\n 0;\n\n if (key === Key.esc) {\n dp.setState({\n view: 'day',\n });\n } else if (shiftBy) {\n e.preventDefault();\n dp.setState({\n hilightedDate: shiftMonth(dp.state.hilightedDate, shiftBy, true)\n });\n }\n }\n\n /**\n * @file Manages the year-picker view.\n */\n\n var yearPicker = {\n render: render$2,\n onKeyDown: keyDown$2,\n onClick: {\n 'dp-year': onChooseYear\n },\n };\n\n /**\n * view renders the year picker as an HTML string.\n *\n * @param {DatePickerContext} dp the date picker context\n * @returns {string}\n */\n function render$2(dp) {\n var state = dp.state;\n var currentYear = state.hilightedDate.getFullYear();\n var selectedYear = state.selectedDate.getFullYear();\n\n return (\n '
' +\n mapYears(dp, function (year) {\n var className = 'dp-year';\n className += (year === currentYear ? ' dp-current' : '');\n className += (year === selectedYear ? ' dp-selected' : '');\n\n return (\n ''\n );\n }) +\n '
'\n );\n }\n\n function onChooseYear(e, dp) {\n dp.setState({\n hilightedDate: setYear(dp.state.hilightedDate, parseInt(e.target.getAttribute('data-year'))),\n view: 'day',\n });\n }\n\n function keyDown$2(e, dp) {\n var key = e.keyCode;\n var opts = dp.opts;\n var shiftBy =\n (key === Key.left || key === Key.up) ? 1 :\n (key === Key.right || key === Key.down) ? -1 :\n 0;\n\n if (key === Key.esc) {\n dp.setState({\n view: 'day',\n });\n } else if (shiftBy) {\n e.preventDefault();\n var shiftedYear = shiftYear(dp.state.hilightedDate, shiftBy);\n\n dp.setState({\n hilightedDate: constrainDate(shiftedYear, opts.min, opts.max),\n });\n }\n }\n\n function mapYears(dp, fn) {\n var result = '';\n var max = dp.opts.max.getFullYear();\n\n for (var i = max; i >= dp.opts.min.getFullYear(); --i) {\n result += fn(i);\n }\n\n return result;\n }\n\n /**\n * @file Defines the base date picker behavior, overridden by various modes.\n */\n\n var views = {\n day: dayPicker,\n year: yearPicker,\n month: monthPicker\n };\n\n function BaseMode(input, emit, opts) {\n var detatchInputEvents; // A function that detaches all events from the input\n var closing = false; // A hack to prevent calendar from re-opening when closing.\n var selectedDate; // The currently selected date\n var dp = {\n // The root DOM element for the date picker, initialized on first open.\n el: undefined,\n opts: opts,\n shouldFocusOnBlur: true,\n shouldFocusOnRender: true,\n state: initialState(),\n adjustPosition: noop,\n containerHTML: '
',\n\n attachToDom: function () {\n document.body.appendChild(dp.el);\n },\n\n updateInput: function (selectedDate) {\n var e = new CustomEvent('change', {bubbles: true});\n e.simulated = true;\n input.value = selectedDate ? opts.format(selectedDate) : '';\n input.dispatchEvent(e);\n },\n\n computeSelectedDate: function () {\n return opts.parse(input.value);\n },\n\n currentView: function() {\n return views[dp.state.view];\n },\n\n open: function () {\n if (closing) {\n return;\n }\n\n if (!dp.el) {\n dp.el = createContainerElement(opts, dp.containerHTML);\n attachContainerEvents(dp);\n }\n\n selectedDate = constrainDate(dp.computeSelectedDate(), opts.min, opts.max);\n dp.state.hilightedDate = selectedDate || opts.hilightedDate;\n dp.state.view = 'day';\n\n dp.attachToDom();\n dp.render();\n\n emit('open');\n },\n\n isVisible: function () {\n return !!dp.el && !!dp.el.parentNode;\n },\n\n hasFocus: function () {\n var focused = document.activeElement;\n return dp.el &&\n dp.el.contains(focused) &&\n focused.className.indexOf('dp-focuser') < 0;\n },\n\n shouldHide: function () {\n return dp.isVisible();\n },\n\n close: function (becauseOfBlur) {\n var el = dp.el;\n\n if (!dp.isVisible()) {\n return;\n }\n\n if (el) {\n var parent = el.parentNode;\n parent && parent.removeChild(el);\n }\n\n closing = true;\n\n if (becauseOfBlur && dp.shouldFocusOnBlur) {\n focusInput(input);\n }\n\n // When we close, the input often gains refocus, which\n // can then launch the date picker again, so we buffer\n // a bit and don't show the date picker within N ms of closing\n setTimeout(function() {\n closing = false;\n }, 100);\n\n emit('close');\n },\n\n destroy: function () {\n dp.close();\n detatchInputEvents();\n },\n\n render: function () {\n if (!dp.el) {\n return;\n }\n\n var hadFocus = dp.hasFocus();\n var html = dp.currentView().render(dp);\n html && (dp.el.firstChild.innerHTML = html);\n\n dp.adjustPosition();\n\n if (hadFocus || dp.shouldFocusOnRender) {\n focusCurrent(dp);\n }\n },\n\n // Conceptually similar to setState in React, updates\n // the view state and re-renders.\n setState: function (state) {\n for (var key in state) {\n dp.state[key] = state[key];\n }\n\n emit('statechange');\n dp.render();\n },\n };\n\n detatchInputEvents = attachInputEvents(input, dp);\n\n // Builds the initial view state\n // selectedDate is a special case and causes changes to hilightedDate\n // hilightedDate is set on open, so remains undefined initially\n // view is the current view (day, month, year)\n function initialState() {\n return {\n get selectedDate() {\n return selectedDate;\n },\n set selectedDate(dt) {\n if (dt && !opts.inRange(dt)) {\n return;\n }\n\n if (dt) {\n selectedDate = new Date(dt);\n dp.state.hilightedDate = selectedDate;\n } else {\n selectedDate = dt;\n }\n\n dp.updateInput(selectedDate);\n emit('select');\n dp.close();\n },\n view: 'day',\n };\n }\n\n return dp;\n }\n\n function createContainerElement(opts, containerHTML) {\n var el = document.createElement('div');\n\n el.className = opts.mode;\n el.innerHTML = containerHTML;\n\n return el;\n }\n\n function attachInputEvents(input, dp) {\n var bufferShow = bufferFn(5, function () {\n if (dp.shouldHide()) {\n dp.close();\n } else {\n dp.open();\n }\n });\n\n var off = [\n on('blur', input, bufferFn(150, function () {\n if (!dp.hasFocus()) {\n dp.close(true);\n }\n })),\n\n on('mousedown', input, function () {\n if (input === document.activeElement) {\n bufferShow();\n }\n }),\n\n on('focus', input, bufferShow),\n\n on('input', input, function (e) {\n var date = dp.opts.parse(e.target.value);\n isNaN(date) || dp.setState({\n hilightedDate: date\n });\n }),\n ];\n\n // Unregister all events that were registered above.\n return function() {\n off.forEach(function (f) {\n f();\n });\n };\n }\n\n function focusCurrent(dp) {\n var current = dp.el.querySelector('.dp-current');\n return current && current.focus();\n }\n\n function attachContainerEvents(dp) {\n var el = dp.el;\n var calEl = el.querySelector('.dp');\n\n // Hack to get iOS to show active CSS states\n el.ontouchstart = noop;\n\n function onClick(e) {\n e.target.className.split(' ').forEach(function(evt) {\n var handler = dp.currentView().onClick[evt];\n handler && handler(e, dp);\n });\n }\n\n // The calender fires a blur event *every* time we redraw\n // this means we need to buffer the blur event to see if\n // it still has no focus after redrawing, and only then\n // do we return focus to the input. A possible other approach\n // would be to set context.redrawing = true on redraw and\n // set it to false in the blur event.\n on('blur', calEl, bufferFn(150, function () {\n if (!dp.hasFocus()) {\n dp.close(true);\n }\n }));\n\n on('keydown', el, function (e) {\n if (e.keyCode === Key.enter) {\n onClick(e);\n } else {\n dp.currentView().onKeyDown(e, dp);\n }\n });\n\n // If the user clicks in non-focusable space, but\n // still within the date picker, we don't want to\n // hide, so we need to hack some things...\n on('mousedown', calEl, function (e) {\n e.target.focus && e.target.focus(); // IE hack\n if (document.activeElement !== e.target) {\n e.preventDefault();\n focusCurrent(dp);\n }\n });\n\n on('click', el, onClick);\n }\n\n function focusInput(input) {\n // When the modal closes, we need to focus the original input so the\n // user can continue tabbing from where they left off.\n input.focus();\n\n // iOS zonks out if we don't blur the input, so...\n if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {\n input.blur();\n }\n }\n\n /**\n * @file Defines the modal date picker behavior.\n */\n\n function ModalMode(input, emit, opts) {\n var dp = BaseMode(input, emit, opts);\n\n // In modal mode, users really shouldn't be able to type in\n // the input, as all input is done via the calendar.\n input.readonly = true;\n\n // In modal mode, we need to know when the user has tabbed\n // off the end of the calendar, and set focus to the original\n // input. To do this, we add a special element to the DOM.\n // When the user tabs off the bottom of the calendar, they\n // will tab onto this element.\n dp.containerHTML += '.';\n\n return dp;\n }\n\n /**\n * @file Defines the dropdown date picker behavior.\n */\n\n function DropdownMode(input, emit, opts) {\n var dp = BaseMode(input, emit, opts);\n\n dp.shouldFocusOnBlur = false;\n\n Object.defineProperty(dp, 'shouldFocusOnRender', {\n get: function() {\n return input !== document.activeElement;\n }\n });\n\n dp.adjustPosition = function () {\n autoPosition(input, dp);\n };\n\n return dp;\n }\n\n function autoPosition(input, dp) {\n var inputPos = input.getBoundingClientRect();\n var win = window;\n\n adjustCalY(dp, inputPos, win);\n adjustCalX(dp, inputPos, win);\n\n dp.el.style.visibility = '';\n }\n\n function adjustCalX(dp, inputPos, win) {\n var cal = dp.el;\n var scrollLeft = win.pageXOffset;\n var inputLeft = inputPos.left + scrollLeft;\n var maxRight = win.innerWidth + scrollLeft;\n var offsetWidth = cal.offsetWidth;\n var calRight = inputLeft + offsetWidth;\n var shiftedLeft = maxRight - offsetWidth;\n var left = calRight > maxRight && shiftedLeft > 0 ? shiftedLeft : inputLeft;\n\n cal.style.left = left + 'px';\n }\n\n function adjustCalY(dp, inputPos, win) {\n var cal = dp.el;\n var scrollTop = win.pageYOffset;\n var inputTop = scrollTop + inputPos.top;\n var calHeight = cal.offsetHeight;\n var belowTop = inputTop + inputPos.height + 8;\n var aboveTop = inputTop - calHeight - 8;\n var isAbove = (aboveTop > 0 && belowTop + calHeight > scrollTop + win.innerHeight);\n var top = isAbove ? aboveTop : belowTop;\n\n if (cal.classList) {\n cal.classList.toggle('dp-is-above', isAbove);\n cal.classList.toggle('dp-is-below', !isAbove);\n }\n cal.style.top = top + 'px';\n }\n\n /**\n * @file Defines the permanent date picker behavior.\n */\n\n function PermanentMode(root, emit, opts) {\n var dp = BaseMode(root, emit, opts);\n\n dp.close = noop;\n dp.destroy = noop;\n dp.updateInput = noop;\n dp.shouldFocusOnRender = opts.shouldFocusOnRender;\n\n dp.computeSelectedDate = function () {\n return opts.hilightedDate;\n };\n\n dp.attachToDom = function () {\n root.appendChild(dp.el);\n };\n\n dp.open();\n\n return dp;\n }\n\n /**\n * @file Defines the various date picker modes (modal, dropdown, permanent)\n */\n\n function Mode(input, emit, opts) {\n input = input && input.tagName ? input : document.querySelector(input);\n\n if (opts.mode === 'dp-modal') {\n return ModalMode(input, emit, opts);\n }\n\n if (opts.mode === 'dp-below') {\n return DropdownMode(input, emit, opts);\n }\n\n if (opts.mode === 'dp-permanent') {\n return PermanentMode(input, emit, opts);\n }\n }\n\n /**\n * @file Defines simple event emitter behavior.\n */\n\n /**\n * Emitter constructs a new emitter object which has on/off methods.\n *\n * @returns {EventEmitter}\n */\n function Emitter() {\n var handlers = {};\n\n function onOne(name, handler) {\n (handlers[name] = (handlers[name] || [])).push(handler);\n }\n\n function onMany(fns) {\n for (var name in fns) {\n onOne(name, fns[name]);\n }\n }\n\n return {\n on: function (name, handler) {\n if (handler) {\n onOne(name, handler);\n } else {\n onMany(name);\n }\n\n return this;\n },\n\n emit: function (name, arg) {\n (handlers[name] || []).forEach(function (handler) {\n handler(name, arg);\n });\n },\n\n off: function (name, handler) {\n if (!name) {\n handlers = {};\n } else if (!handler) {\n handlers[name] = [];\n } else {\n handlers[name] = (handlers[name] || []).filter(function (h) {\n return h !== handler;\n });\n }\n\n return this;\n }\n };\n }\n\n /**\n * @file The root date picker file, defines public exports for the library.\n */\n\n /**\n * The date picker language configuration\n * @typedef {Object} LangOptions\n * @property {Array.} [days] - Days of the week\n * @property {Array.} [months] - Months of the year\n * @property {string} today - The label for the 'today' button\n * @property {string} close - The label for the 'close' button\n * @property {string} clear - The label for the 'clear' button\n */\n\n /**\n * The configuration options for a date picker.\n *\n * @typedef {Object} DatePickerOptions\n * @property {LangOptions} [lang] - Configures the label text, defaults to English\n * @property {('dp-modal'|'dp-below'|'dp-permanent')} [mode] - The date picker mode, defaults to 'dp-modal'\n * @property {(string|Date)} [hilightedDate] - The date to hilight if no date is selected\n * @property {function(string|Date):Date} [parse] - Parses a date, the complement of the \"format\" function\n * @property {function(Date):string} [format] - Formats a date for displaying to user\n * @property {function(Date):string} [dateClass] - Associates a custom CSS class with a date\n * @property {function(Date):boolean} [inRange] - Indicates whether or not a date is selectable\n * @property {(string|Date)} [min] - The minimum selectable date (inclusive, default 100 years ago)\n * @property {(string|Date)} [max] - The maximum selectable date (inclusive, default 100 years from now)\n */\n\n /**\n * The state values for the date picker\n *\n * @typedef {Object} DatePickerState\n * @property {string} view - The current view 'day' | 'month' | 'year'\n * @property {Date} selectedDate - The date which has been selected by the user\n * @property {Date} hilightedDate - The date which is currently hilighted / active\n */\n\n /**\n * An instance of TinyDatePicker\n *\n * @typedef {Object} DatePicker\n * @property {DatePickerState} state - The values currently displayed.\n * @property {function} on - Adds an event handler\n * @property {function} off - Removes an event handler\n * @property {function} setState - Changes the current state of the date picker\n * @property {function} open - Opens the date picker\n * @property {function} close - Closes the date picker\n * @property {function} destroy - Destroys the date picker (removing all handlers from the input, too)\n */\n\n /**\n * TinyDatePicker constructs a new date picker for the specified input\n *\n * @param {HTMLElement | string} input The input or CSS selector associated with the datepicker\n * @param {DatePickerOptions} opts The options for initializing the date picker\n * @returns {DatePicker}\n */\n function TinyDatePicker(input, opts) {\n var emitter = Emitter();\n var options = DatePickerOptions(opts);\n var mode = Mode(input, emit, options);\n var me = {\n get state() {\n return mode.state;\n },\n on: emitter.on,\n off: emitter.off,\n setState: mode.setState,\n open: mode.open,\n close: mode.close,\n destroy: mode.destroy,\n };\n\n function emit(evt) {\n emitter.emit(evt, me);\n }\n\n return me;\n }\n\n return TinyDatePicker;\n\n})));\n","//TOOLS\nimport DataUtils, {\n REQUEST_TYPE_GET,\n REQUEST_TYPE_PUT,\n REQUEST_TYPE_POST,\n REQUEST_TYPE_DELETE,\n CONTENT_TYPE_JSON,\n CONTENT_TYPE_FORM\n} from '../tools/utilities/DataUtils';\nimport * as DataEvent from '../tools/events/DataEvent';\nimport Animate from '../tools/effects/Animate';\nimport * as Ease from '../tools/effects/Animate';\nimport PostActions from '../actions/PostActions';\nimport * as EditorEvent from '../tools/events/EditorEvent';\nimport TextEditor from '../tools/utilities/TextEditor';\nimport TinyDatePicker from 'tiny-date-picker';\nimport DateUtils from '../tools/utilities/DateUtils';\n\n\nclass PostEditor {\n //--------------------------\n // constructor\n //--------------------------\n constructor() {\n reframe('iframe');\n let self = this;\n this.uploadFiles;\n this.dataUtils = new DataUtils();\n this.dateUtils = new DateUtils();\n if (document.getElementById('edit-post-text')) {\n this.editor = new TextEditor(document.getElementById('edit-post-text'),\n document.getElementById('header').offsetHeight +\n document.getElementById('post-header').offsetHeight +\n document.getElementById('post-feature').offsetHeight\n );\n this.editor.addListener(EditorEvent.EDITOR_DELETE, f => this.handleEditorOptions(EditorEvent.EDITOR_DELETE), false)\n this.editor.addListener(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPLOAD_POST_IMAGE), false)\n this.editor.addListener(EditorEvent.EDITOR_UPDATE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPDATE), false)\n this.editor.addListener(EditorEvent.EDITOR_SAVE, f => this.handleEditorOptions(EditorEvent.EDITOR_SAVE), false)\n document.getElementById('post-image').addEventListener('change', e => this.handlePostImageAdd(e), false);\n TinyDatePicker(document.getElementById('post-date'), {\n mode: 'dp-below',\n format(date) {\n //return date;\n return self.dateUtils.getDate('origin', date);\n }\n });\n }\n this.start();\n }\n //--------------------------\n // methods\n //--------------------------\n start() {\n let self = this;\n new Animate().object({\n targets: document.getElementById('loader'),\n duration: 300,\n opacity: 0,\n easing: 'easeInOutQuad',\n complete: function () {\n document.getElementById('loader').style.display = 'none';\n document.getElementById('loader').style.visibility = 'hidden';\n new Animate().object({\n targets: document.getElementById('header'),\n duration: 10,\n opacity: 1,\n easing: 'easeInOutQuad',\n complete: function () {\n if (document.getElementById('the-intro'))\n document.getElementById('the-intro').style.opacity = 1;\n if (document.getElementById('blog-entry'))\n document.getElementById('blog-entry').style.opacity = 1;\n }\n });\n }\n });\n\n if (document.getElementById('featured-image-drop')) {\n document.getElementById('featured-image-drop').addEventListener('dragover', this.handleDragOver, false);\n document.getElementById('featured-image-drop').addEventListener('drop', this.handleDrop, false);\n document.getElementById('featured-click').addEventListener('change', this.handleClicked, false);\n\n if (document.getElementById('new-upload-link')) {\n document.getElementById('new-upload-link').addEventListener('click', e => {\n document.getElementById('featured-click').click();\n })\n }\n\n var optionButtons = document.querySelectorAll('.post-option-btn');\n for (var i = 0, length = optionButtons.length; i < length; i++) {\n optionButtons[i].addEventListener('click', e => this.handlePostOptions(e), false);\n }\n }\n }\n\n //--------------------------\n // event handlers\n //--------------------------\n handlePostOptions(e) {\n\n let currentOption;\n switch (e.target.id) {\n case \"option-page-icon\":\n case \"option-page\":\n currentOption = document.getElementById('option-page');\n break;\n case \"option-feature-icon\":\n case \"option-feature\":\n currentOption = document.getElementById('option-feature');\n break;\n case \"option-published-icon\": \n case \"option-published\":\n currentOption = document.getElementById('option-published');\n break;\n }\n\n let active = currentOption.getAttribute('data-active');\n\n (active == 'false') ? currentOption.setAttribute('data-active', 'true') : currentOption.setAttribute('data-active', 'false') \n\n }\n handleEditorOptions(e) {\n switch (e) {\n case EditorEvent.EDITOR_SAVE:\n case EditorEvent.EDITOR_UPDATE:\n let edit = false;\n if (e == EditorEvent.EDITOR_UPDATE)\n edit = true;\n new PostActions().submitPost(edit, PostEditor.uploadFiles).then((response) => {\n let note = JSON.parse(response['response']['request'].response);\n this.editor.notify(note.message, note.postID);\n if (note.message == DataEvent.POST_ADDED)\n window.location = \"/@/dashboard/posts/edit/\" + note.postID;\n }).catch((err) => {\n console.log(err)\n });\n break;\n\n case EditorEvent.EDITOR_DELETE:\n\n if (confirm('Aye! You know you\\'re deleting this post, right?')) {\n new PostActions().deletePost().then((response) => {\n let note = JSON.parse(response['response']['request'].response);\n window.location = \"/@/dashboard/posts/\";\n //console.log(note);\n }).catch((err) => {\n console.log(err)\n });\n } else {\n // Do nothing!\n }\n break;\n\n case EditorEvent.EDITOR_UPLOAD_POST_IMAGE:\n document.getElementById('post-image').click();\n break;\n }\n }\n\n handleDragOver(e) {\n e.stopPropagation();\n e.preventDefault();\n e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.\n }\n handleClicked(e) {\n e.stopPropagation();\n e.preventDefault();\n //console.log(\"IMAGES \" + e.target.files);\n PostEditor.uploadFiles = e.target.files;\n for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) {\n // Only process image files.\n if (!f.type.match('image.*')) {\n continue;\n }\n var reader = new FileReader();\n // Closure to capture the file information.\n reader.onload = (function (theFile) {\n return function (f) {\n // Render thumbnail.\n var image = document.createElement('img');\n image.src = f.target.result;\n image.title = escape(theFile.name);\n var span = document.createElement('div');\n span.innerHTML = [\n ''\n ].join('');\n //document.getElementById('featured-image-drop').insertBefore(span, null);\n document.getElementById('featured-image-drop').innerHTML = '';\n document.getElementById('featured-image-drop').appendChild(image);\n };\n })(f);\n // Read in the image file as a data URL.\n reader.readAsDataURL(f);\n }\n\n }\n\n handleDrop(e) {\n e.stopPropagation();\n e.preventDefault();\n PostEditor.uploadFiles = e.dataTransfer.files;\n //console.log(MemberArea.uploadFiles.length);\n for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) {\n // Only process image files.\n if (!f.type.match('image.*')) {\n continue;\n }\n var reader = new FileReader();\n // Closure to capture the file information.\n reader.onload = (function (theFile) {\n return function (f) {\n // Render thumbnail.\n var span = document.createElement('span');\n span.innerHTML = [\n ''\n ].join('');\n //document.getElementById('featured-image-drop').insertBefore(span, null);\n document.getElementById('featured-image-drop').innerHTML = '';\n document.getElementById('featured-image-drop').appendChild(span);\n };\n })(f);\n // Read in the image file as a data URL.\n reader.readAsDataURL(f);\n }\n }\n\n handlePostImageAdd(e) {\n e.stopPropagation();\n e.preventDefault();\n let self = this;\n\n var postData = new FormData();\n var files = e.target.files;\n for (var i = 0; i < files.length; i++) {\n var file = files[i];\n // Check the file type.\n if (!file.type.match('image.*')) {\n continue;\n }\n postData.append('post_image', file, file.name);\n }\n this.dataUtils.request(\"/api/blog/add-post-image\", DataEvent.POST_IMAGE_ADDED, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, postData)\n .then((response) => {\n self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, JSON.parse(response.request['response']).url);\n }).catch((err) => {\n console.log(err)\n })\n }\n}\nPostEditor.uploadFiles = [];\nexport {\n PostEditor as\n default\n}","//TOOLS\nimport DataUtils, {\n REQUEST_TYPE_GET,\n REQUEST_TYPE_PUT,\n REQUEST_TYPE_POST,\n REQUEST_TYPE_DELETE,\n CONTENT_TYPE_JSON,\n CONTENT_TYPE_FORM\n} from '../tools/utilities/DataUtils.jsx';\nimport PostEditor from './PostEditor';\nimport Animate from '../tools/effects/Animate.jsx';\nclass DisplayManager {\n //--------------------------\n // constructor\n //--------------------------\n constructor() {\n this.dataUtils = new DataUtils();\n this.currentDisplay = '';\n this.urlPieces = document.URL.split(\"/\");\n //grab url so system knows what to display \n this.chooseDisplay(this.urlPieces[5], this.urlPieces[6]);\n\n }\n //--------------------------\n // methods\n //--------------------------\n start() {\n let self = this;\n new Animate().object({\n targets: document.getElementById('loader'),\n duration: 300,\n opacity: 0,\n easing: 'easeInOutQuad',\n complete: function () {\n document.getElementById('loader').style.display = 'none';\n document.getElementById('loader').style.visibility = 'hidden';\n new Animate().object({\n targets: document.getElementById('header'),\n duration: 10,\n opacity: 1,\n easing: 'easeInOutQuad',\n complete: function () {\n document.getElementById('loader').style.display = 'none';\n document.getElementById('loader').style.visibility = 'hidden';\n }\n });\n }\n });\n }\n\n chooseDisplay(section, page) {\n this.currentDisplay = '';\n //console.log(section+\" \"+page)\n switch (section) {\n case 'posts':\n this.currentDisplay = new PostEditor();\n break;\n \n default:\n // just chill\n break;\n }\n this.start();\n\n }\n //--------------------------\n // event handlers\n //--------------------------\n\n}\nexport {\n DisplayManager as\n default\n}","import DataUtils, { REQUEST_TYPE_GET, REQUEST_TYPE_PUT, REQUEST_TYPE_POST, REQUEST_TYPE_DELETE, CONTENT_TYPE_JSON, CONTENT_TYPE_FORM } from './tools/utilities/DataUtils.jsx';\nimport * as DataEvent from './tools/events/DataEvent.jsx';\nimport DisplayManager from './controllers/DisplayManager.jsx';\n\nexport default class Base {\n //--------------------------\n // constructor\n //--------------------------\n \n //TODO: Flip to unified structure defined in BMG, brah\n constructor() {\n var self = this;\n var admin = [];\n var folio = [];\n var displayManager = [];\n this.dataUtils = new DataUtils();\n this.settings = [];\n this.start(); \n }\n start() {\n this.displayManager = new DisplayManager();\n }\n //--------------------------\n // methods\n //--------------------------\n loadSettings() {\n var self = this;\n this.dataUtils.request('/base-assets/data/settings.json', DataEvent.SETTINGS_LOADED)\n .then((response) => {\n this.settings = JSON.parse(response['request'].response);\n this.start();\n //transfer \n \n })\n .catch((err) => {\n //console.log(err);\n });\n }\n\n //--------------------------\n // event handlers\n //--------------------------\n\n}\n","import Base from './Base.jsx'\n\ndocument.addEventListener('DOMContentLoaded', function() {\n\n var base = new Base();\n}, false);\n"]} \ No newline at end of file +{"version":3,"sources":["../../../../brain/tools/events/EventEmitter.jsx","../../../../brain/tools/events/DataEvent.jsx","../../../../brain/tools/utilities/DataUtils.jsx","../../../../brain/tools/effects/Animate.jsx","../../../../brain/tools/utilities/StringUtils.jsx","actions/PostActions.jsx","../../../../brain/tools/events/EditorEvent.jsx","../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js","../../../../brain/tools/utilities/DateUtils.jsx","../../../../brain/tools/utilities/DateUtils.js","../../src/mirror.js","../../src/utils.js","../../src/input.js","../../src/editable.js","../../src/main.js","../../../../brain/tools/ui/TextEditor.jsx","controllers/PostEditor.jsx","controllers/DisplayManager.jsx","Base.jsx","Start.jsx"],"names":["EventEmitter","listeners","Map","label","callback","has","set","get","push","isFunction","obj","index","length","reduce","i","listener","splice","args","forEach","REQUEST_GOOD","REQUEST_LAME","IMG_REQUEST_GOOD","IMG_REQUEST_LAME","SETTINGS_LOADED","HTML_LOADED","ARCHIVES_JSON_LOADED","ARCHIVES_PAGE_LOADED","ARCHIVES_ENTRY_LOADED","PROJECT_UPDATED","PROJECT_ADDED","PROJECTS_SORTED","POST_IMAGE_ADDED","POST_ERROR","POST_ADDED","POST_UPDATED","POST_DELETED","DataEvent","REQUEST_TYPE_POST","REQUEST_TYPE_GET","REQUEST_TYPE_PUT","REQUEST_TYPE_DELETE","CONTENT_TYPE_JSON","CONTENT_TYPE_FORM","DataUtils","self","requestURL","eventType","requestType","contentType","requestData","Promise","resolve","reject","request","XMLHttpRequest","upload","onprogress","handleLoadProgress","open","onload","e","status","setRequestHeader","send","JSON","stringify","url","responseType","response","Error","statusText","onerror","src","body","document","querySelector","myImage","Image","crossOrigin","imgLoad","then","imageURL","window","URL","createObjectURL","percentComplete","Math","ceil","loaded","total","Animate","properties","animation","anime","StringUtils","string","clean","replace","toLowerCase","quote_style","optTemp","noquotes","toString","OPTS","concat","ENT_HTML_QUOTE_SINGLE","PostActions","folio","dataUtils","edit","uploadFiles","postData","FormData","files","file","type","match","append","name","txt","createElement","innerHTML","getElementById","value","cleanString","getAttribute","postURL","postEventType","postID","catch","err","EDITOR_DELETE","EDITOR_UPLOAD_POST_IMAGE","EDITOR_SAVE","EDITOR_UPDATE","EditorEvent","DateUtils","time","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","getTime","seconds","date","rawdate","day","String","getUTCDate","month","getUTCMonth","year","getUTCFullYear","hour","getUTCHours","minute","getUTCMinutes","getUTCSeconds","millisecond","getUTCMilliseconds","offset","getTimezoneOffset","attributes","createMirror","element","html","mirror","mirrorCss","css","tagName","attr","getComputedStyle","initialize","styles","keys","style","key","parentNode","insertBefore","nextSibling","rect","marker","ownerDocument","boundingRect","offsetLeft","offsetTop","offsetHeight","removeChild","isContentEditable","contentEditable","getContext","settings","customPos","iframe","noShadowCaret","contentWindow","contentDocument","getOffset","ctx","win","doc","getBoundingClientRect","docEl","documentElement","scrollLeft","pageXOffset","scrollTop","pageYOffset","top","left","isObject","createInputCaret","getPos","selectionStart","setPos","pos","setSelectionRange","elementOffset","position","getPosition","height","format","val","undefined","startRange","slice","endRange","createEditableCaret","sel","getSelection","found","find","parent","childNodes","node","nodeType","range","createRange","setStart","removeAllRanges","addRange","getRange","hasCustomPos","endOffset","endContainer","clonedRange","cloneRange","fixedPosition","setEnd","width","detach","shadowCaret","createTextNode","insertNode","selectNode","clientTop","clientLeft","inputOffset","rangeCount","getRangeAt","selectNodeContents","createCaret","options","caret","TextEditor","textEditor","scrollLimit","hljs","initHighlightingOnLoad","dateUtils","fixLimit","caretPos","setInputs","addEventListener","f","refresh","editorButtons","querySelectorAll","handleEditorOption","inputType","spiffed","highlight","innerText","temp","data","classList","add","remove","setTimeout","pulled","deleteContents","preventDefault","target","id","emitEvent","PostEditor","anim","editor","addListener","handleEditorOptions","handlePostImageAdd","mode","start","object","targets","duration","opacity","easing","complete","display","visibility","handleDragOver","handleDrop","handleClicked","click","optionButtons","handlePostOptions","currentOption","active","setAttribute","submitPost","note","parse","notify","message","location","console","log","confirm","deletePost","stopPropagation","dataTransfer","dropEffect","reader","FileReader","theFile","image","result","title","escape","span","join","appendChild","readAsDataURL","DisplayManager","currentDisplay","urlPieces","split","chooseDisplay","section","page","Base","admin","displayManager","base"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;ICjrCMC;;;AAEF;AACA;AACA;AACA,uBAAc;AAAA;AAAE,IAEhB;AACA;AACA;;;;;gCACY;AACR,UAAIC,IAAI,GAAG,IAAIC,IAAJ,CAAS,IAAIA,IAAJ,GAAWC,WAAX,EAAT,EAAmC,IAAID,IAAJ,GAAWE,QAAX,EAAnC,EAA0D,IAAIF,IAAJ,GAAWG,OAAX,EAA1D,EAAgF,IAAIH,IAAJ,GAAWI,QAAX,EAAhF,EAAuG,IAAIJ,IAAJ,GAAWK,UAAX,EAAvG,EAAgI,IAAIL,IAAJ,GAAWM,UAAX,EAAhI,EAAyJ,CAAzJ,EAA4JC,OAA5J,KAAwK,IAAnL;AACA,aAAOR,IAAP;AACH;;;kCAEaS,SAAS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A0DjB,SAAS,CAACb,eAApE,EACKyD,IADL,CACU,UAACZ,QAAD,EAAc;AAChB,QAAA,KAAI,CAAC8H,QAAL,GAAgBlI,IAAI,CAACqQ,KAAL,CAAWjQ,QAAQ,CAAC,SAAD,CAAR,CAAoBA,QAA/B,CAAhB;;AACA,QAAA,KAAI,CAAC6O,KAAL,GAFgB,CAGhB;;AAEH,OANL,EAOKhL,KAPL,CAOW,UAACC,GAAD,EAAS,CACZ;AACH,OATL;AAUH,MAED;AACA;AACA;;;;;;;;;;;AChDJ;;;;AAEAxD,QAAQ,CAAC0M,gBAAT,CAA0B,kBAA1B,EAA8C,YAAW;AAErD,MAAIiF,IAAI,GAAG,IAAIH,aAAJ,EAAX;AACH,CAHD,EAGG,KAHH","file":"dash.min.map","sourceRoot":"../../src/com","sourcesContent":["class EventEmitter\n{\n\n //--------------------------\n // constructor\n //--------------------------\n constructor()\n {\n this.listeners = new Map();\n }\n //--------------------------\n // methods\n //--------------------------\n addListener(label, callback) {\n this.listeners.has(label) || this.listeners.set(label, []);\n this.listeners.get(label).push(callback);\n }\n\n removeListener(label, callback) {\n var isFunction = function(obj) {\n return typeof obj == 'function' || false;\n };\n\n var listeners = this.listeners.get(label),\n index;\n\n if (listeners && listeners.length) {\n index = listeners.reduce((i, listener, index) => {\n return (isFunction(listener) && listener === callback)\n ? i = index\n : i;\n }, -1);\n\n if (index > -1) {\n listeners.splice(index, 1);\n this.listeners.set(label, listeners);\n return true;\n }\n }\n return false;\n }\n\n emitEvent(label, ...args) {\n var listeners = this.listeners.get(label);\n if (listeners && listeners.length) {\n listeners.forEach((listener) => {\n listener(...args);\n });\n return true;\n }\n return false;\n }\n //--------------------------\n // event handlers\n //--------------------------\n}\nexport default EventEmitter\n","export const REQUEST_GOOD = 'requestGood';\nexport const REQUEST_LAME = 'requestLame';\nexport const IMG_REQUEST_GOOD = 'imgRequestGood';\nexport const IMG_REQUEST_LAME = 'imgRequestLame';\nexport const SETTINGS_LOADED = 'dataLoaded';\nexport const HTML_LOADED = 'htmlLoaded';\nexport const ARCHIVES_JSON_LOADED = 'archivesJSONLoaded';\nexport const ARCHIVES_PAGE_LOADED = 'archivesPAGELoaded';\nexport const ARCHIVES_ENTRY_LOADED = 'archivesEntryLoaded';\nexport const PROJECT_UPDATED = 'projectUpdated';\nexport const PROJECT_ADDED = 'projectAdded';\nexport const PROJECTS_SORTED = 'projectsSorted';\nexport const POST_IMAGE_ADDED = 'postImageAdded';\nexport const POST_ERROR = 'postError';\nexport const POST_ADDED = 'postAdded';\nexport const POST_UPDATED = 'postUpdated';\nexport const POST_DELETED = 'postImageAdded';\n\nclass DataEvent\n{\n\n //--------------------------\n // methods\n //--------------------------\n\n\n\n //--------------------------\n // event handlers\n //--------------------------\n}\nexport default new DataEvent\n","export const REQUEST_TYPE_POST = \"POST\";\nexport const REQUEST_TYPE_GET = \"GET\";\nexport const REQUEST_TYPE_PUT = \"PUT\";\nexport const REQUEST_TYPE_DELETE = \"DELETE\";\nexport const CONTENT_TYPE_JSON = 'json';\nexport const CONTENT_TYPE_FORM = 'x-www-form-urlencoded';\nimport EventEmitter from '../events/EventEmitter.jsx';\nimport * as DataEvent from '../events/DataEvent.jsx';\nclass DataUtils extends EventEmitter {\n //--------------------------\n // constructor\n //--------------------------\n constructor() {\n super();\n var self = this;\n }\n //--------------------------\n // methods\n //--------------------------\n request(requestURL, eventType, requestType = REQUEST_TYPE_GET, contentType = CONTENT_TYPE_JSON, requestData = null) {\n var self = this;\n return new Promise(function(resolve, reject) {\n var request = new XMLHttpRequest();\n request.upload.onprogress = self.handleLoadProgress;\n request.open(requestType, requestURL, true);\n request.onload = function(e) {\n if (request.status == 200) {\n resolve({\n request,\n eventType\n });\n } else {\n reject({\n request,\n eventType\n });\n }\n ;\n };\n if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {\n switch (contentType) {\n case CONTENT_TYPE_JSON:\n request.setRequestHeader(\"Content-type\", \"application/\" + contentType);\n request.send(JSON.stringify(requestData));\n break;\n case CONTENT_TYPE_FORM:\n request.send(requestData);\n break;\n }\n } else {\n request.send();\n }\n })\n }\n imgLoad(url) {\n 'use strict';\n // Create new promise with the Promise() constructor;\n // This has as its argument a function with two parameters, resolve and reject\n return new Promise(function(resolve, reject) {\n // Standard XHR to load an image\n var request = new XMLHttpRequest();\n request.open('GET', url);\n request.responseType = 'blob';\n // When the request loads, check whether it was successful\n request.onload = function() {\n if (request.status === 200) {\n // If successful, resolve the promise by passing back the request response\n resolve(request.response);\n } else {\n // If it fails, reject the promise with a error message\n reject(new Error('Image didn\\'t load successfully; error code:' + request.statusText));\n }\n };\n request.onerror = function() {\n // Also deal with the case when the entire request fails to begin with\n // This is probably a network error, so reject the promise with an appropriate message\n reject(new Error('There was a network error.'));\n };\n // Send the request\n request.send();\n });\n }\n loadImage(src) {\n 'use strict';\n let self = this;\n return new Promise(function(resolve, reject) {\n // Get a reference to the body element, and create a new image object\n var body = document.querySelector('body'),\n myImage = new Image();\n myImage.crossOrigin = \"\"; // or \"anonymous\"\n // Call the function with the URL we want to load, but then chain the\n // promise then() method on to the end of it. This contains two callbacks\n self.imgLoad(src).then(function(response) {\n // The first runs when the promise resolves, with the request.reponse specified within the resolve() method.\n var imageURL = window.URL.createObjectURL(response);\n resolve(imageURL);\n //$('background-content').setStyle('background-image', 'url('+imageURL+')') //myImage.src = imageURL;\n //console.log(imageURL);\n //body.appendChild(myImage);\n // The second runs when the promise is rejected, and logs the Error specified with the reject() method.\n }, function(Error) {\n reject(Error)\n });\n });\n }\n //--------------------------\n // event handlers\n //--------------------------\n handleLoadProgress(e) {\n var percentComplete = Math.ceil((e.loaded / e.total) * 100);\n //console.log(percentComplete);\n }\n}\nexport default DataUtils;\n","import EventEmitter from '../events/EventEmitter.jsx';;\n\nclass Animate extends EventEmitter {\n //--------------------------\n // constructor\n //--------------------------\n constructor() {\n super();\n }\n //--------------------------\n // methods\n //--------------------------\n object(properties) {\n var animation = anime(\n properties\n );\n //animation.start(properties);\n }\n //--------------------------\n // event handlers\n //--------------------------\n}\nexport default Animate\n","class StringUtils\n{\n\n //--------------------------\n // constructor\n //--------------------------\n constructor()\n {}\n //--------------------------\n // methods\n //--------------------------\n cleanString(string)\n {\n var clean = string.replace(/(^\\-+|[^a-zA-Z0-9\\/_| -]+|\\-+$)/g, '').toLowerCase().replace(/[\\/_| -]+/g, '-');\n return clean;\n }\n\n decodeHTML(string, quote_style) {\n var optTemp = 0,\n i = 0,\n noquotes = false;\n if (typeof quote_style === 'undefined') {\n quote_style = 2;\n }\n string = string.toString().replace(/</g, '<').replace(/>/g, '>');\n var OPTS = {\n 'ENT_NOQUOTES': 0,\n 'ENT_HTML_QUOTE_SINGLE': 1,\n 'ENT_HTML_QUOTE_DOUBLE': 2,\n 'ENT_COMPAT': 2,\n 'ENT_QUOTES': 3,\n 'ENT_IGNORE': 4\n };\n if (quote_style === 0) {\n noquotes = true;\n }\n if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags\n quote_style = [].concat(quote_style);\n for (i = 0; i < quote_style.length; i++) {\n // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4\n if (OPTS[quote_style[i]] === 0) {\n noquotes = true;\n } else if (OPTS[quote_style[i]]) {\n optTemp = optTemp | OPTS[quote_style[i]];\n }\n }\n quote_style = optTemp;\n }\n if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {\n string = string.replace(/�*39;/g, \"'\"); // PHP doesn't currently escape if more than one 0, but it should\n // string = string.replace(/'|�*27;/g, \"'\"); // This would also be useful here, but not a part of PHP\n }\n if (!noquotes) {\n string = string.replace(/"/g, '\"');\n }\n // Put this in last place to avoid escape being double-decoded\n string = string.replace(/&/g, '&');\n return string;\n }\n\n //--------------------------\n // event handlers\n //--------------------------\n}\nexport default StringUtils\n","import DataUtils, {\n REQUEST_TYPE_GET,\n REQUEST_TYPE_PUT,\n REQUEST_TYPE_POST,\n REQUEST_TYPE_DELETE,\n CONTENT_TYPE_JSON,\n CONTENT_TYPE_FORM\n} from '../../../../../brain//tools/utilities/DataUtils';\nimport * as DataEvent from '../../../../../brain//tools/events/DataEvent';\nimport StringUtils from '../../../../../brain//tools/utilities/StringUtils';\n\nclass PostActions {\n //--------------------------\n // constructor\n //--------------------------\n constructor() {\n var folio = [];\n this.dataUtils = new DataUtils();\n }\n //--------------------------\n // methods\n //--------------------------\n start() {}\n\n submitPost(edit, uploadFiles) {\n let self = this;\n return new Promise(function (resolve, reject) {\n //collect form data\n //if(!this.validateForm())\n var postData = new FormData();\n //let projectImages = document.getElementById('projectImages');\n //var fileSelect = projectImages;\n var files = uploadFiles;\n for (var i = 0; i < files.length; i++) {\n var file = files[i];\n // Check the file type.\n if (!file.type.match('image.*')) {\n continue;\n }\n // Add the file to the request.\n postData.append('feature_image', file, file.name);\n }\n //var category = document.getElementById(\"content_category\");\n //let project_form = document.forms.namedItem(\"folio-project\");\n var txt = document.createElement(\"textarea\");\n txt.innerHTML = document.getElementById('edit-post-text').innerHTML;\n postData.append(\"title\", document.getElementById('post_title').value);\n postData.append('slug', new StringUtils().cleanString(document.getElementById('post_title').value));\n postData.append(\"post_plaintext\", txt.value);\n postData.append(\"origin_date\", document.getElementById('post-date').value);\n postData.append(\"tags\", document.getElementById('post_tags').value);\n postData.append(\"status_page\", document.getElementById('option-page').getAttribute('data-active'));\n postData.append(\"status_feature\", document.getElementById('option-feature').getAttribute('data-active'));\n postData.append(\"status_published\", document.getElementById('option-published').getAttribute('data-active'));\n\n let postURL;\n let postEventType;\n if (edit) {\n let postID = document.getElementById('edit-update').getAttribute('data-id');\n postURL = \"/api/post/update/\" + postID;\n postEventType = DataEvent.POST_UPDATED;\n\n } else {\n postURL = \"/api/post/add\";\n postEventType = DataEvent.POST_ADDED;\n }\n self.dataUtils.request(postURL, postEventType, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, postData)\n .then((response) => {\n resolve({\n response\n })\n }).catch((err) => {\n reject({\n err\n });\n })\n });\n }\n\n deletePost() {\n let self = this;\n let postID = document.getElementById('edit-update').getAttribute('data-id');\n return new Promise(function (resolve, reject) {\n self.dataUtils.request(\"/api/post/delete/\" + postID, DataEvent.POST_DELETED, REQUEST_TYPE_POST, CONTENT_TYPE_FORM)\n .then((response) => {\n resolve({\n response\n })\n }).catch((err) => {\n reject({\n err\n });\n })\n })\n //this.dataUtils.re\n }\n //--------------------------\n // event handlers\n //--------------------------\n}\nexport {\n PostActions as\n default\n}","export const EDITOR_DELETE = 'editorDelete';\nexport const EDITOR_UPLOAD_POST_IMAGE = 'editorUploadImage';\nexport const EDITOR_SAVE = 'editorSave';\nexport const EDITOR_UPDATE = 'editorUpdate';\n\nclass EditorEvent\n{\n\n //--------------------------\n // methods\n //--------------------------\n\n\n\n //--------------------------\n // event handlers\n //--------------------------\n}\nexport default new EditorEvent\n","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global.TinyDatePicker = factory());\n}(this, (function () { 'use strict';\n\n /**\n * @file A generic set of mutation-free date functions.\n */\n\n /**\n * now returns the current date without any time values\n *\n * @returns {Date}\n */\n function now() {\n var dt = new Date();\n dt.setHours(0, 0, 0, 0);\n return dt;\n }\n\n /**\n * dateEq compares two dates\n *\n * @param {Date} date1 the first date\n * @param {Date} date2 the second date\n * @returns {boolean}\n */\n function datesEq(date1, date2) {\n return (date1 && date1.toDateString()) === (date2 && date2.toDateString());\n }\n\n /**\n * shiftDay shifts the specified date by n days\n *\n * @param {Date} dt\n * @param {number} n\n * @returns {Date}\n */\n function shiftDay(dt, n) {\n dt = new Date(dt);\n dt.setDate(dt.getDate() + n);\n return dt;\n }\n\n /**\n * shiftMonth shifts the specified date by a specified number of months\n *\n * @param {Date} dt\n * @param {number} n\n * @param {boolean} wrap optional, if true, does not change year\n * value, defaults to false\n * @returns {Date}\n */\n function shiftMonth(dt, n, wrap) {\n dt = new Date(dt);\n\n var dayOfMonth = dt.getDate();\n var month = dt.getMonth() + n;\n\n dt.setDate(1);\n dt.setMonth(wrap ? (12 + month) % 12 : month);\n dt.setDate(dayOfMonth);\n\n // If dayOfMonth = 31, but the target month only has 30 or 29 or whatever...\n // head back to the max of the target month\n if (dt.getDate() < dayOfMonth) {\n dt.setDate(0);\n }\n\n return dt;\n }\n\n /**\n * shiftYear shifts the specified date by n years\n *\n * @param {Date} dt\n * @param {number} n\n * @returns {Date}\n */\n function shiftYear(dt, n) {\n dt = new Date(dt);\n dt.setFullYear(dt.getFullYear() + n);\n return dt;\n }\n\n /**\n * setYear changes the specified date to the specified year\n *\n * @param {Date} dt\n * @param {number} year\n */\n function setYear(dt, year) {\n dt = new Date(dt);\n dt.setFullYear(year);\n return dt;\n }\n\n /**\n * setMonth changes the specified date to the specified month\n *\n * @param {Date} dt\n * @param {number} month\n */\n function setMonth(dt, month) {\n return shiftMonth(dt, month - dt.getMonth());\n }\n\n /**\n * dateOrParse creates a function which, given a date or string, returns a date\n *\n * @param {function} parse the function used to parse strings\n * @returns {function}\n */\n function dateOrParse(parse) {\n return function (dt) {\n return dropTime(typeof dt === 'string' ? parse(dt) : dt);\n };\n }\n\n /**\n * constrainDate returns dt or min/max depending on whether dt is out of bounds (inclusive)\n *\n * @export\n * @param {Date} dt\n * @param {Date} min\n * @param {Date} max\n * @returns {Date}\n */\n function constrainDate(dt, min, max) {\n return (dt < min) ? min :\n (dt > max) ? max :\n dt;\n }\n\n function dropTime(dt) {\n dt = new Date(dt);\n dt.setHours(0, 0, 0, 0);\n return dt;\n }\n\n /**\n * @file Utility functions for function manipulation.\n */\n\n /**\n * bufferFn buffers calls to fn so they only happen every ms milliseconds\n *\n * @param {number} ms number of milliseconds\n * @param {function} fn the function to be buffered\n * @returns {function}\n */\n function bufferFn(ms, fn) {\n var timeout = undefined;\n return function () {\n clearTimeout(timeout);\n timeout = setTimeout(fn, ms);\n };\n }\n\n /**\n * noop is a function which does nothing at all.\n */\n function noop() { }\n\n /**\n * copy properties from object o2 to object o1.\n *\n * @params {Object} o1\n * @params {Object} o2\n * @returns {Object}\n */\n function cp() {\n var args = arguments;\n var o1 = args[0];\n for (var i = 1; i < args.length; ++i) {\n var o2 = args[i] || {};\n for (var key in o2) {\n o1[key] = o2[key];\n }\n }\n return o1;\n }\n\n /**\n * @file Responsible for sanitizing and creating date picker options.\n */\n\n var english = {\n days: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n months: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ],\n today: 'Today',\n clear: 'Clear',\n close: 'Close',\n };\n\n /**\n * DatePickerOptions constructs a new date picker options object, overriding\n * default values with any values specified in opts.\n *\n * @param {DatePickerOptions} opts\n * @returns {DatePickerOptions}\n */\n function DatePickerOptions(opts) {\n opts = opts || {};\n opts = cp(defaults(), opts);\n var parse = dateOrParse(opts.parse);\n opts.lang = cp(english, opts.lang);\n opts.parse = parse;\n opts.inRange = makeInRangeFn(opts);\n opts.min = parse(opts.min || shiftYear(now(), -100));\n opts.max = parse(opts.max || shiftYear(now(), 100));\n opts.hilightedDate = opts.parse(opts.hilightedDate);\n\n return opts;\n }\n\n function defaults() {\n return {\n lang: english,\n\n // Possible values: dp-modal, dp-below, dp-permanent\n mode: 'dp-modal',\n\n // The date to hilight initially if the date picker has no\n // initial value.\n hilightedDate: now(),\n\n format: function (dt) {\n return (dt.getMonth() + 1) + '/' + dt.getDate() + '/' + dt.getFullYear();\n },\n\n parse: function (str) {\n var date = new Date(str);\n return isNaN(date) ? now() : date;\n },\n\n dateClass: function () { },\n\n inRange: function () {\n return true;\n }\n };\n }\n\n function makeInRangeFn(opts) {\n var inRange = opts.inRange; // Cache this version, and return a variant\n\n return function (dt, dp) {\n return inRange(dt, dp) && opts.min <= dt && opts.max >= dt;\n };\n }\n\n /**\n * @file Helper functions for dealing with dom elements.\n */\n\n var Key = {\n left: 37,\n up: 38,\n right: 39,\n down: 40,\n enter: 13,\n esc: 27,\n };\n\n /**\n * on attaches an event handler to the specified element, and returns an\n * off function which can be used to remove the handler.\n *\n * @param {string} evt the name of the event to handle\n * @param {HTMLElement} el the element to attach to\n * @param {function} handler the event handler\n * @returns {function} the off function\n */\n function on(evt, el, handler) {\n el.addEventListener(evt, handler, true);\n\n return function () {\n el.removeEventListener(evt, handler, true);\n };\n }\n\n var CustomEvent = shimCustomEvent();\n\n function shimCustomEvent() {\n var CustomEvent = window.CustomEvent;\n\n if (typeof CustomEvent !== 'function') {\n CustomEvent = function (event, params) {\n params = params || {bubbles: false, cancelable: false, detail: undefined};\n var evt = document.createEvent('CustomEvent');\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n return evt;\n };\n\n CustomEvent.prototype = window.Event.prototype;\n }\n\n return CustomEvent;\n }\n\n /**\n * @file Manages the calendar / day-picker view.\n */\n\n var dayPicker = {\n onKeyDown: keyDown,\n onClick: {\n 'dp-day': selectDay,\n 'dp-next': gotoNextMonth,\n 'dp-prev': gotoPrevMonth,\n 'dp-today': selectToday,\n 'dp-clear': clear,\n 'dp-close': close,\n 'dp-cal-month': showMonthPicker,\n 'dp-cal-year': showYearPicker,\n },\n render: render\n };\n\n /**\n * view renders the calendar (day picker) as an HTML string.\n *\n * @param {DatePickerContext} context the date picker being rendered\n * @returns {string}\n */\n function render(dp) {\n var opts = dp.opts;\n var lang = opts.lang;\n var state = dp.state;\n var dayNames = lang.days;\n var dayOffset = opts.dayOffset || 0;\n var selectedDate = state.selectedDate;\n var hilightedDate = state.hilightedDate;\n var hilightedMonth = hilightedDate.getMonth();\n var today = now().getTime();\n\n return (\n '
' +\n '
' +\n '' +\n '' +\n '' +\n '' +\n '
' +\n '
' +\n dayNames.map(function (name, i) {\n return (\n '' + dayNames[(i + dayOffset) % dayNames.length] + ''\n );\n }).join('') +\n mapDays(hilightedDate, dayOffset, function (date) {\n var isNotInMonth = date.getMonth() !== hilightedMonth;\n var isDisabled = !opts.inRange(date);\n var isToday = date.getTime() === today;\n var className = 'dp-day';\n className += (isNotInMonth ? ' dp-edge-day' : '');\n className += (datesEq(date, hilightedDate) ? ' dp-current' : '');\n className += (datesEq(date, selectedDate) ? ' dp-selected' : '');\n className += (isDisabled ? ' dp-day-disabled' : '');\n className += (isToday ? ' dp-day-today' : '');\n className += ' ' + opts.dateClass(date, dp);\n\n return (\n ''\n );\n }) +\n '
' +\n '
' +\n '' +\n '' +\n '' +\n '
' +\n '
'\n );\n }\n\n /**\n * keyDown handles the key down event for the day-picker\n *\n * @param {Event} e\n * @param {DatePickerContext} dp\n */\n function keyDown(e, dp) {\n var key = e.keyCode;\n var shiftBy =\n (key === Key.left) ? -1 :\n (key === Key.right) ? 1 :\n (key === Key.up) ? -7 :\n (key === Key.down) ? 7 :\n 0;\n\n if (key === Key.esc) {\n dp.close();\n } else if (shiftBy) {\n e.preventDefault();\n dp.setState({\n hilightedDate: shiftDay(dp.state.hilightedDate, shiftBy)\n });\n }\n }\n\n function selectToday(e, dp) {\n dp.setState({\n selectedDate: now(),\n });\n }\n\n function clear(e, dp) {\n dp.setState({\n selectedDate: null,\n });\n }\n\n function close(e, dp) {\n dp.close();\n }\n\n function showMonthPicker(e, dp) {\n dp.setState({\n view: 'month'\n });\n }\n\n function showYearPicker(e, dp) {\n dp.setState({\n view: 'year'\n });\n }\n\n function gotoNextMonth(e, dp) {\n var hilightedDate = dp.state.hilightedDate;\n dp.setState({\n hilightedDate: shiftMonth(hilightedDate, 1)\n });\n }\n\n function gotoPrevMonth(e, dp) {\n var hilightedDate = dp.state.hilightedDate;\n dp.setState({\n hilightedDate: shiftMonth(hilightedDate, -1)\n });\n }\n\n function selectDay(e, dp) {\n dp.setState({\n selectedDate: new Date(parseInt(e.target.getAttribute('data-date'))),\n });\n }\n\n function mapDays(currentDate, dayOffset, fn) {\n var result = '';\n var iter = new Date(currentDate);\n iter.setDate(1);\n iter.setDate(1 - iter.getDay() + dayOffset);\n\n // If we are showing monday as the 1st of the week,\n // and the monday is the 2nd of the month, the sunday won't\n // show, so we need to shift backwards\n if (dayOffset && iter.getDate() === dayOffset + 1) {\n iter.setDate(dayOffset - 6);\n }\n\n // We are going to have 6 weeks always displayed to keep a consistent\n // calendar size\n for (var day = 0; day < (6 * 7); ++day) {\n result += fn(iter);\n iter.setDate(iter.getDate() + 1);\n }\n\n return result;\n }\n\n /**\n * @file Manages the month-picker view.\n */\n\n var monthPicker = {\n onKeyDown: keyDown$1,\n onClick: {\n 'dp-month': onChooseMonth\n },\n render: render$1\n };\n\n function onChooseMonth(e, dp) {\n dp.setState({\n hilightedDate: setMonth(dp.state.hilightedDate, parseInt(e.target.getAttribute('data-month'))),\n view: 'day',\n });\n }\n\n /**\n * render renders the month picker as an HTML string\n *\n * @param {DatePickerContext} dp the date picker context\n * @returns {string}\n */\n function render$1(dp) {\n var opts = dp.opts;\n var lang = opts.lang;\n var months = lang.months;\n var currentDate = dp.state.hilightedDate;\n var currentMonth = currentDate.getMonth();\n\n return (\n '
' +\n months.map(function (month, i) {\n var className = 'dp-month';\n className += (currentMonth === i ? ' dp-current' : '');\n\n return (\n ''\n );\n }).join('') +\n '
'\n );\n }\n\n /**\n * keyDown handles keydown events that occur in the month picker\n *\n * @param {Event} e\n * @param {DatePickerContext} dp\n */\n function keyDown$1(e, dp) {\n var key = e.keyCode;\n var shiftBy =\n (key === Key.left) ? -1 :\n (key === Key.right) ? 1 :\n (key === Key.up) ? -3 :\n (key === Key.down) ? 3 :\n 0;\n\n if (key === Key.esc) {\n dp.setState({\n view: 'day',\n });\n } else if (shiftBy) {\n e.preventDefault();\n dp.setState({\n hilightedDate: shiftMonth(dp.state.hilightedDate, shiftBy, true)\n });\n }\n }\n\n /**\n * @file Manages the year-picker view.\n */\n\n var yearPicker = {\n render: render$2,\n onKeyDown: keyDown$2,\n onClick: {\n 'dp-year': onChooseYear\n },\n };\n\n /**\n * view renders the year picker as an HTML string.\n *\n * @param {DatePickerContext} dp the date picker context\n * @returns {string}\n */\n function render$2(dp) {\n var state = dp.state;\n var currentYear = state.hilightedDate.getFullYear();\n var selectedYear = state.selectedDate.getFullYear();\n\n return (\n '
' +\n mapYears(dp, function (year) {\n var className = 'dp-year';\n className += (year === currentYear ? ' dp-current' : '');\n className += (year === selectedYear ? ' dp-selected' : '');\n\n return (\n ''\n );\n }) +\n '
'\n );\n }\n\n function onChooseYear(e, dp) {\n dp.setState({\n hilightedDate: setYear(dp.state.hilightedDate, parseInt(e.target.getAttribute('data-year'))),\n view: 'day',\n });\n }\n\n function keyDown$2(e, dp) {\n var key = e.keyCode;\n var opts = dp.opts;\n var shiftBy =\n (key === Key.left || key === Key.up) ? 1 :\n (key === Key.right || key === Key.down) ? -1 :\n 0;\n\n if (key === Key.esc) {\n dp.setState({\n view: 'day',\n });\n } else if (shiftBy) {\n e.preventDefault();\n var shiftedYear = shiftYear(dp.state.hilightedDate, shiftBy);\n\n dp.setState({\n hilightedDate: constrainDate(shiftedYear, opts.min, opts.max),\n });\n }\n }\n\n function mapYears(dp, fn) {\n var result = '';\n var max = dp.opts.max.getFullYear();\n\n for (var i = max; i >= dp.opts.min.getFullYear(); --i) {\n result += fn(i);\n }\n\n return result;\n }\n\n /**\n * @file Defines the base date picker behavior, overridden by various modes.\n */\n\n var views = {\n day: dayPicker,\n year: yearPicker,\n month: monthPicker\n };\n\n function BaseMode(input, emit, opts) {\n var detatchInputEvents; // A function that detaches all events from the input\n var closing = false; // A hack to prevent calendar from re-opening when closing.\n var selectedDate; // The currently selected date\n var dp = {\n // The root DOM element for the date picker, initialized on first open.\n el: undefined,\n opts: opts,\n shouldFocusOnBlur: true,\n shouldFocusOnRender: true,\n state: initialState(),\n adjustPosition: noop,\n containerHTML: '
',\n\n attachToDom: function () {\n document.body.appendChild(dp.el);\n },\n\n updateInput: function (selectedDate) {\n var e = new CustomEvent('change', {bubbles: true});\n e.simulated = true;\n input.value = selectedDate ? opts.format(selectedDate) : '';\n input.dispatchEvent(e);\n },\n\n computeSelectedDate: function () {\n return opts.parse(input.value);\n },\n\n currentView: function() {\n return views[dp.state.view];\n },\n\n open: function () {\n if (closing) {\n return;\n }\n\n if (!dp.el) {\n dp.el = createContainerElement(opts, dp.containerHTML);\n attachContainerEvents(dp);\n }\n\n selectedDate = constrainDate(dp.computeSelectedDate(), opts.min, opts.max);\n dp.state.hilightedDate = selectedDate || opts.hilightedDate;\n dp.state.view = 'day';\n\n dp.attachToDom();\n dp.render();\n\n emit('open');\n },\n\n isVisible: function () {\n return !!dp.el && !!dp.el.parentNode;\n },\n\n hasFocus: function () {\n var focused = document.activeElement;\n return dp.el &&\n dp.el.contains(focused) &&\n focused.className.indexOf('dp-focuser') < 0;\n },\n\n shouldHide: function () {\n return dp.isVisible();\n },\n\n close: function (becauseOfBlur) {\n var el = dp.el;\n\n if (!dp.isVisible()) {\n return;\n }\n\n if (el) {\n var parent = el.parentNode;\n parent && parent.removeChild(el);\n }\n\n closing = true;\n\n if (becauseOfBlur && dp.shouldFocusOnBlur) {\n focusInput(input);\n }\n\n // When we close, the input often gains refocus, which\n // can then launch the date picker again, so we buffer\n // a bit and don't show the date picker within N ms of closing\n setTimeout(function() {\n closing = false;\n }, 100);\n\n emit('close');\n },\n\n destroy: function () {\n dp.close();\n detatchInputEvents();\n },\n\n render: function () {\n if (!dp.el) {\n return;\n }\n\n var hadFocus = dp.hasFocus();\n var html = dp.currentView().render(dp);\n html && (dp.el.firstChild.innerHTML = html);\n\n dp.adjustPosition();\n\n if (hadFocus || dp.shouldFocusOnRender) {\n focusCurrent(dp);\n }\n },\n\n // Conceptually similar to setState in React, updates\n // the view state and re-renders.\n setState: function (state) {\n for (var key in state) {\n dp.state[key] = state[key];\n }\n\n emit('statechange');\n dp.render();\n },\n };\n\n detatchInputEvents = attachInputEvents(input, dp);\n\n // Builds the initial view state\n // selectedDate is a special case and causes changes to hilightedDate\n // hilightedDate is set on open, so remains undefined initially\n // view is the current view (day, month, year)\n function initialState() {\n return {\n get selectedDate() {\n return selectedDate;\n },\n set selectedDate(dt) {\n if (dt && !opts.inRange(dt)) {\n return;\n }\n\n if (dt) {\n selectedDate = new Date(dt);\n dp.state.hilightedDate = selectedDate;\n } else {\n selectedDate = dt;\n }\n\n dp.updateInput(selectedDate);\n emit('select');\n dp.close();\n },\n view: 'day',\n };\n }\n\n return dp;\n }\n\n function createContainerElement(opts, containerHTML) {\n var el = document.createElement('div');\n\n el.className = opts.mode;\n el.innerHTML = containerHTML;\n\n return el;\n }\n\n function attachInputEvents(input, dp) {\n var bufferShow = bufferFn(5, function () {\n if (dp.shouldHide()) {\n dp.close();\n } else {\n dp.open();\n }\n });\n\n var off = [\n on('blur', input, bufferFn(150, function () {\n if (!dp.hasFocus()) {\n dp.close(true);\n }\n })),\n\n on('mousedown', input, function () {\n if (input === document.activeElement) {\n bufferShow();\n }\n }),\n\n on('focus', input, bufferShow),\n\n on('input', input, function (e) {\n var date = dp.opts.parse(e.target.value);\n isNaN(date) || dp.setState({\n hilightedDate: date\n });\n }),\n ];\n\n // Unregister all events that were registered above.\n return function() {\n off.forEach(function (f) {\n f();\n });\n };\n }\n\n function focusCurrent(dp) {\n var current = dp.el.querySelector('.dp-current');\n return current && current.focus();\n }\n\n function attachContainerEvents(dp) {\n var el = dp.el;\n var calEl = el.querySelector('.dp');\n\n // Hack to get iOS to show active CSS states\n el.ontouchstart = noop;\n\n function onClick(e) {\n e.target.className.split(' ').forEach(function(evt) {\n var handler = dp.currentView().onClick[evt];\n handler && handler(e, dp);\n });\n }\n\n // The calender fires a blur event *every* time we redraw\n // this means we need to buffer the blur event to see if\n // it still has no focus after redrawing, and only then\n // do we return focus to the input. A possible other approach\n // would be to set context.redrawing = true on redraw and\n // set it to false in the blur event.\n on('blur', calEl, bufferFn(150, function () {\n if (!dp.hasFocus()) {\n dp.close(true);\n }\n }));\n\n on('keydown', el, function (e) {\n if (e.keyCode === Key.enter) {\n onClick(e);\n } else {\n dp.currentView().onKeyDown(e, dp);\n }\n });\n\n // If the user clicks in non-focusable space, but\n // still within the date picker, we don't want to\n // hide, so we need to hack some things...\n on('mousedown', calEl, function (e) {\n e.target.focus && e.target.focus(); // IE hack\n if (document.activeElement !== e.target) {\n e.preventDefault();\n focusCurrent(dp);\n }\n });\n\n on('click', el, onClick);\n }\n\n function focusInput(input) {\n // When the modal closes, we need to focus the original input so the\n // user can continue tabbing from where they left off.\n input.focus();\n\n // iOS zonks out if we don't blur the input, so...\n if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {\n input.blur();\n }\n }\n\n /**\n * @file Defines the modal date picker behavior.\n */\n\n function ModalMode(input, emit, opts) {\n var dp = BaseMode(input, emit, opts);\n\n // In modal mode, users really shouldn't be able to type in\n // the input, as all input is done via the calendar.\n input.readonly = true;\n\n // In modal mode, we need to know when the user has tabbed\n // off the end of the calendar, and set focus to the original\n // input. To do this, we add a special element to the DOM.\n // When the user tabs off the bottom of the calendar, they\n // will tab onto this element.\n dp.containerHTML += '.';\n\n return dp;\n }\n\n /**\n * @file Defines the dropdown date picker behavior.\n */\n\n function DropdownMode(input, emit, opts) {\n var dp = BaseMode(input, emit, opts);\n\n dp.shouldFocusOnBlur = false;\n\n Object.defineProperty(dp, 'shouldFocusOnRender', {\n get: function() {\n return input !== document.activeElement;\n }\n });\n\n dp.adjustPosition = function () {\n autoPosition(input, dp);\n };\n\n return dp;\n }\n\n function autoPosition(input, dp) {\n var inputPos = input.getBoundingClientRect();\n var win = window;\n\n adjustCalY(dp, inputPos, win);\n adjustCalX(dp, inputPos, win);\n\n dp.el.style.visibility = '';\n }\n\n function adjustCalX(dp, inputPos, win) {\n var cal = dp.el;\n var scrollLeft = win.pageXOffset;\n var inputLeft = inputPos.left + scrollLeft;\n var maxRight = win.innerWidth + scrollLeft;\n var offsetWidth = cal.offsetWidth;\n var calRight = inputLeft + offsetWidth;\n var shiftedLeft = maxRight - offsetWidth;\n var left = calRight > maxRight && shiftedLeft > 0 ? shiftedLeft : inputLeft;\n\n cal.style.left = left + 'px';\n }\n\n function adjustCalY(dp, inputPos, win) {\n var cal = dp.el;\n var scrollTop = win.pageYOffset;\n var inputTop = scrollTop + inputPos.top;\n var calHeight = cal.offsetHeight;\n var belowTop = inputTop + inputPos.height + 8;\n var aboveTop = inputTop - calHeight - 8;\n var isAbove = (aboveTop > 0 && belowTop + calHeight > scrollTop + win.innerHeight);\n var top = isAbove ? aboveTop : belowTop;\n\n if (cal.classList) {\n cal.classList.toggle('dp-is-above', isAbove);\n cal.classList.toggle('dp-is-below', !isAbove);\n }\n cal.style.top = top + 'px';\n }\n\n /**\n * @file Defines the permanent date picker behavior.\n */\n\n function PermanentMode(root, emit, opts) {\n var dp = BaseMode(root, emit, opts);\n\n dp.close = noop;\n dp.destroy = noop;\n dp.updateInput = noop;\n dp.shouldFocusOnRender = opts.shouldFocusOnRender;\n\n dp.computeSelectedDate = function () {\n return opts.hilightedDate;\n };\n\n dp.attachToDom = function () {\n root.appendChild(dp.el);\n };\n\n dp.open();\n\n return dp;\n }\n\n /**\n * @file Defines the various date picker modes (modal, dropdown, permanent)\n */\n\n function Mode(input, emit, opts) {\n input = input && input.tagName ? input : document.querySelector(input);\n\n if (opts.mode === 'dp-modal') {\n return ModalMode(input, emit, opts);\n }\n\n if (opts.mode === 'dp-below') {\n return DropdownMode(input, emit, opts);\n }\n\n if (opts.mode === 'dp-permanent') {\n return PermanentMode(input, emit, opts);\n }\n }\n\n /**\n * @file Defines simple event emitter behavior.\n */\n\n /**\n * Emitter constructs a new emitter object which has on/off methods.\n *\n * @returns {EventEmitter}\n */\n function Emitter() {\n var handlers = {};\n\n function onOne(name, handler) {\n (handlers[name] = (handlers[name] || [])).push(handler);\n }\n\n function onMany(fns) {\n for (var name in fns) {\n onOne(name, fns[name]);\n }\n }\n\n return {\n on: function (name, handler) {\n if (handler) {\n onOne(name, handler);\n } else {\n onMany(name);\n }\n\n return this;\n },\n\n emit: function (name, arg) {\n (handlers[name] || []).forEach(function (handler) {\n handler(name, arg);\n });\n },\n\n off: function (name, handler) {\n if (!name) {\n handlers = {};\n } else if (!handler) {\n handlers[name] = [];\n } else {\n handlers[name] = (handlers[name] || []).filter(function (h) {\n return h !== handler;\n });\n }\n\n return this;\n }\n };\n }\n\n /**\n * @file The root date picker file, defines public exports for the library.\n */\n\n /**\n * The date picker language configuration\n * @typedef {Object} LangOptions\n * @property {Array.} [days] - Days of the week\n * @property {Array.} [months] - Months of the year\n * @property {string} today - The label for the 'today' button\n * @property {string} close - The label for the 'close' button\n * @property {string} clear - The label for the 'clear' button\n */\n\n /**\n * The configuration options for a date picker.\n *\n * @typedef {Object} DatePickerOptions\n * @property {LangOptions} [lang] - Configures the label text, defaults to English\n * @property {('dp-modal'|'dp-below'|'dp-permanent')} [mode] - The date picker mode, defaults to 'dp-modal'\n * @property {(string|Date)} [hilightedDate] - The date to hilight if no date is selected\n * @property {function(string|Date):Date} [parse] - Parses a date, the complement of the \"format\" function\n * @property {function(Date):string} [format] - Formats a date for displaying to user\n * @property {function(Date):string} [dateClass] - Associates a custom CSS class with a date\n * @property {function(Date):boolean} [inRange] - Indicates whether or not a date is selectable\n * @property {(string|Date)} [min] - The minimum selectable date (inclusive, default 100 years ago)\n * @property {(string|Date)} [max] - The maximum selectable date (inclusive, default 100 years from now)\n */\n\n /**\n * The state values for the date picker\n *\n * @typedef {Object} DatePickerState\n * @property {string} view - The current view 'day' | 'month' | 'year'\n * @property {Date} selectedDate - The date which has been selected by the user\n * @property {Date} hilightedDate - The date which is currently hilighted / active\n */\n\n /**\n * An instance of TinyDatePicker\n *\n * @typedef {Object} DatePicker\n * @property {DatePickerState} state - The values currently displayed.\n * @property {function} on - Adds an event handler\n * @property {function} off - Removes an event handler\n * @property {function} setState - Changes the current state of the date picker\n * @property {function} open - Opens the date picker\n * @property {function} close - Closes the date picker\n * @property {function} destroy - Destroys the date picker (removing all handlers from the input, too)\n */\n\n /**\n * TinyDatePicker constructs a new date picker for the specified input\n *\n * @param {HTMLElement | string} input The input or CSS selector associated with the datepicker\n * @param {DatePickerOptions} opts The options for initializing the date picker\n * @returns {DatePicker}\n */\n function TinyDatePicker(input, opts) {\n var emitter = Emitter();\n var options = DatePickerOptions(opts);\n var mode = Mode(input, emit, options);\n var me = {\n get state() {\n return mode.state;\n },\n on: emitter.on,\n off: emitter.off,\n setState: mode.setState,\n open: mode.open,\n close: mode.close,\n destroy: mode.destroy,\n };\n\n function emit(evt) {\n emitter.emit(evt, me);\n }\n\n return me;\n }\n\n return TinyDatePicker;\n\n})));\n","class DateUtils {\n\n //--------------------------\n // constructor\n //--------------------------\n constructor() {}\n\n //--------------------------\n // methods\n //--------------------------\n getMKtime() {\n var time = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), new Date().getMinutes(), new Date().getSeconds(), 0).getTime() / 1000;\n return time;\n }\n\n convertMKtime(seconds) {\n var date = new Date(seconds * 1000);\n return date;\n }\n\n getDate(type, rawdate) {\n var day = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCDate()) : String(new Date().getUTCDate()));\n var month = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMonth() + 1) : String(new Date().getUTCMonth() + 1));\n var year = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCFullYear()) : String(new Date().getUTCFullYear()));\n var hour = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCHours()) : String(new Date().getUTCHours()));\n var minute = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMinutes()) : String(new Date().getUTCMinutes()));\n var seconds = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCSeconds()) : String(new Date().getUTCSeconds()));\n var millisecond = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMilliseconds()) : String(new Date().getUTCMilliseconds()));\n var offset = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getTimezoneOffset()) : String(new Date().getTimezoneOffset()));\n if (day.length == 1)\n day = String(\"0\" + day);\n if (month.length == 1)\n month = String(\"0\" + month);\n offset = String(offset / 60);\n if (offset.length == 1)\n offset = String(\"0\" + offset);\n switch (type) {\n case \"day\":\n return day;\n break;\n case \"month\":\n return month;\n break;\n case \"year\":\n return year;\n break;\n case \"stamp\":\n return String(year + \"-\" + month + \"-\" + day + \" \" + hour + \":\" + minute + \":\" + seconds + \".\" + millisecond + \"-\" + (offset));\n break\n default:\n return String(year + \"-\" + month + \"-\" + day);\n break;\n }\n }\n\n //--------------------------\n // event handlers\n //--------------------------\n}\n\nexport default DateUtils","class DateUtils {\n\n //--------------------------\n // constructor\n //--------------------------\n constructor() {}\n\n //--------------------------\n // methods\n //--------------------------\n getMKtime() {\n var time = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), new Date().getMinutes(), new Date().getSeconds(), 0).getTime() / 1000;\n return time;\n }\n\n convertMKtime(seconds) {\n var date = new Date(seconds * 1000);\n return date;\n }\n\n getDate(type, rawdate) {\n var day = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCDate()) : String(new Date().getUTCDate()));\n var month = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMonth() + 1) : String(new Date().getUTCMonth() + 1));\n var year = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCFullYear()) : String(new Date().getUTCFullYear()));\n var hour = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCHours()) : String(new Date().getUTCHours()));\n var minute = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMinutes()) : String(new Date().getUTCMinutes()));\n var seconds = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCSeconds()) : String(new Date().getUTCSeconds()));\n var millisecond = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMilliseconds()) : String(new Date().getUTCMilliseconds()));\n var offset = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getTimezoneOffset()) : String(new Date().getTimezoneOffset()));\n if (day.length == 1)\n day = String(\"0\" + day);\n if (month.length == 1)\n month = String(\"0\" + month);\n offset = String(offset / 60);\n if (offset.length == 1)\n offset = String(\"0\" + offset);\n switch (type) {\n case \"day\":\n return day;\n break;\n case \"month\":\n return month;\n break;\n case \"year\":\n return year;\n break;\n case \"stamp\":\n return String(year + \"-\" + month + \"-\" + day + \" \" + hour + \":\" + minute + \":\" + seconds + \".\" + millisecond + \"-\" + (offset));\n break\n default:\n return String(year + \"-\" + month + \"-\" + day);\n break;\n }\n }\n\n //--------------------------\n // event handlers\n //--------------------------\n}\n\nexport default DateUtils","const attributes = [\n 'borderBottomWidth',\n 'borderLeftWidth',\n 'borderRightWidth',\n 'borderTopStyle',\n 'borderRightStyle',\n 'borderBottomStyle',\n 'borderLeftStyle',\n 'borderTopWidth',\n 'boxSizing',\n 'fontFamily',\n 'fontSize',\n 'fontWeight',\n 'height',\n 'letterSpacing',\n 'lineHeight',\n 'marginBottom',\n 'marginLeft',\n 'marginRight',\n 'marginTop',\n 'outlineWidth',\n 'overflow',\n 'overflowX',\n 'overflowY',\n 'paddingBottom',\n 'paddingLeft',\n 'paddingRight',\n 'paddingTop',\n 'textAlign',\n 'textOverflow',\n 'textTransform',\n 'whiteSpace',\n 'wordBreak',\n 'wordWrap',\n];\n\n/**\n * Create a mirror\n *\n * @param {Element} element The element\n * @param {string} html The html\n *\n * @return {object} The mirror object\n */\nconst createMirror = (element, html) => {\n\n /**\n * The mirror element\n */\n const mirror = document.createElement('div');\n\n /**\n * Create the CSS for the mirror object\n *\n * @return {object} The style object\n */\n const mirrorCss = () => {\n const css = {\n position: 'absolute',\n left: -9999,\n top: 0,\n zIndex: -2000\n };\n\n if (element.tagName === 'TEXTAREA') {\n attributes.push('width');\n }\n\n attributes.forEach((attr) => {\n css[attr] = getComputedStyle(element)[attr];\n });\n\n return css;\n };\n\n /**\n * Initialize the mirror\n *\n * @param {string} html The html\n *\n * @return {void}\n */\n const initialize = (html) => {\n const styles = mirrorCss();\n Object.keys(styles).forEach(key => {\n mirror.style[key] = styles[key];\n });\n mirror.innerHTML = html;\n element.parentNode.insertBefore(mirror, element.nextSibling);\n };\n\n /**\n * Get the rect\n *\n * @return {Rect} The bounding rect\n */\n const rect = () => {\n const marker = mirror.ownerDocument.getElementById('caret-position-marker');\n const boundingRect = {\n left: marker.offsetLeft,\n top: marker.offsetTop,\n height: marker.offsetHeight\n };\n mirror.parentNode.removeChild(mirror);\n\n return boundingRect;\n };\n\n initialize(html);\n\n return {\n rect,\n };\n};\n\nexport default createMirror;\n","/**\n * Check if a DOM Element is content editable\n *\n * @param {Element} element The DOM element\n *\n * @return {bool} If it is content editable\n */\nexport const isContentEditable = (element) => !!(\n element.contentEditable &&\n element.contentEditable === 'true'\n);\n\n/**\n * Get the context from settings passed in\n *\n * @param {object} settings The settings object\n *\n * @return {object} window and document\n */\nexport const getContext = (settings = {}) => {\n const { customPos, iframe, noShadowCaret } = settings;\n if (iframe) {\n return {\n iframe,\n window: iframe.contentWindow,\n document: iframe.contentDocument || iframe.contentWindow.document,\n noShadowCaret,\n customPos,\n };\n }\n\n return {\n window,\n document,\n noShadowCaret,\n customPos,\n };\n};\n\n/**\n * Get the offset of an element\n *\n * @param {Element} element The DOM element\n * @param {object} ctx The context\n *\n * @return {object} top and left\n */\nexport const getOffset = (element, ctx) => {\n const win = ctx && ctx.window || window;\n const doc = ctx && ctx.document || document;\n const rect = element.getBoundingClientRect();\n const docEl = doc.documentElement;\n const scrollLeft = win.pageXOffset || docEl.scrollLeft;\n const scrollTop = win.pageYOffset || docEl.scrollTop;\n\n return {\n top: rect.top + scrollTop,\n left: rect.left + scrollLeft\n };\n};\n\n/**\n * Check if a value is an object\n *\n * @param {any} value The value to check\n *\n * @return {bool} If it is an object\n */\nexport const isObject = (value) => typeof value === 'object' && value !== null;\n","import createMirror from './mirror';\nimport { getOffset as elementOffset } from './utils';\n\n/**\n * Create a Input caret object.\n *\n * @param {Element} element The element\n * @param {Object} ctx The context\n */\nconst createInputCaret = (element, ctx) => {\n\n /**\n * Get the current position\n *\n * @returns {int} The caret position\n */\n const getPos = () => {\n return element.selectionStart;\n };\n\n /**\n * Set the position\n *\n * @param {int} pos The position\n *\n * @return {Element} The element\n */\n const setPos = (pos) => {\n element.setSelectionRange(pos, pos);\n\n return element;\n };\n\n /**\n * The offset\n *\n * @param {int} pos The position\n *\n * @return {object} The offset\n */\n const getOffset = (pos) => {\n const rect = elementOffset(element);\n const position = getPosition(pos);\n\n return {\n top: rect.top + position.top + ctx.document.body.scrollTop,\n left: rect.left + position.left + ctx.document.body.scrollLeft,\n height: position.height,\n };\n };\n\n /**\n * Get the current position\n *\n * @param {int} pos The position\n *\n * @return {object} The position\n */\n const getPosition = (pos) => {\n const format = (val) => {\n let value = val.replace(/<|>|`|\"|&/g, '?')\n .replace(/\\r\\n|\\r|\\n/g,'
');\n return value;\n };\n\n if (ctx.customPos || ctx.customPos === 0) {\n pos = ctx.customPos;\n }\n\n const position = pos === undefined ? getPos() : pos;\n const startRange = element.value.slice(0, position);\n const endRange = element.value.slice(position);\n let html = `${format(startRange)}`;\n html += '|';\n html += `${format(endRange)}`;\n\n const mirror = createMirror(element, html);\n const rect = mirror.rect();\n rect.pos = getPos();\n\n return rect;\n };\n\n return {\n getPos,\n setPos,\n getOffset,\n getPosition,\n };\n};\n\nexport default createInputCaret;\n","/**\n * Create an Editable Caret\n * @param {Element} element The editable element\n * @param {object|null} ctx The context\n *\n * @return {EditableCaret}\n */\nconst createEditableCaret = (element, ctx) => {\n\n /**\n * Set the caret position\n *\n * @param {int} pos The position to se\n *\n * @return {Element} The element\n */\n const setPos = (pos) => {\n const sel = ctx.window.getSelection();\n if (sel) {\n let offset = 0;\n let found = false;\n const find = (position, parent) => {\n for (let i = 0; i < parent.childNodes.length; i++) {\n const node = parent.childNodes[i];\n if (found) {\n break;\n }\n if (node.nodeType === 3) {\n if (offset + node.length >= position) {\n found = true;\n const range = ctx.document.createRange();\n range.setStart(node, position - offset);\n sel.removeAllRanges();\n sel.addRange(range);\n break;\n } else {\n offset += node.length;\n }\n } else {\n find(pos, node);\n }\n }\n };\n find(pos, element);\n }\n\n return element;\n };\n\n /**\n * Get the offset\n *\n * @return {object} The offset\n */\n const getOffset = () => {\n const range = getRange();\n let offset = {\n height: 0,\n left: 0,\n right: 0,\n };\n\n if (!range) {\n return offset;\n }\n\n const hasCustomPos = ctx.customPos || ctx.customPos === 0;\n\n // endContainer in Firefox would be the element at the start of\n // the line\n if ((range.endOffset - 1 > 0 && range.endContainer !== element) || hasCustomPos) {\n const clonedRange = range.cloneRange();\n const fixedPosition = hasCustomPos ? ctx.customPos : range.endOffset;\n clonedRange.setStart(range.endContainer, fixedPosition - 1 < 0 ? 0 : fixedPosition - 1);\n clonedRange.setEnd(range.endContainer, fixedPosition);\n const rect = clonedRange.getBoundingClientRect();\n offset = {\n height: rect.height,\n left: rect.left + rect.width,\n top: rect.top,\n };\n clonedRange.detach();\n }\n\n if ((!offset || (offset && offset.height === 0)) && !ctx.noShadowCaret) {\n const clonedRange = range.cloneRange();\n const shadowCaret = ctx.document.createTextNode('|');\n clonedRange.insertNode(shadowCaret);\n clonedRange.selectNode(shadowCaret);\n const rect = clonedRange.getBoundingClientRect();\n offset = {\n height: rect.height,\n left: rect.left,\n top: rect.top,\n };\n shadowCaret.parentNode.removeChild(shadowCaret);\n clonedRange.detach();\n }\n\n if (offset) {\n const doc = ctx.document.documentElement;\n offset.top += ctx.window.pageYOffset - (doc.clientTop || 0);\n offset.left += ctx.window.pageXOffset - (doc.clientLeft || 0);\n }\n\n return offset;\n };\n\n /**\n * Get the position\n *\n * @return {object} The position\n */\n const getPosition = () => {\n const offset = getOffset();\n const pos = getPos();\n const rect = element.getBoundingClientRect();\n const inputOffset = {\n top: rect.top + ctx.document.body.scrollTop,\n left: rect.left + ctx.document.body.scrollLeft\n };\n offset.left -= inputOffset.left;\n offset.top -= inputOffset.top;\n offset.pos = pos;\n\n return offset;\n };\n\n /**\n * Get the range\n *\n * @return {Range|null}\n */\n const getRange = () => {\n if (!ctx.window.getSelection) {\n return;\n }\n const sel = ctx.window.getSelection();\n\n return sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n };\n\n /**\n * Get the caret position\n *\n * @return {int} The position\n */\n const getPos = () => {\n const range = getRange();\n const clonedRange = range.cloneRange();\n clonedRange.selectNodeContents(element);\n clonedRange.setEnd(range.endContainer, range.endOffset);\n const pos = clonedRange.toString().length;\n clonedRange.detach();\n\n return pos;\n };\n\n return {\n getPos,\n setPos,\n getPosition,\n getOffset,\n getRange,\n };\n};\n\nexport default createEditableCaret;\n","import createInputCaret from './input';\nimport createEditableCaret from './editable';\nimport {\n isContentEditable,\n getContext,\n isObject,\n} from './utils';\n\nexport { getOffset } from './utils';\n\nconst createCaret = (element, ctx) => {\n if (isContentEditable(element)) {\n return createEditableCaret(element, ctx);\n }\n\n return createInputCaret(element, ctx);\n};\n\nexport const position = (element, value, settings = {}) => {\n let options = settings;\n if (isObject(value)) {\n options = value;\n value = null;\n }\n const ctx = getContext(options);\n const caret = createCaret(element, ctx);\n\n if (value || value === 0) {\n return caret.setPos(value);\n }\n\n return caret.getPosition();\n};\n\n/**\n *\n * @param {Element} element The DOM element\n * @param {number|undefined} value The value to set\n * @param {object} settings Any settings for context\n */\nexport const offset = (element, value, settings = {}) => {\n let options = settings;\n if (isObject(value)) {\n options = value;\n value = null;\n }\n\n const ctx = getContext(options);\n const caret = createCaret(element, ctx);\n return caret.getOffset(value);\n};\n","import * as DataEvent from '../events/DataEvent';\nimport DateUtils from '../utilities/DateUtils';\nimport {\n position,\n offset\n} from 'caret-pos';\n\nimport EventEmitter from '../events/EventEmitter';\nimport * as EditorEvent from '../events/EditorEvent';\n\nclass TextEditor extends EventEmitter {\n\n //--------------------------\n // constructor\n //--------------------------\n constructor(textEditor, scrollLimit) {\n super();\n hljs.initHighlightingOnLoad();\n //this.dataUtils = new DataUtils();\n this.dateUtils = new DateUtils();\n this.textEditor = textEditor;\n this.fixLimit = scrollLimit;\n this.caretPos = null;\n this.url = '';\n let self = this;\n this.setInputs();\n\n window.addEventListener(\"scroll\", f => {\n var fixLimit = this.fixLimit;\n if (window.pageYOffset >= fixLimit) {\n document.getElementById('edit-control').style.position = \"fixed\"\n } else {\n document.getElementById('edit-control').style.position = \"relative\"\n }\n });\n this.refresh();\n }\n //--------------------------\n // methods\n //--------------------------\n setInputs() {\n let self = this;\n var editorButtons = document.querySelectorAll('.editor-button');\n for (var i = 0, length = editorButtons.length; i < length; i++) {\n editorButtons[i].addEventListener('click', e => this.handleEditorOption(e), false);\n }\n this.textEditor.addEventListener('input', f => {\n if(f.inputType == \"insertParagraph\")\n {\n var caret = position(self.textEditor).pos+1;\n var spiffed = hljs.highlight('markdown', self.textEditor.innerText).value;\n var temp = document.createElement(\"div\");\n temp.innerText = spiffed;\n self.textEditor.innerHTML = temp.innerText;\n position(self.textEditor, caret)\n }else{\n self.refresh()\n }\n })\n }\n refresh() {\n var caret = position(this.textEditor).pos;\n var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value;\n var temp = document.createElement(\"div\");\n temp.innerText = spiffed;\n this.textEditor.innerHTML = temp.innerText;\n position(this.textEditor, caret)\n }\n\n notify(type, data) {\n switch (type) {\n case DataEvent.POST_UPDATED:\n document.getElementById('submit-update').classList.add('icon-hide');\n document.getElementById('submit-good').classList.remove('icon-hide');\n document.getElementById('edit-update').classList.remove('submit-start');\n document.getElementById('edit-update').classList.add('submit-cool');\n setTimeout(f => {\n document.getElementById('submit-update').classList.remove('icon-hide');\n document.getElementById('submit-good').classList.add('icon-hide');\n document.getElementById('edit-update').classList.add('submit-start');\n document.getElementById('edit-update').classList.remove('submit-cool');\n }, 2000);\n\n break;\n case DataEvent.POST_ADDED:\n // do nothing\n break;\n case EditorEvent.EDITOR_UPLOAD_POST_IMAGE:\n position(this.textEditor, this.caretPos);\n var sel, range, pulled;\n sel = window.getSelection(); //console.log(sel)\n //console.log(note.message)\n if (sel.rangeCount) {\n range = sel.getRangeAt(0);\n pulled = sel.getRangeAt(0).toString();\n range.deleteContents();\n range.insertNode(document.createTextNode(\"![image alt text](\" + data + \" 'image title')\"));\n }\n this.refresh();\n break;\n }\n }\n\n //--------------------------\n // event handlers\n //--------------------------\n handleEditorOption(e) {\n e.preventDefault();\n var self = this;\n var sel, range, pulled;\n sel = window.getSelection(); //console.log(sel)\n if (sel.rangeCount) {\n range = sel.getRangeAt(0);\n pulled = sel.getRangeAt(0).toString();\n range.deleteContents();\n switch (e.target.id) {\n case \"edit-bold\":\n range.insertNode(document.createTextNode(\"**\" + pulled + \"**\"));\n break;\n case \"edit-italic\":\n range.insertNode(document.createTextNode(\"*\" + pulled + \"*\"));\n break;\n case \"edit-strikethrough\":\n range.insertNode(document.createTextNode(\"\" + pulled + \"\"));\n break;\n case \"edit-header1\":\n range.insertNode(document.createTextNode(\"# \" + pulled));\n break;\n case \"edit-header2\":\n range.insertNode(document.createTextNode(\"## \" + pulled));\n break;\n case \"edit-header3\":\n range.insertNode(document.createTextNode(\"### \" + pulled));\n break;\n case \"edit-image\":\n this.caretPos = position(this.textEditor).pos;\n this.emitEvent(EditorEvent.EDITOR_UPLOAD_POST_IMAGE);\n break;\n case \"submit-save\":\n case \"edit-save\":\n this.emitEvent(EditorEvent.EDITOR_SAVE);\n break;\n case \"submit-update\":\n case \"edit-update\":\n this.emitEvent(EditorEvent.EDITOR_UPDATE);\n break\n case \"edit-link\":\n range.insertNode(document.createTextNode(\"[\" + pulled + \"](PASTE URL HERE)\"));\n break;\n case \"edit-delete\":\n this.emitEvent(EditorEvent.EDITOR_DELETE);\n break\n default:\n //range.insertNode(document.createTextNode(\"[\" + self.url + \"](PASTE URL HERE)\"));\n break;\n }\n }\n this.refresh()\n }\n}\nexport default TextEditor","//TOOLS\nimport DataUtils,\n{\n REQUEST_TYPE_GET,\n REQUEST_TYPE_PUT,\n REQUEST_TYPE_POST,\n REQUEST_TYPE_DELETE,\n CONTENT_TYPE_JSON,\n CONTENT_TYPE_FORM\n}\nfrom '../../../../../brain/tools/utilities/DataUtils';\nimport * as DataEvent from '../../../../../brain/tools/events/DataEvent';\nimport Animate from '../../../../../brain/tools/effects/Animate';\nimport PostActions from '../actions/PostActions';\nimport * as EditorEvent from '../../../../../brain/tools/events/EditorEvent';\nimport TinyDatePicker from 'tiny-date-picker';\nimport DateUtils from '../../../../../brain/tools/utilities/DateUtils';\nimport TextEditor from '../../../../../brain/tools/ui/TextEditor';\nclass PostEditor\n{\n //--------------------------\n // constructor\n //--------------------------\n constructor()\n {\n //reframe('iframe');\n let self = this;\n this.uploadFiles;\n this.anim = new Animate();\n this.dataUtils = new DataUtils();\n this.dateUtils = new DateUtils();\n if ( document.getElementById( 'edit-post-text' ) )\n {\n this.editor = new TextEditor( document.getElementById( 'edit-post-text' ), document.getElementById( 'header' ).offsetHeight + document.getElementById( 'post-header' ).offsetHeight + document.getElementById( 'post-feature' ).offsetHeight );\n this.editor.addListener( EditorEvent.EDITOR_DELETE, f => this.handleEditorOptions( EditorEvent.EDITOR_DELETE ), false )\n this.editor.addListener( EditorEvent.EDITOR_UPLOAD_POST_IMAGE, f => this.handleEditorOptions( EditorEvent.EDITOR_UPLOAD_POST_IMAGE ), false )\n this.editor.addListener( EditorEvent.EDITOR_UPDATE, f => this.handleEditorOptions( EditorEvent.EDITOR_UPDATE ), false )\n this.editor.addListener( EditorEvent.EDITOR_SAVE, f => this.handleEditorOptions( EditorEvent.EDITOR_SAVE ), false )\n document.getElementById( 'post-image' ).addEventListener( 'change', e => this.handlePostImageAdd( e ), false );\n TinyDatePicker( document.getElementById( 'post-date' ),\n {\n mode: 'dp-below',\n format( date )\n {\n //return date;\n return self.dateUtils.getDate( 'origin', date );\n }\n } );\n }\n this.start();\n }\n //--------------------------\n // methods\n //--------------------------\n start()\n {\n let self = this;\n new Animate().object(\n {\n targets: document.getElementById( 'loader' ),\n duration: 300,\n opacity: 0,\n easing: 'easeInOutQuad',\n complete: function()\n {\n document.getElementById( 'loader' ).style.display = 'none';\n document.getElementById( 'loader' ).style.visibility = 'hidden';\n new Animate().object(\n {\n targets: document.getElementById( 'header' ),\n duration: 10,\n opacity: 1,\n easing: 'easeInOutQuad',\n complete: function()\n {\n if ( document.getElementById( 'the-intro' ) ) document.getElementById( 'the-intro' ).style.opacity = 1;\n if ( document.getElementById( 'blog-entry' ) ) document.getElementById( 'blog-entry' ).style.opacity = 1;\n }\n } );\n }\n } );\n if ( document.getElementById( 'featured-image-drop' ) )\n {\n document.getElementById( 'featured-image-drop' ).addEventListener( 'dragover', this.handleDragOver, false );\n document.getElementById( 'featured-image-drop' ).addEventListener( 'drop', this.handleDrop, false );\n document.getElementById( 'featured-click' ).addEventListener( 'change', this.handleClicked, false );\n if ( document.getElementById( 'new-upload-link' ) )\n {\n document.getElementById( 'new-upload-link' ).addEventListener( 'click', e =>\n {\n document.getElementById( 'featured-click' ).click();\n } )\n }\n var optionButtons = document.querySelectorAll( '.post-option-btn' );\n for ( var i = 0, length = optionButtons.length; i < length; i++ )\n {\n optionButtons[ i ].addEventListener( 'click', e => this.handlePostOptions( e ), false );\n }\n }\n }\n //--------------------------\n // event handlers\n //--------------------------\n handlePostOptions( e )\n {\n let currentOption;\n switch ( e.target.id )\n {\n case \"option-page-icon\":\n case \"option-page\":\n currentOption = document.getElementById( 'option-page' );\n break;\n case \"option-feature-icon\":\n case \"option-feature\":\n currentOption = document.getElementById( 'option-feature' );\n break;\n case \"option-published-icon\":\n case \"option-published\":\n currentOption = document.getElementById( 'option-published' );\n break;\n }\n let active = currentOption.getAttribute( 'data-active' );\n ( active == 'false' ) ? currentOption.setAttribute( 'data-active', 'true' ): currentOption.setAttribute( 'data-active', 'false' )\n }\n handleEditorOptions( e )\n {\n switch ( e )\n {\n case EditorEvent.EDITOR_SAVE:\n case EditorEvent.EDITOR_UPDATE:\n let edit = false;\n if ( e == EditorEvent.EDITOR_UPDATE ) edit = true;\n new PostActions().submitPost( edit, PostEditor.uploadFiles ).then( ( response ) =>\n {\n let note = JSON.parse( response[ 'response' ][ 'request' ].response );\n this.editor.notify( note.message, note.postID );\n if ( note.message == DataEvent.POST_ADDED ) window.location = \"/@/dashboard/posts/edit/\" + note.postID;\n } ).catch( ( err ) =>\n {\n console.log( err )\n } );\n break;\n case EditorEvent.EDITOR_DELETE:\n if ( confirm( 'Aye! You know you\\'re deleting this post, right?' ) )\n {\n new PostActions().deletePost().then( ( response ) =>\n {\n let note = JSON.parse( response[ 'response' ][ 'request' ].response );\n window.location = \"/@/dashboard/posts/\";\n //console.log(note);\n } ).catch( ( err ) =>\n {\n console.log( err )\n } );\n }\n else\n {\n // Do nothing!\n }\n break;\n case EditorEvent.EDITOR_UPLOAD_POST_IMAGE:\n document.getElementById( 'post-image' ).click();\n break;\n }\n }\n handleDragOver( e )\n {\n e.stopPropagation();\n e.preventDefault();\n e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.\n }\n handleClicked( e )\n {\n e.stopPropagation();\n e.preventDefault();\n //console.log(\"IMAGES \" + e.target.files);\n PostEditor.uploadFiles = e.target.files;\n for ( var i = 0, f; f = PostEditor.uploadFiles[ i ]; i++ )\n {\n // Only process image files.\n if ( !f.type.match( 'image.*' ) )\n {\n continue;\n }\n var reader = new FileReader();\n // Closure to capture the file information.\n reader.onload = ( function( theFile )\n {\n return function( f )\n {\n // Render thumbnail.\n var image = document.createElement( 'img' );\n image.src = f.target.result;\n image.title = escape( theFile.name );\n var span = document.createElement( 'div' );\n span.innerHTML = [ ''\n ].join( '' );\n //document.getElementById('featured-image-drop').insertBefore(span, null);\n document.getElementById( 'featured-image-drop' ).innerHTML = '';\n document.getElementById( 'featured-image-drop' ).appendChild( image );\n };\n } )( f );\n // Read in the image file as a data URL.\n reader.readAsDataURL( f );\n }\n }\n handleDrop( e )\n {\n e.stopPropagation();\n e.preventDefault();\n PostEditor.uploadFiles = e.dataTransfer.files;\n //console.log(MemberArea.uploadFiles.length);\n for ( var i = 0, f; f = PostEditor.uploadFiles[ i ]; i++ )\n {\n // Only process image files.\n if ( !f.type.match( 'image.*' ) )\n {\n continue;\n }\n var reader = new FileReader();\n // Closure to capture the file information.\n reader.onload = ( function( theFile )\n {\n return function( f )\n {\n // Render thumbnail.\n var span = document.createElement( 'span' );\n span.innerHTML = [ ''\n ].join( '' );\n //document.getElementById('featured-image-drop').insertBefore(span, null);\n document.getElementById( 'featured-image-drop' ).innerHTML = '';\n document.getElementById( 'featured-image-drop' ).appendChild( span );\n };\n } )( f );\n // Read in the image file as a data URL.\n reader.readAsDataURL( f );\n }\n }\n handlePostImageAdd( e )\n {\n e.stopPropagation();\n e.preventDefault();\n let self = this;\n var postData = new FormData();\n var files = e.target.files;\n for ( var i = 0; i < files.length; i++ )\n {\n var file = files[ i ];\n // Check the file type.\n if ( !file.type.match( 'image.*' ) )\n {\n continue;\n }\n postData.append( 'post_image', file, file.name );\n }\n this.dataUtils.request( \"/api/blog/add-post-image\", DataEvent.POST_IMAGE_ADDED, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, postData ).then( ( response ) =>\n {\n self.editor.notify( EditorEvent.EDITOR_UPLOAD_POST_IMAGE, JSON.parse( response.request[ 'response' ] ).url );\n } ).catch( ( err ) =>\n {\n console.log( err )\n } )\n }\n}\nPostEditor.uploadFiles = [];\nexport\n{\n PostEditor as\n default\n}","//TOOLS\nimport DataUtils, {\n REQUEST_TYPE_GET,\n REQUEST_TYPE_PUT,\n REQUEST_TYPE_POST,\n REQUEST_TYPE_DELETE,\n CONTENT_TYPE_JSON,\n CONTENT_TYPE_FORM\n} from '../../../../../brain/tools/utilities/DataUtils';\nimport PostEditor from './PostEditor';\nimport Animate from '../../../../../brain/tools/effects/Animate.jsx';\n\nclass DisplayManager {\n //--------------------------\n // constructor\n //--------------------------\n constructor() {\n this.dataUtils = new DataUtils();\n this.currentDisplay = '';\n this.urlPieces = document.URL.split(\"/\");\n //grab url so system knows what to display \n this.chooseDisplay(this.urlPieces[5], this.urlPieces[6]);\n }\n //--------------------------\n // methods\n //--------------------------\n start() {\n let self = this;\n // new stuff\n new Animate().object({\n targets: document.getElementById('loader'),\n duration: 300,\n opacity: 0,\n easing: 'easeInOutQuad',\n complete: function () {\n document.getElementById('loader').style.display = 'none';\n document.getElementById('loader').style.visibility = 'hidden';\n new Animate().object({\n targets: document.getElementById('header'),\n duration: 10,\n opacity: 1,\n easing: 'easeInOutQuad',\n complete: function () {\n document.getElementById('loader').style.display = 'none';\n document.getElementById('loader').style.visibility = 'hidden';\n }\n });\n }\n });\n }\n\n chooseDisplay(section, page) {\n this.currentDisplay = '';\n switch (section) {\n case 'posts':\n this.currentDisplay = new PostEditor();\n break;\n \n default:\n // just chill\n break;\n }\n this.start();\n\n }\n //--------------------------\n // event handlers\n //--------------------------\n\n}\nexport {\n DisplayManager as\n default\n}","import DataUtils, {\n REQUEST_TYPE_GET,\n REQUEST_TYPE_PUT,\n REQUEST_TYPE_POST,\n REQUEST_TYPE_DELETE,\n CONTENT_TYPE_JSON,\n CONTENT_TYPE_FORM\n} from '../../../../brain/tools/utilities/DataUtils';\nimport * as DataEvent from '../../../../brain/tools/events/DataEvent.jsx';\nimport DisplayManager from './controllers/DisplayManager.jsx';\n\nexport default class Base {\n //--------------------------\n // constructor\n //--------------------------\n\n //TODO: Flip to unified structure defined in BMG, brah\n constructor() {\n var self = this;\n var admin = [];\n var folio = [];\n var displayManager = [];\n this.dataUtils = new DataUtils();\n this.settings = [];\n this.start();\n }\n start() {\n this.displayManager = new DisplayManager();\n }\n //--------------------------\n // methods\n //--------------------------\n loadSettings() {\n var self = this;\n this.dataUtils.request('/base-assets/data/settings.json', DataEvent.SETTINGS_LOADED)\n .then((response) => {\n this.settings = JSON.parse(response['request'].response);\n this.start();\n //transfer \n\n })\n .catch((err) => {\n //console.log(err);\n });\n }\n\n //--------------------------\n // event handlers\n //--------------------------\n\n}","import Base from './Base.jsx'\n\ndocument.addEventListener('DOMContentLoaded', function() {\n\n var base = new Base();\n}, false);\n"]} \ No newline at end of file diff --git a/themes/dash/post-edit.pug b/themes/dash/post-edit.pug index 603d902..886e779 100644 --- a/themes/dash/post-edit.pug +++ b/themes/dash/post-edit.pug @@ -7,7 +7,7 @@ block main-content -var post_tags = '' -var post_id = '' -var post_date = date - -var post_status = ['false', 'false', 'false', ''] + -var post_status = ['false', 'false', 'false',] if(edit) -post_title = post.title diff --git a/themes/dash/src/com/Base.jsx b/themes/dash/src/com/Base.js similarity index 77% rename from themes/dash/src/com/Base.jsx rename to themes/dash/src/com/Base.js index c9c9723..70c9bbb 100644 --- a/themes/dash/src/com/Base.jsx +++ b/themes/dash/src/com/Base.js @@ -1,12 +1,19 @@ -import DataUtils, { REQUEST_TYPE_GET, REQUEST_TYPE_PUT, REQUEST_TYPE_POST, REQUEST_TYPE_DELETE, CONTENT_TYPE_JSON, CONTENT_TYPE_FORM } from './tools/utilities/DataUtils.jsx'; -import * as DataEvent from './tools/events/DataEvent.jsx'; +import DataUtils, { + REQUEST_TYPE_GET, + REQUEST_TYPE_PUT, + REQUEST_TYPE_POST, + REQUEST_TYPE_DELETE, + CONTENT_TYPE_JSON, + CONTENT_TYPE_FORM +} from '../../../../brain/tools/utilities/DataUtils'; +import * as DataEvent from '../../../../brain/tools/events/DataEvent.jsx'; import DisplayManager from './controllers/DisplayManager.jsx'; export default class Base { //-------------------------- // constructor //-------------------------- - + //TODO: Flip to unified structure defined in BMG, brah constructor() { var self = this; @@ -15,7 +22,7 @@ export default class Base { var displayManager = []; this.dataUtils = new DataUtils(); this.settings = []; - this.start(); + this.start(); } start() { this.displayManager = new DisplayManager(); @@ -30,7 +37,7 @@ export default class Base { this.settings = JSON.parse(response['request'].response); this.start(); //transfer - + }) .catch((err) => { //console.log(err); @@ -41,4 +48,4 @@ export default class Base { // event handlers //-------------------------- -} +} \ No newline at end of file diff --git a/themes/dash/src/com/Start.jsx b/themes/dash/src/com/Start.js similarity index 100% rename from themes/dash/src/com/Start.jsx rename to themes/dash/src/com/Start.js diff --git a/themes/dash/src/com/actions/Mailer.jsx b/themes/dash/src/com/actions/Mailer.js similarity index 100% rename from themes/dash/src/com/actions/Mailer.jsx rename to themes/dash/src/com/actions/Mailer.js diff --git a/themes/dash/src/com/actions/PostActions.jsx b/themes/dash/src/com/actions/PostActions.js similarity index 79% rename from themes/dash/src/com/actions/PostActions.jsx rename to themes/dash/src/com/actions/PostActions.js index 7ba5c66..6a53384 100644 --- a/themes/dash/src/com/actions/PostActions.jsx +++ b/themes/dash/src/com/actions/PostActions.js @@ -1,6 +1,14 @@ -import DataUtils, { REQUEST_TYPE_GET, REQUEST_TYPE_PUT, REQUEST_TYPE_POST, REQUEST_TYPE_DELETE, CONTENT_TYPE_JSON, CONTENT_TYPE_FORM } from '../tools/utilities/DataUtils'; -import * as DataEvent from '../tools/events/DataEvent'; -import StringUtils from '../tools/utilities/StringUtils'; +import DataUtils, { + REQUEST_TYPE_GET, + REQUEST_TYPE_PUT, + REQUEST_TYPE_POST, + REQUEST_TYPE_DELETE, + CONTENT_TYPE_JSON, + CONTENT_TYPE_FORM +} from '../../../../../brain//tools/utilities/DataUtils'; +import * as DataEvent from '../../../../../brain//tools/events/DataEvent'; +import StringUtils from '../../../../../brain//tools/utilities/StringUtils'; + class PostActions { //-------------------------- // constructor @@ -16,7 +24,7 @@ class PostActions { submitPost(edit, uploadFiles) { let self = this; - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { //collect form data //if(!this.validateForm()) var postData = new FormData(); @@ -51,7 +59,7 @@ class PostActions { let postID = document.getElementById('edit-update').getAttribute('data-id'); postURL = "/api/post/update/" + postID; postEventType = DataEvent.POST_UPDATED; - + } else { postURL = "/api/post/add"; postEventType = DataEvent.POST_ADDED; @@ -62,32 +70,35 @@ class PostActions { response }) }).catch((err) => { - reject({ - err - }); - }) + reject({ + err + }); + }) }); } - deletePost(){ + deletePost() { let self = this; let postID = document.getElementById('edit-update').getAttribute('data-id'); - return new Promise(function(resolve, reject){ + return new Promise(function (resolve, reject) { self.dataUtils.request("/api/post/delete/" + postID, DataEvent.POST_DELETED, REQUEST_TYPE_POST, CONTENT_TYPE_FORM) .then((response) => { resolve({ response }) }).catch((err) => { - reject({ - err - }); - }) + reject({ + err + }); + }) }) //this.dataUtils.re } -//-------------------------- -// event handlers -//-------------------------- + //-------------------------- + // event handlers + //-------------------------- } -export { PostActions as default } +export { + PostActions as + default +} \ No newline at end of file diff --git a/themes/dash/src/com/actions/ProjectFolio.jsx b/themes/dash/src/com/actions/ProjectFolio.js similarity index 100% rename from themes/dash/src/com/actions/ProjectFolio.jsx rename to themes/dash/src/com/actions/ProjectFolio.js diff --git a/themes/dash/src/com/actions/TaskFipamo.jsx b/themes/dash/src/com/actions/TaskFipamo.js similarity index 100% rename from themes/dash/src/com/actions/TaskFipamo.jsx rename to themes/dash/src/com/actions/TaskFipamo.js diff --git a/themes/dash/src/com/actions/UserAuthentication.jsx b/themes/dash/src/com/actions/UserAuthentication.js similarity index 100% rename from themes/dash/src/com/actions/UserAuthentication.jsx rename to themes/dash/src/com/actions/UserAuthentication.js diff --git a/themes/dash/src/com/controllers/DisplayAdminFipamo.jsx b/themes/dash/src/com/controllers/DisplayAdminFipamo.js similarity index 100% rename from themes/dash/src/com/controllers/DisplayAdminFipamo.jsx rename to themes/dash/src/com/controllers/DisplayAdminFipamo.js diff --git a/themes/dash/src/com/controllers/DisplayAdminFolio.jsx b/themes/dash/src/com/controllers/DisplayAdminFolio.js similarity index 100% rename from themes/dash/src/com/controllers/DisplayAdminFolio.jsx rename to themes/dash/src/com/controllers/DisplayAdminFolio.js diff --git a/themes/dash/src/com/controllers/DisplayBlog.jsx b/themes/dash/src/com/controllers/DisplayBlog.js similarity index 100% rename from themes/dash/src/com/controllers/DisplayBlog.jsx rename to themes/dash/src/com/controllers/DisplayBlog.js diff --git a/themes/dash/src/com/controllers/DisplayClient.jsx b/themes/dash/src/com/controllers/DisplayClient.js similarity index 100% rename from themes/dash/src/com/controllers/DisplayClient.jsx rename to themes/dash/src/com/controllers/DisplayClient.js diff --git a/themes/dash/src/com/controllers/DisplayFi.jsx b/themes/dash/src/com/controllers/DisplayFi.js similarity index 100% rename from themes/dash/src/com/controllers/DisplayFi.jsx rename to themes/dash/src/com/controllers/DisplayFi.js diff --git a/themes/dash/src/com/controllers/DisplayIndex.jsx b/themes/dash/src/com/controllers/DisplayIndex.js similarity index 100% rename from themes/dash/src/com/controllers/DisplayIndex.jsx rename to themes/dash/src/com/controllers/DisplayIndex.js diff --git a/themes/dash/src/com/controllers/DisplayManager.jsx b/themes/dash/src/com/controllers/DisplayManager.js similarity index 90% rename from themes/dash/src/com/controllers/DisplayManager.jsx rename to themes/dash/src/com/controllers/DisplayManager.js index 0507718..9b7c6ae 100644 --- a/themes/dash/src/com/controllers/DisplayManager.jsx +++ b/themes/dash/src/com/controllers/DisplayManager.js @@ -6,9 +6,10 @@ import DataUtils, { REQUEST_TYPE_DELETE, CONTENT_TYPE_JSON, CONTENT_TYPE_FORM -} from '../tools/utilities/DataUtils.jsx'; +} from '../../../../../brain/tools/utilities/DataUtils'; import PostEditor from './PostEditor'; -import Animate from '../tools/effects/Animate.jsx'; +import Animate from '../../../../../brain/tools/effects/Animate.jsx'; + class DisplayManager { //-------------------------- // constructor @@ -17,15 +18,15 @@ class DisplayManager { this.dataUtils = new DataUtils(); this.currentDisplay = ''; this.urlPieces = document.URL.split("/"); - //grab url so system knows what to display + //grab url so system knows what to display this.chooseDisplay(this.urlPieces[5], this.urlPieces[6]); - } //-------------------------- // methods //-------------------------- start() { let self = this; + // new stuff new Animate().object({ targets: document.getElementById('loader'), duration: 300, @@ -50,7 +51,6 @@ class DisplayManager { chooseDisplay(section, page) { this.currentDisplay = ''; - //console.log(section+" "+page) switch (section) { case 'posts': this.currentDisplay = new PostEditor(); diff --git a/themes/dash/src/com/controllers/DisplayWork.jsx b/themes/dash/src/com/controllers/DisplayWork.js similarity index 100% rename from themes/dash/src/com/controllers/DisplayWork.jsx rename to themes/dash/src/com/controllers/DisplayWork.js diff --git a/themes/dash/src/com/controllers/PostEditor.js b/themes/dash/src/com/controllers/PostEditor.js new file mode 100644 index 0000000..32b5a3d --- /dev/null +++ b/themes/dash/src/com/controllers/PostEditor.js @@ -0,0 +1,274 @@ +//TOOLS +import DataUtils, +{ + REQUEST_TYPE_GET, + REQUEST_TYPE_PUT, + REQUEST_TYPE_POST, + REQUEST_TYPE_DELETE, + CONTENT_TYPE_JSON, + CONTENT_TYPE_FORM +} +from '../../../../../brain/tools/utilities/DataUtils'; +import * as DataEvent from '../../../../../brain/tools/events/DataEvent'; +import Animate from '../../../../../brain/tools/effects/Animate'; +import PostActions from '../actions/PostActions'; +import * as EditorEvent from '../../../../../brain/tools/events/EditorEvent'; +import TinyDatePicker from 'tiny-date-picker'; +import DateUtils from '../../../../../brain/tools/utilities/DateUtils'; +import TextEditor from '../../../../../brain/tools/ui/TextEditor'; +class PostEditor +{ + //-------------------------- + // constructor + //-------------------------- + constructor() + { + //reframe('iframe'); + let self = this; + this.uploadFiles; + this.anim = new Animate(); + this.dataUtils = new DataUtils(); + this.dateUtils = new DateUtils(); + if ( document.getElementById( 'edit-post-text' ) ) + { + this.editor = new TextEditor( document.getElementById( 'edit-post-text' ), document.getElementById( 'header' ).offsetHeight + document.getElementById( 'post-header' ).offsetHeight + document.getElementById( 'post-feature' ).offsetHeight ); + this.editor.addListener( EditorEvent.EDITOR_DELETE, f => this.handleEditorOptions( EditorEvent.EDITOR_DELETE ), false ) + this.editor.addListener( EditorEvent.EDITOR_UPLOAD_POST_IMAGE, f => this.handleEditorOptions( EditorEvent.EDITOR_UPLOAD_POST_IMAGE ), false ) + this.editor.addListener( EditorEvent.EDITOR_UPDATE, f => this.handleEditorOptions( EditorEvent.EDITOR_UPDATE ), false ) + this.editor.addListener( EditorEvent.EDITOR_SAVE, f => this.handleEditorOptions( EditorEvent.EDITOR_SAVE ), false ) + document.getElementById( 'post-image' ).addEventListener( 'change', e => this.handlePostImageAdd( e ), false ); + TinyDatePicker( document.getElementById( 'post-date' ), + { + mode: 'dp-below', + format( date ) + { + //return date; + return self.dateUtils.getDate( 'origin', date ); + } + } ); + } + this.start(); + } + //-------------------------- + // methods + //-------------------------- + start() + { + let self = this; + new Animate().object( + { + targets: document.getElementById( 'loader' ), + duration: 300, + opacity: 0, + easing: 'easeInOutQuad', + complete: function() + { + document.getElementById( 'loader' ).style.display = 'none'; + document.getElementById( 'loader' ).style.visibility = 'hidden'; + new Animate().object( + { + targets: document.getElementById( 'header' ), + duration: 10, + opacity: 1, + easing: 'easeInOutQuad', + complete: function() + { + if ( document.getElementById( 'the-intro' ) ) document.getElementById( 'the-intro' ).style.opacity = 1; + if ( document.getElementById( 'blog-entry' ) ) document.getElementById( 'blog-entry' ).style.opacity = 1; + } + } ); + } + } ); + if ( document.getElementById( 'featured-image-drop' ) ) + { + document.getElementById( 'featured-image-drop' ).addEventListener( 'dragover', this.handleDragOver, false ); + document.getElementById( 'featured-image-drop' ).addEventListener( 'drop', this.handleDrop, false ); + document.getElementById( 'featured-click' ).addEventListener( 'change', this.handleClicked, false ); + if ( document.getElementById( 'new-upload-link' ) ) + { + document.getElementById( 'new-upload-link' ).addEventListener( 'click', e => + { + document.getElementById( 'featured-click' ).click(); + } ) + } + 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; + switch ( e.target.id ) + { + case "option-page-icon": + case "option-page": + currentOption = document.getElementById( 'option-page' ); + 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; + } + let active = currentOption.getAttribute( 'data-active' ); + ( active == 'false' ) ? currentOption.setAttribute( 'data-active', 'true' ): currentOption.setAttribute( 'data-active', 'false' ) + } + handleEditorOptions( e ) + { + switch ( e ) + { + case EditorEvent.EDITOR_SAVE: + case EditorEvent.EDITOR_UPDATE: + let edit = false; + if ( e == EditorEvent.EDITOR_UPDATE ) edit = true; + new PostActions().submitPost( edit, PostEditor.uploadFiles ).then( ( response ) => + { + let note = JSON.parse( response[ 'response' ][ 'request' ].response ); + this.editor.notify( note.message, note.postID ); + if ( note.message == DataEvent.POST_ADDED ) window.location = "/@/dashboard/posts/edit/" + note.postID; + } ).catch( ( err ) => + { + console.log( err ) + } ); + break; + case EditorEvent.EDITOR_DELETE: + if ( confirm( 'Aye! You know you\'re deleting this post, right?' ) ) + { + new PostActions().deletePost().then( ( response ) => + { + let note = JSON.parse( response[ 'response' ][ 'request' ].response ); + window.location = "/@/dashboard/posts/"; + //console.log(note); + } ).catch( ( err ) => + { + console.log( err ) + } ); + } + else + { + // Do nothing! + } + break; + case EditorEvent.EDITOR_UPLOAD_POST_IMAGE: + document.getElementById( 'post-image' ).click(); + break; + } + } + handleDragOver( e ) + { + e.stopPropagation(); + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy. + } + handleClicked( e ) + { + e.stopPropagation(); + e.preventDefault(); + //console.log("IMAGES " + e.target.files); + PostEditor.uploadFiles = e.target.files; + for ( var i = 0, f; f = PostEditor.uploadFiles[ i ]; i++ ) + { + // Only process image files. + if ( !f.type.match( 'image.*' ) ) + { + continue; + } + var reader = new FileReader(); + // Closure to capture the file information. + reader.onload = ( function( theFile ) + { + return function( f ) + { + // Render thumbnail. + var image = document.createElement( 'img' ); + image.src = f.target.result; + image.title = escape( theFile.name ); + var span = document.createElement( 'div' ); + span.innerHTML = [ '' + ].join( '' ); + //document.getElementById('featured-image-drop').insertBefore(span, null); + document.getElementById( 'featured-image-drop' ).innerHTML = ''; + document.getElementById( 'featured-image-drop' ).appendChild( image ); + }; + } )( f ); + // Read in the image file as a data URL. + reader.readAsDataURL( f ); + } + } + handleDrop( e ) + { + e.stopPropagation(); + e.preventDefault(); + PostEditor.uploadFiles = e.dataTransfer.files; + //console.log(MemberArea.uploadFiles.length); + for ( var i = 0, f; f = PostEditor.uploadFiles[ i ]; i++ ) + { + // Only process image files. + if ( !f.type.match( 'image.*' ) ) + { + continue; + } + var reader = new FileReader(); + // Closure to capture the file information. + reader.onload = ( function( theFile ) + { + return function( f ) + { + // Render thumbnail. + var span = document.createElement( 'span' ); + span.innerHTML = [ '' + ].join( '' ); + //document.getElementById('featured-image-drop').insertBefore(span, null); + document.getElementById( 'featured-image-drop' ).innerHTML = ''; + document.getElementById( 'featured-image-drop' ).appendChild( span ); + }; + } )( f ); + // Read in the image file as a data URL. + reader.readAsDataURL( f ); + } + } + handlePostImageAdd( e ) + { + e.stopPropagation(); + e.preventDefault(); + let self = this; + var postData = new FormData(); + var files = e.target.files; + for ( var i = 0; i < files.length; i++ ) + { + var file = files[ i ]; + // Check the file type. + if ( !file.type.match( 'image.*' ) ) + { + continue; + } + postData.append( 'post_image', file, file.name ); + } + this.dataUtils.request( "/api/blog/add-post-image", DataEvent.POST_IMAGE_ADDED, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, postData ).then( ( response ) => + { + self.editor.notify( EditorEvent.EDITOR_UPLOAD_POST_IMAGE, JSON.parse( response.request[ 'response' ] ).url ); + } ).catch( ( err ) => + { + console.log( err ) + } ) + } +} +PostEditor.uploadFiles = []; +export +{ + PostEditor as + default +} \ No newline at end of file diff --git a/themes/dash/src/com/controllers/PostEditor.jsx b/themes/dash/src/com/controllers/PostEditor.jsx deleted file mode 100644 index 7711708..0000000 --- a/themes/dash/src/com/controllers/PostEditor.jsx +++ /dev/null @@ -1,263 +0,0 @@ -//TOOLS -import DataUtils, { - REQUEST_TYPE_GET, - REQUEST_TYPE_PUT, - REQUEST_TYPE_POST, - REQUEST_TYPE_DELETE, - CONTENT_TYPE_JSON, - CONTENT_TYPE_FORM -} from '../tools/utilities/DataUtils'; -import * as DataEvent from '../tools/events/DataEvent'; -import Animate from '../tools/effects/Animate'; -import * as Ease from '../tools/effects/Animate'; -import PostActions from '../actions/PostActions'; -import * as EditorEvent from '../tools/events/EditorEvent'; -import TextEditor from '../tools/utilities/TextEditor'; -import TinyDatePicker from 'tiny-date-picker'; -import DateUtils from '../tools/utilities/DateUtils'; - - -class PostEditor { - //-------------------------- - // constructor - //-------------------------- - constructor() { - reframe('iframe'); - let self = this; - this.uploadFiles; - this.dataUtils = new DataUtils(); - this.dateUtils = new DateUtils(); - if (document.getElementById('edit-post-text')) { - this.editor = new TextEditor(document.getElementById('edit-post-text'), - document.getElementById('header').offsetHeight + - document.getElementById('post-header').offsetHeight + - document.getElementById('post-feature').offsetHeight - ); - this.editor.addListener(EditorEvent.EDITOR_DELETE, f => this.handleEditorOptions(EditorEvent.EDITOR_DELETE), false) - this.editor.addListener(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPLOAD_POST_IMAGE), false) - this.editor.addListener(EditorEvent.EDITOR_UPDATE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPDATE), false) - this.editor.addListener(EditorEvent.EDITOR_SAVE, f => this.handleEditorOptions(EditorEvent.EDITOR_SAVE), false) - document.getElementById('post-image').addEventListener('change', e => this.handlePostImageAdd(e), false); - TinyDatePicker(document.getElementById('post-date'), { - mode: 'dp-below', - format(date) { - //return date; - return self.dateUtils.getDate('origin', date); - } - }); - } - this.start(); - } - //-------------------------- - // methods - //-------------------------- - start() { - let self = this; - new Animate().object({ - targets: document.getElementById('loader'), - duration: 300, - opacity: 0, - easing: 'easeInOutQuad', - complete: function () { - document.getElementById('loader').style.display = 'none'; - document.getElementById('loader').style.visibility = 'hidden'; - new Animate().object({ - targets: document.getElementById('header'), - duration: 10, - opacity: 1, - easing: 'easeInOutQuad', - complete: function () { - if (document.getElementById('the-intro')) - document.getElementById('the-intro').style.opacity = 1; - if (document.getElementById('blog-entry')) - document.getElementById('blog-entry').style.opacity = 1; - } - }); - } - }); - - if (document.getElementById('featured-image-drop')) { - document.getElementById('featured-image-drop').addEventListener('dragover', this.handleDragOver, false); - document.getElementById('featured-image-drop').addEventListener('drop', this.handleDrop, false); - document.getElementById('featured-click').addEventListener('change', this.handleClicked, false); - - if (document.getElementById('new-upload-link')) { - document.getElementById('new-upload-link').addEventListener('click', e => { - document.getElementById('featured-click').click(); - }) - } - - 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; - switch (e.target.id) { - case "option-page-icon": - case "option-page": - currentOption = document.getElementById('option-page'); - 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; - } - - let active = currentOption.getAttribute('data-active'); - - (active == 'false') ? currentOption.setAttribute('data-active', 'true') : currentOption.setAttribute('data-active', 'false') - - } - handleEditorOptions(e) { - switch (e) { - case EditorEvent.EDITOR_SAVE: - case EditorEvent.EDITOR_UPDATE: - let edit = false; - if (e == EditorEvent.EDITOR_UPDATE) - edit = true; - new PostActions().submitPost(edit, PostEditor.uploadFiles).then((response) => { - let note = JSON.parse(response['response']['request'].response); - this.editor.notify(note.message, note.postID); - if (note.message == DataEvent.POST_ADDED) - window.location = "/@/dashboard/posts/edit/" + note.postID; - }).catch((err) => { - console.log(err) - }); - break; - - case EditorEvent.EDITOR_DELETE: - - if (confirm('Aye! You know you\'re deleting this post, right?')) { - new PostActions().deletePost().then((response) => { - let note = JSON.parse(response['response']['request'].response); - window.location = "/@/dashboard/posts/"; - //console.log(note); - }).catch((err) => { - console.log(err) - }); - } else { - // Do nothing! - } - break; - - case EditorEvent.EDITOR_UPLOAD_POST_IMAGE: - document.getElementById('post-image').click(); - break; - } - } - - handleDragOver(e) { - e.stopPropagation(); - e.preventDefault(); - e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy. - } - handleClicked(e) { - e.stopPropagation(); - e.preventDefault(); - //console.log("IMAGES " + e.target.files); - PostEditor.uploadFiles = e.target.files; - for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) { - // Only process image files. - if (!f.type.match('image.*')) { - continue; - } - var reader = new FileReader(); - // Closure to capture the file information. - reader.onload = (function (theFile) { - return function (f) { - // Render thumbnail. - var image = document.createElement('img'); - image.src = f.target.result; - image.title = escape(theFile.name); - var span = document.createElement('div'); - span.innerHTML = [ - '' - ].join(''); - //document.getElementById('featured-image-drop').insertBefore(span, null); - document.getElementById('featured-image-drop').innerHTML = ''; - document.getElementById('featured-image-drop').appendChild(image); - }; - })(f); - // Read in the image file as a data URL. - reader.readAsDataURL(f); - } - - } - - handleDrop(e) { - e.stopPropagation(); - e.preventDefault(); - PostEditor.uploadFiles = e.dataTransfer.files; - //console.log(MemberArea.uploadFiles.length); - for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) { - // Only process image files. - if (!f.type.match('image.*')) { - continue; - } - var reader = new FileReader(); - // Closure to capture the file information. - reader.onload = (function (theFile) { - return function (f) { - // Render thumbnail. - var span = document.createElement('span'); - span.innerHTML = [ - '' - ].join(''); - //document.getElementById('featured-image-drop').insertBefore(span, null); - document.getElementById('featured-image-drop').innerHTML = ''; - document.getElementById('featured-image-drop').appendChild(span); - }; - })(f); - // Read in the image file as a data URL. - reader.readAsDataURL(f); - } - } - - handlePostImageAdd(e) { - e.stopPropagation(); - e.preventDefault(); - let self = this; - - var postData = new FormData(); - var files = e.target.files; - for (var i = 0; i < files.length; i++) { - var file = files[i]; - // Check the file type. - if (!file.type.match('image.*')) { - continue; - } - postData.append('post_image', file, file.name); - } - this.dataUtils.request("/api/blog/add-post-image", DataEvent.POST_IMAGE_ADDED, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, postData) - .then((response) => { - self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, JSON.parse(response.request['response']).url); - }).catch((err) => { - console.log(err) - }) - } -} -PostEditor.uploadFiles = []; -export { - PostEditor as - default -} \ No newline at end of file diff --git a/themes/dash/src/com/controllers/PostIndex.jsx b/themes/dash/src/com/controllers/PostIndex.js similarity index 100% rename from themes/dash/src/com/controllers/PostIndex.jsx rename to themes/dash/src/com/controllers/PostIndex.js