/* rdlg.js (used with rdlg.css, images used in rdlg.css) * Simplely designed popup dialog. * * Inspired and based on Prototype, Scriptaculous and popup libraray Prototype library: http://www.prototypejs.org/ Scriptaculous library: http://script.aculo.us/ Popup library: http;//www.methods.co.nz/popup/popup.html * * Version 0.1 * * Author: Kim, Jung Hyun (mail@ikspres.com) * License: This source code is released under MIT license. * Copyright (c) Kim, Jung Hyun 2007 * Usage ==================== // This is an sample html using rdlg // Yes!, you need prototype and scriptaculou at first. // and popup // and rdlg too. // You may need an trigger to open your rdlg // and write your contents into the following format // or, if you want to use a form, use the following format // Finally, you NEED the following js codes to setup rdlg. <%= javascript_tag %{ // initialize rdlg with title , width, height rdlg_setup('my_dialog', 'Add Videos', 400, 480); // initialize your rdlg as a popup (don't change 'draghandle' and 'closebox' option) new Popup('my_dialog', 'opener', { modal:true, duration:1, draghandle:'rdlg-hdr-center', closebox:'rdlg-close' }); } %> */ /* * Modifiations on Popup.js version 1.0.1 * - adjust center position according to the current scroll offsets * - disable overaly div */ Popup.prototype.getPageXOffset = function() { var de = document.documentElement; return window.pageXOffset || (de && de.scrollLeft) || document.body.scrollLeft; }; Popup.prototype.getPageYOffset = function() { var de = document.documentElement; return window.pageYOffset || (de && de.scrollTop) || document.body.scrollTop; }; Popup.prototype.get_center_position = function() { dim = Element.getDimensions(this.popup); var popup_width = dim.width; var popup_height = dim.height; dim = this.get_viewport_dimensions(); var viewport_width = dim.width; var viewport_height = dim.height; var x; if (popup_width >= viewport_width) { x = 0; } else { x = (viewport_width - popup_width)/2; } var y; if (popup_height >= viewport_height) { y = 0; } else { y = (viewport_height - popup_height)/2; } return {x: x+this.getPageXOffset(), y: y+this.getPageYOffset()}; }; Popup.prototype.hide_overlay = function() { return; } Popup.prototype.show_overlay = function() { return; } /* * Initialize and setup rdlg. * * Example: * rdlg_setup('my_rdlg', 'hello world', 100, 200); */ function rdlg_create(rdlg, title, width ) { _rdlg_construct(rdlg); rdlg_config(rdlg, title, width); } function rdlg_config(rdlg, title, width) { if(title) $$('#'+rdlg+' div.rdlg-hdr-center h1')[0].innerHTML = title; if(width) $(rdlg).setStyle({width: width+'px'}); } /* * (internal function which is used by rdlg_setup) * * Add frames and header parts to the rdlg * */ function _rdlg_construct(rdlg) { var part1 = "

Hello

"; var part2 = "
" $(rdlg).innerHTML = part1 + ' ' + $(rdlg).innerHTML + ' ' + part2; }