[Mapbender-commits] r1682 - in trunk/mapbender/http: css img
javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Sep 26 04:13:07 EDT 2007
Author: nimix
Date: 2007-09-26 04:13:07 -0400 (Wed, 26 Sep 2007)
New Revision: 1682
Added:
trunk/mapbender/http/css/popup.css
trunk/mapbender/http/img/close_icon.png
trunk/mapbender/http/img/resize.gif
trunk/mapbender/http/javascripts/popup.js
Modified:
trunk/mapbender/http/javascripts/map.js
Log:
add popup replacement
Added: trunk/mapbender/http/css/popup.css
===================================================================
--- trunk/mapbender/http/css/popup.css (rev 0)
+++ trunk/mapbender/http/css/popup.css 2007-09-26 08:13:07 UTC (rev 1682)
@@ -0,0 +1,39 @@
+ at CHARSET "UTF-8";
+div.jqmNotice img.jqResize {position: absolute; right: 2px; bottom: 2px;}
+div.jqmNotice iframe {width:100%;height:100%;}
+
+div.jqmNotice {
+ display: none;
+ z-index:50;
+ position: absolute;
+ width: 300px;
+ height:250px;
+ background:#EEEEEE url(../img/info_on.gif) 5px 5px no-repeat;
+ border: 1px solid #000;
+ padding: 0;
+ padding-bottom:30px;
+}
+
+.jqmnTitle{margin: 0 25px;}
+
+.jqmnTitle h1{
+ margin: 5px 0;
+ padding-left:5px;
+ width: 100%;
+ font-size:12px;
+ color:#EEEEEE;
+ background-color:#505050;
+}
+
+div.jqmNotice .jqmClose {
+ position: absolute;
+ cursor: pointer;
+ right: 4px;
+ top: 6px;
+}
+
+.jqmnContent{
+ border-top:1px;
+ color:#000;
+ padding:0 20px 5px;
+}
\ No newline at end of file
Added: trunk/mapbender/http/img/close_icon.png
===================================================================
(Binary files differ)
Property changes on: trunk/mapbender/http/img/close_icon.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/mapbender/http/img/resize.gif
===================================================================
(Binary files differ)
Property changes on: trunk/mapbender/http/img/resize.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/mapbender/http/javascripts/map.js
===================================================================
--- trunk/mapbender/http/javascripts/map.js 2007-09-26 08:11:53 UTC (rev 1681)
+++ trunk/mapbender/http/javascripts/map.js 2007-09-26 08:13:07 UTC (rev 1682)
@@ -719,14 +719,25 @@
}
else if(path && validation){
newfeatureInfoRequest += requestParams
- window.open(path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
+ try{
+ var p = new mb_popup("Feature Info","url:"+path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr,300,400);
+ p.show();
+ }catch(e){
+ window.open(path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
+ }
cnt_fi++;
}
else if(validation){
newfeatureInfoRequest += requestParams;
- window.open(newfeatureInfoRequest, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
- cnt_fi++;
- }
+ try{
+ var p = new mb_popup("Feature Info","url:"+newfeatureInfoRequest,300,400);
+ p.show();
+ }
+ catch(e){
+ window.open(newfeatureInfoRequest, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
+ }
+ cnt_fi++;
+ }
}
}
}
Added: trunk/mapbender/http/javascripts/popup.js
===================================================================
--- trunk/mapbender/http/javascripts/popup.js (rev 0)
+++ trunk/mapbender/http/javascripts/popup.js 2007-09-26 08:13:07 UTC (rev 1682)
@@ -0,0 +1,269 @@
+/*
+* $Id: popup.js 895 2007-09-17 17:57:38Z nimix $
+* COPYRIGHT: (C) 2002 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details.
+*/
+//http://www.mapbender.org/index.php/popup.js
+
+/*jqModal*/
+/*
+ * jqModal - Minimalist Modaling with jQuery
+ *
+ * Copyright (c) 2007 Brice Burgess <bhb at iceburg.net>, http://www.iceburg.net
+ * Licensed under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * $Version: 2007.08.17 +r11
+ *
+ */
+(function($) {
+$.fn.jqm=function(o){
+var _o = {
+zIndex: 3000,
+overlay: 50,
+overlayClass: 'jqmOverlay',
+closeClass: 'jqmClose',
+trigger: '.jqModal',
+ajax: false,
+target: false,
+modal: false,
+toTop: false,
+onShow: false,
+onHide: false,
+onLoad: false
+};
+return this.each(function(){if(this._jqm)return; s++; this._jqm=s;
+H[s]={c:$.extend(_o, o),a:false,w:$(this).addClass('jqmID'+s),s:s};
+if(_o.trigger)$(this).jqmAddTrigger(_o.trigger);
+});};
+
+$.fn.jqmAddClose=function(e){hs(this,e,'jqmHide'); return this;};
+$.fn.jqmAddTrigger=function(e){hs(this,e,'jqmShow'); return this;};
+$.fn.jqmShow=function(t){return this.each(function(){if(!H[this._jqm].a)$.jqm.open(this._jqm,t)});};
+$.fn.jqmHide=function(t){return this.each(function(){if(H[this._jqm].a)$.jqm.close(this._jqm,t)});};
+
+$.jqm = {
+hash:{},
+open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(/^\d+$/.test(h.w.css('z-index')))?h.w.css('z-index'):c.zIndex,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});h.t=t;h.a=true;h.w.css('z-index',z);
+ if(c.modal) {if(!A[0])F('bind');A.push(s);o.css('cursor','wait');}
+ else if(c.overlay > 0)h.w.jqmAddClose(o);
+ else o=false;
+
+ h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):false;
+ if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in {Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}}
+
+ if(c.ajax) {var r=c.target||h.w,u=c.ajax,r=(typeof r == 'string')?$(r,h.w):$(r),u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u;
+ r.load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
+ else if(cc)h.w.jqmAddClose($(cc,h.w));
+
+ if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);
+ (c.onShow)?c.onShow(h):h.w.show();e(h);return false;
+},
+close:function(s){var h=H[s];h.a=false;
+ if(A[0]){A.pop();if(!A[0])F('unbind');}
+ if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();
+ if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return false;
+}};
+var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version == "6.0"),
+i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),
+e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i); f(h);},
+f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(e){}},
+F=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},
+m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return !r;},
+hs=function(w,e,y){var s=[];w.each(function(){s.push(this._jqm)});
+ $(e).each(function(){if(this[y])$.extend(this[y],s);else{this[y]=s;$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return false;});}});};
+})(jQuery);
+/*
+ * jqDnR - Minimalistic Drag'n'Resize for jQuery.
+ *
+ * Copyright (c) 2007 Brice Burgess <bhb at iceburg.net>, http://www.iceburg.net
+ * Licensed under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * $Version: 2007.08.19 +r2
+ */
+
+(function($){
+$.fn.jqDrag=function(h){return i(this,h,'d');};
+$.fn.jqResize=function(h){return i(this,h,'r');};
+$.jqDnR={dnr:{},e:0,
+drag:function(v){
+ if(M.k == 'd')E.css({left:M.X+v.pageX-M.pX,top:M.Y+v.pageY-M.pY});
+ else E.css({width:Math.max(v.pageX-M.pX+M.W,0),height:Math.max(v.pageY-M.pY+M.H,0)});
+ return false;},
+stop:function(){E.css('opacity',M.o);$().unbind('mousemove',J.drag).unbind('mouseup',J.stop);}
+};
+var J=$.jqDnR,M=J.dnr,E=J.e,
+i=function(e,h,k){return e.each(function(){h=(h)?$(h,e):e;
+ h.bind('mousedown',{e:e,k:k},function(v){var d=v.data,p={};E=d.e;
+ // attempt utilization of dimensions plugin to fix IE issues
+ if(E.css('position') != 'relative'){try{E.position(p);}catch(e){}}
+ M={X:p.left||f('left')||0,Y:p.top||f('top')||0,W:f('width')||E[0].scrollWidth||0,H:f('height')||E[0].scrollHeight||0,pX:v.pageX,pY:v.pageY,k:d.k,o:E.css('opacity')};
+ E.css({opacity:0.8});$().mousemove($.jqDnR.drag).mouseup($.jqDnR.stop);
+ return false;
+ });
+});},
+f=function(k){return parseInt(E.css(k))||false;};
+})(jQuery);
+/*end jqModal*/
+
+var popup_count = 0;
+var popup_top = 150;
+
+/**
+ * @class A class representing a popup window
+ *
+ * @constructor
+ * @param {String} title the title text of the popup
+ * @param {String} html the "body" of the popup, can also be "url:http://foo.de" to display a website
+ * @param {Number} width width of the popup
+ * @param {Number} height hight of the popup
+ * @param {Number} posx left position of the popup
+ * @param {Number} popy top posision of the popup
+ *
+ */
+function mb_popup(title,html,width,height,posx,posy) {
+ //get first free place
+ var create_pos=popup_count;
+ for(var i = 0; i < popup_count;i++)
+ if(!document.getElementById("popup"+String(i))){
+ create_pos=i;
+ break;
+ }
+
+ //Set member vars
+ this.left=posx?posx:25*create_pos;
+ this.top=posy?posy:25*create_pos;
+ this.width=width;
+ this.height=height;
+ this.title=title;
+ this.html=html.indexOf("url:")==0?'<iframe src="'+html.substr(4)+'"></iframe>':html;
+ this.id="popup"+String(create_pos);
+ popup_count++;
+}
+
+/**
+ * Shows the popup
+ */
+mb_popup.prototype.show = function(){
+ if(document.getElementById(this.id))return;
+ //create popup div
+ div=document.createElement('div');
+ div.id=this.id;
+ div.className = "jqmNotice";
+
+ div.style.left=String(this.left)+"px";
+ div.style.top=String(this.top)+"px";
+// div.style.width=String(this.width)+"px";
+// div.style.height=String(this.height)+"px";
+ div.style.zIndex=popup_top++;
+
+ //create Window elements
+ div.innerHTML='<div class="jqmnTitle jqDrag"><h1>'+this.title+'</h1></div><div class="jqmnContent">'+this.html+'</div><img src="../img/close_icon.png" class="jqmClose" alt="close" /><img src="../img/resize.gif" alt="resize" class="jqResize" />';
+
+ //create window
+ document.body.appendChild(div);
+ $("#"+this.id, document).jqDrag('.jqDrag').jqResize('.jqResize').jqm({
+ overlay: 0,
+ onShow: function(h) {
+ //on show annimate
+ h.w.css('opacity',1.00).slideDown("slow");
+ },
+ onHide: function(h) {
+ // on close do animation and destroy dom element.
+ h.w.slideUp("slow",function() {if(h.o) h.o.remove(); if(h.w)h.w.remove();});}
+ });
+ $("#"+this.id).jqm().jqmShow();
+ //on click bring window to top
+ $("*>#"+this.id).click(function (){this.style.zIndex=popup_top++});
+}
+
+/**
+ * Hides the popup
+ */
+mb_popup.prototype.hide = function(){
+ $("#"+this.id).jqm().jqmHide();
+}
+
+/**
+ * sets the width of the popup window
+ *
+ * @param {Number} width new width of the popup
+ */
+mb_popup.prototype.setWidth = function(width){
+ this.width=width;
+ var div=document.getElementById(this.id);
+ if(div)div.style.width=width;
+}
+
+/**
+ * sets the height of the popup window
+ *
+ * @param {Number} height new height of the popup
+ */
+mb_popup.prototype.setHeigth = function(height){
+ this.height=height;
+ var div=document.getElementById(this.id);
+ if(div)div.style.height=height;
+}
+
+/**
+ * sets the left position of the popup window
+ *
+ * @param {Number} left new left position of the popup
+ */
+mb_popup.prototype.setLeft = function(left){
+ this.left=left;
+ var div=document.getElementById(this.id);
+ if(div)div.style.left=left;
+}
+
+/**
+ * sets the top position of the popup window
+ *
+ * @param {Number} top new top position of the popup
+ */
+mb_popup.prototype.setTop = function(topp){
+ this.top=topp;
+ var div=document.getElementById(this.id);
+ if(div)div.style.top=topp;
+}
+
+/**
+ * sets the title of the popup window
+ *
+ * @param {String} title new title text of the popup
+ */
+mb_popup.prototype.setTitle = function(title){
+ this.title=title;
+ $("#"+this.id+" h1").text(title);
+}
+
+/**
+ * sets the html content of the popup window
+ *
+ * @param {String} html new html "body" of the popup
+ */
+mb_popup.prototype.setHtml = function(htmll){
+ this.html=htmll;
+ $("#"+this.id+" .jqmnContent").html(htmll);
+}
+
+/**
+ * sets the url of the content
+ *
+ * @param {String} url new url of the popup
+ */
+mb_popup.prototype.setUrl = function(url){
+ this.html="url:"+url;
+ $("#"+this.id+" .jqmnContent").html('<iframe src="'+url+'"></iframe>');
+}
+
+/**
+ * gets the visible state of the popup window
+ * @return visible state of the popup
+ * @type Boolean
+ */
+mb_popup.prototype.isVisible = function(){
+ return document.getElementById(this.id)?true:false;
+}
More information about the Mapbender_commits
mailing list