예제 #1
0
 function requiresJsAndCss()
 {
     $elements = $this->field->headElements(new Parameter('notUsed', new StringType()));
     $this->assert(array_slice($elements, 0, 4), [HeadElements::jquery(), HeadElements::bootstrap(), HeadElements::bootstrapJs(), HeadElements::fontAwesome()]);
     $this->assert->contains((string) $elements[4], 'summernote.min.css');
     $this->assert->contains((string) $elements[5], 'summernote.min.js');
     $this->assert->contains((string) $elements[6], "\$(this).val(\$(this).code());");
 }
예제 #2
0
 function requireHeadElementsOfInnerField()
 {
     M::stub($this->inside->headElements(Arg::any()))->will()->return_([new Element('link', ['src' => 'foo.bar']), new Element('link', ['src' => 'bar.bas'])]);
     $headElements = implode('', $this->field->headElements($this->param('foo')));
     $this->assert->contains($headElements, (string) HeadElements::jquery());
     $this->assert->contains($headElements, 'src="foo.bar"');
     $this->assert->contains($headElements, 'src="bar.bas"');
 }
예제 #3
0
파일: RangeField.php 프로젝트: rtens/domin
 /**
  * @param Parameter $parameter
  * @return array|Element[]
  */
 public function headElements(Parameter $parameter)
 {
     $elements = [HeadElements::jquery(), HeadElements::jqueryUi(), HeadElements::jqueryUiCss()];
     if ($this->mobile->isMobile()) {
         $elements[] = HeadElements::script('//cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js');
     }
     return $elements;
 }
예제 #4
0
 function noHeadElements()
 {
     $elements = $this->field->headElements($this->param);
     $this->assert($elements[0], HeadElements::bootstrap());
     $this->assert($elements[1], HeadElements::jquery());
     $this->assert->contains((string) $elements[2], 'bootstrap-switch.min.css');
     $this->assert->contains((string) $elements[3], 'bootstrap-switch.min.js');
     $this->assert->contains((string) $elements[4], "\$('.boolean-switch').bootstrapSwitch(");
 }
예제 #5
0
파일: Panel.php 프로젝트: jonfm/domin
 /**
  * @param RendererRegistry $renderers
  * @return \rtens\domin\delivery\web\Element[]
  */
 public function headElements(RendererRegistry $renderers)
 {
     $elements = [HeadElements::jquery()];
     $renderer = $renderers->getRenderer($this->content);
     if ($renderer instanceof WebRenderer) {
         $elements = array_merge($elements, $renderer->headElements($this->content));
     }
     return $elements;
 }
예제 #6
0
 function requiresLibraries()
 {
     $headElements = implode('', $this->field->headElements(new Parameter('foo', new UnknownType())));
     $this->assert->contains($headElements, (string) HeadElements::jquery());
     $this->assert->contains($headElements, (string) HeadElements::bootstrap());
     $this->assert->contains($headElements, (string) HeadElements::bootstrapJs());
     $this->assert->contains($headElements, 'moment.js');
     $this->assert->contains($headElements, 'bootstrap-datetimepicker.min.js');
     $this->assert->contains($headElements, 'bootstrap-datetimepicker.min.css');
 }
예제 #7
0
파일: MultiField.php 프로젝트: jonfm/domin
 /**
  * @param Parameter $parameter
  * @return array|Element[]
  */
 public function headElements(Parameter $parameter)
 {
     $ownElements = [HeadElements::jquery(), new Element('script', [], ["\$(function () {\n                    \$('.multi-control.not-selected').hide().appendTo('body');\n                });"])];
     foreach ($this->getTypes($parameter) as $i => $type) {
         $optionParameter = new Parameter($parameter->getName(), $type);
         $optionElements = $this->getField($optionParameter)->headElements($optionParameter);
         $ownElements = array_merge($ownElements, $optionElements);
     }
     return $ownElements;
 }
