]> git.parisson.com Git - telemeta.git/commitdiff
fixed and compressed popupdiv
authorriccardo <riccardo@parisson.com>
Wed, 22 Jun 2011 13:40:28 +0000 (15:40 +0200)
committerriccardo <riccardo@parisson.com>
Wed, 22 Jun 2011 13:40:28 +0000 (15:40 +0200)
telemeta/htdocs/js/popupdiv-min.js
telemeta/htdocs/js/popupdiv.js
telemeta/templates/telemeta_default/home.html
telemeta/templates/telemeta_default/mediaitem_detail.html

index 0737a607ab54ed41d24302b6c7f0e1b6d50635a8..77bfb21af9981873a86f24f94989d876681cdf5c 100644 (file)
@@ -1 +1 @@
-function PopupDiv(){var a=jQuery;var b=this;var c={};if(arguments.length&&arguments[0]){c=arguments[0]}var d=a('<div/>');var e=a('<div/>').append(a('<a/>').attr('href','#').click(function(){b.close();return false})).append(' ').append(a('<div/>').css('clear','both'));var g=a('<div/>').css('overflow','auto');var h=a('<div/>').append(a('<a/>').attr('href','#').click(function(){b.trigger('ok',true);return false}));d.append(e).append(g).append(h);this.getDiv=function(){return d};var i={};this.getListeners=function(){return i};var k;var j;for(k in PopupDiv){var f=PopupDiv[k];if(PopupDiv.hasOwnProperty(k)&&(typeof f!=='function')){if(!j){j={}}j[k]=f}}if(j){var l=true;var m=undefined;if(typeof Object.getPrototypeOf!=="function"){if(typeof this.__proto__==="object"){m=this.__proto__}else{m=this;l=false}}else{m=Object.getPrototypeOf(this)}for(k in j){if(j.hasOwnProperty(k)){m[k]=j[k];if(l){delete PopupDiv[k]}}}}for(k in c){if(c.hasOwnProperty(k)){if(k==='onOk'||k==='onShow'||k==='onClose'){this.bind(k.substring(2).toLowerCase(),c[k])}else if(k=='content'){this.setContent(c[k])}else{this[k]=c[k]}}}if(!this.popupCss){this.popupCss={}}}(function(p){var $=jQuery;var z=window;var A=document;var B=$(z);var C='popup_'+(new Date().getTime());p.isClickElement=function(a){return a&&a.length==1&&a instanceof $&&a[0]!==z&&a[0]!==A&&(a.is('a')||a.is('input[type=button]')||a.is('button')||a.is('input[type=submit]'))};p.getId=function(){var a=this.getDiv();if(!(a.attr('id'))){a.attr('id',C+'_'+(new Date().getTime()))}return a.attr('id')};p.shadowOffset=4;p.invoker=B;p.bounds={'top':0.25,'left':0.25,'right':0.25,'bottom':0.25};p.boundsExact=false;p.popupClass='';p.popupCss={};p.showOk=false;p.showClose=false;p.title="";p.okButtonClass='';p.okButtonAlign='right';p.closeButtonClass='';p.titleClass='';p.okButtonTitle='Ok';p.closeButtonTitle='x';p.defaultCloseOperation='hide';p.focusable=false;p.fadInTime='fast';p.fadeOutTime=0;p.shadowOpacity=0.25;p.zIndex=10000;p.listItemClass='';p.listItemCss='';p.getFormData=function(){var c=this.find('input,select,textarea');var d={};var f=this.getFormDataAttrName();c.each(function(i,e){var a=$(e);var b=a.attr(f);if(b){d[b]=a.val()}});return d};p.setTitle=function(a){this.getDiv().children().eq(0).find(':title').eq(0).val(a)};p.find=function(a){return this.getDiv().children().eq(1).find(a)};p.bind=function(a,b){var c=this.getListeners();if(c.hasOwnProperty(a)){c[a].push(b)}else{c[a]=[b]}};p.unbind=function(a){var b=this.getListeners();if(a&&b.hasOwnProperty(a)){delete b[a]}else if(!a){for(var k in b){if(b.hasOwnProperty(k)){delete b[k]}}}};p.trigger=function(a){var b=this.getListeners();var c=this;if(b.hasOwnProperty(a)){var d=b[a];var i=0;if(a=='ok'){var e=this.getFormData();for(i=0;i<d.length;i++){d[i].apply(c,[e])}this.__okButtonHasBeenPressed=true;this.close();delete this['__okButtonHasBeenPressed']}else if(a=='close'){var f=this.__okButtonHasBeenPressed||false;for(i=0;i<d.length;i++){d[i].apply(c,[f])}}else{for(i=0;i<d.length;i++){d[i].apply(c)}}}};p.setContent=function(d){var e=this.getDiv();var f=$($(e).children()[1]);f.empty();var g=this.getFormDataAttrName();if(d instanceof $){f.append(d)}else if(d instanceof Array){var j=this;var l=$('<input/>').attr('type','hidden').attr(g,'selIndex');var m=function(a,b,c){b.click(function(){c.val(a);j.trigger('ok',true);return false}).focus(function(){c.val(a)})};var n=$([]);for(var h=0;h<d.length;h++){var o=d[h];var a=$('<a/>').attr('href','#').html(""+o).css('whiteSpace','nowrap');n=n.add(a);m(h,a,l);f.append(a)}n.css({'margin':'2px'});if(this.listItemClass){n.addClass(this.listItemClass)}if(this.listItemCss){n.css(this.listItemCss)}n.css({'position':'','display':'block'});f.append(l)}else if(d&&d.constructor==Object){var p=$([]);var q=$([]);var r=[0,0];var s=function(a,b){var c=$('<div/>');if(!b){b=a;a=$('<span/>')}q=q.add(b);p=p.add(a);f.append(c.append(a).append(b));return c};var t,component;var u=Math.max;var v=undefined;var w=$([]);for(var k in d){if(d.hasOwnProperty(k)){var x=d[k];if(typeof x=='string'||typeof x=='number'){t=$('<span/>').html(k);r[0]=u(r[0],k.length);r[1]=u(r[1],x.length);component=$('<input/>').attr('type','text').val(x).attr(g,k);w=w.add(s(t,component))}else if(x===true||x===false){var y=this.getId()+"_checkbox";t=$('<input/>').attr('type','checkbox').attr(g,k).attr('id',y);if(x){t.attr('checked','checked')}else{t.removeAttr('checked')}component=$('<label/>').attr('for',y).html(k);r[1]=u(r[1],k.length);w=w.add(s($('<span/>').append(t),component))}else if(x instanceof Array){t=$('<span/>').html(k);r[0]=u(r[0],k.length);component=$('<select/>').attr('size',1).attr(g,k);for(var i=0;i<x.length;i++){component.append($('<option/>').val(x[i]).html(x[i]));r[1]=u(r[1],x[i].length)}w=w.add(s(t,component))}if(v){v.css('marginBottom','1ex')}}}w.css({'white-space':'nowrap','marginBottom':'0.5ex'});$(w[w.length-1]).css('marginBottom','');p.add(q).css({'display':'inline-block','margin':'0px','padding':'0px'});p.css({'textAlign':'right','marginRight':'0.5ex','width':Math.round((3/5)*r[0])+'em'});q.css({'width':Math.round((3/5)*u(r[0],r[1]))+'em'})}else{f.append(""+d)}};p.setFocusCycleRoot=function(b){var c=this.getDiv();var d=this.getFocusAttr();var f=this.isClickElement(this.invoker);var g=c.children();var h=$(g[0]);var j=$(g[1]);var k=$(g[2]);var l=j.find('input[type!=hidden],select,textarea,a');var m=l.length?$(l[0]):c;if(this.showClose){l=l.add(h.find('a'))}if(this.showOk||this.title){l=l.add(h.find(':text'));if(this.showOk){l=l.add(k.find('a'))}}l=l.add(c);var n="blur."+this.getId();if(!b){l.each(function(i,a){$(a).unbind(n).removeAttr('tabindex').removeAttr(d)});this.getFirstFocusableElement=function(){return undefined};if(f){this.invoker.removeAttr('tabindex').removeAttr(d)}return}if(f){this.invoker.attr('tabindex',0).attr(d,'true')}var o=A;var p=this;l.each(function(i,e){var a=$(e);a.attr(d,'true');a.attr('tabindex',i+1);a.unbind(n).bind(n,function(){setTimeout(function(){var v=o.activeElement;if((v&&$(v).attr(d))||p.__isClosing){return}p.close()},200)})});this.getFirstFocusableElement=function(){return m}};p.getFirstFocusableElement=function(){return undefined};p.refresh=function(a,b){var c=this.isShowing();var d=this.focusable;if(a!==undefined){this.setContent(a);if(c&&d){this.setFocusCycleRoot(this.focusable)}}if(b!=undefined){if(c){this.setTitle(b)}else{this.title=b}}if(!c){return}var e=this.invoker;if(this.isClickElement(e)){this.setBoundsAsPopup(e)}else{this.setBoundsInside(e,this.bounds,this.boundsExact)}if(d){this.getFirstFocusableElement().focus()}};p.setTitle=function(a){var b=this.getDiv().children().eq(0);var c=b.contents().filter(function(){return this.nodeType==3});var d=c.get(0);if(!a){a=' '}if(d.textContent){d.textContent=a}else if(d.nodeValue){d.nodeValue=a}};p.isShowing=function(){return this.getDiv().is(':visible')};p.show=function(){var c=this.getDiv();var d=this;if(this.popupClass){c.removeClass().addClass(this.popupClass);this.popupClass=''}if(this.popupCss){c.css(this.popupCss);this.popupCss=''}this.setFocusCycleRoot(this.focusable);var e=c.children();var f=$(e[0]);var g=f.find('a').eq(0);if(this.showClose||this.title){f.css({'paddingBottom':'0.25em','whiteSpace':'nowrap'});if(this.titleClass&&this.title){f.attr('class',this.titleClass);this.titleClass=''}if(this.showClose){g.css('marginLeft','0.5em').attr('class',this.closeButtonClass).html(this.closeButtonTitle).css({'display':'inline-block','float':'right'})}else{g.hide()}this.setTitle(this.title)}var i=$(e[2]);var j=i.find('a').eq(0);if(this.showOk){i.css({'paddingTop':'0.25em','textAlign':this.okButtonAlign});j.attr('class',this.okButtonClass);j.html(this.okButtonTitle);j.css({'float':'none','display':'inline-block'})}if(!c.parent().length){c.appendTo('body')}var k=this.invoker;var l=this.isClickElement(k);if(l){this.setBoundsAsPopup(k);this['_tmpHandlers'+this.getId()]=undefined;var m=this.getFirstFocusableElement();if(m){var n=[];var o='click';var p=k.data("events")[o];$.each(p,function(a,b){n.push(b)});k.unbind(o);this['_tmpHandlers'+this.getId()]=n;k.unbind(o).bind(o,function(a){if(c.length&&c.is(':visible')){m.focus();return false}d.close.apply(d);return false})}}else{this.setBoundsInside(k,this.bounds,this.boundsExact)}var q=this.shadow();var r=l?this.placeAsPopup:this.placeInside;var s=function(){var w=B.width();var h=B.height();d._resizeTimeInterval=setInterval(function(){var a=B.width();var b=B.height();if(a!==w||b!==h){setTimeout(function(){if(!d.isShowing()||d.__isClosing){return}if(B.width()===a&&B.height()===b){r.apply(d)}},100)}},200);d.trigger('show');q.fadeTo(d.fadInTime,d.shadowOpacity,function(){var v=d.getFirstFocusableElement();if(v){v.focus()}})};c.show(this.fadInTime,function(){s()})};p.shadow=function(){var a=$('#'+this.getShadowDivId());var b=this.shadowOffset;if(!b&&a.length){a.remove();return $([])}else if(b){var c=this.getDiv();if(!a.length){a=c.clone(false,false).empty().css({'backgroundColor':'#000','borderColor':'#000','display':'block','zIndex':this.zIndex-1}).removeAttr('tabindex').removeAttr(this.getFocusAttr()).fadeTo(0,0).attr('id',this.getShadowDivId()).insertAfter(c)}var d=this.getBounds.apply(this);a.css({'left':(d.x+b)+'px','top':(d.y+b)+'px','width':(d.width)+'px','height':(d.height)+'px'})}return a};p.setBoundsAsPopup=function(a){var b=a;this.preSizeFcn();var c=this.getDiv();var d=this.shadowOffset;var e=this.getBoundsOf(B);var f=b.offset();var g=b.outerHeight();var h=f.top-e.y;var i=e.height-g-h;var j=h>i&&c.outerHeight(false)+d>i;var k=b.outerWidth();var l=e.x+e.width-f.left;var m=f.left+k-e.x;var n=m>l&&c.outerWidth(false)+d>l;this.setMaxSize({height:(j?h:i),width:(n?m:l)});this.setMinSize({width:b.outerWidth()+this.shadowOffset});this.postSizeFcn()};p.setBoundsInside=function(a,b,c){var d=this.getDiv();this.preSizeFcn();var e=this.getBoundsOf(a);var x=e.x;var y=e.y;var w=e.width;var h=e.height;var f=parseInt;var g={top:b['top'],left:b['left'],bottom:b['bottom'],right:b['right']};for(var k in g){if(g.hasOwnProperty(k)){if(g[k]<=0){g[k]=0}else if(g[k]<=1){g[k]=k=='top'||k=='bottom'?h*g[k]:w*g[k]}else{g[k]=f(g[k])}}}var i={'width':w-g['left']-g['right']+this.shadowOffset,'height':h-g['top']-g['bottom']+this.shadowOffset};this.setMaxSize({width:i.width,height:i.height});if(c){this.setMinSize({width:i.width,height:i.height})}this.postSizeFcn()};p.preSizeFcn=function(){var a=this.getDiv();var b=a.children();b.css('display','none');var c=b.eq(1);if(this.showClose||this.title){c=c.add(b.eq(0))}if(this.showOk){c=c.add(b.eq(2))}c=c.add(a);c.css({'display':'block','float':'','overflow':'visible'});c.css({'maxHeight':'','maxWidth':'','minHeight':'','minWidth':'','height':'','width':'','overflow':'','visibility':'visible','float':''});a.css({'margin':'0px','zIndex':this.zIndex,'position':'absolute'});var d=this.getBoundsOf();a.css({'left':d.x+'px','top':d.y+'px'})};p.postSizeFcn=function(){var a=this.getDiv();var b=a.children();var c=b.eq(0);var d=b.eq(1);var e=b.eq(2);var f=d.height();var g=(a.height()-c.outerHeight(true)-e.outerHeight(true)-(d.outerHeight(true)-d.height()));var h=a.width();var i=d.outerWidth(true);if(g<=0||h<=0){return}d.css('height',g+'px');d.css('width',h+'px');d.css('overflow','auto');if(this.isClickElement(this.invoker)){this.placeAsPopup()}else{this.placeInside()}};p.placeAsPopup=function(){var a=this.getDiv();var b=this.shadowOffset;var c=this.getBoundsOf(B);var d=this.invoker;var e=d.offset();var f=d.outerHeight();var g=e.top-c.y;var h=c.height-f-g;var i=g>h&&a.outerHeight(false)+b>h;var j=d.outerWidth();var k=c.x+c.width-e.left;var l=e.left+j-c.x;var m=l>k&&a.outerWidth(false)+b>k;var n={'left':m?e.left+j-a.outerWidth(true)-b:e.left,'top':(i?e.top-a.outerHeight(true):e.top+f)};a.css({'top':n.top+'px','left':n.left+'px'});this.shadow()};p.placeInside=function(){var a=this.getDiv();var b=this.invoker;var c=this.getBoundsOf(b);var d=this.bounds;var x=c.x;var y=c.y;var w=c.width;var h=c.height;var e=parseInt;var f={top:d['top'],left:d['left'],bottom:d['bottom'],right:d['right']};for(var k in f){if(f.hasOwnProperty(k)){if(f[k]<=0){f[k]=0}else if(f[k]<=1){f[k]=k=='top'||k=='bottom'?h*f[k]:w*f[k]}else{f[k]=e(f[k])}}}var g={'width':w-f['left']-f['right']+this.shadowOffset,'height':h-f['top']-f['bottom']+this.shadowOffset};var i=a.outerWidth(true);var j=a.outerHeight(true);var l=0;var m=0;if(i<g.width){l=(g.width-i)/2}if(j<g.height){m=(g.height-j)/2}a.css({'left':(x+f['left']+l)+'px','top':(y+f['top']+m)+'px'});this.shadow()};p.getBounds=function(){return this.getBoundsOf(this.getDiv())};p.getBoundsOf=function(a){var b={x:0,y:0,width:0,height:0};if(!a||!(a instanceof $)){a=B}if(a[0]===z){b.x=a.scrollLeft();b.y=a.scrollTop()}else{var c=a.offset();b.x=c.left;b.y=c.top}b.width=a.width();b.height=a.height();return b};p.setMaxSize=function(a){var b=this.getDiv();this._convertSize(b,a);var c;if(a.hasOwnProperty('width')){if(!c){c={}}c.maxWidth=a.width+'px'}if(a.hasOwnProperty('height')){if(!c){c={}}c.maxHeight=a.height+'px'}if(c){b.css(c)}return a};p.setMinSize=function(a){var b=this.getDiv();this._convertSize(b,a);var c;if(a.hasOwnProperty('width')){if(!c){c={}}c.minWidth=a.width+'px'}if(a.hasOwnProperty('height')){if(!c){c={}}c.minHeight=a.height+'px'}if(c){b.css(c)}return a};p._convertSize=function(a,b){var c={'width':a.outerWidth(true)-a.width(),'height':a.outerHeight(true)-a.height()};if(b.hasOwnProperty('width')){b.width-=(c.width+this.shadowOffset)}if(b.hasOwnProperty('height')){b.height-=(c.height+this.shadowOffset)}};p.offset=function(a){var b=this.getDiv();b.offset(a)};p.close=function(){this.__isClosing=true;if(this._resizeTimeInterval!==undefined){clearInterval(this._resizeTimeInterval);this._resizeTimeInterval=undefined}this.setFocusCycleRoot(false);var c=this.getDiv();var d=$('#'+this.getShadowDivId());d.remove();var e=this;var f=this.defaultCloseOperation=='remove';c.hide(this.fadeOutTime,function(){if(f){c.remove()}var a='_tmpHandlers'+e.getId();if(e[a]){var b=e[a];delete e[a];e.invoker.unbind('click');for(var k=0;k<b.length;k++){var h=b[k];e.invoker.bind(h.type+(h.namespace?"."+h.namespace:""),h.handler)}}delete e['__isClosing'];e.trigger('close')})};p.setTimeout=function(a,b){var c=this;var t=undefined;if(a==='show'){t=setTimeout(function(){c.show()},b)}else if(a==='close'){t=setTimeout(function(){c.close()},b)}return t};p.getShadowDivId=function(){return this.getId()+"_shadow"};p.getFocusAttr=function(){return this.getId()+"_focus"};p.getFormDataAttrName=function(){return this.getId()+"_data"}})(PopupDiv.prototype);
\ No newline at end of file
+function PopupDiv(){var a=jQuery;var b=this;var c={};if(arguments.length&&arguments[0]){c=arguments[0]}var d=a('<div/>');var e=a('<div/>').append(a('<a/>').attr('href','#').click(function(){b.close('closeClicked');return false})).append(' ').append(a('<div/>').css('clear','both'));var g=a('<div/>').css('overflow','auto');var h=a('<div/>').append(a('<a/>').attr('href','#').click(function(){b.trigger('ok');return false}));d.append(e).append(g).append(h);this.getDiv=function(){return d};var i={};this.getListeners=function(){return i};var k;var j;for(k in PopupDiv){var f=PopupDiv[k];if(PopupDiv.hasOwnProperty(k)&&(typeof f!=='function')){if(!j){j={}}j[k]=f}}if(j){var l=true;var m=undefined;if(typeof Object.getPrototypeOf!=="function"){if(typeof this.__proto__==="object"){m=this.__proto__}else{m=this;l=false}}else{m=Object.getPrototypeOf(this)}for(k in j){if(j.hasOwnProperty(k)){m[k]=j[k];if(l){delete PopupDiv[k]}}}}for(k in c){if(c.hasOwnProperty(k)){if(k==='onOk'||k==='onShow'||k==='onClose'){this.bind(k.substring(2).toLowerCase(),c[k])}else if(k=='content'){this.setContent(c[k])}else{this[k]=c[k]}}}if(!this.popupCss){this.popupCss={}}}(function(p){var $=jQuery;var z=window;var A=document;var B=$(z);var C='popup_'+(new Date().getTime());p.isClickElement=function(a){return a&&a.length==1&&a instanceof $&&a[0]!==z&&a[0]!==A&&(a.is('a')||a.is('input[type=button]')||a.is('button')||a.is('input[type=submit]'))};p.getId=function(){var a=this.getDiv();if(!(a.attr('id'))){a.attr('id',C+'_'+(new Date().getTime()))}return a.attr('id')};p.shadowOffset=4;p.invoker=B;p.bounds={'top':0.25,'left':0.25,'right':0.25,'bottom':0.25};p.boundsExact=false;p.popupClass='';p.popupCss={};p.showOk=false;p.showClose=false;p.title="";p.okButtonClass='';p.okButtonAlign='right';p.closeButtonClass='';p.titleClass='';p.okButtonTitle='Ok';p.closeButtonTitle='x';p.defaultCloseOperation='hide';p.focusable=false;p.fadInTime='fast';p.fadeOutTime=0;p.shadowOpacity=0.25;p.zIndex=10000;p.listItemClass='';p.listItemCss='';p.getFormData=function(){var c=this.find('input,select,textarea');var d={};var f=this.getFormDataAttrName();c.each(function(i,e){var a=$(e);var b=a.attr(f);if(b){d[b]=a.val()}});return d};p.find=function(a){return this.getDiv().children().eq(1).find(a)};p.bind=function(a,b){var c=this.getListeners();if(c.hasOwnProperty(a)){c[a].push(b)}else{c[a]=[b]}};p.unbind=function(a){var b=this.getListeners();if(a&&b.hasOwnProperty(a)){delete b[a]}else if(!a){for(var k in b){if(b.hasOwnProperty(k)){delete b[k]}}}};p.trigger=function(a){var b=this.getListeners();var c=this;if(b.hasOwnProperty(a)){var d=b[a];var i=0;if(a=='ok'){var e=this.getFormData();for(i=0;i<d.length;i++){d[i].apply(c,[e])}this.close('okClicked')}else if(a=='close'){var f="";if(arguments&&arguments.length>1&&typeof arguments[1]==='string'){f=arguments[1]}for(i=0;i<d.length;i++){d[i].apply(c,[f])}}else{for(i=0;i<d.length;i++){d[i].apply(c)}}}};p.setContent=function(d){var e=this.getDiv();var f=$($(e).children()[1]);f.empty();var g=this.getFormDataAttrName();if(d instanceof $){f.append(d)}else if(d instanceof Array){var j=this;var l=$('<input/>').attr('type','hidden').attr(g,'selIndex');var m=function(a,b,c){b.click(function(){c.val(a);j.trigger('ok');return false}).focus(function(){c.val(a)})};var n=$([]);for(var h=0;h<d.length;h++){var o=d[h];var a=$('<a/>').attr('href','#').html(""+o);n=n.add(a);m(h,a,l);f.append(a)}n.css({'margin':'2px'});if(this.listItemClass){n.addClass(this.listItemClass)}if(this.listItemCss){n.css(this.listItemCss)}n.css({'position':'','display':'block'});f.append(l)}else if(d&&d.constructor==Object){var p=$([]);var q=$([]);var r=[0,0];var s=function(a,b){var c=$('<div/>');if(!b){b=a;a=$('<span/>')}q=q.add(b);p=p.add(a);f.append(c.append(a).append(b));return c};var t,component;var u=Math.max;var v=undefined;var w=$([]);for(var k in d){if(d.hasOwnProperty(k)){var x=d[k];if(typeof x=='string'||typeof x=='number'){t=$('<span/>').html(k);r[0]=u(r[0],k.length);r[1]=u(r[1],x.length);component=$('<input/>').attr('type','text').val(x).attr(g,k);w=w.add(s(t,component))}else if(x===true||x===false){var y=this.getId()+"_checkbox";t=$('<input/>').attr('type','checkbox').attr(g,k).attr('id',y);if(x){t.attr('checked','checked')}else{t.removeAttr('checked')}component=$('<label/>').attr('for',y).html(k);r[1]=u(r[1],k.length);w=w.add(s($('<span/>').append(t),component))}else if(x instanceof Array){t=$('<span/>').html(k);r[0]=u(r[0],k.length);component=$('<select/>').attr('size',1).attr(g,k);for(var i=0;i<x.length;i++){component.append($('<option/>').val(x[i]).html(x[i]));r[1]=u(r[1],x[i].length)}w=w.add(s(t,component))}if(v){v.css('marginBottom','1ex')}}}w.css({'white-space':'nowrap','marginBottom':'0.5ex'});$(w[w.length-1]).css('marginBottom','');p.add(q).css({'display':'inline-block','margin':'0px','padding':'0px'});p.css({'textAlign':'right','marginRight':'0.5ex','width':Math.round((3/5)*r[0])+'em'});q.css({'width':Math.round((3/5)*u(r[0],r[1]))+'em'})}else{f.append(""+d)}};p.setFocusCycleRoot=function(b){var c=this.getDiv();var d=this.getFocusAttr();var f=this.isClickElement(this.invoker);var g=c.children();var h=$(g[0]);var j=$(g[1]);var k=$(g[2]);var l=j.find('input[type!=hidden],select,textarea,a');var m=l.length?$(l[0]):j;if(this.showClose){l=l.add(h.find('a'))}if(this.showOk||this.title){l=l.add(h.find(':text'));if(this.showOk){l=l.add(k.find('a'))}}c.add(j).css('outline','#FFF none 0px');l=l.add(c).add(j);var n="blur."+this.getId();if(!b){l.each(function(i,a){$(a).unbind(n).removeAttr('tabindex').removeAttr(d)});this.getFirstFocusableElement=function(){return undefined};if(f){this.invoker.removeAttr('tabindex').removeAttr(d)}return}if(f){this.invoker.attr('tabindex',0).attr(d,'true')}var o=A;var p=this;l.each(function(i,e){var a=$(e);a.attr(d,'true');a.attr('tabindex',i+1);a.unbind(n).bind(n,function(){setTimeout(function(){var v=o.activeElement;if((v&&$(v).attr(d))||p.__isClosing){return}p.close('focusLost')},200)})});this.getFirstFocusableElement=function(){return m}};p.getFirstFocusableElement=function(){return undefined};p.refresh=function(a,b){var c=this.isShowing();var d=this.focusable;if(a!==undefined){this.setContent(a);if(c&&d){this.setFocusCycleRoot(this.focusable)}}if(b!=undefined){if(c){this.setTitle(b)}else{this.title=b}}if(!c){return}this.setBounds();if(d){this.getFirstFocusableElement().focus()}};p.setTitle=function(a){var b=this.getDiv().children().eq(0);var c=b.contents().filter(function(){return this.nodeType==3});var d=c.get(0);if(!a){a=' '}if(d.textContent){d.textContent=a}else if(d.nodeValue){d.nodeValue=a}};p.isShowing=function(){return this.getDiv().is(':visible')};p.show=function(){var c=this.getDiv();var d=this;var e=this.invoker;var f=this.isClickElement(e);this._isClickElement=f;this.setBounds=f?this._setBoundsAsPopup:this._setBoundsInside;this.setOffset=f?this._setOffsetAsPopup:this._setOffsetInside;if(this.popupClass){c.removeClass().addClass(this.popupClass);this.popupClass=''}if(this.popupCss){c.css(this.popupCss);this.popupCss=''}this.setFocusCycleRoot(this.focusable);var g=c.children();var i=$(g[0]);var j=i.find('a').eq(0);if(this.showClose||this.title){i.css({'paddingBottom':'0.25em'});if(this.titleClass&&this.title){i.attr('class',this.titleClass);this.titleClass=''}if(this.showClose){j.css('marginLeft','0.5em').attr('class',this.closeButtonClass).html(this.closeButtonTitle).css({'display':'inline-block','float':'right'})}else{j.hide()}this.setTitle(this.title)}var k=$(g[2]);var l=k.find('a').eq(0);if(this.showOk){k.css({'paddingTop':'0.25em','textAlign':this.okButtonAlign});l.attr('class',this.okButtonClass);l.html(this.okButtonTitle);l.css({'float':'none','display':'inline-block'})}if(!c.parent().length){c.appendTo('body')}if(f){this['_tmpHandlers'+this.getId()]=undefined;var m=this.getFirstFocusableElement();if(m){var n=[];var o='click';var p=e.data("events")[o];$.each(p,function(a,b){n.push(b)});e.unbind(o);this['_tmpHandlers'+this.getId()]=n;e.unbind(o).bind(o,function(a){if(c.length&&c.is(':visible')){m.focus();return false}d.close.apply(d);return false})}}this.setBounds();var q=this._getShadow();var r=this.setOffset;var s=function(){var w=B.width();var h=B.height();d._resizeTimeInterval=setInterval(function(){var a=B.width();var b=B.height();if(a!==w||b!==h){setTimeout(function(){if(!d.isShowing()||d.__isClosing){return}if(B.width()===a&&B.height()===b){r.apply(d)}},100)}},200);d.trigger('show');if(q!==undefined){q.fadeTo(d.fadInTime,d.shadowOpacity,function(){var v=d.getFirstFocusableElement();if(v){v.focus()}})}else{var v=d.getFirstFocusableElement();if(v){v.focus()}}};c.show(this.fadInTime,function(){s()})};p.refreshShadow=function(){var a=this._getShadow();var b=this.shadowOffset;if(!b&&a!==undefined){a.remove()}else if(b){var c=this.getDiv();if(a===undefined){a=c.clone(false,false).empty().css({'backgroundColor':'#000','borderColor':'#000','display':'block','zIndex':this.zIndex-1}).removeAttr('tabindex').removeAttr(this.getFocusAttr()).fadeTo(0,0).attr('id',this.getShadowDivId()).insertAfter(c)}var d=this.getBounds.apply(this);a.css({'left':(d.x+b)+'px','top':(d.y+b)+'px','width':(d.width)+'px','height':(d.height)+'px'})}};p._getShadow=function(){var a=this.getDiv().next('div');if(a&&a.length&&a.attr('id')===this.getShadowDivId()){return a}return undefined};p._setBoundsAsPopup=function(){var a=this.invoker;this.preSizeFcn();var b=this.getDiv();var c=this.shadowOffset;var d=this.getBoundsOf(B);var e=a.offset();var f=a.outerHeight();var g=e.top-d.y;var h=d.height-f-g;var i=g>h&&b.outerHeight(false)+c>h;var j=a.outerWidth();var k=d.x+d.width-e.left;var l=e.left+j-d.x;var m=l>k&&b.outerWidth(false)+c>k;this.setMaxSize({height:(i?g:h),width:(m?l:k)});this.setMinSize({width:a.outerWidth()+this.shadowOffset});this.postSizeFcn()};p._setBoundsInside=function(){var a=this.invoker;var b=this.bounds;var c=this.boundsExact;var d=this.getDiv();this.preSizeFcn();var e=this.getBoundsOf(a);var x=e.x;var y=e.y;var w=e.width;var h=e.height;var f=parseInt;var g={top:b['top'],left:b['left'],bottom:b['bottom'],right:b['right']};for(var k in g){if(g.hasOwnProperty(k)){if(g[k]<=0){g[k]=0}else if(g[k]<=1){g[k]=k=='top'||k=='bottom'?h*g[k]:w*g[k]}else{g[k]=f(g[k])}}}var i={'width':w-g['left']-g['right']+this.shadowOffset,'height':h-g['top']-g['bottom']+this.shadowOffset};this.setMaxSize({width:i.width,height:i.height});if(c){this.setMinSize({width:i.width,height:i.height})}this.postSizeFcn()};p.preSizeFcn=function(){var a=this.getDiv();var b=a.children();b.css('display','none');var c=b.eq(1);if(this.showClose||this.title){c=c.add(b.eq(0))}if(this.showOk){c=c.add(b.eq(2))}c=c.add(a);c.css({'display':'block','float':'','overflow':'visible'});c.css({'maxHeight':'','maxWidth':'','minHeight':'','minWidth':'','height':'','width':'','overflow':'','visibility':'visible','float':''});a.css({'margin':'0px','zIndex':this.zIndex,'position':'absolute'});var d=this.getBoundsOf();a.css({'left':d.x+'px','top':d.y+'px'})};p.postSizeFcn=function(){var a=this.getDiv();var b=a.children();var c=b.eq(0);var d=b.eq(1);var e=b.eq(2);var f=(a.height()-c.outerHeight(true)-e.outerHeight(true)-(d.outerHeight(true)-d.height()));if(f>0){d.css('height',f+'px')}d.css('overflow','auto');this.setOffset()};p._setOffsetAsPopup=function(){var a=this.getDiv();var b=this.shadowOffset;var c=this.getBoundsOf(B);var d=this.invoker;var e=d.offset();var f=d.outerHeight();var g=e.top-c.y;var h=c.height-f-g;var i=g>h&&a.outerHeight(false)+b>h;var j=d.outerWidth();var k=c.x+c.width-e.left;var l=e.left+j-c.x;var m=l>k&&a.outerWidth(false)+b>k;var n={'left':m?e.left+j-a.outerWidth(true)-b:e.left,'top':(i?e.top-a.outerHeight(true):e.top+f)};a.css({'top':n.top+'px','left':n.left+'px'});this.refreshShadow()};p._setOffsetInside=function(){var a=this.getDiv();var b=this.invoker;var c=this.getBoundsOf(b);var d=this.bounds;var x=c.x;var y=c.y;var w=c.width;var h=c.height;var e=parseInt;var f={top:d['top'],left:d['left'],bottom:d['bottom'],right:d['right']};for(var k in f){if(f.hasOwnProperty(k)){if(f[k]<=0){f[k]=0}else if(f[k]<=1){f[k]=k=='top'||k=='bottom'?h*f[k]:w*f[k]}else{f[k]=e(f[k])}}}var g={'width':w-f['left']-f['right']+this.shadowOffset,'height':h-f['top']-f['bottom']+this.shadowOffset};var i=a.outerWidth(true);var j=a.outerHeight(true);var l=0;var m=0;if(i<g.width){l=(g.width-i)/2}if(j<g.height){m=(g.height-j)/2}a.css({'left':(x+f['left']+l)+'px','top':(y+f['top']+m)+'px'});this.refreshShadow()};p.getBounds=function(){return this.getBoundsOf(this.getDiv())};p.getBoundsOf=function(a){var b={x:0,y:0,width:0,height:0};if(!a||!(a instanceof $)){a=B}if(a[0]===z){b.x=a.scrollLeft();b.y=a.scrollTop()}else{var c=a.offset();b.x=c.left;b.y=c.top}b.width=a.width();b.height=a.height();return b};p.setMaxSize=function(a){var b=this.getDiv();this._convertSize(b,a);var c;if(a.hasOwnProperty('width')){if(!c){c={}}c.maxWidth=a.width+'px'}if(a.hasOwnProperty('height')){if(!c){c={}}c.maxHeight=a.height+'px'}if(c){b.css(c)}return a};p.setMinSize=function(a){var b=this.getDiv();this._convertSize(b,a);var c;if(a.hasOwnProperty('width')){if(!c){c={}}c.minWidth=a.width+'px'}if(a.hasOwnProperty('height')){if(!c){c={}}c.minHeight=a.height+'px'}if(c){b.css(c)}return a};p._convertSize=function(a,b){var c={'width':a.outerWidth(true)-a.width(),'height':a.outerHeight(true)-a.height()};if(b.hasOwnProperty('width')){b.width-=(c.width+this.shadowOffset)}if(b.hasOwnProperty('height')){b.height-=(c.height+this.shadowOffset)}};p.offset=function(a){var b=this.getDiv();b.offset(a)};p.close=function(){this.__isClosing=true;if(this._resizeTimeInterval!==undefined){clearInterval(this._resizeTimeInterval);this._resizeTimeInterval=undefined}this.setFocusCycleRoot(false);var c=this.getDiv();var d=this._getShadow();if(d!==undefined){d.remove()}var e=this;var f=this.defaultCloseOperation=='remove';c.hide(this.fadeOutTime,function(){if(f){c.remove()}var a='_tmpHandlers'+e.getId();if(e[a]){var b=e[a];delete e[a];e.invoker.unbind('click');for(var k=0;k<b.length;k++){var h=b[k];e.invoker.bind(h.type+(h.namespace?"."+h.namespace:""),h.handler)}}delete e['__isClosing'];if(arguments&&arguments.length>0&&typeof arguments[0]==='string'){e.trigger('close',arguments[0])}else{e.trigger('close')}})};p.setTimeout=function(a,b){var c=this;var t=undefined;if(a==='show'){t=setTimeout(function(){c.show()},b)}else if(a==='close'){t=setTimeout(function(){c.close()},b)}return t};p.getShadowDivId=function(){return this.getId()+"_shadow"};p.getFocusAttr=function(){return this.getId()+"_focus"};p.getFormDataAttrName=function(){return this.getId()+"_data"}})(PopupDiv.prototype);
\ No newline at end of file
index fde0afd6cb793ae9499de8f771c82177fe8072a4..a1c5a9b9175c1a5fada9c10141123255fc378f6b 100644 (file)
@@ -21,7 +21,8 @@
  */\r
 \r
 /**\r
- * Class for showing non-modal dialogs such as popups or combo lists. Requires jQuery.\r
+ * Class for showing non-modal dialogs such as popups or combo lists. Requires jQuery. Works in IE7+, FF, Chrome. In IE7 some dimensions\r
+ * do not span the whole optimized width. Probably due to a bug in calculating the size when scrollbars are present. It works however.\r
  * This class builds an absolutely positioned div for popup forms, message dialogs or listitem popup (emilating the\r
  * <select> tag element popup). If you're scared about the doc, scroll below to see some examples.\r
  * Usage:\r
  *        After each onOk callback has been executed, popup.close() will be always called\r
  * onShow (null): callback to be executed when the popup shows up\r
  * defaultCloseOperation ('hide'): specified what to do when popup.close() is called. 'remove' calls jQuery.remove() on the popup, ie it removes the html element from the document, 'hide' or any other value simply call jQuery.hide() on the popup\r
- * onClose (null): callback to be executed when the popup .close() function is called. The callback must take one argument (boolean) which\r
- *        denotes wether the popup is closing after the ok button has been pressed or not. On the other hand, the argument is false, e.g.,\r
- *        if the close button is clicked (see showClose below), or when popup.focusable=true and the popup looses the focus\r
+ * onClose (null): callback to be executed when the popup .close() function is called. The callback must take one argument (string) which\r
+ *        denotes wether the popup is closing  because of 1) the ok button click, 2) a lost of focus, 3) the close button click or 4)\r
+ *        another reason (eg, a custom code call to popup.close()). In these cases, the string argument is\r
+ *        1) "okClicked", 2) "focusLost", 3) "closeClicked" and 4) the empty string ""\r
  * showClose (false): a parameter specifying whether a close button should appear on the top-right corner of the popup. Clicking the close button\r
  *      (internally, an <a> tag) will close the popup and trigger popup.close() (and associated callbacks bindings, if any)\r
  * closeButtonTitle ('x') [see note4]: self-explanatory\r
@@ -162,12 +164,12 @@ function PopupDiv() {
     //2: if text title overlaps, with a span it is not selectable, with an input it is\r
     //we however append a span to calculate the input width, not really ortodox I know. See setTitle (below)\r
     var header = $J('<div/>').append($J('<a/>').attr('href','#').click(function(){\r
-        me.close();\r
+        me.close('closeClicked');\r
         return false;\r
     })).append(' ').append($J('<div/>').css('clear','both')); //.css('float','right');\r
     var container = $J('<div/>').css('overflow','auto');\r
     var footer = $J('<div/>').append($J('<a/>').attr('href','#').click(function(){\r
-        me.trigger('ok',true);\r
+        me.trigger('ok');\r
         return false;\r
     }));\r
     //header.find('*').add(footer.find('*')).css('display','none');\r
@@ -285,7 +287,7 @@ function PopupDiv() {
 \r
 \r
     //default properties which can be overridden\r
-    p.shadowOffset = 4;\r
+    p.shadowOffset = 4; //zero means: no shadow\r
     p.invoker = wdw;\r
     p.bounds = {\r
         'top':0.25,\r
@@ -331,10 +333,6 @@ function PopupDiv() {
         return ret;\r
     };\r
 \r
-    p.setTitle = function(title){\r
-        this.getDiv().children().eq(0).find(':title').eq(0).val(title);\r
-    };\r
-\r
     //methods:\r
     p.find = function(argumentAsInJQueryFind){\r
         return this.getDiv().children().eq(1).find(argumentAsInJQueryFind);\r
@@ -374,13 +372,14 @@ function PopupDiv() {
                 for(i=0; i<callbacks.length; i++){\r
                     callbacks[i].apply(me,[data]);\r
                 }\r
-                this.__okButtonHasBeenPressed = true;\r
-                this.close();\r
-                delete this['__okButtonHasBeenPressed'];\r
+                this.close('okClicked');\r
             }else if(eventName == 'close'){\r
-                var okBHBP = this.__okButtonHasBeenPressed || false;\r
+                var str = "";\r
+                if(arguments && arguments.length>1 && typeof arguments[1] === 'string'){\r
+                    str = arguments[1];\r
+                }\r
                 for(i=0; i<callbacks.length; i++){\r
-                    callbacks[i].apply(me,[okBHBP]);\r
+                    callbacks[i].apply(me,[str]);\r
                 }\r
             }else{\r
                 for(i=0; i<callbacks.length; i++){\r
@@ -406,7 +405,7 @@ function PopupDiv() {
             var setEvents = function(idx,anchor,input){\r
                 anchor.click(function(){\r
                     input.val(idx);\r
-                    me.trigger('ok',true);\r
+                    me.trigger('ok');\r
                     return false;\r
                 }).focus(function(){ //focus because we need to get the value if ok is present\r
                     input.val(idx);\r
@@ -495,7 +494,7 @@ function PopupDiv() {
             }\r
             lineDivs.css({\r
                 'white-space': 'nowrap',\r
-                'marginBottom':'0.5ex'\r
+                'marginBottom': '0.5ex'\r
             });\r
             //last div erase marginBottom\r
             $(lineDivs[lineDivs.length-1]).css('marginBottom','');\r
@@ -517,7 +516,7 @@ function PopupDiv() {
                 'width':Math.round((3/5)*maxw[0])+'em'\r
             });\r
             rightElements.css({\r
-                'width':Math.round((3/5)*max(maxw[0], maxw[1]))+'em'\r
+                'width':Math.round((3/5)*max(maxw[0], maxw[1]))+'em' //approximate width\r
             }); //might be zero if default values are all ""\r
         }else{\r
             container.append(""+content);\r
@@ -547,7 +546,7 @@ function PopupDiv() {
                 elementsWithFocus = elementsWithFocus.add(bottomDiv.find('a'));\r
             }\r
         }\r
-        popup.add(centralDiv).css('outline','#FFF none 0px'); //DO NOT SHOW BORDER FOCUS FOR DIVS (NICER)\r
+        popup.add(centralDiv).css('outline','#FFF none 0px'); //DO NOT SHOW BORDER FOCUS FOR DIVS (NICER). Doesnt work in IE7\r
         elementsWithFocus = elementsWithFocus.add(popup).add(centralDiv);\r
         //we add the popup div cause in case of padding clicking on the popup padding should NOT hide the popup\r
         //we add the centralDiv cause, if scrollbars are present, then moving the scrollbars sets the focus to the\r
@@ -592,7 +591,7 @@ function PopupDiv() {
                         return;\r
                     }\r
 \r
-                    me.close();\r
+                    me.close('focusLost');\r
                 },200)\r
             }); //set here another time delay. 300 seems to be the good compromise between visual hide and safetiness that\r
         //meanwhile the focus has already been given to the next component\r
@@ -624,20 +623,15 @@ function PopupDiv() {
         if(!showing){\r
             return; //show(), when called, will update size and other stuff written in this method here bwloe\r
         }\r
-        var invoker = this.invoker;\r
-        if(this.isClickElement(invoker)){\r
-            this.setBoundsAsPopup(invoker);\r
-        }else{\r
-            this.setBoundsInside(invoker, this.bounds, this.boundsExact);\r
-        }\r
+        this.setBounds();\r
+        \r
         \r
-        //this.shadow(); //updates shadow\r
         if(focusable){\r
             this.getFirstFocusableElement().focus();\r
         }\r
     };\r
 \r
-    p.setTitle= function(title){\r
+    p.setTitle = function(title){\r
         var subdiv = this.getDiv().children().eq(0);\r
 \r
 \r
@@ -666,6 +660,11 @@ function PopupDiv() {
     p.show = function(){\r
         var div = this.getDiv();\r
         var me = this;\r
+        var invoker = this.invoker;\r
+        var isClickElement = this.isClickElement(invoker);\r
+        this._isClickElement = isClickElement;\r
+        this.setBounds = isClickElement ? this._setBoundsAsPopup : this._setBoundsInside;\r
+        this.setOffset = isClickElement ? this._setOffsetAsPopup : this._setOffsetInside;\r
 \r
         if(this.popupClass){\r
             //this.popupClass might be in the prototype (not set by user)\r
@@ -731,14 +730,12 @@ function PopupDiv() {
             }); //in order to set width and height on the element\r
         }\r
 \r
-        if(!div.parent().length){ //to be done before setSizeAsPopup or setBoundsInside\r
+        if(!div.parent().length){ //to be done before setsetBounds\r
             div.appendTo('body');\r
         }\r
 \r
-        var invoker = this.invoker;\r
-        var isClickElement = this.isClickElement(invoker);\r
+        \r
         if(isClickElement){\r
-            this.setBoundsAsPopup(invoker);\r
             //storing click events, when showing clicking on an event must give the focus to the popup\r
             //old handlers will be restored in close()\r
             this['_tmpHandlers'+this.getId()] = undefined;\r
@@ -768,13 +765,11 @@ function PopupDiv() {
                 });\r
             }\r
 \r
-        }else{\r
-            this.setBoundsInside(invoker, this.bounds, this.boundsExact);\r
         }\r
-\r
+        this.setBounds();\r
        \r
-        var shadow = this.shadow();\r
-        var place = isClickElement ? this.placeAsPopup : this.placeInside;\r
+        var shadow = this._getShadow();\r
+        var place = this.setOffset;\r
         var postShowFcn = function(){\r
             //adding window resize interval to track window changes\r
             var w = wdw.width();\r
@@ -796,12 +791,20 @@ function PopupDiv() {
 \r
 \r
             me.trigger('show');\r
-            shadow.fadeTo(me.fadInTime,me.shadowOpacity, function(){\r
+            if(shadow !== undefined){\r
+                shadow.fadeTo(me.fadInTime,me.shadowOpacity, function(){\r
+                    var v = me.getFirstFocusableElement();\r
+                    if(v){\r
+                        v.focus();\r
+                    }\r
+                });\r
+            }else{\r
                 var v = me.getFirstFocusableElement();\r
                 if(v){\r
                     v.focus();\r
                 }\r
-            });\r
+            }\r
+            \r
         };\r
 \r
         div.show(this.fadInTime,function(){\r
@@ -809,15 +812,15 @@ function PopupDiv() {
         });\r
     };\r
     //div must be visible\r
-    p.shadow = function(){\r
-        var shadow = $('#'+this.getShadowDivId());\r
+    p.refreshShadow = function(){\r
+        var shadow = this._getShadow(); //$('#'+this.getShadowDivId());\r
         var so = this.shadowOffset;\r
-        if(!so && shadow.length){\r
+        if(!so && shadow !== undefined){\r
             shadow.remove();\r
-            return $([]);\r
+        //shadow = undefined;\r
         }else if(so){\r
             var div = this.getDiv();\r
-            if(!shadow.length){\r
+            if(shadow === undefined){\r
                 //creating shadow. Remove attributes tabindex (unnecessary) and especially focusAttr,\r
                 //so that clicking tab key and setting the shadow focusable hides the popup. If one wants the shadow not to hide the popup. keep\r
                 //focusAttr BUT insert shadow in the focus cycle root (see method)\r
@@ -837,11 +840,19 @@ function PopupDiv() {
                 'height':(rect.height)+'px'\r
             });\r
         }\r
-        return shadow;\r
+    //return shadow;\r
     };\r
 \r
-    p.setBoundsAsPopup = function(popupInvoker){\r
-        var invoker = popupInvoker;\r
+    p._getShadow = function(){\r
+        var next = this.getDiv().next('div');\r
+        if(next && next.length && next.attr('id') === this.getShadowDivId()){\r
+            return next;\r
+        }\r
+        return undefined;\r
+    };\r
+\r
+    p._setBoundsAsPopup = function(){\r
+        var invoker = this.invoker;\r
 \r
         this.preSizeFcn();\r
 \r
@@ -887,7 +898,10 @@ function PopupDiv() {
     //padding={top:0.25,left:0.25,bottom:0.25,right:0.25} will place the popupdiv at the center of parent\r
     //padding={top:25,left:25,bottom:25,right:25} will place the popupdiv at distances 25 px from parent sides\r
     //in other words, padding keys lower or euqals to 1 will be conbsidered as percentage, otherwise as absolute measures in px\r
-    p.setBoundsInside = function(parent, pd, boundsExact){\r
+    p._setBoundsInside = function(){\r
+        var parent = this.invoker;\r
+        var pd = this.bounds;\r
+        var boundsExact = this.boundsExact;\r
 \r
         var div = this.getDiv();\r
         \r
@@ -977,26 +991,6 @@ function PopupDiv() {
             'visibility' : 'visible',\r
             'float':''\r
         });\r
-        //        subdivsshow.css({\r
-        //            'height':'',\r
-        //            'width':''\r
-        //        });\r
-\r
-        //subdivs.eq(0).css('width','');\r
-\r
-        //        subdivsshow.add(div).css({\r
-        //            'maxHeight':'none',\r
-        //            'maxWidth':'none',\r
-        //            'minHeight':'none',\r
-        //            'minWidth':'none',\r
-        //            'height':'auto',\r
-        //            'width':'auto',\r
-        //            'display':'block',\r
-        //            'overflow':'visible',\r
-        //            'float':'none'\r
-        //        });\r
-\r
-\r
         div.css({\r
             'margin':'0px',\r
             'zIndex':this.zIndex,\r
@@ -1011,14 +1005,14 @@ function PopupDiv() {
             'top':bounds.y+'px'\r
         });\r
 \r
-//            var topDiv =subdivs.eq(0);\r
-//            var centralDiv = subdivs.eq(1);\r
-//            var bottomDiv = subdivs.eq(2);\r
-//            console.log('presize');\r
-//            console.log('width: '+ topDiv.width()+' css-minWidth: ' +topDiv.css('minWidth')+' css-width: ' +topDiv.css('width')+' css-maxWidth: ' +topDiv.css('maxWidth'));\r
-//            console.log('width: '+centralDiv.width()+' css-minWidth: ' +centralDiv.css('minWidth')+' css-width: ' +centralDiv.css('width')+' css-maxWidth: ' +centralDiv.css('maxWidth'));\r
-//            console.log('width: '+bottomDiv.width()+' css-minWidth: ' +bottomDiv.css('minWidth')+' css-width: ' +bottomDiv.css('width')+' css-maxWidth: ' +bottomDiv.css('maxWidth'));\r
-//            console.log(' ' );\r
+    //            var topDiv =subdivs.eq(0);\r
+    //            var centralDiv = subdivs.eq(1);\r
+    //            var bottomDiv = subdivs.eq(2);\r
+    //            console.log('presize');\r
+    //            console.log('width: '+ topDiv.width()+' css-minWidth: ' +topDiv.css('minWidth')+' css-width: ' +topDiv.css('width')+' css-maxWidth: ' +topDiv.css('maxWidth'));\r
+    //            console.log('width: '+centralDiv.width()+' css-minWidth: ' +centralDiv.css('minWidth')+' css-width: ' +centralDiv.css('width')+' css-maxWidth: ' +centralDiv.css('maxWidth'));\r
+    //            console.log('width: '+bottomDiv.width()+' css-minWidth: ' +bottomDiv.css('minWidth')+' css-width: ' +bottomDiv.css('width')+' css-maxWidth: ' +bottomDiv.css('maxWidth'));\r
+    //            console.log(' ' );\r
     };\r
     \r
     p.postSizeFcn = function(){\r
@@ -1033,56 +1027,36 @@ function PopupDiv() {
         var centralDiv = subdivs.eq(1);\r
         //\r
         var bottomDiv = subdivs.eq(2);\r
-        //set central div max height ONLY IF NECESSARY (overflow). Until here, the main popup is sized and placed\r
-        //but the central div might overflow\r
-        var height = centralDiv.height();\r
+        //set central div height. We could set the central div height only if necessary, or the central div max height,\r
+        //but this has side effect in IE\r
+       \r
         var maxHeight = (div.height()-topDiv.outerHeight(true)-bottomDiv.outerHeight(true)-\r
             (centralDiv.outerHeight(true)-centralDiv.height()));\r
-        //same for width:\r
-        var maxWidth = div.width();\r
-        var width = centralDiv.outerWidth(true);\r
-            \r
-        \r
-        \r
-        \r
-\r
-        //setting centralDiv maxHeight is buggy and not the same behaviour in all browsers\r
-        //so we set a height, which will be reset in preSizeFcn\r
+       \r
+        //setting centralDiv maxHeight or height is actually the same, we use height to be sure...\r
         if(maxHeight>0){\r
             centralDiv.css('height',maxHeight+'px');\r
         }\r
-        //same for width\r
-        //centralDiv.css('width',maxWidth+'px');\r
-\r
-        \r
-\r
+       \r
         //to be put AT THE END otherwise bug in IE7\r
         centralDiv.css('overflow','auto');\r
         //after the command above, centralDiv.hegith is set to zero in IE7.\r
         //It might be a refresh problem cause if we display an alert then the size is properly set.\r
-        //However:\r
-        //if(centralDiv.height()==0 && maxHeight>0){\r
-       \r
-        //centralDiv.css('height',maxHeight);\r
-        //}\r
-\r
+        //However, put it at the end\r
         \r
 \r
-//                console.log('postsize');\r
-//                console.log('width: '+ topDiv.width()+' css-minWidth: ' +topDiv.css('minWidth')+' css-width: ' +topDiv.css('width')+' css-maxWidth: ' +topDiv.css('maxWidth'));\r
-//                console.log('width: '+centralDiv.width()+' css-minWidth: ' +centralDiv.css('minWidth')+' css-width: ' +centralDiv.css('width')+' css-maxWidth: ' +centralDiv.css('maxWidth'));\r
-//                console.log('width: '+bottomDiv.width()+' css-minWidth: ' +bottomDiv.css('minWidth')+' css-width: ' +bottomDiv.css('width')+' css-maxWidth: ' +bottomDiv.css('maxWidth'));\r
-//                console.log(' ' );\r
+        //                console.log('postsize');\r
+        //                console.log('width: '+ topDiv.width()+' css-minWidth: ' +topDiv.css('minWidth')+' css-width: ' +topDiv.css('width')+' css-maxWidth: ' +topDiv.css('maxWidth'));\r
+        //                console.log('width: '+centralDiv.width()+' css-minWidth: ' +centralDiv.css('minWidth')+' css-width: ' +centralDiv.css('width')+' css-maxWidth: ' +centralDiv.css('maxWidth'));\r
+        //                console.log('width: '+bottomDiv.width()+' css-minWidth: ' +bottomDiv.css('minWidth')+' css-width: ' +bottomDiv.css('width')+' css-maxWidth: ' +bottomDiv.css('maxWidth'));\r
+        //                console.log(' ' );\r
 \r
-        if(this.isClickElement(this.invoker)){\r
-            this.placeAsPopup();\r
-        }else{\r
-            this.placeInside();\r
-        }\r
+        \r
+        this.setOffset();\r
 \r
     };\r
 \r
-    p.placeAsPopup = function(){\r
+    p._setOffsetAsPopup = function(){\r
         var div = this.getDiv();\r
 \r
         var shadowOffset = this.shadowOffset;\r
@@ -1113,10 +1087,10 @@ function PopupDiv() {
             'top':offs.top+'px',\r
             'left':offs.left+'px'\r
         });\r
-        this.shadow(); //repositioning the shadow\r
+        this.refreshShadow(); //repositioning the shadow\r
     };\r
 \r
-    p.placeInside = function(){\r
+    p._setOffsetInside = function(){\r
        \r
         var div = this.getDiv();\r
 \r
@@ -1177,7 +1151,7 @@ function PopupDiv() {
             'top':(y+padding['top']+spanTop)+'px'\r
         });\r
 \r
-        this.shadow(); //repositioning the shadow\r
+        this.refreshShadow(); //repositioning the shadow\r
     };\r
 \r
     p.getBounds = function(){\r
@@ -1280,8 +1254,10 @@ function PopupDiv() {
         }\r
         this.setFocusCycleRoot(false);\r
         var div = this.getDiv();\r
-        var shadow = $('#'+this.getShadowDivId());\r
-        shadow.remove();\r
+        var shadow = this._getShadow(); //$('#'+this.getShadowDivId());\r
+        if(shadow !== undefined){\r
+            shadow.remove();\r
+        }\r
         var me = this;\r
         var remove = this.defaultCloseOperation == 'remove';\r
         div.hide(this.fadeOutTime, function(){\r
@@ -1303,7 +1279,11 @@ function PopupDiv() {
             }\r
 \r
             delete me['__isClosing'];\r
-            me.trigger('close');\r
+            if(arguments && arguments.length>0 && typeof arguments[0] === 'string'){\r
+                me.trigger('close',arguments[0]);\r
+            }else{\r
+                me.trigger('close');\r
+            }\r
         });\r
 \r
     };\r
index 846c0474d58dc91fbc0ecf4611e1423db91f34ab..a4e59a891b03cd0fb35e184795117e05a644f80d 100644 (file)
@@ -3,7 +3,7 @@
 {% load i18n %}
 
 {% block extra_javascript %}
-<script src="{% url telemeta-js "popupdiv.js" %}" type="text/javascript"></script>
+<script src="{% url telemeta-js "popupdiv-min.js" %}" type="text/javascript"></script>
 <script src="{% url telemeta-js "playlist.js" %}" type="text/javascript"></script>
 <script>
     jQuery(window).ready(function(){
index a2fcc37f1bdd721e306b721ea47b1c51e7ad21a4..822f7e26174d3425e95cab31c6c53736d3b058fa 100644 (file)
@@ -15,7 +15,7 @@
 
 <script src="{% url telemeta-timeside "js/libs/soundmanager2-nodebug-jsmin.js" %}" type="text/javascript"></script>
 <script src="{% url telemeta-timeside "js/timeside.js" %}" type="text/javascript"></script>
-<script src="{% url telemeta-js "popupdiv.js" %}" type="text/javascript"></script>
+<script src="{% url telemeta-js "popupdiv-min.js" %}" type="text/javascript"></script>
 <script src="{% url telemeta-js "playlist.js" %}" type="text/javascript"></script>
 <script src="{% url telemeta-js "playerLoader.js" %}" type="text/javascript"></script>
 <script src="{% url telemeta-js "divmarker.js" %}" type="text/javascript"></script>