;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*- ;;; $Header: dojo/tests/djprogressbar-test.lisp $ ;;; Copyright (c) 2008, Andrea Chiumenti. All rights reserved. ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package :claw-dojo-tests) (defclass djmenu-page (page) ((top-left :initform "top-left" :accessor top-left) (top-right :initform "top-right" :accessor top-right) (bottom-left :initform "bottom-left" :accessor bottom-left) (bottom-right :initform "bottom-right" :accessor bottom-right) (text-area :initform "Hello there" :accessor text-area) (select-value :initform "1" :accessor select-value))) (defclass djmenu-page-menu (wcomponent) () (:metaclass metacomponent) (:default-initargs :empty t)) (defmethod wcomponent-template ((obj djmenu-page-menu)) (let ((id (htcomponent-client-id obj))) (djmenu> :static-id id (wcomponent-informal-parameters obj) (djmenu-item> :id "mi" :onClick "alert\('Hello world');" "Enabled Item") (djmenu-item> :id "mi" :disabled "true" "Disabled Item") (djmenu-separator> :id "ms") (djmenu-item> :id "mi" :icon-class "dijitEditorIcon dijitEditorIconCut" :on-click "alert\('not actually cutting anything, just a test!')" "Cut") (djmenu-item> :id "mi" :icon-class "dijitEditorIcon dijitEditorIconCopy" :on-click "alert\('not actually copying anything, just a test!')" "Copy") (djmenu-item> :id "mi" :icon-class "dijitEditorIcon dijitEditorIconPaste" :on-click "alert\('not actually pasting anything, just a test!')" "Paste") (djmenu-separator> :id "ms") (djpopup-menu-item> :id "mpi" (span> "Enabled Submenu") (djmenu> :id "submenu2" (djmenu-item> :id "mi" :on-click "alert\('Submenu 1!')" "Submenu Item One") (djmenu-item> :id "mi" :on-click "alert\('Submenu 2!')" "Submenu Item Two") (djpopup-menu-item> :id "pmi" (span> "Deeper Submenu") (djmenu> :id "submenu4" (djmenu-item> :id "mi" :on-click "alert\('Sub-submenu 1!')" "Sub-sub-menu Item One") (djmenu-item> :id "mi" :on-click "alert\('Sub-submenu 2!')" "Sub-sub-menu Item Two"))))) (djpopup-menu-item> :id "pmi" :disabled "true" (span> "Disabled Submenu") (djmenu> :id "submenu3" :style "display: none;" (djmenu-item> :id "mi" :on-click "alert\('Submenu 1!')" "Submenu Item One") (djmenu-item> :id "mi" :on-click "alert\('Submenu 2!')" "Submenu Item Two"))) (djpopup-menu-item> :id "pmi" (span> "Different popup") (djcolor-palette> :id "cp"))))) (defmethod page-content ((o djmenu-page)) (let ((input2-id (generate-id "input2"))) (site-template> :title "dojo menu test page" (script> :language "Javascript" :type "text/javascript" "function createMenu\() { // create a menu programmatically function fClick\() {alert\('clicked!')}; pMenu = new dijit.Menu\({targetNodeIds:['prog_menu'], id:'progMenu'}); pMenu.addChild\(new dijit.MenuItem\({label:'Programmatic Context Menu', disabled:true})); pMenu.addChild\(new dijit.MenuSeparator\()); pMenu.addChild\(new dijit.MenuItem\({label:'Simple menu item', onClick:fClick})); pMenu.addChild\(new dijit.MenuItem\({label:'Another menu item', onClick:fClick})); pMenu.addChild\(new dijit.MenuItem\({label:'With an icon', iconClass:'dijitEditorIcon dijitEditorIconCut', onClick:fClick})); var mItem = new dijit.MenuItem\({label:'dojo.event clicking'}); dojo.connect\(mItem, 'onClick', function\(){alert\('click! handler created via dojo.connect\()')}); pMenu.addChild\(mItem); var pSubMenu = new dijit.Menu\({parentMenu:pMenu, id:'progSubMenu'}); pSubMenu.addChild\(new dijit.MenuItem\({label:'Submenu item', onClick:fClick})); pSubMenu.addChild\(new dijit.MenuItem\({label:'Submenu item', onClick:fClick})); pMenu.addChild\(new dijit.PopupMenuItem\({label:'Submenu', popup:pSubMenu, id:'progPopupMenuItem'})); pMenu.startup\(); dojo.byId\('prog_menu').innerHTML=\"This div has a programmatic context menu on it that's different to the page menu.\"; dojo.byId\('createButton').disabled = true; dojo.byId\('destroyButton').disabled = false; } function destroyMenu\(){ pMenu.destroyRecursive\(); dojo.byId\('prog_menu').innerHTML='No programmatic menu on this div, should get page level menu.'; dojo.byId\('createButton').disabled = false; dojo.byId\('destroyButton').disabled = true; }") (djmenu-page-menu> :id "submenu1" :context-menu-for-window "true" :style "display: none;") (djmenu-page-menu> :id "leftClick" :left-click-to-open "true" :target-node-ids input2-id :style "display: none;") (div> :style "padding: 1em" (h1> :class "testTitle" "Dijit Menu System Test") (h3> "Form") (cform> :id "theForm" (cinput> :id "input1" :accessor 'top-left) (p> :style "text-align:right" "left click to open the menu for this input:" (br>) "Note: because of the window contextMenu, make sure you get" (br>) "the right menu by verifying the left" (br>) "click one starts with \"Left Click Menu\"" (br>) "at the very top." (cinput> :static-id input2-id :accessor 'top-right)) (ctextarea> :id "textarea" :accessor 'text-area) (br>) (cselect> :id "select" :accessor 'select-value (option> :value "1" (when (string= "1" (select-value o)) (list :selected "selected")) "check if i") (option> :value "2" (when (string= "2" (select-value o)) (list :selected "selected")) "bleed through") (option> :value "3" (when (string= "3" (select-value o)) (list :selected "selected")) "on IE6")) (button> :id "button" "push me")) (div> :id "prog_menu" :style "border:1px solid blue; padding:10px; margin:20px 0;" "Click button below to create special menu on this div.") (button> :id "createButton" :onclick "createMenu\();" "create programmatic menu") (button> :id "destroyButton" :onclick "destroyMenu\();" :disabled "disabled" "destroy programmatic menu") (div> :style "height:500px") (p> "\(this space intentionally left blank to aid testing with controls at the bottom of the browser window)") (div> :style "height:500px") (cform> :id "theForm" (cinput> :id "input3" :accessor 'bottom-left) (p> :style "text-align:right" (cinput> :id "input4" :accessor 'bottom-right)) (p> "See also: " (a> :href "djbutton.html" "test Button") "\(PopupMenu is used with DropDownButton and ComboButton)") (h3> "Mouse opening tests") (ul> (li> "Right click on the client area of the page \(ctrl-click for Macintosh). Menu should open.") (li> "Right click on each of the form controls above. Menu should open.") (li> "Right click near the righthand window border. Menu should open to the left of the pointer.") (li> "Right click near the bottom window border. Menu should open above the pointer.")) (h3> "Mouse hover tests") (ul> (li> "Hover over the first item with the pointer. Item should highlight and get focus.") (li> "Hover over the second \(disabled) item. Item should highlight and get focus.") (li> "Seperator items should not highlight on hover - no items should highlight in this case.")) (h3> "Mouse click tests") (ul> (li> "Click on the first menu item. Alert should open with the message \"Hello world\". The menu should dissapear.") (li> "Click on the second menu item \(disabled). Should not do anything - focus should remain on the disabled item.") (li> "Click anywhere outside the menu. Menu should close. Focus will be set by the browser based on where the user clicks.")) (h3> "Mouse submenu tests") (ul> (li> "Hover over the \"Enabled Submenu\" item. Item should highlight and then pop open a submenu after a short \(500ms) delay.") (li> "Hover over any of the other menu items. Submenu should close immediately and deselect the submenu parent item. The newly hovered item should become selected.") (li> "Hover over the \"Disabled Submenu\" item. Item should highlight, but no submenu should appear.") (li> "Clicking on the \"Enabled Submenu\" item before the submenu has opened \(you'll have to be quick!) should immediatley open the submenu.") (li> "Clicking on the \"Enabled Submenu\" item " (i> "after") " the submenu has opened should have no effect - the item is still selected and the submenu still open.") (li> "Hover over submenu item 1. Should select it - the parent menu item should stay selected also.") (li> "Hover over submenu item 2. Should select it - the parent menu item should stay selected also.")) (h3> "Keyboard opening tests") (ul> (li> "On Windows: press shift-f10 with focus on any of the form controls. Should open the menu.") (li> "On Windows: press the context menu key \(located on the right of the space bar on North American keyboards) with focus on any of the form controls. Should open the menu.") (li> "On Firefox on the Mac: press ctrl-space with focus on any of the form controls. Should open the menu.")) (h3> "Keyboard closing tests") (ul> (li> "Open the menu.") (li> "Press tab. Should close the menu and return focus to where it was before the menu was opened.") (li> "Open the menu.") (li> "Press escape. Should close the menu and return focus to where it was before the menu was opened.")) (h3> "Keyboard navigation tests") (ul> (li> "Open the menu.") (li> "Pressing up or down arrow should cycle focus through the items in that menu.") (li> "Pressing enter or space should invoke the menu item.") (li> "Disabled items receive focus but no action is taken upon pressing enter or space.")) (h3> "Keyboard submenu tests") (ul> (li> "Open the menu.") (li> "The first item should become selected.") (li> "Press the right arrow key. Nothing should happen.") (li> "Press the left arrow key. Nothing should happen.") (li> "Press the down arrow until \"Enabled Submenu\" is selected. The submenu should not appear.") (li> "Press enter. The submenu should appear with the first item selected.") (li> "Press escape. The submenu should vanish - \"Enabled Submenu\" should remain selected.") (li> "Press the right arrow key. The submenu should appear with the first item selected.") (li> "Press the right arrow key. Nothing should happen.") (li> "Press the left arrow key. The submenu should close - \"Enabled Submenu\" should remain selected.") (li> "Press the left arrow key. The menu should " (i> "not") " close and \"Enabled Submenu\" should remain selected.") (li> "Press escape. The menu should close and focus should be returned to where it was before the menu was opened."))))))) (lisplet-register-page-location *dojo-test-lisplet* 'djmenu-page "djmenu.html")