phpMv  -UI toolkit 2.2.5
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
JsUtils Class Reference

JQuery PHP library. More...

+ Inheritance diagram for JsUtils:

Public Member Functions

 getUrl ($url)
 Generates an URL Used internally by phpMv. More...
 
 addViewElement ($identifier, $content, &$view)
 Adds the array of controls q in the $view element Used internally by phpMv. More...
 
 createScriptVariable (&$view, $view_var, $output)
 Creates the script variable script_foot Used internally by phpMv. More...
 
 forward ($initialController, $controller, $action, $params)
 Forwards to. More...
 
 renderContent ($initialControllerInstance, $viewName, $params=NULL)
 render the content of an existing view : $viewName and set the response to the modal content Used internally by phpMv More...
 
 fromDispatcher ($dispatcher)
 Collects url parts from the request dispatcher : controllerName, actionName, parameters Used internally by phpMv. More...
 
 ui (JqueryUI $ui=NULL)
 getter or setter of the jQuery-UI variable More...
 
 bootstrap (Bootstrap $bootstrap=NULL)
 getter or setter of the Twitter Bootstrap variable More...
 
 semantic (Semantic $semantic=NULL)
 getter or setter of the Semantic-UI variable More...
 
 config ($config=NULL)
 
 __construct ($params=array(), $injected=NULL)
 
 __set ($property, $value)
 
 getParam ($key)
 
 output ($array_js)
 Outputs the called javascript to the screen. More...
 
 compile (&$view=NULL, $view_var='script_foot', $script_tags=TRUE)
 gather together all script needing to be output More...
 
 clear_compile ()
 Clears the array of script events collected for output. More...
 
 getScript ($offset=0)
 
 scriptCount ()
 
 inline ($script, $cdata=TRUE)
 Outputs a <script> tag. More...
 
 generate_json ($result=NULL, $match_array_type=FALSE)
 Can be passed a database result or associative array and returns a JSON formatted string. More...
 
 _prep_args ($result, $is_key=FALSE)
 Ensures a standard json value and escapes values. More...
 
 _add_event ($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true)
 Constructs the syntax for an event, and adds to into the array for compilation. More...
 
 getInjected ()
 
- Public Member Functions inherited from JsUtilsEventsTrait
 _add_event ($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true)
 
 blur ($element='this', $js='')
 Outputs a javascript library blur event. More...
 
 change ($element='this', $js='', $preventDefault=false, $stopPropagation=false)
 Outputs a javascript library change event. More...
 
 click ($element='this', $js='', $ret_false=TRUE, $preventDefault=false, $stopPropagation=false)
 Outputs a javascript library click event. More...
 
 contextmenu ($element='this', $js='')
 Outputs a javascript library contextmenu event. More...
 
 dblclick ($element='this', $js='')
 Outputs a javascript library dblclick event. More...
 
 error ($element='this', $js='')
 Outputs a javascript library error event. More...
 
 focus ($element='this', $js='')
 Outputs a javascript library focus event. More...
 
 hover ($element='this', $over, $out)
 Outputs a javascript library hover event. More...
 
 keydown ($element='this', $js='')
 Outputs a javascript library keydown event. More...
 
 keypress ($element='this', $js='')
 Outputs a javascript library keypress event. More...
 
 keyup ($element='this', $js='')
 Outputs a javascript library keydown event. More...
 
 load ($element='this', $js='')
 Outputs a javascript library load event. More...
 
 mousedown ($element='this', $js='')
 Outputs a javascript library mousedown event. More...
 
 mouseout ($element='this', $js='')
 Outputs a javascript library mouseout event. More...
 
 mouseover ($element='this', $js='')
 Outputs a javascript library mouseover event. More...
 
 mouseup ($element='this', $js='')
 Outputs a javascript library mouseup event. More...
 
 unload ($element='this', $js='')
 Outputs a javascript library unload event. More...
 
 resize ($element='this', $js='')
 Outputs a javascript library resize event. More...
 
 scroll ($element='this', $js='')
 Outputs a javascript library scroll event. More...
 
