Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Readd erroneously removed file.
- Loading branch information
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
framework/Core/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} |