Sha256: e6344f619219966f2a4902c7f9150166ed59b266070341797e65d240f3f849cc

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

# = Popup
#
# code: gmosx
#
# (c) 2004 Navel, all rights reserved.
# $Id: popup.rb 71 2004-10-18 10:50:22Z gmosx $

module N; module UI

# = Popup
#
class Popup

	#  Emit the needed javascript.
	#  Alternatively use this code: <script src="/r/js/std.js">#{}</script>
	# 
	def self.script
%[
function newWin(url, name, w, h, scroll) {
	var pleft = (screen.width - w) / 2;
	var ptop = (screen.height - h) / 2;
	var settings = 'height=' + h + ',width=' + w + ',top=' + ptop + ',left=' + pleft + ',scrollbars=' + scroll + ',resizable';

	win = window.open(url, name, settings);

	return false;
}
]
	end

	# gmosx: keep the leading / to be IE friendly.
	#
	def self.onclick(uri, width, height, title = "Popup", type="PAGE", options = "scrollbars=yes,resizable", container = "/p/glue/popup.sx")
		%[javascript: var pwl = (screen.width - #{width}) / 2; var pwt = (screen.height - #{height}) / 2; window.open('#{container}?uri=#{uri};type=#{type}', '#{title}', 'width=#{width},height=#{height},top='+pwt+',left='+pwl+', #{options}'); return false"]		
	end	
	
	# gmosx: keep the leading / to be IE friendly.
	#
	def self.link(uri, width, height, link = "link", title = "Popup", type="PAGE", options = "scrollbars=yes,resizable", container = "/p/glue/popup.sx")
		%[<a href="#" onclick="#{self.onclick(uri, width, height, title, type, options, container)}">#{link}</a>]
	end
end

end; end # module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.1.2 lib/n/ui/popup.rb