public function endRender(__IComponent &$component) { $component_id = $component->getId(); $return_value = $this->_component_writer->endRender($component); $place_after_element = $component->placeAfterElement; if (!empty($place_after_element)) { $jod_response_writer = new __JavascriptOnDemandResponseWriter('place-after-element' . $component_id); $jod_response_writer->addJsCode("var {$component_id} = \$('{$component_id}').remove();\n\n {$component_id}.insert({$place_after_element});\n"); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } $waiting_components = $component->waitingComponents; if (!empty($waiting_components)) { if (__ResponseWriterManager::getInstance()->hasResponseWriter('waiting-components')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('waiting-components'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('waiting-components'); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } $waiting_components_array = preg_split('/,/', $waiting_components); foreach ($waiting_components_array as $waiting_component_name) { $component_handler = __ComponentHandlerManager::getInstance()->getComponentHandler($component->getViewCode()); $waiting_component = $component_handler->getComponent($waiting_component_name); $waiting_component_id = $waiting_component->getId(); $js_code = <<<CODE (__ProgressBroadcaster.getInstance()).setWaitingDependence("{$waiting_component_id}", "{$component_id}"); CODE; $jod_response_writer->addJsCode($js_code); } } return $return_value; }
public function renderContent($enclosed_content, __IComponent &$component) { $group_id = $component->getGroup(); if ($group_id == null) { $group_id = $component->getId(); } if (__ResponseWriterManager::getInstance()->hasResponseWriter($group_id)) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter($group_id); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter($group_id); $js_files = $component->getJsFiles(); foreach ($js_files as $js_file) { $jod_response_writer->addJsFileRef($js_file); } $checking_variables = $component->getCheckingVariables(); foreach ($checking_variables as $checking_variable) { $jod_response_writer->addLoadCheckingVariable($checking_variable); } $javascript_rw = null; if ($component->hasContainer()) { $container = $component->getContainer(); if ($container instanceof __JavascriptComponent) { $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter($container->getId()); } } if ($javascript_rw == null) { $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); } $javascript_rw->addResponseWriter($jod_response_writer); } $jod_response_writer->setLoadAfterDomLoaded($component->getAfterDomLoaded()); $jod_response_writer->addJsCode($enclosed_content); }
/** * Gets a reference to the singleton {@link __ResponseWriterManager} instance * * @return __ResponseWriterManager */ public static function &getInstance() { if (self::$_instance == null) { self::$_instance = new __ResponseWriterManager(); } return self::$_instance; }
protected function _doGetContent() { if (__FrontController::getInstance()->getRequestType() == REQUEST_TYPE_XMLHTTP || $this == __FrontController::getInstance()->getResponse()) { __ResponseWriterManager::getInstance()->write($this); __ResponseWriterManager::getInstance()->clear(); } $return_value = parent::_doGetContent(); return $return_value; }
public function startRender(__IComponent &$component) { $component_id = $component->getId(); $data = $component->getData(); $data_json_string = json_encode($data); $javascript_code = <<<CODESET {$component_id} = {$data_json_string}; CODESET; $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addJsCode($javascript_code); return ''; }
protected function _renderLibraryDependencies() { if (__ResponseWriterManager::getInstance()->hasResponseWriter('validation')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('validation'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('validation'); $jod_response_writer->addJsFileRef('validation/validation.js'); $jod_response_writer->addLoadCheckingVariable('Validator'); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } }
public function startRender(__IComponent &$component) { $component_id = $component->getId(); $properties = array(); $component_properties = $component->getProperties(); foreach ($component_properties as $property => $value) { $property = strtolower($property); if ($property != 'runat') { $properties[] = $property . '="' . $value . '"'; } } if (!key_exists('TYPE', $component_properties)) { $properties[] = 'type="text"'; } $properties[] = 'id="' . $component_id . '"'; $properties[] = 'name="' . $component->getName() . '"'; $value = $component->getValue(); $example_value = $component->getExampleValue(); if (!empty($value)) { $properties[] = 'value="' . htmlentities($value) . '"'; } else { if (!empty($example_value)) { $properties[] = 'value="' . htmlentities($example_value) . '"'; } } if ($component->getVisible() == false) { $properties[] = 'style = "display : none;"'; } $return_value = '<input ' . implode(' ', $properties) . '>'; if (!empty($example_value)) { if (__ResponseWriterManager::getInstance()->hasResponseWriter('examplevalues')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('examplevalues'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('examplevalues'); $js_code = <<<CODE function hideExampleValue(event){ var formfield = Event.element(event); var exampleValue = (\$A(arguments)).last(); if (formfield.value == exampleValue) { formfield.value = ""; } } CODE; $jod_response_writer->addJsCode($js_code); $jod_response_writer->setLoadAfterDomLoaded(true); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } $js_code = "Event.observe('{$component_id}', 'focus', hideExampleValue.bindAsEventListener(\$({$component_id}), '{$example_value}'));\n"; $jod_response_writer->addJsCode($js_code); } return $return_value; }
public function endRender(__IComponent &$component) { $return_value = $this->_component_writer->endRender($component); $spinner = $component->spinner; if (empty($spinner)) { $spinner = true; //by default } else { $spinner = $this->_toBool($spinner); } if ($spinner) { $component_id = $component->getId(); $spinner_id = $component_id . '_spinner'; $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); //setup spinner if ($component->hasProperty('spinnerTargetComponent')) { $target_component_name = $component->getProperty('spinnerTargetComponent'); $view_code = $component->getViewCode(); $component_handler = __ComponentHandlerManager::getInstance()->getComponentHandler($view_code); if ($component_handler != null && $component_handler->hasComponent($target_component_name)) { $spinner_target = $component_handler->getComponent($target_component_name)->getId(); } else { throw __ExceptionFactory::getInstance()->createException('Target spinner component not found: ' . $target_component_name); } } else { if ($component->hasProperty('spinnerTargetElement')) { $spinner_target = $component->getProperty('spinnerTargetElement'); } else { $spinner_target = $component_id; } } $spinner_target = $javascript_rw->addJsCode($spinner_id . ' = new __Spinner("' . $spinner_target . '");'); //setup waiting message: $waiting_message = $component->waitingMessage; if (!empty($waiting_message)) { $javascript_rw->addJsCode($spinner_id . '.setWaitingMessage("' . nl2br(stripslashes($waiting_message)) . '");'); } //setup progress bar: $show_progress = $this->_toBool($component->showProgress); if ($show_progress) { $js_code = <<<CODE var progressHandler = (__ProgressBroadcaster.getInstance()).getProgressHandler("{$component_id}"); if(typeof(progressHandler) != "undefined") { progressHandler.registerUiProgressIndicator({$spinner_id}); } CODE; $javascript_rw->addJsCode($js_code); } } return $return_value; }
public function dispatch(__IRequest &$request, __IResponse &$response) { $front_controller = self::$_instance; self::$_instance = $this; //now call the parent dispatch method: parent::dispatch($request, $response); //finally restore the previous front controller singleton self::$_instance = $front_controller; //and clear the response writer: __ResponseWriterManager::getInstance()->clear(); __ClientNotificator::getInstance()->clearDirty(); @ob_clean(); //clear the output buffer }
public function startRender(__IComponent &$component) { $properties = array(); $component_id = $component->getId(); $date_format = $component->getDateFormat(); $datebox_button_id = $component_id . '_calbutton'; if (__ResponseWriterManager::getInstance()->hasResponseWriter('datebox')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('datebox'); $jod_setup_response_writer = $jod_response_writer->getResponseWriter('datebox-setup'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('datebox'); $jod_response_writer->addCssFileRef('jscalendar/calendar-green.css'); $jod_response_writer->addJsFileRef('jscalendar/calendar.js'); $jod_response_writer->addLoadCheckingVariable('Calendar'); $jod_language_response_writer = new __JavascriptOnDemandResponseWriter('datebox-language'); $jod_language_response_writer->addJsFileRef('jscalendar/lang/calendar-en.js'); $jod_language_response_writer->addLoadCheckingVariable('Calendar._DN'); $jod_response_writer->addResponseWriter($jod_language_response_writer); $jod_setup_response_writer = new __JavascriptOnDemandResponseWriter('datebox-setup'); $jod_setup_response_writer->addJsFileRef('jscalendar/calendar-setup.js'); $jod_setup_response_writer->addLoadCheckingVariable('Calendar.setup'); $jod_language_response_writer->addResponseWriter($jod_setup_response_writer); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } $js_code = <<<CODESET Calendar.setup({ \tinputField:"{$component_id}", \tifFormat:"{$date_format}", \tbutton:"{$datebox_button_id}", \tshowsTime:false }); CODESET; $jod_setup_response_writer->addJsCode($js_code); $component_properties = $component->getProperties(); foreach ($component_properties as $property => $value) { $properties[] = $property . '="' . $value . '"'; } $properties[] = 'type="text"'; $properties[] = 'id="' . $component->getId() . '"'; $properties[] = 'name="' . $component->getName() . '"'; $properties[] = 'value="' . $component->getValue() . '"'; if ($component->getVisible() == false) { $properties[] = 'style = "display : none;"'; } $local_js_lib = __ApplicationContext::getInstance()->getPropertyContent('JS_LIB_DIR'); $calendar_image_url = __UrlHelper::resolveUrl('jscalendar/calendar.gif', $local_js_lib); $return_value = '<input onchange="this.fire(\'lion:validate\');" ' . implode(' ', $properties) . '> <input type="image" src="' . $calendar_image_url . '" id="' . $datebox_button_id . '" width="16" height="16" border="0">'; return $return_value; }
public function startRender(__IComponent &$component) { $component_id = $component->getId(); $class_name = $component->getClassName(); $window_properties = array(); $window_properties[] = 'width: ' . $component->getWidth(); $window_properties[] = 'height: ' . $component->getHeight(); $window_properties[] = 'className: "' . $class_name . '"'; $window_properties[] = 'destroyOnClose: false'; $window_properties[] = 'recenterAuto: false'; $window_properties[] = 'id: "' . $component->getId() . '"'; if ($component->getTitle() !== null) { $window_properties[] = 'title: "' . $component->getTitle() . '"'; } if (!$component->getShowCloseButton()) { $window_properties[] = 'closable: false'; } if (!$component->getShowMaximizeButton()) { $window_properties[] = 'maximizable: false'; } if (!$component->getShowMinimizeButton()) { $window_properties[] = 'minimizable: false'; } if (__ResponseWriterManager::getInstance()->hasResponseWriter('prototype_window')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('prototype_window'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('prototype_window'); $jod_response_writer->addCssFileRef('prototypewindow/themes/default.css'); if ($class_name != 'dialog') { $jod_response_writer->addCssFileRef('prototypewindow/themes/' . $class_name . '.css'); } $jod_response_writer->addJsFileRef('prototypewindow/javascripts/window.js'); $jod_response_writer->addLoadCheckingVariable('Window'); $jod_response_writer->addLoadCheckingVariable('Windows'); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } $js_code = "if(!window['{$component_id}']) {\n"; $js_code .= " {$component_id} = new Window({" . join(', ', $window_properties) . "});\n"; $js_code .= " {$component_id}.setCloseCallback(function() {\n"; $js_code .= " (__ClientEventHandler.getInstance()).sendEvent(\"close\", {}, \"{$component_id}\");\n"; $js_code .= " return true;\n"; $js_code .= " });\n"; $content = $component->getContent(); if (!empty($content)) { $js_code .= " {$component_id}.setHTMLContent(" . json_encode($content) . ");\n"; } $js_code .= "}\n"; $jod_response_writer->addJsCode($js_code); }
public function endRender() { parent::endRender(); $async_message = __ClientNotificator::getInstance()->getStartupNotification($this->_view_code); if ($async_message != null && ($async_message->getHeader()->getStatus() != __AsyncMessageHeader::ASYNC_MESSAGE_STATUS_OK || $async_message->hasPayload())) { $response_writer_manager = __ResponseWriterManager::getInstance(); if ($response_writer_manager->hasResponseWriter('javascript')) { $javascript_response_writer = $response_writer_manager->getResponseWriter('javascript'); } else { $javascript_response_writer = new __JavascriptOnDemandResponseWriter('javascript'); $response_writer_manager->addResponseWriter($javascript_response_writer); } if ($response_writer_manager->hasResponseWriter('setup-client-view')) { $setup_client_view_rw = $response_writer_manager->getResponseWriter('setup-client-view'); } else { $setup_client_view_rw = new __JavascriptOnDemandResponseWriter('setup-client-view'); $setup_client_view_rw->setLoadAfterDomLoaded(false); $javascript_response_writer->addResponseWriter($setup_client_view_rw); } $javascript_response_writer->addJsCode('__MessageProcessor.process(Object.extend(new __Message(), ' . $async_message->toJson() . '));', __JavascriptOnDemandResponseWriter::JS_CODE_POSITION_BOTTOM); } }
public function startRender(__IComponent &$component) { $component_id = $component->getId(); if (__ResponseWriterManager::getInstance()->hasResponseWriter('uploadfile')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('uploadfile'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('uploadfile'); $jod_response_writer->setLoadAfterDomLoaded(true); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } $jod_response_writer->addJsCode($component_id . ' = new __FileUploader($("' . $component_id . '"));' . "\n"); if ($component->getStatus() == __IUploaderComponent::UPLOAD_STATUS_DONE) { $filename = $component->getFilename(); $icon = $component->getIcon(); if ($icon != null) { $filename = "<img src='{$icon}' width='32' height='32' valign='absmiddle'> " . $filename; } $jod_response_writer->addJsCode($component_id . '.renderAsUploaded("' . $filename . '");'); } $properties = array(); $component_properties = $component->getProperties(); foreach ($component_properties as $property => $value) { $properties[] = $property . '="' . $value . '"'; } $properties[] = 'type = "file"'; $properties[] = 'id = "' . $component_id . '"'; $properties[] = 'name = "' . $component_id . '"'; if ($component->getVisible() == false) { $properties[] = 'style = "display : none;"'; } $input_file_properties = implode(' ', $properties); $return_value = <<<CODE <input type="file" {$input_file_properties}> CODE; return $return_value; }
public function startRender(__IComponent &$component) { $component_id = $component->getId(); $component_name = $component->getName(); if (!__ResponseWriterManager::getInstance()->hasResponseWriter('remoteservicedeclarations_' . $component_name)) { $send_event_parameters = array(); $send_event_parameters[] = "'remotecall'"; $send_event_parameters[] = "arg"; $send_event_parameters[] = "'{$component_id}'"; $send_event_parameters = join(', ', $send_event_parameters); //generate the remote service function: $js_code = <<<CODESET {$component_name} = function() { var arg = \$A({$component_name}.arguments); (__ClientEventHandler.getInstance()).sendEvent({$send_event_parameters}); }; CODESET; $jod_response_writer2 = new __JavascriptOnDemandResponseWriter('remoteservicedeclarations_' . $component_name); $jod_response_writer2->addJsCode($js_code); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer2); //generate the callback code (if applicable) $callback = $component->getClientResponseCallback(); if ($callback != null) { $js_callback_code = "{$component_id} = new __ResponseCallbackHandler({$callback});"; if (__ResponseWriterManager::getInstance()->hasResponseWriter('remoteservicecallback')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('remoteservicecallback'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('remoteservicecallback'); } $jod_response_writer->addJsCode($js_callback_code); $jod_response_writer->setLoadAfterDomLoaded(true); $javascript_rw->addResponseWriter($jod_response_writer); } } }
public function startRender(__IComponent &$component) { if (__ResponseWriterManager::getInstance()->hasResponseWriter('sliderjscode')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('sliderjscode'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('sliderjscode'); $jod_response_writer->addJsFileRef('scriptaculous/src/slider.js'); $jod_response_writer->addLoadCheckingVariable('Control'); $jod_response_writer->addLoadCheckingVariable('Control.Slider'); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } $component_id = $component->getId(); $handle = $component_id . '_handle'; $track = $component_id . '_track'; $initial_value = $component->getValue(); $input_receiver = $component->getInputReceiver(); $decimals = $component->getDecimals(); if ($decimals > 0) { $v = 'Math.round(v*1' . str_pad('', $decimals, '0') . ')/1' . str_pad('', $decimals, '0'); } else { $v = 'Math.round(v)'; } $onreceiver_keyup_js = ''; $onslide_js = ''; if ($input_receiver != null) { $input_receiver_id = $input_receiver->getId(); $onslide_js = ''; if ($input_receiver instanceof __InputBoxComponent) { $onslide_js = 'onSlide: function(v) { $(\'' . $input_receiver_id . '\').value = ' . $v . '; },'; $onreceiver_keyup_js = <<<CODE \$("{$input_receiver_id}").onKeyUp = function() { var value = \$("{$input_receiver_id}").value; if (value == '') return; if (isNaN(value)) \$('{$component_id}').setValue(0); else \$('{$component_id}').setValue(value); } CODE; } else { if ($input_receiver instanceof __LabelComponent) { $onslide_js = 'onSlide: function(v) { $(\'' . $input_receiver_id . '\').update(' . $v . '); },'; } } } $lower_limit = $component->getLowerLimit(); $upper_limit = $component->getUpperLimit(); $axis = $component->getAxis(); $js_code = <<<CODE window['{$component_id}'] = new Control.Slider("{$handle}", "{$track}", { {$onslide_js} onChange: function(v) { (__ClientEventHandler.getInstance()).sendEvent("change", {}, "{$component_id}"); }, range: \$R({$lower_limit},{$upper_limit}), sliderValue: {$initial_value}, axis: "{$axis}" }); {$onreceiver_keyup_js} CODE; $jod_response_writer->addJsCode($js_code); $width = $component->getWidth(); $height = $component->getHeight(); $handle_width = $component->getHandleWidth(); $handle_height = $component->getHandleHeight(); $track_css_class = $component->getTrackCssClass(); $left_track_css_class = $component->getLeftTrackCssClass(); $handle_img = $component->getHandleImg(); if (empty($track_css_class)) { $track_style = 'style="width:' . $width . '; background-color:#ccc; height: ' . $height . ';"'; } else { $track_style = 'class="' . $track_css_class . '"'; } if (empty($handle_img)) { $handle_style = 'style="width:' . $handle_width . '; height:' . $handle_height . ';background-color:#f00; cursor:move;"'; } else { $handle_style = 'style="width:' . $handle_width . '; height:' . $handle_height . ';"'; } $return_value = <<<CODE <div id="{$component_id}" style="width:{$width}; height: {$handle_height};"> <div {$track_style} id="{$track}" style="width:{$width}; height:{$height};"> <div class="{$left_track_css_class}"></div><div id="{$handle}" {$handle_style}><img src="{$handle_img}" alt="" style="float: left;" /></div> </div> </div> CODE; return $return_value; }
public function startRender(__IComponent &$component) { $component_id = $component->getId(); $event_handler = __EventHandlerManager::getInstance()->getEventHandler($component->getViewCode()); $component_to_validate = $component->getComponentToValidate(); $component_to_validate_id = $component_to_validate->getId(); if (__ResponseWriterManager::getInstance()->hasResponseWriter('livevalidation')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('livevalidation'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('livevalidation'); $jod_response_writer->addJsFileRef('livevalidation/livevalidation_1.3.1.js'); $jod_response_writer->addLoadCheckingVariable('Validate'); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } $configuration = array('validMessage : ""'); if ($component->getValidateOnlyOnBlur()) { $configuration[] = 'onlyOnBlur: true'; } else { if ($component->getValidateOnlyOnSubmit()) { $configuration[] = 'onlyOnSubmit: true'; } else { $configuration[] = 'wait: ' . $component->getWait(); } } $report_after_component = $component->getComponentForErrorReporting(); $report_after_element = $component->getReportAfterElement(); if ($report_after_component != null) { $configuration[] = 'insertAfterWhatNode: "' . $report_after_component->getId() . '"'; } else { if ($report_after_element != null) { $configuration[] = 'insertAfterWhatNode: "' . $report_after_element . '"'; } } if ($event_handler->isEventHandled('validate', $component_to_validate->getName())) { $configuration[] = 'onValid: function() { (__ClientEventHandler.getInstance()).sendEvent("validate", { validationRule : "' . $component_id . '"}, "' . $component_to_validate_id . '", true); }'; } else { if ($event_handler->isEventHandled('validate', $component->getName())) { $configuration[] = 'onValid: function() { (__ClientEventHandler.getInstance()).sendEvent("validate", { validationRule : "' . $component_id . '"}, "' . $component_id . '", true); }'; } } $on_invalid = $component->getOnInvalid(); if (!empty($on_invalid)) { $configuration[] = 'onInvalid: ' . $on_invalid; } $js_code = "if(\$(\"{$component_to_validate_id}\")) {\n"; $js_code .= "if(!window['{$component_id}']) {\n"; $js_code .= ' window[\'' . $component_id . '\'] = new LiveValidation("' . $component_to_validate_id . '", {' . join(', ', $configuration) . '});' . "\n"; $js_code .= "} else {\n"; $js_code .= ' ' . $component_id . '.initialize("' . $component_to_validate_id . '", {' . join(', ', $configuration) . '});' . "\n"; $js_code .= "}\n"; $js_code .= $this->_getValidLengthJsPart($component); $js_code .= $this->_getValidFormatJsPart($component); $js_code .= $this->_getComponentMatchJsPart($component); $js_code .= $this->_getMandatoryJsPart($component); $js_code .= $this->_getAcceptanceJsPart($component); $js_code .= $this->_getShowMessageJsPart($component); $js_code .= $this->_getAllowedExtensionsJsPart($component); $js_code .= $this->_getNumericalityJsPart($component); $js_code .= $this->_getListenValidateEvent($component); $js_code .= "}\n"; $jod_response_writer->addJsCode($js_code); }
protected function &_getJavascriptResponseWriter() { $js_code = <<<CODESET function toggleButton(element) { if(element.className == 'depressed') { element.className = 'raised'; } else { element.className = 'depressed'; } } CODESET; if (__ResponseWriterManager::getInstance()->hasResponseWriter('togglebutton')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('togglebutton'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('togglebutton'); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); $jod_response_writer->addJsCode($js_code); } if (!__ResponseWriterManager::getInstance()->hasResponseWriter('togglebuttoncss')) { $css_response_writer = new __CssResponseWriter('togglebuttoncss'); $css_rules = <<<CODESET span.depressed { text-align: center; border:1px inset #CCCCCC; color: black; background: url(media/images/backgrounds/button_pressed.gif) repeat-x; padding: 1px 4px 1px 4px; line-height: 1.4em; } span.raised { text-align: center; border:1px outset #CCCCCC; color: black; background: url(media/images/backgrounds/button.gif) repeat-x; background-color: #F3F3EE; padding: 1px 4px 1px 4px; line-height: 1.4em; } span.depressed:hover { cursor: pointer; cursor: hand; } span.raised:hover { cursor: pointer; cursor: hand; } CODESET; $css_response_writer->addCssRules($css_rules); __ResponseWriterManager::getInstance()->addResponseWriter($css_response_writer); } return $jod_response_writer; }
public function endRender(__IComponent &$component) { $component_id = $component->getId(); $return_value = $this->_component_writer->endRender($component); $context_help = $component->getContextHelp(); if (!empty($context_help)) { if (__ResponseWriterManager::getInstance()->hasResponseWriter('formcontexthelp')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('formcontexthelp'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('formcontexthelp'); $jod_response_writer->addCssFileRef('formcontexthelp/formcontexthelp.css'); $jod_response_writer->addJsFileRef('formcontexthelp/formcontexthelp.js'); $jod_response_writer->addLoadCheckingVariable('prepareInputsForHints'); $jod_response_writer->addJsCode("\nprepareInputsForHints();\n"); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } $return_value .= '<span id="' . $component_id . '_contextHelp" class="hint" style="display: none;">' . $context_help . '<span id="' . $component_id . '_contextHelpPointer" class="hint-pointer" style="display: none;"> </span></span>'; } $example = str_replace("'", "\\'", $component->getExample()); if (!empty($example)) { if (__ResponseWriterManager::getInstance()->hasResponseWriter('inputexamples')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('inputexamples'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('inputexamples'); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); $code = <<<CODESET window['showAllExamples'] = function() { \$\$('input').each(function(inputElement) { showExampleValueOnInput(inputElement); }); }; var showExampleValueOnInput = function(input) { if(input['exampleValue']) { input.onfocus = function () { if(input.exampleValue == input.value) { if(input.originalType == 'password') { input.type = 'password'; } input.value = ''; input.style.color = ''; } } input.onblur = function () { if(input.value == '') { if(input.type == 'password') { input.originalType = 'password'; input.type = 'text'; } input.value = input.exampleValue; input.style.color = '#858585'; } } if(input.value == '') { if(input.type == 'password') { input.originalType = 'password'; input.type = 'text'; } input.value = input.exampleValue; } if(input.value == input.exampleValue) { if(input.type == 'password') { input.originalType = 'password'; input.type = 'text'; } input.style.color = '#858585'; } } }; CODESET; $jod_response_writer->addJsCode($code); } $code = <<<CODESET var {$component_id} = \$('{$component_id}'); {$component_id}.exampleValue = '{$example}'; showExampleValueOnInput({$component_id}); CODESET; $jod_response_writer->addJsCode($code); } $mask = $component->getMask(); if (!empty($mask)) { if (__ResponseWriterManager::getInstance()->hasResponseWriter('inputmask')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('inputmask'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('inputmask'); $jod_response_writer->addJsFileRef('inputmask/inputmask.js'); $jod_response_writer->addLoadCheckingVariable('__InputMask'); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } $jod_response_writer->addJsCode("(__InputMask.getInstance()).addMask(\"{$component_id}\", \"{$mask}\");\n"); } return $return_value; }