- Public Member Functions inherited from JsUtilsActionsTrait
 _add_event ($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true)
 
 _genericCallValue ($jQueryCall, $element='this', $param="", $immediatly=false)
 Execute a generic jQuery call with a value. More...
 
 _genericCallElement ($jQueryCall, $to='this', $element, $immediatly=false)
 Execute a generic jQuery call with 2 elements. More...
 
 addClass ($element='this', $class='', $immediatly=false)
 add class to element More...
 
 after ($to, $element, $immediatly=false)
 Insert content, specified by the parameter, after each element in the set of matched elements. More...
 
 before ($to, $element, $immediatly=false)
 Insert content, specified by the parameter, before each element in the set of matched elements. More...
 
 attr ($element='this', $attributeName, $value="", $immediatly=false)
 Get or set the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched element. More...
 
 val ($element='this', $value='', $immediatly=false)
 Get or set the value of the first element in the set of matched elements or set one or more attributes for every matched element. More...
 
 html ($element='this', $value='', $immediatly=false)
 Get or set the html of an attribute for the first element in the set of matched elements. More...
 
 animate ($element='this', $params=array(), $speed='', $extra='', $immediatly=false)
 Outputs a javascript library animate event. More...
 
 append ($to, $element, $immediatly=false)
 Insert content, specified by the parameter $element, to the end of each element in the set of matched elements $to. More...
 
 prepend ($to, $element, $immediatly=false)
 Insert content, specified by the parameter $element, to the beginning of each element in the set of matched elements $to. More...
 
 fadeIn ($element='this', $speed='', $callback='', $immediatly=false)
 Execute a javascript library hide action. More...
 
 fadeOut ($element='this', $speed='', $callback='', $immediatly=false)
 Execute a javascript library hide action. More...
 
 slideUp ($element='this', $speed='', $callback='', $immediatly=false)
 Execute a javascript library slideUp action. More...
 
 removeClass ($element='this', $class='', $immediatly=false)
 Execute a javascript library removeClass action. More...
 
 slideDown ($element='this', $speed='', $callback='', $immediatly=false)
 Execute a javascript library slideDown action. More...
 
 slideToggle ($element='this', $speed='', $callback='', $immediatly=false)
 Execute a javascript library slideToggle action. More...
 
 hide ($element='this', $speed='', $callback='', $immediatly=false)
 Execute a javascript library hide action. More...
 
 toggle ($element='this', $speed='', $callback='', $immediatly=false)
 Execute a javascript library toggle action. More...
 
 toggleClass ($element='this', $class='', $immediatly=false)
 Execute a javascript library toggle class action. More...
 
 trigger ($element='this', $event='click', $immediatly=false)
 Execute all handlers and behaviors attached to the matched elements for the given event. More...
 
 show ($element='this', $speed='', $callback='', $immediatly=false)
 Execute a javascript library show action. More...
 
 sortable ($element, $options=array())
 Creates a jQuery sortable. More...
 
 tablesorter ($table='', $options='')
 Table Sorter Plugin. More...
 
 condition ($condition, $jsCodeIfTrue, $jsCodeIfFalse=null, $immediatly=false)
 Allows to attach a condition. More...
 
 doJQuery ($element, $jqueryCall, $param="", $jsCallback="")
 Calls the JQuery callback $someThing on $element with facultative parameter $param. More...
 
 doJQueryDeferred ($element, $jqueryCall, $param="", $jsCallback="")
 Calls the JQuery callback $someThing on $element with facultative parameter $param. More...
 
 doJQueryOn ($event, $element, $elementToModify, $jqueryCall, $param="", $parameters=array())
 Calls the JQuery callback $jqueryCall on $element with facultative parameter $param in response to an event $event. More...
 
 exec ($js, $immediatly=false)
 Executes the code $js. More...
 
 execAtLast ($js)
 Executes the code $js. More...
 
 execOn ($event, $element, $js, $parameters=array())
 Executes the javascript code $js when $event fires on $element. More...
 
 setJsonToElement ($json, $elementClass="_element", $immediatly=true)
 
 setDraggable ($element, $parameters=[])
 Sets an element draggable (HTML5 drag and drop) More...
 
 asDropZone ($element, $jsCallback="", $parameters=[])
 Declares an element as a drop zone (HTML5 drag and drop) More...
 
 interval ($jsCode, $time, $globalName=null, $immediatly=true)
 Calls a function or evaluates an expression at specified intervals (in milliseconds) More...
 
 clearInterval ($globalName, $immediatly=true)
 Clears an existing interval. More...
 
