/**
  * Initialize the view
  *
  * Make sure the needed javascript is loaded
  *
  * @param \Zend_View $view
  */
 protected function _initView($view)
 {
     $baseUrl = \GemsEscort::getInstance()->basepath->getBasePath();
     // Make sure we can use jQuery
     \MUtil_JQuery::enableView($view);
     // Now add the scrollTo plugin so we can scroll to today
     $view->headScript()->appendFile($baseUrl . '/gems/js/jquery.scrollTo.min.js');
     /*
      * And add some initialization:
      *  - Hide all tokens initially (accessability, when no javascript they should be visible)
      *  - If there is a day labeled today, scroll to it (prevents errors when not visible)
      */
     $view->headScript()->appendFile($baseUrl . '/gems/js/trafficlight.js');
 }
 public function setView(\Zend_View_Abstract $view)
 {
     if (isset($view->request) && $view->request instanceof \Zend_Controller_Request_Http) {
         $this->setBasePath($view->request->getBasePath());
     }
     if (!\MUtil_JQuery::usesJQuery($view)) {
         \ZendX_JQuery::enableView($view);
     }
     $this->view = $view;
 }
 /**
  * Copied from parent, but insert chart instead of table after commented out part
  *
  * @param \Zend_View_Abstract $view
  * @return type
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     //$view->headLink()->prependStylesheet($view->serverUrl() . \GemsEscort::getInstance()->basepath->getBasePath() . '/gems/css/barchart.less', 'screen,print');
     $htmlDiv = \MUtil_Html::create()->div(' ', array('class' => 'barchartcontainer'));
     if ($this->showHeaders) {
         if (isset($this->token)) {
             $htmlDiv->h3(sprintf($this->_('Overview for patient number %s'), $this->token->getPatientNumber()));
             $htmlDiv->pInfo(sprintf($this->_('Overview for patient number %s: %s.'), $this->token->getPatientNumber(), $this->token->getRespondentName()))->appendAttrib('class', 'noprint');
         } else {
             $htmlDiv->pInfo($this->_('No data present'));
         }
     }
     if (!empty($this->data)) {
         $htmlDiv->append($this->getChart());
         // Insert the chart here
     }
     if ($this->showButtons) {
         $buttonDiv = $htmlDiv->buttonDiv();
         $buttonDiv->actionLink(array(), $this->_('Back'), array('onclick' => 'window.history.go(-1); return false;'));
         $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();'));
     }
     // Make vertically resizable
     $view = \Zend_Layout::getMvcInstance()->getView();
     /*$jquery = $view->jQuery();
       $jquery->enable();*/
     \MUtil_JQuery::enableView($view);
     // We need width 100% otherwise it will look strange in print output
     $view->jQuery()->addOnLoad("\$('.barchart').resizable({\r\n            handles: 's',\r\n            resize: function( event, ui ) { ui.element.css({ width: '100%'}); },\r\n            minHeight: 150\r\n            });");
     return $htmlDiv;
 }
 /**
  * Preparations for creating and editing
  */
 protected function createEditPrepare()
 {
     $this->createEditSnippets = $this->getTrackEngine()->getRoundEditSnippetNames();
     \MUtil_JQuery::enableView($this->view);
     $this->view->headScript()->appendFile($this->basepath->getBasePath() . '/gems/js/jquery.showOnChecked.js');
     if (\MUtil_Bootstrap::enabled()) {
         $this->view->headScript()->appendScript("jQuery(document).ready(function(\$) {\n                \$('input[name=\"organizations[]\"]').closest('div').showOnChecked( { showInput: \$('#org_specific_round-1') });\n            });");
     } else {
         $this->view->headScript()->appendScript("jQuery(document).ready(function(\$) {\n                \$('input[name=\"organizations[]\"]').closest('tr').showOnChecked( { showInput: \$('#org_specific_round-1') });\n            });");
     }
 }
