Skip to content

Commit 8471858

Browse files
committed
Random transitions
1 parent d9189f3 commit 8471858

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed

Ajax/common/traits/JqueryAjaxTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCal
5555

5656
protected function setAjaxDataCall($params){
5757
$result=null;
58-
if(!\is_callable($params) && \method_exists("Ajax\service\AjaxTransition",$params)){
58+
if(!\is_callable($params)){
5959
$result=function ($responseElement,$jqueryDone="html") use($params){
6060
return AjaxTransition::{$params}($responseElement,$jqueryDone);
6161
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
namespace Ajax\semantic\html\base\constants;
3+
use Ajax\common\BaseEnum;
4+
abstract class Transition extends BaseEnum {
5+
const SCALE="scale",
6+
FADE="fade",FADE_UP="fadeUp",FADE_DOWN="fadeDown",FADE_LEFT="fadeLeft",FADE_RIGHT="fadeRight",
7+
HORIZONTAL_FLIP="horizontalFlip",VERTICAL_FLIP="verticalFlip",
8+
DROP="drop",
9+
FLY_LEFT="flyLeft",FLY_RIGHT="flyRight",FLY_UP="flyUp",FLY_DOWN="flyDown",
10+
SWING_LEFT="swingLeft",SWING_RIGHT="swingRight",SWING_UP="swingUp",SWING_DOWN="swingDown",
11+
BROWSE="browse",BROWSE_RIGHT="browseRight",
12+
SLIDE_LEFT="slideLeft",SLIDE_RIGHT="slideRight",SLIDE_UP="slideUp",SLIDE_DOWN="slideDown",
13+
JIGGLE="jiggle",FLASH="flash",SHAKE="shake",PULSE="pulse",TADA="tada",BOUNCE="bounce";
14+
}

Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private function getDefaultButton($icon,$class=null,$visibleHover=true){
143143

144144
/**
145145
* @param boolean $visibleHover
146-
* @param boolean $generateBehavior
146+
* @param array $deleteBehavior
147147
* @param callable $callback
148148
* @return \Ajax\semantic\widgets\datatable\DataTableFieldAsTrait
149149
*/
@@ -164,7 +164,7 @@ public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEd
164164
return $this;
165165
}
166166

167-
public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=true,$callback=null){
167+
public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){
168168
$this->_deleteBehavior=$deleteBehavior;
169169
return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback);
170170
}

Ajax/service/AjaxTransition.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
<?php
22
namespace Ajax\service;
3+
use Ajax\semantic\html\base\constants\Transition;
4+
35
class AjaxTransition {
46
public static function none($responseElement,$jqueryDone="html"){
57
return "$({$responseElement}).{$jqueryDone}( data )";
68
}
79

8-
public static function fade($responseElement,$jqueryDone="html"){
10+
public static function jqFade($responseElement,$jqueryDone="html"){
911
return "$({$responseElement}).hide().{$jqueryDone}( data ).fadeIn()";
1012
}
1113

12-
public static function slide($responseElement,$jqueryDone="html"){
14+
public static function jqSlide($responseElement,$jqueryDone="html"){
1315
return "$({$responseElement}).hide().{$jqueryDone}( data ).slideDown()";
1416
}
1517

16-
public static function bSlidedown($responseElement,$jqueryDone="html"){
17-
return "$({$responseElement}).{$jqueryDone}( data ).transition('slide down in')";
18+
public static function random($responseElement,$jqueryDone="html"){
19+
$transitions=Transition::getConstantValues();
20+
$transition=$transitions[\rand(0,\sizeof($transitions)-1)];
21+
return self::__callStatic($transition, [$responseElement,$jqueryDone]);
1822
}
1923

20-
public static function bScale($responseElement,$jqueryDone="html"){
21-
return "$({$responseElement}).{$jqueryDone}( data ).transition('scale in')";
24+
public static function __callStatic($name, $arguments){
25+
if(\sizeof($arguments)==2){
26+
$responseElement=$arguments[0];
27+
$jqueryDone=$arguments[1];
28+
$name=JString::camelCaseToSeparated($name);
29+
return "$({$responseElement}).{$jqueryDone}( data ).transition('{$name} in')";
30+
}
2231
}
2332
}

Ajax/service/JString.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ public static function isBooleanTrue($value){
3131
public static function isBooleanFalse($value){
3232
return $value==0 || !$value;
3333
}
34+
35+
public static function camelCaseToSeparated($input,$separator=" "){
36+
return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator.'$0', $input));
37+
}
3438
}

0 commit comments

Comments
 (0)