phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
JsUtils Class Reference

JQuery PHP library. More...

+ Inheritance diagram for JsUtils:

Public Member Functions

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

Protected Member Functions

 initialize ()
 To override for special initialization of the component.
 
- Protected Member Functions inherited from JsUtilsActionsTrait
 _showHideWithEffect ($action, $element='this', $speed='', $callback='', $immediatly=false)
 show or hide with effect
 
- 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, $history=null)
 
 removeLoader ($hasLoader)
 
 _getResponseElement ($responseElement)
 
 _getFormElement ($formElement)
 
 _correctAjaxUrl ($url)
 
 addLoading (&$retour, $responseElement, $ajaxLoader=null)
 
 addResponseLoading (&$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>
 
 _close_script ($extra="\n")
 Outputs an closing </script>
 
 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, $ajaxParameters=[])
 
static _implodeParams ($parameters)
 

Detailed Description

JQuery PHP library.

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

Definition at line 23 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

Reimplemented in JsUtils.

Definition at line 195 of file JsUtils.php.

Member Function Documentation

◆ __set()

__set (   $property,
  $value 
)

Definition at line 265 of file JsUtils.php.

◆ _add_event()

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

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.
boolean$immediatlyif true, execute this code immediatly
boolean|stringfalse for an event associated with existing DOM elements, or a string selector and then the event is dynamically associated to all elements created in this selector
Returns
string

Reimplemented from JsUtilsEventsTrait.

Definition at line 488 of file JsUtils.php.

◆ _create_json()

_create_json (   $json_result,
  $match_array_type 
)
private

Definition at line 417 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 443 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

Reimplemented in _JsUtils, JsUtils, JsUtils, JsUtils, JsUtils, JsUtils, and JsUtils.

◆ bootstrap()

bootstrap ( Bootstrap  $bootstrap = NULL)

getter or setter of the Twitter Bootstrap variable

Parameters
Bootstrap$bootstrap
Returns
Bootstrap

Definition at line 140 of file JsUtils.php.

◆ clear_compile()

clear_compile ( )

Clears the array of script events collected for output.

Returns
void

Definition at line 360 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 318 of file JsUtils.php.

◆ config()

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

Definition at line 175 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

Reimplemented in _JsUtils, JsUtils, JsUtils, JsUtils, JsUtils, JsUtils, and JsUtils.

◆ 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

Reimplemented in JsUtils, JsUtils, _JsUtils, JsUtils, JsUtils, JsUtils, and JsUtils.

◆ fromDispatcher()

fromDispatcher (   $dispatcher)
abstract

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

Parameters
mixed$dispatcher
Returns
array

Reimplemented in _JsUtils, JsUtils, JsUtils, JsUtils, JsUtils, JsUtils, and JsUtils.

◆ 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 400 of file JsUtils.php.

◆ getInjected()

getInjected ( )

Definition at line 512 of file JsUtils.php.

◆ getParam()

getParam (   $key)
Parameters
string$key

Definition at line 285 of file JsUtils.php.

◆ getScript()

getScript (   $offset = 0)

Definition at line 364 of file JsUtils.php.

◆ getUrl()

getUrl (   $url)
abstract

Generates an URL Used internally by phpMv.

Parameters
string$url
Returns
string the generated url

Reimplemented from JsUtilsAjaxTrait.

Reimplemented in _JsUtils, JsUtils, JsUtils, JsUtils, JsUtils, JsUtils, and JsUtils.

◆ initialize()

initialize ( )
protected

To override for special initialization of the component.

Definition at line 263 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

Reimplemented in JsUtils.

Definition at line 384 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 297 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

Reimplemented in _JsUtils, JsUtils, JsUtils, JsUtils, JsUtils, JsUtils, and JsUtils.

◆ scriptCount()

scriptCount ( )

Definition at line 372 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 158 of file JsUtils.php.

◆ setParam()

setParam ( string  $param,
  $value 
)

Definition at line 516 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 122 of file JsUtils.php.

Field Documentation

◆ $_bootstrap

$_bootstrap
protected

Definition at line 39 of file JsUtils.php.

◆ $_semantic

$_semantic
protected

Definition at line 45 of file JsUtils.php.

◆ $_ui

$_ui
protected

Definition at line 33 of file JsUtils.php.

◆ $config

$config
protected

Definition at line 51 of file JsUtils.php.

◆ $injected

$injected
protected

Definition at line 27 of file JsUtils.php.

◆ $params

$params
protected

Definition at line 25 of file JsUtils.php.


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