summaryrefslogtreecommitdiff
path: root/live/js
diff options
context:
space:
mode:
authorDieter Hametner <dh (plus) vdr (at) gekrumbel (dot) de>2007-07-21 17:52:41 +0000
committerDieter Hametner <dh (plus) vdr (at) gekrumbel (dot) de>2007-07-21 17:52:41 +0000
commitadc7c9d1a40957c1ee377887b7654174730d665b (patch)
treeb73a38ada38b9fee545f39c45ba4c1e8b5dfdf4c /live/js
parentff170db465b8b91b9732cb49bccb47a3110e2388 (diff)
downloadvdr-plugin-live-adc7c9d1a40957c1ee377887b7654174730d665b.tar.gz
vdr-plugin-live-adc7c9d1a40957c1ee377887b7654174730d665b.tar.bz2
- Introducing explicit pageenhance javascript class. See Changelog and
the files itself for more info.
Diffstat (limited to 'live/js')
-rw-r--r--live/js/live/hinttips.js19
-rw-r--r--live/js/live/infowin.js57
-rw-r--r--live/js/live/pageenhance.js87
3 files changed, 121 insertions, 42 deletions
diff --git a/live/js/live/hinttips.js b/live/js/live/hinttips.js
index 5cf899a..a750988 100644
--- a/live/js/live/hinttips.js
+++ b/live/js/live/hinttips.js
@@ -1,6 +1,10 @@
/*
- * Extension of mootools Tips class for rounded corner
- * tooltips of variable size up to some maximum.
+ * This is part of the live vdr plugin. See COPYING for license information.
+ *
+ * HintTips class.
+ *
+ * Extension of mootools Tips class for rounded corner tooltips of
+ * variable size up to some maximum.
*/
var HintTips = Tips.extend({
@@ -21,14 +25,3 @@ var HintTips = Tips.extend({
bt = new Element('div', {'class': this.options.className + '-tip-c'}).inject(bt);
}
});
-
-window.addEvent('domready', function(){
- var tips = new HintTips($$('*[title]'), {
- maxTitleChars: 100,
- className: 'hint'
- });
- });
-
-window.addEvent('mousedown', function(){
- $$('.hint-tip').setStyle('visibility', 'hidden');
- }); \ No newline at end of file
diff --git a/live/js/live/infowin.js b/live/js/live/infowin.js
index 8787899..393cd87 100644
--- a/live/js/live/infowin.js
+++ b/live/js/live/infowin.js
@@ -1,6 +1,12 @@
/*
- * Extension of mootools to display a popup window with
- * some html code.
+ * This is part of the live vdr plugin. See COPYING for license information.
+ *
+ * InfoWin.js
+ *
+ * InfoWin class, InfoWin.Manager class, InfoWin.Ajax class.
+ *
+ * Extension of mootools to display a popup window with some html
+ * code.
*/
/*
@@ -28,20 +34,22 @@ var InfoWin = new Class({
timeout: 0,
onShow: Class.empty,
onHide: Class.empty,
+ onDomExtend: Class.empty,
className: 'info',
wm: false, // overide default window manager.
draggable: true,
resizable: true,
buttonimg: 'transparent.png',
- bodyselect: 'div.epg_content',
+ bodyselect: 'div.content',
titleselect: 'div.caption',
+ idSuffix: '-win-id',
offsets: {'x': -16, 'y': -16}
},
initialize: function(id, options){
this.setOptions(options);
this.wm = this.options.wm || InfoWin.$wm;
- this.winFrame = $(id + '-win-id');
+ this.winFrame = $(id + this.options.idSuffix);
if (!$defined(this.winFrame)){
this.build(id);
this.wm.register(this);
@@ -56,7 +64,7 @@ var InfoWin = new Class({
// with the user data, false otherwise.
build: function(id){
this.winFrame = new Element('div', {
- 'id': id + '-win-id',
+ 'id': id + this.options.idSuffix,
'class': this.options.className + '-win',
'styles': {
'position': 'absolute',
@@ -144,7 +152,9 @@ var InfoWin = new Class({
fillBody: function(id){
var bodyElems = $$('#'+ id + ' ' + this.options.bodyselect);
if ($defined(bodyElems) && bodyElems.length > 0) {
- this.winBody.empty().adopt(bodyElems);
+ this.winBody.empty();
+ this.fireEvent('onDomExtend', [id, bodyElems]);
+ this.winBody.adopt(bodyElems);
return true;
}
return false;
@@ -170,6 +180,12 @@ var InfoWin = new Class({
InfoWin.implement(new Events, new Options);
+/*
+Class: InfoWin.Manager
+ Provide an container and events for the created info win
+ instances. Closed info-wins are preserved in a hidden dom element
+ and used again if a window with a closed id is openend again.
+*/
InfoWin.Manager = new Class({
options: {
zIndex: 100,
@@ -228,12 +244,17 @@ window.addEvent('domready', function(){
InfoWin.$wm = new InfoWin.Manager();
});
+/*
+Class: InfoWin.Ajax
+ Use an instance of mootools Ajax class to asynchronously request
+ the content of an info win.
+*/
InfoWin.Ajax = InfoWin.extend({
options: {
loadingMsg: 'loading',
errorMsg: 'an error occured!',
- onError: Class.empty
+ onError: Class.empty,
},
initialize: function(id, url, options){
@@ -273,25 +294,3 @@ InfoWin.Ajax = InfoWin.extend({
});
InfoWin.Ajax.implement(new Events, new Options);
-
-
-window.addEvent('domready', function(){
- $$('a[href^="epginfo.html?epgid"]').each(function(el){
- var href = el.href;
- var epgid = $pick(href, "");
- if (epgid != "") {
- var extractId = /epgid=(\w+)/;
- var found = extractId.exec(epgid);
- if ($defined(found) && found.length > 1) {
- epgid = found[1];
- el.addEvent('click', function(event){
- var event = new Event(event);
- new InfoWin.Ajax(epgid, href).show(event);
- event.stop();
- return false;
- });
- }
- }
- });
- });
-
diff --git a/live/js/live/pageenhance.js b/live/js/live/pageenhance.js
new file mode 100644
index 0000000..6d1ff10
--- /dev/null
+++ b/live/js/live/pageenhance.js
@@ -0,0 +1,87 @@
+/*
+ * This is part of the live vdr plugin. See COPYING for license information.
+ *
+ * PageEnhance class.
+ *
+ * This class applies several functions to the page based on
+ * selectors. This class is quite project dependent and not a general
+ * purpose class.
+ */
+
+var PageEnhance = new Class({
+ options: {
+ epgLinkSelector: 'a[href^="epginfo.html?epgid"]',
+ hintTipSelector: '*[title]',
+ hintClassName: 'hint',
+ infoWinStrings: {
+ loadingMsg: 'loading',
+ errorMsg: 'an error occured!'
+ }
+ },
+
+ initialize: function(options){
+ this.setOptions(options);
+ window.addEvent('domready', this.domReadySetup.bind(this));
+ window.addEvent('mousedown', this.mouseDownSetup.bind(this));
+ },
+
+ // actions applied on domready to the page.
+ domReadySetup: function(){
+ $$(this.options.epgLinkSelector).each(this.epgPopup.bind(this));
+ this.addHintTips($$(this.options.hintTipSelector));
+ },
+
+ // actions applied on mouse down.
+ mouseDownSetup: function(){
+ $$('.' + this.options.hintClassName + '-tip').setStyle('visibility', 'hidden');
+ },
+
+ // Epg Popup function. Apply to all elements that should
+ // pop up an Epg InfoWin window.
+ epgPopup: function(el){
+ var href = el.href;
+ var epgid = $pick(href, "");
+ if (epgid != "") {
+ var extractId = /epgid=(\w+)/;
+ var found = extractId.exec(epgid);
+ if ($defined(found) && found.length > 1) {
+ epgid = found[1];
+ el.addEvent('click', function(event){
+ var event = new Event(event);
+ new InfoWin.Ajax(epgid, href, {
+ bodyselect: 'div.epg_content',
+ onDomExtend: this.domExtend.bind(this),
+ loadingMsg: this.options.infoWinStrings.loadingMsg,
+ errorMsg: this.options.infoWinStrings.errorMsg
+ }).show(event);
+ event.stop();
+ return false;
+ }.bind(this));
+ }
+ }
+ },
+
+ // registered as 'onDomExtend' event for InfoWin. Takes care to
+ // enhance the new dom elements too.
+ domExtend: function(id, elems){
+ var sel = '#' + id + ' ' + this.options.hintTipSelector;
+ elems = $$(sel);
+ this.addHintTips(elems);
+ },
+
+ // change normal 'title'-Attributes into enhanced hinttips
+ // usesd by domExtend and domReadySetup functions.
+ addHintTips: function(elems){
+ if (!$defined(this.tips)) {
+ this.tips = new HintTips(elems, {
+ maxTitleChars: 100,
+ className: this.options.hintClassName
+ });
+ }
+ else {
+ $$(elems).each(this.tips.build, this.tips);
+ }
+ }
+ });
+
+PageEnhance.implement(new Events, new Options);