Invado Posted September 24, 2006 Posted September 24, 2006 Not sure exactly where you change/add the button names in the javascript file. These are the installation directions, but I'm not quite sure what/where I need to edit: Button naming conventions: We will have two butons for each catgory; one normal and other one for rollover. Category buttons are named quite interestingly. You will have to check out the cpath of each category (the easiest way to do this is by hovering the mouse over each category and checking its link which shows the cpath number at the end. After you got the number, just use a generic button name, here we have used 'category' and attach the umber at the end for each category. For rollover buttons, use the 'category' followed by the number and then '_'. for example, in default Oscommerce, we have 'hardware' category with cpath equals to 1. The buttons naming would be; Normal hardware categroy button: category1.gif Rollover category button: category1_.gif Here is my javascript file, but I don't know where I need to paste my button names. I am not too familiar with any of this. I need some help. // The following functions were pulled from lib.js // by Caio Chassot (http://v2studio.com/k/code/) Array.prototype.find = function(value, start) { start = start || 0; for (var i=start; i<this.length; i++) if (this==value) return i; return false; } Array.prototype.count = function(value) { var pos, start = 0, count = 0; while ((pos = this.find(value, start))!==false) { start = pos + 1; count++; } return count; } function isUndefined(v) { var undef; return v===undef; } function undef(v) { return isUndefined(v) } function isdef(v) { return !isUndefined(v) } function map(list, fn) { if (typeof(fn)=='string') return map(list, __strfn('item,idx,list', fn)); var result = []; fn = fn || function(v) {return v}; for (var i=0; i < list.length; i++) result.push(fn(list, i, list)); return result; } function filter(list, fn) { if (typeof(fn)=='string') return filter(list, __strfn('item,idx,list', fn)); var result = []; fn = fn || function(v) {return v}; map(list, function(item,idx,list) { if (fn(item,idx,list)) result.push(item) } ); return result; } String.prototype.insert = function(idx,value) { return this.slice(0,idx) + value + this.slice(idx); } function getElem(elem) { if (document.getElementById) { if (typeof elem == "string") { elem = document.getElementById(elem); if (elem===null) throw 'cannot get element: element does not exist'; } else if (typeof elem != "object") { throw 'cannot get element: invalid datatype'; } } else throw 'cannot get element: unsupported DOM'; return elem; } function getElementsByClass(className, tagName, parentNode) { parentNode = isdef(parentNode)? getElem(parentNode) : document; if (undef(tagName)) tagName = '*'; return filter(parentNode.getElementsByTagName(tagName), function(elem) { return hasClass(elem, className) }); } function hasClass(elem, className) { return getElem(elem).className.split(' ').count(className); } // ATTACH ROLLOVERS // This function loops through every image and input tag // looking for the class "rollover", if found it then preloads // the rollover image and attaches mouse events for the rollover // by Tim Walling // User Defined Variables var erClassName = "rollover"; var erImageName = "_"; function newImageName(oldName) { var newName = oldName.insert (oldName.length-4,erImageName); return newName; } function oldImageName(curName) { var re = new RegExp (erImageName, 'gi') ; var oldName = curName.replace(re, '') ; return oldName; } function attachRollovers(){ var btnsTemp = new Array(); var origSrc = new Array(); var newSrc = new Array(); var btnsImage = getElementsByClass(erClassName,'img'); // for images var btnsInput = getElementsByClass(erClassName,'input'); // for inputs var btns = btnsImage.concat(btnsInput); // combine into one array for (var i=0; i<btns.length; i++){ origSrc = btns.src; newSrc = newImageName(origSrc); btnsTemp = new Image(); btnsTemp.src = newSrc; btns.onmouseover = function() { var newSrcString = newImageName(this.src); this.setAttribute('src',newSrcString) } btns.onmouseout = function() { var oldSrcString = oldImageName(this.src); this.setAttribute('src',oldSrcString) } } } window.onload = attachRollovers; Quote
Invado Posted September 24, 2006 Author Posted September 24, 2006 Should I even be looking to add/edit the buttons in the javascript? or is it supposed to be done in another file? Anyone able to help? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.