From VisualWorks®, 7.5 of April 16, 2007 on September 22, 2007 at 2:56:23 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>PGPropertyObject</name> <environment>Seaside</environment> <super>Core.Object</super> <private>false</private> none properties <imports></imports> <category>protoGrowl-Core</category> <attributes> <package>protoGrowl-Core</package> </attributes> </class> <class> <name>PGLibrary</name> <environment>Seaside</environment> <super>Seaside.WAFileLibrary</super> <private>false</private> none <imports></imports> <category>protoGrowl-Seaside</category> <attributes> <package>protoGrowl-Seaside</package> </attributes> </class> <class> <name>PGMessage</name> <environment>Seaside</environment> <super>Seaside.PGPropertyObject</super> <private>false</private> none <imports></imports> <category>protoGrowl-Core</category> <attributes> <package>protoGrowl-Core</package> </attributes> </class> <comment> Seaside.PGMessage
http://www.midgard-project.org/documentation/protogrowl/
</comment> <class> <name>PGErrorMessage</name> <environment>Seaside</environment> <super>Seaside.PGMessage</super> <private>false</private> none <imports></imports> <category>protoGrowl-Core</category> <attributes> <package>protoGrowl-Core</package> </attributes> </class> <class> <name>PGOkMessage</name> <environment>Seaside</environment> <super>Seaside.PGMessage</super> <private>false</private> none <imports></imports> <category>protoGrowl-Core</category> <attributes> <package>protoGrowl-Core</package> </attributes> </class> <class> <name>PGWarningMessage</name> <environment>Seaside</environment> <super>Seaside.PGMessage</super> <private>false</private> none <imports></imports> <category>protoGrowl-Core</category> <attributes> <package>protoGrowl-Core</package> </attributes> </class> <class> <name>PGInfoMessage</name> <environment>Seaside</environment> <super>Seaside.PGMessage</super> <private>false</private> none <imports></imports> <category>protoGrowl-Core</category> <attributes> <package>protoGrowl-Core</package> </attributes> </class> <class> <name>PGDemo</name> <environment>Seaside</environment> <super>Seaside.WAComponent</super> <private>false</private> none staticApp <imports></imports> <category>protoGrowl-Demo</category> <attributes> <package>protoGrowl-Demo</package> </attributes> </class> <class> <name>PGGrowlFactory</name> <environment>Seaside</environment> <super>Seaside.PGPropertyObject</super> <private>false</private> none canvas messageClass <imports></imports> <category>protoGrowl-Core</category> <attributes> <package>protoGrowl-Core</package> </attributes> </class> <methods> Seaside.PGPropertyObject <category>accessing</category>
beClosable self closable: true
beNotClosable self closable: false
closable: aBoolean "does he growl have the close button on it (default: true)" ^properties at: 'closable' put: aBoolean
height: anInteger "growl height (defaults to 80 (px))" properties at: 'height' put: anInteger
lifeTime: milliseconds "sets growls lifeTime in seconds (default to 3600 milliseconds)" ^properties at: 'lifeTime' put: milliseconds
maxHeight: anInteger "maximum height" properties at: 'maxHeight' put: anInteger
maxprotoGrowls: anInteger "this sets the maximum for how many growl can be displayed at once, if the count is exceeded it will hide the oldest automatically default: 3" ^properties at: 'maxprotoGrowls' put: anInteger.
maxWidth: anInteger "maximum width" properties at: 'maxWidth' put: anInteger
message: aString ^properties at: 'message' put: aString
minHeight: anInteger "minimum height (defaults to 80 (px))" properties at: 'minHeight' put: anInteger
minWidth: anInteger "minimum width (defaults to 350 (px))" properties at: 'minWidth' put: anInteger
paddingTop: aTopInteger right: aRightInteger bottom: aBottomInteger left: aLeftInteger "array of growl padding. Defaults to [10,0,0,0] (top,right,bottom,left)" properties at: 'padding' put: (Array with: aTopInteger with: aRightInteger with: aBottomInteger with: aLeftInteger)
title: aString ^properties at: 'title' put: aString
width: anInteger "growl width (defaults to 350 (px))" properties at: 'width' put: anInteger
</methods> <methods> Seaside.PGPropertyObject <category>initialize-release</category>
initialize properties := Dictionary new
</methods> <methods> Seaside.PGPropertyObject class <category>instance creation</category>
new ^self basicNew initialize
</methods> <methods> Seaside.PGLibrary <category>accessing</category>
selectorsToInclude ^#(#protoGrowlCss #protoGrowlJs)
</methods> <methods> Seaside.PGLibrary <category>styles</category>
protoGrowlCss ^ ' /* Growl windows */ div.midcom-service-uimessages-protogrowl { display: block; width: 350px; height: 80px; } div.midcom-service-uimessages-protogrowl-type-info { -moz-border-radius: 0.6em 0.6em 0.6em 0.6em; border-right: 3px solid #A19981; border-bottom: 3px solid #A19981; } div.midcom-service-uimessages-protogrowl-contenthelper-type-info { height: 74px; border: 1px solid #CCCCCC; -moz-border-radius: 0.5em 0.5em 0.5em 0.5em; padding: 2px 2px 2px 2px; background-color: #FFFFFF; } div.midcom-service-uimessages-protogrowl-type-ok { -moz-border-radius: 0.6em 0.6em 0.6em 0.6em; border-right: 3px solid #A19981; border-bottom: 3px solid #A19981; } div.growl-window-contenthelper-type-ok { height: 74px; border: 1px solid #CCCCCC; -moz-border-radius: 0.5em 0.5em 0.5em 0.5em; padding: 2px 2px 2px 2px; background-color: #F57900; } div.midcom-service-uimessages-protogrowl-type-warning { -moz-border-radius: 0.6em 0.6em 0.6em 0.6em; border-right: 3px solid #A19981; border-bottom: 3px solid #A19981; } div.growl-window-contenthelper-type-warning { height: 74px; border: 1px solid #CCCCCC; -moz-border-radius: 0.5em 0.5em 0.5em 0.5em; padding: 2px 2px 2px 2px; background-color: #F57900; } div.midcom-service-uimessages-protogrowl-type-error { -moz-border-radius: 0.6em 0.6em 0.6em 0.6em; border-right: 3px solid #A19981; border-bottom: 3px solid #A19981; } div.growl-window-contenthelper-type-error { height: 74px; border: 1px solid #CCCCCC; -moz-border-radius: 0.5em 0.5em 0.5em 0.5em; padding: 2px 2px 2px 2px; background-color: #F57900; } div.midcom-service-uimessages-protogrowl-closebutton { float: right; width: 12px; height: 12px; line-height: 12px; font-size: 10px; cursor: pointer; } div.midcom-service-uimessages-protogrowl-title { margin: 0; padding: 0; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: 800; } div.midcom-service-uimessages-protogrowl-content { text-align: left; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: normal; padding-left: 5px; padding-top: 5px; } /* Growl windows ends */ '
</methods> <methods> Seaside.PGLibrary <category>scripts</category>
protoGrowlJs ^ ' /* Class: protoGrowl Version: 1.0b (Work in progress) License: GNU LGPL Jerry Jalava, jerry.jalava@incognito.fi 2006 -------------------------- To create a growl: var growl = new protoGrowl({type: ''info'', title: ''title'', content: ''content''}); -------------------------- -------------------------- Hint: if you have html coded growls do this on body onLoad: new BodyReader( {} ); It reads the whole document and transforms every element with attribute id="midcom-service-uimessages-protogrowl" to growl windows (read more from BodyReader description) -------------------------- Updated documentation will reside in: http://www.midgard-project.org/documentation/protogrowl ** Warning ** This is still a big work in progress. */ var protoGrowl = Class.create(); protoGrowl.prototype = { /* Initializes protoGrowl Class. This is where we''ll set some defaults and parse all user input to creation process. Available parameters: id: growl id (this you don''t need to set, but can be overrided if wanted) type: growl type (notfication, warning, error, message) title: growls title (this gets populated to div with class $className+''-title'') content: growls content (Can be html or just plain text. $className+''-content'') width: growl width (defaults to 350 (px)) height: growl height (defaults to 80 (px)) minWidth: minimum width (defaults to 350 (px)) minHeight: minimum height (defaults to 80 (px)) maxWidth: maximum width maxHeight: maximum height - You can adjust the effect growls are revealed/hidden showEffect: not yet in use showEffectOptions: not yet in use hideEffect: not yet in use hideEffectOptions: not yet in use maxprotoGrowls: this sets the maximum for how many growl can be displayed at once, if the count is exceeded it will hide the oldest automatically lifeTime: sets growls lifeTime in seconds (default to 3600 seconds) closable: true/false (does he growl have the close button on it...) className: defaults to ''midcom-service-uimessages-protogrowl'' padding: array of growl padding. Defaults to [10,0,0,0] (top,right,bottom,left) */ initialize: function(parameters) { this.id = parameters.id || this.nextID(); this.type = parameters.type || ''info''; this.title = parameters.title; this.content = parameters.message; this.minWidth = parameters.minWidth || 350; this.minHeight = parameters.minHeight || 80; this.maxWidth = parameters.maxWidth; this.maxHeight = parameters.maxHeight; this.hasEffectLib = String.prototype.parseColor != null; this.showEffectOptions = parameters.showEffectOptions || (parameters.effectOptions || { duration:0.50 }); this.hideEffectOptions = parameters.hideEffectOptions || (parameters.effectOptions || { duration:0.80, afterFinish: function(){ this.destroy(); }.bind(this) } ); //afterFinish: .bind(this) this.showEffect = parameters.showEffect || (this.hasEffectLib ? Effect.Appear : Element.show); this.hideEffect = parameters.hideEffect || (this.hasEffectLib ? Effect.Fade : Element.hide); var maxprotoGrowls = parameters.maxprotoGrowls || 3; protoGrowls.setMaxprotoGrowls( maxprotoGrowls ); this.lifetime = parameters.lifeTime || 3600; this.closable = parameters.closable != null ? parameters.closable : true; this.destroyOnClose = true; var className = parameters.className != null ? parameters.className : "midcom-service-uimessages-protogrowl"; this.className = className; var parent = parameters.parent || document.getElementsByTagName("body")[0];//.item(0); if(parameters.element != null && parameters.element != undefined) { this.element = this.collectElement( parameters.element, parent ); } else { this.element = this.create( parent ); } for(var k in this.element) { // debug("k: "+k+" val:"+this.element[k]); } this.eventMouseUp = this.hide.bindAsEventListener(this); this.eventOnLoad = this.getWindowMeasurements.bindAsEventListener(this); var closeBtnClass = this.className + "-closebutton"; this.closeBtn = document.getElementsByClassName(closeBtnClass); //debug("this.closeBtn "+this.closeBtn); //debug("this.element "+this.element); Event.observe(this.closeBtn, "mouseup", this.eventMouseUp); Event.observe(window, "load", this.eventOnLoad); var offset = [0,0]; this.padding = parameters.padding || [10,0,0,0]; var width = parseFloat(parameters.width) || 350; var height = parseFloat(parameters.height) || 80; if (parameters.left != null) { this.setStyle({left: parseFloat(parameters.left) + offset[0] + ''px''}); this.useLeft = true; } if (parameters.right != null) { this.setStyle({right: parseFloat(parameters.right) + ''px''}); this.useLeft = false; } if (parameters.top != null) { this.setStyle({top: parseFloat(parameters.top) + ''px''}); this.useTop = true; } if (parameters.bottom != null) { this.setStyle({bottom: parseFloat(parameters.bottom) + ''px''}); this.useTop = false; } if (parameters.zIndex) { this.setZIndex(parameters.zIndex); } this.getWindowMeasurements(); this.setSize(width, height); //this.placeprotoGrowl(); if(this.content != null && this.content != undefined) { this.getContent().innerHTML = this.content; } protoGrowls.register(this); this.destroyed = false; if(parameters.dontShow == false || parameters.dontShow == undefined) { this.show(); } }, create: function( parent ) { var growl_div = document.createElement("div"); var growl_id = this.id; growl_div.setAttribute(''id'', growl_id); growl_div.className = this.className + '' '' + this.className + ''-type-'' + this.type; if(!this.title) { this.title = "&nbsp;"; } //debug("id: "+growl_id); growl_div.innerHTML = "\ <div class=''"+ this.className +"-contenthelper-type-"+this.type+"''>\ <div class=''"+ this.className +"-closebutton'' id=''"+ this.className +"-closebutton'' onclick=''protoGrowls.close(\""+ growl_id +"\");''>X</div>\ <div class=''"+ this.className +"-title'' id=''"+ this.className +"-title''>"+ this.title +"</div>\ <div class=''"+ this.className +"-content'' id=''"+ this.className +"-content-" + this.id +"''> </div>\ </div>\ "; Element.hide(growl_div); parent.insertBefore(growl_div, parent.firstChild); if(!this.closable) { Element.hide(this.className + "-closebutton"); } //debug(growl_div.innerHTML); return growl_div; }, collectElement: function( elmId, def_parent ) { var growl_div = document.getElementById(elmId); var growl_id = this.id; //debug(''collect elmid: ''+elmId); //debug(''collect id: ''+growl_id); if(!growl_div) { //debug( ''element not found!'' ); this.create( def_parent ); } //var growl_div_content = document.getElementById(elmId+''-content''); //growl_div_content.setAttribute(''id'', elmId+''-content-''+growl_id); growl_div.setAttribute(''id'', growl_id); var growl_div_real = document.getElementById(growl_id); //debug(''collect afterid: ''+growl_div_real.id); //if(this.title != '''') { //this.setTitle(this.title); //} Element.hide(growl_div_real); return growl_div_real; }, placeprotoGrowl: function() { var element = this.element; if(element == undefined || isNull(element)) { return false; } var windowScroll = WindowUtilities.getWindowScroll(); var pageSize = WindowUtilities.getPageSize(); var X = 0; var Y = 0; var middle = getViewportSize()[0]/2 + getScrollXY()[0] - this.width/2; //var growlCnt = activeprotoGrowlList.length-1; Y = ((getViewportSize()[1] + getScrollXY()[1]) - this.padding[0] - this.height); // - (growlCnt*gH) - (growlCnt*gPadding); X = windowScroll.left + (pageSize.windowWidth - (this.width + this.widthW + this.widthE))/2;//middle; //debug(''x:''+X+'' y:''+Y); this.setStyle({position: ''absolute''}); this.setLocation( Y, X ); }, moveUp: function() { //debug(''move up: ''+this.id); var Y = 0; Y = this.top - this.height - this.padding[0]; this.setLocation( Y ); }, setLocation: function(top, left, bottom, right) { if(top == null || top == undefined) { var top = ''''; } if(left == null || left == undefined) { var left = ''''; } if(right == null || right == undefined) { var right = ''''; } if(bottom == null || bottom == undefined) { var bottom = ''''; } if(top != '''') { this.top = top; this.setStyle({top: top + ''px''}); this.useTop = true; this.useBottom = false; } else if(bottom != '''') { this.bottom = bottom; this.setStyle({bottom: bottom + ''px''}); this.useTop = false; this.useBottom = true; } if(left != '''') { this.left = left; this.setStyle({left: left + ''px''}); this.useLeft = true; this.useRight = false; } else if(right != '''') { this.right = right; this.setStyle({right: right + ''px''}); this.useLeft = false; this.useRight = true; } }, setSize: function(width, height) { if(width < this.minWidth) { width = this.minWidth; } if(height < this.minHeight) { height = this.minHeight; } if(this.maxHeight && height > this.maxHeight) { height = this.maxHeight; } if(this.maxWidth && width > this.maxWidth) { width = this.maxWidth; } this.width = width; this.height = height; this.setStyle({width: width + this.widthW + this.widthE + "px"}); this.setStyle({height: height + this.heightN + this.heightS + "px"}); }, show: function() { //debug(''show: ''+this.id); //debug(''show x:''+this.element.style.left+'' y:''+this.element.style.top); this.placeprotoGrowl(); this.setSize(this.width, this.height); if(this.showEffect != Element.show && this.showEffectOptions ) { //debug(''this.showEffect: ''+this.showEffect); this.showEffect(this.element, this.showEffectOptions); } else { //debug(''this.showEffect (no options): ''+this.showEffect); this.showEffect(this.element); } }, hide: function( id ) { //debug(''hide: ''+this.id); if(this.hideEffectOptions) { this.hideEffect(this.element, this.hideEffectOptions); } else { this.hideEffect(this.element); } //if(this.iefix) // this.iefix.hide(); }, center: function() { var windowScroll = WindowUtilities.getWindowScroll(); var pageSize = WindowUtilities.getPageSize(); this.setLocation(windowScroll.top + (pageSize.windowHeight - (this.height + this.heightN + this.heightS))/2, windowScroll.left + (pageSize.windowWidth - (this.width + this.widthW + this.widthE))/2); }, destroy: function( id ) { if(this.destroyed) { return false; } protoGrowls.notify("onDestroy", this); Event.stopObserving(this.closeBtn, "mouseup", this.eventMouseUp); Event.stopObserving(window, "load", this.eventOnLoad); if(this.iefix) { Element.hide(this.iefix); } var objBody = document.getElementsByTagName("body").item(0); objBody.removeChild(this.element); this.destroyed = true; protoGrowls.unregister(this); }, setDelegate: function(delegate) { this.delegate = delegate; }, getDelegate: function() { return this.delegate; }, getContent: function () { //alert(document.getElementById(this.id).innerHTML); //var elid = this.className + "-content-" + this.id; //alert(elid); //alert(document.getElementById(elid)); //alert(document.getElementsByClassName(this.className + "-content-" + this.id)); return document.getElementById(this.className + "-content-" + this.id); }, setContent: function(id, autoposition) { var d = null; var p = null; if(autoposition) { p = Position.cumulativeOffset($(id)); } var content = this.getContent() content.appendChild($(id)); if(autoposition) { this.setLocation(p[1] - this.heightN, p[0] - this.widthW); } }, setStyle: function(style) { for (name in style) { this.element.style[name.camelize()] = style[name]; } }, getId: function() { return this.element.id; }, closeObject: function() { if(this.closeBtn) { return; } }, getWindowMeasurements: function(event) { var div = this.createHiddenDiv(this.className + "_n") this.heightN = Element.getDimensions(div).height; div.parentNode.removeChild(div) var div = this.createHiddenDiv(this.className + "_s") this.heightS = Element.getDimensions(div).height; div.parentNode.removeChild(div) var div = this.createHiddenDiv(this.className + "_e") this.widthE = Element.getDimensions(div).width; div.parentNode.removeChild(div) var div = this.createHiddenDiv(this.className + "_w") this.widthW = Element.getDimensions(div).width; div.parentNode.removeChild(div); }, createHiddenDiv: function(className) { var objBody = document.getElementsByTagName("body").item(0); var growl_hidden_div = document.createElement("div"); growl_hidden_div.setAttribute(''id'', this.id + "-tmp"); growl_hidden_div.className = className; growl_hidden_div.style.display = ''none''; growl_hidden_div.innerHTML = ''''; objBody.insertBefore(growl_hidden_div, objBody.firstChild) return growl_hidden_div; }, nextID: function() { return protoGrowls.getNextId(); }, setZIndex: function(zindex) { this.setStyle({zIndex: zindex}); protoGrowls.updateZindex(zindex, this); }, setTitle: function(newTitle) { if(!newTitle) { newTitle = "&nbsp;"; Element.update(this.className + ''-title'', newTitle); } } }; var protoGrowls = { growls: [], observers: [], focusedWindow: null, maxZIndex: 0, maxprotoGrowls: 3, listenFrequency: 0.8, nextid: 1, addObserver: function(observer) { this.observers.push(observer); }, removeObserver: function(observer) { this.observers = this.observers.reject( function(o) { return o==observer }); }, notify: function(eventName, growl) { this.observers.each( function(o) {if(o[eventName]) o[eventName](eventName, growl);}); }, growlExists: function(id) { return this.growls.detect(function(d) { return d.getId() ==id }); }, getprotoGrowl: function(id) { return this.growls.detect(function(d) { if(d.getId()==id){return d;} }); }, setMaxprotoGrowls: function( max ) { this.maxprotoGrowls = max; }, getNextId: function() { return this.nextid; }, register: function(growl) { var growlCnt = this.growls.length; this.nextid = growl.id+1; if(growlCnt < this.maxprotoGrowls) { this.moveUp(); growl.registered = new Date().getTime(); this.growls.push(growl); } else { this.removeFirst(); this.moveUp(); growl.registered = new Date().getTime(); this.growls.push(growl); } }, removeFirst: function() { var oldest = this.growls[0]; //debug(''oldest id: ''+oldest.id); this.close(oldest.id); }, unregister: function(growl) { this.growls = this.growls.reject(function(d) { return d==growl }); }, close: function(id) { growl = this.growlExists(id); if (growl) { if(growl.getDelegate() && ! growl.getDelegate().canClose(growl)) { return; } this.notify("onClose", growl); growl.hide(); } }, isExpired: function( id ) { var growl = this.getprotoGrowl(id); var timestamp = new Date().getTime(); var expires = growl.registered + growl.lifetime; if(expires <= timestamp) { return true; } return false; }, moveUp: function() { this.growls.each( function(g) {g.moveUp()} ); }, closeAll: function() { this.growls.each( function(g) {protoGrowls.close(g.getId())} ); }, updateZindex: function(zindex, growl) { if(zindex > this.maxZIndex) { this.maxZIndex = zindex; } this.focusedWindow = growl; } }; var BodyReader = Class.create(); BodyReader.prototype = { initialize: function( params ) { this.deftype = ''class''; this.start = params.body || ''body''; this.autotransform = params.autotransf || true; this.name = params.name || ''midcom-service-uimessages-protogrowl''; this.growl_type = params.type || ''info''; if(!params.type) { this.collect( this.name, this.deftype ); } }, collect: function( p_var, p_type ) { var element = ''''; var elements = ''''; if(p_type == ''id'') { element = document.getElementById(p_var); var growl_type = this.growl_type || ''info''; if(this.autotransform && element) { this.transform( p_var, growl_type ); } } if(p_type == ''class'') { elements = document.getElementsByClassName(p_var); if(elements.length>0) { for(var i=0;i<elements.length;i++) { var growl_type = this.growl_type || ''info''; if(this.autotransform && elements[i]) { var tempid = ''midcom-service-uimessages-protogrowl_tmp_obj_''+i; elements[i].setAttribute(''id'', tempid); this.transform( tempid, growl_type ); } } } } }, transform: function( p_name, p_type, p_readtype ) { new protoGrowl({type: p_type, element: p_name}); } }; //var BodyReader = new BodyReader( {} ); var LifeWatcher = Class.create(); LifeWatcher.prototype = { initialize: function() { this.defaultLifetime = 8; //this.execute(); }, execute: function() { var growlCnt = protoGrowls.growls.length; //debug(''lw execute: ''+new Date().getTime()); if(growlCnt>=1) { protoGrowls.growls.each( function(g) { var gID = g.getId(); if(protoGrowls.isExpired(gID)) { protoGrowls.close(gID); } } ); } } }; var LifeGuard = new LifeWatcher(); new PeriodicalExecuter(LifeGuard.execute,protoGrowls.listenFrequency); var isIE = navigator.appVersion.match(/MSIE/) == "MSIE"; var WindowUtilities = { getWindowScroll: function() { var w = window; var T, L, W, H; with (w.document) { if (w.document.documentElement && documentElement.scrollTop) { T = documentElement.scrollTop; L = documentElement.scrollLeft; } else if (w.document.body) { T = body.scrollTop; L = body.scrollLeft; } if (w.innerWidth) { W = w.innerWidth; H = w.innerHeight; } else if (w.document.documentElement && documentElement.clientWidth) { W = documentElement.clientWidth; H = documentElement.clientHeight; } else { W = body.offsetWidth; H = body.offsetHeight } } return { top: T, left: L, width: W, height: H }; }, getPageSize: function(){ var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { windowWidth = self.innerWidth; windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } var pageHeight, pageWidth; if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } if(xScroll < windowWidth){ pageWidth = windowWidth; } else { pageWidth = xScroll; } return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight}; } }; /* Midgard common */ function isNull(a) { return typeof a == ''object'' && !a; } function getScrollXY() { var scrOfX = 0, scrOfY = 0; if(typeof(window.pageYOffset) == ''number'') { //Netscape compliant scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { //DOM compliant scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { //IE6 standards compliant mode scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } return [scrOfX, scrOfY]; } function getViewportSize() { var myWidth = 0, myHeight = 0; if (typeof(window.innerWidth ) == ''number'') { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { //IE 6+ in ''standards compliant mode'' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } return [myWidth, myHeight]; } '
</methods> <methods> Seaside.PGMessage <category>accessing</category>
message ^properties at: 'message'
title ^properties at: 'title'
type ^properties at: 'type'
type: aString ^properties at: 'type' put: aString
</methods> <methods> Seaside.PGMessage <category>initialize-release</category>
initialize super initialize. self type: self defaultType. self title: ''. self message: ''
initializeWithProperties: aDictionary aDictionary keysAndValuesDo: [ :key :value | properties at: key put: value ]
</methods> <methods> Seaside.PGMessage <category>converting</category>
displayString ^self asJavascript
javascriptOn: aStream aStream nextPutAll: 'new protoGrowl('. properties javascriptOn: aStream. aStream nextPutAll: ');'
</methods> <methods> Seaside.PGMessage <category>private</category>
defaultType self subclassResponsibility
</methods> <methods> Seaside.PGMessage class <category>instance creation</category>
fromProperties: aDictionary ^self new initializeWithProperties: aDictionary; yourself
title: aTitleString message: aMessageString ^self new title: aTitleString; message: aMessageString; yourself
</methods> <methods> Seaside.PGErrorMessage <category>private</category>
defaultType ^'error'
</methods> <methods> Seaside.PGOkMessage <category>private</category>
defaultType ^'ok'
</methods> <methods> Seaside.PGWarningMessage <category>private</category>
defaultType ^'warning'
</methods> <methods> Seaside.PGInfoMessage <category>private</category>
defaultType ^'info'
</methods> <methods> Seaside.PGDemo <category>initialization</category>
initialize super initialize. staticApp := self sampleApp
</methods> <methods> Seaside.PGDemo <category>actions</category>
counterApp ^(WACounter new) addDecoration: (WAWindowDecoration new title: 'Counter'); yourself
periodicalCallback: html html script: (html growl beInfo title: 'Information'; renderMessage: [ :r | r text: 'This is a periodical message.'. r break. r text: 'It shows up: '. r strong: 'every 10 seconds'. r break. r text: 'Time now: '. r render: Time now]; yourself)
protoGrowlCallback: aScript aScript growl beInfo title: 'Seaside examples'; renderMessage: [:r | r text: 'This is a server callback.'. r break. r text: 'A link to '. r anchor callback: [self call: staticApp]; with: 'Seaside example browser']; yourself
sampleApp ^ WAExampleBrowser new addDecoration: (WAWindowDecoration new title: 'Seaside example browser'); yourself
</methods> <methods> Seaside.PGDemo <category>rendering</category>
renderCallbackOn: html html heading level2; with: 'Callback'. html paragraph: [ html text: 'Messages created by server callback.' ]. html anchor onClick: (html evaluator callback: [ :script | self protoGrowlCallback: script ]; return: false; yourself); with: 'server callback'
renderContentOn: html html div class: #demo; with: [ html heading: 'protoGrowl Demo'. html div class: #growl; id: #growl1; with: [self renderDirectOn: html]. html div class: #growl; id: #growl2; with: [self renderCallbackOn: html]. html div class: #growl; id: #growl3; with: [self renderPeriodicalOn: html]. ]
renderDirectOn: html html heading level2; with: 'No callback'. html paragraph: [ html text: 'Messages created at render time.'. html break. html text: 'No server callback' ]. "create messages via explicit instantiation" html anchor onClick: (PGInfoMessage title: 'Direct Evalutation with Explicit Instantiation' message: 'No server callback. No HTML.'); with: 'Create via explicit instantiation'. html break. "create messages with canvas api" html anchor onClick: ( html growl beInfo title: 'Direct Evalutation with HTML and Canvas'; renderMessage: [ :r | r text: 'a link to '. r anchor callback: [ self call: self counterApp ]; with: 'a counter' ]; yourself); with: 'Create via canvas API'.
rendererClass ^ WARenderCanvas
renderPeriodicalOn: html html heading level2; with: 'Periodical'. html paragraph: 'Will display an information message every 10 seconds.'. html paragraph script: (html updater every: 10 seconds; on: #periodicalCallback: of: self; yourself)
style ^' div.demo { font-family: Tahoma, Arial, Helvetica, sans-serif; } div.growl { font-size: 80%; width: 28%; height: 20em; margin: 5px; padding: 5px; border: 1px dotted darkblue; background-color: #eef; float: left; } '
</methods> <methods> Seaside.PGDemo <category>path</category>
updateRoot: anHtmlRoot super updateRoot: anHtmlRoot. anHtmlRoot title: 'protoGrowl Demo'
</methods> <methods> Seaside.PGDemo class <category>accessing</category>
description ^'protoGrowl Demo'
</methods> <methods> Seaside.PGDemo class <category>class initialization</category>
initialize (self registerAsApplication: 'examples/protogrowl') libraries add: SULibrary; add: PGLibrary
</methods> <methods> Seaside.PGDemo class <category>testing</category>
canBeRoot ^true
</methods> <methods> Seaside.PGGrowlFactory <category>converting</category>
displayString ^self growlMessage asJavascript
javascriptOn: aStream self growlMessage javascriptOn: aStream
</methods> <methods> Seaside.PGGrowlFactory <category>public</category>
beError messageClass := PGErrorMessage
beInfo messageClass := PGInfoMessage
beOk messageClass := PGOkMessage
beWarning messageClass := PGWarningMessage
renderMessage: aBlock self message: (self render: aBlock)
renderTitle: aBlock self title: (self render: aBlock)
</methods> <methods> Seaside.PGGrowlFactory <category>private</category>
growlMessage ^messageClass fromProperties: properties
render: aBlock ^canvas isNil ifTrue: [ self renderStatic: aBlock ] ifFalse: [ self renderDynamic: aBlock ]
renderDynamic: aBlock ^String streamContents: [ :stream | | document html previous | previous := canvas context document. previous := canvas context document. document := SUDocument new. document stream: stream; open: nil. canvas context document: document. html := canvas species context: canvas context callbacks: canvas callbacks. aBlock value: html. html flush. document close: nil. canvas context document: previous ]
renderStatic: aBlock ^String streamContents: [ :stream | | document html | document := SUDocument new stream: stream. html := WAStaticHtmlCanvas document: document. aBlock value: html. html flush. document close ]
</methods> <methods> Seaside.PGGrowlFactory <category>initialize-release</category>
setCanvas: aCanvas canvas := aCanvas
</methods> <methods> Seaside.PGGrowlFactory class <category>instance creation</category>
on: aCanvas ^ self new setCanvas: aCanvas
</methods> <methods> Seaside.WAHtmlCanvas <category>*protoGrowl</category>
growl ^Seaside.PGGrowlFactory on: self
</methods> <methods> Seaside.SUScript <category>*protoGrowl</category>
growl ^self add: (Seaside.PGGrowlFactory on: canvas)
</methods> <initialize> Seaside.PGDemo </initialize> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>Object</name> <environment>Core</environment> <super></super> <private>false</private> none <imports></imports> <category>Kernel-Objects</category> <attributes> <package>Kernel-Objects</package> </attributes> </class> <class> <name>WAComponent</name> <environment>Seaside</environment> <super>Seaside.WAPresenter</super> <private>false</private> none decoration <imports></imports> <category>Seaside-Component</category> <attributes> <package>Seaside-Component</package> </attributes> </class> <class> <name>WAHtmlCanvas</name> <environment>Seaside</environment> <super>Seaside.WACanvas</super> <private>false</private> none <imports></imports> <category>Seaside-Canvas</category> <attributes> <package>Seaside-Canvas</package> </attributes> </class> <class> <name>SUScript</name> <environment>Seaside</environment> <super>Seaside.SUObject</super> <private>false</private> none statements <imports></imports> <category>Scriptaculous-Core</category> <attributes> <package>Scriptaculous-Core</package> </attributes> </class> <class> <name>WAFileLibrary</name> <environment>Seaside</environment> <super>Seaside.WALibrary</super> <private>false</private> none default <imports></imports> <category>Seaside-Libraries</category> <attributes> <package>Seaside-Libraries</package> </attributes> </class>