Topic: Script after Dean Edwards packer causes error

There are several semi-colons missing
Here's all of them fix

[code]/*
Mif.Tree
*/
if(!Mif) var Mif={};

Mif.Tree = new Class({

    Implements: [new Events, new Options],
       
    options:{
        types: {},
        forest: false,
        animateScroll: true,
        height: 18
    },
   
    initialize: function(options) {
        this.setOptions(options);
        $extend(this, {
            types: this.options.types,
            forest: this.options.forest,
            animateScroll: this.options.animateScroll,
            dfltType: this.options.dfltType,
            height: this.options.height,
            container: $(options.container),
            UID: 0,
            $: {},
            key: {}
        });
        this.defaults={
            name: '',
            cls: '',
            openIcon: 'mif-tree-empty-icon',
            closeIcon: 'mif-tree-empty-icon',
            loadable: false
        };
        this.dfltState={
            open: false
        };
        this.updateOpenState();
        Mif.Tree.UID++;
        this.DOMidPrefix='mif-tree-'+Mif.Tree.UID+'-';
        this.wrapper=new Element('div').addClass('mif-tree-wrapper').injectInside(this.container);
        this.initEvents();
        this.initScroll();
        this.initSelection();
        this.initHover();
    },
   
    initEvents: function(){
        this.wrapper.addEvents({
            mousemove: this.mouse.bindWithEvent(this),
            mouseover: this.mouse.bindWithEvent(this),
            mouseout: this.mouse.bindWithEvent(this),
            mouseleave: this.mouseLeave.bind(this),
            mousedown: $lambda(false),
            click: this.toggleClick.bindWithEvent(this),
            dblclick: this.toggleDblclick.bindWithEvent(this),
            keydown: this.keyDown.bindWithEvent(this),
            keyup: this.keyUp.bindWithEvent(this)
        });
    },
   
    $getIndex: function(){//return array of visible nodes.
        this.$index=[];
        var node=this.forest ? this.root.getFirst() : this.root;
        do{
            this.$index.push(node);
        }while(node=node.getNextVisible());
    },
   
    mouseLeave: function(){
        this.mouse.coords={x:null,y:null};
        this.mouse.target=false;
        this.mouse.node=false;
        if(this.hover) this.hover();
    },
   
    mouse: function(event){
        this.mouse.coords=this.getCoords(event);
        var target=this.getTarget(event);
        this.mouse.target=target.target;
        this.mouse.node    = target.node;
    },
   
    getTarget: function(event){
        var target=event.target;
        while(!/mif-tree/.test(target.className)){
            target=target.parentNode;
        }
        var test=target.className.match(/mif-tree-(gadjet)-[^n]|mif-tree-(icon)|mif-tree-(name)|mif-tree-(checkbox)/);
        if(!test){
            var y=this.mouse.coords.y;
            if(y==-1||!this.$index) {
                node=false;
            }else{
                node=this.$index[((y)/this.height).toInt()];
            }
            return {
                node: node,
                target: 'node'
            }
        }
        for(var i=5;i>0;i--){
            if(test[i]){
                var type=test[i];
                break;
            }
        }
        return {
            node: this.$[target.getAttribute('uid')],
            target: type
        }
    },
   
    getCoords: function(event){
        var position=this.wrapper.getPosition();
        var x=event.page.x-position.x;
        var y=event.page.y-position.y;
        var wrapper=this.wrapper;
        if((y-wrapper.scrollTop>wrapper.clientHeight)||(x-wrapper.scrollLeft>wrapper.clientWidth)){//scroll line
            y=-1;
        }
        return{
            x: x,
            y: y
        };
    },
   
    keyDown: function(event){
        this.key=event;
        this.key.state='down';
    },
   
    keyUp: function(event){
        this.key={};
        this.key.state='up';
    },
   
    toggleDblclick: function(event){
        var target=this.mouse.target;
        if(!(target=='name'||target=='icon')) return;
        this.mouse.node.toggle();
    },
   
    toggleClick: function(event){
        if(this.mouse.target!='gadjet') return;
        this.mouse.node.toggle();
    },
   
    initScroll: function(){
        this.scroll=new Fx.Scroll(this.wrapper);
    },
   
    scrollTo: function(node){
        var position=node.getVisiblePosition();
        var top=position*this.height;
        var up=top<this.wrapper.scrollTop;
        var down=top>(this.wrapper.scrollTop+this.wrapper.offsetHeight);
        if(position==-1 || ( !up && !down ) ) {
            this.scroll.fireEvent('complete');
            return false;
        }
        if(this.animateScroll){
            this.scroll.start(this.wrapper.scrollLeft, top-(down ? this.wrapper.offsetHeight-this.height : 0));
        }else{
            this.scroll.set(this.wrapper.scrollLeft, top-(down ? this.wrapper.offsetHeight-this.height : 0));
            this.scroll.fireEvent('complete');
        }
    },
   
    updateOpenState: function(){
        this.addEvents({
            'drawChildren': function(parent){
                var children=parent.children;
                for(var i=0, l=children.length; i<l; i++){
                    children[i].updateOpenState();
                }
            },
            'drawRoot': function(){
                this.root.updateOpenState();
            }
        });
    }
   
});
Mif.Tree.UID=0;


