/* Copyright (c) 2006-2007, ePages GmbH All Rights Reserved. epages.cartridges.de_epages.design.widget.Toolbuttonimages $Revision: 1.15 $ */ dojo.provide("epages.cartridges.de_epages.design.widget.Toolbuttonimageright"); dojo.require("epages.widget.LocalizedWidget"); dojo.require("epages.lang.hitch"); dojo.require('epages.event'); epages.require('ep_shop_upload', 'epages.uploader'); dojo.require('epages.widget.Tooltip'); dojo.declare( "epages.cartridges.de_epages.design.widget.Toolbuttonimageright", [epages.widget.LocalizedWidget], { /** * public properties */ label : "", fileNameRight : "", imageType : "", objectId : epages.vars.ObjectID, /** * widget properties */ widgetType : "Toolbuttonimageright", templatePath : dojo.moduleUrl('epages.cartridges.de_epages.design.widget' , 'templates/Toolbuttonimageright.html'), translationName : dojo.moduleUrl('epages.cartridges.de_epages.design.widget' , 'templates/translation'), imagePath : epages.themeUrl('images'), widgetsInTemplate : true, // override postCreate : function() { // summary: initalize file upload widget and other background image related events this.inherited("postCreate", arguments); // pass callback function to toolMediaGalleryWidget var me=this; this.toolMediaGalleryWidget.onApply = function(pathFromSite) { me.setFileName(pathFromSite); }; // init events this._appendEvents(); // init buttons this._showButtons(); }, getFileName: function() { return this.fileNameRightNode.value; }, setFileName: function(pathFromSite){ this.fileNameRightNode.value = pathFromSite; epages.event.fire(this.fileNameRightNode, "change"); }, /** * private methods */ _appendEvents: function() { // summary: append onclick and onchange events to buttons and inputs // add button events this.connect(this.clearImageRightNode, 'onclick', '_clearImageRight'); // add input events (listen to value changes and update display) this.connect(this.fileNameRightNode, 'onchange', '_showButtons'); }, _clearImageRight: function(evt) { // summary: clears the value of left image file name input and throw change event this.fileNameRightNode.value=""; epages.event.fire(this.fileNameRightNode,"change"); }, _showButtons: function() { // summary: decides which button is visible dojo.publish(this.id+'/filenamechanged', [this.getFileName()]); if(this.fileNameRightNode.value!="") { this.clearImageRightNode.style.display=""; // show hide clear button right } else { this.clearImageRightNode.style.display="none"; } } });