[Mapbender-commits] r8579 - in branches/2.7: http/plugins http/print lib resources/db/pgsql/UTF-8/update
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Mar 4 02:19:51 PST 2013
Author: verenadiewald
Date: 2013-03-04 02:19:51 -0800 (Mon, 04 Mar 2013)
New Revision: 8579
Modified:
branches/2.7/http/plugins/mb_print.php
branches/2.7/http/print/A4_landscape_template.json
branches/2.7/lib/printbox.js
branches/2.7/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql
Log:
http://trac.osgeo.org/mapbender/ticket/889 + http://trac.osgeo.org/mapbender/ticket/890
Modified: branches/2.7/http/plugins/mb_print.php
===================================================================
--- branches/2.7/http/plugins/mb_print.php 2013-03-04 09:06:06 UTC (rev 8578)
+++ branches/2.7/http/plugins/mb_print.php 2013-03-04 10:19:51 UTC (rev 8579)
@@ -179,9 +179,29 @@
jqForm[0].scale.value = parseInt(obj.scale / 10, 10) * 10;
}
else {
- $("#scale .addedScale").remove();
- $("#scale").append("<option selected class='addedScale' value='"+parseInt(obj.scale / 10, 10) * 10+"'>1 : " + parseInt(obj.scale / 10, 10) * 10 + "</option>");
- }
+ //$("#scale .addedScale").remove();
+ //$("#scale").append("<option selected class='addedScale' value='"+parseInt(obj.scale / 10, 10) * 10+"'>1 : " + parseInt(obj.scale / 10, 10) * 10 + "</option>");
+
+ var currentScale = parseInt($("#scale").val(), 10);
+ var objScale = parseInt(obj.scale / 10, 10) * 10;
+
+ if(obj.scale != currentScale) {
+ var scaleOptions = [];
+ $("#scale option").each( function() {
+ scaleOptions.push(parseInt(this.value, 10));
+ });
+
+ var closest = getClosestNum(objScale,scaleOptions);
+ $("#scale option[value='"+closest+"']").attr('selected', 'selected');
+ if(printBox) {
+ if(objScale != closest) {
+ printBox.setScale(closest);
+ }
+ }
+ }
+
+
+ }
}
if (obj.coordinates) {
if(typeof(jqForm[0].coordinates) != "undefined") {
@@ -193,9 +213,32 @@
});
printBox.paintPoints();
printBox.paintBox();
-
+ printBox.show();
}
};
+
+ function getClosestNum(num, ar) {
+ var i = 0, closest, closestDiff, currentDiff;
+ if(ar.length)
+ {
+ closest = ar[0];
+ for(i;i<ar.length;i++)
+ {
+ closestDiff = Math.abs(num - closest);
+ currentDiff = Math.abs(num - ar[i]);
+ if(currentDiff < closestDiff)
+ {
+ closest = ar[i];
+ }
+ closestDiff = null;
+ currentDiff = null;
+ }
+ //returns first element that is closest to number
+ return closest;
+ }
+ //no length
+ return false;
+ }
/**
* Method: getPDFMapSize
@@ -228,6 +271,20 @@
};
/**
+ * Change status of printbox
+ *
+ * @param {String} newStatus either "hide or "show"
+ */
+ var showHidePrintBox = function (newStatus) {
+ if (newStatus=="hide") {
+ printBox.hide();
+ }
+ else {
+ printBox.show();
+ }
+ };
+
+ /**
* Method: mod_printPDF_init
*
* initializes the print modules, generates template chooser and loads first configuration.
@@ -551,8 +608,8 @@
stripslashes(res.outputFileName);
}
showHideWorking("hide");
- //remove printbox after successful print
- destroyPrintBox();
+ //remove printbox after successful print
+ //destroyPrintBox();
}
else {
/* something went wrong */
@@ -569,6 +626,9 @@
var buildForm = function () {
$(".print_option_dyn").remove();
var str = "";
+ str += '<input type="hidden" name="printboxScale" id="printboxScale">\n';
+ str += '<input type="hidden" name="printboxCoordinates" id="printboxCoordinates">\n';
+ str += '<input type="hidden" name="printboxAngle" id="printboxAngle">\n';
for (var item in actualConfig.controls) {
var element = actualConfig.controls[item];
var element_id = myId + "_" + element.id;
@@ -600,7 +660,8 @@
str += '<select id="'+element.id+'" name="'+element.id+'" size="1">\n';
for (var option_index in element.options) {
option = element.options[option_index];
- str += '<option value="'+option.value+'">'+option.label+'</option>\n';
+ var selected = option.selected ? option.selected : "";
+ str += '<option '+selected+' value="'+option.value+'">'+option.label+'</option>\n';
}
str += '</select><br>\n';
break;
@@ -627,28 +688,28 @@
return false;
}
- var scale = parseInt(this.value, 10);
+ var scale = parseInt(this.value, 10);
if (isNaN(scale) || typeof printBox === "undefined") {
return true;
}
- if(scale < 10) {
- return true;
- }
+ if(scale < 10) {
+ return true;
+ }
printBox.setScale(scale);
return true;
});
}
else {
$("#scale").change(function (e) {
- var scale = parseInt(this.value, 10);
- if (isNaN(scale) || typeof printBox === "undefined") {
- return true;
- }
-
- if(scale < 10) {
- return true;
- }
+ var scale = parseInt(this.value, 10);
+ if (isNaN(scale) || typeof printBox === "undefined") {
+ return true;
+ }
+
+ if(scale < 10) {
+ return true;
+ }
printBox.setScale(scale);
return true;
});
@@ -692,7 +753,28 @@
});
$("#printPDF_handle").click(function () {
- printObj.createPrintBox();
+ if (printBox) {
+ if(printBox.isVisible()) {
+ showHidePrintBox("hide");
+ $("#printboxScale").val($("#printPDF_form #scale").val());
+ $("#printboxCoordinates").val($("#printPDF_form #coordinates").val());
+ $("#printboxAngle").val($("#printPDF_form #angle").val());
+
+ $("#printPDF_form #scale").val("");
+ $("#printPDF_form #coordinates").val("");
+ $("#printPDF_form #angle").val("");
+ }
+ else {
+ showHidePrintBox("show");
+ $("#printPDF_form #scale").val($("#printboxScale").val());
+ $("#printPDF_form #coordinates").val($("#printboxCoordinates").val());
+ $("#printPDF_form #angle").val($("#printboxAngle").val());
+ }
+ }
+ else {
+ printObj.createPrintBox();
+ }
+
});
$("#printPDF_working").bgiframe({
src: "BLOCKED SCRIPT'<html></html>';",
Modified: branches/2.7/http/print/A4_landscape_template.json
===================================================================
--- branches/2.7/http/print/A4_landscape_template.json 2013-03-04 09:06:06 UTC (rev 8578)
+++ branches/2.7/http/print/A4_landscape_template.json 2013-03-04 10:19:51 UTC (rev 8579)
@@ -71,10 +71,37 @@
{
"id" : "scale",
"label" : "Maßstab",
- "type" : "text",
+ "type" : "select",
"pageElementsLink" : {
"scale" : "value"
- }
+ },
+ "options" : [
+ {
+ "value" : "500",
+ "label" : "1 : 500"
+ },
+ {
+ "value" : "1000",
+ "label" : "1 : 1000"
+ },
+ {
+ "value" : "2000",
+ "label" : "1 : 2000"
+ },
+ {
+ "value" : "5000",
+ "label" : "1 : 5000"
+ },
+ {
+ "value" : "10000",
+ "label" : "1 : 10000"
+ },
+ {
+ "value" : "100000",
+ "label" : "1 : 100000",
+ "selected" : "selected"
+ }
+ ]
}
],
"pages" : [
Modified: branches/2.7/lib/printbox.js
===================================================================
--- branches/2.7/lib/printbox.js 2013-03-04 09:06:06 UTC (rev 8578)
+++ branches/2.7/lib/printbox.js 2013-03-04 10:19:51 UTC (rev 8579)
@@ -643,8 +643,25 @@
activeCanvas.clear();
passiveCanvas.clear();
$("#" + this.id).remove();
- $("#container_" + this.id).remove();
+ $("#container_" + this.id).remove();
+ };
+
+ this.hide = function () {
+ $("#container_" + this.id).hide();
};
+
+ this.show = function () {
+ $("#container_" + this.id).show();
+ };
+
+ this.isVisible = function () {
+ if($("#container_printbox").css("display") == "none") {
+ return false;
+ }
+ else {
+ return true;
+ }
+ };
var switchActiveCanvas = function () {
if (canvasNr == 1) {
Modified: branches/2.7/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql
===================================================================
--- branches/2.7/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql 2013-03-04 09:06:06 UTC (rev 8578)
+++ branches/2.7/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql 2013-03-04 10:19:51 UTC (rev 8579)
@@ -1,3 +1,6 @@
-- change element_vars ui-theme-css in gui_digitize (customized-css doesn't work correct in mapbender 2.7.3)
update gui_element_vars set var_value = '../extensions/jquery-ui-1.7.2.custom/css/smoothness/jquery-ui-1.7.2.custom.css'
-where fkey_gui_id = 'gui_digitize' and var_name = 'jq_ui_theme'
\ No newline at end of file
+where fkey_gui_id = 'gui_digitize' and var_name = 'jq_ui_theme'
+
+-- legend_url in e_content for printPDF template print
+UPDATE gui_element SET e_content = '<div id="printPDF_working_bg"></div><div id="printPDF_working"><img src="../img/indicator_wheel.gif" style="padding:10px 0 0 10px">Generating PDF</div><div id="printPDF_input"><form id="printPDF_form" action="../print/printFactory.php"><div id="printPDF_selector"></div><div class="print_option"><input type="hidden" id="opacity" name="opacity" value=""/><input type="hidden" id="map_url" name="map_url" value=""/><input type="hidden" id="overview_url" name="overview_url" value=""/><input type="hidden" id="legend_url" name="legend_url" value=""/><input type="hidden" id="map_scale" name="map_scale" value=""/><input type="hidden" name="measured_x_values" /><input type="hidden" name="measured_y_values" /><br /></div><div class="print_option" id="printPDF_formsubmit"><input id="submit" type="submit" value="Print"><br /></div></form><div id="printPDF_result"></div></div>' WHERE e_id = 'printPDF' and fkey_gui_id = 'template_print';
\ No newline at end of file
More information about the Mapbender_commits
mailing list