[Mapbender-commits] r5466 - in trunk/mapbender: http/plugins lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sun Jan 31 05:00:49 EST 2010


Author: christoph
Date: 2010-01-31 05:00:48 -0500 (Sun, 31 Jan 2010)
New Revision: 5466

Modified:
   trunk/mapbender/http/plugins/mb_twitter.php
   trunk/mapbender/http/plugins/mb_twitter_update.js
   trunk/mapbender/lib/marker.js
Log:


Modified: trunk/mapbender/http/plugins/mb_twitter.php
===================================================================
--- trunk/mapbender/http/plugins/mb_twitter.php	2010-01-30 08:33:05 UTC (rev 5465)
+++ trunk/mapbender/http/plugins/mb_twitter.php	2010-01-31 10:00:48 UTC (rev 5466)
@@ -55,6 +55,26 @@
 		$ajaxResponse->setSuccess(true);
 		break;
 
+	case "update":
+		$Twitter = new EpiTwitter($consumerKey, $consumerSecret);
+		$status = $ajaxResponse->getParameter("status");
+		$lat = $ajaxResponse->getParameter("lat");
+		$lon = $ajaxResponse->getParameter("lon");
+		try {
+			$newStatus = $Twitter->post_statusesUpdate(array(
+				'status' => $text, 
+				'lat' => $lat, 
+				'long' => $long
+			));
+		}
+		catch (Exception $e) {
+			$ajaxResponse->setSuccess(false);
+			$ajaxResponse->setMessage(_mb("Could not connect to Twitter."));
+			$ajaxResponse->send();
+		}
+		$ajaxResponse->setResult(array("res" => serialize($newStatus))); 
+		$ajaxResponse->setSuccess(true);
+		break;
 	default: 
 		$ajaxResponse->setSuccess(false);
 		$ajaxResponse->setMessage(_mb("An unknown error occured."));

Modified: trunk/mapbender/http/plugins/mb_twitter_update.js
===================================================================
--- trunk/mapbender/http/plugins/mb_twitter_update.js	2010-01-30 08:33:05 UTC (rev 5465)
+++ trunk/mapbender/http/plugins/mb_twitter_update.js	2010-01-31 10:00:48 UTC (rev 5466)
@@ -2,6 +2,30 @@
 var that = this;
 
 Mapbender.events.init.register(function () {
+	var updateStatus = function (status, lat, lon, callback) {
+		var req = new Mapbender.Ajax.Request({
+			url: "../plugins/mb_twitter.php",
+			method: "update",
+			parameters: {
+				status: status,
+				lat: lat,
+				lon: lon
+			},
+			callback: function (obj, result, message) {
+				if (!result) {
+					alert(message);
+					return;
+				}
+								
+				if (typeof callback === "function") {
+					callback();				
+				}
+				alert("Updated");
+				new Mapbender.Notice($.toJSON(obj));
+			}
+		});
+		req.send();	
+	}
 	var button = new Mapbender.Button({
 		domElement: that,
 		over: options.src.replace(/_off/, "_over"),
@@ -23,18 +47,37 @@
 						"style='position:absolute;top:" + 
 						(pix.y + parseInt(this.style.top, 10)) + "px;" + 
 						"left:" + (pix.x + parseInt(this.style.left, 10)) + "px;" + 
-						"border:1px solid black;z-index:999'>" + 
+						"border:1px solid black;z-index:999;padding:8px;display:none'>" + 
 						"<div>What's happening?<span style='float:right'>140</span></div>" + 
 						"<textarea rows='2' cols='70'></textarea>" + 
-						"<br><a style='float:right' class='ui-state-default ui-corner-all' href='#'>update</a>" + 
-						"</div>").appendTo("body");
+						"<br><span style='float:right;margin:10px;'>" + 
+						"<span id='twitter_update' style='margin:5px;padding:5px;' " + 
+						"class='ui-state-default ui-corner-all'>update</span>" + 
+						"<a id='twitter_cancel' href='#'>cancel</a></span>" + 
+						"</div>").appendTo("body").show("slow");
 					var $charsLeft = $("span", $twitterStatus);
-					var $textarea = $twitterStatus.children().eq(1);
+					var $textarea = $twitterStatus.children("textarea");
 					$textarea.focus().keypress(function () {
 						var chars = $textarea.val().length;
 						var avail = 140 - chars;
 						$charsLeft.text(avail);
 					});
+					var $button = $("#twitter_update");
+					$button.click(function () {
+						twitterStatus.hide("slow", function () {
+							m.remove();						
+						});
+						// show sandclock
+						updateStatus($textarea.val(), p.y, p.x, function () {
+							// hide sandclock
+						});
+					});
+					var $cancel = $("#twitter_cancel");
+					$cancel.click(function () {
+						twitterStatus.hide("slow", function () {
+							m.remove();						
+						});
+					});
 					return false;
 	 			});
 			});

Modified: trunk/mapbender/lib/marker.js
===================================================================
--- trunk/mapbender/lib/marker.js	2010-01-30 08:33:05 UTC (rev 5465)
+++ trunk/mapbender/lib/marker.js	2010-01-31 10:00:48 UTC (rev 5466)
@@ -1,7 +1,8 @@
 Mapbender.Marker = function (p, map) {
+	var id = map.elementName + "_" + parseInt(Math.random()*100000,10);
 	var h = new Highlight(
 		[map.elementName],
-		map.elementName + "_" + parseInt(Math.random()*100000,10),
+		id,
 		"",
 		1
 	);
@@ -18,5 +19,8 @@
 	map.events.afterMapRequest.register(function () {
 		h.paint();
 	});
-	
+
+	this.remove = function () {
+		h.clean();
+	};
 };



More information about the Mapbender_commits mailing list