/* * ***** BEGIN LICENSE BLOCK ***** * Version: ZAPL 1.1 * * The contents of this file are subject to the Zimbra AJAX Public * License Version 1.1 ("License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.zimbra.com/license * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is: Zimbra AJAX Toolkit. * * The Initial Developer of the Original Code is Zimbra, Inc. * Portions created by Zimbra are Copyright (C) 2005 Zimbra, Inc. * All Rights Reserved. * * Contributor(s): * * ***** END LICENSE BLOCK ***** */ /** * @class * This static class allows you to draw "interesting" borders * (eg: borders that are composed of multiple images) * * Note that images for the border are used in the same style as AjxImage. * * * TODO: get the borders working with the AjxImg scheme to do hires/lores images. * * @author Owen Williams */ // // DwtBorder.js // // Class that allows you to draw "interesting" borders // (eg: borders that are composed of multiple images) // // Note: you'll use this class statically, like AjxImage // function DwtBorder() { } DwtBorder._borderTemplates = {}; DwtBorder.getBorderTemplate = function(style) { return this._borderTemplates[style]; } DwtBorder.getBorderHtml = function (style, substitutions, innerDivId) { return AjxBuffer.append( this.getBorderStartHtml(style, substitutions), (innerDivId ? "
" : ""), this.getBorderEndHtml(style, substitutions) ); } DwtBorder.getBorderStartHtml = function(style, substitutions) { var template = this._borderTemplates[style]; if (template == null) { DBG.println("DwtBorder.getBorderStartHtml(",style,"): no border template found."); return ""; } if (template == null) return ""; var html = template.start; if (substitutions != null) { html = DwtBorder.performSubstitutions(html, substitutions); } return html; } DwtBorder.getBorderEndHtml = function(style, substitutions) { var template = this._borderTemplates[style]; if (template == null || template == "") return ""; var html = template.end; if (substitutions != null) { html = DwtBorder.performSubstitutions(html, substitutions); } return html; } DwtBorder.getBorderHeight = function(style) { var template = this._borderTemplates[style]; if (template != null) return template.height; return 0; } DwtBorder.getBorderWidth = function(style) { var template = this._borderTemplates[style]; if (template != null) return template.width; return 0; } DwtBorder.performSubstitutions = function (html, substitutions) { for (var prop in substitutions) { var str = ""; if (html.indexOf(str)) { html = html.split(str).join(substitutions[prop]); } //MOW: Why is this here? This will make substitution twice as slow... do we need it? var str = "{$"+prop+"}"; if (html.indexOf(str)) { html = html.split(str).join(substitutions[prop]); } } return html; } DwtBorder.registerBorder = function (style, template) { this._borderTemplates[style] = template } DwtBorder.registerBorder( "1pxBlack", { start:"
", end:"
", width:2, height:2 } ); DwtBorder.registerBorder( "card", { start:""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ "
"+ "
", end: "
"+ "
", width:20, height:20 } ); DwtBorder.registerBorder( "selected_card", { start:""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ "
"+ "
", end: "
"+ "
", width:19, height:18 } ); var dialogPieces = { start:AjxBuffer.concat( "", // top edge "", "", "", "", "", // titlebar "", "", "", "", "" ), topNoToolbar: AjxBuffer.concat( // top inside edge "", "", "", "", "", "", "", // dialog center "", "", "", "", "", "", "", "", "", // top toolbar "", "", "", "", "", "", "", "", "", "", "", "", "", "", // dialog center "", "", " ", "", "", "", "", // bottom inside edge "", "", "", "", "", "", "" ), bottomWithToolbar: AjxBuffer.concat( "", "", "", "", "", // bottom toolbar "", "", "", "", "", "", "", "", "", "", "", "", "", "", // bottom inside edge "", "", "", "", "", "", "" ), end: AjxBuffer.concat( // bottom edge "", "", "", "", "", // bottom shadow "", "", "", "
", "
", "
", "", "", "", "", "", "
" ), topWithToolbar: AjxBuffer.concat( // top inside edge "
" ), bottomNoToolbar: AjxBuffer.concat( "
", "
", "
", "
", "
" ) } DwtBorder.registerBorder( "dialog", { start: dialogPieces.start + dialogPieces.topNoToolbar, end: dialogPieces.bottomNoToolbar + dialogPieces.end, width:40, height:45 } ); DwtBorder.registerBorder( "dialogWithTopToolbar", { start: dialogPieces.start + dialogPieces.topWithToolbar, end: dialogPieces.bottomNoToolbar + dialogPieces.end, width:40, height:45 } ); DwtBorder.registerBorder( "dialogWithBottomToolbar", { start: dialogPieces.start + dialogPieces.topNoToolbar, end: dialogPieces.bottomWithToolbar + dialogPieces.end, width:40, height:45 } ); DwtBorder.registerBorder( "dialogWithBothToolbars", { start: dialogPieces.start + dialogPieces.topWithToolbar, end: dialogPieces.bottomWithToolbar + dialogPieces.end, width:40, height:45 } ); DwtBorder.registerBorder( "h_sash", { start: AjxBuffer.concat( "", "", "", "", "", "", "
" ), end:"", width:10, //NOT ACCURATE height:7 } ); DwtBorder.registerBorder( "calendar_appt", { start:AjxBuffer.concat( "
", "", "_header>", "", "", // "", "", "", "", "", "", "", "
style='text-align:right'>_tag>
_name style='height:100%'>", "", "
", "", "
", // "
", "
" ), end: "", width:10, //NOT ACCURATE height:7 } ); DwtBorder.registerBorder( "calendar_appt_bottom_only", { start:AjxBuffer.concat( "
", "", "", "", "", "", "", "
_name style='height:100%'>", "", "
", "", "
", "
" ), end: "", width:10, //NOT ACCURATE height:7 } ); DwtBorder.registerBorder( "calendar_appt_30", { start:AjxBuffer.concat( "
", "", "", "", // "", "", "
_name>_tag>
", "
" ), end: "", width:4, height:4 } ); DwtBorder.registerBorder( "hover", { start: AjxBuffer.concat( "
", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "
" ), end: AjxBuffer.concat( "
", "
" ) } ); DwtBorder.registerBorder( "hover_IE", { start: AjxBuffer.concat( "
", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "
" ), end: AjxBuffer.concat( "
", "
" ) } );