From d562585c1adfa15db85688169a1893ce90aac0fb Mon Sep 17 00:00:00 2001 From: Cyrille Courtiere Date: Mon, 13 May 2019 12:39:41 +0200 Subject: [PATCH 1/7] Init webpack configuration --- .gitignore | 1 + .yo-rc.json | 61 +++++++++++++++++++++++++++++++++++++++ package.json | 22 ++++++++++++-- webpack.config.js | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 .yo-rc.json create mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore index 7133195..dd1b92f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ client/config.js components node_modules npm-debug.log +package-lock.json diff --git a/.yo-rc.json b/.yo-rc.json new file mode 100644 index 0000000..82dc3c5 --- /dev/null +++ b/.yo-rc.json @@ -0,0 +1,61 @@ +{ + "otpjs": { + "configuration": { + "config": { + "topScope": [ + "const webpack = require('webpack')", + "const path = require('path')", + "\n", + "/*\n * SplitChunksPlugin is enabled by default and replaced\n * deprecated CommonsChunkPlugin. It automatically identifies modules which\n * should be splitted of chunk by heuristics using module duplication count and\n * module category (i. e. node_modules). And splits the chunks…\n *\n * It is safe to remove \"splitChunks\" from the generated configuration\n * and was added as an educational example.\n *\n * https://webpack.js.org/plugins/split-chunks-plugin/\n *\n */", + "/*\n * We've enabled UglifyJSPlugin for you! This minifies your app\n * in order to load faster and run less javascript.\n *\n * https://github.com/webpack-contrib/uglifyjs-webpack-plugin\n *\n */", + "const UglifyJSPlugin = require('uglifyjs-webpack-plugin');", + "\n" + ], + "webpackOptions": { + "module": { + "rules": [ + { + "test": "/\\.css$/", + "use": [ + { + "loader": "'style-loader'", + "options": { + "sourceMap": true + } + }, + { + "loader": "'css-loader'" + } + ] + } + ] + }, + "output": { + "chunkFilename": "'[name].[chunkhash].js'", + "filename": "'[name].[chunkhash].js'", + "path": "path.resolve(__dirname, './client/build')" + }, + "mode": "'development'", + "plugins": [ + "new UglifyJSPlugin()" + ], + "optimization": { + "splitChunks": { + "cacheGroups": { + "vendors": { + "priority": -10, + "test": "/[\\\\/]node_modules[\\\\/]/" + } + }, + "chunks": "'async'", + "minChunks": 1, + "minSize": 30000, + "name": true + } + } + }, + "configName": "config" + } + } + } +} \ No newline at end of file diff --git a/package.json b/package.json index 4dd3a7d..94eb253 100644 --- a/package.json +++ b/package.json @@ -11,14 +11,30 @@ "url": "git://github.com/conveyal/otp.js.git" }, "devDependencies": { - "component": "*", - "component-uglifyjs": "*", + "babel-plugin-syntax-dynamic-import": "^6.18.0", + "css-loader": "^2.1.1", "serve": "^1.4.0", - "standard": "8.3.0" + "standard": "8.3.0", + "style-loader": "^0.23.1", + "uglifyjs-webpack-plugin": "^2.1.2", + "webpack": "^4.31.0", + "webpack-cli": "^3.3.2" }, "scripts": { "start": "serve client", "format": "standard --format lib/*.js client.js config.js index.js", "lint": "standard --verbose lib/*.js client.js config.js index.js" + }, + "bugs": { + "url": "https://github.com/conveyal/otp.js/issues" + }, + "main": "client/client.js", + "directories": { + "lib": "lib", + "test": "test" + }, + "dependencies": { + "@webpack-cli/init": "^0.1.5", + "debug": "^4.1.0" } } diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..ad41977 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,73 @@ +const webpack = require('webpack'); +const path = require('path'); + +/* + * SplitChunksPlugin is enabled by default and replaced + * deprecated CommonsChunkPlugin. It automatically identifies modules which + * should be splitted of chunk by heuristics using module duplication count and + * module category (i. e. node_modules). And splits the chunks… + * + * It is safe to remove "splitChunks" from the generated configuration + * and was added as an educational example. + * + * https://webpack.js.org/plugins/split-chunks-plugin/ + * + */ + +/* + * We've enabled UglifyJSPlugin for you! This minifies your app + * in order to load faster and run less javascript. + * + * https://github.com/webpack-contrib/uglifyjs-webpack-plugin + * + */ + +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); + +module.exports = { + module: { + rules: [ + { + test: /\.css$/, + + use: [ + { + loader: 'style-loader', + + options: { + sourceMap: true + } + }, + { + loader: 'css-loader' + } + ] + } + ] + }, + + output: { + chunkFilename: '[name].[chunkhash].js', + filename: '[name].[chunkhash].js', + path: path.resolve(__dirname, './client/build') + }, + + mode: 'development', + plugins: [new UglifyJSPlugin()], + + optimization: { + splitChunks: { + cacheGroups: { + vendors: { + priority: -10, + test: /[\\/]node_modules[\\/]/ + } + }, + + chunks: 'async', + minChunks: 1, + minSize: 30000, + name: true + } + } +}; From 03ddd2ca71dae3cd8c99049d0d33c225346ca580 Mon Sep 17 00:00:00 2001 From: Cyrille Courtiere Date: Tue, 14 May 2019 17:01:42 +0200 Subject: [PATCH 2/7] remove unused leg bubble template & css --- lib/styles/map.css | 118 +---------------------------- lib/templates/leg-from-bubble.html | 8 -- 2 files changed, 1 insertion(+), 125 deletions(-) delete mode 100644 lib/templates/leg-from-bubble.html diff --git a/lib/styles/map.css b/lib/styles/map.css index dad91bf..da7a4ff 100644 --- a/lib/styles/map.css +++ b/lib/styles/map.css @@ -22,122 +22,6 @@ margin-top: -6px; } -.otp-legBubble-iconModeSymbol { - width: 16px; - height: 16px; - margin-left: 7px; - background: black; -} - -.otp-legBubble-icon { - width: 20px; - height: 30px; - text-align: center; - font-size: 9px; - font-weight: bold; -} - -.otp-legBubble-icon-nw { - background: url('../images/legbubble/nw.png'); -} - -.otp-legBubble-icon-ne { - background: url('../images/legbubble/ne.png'); -} - -.otp-legBubble-icon-sw { - background: url('../images/legbubble/sw.png'); -} - -.otp-legBubble-icon-se { - background: url('../images/legbubble/se.png'); -} - -.otp-legBubble-icon-nw-highlight { - background: url('../images/legbubble/nw_highlight.png'); -} - -.otp-legBubble-icon-ne-highlight { - background: url('../images/legbubble/ne_highlight.png'); -} - -.otp-legBubble-icon-sw-highlight { - background: url('../images/legbubble/sw_highlight.png'); -} - -.otp-legBubble-icon-se-highlight { - background: url('../images/legbubble/se_highlight.png'); -} - - -.otp-legBubble-icon-topRow-n { - height: 16px; - margin-top: 3px; -} - -.otp-legBubble-icon-topRow-s { - height: 16px; - margin-top: 16px; -} - - -.otp-legBubble-arrow-right { - background: url('../images/mode/arrow_right.png'); - width: 8px; - height: 16px; -} - -.otp-legBubble-arrow-left { - background: url('../images/mode/arrow_left.png'); - width: 8px; - height: 16px; -} - -.otp-modeIcon-BICYCLE { - background: url('../images/mode/bicycle.png'); - width: 16px; height: 16px; -} - -.otp-modeIcon-WALK { - background: url('../images/mode/walk.png'); - width: 10px; height: 16px; -} - -.otp-modeIcon-BUS { - background: url('../images/mode/bus.png'); - width: 11px; height: 16px; -} - -.otp-modeIcon-RAIL { - background: url('../images/mode/rail.png'); - width: 12px; height: 16px; -} - -.otp-modeIcon-TRAM { - background: url('../images/mode/tram.png'); - width: 11px; height: 16px; -} - -.otp-modeIcon-SUBWAY { - background: url('../images/mode/subway.png'); - width: 14px; height: 16px; -} - -.otp-modeIcon-FERRY { - background: url('../images/mode/ferry.png'); - width: 16px; height: 16px; -} - -.otp-modeIcon-GONDOLA { - background: url('../images/mode/gondola.png'); - width: 15px; height: 16px; -} - -.otp-modeIcon-CAR { - background: url('../images/mode/car.png'); - width: 15px; height: 16px; -} - .otp-routeShortName { margin-top: -1px; @@ -172,4 +56,4 @@ #map { display: none !important; } -} \ No newline at end of file +} diff --git a/lib/templates/leg-from-bubble.html b/lib/templates/leg-from-bubble.html deleted file mode 100644 index 7a82728..0000000 --- a/lib/templates/leg-from-bubble.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
-
-
-
{{routeShortName}}
-
-
-{{{formatTime from.departure format="h:mm"}}} \ No newline at end of file From 523e9b32f395f7491f5cf8b5e8450ba9915dfda9 Mon Sep 17 00:00:00 2001 From: Cyrille Courtiere Date: Tue, 14 May 2019 17:08:53 +0200 Subject: [PATCH 3/7] move from conponent to webpack --- client/client.js | 4 +- client/index.html | 26 +++--- client/widget.html | 11 +-- component.json | 80 ---------------- lib/bike-triangle-control.js | 4 +- lib/entry.js | 7 ++ lib/geocoder.js | 2 +- lib/index.js | 5 +- lib/itineraries.js | 2 +- lib/itinerary-leg.js | 4 +- lib/itinerary-legs.js | 2 +- lib/itinerary-map-view.js | 4 +- lib/itinerary-narrative-view.js | 4 +- lib/itinerary-stop.js | 2 +- lib/itinerary-topo-view.js | 10 +- lib/itinerary-walk-step.js | 2 +- lib/itinerary-walk-steps.js | 2 +- lib/itinerary.js | 4 +- lib/leaflet-topo-graph-control.js | 4 +- .../leaflet.label/leaflet.label-src.js | 0 .../leaflet.label/leaflet.label.css | 0 {local => lib}/leaflet.label/leaflet.label.js | 2 +- lib/leg-narrative-view.js | 4 +- lib/plan-request.js | 6 +- lib/plan-response-narrative-view.js | 4 +- lib/plan-response-view.js | 4 +- lib/plan-response.js | 4 +- lib/request-form-common.js | 6 +- lib/request-form-widget.js | 6 +- lib/request-form.js | 31 +++---- lib/request-map-view.js | 10 +- lib/step-narrative-view.js | 3 +- lib/stop.js | 2 +- lib/stops-in-rectangle-request.js | 4 +- lib/stops-request-map-view.js | 4 +- lib/stops-response-map-view.js | 6 +- lib/stops-response.js | 4 +- lib/stops.js | 2 +- lib/utils.js | 4 +- local/leaflet.label/component.json | 12 --- package.json | 27 +++++- webpack.config.js | 93 ++++++++++--------- 42 files changed, 179 insertions(+), 238 deletions(-) delete mode 100644 component.json create mode 100644 lib/entry.js rename {local => lib}/leaflet.label/leaflet.label-src.js (100%) rename {local => lib}/leaflet.label/leaflet.label.css (100%) rename {local => lib}/leaflet.label/leaflet.label.js (99%) delete mode 100644 local/leaflet.label/component.json diff --git a/client/client.js b/client/client.js index 4b67f82..47b8a20 100644 --- a/client/client.js +++ b/client/client.js @@ -24,7 +24,6 @@ function assign_bootstrap_mode () { } $(document).ready(function () { - var OTP = require('otpjs') var log = OTP.log('client') // set up the leafet map object @@ -182,8 +181,7 @@ $(document).ready(function () { }) $(window).resize(resize) - resize() + setTimeout(function(){ resize() }, 10) $('#tabs').tab() - map.invalidateSize() assign_bootstrap_mode() }) diff --git a/client/index.html b/client/index.html index 30cbb03..fdd0cb5 100644 --- a/client/index.html +++ b/client/index.html @@ -8,11 +8,9 @@ - - - - - + + + - - - - - - + + + + + + + - + - + + diff --git a/client/widget.html b/client/widget.html index 1889525..ecfffa7 100644 --- a/client/widget.html +++ b/client/widget.html @@ -15,9 +15,7 @@ - - - + - - + + diff --git a/component.json b/component.json deleted file mode 100644 index f0b9eaf..0000000 --- a/component.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "name": "otpjs", - "version": "0.13.3", - "description": "A lightweight library for modular development of modern OpenTripPlanner front-end interfaces", - "dependencies": { - "component/querystring": "*", - "components/handlebars.js": "*", - "es-shims/es5-shim": "*", - "es-shims/es6-shim": "*", - "kpwebb/select2": "*", - "trevorgerhardt/haversine": "*", - "visionmedia/debug": "*" - }, - "development": {}, - "local": [ - "leaflet.label" - ], - "paths": [ - "local" - ], - "main": "lib/index.js", - "scripts": [ - "lib/bike-triangle-control.js", - "lib/geocoder.js", - "lib/helpers.js", - "lib/index.js", - "lib/itineraries.js", - "lib/itinerary-leg.js", - "lib/itinerary-legs.js", - "lib/itinerary-map-view.js", - "lib/itinerary-narrative-view.js", - "lib/itinerary-stop.js", - "lib/itinerary-topo-view.js", - "lib/itinerary-walk-step.js", - "lib/itinerary-walk-steps.js", - "lib/itinerary.js", - "lib/leaflet-topo-graph-control.js", - "lib/leg-narrative-view.js", - "lib/log.js", - "lib/plan-request.js", - "lib/plan-response-narrative-view.js", - "lib/plan-response-view.js", - "lib/plan-response.js", - "lib/request-form.js", - "lib/request-form-common.js", - "lib/request-form-widget.js", - "lib/request-map-view.js", - "lib/step-narrative-view.js", - "lib/stop.js", - "lib/stops-in-rectangle-request.js", - "lib/stops-request-map-view.js", - "lib/stops-response-map-view.js", - "lib/stops-response.js", - "lib/stops.js", - "lib/utils.js" - ], - "styles": [ - "lib/styles/map.css", - "lib/styles/narrative.css", - "lib/styles/request-form.css", - "lib/styles/tabs.css", - "lib/styles/topo.css" - ], - "images": [ - "lib/images" - ], - "templates": [ - "lib/templates/access-leg.html", - "lib/templates/generic-leg.html", - "lib/templates/leg-from-bubble.html", - "lib/templates/map-context-menu.html", - "lib/templates/narrative-adjust.html", - "lib/templates/narrative-error.html", - "lib/templates/narrative-new.html", - "lib/templates/narrative-itinerary.html", - "lib/templates/request-form.html", - "lib/templates/step.html", - "lib/templates/transit-leg.html" - ] -} diff --git a/lib/bike-triangle-control.js b/lib/bike-triangle-control.js index 3499bfb..1d8c046 100644 --- a/lib/bike-triangle-control.js +++ b/lib/bike-triangle-control.js @@ -1,5 +1,5 @@ -var Backbone = window.Backbone -var Raphael = window.Raphael +var Backbone = require('backbone') +var Raphael = require('raphael') var BikeTriangleControl = Backbone.View.extend({ cursor_size: 19, diff --git a/lib/entry.js b/lib/entry.js new file mode 100644 index 0000000..407077b --- /dev/null +++ b/lib/entry.js @@ -0,0 +1,7 @@ +import './styles/map.css' +import './styles/narrative.css' +import './styles/request-form.css' +import './styles/tabs.css' +import './styles/topo.css' + +import './leaflet.label/leaflet.label.css'; diff --git a/lib/geocoder.js b/lib/geocoder.js index c753714..3b0aa27 100644 --- a/lib/geocoder.js +++ b/lib/geocoder.js @@ -1,4 +1,4 @@ -var $ = window.$ +var $ = require('jquery') var maxSuggestResults = 10 diff --git a/lib/index.js b/lib/index.js index 1d48fa8..349cc8a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,6 @@ -require('leaflet.label') // load leaflet.label require('./helpers') // register handlebars helpers +module.exports.entry = require('./entry') module.exports.BikeTriangleControl = require('./bike-triangle-control') module.exports.Itineraries = require('./itineraries') module.exports.ItineraryLeg = require('./itinerary-leg') @@ -28,3 +28,6 @@ module.exports.StopsResponseMapView = require('./stops-response-map-view') module.exports.StopsResponse = require('./stops-response') module.exports.Stops = require('./stops') module.exports.utils = require('./utils') + +// Make modules available to client.js +window.OTP = module.exports diff --git a/lib/itineraries.js b/lib/itineraries.js index 0d45e6a..06942de 100644 --- a/lib/itineraries.js +++ b/lib/itineraries.js @@ -1,6 +1,6 @@ var Itinerary = require('./itinerary') -var Backbone = window.Backbone +var Backbone = require('backbone') var Itineraries = Backbone.Collection.extend({ model: Itinerary, diff --git a/lib/itinerary-leg.js b/lib/itinerary-leg.js index e5ec34a..a27c2e9 100644 --- a/lib/itinerary-leg.js +++ b/lib/itinerary-leg.js @@ -1,7 +1,7 @@ var ItineraryWalkSteps = require('./itinerary-walk-steps') -var Backbone = window.Backbone -var $ = window.$ +var Backbone = require('backbone') +var $ = require('jquery') var OTPURL = window.OTP_config.otpApi + window.OTP_config.routerId diff --git a/lib/itinerary-legs.js b/lib/itinerary-legs.js index 25918cd..1a26c64 100644 --- a/lib/itinerary-legs.js +++ b/lib/itinerary-legs.js @@ -1,6 +1,6 @@ var ItineraryLeg = require('./itinerary-leg') -var Backbone = window.Backbone +var Backbone = require('backbone') var ItineraryLegs = Backbone.Collection.extend({ model: ItineraryLeg diff --git a/lib/itinerary-map-view.js b/lib/itinerary-map-view.js index 1af700f..d81e5fb 100644 --- a/lib/itinerary-map-view.js +++ b/lib/itinerary-map-view.js @@ -1,8 +1,8 @@ var log = require('./log')('itinerary-map-view') var utils = require('./utils') -var Backbone = window.Backbone -var L = window.L +var Backbone = require('backbone') +var L = require('leaflet') var ItineraryMapView = Backbone.View.extend({ initialize: function (options) { diff --git a/lib/itinerary-narrative-view.js b/lib/itinerary-narrative-view.js index 5624af8..782a47f 100644 --- a/lib/itinerary-narrative-view.js +++ b/lib/itinerary-narrative-view.js @@ -4,8 +4,8 @@ var LegNarrativeView = require('./leg-narrative-view') var itinNarrativeTemplate = Handlebars.compile(require('./templates/narrative-itinerary.html')) -var Backbone = window.Backbone -var _ = window._ +var Backbone = require('backbone') + var ItineraryNarrativeView = Backbone.View.extend({ className: 'PlanResponseNarrativeView', diff --git a/lib/itinerary-stop.js b/lib/itinerary-stop.js index 83592a3..976a57f 100644 --- a/lib/itinerary-stop.js +++ b/lib/itinerary-stop.js @@ -1,4 +1,4 @@ -var Backbone = window.Backbone +var Backbone = require('backbone') var ItineraryStop = Backbone.Model.extend({ defaults: { diff --git a/lib/itinerary-topo-view.js b/lib/itinerary-topo-view.js index f7d9f03..1c8bf90 100644 --- a/lib/itinerary-topo-view.js +++ b/lib/itinerary-topo-view.js @@ -1,10 +1,10 @@ var utils = require('./utils') -var Backbone = window.Backbone -var L = window.L -var Raphael = window.Raphael -var _ = window._ -var $ = window.$ +var Backbone = require('backbone') +var L = require('leaflet') +var Raphael = require('raphael') + +var $ = require('jquery') function getElevation (elevCoord) { return elevCoord.second * 3.28084 diff --git a/lib/itinerary-walk-step.js b/lib/itinerary-walk-step.js index fd2283f..5d4ae86 100644 --- a/lib/itinerary-walk-step.js +++ b/lib/itinerary-walk-step.js @@ -1,4 +1,4 @@ -var Backbone = window.Backbone +var Backbone = require('backbone') var ItineraryWalkStep = Backbone.Model.extend({ defaults: { diff --git a/lib/itinerary-walk-steps.js b/lib/itinerary-walk-steps.js index a64fbd2..b80034d 100644 --- a/lib/itinerary-walk-steps.js +++ b/lib/itinerary-walk-steps.js @@ -1,6 +1,6 @@ var ItineraryWalkStep = require('./itinerary-walk-step') -var Backbone = window.Backbone +var Backbone = require('backbone') var ItineraryWalkSteps = Backbone.Collection.extend({ model: ItineraryWalkStep diff --git a/lib/itinerary.js b/lib/itinerary.js index bdf9832..ea09f0f 100644 --- a/lib/itinerary.js +++ b/lib/itinerary.js @@ -1,8 +1,8 @@ var ItineraryLegs = require('./itinerary-legs') var utils = require('./utils') -var Backbone = window.Backbone -var moment = window.moment +var Backbone = require('backbone') +var moment = require('moment') var Itinerary = Backbone.Model.extend({ initialize: function (opts) { diff --git a/lib/leaflet-topo-graph-control.js b/lib/leaflet-topo-graph-control.js index e63d014..c340980 100644 --- a/lib/leaflet-topo-graph-control.js +++ b/lib/leaflet-topo-graph-control.js @@ -1,5 +1,5 @@ -var L = window.L -var $ = window.$ +var L = require('leaflet') +var $ = require('jquery') var LeafletTopoGraphControl = L.Control.extend({ options: { diff --git a/local/leaflet.label/leaflet.label-src.js b/lib/leaflet.label/leaflet.label-src.js similarity index 100% rename from local/leaflet.label/leaflet.label-src.js rename to lib/leaflet.label/leaflet.label-src.js diff --git a/local/leaflet.label/leaflet.label.css b/lib/leaflet.label/leaflet.label.css similarity index 100% rename from local/leaflet.label/leaflet.label.css rename to lib/leaflet.label/leaflet.label.css diff --git a/local/leaflet.label/leaflet.label.js b/lib/leaflet.label/leaflet.label.js similarity index 99% rename from local/leaflet.label/leaflet.label.js rename to lib/leaflet.label/leaflet.label.js index 4a054b3..b3a9750 100644 --- a/local/leaflet.label/leaflet.label.js +++ b/lib/leaflet.label/leaflet.label.js @@ -6,4 +6,4 @@ http://leafletjs.com https://github.com/jacobtoye */ -(function(){L.labelVersion="0.2.1",L.Label=L.Class.extend({includes:L.Mixin.Events,options:{className:"",clickable:!1,direction:"right",noHide:!1,offset:[12,-15],opacity:1,zoomAnimation:!0},initialize:function(t,e){L.setOptions(this,t),this._source=e,this._animated=L.Browser.any3d&&this.options.zoomAnimation,this._isOpen=!1},onAdd:function(t){this._map=t,this._pane=this._source instanceof L.Marker?t._panes.markerPane:t._panes.popupPane,this._container||this._initLayout(),this._pane.appendChild(this._container),this._initInteraction(),this._update(),this.setOpacity(this.options.opacity),t.on("moveend",this._onMoveEnd,this).on("viewreset",this._onViewReset,this),this._animated&&t.on("zoomanim",this._zoomAnimation,this),L.Browser.touch&&!this.options.noHide&&L.DomEvent.on(this._container,"click",this.close,this)},onRemove:function(t){this._pane.removeChild(this._container),t.off({zoomanim:this._zoomAnimation,moveend:this._onMoveEnd,viewreset:this._onViewReset},this),this._removeInteraction(),this._map=null},setLatLng:function(t){return this._latlng=L.latLng(t),this._map&&this._updatePosition(),this},setContent:function(t){return this._previousContent=this._content,this._content=t,this._updateContent(),this},close:function(){var t=this._map;t&&(L.Browser.touch&&!this.options.noHide&&L.DomEvent.off(this._container,"click",this.close),t.removeLayer(this))},updateZIndex:function(t){this._zIndex=t,this._container&&this._zIndex&&(this._container.style.zIndex=t)},setOpacity:function(t){this.options.opacity=t,this._container&&L.DomUtil.setOpacity(this._container,t)},_initLayout:function(){this._container=L.DomUtil.create("div","leaflet-label "+this.options.className+" leaflet-zoom-animated"),this.updateZIndex(this._zIndex)},_update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updatePosition(),this._container.style.visibility="")},_updateContent:function(){this._content&&this._map&&this._prevContent!==this._content&&"string"==typeof this._content&&(this._container.innerHTML=this._content,this._prevContent=this._content,this._labelWidth=this._container.offsetWidth)},_updatePosition:function(){var t=this._map.latLngToLayerPoint(this._latlng);this._setPosition(t)},_setPosition:function(t){var e=this._map,i=this._container,n=e.latLngToContainerPoint(e.getCenter()),o=e.layerPointToContainerPoint(t),s=this.options.direction,a=this._labelWidth,l=L.point(this.options.offset);"right"===s||"auto"===s&&o.xi;i++)L.DomEvent.on(t,e[i],this._fireMouseEvent,this)}},_removeInteraction:function(){if(this.options.clickable){var t=this._container,e=["dblclick","mousedown","mouseover","mouseout","contextmenu"];L.DomUtil.removeClass(t,"leaflet-clickable"),L.DomEvent.off(t,"click",this._onMouseClick,this);for(var i=0;e.length>i;i++)L.DomEvent.off(t,e[i],this._fireMouseEvent,this)}},_onMouseClick:function(t){this.hasEventListeners(t.type)&&L.DomEvent.stopPropagation(t),this.fire(t.type,{originalEvent:t})},_fireMouseEvent:function(t){this.fire(t.type,{originalEvent:t}),"contextmenu"===t.type&&this.hasEventListeners(t.type)&&L.DomEvent.preventDefault(t),"mousedown"!==t.type?L.DomEvent.stopPropagation(t):L.DomEvent.preventDefault(t)}}),L.BaseMarkerMethods={showLabel:function(){return this.label&&this._map&&(this.label.setLatLng(this._latlng),this._map.showLabel(this.label)),this},hideLabel:function(){return this.label&&this.label.close(),this},setLabelNoHide:function(t){this._labelNoHide!==t&&(this._labelNoHide=t,t?(this._removeLabelRevealHandlers(),this.showLabel()):(this._addLabelRevealHandlers(),this.hideLabel()))},bindLabel:function(t,e){var i=this.options.icon?this.options.icon.options.labelAnchor:this.options.labelAnchor,n=L.point(i)||L.point(0,0);return n=n.add(L.Label.prototype.options.offset),e&&e.offset&&(n=n.add(e.offset)),e=L.Util.extend({offset:n},e),this._labelNoHide=e.noHide,this.label||(this._labelNoHide||this._addLabelRevealHandlers(),this.on("remove",this.hideLabel,this).on("move",this._moveLabel,this).on("add",this._onMarkerAdd,this),this._hasLabelHandlers=!0),this.label=new L.Label(e,this).setContent(t),this},unbindLabel:function(){return this.label&&(this.hideLabel(),this.label=null,this._hasLabelHandlers&&(this._labelNoHide||this._removeLabelRevealHandlers(),this.off("remove",this.hideLabel,this).off("move",this._moveLabel,this).off("add",this._onMarkerAdd,this)),this._hasLabelHandlers=!1),this},updateLabelContent:function(t){this.label&&this.label.setContent(t)},getLabel:function(){return this.label},_onMarkerAdd:function(){this._labelNoHide&&this.showLabel()},_addLabelRevealHandlers:function(){this.on("mouseover",this.showLabel,this).on("mouseout",this.hideLabel,this),L.Browser.touch&&this.on("click",this.showLabel,this)},_removeLabelRevealHandlers:function(){this.off("mouseover",this.showLabel,this).off("mouseout",this.hideLabel,this),L.Browser.touch&&this.off("click",this.showLabel,this)},_moveLabel:function(t){this.label.setLatLng(t.latlng)}},L.Icon.Default.mergeOptions({labelAnchor:new L.Point(9,-20)}),L.Marker.mergeOptions({icon:new L.Icon.Default}),L.Marker.include(L.BaseMarkerMethods),L.Marker.include({_originalUpdateZIndex:L.Marker.prototype._updateZIndex,_updateZIndex:function(t){var e=this._zIndex+t;this._originalUpdateZIndex(t),this.label&&this.label.updateZIndex(e)},_originalSetOpacity:L.Marker.prototype.setOpacity,setOpacity:function(t,e){this.options.labelHasSemiTransparency=e,this._originalSetOpacity(t)},_originalUpdateOpacity:L.Marker.prototype._updateOpacity,_updateOpacity:function(){var t=0===this.options.opacity?0:1;this._originalUpdateOpacity(),this.label&&this.label.setOpacity(this.options.labelHasSemiTransparency?this.options.opacity:t)},_originalSetLatLng:L.Marker.prototype.setLatLng,setLatLng:function(t){return this.label&&!this._labelNoHide&&this.hideLabel(),this._originalSetLatLng(t)}}),L.CircleMarker.mergeOptions({labelAnchor:new L.Point(0,0)}),L.CircleMarker.include(L.BaseMarkerMethods),L.Path.include({bindLabel:function(t,e){return this.label&&this.label.options===e||(this.label=new L.Label(e,this)),this.label.setContent(t),this._showLabelAdded||(this.on("mouseover",this._showLabel,this).on("mousemove",this._moveLabel,this).on("mouseout remove",this._hideLabel,this),L.Browser.touch&&this.on("click",this._showLabel,this),this._showLabelAdded=!0),this},unbindLabel:function(){return this.label&&(this._hideLabel(),this.label=null,this._showLabelAdded=!1,this.off("mouseover",this._showLabel,this).off("mousemove",this._moveLabel,this).off("mouseout remove",this._hideLabel,this)),this},updateLabelContent:function(t){this.label&&this.label.setContent(t)},_showLabel:function(t){this.label.setLatLng(t.latlng),this._map.showLabel(this.label)},_moveLabel:function(t){this.label.setLatLng(t.latlng)},_hideLabel:function(){this.label.close()}}),L.Map.include({showLabel:function(t){return this.addLayer(t)}}),L.FeatureGroup.include({clearLayers:function(){return this.unbindLabel(),this.eachLayer(this.removeLayer,this),this},bindLabel:function(t,e){return this.invoke("bindLabel",t,e)},unbindLabel:function(){return this.invoke("unbindLabel")},updateLabelContent:function(t){this.invoke("updateLabelContent",t)}})})(this,document); \ No newline at end of file +(function(){L.labelVersion="0.2.1",L.Label=L.Class.extend({includes:L.Mixin.Events,options:{className:"",clickable:!1,direction:"right",noHide:!1,offset:[12,-15],opacity:1,zoomAnimation:!0},initialize:function(t,e){L.setOptions(this,t),this._source=e,this._animated=L.Browser.any3d&&this.options.zoomAnimation,this._isOpen=!1},onAdd:function(t){this._map=t,this._pane=this._source instanceof L.Marker?t._panes.markerPane:t._panes.popupPane,this._container||this._initLayout(),this._pane.appendChild(this._container),this._initInteraction(),this._update(),this.setOpacity(this.options.opacity),t.on("moveend",this._onMoveEnd,this).on("viewreset",this._onViewReset,this),this._animated&&t.on("zoomanim",this._zoomAnimation,this),L.Browser.touch&&!this.options.noHide&&L.DomEvent.on(this._container,"click",this.close,this)},onRemove:function(t){this._pane.removeChild(this._container),t.off({zoomanim:this._zoomAnimation,moveend:this._onMoveEnd,viewreset:this._onViewReset},this),this._removeInteraction(),this._map=null},setLatLng:function(t){return this._latlng=L.latLng(t),this._map&&this._updatePosition(),this},setContent:function(t){return this._previousContent=this._content,this._content=t,this._updateContent(),this},close:function(){var t=this._map;t&&(L.Browser.touch&&!this.options.noHide&&L.DomEvent.off(this._container,"click",this.close),t.removeLayer(this))},updateZIndex:function(t){this._zIndex=t,this._container&&this._zIndex&&(this._container.style.zIndex=t)},setOpacity:function(t){this.options.opacity=t,this._container&&L.DomUtil.setOpacity(this._container,t)},_initLayout:function(){this._container=L.DomUtil.create("div","leaflet-label "+this.options.className+" leaflet-zoom-animated"),this.updateZIndex(this._zIndex)},_update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updatePosition(),this._container.style.visibility="")},_updateContent:function(){this._content&&this._map&&this._prevContent!==this._content&&"string"==typeof this._content&&(this._container.innerHTML=this._content,this._prevContent=this._content,this._labelWidth=this._container.offsetWidth)},_updatePosition:function(){var t=this._map.latLngToLayerPoint(this._latlng);this._setPosition(t)},_setPosition:function(t){var e=this._map,i=this._container,n=e.latLngToContainerPoint(e.getCenter()),o=e.layerPointToContainerPoint(t),s=this.options.direction,a=this._labelWidth,l=L.point(this.options.offset);"right"===s||"auto"===s&&o.xi;i++)L.DomEvent.on(t,e[i],this._fireMouseEvent,this)}},_removeInteraction:function(){if(this.options.clickable){var t=this._container,e=["dblclick","mousedown","mouseover","mouseout","contextmenu"];L.DomUtil.removeClass(t,"leaflet-clickable"),L.DomEvent.off(t,"click",this._onMouseClick,this);for(var i=0;e.length>i;i++)L.DomEvent.off(t,e[i],this._fireMouseEvent,this)}},_onMouseClick:function(t){this.hasEventListeners(t.type)&&L.DomEvent.stopPropagation(t),this.fire(t.type,{originalEvent:t})},_fireMouseEvent:function(t){this.fire(t.type,{originalEvent:t}),"contextmenu"===t.type&&this.hasEventListeners(t.type)&&L.DomEvent.preventDefault(t),"mousedown"!==t.type?L.DomEvent.stopPropagation(t):L.DomEvent.preventDefault(t)}}),L.BaseMarkerMethods={showLabel:function(){return this.label&&this._map&&(this.label.setLatLng(this._latlng),this._map.showLabel(this.label)),this},hideLabel:function(){return this.label&&this.label.close(),this},setLabelNoHide:function(t){this._labelNoHide!==t&&(this._labelNoHide=t,t?(this._removeLabelRevealHandlers(),this.showLabel()):(this._addLabelRevealHandlers(),this.hideLabel()))},bindLabel:function(t,e){var i=this.options.icon?this.options.icon.options.labelAnchor:this.options.labelAnchor,n=L.point(i)||L.point(0,0);return n=n.add(L.Label.prototype.options.offset),e&&e.offset&&(n=n.add(e.offset)),e=L.Util.extend({offset:n},e),this._labelNoHide=e.noHide,this.label||(this._labelNoHide||this._addLabelRevealHandlers(),this.on("remove",this.hideLabel,this).on("move",this._moveLabel,this).on("add",this._onMarkerAdd,this),this._hasLabelHandlers=!0),this.label=new L.Label(e,this).setContent(t),this},unbindLabel:function(){return this.label&&(this.hideLabel(),this.label=null,this._hasLabelHandlers&&(this._labelNoHide||this._removeLabelRevealHandlers(),this.off("remove",this.hideLabel,this).off("move",this._moveLabel,this).off("add",this._onMarkerAdd,this)),this._hasLabelHandlers=!1),this},updateLabelContent:function(t){this.label&&this.label.setContent(t)},getLabel:function(){return this.label},_onMarkerAdd:function(){this._labelNoHide&&this.showLabel()},_addLabelRevealHandlers:function(){this.on("mouseover",this.showLabel,this).on("mouseout",this.hideLabel,this),L.Browser.touch&&this.on("click",this.showLabel,this)},_removeLabelRevealHandlers:function(){this.off("mouseover",this.showLabel,this).off("mouseout",this.hideLabel,this),L.Browser.touch&&this.off("click",this.showLabel,this)},_moveLabel:function(t){this.label.setLatLng(t.latlng)}},L.Icon.Default.mergeOptions({labelAnchor:new L.Point(9,-20)}),L.Marker.mergeOptions({icon:new L.Icon.Default}),L.Marker.include(L.BaseMarkerMethods),L.Marker.include({_originalUpdateZIndex:L.Marker.prototype._updateZIndex,_updateZIndex:function(t){var e=this._zIndex+t;this._originalUpdateZIndex(t),this.label&&this.label.updateZIndex(e)},_originalSetOpacity:L.Marker.prototype.setOpacity,setOpacity:function(t,e){this.options.labelHasSemiTransparency=e,this._originalSetOpacity(t)},_originalUpdateOpacity:L.Marker.prototype._updateOpacity,_updateOpacity:function(){var t=0===this.options.opacity?0:1;this._originalUpdateOpacity(),this.label&&this.label.setOpacity(this.options.labelHasSemiTransparency?this.options.opacity:t)},_originalSetLatLng:L.Marker.prototype.setLatLng,setLatLng:function(t){return this.label&&!this._labelNoHide&&this.hideLabel(),this._originalSetLatLng(t)}}),L.CircleMarker.mergeOptions({labelAnchor:new L.Point(0,0)}),L.CircleMarker.include(L.BaseMarkerMethods),L.Path.include({bindLabel:function(t,e){return this.label&&this.label.options===e||(this.label=new L.Label(e,this)),this.label.setContent(t),this._showLabelAdded||(this.on("mouseover",this._showLabel,this).on("mousemove",this._moveLabel,this).on("mouseout remove",this._hideLabel,this),L.Browser.touch&&this.on("click",this._showLabel,this),this._showLabelAdded=!0),this},unbindLabel:function(){return this.label&&(this._hideLabel(),this.label=null,this._showLabelAdded=!1,this.off("mouseover",this._showLabel,this).off("mousemove",this._moveLabel,this).off("mouseout remove",this._hideLabel,this)),this},updateLabelContent:function(t){this.label&&this.label.setContent(t)},_showLabel:function(t){this.label.setLatLng(t.latlng),this._map.showLabel(this.label)},_moveLabel:function(t){this.label.setLatLng(t.latlng)},_hideLabel:function(){this.label.close()}}),L.Map.include({showLabel:function(t){return this.addLayer(t)}}),L.FeatureGroup.include({clearLayers:function(){return this.unbindLabel(),this.eachLayer(this.removeLayer,this),this},bindLabel:function(t,e){return this.invoke("bindLabel",t,e)},unbindLabel:function(){return this.invoke("unbindLabel")},updateLabelContent:function(t){this.invoke("updateLabelContent",t)}})})(this,document); diff --git a/lib/leg-narrative-view.js b/lib/leg-narrative-view.js index 2ab28f6..daef9be 100644 --- a/lib/leg-narrative-view.js +++ b/lib/leg-narrative-view.js @@ -2,8 +2,8 @@ var Handlebars = require('handlebars') var StepNarrativeView = require('./step-narrative-view') -var Backbone = window.Backbone -var _ = window._ +var Backbone = require('backbone') + var accessLegTemplate = Handlebars.compile(require('./templates/access-leg.html')) var transitLegTemplate = Handlebars.compile(require('./templates/transit-leg.html')) diff --git a/lib/plan-request.js b/lib/plan-request.js index 8907b57..96bbbbf 100644 --- a/lib/plan-request.js +++ b/lib/plan-request.js @@ -6,8 +6,8 @@ var log = require('./log')('plan-request') var PlanResponse = require('./plan-response') var utils = require('./utils') -var Backbone = window.Backbone -var $ = window.$ +var Backbone = require('backbone') +var $ = require('jquery') var PlanRequest = Backbone.Model.extend({ initialize: function (opts) { @@ -30,7 +30,7 @@ var PlanRequest = Backbone.Model.extend({ date: null, time: null, routerId: null, - arriveBy: null, + arriveBy: false, wheelchair: false, maxWalkDistance: 8046, walkSpeed: null, diff --git a/lib/plan-response-narrative-view.js b/lib/plan-response-narrative-view.js index 01eed7d..b481cd8 100644 --- a/lib/plan-response-narrative-view.js +++ b/lib/plan-response-narrative-view.js @@ -3,8 +3,8 @@ var Handlebars = require('handlebars') var log = require('./log')('plan-response-narrative-view') var ItineraryNarrativeView = require('./itinerary-narrative-view') -var Backbone = window.Backbone -var _ = window._ +var Backbone = require('backbone') + var narrativeNewTemplate = Handlebars.compile(require('./templates/narrative-new.html')) var narrativeAdjustTemplate = Handlebars.compile(require('./templates/narrative-adjust.html')) diff --git a/lib/plan-response-view.js b/lib/plan-response-view.js index 8f6505e..cfbd519 100644 --- a/lib/plan-response-view.js +++ b/lib/plan-response-view.js @@ -3,8 +3,8 @@ var ItineraryTopoView = require('./itinerary-topo-view') var log = require('./log')('plan-response-view') var PlanResponseNarrativeView = require('./plan-response-narrative-view') -var Backbone = window.Backbone -var _ = window._ +var Backbone = require('backbone') + module.exports = Backbone.View.extend({ initialize: function (options) { diff --git a/lib/plan-response.js b/lib/plan-response.js index eb64c3d..b8eebf3 100644 --- a/lib/plan-response.js +++ b/lib/plan-response.js @@ -1,5 +1,5 @@ -var Backbone = window.Backbone -var moment = window.moment +var Backbone = require('backbone') +var moment = require('moment') var PlanResponse = Backbone.Model.extend({ defaults: { diff --git a/lib/request-form-common.js b/lib/request-form-common.js index 73a4ea8..cb3797e 100644 --- a/lib/request-form-common.js +++ b/lib/request-form-common.js @@ -1,9 +1,11 @@ var Handlebars = require('handlebars') var haversine = require('haversine') var geocoder = require('./geocoder') -require('select2') +var select2 = require('select2') +require('select2/select2.css') +require('select2/select2-bootstrap.css') + -var _ = window._ /** * Creates a select2 widget for a provided input element with geocoding enabled diff --git a/lib/request-form-widget.js b/lib/request-form-widget.js index 226cbd3..ca46088 100644 --- a/lib/request-form-widget.js +++ b/lib/request-form-widget.js @@ -1,8 +1,10 @@ -var Backbone = window.Backbone -var _ = window._ +var Backbone = require('backbone') + var rfCommon = require('./request-form-common') +require("eonasdan-bootstrap-datetimepicker") + /** * View to help embed a simple otp.js search form on a third party website. View * should ne created with 'el' set to the element containing the form and the diff --git a/lib/request-form.js b/lib/request-form.js index b47e36b..c505f2f 100644 --- a/lib/request-form.js +++ b/lib/request-form.js @@ -5,10 +5,11 @@ var geocoder = require('./geocoder') var log = require('./log')('request-form') var rfCommon = require('./request-form-common') -var Backbone = window.Backbone -var moment = window.moment -var $ = window.$ -var _ = window._ +var Backbone = require('backbone') +var moment = require('moment') +var $ = require("jquery") + +require("eonasdan-bootstrap-datetimepicker") var requestFormTemplate = Handlebars.compile(require('./templates/request-form.html')) @@ -41,8 +42,8 @@ var RequestView = Backbone.View.extend({ this.model.set({ arriveBy: true, - date: date.format('MM-DD-YYYY'), - time: date.format('hh:mm a') + date: date.format('MM/DD/YYYY'), + time: date.format('hh:mm A') }) }, @@ -53,8 +54,8 @@ var RequestView = Backbone.View.extend({ this.model.set({ arriveBy: false, - date: date.format('MM-DD-YYYY'), - time: date.format('hh:mm a') + date: date.format('MM/DD/YYYY'), + time: date.format('hh:mm A') }) }, @@ -111,12 +112,12 @@ var RequestView = Backbone.View.extend({ if (data.attributes.date) { var date = moment(data.attributes.date, 'MM-DD-YYYY').toDate() - view.datepicker.setDate(date) + view.datepicker.date(date) } if (data.attributes.time) { var time = moment(data.attributes.time, 'hh:mm a').toDate() - view.timepicker.setDate(time) + view.timepicker.date(time) } if (data.attributes.wheelchair === 'true') { @@ -196,23 +197,21 @@ var RequestView = Backbone.View.extend({ this.$('#hideSettings').hide() this.$('#hidableSettings').hide() this.$('#date').datetimepicker({ - pickTime: false + format: 'MM/DD/YYYY' }) this.datepicker = this.$('#date').data('DateTimePicker') - this.datepicker.setDate(new Date()) + this.datepicker.date(new Date()) this.$('#date').on('dp.change', function () { view.changeForm() }) this.$('#time').datetimepicker({ - pick12HourFormat: true, - pickSeconds: false, - pickDate: false + format: 'hh:mm A' }) this.timepicker = this.$('#time').data('DateTimePicker') - this.timepicker.setDate(new Date()) + this.timepicker.date(new Date()) this.$('#time').on('dp.change', function () { view.changeForm() }) diff --git a/lib/request-map-view.js b/lib/request-map-view.js index 83c4e0a..4fe51ba 100644 --- a/lib/request-map-view.js +++ b/lib/request-map-view.js @@ -2,10 +2,12 @@ var Handlebars = require('handlebars') var log = require('./log')('map-views') -var Backbone = window.Backbone -var L = window.L -var $ = window.$ -var _ = window._ +var Backbone = require('backbone') +var L = require('leaflet') +var $ = require('jquery') + + +require('./leaflet.label/leaflet.label') var mapContextMenuTemplate = Handlebars.compile(require('./templates/map-context-menu.html')) diff --git a/lib/step-narrative-view.js b/lib/step-narrative-view.js index 466eff9..589a87b 100644 --- a/lib/step-narrative-view.js +++ b/lib/step-narrative-view.js @@ -2,8 +2,7 @@ var Handlebars = require('handlebars') var utils = require('./utils') -var Backbone = window.Backbone -var _ = window._ +var Backbone = require('backbone') var stepTemplate = Handlebars.compile(require('./templates/step.html')) diff --git a/lib/stop.js b/lib/stop.js index f6932e1..30641e7 100644 --- a/lib/stop.js +++ b/lib/stop.js @@ -1,4 +1,4 @@ -var Backbone = window.Backbone +var Backbone = require('backbone') var Stop = Backbone.Model.extend({ initialize: function () {}, diff --git a/lib/stops-in-rectangle-request.js b/lib/stops-in-rectangle-request.js index 367aa86..9d4114a 100644 --- a/lib/stops-in-rectangle-request.js +++ b/lib/stops-in-rectangle-request.js @@ -1,8 +1,8 @@ var StopsResponse = require('./stops-response') var utils = require('./utils') -var Backbone = window.Backbone -var $ = window.$ +var Backbone = require('backbone') +var $ = require('jquery') var StopsInRectangleRequest = Backbone.Model.extend({ initialize: function (opts) { diff --git a/lib/stops-request-map-view.js b/lib/stops-request-map-view.js index 88e7a71..e4ba2e0 100644 --- a/lib/stops-request-map-view.js +++ b/lib/stops-request-map-view.js @@ -1,5 +1,5 @@ -var Backbone = window.Backbone -var _ = window._ +var Backbone = require('backbone') + var StopsRequestMapView = Backbone.View.extend({ initialize: function (options) { diff --git a/lib/stops-response-map-view.js b/lib/stops-response-map-view.js index d4ce6fc..f9c4dfb 100644 --- a/lib/stops-response-map-view.js +++ b/lib/stops-response-map-view.js @@ -1,6 +1,6 @@ -var Backbone = window.Backbone -var L = window.L -var _ = window._ +var Backbone = require('backbone') +var L = require('leaflet') + var StopsResponseMapView = Backbone.View.extend({ initialize: function (options) { diff --git a/lib/stops-response.js b/lib/stops-response.js index 920b41e..c07298b 100644 --- a/lib/stops-response.js +++ b/lib/stops-response.js @@ -1,7 +1,7 @@ var Stops = require('./stops') -var Backbone = window.Backbone -var _ = window._ +var Backbone = require('backbone') + var StopsResponse = Backbone.Model.extend({ initialize: function () { diff --git a/lib/stops.js b/lib/stops.js index bdcd54c..48f4a90 100644 --- a/lib/stops.js +++ b/lib/stops.js @@ -1,6 +1,6 @@ var Stop = require('./stop') -var Backbone = window.Backbone +var Backbone = require('backbone') var Stops = Backbone.Collection.extend({ model: Stop diff --git a/lib/utils.js b/lib/utils.js index 792a92c..03d50b0 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,7 +1,7 @@ 'use strict' -var L = window.L -var moment = window.moment +var L = require('leaflet') +var moment = require('moment') module.exports.filterParams = function filterParams (data) { var filtered = {} diff --git a/local/leaflet.label/component.json b/local/leaflet.label/component.json deleted file mode 100644 index 7e7c6de..0000000 --- a/local/leaflet.label/component.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "leaflet.label", - "version": "0.2.1", - "description": "", - "main" : "leaflet.label-src.js", - "scripts": [ - "leaflet.label-src.js" - ], - "styles": [ - "leaflet.label.css" - ] -} \ No newline at end of file diff --git a/package.json b/package.json index 94eb253..f370447 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,17 @@ "url": "git://github.com/conveyal/otp.js.git" }, "devDependencies": { + "@webpack-cli/init": "^0.1.5", "babel-plugin-syntax-dynamic-import": "^6.18.0", - "css-loader": "^2.1.1", + "debug": "^4.1.0", + "es5-shim": "^4.5.13", + "es6-shim": "^0.35.0", + "file-loader": "^3.0.1", + "format-package": "^4.5.0", + "html-loader": "^0.5.5", + "inquirer": "^6.3.1", "serve": "^1.4.0", - "standard": "8.3.0", + "standard": "^8.3.0", "style-loader": "^0.23.1", "uglifyjs-webpack-plugin": "^2.1.2", "webpack": "^4.31.0", @@ -22,6 +29,8 @@ }, "scripts": { "start": "serve client", + "watch": "webpack --watch", + "build": "webpack", "format": "standard --format lib/*.js client.js config.js index.js", "lint": "standard --verbose lib/*.js client.js config.js index.js" }, @@ -34,7 +43,17 @@ "test": "test" }, "dependencies": { - "@webpack-cli/init": "^0.1.5", - "debug": "^4.1.0" + "backbone": "^1.2.1", + "bootstrap": "^3.3.5", + "css-loader": "^2.1.1", + "eonasdan-bootstrap-datetimepicker": "^3.1.3", + "handlebars": "^4.1.2", + "haversine": "^1.1.1", + "jquery": "^1.11.3", + "leaflet": "^0.7.3", + "moment": "^2.10.3", + "raphael": "^2.1.4", + "select2": "^3.5.1", + "underscore": "^1.8.3" } } diff --git a/webpack.config.js b/webpack.config.js index ad41977..2d429b3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -25,49 +25,54 @@ const path = require('path'); const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); module.exports = { - module: { - rules: [ - { - test: /\.css$/, + entry: [ + "./lib" + ], + output: { + filename: "build.js", + path: path.resolve(__dirname, './client/build'), + publicPath: './build' + }, + module: { + rules: [ + { + test: /\.css$/, + use: ['style-loader', 'css-loader?sourceMap'], + }, + { + test: /\.html$/, + use: [ + { + loader: 'html-loader', + options: { + attrs: [':data-src'] + } + } + ] + }, + { + test: /\.(gif|png|jpe?g|svg)$/i, + use: [ 'file-loader?name=/images/[name]-[hash].[ext]' ], - use: [ - { - loader: 'style-loader', - - options: { - sourceMap: true - } - }, - { - loader: 'css-loader' - } - ] - } - ] - }, - - output: { - chunkFilename: '[name].[chunkhash].js', - filename: '[name].[chunkhash].js', - path: path.resolve(__dirname, './client/build') - }, - - mode: 'development', - plugins: [new UglifyJSPlugin()], - - optimization: { - splitChunks: { - cacheGroups: { - vendors: { - priority: -10, - test: /[\\/]node_modules[\\/]/ - } - }, - - chunks: 'async', - minChunks: 1, - minSize: 30000, - name: true - } - } + } + ] + }, + mode: 'development', + plugins: [new UglifyJSPlugin()], + resolve: { + alias: { + handlebars: 'handlebars/dist/handlebars.min.js' + } + }, + externals: { + 'backbone': 'Backbone', + 'bootstrap': 'bootstrap', + 'jquery': 'jQuery', + 'L': 'leaflet', + 'moment': 'moment', + 'underscore': 'underscore', + 'raphael': 'Raphael', + 'window.L': 'leaflet', + '$': 'jQuery' + } }; From 3bb66097a765a70994fdd23d7a9c37762fcd9977 Mon Sep 17 00:00:00 2001 From: Cyrille Courtiere Date: Tue, 14 May 2019 17:57:55 +0200 Subject: [PATCH 4/7] vendor bootstrap-datetimepicker (not iso between npm and cloudflare) --- .../bootstrap-datetimepicker.css | 238 ++++++++++++++++++ .../bootstrap-datetimepicker.min.js | 6 + lib/entry.js | 1 + lib/request-form-widget.js | 3 +- lib/request-form.js | 11 +- 5 files changed, 251 insertions(+), 8 deletions(-) create mode 100644 lib/bootstrap-datetimepicker/bootstrap-datetimepicker.css create mode 100644 lib/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js diff --git a/lib/bootstrap-datetimepicker/bootstrap-datetimepicker.css b/lib/bootstrap-datetimepicker/bootstrap-datetimepicker.css new file mode 100644 index 0000000..bd37b08 --- /dev/null +++ b/lib/bootstrap-datetimepicker/bootstrap-datetimepicker.css @@ -0,0 +1,238 @@ +/*! + * Datetimepicker for Bootstrap v3 +//! version : 3.1.3 + * https://github.com/Eonasdan/bootstrap-datetimepicker/ + */ +.bootstrap-datetimepicker-widget { + top: 0; + left: 0; + width: 250px; + padding: 4px; + margin-top: 1px; + z-index: 99999 !important; + border-radius: 4px; +} +.bootstrap-datetimepicker-widget.timepicker-sbs { + width: 600px; +} +.bootstrap-datetimepicker-widget.bottom:before { + content: ''; + display: inline-block; + border-left: 7px solid transparent; + border-right: 7px solid transparent; + border-bottom: 7px solid #ccc; + border-bottom-color: rgba(0, 0, 0, 0.2); + position: absolute; + top: -7px; + left: 7px; +} +.bootstrap-datetimepicker-widget.bottom:after { + content: ''; + display: inline-block; + border-left: 6px solid transparent; + border-right: 6px solid transparent; + border-bottom: 6px solid white; + position: absolute; + top: -6px; + left: 8px; +} +.bootstrap-datetimepicker-widget.top:before { + content: ''; + display: inline-block; + border-left: 7px solid transparent; + border-right: 7px solid transparent; + border-top: 7px solid #ccc; + border-top-color: rgba(0, 0, 0, 0.2); + position: absolute; + bottom: -7px; + left: 6px; +} +.bootstrap-datetimepicker-widget.top:after { + content: ''; + display: inline-block; + border-left: 6px solid transparent; + border-right: 6px solid transparent; + border-top: 6px solid white; + position: absolute; + bottom: -6px; + left: 7px; +} +.bootstrap-datetimepicker-widget .dow { + width: 14.2857%; +} +.bootstrap-datetimepicker-widget.pull-right:before { + left: auto; + right: 6px; +} +.bootstrap-datetimepicker-widget.pull-right:after { + left: auto; + right: 7px; +} +.bootstrap-datetimepicker-widget > ul { + list-style-type: none; + margin: 0; +} +.bootstrap-datetimepicker-widget a[data-action] { + padding: 6px 0; +} +.bootstrap-datetimepicker-widget a[data-action]:active { + box-shadow: none; +} +.bootstrap-datetimepicker-widget .timepicker-hour, +.bootstrap-datetimepicker-widget .timepicker-minute, +.bootstrap-datetimepicker-widget .timepicker-second { + width: 54px; + font-weight: bold; + font-size: 1.2em; + margin: 0; +} +.bootstrap-datetimepicker-widget button[data-action] { + padding: 6px; +} +.bootstrap-datetimepicker-widget table[data-hour-format="12"] .separator { + width: 4px; + padding: 0; + margin: 0; +} +.bootstrap-datetimepicker-widget .datepicker > div { + display: none; +} +.bootstrap-datetimepicker-widget .picker-switch { + text-align: center; +} +.bootstrap-datetimepicker-widget table { + width: 100%; + margin: 0; +} +.bootstrap-datetimepicker-widget td, +.bootstrap-datetimepicker-widget th { + text-align: center; + border-radius: 4px; +} +.bootstrap-datetimepicker-widget td { + height: 54px; + line-height: 54px; + width: 54px; +} +.bootstrap-datetimepicker-widget td.cw { + font-size: 10px; + height: 20px; + line-height: 20px; + color: #777777; +} +.bootstrap-datetimepicker-widget td.day { + height: 20px; + line-height: 20px; + width: 20px; +} +.bootstrap-datetimepicker-widget td.day:hover, +.bootstrap-datetimepicker-widget td.hour:hover, +.bootstrap-datetimepicker-widget td.minute:hover, +.bootstrap-datetimepicker-widget td.second:hover { + background: #eeeeee; + cursor: pointer; +} +.bootstrap-datetimepicker-widget td.old, +.bootstrap-datetimepicker-widget td.new { + color: #777777; +} +.bootstrap-datetimepicker-widget td.today { + position: relative; +} +.bootstrap-datetimepicker-widget td.today:before { + content: ''; + display: inline-block; + border-left: 7px solid transparent; + border-bottom: 7px solid #428bca; + border-top-color: rgba(0, 0, 0, 0.2); + position: absolute; + bottom: 4px; + right: 4px; +} +.bootstrap-datetimepicker-widget td.active, +.bootstrap-datetimepicker-widget td.active:hover { + background-color: #428bca; + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); +} +.bootstrap-datetimepicker-widget td.active.today:before { + border-bottom-color: #fff; +} +.bootstrap-datetimepicker-widget td.disabled, +.bootstrap-datetimepicker-widget td.disabled:hover { + background: none; + color: #777777; + cursor: not-allowed; +} +.bootstrap-datetimepicker-widget td span { + display: inline-block; + width: 54px; + height: 54px; + line-height: 54px; + margin: 2px 1.5px; + cursor: pointer; + border-radius: 4px; +} +.bootstrap-datetimepicker-widget td span:hover { + background: #eeeeee; +} +.bootstrap-datetimepicker-widget td span.active { + background-color: #428bca; + color: #ffffff; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); +} +.bootstrap-datetimepicker-widget td span.old { + color: #777777; +} +.bootstrap-datetimepicker-widget td span.disabled, +.bootstrap-datetimepicker-widget td span.disabled:hover { + background: none; + color: #777777; + cursor: not-allowed; +} +.bootstrap-datetimepicker-widget th { + height: 20px; + line-height: 20px; + width: 20px; +} +.bootstrap-datetimepicker-widget th.picker-switch { + width: 145px; +} +.bootstrap-datetimepicker-widget th.next, +.bootstrap-datetimepicker-widget th.prev { + font-size: 21px; +} +.bootstrap-datetimepicker-widget th.disabled, +.bootstrap-datetimepicker-widget th.disabled:hover { + background: none; + color: #777777; + cursor: not-allowed; +} +.bootstrap-datetimepicker-widget thead tr:first-child th { + cursor: pointer; +} +.bootstrap-datetimepicker-widget thead tr:first-child th:hover { + background: #eeeeee; +} +.input-group.date .input-group-addon span { + display: block; + cursor: pointer; + width: 16px; + height: 16px; +} +.bootstrap-datetimepicker-widget.left-oriented:before { + left: auto; + right: 6px; +} +.bootstrap-datetimepicker-widget.left-oriented:after { + left: auto; + right: 7px; +} +.bootstrap-datetimepicker-widget ul.list-unstyled li div.timepicker div.timepicker-picker table.table-condensed tbody > tr > td { + padding: 0px !important; +} +@media screen and (max-width: 767px) { + .bootstrap-datetimepicker-widget.timepicker-sbs { + width: 283px; + } +} diff --git a/lib/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js b/lib/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js new file mode 100644 index 0000000..0f61115 --- /dev/null +++ b/lib/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js @@ -0,0 +1,6 @@ +/*! + * Datetimepicker for Bootstrap v3 +//! version : 3.1.3 + * https://github.com/Eonasdan/bootstrap-datetimepicker/ + */ +!function(a,b){"use strict";if("function"==typeof define&&define.amd)define(["jquery","moment"],b);else if("object"==typeof exports)b(require("jquery"),require("moment"));else{if(!jQuery)throw new Error("bootstrap-datetimepicker requires jQuery to be loaded first");if(!moment)throw new Error("bootstrap-datetimepicker requires moment.js to be loaded first");b(a.jQuery,moment)}}(this,function(a,b){"use strict";if("undefined"==typeof b)throw new Error("momentjs is required");var c=0,d=function(d,e){var f,g=a.fn.datetimepicker.defaults,h={time:"glyphicon glyphicon-time",date:"glyphicon glyphicon-calendar",up:"glyphicon glyphicon-chevron-up",down:"glyphicon glyphicon-chevron-down"},i=this,j=!1,k=function(){var f,j,k=!1;if(i.options=a.extend({},g,e),i.options.icons=a.extend({},h,i.options.icons),i.element=a(d),m(),!i.options.pickTime&&!i.options.pickDate)throw new Error("Must choose at least one picker");if(i.id=c++,b.locale(i.options.language),i.date=b(),i.unset=!1,i.isInput=i.element.is("input"),i.component=!1,i.element.hasClass("input-group")&&(i.component=i.element.find(0===i.element.find(".datepickerbutton").size()?'[class^="input-group-"]':".datepickerbutton")),i.format=i.options.format,f=b().localeData(),i.format||(i.format=i.options.pickDate?f.longDateFormat("L"):"",i.options.pickDate&&i.options.pickTime&&(i.format+=" "),i.format+=i.options.pickTime?f.longDateFormat("LT"):"",i.options.useSeconds&&(-1!==f.longDateFormat("LT").indexOf(" A")?i.format=i.format.split(" A")[0]+":ss A":i.format+=":ss")),i.use24hours=i.format.toLowerCase().indexOf("a")<0&&i.format.indexOf("h")<0,i.component&&(k=i.component.find("span")),i.options.pickTime&&k&&k.addClass(i.options.icons.time),i.options.pickDate&&k&&(k.removeClass(i.options.icons.time),k.addClass(i.options.icons.date)),i.options.widgetParent="string"==typeof i.options.widgetParent&&i.options.widgetParent||i.element.parents().filter(function(){return"scroll"===a(this).css("overflow-y")}).get(0)||"body",i.widget=a(Q()).appendTo(i.options.widgetParent),i.minViewMode=i.options.minViewMode||0,"string"==typeof i.minViewMode)switch(i.minViewMode){case"months":i.minViewMode=1;break;case"years":i.minViewMode=2;break;default:i.minViewMode=0}if(i.viewMode=i.options.viewMode||0,"string"==typeof i.viewMode)switch(i.viewMode){case"months":i.viewMode=1;break;case"years":i.viewMode=2;break;default:i.viewMode=0}i.viewMode=Math.max(i.viewMode,i.minViewMode),i.options.disabledDates=O(i.options.disabledDates),i.options.enabledDates=O(i.options.enabledDates),i.startViewMode=i.viewMode,i.setMinDate(i.options.minDate),i.setMaxDate(i.options.maxDate),r(),s(),u(),v(),w(),q(),E(),l().prop("disabled")||F(),""!==i.options.defaultDate&&""===l().val()&&i.setValue(i.options.defaultDate),1!==i.options.minuteStepping&&(j=i.options.minuteStepping,i.date.minutes(Math.round(i.date.minutes()/j)*j%60).seconds(0))},l=function(){var a;if(i.isInput)return i.element;if(a=i.element.find(".datepickerinput"),0===a.size())a=i.element.find("input");else if(!a.is("input"))throw new Error('CSS class "datepickerinput" cannot be applied to non input element');return a},m=function(){var a;a=i.element.is("input")?i.element.data():i.element.find("input").data(),void 0!==a.dateFormat&&(i.options.format=a.dateFormat),void 0!==a.datePickdate&&(i.options.pickDate=a.datePickdate),void 0!==a.datePicktime&&(i.options.pickTime=a.datePicktime),void 0!==a.dateUseminutes&&(i.options.useMinutes=a.dateUseminutes),void 0!==a.dateUseseconds&&(i.options.useSeconds=a.dateUseseconds),void 0!==a.dateUsecurrent&&(i.options.useCurrent=a.dateUsecurrent),void 0!==a.calendarWeeks&&(i.options.calendarWeeks=a.calendarWeeks),void 0!==a.dateMinutestepping&&(i.options.minuteStepping=a.dateMinutestepping),void 0!==a.dateMindate&&(i.options.minDate=a.dateMindate),void 0!==a.dateMaxdate&&(i.options.maxDate=a.dateMaxdate),void 0!==a.dateShowtoday&&(i.options.showToday=a.dateShowtoday),void 0!==a.dateCollapse&&(i.options.collapse=a.dateCollapse),void 0!==a.dateLanguage&&(i.options.language=a.dateLanguage),void 0!==a.dateDefaultdate&&(i.options.defaultDate=a.dateDefaultdate),void 0!==a.dateDisableddates&&(i.options.disabledDates=a.dateDisableddates),void 0!==a.dateEnableddates&&(i.options.enabledDates=a.dateEnableddates),void 0!==a.dateIcons&&(i.options.icons=a.dateIcons),void 0!==a.dateUsestrict&&(i.options.useStrict=a.dateUsestrict),void 0!==a.dateDirection&&(i.options.direction=a.dateDirection),void 0!==a.dateSidebyside&&(i.options.sideBySide=a.dateSidebyside),void 0!==a.dateDaysofweekdisabled&&(i.options.daysOfWeekDisabled=a.dateDaysofweekdisabled)},n=function(){var b,c="absolute",d=i.component?i.component.offset():i.element.offset(),e=a(window);i.width=i.component?i.component.outerWidth():i.element.outerWidth(),d.top=d.top+i.element.outerHeight(),"up"===i.options.direction?b="top":"bottom"===i.options.direction?b="bottom":"auto"===i.options.direction&&(b=d.top+i.widget.height()>e.height()+e.scrollTop()&&i.widget.height()+i.element.outerHeight()"),e=b.weekdaysMin();if(i.options.calendarWeeks===!0&&d.append('#'),0===b().localeData()._week.dow)for(c=0;7>c;c++)d.append(''+e[c]+"");else for(c=1;8>c;c++)d.append(7===c?''+e[0]+"":''+e[c]+"");i.widget.find(".datepicker-days thead").append(d)},s=function(){b.locale(i.options.language);var a,c="",d=b.monthsShort();for(a=0;12>a;a++)c+=''+d[a]+"";i.widget.find(".datepicker-months td").append(c)},t=function(){if(i.options.pickDate){b.locale(i.options.language);var c,d,e,f,g,h,j,k,l,m=i.viewDate.year(),n=i.viewDate.month(),o=i.options.minDate.year(),p=i.options.minDate.month(),q=i.options.maxDate.year(),r=i.options.maxDate.month(),s=[],t=b.months();for(i.widget.find(".datepicker-days").find(".disabled").removeClass("disabled"),i.widget.find(".datepicker-months").find(".disabled").removeClass("disabled"),i.widget.find(".datepicker-years").find(".disabled").removeClass("disabled"),i.widget.find(".datepicker-days th:eq(1)").text(t[n]+" "+m),d=b(i.viewDate,i.format,i.options.useStrict).subtract(1,"months"),j=d.daysInMonth(),d.date(j).startOf("week"),(m===o&&p>=n||o>m)&&i.widget.find(".datepicker-days th:eq(0)").addClass("disabled"),(m===q&&n>=r||m>q)&&i.widget.find(".datepicker-days th:eq(2)").addClass("disabled"),e=b(d).add(42,"d");d.isBefore(e);){if(d.weekday()===b().startOf("week").weekday()&&(f=a(""),s.push(f),i.options.calendarWeeks===!0&&f.append(''+d.week()+"")),g="",d.year()m||d.year()===m&&d.month()>n)&&(g+=" new"),d.isSame(b({y:i.date.year(),M:i.date.month(),d:i.date.date()}))&&(g+=" active"),(M(d,"day")||!N(d))&&(g+=" disabled"),i.options.showToday===!0&&d.isSame(b(),"day")&&(g+=" today"),i.options.daysOfWeekDisabled)for(h=0;h'+d.date()+""),c=d.date(),d.add(1,"d"),c===d.date()&&d.add(1,"d")}for(i.widget.find(".datepicker-days tbody").empty().append(s),l=i.date.year(),t=i.widget.find(".datepicker-months").find("th:eq(1)").text(m).end().find("span").removeClass("active"),l===m&&t.eq(i.date.month()).addClass("active"),o>m-1&&i.widget.find(".datepicker-months th:eq(0)").addClass("disabled"),m+1>q&&i.widget.find(".datepicker-months th:eq(2)").addClass("disabled"),h=0;12>h;h++)m===o&&p>h||o>m?a(t[h]).addClass("disabled"):(m===q&&h>r||m>q)&&a(t[h]).addClass("disabled");for(s="",m=10*parseInt(m/10,10),k=i.widget.find(".datepicker-years").find("th:eq(1)").text(m+"-"+(m+9)).parents("table").find("td"),i.widget.find(".datepicker-years").find("th").removeClass("disabled"),o>m&&i.widget.find(".datepicker-years").find("th:eq(0)").addClass("disabled"),m+9>q&&i.widget.find(".datepicker-years").find("th:eq(2)").addClass("disabled"),m-=1,h=-1;11>h;h++)s+='m||m>q?" disabled":"")+'">'+m+"",m+=1;k.html(s)}},u=function(){b.locale(i.options.language);var a,c,d,e=i.widget.find(".timepicker .timepicker-hours table"),f="";if(e.parent().hide(),i.use24hours)for(a=0,c=0;6>c;c+=1){for(f+="",d=0;4>d;d+=1)f+=''+P(a.toString())+"",a++;f+=""}else for(a=1,c=0;3>c;c+=1){for(f+="",d=0;4>d;d+=1)f+=''+P(a.toString())+"",a++;f+=""}e.html(f)},v=function(){var a,b,c=i.widget.find(".timepicker .timepicker-minutes table"),d="",e=0,f=i.options.minuteStepping;for(c.parent().hide(),1===f&&(f=5),a=0;ab;b+=1)60>e?(d+=''+P(e.toString())+"",e+=f):d+="";d+=""}c.html(d)},w=function(){var a,b,c=i.widget.find(".timepicker .timepicker-seconds table"),d="",e=0;for(c.parent().hide(),a=0;3>a;a++){for(d+="",b=0;4>b;b+=1)d+=''+P(e.toString())+"",e+=5;d+=""}c.html(d)},x=function(){if(i.date){var a=i.widget.find(".timepicker span[data-time-component]"),b=i.date.hours(),c=i.date.format("A");i.use24hours||(0===b?b=12:12!==b&&(b%=12),i.widget.find(".timepicker [data-action=togglePeriod]").text(c)),a.filter("[data-time-component=hours]").text(P(b)),a.filter("[data-time-component=minutes]").text(P(i.date.minutes())),a.filter("[data-time-component=seconds]").text(P(i.date.second()))}},y=function(c){c.stopPropagation(),c.preventDefault(),i.unset=!1;var d,e,f,g,h=a(c.target).closest("span, td, th"),j=b(i.date);if(1===h.length&&!h.is(".disabled"))switch(h[0].nodeName.toLowerCase()){case"th":switch(h[0].className){case"picker-switch":E(1);break;case"prev":case"next":f=R.modes[i.viewMode].navStep,"prev"===h[0].className&&(f=-1*f),i.viewDate.add(f,R.modes[i.viewMode].navFnc),t()}break;case"span":h.is(".month")?(d=h.parent().find("span").index(h),i.viewDate.month(d)):(e=parseInt(h.text(),10)||0,i.viewDate.year(e)),i.viewMode===i.minViewMode&&(i.date=b({y:i.viewDate.year(),M:i.viewDate.month(),d:i.viewDate.date(),h:i.date.hours(),m:i.date.minutes(),s:i.date.seconds()}),K(),o(j,c.type)),E(-1),t();break;case"td":h.is(".day")&&(g=parseInt(h.text(),10)||1,d=i.viewDate.month(),e=i.viewDate.year(),h.is(".old")?0===d?(d=11,e-=1):d-=1:h.is(".new")&&(11===d?(d=0,e+=1):d+=1),i.date=b({y:e,M:d,d:g,h:i.date.hours(),m:i.date.minutes(),s:i.date.seconds()}),i.viewDate=b({y:e,M:d,d:Math.min(28,g)}),t(),K(),o(j,c.type))}},z={incrementHours:function(){L("add","hours",1)},incrementMinutes:function(){L("add","minutes",i.options.minuteStepping)},incrementSeconds:function(){L("add","seconds",1)},decrementHours:function(){L("subtract","hours",1)},decrementMinutes:function(){L("subtract","minutes",i.options.minuteStepping)},decrementSeconds:function(){L("subtract","seconds",1)},togglePeriod:function(){var a=i.date.hours();a>=12?a-=12:a+=12,i.date.hours(a)},showPicker:function(){i.widget.find(".timepicker > div:not(.timepicker-picker)").hide(),i.widget.find(".timepicker .timepicker-picker").show()},showHours:function(){i.widget.find(".timepicker .timepicker-picker").hide(),i.widget.find(".timepicker .timepicker-hours").show()},showMinutes:function(){i.widget.find(".timepicker .timepicker-picker").hide(),i.widget.find(".timepicker .timepicker-minutes").show()},showSeconds:function(){i.widget.find(".timepicker .timepicker-picker").hide(),i.widget.find(".timepicker .timepicker-seconds").show()},selectHour:function(b){var c=parseInt(a(b.target).text(),10);i.use24hours||(i.date.hours()>=12?12!==c&&(c+=12):12===c&&(c=0)),i.date.hours(c),z.showPicker.call(i)},selectMinute:function(b){i.date.minutes(parseInt(a(b.target).text(),10)),z.showPicker.call(i)},selectSecond:function(b){i.date.seconds(parseInt(a(b.target).text(),10)),z.showPicker.call(i)}},A=function(c){var d=b(i.date),e=a(c.currentTarget).data("action"),f=z[e].apply(i,arguments);return B(c),i.date||(i.date=b({y:1970})),K(),x(),o(d,c.type),f},B=function(a){a.stopPropagation(),a.preventDefault()},C=function(a){27===a.keyCode&&i.hide()},D=function(c){b.locale(i.options.language);var d=a(c.target),e=b(i.date),f=b(d.val(),i.format,i.options.useStrict);f.isValid()&&!M(f)&&N(f)?(q(),i.setValue(f),o(e,c.type),K()):(i.viewDate=e,i.unset=!0,o(e,c.type),p(f))},E=function(a){a&&(i.viewMode=Math.max(i.minViewMode,Math.min(2,i.viewMode+a))),i.widget.find(".datepicker > div").hide().filter(".datepicker-"+R.modes[i.viewMode].clsName).show()},F=function(){var b,c,d,e,f;i.widget.on("click",".datepicker *",a.proxy(y,this)),i.widget.on("click","[data-action]",a.proxy(A,this)),i.widget.on("mousedown",a.proxy(B,this)),i.element.on("keydown",a.proxy(C,this)),i.options.pickDate&&i.options.pickTime&&i.widget.on("click.togglePicker",".accordion-toggle",function(g){if(g.stopPropagation(),b=a(this),c=b.closest("ul"),d=c.find(".in"),e=c.find(".collapse:not(.in)"),d&&d.length){if(f=d.data("collapse"),f&&f.transitioning)return;d.collapse("hide"),e.collapse("show"),b.find("span").toggleClass(i.options.icons.time+" "+i.options.icons.date),i.component&&i.component.find("span").toggleClass(i.options.icons.time+" "+i.options.icons.date)}}),i.isInput?i.element.on({click:a.proxy(i.show,this),focus:a.proxy(i.show,this),change:a.proxy(D,this),blur:a.proxy(i.hide,this)}):(i.element.on({change:a.proxy(D,this)},"input"),i.component?(i.component.on("click",a.proxy(i.show,this)),i.component.on("mousedown",a.proxy(B,this))):i.element.on("click",a.proxy(i.show,this)))},G=function(){a(window).on("resize.datetimepicker"+i.id,a.proxy(n,this)),i.isInput||a(document).on("mousedown.datetimepicker"+i.id,a.proxy(i.hide,this))},H=function(){i.widget.off("click",".datepicker *",i.click),i.widget.off("click","[data-action]"),i.widget.off("mousedown",i.stopEvent),i.options.pickDate&&i.options.pickTime&&i.widget.off("click.togglePicker"),i.isInput?i.element.off({focus:i.show,change:D,click:i.show,blur:i.hide}):(i.element.off({change:D},"input"),i.component?(i.component.off("click",i.show),i.component.off("mousedown",i.stopEvent)):i.element.off("click",i.show))},I=function(){a(window).off("resize.datetimepicker"+i.id),i.isInput||a(document).off("mousedown.datetimepicker"+i.id)},J=function(){if(i.element){var b,c=i.element.parents(),d=!1;for(b=0;b0?d:!1},P=function(a){return a=a.toString(),a.length>=2?a:"0"+a},Q=function(){var a='‹›',b='',c='
'+a+'
'+a+b+'
'+a+b+"
",d="";return i.options.pickDate&&i.options.pickTime?(d='
',d+=i.options.sideBySide?'
'+c+'
'+S.getTemplate()+"
":'
    '+c+'
  • '+S.getTemplate()+"
",d+="
"):i.options.pickTime?'":'"},R={modes:[{clsName:"days",navFnc:"month",navStep:1},{clsName:"months",navFnc:"year",navStep:1},{clsName:"years",navFnc:"year",navStep:10}]},S={hourTemplate:'',minuteTemplate:'',secondTemplate:''};S.getTemplate=function(){return'
"+(i.options.useSeconds?'':"")+(i.use24hours?"":'')+" "+(i.options.useSeconds?'":"")+(i.use24hours?"":'')+'"+(i.options.useSeconds?'':"")+(i.use24hours?"":'')+'
'+(i.options.useMinutes?'':"")+"
"+S.hourTemplate+' :'+(i.options.useMinutes?S.minuteTemplate:'00')+":'+S.secondTemplate+"
'+(i.options.useMinutes?'':"")+"
'+(i.options.useSeconds?'
':"")},i.destroy=function(){H(),I(),i.widget.remove(),i.element.removeData("DateTimePicker"),i.component&&i.component.removeData("DateTimePicker")},i.show=function(a){if(!l().prop("disabled")){if(i.options.useCurrent&&""===l().val()){if(1!==i.options.minuteStepping){var c=b(),d=i.options.minuteStepping;c.minutes(Math.round(c.minutes()/d)*d%60).seconds(0),i.setValue(c.format(i.format))}else i.setValue(b().format(i.format));o("",a.type)}a&&"click"===a.type&&i.isInput&&i.widget.hasClass("picker-open")||(i.widget.hasClass("picker-open")?(i.widget.hide(),i.widget.removeClass("picker-open")):(i.widget.show(),i.widget.addClass("picker-open")),i.height=i.component?i.component.outerHeight():i.element.outerHeight(),n(),i.element.trigger({type:"dp.show",date:b(i.date)}),G(),a&&B(a))}},i.disable=function(){var a=l();a.prop("disabled")||(a.prop("disabled",!0),H())},i.enable=function(){var a=l();a.prop("disabled")&&(a.prop("disabled",!1),F())},i.hide=function(){var a,c,d=i.widget.find(".collapse");for(a=0;a Date: Tue, 14 May 2019 18:17:56 +0200 Subject: [PATCH 5/7] rework Makefile for webpack --- Makefile | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index d03f35a..2f42fda 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,13 @@ - -COMPONENT = node_modules/.bin/component -SERVE = serve - -JS := $(shell find lib -name '*.js' -print) - -PORT = 3000 - -build: components $(JS) - @$(COMPONENT) build --dev --out client/build +build: install + npm run build clean: - rm -rf build components node_modules + rm -rf client/build node_modules -components: component.json - @$(COMPONENT) install --dev - -install: node_modules - @npm install -g component myth serve - -node_modules: package.json +install: @npm install -server: - @$(SERVE) client --port $(PORT) - watch: - watch $(MAKE) build + npm run watch -.PHONY: build clean install server watch +.PHONY: build clean install watch From c571aac3618d697387bbda2261b1c4c97fbf1d66 Mon Sep 17 00:00:00 2001 From: Cyrille Courtiere Date: Tue, 14 May 2019 20:38:20 +0200 Subject: [PATCH 6/7] fix datetime pickers config --- lib/request-form.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/request-form.js b/lib/request-form.js index d5c365b..072ffd5 100644 --- a/lib/request-form.js +++ b/lib/request-form.js @@ -111,12 +111,12 @@ var RequestView = Backbone.View.extend({ if (data.attributes.date) { var date = moment(data.attributes.date, 'MM-DD-YYYY').toDate() - view.datepicker.date(date) + view.datepicker.setDate(date) } if (data.attributes.time) { var time = moment(data.attributes.time, 'hh:mm a').toDate() - view.timepicker.date(time) + view.timepicker.setDate(time) } if (data.attributes.wheelchair === 'true') { @@ -196,21 +196,23 @@ var RequestView = Backbone.View.extend({ this.$('#hideSettings').hide() this.$('#hidableSettings').hide() this.$('#date').datetimepicker({ - format: 'MM/DD/YYYY' + pickTime: false }) this.datepicker = this.$('#date').data('DateTimePicker') - this.datepicker.date(new Date()) + this.datepicker.setDate(new Date()) this.$('#date').on('dp.change', function () { view.changeForm() }) this.$('#time').datetimepicker({ - format: 'hh:mm A' + pick12HourFormat: true, + pickSeconds: false, + pickDate: false }) this.timepicker = this.$('#time').data('DateTimePicker') - this.timepicker.date(new Date()) + this.timepicker.setDate(new Date()) this.$('#time').on('dp.change', function () { view.changeForm() }) From 9d5a139a691c00b0197638b14dfebf6c53a3c3eb Mon Sep 17 00:00:00 2001 From: Cyrille Courtiere Date: Wed, 15 May 2019 00:24:05 +0200 Subject: [PATCH 7/7] remove unused files --- .yo-rc.json | 61 ------------------------------------- client/css3-mediaqueries.js | 1 - client/html5.js | 8 ----- 3 files changed, 70 deletions(-) delete mode 100644 .yo-rc.json delete mode 100644 client/css3-mediaqueries.js delete mode 100644 client/html5.js diff --git a/.yo-rc.json b/.yo-rc.json deleted file mode 100644 index 82dc3c5..0000000 --- a/.yo-rc.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "otpjs": { - "configuration": { - "config": { - "topScope": [ - "const webpack = require('webpack')", - "const path = require('path')", - "\n", - "/*\n * SplitChunksPlugin is enabled by default and replaced\n * deprecated CommonsChunkPlugin. It automatically identifies modules which\n * should be splitted of chunk by heuristics using module duplication count and\n * module category (i. e. node_modules). And splits the chunks…\n *\n * It is safe to remove \"splitChunks\" from the generated configuration\n * and was added as an educational example.\n *\n * https://webpack.js.org/plugins/split-chunks-plugin/\n *\n */", - "/*\n * We've enabled UglifyJSPlugin for you! This minifies your app\n * in order to load faster and run less javascript.\n *\n * https://github.com/webpack-contrib/uglifyjs-webpack-plugin\n *\n */", - "const UglifyJSPlugin = require('uglifyjs-webpack-plugin');", - "\n" - ], - "webpackOptions": { - "module": { - "rules": [ - { - "test": "/\\.css$/", - "use": [ - { - "loader": "'style-loader'", - "options": { - "sourceMap": true - } - }, - { - "loader": "'css-loader'" - } - ] - } - ] - }, - "output": { - "chunkFilename": "'[name].[chunkhash].js'", - "filename": "'[name].[chunkhash].js'", - "path": "path.resolve(__dirname, './client/build')" - }, - "mode": "'development'", - "plugins": [ - "new UglifyJSPlugin()" - ], - "optimization": { - "splitChunks": { - "cacheGroups": { - "vendors": { - "priority": -10, - "test": "/[\\\\/]node_modules[\\\\/]/" - } - }, - "chunks": "'async'", - "minChunks": 1, - "minSize": 30000, - "name": true - } - } - }, - "configName": "config" - } - } - } -} \ No newline at end of file diff --git a/client/css3-mediaqueries.js b/client/css3-mediaqueries.js deleted file mode 100644 index 3b90652..0000000 --- a/client/css3-mediaqueries.js +++ /dev/null @@ -1 +0,0 @@ -if(typeof Object.create!=="function"){Object.create=function(e){function t(){}t.prototype=e;return new t}}var ua={toString:function(){return navigator.userAgent},test:function(e){return this.toString().toLowerCase().indexOf(e.toLowerCase())>-1}};ua.version=(ua.toString().toLowerCase().match(/[\s\S]+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];ua.webkit=ua.test("webkit");ua.gecko=ua.test("gecko")&&!ua.webkit;ua.opera=ua.test("opera");ua.ie=ua.test("msie")&&!ua.opera;ua.ie6=ua.ie&&document.compatMode&&typeof document.documentElement.style.maxHeight==="undefined";ua.ie7=ua.ie&&document.documentElement&&typeof document.documentElement.style.maxHeight!=="undefined"&&typeof XDomainRequest==="undefined";ua.ie8=ua.ie&&typeof XDomainRequest!=="undefined";var domReady=function(){var e=[];var t=function(){if(!arguments.callee.done){arguments.callee.done=true;for(var t=0;t=200&&r.status<300||r.status===304||navigator.userAgent.indexOf("Safari")>-1&&typeof r.status==="undefined"){t(r.responseText)}else{n()}document.documentElement.style.cursor="";r=null}};r.send("")};var l=function(t){t=t.replace(e.REDUNDANT_COMPONENTS,"");t=t.replace(e.REDUNDANT_WHITESPACE,"$1");t=t.replace(e.WHITESPACE_IN_PARENTHESES,"($1)");t=t.replace(e.MORE_WHITESPACE," ");t=t.replace(e.FINAL_SEMICOLONS,"}");return t};var c={stylesheet:function(t){var n={};var r=[],i=[],s=[],o=[];var u=t.cssHelperText;var a=t.getAttribute("media");if(a){var f=a.toLowerCase().split(",")}else{var f=["all"]}for(var l=0;l-1&&a.href&&a.href.length!==0&&!a.disabled){r[r.length]=a}}if(r.length>0){var c=0;var d=function(){c++;if(c===r.length){i()}};var v=function(t){var n=t.href;f(n,function(r){r=l(r).replace(e.RELATIVE_URLS,"url("+n.substring(0,n.lastIndexOf("/"))+"/$1)");t.cssHelperText=r;d()},d)};for(u=0;u0){r.setAttribute("media",t.join(","))}document.getElementsByTagName("head")[0].appendChild(r);if(r.styleSheet){r.styleSheet.cssText=e}else{r.appendChild(document.createTextNode(e))}r.addedWithCssHelper=true;if(typeof n==="undefined"||n===true){cssHelper.parsed(function(t){var n=p(r,e);for(var i in n){if(n.hasOwnProperty(i)){g(i,n[i])}}a("newStyleParsed",r)})}else{r.parsingDisallowed=true}return r},removeStyle:function(e){return e.parentNode.removeChild(e)},parsed:function(e){if(n){s(e)}else{if(typeof t!=="undefined"){if(typeof e==="function"){e(t)}}else{s(e);d()}}},stylesheets:function(e){cssHelper.parsed(function(t){e(m.stylesheets||y("stylesheets"))})},mediaQueryLists:function(e){cssHelper.parsed(function(t){e(m.mediaQueryLists||y("mediaQueryLists"))})},rules:function(e){cssHelper.parsed(function(t){e(m.rules||y("rules"))})},selectors:function(e){cssHelper.parsed(function(t){e(m.selectors||y("selectors"))})},declarations:function(e){cssHelper.parsed(function(t){e(m.declarations||y("declarations"))})},properties:function(e){cssHelper.parsed(function(t){e(m.properties||y("properties"))})},broadcast:a,addListener:function(e,t){if(typeof t==="function"){if(!u[e]){u[e]={listeners:[]}}u[e].listeners[u[e].listeners.length]=t}},removeListener:function(e,t){if(typeof t==="function"&&u[e]){var n=u[e].listeners;for(var r=0;r=a||s&&l0}}else if("device-height"===e.substring(r-13,r)){c=screen.height;if(t!==null){if(u==="length"){return i&&c>=a||s&&c0}}else if("width"===e.substring(r-5,r)){l=document.documentElement.clientWidth||document.body.clientWidth;if(t!==null){if(u==="length"){return i&&l>=a||s&&l0}}else if("height"===e.substring(r-6,r)){c=document.documentElement.clientHeight||document.body.clientHeight;if(t!==null){if(u==="length"){return i&&c>=a||s&&c0}}else if("device-aspect-ratio"===e.substring(r-19,r)){return u==="aspect-ratio"&&screen.width*a[1]===screen.height*a[0]}else if("color-index"===e.substring(r-11,r)){var h=Math.pow(2,screen.colorDepth);if(t!==null){if(u==="absolute"){return i&&h>=a||s&&h0}}else if("color"===e.substring(r-5,r)){var p=screen.colorDepth;if(t!==null){if(u==="absolute"){return i&&p>=a||s&&p0}}else if("resolution"===e.substring(r-10,r)){var d;if(f==="dpcm"){d=o("1cm")}else{d=o("1in")}if(t!==null){if(u==="resolution"){return i&&d>=a||s&&d0}}else{return false}};var a=function(e){var t=e.getValid();var n=e.getExpressions();var r=n.length;if(r>0){for(var i=0;i0){u=false;for(var f=0;f0){l[c++]=","}l[c++]=h}}if(l.length>0){r[r.length]=cssHelper.addStyle("@media "+l.join("")+"{"+e.getCssText()+"}",t,false)}};var l=function(e,t){for(var n=0;n0}}var o=[],u=[];for(var f in i){if(i.hasOwnProperty(f)){o[o.length]=f;if(i[f]){u[u.length]=f}if(f==="all"){n=true}}}if(u.length>0){r[r.length]=cssHelper.addStyle(e.getCssText(),u,false)}var c=e.getMediaQueryLists();if(n){l(c)}else{l(c,o)}};var h=function(e){for(var t=0;td||Math.abs(s-t)>d){e=n;t=s;clearTimeout(r);r=setTimeout(function(){if(!i()){p()}else{cssHelper.broadcast("cssMediaQueriesTested")}},500)}};window.onresize=function(){var e=window.onresize||function(){};return function(){e();s()}}()};var m=document.documentElement;m.style.marginLeft="-32767px";setTimeout(function(){m.style.marginLeft=""},5e3);return function(){if(!i()){cssHelper.addListener("newStyleParsed",function(e){c(e.cssHelperParsed.stylesheet)});cssHelper.addListener("cssMediaQueriesTested",function(){if(ua.ie){m.style.width="1px"}setTimeout(function(){m.style.width="";m.style.marginLeft=""},0);cssHelper.removeListener("cssMediaQueriesTested",arguments.callee)});s();p()}else{m.style.marginLeft=""}v()}}());try{document.execCommand("BackgroundImageCache",false,true)}catch(e){} \ No newline at end of file diff --git a/client/html5.js b/client/html5.js deleted file mode 100644 index 448cebd..0000000 --- a/client/html5.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - HTML5 Shiv v3.7.0 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed -*/ -(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag(); -a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/[\w\-]+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x"; -c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode|| -"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:"3.7.0",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f); -if(g)return a.createDocumentFragment();for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d