Smutty
MVC Framework
View Code: function.droppable
Browse: All · Classes · Plugins
1
<?php
2
3
/**
4
* returns the html for a droppable element
5
*
6
* @param array $params assoc array of params
7
* @param Smarty $smarty smarty object
8
* @return html
9
*
10
*/
11
13
14
$smarty->depend( 'modifier', 'escape' );
15
16
$id = $params['id'] ? $params['id'] : Smutty_Utils::getUniqueId();
17
18
// check elements should we accept
19
$accept = $params['accept'];
20
21
// work out what to do when an element is dropped
22
// onto this element. the default is to do nothing.
23
$onDrop = 'smutty_doNothing';
24
if ( $params['drop_url'] ) {
25
// which element is gonna be getting the changes
26
$update = $params['update'] ? $params['update'] : $id;
27
// does the user want to provide feedback on the drop?
28
$feedback = $params['feedback'];
29
$onDrop = 'function ( eElem ) {' .
30
'smutty_ajaxCall(' .
31
'\'' . Smutty_Utils::getUrl(Smutty_Utils::strToHash($params['drop_url'])) . '\',' .
32
'\'' . $update . '\',' .
33
'null,' .
34
'{ element_id: eElem.id },' .
35
'\'' . $feedback . '\'' .
36
');}';
37
}
38
elseif ( $params['drop_handler'] )
39
$onDrop = $params['drop_handler'];
40
41
// do we need to do any loading?
42
$load = '';
43
if ( $params['load_url'] )
44
$load = 'smutty_ajaxCall(' .
45
'\'' . Smutty_Utils::getUrl(Smutty_Utils::strToHash($params['load_url'])) . '\',' .
46
'\'' . $update . '\'' .
47
');';
48
49
// create the link!
50
return Smutty_Smarty::htmlElement( 'div',array(
51
'id' => $id,
52
'class' => $params['class']
53
), $smarty ) . smarty_modifier_escape($params['text']) . '</div>' .
54
'<script type="text/javascript">Droppables.add(\'' . $id . '\',' .
55
'{' .
56
'onDrop: ' . $onDrop . ',' .
57
'accept: \'' . $accept . '\'' .
58
'});' .
59
$load . '</script>';
60
61
}
62
64
echo smutty_function_droppable( $params, $smarty );
65
}
66
67
?>
The code shown here is the code that is currently running this site. If you want to view the latest SVN version of the code then go to the Subversion repository.