load($value);
}
else
{
$item->title = JText::_('K2_SELECT_AN_ITEM');
}
/*$js = "
function jSelectItem(id, title, object) {
document.getElementById( '".$name."' + '_id').value = id;
console.log(".$name.");
document.getElementById('".$name."' + '_name').value = title;
if(typeof(window.parent.SqueezeBox.close=='function')){
window.parent.SqueezeBox.close();
}
else {
document.getElementById('sbox-window').close();
}
}
";
$doc->addScriptDeclaration($js);*/
if(!defined('CBYNEWSSLIDERJS')){
$js = " jQuery(document).ready(function(){
jQuery('.cbitemSelect').click(function(el){
//console.log(this);
//console.log(jQuery(this).attr('val'));
window.cbSelectItem = jQuery(this).attr('val');
});
});
function jSelectItem(id, title, object) {
//var name = 'jform[params]['+object.split('jformparams')[1]+']';
//console.log(name);
//console.log(window.cbSelectItem);
name = window.cbSelectItem;
document.getElementById( name + '_id').value = id;
//console.log(object.split('jformparams')[1]);
document.getElementById(name + '_name').value = title;
if(typeof(window.parent.SqueezeBox.close=='function')){
window.parent.SqueezeBox.close();
}
else {
document.getElementById('sbox-window').close();
}
}";
$doc->addScriptDeclaration($js);
define('CBYNEWSSLIDERJS',1);
}
$link = 'index.php?option=com_k2&view=items&task=element&tmpl=component&object='.$name;
JHTML::_('behavior.modal', 'a.modal');
if (K2_JVERSION == '30')
{
//var_dump('asdas');
$html = '
'.JText::_('K2_SELECT').'
';
}
else
{
$html = '
';
}
return $html;
}
}
class JFormFieldItem extends K2ElementItem
{
var $type = 'item';
}
class JElementItem extends K2ElementItem
{
var $_name = 'item';
}
else:
$doc = JFactory::getDocument();
$doc->addScript(JURI::root().'modules/mod_yahoostylenewsslider/yahoostylenewsslider/js/jquery.js?v=2');
$doc->addScriptDeclaration('jQuery.noConflict();');
if(K2_JVERSION=='16'){
jimport('joomla.form.formfield');
class JFormFieldItem extends JFormField {
var $type = 'item';
function getInput(){
return JElementItem::fetchElement($this->name, $this->value, $this->element, $this->options['control']);
}
}
}
jimport('joomla.html.parameter.element');
class JElementItem extends JElement {
var $_name = 'Item';
function fetchElement($name, $value, & $node, $control_name) {
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$doc = JFactory::getDocument();
$fieldName = (K2_JVERSION=='16')?$name:$control_name.'['.$name.']';
JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'tables');
$item = JTable::getInstance('K2Item', 'Table');
if ($value) {
$item->load($value);
}
else {
$item->title = JText::_('K2_SELECT_AN_ITEM');
}
if(!defined('CBYNEWSSLIDERJS')){
$js = " jQuery(document).ready(function(){
jQuery('.cbitemSelect').click(function(el){
//console.log(this);
//console.log(jQuery(this).attr('val'));
window.cbSelectItem = jQuery(this).attr('val');
});
});
function jSelectItem(id, title, object) {
//var name = 'jform[params]['+object.split('jformparams')[1]+']';
//console.log(name);
//console.log(window.cbSelectItem);
name = window.cbSelectItem;
document.getElementById( name + '_id').value = id;
//console.log(object.split('jformparams')[1]);
document.getElementById(name + '_name').value = title;
if(typeof(window.parent.SqueezeBox.close=='function')){
window.parent.SqueezeBox.close();
}
else {
document.getElementById('sbox-window').close();
}
}";
$doc->addScriptDeclaration($js);
define('CBYNEWSSLIDERJS',1);
}
$link = 'index.php?option=com_k2&view=items&task=element&tmpl=component&object='.$name;
JHTML::_('behavior.modal', 'a.modal');
$html = '
';
return $html;
}
}
endif;