public function GetEndScript()
 {
     $ctrlId = $this->ControlId;
     if ($this->intButtonMode == self::ButtonModeSet) {
         QApplication::ExecuteControlCommand($ctrlId, 'buttonset', QJsPriority::High);
     } elseif ($this->intButtonMode == self::ButtonModeJq) {
         QApplication::ExecuteSelectorFunction(["input:radio", "#" . $ctrlId], 'button', QJsPriority::High);
     }
     $strScript = parent::GetEndScript();
     return $strScript;
 }
 protected function lblArray_Click($strFormId, $strControlId, $strParameter)
 {
     // Is the Label being clicked already selected?
     if ($this->lblArray[$strParameter]->Selected) {
         // It's already selected -- go ahead and replace it with the textbox
         $this->lblArray[$strParameter]->Visible = false;
         $this->txtArray[$strParameter]->Visible = true;
         $this->txtArray[$strParameter]->Text = html_entity_decode($this->lblArray[$strParameter]->Text, ENT_COMPAT, QApplication::$EncodingType);
         QApplication::ExecuteControlCommand($this->txtArray[$strParameter]->ControlId, 'select');
         QApplication::ExecuteControlCommand($this->txtArray[$strParameter]->ControlId, 'focus');
     } else {
         // Nope -- not yet selected
         // First, unselect everything else
         for ($intIndex = 0; $intIndex < 10; $intIndex++) {
             if ($this->lblArray[$intIndex]->Selected) {
                 $this->lblArray[$intIndex]->Selected = false;
                 $this->lblArray[$intIndex]->CssClass = 'renamer_item';
             }
         }
         // Now, make this item selected
         $this->lblArray[$strParameter]->Selected = true;
         $this->lblArray[$strParameter]->CssClass = 'renamer_item renamer_item_selected';
     }
 }
