;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*- ;;; $Header: dojo/tests/slider-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) (defgeneric slide-page-null-action (slider-page)) (defclass slider-page (page) ((hval :initform 10 :accessor slider-page-hval) (vval :initform 50 :accessor slider-page-vval) (message-content :initform "" :accessor slider-page-message-content))) (defmethod slide-page-null-action ((slider-page slider-page)) (setf (slider-page-message-content slider-page) (div> :style "border: 1px solid gray;" (format nil "Sent djhorizontal-slider value: ~a" (slider-page-hval slider-page)) (br>) (format nil "Sent djvertical-slider value: ~a" (slider-page-vval slider-page))))) (defmethod page-content ((pobj slider-page)) (let ((hs-content-id (generate-id "content")) (vs-content-id (generate-id "content"))) (site-template> :title "dojo slider test page" (h1> :class "testTitle" "Slider") "Also try using the arrow keys, buttons, or clicking on the progress bar to move the slider." (br>) (cform> :id "djform" :action 'slide-page-null-action (br>) "initial value=10, min=0, max=100, pageIncrement=100, onChange event triggers span innerHTML change immediately" (br>) (djhorizontal-slider> :id "slider1" :onChange (parenscript:ps* `(setf (slot-value (dojo.by-id ,hs-content-id) 'inner-H-T-M-L) (dojo.number.format (/ (aref arguments 0) 100) (create :places 1 :pattern "#%")))) :accessor 'slider-page-hval :maximum 100 :minimum 0 :page-increment 100 :show-buttons "false" :intermediate-changes "true" :style "width:50%; height: 20px;" (djhorizontal-rule-labels> :container "topDecoration" :style "height:1.2em;font-size:75%;color:gray;" :count 6 :numeric-margin 1) (djhorizontal-rule> :container "topDecoration" :style "height:5px;" :count 6) (djhorizontal-rule> :container "bottomDecoration" :style "height:5px;" :count 5) (djhorizontal-rule-labels> :container "bottomDecoration" :style "height:1em;font-size:75%;color:gray;" (li> "lowest") (li> "normal") (li> "highest"))) (p> (span> :style="font-weight: bolder;" "djhorizontal-slider current value:")(span> :static-id hs-content-id "--")) (br>) "initial value=10, min=0, max=100, pageIncrement=100, onChange event triggers span innerHTML change immediately" (br>) (djvertical-slider> :id "slider2" :onChange (parenscript:ps* `(setf (slot-value (dojo.by-id ,vs-content-id) 'inner-H-T-M-L) (dojo.number.format (/ (aref arguments 0) 100) (create :places 1 :pattern "#%")))) :accessor 'slider-page-vval :maximum 100 :minimum 0 :page-increment 100 :discrete-values 11 :style "height: 300px;" (djvertical-rule-labels> :container "leftDecoration" :style "width:2em;color:gray;" (li> "0") (li> "100")) (djvertical-rule> :container "leftDecoration" :style "width:5px;" :count 11 :rule-style "border-color:gray;") (djvertical-rule> :container "rightDecoration" :style "width:5px;" :count 11 :rule-style "border-color:gray;") (djvertical-rule-labels> :container "rightDecoration" :style "width:2em;color:gray;" :count 6 :numeric-margin 1 :maximum 100 :constraints "{pattern:'#'}")) (p> (span> :style="font-weight: bolder;" "djvertical-slider current value:")(span> :static-id vs-content-id "--")) (djsubmit-button> :id "submit" :value "Submit")) (slider-page-message-content pobj)))) (lisplet-register-page-location *dojo-test-lisplet* 'slider-page "slider.html")