Library Conflict Between Superfish.js And Effects.js / Prototype.js?
May 24, 2010
I think I'm having a library conflict, but as I don't know javascript, I'm finding it difficult to resolve.
In my document I have an animated navigation using superfish.js [URL].. I also have an accordion menu which uses effects.js and prototype.js. The animated navigation was working before, however after adding the effects.js and protoype.js the menu drop downs only appear and don't animate.
Is this a library conflict and if so howdo I fix it?
I'm working on a unit test for a javascript library that has several handlers. I wish to fire those handlers in a "natural" way, by raising an event that gets caught. I am having trouble creating an event that gets caught in Firefox.I do development in Firefox to take advantage of Firebug, but the software is for a closed intranet and IE 7 is the required browser (we support IE 8 insofar as we force it to IE 8 mode). This policy predate my hire, I'm trying to get the software to a browser agnostic state - first I have to replace an ActiveX object known as MeadCo Script X - but that's a whole other issue.Anyway I need to raise events, specifically onchange events in Firefox. I have this so far...
Code javascript:
function fire(el, ev) { el = $(el); if (typeof(el.fireEvent) != 'undefined') { // IE
[code]...
Prototype library is in use for this project, though I haven't used it for this particular corner case.
I have been trying in vain for many days to resolve a conflict between javascript libraries. My homepage uses jquery horizontal css menubar + a combined mootool and prototype accordian type sliding information box in the middle of the webpage. I find that the highlighter of the css menubar does not work when prototype.js is also loaded on the same page. I have read somewhere that $ should be replaced however I have tried every possible option and none works. I have jquery loading first as it is on my template, with this: <script type='text/javascript' src='../Web/Templates/jquery-1.3.2.js'></script> <script type='text/javascript' src='js/example.js'></script>
And my mootool and prototype loades further below like this: <script type="text/javascript" src="scripts/intro/prototype.lite.js"></script> <script type="text/javascript" src="scripts/intro/moo.fx.js"></script> <script type="text/javascript" src="scripts/intro/moo.fx.pack.js"></script> <script type="text/javascript"> function init(){ var stretchers = document.getElementsByClassName('box'); var toggles = document.getElementsByClassName('tab'); var myAccordion = new fx.Accordion( toggles, stretchers, {opacity: false, height: true, duration: 600} ); //hash functions var found = false; toggles.each(function(h3, i){ var div = Element.find(h3, 'nextSibling'); if (window.location.href.indexOf(h3.title) > 0) { myAccordion.showThisHideOpen(div); found = true; } }); if (!found) myAccordion.showThisHideOpen(stretchers[0]); } </script>
I want an identical effect that has three buttons -- print, email, text that does the same thing on the site.I can handle the server-side code (PHP), but I want to know how I can get that exact effect? My JavaScript is a bit above beginners, and I see they are using Prototype with some other effects.Now, on Firefox, I had saved the webpages but when I tried click on either of the 3 buttons, the JavaScript effect did not work. Can anyone show me how to implement something similar on my site?
I'm not much more than a jquery cut and paste - change a simple user definition, guy. I can't write javascript...So, I was trying to marry two jquery "animation effects" in one page and apparently have a conflict. The two things work separately but it seems that there is unhappiness having jquery-1.3.2.js and jquery-1.2.6.min.js called in the same HTML page.
All the scripts are: jquery-1.3.2.js jquery.easing.1.3.js
I am using GreaseMonkey to load jQuery 1.3.2 (there is a bug with the latest version of jquery and GM) and jQuery UI 1.8.0.I am using jQuery via GM to manipulate the GUI of a content management system. This CMS uses its own JS library to dynamically add stuff to the dom.
Question:How can I target a dom element that was added to the dom via this other JS lib?In other words, the CMS will add a div to the dom, and I am not sure how to tell jquery to wait for these elements to "be there" before applying the jquery goodness. Specifically, I would like to do this:
$(function() { $('#zen1227').resizable(); });
But "#zen1227" does not "appear" until later via this other JS library.
According to ECMAScript, the root of the prototype chain is Object.Prototype. Each object has an internal property [[Prototype]] that could be another object or NULL.... However, it also says that every function has the Function prototype object: Function.Prototype, it confused me, because a function is an object, for a function object, what is its function prototype and object prototype..For example:
var x = function (n) {return n+1;};
what is the relationships of x, Object.Prototype and Function.Prototype
I am trying to get to the bottom of javascript object, prototypes etc. I have a fairly good grasp of it, but I get confused the closer I get to the base object.prototype. FIrst of all, I was under the impression that all objects descend directly from Object. But some objects (like Array) seem to inherit properties and methods from the function.prototype. So does this mean that the chain is like this:
object -- function -- array Second, I noticed (on the mozilla javascript reference site that object.prototype inherits properties and methods from function.prototype and vice versa!? How can this be? I must be missing something important about understanding the chain?
I was basically trying to follow several tutorials to get a superfish menu working on my website, but I don't seem to be able to get it to work.I included both the superfish.css and the superfish.js in my website's header; both paths are corrent and point to the designated file.I then included the superfish function in my header like this:
<script> $(document).ready(function(){ $('ul.sf-menu').superfish({ delay: 1000, // one second delay on mouseout animation: {opacity:'show',height:'show'}, // fade-in and slide-down animation
[code]....
The corresponding <ul> element has the required sf-menu class, but still there are no animations, no fading, no delays, just the plain css functionality provided by the superfish.css.
I would like to know if there exists a javascript library (at least for IE and Firefox) that let me get css properties in a more structured way. I would like to have a css value that seperates the size/length value from the type. For example:
width: 2.5em size=2.5 type=em
And most importantly I would like a way to convert each such value into pixels.
Does it exist? I am aware of the CSSStyleDeclaration and related methods in Firefox.
If not, is it possible to convert such a value as 2.5em into pixels in javascript? Sometimes the standard available methods that return pixels cannot calculate the value I need. For example calculating the border size.
I want to have one statement in my web page that includes a single file (for example "Mylib.inc" that contains a list of ".js" files to include. Is that possible? And if so can some one show me the basic format to use?
This would allow me to add and remove scripts from my pages without having to edit each page, only w3ouyld need to make a change in the MyLib.inc file I'm envisioning MyLib.inc to look something like this:
I know nothing about javascript at the moment, but I've been hitting php very aggressively the past few months.
I've came across a challenge and I'm not sure how to go about fixing it.
Basically, I need to be able to drag an image into a box on my webpage, crop it, and then upload it. I've done basic image uploading and resizing with php. That's no big deal.
The problem is I may want to crop in different spots. The idea is to have some sort of box tool that is set at a given aspect ratio (like Photoshop does). Then, I could select the part of the image I wanted to keep, hit one button that would then crop, resize, and upload the image (storing the pathway to the MySQL database).
So does anyone know of any either standalone GUI's that work well for this sort of image manipulation or possibly a javascript that will allow me to select part of the image and spit out some co-ordinates that I could use with php's GD Library.
I would like to know if there is somewhere a JS library for managing media content depends on the client's default media player. The player can be QT, WMP, or any other players.
the idea is to code something like this :
var m = new MediaPlayer('my_media_file.ext'); m.display(); // generate a running code to display the media
and the object can be control by a set of method : m.play(); m.pause(); m.stop();
I am new to javascript and intend to build a custom library. After saving independent files which contain separate functions, how does one build the library?
I have a js dropdown menu and js slideshow on the same webpage. The menu dropdowns work great in FF but not in IE 6. The menus in ie drop down behind the slide show which I do not want. Does anyone know how I can fix that? Perhaps an iFrame?
I have a javascript dropdown menu and a scrolling marquee on my site, but there is a conflict of script which only allows one of them to be visible. Not sure how to get round this.
Is there a small graphics library that I can use? All I need to do is draw a line of a nominated thickness and colour between two specified points and to, at some later time, "delete" the line?
I've found a few offerings but either they weren't multi-browser compatible or they were too big for me to consider (20K instead of 2 or 3K).
I've been asking questions about library design over the last week and would like to get feedback on my overall idea for a JavaScript GUI library. I need a nice GUI library so there is a good chance I will write this as I need new widgets. I haven't found anything like this and I'm surprised/disapointed this doesn't already exist. My library prototype works nicely. I think parts of these ideas are not commonly used for JavaScript library development and before I dive in too deeply any experienced advice might make my efforts a lot better.
While trying to develop a rich GUI for a web app backend I started needing a large set of GUI widgets that behaved and were coded similarly. Things like flyout menus, drop down menubars, tree menus, adjustable table widths, spinners...all the things that are in Java Swing or other GUI widget libraries. Yes I know all of these things exist individually as JavaScripts but I would like to build a library that uses a class hierarchy structure and inheritance to take advantage of all the nice OOP ideas of encapsulation etc. Certainly this library will be different than a desktop app GUI library since HTML, CSS and the browser already provide a lot of what is needed (<ul>'s for menus, <table> for tables, all sorts of font display stuff, some form elements). In JavaScript we are adding functionality on top of what the browser already gives us.
This could end up being a big library but if each class is in it's own file and the class hierarchy is known then people could string together only the pieces they need. I would like a develop a way to automate this step. Something like compiling one JavaScript file with all you need for your page from the big library.....
Is there a free js library for doing unit conversions? I am putting together an app that needs to convert volume and weight, among others. You'd think that one exists, but I have yet to find it.
I started studying javascript when I decided that I wanted to create a dynamic webpage after viewing some books that were made to pageflip with Javascript and after viewing a ton of animations. So I figured since everyone keeps saying Javascript is simple that if all I wanted to do was to make a book extend outwards on mouseover and then open up on click and flip pages which they already have a code for that it wouldn't be so difficult. I've read everything I could practiced a little bit, I'm not fluent but I do have a goal and a time. The problem for me comes up with figuring out what I need to do in order to make it appear as if the book is coming out of a book shelf. There is a lot of information on animations where flat objects rise above clouds.
I am thinking that I would have to use some sort of sprite of a row of books both sorta sideways where you can see the side of the book as well as the edge, and both a row of books on a shelf, or perhaps a row of books with some of the books being pulled out and then on mouse over animate the scene so that it looks like the book is being pulled out. Would that work? Or is there a simpler way? Another way or I don't know. Is there a code that can make it look like a book is extending outwards without an animation or would I need to create an animation for that?
After a good deal of internal development, I've decided this library will do more good in the wild. It works in IE6, Safari 2, Opera 9, Firefox 1.5, and IE5.5/Mac (sort of buggy behavior with text selection in IE5.5/Mac though). It should also work in virtually any version of Gecko, Opera 6+, Safari 1, and IE5+ (anybody who wants to test those, feel free). The scripting is highly efficient, and only exposes two functions globally, Draggable and Droppable. The below code is licensed under the LGPL, though it is available under other licenses per request.
Let me know if you have any issues with it - this is something I'm interested in maintaining. Also, compared to other scripts, such as script.tac.ulo.us, this is much less code (lots of whitespace/comments could be taken out), and more widely supported across browsers.
Other than below, it can be found here: http://www.jasonkarldavis.com/scripts/dragdropable/dragdropable.html
// dragdropable.js (1.0.1) //Copyright (C) 2006 Jason Davis, www.jasonkarldavis.com //This code is licensed under the LGPL: //http://www.gnu.org/licenses/lgpl.html // // Documentation: //This script exposes two global variables, Draggable and Droppable. To make an //element draggable, simply call `Draggable(element)`. This sets the necessary //CSS properties and event handlers. It also overrides the addEventListener and //and attachEvent methods (if present) to include the following events: //onstart(When the element begins dragging) //ondrag(When the element is being dragged) //onstop(When the element has stopped dragging) //You may also assign element.onstart, element.ondrag, and element.onstart to //add event listeners. //Lastly, if you need to physically prevent an element from dragging, you may //call event.preventDefault() from within the onstart handler. // //To make an element droppable (have things dragged onto it), call //`Droppable(element)`. This sets the necessary event handlers and coordinate //searches. Once again, it overrides addEventListener and attachEvent to //include the following events: //onhover(When another element has been dragged over the element) //ondrop(When another element has been dropped onto the element) //onunhover(When another element has been dragged off the element) //As before, you may also set element.onhover, element.ondrop, and //element.onunhover directly. //To remove all drop points from the current session, call `Droppable.reset()`. // //The event object is also extended with the following properties: //dragTarget(The element being dragged) //dropTarget(The element being dropped onto) // // Known bugs: //* removeEventListener and detachEvent do not work with the custom events. //Workaround: Use direct assignment (element.onevent) instead. //* There is no way to remove a single drop point. //Workaround: Call Droppable.reset(), then reinitialize the other drop points. //* There is no way to remove dragging from an element. //Workaround: element.onstart = function(event) { event.preventDefault() } //* Changing position of droppable elements after initialization breaks drop //Workaround: Static droppables are much faster than moving ones. Either call //Droppable.reset() and reinitialize often, or ask the author to modify the //script to account for this (and accept the resulting slowdown)
function Draggable(element) { // initialize drag variable var x = 0, y = 0, oldMouseMove, oldMouseUp;
// get style properties of element var computedStyle; if (typeof document.defaultView != "undefined" && typeof document.defaultView.getComputedStyle != "undefined") computedStyle = document.defaultView.getComputedStyle(element, ""); else if (typeof element.currentStyle != "undefined") computedStyle = element.currentStyle; else computedStyle = element.style;
if (element.onstart) element.onstart(event); } function ondrag(event) { event.dragTarget = element; element.style.left = parseInt(element.style.left) + event.clientX - x + "px"; element.style.top = parseInt(element.style.top) + event.clientY - y + "px"; x = event.clientX; y = event.clientY; Droppable.query(event);
if (element.ondrag) element.ondrag(event); } function onstop(event) { event.dragTarget = element; Droppable.query(event);
if (element.onstop) element.onstop(event); }
// make listeners active element.onmousedown = (function(oldMouseDown) { return function() { // Call old listener if (oldMouseDown) oldMouseDown.apply(this, arguments);
// Store old event handlers oldMouseMove = this.ownerDocument.onmousemove; oldMouseUp = this.ownerDocument.onmouseup;
// Setup events this.ownerDocument.onmousemove = function() { // Call old listener if (oldMouseMove) oldMouseMove.apply(this, arguments);
// Fix the function prototype for IE5/Mac if (typeof Function.prototype.apply == "undefined") Function.prototype.apply = function(scope, args) { if (!args) args = []; var index = 0, result; do { -- index } while (typeof scope[index] != "undefined"); scope[index] = this;
switch (args.length) { case 0: result = scope[index](); break; case 1: result = scope[index](args[0]); break; case 2: result = scope[index](args[0], args[1]); break; case 3: result = scope[index](args[0], args[1], args[2]); break; case 4: result = scope[index](args[0], args[1], args[2], args[3]); break; default: result = scope[index](args[0], args[1], args[2], args[3], args[4]); break; }
delete scope[index]; return result; }
if (typeof Function.prototype.call == "undefined") Function.prototype.call = function(scope) { var args = new Array(Math.max(arguments.length-1, 0)); for (var i = 1; i < arguments.length; i++) args[i-1] = arguments[i]; return this.apply(scope, args); }
I downloaded the tablekit javascript library and put it in the js directory which is in the jsp directory. i.e. the directory is
C:workspacecom.mycomp.data.warWEB-INFjspjs
The jsp page is as follows and display correctly with FF and chrome on Windows Vista.However, the column of the page is not sorted by clicking on the column. i.e. the tablekit javascript library sorting function does not work on the web page generated by jsp.