Closed GoogleCodeExporter closed 9 years ago
I have no particular loyalty to Prototype; it was just the framework I happened
to have already learned at the time I was developing Canviz. If I switch Canviz
from Prototype to jQuery, that might make you happy, but displease those
already using Canviz with Prototype. And there may be others wanting to use
MooTools or another framework.
For maximum interoperability, I would like for Canviz to not require any
JavaScript framework, but I'm not sure how best to do that. There are features
Canviz uses which aren't built into JavaScript. For example, Canviz uses
Prototype's class-based object inheritance model; this fit more easily into my
brain than JavaScript's default prototype-based object model. Also, I want to
dynamically load additional JavaScript files as needed (see issue #20), and I
assume that Prototype and other frameworks offer a function to do that, and
that it would be tedious to do manually. Canviz already uses other Prototype
conveniences which are tedious to do manually, but in the interest of
decreasing framework dependence, I'm willing to forgo those conveniences, if
they can be replicated without bloating the code too much.
Any work on reducing Canviz's framework dependence should also consider the
Path library, which Canviz uses. There was a patch submitted to remove the
Prototype dependency from Path, in response to this discussion thread:
http://groups.google.com/group/canviz/browse_thread/thread/ae7ff77d60825bf3/6974
cc25e2255948 The patch was submitted to me privately by Frank Hess, but I will
attach it to this ticket now. I did not apply it at the time because it made
many different changes at once, and was hundreds of lines long, making it hard
for me to review. He said:
"I made the following changes:
"- Classes created using closures where possible
"- changed Object.isUndefined() -> ===undefined
"- changed the prototype each constructs to for loops
"There is only one function call I'm unsure: In line 42 (this.reset();) - I
commented it out."
So the reset issue needs to be addressed, and the patch needs to be evaluated
by someone who has a thorough understanding of both class-based and
prototype-based object models who can determine if Canviz still works the way I
programmed it to after these changes. I would also want each logical change
committed separately: for example, all instances of changing
"Object.isUndefined()" to "=== undefined" would be one commit, changing all
Prototype "each" constructs to "for" loops would be a second commit, and so on.
How do other JavaScript libraries deal with this problem? Do they offer a
choice of frameworks (if so, how do they accomplish that?) or do they just
write everything themselves?
Original comment by ryandesi...@gmail.com
on 13 Jun 2011 at 7:44
Attachments:
Xavier Roger-Machart wrote to the discussion group about this problem:
http://groups.google.com/group/canviz/browse_thread/thread/ec535a3da645f790
He provided a link to a patch that removes Prototype-specific code from Canviz
and factors it out into "adapters" that let Canviz use either Prototype or
jQuery or perhaps other libraries later. To ensure that patch is not lost, I'm
attaching it here. Since the patch appears to have been made without knowledge
of the above considerations, we'll talk about it some more on the discussion
group first.
Original comment by ryandesi...@gmail.com
on 6 Oct 2011 at 1:00
Attachments:
Removed use of Object.isUndefined() from path.js in r297 and canviz.js in r298.
Original comment by ryandesi...@gmail.com
on 15 Dec 2011 at 1:19
Now attaching additional files by Xavier Roger-Machart: a no-library vanilla.js
adapter, and index.html files showing use of each adapter.
Original comment by ryandesi...@gmail.com
on 15 Dec 2011 at 1:33
Attachments:
Removed prototype.js class-based inheritance from path.js in r299.
Original comment by ryandesi...@gmail.com
on 15 Dec 2011 at 12:11
Removed most occurrences of each() and bind() from path.js in r303.
Original comment by ryandesi...@gmail.com
on 16 Dec 2011 at 1:55
Slightly revert r303: use JavaScript-native forEach() method for iteration in
path.js, in r306.
Original comment by ryandesi...@gmail.com
on 23 Dec 2011 at 2:04
r308: revert r306; for loop is faster than forEach
Original comment by ryandesi...@gmail.com
on 22 Jan 2012 at 1:34
r309: use plain JavaScript objects instead of prototype.js hashes
Original comment by ryandesi...@gmail.com
on 22 Jan 2012 at 1:50
r311: removed use of prototype's $() from Path examples
Original comment by ryandesi...@gmail.com
on 22 Jan 2012 at 2:03
r313: removed use of prototype's String#startsWith
Original comment by ryandesi...@gmail.com
on 22 Jan 2012 at 2:59
r314: removed use of prototype's Array#each from Path examples
Original comment by ryandesi...@gmail.com
on 22 Jan 2012 at 3:28
r315: removed use of prototype's $F() from Path examples
Original comment by ryandesi...@gmail.com
on 22 Jan 2012 at 3:33
r316: removed use of prototype's Event#pointerX / Event#pointerY from Path
example1
Original comment by ryandesi...@gmail.com
on 22 Jan 2012 at 9:47
John Resig wrote a great article/library on class-based inheritance.
http://ejohn.org/blog/simple-javascript-inheritance/
I come from a Java background, and having used Resig's solution it felt very
comfortable.
Original comment by pe...@clicksecurity.com
on 11 Jul 2012 at 8:21
Hey,
I tried applying canviz-libneutral.diff to canviz and to fix
examples/hello_world/new.html to work with it, however I keep getting in the
java console:
"Rect is not a constructor".
It looks like a bug, but I can't seem to figure out what is causing it.
Attached is the canviz tar.gz package, patched with canviz-libneutral.diff and
with the fixed examples/hello_world/new.html .
Could anyone please look at it and figure out what is wrong?
Thanks,
Guy
Original comment by guys...@gmail.com
on 1 Oct 2012 at 6:08
Attachments:
After applying all the patches on top of v0.1 I have the attached set of files.
I am uploading them for easy usage.
--
patches applied on top of canviz-0.1.tar.bz2:
path.js.diff
canviz-libneutral.diff
canviz-vanilla-and-tests.zip
-------------------------
Original comment by sarkarbi...@gmail.com
on 6 May 2013 at 5:28
Attachments:
r393: use plain JavaScript classes instead of PrototypeJS classes
r399: remove PrototypeJS-style Element creation and manipulation, arrays,
hashes, ajax, iteration (each)
Original comment by ryandesi...@gmail.com
on 24 Jul 2013 at 7:06
r400: use escape-html from npm instead of String.prototype.escapeHTML from
PrototypeJS
r401: remove PrototypeJS include from examples that no longer need it
r402: remove some PrototypeJS usage from example
r404: use contentloaded() instead of document.observe('dom:loaded') from
PrototypeJS
r405: remove use of PrototypeJS Array.prototype.each for iteration
r406: remove hopefully last vestiges of PrototypeJS from example
Original comment by ryandesi...@gmail.com
on 24 Jul 2013 at 8:25
r430: fix transparent text; replace PrototypeJS setOpacity method with our own
Original comment by ryandesi...@gmail.com
on 30 Jul 2013 at 4:44
r434: fix labels that begin with spaces: remove PrototypeJS "times" method
Original comment by ryandesi...@gmail.com
on 10 Aug 2013 at 7:32
Original issue reported on code.google.com by
andreas....@gmail.com
on 12 Jun 2011 at 9:58