dbm 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/site/index.js CHANGED
@@ -1,2 +1,21 @@
1
+ import Dbm from "../index.js";
2
+
1
3
  export {default as SiteNavigation} from "./SiteNavigation.js";
2
- export {default as SiteDataLoader} from "./SiteDataLoader.js";
4
+ export {default as SiteDataLoader} from "./SiteDataLoader.js";
5
+ export {default as BrowserUpdater} from "./BrowserUpdater.js";
6
+
7
+ export const setupAndStart = function(aTitleSuffix) {
8
+ let siteNavigation = new Dbm.site.SiteNavigation();
9
+ siteNavigation.item.register("siteNavigation");
10
+ siteNavigation.start();
11
+ siteNavigation.setUrlFromLocation();
12
+
13
+ let siteDataLoader = new Dbm.site.SiteDataLoader();
14
+ siteDataLoader.item.register("siteDataLoader");
15
+ siteDataLoader.item.properties.url.connectInput(siteNavigation.item.properties.url);
16
+
17
+ let browserUpdater = new Dbm.site.BrowserUpdater();
18
+ siteDataLoader.item.register("site/browserUpdater");
19
+ browserUpdater.setTitleSuffix(aTitleSuffix);
20
+ browserUpdater.item.propertyInput("pageData", siteDataLoader.item.properties.currentPage);
21
+ }
@@ -125,7 +125,6 @@ export const filterByField = function(aArray, aField, aValue) {
125
125
  for(let i = 0; i < currentArrayLength; i++) {
126
126
  let currentItem = aArray[i];
127
127
  let currentValue = Dbm.objectPath(aArray[i], aField);
128
- console.log(currentValue, aValue);
129
128
  if(currentValue === aValue) {
130
129
  returnArray.push(currentItem);
131
130
  }
@@ -49,6 +49,20 @@ export let createCoverScaledImageUrl = function(aImageData, aWantedWidth, aWante
49
49
  return url;
50
50
  }
51
51
 
52
+ export const getContainScaledImageUrl = function(aUrl, aWantedWidth, aWantedHeight) {
53
+ let scaleToWidth = Math.min(
54
+ Math.round(window.devicePixelRatio*aWantedWidth),
55
+ Math.max(
56
+ 100,
57
+ 100*Math.round(window.devicePixelRatio*window.innerWidth/100)
58
+ )
59
+ );
60
+
61
+ let scaleToHeight = Math.round(aWantedHeight*scaleToWidth/aWantedWidth);
62
+
63
+ return aUrl.split("{scale}").join("width=" + scaleToWidth + ",height=" + scaleToHeight + ",fit=contain");
64
+ }
65
+
52
66
  export let createContainScaledImageUrl = function(aImageData, aWantedWidth, aWantedHeight) {
53
67
  if(!aImageData || !aImageData["url"]) {
54
68
  return null;
@@ -60,17 +74,7 @@ export let createContainScaledImageUrl = function(aImageData, aWantedWidth, aWan
60
74
  }
61
75
 
62
76
  if(aImageData["resizeUrl"]) {
63
- let scaleToWidth = Math.min(
64
- Math.round(window.devicePixelRatio*aWantedWidth),
65
- Math.max(
66
- 100,
67
- 100*Math.round(window.devicePixelRatio*window.innerWidth/100)
68
- )
69
- );
70
-
71
- let scaleToHeight = Math.round(aWantedHeight*scaleToWidth/aWantedWidth);
72
-
73
- url = aImageData["resizeUrl"].split("{scale}").join("width=" + scaleToWidth + ",height=" + scaleToHeight + ",fit=contain");
77
+ url = getContainScaledImageUrl(aImageData["resizeUrl"], aWantedWidth, aWantedHeight);
74
78
  }
75
79
 
76
80
  return url;