* }\r
* });\r
*/\r
-function PopupDiv(){\r
+function PopupDiv() {\r
var $J = jQuery;\r
var me = this;\r
- var data = arguments.length && arguments[0] || {};\r
-\r
+ var data = {};\r
+ if(arguments.length && arguments[0]){\r
+ data= arguments[0];\r
+ }\r
//var wdw = $J(window);\r
var div = $J('<div/>');\r
//we use an input rather than a span for two reasons:\r
}));\r
//header.find('*').add(footer.find('*')).css('display','none');\r
div.append(header).append(container).append(footer);\r
+\r
//defining immediately the method getDiv (because it is used below)\r
this.getDiv = function(){\r
return div;\r
- }\r
+ };\r
//setting functions:\r
\r
var listeners = {};\r
this.getListeners = function(){\r
return listeners;\r
- }\r
+ };\r
\r
\r
//setting static properties, if any.\r
//but it assures cross browser compatibility\r
\r
var k;\r
- var staticProps = undefined;\r
+ var staticProps;\r
for(k in PopupDiv){\r
var f = PopupDiv[k];\r
- if(typeof f !== 'function'){ //do not assign functions (PopupDiv.function... might be used in future as\r
+ if(PopupDiv.hasOwnProperty(k) && (typeof f !== 'function')){ //do not assign functions (PopupDiv.function... might be used in future as\r
//static functions accessible from outside\r
if(!staticProps){\r
staticProps = {};\r
var remove = true;\r
var proto = undefined;\r
if ( typeof Object.getPrototypeOf !== "function" ) {\r
- if ( typeof this.__proto__ === "object" ) {\r
+ if (typeof this.__proto__ === "object" ) {\r
proto = this.__proto__;\r
} else {\r
// May break if the constructor has been tampered with:\r
proto = Object.getPrototypeOf(this);\r
}\r
for(k in staticProps){\r
- proto[k] = staticProps[k];\r
- if(remove){\r
- delete PopupDiv[k];\r
+ if(staticProps.hasOwnProperty(k)){\r
+ proto[k] = staticProps[k];\r
+ if(remove){\r
+ delete PopupDiv[k];\r
+ }\r
}\r
}\r
}\r
\r
//setting instance-specific properties:\r
for(k in data){\r
- if(k == 'onOk' || k == 'onShow' || k == 'onClose'){\r
- this.bind(k.substring(2).toLowerCase(),data[k]);\r
- }else if(k == 'content'){\r
- this.setContent(data[k]);\r
- }else {\r
- this[k] = data[k];\r
+ if(data.hasOwnProperty(k)){\r
+ if(k === 'onOk' || k === 'onShow' || k === 'onClose'){\r
+ this.bind(k.substring(2).toLowerCase(),data[k]);\r
+ }else if(k == 'content'){\r
+ this.setContent(data[k]);\r
+ }else {\r
+ this[k] = data[k];\r
+ }\r
}\r
}\r
\r
p.closeButtonTitle = 'x';\r
p.defaultCloseOperation = 'hide';\r
p.focusable = false;\r
- p.fadInTime = 'fast',\r
- p.fadeOutTime = 0,\r
+ p.fadInTime = 'fast';\r
+ p.fadeOutTime = 0;\r
p.shadowOpacity = 0.25;\r
p.zIndex = 10000;\r
p.listItemClass = '';\r
\r
p.setTitle = function(title){\r
this.getDiv().children().eq(0).find(':title').eq(0).val(title);\r
- }\r
+ };\r
\r
//methods:\r
p.find = function(argumentAsInJQueryFind){\r
\r
p.bind = function(eventName, callback){ //eventname: show, close or ok\r
var listeners = this.getListeners();\r
- if(eventName in listeners){\r
+ if(listeners.hasOwnProperty(eventName)){\r
listeners[eventName].push(callback);\r
}else{\r
listeners[eventName] = [callback];\r
\r
p.unbind = function(eventName){\r
var listeners = this.getListeners();\r
- if(eventName && eventName in listeners){\r
+ if(eventName && listeners.hasOwnProperty(eventName)){\r
delete listeners[eventName];\r
}else if(!eventName){\r
for(var k in listeners){\r
- delete listeners[k];\r
+ if(listeners.hasOwnProperty(k)){\r
+ delete listeners[k];\r
+ }\r
}\r
}\r
};\r
p.trigger = function(eventName){\r
var listeners = this.getListeners();\r
var me = this;\r
- if(eventName in listeners){\r
+ if(listeners.hasOwnProperty(eventName)){\r
var callbacks = listeners[eventName];\r
var i = 0;\r
if(eventName == 'ok'){\r
var listItems = $([]);\r
for(var h=0; h<content.length; h++){\r
var item = content[h];\r
- var a = $('<a/>').attr('href','#').html(""+item);\r
+ var a = $('<a/>').attr('href','#').html(""+item).css('whiteSpace','nowrap');\r
listItems = listItems.add(a);\r
setEvents(h,a,input);\r
container.append(a);\r
leftElements = leftElements.add(e1);\r
container.append(lineDiv.append(e1).append(e2));\r
return lineDiv;\r
- }\r
+ };\r
var title, component;\r
\r
var max = Math.max; //instantiate once\r
var lineDiv = undefined;\r
var lineDivs = $([]);\r
for(var k in content){\r
- var val = content[k];\r
- if(typeof val == 'string' || typeof val == 'number'){\r
- title = $('<span/>').html(k);\r
- maxw[0] = max(maxw[0],k.length);\r
- maxw[1] = max(maxw[1],val.length);\r
- component = $('<input/>').attr('type','text').val(val).attr(att,k);\r
- lineDivs = lineDivs.add(insert(title,component));\r
- }else if(val === true || val === false){\r
- var id = this.getId()+"_checkbox";\r
- title = $('<input/>').attr('type','checkbox').attr(att,k).attr('id',id);\r
- if(val){\r
- title.attr('checked','checked');\r
- }else{\r
- title.removeAttr('checked');\r
+ if(content.hasOwnProperty(k)){\r
+ var val = content[k];\r
+ if(typeof val == 'string' || typeof val == 'number'){\r
+ title = $('<span/>').html(k);\r
+ maxw[0] = max(maxw[0],k.length);\r
+ maxw[1] = max(maxw[1],val.length);\r
+ component = $('<input/>').attr('type','text').val(val).attr(att,k);\r
+ lineDivs = lineDivs.add(insert(title,component));\r
+ }else if(val === true || val === false){\r
+ var id = this.getId()+"_checkbox";\r
+ title = $('<input/>').attr('type','checkbox').attr(att,k).attr('id',id);\r
+ if(val){\r
+ title.attr('checked','checked');\r
+ }else{\r
+ title.removeAttr('checked');\r
+ }\r
+ component = $('<label/>').attr('for',id).html(k);\r
+ maxw[1] = max(maxw[1],k.length);\r
+ lineDivs = lineDivs.add(insert($('<span/>').append(title),component));\r
+ }else if(val instanceof Array){\r
+ title = $('<span/>').html(k);\r
+ maxw[0] = max(maxw[0],k.length);\r
+ component = $('<select/>').attr('size',1).attr(att,k);\r
+ for(var i=0; i< val.length; i++){\r
+ component.append($('<option/>').val(val[i]).html(val[i]));\r
+ maxw[1] = max(maxw[1],val[i].length);\r
+ }\r
+ lineDivs = lineDivs.add(insert(title,component));\r
}\r
- component = $('<label/>').attr('for',id).html(k);\r
- maxw[1] = max(maxw[1],k.length);\r
- lineDivs = lineDivs.add(insert($('<span/>').append(title),component));\r
- }else if(val instanceof Array){\r
- title = $('<span/>').html(k);\r
- maxw[0] = max(maxw[0],k.length);\r
- component = $('<select/>').attr('size',1).attr(att,k);\r
- for(var i=0; i< val.length; i++){\r
- component.append($('<option/>').val(val[i]).html(val[i]));\r
- maxw[1] = max(maxw[1],val[i].length);\r
+ if(lineDiv){\r
+ lineDiv.css('marginBottom','1ex');\r
}\r
- lineDivs = lineDivs.add(insert(title,component));\r
- }\r
- if(lineDiv){\r
- lineDiv.css('marginBottom','1ex');\r
}\r
}\r
lineDivs.css({\r
var bottomDiv = $(children_[2]);\r
var elementsWithFocus = centralDiv.find('input[type!=hidden],select,textarea,a'); //input:not(:hidden),select,textarea,a,\r
\r
- var ret = elementsWithFocus.length ? $(elementsWithFocus[0]) : popup;\r
+ //set the element with focus by default if there is no focusable element inside the popup\r
+ var ret = elementsWithFocus.length ? $(elementsWithFocus[0]) : centralDiv;\r
+\r
if(this.showClose){\r
elementsWithFocus =elementsWithFocus.add(topDiv.find('a'));\r
}\r
elementsWithFocus = elementsWithFocus.add(bottomDiv.find('a'));\r
}\r
}\r
- elementsWithFocus = elementsWithFocus.add(popup);\r
+ popup.add(centralDiv).css('outline','#FFF none 0px'); //DO NOT SHOW BORDER FOCUS FOR DIVS (NICER)\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
+ //centralDiv in IE and therefore the popup would hide\r
+\r
+ \r
var focusNameSpace = "blur."+this.getId();\r
if(!value){\r
elementsWithFocus.each(function(i,elm){\r
});\r
this.getFirstFocusableElement = function(){\r
return undefined;\r
- }\r
+ };\r
if(invokerIsClickable){\r
this.invoker.removeAttr('tabindex').removeAttr(focusAttr);\r
}\r
//otherwise execute callback\r
setTimeout(function(){\r
var v = doc_.activeElement;\r
+ consolelog(v.tagName+' ' +$(v).attr(focusAttr));\r
//console.log(v);\r
if((v && $(v).attr(focusAttr)) || me.__isClosing){\r
//if we are closing, we will call back this method which removes the focus attributes, bt meanwhile the\r
this.setBoundsInside(invoker, this.bounds, this.boundsExact);\r
}\r
\r
- this.shadow(); //updates shadow\r
+ //this.shadow(); //updates shadow\r
if(focusable){\r
this.getFirstFocusableElement().focus();\r
}\r
- }\r
+ };\r
\r
p.setTitle= function(title){\r
var subdiv = this.getDiv().children().eq(0);\r
} else if (node.nodeValue) {\r
node.nodeValue = title;\r
}\r
-// consolelog('"'+ title+'"');\r
-// consolelog(text);\r
-// consolelog(node);\r
- }\r
+ // consolelog('"'+ title+'"');\r
+ // consolelog(text);\r
+ // consolelog(node);\r
+ };\r
\r
p.isShowing = function(){\r
return this.getDiv().is(':visible');\r
\r
if(this.showClose || this.title){\r
topDiv.css({\r
- 'paddingBottom':'0.25em'\r
+ 'paddingBottom':'0.25em',\r
+ 'whiteSpace':'nowrap'\r
}); //add padding to bottom\r
//warning: do NOT use real numbers such as 0.5ex cause browsers round it in a different manner\r
//whiteSpace is FUNDAMENTAL in calculating the popup div in case the title is the longest (max width) element\r
}\r
\r
var invoker = this.invoker;\r
-\r
- if(this.isClickElement(invoker)){\r
+ var isClickElement = this.isClickElement(invoker);\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
var clickEvents =invoker.data("events")[type];\r
$.each(clickEvents, function(key, value) {\r
oldHandlers.push(value);\r
- })\r
+ });\r
invoker.unbind(type); //remove (temporarily) the binding to the event.\r
//for instance, if we show the popup by clicking invoker, when the popup is shown do nothing\r
//on clicking invoker until popup.hide is called\r
\r
\r
var shadow = this.shadow();\r
+ var place = isClickElement ? this.placeAsPopup : this.placeInside;\r
var postShowFcn = function(){\r
+ //adding window resize interval to track window changes\r
+ var w = wdw.width();\r
+ var h = wdw.height();\r
+ me._resizeTimeInterval = setInterval(function(){\r
+ var w2 = wdw.width();\r
+ var h2 = wdw.height();\r
+ if(w2!==w || h2 !==h){\r
+ setTimeout(function(){\r
+ if(!me.isShowing() || me.__isClosing){\r
+ return;\r
+ }\r
+ if(wdw.width()===w2 && wdw.height()===h2){\r
+ place.apply(me);\r
+ }\r
+ },100);\r
+ }\r
+ },200);\r
+\r
+\r
me.trigger('show');\r
shadow.fadeTo(me.fadInTime,me.shadowOpacity, function(){\r
var v = me.getFirstFocusableElement();\r
v.focus();\r
}\r
});\r
- }\r
+ };\r
\r
div.show(this.fadInTime,function(){\r
postShowFcn();\r
});\r
}\r
return shadow;\r
- }\r
+ };\r
\r
p.setBoundsAsPopup = function(popupInvoker){\r
var invoker = popupInvoker;\r
var spaceLeft = invokerOffset.left + invokerOuterWidth - windowRectangle.x;\r
var placeLeft = spaceLeft > spaceRight && div.outerWidth(false) + shadowOffset > spaceRight;\r
\r
+ \r
this.setMaxSize({\r
height : (placeAbove ? spaceAbove : spaceBelow),\r
width: (placeLeft ? spaceLeft : spaceRight)\r
//however, we want CH to change even if a new maxHeight greater than CH is set\r
});\r
\r
- //setting the top and left. This must be done at last because popupDiv.outerHeight(true)\r
- //must have been computed according to the height set above...\r
- this.offset({\r
- 'left': placeLeft ? invokerOffset.left+ invokerOuterWidth - div.outerWidth(true)-shadowOffset : invokerOffset.left,\r
- 'top': (placeAbove ? invokerOffset.top - div.outerHeight(true) :\r
- invokerOffset.top + invokerOuterHeight)\r
- });\r
-\r
+ \r
this.postSizeFcn();\r
\r
};\r
this.preSizeFcn();\r
\r
var bounds = this.getBoundsOf(parent);\r
- \r
+ \r
\r
var x=bounds.x;\r
var y = bounds.y;\r
- var w = bounds.width\r
+ var w = bounds.width;\r
var h = bounds.height;\r
+\r
+ \r
var pInt = parseInt;\r
//rebuilding:\r
\r
};\r
\r
for(var k in padding){\r
- if(padding[k]<=0){\r
- padding[k]=0;\r
- }else if(padding[k]<=1){\r
- padding[k] = k=='top' || k =='bottom' ? h*padding[k] : w*padding[k];\r
- }else{\r
- padding[k] = pInt(padding[k]);\r
+ if(padding.hasOwnProperty(k)){\r
+ if(padding[k]<=0){\r
+ padding[k]=0;\r
+ }else if(padding[k]<=1){\r
+ padding[k] = k=='top' || k =='bottom' ? h*padding[k] : w*padding[k];\r
+ }else{\r
+ padding[k] = pInt(padding[k]);\r
+ }\r
}\r
}\r
\r
'width':w-padding['left']-padding['right']+this.shadowOffset,\r
'height':h-padding['top']-padding['bottom']+this.shadowOffset\r
};\r
-\r
- var vvvv ={\r
- width:maxSize.width,\r
- height:maxSize.height\r
- };\r
- this._convertSize(div, vvvv);\r
-\r
- if(boundsExact){\r
- this.setMinSize({\r
- width:maxSize.width,\r
- height:maxSize.height\r
- }); //a copy cause the argument will be modified\r
+ \r
this.setMaxSize({\r
width:maxSize.width,\r
height:maxSize.height\r
}); //a copy cause the argument will be modified\r
\r
- this.offset({\r
- 'left':x + padding['left'],\r
- 'top': y + padding['top']\r
- });\r
- }else{\r
- this.setMaxSize({\r
+ if(boundsExact){\r
+ this.setMinSize({\r
width:maxSize.width,\r
height:maxSize.height\r
}); //a copy cause the argument will be modified\r
- var spanLeft = maxSize.width - div.outerWidth(true);\r
- var spanTop = maxSize.height - div.outerHeight(true);\r
- this.offset({\r
- 'left':x + padding['left'] + (spanLeft > 0 ? spanLeft/2 : 0),\r
- 'top': y + padding['top'] +(spanTop > 0 ? spanTop/2 : 0)\r
- });\r
\r
}\r
\r
};\r
p.preSizeFcn = function(){\r
var div = this.getDiv();\r
- var subdivs = div.children().hide();\r
+ var subdivs = div.children();\r
+ subdivs.css('display','none');\r
var subdivsshow = subdivs.eq(1);\r
if(this.showClose || this.title){\r
subdivsshow = subdivsshow.add(subdivs.eq(0));\r
if(this.showOk){\r
subdivsshow = subdivsshow.add(subdivs.eq(2));\r
}\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
+\r
+ subdivsshow = subdivsshow.add(div);\r
+ subdivsshow.css({\r
'display':'block',\r
- 'overflow':'visible',\r
- 'float':'none'\r
+ 'float':'',\r
+ 'overflow' : 'visible'\r
});\r
\r
+\r
+ //reset properties:\r
+ subdivsshow.css({\r
+ 'maxHeight':'',\r
+ 'maxWidth':'',\r
+ 'minHeight':'',\r
+ 'minWidth':'',\r
+ 'height':'',\r
+ 'width':'',\r
+ 'overflow':'',\r
+ '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
'position':'absolute'\r
});\r
- }\r
+\r
+\r
+ //place the div in the upperleft corner of the window\r
+ var bounds = this.getBoundsOf(); //returns the window rectangle\r
+ div.css({\r
+ 'left':bounds.x+'px',\r
+ '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
+ // consolelog('presize');\r
+ // consolelog('width: '+ topDiv.width()+' css-minWidth: ' +topDiv.css('minWidth')+' css-width: ' +topDiv.css('width')+' css-maxWidth: ' +topDiv.css('maxWidth'));\r
+ // consolelog('width: '+centralDiv.width()+' css-minWidth: ' +centralDiv.css('minWidth')+' css-width: ' +centralDiv.css('width')+' css-maxWidth: ' +centralDiv.css('maxWidth'));\r
+ // consolelog('width: '+bottomDiv.width()+' css-minWidth: ' +bottomDiv.css('minWidth')+' css-width: ' +bottomDiv.css('width')+' css-maxWidth: ' +bottomDiv.css('maxWidth'));\r
+ // consolelog(' ' );\r
+ };\r
\r
p.postSizeFcn = function(){\r
//set title and close button to span whole width, if necessary\r
var topDiv = subdivs.eq(0);\r
\r
var centralDiv = subdivs.eq(1);\r
- centralDiv.css('overflow','auto');\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
//same for width:\r
var maxWidth = div.width();\r
var width = centralDiv.outerWidth(true);\r
-\r
+ \r
if(maxHeight<=0 || maxWidth<=0){\r
- centralDiv.hide();\r
+ //centralDiv.hide();\r
return;\r
}\r
\r
- if(maxHeight<height){\r
- centralDiv.css('maxHeight',maxHeight+'px');\r
+ // if(maxHeight<height){\r
+ // centralDiv.css('maxHeight',maxHeight+'px');\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
+ centralDiv.css('height',maxHeight+'px');\r
+ //same for width\r
+ centralDiv.css('width',maxWidth+'px');\r
+\r
+ //TODO: check padding margins border or set them to zero in preSizeFcn!!!!!!\r
+\r
+\r
+ // centralDiv.css('width',maxWidth+'px');\r
+ // if(maxWidth<width){\r
+ // centralDiv.css('maxWidth',maxWidth+'px');\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
+ //consolelog('buggy: '+maxHeight);\r
+ //centralDiv.css('height',maxHeight);\r
+ //}\r
+\r
+ //last thing: the subelements width property seems to be handles in different ways across browsers:\r
+ //in preSizeFcn, we set a width to auto. Curiously, when resizing the parent div (this.getDiv()), subelements are assigned\r
+ //a specified width property\r
+ //IE does what it is expected (werird enogh...), ie sets a maxWidth and\r
+\r
+ // consolelog('postsize');\r
+ // consolelog('width: '+ topDiv.width()+' css-minWidth: ' +topDiv.css('minWidth')+' css-width: ' +topDiv.css('width')+' css-maxWidth: ' +topDiv.css('maxWidth'));\r
+ // consolelog('width: '+centralDiv.width()+' css-minWidth: ' +centralDiv.css('minWidth')+' css-width: ' +centralDiv.css('width')+' css-maxWidth: ' +centralDiv.css('maxWidth'));\r
+ // consolelog('width: '+bottomDiv.width()+' css-minWidth: ' +bottomDiv.css('minWidth')+' css-width: ' +bottomDiv.css('width')+' css-maxWidth: ' +bottomDiv.css('maxWidth'));\r
+ // consolelog(' ' );\r
+ if(this.isClickElement(this.invoker)){\r
+ this.placeAsPopup();\r
+ }else{\r
+ this.placeInside();\r
}\r
+\r
+ };\r
+\r
+ p.placeAsPopup = function(){\r
+ var div = this.getDiv();\r
+\r
+ var shadowOffset = this.shadowOffset;\r
+ var windowRectangle = this.getBoundsOf(wdw); //returns the window rectangle\r
+ var invoker = this.invoker;\r
+ var invokerOffset = invoker.offset();\r
+\r
+ var invokerOuterHeight = invoker.outerHeight();\r
+ var spaceAbove = invokerOffset.top - windowRectangle.y;\r
+ var spaceBelow = windowRectangle.height - invokerOuterHeight - spaceAbove;\r
+ var placeAbove = spaceAbove > spaceBelow && div.outerHeight(false) + shadowOffset > spaceBelow;\r
+\r
+ var invokerOuterWidth = invoker.outerWidth();\r
+ var spaceRight = windowRectangle.x + windowRectangle.width - invokerOffset.left ;\r
+ var spaceLeft = invokerOffset.left + invokerOuterWidth - windowRectangle.x;\r
+ var placeLeft = spaceLeft > spaceRight && div.outerWidth(false) + shadowOffset > spaceRight;\r
+\r
+\r
+\r
+ //setting the top and left. This must be done at last because popupDiv.outerHeight(true)\r
+ //must have been computed according to the height set above...\r
+ var offs = {\r
+ 'left': placeLeft ? invokerOffset.left+ invokerOuterWidth - div.outerWidth(true)-shadowOffset : invokerOffset.left,\r
+ 'top': (placeAbove ? invokerOffset.top - div.outerHeight(true) :\r
+ invokerOffset.top + invokerOuterHeight)\r
+ };\r
+ div.css({\r
+ 'top':offs.top+'px',\r
+ 'left':offs.left+'px'\r
+ });\r
+ this.shadow(); //replace the shadow\r
+ };\r
+\r
+ p.placeInside = function(){\r
+ \r
+ var div = this.getDiv();\r
+\r
\r
- if(maxWidth<width){\r
- centralDiv.css('maxWidth',maxWidth+'px');\r
+ var parent = this.invoker;\r
+ var bounds = this.getBoundsOf(parent);\r
+ var pd = this.bounds;\r
+\r
+ var x=bounds.x;\r
+ var y = bounds.y;\r
+ var w = bounds.width;\r
+ var h = bounds.height;\r
+\r
+\r
+ var pInt = parseInt;\r
+ //rebuilding:\r
+\r
+ var padding = {\r
+ top: pd['top'],\r
+ left:pd['left'],\r
+ bottom:pd['bottom'],\r
+ right:pd['right']\r
+ };\r
+\r
+ for(var k in padding){\r
+ if(padding.hasOwnProperty(k)){\r
+ if(padding[k]<=0){\r
+ padding[k]=0;\r
+ }else if(padding[k]<=1){\r
+ padding[k] = k=='top' || k =='bottom' ? h*padding[k] : w*padding[k];\r
+ }else{\r
+ padding[k] = pInt(padding[k]);\r
+ }\r
+ }\r
+ }\r
+\r
+ var maxSize = {\r
+ 'width':w-padding['left']-padding['right']+this.shadowOffset,\r
+ 'height':h-padding['top']-padding['bottom']+this.shadowOffset\r
+ };\r
+ //we add shadowOffset cause in convertSize below we will substract the shadow. However, in this case the shadow is NOT\r
+ //counted in the size\r
+\r
+ var ww = div.outerWidth(true);\r
+ var hh = div.outerHeight(true);\r
+\r
+ var spanLeft = 0;\r
+ var spanTop = 0;\r
+ if(ww<maxSize.width){\r
+ spanLeft = (maxSize.width-ww)/2;\r
+ }\r
+ if(hh < maxSize.height){\r
+ spanTop = (maxSize.height-hh)/2;\r
}\r
\r
+ div.css({\r
+ 'left':(x+padding['left']+spanLeft)+'px',\r
+ 'top':(y+padding['top']+spanTop)+'px'\r
+ });\r
+\r
+ this.shadow(); //replace the shadow\r
};\r
\r
p.getBounds = function(){\r
var div = this.getDiv();\r
\r
this._convertSize(div, size);\r
- var css = {};\r
- if('width' in size){\r
+ var css;\r
+ if(size.hasOwnProperty('width')){\r
+ if(!css){\r
+ css = {};\r
+ }\r
css.maxWidth = size.width+'px';\r
}\r
- if('height' in size){\r
+ if(size.hasOwnProperty('height')){\r
+ if(!css){\r
+ css = {};\r
+ }\r
css.maxHeight = size.height+'px';\r
}\r
if(css){\r
var div = this.getDiv();\r
\r
this._convertSize(div, size);\r
- var css = {};\r
- if('width' in size){\r
+ var css;\r
+ if(size.hasOwnProperty('width')){\r
+ if(!css){\r
+ css = {};\r
+ }\r
css.minWidth = size.width+'px';\r
}\r
- if('height' in size){\r
+ if(size.hasOwnProperty('height')){\r
+ if(!css){\r
+ css = {};\r
+ }\r
css.minHeight = size.height+'px';\r
}\r
if(css){\r
'height':div.outerHeight(true)-div.height()\r
};\r
\r
- if('width' in size){\r
+ if(size.hasOwnProperty('width')){\r
size.width -= (eD.width + this.shadowOffset);\r
}\r
- if('height' in size){\r
+ if(size.hasOwnProperty('height')){\r
size.height -= (eD.height + this.shadowOffset);\r
}\r
};\r
\r
p.close = function(){\r
this.__isClosing = true;\r
+ if(this._resizeTimeInterval!==undefined){\r
+ clearInterval(this._resizeTimeInterval);\r
+ this._resizeTimeInterval = undefined;\r
+ }\r
this.setFocusCycleRoot(false);\r
var div = this.getDiv();\r
var shadow = $('#'+this.getShadowDivId());\r
p.setTimeout = function(eventName, millseconds){\r
var me = this;\r
var t=undefined;\r
- if(eventName == 'show'){\r
+ if(eventName === 'show'){\r
t=setTimeout(function(){\r
me.show();\r
},millseconds);\r
- }else if(eventName == 'close'){\r
+ }else if(eventName === 'close'){\r
t=setTimeout(function(){\r
me.close();\r
},millseconds);\r
}\r
return t;\r
- },\r
+ };\r
\r
p.getShadowDivId = function(){\r
return this.getId()+"_shadow";\r
- }\r
+ };\r
\r
p.getFocusAttr = function(){\r
return this.getId()+"_focus";\r
- }\r
+ };\r
\r
p.getFormDataAttrName = function(){\r
return this.getId()+"_data";\r
- }\r
+ };\r
\r
})(PopupDiv.prototype);
\ No newline at end of file