Skip to content

Commit

Permalink
Bug: 14474 Fix BC break.
Browse files Browse the repository at this point in the history
Readd erroneously removed file.
  • Loading branch information
mrubinsk committed Sep 21, 2016
1 parent 1948781 commit 93193c7
Showing 1 changed file with 95 additions and 0 deletions.
@@ -0,0 +1,95 @@
<?php
/**
* Imple to provide weather/location autocompletion.
*
* Copyright 2011-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @deprecated Use Horde_Core_Ajax_Imple_WeatherAutocompleter_[Metar|Weather]
*/
class Horde_Core_Ajax_Imple_WeatherLocationAutoCompleter extends Horde_Core_Ajax_Imple_AutoCompleter
{
/**
*/
protected function _getAutoCompleter()
{
$indicator = $this->_params['id'] . '_loading_img';

$GLOBALS['injector']->getInstance('Horde_PageOutput')->addInlineScript(
array(
'window.weatherupdate = window.weatherupdate || {}',
'window.weatherupdate["' . $this->_params['instance'] . '"] = {
value: false,
choices: {},
update: function() {
var v;
if (this.value) {
v = this.value;
} else {
v = $F("location' . $this->_params['instance'] . '");
}
$("' . $indicator . '").toggle();
HordeCore.doAction("blockRefresh",
{ blockid: "Horde_Block_Weather", location: v },
{ callback: function(r) {
var point = v.split(",");
var p = { lat: point[0], lon: point[1] };
$("weathercontent' . $this->_params['instance'] . '").update(r);
$("' . $indicator . '").toggle();
WeatherBlockMap.maps["' . $this->_params['instance'] . '"].setCenter(p, 7);
}
}
);
this.value = false;
}
}',
'$("button' . $this->_params['instance'] . '").observe("click", function(e) {
window.weatherupdate["' . $this->_params['instance'] . '"].update();
e.stop();
})'
)
);

return new Horde_Core_Ajax_Imple_AutoCompleter_Ajax(array(
'minChars' => 3,
'tokens' => array(),
'domParent' => 'horde-content',
'filterCallback' => 'function(c) {
if (c) {
window.weatherupdate["' . $this->_params['instance'] . '"].choices = c;
var r = [];
c.each(function(i) {
r.push(i.name);
});
return r;
} else {
return [];
}
}',
'onSelect' => 'function(c) {
window.weatherupdate["' . $this->_params['instance'] . '"].choices.each(function(i) {
if (i.name == c) {
window.weatherupdate["' . $this->_params['instance'] . '"].value = i.code.replace("/q/", "");
throw $break;
} else {
window.weatherupdate["' . $this->_params['instance'] . '"].value = false;
}
});
return c;
}'
));
}

/**
*/
protected function _handleAutoCompleter($input)
{
return $GLOBALS['injector']->getInstance('Horde_Weather')->autocompleteLocation($input);
}

}

0 comments on commit 93193c7

Please sign in to comment.