- Public Member Functions inherited from JsUtilsAjaxTrait
 getUrl ($url)
 
 _add_event ($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true)
 
 interval ($jsCode, $time, $globalName=null, $immediatly=true)
 
 setAjaxLoader ($loader)
 
 get ($url, $responseElement="", $parameters=[])
 Performs an ajax GET request. More...
 
 ajax ($method, $url, $responseElement="", $parameters=[])
 Performs an ajax request. More...
 
 ajaxInterval ($method, $url, $interval, $globalName=null, $responseElement="", $parameters=[])
 
 ajaxDeferred ($method, $url, $responseElement="", $parameters=[])
 Performs a deferred ajax request. More...
 
 json ($url, $method="get", $parameters=[])
 Performs an ajax request and receives the JSON data types by assigning DOM elements with the same name. More...
 
 jsonOn ($event, $element, $url, $method="get", $parameters=array())
 Makes an ajax request and receives the JSON data types by assigning DOM elements with the same name when $event fired on $element. More...
 
 jsonDeferred ($url, $method="get", $parameters=[])
 Prepares an ajax request delayed and receives the JSON data types by assigning DOM elements with the same name. More...
 
 jsonArray ($maskSelector, $url, $method="get", $parameters=[])
 Performs an ajax request and receives the JSON array data types by assigning DOM elements with the same name. More...
 
 jsonArrayDeferred ($maskSelector, $url, $method="get", $parameters)
 Peforms an ajax request delayed and receives a JSON array data types by copying and assigning them to the DOM elements with the same name. More...
 
 jsonArrayOn ($event, $element, $maskSelector, $url, $method="get", $parameters=array())
 Performs an ajax request and receives the JSON array data types by assigning DOM elements with the same name when $event fired on $element. More...
 
 getDeferred ($url, $responseElement="", $parameters=[])
 Prepares a Get ajax request for using on an event. More...
 
 getOn ($event, $element, $url, $responseElement="", $parameters=array())
 Performs a get to $url on the event $event on $element and display it in $responseElement. More...
 
 ajaxOn ($event, $element, $url, $responseElement="", $parameters=array())
 Performs an ajax request to $url on the event $event on $element and display it in $responseElement. More...
 
 ajaxOnClick ($element, $url, $responseElement="", $parameters=array())
 Performs a get to $url on the click event on $element and display it in $responseElement. More...
 
 getOnClick ($element, $url, $responseElement="", $parameters=array())
 Performs a get to $url on the click event on $element and display it in $responseElement. More...
 
 getHref ($element, $responseElement="", $parameters=array())
 Uses an hyperlink to make an ajax get request. More...
 
 postHref ($element, $responseElement="", $parameters=array())
 Uses an hyperlink to make an ajax get request. More...
 
 post ($url, $params="{}", $responseElement="", $parameters=[])
 Makes an ajax post. More...
 
 postDeferred ($url, $params="{}", $responseElement="", $parameters=[])
 Prepares a delayed ajax POST to use on an event. More...
 
 postOn ($event, $element, $url, $params="{}", $responseElement="", $parameters=array())
 Performs a post to $url on the event $event fired on $element and pass the parameters $params Display the result in $responseElement. More...
 
 postOnClick ($element, $url, $params="{}", $responseElement="", $parameters=array())
 Performs a post to $url on the click event fired on $element and pass the parameters $params Display the result in $responseElement. More...
 
 postForm ($url, $form, $responseElement, $parameters=[])
 Performs a post form with ajax. More...
 
 postFormDeferred ($url, $form, $responseElement, $parameters=[])
 Performs a delayed post form with ajax For use on an event. More...
 
 postFormOn ($event, $element, $url, $form, $responseElement="", $parameters=array())
 Performs a post form with ajax in response to an event $event on $element display the result in $responseElement. More...
 
 postFormOnClick ($element, $url, $form, $responseElement="", $parameters=array())
 Performs a post form with ajax in response to the click event on $element display the result in $responseElement. More...
 
- Public Member Functions inherited from JsUtilsInternalTrait
 addToCompile ($jsScript)
 

