Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/hemebond/eden
Browse files Browse the repository at this point in the history
  • Loading branch information
flavour committed Oct 7, 2012
2 parents 8aa5f4c + 35880c3 commit 764df2e
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 19 deletions.
14 changes: 8 additions & 6 deletions modules/s3/s3search.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,17 +803,19 @@ def widget(self, resource, vars):

# Button to open the Map
OPEN_MAP = T("Open Map")
map_button = A(OPEN_MAP,
_style="cursor:pointer; cursor:hand",
_id="gis_search_map-btn")
CLEAR_MAP = T("Clear selection")
map_buttons = TAG[""](BUTTON(OPEN_MAP,
_id="gis_search_map-btn"),
BUTTON(CLEAR_MAP,
_id="gis_search_polygon_input_clear"))

# Settings to be read by static/scripts/S3/s3.gis.js
js_location_search = """S3.gis.draw_polygon = true;"""
js_location_search = "S3.gis.draw_polygon = true;"

# The overall layout of the components
return TAG[""](
polygon_input,
map_button,
map_buttons,
#map_popup,
SCRIPT(js_location_search)
)
Expand Down Expand Up @@ -2379,7 +2381,7 @@ def search_json(self, r, **attr):

resource.add_filter(query)

limit = int(_vars.limit or 0)
limit = int(_vars.limit or MAX_SEARCH_RESULTS)
if (not limit or limit > MAX_SEARCH_RESULTS) and resource.count() > MAX_SEARCH_RESULTS:
output = jsons([dict(id="",
name="Search results are over %d. Please input more characters." \
Expand Down
10 changes: 10 additions & 0 deletions static/scripts/S3/S3.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ $(document).ready(function() {
$('.confirmation').click(function() { $(this).fadeOut('slow'); return false; });
$("input[type='checkbox'].delete").click(function() { if(this.checked) if(!confirm(S3.i18n.delete_confirmation)) this.checked=false; });

// If a form is submitted with errors, this will scroll
// the window to the first form error message
inputErrorId = $('form .error[id]').eq(0).attr('id');
if (inputErrorId != undefined) {
inputName = inputErrorId.replace("__error", "");
inputId = $('[name=' + inputName + ']').attr('id');
inputLabel = $('[for=' + inputId + ']');
window.scrollTo(0, inputLabel.offset().top)
}

// T2 Layer
//try { $('.zoom').fancyZoom( {
// scaleImg: true,
Expand Down
8 changes: 5 additions & 3 deletions static/scripts/S3/s3.dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ $(document).ready(function() {

/****************************************************************/
/* Helper function to add the new group row */
/****************************************************************/
/****************************************************************/
function addNewGroup(t,
sGroup,
level,
Expand Down Expand Up @@ -614,7 +614,7 @@ $(document).ready(function() {

/*********************************************************************
* Function to group the data
*
*
* @param oSettings the dataTable settings
* @param t the index of the table
* @param group The index of the colum that will be grouped
Expand Down Expand Up @@ -1020,7 +1020,9 @@ Ext.onReady(function(){
}
var s3_search_mapButton = Ext.get('gis_search_map-btn');
if (s3_search_mapButton) {
s3_search_mapButton.on('click', function() {
s3_search_mapButton.on('click', function(evt) {
// prevent button submitting the form
evt.preventDefault();
// Enable the polygon control
S3.gis.polygonButton.enable();
// @ToDo: Set appropriate Bounds
Expand Down
16 changes: 8 additions & 8 deletions static/scripts/S3/s3.gis.controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ function googleEarthKmlLoaded(object) {

// Google Streetview control
function addGoogleStreetviewControl(toolbar) {
var Clicker = OpenLayers.Class(OpenLayers.Control, {
var Clicker = OpenLayers.Class(OpenLayers.Control, {
defaults: {
pixelTolerance: 1,
stopSingle: true
Expand All @@ -348,11 +348,11 @@ function addGoogleStreetviewControl(toolbar) {
this.handlerOptions = OpenLayers.Util.extend(
{}, this.defaults
);
OpenLayers.Control.prototype.initialize.apply(this, arguments);
OpenLayers.Control.prototype.initialize.apply(this, arguments);
this.handler = new OpenLayers.Handler.Click(
this, {click: this.trigger}, this.handlerOptions
);
},
},
trigger: function(event) {
openStreetviewPopup(map.getLonLatFromViewPortPx(event.xy));
}
Expand Down Expand Up @@ -491,7 +491,7 @@ function addMeasureControls(toolbar) {
allowDepress: true,
enableToggle: true
});

toolbar.add(areaButton);
}
}
Expand Down Expand Up @@ -587,7 +587,7 @@ function addPolygonControl(toolbar, polygon_pressed, not_regular) {
}
// update Form Field
var WKT = feature.geometry.transform(S3.gis.projection_current, S3.gis.proj4326).toString();
$('#gis_search_polygon_input').val(WKT);
$('#gis_search_polygon_input').val(WKT).trigger('change');
$('#gis_location_wkt').val(WKT);
// Prepare in case user draws a new polygon
S3.gis.lastDraftFeature = feature;
Expand Down Expand Up @@ -846,13 +846,13 @@ function addRemoveLayersControl() {
uploadText: S3.i18n.gis_uploadlayer,
relativeUploadOnly: false
});

// @ToDo: Populate this from disabled Catalogue Layers (to which the user has access)
// Use WMStore for the GeoServer which we can write to?
// Use current layerStore for Removelayer()?
//var store = S3.gis.mapPanel.layers;
var store = new GeoExt.data.LayerStore();

// Set up shortcuts to allow GXP Plugin to work
S3.gis.addLayersControl.target = S3.gis.layerTree;
S3.gis.layerTree.proxy = OpenLayers.ProxyHost; // Required for 'Add a New Server'
Expand Down Expand Up @@ -981,7 +981,7 @@ function addLayerPropertiesButton() {
var pcs = [];
for (i=0; i < ids.length; i++) {
q = $('#' + ids[i]).serialize();
if (q) {
if (q) {
pcs.push(q);
}
}
Expand Down
47 changes: 45 additions & 2 deletions static/scripts/S3/s3.search.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,48 @@ $(document).ready(function() {
});

// Activate the Save Search buttons
$('button#save-search').on('click', S3.search.saveCurrentSearch);
});
$('button#save-search').on('click', S3.search.saveCurrentSearch);

// S3SearchLocationWidget
// Allow clearing of map polygons in search forms
$('button#gis_search_polygon_input_clear')
.on('click', function(event) {
S3.search.clearMapPolygon();
// prevent form submission
event.preventDefault();
});
$('input#gis_search_polygon_input')
.on('change', S3.search.toggleMapClearButton)
.trigger('change');
});

/*
* S3SearchLocationWidget
*
* Clears the map widget in a search form and also removes the
* polygon from the map itself
*/
S3.search.clearMapPolygon = function() {
if (S3.gis.lastDraftFeature) {
S3.gis.lastDraftFeature.destroy();
}
$('input#gis_search_polygon_input').val("").trigger('change');
}

/*
* S3SearchLocationWidget
*
* If the map widget has a value, a clear button will be shown
* otherwise it is hidden
*/
S3.search.toggleMapClearButton = function(event) {
var inputElement = $(event.currentTarget);
var clearButton = inputElement.siblings('button#gis_search_polygon_input_clear');

if (inputElement.val()) {
clearButton.show();
}
else {
clearButton.hide();
}
}

0 comments on commit 764df2e

Please sign in to comment.