示例#5
0
 /**
  * Activate JQuery for this form
  *
  * @return \MUtil_Form (continuation pattern)
  */
 public function activateJQuery()
 {
     if ($this->_no_jquery) {
         \MUtil_JQuery::enableForm($this);
         //$this->addPrefixPath('MUtil_JQuery_Form_Decorator', 'MUtil/JQuery/Form/Decorator/', \Zend_Form::DECORATOR);
         $this->addPrefixPath('MUtil_JQuery_Form_Element', 'MUtil/JQuery/Form/Element/', \Zend_Form::ELEMENT);
         $this->_activateJQueryView();
         $this->_no_jquery = false;
     }
     return $this;
 }
示例#6
0
 /**
 * jQuery-enable a form instance
 *
 * @param  \Zend_Form $form
 * @return void
 * /
     public static function enableForm(\Zend_Form $form)
     {
    $form->addPrefixPath('MUtil_Bootstrap_Form_Decorator', 'MUtil/Bootstrap/Form/Decorator', 'decorator')
         ->addPrefixPath('MUtil_Bootstrap_Form_Element', 'MUtil/Bootstrap/Form/Element', 'element')
         ->addElementPrefixPath('MUtil_Bootstrap_Form_Decorator', 'MUtil/Bootstrap/Form/Decorator', 'decorator')
         ->addDisplayGroupPrefixPath('MUtil_Bootstrap_Form_Decorator', 'MUtil/Bootstrap/Form/Decorator');
 
    foreach ($form->getSubForms() as $subForm) {
        self::enableForm($subForm);
    }
 
    if (null !== ($view = $form->getView())) {
        self::enableView($view);
    }
     }
 
     /**
 * Bootstrap-enable a view instance
 *
 * @param  \Zend_View_Interface $view
 * @return void
 */
 public static function enableView(\Zend_View_Interface $view)
 {
     if (!\MUtil_JQuery::usesJQuery($view)) {
         \MUtil_JQuery::enableView($view);
     }
     if (false === $view->getPluginLoader('helper')->getPaths('MUtil_Bootstrap_View_Helper')) {
         $view->addHelperPath('MUtil/Bootstrap/View/Helper', 'MUtil_Bootstrap_View_Helper');
     }
     self::$_bootstrap = $view->bootstrap();
 }
