Changes between Version 7 and Version 8 of Development/PlugIns/JavaScript


Ignore:
Timestamp:
Dec 17, 2006 1:07:04 AM (13 years ago)
Author:
timothy
Comment:

New example script on how to add toolbar items.

Legend:

Unmodified
Added
Removed
Modified
  • Development/PlugIns/JavaScript

    v7 v8  
    3434                view.echoSentMessageToDisplay(msg); 
    3535        } 
     36} 
     37}}} 
     38 
     39= Example Plugin: Digg Toolbar Item = 
     40 
     41The following example will allow you to add a Digg toolbar icon to a chat room or direct chat. '''Note: this script requires build [changeset:3466 3466] or later.''' 
     42 
     43{{{ 
     44#!text/x-javascript 
     45// return an array of toolbar item identifier strings that can be associated with 'view' 
     46function toolbarItemIdentifiers( view ) { 
     47        return ['diggBookmarkItem']; 
     48} 
     49 
     50// return a NSToolbarItem for 'identifier' associated with 'view' 
     51function toolbarItem( identifier, view, willBeInserted ) { 
     52        if( identifier == 'diggBookmarkItem' ) { 
     53                var item = new NSToolbarItem(identifier); 
     54                item.setImage(new NSImage(new NSURL('http://www.digg.com/img/little-digg.gif'))); 
     55                item.setLabel('Digg'); 
     56                item.setPaletteLabel('Digg Bookmark'); 
     57                return item; 
     58        } 
     59} 
     60 
     61// perform the action associated with 'toolbarItem' for 'view' 
     62function handleClickedToolbarItem( toolbarItem, view ) { 
     63        window.location.href = 'http://www.digg.com'; 
    3664} 
    3765}}}