/*
Mif.Tree.Node
*/
Mif.Tree.Node = new Class({

    Implements: [new Events],
   
    initialize: function(structure, options) {
        $extend(this, structure);
        this.children=[];
        this.type=options.type||this.tree.dfltType;
        this.property=options.property;
        this.data=options.data;
        this.state=$extend($unlink(this.tree.dfltState), options.state);
        this.$calculate();
       
        this.UID=this.tree.UID++;
        this.tree.$[this.UID]=this;
    },
   
    $calculate: function(){
        $extend(this, $unlink(this.tree.defaults));
        this.type=$splat(this.type);
        this.type.each(function(type){
            var props=this.tree.types[type];
            if(props) $extend(this, props);
        }, this);
        $extend(this, this.property);
    },
   
    getDOM: function(what){
        var node=$(this.tree.DOMidPrefix+this.UID);
        if(what=='node') return node;
        var wrapper=node.getFirst();
        if(what=='wrapper') return wrapper;
        if(what=='children') return wrapper.getNext();
        return wrapper.getElement('.mif-tree-'+what);
    },
   
    getGadjetType: function(){
        return (this.loadable && !this.isLoaded()) ? 'plus' : (this.hasChildren() ? (this.isOpen() ? 'minus' : 'plus') : 'none');
    },
   
    toggle: function(state) {
        if(this.state.open==state || this.$loading || this.$toggling) return;
        if(this.loadable && !this.state.loaded) {
            this.addEvent('load',function(){
                this.toggle();
            }.bind(this));
            this.load();
            return;
        }
        if(!this.hasChildren()) return;
        var next=this.getNextVisible();
        this.state.open = !this.state.open;
        var state=this.state.open;
        if(!this.$draw) Mif.Tree.Draw.children(this);
        var children=this.getDOM('children');   
        var gadjet=this.getDOM('gadjet');
        var icon=this.getDOM('icon');
        children.style.display=this.isOpen() ? 'block' : 'none';
        gadjet.className='mif-tree-gadjet mif-tree-gadjet-'+this.getGadjetType();
        icon.className='mif-tree-icon '+this[this.isOpen() ? 'openIcon' : 'closeIcon'];
        this.tree.hoverState.gadjet=false;
        this.tree.hover();
        this.tree.$getIndex();
        this.tree.fireEvent('toggle', [this, this.state.open]);
    },
   
    recursive: function(fn, args){
        args=$splat(args);
        if(fn.apply(this, args)!==false){
            this.children.each(function(node){
                if(node.recursive(fn, args)===false){
                    return false;
                };
            });
        }
        return this;
    },
   
    isOpen: function(){
        return this.state.open;
    },
   
    isLoaded: function(){
        return this.state.loaded;
    },
   
    isLast: function(){
        if(this.parentNode==null || this.parentNode.children.getLast()==this) return true;
        return false;
    },
   
    isFirst: function(){
        if(this.parentNode==null || this.parentNode.children[0]==this) return true;
        return false;
    },
   
    isRoot: function(){
        return this.parentNode==null ? true : false;
    },
   
    getChildren: function(){
        return this.children;
    },
   
    hasChildren: function(){
        return this.children.length ? true : false;
    },
   
    index: function(){
        if( this.isRoot() ) return 0;
        return this.parentNode.children.indexOf(this);
    },
   
    getNext: function(){
        if(this.isLast()) return null;
        return this.parentNode.children[this.index()+1];
    },
   
    getPrevious: function(){
        if( this.isFirst() ) return null;
        return this.parentNode.children[this.index()-1];
    },
   
    getFirst: function(){
        if(!this.hasChildren()) return null;
        return this.children[0];
    },
   
    getLast: function(){
        if(!this.hasChildren()) return null;
        return this.children.getLast();       
    },
   
    getParent: function(){
        return this.parentNode;
    },
   
    getNextVisible: function(){
        var current=this;
        if(current.isRoot()){
            if(!current.isOpen() || !current.hasChildren()) return false;
            return current.getFirst();
        }else{
            if(current.isOpen() && current.getFirst()){
                return current.getFirst();
            }else{
                var parent=current;
                do{
                    current=parent.getNext();
                    if(current) return current;
                }while( parent=parent.parentNode )
                return false;
            }
        }
    },
   
    getPreviousVisible: function(){
        var current=this;
        if( current.isFirst() && ( !current.parentNode || (current.tree.forest && current.parentNode.isRoot()) ) ){
            return false;
        }else{
            if( current.getPrevious() ){
                current=current.getPrevious();
                while( current.isOpen() && current.getLast() ){
                    current=current.getLast();
                }
                return current;
            }else{
                return current.parentNode;
            }
        }
    },
   
    getVisiblePosition: function(){
        return this.tree.$index.indexOf(this);
    },
       
    contains: function(node){
        do{
            if(node==this) return true;
            node=node.parentNode;
        }while(node);
        return false;
    },

    addType: function(type){
        this.type.include(type);
        this.$calculate();
        Mif.Tree.Draw.update(this);
        return this;
    },

    removeType: function(type){
        this.type.erase(type);
        this.$calculate();
        Mif.Tree.Draw.update(this);
        return this;
    },
   
    set: function(props){
        this.tree.fireEvent('beforeSet', [this]);
        $extend(this, props);
        if(props.property||props.type||props.state){
            this.$calculate();
            Mif.Tree.Draw.update(this);
        }
        this.tree.fireEvent('set', [this, props]);
    },
   
    updateOpenState: function(){
        if(this.state.open){
            this.state.open=false;
            this.toggle();
        }
    }
   
});