示例#7
0
 /**
  * Return a progress panel object, set up to be used by
  * this batch.
  *
  * @param \Zend_View_Abstract $view
  * @param mixed $arg_array \MUtil_Ra::args() arguments to populate progress bar with
  * @return \MUtil_Html_ProgressPanel
  */
 public function getPanel(\Zend_View_Abstract $view, $arg_array = null)
 {
     $args = func_get_args();
     \MUtil_JQuery::enableView($view);
     //$jquery = $view->jQuery();
     //$jquery->enable();
     if (isset($this->finishUrl)) {
         $urlFinish = $this->finishUrl;
     } else {
         $urlFinish = $view->url(array($this->progressParameterName => $this->progressParameterReportValue));
     }
     $urlRun = $view->url(array($this->progressParameterName => $this->progressParameterRunValue));
     $panel = new \MUtil_Html_ProgressPanel($args);
     $panel->id = $this->_id;
     $js = new \MUtil_Html_Code_JavaScript(dirname(__FILE__) . '/Batch' . $this->method . '.js');
     $js->setInHeader(false);
     // Set the fields, in case they where not set earlier
     $js->setDefault('__AUTOSTART__', $this->autoStart ? 'true' : 'false');
     $js->setDefault('{PANEL_ID}', '#' . $this->_id);
     $js->setDefault('{FORM_ID}', $this->_formId);
     $js->setDefault('{TEXT_ID}', $panel->getDefaultChildTag() . '.' . $panel->progressTextClass);
     $js->setDefault('{URL_FINISH}', addcslashes($urlFinish, "/"));
     $js->setDefault('{URL_START_RUN}', addcslashes($urlRun, "/"));
     $js->setDefault('FUNCTION_PREFIX_', $this->getFunctionPrefix());
     $panel->append($js);
     return $panel;
 }
 /**
  * Create the snippets content
  *
  * This is a stub function either override getHtmlOutput() or override render()
  *
  * @param \Zend_View_Abstract $view Just in case it is needed here
  * @return \MUtil_Html_HtmlInterface Something that can be rendered
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     if ($script = $this->getAjaxEventScript()) {
         \MUtil_JQuery::enableView($view);
         $view->headScript()->appendFile(\Zend_Controller_Front::getInstance()->getBaseUrl() . '/gems/js/jquery.getSelectOptions.js');
         $view->inlineScript()->appendScript($script);
     }
     return parent::getHtmlOutput($view);
 }
 /**
  * Hook 3: Called in $this->setRequest.
  *
  * All resources have been loaded and the $request object is created.
  * Theoretically this event can be triggered multiple times, but this does
  * not happen in a standard Zend application.
  *
  * Not initialized are the $response and $controller objects.
  *
  * Previous hook: beforeRun()
  * Actions since: $this->request object created
  * Actions after: $this->response object created
  * Next hook: responseChanged()
  *
  * @param \Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function requestChanged(\Zend_Controller_Request_Abstract $request)
 {
     if ($this->project->isMultiLocale()) {
         // Get the choosen language
         $localeId = \Gems_Cookies::getLocale($request);
         // Change when $localeId exists and is different from session
         if ($localeId && $this->locale->getLanguage() !== $localeId) {
             // \MUtil_Echo::r('On cookie ' . $localeId . ' <> ' . $this->locale->getLanguage());
             // Does the locale exist?
             if (isset($this->project->locales[$localeId])) {
                 // Add and implement the choosen locale
                 $this->session->user_locale = $localeId;
                 $this->locale->setLocale($localeId);
                 if (!$this->translate->isAvailable($localeId)) {
                     $languageFilename = APPLICATION_PATH . '/languages/default-' . $localeId . '.mo';
                     if (file_exists($languageFilename)) {
                         $this->translate->addTranslation($languageFilename, $localeId);
                     }
                 }
                 $this->translate->setLocale($localeId);
                 $this->translateAdapter = $this->translate->getAdapter();
             }
         }
     }
     // Set the base path, the route is now fixed
     $this->basepath->setBasePath($request->getBasePath());
     // Set the jQuery version and other information needed
     // by classes using jQuery
     $jquery = \MUtil_JQuery::jQuery();
     $jqueryVersion = '1.11.1';
     $jqueryUiVersion = '1.11.1';
     $jquery->setVersion($jqueryVersion);
     $jquery->setUiVersion($jqueryUiVersion);
     if ($this->project->isJQueryLocal()) {
         $jqueryDir = $request->getBasePath() . $this->project->getJQueryLocal();
         $jquery->setLocalPath($jqueryDir . 'jquery-' . $jqueryVersion . '.js');
         $jquery->setUiLocalPath($jqueryDir . 'jquery-ui-' . $jqueryUiVersion . '.js');
     } else {
         if (\MUtil_Https::on()) {
             $jquery->setCdnSsl(true);
         }
     }
     if (\MUtil_Bootstrap::enabled() && $this->project->isBootstrapLocal()) {
         $bootstrap = \MUtil_Bootstrap::bootstrap();
         $basePath = $request->getBasePath();
         $bootstrap->setBootstrapScriptPath($basePath . '/bootstrap/js/bootstrap.min.js');
         $bootstrap->setBootstrapStylePath($basePath . '/bootstrap/css/bootstrap.min.css');
         $bootstrap->setFontAwesomeStylePath($basePath . '/bootstrap/css/font-awesome.min.css');
     }
 }
    /**
     * Initialize the view
     *
     * Make sure the needed javascript is loaded
     *
     * @param \Zend_View $view
     */
    protected function _initView($view)
    {
        $baseUrl = \GemsEscort::getInstance()->basepath->getBasePath();
        // Make sure we can use jQuery
        \MUtil_JQuery::enableView($view);
        // Now add the scrollTo plugin so we can scroll to today
        $view->headScript()->appendFile($baseUrl . '/gems/js/jquery.scrollTo.min.js');
        /*
         * And add some initialization:
         *  - Hide all tokens initially (accessability, when no javascript they should be visible)
         *  - If there is a day labeled today, scroll to it (prevents errors when not visible)
         */
        $view->headScript()->appendScript('

    // Click track
    $(".traject .panel-heading").click(function(){
        $(this).next().toggle();
        if($(this).next().is(":visible")) {
            $(this).find("h3 span").removeClass("fa-chevron-right").addClass("fa-chevron-down");
            // Close all days
            $(this).next().find(".actor").each(function(){if ( $(this).find(".zpitems").is(":visible") ) { $(this).find("h5").click(); }});
            // Scroll to today
            $(this).next().find(".object.today").each(function(){
                // Open current day
                $(this).children(".actor").each(function(){if ( $(this).find(".zplegenda").is(":visible") ) { $(this).find("h5").click(); }});
                // Scroll to today
                $(this).parent().parent().scrollTo($(this),0, { offset: $(this).outerWidth(true)-$(this).parent().parent().innerWidth()} );    /* today is rightmost block */
            });
        } else {
            $(this).find("h3 span").addClass("fa-chevron-right").removeClass("fa-chevron-down");
        }
    });

    // Click day
    $(".object h4").click(function(){
        if ( $(this).parent().find(".actor h5 span").first().hasClass("fa-minus-square") ) {
            // First is open, now close first and all others
            $(this).parent().find(".actor h5 span").each(function(){
                if ( $(this).hasClass("fa-minus-square")) {
                    $(this).parent().click();
                }
            });
        } else {
            // First is closed, now open first and all others
            $(this).parent().find(".actor h5 span").each(function(){
                if ( $(this).hasClass("fa-plus-square")) {
                    $(this).parent().click();
                }
            });
        }
    });

    // Click actor
    $(".actor h5").click(function(){
        if ( $(this).find("span").first().hasClass("fa-plus-square") ) {
            $(this).find("span").removeClass("fa-plus-square").addClass("fa-minus-square");
            $(this).parent().find(".zplegenda").toggle(false);
            $(this).parent().find(".zpitems").toggle(true);
        } else {
            $(this).find("span").addClass("fa-plus-square").removeClass("fa-minus-square");
            $(this).parent().find(".zplegenda").toggle(true);
            $(this).parent().find(".zpitems").toggle(false);
        }
    });

    // Click legend
    $(".actor .zplegenda").click(function(){
        // delegate to actor
        $(this).parent().find("h5").click();
    });

    // Initially hide all zpitems so only zplegende remains visible
    $(".object .actor").children(".zpitems").toggle(false);

    // First close all tracks
    $(".traject .panel-heading").click();
    // and open the first one
    $(".traject .panel-heading").first().click();

    // Inline answers + printing dialog
    $(".zpitem.success a[target=\'inline\']").click(function(e){
        e.preventDefault();
        // Now open a new div, not #menu and bring it to the front
        // Add a close button to it, maybe the available tooltip can help here
        $("div#modalpopup").html("<div class=\'loading\'></div>"); // Make sure we show no old information
        $("div#modalpopup").load($(this).attr(\'href\'));
        $("div#modalpopup").dialog({
            modal: true,
            width: 500,
            position:{ my: "left top", at: "left top", of: "#main" },
            buttons: [
                {
                text: "Print",
                "class": "btn-primary",
                click: function() {
                        if ($(".modal").is(":visible")) {
                            var oldId = $(event.target).closest(".modal").attr("id");
                            var modalId = "modelprint";
                            $(event.target).closest(".modal").attr("id", modalId);
                            $("body").css("visibility", "hidden");
                            $("body #container").css("display", "none");
                            $("div#modalpopup").css("visibility", "visible");
                            $("#" + modalId).removeClass("modal");
                            window.print();
                            $("body").css("visibility", "visible");
                            $("body #container").css("display", "block");
                            $("#" + modalId).addClass("modal");
                            $(event.target).closest(".modal").attr("id", oldId);
                        } else {
                            window.print();
                        }
                    }
                }
                ]
        });
    });');
        // find the menu items only once for more efficiency
        $this->_trackAnswer = $this->findMenuItem('track', 'answer');
        $this->_surveyAnswer = $this->findMenuItem('survey', 'answer');
        $this->_takeSurvey = $this->findMenuItem('ask', 'take');
    }