PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_QuickForm » Bug #5245

Some fixes to work hierselect on MAC IE5.2.3

Details

Submitted2005-08-30 18:44 UTC
Fromsotela at sotela dot com
StatusWont fix
PackageHTML_QuickForm
PHP Version4.3.11
OSMAC
Roadmaps(Not assigned)

Comments

[2005-08-30 18:44 UTC] sotela at sotela dot com

Description:
------------
hello !

i have hounded that existing hierselect doesn't works on MAC Iòåóêòóå Explorer 5.2.3

here is working part of code:
$this->_js .= <<<JAVASCRIPT
function Array_shift() {
var A_s = 0
var response = this[0]
for (A_s = 0; A_s < this.length-1; A_s++) {
this[A_s] = this[A_s + 1];
}
this.length--;
return response;
}

if (typeof Array.prototype.shift == "undefined") {
Array.prototype.shift = Array_shift
}

function _hs_findOptions(ary, keys)
{
var key = keys.shift();
// IE5.2MACFIX
// if (!key in ary) {
if (!ary[key]) {
return {};
} else if (0 == keys.length) {
return ary[key];
} else {
return _hs_findOptions(ary[key], keys);
}
}

function _hs_findSelect(form, groupName, selectIndex)
{
// IE5.2MACFIX
// if (groupName+'['+ selectIndex +']' in form) {
if(form[groupName+'['+ selectIndex +']']){
return form[groupName+'['+ selectIndex +']'];
} else {
return form[groupName+'['+ selectIndex +'][]'];
}
}

function _hs_replaceOptions(ctl, optionList)
{
var j = 0;
ctl.options.length = 0;
for (i in optionList) {
ctl.options[j++] = new Option(optionList[i], i, false, false);
}
}

function _hs_setValue(ctl, value)
{
var testValue = {};
// IE5.2MACFIX
// if (value instanceof Array) {
if(typeof(value)=='array' || typeof(value)=='object'){
for (var i = 0; i < value.length; i++) {
testValue[value[i]] = true;
}
} else {
testValue[value] = true;
}
for (var i = 0; i < ctl.options.length; i++) {
// IE5.2MACFIX
// if (ctl.options[i].value in testValue) {
if (testValue[ctl.options[i].value]) {
ctl.options[i].selected = true;
}
}
}

function _hs_swapOptions(form, groupName, selectIndex)
{
var hsValue = [];
for (var i = 0; i <= selectIndex; i++) {
hsValue[i] = _hs_findSelect(form, groupName, i).value;
}

_hs_replaceOptions(_hs_findSelect(form, groupName, selectIndex + 1),
_hs_findOptions(_hs_options[groupName][selectIndex], hsValue));
if (selectIndex + 1 < _hs_options[groupName].length) {
_hs_swapOptions(form, groupName, selectIndex + 1);
}
}

function instanceOf(object, constructorFunction) {
while (object != null) {
if (object == constructorFunction.prototype)
{return true}
object = object.__proto__;
}
return false;
}

function _hs_onReset(form, groupNames)
{
for (var i = 0; i < groupNames.length; i++) {
try {
for (var j = 0; j <= _hs_options[groupNames[i]].length; j++) {
_hs_setValue(_hs_findSelect(form, groupNames[i], j), _hs_defaults[groupNames[i]][j]);
if (j < _hs_options[groupNames[i]].length) {
_hs_replaceOptions(_hs_findSelect(form, groupNames[i], j + 1),
_hs_findOptions(_hs_options[groupNames[i]][j], _hs_defaults[groupNames[i]].slice(0, j + 1)));
}
}
} catch (e) {
// IE5.2MACFIX
// if (!(e instanceof TypeError)) {
if(instanceOf(e, TypeError)){
throw e;
}
}
}
}

function _hs_setupOnReset(form, groupNames)
{
setTimeout(function() { _hs_onReset(form, groupNames); }, 25);
}

function _hs_onReload()
{
var ctl;
for (var i = 0; i < document.forms.length; i++) {
for (var j in _hs_defaults) {
if (ctl = _hs_findSelect(document.forms[i], j, 0)) {
for (var k = 0; k < _hs_defaults[j].length; k++) {
_hs_setValue(_hs_findSelect(document.forms[i], j, k), _hs_defaults[j][k]);
}
}
}
}

if (_hs_prevOnload) {
_hs_prevOnload();
}
}

var _hs_prevOnload = null;
if (window.onload) {
_hs_prevOnload = window.onload;
}
window.onload = _hs_onReload;

var _hs_options = {};
var _hs_defaults = {};

JAVASCRIPT;