Exemple #1
0
    /**
     * Enables client validation for forms loaded via AJAX
     * appends script to each form, required for Nette 1.0
     * appends script to forms with class="useUICss" calling applyUIForm()
     * 
     * todo: temporary? David should fix it natively
     * @return void
     */
    public function render()
    {
        $args = func_get_args();
        call_user_func_array('parent::render', $args);
        $js = '';
        if ($this->getPresenter()->isAjax()) {
            $js .= 'Nette.initForm(document.getElementById("' . $this->getElementPrototype()->id . '"));';
        }
        //		dump($this->getElementPrototype()->class);die();
        //		if (strchr($this->getElementPrototype()->class, 'useUICss')) {
        if (in_array('useUICss', (array) $this->getElementPrototype()->class)) {
            $js .= '$(function(){applyUItoForm("' . $this->getElementPrototype()->id . '")});';
        }
        if (!empty($js)) {
            echo '
				<script type="text/javascript">
					' . $js . '
				</script>
			';
        }
        if ($this->ajaxFileUploadEnabled and !self::$ajaxFileUploadLoaded) {
            self::$ajaxFileUploadLoaded = true;
            $basePath = Environment::getApplication()->getPresenter()->getTemplate()->basePath;
            echo '
			<!--	FILE UPLOAD-->

				<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/themes/base/jquery-ui.css" id="theme">
			<!--	<link rel="stylesheet" href="' . $basePath . '/modules/file-upload/jquery.fileupload-ui.css">-->
				<link rel="stylesheet" href="' . $basePath . '/modules/file-upload/jquery.fileupload-ui-admin.css">
			
			<!-- jQuery should be already loaded
				<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
			-->
				<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"></script>
				<script src="' . $basePath . '/modules/file-upload/jquery.fileupload.js"></script>
				<script src="' . $basePath . '/modules/file-upload/jquery.fileupload-ui.js"></script>
				<script src="' . $basePath . '/modules/file-upload/jquery.fileupload-uix.js"></script>
				<script src="' . $basePath . '/modules/file-upload/fileupload-lib.js"></script>
				<script src="' . $basePath . '/modules/file-upload/admin-inline.js"></script>
				
			<!--	FILE UPLOAD END-->
			';
        }
    }