~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/browser/browser.js

  • Committer: wagrant
  • Date: 2008-07-14 05:07:51 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:863
browser: Let set_action_state take an Array of names as well. We now
         utilise this feature for similar actions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
475
475
    div.appendChild(par2);
476
476
}
477
477
 
478
 
/* Enable or disable an actions1 moreactions action. */
479
 
function set_action_state(name, which)
 
478
/* Enable or disable actions1 moreactions actions. Takes either a single
 
479
 * name, or an array of them.*/
 
480
function set_action_state(names, which)
480
481
{
481
 
    element = document.getElementById('act_' + name);
482
 
    if (which)
483
 
    {
484
 
        /* Enabling */
485
 
        element.setAttribute("class", "choice");
486
 
        element.removeAttribute("disabled");
487
 
    }
488
 
    else
489
 
    {
490
 
        /* Disabling */
491
 
        element.setAttribute("class", "disabled");
492
 
        element.setAttribute("disabled", "disabled");
 
482
    if (!(names instanceof Array)) names = Array(names);
 
483
 
 
484
    for (var i=0; i < names.length; i++)
 
485
    {
 
486
        element = document.getElementById('act_' + names[i]);
 
487
        if (which)
 
488
        {
 
489
            /* Enabling */
 
490
            element.setAttribute("class", "choice");
 
491
            element.removeAttribute("disabled");
 
492
        }
 
493
        else
 
494
        {
 
495
            /* Disabling */
 
496
            element.setAttribute("class", "disabled");
 
497
            element.setAttribute("disabled", "disabled");
 
498
        }
493
499
    }
494
500
}
495
501
 
653
659
            publish.textContent = "Publish";
654
660
        }
655
661
    }
656
 
    set_action_state("publish", pubcond);
657
 
    set_action_state("submit", pubcond);
 
662
    set_action_state(["publish", "submit"], pubcond);
658
663
 
659
664
    /* Share */
660
665
    /* If exactly 1 non-directory file is selected, and its parent
669
674
 
670
675
    /* Delete, cut, copy */
671
676
    /* If >= 1 file is selected */
672
 
    set_action_state("delete", numsel >= 1);
673
 
    set_action_state("cut", numsel >= 1);
674
 
    set_action_state("copy", numsel >= 1);
 
677
    set_action_state(["delete", "cut", "copy"], numsel >= 1);
675
678
 
676
679
    /* Paste, new file, new directory, upload */
677
680
    /* Disable if the current file is not a directory */
678
 
    set_action_state("paste", current_file.isdir);
679
 
    set_action_state("newfile", current_file.isdir);
680
 
    set_action_state("mkdir", current_file.isdir);
681
 
    set_action_state("upload", current_file.isdir);
 
681
    set_action_state(["paste", "newfile", "mkdir", "upload"], current_file.isdir);
682
682
 
683
683
    /* Subversion actions */
684
 
    var svndiff = document.getElementById("act_svndiff");
685
 
    var svnlog = document.getElementById("act_svnlog");
686
684
    /* These are only useful if we are in a versioned directory and have some
687
685
     * files selected. */
688
 
    set_action_state("svnadd", numsel >= 1 && current_file.svnstatus);
689
 
    set_action_state("svnrevert", numsel >= 1 && current_file.svnstatus);
690
 
    set_action_state("svncommit", numsel >= 1 && current_file.svnstatus);
 
686
    set_action_state(["svnadd", "svnrevert", "svncommit"], numsel >= 1 && current_file.svnstatus);
691
687
 
692
688
    /* Diff and log only support one path at the moment. */
693
689
    single_versioned_path = (numsel == 1 &&