/*
Mif.Tree.Draw
*/
Mif.Tree.Draw={

    getHTML: function(node,html){
        var prefix=node.tree.DOMidPrefix;
        if($defined(node.state.checked)){
            if(!node.hasCheckbox) node.state.checked='nochecked';
            var checkbox='<span class="mif-tree-checkbox mif-tree-node-'+node.state.checked+'" uid="'+node.UID+'">'+Mif.Tree.Draw.zeroSpace+'</span>';
        }else{
            var checkbox='';
        }
        html=html||[];
        html.push(
        '<div class="mif-tree-node ',(node.isLast() ? 'mif-tree-node-last' : ''),'" id="',prefix,node.UID,'">',
            '<span class="mif-tree-node-wrapper ',node.cls,'" uid="',node.UID,'">',
                '<span class="mif-tree-gadjet mif-tree-gadjet-',node.getGadjetType(),'" uid="',node.UID,'">',Mif.Tree.Draw.zeroSpace,'</span>',
                checkbox,
                '<span class="mif-tree-icon ',node.closeIcon,'" uid="',node.UID,'">',Mif.Tree.Draw.zeroSpace,'</span>',
                '<span class="mif-tree-name" uid="',node.UID,'">',node.name,'</span>',
            '</span>',
            '<div class="mif-tree-children" style="display:none"></div>',
        '</div>'
        );
        return html;
    },
   
    children: function(parent, container){
        parent.open=true;
        parent.$draw=true;
        var html=[];
        var children=parent.children;
        for(var i=0,l=children.length;i<l;i++){
            this.getHTML(children[i],html);
        }
        container=container || parent.getDOM('children');
        container.set('html', html.join(''));
        parent.tree.fireEvent('drawChildren',[parent]);
    },
   
    root: function(tree){
        var domRoot=this.node(tree.root);
        domRoot.injectInside(tree.wrapper);
        tree.fireEvent('drawRoot');
    },
   
    forestRoot: function(tree){
        var container=new Element('div').addClass('mif-tree-children-root').injectInside(tree.wrapper);
        Mif.Tree.Draw.children(tree.root, container);
    },
   
    node: function(node){
        return new Element('div').set('html', this.getHTML(node).join('')).getFirst();
    },
   
    update: function(node){
        if(!node) return;
        if(node.tree.forest && node.isRoot()) return;
        if(!node.hasChildren()) node.state.open=false;
        node.getDOM('name').set('html', node.name);
        node.getDOM('gadjet').className='mif-tree-gadjet mif-tree-gadjet-'+node.getGadjetType();
        node.getDOM('icon').className='mif-tree-icon '+node[node.isOpen() ? 'openIcon' : 'closeIcon'];
        node.getDOM('node')[(node.isLast() ?'add' : 'remove')+'Class']('mif-tree-node-last');
        if(node.$loading) return;
        var children=node.getDOM('children');
        children.className='mif-tree-children';
        if(node.isOpen()){
            if(!node.$draw) Mif.Tree.Draw.children(node);
            children.style.display='block';
        }else{
            children.style.display='none';
        }
        node.tree.fireEvent('updateNode', node);
        return node;
    },
   
    updateDOM: function(node, domNode){
        domNode= domNode||node.getDOM('node');
        var previous=node.getPrevious();
        if(previous){
            domNode.injectAfter(previous.getDOM('node'));
        }else{
            if(node.tree.forest && node.parentNode.isRoot()){
                var children=node.tree.wrapper.getElement('.mif-tree-children-root');
            }else{
                var children=node.parentNode.getDOM('children');
            }
            domNode.injectTop(children);
        }
    }
   
};
Mif.Tree.Draw.zeroSpace=Browser.Engine.trident ? '

Thumbs up Thumbs down

Re: Script after Dean Edwards packer causes error

fixed rev24

Re: Script after Dean Edwards packer causes error

It's still not updated in the Builder, can you please update?
Thanks.

Thumbs up Thumbs down

Re: Script after Dean Edwards packer causes error

updated