/usr/share/vdr/plugins/live/js/live/infowin.js is in vdr-plugin-live 0.2.0+git20130305-6.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | /*
* 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.
*/
/*
Class: InfoWin
Create an information window as overlay to current page.
Arguments:
Options:
Note:
A window consists of a frame-element. This is the overall
containing element used to control the display and size of the
window. It is accesable through the 'winFrame' property.
The InfoWin class provides the followin properties to fill the
window with content:
- titleBox: the element meant to place the title of the window into.
- buttonBox: here the default window buttons are created. You might
clear this and create your own kind of window controls.
- winBody: this is where your window contents goes.
*/
var InfoWin = new Class({
options: {
timeout: 0,
onShow: Class.empty,
onHide: Class.empty,
onDomExtend: Class.empty,
destroyOnHide: false,
className: 'info',
wm: false, // overide default window manager.
draggable: true,
resizable: true,
buttonimg: 'transparent.png',
bodyselect: 'div.content',
titleselect: 'div.caption',
classSuffix: '-win',
idSuffix: '-id',
offsets: {'x': -16, 'y': -16}
},
initialize: function(id, options){
this.setOptions(options);
this.wm = this.options.wm || InfoWin.$wm;
this.winFrame = $(id + this.options.classSuffix + this.options.idSuffix);
if (!$defined(this.winFrame)){
this.buildFrame(id);
this.build(id);
this.wm.register(this);
}
},
// internal: build new window element.
//
// build sets up a frame for a new InfoWin. The parent element
// of the window frame has the id '<id>-win-id'. The function
// must return true if the body of the InfoWin has been filled
// with the user data, false otherwise.
build: function(id){
// header of window: upper shadows, corners title and controls
var top = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-top'
}).inject(this.winFrame);
if (this.options.draggable) this.winFrame.makeDraggable({'handle': top});
top = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-c'
}).inject(top);
this.titleBox = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-t'
}).inject(top);
this.buttonBox = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-b'
}).inject(top);
var cls = new Element('div', {
'class': 'close'
}).inject(this.buttonBox);
cls.addEvent('click', function(event){
var event = new Event(event);
event.stop();
return this.hide();
}.bind(this));
cls = new Element('img', {
'src': this.options.buttonimg,
'alt': 'close',
'width': '16px',
'height': '16px'
}).inject(cls);
// body of window: user content.
var bdy = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-body'
}).inject(this.winFrame);
bdy = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-c'
}).inject(bdy);
this.winBody = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-s'
}).inject(bdy);
// bottom border of window: lower shadows and corners, optional
// resize handle.
var bot = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-bot'
}).inject(this.winFrame);
bot = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-c'
}).inject(bot);
if (this.options.resizable) {
this.winFrame.makeResizable({'handle': bot});
}
if (!this.fillTitle(id)) {
// todo: add generic title
}
return this.fillBody(id);
},
buildFrame: function(id){
this.winFrame = new Element('div', {
'id': id + this.options.classSuffix + this.options.idSuffix,
'class': this.options.className + this.options.classSuffix,
'styles': {
'position': 'absolute',
'top': '0',
'left': '0'
}
});
},
show: function(event){
this.position(event);
this.fireEvent('onShow', [this.winFrame]);
this.wm.raise(this);
if (this.options.timeout)
this.timer = this.hide.delay(this.options.timeout, this);
return false;
},
hide: function(){
this.fireEvent('onHide', [this.winFrame]);
if (this.options.destroyOnHide) {
this.wm.unregister(this);
for (var z in this) this[z] = null;
this.destroyed = true;
}
else {
this.wm.bury(this);
}
return false;
},
fillBody: function(id){
var bodyElems = $$('#'+ id + ' ' + this.options.bodyselect);
if ($defined(bodyElems) && bodyElems.length > 0) {
this.winBody.empty();
this.fireEvent('onDomExtend', [id, bodyElems]);
this.winBody.adopt(bodyElems);
return true;
}
return false;
},
fillTitle: function(id){
var titleElems = $$('#' + id + ' ' + this.options.titleselect);
if ($defined(titleElems) && titleElems.length > 0) {
this.titleBox.empty().adopt(titleElems);
return true;
}
return false;
},
position: function(event){
var prop = {'x': 'left', 'y': 'top'};
for (var z in prop) {
var pos = event.page[z] + this.options.offsets[z];
this.winFrame.setStyle(prop[z], pos);
}
}
});
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: {
closedContainer: 'infowin-closed',
openedContainer: 'infowin-opened',
onRegister: Class.empty,
onUnregister: Class.empty,
onRaise: Class.empty,
onBury: Class.empty
},
initialize: function(options){
this.setOptions(options);
// initialize properties this.closedWins and this.openedWins:
['closed', 'opened'].each(function(kind){
var wins = kind + 'Wins';
var opts = this.options[kind + 'Container'];
this[wins] = $(opts);
if (!$defined(this[wins])){
this[wins] = new Element('div', {
'id': opts,
'styles' : {
'display' : (kind == 'closed') ? 'none' : 'block'
}
});
this[wins].inject(document.body);
}
}, this);
},
register: function(infoWin){
this.fireEvent('onRegister', [infoWin]);
infoWin.winFrame.addEvent('click', function(){
this.raise(infoWin);
}.bind(this));
infoWin.winFrame.inject(this.closedWins);
},
unregister: function(infoWin){
this.fireEvent('onUnregister', [infoWin]);
infoWin.winFrame.remove();
},
raise: function(infoWin){
this.fireEvent('onRaise', [infoWin]);
infoWin.winFrame.inject(this.openedWins);
},
bury: function(infoWin){
this.fireEvent('onBury', [infoWin]);
infoWin.winFrame.inject(this.closedWins);
}
});
InfoWin.Manager.implement(new Events, new Options);
InfoWin.$wm = null;
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
},
initialize: function(id, url, options){
this.parent(id, options);
if ($defined(this.ajaxResponse)) {
this.addEvent('onError', function(){
this.hide.delay(1000, this);
}.bind(this));
var ajax = new Ajax(url, {
update: this.ajaxResponse,
onComplete: function(text, xmldoc){
this.fillTitle(id);
this.fillBody(id);
this.ajaxResponse.remove();
}.bind(this),
onFailure: function(transport){
this.titleBox.setHTML(this.options.errorMsg);
this.fireEvent('onError', [id, url]);
}.bind(this)
}).request('async=1');
}
},
// this function gets called when no previous instance for 'id'
// created a dom subtree for an infowin.
build: function(id){
if (!this.parent(id)) {
this.titleBox.setHTML(this.options.loadingMsg);
this.ajaxResponse = new Element('div', {
'styles' : {
'display': 'none'
}
}).inject(this.winFrame);
}
}
});
/*
Class: Infowin.Notifier
Creates a notification popup that disappears automaticaly.
Usefull for a confirmation message after a AJAX action request.
*/
InfoWin.Notifier = InfoWin.extend({
options: {
timeout: 2500,
destroyOnHide: true,
className: 'ok',
classSuffix: '-info',
message: '',
offsets: {'x': 16, 'y': 16}
},
initialize: function(id, options){
this.parent(id, options);
},
build: function(id){
/* top border of hint */
var top = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-top'
}).inject(this.winFrame);
top = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-c'
}).inject(top);
/* body of tip: some helper divs and content */
var bdy = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-body'
}).inject(this.winFrame);
bdy = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-c'
}).inject(bdy);
this.winBody = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-s'
}).inject(bdy);
/* bottom border of tip */
var bot = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-bot'
}).inject(this.winFrame);
bot = new Element('div', {
'class': this.options.className + this.options.classSuffix + '-c'
}).inject(bot);
return this.fillBody(id);
},
fillBody: function(id){
this.winFrame.setStyle('position', 'fixed');
this.winBody.empty().setHTML(this.options.message);
return true;
},
position: function(event){
var prop = {'x': 'left', 'y': 'top'};
for (var z in prop) {
var pos = this.options.offsets[z];
this.winFrame.setStyle(prop[z], pos);
}
}
});
|