Exemple #3
0
 /**
  * @return string
  */
 public function GetEndScript()
 {
     \QApplication::ExecuteControlCommand($this->ControlId, 'on', 'click', 'li', new \QJsClosure("qcubed.recordControlModification ('{$this->ControlId}', 'SelectedId', this.id); jQuery(this).trigger ('bsmenubarselect', this.id)"), \QJsPriority::High);
     return parent::GetEndScript();
 }
 /**
  * Returns the End Script of the Control which is sent to the client when the control's Render is complete
  * @return string The JS EndScript for the control
  */
 public function GetEndScript()
 {
     $strToReturn = parent::GetEndScript();
     // DROP ZONES
     foreach ($this->objDropsControlsArray as $strKey => $blnIsDropZone) {
         if ($blnIsDropZone) {
             QApplication::ExecuteControlCommand($strKey, 'droppable');
         }
     }
     foreach ($this->objIsDropZoneFor as $strKey => $blnIsDropZone) {
         if ($blnIsDropZone) {
             $objControl = $this->objForm->GetControl($strKey);
             if ($objControl && $objControl->strRenderMethod) {
                 QApplication::ExecuteControlCommand($this->strControlId, 'droppable', 'option', 'accept', '#' . $strKey);
             }
         }
     }
     return $strToReturn;
 }
 /**
  * Open the date picker. If the datepicker is attached to an input, the
  * input must be visible for the datepicker to be shown.
  * 
  * 	* This method does not accept any arguments.
  */
 public function Show()
 {
     QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "show", QJsPriority::Low);
 }
 protected function btnEdit_Click($strFormId, $strControlId, $strParameter)
 {
     $this->intEditPersonId = $strParameter;
     $objPerson = Person::Load($strParameter);
     $this->txtFirstName->Text = $objPerson->FirstName;
     $this->txtLastName->Text = $objPerson->LastName;
     // Let's put the focus on the FirstName Textbox
     QApplication::ExecuteControlCommand($this->txtFirstName->ControlId, 'focus');
 }
 /**
  * Override of superclass that will update the selection using javascript so that the whole control does
  * not need to be redrawn.
  */
 protected function RefreshSelection()
 {
     $items = $this->SelectedItems;
     $values = [];
     foreach ($items as $objItem) {
         $values[] = $objItem->Id;
     }
     QApplication::ExecuteControlCommand($this->ControlId, 'val', $values);
 }
    /**
     * Renders the end of the form, including the closing form and body tags.
     * Renders the html for hidden controls.
     * @param bool $blnDisplayOutput should the output be returned or directly printed to screen.
     *
     * @return null|string
     * @throws QCallerException
     */
    public function RenderEnd($blnDisplayOutput = true)
    {
        // Ensure that RenderEnd() has not yet been called
        switch ($this->intFormStatus) {
            case QFormBase::FormStatusUnrendered:
                throw new QCallerException('$this->RenderBegin() was never called');
            case QFormBase::FormStatusRenderBegun:
                break;
            case QFormBase::FormStatusRenderEnded:
                throw new QCallerException('$this->RenderEnd() has already been called');
                break;
            default:
                throw new QCallerException('FormStatus is in an unknown status');
        }
        $strHtml = '';
        // This will be the final output
        /**** Render any controls that get automatically rendered ****/
        foreach ($this->GetAllControls() as $objControl) {
            if ($objControl->AutoRender && !$objControl->Rendered) {
                $strRenderMethod = $objControl->PreferredRenderMethod;
                $strHtml .= $objControl->{$strRenderMethod}(false) . _nl();
            }
        }
        /**** Prepare Javascripts ****/
        // Clear included javascript array since we are completely redrawing the page
        $this->strIncludedJavaScriptFileArray = array();
        $strControlIdToRegister = array();
        $strEventScripts = '';
        // Add form level javascripts and libraries
        $strJavaScriptArray = $this->ProcessJavaScriptList($this->GetFormJavaScripts());
        QApplication::AddJavaScriptFiles($strJavaScriptArray);
        $strFormJsFiles = QApplication::RenderFiles();
        // Render the form-level javascript files separately
        // Go through all controls and gather up any JS or CSS to run or Form Attributes to modify
        foreach ($this->GetAllControls() as $objControl) {
            if ($objControl->Rendered || $objControl->ScriptsOnly) {
                $strControlIdToRegister[] = $objControl->ControlId;
                /* Note: GetEndScript may cause the control to register additional commands, or even add javascripts, so those should be handled after this. */
                if ($strControlScript = $objControl->GetEndScript()) {
                    $strControlScript = JavaScriptHelper::TerminateScript($strControlScript);
                    // Add comments for developer version of output
                    if (!QApplication::$Minimize) {
                        // Render a comment
                        $strControlScript = _nl() . _nl() . sprintf('/*** EndScript -- Control Type: %s, Control Name: %s, Control Id: %s  ***/', get_class($objControl), $objControl->Name, $objControl->ControlId) . _nl() . _indent($strControlScript);
                    }
                    $strEventScripts .= $strControlScript;
                }
            }
            // Include the javascripts specified by each control.
            if ($strScriptArray = $this->ProcessJavaScriptList($objControl->JavaScripts)) {
                QApplication::AddJavaScriptFiles($strScriptArray);
            }
            // Include any StyleSheets?  The control would have a
            // comma-delimited list of stylesheet files to include (if applicable)
            if ($strScriptArray = $this->ProcessStyleSheetList($objControl->StyleSheets)) {
                QApplication::AddStyleSheets(array_keys($strScriptArray));
            }
            // Form Attributes?
            if ($objControl->FormAttributes) {
                QApplication::ExecuteControlCommand($this->strFormId, 'attr', $objControl->FormAttributes);
                foreach ($objControl->FormAttributes as $strKey => $strValue) {
                    if (!array_key_exists($strKey, $this->strFormAttributeArray)) {
                        $this->strFormAttributeArray[$strKey] = $strValue;
                    } else {
                        if ($this->strFormAttributeArray[$strKey] != $strValue) {
                            $this->strFormAttributeArray[$strKey] = $strValue;
                        }
                    }
                }
            }
        }
        // Add grouping commands to events (Used for deprecated drag and drop, but not removed yet)
        foreach ($this->objGroupingArray as $objGrouping) {
            $strGroupingScript = $objGrouping->Render();
            if (strlen($strGroupingScript) > 0) {
                $strGroupingScript = JavaScriptHelper::TerminateScript($strGroupingScript);
                $strEventScripts .= $strGroupingScript;
            }
        }
        /*** Build the javascript block ****/
        // Start with variable settings and initForm
        $strEndScript = sprintf('qc.initForm("%s"); ', $this->strFormId);
        // Register controls
        if ($strControlIdToRegister) {
            $strEndScript .= sprintf("qc.regCA(%s); \n", JavaScriptHelper::toJsObject($strControlIdToRegister));
        }
        // Design mode event
        if (defined('__DESIGN_MODE__') && __DESIGN_MODE__ == 1) {
            // attach an event listener to the form to send context menu selections to the designer dialog for processing
            $strEndScript .= sprintf('$j("#%s").on("contextmenu", "[id]", 
						function(event) {
							$j("#qconnectoreditdlg").trigger("qdesignerclick", 
								[{id: event.target.id ? event.target.id : $j(event.target).parents("[id]").attr("id"), for: $j(event.target).attr("for")}]
							);
							return false;
						}
					);', $this->FormId);
        }
        // Add any application level js commands.
        // This will include high and medimum level commands
        $strEndScript .= QApplication::RenderJavascript(true);
        // Add the javascript coming from controls and events just after the medium level commands
        $strEndScript .= ';' . $strEventScripts;
        // Add low level commands and other things that need to execute at the end
        $strEndScript .= ';' . QApplication::RenderJavascript(false);
        // Create Final EndScript Script
        $strEndScript = sprintf('<script type="text/javascript">$j(document).ready(function() { %s; });</script>', $strEndScript);
        /**** Render the HTML itself, appending the javascript we generated above ****/
        foreach ($this->GetAllControls() as $objControl) {
            if ($objControl->Rendered) {
                $strHtml .= $objControl->GetEndHtml();
            }
            $objControl->ResetFlags();
            // Make sure controls are serialized in a reset state
        }
        $strHtml .= $strFormJsFiles . _nl();
        // Add form level javascript files
        // put javascript environment defines up early for use by other js files.
        $strHtml .= '<script type="text/javascript">' . sprintf('qc.baseDir = "%s"; ', __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__) . sprintf('qc.jsAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __JS_ASSETS__) . sprintf('qc.phpAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __PHP_ASSETS__) . sprintf('qc.cssAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __CSS_ASSETS__) . sprintf('qc.imageAssets = "%s"; ', __VIRTUAL_DIRECTORY__ . __IMAGE_ASSETS__) . '</script>' . _nl();
        $strHtml .= QApplication::RenderFiles() . _nl();
        // add plugin and control js files
        // Render hidden controls related to the form
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormId" id="Qform__FormId" value="%s" />', $this->strFormId) . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormControl" id="Qform__FormControl" value="" />') . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormEvent" id="Qform__FormEvent" value="" />') . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormParameter" id="Qform__FormParameter" value="" />') . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormCallType" id="Qform__FormCallType" value="" />') . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormUpdates" id="Qform__FormUpdates" value="" />') . _nl();
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormCheckableControls" id="Qform__FormCheckableControls" value="" />') . _nl();
        // Serialize and write out the formstate
        $strHtml .= sprintf('<input type="hidden" name="Qform__FormState" id="Qform__FormState" value="%s" />', QForm::Serialize(clone $this)) . _nl();
        // close the form tag
        $strHtml .= "</form>";
        // Add the JavaScripts rendered above
        $strHtml .= $strEndScript;
        // close the body tag
        if ($this->blnRenderedBodyTag) {
            $strHtml .= '</body>';
        }
        /**** Cleanup ****/
        // Update Form Status
        $this->intFormStatus = QFormBase::FormStatusRenderEnded;
        // Display or Return
        if ($blnDisplayOutput) {
            if (!QApplication::$CliMode) {
                print $strHtml;
            }
            return null;
        } else {
            if (!QApplication::$CliMode) {
                return $strHtml;
            } else {
                return '';
            }
        }
    }
