<s> """<STR_LIT>""" <EOL> closingListeners = [ ] <EOL> resizeListeners = [ ] <EOL> from __pyjamas__ import JS , doc , wnd , get_main_frame <EOL> from pyjamas import Location <EOL> def init_listeners ( ) : <EOL> pass <EOL> def addWindowCloseListener ( listener ) : <EOL> closingListeners . append ( listener ) <EOL> def addWindowResizeListener ( listener ) : <EOL> resizeListeners . append ( listener ) <EOL> def removeWindowCloseListener ( listener ) : <EOL> closingListeners . remove ( listener ) <EOL> def removeWindowResizeListener ( listener ) : <EOL> resizeListeners . remove ( listener ) <EOL> def alert ( txt ) : <EOL> get_main_frame ( ) . _alert ( txt ) <EOL> def confirm ( msg ) : <EOL> return wnd ( ) . confirm ( msg ) <EOL> def prompt ( msg , defaultReply = "<STR_LIT>" ) : <EOL> return wnd ( ) . prompt ( msg , defaultReply , "<STR_LIT>" , <NUM_LIT:0> ) <EOL> def enableScrolling ( enable ) : <EOL> doc ( ) . body . style . overflow = enable and '<STR_LIT>' or '<STR_LIT>' <EOL> def scrollBy ( x , y ) : <EOL> wnd ( ) . scrollBy ( x , y ) <EOL> def scroll ( x , y ) : <EOL> wnd ( ) . scroll ( x , y ) <EOL> def getClientHeight ( ) : <EOL> try : <EOL> return wnd ( ) . innerHeight <EOL> except : <EOL> return doc ( ) . body . clientHeight ; <EOL> def getClientWidth ( ) : <EOL> try : <EOL> return wnd ( ) . innerWidth <EOL> except : <EOL> return doc ( ) . body . clientWidth ; <EOL> def getScrollLeft ( ) : <EOL> return getDocumentRoot ( ) . scrollLeft ; <EOL> def getScrollTop ( ) : <EOL> return getDocumentRoot ( ) . scrollTop ; <EOL> def getDocumentRoot ( ) : <EOL> if doc ( ) . compatMode == '<STR_LIT>' : <EOL> return doc ( ) . documentElement <EOL> return doc ( ) . body <EOL> def setLocation ( url ) : <EOL> w = wnd ( ) <EOL> w . location = url <EOL> location = None <EOL> def getLocation ( ) : <EOL> global location <EOL> if not location : <EOL> location = Location . Location ( wnd ( ) . location ) <EOL> return location <EOL> def getTitle ( ) : <EOL> return doc ( ) . title <EOL> def open ( url , name , features ) : <EOL> return wnd ( ) . open ( url , name , features ) <EOL> def setMargin ( size ) : <EOL> doc ( ) . body . style . margin = size <EOL> def setTitle ( title ) : <EOL> d = doc ( ) <EOL> d . title = title <EOL> def setOnError ( onError ) : <EOL> pass <EOL> def onError ( msg , url , linenumber ) : <EOL> pass <EOL> def onClosed ( ) : <EOL> fireClosedImpl ( ) <EOL> def onClosing ( ) : <EOL> fireClosingImpl ( ) <EOL> def onResize ( ) : <EOL> fireResizedImpl ( ) <EOL> def fireClosedAndCatch ( handler ) : <EOL> pass <EOL> def fireClosedImpl ( ) : <EOL> for listener in closingListeners : <EOL> listener . onWindowClosed ( ) <EOL> def fireClosingAndCatch ( handler ) : <EOL> pass <EOL> def resize ( width , height ) : <EOL> """<STR_LIT>""" <EOL> wnd ( ) . resizeTo ( width , height ) <EOL> def resizeBy ( width , height ) : <EOL> """<STR_LIT>""" <EOL> wnd ( ) . resizeBy ( width , height ) <EOL> def fireClosingImpl ( ) : <EOL> ret = None <EOL> for listener in closingListeners : <EOL> msg = listener . onWindowClosing ( ) <EOL> if ret is None : <EOL> ret = msg <EOL> return ret <EOL> def fireResizedAndCatch ( handler ) : <EOL> pass <EOL> def fireResizedImpl ( ) : <EOL> for listener in resizeListeners : <EOL> listener . onWindowResized ( getClientWidth ( ) , getClientHeight ( ) ) <EOL> def init ( ) : <EOL> pass <EOL> init ( ) </s>