Protected Member Functions

 initialize ()
 To override for special initialization of the component. More...
 
- Protected Member Functions inherited from JsUtilsActionsTrait
 _showHideWithEffect ($action, $element='this', $speed='', $callback='', $immediatly=false)
 show or hide with effect More...
 
- Protected Member Functions inherited from JsUtilsAjaxTrait
 _ajax ($method, $url, $responseElement="", $parameters=[])
 
 createAjaxParameters (&$original, $parameters)
 
 implodeAjaxParameters ($ajaxParameters)
 
 _addJsCondition ($jsCondition, $jsSource)
 
 _getAjaxUrl ($url, $attr)
 
 onPopstate ()
 
 autoActiveLinks ($previousURL="window.location.href")
 
 _getOnAjaxDone ($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader=false, $history=null)
 
 _getResponseElement ($responseElement)
 
 _correctAjaxUrl ($url)
 
 addLoading (&$retour, $responseElement, $ajaxLoader=null)
 
 setAjaxDataCall ($params)
 
 setDefaultParameters (&$parameters, $default)
 
- Protected Member Functions inherited from JsUtilsInternalTrait
 _addToCompile ($jsScript)
 
 _compileLibrary (BaseGui $library, &$view=NULL)
 
 defer ($script)
 
 ready ($script)
 
 minify ($input)
 
 _open_script ($src='')
 Outputs an opening <script> More...
 
 _close_script ($extra="\)
 Outputs an closing </script> More...
 
 conflict ()
 

Protected Attributes

 $params
 
 $injected
 
 $_ui
 
 $_bootstrap
 
 $_semantic
 
 $config
 
- Protected Attributes inherited from JsUtilsEventsTrait
 $jquery_events
 
- Protected Attributes inherited from JsUtilsAjaxTrait
 $ajaxTransition
 
 $ajaxLoader ="<div class=\"ui active centered inline text loader\">Loading</div>"
 
- Protected Attributes inherited from JsUtilsInternalTrait
 $jquery_code_for_compile =array ()
 
 $jquery_code_for_compile_at_last =array ()
 

Private Member Functions

 _create_json ($json_result, $match_array_type)
 

Additional Inherited Members

- Static Public Member Functions inherited from JsUtilsAjaxTrait
static _correctParams ($params)
 
static _implodeParams ($parameters)
 

Detailed Description

JQuery PHP library.

Author
jcheron
Version
1.004 Apache 2 http://www.apache.org/licenses/ JsUtils Class : Service to be injected

Definition at line 24 of file JsUtils.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $params = array(),
  $injected = NULL 
)
Parameters
array$params['debug'=>true,'defer'=>false,'ajax'=>['ajaxTransition'=>null,'attr'=>'','historize'=>false,'attr'=>''],'beforeCompileHtml'=>null,'semantic'=>false,'bootstrap'=>false,'historize'=>true,'autoActiveLinks'=>true]
mixed$injectedoptional param for Symfony/Ubiquity

Definition at line 173 of file JsUtils.php.

Member Function Documentation

◆ __set()

__set (   $property,
  $value 
)

Definition at line 226 of file JsUtils.php.

◆ _add_event()

_add_event (   $element,
  $js,
  $event,
  $preventDefault = false,
  $stopPropagation = false,
  $immediatly = true 
)

Constructs the syntax for an event, and adds to into the array for compilation.

Parameters
string$elementThe element to attach the event to
string$jsThe code to execute
string$eventThe event to pass
boolean$preventDefaultIf set to true, the default action of the event will not be triggered.
boolean$stopPropagationPrevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.
Returns
string

Definition at line 428 of file JsUtils.php.

◆ _create_json()

_create_json (   $json_result,
  $match_array_type 
)
private

Definition at line 376 of file JsUtils.php.

◆ _prep_args()

_prep_args (   $result,
  $is_key = FALSE 
)

Ensures a standard json value and escapes values.

Parameters
mixed$result
boolean$is_key
Returns
string

Definition at line 402 of file JsUtils.php.

◆ addViewElement()

addViewElement (   $identifier,
  $content,
$view 
)
abstract

Adds the array of controls q in the $view element Used internally by phpMv.

Parameters
string$identifier
string$content
object$view

◆ bootstrap()

bootstrap ( Bootstrap  $bootstrap = NULL)

