Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into menu-jui
Browse files Browse the repository at this point in the history
Conflicts:
	lib/Form/Field.php
	lib/Menu/Basic.php
	lib/View/Button.php
  • Loading branch information
Romans Malinovskis committed Dec 6, 2012
2 parents e53e1f0 + 2e41d81 commit 803f180
Show file tree
Hide file tree
Showing 19 changed files with 353 additions and 261 deletions.
2 changes: 1 addition & 1 deletion lib/DB/dsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ function render_group(){
if(!$this->args['group'])return'';
$x=array();
foreach($this->args['group'] as $arg){
$x[]=$this->bt($arg);
$x[]=$this->consume($arg);
}
return 'group by '.implode(', ',$x);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function getBooleanValue($value){
reset($this->listData);
list($junk,$yes_value)=each($this->listData);
@list($junk,$no_value)=each($this->listData);
if($no_value==null)$no_value='';
if($no_value===null)$no_value='';
/* not to convert N to Y */
if ($yes_value == $value){
return $yes_value;
Expand Down
16 changes: 6 additions & 10 deletions lib/Form/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ function _cutField(){
if($this->api->jquery)$this->api->jquery->getJS($this);
throw new Exception_StopRender(
$this->template->renderRegion($this->template->tags['before_field']).
$this->getInput().
$this->template->renderRegion($this->template->tags['after_field'])
);
$this->getInput().
$this->template->renderRegion($this->template->tags['after_field'])
);
}
function setMandatory($mandatory=true){
$this->mandatory=$mandatory;
Expand All @@ -80,7 +80,7 @@ function displayFieldError($msg=null){
if(!isset($msg))$msg='Error in field "'.$this->caption.'"';

$this->form->js(true)
->atk4_form('fieldError',$this->name,$msg)
->atk4_form('fieldError',$this->short_name,$msg)
->execute();

$this->form->errors[$this->short_name]=$msg;
Expand Down Expand Up @@ -254,6 +254,7 @@ function getInput($attr=array()){
return $this->getTag('input',
array_merge(array(
'name'=>$this->name,
'data-shortname'=>$this->short_name,
'id'=>$this->name,
'value'=>$this->value,
),$attr,$this->attr)
Expand Down Expand Up @@ -291,7 +292,6 @@ function render(){
}
$this->output($this->template->render());
}

function getTag($tag, $attr=null, $value=null){
/**
* Draw HTML attribute with supplied attributes.
Expand Down Expand Up @@ -471,11 +471,7 @@ function init(){
}

function getInput($attr=array()){
if (isset($this->value_list)){
return $this->value_list[$this->value];
} else {
return $this->value;
}
return nl2br(isset($this->value_list) ? $this->value_list[$this->value] : $this->value);
}
function setValueList($list){
$this->value_list = $list;
Expand Down
1 change: 1 addition & 0 deletions lib/Form/Field/DropDown.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function validate(){
function getInput($attr=array()){
$output=$this->getTag('select',array_merge(array(
'name'=>$this->name,
'data-shortname'=>$this->short_name,
'id'=>$this->name,
),
$attr,
Expand Down
10 changes: 5 additions & 5 deletions lib/Grid/Advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class Grid_Advanced extends Grid_Basic {
public $last_column;
public $sortby='0';
public $sortby_db=null;
public $not_found=false;

public $displayed_rows=0;
public $buttonset=null;

private $totals_title_field=null;
private $totals_title="";
Expand Down Expand Up @@ -105,8 +103,10 @@ function removeColumn($name){
return $this;
}
function addButton($label){
return $this
->add('Button','gbtn'.count($this->elements),'grid_buttons')
if(!$this->buttonset)
$this->buttonset=$this->add('ButtonSet',null,'grid_buttons');
return $this->buttonset
->add('Button','gbtn'.count($this->elements))
->setLabel($label);
}
function addQuickSearch($fields,$class='QuickSearch'){
Expand Down
42 changes: 21 additions & 21 deletions lib/Menu/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,34 @@ function init(){
parent::init();
}
function defaultTemplate(){
return array('menu','Menu');
}
function addMenuItem($page,$label=null){
if(!$label){
$label=ucwords(str_replace('_',' ',$page));
}
return array('menu','Menu');
}
function addMenuItem($page,$label=null){
if(!$label){
$label=ucwords(str_replace('_',' ',$page));
}
$id=$this->name.'_i'.count($this->items);
$label=$this->api->_($label);
$label=$this->api->_($label);
$js_page=null;
if($page instanceof jQuery_Chain){
$js_page="#";
$this->js('click',$page)->_selector('#'.$id);
$page=$id;
}
$this->items[]=array(
'id'=>$id,
'page'=>$page,
'href'=>$js_page?:$this->api->url($page),
'label'=>$label,
$this->class_tag=>$this->isCurrent($page)?$this->current_menu_class:$this->inactive_menu_class,
);
return $this;
}
protected function getDefaultHref($label){
$href=preg_replace('/[^a-zA-Z0-9]/','',$label);
if($label[0]==';'){
$label=substr($label,1);
$href=';'.$href;
$this->items[]=array(
'id'=>$id,
'page'=>$page,
'href'=>$js_page?:$this->api->url($page),
'label'=>$label,
$this->class_tag=>$this->isCurrent($page)?$this->current_menu_class:$this->inactive_menu_class,
);
return $this;
}
protected function getDefaultHref($label){
$href=preg_replace('/[^a-zA-Z0-9]/','',$label);
if($label[0]==';'){
$label=substr($label,1);
$href=';'.$href;
}
return $href;
}
Expand Down
4 changes: 0 additions & 4 deletions lib/Page/Tester.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ function init(){
function ticker(){
$this->cnt++;
}
public $cnt;
function ticker(){
$this->cnt++;
}
function silentTest($test_obj=null){
if(!$test_obj)$test_obj=$this;

Expand Down
11 changes: 6 additions & 5 deletions lib/PathFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,12 @@ function getURL($file_path=null){
}else
throw new BaseException('Unable to determine URL');

if($file_path){
if(substr($url,-1)!='/')$url.='/';
$url.=$file_path;
}
return $url;
if($file_path){
if(substr($url,-1)!='/')$url.='/';
$url.=$file_path;
}
$url=str_replace('/./','/',$url);
return $url;
}

function getPath($file_path=null){
Expand Down
14 changes: 3 additions & 11 deletions lib/QuickSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,19 @@ class QuickSearch extends Filter {
/*
* Quicksearch represents one-field filter which goes perfectly with a grid
*/

public $js_widget='ui.atk4_form';
public $icon;// to configure icon
var $region=null;
var $region_url=null;
public $search_cross=null;
public $grid;
public $icon='search'; // to configure icon

function init(){
parent::init();
//$this->addClass('span3');

$this->addClass('float-right stacked span4');
$this->addClass('float-right span4 atk-quicksearch');
$this->template->trySet('fieldset','atk-row');
$this->template->tryDel('button_row');
$this->search_field=$this->addField('line','q','')->setNoSave();
$this->search_field->addButton('')
->setHtml(' ')
->setIcon('search')
->setIcon($this->icon)
->js('click',$this->js()->submit());
;
}
function useFields($fields){
$this->fields=$fields;
Expand Down
2 changes: 1 addition & 1 deletion lib/View/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function setClass($class){
/** redefine this method with empty one if you DONT want buttons to use jQuery UI */
function jsButton(){
$opt=$this->options;
if($this->icon)$opt['icons']['primary']='ui-icon-'.$this->icon;
if($this->icon)$opt['icons']['primary']=$this->icon;
if(!($this->owner instanceof ButtonSet))$this->js(true)->button($opt);
}
function render(){
Expand Down
6 changes: 6 additions & 0 deletions templates/js/atk4_univ.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ $.each({
setTimeout: function(code,delay){
setTimeout(code,delay);
},
setInterval: function(code,delay){
return setInterval(code,delay);
},
clearInterval: function(a){
clearInterval(a);
},
displayAlert: function(a){
alert(a);
},
Expand Down
18 changes: 11 additions & 7 deletions templates/js/start-atk4.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,17 @@ $.extend($.atk4,{
Also relative URLs like url(../images) will not break.
*/
includeCSS: function(url){
if(this._isIncluded(url))return;

$("<link>", {
rel: "stylesheet",
type: "text/css",
href: url
}).appendTo("head");
if(this._isIncluded(url))return;

/*
Dynamically loads CSS. Now works for IE too as noted in:
http://stackoverflow.com/questions/1184950/dynamically-loading-css-stylesheet-doesnt-work-on-ie
see comment by ekerner on Apr 4 11 at 16:44
*/
$("<link>")
.appendTo($('head'))
.attr({type : 'text/css', rel : 'stylesheet'})
.attr('href', url);
},
_isIncluded: function(url){
if(this._includes[url])return true;
Expand Down
8 changes: 4 additions & 4 deletions templates/js/ui.atk4_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ jQuery.widget("ui.atk4_form", {
return this.options.error_handler(field_name,error);
}

var field=
typeof(field_name)=='string'?
$('#'+this.id+'_'+field_name):
field_name;
var field=
typeof(field_name)=='string'?
$('[data-shortname="'+field_name+'"]','#'+this.id):
field_name;

if(!field.length){
field=this.form.find('[name="'+field_name+'"]');
Expand Down
21 changes: 11 additions & 10 deletions templates/js/ui.atk4_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@

$.widget('ui.atk4_loader', {

/*
base_url will contain URL which will be used to refresh contents.
*/
options: {
/*
base_url will contain URL which will be used to refresh contents.
*/
base_url: undefined,

/*
loading will be set to true, when contents of this widgets are being
loaded.
*/
loading: false,

cogs: '<div class="loading"><i></i><i></i></div>',

/*
when we are loading URLs, we will automaticaly pass arguments to cut stuff out
*/
cut_mode: 'page',
cut: '1',
history: false,

/*
Helper contains some extra thingies
*/
history: false
},

/*
Helper contains some extra thingies
*/
helper: undefined,
loader: undefined,

Expand Down Expand Up @@ -250,8 +250,9 @@ $.widget('ui.atk4_loader', {
if(!f.hasClass('nofocus'))f.focus();
});
},function(){ // second callback, which is always called, when loading is completed
self.loader.hide();
self.loader.hide();
self.loading=false;
el.trigger('after_html_loaded');
});
},
/*
Expand Down
Loading

0 comments on commit 803f180

Please sign in to comment.