6 public static $preventDefault =
"\nif(event && event.preventDefault) event.preventDefault();\n";
8 public static $stopPropagation =
"\nif(event && event.stopPropagation) event.stopPropagation();\n";
11 return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;dt.setData("text/plain",JSON.stringify({id:$(event.target).attr("id"),data:$(event.target).attr("' . $attr .
'")}));';
14 public static function dropZone($jqueryDone, $jsCallback =
"") {
15 $done = ($jqueryDone !=
null) ?
'$(event.target).' . $jqueryDone .
'($("#"+_data.id));' :
'';
16 return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var _data=JSON.parse(dt.getData("text/plain"));' . $done .
'var data=_data.data;' . $jsCallback;
20 $done =
'event.target.upload=formData;$(event.target).trigger("upload");';
21 return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var files=dt.files;var formData = new FormData();for (var i = 0; i < files.length; i++) {formData.append("file-"+i,files[i]);}' . $done . $jsCallback;
25 if ($expression ==
null) {
28 return \strrpos($expression,
'this') !==
false || \strrpos($expression,
'event') !==
false || \strrpos($expression,
'self') !==
false;
36 return "$('input:text, .ui.button', '#{$id}').on('click', function (e) {e.preventDefault();\$('input:file', '#{$id}').click();});
37 $('input:file', '#{$id}').on('change', function (e) {if(e.target.files.length){var name = e.target.files[0].name;$('input:text', $(e.target).parent()).val(name);}});";
49 if (self::containsCode($element) ===
false) {
50 $element =
'"' . addslashes($element ??
'') .
'"';
64 if (\is_array($value)) {
65 $value = implode(
",", $value);
67 if (self::containsCode($value) ===
false) {
68 $value = \str_replace([
75 $value =
'"' . $value .
'"';
77 return trim($value,
"%");
static startswith($hay, $needle)
static draggable($attr="id")
static containsCode($expression)
static fileUploadBehavior($id='')
static isFunction($jsCode)
static prep_jquery_selector($value)
static dropZone($jqueryDone, $jsCallback="")
static prep_value($value)
Puts HTML values in quotes for use in jQuery code unless the supplied value contains the Javascript '...
static prep_element($element)
Puts HTML element in quotes for use in jQuery code unless the supplied element is the Javascript 'thi...
static fileDropZone($jsCallback="")