[Mapbender-commits] r8050 - in branches/2.7/http: javascripts
plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Aug 3 05:39:38 EDT 2011
Author: verenadiewald
Date: 2011-08-03 02:39:38 -0700 (Wed, 03 Aug 2011)
New Revision: 8050
Added:
branches/2.7/http/plugins/mapdependentSelectBox.js
Modified:
branches/2.7/http/javascripts/mod_digitize_tab.php
Log:
add possibility to use mapdependent selectbox in digitize
Modified: branches/2.7/http/javascripts/mod_digitize_tab.php
===================================================================
--- branches/2.7/http/javascripts/mod_digitize_tab.php 2011-08-03 08:44:02 UTC (rev 8049)
+++ branches/2.7/http/javascripts/mod_digitize_tab.php 2011-08-03 09:39:38 UTC (rev 8050)
@@ -2334,7 +2334,20 @@
"});";
onChangeText += uploaderText;
-
+
+ var targetObject = parent.getMapObjByName("mapframe1");
+ var mapExtentObj = targetObject.extent;
+ var mapExtent = mapExtentObj.minx + ","+ mapExtentObj.miny +","+ mapExtentObj.maxx + ","+ mapExtentObj.maxy;
+
+ var mapSelectBoxText = "$('.hasMapdependentSelect').each(function () { \n" +
+ "var data = $.parseJSON(window.opener.stripslashes($(this).attr('data'), true));\n" +
+ "data.bbox='"+ mapExtent + "';\n"+
+ "var defaults = {};\n" +
+ "var settings = $.extend({}, defaults, data);\n" +
+ "$(this).mapdependentSelect(settings);\n" +
+ "});\n";
+ onChangeText += mapSelectBoxText;
+
str += "\t<select name='wfs' size='" + wfsConf.length + "'";
str += " onChange=\""+ onChangeText +"\"";
str += ">\n\t\t";
@@ -2389,6 +2402,7 @@
str += "<script type='text/javascript' src='../extensions/jquery-ui-1.7.1.w.o.effects.min.js'><\/script>";
str += "<script type='text/javascript' src='../plugins/jq_upload.js'><\/script>";
str += "<script type='text/javascript' src='../extensions/jqjson.js'><\/script>";
+ str += "<script type='text/javascript' src='../plugins/mapdependentSelectBox.js'><\/script>";
str += "</body></html>";
wfsWindow.document.write(str);
wfsWindow.document.close();
@@ -2437,6 +2451,42 @@
return formElementHtml;
}
+function prepareMapdependentSelect (formElementHtml, categoryName, isMandatory, elementLabel, elementValue, styleId) {
+ var classString = (styleId == '0') ? "" : styleId;
+ var patternString = "<select";
+ var pattern = new RegExp(patternString);
+ // set category
+ if (categoryName) {
+ formElementHtml = formElementHtml.replace(pattern, patternString + " category='" + categoryName + "' ");
+ }
+
+ if (isMandatory) {
+ // set border if mandatory
+ classString += "hasMapdependentSelect mandatory";
+ }
+ classString = (classString !== "") ? " class='"+classString+"' " : " ";
+ formElementHtml = formElementHtml.replace(pattern, patternString + classString);
+
+ // set name of select box to elementlabel
+ patternString = "name\s*=\s*\\*'\w+\\*'";
+ pattern = new RegExp(patternString);
+ if (pattern.test(formElementHtml)) {
+ formElementHtml = formElementHtml.replace(pattern, "name='" + elementLabel + "'");
+ }
+ else {
+ patternString = "<select";
+ pattern = new RegExp(patternString);
+ formElementHtml = formElementHtml.replace(pattern, "<select name='" + elementLabel + "'");
+ }
+
+ // preselect the correct entry of the box
+ // not so easy because this can happen after the WFSsearch returns results
+ // so give it an extra attribute which can be parsed bythe javascript side of things
+
+ formElementHtml = formElementHtml.replace(pattern,patternString + " elementvalue='"+elementValue + "' ");
+ return formElementHtml;
+}
+
function prepareDatepicker (formElementHtml, categoryName, isMandatory, elementLabel, elementValue, styleId) {
var classString = (styleId == '0') ? "" : styleId;
var patternString = "<input";
Added: branches/2.7/http/plugins/mapdependentSelectBox.js
===================================================================
--- branches/2.7/http/plugins/mapdependentSelectBox.js (rev 0)
+++ branches/2.7/http/plugins/mapdependentSelectBox.js 2011-08-03 09:39:38 UTC (rev 8050)
@@ -0,0 +1,27 @@
+jQuery.fn.mapdependentSelect = function(o){
+ return this.each(function(){
+ var that = $(this);
+ var options = o;
+ options.url = options.url || "../html/mod_blank.html";
+ var requestData = {BBOX:options.bbox};
+ jQuery.post(
+ options.url,
+ requestData,
+ function(data, status, xhr){
+ $('option',that).remove();
+ that.append('<option value="" selected="selected">...</option>');
+ for(var i = 0; i < data.length; i++){
+ that.append('<option value="'+ data[i].val +'">'+ data[i].show +'</option>');
+ }
+ // elementValue is set if we are working on an exitising feature
+ var elementValue = that.attr('elementvalue');
+ if(elementValue){
+ $('option[value="'+elementValue +'"]',that).attr('selected','selected');
+ }
+ return true;
+ },
+ "json"
+ );
+ });
+};
+
More information about the Mapbender_commits
mailing list