forked from mozilla-b2g/gaia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mozilla-b2g#30339 from sean2449/Bug-1170067-move-p…
…rogram Bug 1170067 - [Stingray][EPG] Make program element as a web component, r=johnhu
- Loading branch information
Showing
7 changed files
with
325 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* global EPG */ | ||
|
||
'use strict'; | ||
|
||
window.EPGProgram = (function(exports) { | ||
var proto = Object.create(HTMLElement.prototype); | ||
|
||
proto.createdCallback = function() { | ||
this._duration = 1; | ||
this.dataset.duration = '1'; | ||
this.titleElement = document.createElement('DIV'); | ||
this.titleElement.classList.add('title'); | ||
this.appendChild(this.titleElement); | ||
|
||
this.progressElement = document.createElement('DIV'); | ||
this.progressElement.classList.add('background-progress'); | ||
this.appendChild(this.progressElement); | ||
}; | ||
|
||
Object.defineProperty(proto, 'progress', { | ||
set: function(time) { | ||
if (!this.startTime || !time) { | ||
return; | ||
} | ||
|
||
var scaleX = (time - this.startTime) * EPG.COLUMN_WIDTH; | ||
scaleX = scaleX / (this.duration * EPG.COLUMN_WIDTH - EPG.COLUMN_MARGIN); | ||
scaleX = Math.min(scaleX, 1); | ||
this.progressElement.style.transform = 'scaleX(' + scaleX + ')'; | ||
} | ||
}); | ||
|
||
Object.defineProperty(proto, 'startTime', { | ||
set: function(time) { | ||
this._startTime = time; | ||
}, | ||
get: function() { | ||
return this._startTime; | ||
} | ||
}); | ||
|
||
Object.defineProperty(proto, 'title', { | ||
set: function(title) { | ||
this.titleElement.textContent = title; | ||
} | ||
}); | ||
|
||
Object.defineProperty(proto, 'titlePadding', { | ||
set: function(padding) { | ||
this.titleElement.style.paddingLeft = padding; | ||
} | ||
}); | ||
|
||
Object.defineProperty(proto, 'duration', { | ||
set: function(duration) { | ||
this._duration = duration; | ||
this.dataset.duration = duration; | ||
}, | ||
get: function() { | ||
return this._duration; | ||
} | ||
}); | ||
|
||
proto.resetProgressElement = function(time) { | ||
if (!this.startTime || !time) { | ||
return; | ||
} | ||
|
||
if (this.startTime + this.duration <= time) { | ||
this.fillProgress(); | ||
} else { | ||
this.progressElement.classList.add('smooth'); | ||
} | ||
this.appendChild(this.progressElement); | ||
}; | ||
|
||
proto.fillProgress = function() { | ||
this.progressElement.style.transform = 'scaleX(1)'; | ||
}; | ||
|
||
proto.hide = function() { | ||
this.classList.add('hidden'); | ||
}; | ||
|
||
proto.show = function() { | ||
this.classList.remove('hidden'); | ||
}; | ||
|
||
return document.registerElement('epg-program', { prototype: proto }); | ||
})(window); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
epg-program { | ||
display: inline-block; | ||
position: relative; | ||
width: 33.5rem; | ||
font-size: 2.5rem; | ||
line-height: 10.8rem; | ||
overflow: hidden; | ||
padding-bottom: 0.3rem; | ||
padding-right: 0.3rem; | ||
border-bottom: 0.1rem #5e5e5e solid; | ||
margin-top: 0.3rem; | ||
background-color: #404040; | ||
height: 11.2rem; | ||
background-clip: content-box; | ||
box-sizing: border-box; | ||
outline: none; | ||
} | ||
|
||
epg-program:after { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
width: 0.1rem; | ||
background-color: #5e5e5e; | ||
height: 10.8rem; | ||
} | ||
|
||
epg-program.focus { | ||
background-color: #00caf2; | ||
} | ||
|
||
epg-program.hidden { | ||
display: none; | ||
} | ||
|
||
epg-program[data-duration="1"] { | ||
width: 33.8rem; | ||
} | ||
|
||
epg-program[data-duration="2"] { | ||
width: 67.6rem; | ||
} | ||
|
||
epg-program[data-duration="3"] { | ||
width: 101.4rem; | ||
} | ||
|
||
epg-program[data-duration="4"] { | ||
width: 135.2rem; | ||
} | ||
|
||
epg-program[data-duration="5"] { | ||
width: 169rem; | ||
} | ||
|
||
epg-program[data-duration="6"] { | ||
width: 202.8rem; | ||
} | ||
|
||
epg-program[data-duration="7"] { | ||
width: 236.9rem; | ||
} | ||
|
||
epg-program > .title { | ||
margin-left: 2rem; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
width: calc(100% - 2rem); | ||
box-sizing: border-box; | ||
position: absolute; | ||
} | ||
|
||
epg-program > .background-progress { | ||
position: absolute; | ||
background-color: rgba(0, 0, 0, 0.2); | ||
height: calc(100% - 0.3rem); | ||
transform: scaleX(0); | ||
transform-origin: 0; | ||
width: calc(100% - 0.3rem); | ||
} | ||
|
||
epg-program > .background-progress.smooth { | ||
transition: transform 0.3s; | ||
} |
Oops, something went wrong.