Skip to content

Commit

Permalink
extract dateinput-picker LE
Browse files Browse the repository at this point in the history
  • Loading branch information
chemerisuk committed Nov 17, 2018
1 parent 8c0ba94 commit 9d4b65f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ cache:
before_install:
- npm install better-dom@latest
- npm install -g gulp
install: npm install
39 changes: 21 additions & 18 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,12 @@ table+table[aria-hidden=true] {
this._svgTextFont = this.css("font");
this._svgTextOffset = ["padding-left", "border-left-width", "text-indent"].map(p => parseFloat(this.css(p))).reduce((a, b) => a + b);

const picker = DOM.create("<dateinput-picker>");
const object = DOM.create("<object>")[0];
object.type = "text/html";
object.width = "100%";
object.height = "100%";
object.onload = this._initPicker.bind(this, object, picker);
// non-IE: must be BEFORE the element added to the document
if (!IE) {
object.data = "about:blank";
}
const picker = DOM.create("<dateinput-picker tabindex='-1'>");

picker.set("tabindex", -1);
picker.on("load", {capture: true}, ["target"], this._initPicker.bind(this, picker));
picker.css("z-index", 1 + (this.css("z-index") | 0));

this.before(picker.append(DOM.constructor(object)).hide());
// IE: must be AFTER the element added to the document
if (IE) {
object.data = "about:blank";
}
this.before(picker.hide());
},
_isNative() {
var polyfillType = this.get("data-polyfill"),
Expand All @@ -193,8 +180,8 @@ table+table[aria-hidden=true] {

return TYPE_SUPPORTED;
},
_initPicker(object, picker) {
const pickerRoot = DOM.constructor(object.contentDocument);
_initPicker(picker, object) {
const pickerRoot = DOM.constructor(object.get("contentDocument"));
const pickerBody = pickerRoot.find("body");
pickerBody.set(PICKER_BODY_HTML);

Expand Down Expand Up @@ -493,4 +480,20 @@ table+table[aria-hidden=true] {
picker.css("margin-top", marginTop).show();
}
});

DOM.extend("dateinput-picker", {
constructor() {
const object = DOM.create("<object type='text/html' width='100%' height='100%'>");
// non-IE: must be BEFORE the element added to the document
if (!IE) {
object.set("data", "about:blank");
}
// add object element to the document
this.append(object);
// IE: must be AFTER the element added to the document
if (IE) {
object.set("data", "about:blank");
}
}
});
}(window.DOM, 32, 9, 13, 27, 8, 46, 17));

0 comments on commit 9d4b65f

Please sign in to comment.