[Mapbender-commits] r4919 - in trunk/mapbender/http: . plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Nov 4 09:48:09 EST 2009
Author: christoph
Date: 2009-11-04 09:48:09 -0500 (Wed, 04 Nov 2009)
New Revision: 4919
Added:
trunk/mapbender/http/plugins/
trunk/mapbender/http/plugins/jq_ui_accordion.js
trunk/mapbender/http/plugins/jq_ui_dialog.js
trunk/mapbender/http/plugins/jq_upload.js
trunk/mapbender/http/plugins/jq_upload.php
Log:
Added: trunk/mapbender/http/plugins/jq_ui_accordion.js
===================================================================
--- trunk/mapbender/http/plugins/jq_ui_accordion.js (rev 0)
+++ trunk/mapbender/http/plugins/jq_ui_accordion.js 2009-11-04 14:48:09 UTC (rev 4919)
@@ -0,0 +1,75 @@
+/**
+ * Package: jq_ui_accordion
+ *
+ * Description:
+ * An accordion decorator, replaces the deprecated element "tabs"
+ *
+ * Enter the elements to be put in the accordion in its target field
+ * (comma-separated list of element ids).
+ *
+ * Avoid styles in elements within the accordion.
+ *
+ * The overview won't work in the accordion, as it cannot be positioned
+ * absolutely.
+ *
+ * The width of this module determines the accordion width, but the height
+ * of the individual elements determines the height.
+ *
+ *
+ * Files:
+ * - http/plugins/jq_ui_accordion.js
+ * - http/extensions/jquery-ui-1.7.2.custom/development-bundle/ui/ui.accordion.js
+ *
+ * SQL:
+ * > INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment,
+ * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width,
+ * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file,
+ * > e_mb_mod, e_target, e_requires, e_url) VALUES('<app_id>','jq_ui_accordion',2,1,
+ * > 'An accordion decorator, replaces the deprecated element tabs','','div',
+ * > '','',10,240,300,NULL ,2,'','','div','../plugins/jq_ui_accordion.js',
+ * > '../extensions/jquery-ui-1.7.2.custom/development-bundle/ui/ui.accordion.js',
+ * > '','jq_ui','http://docs.jquery.com/UI/Accordion');
+ *
+ * Help:
+ * http://docs.jquery.com/UI/Accordion
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Christoph_Baudson
+ *
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License
+ * and Simplified BSD license.
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+ */
+
+$this = $(this);
+
+// tab to open onload
+var active = typeof options.active !== "number" ?
+ false : options.active - 1;
+
+for (var i = 0; i < options.target.length; i++) {
+ $c = $("#" + options.target[i]);
+ $this.append(
+ $(
+ "<h3><a id='header_" + options.id + "_" + $c.attr("id") +
+ "' href='#'>" + Mapbender.modules[$c.attr("id")].currentTitle +
+ "</a></h3>"
+ )
+ ).append(
+ $(
+ "<div></div>"
+ ).append(
+ $(
+ "<div style='height:" + $c.css("height") + "'></div>"
+ ).append($c)
+ )
+ );
+}
+
+$("#" + options.id).accordion({
+ collapsible: true,
+ autoHeight: false,
+ active: active
+});
Added: trunk/mapbender/http/plugins/jq_ui_dialog.js
===================================================================
--- trunk/mapbender/http/plugins/jq_ui_dialog.js (rev 0)
+++ trunk/mapbender/http/plugins/jq_ui_dialog.js 2009-11-04 14:48:09 UTC (rev 4919)
@@ -0,0 +1,163 @@
+/**
+ * Package:
+ * jq_ui_dialog
+ *
+ * Description:
+ * Module to managing dialog windows with multiple options for customization.
+ *
+ * Files:
+ * - http/javascripts/mod_dialogManager.js
+ * - http/extensions/jquery-1.3.2.min.js (minium v1.3.2)
+* - http/extensions/jquery-ui-1.7.2.custom (minimum v1.7.2, complete folder including CSS)
+ *
+ * SQL:
+ * INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('<GUI name>','dialogManager',5,1,'','','div','','',-1,-1,NULL ,NULL ,NULL ,'','','div','../x_test/portalu/mod_dialogManager.js','','','','');
+ *
+ * Help:
+ * http://www.mapbender.org/Dialog_Manager
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Lars_Beck
+ *
+ * Parameters:
+ * <normal element var name> - <type and description>
+ * <optional element var name> - *[optional]* <type and description>
+ * <deprecated element var name> - *[deprecated]* <type and description>
+ *
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License
+ * and Simplified BSD license.
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+ */
+
+var defaultOptions = {};
+
+defaultOptions.content = (typeof options.dialogContent !== 'undefined') ? options.dialogContent : '';
+defaultOptions.url = (typeof options.dialogURL !== 'undefined') ? options.dialogURL : null;
+defaultOptions.dimensions = (typeof options.dialogDimensions !== 'undefined') ? options.dialogDimensions : [550,400];
+defaultOptions.position = (typeof options.dialogPosition !== 'undefined') ? options.dialogPosition : 'center';
+defaultOptions.isModal = (typeof options.dialogIsModal !== 'undefined') ? options.dialogIsModal : true;
+defaultOptions.isResizeable = (typeof options.dialogIsResizeable !== 'undefined') ? options.dialogIsResizeable : false;
+defaultOptions.isDraggable = (typeof options.dialogIsDraggable !== 'undefined') ? options.dialogIsDraggable : false;
+defaultOptions.title = (typeof options.dialogTitle !== 'undefined') ? options.dialogTitle : null;
+defaultOptions.effectShow = (typeof options.dialogEffectShow !== 'undefined') ? options.dialogEffectShow : null;
+defaultOptions.effectHide = (typeof options.dialogEffectHide !== 'undefined') ? options.dialogEffectHide : null;
+
+var DialogManager = function() {
+
+ this.dialogOptions = {};
+ this.currentDialogs = [];
+
+ this.openDialog = function(customOptions) {
+ if(typeof customOptions === 'undefined') {
+ customOptions = {};
+ }
+
+ dialogManager = this;
+
+ this.createDialogID();
+
+ this.dialogOptions.content = (typeof customOptions.content !== 'undefined') ? customOptions.content : defaultOptions.content;
+ this.dialogOptions.dimensions = (typeof customOptions.dimensions !== 'undefined') ? customOptions.dimensions : defaultOptions.dimensions;
+ this.dialogOptions.position = (typeof customOptions.position !== 'undefined') ? customOptions.position : defaultOptions.position;
+ this.dialogOptions.isModal = (typeof customOptions.isModal !== 'undefined') ? customOptions.isModal : defaultOptions.isModal;
+ this.dialogOptions.isResizeable = (typeof customOptions.isResizeable !== 'undefined') ? customOptions.isResizeable : defaultOptions.isResizeable;
+ this.dialogOptions.isDraggable = (typeof customOptions.isDraggable !== 'undefined') ? customOptions.isDraggable : defaultOptions.isDraggable;
+ this.dialogOptions.title = (typeof customOptions.title !== 'undefined') ? customOptions.title : defaultOptions.title;
+ this.dialogOptions.effectShow = (typeof customOptions.effectShow !== 'undefined') ? customOptions.effectShow : defaultOptions.effectShow;
+ this.dialogOptions.effectHide = (typeof customOptions.effectHide !== 'undefined') ? customOptions.effectHide : defaultOptions.effectHide;
+
+ if(typeof customOptions.url !== 'undefined') {
+ this.dialogOptions.content = '<iframe src="' + customOptions.url + '" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>';
+ }
+
+ this.dialog = $(document.createElement('div'))
+ .attr('id',this.dialogID)
+ .html(this.dialogOptions.content)
+ .appendTo('body')
+ .dialog({
+ width: this.dialogOptions.dimensions.shift(),
+ height: this.dialogOptions.dimensions.shift(),
+ position: this.dialogOptions.position,
+ modal: this.dialogOptions.isModal,
+ resizeable: this.dialogOptions.isResizable,
+ draggable: this.dialogOptions.isResizable,
+ title: this.dialogOptions.title,
+ show: this.dialogOptions.effectShow,
+ hide: this.dialogOptions.effectHide,
+ open: function() {
+ dialogManager.addToCurrentDialogs(this.id);
+ },
+ close: function() {
+ dialogManager.removeFromCurrentDialogs(this.id);
+ }
+ });
+
+ return this.dialog;
+ }
+
+ this.closeDialog = function(openDialog) {
+ $(openDialog).dialog('close');
+ }
+
+ this.createDialogID = function() {
+ this.dialogID = 'mb-dialog-' + parseInt(new Date().getTime());
+ }
+
+ this.addToCurrentDialogs = function() {
+ this.currentDialogs.push(this.dialogID);
+ }
+
+ this.removeFromCurrentDialogs = function(dialogID) {
+ for(var i = 0; i < this.currentDialogs.length; i++) {
+ if(this.currentDialogs[i] === dialogID) {
+ if (i === 0) {
+ this.currentDialogs.shift();
+ }
+ else if (i === (this.currentDialogs.length - 1)) {
+ this.currentDialogs.pop();
+ }
+ else {
+ var partA = this.currentDialogs.slice(0,(i - 1));
+ var partB = this.currentDialogs.slice(i + 1,(this.currentDialogs.length - 1));
+
+ this.currentDialogs = (partA + partB);
+ }
+
+ return;
+ }
+ }
+ }
+
+};
+
+/*
+$(document).ready(function() {
+ Mapbender.modules[options.id] = $.extend(new DialogManager(),Mapbender.modules[options.id]);
+});
+
+$('#dialog-trigger-a').click(function() {
+ Mapbender.modules.dialogManager.openDialog();
+});
+
+$('#dialog-trigger-b').click(function() {
+ Mapbender.modules.dialogManager.openDialog({
+ 'url': 'http://www.google.de/',
+ 'dimensions': [800,600],
+ 'position': [5,5],
+ 'title': 'Google',
+ 'isModal': false,
+ 'effectShow': 'blind'
+ });
+});
+
+$('#dialog-trigger-c').click(function() {
+ Mapbender.modules.dialogManager.openDialog({
+ 'content': 'Verbrechen lohnt sich nicht.',
+ 'title': 'Hinweis',
+ 'effectShow': 'puff',
+ 'effectHide': 'puff'
+ });
+});
+*/
\ No newline at end of file
Added: trunk/mapbender/http/plugins/jq_upload.js
===================================================================
--- trunk/mapbender/http/plugins/jq_upload.js (rev 0)
+++ trunk/mapbender/http/plugins/jq_upload.js 2009-11-04 14:48:09 UTC (rev 4919)
@@ -0,0 +1,73 @@
+$.fn.upload = function (args) {
+ return this.each(function () {
+ var options = args || {};
+ var $this = $(this);
+ $this.append();
+ var id = this.id;
+ var time = 0;
+ var timeout = options.timeout || 7000;
+ var timeinterval = options.interval || 200;
+
+ var startUpload = function () {
+ var t = setInterval(function () {
+ var returnValue = window.frames[id + "_target"].id;
+ time += timeinterval;
+ if (typeof returnValue !== "undefined") {
+ clearInterval(t);
+ time = 0;
+
+ var returnValueArray = returnValue.split("_");
+ var filename = returnValueArray[returnValueArray.length - 2];
+ var msg = "";
+ var success = false;
+ if (returnValue.match(/_finished/)) {
+ delete window.frames[id + "_target"].id;
+ if (typeof options.callback === "function") {
+ options.callback(filename, true, "");
+ }
+ }
+ else if (returnValue.match(/_cancelled/)) {
+ delete window.frames[id + "_target"].id;
+ msg = "File upload cancelled.";
+ new Mb_exception(msg);
+ if (typeof options.callback === "function") {
+ options.callback("", false, msg);
+ }
+ }
+ return;
+ }
+ if (time >= timeout) {
+ clearInterval(t);
+ time = 0;
+
+ msg = "File upload failed, timeout reached (" +
+ timeout + " ms)";
+ new Mb_exception(msg);
+
+ if (typeof options.callback === "function") {
+ options.callback("", false, msg);
+ }
+ return;
+ }
+ }, timeinterval);
+ };
+
+ var $form = $(
+ "<form action='../plugins/jq_upload.php?id=" + id + "' method='post' " +
+ "enctype='multipart/form-data' target='" + id + "_target'>" +
+ "</form>"
+ ).submit(function () {
+ startUpload();
+ return true;
+ });
+ $form.append($(
+ "<p id=" + id + "'_form' align='center'><br/>" +
+ "<input name='myfile' type='file' size='30' />" +
+ "<input type='submit' value='Upload' />" +
+ "</p>" +
+ "<iframe name='" + id + "_target' src='#' " +
+ "style='width:0;height:0;border:0px solid #fff;'></iframe>"
+ ));
+ $this.append($form);
+ });
+};
\ No newline at end of file
Added: trunk/mapbender/http/plugins/jq_upload.php
===================================================================
--- trunk/mapbender/http/plugins/jq_upload.php (rev 0)
+++ trunk/mapbender/http/plugins/jq_upload.php 2009-11-04 14:48:09 UTC (rev 4919)
@@ -0,0 +1,33 @@
+<?php
+ require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
+
+ $id = $_GET["id"];
+ if (!preg_match("/[a-zA-Z0-9-_]+/", $id)) {
+ $message = "cancelled";
+ }
+ else {
+ $result = 0;
+ $clientFilename = $_FILES['myfile']['tmp_name'];
+
+ $serverFilename = uniqid(true);
+ $serverFullFilename = TMPDIR . "/" . $serverFilename;
+ if (copy($clientFilename, $serverFullFilename)) {
+ $message = "finished";
+ }
+ else {
+ $message = "cancelled";
+ }
+ }
+?>
+<html>
+ <head>
+ <script type="text/javascript">
+ window.id = "<?php
+ echo $id . "_" . $serverFilename . "_" . $message;
+ ?>";
+ </script>
+ </head>
+ <body>
+
+ </body>
+</html>
\ No newline at end of file
More information about the Mapbender_commits
mailing list