예제 #8
0
 function collectHeadElements()
 {
     $this->action->givenTheAction('foo');
     $this->givenAWebFieldRequiringTheHeadElements(function (Parameter $parameter) {
         return [new Element('one'), new Element($parameter->getName())];
     });
     $this->whenIExecute('foo');
     $this->thenThereShouldBeAHeadElement(HeadElements::jquery());
     $this->thenThereShouldBeAHeadElement(HeadElements::jqueryUi());
     $this->thenThereShouldBeAHeadElement(HeadElements::bootstrap());
     $this->thenThereShouldBeAHeadElement(HeadElements::bootstrapJs());
     $this->thenThereShouldBeAHeadElement('<one></one>');
     $this->thenThereShouldBeAHeadElement('<foo></foo>');
 }
예제 #9
0
 /**
  * @param DataTable $value
  * @return array|Element[]
  */
 public function headElements($value)
 {
     $elements = [];
     $table = $value->getTable();
     $renderer = $this->renderers->getRenderer($table);
     if ($renderer instanceof WebRenderer) {
         $elements = $renderer->headElements($table);
     }
     $options = json_encode($value->getOptions());
     $elements[] = HeadElements::style('//cdn.datatables.net/1.10.7/css/jquery.dataTables.min.css');
     $elements[] = HeadElements::script('//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js');
     $elements[] = new Element('script', [], ["\n            \$(function () {\n                \$('.data-table > table').dataTable({$options});\n            });\n        "]);
     return $elements;
 }
예제 #10
0
 private function doExecute($actionId = null, $mayBeModifying = false)
 {
     if (!$actionId) {
         $actionId = $this->app->defaultAction;
     }
     if (!$this->app->access->isPermitted($actionId)) {
         throw new \Exception('Permission denied.');
     }
     $action = $this->getAction($actionId);
     $headElements = self::baseHeadElements();
     $form = new ActionForm($this->reader, $this->app->fields, $action, $actionId);
     $headElements = array_merge($headElements, $form->getHeadElements());
     if ($mayBeModifying || !$action->isModifying()) {
         $executor = new Executor($this->app->actions, $this->app->fields, $this->reader, $this->app->access);
         $result = new ActionResult($executor, $this->app->renderers, $action, $actionId, $this->crumbs);
         $headElements = array_merge($headElements, $result->getHeadElements());
         $confirm = false;
     } else {
         $confirm = true;
     }
     return (new Template(__DIR__ . '/ExecutionTemplate.html.php'))->render(['name' => $this->app->name, 'caption' => $action->caption(), 'menu' => $this->app->menu->render(), 'breadcrumbs' => $this->assembleBreadCrumbs(), 'action' => $form->getModel(), 'result' => isset($result) ? $result->getModel() : null, 'headElements' => HeadElements::filter($headElements), 'executed' => isset($result) && $result->wasExecuted(), 'confirmationRequired' => $confirm, 'token' => $action->isModifying() && $this->app->token ? ['name' => self::TOKEN_ARG, 'value' => $this->app->token->generate($actionId)] : null]);
 }
예제 #11
0
 /**
  * @param mixed $value
  * @return array|\rtens\domin\delivery\web\Element[]
  */
 public function headElements($value)
 {
     $elements = parent::headElements($value);
     $elements[] = HeadElements::script('http://dima117.github.io/Chart.Scatter/Chart.Scatter.min.js');
     return $elements;
 }
