forked from GavickPro/News-Show-Pro-GK5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
708 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "Portfolio", | ||
"full_name": "PORTFOLIO", | ||
"support": [ | ||
"com_content", | ||
"com_k2" | ||
], | ||
"thumbnails": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
class NSP_GK5_Portfolio { | ||
// necessary class fields | ||
private $parent; | ||
private $mode; | ||
// constructor | ||
function __construct($parent) { | ||
$this->parent = $parent; | ||
// detect the supported Data Sources | ||
if(stripos($this->parent->config['data_source'], 'com_content_') !== FALSE) { | ||
$this->mode = 'com_content'; | ||
} else if(stripos($this->parent->config['data_source'], 'k2_') !== FALSE) { | ||
$this->mode = 'com_k2'; | ||
} else { | ||
$this->mode = false; | ||
} | ||
} | ||
// static function which returns amount of articles to render - VERY IMPORTANT!! | ||
static function amount_of_articles($parent) { | ||
return $parent->config['portal_mode_portfolio_cols'] * $parent->config['portal_mode_portfolio_rows'] * $parent->config['portal_mode_portfolio_pages']; | ||
} | ||
// output generator | ||
function output() { | ||
// amount | ||
$amount = 0; | ||
// main wrapper | ||
echo '<div class="gkNspPM gkNspPM-Portfolio" data-cols="'.$this->parent->config['portal_mode_portfolio_cols'].'" data-rows="'.$this->parent->config['portal_mode_portfolio_rows'].'">'; | ||
// images wrapper | ||
echo '<div class="gkImagesWrapper gkImagesCols'.$this->parent->config['portal_mode_news_gallery_cols'].' animate_queue">'; | ||
// JSON data array | ||
$jsondata = array(); | ||
// render images | ||
for($i = 0; $i < count($this->parent->content); $i++) { | ||
if($this->get_image($i)) { | ||
if($amount < ($this->parent->config['portal_mode_portfolio_cols'] * $this->parent->config['portal_mode_portfolio_rows'])) { | ||
echo '<a href="'.$this->get_link($i).'" title="'.strip_tags($this->parent->content[$i]['title']).'" class="gkImage animate_queue_element active">'; | ||
echo '<img src="'.strip_tags($this->get_image($i)).'" alt="'.strip_tags($this->parent->content[$i]['title']).'" />'; | ||
echo '</a>'; | ||
// increase the amount | ||
$amount++; | ||
} else { | ||
array_push($jsondata, array( | ||
'title' => str_replace("'", "\'", strip_tags($this->parent->content[$i]['title'])), | ||
'link' => $this->get_link($i), | ||
'src' => strip_tags($this->get_image($i)) | ||
) | ||
); | ||
} | ||
} | ||
} | ||
// closing images wrapper | ||
echo '</div>'; | ||
if($this->parent->config['portal_mode_portfolio_link'] == '1') { | ||
if(count($jsondata) == 0) { | ||
echo '<a href="'.$this->parent->config['portal_mode_portfolio_link_url'].'" class="gkLoadMore border bigbutton" data-text="false">'.JText::_('MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_TEXT2').'</a>'; | ||
} else { | ||
echo '<a href="'.$this->parent->config['portal_mode_portfolio_link_url'].'" class="gkLoadMore border bigbutton" data-text="'.JText::_('MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_TEXT2').'" data-toload="'.str_replace('"', '\'', json_encode($jsondata)).'" data-max="'.count($jsondata).'">'.JText::_('MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_TEXT1').'</a>'; | ||
} | ||
} | ||
// closing main wrapper | ||
echo '</div>'; | ||
} | ||
// function used to retrieve the item URL | ||
function get_link($num) { | ||
if($this->mode == 'com_content') { | ||
return ($this->parent->content[$num]['id'] != 0) ? JRoute::_(ContentHelperRoute::getArticleRoute($this->parent->content[$num]['id'], $this->parent->content[$num]['cid'])) : JRoute::_('index.php?option=com_users&view=login'); | ||
} else if($this->mode == 'com_k2') { | ||
// | ||
require_once (JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'route.php'); | ||
// | ||
return urldecode(JRoute::_(K2HelperRoute::getItemRoute($this->parent->content[$num]['id'].':'.urlencode($this->parent->content[$num]['alias']), $this->parent->content[$num]['cid'].':'.urlencode($this->parent->content[$num]['cat_alias'])))); | ||
} else { | ||
return false; | ||
} | ||
} | ||
// image generator | ||
function get_image($num) { | ||
// used variables | ||
$url = false; | ||
$output = ''; | ||
// select the proper image function | ||
if($this->mode == 'com_content') { | ||
// load necessary com_content View class | ||
if(!class_exists('NSP_GK5_com_content_View')) { | ||
require_once(JModuleHelper::getLayoutPath('mod_news_pro_gk5', 'com_content/view')); | ||
} | ||
// generate the com_content image URL only | ||
$url = NSP_GK5_com_content_View::image($this->parent->config, $this->parent->content[$num], true, true); | ||
} else if($this->mode == 'com_k2') { | ||
// load necessary k2 View class | ||
if(!class_exists('NSP_GK5_com_k2_View')) { | ||
require_once(JModuleHelper::getLayoutPath('mod_news_pro_gk5', 'com_k2/view')); | ||
} | ||
// generate the K2 image URL only | ||
$url = NSP_GK5_com_k2_View::image($this->parent->config, $this->parent->content[$num], true, true); | ||
} | ||
// check if the URL exists | ||
if($url === FALSE) { | ||
return false; | ||
} else { | ||
// if URL isn't blank - return it! | ||
if($url != '') { | ||
return $url; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><body bgcolor="#FFFFFF"></body></html> |
161 changes: 161 additions & 0 deletions
161
mod_news_pro_gk5/portal_modes/portfolio/script.jquery.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
jQuery(document).ready(function() { | ||
jQuery(document).find('.gkNspPM-Portfolio').each(function(i, module) { | ||
if(!module.hasClass('active')) { | ||
module.addClass('active'); | ||
gkPortalModePortfolioInit(module); | ||
} | ||
}); | ||
}); | ||
|
||
var gkPortalModePortfolioInit = function(module) { | ||
// button events | ||
if(jQuery(module).find('.gkLoadMore')) { | ||
module = jQuery(module); | ||
var btn = module.find('.gkLoadMore'); | ||
btn = jQuery(btn); | ||
var preloaded = 0; | ||
var maxpreloaded = btn.attr('data-max') * 1; | ||
var pageamount = module.attr('data-cols') * module.attr('data-rows'); | ||
var jsondata = btn.attr('data-toload') != null ? JSON.decode(btn.attr('data-toload').replace(/\\\'/g, ''').replace(/\'/g, '"')) : false; | ||
// button | ||
if(btn.attr('data-text') != 'false') { | ||
// add the load area | ||
var loadarea = jQuery('<div class="gkImagesWrapperLoadArea"></div>'); | ||
module.append(loadarea); | ||
// add the click event | ||
btn.click(function(e) { | ||
// if there are thumbnails to load | ||
if(preloaded < maxpreloaded && !btn.hasClass('inactive')) { | ||
// prevent the default event | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
|
||
var prevtext = btn.html(); | ||
btn.html('<div class="gkLoader"></div>'); | ||
btn.addClass('inactive'); | ||
|
||
var start = preloaded; | ||
var toInject = []; | ||
for(i = preloaded; i < start + pageamount && i < maxpreloaded; i++) { | ||
var img = new jQuery('<a></a>'); | ||
img.attr('href', jsondata[i].link); | ||
img.attr('title', jsondata[i].title); | ||
img.attr('class', 'gkImage active'); | ||
img.html('<img src="' + jsondata[i].src + '" alt="' + jsondata[i].title + '" />'); | ||
toInject.push(img); | ||
module.find('.gkImagesWrapperLoadArea').append(img); | ||
preloaded++; | ||
} | ||
|
||
var imgWrap = module.find('.gkImagesWrapper'); | ||
imgWrap = jQuery(imgWrap); | ||
imgWrap.css('height', imgWrap.outerHeight(true) + "px"); | ||
|
||
var preloaderTimer = setInterval(function() { | ||
var sum = toInject.length; | ||
var loaded = 0; | ||
|
||
for(var i = 0; i < sum; i++) { | ||
if(toInject[i].find('img')[0].complete) { | ||
loaded++; | ||
} | ||
} | ||
|
||
if(loaded == sum) { | ||
|
||
clearInterval(preloaderTimer); | ||
for(var i = 0; i < sum; i++) { | ||
|
||
module.find('.gkImagesWrapper').append(toInject[i]); | ||
//toInject[i].inject(module.getElement('.gkImagesWrapper'), 'bottom'); | ||
//toInject[i].addClass('show'); | ||
gkPortalModePortfolioImgClass(toInject[i], 'show', true, 150, i); | ||
|
||
|
||
} | ||
|
||
btn.removeClass('inactive'); | ||
|
||
// height animation | ||
imgWrap.animate({ | ||
height: imgWrap.scrollTop(), | ||
}, 350, function() { | ||
imgWrap.css('height', 'auto'); | ||
}); | ||
|
||
// add overlays | ||
module.find('.gkImage').each(function(i, img) { | ||
img = jQuery(img); | ||
if(img.find('.gkImgOverlay').length == 0) { | ||
// create overlays | ||
var overlay = new jQuery('<div class="gkImgOverlay"></div>'); | ||
overlay.html('<span></span>'); | ||
img.append(overlay); | ||
// add overlay events | ||
img.mouseenter( function() { | ||
var overlay = img.find('.gkImgOverlay'); | ||
var realImg = img.find('img'); | ||
overlay.css({ | ||
'margin-left': (-1.0 * (realImg.width() / 2.0)) + "px", | ||
'width': realImg.width() + "px" | ||
}); | ||
overlay.attr('class', 'gkImgOverlay active'); | ||
}); | ||
|
||
img.mouseleave( function() { | ||
var overlay = img.find('.gkImgOverlay'); | ||
overlay.attr('class', 'gkImgOverlay'); | ||
}); | ||
} | ||
}); | ||
|
||
if(preloaded < maxpreloaded) { | ||
btn.html(prevtext); | ||
} else { | ||
btn.html(btn.attr('data-text')); | ||
} | ||
} | ||
}, 1000); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
// add overlays | ||
module.find('.gkImage').each(function(i, img) { | ||
img = jQuery(img); | ||
if(img.find('.gkImgOverlay').length == 0) { | ||
// create overlays | ||
var overlay = jQuery('<div class="gkImgOverlay"></div>'); | ||
overlay.html('<span></span>'); | ||
img.append(overlay); | ||
// add overlay events | ||
img.mouseenter( function() { | ||
var overlay = img.find('.gkImgOverlay'); | ||
var realImg = img.find('img'); | ||
overlay.css({ | ||
'margin-left': (-1.0 * (realImg.width() / 2.0)) + "px", | ||
'width': realImg.width() + "px" | ||
}); | ||
overlay.attr('class', 'gkImgOverlay active'); | ||
}); | ||
|
||
img.mouseleave(function() { | ||
var overlay = img.find('.gkImgOverlay'); | ||
overlay.attr('class', 'gkImgOverlay'); | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
var gkPortalModePortfolioImgClass = function(img, className, delay, time, i) { | ||
i = i || 1; | ||
|
||
if(!delay) { | ||
img.attr('class', 'gkImage ' + className); | ||
} else { | ||
setTimeout(function() { | ||
img.attr('class', 'gkImage ' + className); | ||
}, time * i); | ||
} | ||
}; |
Oops, something went wrong.