Exemple #9
0
 /**
  * Hide the dialog
  */
 public function Close()
 {
     \QApplication::ExecuteControlCommand($this->ControlId, $this->GetJqSetupFunction(), 'close', QJsPriority::Low);
 }
Exemple #10
0
 public function GetEndScript()
 {
     \QApplication::ExecuteControlCommand($this->ControlId, 'on', 'click', '.item', new \QJsClosure("jQuery(this).trigger('bscarousselect', this.id)"), \QJsPriority::High);
     return parent::GetEndScript();
 }
 /**
  * Sets focus to this control
  * TODO: Turn this into a specific command to avoid the javascript eval that happens on the other end.
  */
 public function Focus()
 {
     QApplication::ExecuteControlCommand($this->strControlId, 'focus');
 }
 public function __set($strName, $mixValue)
 {
     switch ($strName) {
         case "DefaultAreaCode":
             try {
                 return $this->strDefaultAreaCode = QType::Cast($mixValue, QType::String);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "Text":
         case "Value":
             parent::__set($strName, $mixValue);
             // Reformat after a change. Can't detect this kind of change just in JavaScript.
             QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), 'checkChanged', QJsPriority::Low);
             break;
         default:
             try {
                 parent::__set($strName, $mixValue);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 /**
  * An alert is closing, so we remove the dialog from the dom.
  *
  * @param $strFormId
  * @param $strControlId
  * @param $strParameter
  */
 protected function alert_Close($strFormId, $strControlId, $strParameter)
 {
     $this->Form->RemoveControl($this->ControlId);
     QApplication::ExecuteControlCommand($this->getJqControlId(), 'remove');
 }
 /**
  * Selects the currently active menu item, collapses all sub-menus and
  * triggers the menus select event.
  * 
  * 	* event Type: Event What triggered the selection.
  * @param $event
  */
 public function Select($event = null)
 {
     QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "select", $event, QJsPriority::Low);
 }
 /**
  * Serializes the sortables item ids into an array of string.
  * 
  * 	* options Type: Object Options to customize the serialization. 
  * 
  * 	* attribute (default: "id") Type: String The name of the attribute to
  * use for the values.
  * @param $options
  */
 public function ToArray($options)
 {
     QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "toArray", $options, QJsPriority::Low);
 }
 /**
  * Set the value for all handles.
  * 
  * 	* values Type: Array The values to set.
  * @param $values
  */
 public function Values3($values)
 {
     QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "values", $values, QJsPriority::Low);
 }