예제 #12
0
파일: ImageField.php 프로젝트: jonfm/domin
 /**
  * @param Parameter $parameter
  * @return array|\rtens\domin\delivery\web\Element[]
  */
 public function headElements(Parameter $parameter)
 {
     $script = file_get_contents(__DIR__ . '/js/ImageField.js');
     $script = str_replace('$cropperOptions$', json_encode($this->getCropperOptions()), $script);
     $script = str_replace('$webcamjsOptions$', json_encode($this->getWebcamOptions()), $script);
     return [HeadElements::jquery(), HeadElements::bootstrapJs(), HeadElements::bootstrap(), HeadElements::script('//cdnjs.cloudflare.com/ajax/libs/cropper/0.9.3/cropper.min.js'), HeadElements::style('//cdnjs.cloudflare.com/ajax/libs/cropper/0.9.3/cropper.min.css'), HeadElements::script('http://pixlcore.com/demos/webcamjs/webcam.js'), new Element('script', [], [$script])];
 }
예제 #13
0
 /**
  * @param string $__action
  * @param WebRequest $__request <-
  * @return array
  * @throws \Exception
  */
 public function doGet($__action, WebRequest $__request)
 {
     $headElements = self::baseHeadElements();
     $renderedAction = null;
     $caption = 'Error';
     $crumbs = [];
     $reader = new RequestParameterReader($__request);
     try {
         $action = $this->app->actions->getAction($__action);
         $caption = $action->caption();
         $executor = new WebExecutor($this->app->actions, $this->app->fields, $this->app->renderers, $reader);
         $executor->restrictAccess($this->app->getAccessControl($__request));
         $result = $executor->execute($__action);
         if (!$result instanceof RedirectResult) {
             $crumbs = $this->updateCrumbs($__action, $result, $__request, $reader);
             $headElements = array_merge($headElements, $executor->getHeadElements());
             $actionParameter = new Parameter($__action, new ClassType(get_class($action)));
             $actionField = $this->app->fields->getField($actionParameter);
             if (!$actionField instanceof WebField) {
                 throw new \Exception(get_class($actionField) . " must implement WebField");
             }
             $renderedAction = $actionField->render($actionParameter, $this->readParameters($action, $reader));
             $headElements = array_merge($headElements, $actionField->headElements($actionParameter));
         }
     } catch (\Exception $e) {
         $result = new FailedResult($e);
     }
     $resultModel = $this->assembleResult($result, $__request);
     return array_merge(['name' => $this->app->name, 'menu' => $this->app->menu->render($__request), 'breadcrumbs' => $crumbs ? array_slice($crumbs, 0, -1) : null, 'current' => $crumbs ? array_slice($crumbs, -1)[0]['target'] : null, 'caption' => $caption, 'action' => $renderedAction, 'headElements' => HeadElements::filter($headElements)], $resultModel);
 }
예제 #14
0
 function requireTouchPunchForMobile()
 {
     Mockster::stub($this->detector->isMobile())->will()->return_(true);
     $this->assert->contains($this->field->headElements(new Parameter('foo', new ArrayType(new UnknownType()))), HeadElements::script('//cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js'));
 }
예제 #15
0
 /**
  * @param Parameter $parameter
  * @return array|Element[]
  */
 public function headElements(Parameter $parameter)
 {
     return [HeadElements::bootstrap(), HeadElements::jquery(), HeadElements::style('//cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/css/bootstrap3/bootstrap-switch.min.css'), HeadElements::script('//cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/js/bootstrap-switch.min.js'), new Element('script', [], ["\n                \$(function () {\n                    \$('.boolean-switch').bootstrapSwitch({\n                        size: 'small',\n                        onColor: 'success',\n                        onText: 'Yes',\n                        offText: 'No'\n                    });\n                });"])];
 }
예제 #16
0
파일: HtmlField.php 프로젝트: jonfm/domin
 /**
  * @param Parameter $parameter
  * @return array|Element[]
  */
 public function headElements(Parameter $parameter)
 {
     return [HeadElements::jquery(), HeadElements::bootstrap(), HeadElements::bootstrapJs(), HeadElements::fontAwesome(), HeadElements::style('//cdnjs.cloudflare.com/ajax/libs/summernote/0.6.10/summernote.min.css'), HeadElements::script('//cdnjs.cloudflare.com/ajax/libs/summernote/0.6.10/summernote.min.js'), new Element('script', [], ["\n                \$(function() {\n                    \$('.summernote').summernote({\n                        onKeyup: function(e) {\n                            \$(this).val(\$(this).code());\n                        }\n                    });\n                    \$('.summernote').on('invalid', function (e) {\n                        var editor = \$(e.target).siblings('.note-editor');\n                        editor.popover({\n                            content: 'Please fill out this field.',\n                            placement: 'bottom',\n                            trigger: 'manual'\n                        });\n                        editor.popover('show');\n\n                        editor.click(function () {\n                            editor.popover('hide');\n                        });\n                    });\n                });\n            "])];
 }
예제 #17
0
 /**
  * @param Parameter $parameter
  * @return array|Element[]
  */
 public function headElements(Parameter $parameter)
 {
     return [HeadElements::jquery(), HeadElements::bootstrap(), HeadElements::bootstrapJs(), HeadElements::script('//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js'), HeadElements::script('//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.14.30/js/bootstrap-datetimepicker.min.js'), HeadElements::style('//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.14.30/css/bootstrap-datetimepicker.min.css'), new Element('script', [], ['var dateTimePickerSettings = ' . json_encode($this->getOptions()) . ';'])];
 }
예제 #18
0
 /**
  * @param ActionList $value
  * @return array|Element[]
  */
 public function headElements($value)
 {
     return [HeadElements::jquery(), HeadElements::bootstrap(), HeadElements::bootstrapJs()];
 }
예제 #19
0
 /**
  * @param Parameter $parameter
  * @return array|\rtens\domin\delivery\web\Element[]
  */
 public function headElements(Parameter $parameter)
 {
     return [HeadElements::jquery(), HeadElements::style('//cdn.rawgit.com/rtens/bootstrap-combobox/cffe84e7/css/bootstrap-combobox.css'), HeadElements::script('//cdn.rawgit.com/rtens/bootstrap-combobox/cffe84e7/js/bootstrap-combobox.js'), new Element('style', [], ['.typeahead-long { width:100% }'])];
 }
예제 #20
0
 /**
  * @param Parameter $parameter
  * @return array|Element[]
  */
 public function headElements(Parameter $parameter)
 {
     $innerParameter = $this->getInnerParameter($parameter);
     return array_merge($this->getInnerField($innerParameter)->headElements($innerParameter), [HeadElements::jquery(), new Element('script', [], ["\$(function () {\n                    \$('.null-nullable').hide().appendTo('body');\n                });"])]);
 }
예제 #21
0
파일: ArrayField.php 프로젝트: rtens/domin
 /**
  * @param Parameter $parameter
  * @return array|Element[]
  */
 public function headElements(Parameter $parameter)
 {
     return array_merge([HeadElements::jquery(), HeadElements::jqueryUi(), new Element('script', [], ["\$(function () {\n                    \$('.array-new-items').appendTo('body');\n                    \$('.array-items').sortable({handle:'.sortable-handle'});\n                    \$('.array-items .sortable-handle').disableSelection();\n                });"])], $this->mobile->isMobile() ? [HeadElements::script('//cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js')] : [], $this->itemHeadElements($this->makeInnerParameter($parameter)));
 }
예제 #22
0
 /**
  * @param WebRequest $request <-
  * @return array
  */
 public function doGet(WebRequest $request)
 {
     $this->resetBreadCrumbs();
     return ['name' => $this->app->name, 'menu' => $this->app->menu->render($request), 'action' => $this->assembleActions($request->getContext()), 'headElements' => [(string) HeadElements::jquery(), (string) HeadElements::bootstrap(), (string) HeadElements::bootstrapJs()]];
 }
예제 #23
0
 /**
  * @param mixed $value
  * @return array|Element[]
  */
 public function headElements($value)
 {
     return [HeadElements::script('//cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js')];
 }