diff --git a/package-lock.json b/package-lock.json index 06fbf40c..7b3b39b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2,9 +2,6 @@ "requires": true, "lockfileVersion": 1, "dependencies": { - "Leaflet.Geodesic": { - "version": "git+https://git@github.com/henrythasler/Leaflet.Geodesic.git#c5dd6d6a0ee394d0c274d2a3a09d69a11fc11b8b" - }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -1203,14 +1200,6 @@ "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-3.3.7.tgz", "integrity": "sha1-WjiTlFSfIzMIdaOxUGVldPip63E=" }, - "bootstrap-datepicker": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/bootstrap-datepicker/-/bootstrap-datepicker-1.7.1.tgz", - "integrity": "sha1-Tuf680iI2+x4NPv52+fEJ34B3a8=", - "requires": { - "jquery": "3.2.1" - } - }, "bootstrap-sass": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/bootstrap-sass/-/bootstrap-sass-3.3.7.tgz", @@ -5481,6 +5470,11 @@ "resolved": "https://registry.npmjs.org/jquery-mousewheel/-/jquery-mousewheel-3.1.13.tgz", "integrity": "sha1-BvAzXxbjU6aV5yBr9QUDy1I6buU=" }, + "jquery-pjax": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jquery-pjax/-/jquery-pjax-2.0.1.tgz", + "integrity": "sha1-azoboW5kTmJL3P5y62s9lqhG9fI=" + }, "js-base64": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.0.tgz", diff --git a/package.json b/package.json index d9b4bed4..d94c1bff 100755 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "eonasdan-bootstrap-datetimepicker": "^4.17.47", "icheck": "^1.0.2", "jquery": "^3.2.1", + "jquery-pjax": "^2.0.1", "laravel-mix": "^1.0", "leaflet": "^1.2.0", "leaflet-ajax": "2.1.0", diff --git a/public/assets/admin/css/clear.png b/public/assets/admin/css/clear.png new file mode 100644 index 00000000..580b52a5 Binary files /dev/null and b/public/assets/admin/css/clear.png differ diff --git a/public/assets/admin/css/loading.gif b/public/assets/admin/css/loading.gif new file mode 100644 index 00000000..5b33f7e5 Binary files /dev/null and b/public/assets/admin/css/loading.gif differ diff --git a/public/assets/admin/js/vendor.js b/public/assets/admin/js/vendor.js index 8804f691..c58f0979 100644 --- a/public/assets/admin/js/vendor.js +++ b/public/assets/admin/js/vendor.js @@ -34046,790 +34046,6 @@ S2.define('jquery.select2',[ } })(window.jQuery || window.Zepto); -!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Pjax=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o) - var htmlRegex = /]+>/gi - var htmlAttribsRegex = /\s?[a-z:]+(?:\=(?:\'|\")[^\'\">]+(?:\'|\"))*/gi - var matches = html.match(htmlRegex) - if (matches && matches.length) { - matches = matches[0].match(htmlAttribsRegex) - if (matches.length) { - matches.shift() - matches.forEach(function(htmlAttrib) { - var attr = htmlAttrib.trim().split("=") - if (attr.length === 1) { - tmpEl.documentElement.setAttribute(attr[0], true) - } - else { - tmpEl.documentElement.setAttribute(attr[0], attr[1].slice(1, -1)) - } - }) - } - } - - tmpEl.documentElement.innerHTML = html - this.log("load content", tmpEl.documentElement.attributes, tmpEl.documentElement.innerHTML.length) - - // Clear out any focused controls before inserting new page contents. - // we clear focus on non form elements - if (document.activeElement && !document.activeElement.value) { - try { - document.activeElement.blur() - } catch (e) { } - } - - // try { - this.switchSelectors(this.options.selectors, tmpEl, document, options) - - // FF bug: Won’t autofocus fields that are inserted via JS. - // This behavior is incorrect. So if theres no current focus, autofocus - // the last field. - // - // http://www.w3.org/html/wg/drafts/html/master/forms.html - var autofocusEl = Array.prototype.slice.call(document.querySelectorAll("[autofocus]")).pop() - if (autofocusEl && document.activeElement !== autofocusEl) { - autofocusEl.focus(); - } - - // execute scripts when DOM have been completely updated - this.options.selectors.forEach(function(selector) { - forEachEls(document.querySelectorAll(selector), function(el) { - executeScripts(el) - }) - }) - // } - // catch(e) { - // if (this.options.debug) { - // this.log("Pjax switch fail: ", e) - // } - // this.switchFallback(tmpEl, document) - // } - }, - - doRequest: _dereq_("./lib/request.js"), - - loadUrl: function(href, options) { - this.log("load href", href, options) - - trigger(document, "pjax:send", options); - - // Do the request - this.doRequest(href, function(html) { - // Fail if unable to load HTML via AJAX - if (html === false) { - trigger(document,"pjax:complete pjax:error", options) - - return - } - - // Clear out any focused controls before inserting new page contents. - document.activeElement.blur() - - try { - this.loadContent(html, options) - } - catch (e) { - if (!this.options.debug) { - if (console && console.error) { - console.error("Pjax switch fail: ", e) - } - this.latestChance(href) - return - } - else { - throw e - } - } - - if (options.history) { - if (this.firstrun) { - this.lastUid = this.maxUid = newUid() - this.firstrun = false - window.history.replaceState({ - url: window.location.href, - title: document.title, - uid: this.maxUid - }, - document.title) - } - - // Update browser history - this.lastUid = this.maxUid = newUid() - window.history.pushState({ - url: href, - title: options.title, - uid: this.maxUid - }, - options.title, - href) - } - - this.forEachSelectors(function(el) { - this.parseDOM(el) - }, this) - - // Fire Events - trigger(document,"pjax:complete pjax:success", options) - - options.analytics() - - // Scroll page to top on new page load - if (options.scrollTo !== false) { - if (options.scrollTo.length > 1) { - window.scrollTo(options.scrollTo[0], options.scrollTo[1]) - } - else { - window.scrollTo(0, options.scrollTo) - } - } - }.bind(this)) - } -} - -Pjax.isSupported = _dereq_("./lib/is-supported.js"); - -//arguably could do `if( require("./lib/is-supported.js")()) {` but that might be a little to simple -if (Pjax.isSupported()) { - module.exports = Pjax -} -// if there isn’t required browser functions, returning stupid api -else { - var stupidPjax = function() {} - for (var key in Pjax.prototype) { - if (Pjax.prototype.hasOwnProperty(key) && typeof Pjax.prototype[key] === "function") { - stupidPjax[key] = stupidPjax - } - } - - module.exports = stupidPjax -} - -},{"./lib/clone.js":2,"./lib/events/on.js":4,"./lib/events/trigger.js":5,"./lib/execute-scripts.js":6,"./lib/foreach-els.js":7,"./lib/foreach-selectors.js":8,"./lib/is-supported.js":9,"./lib/proto/attach-link.js":11,"./lib/proto/get-elements.js":12,"./lib/proto/log.js":13,"./lib/proto/parse-dom.js":14,"./lib/proto/parse-options.js":16,"./lib/proto/refresh.js":17,"./lib/reload.js":18,"./lib/request.js":19,"./lib/switches-selectors.js":20,"./lib/uniqueid.js":22}],2:[function(_dereq_,module,exports){ -module.exports = function(obj) { - if (null === obj || "object" != typeof obj) { - return obj - } - var copy = obj.constructor() - for (var attr in obj) { - if (obj.hasOwnProperty(attr)) { - copy[attr] = obj[attr] - } - } - return copy -} - -},{}],3:[function(_dereq_,module,exports){ -module.exports = function(el) { - // console.log("going to execute script", el) - - var code = (el.text || el.textContent || el.innerHTML || "") - var head = document.querySelector("head") || document.documentElement - var script = document.createElement("script") - - if (code.match("document.write")) { - if (console && console.log) { - console.log("Script contains document.write. Can’t be executed correctly. Code skipped ", el) - } - return false - } - - script.type = "text/javascript" - try { - script.appendChild(document.createTextNode(code)) - } - catch (e) { - // old IEs have funky script nodes - script.text = code - } - - // execute - head.insertBefore(script, head.firstChild) - head.removeChild(script) // avoid pollution - - return true -} - -},{}],4:[function(_dereq_,module,exports){ -var forEachEls = _dereq_("../foreach-els") - -module.exports = function(els, events, listener, useCapture) { - events = (typeof events === "string" ? events.split(" ") : events) - - events.forEach(function(e) { - forEachEls(els, function(el) { - el.addEventListener(e, listener, useCapture) - }) - }) -} - -},{"../foreach-els":7}],5:[function(_dereq_,module,exports){ -var forEachEls = _dereq_("../foreach-els") - -module.exports = function(els, events, opts) { - events = (typeof events === "string" ? events.split(" ") : events) - - events.forEach(function(e) { - var event // = new CustomEvent(e) // doesn't everywhere yet - event = document.createEvent("HTMLEvents") - event.initEvent(e, true, true) - event.eventName = e - if (opts) { - Object.keys(opts).forEach(function(key) { - event[key] = opts[key] - }) - } - - forEachEls(els, function(el) { - var domFix = false - if (!el.parentNode && el !== document && el !== window) { - // THANKS YOU IE (9/10//11 concerned) - // dispatchEvent doesn't work if element is not in the dom - domFix = true - document.body.appendChild(el) - } - el.dispatchEvent(event) - if (domFix) { - el.parentNode.removeChild(el) - } - }) - }) -} - -},{"../foreach-els":7}],6:[function(_dereq_,module,exports){ -var forEachEls = _dereq_("./foreach-els") -var evalScript = _dereq_("./eval-script") -// Finds and executes scripts (used for newly added elements) -// Needed since innerHTML does not run scripts -module.exports = function(el) { - // console.log("going to execute scripts for ", el) - forEachEls(el.querySelectorAll("script"), function(script) { - if (!script.type || script.type.toLowerCase() === "text/javascript") { - if (script.parentNode) { - script.parentNode.removeChild(script) - } - evalScript(script) - } - }) -} - -},{"./eval-script":3,"./foreach-els":7}],7:[function(_dereq_,module,exports){ -/* global HTMLCollection: true */ - -module.exports = function(els, fn, context) { - if (els instanceof HTMLCollection || els instanceof NodeList || els instanceof Array) { - return Array.prototype.forEach.call(els, fn, context) - } - // assume simple dom element - return fn.call(context, els) -} - -},{}],8:[function(_dereq_,module,exports){ -var forEachEls = _dereq_("./foreach-els") - -module.exports = function(selectors, cb, context, DOMcontext) { - DOMcontext = DOMcontext || document - selectors.forEach(function(selector) { - forEachEls(DOMcontext.querySelectorAll(selector), cb, context) - }) -} - -},{"./foreach-els":7}],9:[function(_dereq_,module,exports){ -module.exports = function() { - // Borrowed wholesale from https://github.com/defunkt/jquery-pjax - return window.history && - window.history.pushState && - window.history.replaceState && - // pushState isn’t reliable on iOS until 5. - !navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/) -} - -},{}],10:[function(_dereq_,module,exports){ -if (!Function.prototype.bind) { - Function.prototype.bind = function(oThis) { - if (typeof this !== "function") { - // closest thing possible to the ECMAScript 5 internal IsCallable function - throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable") - } - - var aArgs = Array.prototype.slice.call(arguments, 1) - var that = this - var Fnoop = function() {} - var fBound = function() { - return that.apply(this instanceof Fnoop && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))) - } - - Fnoop.prototype = this.prototype - fBound.prototype = new Fnoop() - - return fBound - } -} - -},{}],11:[function(_dereq_,module,exports){ -_dereq_("../polyfills/Function.prototype.bind") - -var on = _dereq_("../events/on") -var clone = _dereq_("../clone") - -var attrClick = "data-pjax-click-state" -var attrKey = "data-pjax-keyup-state" - -var linkAction = function(el, event) { - // Don’t break browser special behavior on links (like page in new window) - if (event.which > 1 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) { - el.setAttribute(attrClick, "modifier") - return - } - - // we do test on href now to prevent unexpected behavior if for some reason - // user have href that can be dynamically updated - - // Ignore external links. - if (el.protocol !== window.location.protocol || el.host !== window.location.host) { - el.setAttribute(attrClick, "external") - return - } - - // Ignore click if we are on an anchor on the same page - if (el.pathname === window.location.pathname && el.hash.length > 0) { - el.setAttribute(attrClick, "anchor-present") - return - } - - // Ignore anchors on the same page (keep native behavior) - if (el.hash && el.href.replace(el.hash, "") === window.location.href.replace(location.hash, "")) { - el.setAttribute(attrClick, "anchor") - return - } - - // Ignore empty anchor "foo.html#" - if (el.href === window.location.href.split("#")[0] + "#") { - el.setAttribute(attrClick, "anchor-empty") - return - } - - event.preventDefault() - - // don’t do "nothing" if user try to reload the page by clicking the same link twice - if ( - this.options.currentUrlFullReload && - el.href === window.location.href.split("#")[0] - ) { - el.setAttribute(attrClick, "reload") - this.reload() - return - } - - el.setAttribute(attrClick, "load") - this.loadUrl(el.href, clone(this.options)) -} - -var isDefaultPrevented = function(event) { - return event.defaultPrevented || event.returnValue === false; -} - -module.exports = function(el) { - var that = this - - on(el, "click", function(event) { - if (isDefaultPrevented(event)) { - return - } - - linkAction.call(that, el, event) - }) - - on(el, "keyup", function(event) { - if (isDefaultPrevented(event)) { - return - } - - // Don’t break browser special behavior on links (like page in new window) - if (event.which > 1 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) { - el.setAttribute(attrKey, "modifier") - return - } - - if (event.keyCode == 13) { - linkAction.call(that, el, event) - } - }.bind(this)) -} - -},{"../clone":2,"../events/on":4,"../polyfills/Function.prototype.bind":10}],12:[function(_dereq_,module,exports){ -module.exports = function(el) { - return el.querySelectorAll(this.options.elements) -} - -},{}],13:[function(_dereq_,module,exports){ -module.exports = function() { - if (this.options.debug && console) { - if (typeof console.log === "function") { - console.log.apply(console, arguments); - } - // ie is weird - else if (console.log) { - console.log(arguments); - } - } -} - -},{}],14:[function(_dereq_,module,exports){ -var forEachEls = _dereq_("../foreach-els") - -var parseElement = _dereq_("./parse-element") - -module.exports = function(el) { - forEachEls(this.getElements(el), parseElement, this) -} - -},{"../foreach-els":7,"./parse-element":15}],15:[function(_dereq_,module,exports){ -module.exports = function(el) { - switch (el.tagName.toLowerCase()) { - case "a": - // only attach link if el does not already have link attached - if (!el.hasAttribute('data-pjax-click-state')) { - this.attachLink(el) - } - break - - case "form": - throw "Pjax doesnt support
yet." - break - - default: - throw "Pjax can only be applied on or submit" - } -} - -},{}],16:[function(_dereq_,module,exports){ -/* global _gaq: true, ga: true */ - -module.exports = function(options){ - this.options = options - this.options.elements = this.options.elements || "a[href], form[action]" - this.options.selectors = this.options.selectors || ["title", ".js-Pjax"] - this.options.switches = this.options.switches || {} - this.options.switchesOptions = this.options.switchesOptions || {} - this.options.history = this.options.history || true - this.options.analytics = this.options.analytics || function() { - // options.backward or options.foward can be true or undefined - // by default, we do track back/foward hit - // https://productforums.google.com/forum/#!topic/analytics/WVwMDjLhXYk - if (window._gaq) { - _gaq.push(["_trackPageview"]) - } - if (window.ga) { - ga("send", "pageview", {page: location.pathname, title: document.title}) - } - } - this.options.scrollTo = (typeof this.options.scrollTo === 'undefined') ? 0 : this.options.scrollTo; - this.options.cacheBust = (typeof this.options.cacheBust === 'undefined') ? true : this.options.cacheBust - this.options.debug = this.options.debug || false - - // we can’t replace body.outerHTML or head.outerHTML - // it create a bug where new body or new head are created in the dom - // if you set head.outerHTML, a new body tag is appended, so the dom get 2 body - // & it break the switchFallback which replace head & body - if (!this.options.switches.head) { - this.options.switches.head = this.switchElementsAlt - } - if (!this.options.switches.body) { - this.options.switches.body = this.switchElementsAlt - } - if (typeof options.analytics !== "function") { - options.analytics = function() {} - } -} -},{}],17:[function(_dereq_,module,exports){ -module.exports = function(el) { - this.parseDOM(el || document) -} - -},{}],18:[function(_dereq_,module,exports){ -module.exports = function() { - window.location.reload() -} - -},{}],19:[function(_dereq_,module,exports){ -module.exports = function(location, callback) { - var request = new XMLHttpRequest() - - request.onreadystatechange = function() { - if (request.readyState === 4) { - if (request.status === 200) { - callback(request.responseText, request) - } - else { - callback(null, request) - } - } - } - - // Add a timestamp as part of the query string if cache busting is enabled - if (this.options.cacheBust) { - location += (!/[?&]/.test(location) ? "?" : "&") + new Date().getTime() - } - - request.open("GET", location, true) - request.setRequestHeader("X-Requested-With", "XMLHttpRequest") - request.send(null) - return request -} - -},{}],20:[function(_dereq_,module,exports){ -var forEachEls = _dereq_("./foreach-els") - -var defaultSwitches = _dereq_("./switches") - -module.exports = function(switches, switchesOptions, selectors, fromEl, toEl, options) { - selectors.forEach(function(selector) { - var newEls = fromEl.querySelectorAll(selector) - var oldEls = toEl.querySelectorAll(selector) - if (this.log) { - this.log("Pjax switch", selector, newEls, oldEls) - } - if (newEls.length !== oldEls.length) { - // forEachEls(newEls, function(el) { - // this.log("newEl", el, el.outerHTML) - // }, this) - // forEachEls(oldEls, function(el) { - // this.log("oldEl", el, el.outerHTML) - // }, this) - throw "DOM doesn’t look the same on new loaded page: ’" + selector + "’ - new " + newEls.length + ", old " + oldEls.length - } - - forEachEls(newEls, function(newEl, i) { - var oldEl = oldEls[i] - if (this.log) { - this.log("newEl", newEl, "oldEl", oldEl) - } - if (switches[selector]) { - switches[selector].bind(this)(oldEl, newEl, options, switchesOptions[selector]) - } - else { - defaultSwitches.outerHTML.bind(this)(oldEl, newEl, options) - } - }, this) - }, this) -} - -},{"./foreach-els":7,"./switches":21}],21:[function(_dereq_,module,exports){ -var on = _dereq_("./events/on.js") -// var off = require("./lib/events/on.js") -// var trigger = require("./lib/events/trigger.js") - - -module.exports = { - outerHTML: function(oldEl, newEl) { - oldEl.outerHTML = newEl.outerHTML - this.onSwitch() - }, - - innerHTML: function(oldEl, newEl) { - oldEl.innerHTML = newEl.innerHTML - oldEl.className = newEl.className - this.onSwitch() - }, - - sideBySide: function(oldEl, newEl, options, switchOptions) { - var forEach = Array.prototype.forEach - var elsToRemove = [] - var elsToAdd = [] - var fragToAppend = document.createDocumentFragment() - // height transition are shitty on safari - // so commented for now (until I found something ?) - // var relevantHeight = 0 - var animationEventNames = "animationend webkitAnimationEnd MSAnimationEnd oanimationend" - var animatedElsNumber = 0 - var sexyAnimationEnd = function(e) { - if (e.target != e.currentTarget) { - // end triggered by an animation on a child - return - } - - animatedElsNumber-- - if (animatedElsNumber <= 0 && elsToRemove) { - elsToRemove.forEach(function(el) { - // browsing quickly can make the el - // already removed by last page update ? - if (el.parentNode) { - el.parentNode.removeChild(el) - } - }) - - elsToAdd.forEach(function(el) { - el.className = el.className.replace(el.getAttribute("data-pjax-classes"), "") - el.removeAttribute("data-pjax-classes") - // Pjax.off(el, animationEventNames, sexyAnimationEnd, true) - }) - - elsToAdd = null // free memory - elsToRemove = null // free memory - - // assume the height is now useless (avoid bug since there is overflow hidden on the parent) - // oldEl.style.height = "auto" - - // this is to trigger some repaint (example: picturefill) - this.onSwitch() - // Pjax.trigger(window, "scroll") - } - }.bind(this) - - // Force height to be able to trigger css animation - // here we get the relevant height - // oldEl.parentNode.appendChild(newEl) - // relevantHeight = newEl.getBoundingClientRect().height - // oldEl.parentNode.removeChild(newEl) - // oldEl.style.height = oldEl.getBoundingClientRect().height + "px" - - switchOptions = switchOptions || {} - - forEach.call(oldEl.childNodes, function(el) { - elsToRemove.push(el) - if (el.classList && !el.classList.contains("js-Pjax-remove")) { - // for fast switch, clean element that just have been added, & not cleaned yet. - if (el.hasAttribute("data-pjax-classes")) { - el.className = el.className.replace(el.getAttribute("data-pjax-classes"), "") - el.removeAttribute("data-pjax-classes") - } - el.classList.add("js-Pjax-remove") - if (switchOptions.callbacks && switchOptions.callbacks.removeElement) { - switchOptions.callbacks.removeElement(el) - } - if (switchOptions.classNames) { - el.className += " " + switchOptions.classNames.remove + " " + (options.backward ? switchOptions.classNames.backward : switchOptions.classNames.forward) - } - animatedElsNumber++ - on(el, animationEventNames, sexyAnimationEnd, true) - } - }) - - forEach.call(newEl.childNodes, function(el) { - if (el.classList) { - var addClasses = "" - if (switchOptions.classNames) { - addClasses = " js-Pjax-add " + switchOptions.classNames.add + " " + (options.backward ? switchOptions.classNames.forward : switchOptions.classNames.backward) - } - if (switchOptions.callbacks && switchOptions.callbacks.addElement) { - switchOptions.callbacks.addElement(el) - } - el.className += addClasses - el.setAttribute("data-pjax-classes", addClasses) - elsToAdd.push(el) - fragToAppend.appendChild(el) - animatedElsNumber++ - on(el, animationEventNames, sexyAnimationEnd, true) - } - }) - - // pass all className of the parent - oldEl.className = newEl.className - oldEl.appendChild(fragToAppend) - - // oldEl.style.height = relevantHeight + "px" - } -} - -},{"./events/on.js":4}],22:[function(_dereq_,module,exports){ -module.exports = (function() { - var counter = 0 - return function() { - var id = ("pjax" + (new Date().getTime())) + "_" + counter - counter++ - return id - } -})() - -},{}]},{},[1]) -(1) -}); /*! X-editable - v1.5.1 * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * http://github.com/vitalets/x-editable @@ -44273,3 +43489,907 @@ Automatically shown in inline mode. return $.fn.datetimepicker; })); + +/*! + * Copyright 2012, Chris Wanstrath + * Released under the MIT License + * https://github.com/defunkt/jquery-pjax + */ + +(function($){ + +// When called on a container with a selector, fetches the href with +// ajax into the container or with the data-pjax attribute on the link +// itself. +// +// Tries to make sure the back button and ctrl+click work the way +// you'd expect. +// +// Exported as $.fn.pjax +// +// Accepts a jQuery ajax options object that may include these +// pjax specific options: +// +// +// container - String selector for the element where to place the response body. +// push - Whether to pushState the URL. Defaults to true (of course). +// replace - Want to use replaceState instead? That's cool. +// +// For convenience the second parameter can be either the container or +// the options object. +// +// Returns the jQuery object +function fnPjax(selector, container, options) { + options = optionsFor(container, options) + return this.on('click.pjax', selector, function(event) { + var opts = options + if (!opts.container) { + opts = $.extend({}, options) + opts.container = $(this).attr('data-pjax') + } + handleClick(event, opts) + }) +} + +// Public: pjax on click handler +// +// Exported as $.pjax.click. +// +// event - "click" jQuery.Event +// options - pjax options +// +// Examples +// +// $(document).on('click', 'a', $.pjax.click) +// // is the same as +// $(document).pjax('a') +// +// Returns nothing. +function handleClick(event, container, options) { + options = optionsFor(container, options) + + var link = event.currentTarget + var $link = $(link) + + if (link.tagName.toUpperCase() !== 'A') + throw "$.fn.pjax or $.pjax.click requires an anchor element" + + // Middle click, cmd click, and ctrl click should open + // links in a new tab as normal. + if ( event.which > 1 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey ) + return + + // Ignore cross origin links + if ( location.protocol !== link.protocol || location.hostname !== link.hostname ) + return + + // Ignore case when a hash is being tacked on the current URL + if ( link.href.indexOf('#') > -1 && stripHash(link) == stripHash(location) ) + return + + // Ignore event with default prevented + if (event.isDefaultPrevented()) + return + + var defaults = { + url: link.href, + container: $link.attr('data-pjax'), + target: link + } + + var opts = $.extend({}, defaults, options) + var clickEvent = $.Event('pjax:click') + $link.trigger(clickEvent, [opts]) + + if (!clickEvent.isDefaultPrevented()) { + pjax(opts) + event.preventDefault() + $link.trigger('pjax:clicked', [opts]) + } +} + +// Public: pjax on form submit handler +// +// Exported as $.pjax.submit +// +// event - "click" jQuery.Event +// options - pjax options +// +// Examples +// +// $(document).on('submit', 'form', function(event) { +// $.pjax.submit(event, '[data-pjax-container]') +// }) +// +// Returns nothing. +function handleSubmit(event, container, options) { + options = optionsFor(container, options) + + var form = event.currentTarget + var $form = $(form) + + if (form.tagName.toUpperCase() !== 'FORM') + throw "$.pjax.submit requires a form element" + + var defaults = { + type: ($form.attr('method') || 'GET').toUpperCase(), + url: $form.attr('action'), + container: $form.attr('data-pjax'), + target: form + } + + if (defaults.type !== 'GET' && window.FormData !== undefined) { + defaults.data = new FormData(form) + defaults.processData = false + defaults.contentType = false + } else { + // Can't handle file uploads, exit + if ($form.find(':file').length) { + return + } + + // Fallback to manually serializing the fields + defaults.data = $form.serializeArray() + } + + pjax($.extend({}, defaults, options)) + + event.preventDefault() +} + +// Loads a URL with ajax, puts the response body inside a container, +// then pushState()'s the loaded URL. +// +// Works just like $.ajax in that it accepts a jQuery ajax +// settings object (with keys like url, type, data, etc). +// +// Accepts these extra keys: +// +// container - String selector for where to stick the response body. +// push - Whether to pushState the URL. Defaults to true (of course). +// replace - Want to use replaceState instead? That's cool. +// +// Use it just like $.ajax: +// +// var xhr = $.pjax({ url: this.href, container: '#main' }) +// console.log( xhr.readyState ) +// +// Returns whatever $.ajax returns. +function pjax(options) { + options = $.extend(true, {}, $.ajaxSettings, pjax.defaults, options) + + if ($.isFunction(options.url)) { + options.url = options.url() + } + + var hash = parseURL(options.url).hash + + var containerType = $.type(options.container) + if (containerType !== 'string') { + throw "expected string value for 'container' option; got " + containerType + } + var context = options.context = $(options.container) + if (!context.length) { + throw "the container selector '" + options.container + "' did not match anything" + } + + // We want the browser to maintain two separate internal caches: one + // for pjax'd partial page loads and one for normal page loads. + // Without adding this secret parameter, some browsers will often + // confuse the two. + if (!options.data) options.data = {} + if ($.isArray(options.data)) { + options.data.push({name: '_pjax', value: options.container}) + } else { + options.data._pjax = options.container + } + + function fire(type, args, props) { + if (!props) props = {} + props.relatedTarget = options.target + var event = $.Event(type, props) + context.trigger(event, args) + return !event.isDefaultPrevented() + } + + var timeoutTimer + + options.beforeSend = function(xhr, settings) { + // No timeout for non-GET requests + // Its not safe to request the resource again with a fallback method. + if (settings.type !== 'GET') { + settings.timeout = 0 + } + + xhr.setRequestHeader('X-PJAX', 'true') + xhr.setRequestHeader('X-PJAX-Container', options.container) + + if (!fire('pjax:beforeSend', [xhr, settings])) + return false + + if (settings.timeout > 0) { + timeoutTimer = setTimeout(function() { + if (fire('pjax:timeout', [xhr, options])) + xhr.abort('timeout') + }, settings.timeout) + + // Clear timeout setting so jquerys internal timeout isn't invoked + settings.timeout = 0 + } + + var url = parseURL(settings.url) + if (hash) url.hash = hash + options.requestUrl = stripInternalParams(url) + } + + options.complete = function(xhr, textStatus) { + if (timeoutTimer) + clearTimeout(timeoutTimer) + + fire('pjax:complete', [xhr, textStatus, options]) + + fire('pjax:end', [xhr, options]) + } + + options.error = function(xhr, textStatus, errorThrown) { + var container = extractContainer("", xhr, options) + + var allowed = fire('pjax:error', [xhr, textStatus, errorThrown, options]) + if (options.type == 'GET' && textStatus !== 'abort' && allowed) { + locationReplace(container.url) + } + } + + options.success = function(data, status, xhr) { + var previousState = pjax.state + + // If $.pjax.defaults.version is a function, invoke it first. + // Otherwise it can be a static string. + var currentVersion = typeof $.pjax.defaults.version === 'function' ? + $.pjax.defaults.version() : + $.pjax.defaults.version + + var latestVersion = xhr.getResponseHeader('X-PJAX-Version') + + var container = extractContainer(data, xhr, options) + + var url = parseURL(container.url) + if (hash) { + url.hash = hash + container.url = url.href + } + + // If there is a layout version mismatch, hard load the new url + if (currentVersion && latestVersion && currentVersion !== latestVersion) { + locationReplace(container.url) + return + } + + // If the new response is missing a body, hard load the page + if (!container.contents) { + locationReplace(container.url) + return + } + + pjax.state = { + id: options.id || uniqueId(), + url: container.url, + title: container.title, + container: options.container, + fragment: options.fragment, + timeout: options.timeout + } + + if (options.push || options.replace) { + window.history.replaceState(pjax.state, container.title, container.url) + } + + // Only blur the focus if the focused element is within the container. + var blurFocus = $.contains(context, document.activeElement) + + // Clear out any focused controls before inserting new page contents. + if (blurFocus) { + try { + document.activeElement.blur() + } catch (e) { /* ignore */ } + } + + if (container.title) document.title = container.title + + fire('pjax:beforeReplace', [container.contents, options], { + state: pjax.state, + previousState: previousState + }) + context.html(container.contents) + + // FF bug: Won't autofocus fields that are inserted via JS. + // This behavior is incorrect. So if theres no current focus, autofocus + // the last field. + // + // http://www.w3.org/html/wg/drafts/html/master/forms.html + var autofocusEl = context.find('input[autofocus], textarea[autofocus]').last()[0] + if (autofocusEl && document.activeElement !== autofocusEl) { + autofocusEl.focus() + } + + executeScriptTags(container.scripts) + + var scrollTo = options.scrollTo + + // Ensure browser scrolls to the element referenced by the URL anchor + if (hash) { + var name = decodeURIComponent(hash.slice(1)) + var target = document.getElementById(name) || document.getElementsByName(name)[0] + if (target) scrollTo = $(target).offset().top + } + + if (typeof scrollTo == 'number') $(window).scrollTop(scrollTo) + + fire('pjax:success', [data, status, xhr, options]) + } + + + // Initialize pjax.state for the initial page load. Assume we're + // using the container and options of the link we're loading for the + // back button to the initial page. This ensures good back button + // behavior. + if (!pjax.state) { + pjax.state = { + id: uniqueId(), + url: window.location.href, + title: document.title, + container: options.container, + fragment: options.fragment, + timeout: options.timeout + } + window.history.replaceState(pjax.state, document.title) + } + + // Cancel the current request if we're already pjaxing + abortXHR(pjax.xhr) + + pjax.options = options + var xhr = pjax.xhr = $.ajax(options) + + if (xhr.readyState > 0) { + if (options.push && !options.replace) { + // Cache current container element before replacing it + cachePush(pjax.state.id, [options.container, cloneContents(context)]) + + window.history.pushState(null, "", options.requestUrl) + } + + fire('pjax:start', [xhr, options]) + fire('pjax:send', [xhr, options]) + } + + return pjax.xhr +} + +// Public: Reload current page with pjax. +// +// Returns whatever $.pjax returns. +function pjaxReload(container, options) { + var defaults = { + url: window.location.href, + push: false, + replace: true, + scrollTo: false + } + + return pjax($.extend(defaults, optionsFor(container, options))) +} + +// Internal: Hard replace current state with url. +// +// Work for around WebKit +// https://bugs.webkit.org/show_bug.cgi?id=93506 +// +// Returns nothing. +function locationReplace(url) { + window.history.replaceState(null, "", pjax.state.url) + window.location.replace(url) +} + + +var initialPop = true +var initialURL = window.location.href +var initialState = window.history.state + +// Initialize $.pjax.state if possible +// Happens when reloading a page and coming forward from a different +// session history. +if (initialState && initialState.container) { + pjax.state = initialState +} + +// Non-webkit browsers don't fire an initial popstate event +if ('state' in window.history) { + initialPop = false +} + +// popstate handler takes care of the back and forward buttons +// +// You probably shouldn't use pjax on pages with other pushState +// stuff yet. +function onPjaxPopstate(event) { + + // Hitting back or forward should override any pending PJAX request. + if (!initialPop) { + abortXHR(pjax.xhr) + } + + var previousState = pjax.state + var state = event.state + var direction + + if (state && state.container) { + // When coming forward from a separate history session, will get an + // initial pop with a state we are already at. Skip reloading the current + // page. + if (initialPop && initialURL == state.url) return + + if (previousState) { + // If popping back to the same state, just skip. + // Could be clicking back from hashchange rather than a pushState. + if (previousState.id === state.id) return + + // Since state IDs always increase, we can deduce the navigation direction + direction = previousState.id < state.id ? 'forward' : 'back' + } + + var cache = cacheMapping[state.id] || [] + var containerSelector = cache[0] || state.container + var container = $(containerSelector), contents = cache[1] + + if (container.length) { + if (previousState) { + // Cache current container before replacement and inform the + // cache which direction the history shifted. + cachePop(direction, previousState.id, [containerSelector, cloneContents(container)]) + } + + var popstateEvent = $.Event('pjax:popstate', { + state: state, + direction: direction + }) + container.trigger(popstateEvent) + + var options = { + id: state.id, + url: state.url, + container: containerSelector, + push: false, + fragment: state.fragment, + timeout: state.timeout, + scrollTo: false + } + + if (contents) { + container.trigger('pjax:start', [null, options]) + + pjax.state = state + if (state.title) document.title = state.title + var beforeReplaceEvent = $.Event('pjax:beforeReplace', { + state: state, + previousState: previousState + }) + container.trigger(beforeReplaceEvent, [contents, options]) + container.html(contents) + + container.trigger('pjax:end', [null, options]) + } else { + pjax(options) + } + + // Force reflow/relayout before the browser tries to restore the + // scroll position. + container[0].offsetHeight // eslint-disable-line no-unused-expressions + } else { + locationReplace(location.href) + } + } + initialPop = false +} + +// Fallback version of main pjax function for browsers that don't +// support pushState. +// +// Returns nothing since it retriggers a hard form submission. +function fallbackPjax(options) { + var url = $.isFunction(options.url) ? options.url() : options.url, + method = options.type ? options.type.toUpperCase() : 'GET' + + var form = $('', { + method: method === 'GET' ? 'GET' : 'POST', + action: url, + style: 'display:none' + }) + + if (method !== 'GET' && method !== 'POST') { + form.append($('', { + type: 'hidden', + name: '_method', + value: method.toLowerCase() + })) + } + + var data = options.data + if (typeof data === 'string') { + $.each(data.split('&'), function(index, value) { + var pair = value.split('=') + form.append($('', {type: 'hidden', name: pair[0], value: pair[1]})) + }) + } else if ($.isArray(data)) { + $.each(data, function(index, value) { + form.append($('', {type: 'hidden', name: value.name, value: value.value})) + }) + } else if (typeof data === 'object') { + var key + for (key in data) + form.append($('', {type: 'hidden', name: key, value: data[key]})) + } + + $(document.body).append(form) + form.submit() +} + +// Internal: Abort an XmlHttpRequest if it hasn't been completed, +// also removing its event handlers. +function abortXHR(xhr) { + if ( xhr && xhr.readyState < 4) { + xhr.onreadystatechange = $.noop + xhr.abort() + } +} + +// Internal: Generate unique id for state object. +// +// Use a timestamp instead of a counter since ids should still be +// unique across page loads. +// +// Returns Number. +function uniqueId() { + return (new Date).getTime() +} + +function cloneContents(container) { + var cloned = container.clone() + // Unmark script tags as already being eval'd so they can get executed again + // when restored from cache. HAXX: Uses jQuery internal method. + cloned.find('script').each(function(){ + if (!this.src) $._data(this, 'globalEval', false) + }) + return cloned.contents() +} + +// Internal: Strip internal query params from parsed URL. +// +// Returns sanitized url.href String. +function stripInternalParams(url) { + url.search = url.search.replace(/([?&])(_pjax|_)=[^&]*/g, '').replace(/^&/, '') + return url.href.replace(/\?($|#)/, '$1') +} + +// Internal: Parse URL components and returns a Locationish object. +// +// url - String URL +// +// Returns HTMLAnchorElement that acts like Location. +function parseURL(url) { + var a = document.createElement('a') + a.href = url + return a +} + +// Internal: Return the `href` component of given URL object with the hash +// portion removed. +// +// location - Location or HTMLAnchorElement +// +// Returns String +function stripHash(location) { + return location.href.replace(/#.*/, '') +} + +// Internal: Build options Object for arguments. +// +// For convenience the first parameter can be either the container or +// the options object. +// +// Examples +// +// optionsFor('#container') +// // => {container: '#container'} +// +// optionsFor('#container', {push: true}) +// // => {container: '#container', push: true} +// +// optionsFor({container: '#container', push: true}) +// // => {container: '#container', push: true} +// +// Returns options Object. +function optionsFor(container, options) { + if (container && options) { + options = $.extend({}, options) + options.container = container + return options + } else if ($.isPlainObject(container)) { + return container + } else { + return {container: container} + } +} + +// Internal: Filter and find all elements matching the selector. +// +// Where $.fn.find only matches descendants, findAll will test all the +// top level elements in the jQuery object as well. +// +// elems - jQuery object of Elements +// selector - String selector to match +// +// Returns a jQuery object. +function findAll(elems, selector) { + return elems.filter(selector).add(elems.find(selector)) +} + +function parseHTML(html) { + return $.parseHTML(html, document, true) +} + +// Internal: Extracts container and metadata from response. +// +// 1. Extracts X-PJAX-URL header if set +// 2. Extracts inline tags +// 3. Builds response Element and extracts fragment if set +// +// data - String response data +// xhr - XHR response +// options - pjax options Object +// +// Returns an Object with url, title, and contents keys. +function extractContainer(data, xhr, options) { + var obj = {}, fullDocument = /<html/i.test(data) + + // Prefer X-PJAX-URL header if it was set, otherwise fallback to + // using the original requested url. + var serverUrl = xhr.getResponseHeader('X-PJAX-URL') + obj.url = serverUrl ? stripInternalParams(parseURL(serverUrl)) : options.requestUrl + + var $head, $body + // Attempt to parse response html into elements + if (fullDocument) { + $body = $(parseHTML(data.match(/<body[^>]*>([\s\S.]*)<\/body>/i)[0])) + var head = data.match(/<head[^>]*>([\s\S.]*)<\/head>/i) + $head = head != null ? $(parseHTML(head[0])) : $body + } else { + $head = $body = $(parseHTML(data)) + } + + // If response data is empty, return fast + if ($body.length === 0) + return obj + + // If there's a <title> tag in the header, use it as + // the page's title. + obj.title = findAll($head, 'title').last().text() + + if (options.fragment) { + var $fragment = $body + // If they specified a fragment, look for it in the response + // and pull it out. + if (options.fragment !== 'body') { + $fragment = findAll($fragment, options.fragment).first() + } + + if ($fragment.length) { + obj.contents = options.fragment === 'body' ? $fragment : $fragment.contents() + + // If there's no title, look for data-title and title attributes + // on the fragment + if (!obj.title) + obj.title = $fragment.attr('title') || $fragment.data('title') + } + + } else if (!fullDocument) { + obj.contents = $body + } + + // Clean up any <title> tags + if (obj.contents) { + // Remove any parent title elements + obj.contents = obj.contents.not(function() { return $(this).is('title') }) + + // Then scrub any titles from their descendants + obj.contents.find('title').remove() + + // Gather all script[src] elements + obj.scripts = findAll(obj.contents, 'script[src]').remove() + obj.contents = obj.contents.not(obj.scripts) + } + + // Trim any whitespace off the title + if (obj.title) obj.title = $.trim(obj.title) + + return obj +} + +// Load an execute scripts using standard script request. +// +// Avoids jQuery's traditional $.getScript which does a XHR request and +// globalEval. +// +// scripts - jQuery object of script Elements +// +// Returns nothing. +function executeScriptTags(scripts) { + if (!scripts) return + + var existingScripts = $('script[src]') + + scripts.each(function() { + var src = this.src + var matchedScripts = existingScripts.filter(function() { + return this.src === src + }) + if (matchedScripts.length) return + + var script = document.createElement('script') + var type = $(this).attr('type') + if (type) script.type = type + script.src = $(this).attr('src') + document.head.appendChild(script) + }) +} + +// Internal: History DOM caching class. +var cacheMapping = {} +var cacheForwardStack = [] +var cacheBackStack = [] + +// Push previous state id and container contents into the history +// cache. Should be called in conjunction with `pushState` to save the +// previous container contents. +// +// id - State ID Number +// value - DOM Element to cache +// +// Returns nothing. +function cachePush(id, value) { + cacheMapping[id] = value + cacheBackStack.push(id) + + // Remove all entries in forward history stack after pushing a new page. + trimCacheStack(cacheForwardStack, 0) + + // Trim back history stack to max cache length. + trimCacheStack(cacheBackStack, pjax.defaults.maxCacheLength) +} + +// Shifts cache from directional history cache. Should be +// called on `popstate` with the previous state id and container +// contents. +// +// direction - "forward" or "back" String +// id - State ID Number +// value - DOM Element to cache +// +// Returns nothing. +function cachePop(direction, id, value) { + var pushStack, popStack + cacheMapping[id] = value + + if (direction === 'forward') { + pushStack = cacheBackStack + popStack = cacheForwardStack + } else { + pushStack = cacheForwardStack + popStack = cacheBackStack + } + + pushStack.push(id) + id = popStack.pop() + if (id) delete cacheMapping[id] + + // Trim whichever stack we just pushed to to max cache length. + trimCacheStack(pushStack, pjax.defaults.maxCacheLength) +} + +// Trim a cache stack (either cacheBackStack or cacheForwardStack) to be no +// longer than the specified length, deleting cached DOM elements as necessary. +// +// stack - Array of state IDs +// length - Maximum length to trim to +// +// Returns nothing. +function trimCacheStack(stack, length) { + while (stack.length > length) + delete cacheMapping[stack.shift()] +} + +// Public: Find version identifier for the initial page load. +// +// Returns String version or undefined. +function findVersion() { + return $('meta').filter(function() { + var name = $(this).attr('http-equiv') + return name && name.toUpperCase() === 'X-PJAX-VERSION' + }).attr('content') +} + +// Install pjax functions on $.pjax to enable pushState behavior. +// +// Does nothing if already enabled. +// +// Examples +// +// $.pjax.enable() +// +// Returns nothing. +function enable() { + $.fn.pjax = fnPjax + $.pjax = pjax + $.pjax.enable = $.noop + $.pjax.disable = disable + $.pjax.click = handleClick + $.pjax.submit = handleSubmit + $.pjax.reload = pjaxReload + $.pjax.defaults = { + timeout: 650, + push: true, + replace: false, + type: 'GET', + dataType: 'html', + scrollTo: 0, + maxCacheLength: 20, + version: findVersion + } + $(window).on('popstate.pjax', onPjaxPopstate) +} + +// Disable pushState behavior. +// +// This is the case when a browser doesn't support pushState. It is +// sometimes useful to disable pushState for debugging on a modern +// browser. +// +// Examples +// +// $.pjax.disable() +// +// Returns nothing. +function disable() { + $.fn.pjax = function() { return this } + $.pjax = fallbackPjax + $.pjax.enable = enable + $.pjax.disable = $.noop + $.pjax.click = $.noop + $.pjax.submit = $.noop + $.pjax.reload = function() { window.location.reload() } + + $(window).off('popstate.pjax', onPjaxPopstate) +} + + +// Add the state property to jQuery's event object so we can use it in +// $(window).bind('popstate') +if ($.event.props && $.inArray('state', $.event.props) < 0) { + $.event.props.push('state') +} else if (!('state' in $.Event.prototype)) { + $.event.addProp('state') +} + +// Is pjax supported by this browser? +$.support.pjax = + window.history && window.history.pushState && window.history.replaceState && + // pushState isn't reliable on iOS until 5. + !navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/) + +if ($.support.pjax) { + enable() +} else { + disable() +} + +})(jQuery) diff --git a/public/assets/system/js/vendor.js b/public/assets/system/js/vendor.js index a66bb2ff..77a29948 100644 --- a/public/assets/system/js/vendor.js +++ b/public/assets/system/js/vendor.js @@ -39766,555 +39766,6 @@ module.exports = (function() { },{}]},{},[1]) (1) }); -"use strict"; - -// This file is part of Leaflet.Geodesic. -// Copyright (C) 2017 Henry Thasler -// based on code by Chris Veness Copyright (C) 2014 https://github.com/chrisveness/geodesy -// -// Leaflet.Geodesic is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Leaflet.Geodesic is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Leaflet.Geodesic. If not, see <http://www.gnu.org/licenses/>. - - - -/** Extend Number object with method to convert numeric degrees to radians */ -if (typeof Number.prototype.toRadians === "undefined") { - Number.prototype.toRadians = function() { - return this * Math.PI / 180 - } -} - -/** Extend Number object with method to convert radians to numeric (signed) degrees */ -if (typeof Number.prototype.toDegrees === "undefined") { - Number.prototype.toDegrees = function() { - return this * 180 / Math.PI - } -} - -const INTERSECT_LNG = 179.999 // Lng used for intersection and wrap around on map edges - -L.Geodesic = L.Polyline.extend({ - options: { - color: "blue", - steps: 10, - dash: 1, - wrap: true - }, - - initialize: function(latlngs, options) { - this.options = this._merge_options(this.options, options) - this.datum = {} - this.datum.ellipsoid = { - a: 6378137, - b: 6356752.3142, - f: 1 / 298.257223563 - } // WGS-84 - this._latlngs = (this.options.dash < 1) ? this._generate_GeodesicDashed( - latlngs) : this._generate_Geodesic(latlngs) - L.Polyline.prototype.initialize.call(this, this._latlngs, this.options) - }, - - setLatLngs: function(latlngs) { - this._latlngs = (this.options.dash < 1) ? this._generate_GeodesicDashed( - latlngs) : this._generate_Geodesic(latlngs) - L.Polyline.prototype.setLatLngs.call(this, this._latlngs) - }, - - /** - * Calculates some statistic values of current geodesic multipolyline - * @returns (Object} Object with several properties (e.g. overall distance) - */ - getStats: function() { - let obj = { - distance: 0, - points: 0, - polygons: this._latlngs.length - }, - poly, points - - for (poly = 0; poly < this._latlngs.length; poly++) { - obj.points += this._latlngs[poly].length - for (points = 0; points < (this._latlngs[poly].length - 1); points++) { - obj.distance += this._vincenty_inverse(this._latlngs[poly][points], - this._latlngs[poly][points + 1]).distance - } - } - return obj - }, - - - /** - * Creates geodesic lines from geoJson. Replaces all current features of this instance. - * Supports LineString, MultiLineString and Polygon - * @param {Object} geojson - geosjon as object. - */ - geoJson: function(geojson) { - - let normalized = L.GeoJSON.asFeature(geojson) - let features = normalized.type === "FeatureCollection" ? normalized.features : [ - normalized - ] - this._latlngs = [] - for (let feature of features) { - let geometry = feature.type === "Feature" ? feature.geometry : - feature, - coords = geometry.coordinates - - switch (geometry.type) { - case "LineString": - this._latlngs.push(this._generate_Geodesic([L.GeoJSON.coordsToLatLngs( - coords, 0)])) - break - case "MultiLineString": - case "Polygon": - this._latlngs.push(this._generate_Geodesic(L.GeoJSON.coordsToLatLngs( - coords, 1))) - break - case "Point": - case "MultiPoint": - console.log("Dude, points can't be drawn as geodesic lines...") - break - default: - console.log("Drawing " + geometry.type + - " as a geodesic is not supported. Skipping...") - } - } - L.Polyline.prototype.setLatLngs.call(this, this._latlngs) - }, - - /** - * Creates a great circle. Replaces all current lines. - * @param {Object} center - geographic position - * @param {number} radius - radius of the circle in metres - */ - createCircle: function(center, radius) { - let polylineIndex = 0 - let prev = { - lat: 0, - lng: 0, - brg: 0 - } - let step - - this._latlngs = [] - this._latlngs[polylineIndex] = [] - - let direct = this._vincenty_direct(L.latLng(center), 0, radius, this.options - .wrap) - prev = L.latLng(direct.lat, direct.lng) - this._latlngs[polylineIndex].push(prev) - for (step = 1; step <= this.options.steps;) { - direct = this._vincenty_direct(L.latLng(center), 360 / this.options - .steps * step, radius, this.options.wrap) - let gp = L.latLng(direct.lat, direct.lng) - if (Math.abs(gp.lng - prev.lng) > 180) { - let inverse = this._vincenty_inverse(prev, gp) - let sec = this._intersection(prev, inverse.initialBearing, { - lat: -89, - lng: ((gp.lng - prev.lng) > 0) ? -INTERSECT_LNG : INTERSECT_LNG - }, 0) - if (sec) { - this._latlngs[polylineIndex].push(L.latLng(sec.lat, sec.lng)) - polylineIndex++ - this._latlngs[polylineIndex] = [] - prev = L.latLng(sec.lat, -sec.lng) - this._latlngs[polylineIndex].push(prev) - } else { - polylineIndex++ - this._latlngs[polylineIndex] = [] - this._latlngs[polylineIndex].push(gp) - prev = gp - step++ - } - } else { - this._latlngs[polylineIndex].push(gp) - prev = gp - step++ - } - } - - L.Polyline.prototype.setLatLngs.call(this, this._latlngs) - }, - - /** - * Creates a geodesic Polyline from given coordinates - * @param {Object} latlngs - One or more polylines as an array. See Leaflet doc about Polyline - * @returns (Object} An array of arrays of geographical points. - */ - _generate_Geodesic: function(latlngs) { - let _geo = [], - _geocnt = 0, - s, poly, points, pointA, pointB - - for (poly = 0; poly < latlngs.length; poly++) { - _geo[_geocnt] = [] - for (points = 0; points < (latlngs[poly].length - 1); points++) { - pointA = L.latLng(latlngs[poly][points]) - pointB = L.latLng(latlngs[poly][points + 1]) - if (pointA.equals(pointB)) { - continue; - } - let inverse = this._vincenty_inverse(pointA, pointB) - let prev = pointA - _geo[_geocnt].push(prev) - for (s = 1; s <= this.options.steps;) { - let direct = this._vincenty_direct(pointA, inverse.initialBearing, - inverse.distance / this.options.steps * s, this.options.wrap - ) - let gp = L.latLng(direct.lat, direct.lng) - if (Math.abs(gp.lng - prev.lng) > 180) { - let sec = this._intersection(pointA, inverse.initialBearing, { - lat: -89, - lng: ((gp.lng - prev.lng) > 0) ? -INTERSECT_LNG : INTERSECT_LNG - }, 0) - if (sec) { - _geo[_geocnt].push(L.latLng(sec.lat, sec.lng)) - _geocnt++ - _geo[_geocnt] = [] - prev = L.latLng(sec.lat, -sec.lng) - _geo[_geocnt].push(prev) - } else { - _geocnt++ - _geo[_geocnt] = [] - _geo[_geocnt].push(gp) - prev = gp - s++ - } - } else { - _geo[_geocnt].push(gp) - prev = gp - s++ - } - } - } - _geocnt++ - } - return _geo - }, - - - /** - * Creates a dashed geodesic Polyline from given coordinates - under work - * @param {Object} latlngs - One or more polylines as an array. See Leaflet doc about Polyline - * @returns (Object} An array of arrays of geographical points. - */ - _generate_GeodesicDashed: function(latlngs) { - let _geo = [], - _geocnt = 0, - s, poly, points - // _geo = latlngs; // bypass - - for (poly = 0; poly < latlngs.length; poly++) { - _geo[_geocnt] = [] - for (points = 0; points < (latlngs[poly].length - 1); points++) { - let inverse = this._vincenty_inverse(L.latLng(latlngs[poly][ - points - ]), L.latLng(latlngs[poly][points + 1])) - let prev = L.latLng(latlngs[poly][points]) - _geo[_geocnt].push(prev) - for (s = 1; s <= this.options.steps;) { - let direct = this._vincenty_direct(L.latLng(latlngs[poly][ - points - ]), inverse.initialBearing, inverse.distance / this.options - .steps * s - inverse.distance / this.options.steps * (1 - - this.options.dash), this.options.wrap) - let gp = L.latLng(direct.lat, direct.lng) - if (Math.abs(gp.lng - prev.lng) > 180) { - let sec = this._intersection(L.latLng(latlngs[poly][points]), - inverse.initialBearing, { - lat: -89, - lng: ((gp.lng - prev.lng) > 0) ? -INTERSECT_LNG : INTERSECT_LNG - }, 0) - if (sec) { - _geo[_geocnt].push(L.latLng(sec.lat, sec.lng)) - _geocnt++ - _geo[_geocnt] = [] - prev = L.latLng(sec.lat, -sec.lng) - _geo[_geocnt].push(prev) - } else { - _geocnt++ - _geo[_geocnt] = [] - _geo[_geocnt].push(gp) - prev = gp - s++ - } - } else { - _geo[_geocnt].push(gp) - _geocnt++ - let direct2 = this._vincenty_direct(L.latLng(latlngs[poly][ - points - ]), inverse.initialBearing, inverse.distance / this.options - .steps * s, this.options.wrap) - _geo[_geocnt] = [] - _geo[_geocnt].push(L.latLng(direct2.lat, direct2.lng)) - s++ - } - } - } - _geocnt++ - } - return _geo - }, - - - /** - * Vincenty direct calculation. - * based on the work of Chris Veness (https://github.com/chrisveness/geodesy) - * - * @private - * @param {number} initialBearing - Initial bearing in degrees from north. - * @param {number} distance - Distance along bearing in metres. - * @returns (Object} Object including point (destination point), finalBearing. - */ - - _vincenty_direct: function(p1, initialBearing, distance, wrap) { - var φ1 = p1.lat.toRadians(), - λ1 = p1.lng.toRadians(); - var α1 = initialBearing.toRadians(); - var s = distance; - - var a = this.datum.ellipsoid.a, - b = this.datum.ellipsoid.b, - f = this.datum.ellipsoid.f; - - var sinα1 = Math.sin(α1); - var cosα1 = Math.cos(α1); - - var tanU1 = (1 - f) * Math.tan(φ1), - cosU1 = 1 / Math.sqrt((1 + tanU1 * tanU1)), - sinU1 = tanU1 * cosU1; - var σ1 = Math.atan2(tanU1, cosα1); - var sinα = cosU1 * sinα1; - var cosSqα = 1 - sinα * sinα; - var uSq = cosSqα * (a * a - b * b) / (b * b); - var A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * - uSq))); - var B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq))); - - var σ = s / (b * A), - σʹ, iterations = 0; - do { - var cos2σM = Math.cos(2 * σ1 + σ); - var sinσ = Math.sin(σ); - var cosσ = Math.cos(σ); - var Δσ = B * sinσ * (cos2σM + B / 4 * (cosσ * (-1 + 2 * cos2σM * - cos2σM) - - B / 6 * cos2σM * (-3 + 4 * sinσ * sinσ) * (-3 + 4 * cos2σM * - cos2σM))); - σʹ = σ; - σ = s / (b * A) + Δσ; - } while (Math.abs(σ - σʹ) > 1e-12 && ++iterations); - - var x = sinU1 * sinσ - cosU1 * cosσ * cosα1; - var φ2 = Math.atan2(sinU1 * cosσ + cosU1 * sinσ * cosα1, (1 - f) * - Math.sqrt(sinα * sinα + x * x)); - var λ = Math.atan2(sinσ * sinα1, cosU1 * cosσ - sinU1 * sinσ * cosα1); - var C = f / 16 * cosSqα * (4 + f * (4 - 3 * cosSqα)); - var L = λ - (1 - C) * f * sinα * - (σ + C * sinσ * (cos2σM + C * cosσ * (-1 + 2 * cos2σM * cos2σM))); - - if (wrap) - var λ2 = (λ1 + L + 3 * Math.PI) % (2 * Math.PI) - Math.PI; // normalise to -180...+180 - else - var λ2 = (λ1 + L); // do not normalize - - var revAz = Math.atan2(sinα, -x); - - return { - lat: φ2.toDegrees(), - lng: λ2.toDegrees(), - finalBearing: revAz.toDegrees() - }; - }, - - /** - * Vincenty inverse calculation. - * based on the work of Chris Veness (https://github.com/chrisveness/geodesy) - * - * @private - * @param {LatLng} p1 - Latitude/longitude of start point. - * @param {LatLng} p2 - Latitude/longitude of destination point. - * @returns {Object} Object including distance, initialBearing, finalBearing. - * @throws {Error} If formula failed to converge. - */ - _vincenty_inverse: function(p1, p2) { - var φ1 = p1.lat.toRadians(), - λ1 = p1.lng.toRadians(); - var φ2 = p2.lat.toRadians(), - λ2 = p2.lng.toRadians(); - - var a = this.datum.ellipsoid.a, - b = this.datum.ellipsoid.b, - f = this.datum.ellipsoid.f; - - var L = λ2 - λ1; - var tanU1 = (1 - f) * Math.tan(φ1), - cosU1 = 1 / Math.sqrt((1 + tanU1 * tanU1)), - sinU1 = tanU1 * cosU1; - var tanU2 = (1 - f) * Math.tan(φ2), - cosU2 = 1 / Math.sqrt((1 + tanU2 * tanU2)), - sinU2 = tanU2 * cosU2; - - var λ = L, - λʹ, iterations = 0; - do { - var sinλ = Math.sin(λ), - cosλ = Math.cos(λ); - var sinSqσ = (cosU2 * sinλ) * (cosU2 * sinλ) + (cosU1 * sinU2 - - sinU1 * cosU2 * cosλ) * (cosU1 * sinU2 - sinU1 * cosU2 * cosλ); - var sinσ = Math.sqrt(sinSqσ); - if (sinσ == 0) return 0; // co-incident points - var cosσ = sinU1 * sinU2 + cosU1 * cosU2 * cosλ; - var σ = Math.atan2(sinσ, cosσ); - var sinα = cosU1 * cosU2 * sinλ / sinσ; - var cosSqα = 1 - sinα * sinα; - var cos2σM = cosσ - 2 * sinU1 * sinU2 / cosSqα; - if (isNaN(cos2σM)) cos2σM = 0; // equatorial line: cosSqα=0 (§6) - var C = f / 16 * cosSqα * (4 + f * (4 - 3 * cosSqα)); - λʹ = λ; - λ = L + (1 - C) * f * sinα * (σ + C * sinσ * (cos2σM + C * cosσ * (- - 1 + 2 * cos2σM * cos2σM))); - } while (Math.abs(λ - λʹ) > 1e-12 && ++iterations < 100); - if (iterations >= 100) { - console.log("Formula failed to converge. Altering target position.") - return this._vincenty_inverse(p1, { - lat: p2.lat, - lng: p2.lng - 0.01 - }) - // throw new Error('Formula failed to converge'); - } - - var uSq = cosSqα * (a * a - b * b) / (b * b); - var A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * - uSq))); - var B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq))); - var Δσ = B * sinσ * (cos2σM + B / 4 * (cosσ * (-1 + 2 * cos2σM * - cos2σM) - - B / 6 * cos2σM * (-3 + 4 * sinσ * sinσ) * (-3 + 4 * cos2σM * - cos2σM))); - - var s = b * A * (σ - Δσ); - - var fwdAz = Math.atan2(cosU2 * sinλ, cosU1 * sinU2 - sinU1 * cosU2 * - cosλ); - var revAz = Math.atan2(cosU1 * sinλ, -sinU1 * cosU2 + cosU1 * sinU2 * - cosλ); - - s = Number(s.toFixed(3)); // round to 1mm precision - return { - distance: s, - initialBearing: fwdAz.toDegrees(), - finalBearing: revAz.toDegrees() - }; - }, - - - /** - * Returns the point of intersection of two paths defined by point and bearing. - * based on the work of Chris Veness (https://github.com/chrisveness/geodesy) - * - * @param {LatLon} p1 - First point. - * @param {number} brng1 - Initial bearing from first point. - * @param {LatLon} p2 - Second point. - * @param {number} brng2 - Initial bearing from second point. - * @returns {Object} containing lat/lng information of intersection. - * - * @example - * var p1 = LatLon(51.8853, 0.2545), brng1 = 108.55; - * var p2 = LatLon(49.0034, 2.5735), brng2 = 32.44; - * var pInt = LatLon.intersection(p1, brng1, p2, brng2); // pInt.toString(): 50.9078°N, 4.5084°E - */ - _intersection: function(p1, brng1, p2, brng2) { - // see http://williams.best.vwh.net/avform.htm#Intersection - - var φ1 = p1.lat.toRadians(), - λ1 = p1.lng.toRadians(); - var φ2 = p2.lat.toRadians(), - λ2 = p2.lng.toRadians(); - var θ13 = Number(brng1).toRadians(), - θ23 = Number(brng2).toRadians(); - var Δφ = φ2 - φ1, - Δλ = λ2 - λ1; - - var δ12 = 2 * Math.asin(Math.sqrt(Math.sin(Δφ / 2) * Math.sin(Δφ / 2) + - Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ / 2) * Math.sin(Δλ / - 2))); - if (δ12 == 0) return null; - - // initial/final bearings between points - var θ1 = Math.acos((Math.sin(φ2) - Math.sin(φ1) * Math.cos(δ12)) / - (Math.sin(δ12) * Math.cos(φ1))); - if (isNaN(θ1)) θ1 = 0; // protect against rounding - var θ2 = Math.acos((Math.sin(φ1) - Math.sin(φ2) * Math.cos(δ12)) / - (Math.sin(δ12) * Math.cos(φ2))); - - if (Math.sin(λ2 - λ1) > 0) { - var θ12 = θ1; - var θ21 = 2 * Math.PI - θ2; - } else { - var θ12 = 2 * Math.PI - θ1; - var θ21 = θ2; - } - - var α1 = (θ13 - θ12 + Math.PI) % (2 * Math.PI) - Math.PI; // angle 2-1-3 - var α2 = (θ21 - θ23 + Math.PI) % (2 * Math.PI) - Math.PI; // angle 1-2-3 - - if (Math.sin(α1) == 0 && Math.sin(α2) == 0) return null; // infinite intersections - if (Math.sin(α1) * Math.sin(α2) < 0) return null; // ambiguous intersection - - //α1 = Math.abs(α1); - //α2 = Math.abs(α2); - // ... Ed Williams takes abs of α1/α2, but seems to break calculation? - - var α3 = Math.acos(-Math.cos(α1) * Math.cos(α2) + - Math.sin(α1) * Math.sin(α2) * Math.cos(δ12)); - var δ13 = Math.atan2(Math.sin(δ12) * Math.sin(α1) * Math.sin(α2), - Math.cos(α2) + Math.cos(α1) * Math.cos(α3)) - var φ3 = Math.asin(Math.sin(φ1) * Math.cos(δ13) + - Math.cos(φ1) * Math.sin(δ13) * Math.cos(θ13)); - var Δλ13 = Math.atan2(Math.sin(θ13) * Math.sin(δ13) * Math.cos(φ1), - Math.cos(δ13) - Math.sin(φ1) * Math.sin(φ3)); - var λ3 = λ1 + Δλ13; - λ3 = (λ3 + 3 * Math.PI) % (2 * Math.PI) - Math.PI; // normalise to -180..+180º - - return { - lat: φ3.toDegrees(), - lng: λ3.toDegrees() - }; - }, - - /** - * Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1 - * @param obj1 - * @param obj2 - * @returns obj3 a new object based on obj1 and obj2 - */ - _merge_options: function(obj1, obj2) { - let obj3 = {}; - for (let attrname in obj1) { - obj3[attrname] = obj1[attrname]; - } - for (let attrname in obj2) { - obj3[attrname] = obj2[attrname]; - } - return obj3; - } -}); - -L.geodesic = function(latlngs, options) { - return new L.Geodesic(latlngs, options); -}; - (function() { // save these original methods before they are overwritten var proto_initIcon = L.Marker.prototype._initIcon; diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 9cdec124..08377f60 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -4,11 +4,13 @@ "/assets/system/js/jquery.js": "/assets/system/js/jquery.js?id=09dd64a64ba840c31a81", "/assets/fonts/glyphicons-halflings-regular.woff2": "/assets/fonts/glyphicons-halflings-regular.woff2?id=b5b5055c6d812c0f9f0d", "/assets/admin/fonts/glyphicons-halflings-regular.woff2": "/assets/admin/fonts/glyphicons-halflings-regular.woff2?id=b5b5055c6d812c0f9f0d", + "/assets/admin/css/clear.png": "/assets/admin/css/clear.png?id=0e92f4c3efc6988a3c96", + "/assets/admin/css/loading.gif": "/assets/admin/css/loading.gif?id=90a4b76b4f11558691f6", "/assets/admin/css/vendor.min.css": "/assets/admin/css/vendor.min.css?id=b7f27b62f5cf3ebb7a65", - "/assets/admin/js/vendor.js": "/assets/admin/js/vendor.js?id=2831a0e25aded202c08c", + "/assets/admin/js/vendor.js": "/assets/admin/js/vendor.js?id=0f6b516f7ea80d70d407", "/assets/admin/css/blue.png": "/assets/admin/css/blue.png?id=753a3c0dec86d3a38d9c", "/assets/admin/css/blue@2x.png": "/assets/admin/css/blue@2x.png?id=97da23d47b838cbd4bef", - "/assets/system/js/vendor.js": "/assets/system/js/vendor.js?id=022e73793e29fb2c6825", + "/assets/system/js/vendor.js": "/assets/system/js/vendor.js?id=434db3f2c9beafd58bae", "/assets/system/css/vendor.css": "/assets/system/css/vendor.css?id=7bd98a28084fea99e307", "/assets/system/js/installer-vendor.js": "/assets/system/js/installer-vendor.js?id=b2bca761f222e97bf4ff" } \ No newline at end of file diff --git a/resources/views/admin/subfleets/script.blade.php b/resources/views/admin/subfleets/script.blade.php index 147a9e57..bec551c0 100644 --- a/resources/views/admin/subfleets/script.blade.php +++ b/resources/views/admin/subfleets/script.blade.php @@ -1,14 +1,14 @@ @section('scripts') <script> -$(document).ready(function() { +function setEditable() { $('#aircraft_fares a').editable({ type: 'text', mode: 'inline', emptytext: 'default', url: '/admin/subfleets/{!! $subfleet->id !!}/fares', title: 'Enter override value', - ajaxOptions: { 'type': 'put'}, - params: function(params) { + ajaxOptions: {'type': 'put'}, + params: function (params) { return { fare_id: params.pk, name: params.name, @@ -16,15 +16,22 @@ $(document).ready(function() { } } }); +} + +$(document).ready(function() { + + setEditable(); $(document).on('submit', 'form.rm_fare', function(event) { event.preventDefault(); console.log(event); $.pjax.submit(event, '#aircraft_fares_wrapper', {push: false}); + setEditable(); }); $(document).on('pjax:complete', function() { $(".select2").select2(); + setEditable(); }); }); </script> diff --git a/webpack.mix.js b/webpack.mix.js index 69cff1b9..b1270c0f 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -23,6 +23,7 @@ mix.webpackConfig({ mix.copy('node_modules/jquery/dist/jquery.js', 'public/assets/system/js/'); mix.copy('node_modules/bootstrap3/fonts/*.woff2', 'public/assets/fonts/'); mix.copy('node_modules/bootstrap3/fonts/*.woff2', 'public/assets/admin/fonts/'); +mix.copy('node_modules/x-editable/dist/bootstrap3-editable/img/*', 'public/assets/admin/css/'); /** * ADMIN REQUIRED FILES @@ -59,10 +60,11 @@ mix.scripts([ 'node_modules/select2/dist/js/select2.js', 'node_modules/leaflet/dist/leaflet.js', 'node_modules/icheck/icheck.js', - 'node_modules/pjax/pjax.js', + // 'node_modules/pjax/pjax.js', 'node_modules/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js', // 'node_modules/x-editable/dist/bootstrap-datepicker/dist/js/bootstrap-datepicker.js', 'node_modules/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js', + 'node_modules/jquery-pjax/jquery.pjax.js', ], 'public/assets/admin/js/vendor.js'); mix.copy('node_modules/icheck/skins/square/blue*.png', 'public/assets/admin/css');