Exemple #17
0
 /**
  * Closes the alert using the Bootstrap javascript mechanism to close it. Removes the alert from the DOM.
  * Bootstrap has no mechanism for showing it again, so you will need
  * to redraw the control to show it.
  */
 public function Close()
 {
     $this->blnVisible = false;
     \QApplication::ExecuteControlCommand($this->ControlId, 'alert', 'close');
 }
 /**
  * Triggers a search event and invokes the data source if the event is
  * not canceled. Can be used by a selectbox-like button to open the
  * suggestions when clicked. When invoked with no parameters, the current
  * inputs value is used. Can be called with an empty string and
  * minLength: 0 to display all items.
  * 
  * 	* value Type: String
  * @param $value
  */
 public function Search($value = null)
 {
     QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "search", $value, QJsPriority::Low);
 }
 /**
  * Refresh the position and size of each selectee element. This method
  * can be used to manually recalculate the position and size of each
  * selectee when the autoRefresh option is set to false.
  * 
  * 	* This method does not accept any arguments.
  */
 public function Refresh()
 {
     QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "refresh", QJsPriority::Low);
 }
 /**
  * Add one or more items to the start of an API instance's result set.
  * @param $value_1
  */
 public function Unshift($value_1 = null)
 {
     QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction() . "().unshift", $value_1, QJsPriority::Low);
 }