Skip to content

Commit

Permalink
Added new portal mode - Portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
dziudek committed May 28, 2013
1 parent 5eae997 commit dd3d911
Show file tree
Hide file tree
Showing 9 changed files with 708 additions and 5 deletions.
19 changes: 18 additions & 1 deletion mod_news_pro_gk5/language/en-GB.mod_news_pro_gk5.ini
Original file line number Diff line number Diff line change
Expand Up @@ -468,4 +468,21 @@ MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_TEXT_BG_DESC="You can specify the tex
MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_TEXT_WIDTH="Text block width"
MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_TEXT_WIDTH_DESC="You can specify the text block width in percents"
MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_TOP="Top"
MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_BOTTOM="Bottom"
MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_BOTTOM="Bottom"

; - PORTFOLIO

COM_MODULES_NSP_PORTAL_MODE_PORTFOLIO_FIELDSET_LABEL="Portfolio - Portal Mode Settings"
MOD_NEWS_PRO_GK5_PORTFOLIO="Portfolio"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_COLS="Amount of columns"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_COLS_DESC="This option specify amount of news columns displayed in the portal mode per page."
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_ROWS="Amount of rows"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_ROWS_DESC="This option specify amount of news rows displayed in the portal mode per page."
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_PAGES="Amount of pages"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_PAGES_DESC="This option specify amount of pages displayed in the portal mode."
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK="Link at the bottom"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_DESC="If you have one page you can disable link at the bottom totally or hide the bottom button after loading all pages"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_URL="URL for the link"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_URL_DESC="This option specify the link displayed at the bottom after loading all items."
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_TEXT1="More work"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_TEXT2="See more"
19 changes: 18 additions & 1 deletion mod_news_pro_gk5/language/pl-PL.mod_news_pro_gk5.ini
Original file line number Diff line number Diff line change
Expand Up @@ -468,4 +468,21 @@ MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_TEXT_BG_DESC="Opcja ta pozwala okreś
MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_TEXT_WIDTH="Szerokość bloku z tekstem"
MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_TEXT_WIDTH_DESC="Opcja ta pozwala określić szerokośc bloku z tekstem w procentach"
MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_TOP="Położenie górne"
MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_BOTTOM="Położenie dolne"
MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_BOTTOM="Położenie dolne"

; - PORTFOLIO

COM_MODULES_NSP_PORTAL_MODE_PORTFOLIO_FIELDSET_LABEL="Portfolio - Ustawienia trybu portalowego"
MOD_NEWS_PRO_GK5_PORTFOLIO="Portfolio"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_COLS="Ilość kolumn"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_COLS_DESC="Opcja ta pozwala określić ilość kolumn wyświetlanych na stronie."
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_ROWS="Ilość wierszy"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_ROWS_DESC="Opcja ta pozwala określić ilość wierszy wyświetlanych na stronie."
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_PAGES="Ilość stron"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_PAGES_DESC="Opcja ta określa ilość stron z grafikami wczytywanych na stronie."
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK="Link pod zdjęciami"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_DESC="Jeżeli posiadasz tylko jedną stronę ze zdjęciami możesz całkowicie wyłączyć link pod zdjęciami, lub ukryć go po załadowaniu wszystkich zdjęć."
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_URL="URL dla linka"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_URL_DESC="Opcja ta określa URL linka pod zdjęciami po załadowaniu wszystkich zdjęć."
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_TEXT1="Więcej prac"
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_TEXT2="Zobacz więcej"
21 changes: 18 additions & 3 deletions mod_news_pro_gk5/mod_news_pro_gk5.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="2.5.0" client="site" method="upgrade">
<name>News Show Pro GK5</name>
<creationDate>01/05/2013</creationDate>
<creationDate>27/05/2013</creationDate>
<author>Gavick.com</author>
<copyright>(C) 2009-2013 Gavick.com</copyright>
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
<authorEmail>info@gavick.com</authorEmail>
<authorUrl>www.gavick.com</authorUrl>
<version>1.1.3</version>
<version>1.1.4</version>
<description>
<![CDATA[
<style type='text/css'>
Expand All @@ -19,7 +19,7 @@
span.readonly p.license { border-top: 1px solid #eee; font-size: 11px; margin: 30px 26px 0; padding: 6px 0; }
</style>
<span class='readonly'>
<h1>News Show Pro GK5 <small>ver. 1.1.3</small></h1>
<h1>News Show Pro GK5 <small>ver. 1.1.4</small></h1>
<p>GK5 is new generation of our extensions dedicated to Joomla 2.5+.</p>
<p>Basing on experiences gathered, we created probably the best tool to present articles for Joomla! Huge amount of options and possibilities of formatting causes News Show Pro GK5 is a complex tool in making www pages content attractive. News Show Pro is appropriate while preparing simple structures with an individual article, the same as, complex arrangements including few articles and a list of links.</p>
<p class='homepage'><a href='http://www.gavick.com/news-show-pro-gk5.html' target='_blank'>Learn more at the NSP GK5 project website.</a></p>
Expand Down Expand Up @@ -293,6 +293,21 @@
<field type="text" name="portal_mode_title_overlay_text_width" default="100" class="input-percents" size="5" label="MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_TEXT_WIDTH" description="MOD_NEWS_PRO_GK5_PORTAL_MODE_TITLE_OVERLAY_TEXT_WIDTH_DESC" />
</fieldset>

<fieldset name="NSP_PORTAL_MODE_PORTFOLIO">
<field name="portal_mode_portfolio_cols" type="text" default="3" size="5" label="MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_COLS" description="MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_COLS_DESC" />

<field name="portal_mode_portfolio_rows" type="text" default="3" size="5" label="MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_ROWS" description="MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_ROWS_DESC" />

<field name="portal_mode_portfolio_pages" type="text" default="3" size="5" label="MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_PAGES" description="MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_PAGES_DESC" />

<field name="portal_mode_portfolio_link" type="list" class="gk_switch" default="1" label="MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK" description="MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_DESC">
<option value="0">MOD_NEWS_PRO_GK5_DISABLED</option>
<option value="1">MOD_NEWS_PRO_GK5_ENABLED</option>
</field>

<field name="portal_mode_portfolio_link_url" type="text" default="" size="20" label="MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_URL" description="MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO_LINK_URL_DESC" />
</fieldset>

<!-- Portal Modes fieldsets END -->

<fieldset name="NSP_ARTICLE_LAYOUT">
Expand Down
9 changes: 9 additions & 0 deletions mod_news_pro_gk5/portal_modes/portfolio/configuration.json
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
}
112 changes: 112 additions & 0 deletions mod_news_pro_gk5/portal_modes/portfolio/controller.php
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
1 change: 1 addition & 0 deletions mod_news_pro_gk5/portal_modes/portfolio/index.html
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 mod_news_pro_gk5/portal_modes/portfolio/script.jquery.js
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, '&apos;').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);
}
};
Loading

0 comments on commit dd3d911

Please sign in to comment.