Spinelzã®Windowã®ãªãã·ã§ã³
JavaScriptã©ã¤ãã©ãªã®Spinelzã®Windowã使ãã¨ãã«ã
å©ç¨ã§ãããªãã·ã§ã³ä¸è¦§ã®ã¡ã¢ã
Windowã®ãªãã·ã§ã³ä¸è¦§
å·¦ããªãã·ã§ã³åãå³ãããã©ã«ãå¤ã§ãã
className: Window.className.window, width: 300, height: 300, minWidth: 200, minHeight: 40, drag: true, resize: true, resizeX: true, resizeY: true, modal: false, closeButton: true, maxButton: true, minButton: true, cssPrefix: 'custom_', restriction: false, endDrag: Prototype.emptyFunction, endResize: Prototype.emptyFunction, addButton: Prototype.emptyFunction, preMaximize: function() {return true}, preMinimize: function() {return true}, preRevertMaximize: function() {return true}, preRevertMinimize: function() {return true}, preClose: function() {return true}, endMaximize: Prototype.emptyFunction, endMinimize: Prototype.emptyFunction, endRevertMaximize: Prototype.emptyFunction, endRevertMinimize: Prototype.emptyFunction, endClose: Prototype.emptyFunction, dragOptions: {}, appendToBody: false
Railsç¨Helper
Railsã§å©ç¨ããã¨ãã®Helperã®ãµã³ãã«ã§ãã
def window(name, options = {}) options.stringify_keys! options["cssPrefix"] = %Q!'#{options["cssPrefix"]}'! if options["cssPrefix"] win = %Q!var win = new Window('#{name}', {#{hash_to_javascript_options(options)}});! javascript_tag(win) end private def hash_to_javascript_options(hash_options) ary = Array.new hash_options.each do |key, value| ary << %Q!#{key}:#{value}! end ary.join(',') end
Helperå©ç¨æ³
ãããªæãã«ä½¿ãã¾ãã
<div id=window1> <div> Title </div> <div> Body </div> </div> <%= submit_tag("å®è¡", :onclick => "win.open();") %> <%= window("window1", {:width => 500, :height => 450} %>
ãã ããã®Helperã ã¨Windowãä¸ã¤ããä½ããªããã§ã
def window(name, options = {}, id = nil) options.stringify_keys! options["cssPrefix"] = %Q!'#{options["cssPrefix"]}'! if options["cssPrefix"] win = %Q!var win#{id} = new Window('#{name}', {#{hash_to_javascript_options(options)}});! javascript_tag(win) end
ã¨ãã
def win(name, options = {}) options.stringify_keys! options["cssPrefix"] = %Q!'#{options["cssPrefix"]}'! if options["cssPrefix"] win = %Q!var #{name} = new Window('#{name}', {#{hash_to_javascript_options(options)}});! javascript_tag(win) end
ã¨ãã«ããã»ããããããã
ããã¨ãhash_to_javascript_optionsã¡ã½ãããæ¸ãã®ãå¿ããã«ã
ãã ããä¸ã®ã»ãã使ãã¨ãã¯ãnameã«"window"ãæå®ããã¨ãã¨ã©ã¼ã«ãªãã®ã§ã注æãã ããã
ã©ã¤ãã©ãªå
ã§ãã®ååã使ç¨ãã¦ããããã§ãã
ãããªã¨ãã§ã
ãªãã·ã§ã³ã®å 容ã¯ããªãã·ã§ã³åãããããã¨æãã¾ãã
ã¯ããããã¾ãããããã©ãã ãã§ãï½
ã¨ããããã¾ã ã¡ããã¨èª¿ã¹ã¦ãªããã§ãæ¸ããªãã£ã¦ã®ãæ¬é³ã§ããã©ï¼ï¼