Permalink
Browse files

Modifying the widget class to work properly. Now its fully functional.

  • Loading branch information...
1 parent dd66c46 commit 7b13f52b4a642a5f4189a987309d08c7f5b6cd94 @guiman committed Mar 10, 2012
Showing with 14 additions and 15 deletions.
  1. +14 −15 lib/widget/alWidgetFormJQueryAddressPicker.class.php
@@ -18,7 +18,9 @@ public function render($name, $value = null, $attributes = array(), $errors = ar
{
$map_input = '
<div id="input">
- <label>'.__($name).': </lable> <input id="'.$name .'_map" name="'.$name.'"> <br/>
+ <label>'.__($name).': </lable> <input id="'.$this->generateId($name) .'" name="'.$name.'"> <br/>
+ </div>
+ <div id="extra-info">
<label>'.__('Locality').': </label> <input id="locality" disabled=disabled> <br/>
<label>'.__('Country').': </label> <input id="country" disabled=disabled> <br/>
<label>Lat: </label> <input id="lat" disabled=disabled> <br/>
@@ -28,16 +30,17 @@ public function render($name, $value = null, $attributes = array(), $errors = ar
<div id="legend">'.__('You can drag and drop the marker to the correct location').'</div>
';
- $return = ($this->getOption("add_map")? $map_input : parent::render($name,$value,$attributes,$errors));
+ $return = ($this->getOption("add_map")? $map_input : parent::render($name,$value,$attributes,$errors));
- return $return . $this->renderJavascript($name);
+ return $return . $this->renderJavascript($this->generateId($name));
}
protected function renderJavascript($name)
{
if($this->getOption("add_map"))
{
- $javascript = 'var addresspickerMap = $( "#'.$name.'_map" ).addresspicker({
+ $javascript = '
+ var addresspickerMap = $( "#'.$name.'" ).addresspicker({
elements: {
map: "#map",
lat: "#lat",
@@ -50,7 +53,7 @@ protected function renderJavascript($name)
gmarker.setVisible(true);
addresspickerMap.addresspicker( "updatePosition");';
} else {
- $javascript = '$(function(){var addresspicker = $( "#'.$name.'" ).addresspicker();});';
+ $javascript = 'var addresspicker = $( "#'.$name.'" ).addresspicker();';
}
return javascript_tag($javascript);
@@ -61,24 +64,20 @@ protected function renderJavascript($name)
*/
public function getJavaScripts()
{
- $javascripts = array("/alWidgetFormJQueryAddressPicker/js/jquery.ui.addresspicker.js",
- "/alWidgetFormJQueryAddressPicker/js/jquery-1.4.4.min.js",
- "/alWidgetFormJQueryAddressPicker/js/jquery-ui-1.8.7.min.js",
- );
+ $javascripts = array("http://maps.google.com/maps/api/js?sensor=false");
- if ($this->getOption("add_map"))
- {
- $javascripts[] = "http://maps.google.com/maps/api/js?sensor=false";
- }
+ //$javascripts[] = "/js/jquery-1.4.4.min.js";
+ $javascripts[] = "/js/jquery-ui-1.8.7.min.js";
+ $javascripts[] = "/js/jquery.ui.addresspicker.js";
- return array_merge(parent::getJavaScripts(),$javascripts);
+ return array_merge($javascripts,parent::getJavaScripts());
}
/*
* Required Stylesheets for this widget
*/
public function getStylesheets()
{
- return array_merge(parent::getStylesheets(),array("/alWidgetFormJQueryAddressPicker/css/themes/base/jquery.ui.all.css" => "screen"));
+ return array_merge(parent::getStylesheets(),array("/css/themes/base/jquery.ui.all.css" => "screen"));
}
}

0 comments on commit 7b13f52

Please sign in to comment.