コード例 #1
0
 /**
  * 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');
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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            });");
     }
 }
コード例 #4
0
ファイル: Form.php プロジェクト: GemsTracker/MUtil
 /**
  * Activate JQuery for the view
  *
  * @param \Zend_View_Interface $view
  * @return void
  */
 protected function _activateJQueryView(\Zend_View_Interface $view = null)
 {
     if ($this->_no_jquery) {
         return;
     }
     if (null === $view) {
         $view = $this->getView();
         if (null === $view) {
             return;
         }
     }
     \MUtil_JQuery::enableView($view);
     if (false === $view->getPluginLoader('helper')->getPaths('MUtil_JQuery_View_Helper')) {
         $view->addHelperPath('MUtil/JQuery/View/Helper', 'MUtil_JQuery_View_Helper');
     }
 }
コード例 #5
0
ファイル: Bootstrap.php プロジェクト: GemsTracker/MUtil
 /**
 * 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();
 }
コード例 #6
0
ファイル: BatchAbstract.php プロジェクト: GemsTracker/MUtil
 /**
  * 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);
 }
コード例 #8
0
 /**
  * Hook 12: Called after an action is dispatched by \Zend_Controller_Dispatcher.
  *
  * This callback allows for proxy or filter behavior. By altering the
  * request and resetting its dispatched flag (via {@link
  * \Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
  * a new action may be specified for dispatching.
  *
  * \Zend_Layout_Controller_Plugin_Layout uses this event to change the output
  * of the $response with the rendering of the layout. As the Layout plugin
  * has a priority of 99, this Escort event will take place before the layout
  * is rendered, unless $this->run() was called with a stackIndex lower than zero.
  *
  * Previous hook: controllerAfterAction()
  * Actions since: ob_get_clean(); $response->appendBody()
  * Actions after: while (! Request->isDispatched()) or back to Hook 8 preDispatch()
  * Next hook: dispatchLoopShutdown()
  *
  * @param  \Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function postDispatch(\Zend_Controller_Request_Abstract $request)
 {
     if ($request->isDispatched()) {
         $response = \Zend_Controller_Front::getInstance()->getResponse();
         $response->setHeader('X-UA-Compatible', 'IE=edge,chrome=1', true);
         if ($this->project->offsetExists('x-frame')) {
             $response->setHeader('X-Frame-Options', $this->project->offsetGet('x-frame'), true);
         }
         // Only when we need to render the layout, we run the layout prepare
         if (\Zend_Controller_Action_HelperBroker::hasHelper('layout') && \Zend_Controller_Action_HelperBroker::getExistingHelper('layout')->isEnabled()) {
             // Per project layout preparation
             if (isset($this->project->layoutPrepare)) {
                 foreach ($this->project->layoutPrepare as $prepare => $type) {
                     if ($type) {
                         $function = '_layout' . ucfirst($prepare);
                         if (isset($this->project->layoutPrepareArgs, $this->project->layoutPrepareArgs[$prepare])) {
                             $args = $this->project->layoutPrepareArgs[$prepare];
                         } else {
                             $args = array();
                         }
                         $result = $this->{$function}($args);
                         // When a result is returned, add it to the view,
                         // according to the type method
                         if (null !== $result) {
                             if (is_numeric($type)) {
                                 $this->view->{$prepare} = $result;
                             } else {
                                 if (!isset($this->view->{$type})) {
                                     $this->view->{$type} = new \MUtil_Html_Sequence();
                                 }
                                 $sequence = $this->view->{$type};
                                 $sequence[$prepare] = $result;
                             }
                         }
                     }
                 }
             }
         }
         // For AJAX calls we sometimes need to add JQuery onload scripts since otherwise they won't get rendered:
         // We expect JQuery to be loaded in the master page, since the call is probably made using JQuery
         if ($request instanceof \Zend_Controller_Request_Http && $request->isXmlHttpRequest()) {
             \MUtil_JQuery::enableView($this->view);
             $scripts = $this->view->jQuery()->getOnLoadActions();
             $content = '';
             foreach ($scripts as $script) {
                 $content .= "<script type='text/javascript'>{$script}</script>\n";
             }
             $content .= $this->view->inlineScript();
             // Now cleanup the rendered content (just to make sure)
             $this->view->jQuery()->clearOnLoadActions();
             $this->view->inlineScript()->exchangeArray(array());
             if (!empty($content)) {
                 $response->appendBody($content);
             }
         }
     }
 }
コード例 #9
0
    /**
     * 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');
    }