getter or setter of the Twitter Bootstrap variable

Parameters
Bootstrap$bootstrap
Returns
Bootstrap

Definition at line 122 of file JsUtils.php.

◆ clear_compile()

clear_compile ( )

Clears the array of script events collected for output.

Returns
void

Definition at line 320 of file JsUtils.php.

◆ compile()

compile ( $view = NULL,
  $view_var = 'script_foot',
  $script_tags = TRUE 
)

gather together all script needing to be output

Parameters
object$view
string$view_varview script variable name, default : script_foot
boolean$script_tags
Returns
string

Definition at line 278 of file JsUtils.php.

◆ config()

config (   $config = NULL)
Parameters
Config$config
Returns
Config

Definition at line 156 of file JsUtils.php.

◆ createScriptVariable()

createScriptVariable ( $view,
  $view_var,
  $output 
)
abstract

Creates the script variable script_foot Used internally by phpMv.

Parameters
object$view
string$view_vardefault: script_foot
string$output

◆ forward()

forward (   $initialController,
  $controller,
  $action,
  $params 
)
abstract

Forwards to.

$controller::$action and set the response to the modal content Used internally by phpMv

Parameters
object$initialController
string$controllera controller
string$actionan action
array$params

◆ fromDispatcher()

fromDispatcher (   $dispatcher)
abstract

Collects url parts from the request dispatcher : controllerName, actionName, parameters Used internally by phpMv.

Parameters
mixed$dispatcher
Returns
array

◆ generate_json()

generate_json (   $result = NULL,
  $match_array_type = FALSE 
)

Can be passed a database result or associative array and returns a JSON formatted string.

Parameters
mixed$resultresult set or array
bool$match_array_typematch array types (defaults to objects)
Returns
string json formatted string

Definition at line 359 of file JsUtils.php.

◆ getInjected()

getInjected ( )

Definition at line 447 of file JsUtils.php.

◆ getParam()

getParam (   $key)
Parameters
string$key

Definition at line 245 of file JsUtils.php.

◆ getScript()

getScript (   $offset = 0)

Definition at line 324 of file JsUtils.php.

◆ getUrl()

getUrl (   $url)
abstract

Generates an URL Used internally by phpMv.

Parameters
string$url
Returns
string the generated url

◆ initialize()

initialize ( )
protected

To override for special initialization of the component.

Definition at line 222 of file JsUtils.php.

◆ inline()

inline (   $script,
  $cdata = TRUE 
)

Outputs a <script> tag.

Parameters
string$script
boolean$cdataIf a CDATA section should be added
Returns
string

Definition at line 342 of file JsUtils.php.

◆ output()

output (   $array_js)

Outputs the called javascript to the screen.

Parameters
string$array_jscode to output
Returns
string

Definition at line 258 of file JsUtils.php.

◆ renderContent()

renderContent (   $initialControllerInstance,
  $viewName,
  $params = NULL 
)
abstract

render the content of an existing view : $viewName and set the response to the modal content Used internally by phpMv

Parameters
object$initialControllerInstance
string$viewName
array$paramsThe parameters to pass to the view

◆ scriptCount()

scriptCount ( )

Definition at line 331 of file JsUtils.php.

◆ semantic()

semantic ( Semantic  $semantic = NULL)

getter or setter of the Semantic-UI variable

Parameters
Semantic$semantic
Returns
Semantic

Definition at line 139 of file JsUtils.php.

◆ ui()

ui ( JqueryUI  $ui = NULL)

getter or setter of the jQuery-UI variable

Parameters
JqueryUI$ui
Returns
JqueryUI

Definition at line 105 of file JsUtils.php.

Field Documentation

◆ $_bootstrap

$_bootstrap
protected

Definition at line 37 of file JsUtils.php.

◆ $_semantic

$_semantic
protected

Definition at line 43 of file JsUtils.php.

◆ $_ui

$_ui
protected

Definition at line 32 of file JsUtils.php.

◆ $config

$config
protected

Definition at line 48 of file JsUtils.php.

◆ $injected

$injected
protected

Definition at line 27 of file JsUtils.php.

◆ $params

$params
protected

Definition at line 26 of file JsUtils.php.


The documentation for this class was generated from the following file: