From da84ed06a442b7dc5d5dd8b6544f2fd018ec2770 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Tue, 7 May 2013 22:16:19 +0300 Subject: [PATCH] delay admin scripts --- ipf/admin/media/css/forms.css | 9 ++- ipf/admin/templates/admin/base.html | 19 +++-- ipf/admin/templates/admin/change.html | 5 +- ipf/form.php | 70 +++++++++-------- ipf/form/widget.php | 6 ++ ipf/form/widget/htmlinput.php | 107 +++++++++++++------------- 6 files changed, 113 insertions(+), 103 deletions(-) diff --git a/ipf/admin/media/css/forms.css b/ipf/admin/media/css/forms.css index 2d112cf..adc1249 100644 --- a/ipf/admin/media/css/forms.css +++ b/ipf/admin/media/css/forms.css @@ -54,6 +54,12 @@ fieldset.collapsed .collapse-toggle { padding:3px 5px !important; background:tra /* MONOSPACE TEXTAREAS */ fieldset.monospace textarea { font-family:"Bitstream Vera Sans Mono",Monaco,"Courier New",Courier,monospace; } +/* INLINE */ +.inline-related table {width: 100%;} + +/* INLINE REORDER */ +.ItemsDragClass{background-color:#E3F3FE;} + /* SUBMIT ROW */ .submit-row { padding:5px 7px; text-align:right; background:white url(../img/nav-bg.gif) 0 100% repeat-x; border:1px solid #ccc; margin:5px 0; } .submit-row input { margin:0 0 0 5px; } @@ -69,6 +75,3 @@ fieldset.monospace textarea { font-family:"Bitstream Vera Sans Mono",Monaco,"Cou .flatpages-flatpage #id_content { height:40.2em; } .module table .vPositiveSmallIntegerField { width:2.2em; } -/* INLINE REORDER */ -.ItemsDragClass{background-color:#E3F3FE;} - diff --git a/ipf/admin/templates/admin/base.html b/ipf/admin/templates/admin/base.html index 59122bf..3c8a35e 100644 --- a/ipf/admin/templates/admin/base.html +++ b/ipf/admin/templates/admin/base.html @@ -11,16 +11,6 @@ -{block commonjs} -{if isset($form) && method_exists($form, 'render_commonjs')} -{$form.render_commonjs()|safe} -{else} - - - -{/if} -{/block} -
', + '

%s

', + true, + '
%s
'); } function __get($prop) @@ -280,33 +289,32 @@ class IPF_Form implements Iterator return new IPF_Form_BoundField($this, $this->fields[$key], $key); } - public function current() + public function current() { $field = current($this->fields); $name = key($this->fields); return new IPF_Form_BoundField($this, $field, $name); } - public function key() + public function key() { return key($this->fields); } - public function next() + public function next() { next($this->fields); } - public function rewind() + public function rewind() { reset($this->fields); } - public function valid() + public function valid() { return (false !== current($this->fields)); } - } function IPF_Form_htmlspecialcharsArray(&$item, $key) @@ -316,8 +324,8 @@ function IPF_Form_htmlspecialcharsArray(&$item, $key) function IPF_Form_renderErrorsAsHTML($errors) { - if (count($errors)==0) - return ''; + if (count($errors)==0) + return ''; $tmp = array(); foreach ($errors as $err) { $tmp[] = '
  • '.$err.'
  • '; diff --git a/ipf/form/widget.php b/ipf/form/widget.php index 5870938..8e7c235 100644 --- a/ipf/form/widget.php +++ b/ipf/form/widget.php @@ -17,6 +17,11 @@ class IPF_Form_Widget throw new IPF_Exception('Not Implemented.'); } + public function extra_js() + { + return array(); + } + protected function buildAttrs($attrs, $extra_attrs=array()) { return array_merge($this->attrs, $attrs, $extra_attrs); @@ -52,3 +57,4 @@ function IPF_Form_Widget_Attrs($attrs) } return ' '.implode(' ', $_tmp); } + diff --git a/ipf/form/widget/htmlinput.php b/ipf/form/widget/htmlinput.php index 3ed0f78..b8b26ec 100644 --- a/ipf/form/widget/htmlinput.php +++ b/ipf/form/widget/htmlinput.php @@ -6,8 +6,6 @@ class IPF_Form_Widget_HTMLInput extends IPF_Form_Widget public $theme = 'simple'; public $include_tinymce = true; - static $js_include = False; - public function __construct($attrs=array()) { $defaults = array('cols' => '70', @@ -46,57 +44,56 @@ class IPF_Form_Widget_HTMLInput extends IPF_Form_Widget } } $final_attrs = $this->buildAttrs(array('name' => $name), $extra_attrs); - $out = ''; - if (!IPF_Form_Widget_HTMLInput::$js_include){ - IPF_Form_Widget_HTMLInput::$js_include = true; - $out .= ''."\n"; - $out .=''; - } - return new IPF_Template_SafeString( - $out.sprintf('%s', - IPF_Form_Widget_Attrs($final_attrs), - htmlspecialchars($value, ENT_COMPAT, 'UTF-8')), - true); + return new IPF_Template_SafeString(''.htmlspecialchars($value, ENT_COMPAT, 'UTF-8').'', true); + } + + public function extra_js() + { + return array( + '', + '', + ); } -} \ No newline at end of file +} + -- 2.49.0