;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*- ;;; $Header: dojo/tests/djeditor-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 djeditor-page (page) ((text1 :initarg :text1 :accessor djeditor-page-text1) (text2 :initarg :text2 :accessor djeditor-page-text2) (text3 :initarg :text3 :accessor djeditor-page-text3) (text4 :initarg :text4 :accessor djeditor-page-text4)) (:default-initargs :text1 "" :text2 "" :text3 "" :text4 "")) (defclass editor-dialog (djdialog) () (:metaclass metacomponent)) (defmethod htcomponent-instance-initscript ((editor-dialog editor-dialog)) (parenscript:ps* `(.show (dijit.by-id ,(htcomponent-client-id editor-dialog))))) (defclass result-text (wcomponent) ((dialog-content :initarg :dialog-content :accessor dialog-content) (style :initarg :style :reader style)) (:metaclass metacomponent) (:default-initargs :style "display:inline;line-height:normal;vertical-align:middle;padding:0pt 0.3em;")) (defmethod wcomponent-template ((obj result-text)) (let* ((dialog-id (generate-id "resultDialog")) (dialog-content (dialog-content obj)) (render-content-function #'(lambda () (progn (hunchentoot:log-message :info "~a::------->~a" (htcomponent-client-id obj) dialog-content) (and dialog-content (string-not-equal dialog-content "")))))) (div> :static-id (htcomponent-client-id obj) :style (style obj) (wcomponent-informal-parameters obj) (htcomponent-body obj) (djbutton> :id "showDialog" :render-condition render-content-function :onclick (format nil "dijit.byId('~a').show()" dialog-id) "show text") (editor-dialog> :render-condition render-content-function :static-id dialog-id (div> :style "height:370px;width: 800px;overflow:auto;border: 1px solid gray;padding: 0 .5em;" ($raw> dialog-content)) (div> :style "text-align:center;margin-top: 1em;" (djbutton> :id "close" :onclick (format nil "dijit.byId('~a').hide()" dialog-id) (span> "Close"))))))) (defmethod page-content ((o djeditor-page)) (let ((result-text1 (generate-id "resultText")) (result-text2 (generate-id "resultText")) (result-text3 (generate-id "resultText")) (result-text4 (generate-id "resultText")) (text1 (djeditor-page-text1 o)) (text2 (djeditor-page-text2 o)) (text3 (djeditor-page-text3 o)) (text4 (djeditor-page-text4 o))) (site-template> :title "dojo editor test page" (djeditor-plugins-always-show-toolbar>) (djeditor-plugins-enter-key-handling>) (djeditor-plugins-font-choice>) (djeditor-plugins-link-dialog>) (djeditor-plugins-text-color>) (djeditor-plugins-toggle-dir>) (djform> :id "theForm" :ajax-form-p nil :update-id (list result-text1) (p> (djeditor> :id "editor" :tag-name "div" :accessor 'djeditor-page-text1)) (result-text> :static-id result-text1 :dialog-content text1 (djsubmit-button> :id "submitData" :value "Submit on normal form"))) (djform> :id "theForm" :update-id (list result-text2) (p> (djeditor> :id "editor" :extraPlugins "['dijit._editor.plugins.AlwaysShowToolbar']" :accessor 'djeditor-page-text2)) (result-text> :static-id result-text2 :dialog-content text2 (djsubmit-button> :id "submitData" :value "Submit on claw.Form"))) (djform> :id "theForm" :update-id (list result-text3) (p> (djeditor> :id "editor" :plugins "['bold','italic','|','createLink','foreColor','hiliteColor',{name:'dijit._editor.plugins.FontChoice', command:'fontName', generic:true},'fontSize','formatBlock','insertImage']" :accessor 'djeditor-page-text3)) (result-text> :static-id result-text3 :dialog-content text3 (csubmit> :id "submitData" :value "Standard submit"))) (djform> :id "theForm" :update-id (list result-text4) (p> (djeditor> :id "editor" :plugins "['bold','italic','|',{name:'dijit._editor.plugins.EnterKeyHandling'},{name:'dijit._editor.plugins.FontChoice', command:'fontName', custom:['Verdana','Myriad','Garamond','Apple Chancery','Hiragino Mincho Pro']}, {name:'dijit._editor.plugins.FontChoice', command:'fontSize', custom:[3,4,5]}]" :accessor 'djeditor-page-text4)) (result-text> :static-id result-text4 :dialog-content text4 (djsubmit-button> :id "submitData" :value "Submit")))))) (lisplet-register-page-location *dojo-test-lisplet* 'djeditor-page "djeditor.html")