Permalink
Browse files

fixing documentation

  • Loading branch information...
Jorge Falcão
Jorge Falcão committed Nov 1, 2010
1 parent 8ba52b8 commit f1071a4f7d0b05ef75ed0e4800d86e7d47eef7c7
Showing with 35 additions and 43 deletions.
  1. +3 −1 README.rdoc
  2. +31 −0 ext-reload.js
  3. +1 −42 lib/textmate/Support/lib/mozrepl_tools.rb
View
@@ -19,7 +19,9 @@ gem install mozrepl_tools
#> mozrepl 'my/path/file.js'
It's works with Sencha(ExtJS) Components!!!
== Use with Sencha|ExtJS.
Just ext-reload.js to your project.
== Using with Textmate (~/Library/Application Support/TextMate/Bundles/MozRepl.tmbundle)
View
@@ -0,0 +1,31 @@
//reload if xtype is registered again, by watching Ext.reg
Ext.reg = Ext.reg.createSequence(function(xtype) {
console.log("Attempting to reload xtype", xtype);
//find all current instances of this type
Ext.ComponentMgr.all.filterBy(function(e) {return e.getXType() == xtype; })
.each(function(item) {
//recreate and read
var ic = item.initialConfig;
var o = item.ownerCt;
if(ic && o) {
console.log("Reloading component instance", item, ic, o);
//remove
o.remove(item);
//add it again
var it = o.add(Ext.apply({xtype: xtype}, ic));
//TODO: test if it was indeed active
if ( it && o.getLayout().setActiveItem ) {
o.getLayout().setActiveItem(it);
};
o.doLayout();
}
});
});
@@ -6,36 +6,22 @@
script = DATA.read
# print "asdad'asdasda"
# print "aa\"aa"
# print "aa\"aa".gsub(/["]/, '\"')
filepath = ENV["TM_FILEPATH"] || ARGV[0]
file = File.basename filepath
ext = File.extname filepath
filename = File.expand_path filepath
# p ext
s.puts(script)
if ext == ".css" || ext == ".scss"
file = file.split(".")[0] + ".css"
s.puts("reload.css('#{file}')")
puts "reloaded #{file}"
elsif ext == ".js"
# content = (IO.readlines(filename).map do |l|
# "\"" + l.gsub(/[']/, '\\\\\'').gsub(/["]/, '\"').chop() + " \\n \"" + " + \n"
# end).join("")
# content += '""'
# puts contenttoutf8 → string
# puts content
s.puts("reload.js('#{filename}')")
puts "reloaded #{filename}"
end
# puts script
# workaround
sleep 1
@@ -72,40 +58,13 @@
}
}
var document = doc = window.document;
var Ext = window.Ext;
// firebug
var console = window.console || {debug:function(){}};
console.debug("loading...");
// add development Ext.reg
if ( ! Ext._reg ) {
console.debug('saving original Ext.reg');
Ext._reg = Ext.reg;
}
Ext.reg = function(xtype) {
console.debug("Ext.reg:", arguments);
// calling old Ext.reg
Ext._reg.apply(Ext, arguments);
// reinstance all xtypes
var items = Ext.ComponentMgr.all.filterBy(function(e) { return e.getXType() == xtype }).each(function(item) {
repl.print(item)
var ic = item.initialConfig;
var o = item.ownerCt;
o.remove(item);
var it = o.add(ic)
if ( o.getLayout().setActiveItem ) {
o.getLayout().setActiveItem(it);
};
o.doLayout();
});
};
var head = document.getElementsByTagName("head")[0];

0 comments on commit f1071a4

Please sign in to comment.