Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • synapsis Friend
    #196553

    Using JA-Slideshow-Lite on Mitius, I am wanting to make an image in the slideshow link to an off-site URL, but I want the link to open in a new tab/window, so the user doesn’t leave my site in the process.

    Is there a way to do this in Slideshow-Lite? I don’t want to use a link in the description. I want to link the entire image, and have that link open in a new window.

    I looked for an answer, but only found references to such a hack/fix on Slideshow2. Your help is greatly appreciated!

    chavan Friend
    #529904

    yes it is a kind of a hack/fix. can you please post your ftp details in PM.

    synapsis Friend
    #530060

    I’m sorry, I can’t give FTP access at this time.

    Is there any way for you to just provide line numbers and code that require editing? I am comfortable changing them myself, if you can point out what needs editing.

    Also, please note, that I don’t want a slideshow that JUST opens in new windows. I need it as an option. Some slides will link internally, and should open in the parent window. Maybe an if/then statement to check the URL for my domain?

    Thank you!

    chavan Friend
    #530392

    Go to this File: modulesmod_jaslideshowlitemod_jaslideshowlite.php

    Replace this code


    $timages[] = $images[$i];
    $tthumbArray[] = $thumbArray[$i];
    $tcaptionsArray[] = $captionsArray[$i];
    $turls[] = $urls[$i];
    $ttargets[] = $targets[$i];
    $ttitles[] = $titles[$i];

    with

    $timages[] = $images[$i];
    $tthumbArray[] = $thumbArray[$i];
    $tcaptionsArray[] = $captionsArray[$i];
    $turls[] = $urls[$i];
    $ttargets[] = '_blank'; //$targets[$i];
    $ttitles[] = $titles[$i];

    synapsis Friend
    #530405

    That will open ALL linked slides in a new window, yes? Is there any way to link to new window only if the URL is not my own?

    Thank you for your continued assistance.

    chavan Friend
    #530473

    yes, all links will open in a new window.

    i have added some custom changes throughout the file so you can add “_blank” in the Image edit link popup in the JA Slideshow module.

    back your files and extract and upload the files to /modules/mod_jaslideshowlite/


    synapsis Friend
    #530627

    Chavan, that works pretty well. You should finish the pop-up confirmations with actual messages if they need to be there at all (I don’t think they do), and send your changes up the chain of command for inclusion in the next release of JA Slideshow Lite. It’s brilliant! Thank you for sharing this.

    chavan Friend
    #530705

    Go to this File: modulesmod_jaslideshowliteassetselementsjagallery.php

    Remove the complete code and replace with this
    [PHP]<?php
    /**
    * ————————————————————————
    * JA Slideshow Lite Module for J25 & J3.2
    * ————————————————————————
    * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
    * @license – GNU/GPL, http://www.gnu.org/licenses/gpl.html
    * Author: J.O.O.M Solutions Co., Ltd
    * Websites: http://www.joomlart.comhttp://www.joomlancers.com
    * ————————————————————————
    */

    defined(‘_JEXEC’) or die( ‘Restricted access’ );

    jimport(‘joomla.form.formfield’);

    class JFormFieldJagallery extends JFormField {
    protected $type = ‘Jagallery’;

    protected function getInput() {
    Jhtml::_(‘behavior.modal’);
    Jhtml::_(‘stylesheet’, JURI::root() . ‘modules/’ . $this->form->getValue(‘module’) . ‘/assets/elements/jagallery/style.css’);

    $jaGalleryId = $this->id ;

    $params = $this->form->getValue(‘params’);
    if(!isset($params)){
    $params = new stdClass();
    $params->folder = ”;
    }

    if(!isset($params->folder)){
    $params->folder = ”;
    }else{
    $params->folder = trim($params->folder, ‘/’) . ‘/’;
    }

    //Check data format && convert it to json data if it is older format
    $updateFormatData = 0;

    if($this->value && ! $this->isJson($this->value)){
    $this->value = $this->convertFormatData($this->value,$params->folder);
    if(isset($this->element[“updatedata”]) && $this->element[“updatedata”]){
    $updateFormatData = 1;
    }
    }
    //Create element
    $button = ‘<input type=”button” id=”jaGetImages” value=”‘.JText::_(“JA_GET_IMAGES”).'” style=”display: none;” /><br /><div id=”listImages” style=”width: 100%; overflow: hidden;”></div>’;
    $button .= ‘<textarea style=”width: 75%; display: none;” rows=”6″ cols=”75″ name=”‘ . $this->name . ‘” id=”‘ . $jaGalleryId . ‘” >’. htmlspecialchars($this->value, ENT_COMPAT, ‘UTF-8′) .'</textarea>’;
    $js = ‘
    var current_jagallery = ”.addslashes($this->value).”;
    var current_jafolder = “‘.$params->folder.'”;
    var autoUpdate = ‘.$updateFormatData.’;
    jQuery(document).ready(function(){
    jQuery(“#jaGetImages”).click(function(){
    jaListImages();
    });
    jaListImages();
    if(autoUpdate){
    Joomla.submitbutton(“module.apply”);
    }
    });
    function changetype(obj){

    jaListImages(jQuery(obj).val());

    }
    function jaListImages(type){
    var folder_path = jQuery(“#jform_params_folder”).val();
    if(folder_path == “”){
    alert(“‘.JText::_(“FOLDER_PATH_REQUIRED”).'”);
    return;
    }
    query = “jarequest=images&path=”+folder_path+”&task=loadImages”;
    if(type) query+=”&type=”+type;
    jQuery.ajax({
    url: location.href,
    data: query,
    type: “post”,
    beforeSend: function(){
    jQuery(“#listImages”).html(“<img src=”‘.JURI::root().’modules/mod_jaslideshowlite/assets/elements/jagallery/loading.gif” width=”30″ height=”30″ />”);
    },
    success: function(responseJSON){
    var data = jQuery.parseJSON(responseJSON);
    if (!data.success) {
    jQuery(“#’.$jaGalleryId.'”).val(“”);
    jQuery(“#listImages”).html(“<strong style=’color: red’>’.JText::_(“FOLDER_EMPTY”).'</strong>”);
    return;
    }
    else {
    if(folder_path === current_jafolder && current_jagallery != “”){
    var current_data = jQuery.parseJSON(current_jagallery);
    for(var i=0; i<current_data.length; i++){
    for(var j=0; j<data.images.length; j++){
    if(current_data.image == data.images[j].image){
    if(typeof(current_data.title) !== “undefined”){
    data.images[j].title = current_data.title;
    }
    if(typeof(current_data.link) !== “undefined”){
    data.images[j].link = current_data.link;
    }
    if(typeof(current_data.description) !== “undefined”){
    data.images[j].description = current_data.description;
    }
    if(typeof(current_data.class) !== “undefined”){
    data.images[j].class = current_data.class;
    }
    if(typeof(current_data.target) !== “undefined”){
    data.images[j].target = current_data.target;
    }
    if(typeof(current_data.show) !== “undefined”){
    data.images[j].show = current_data.show;
    }
    break;
    }
    }
    }
    }
    jaupdateImages(data.images, “#listImages”);
    }

    }
    });

    return false;
    }

    function jaupdateImages(images, boxID){
    var data = “”;
    if(images.length){
    for(var i=0; i<images.length; i++){
    var showImage = “”;
    if(images.show === true || images.show === “true”){
    showImage = “checked”;
    }
    data += “<div class=’img-element’ style=’width: 100px; height: 150px; float: left; margin: 0 5px;’>”;
    data += “<img src=”+ encodeURI(images.imageSrc) +” style=’max-width: 100px; max-height: 100px;’ />”;
    data += “<br />”;
    data += “<span style=”font-size:80%;”>[“+images.image+”]</span>”;
    data += “<br />”;
    data += “<span style=’float: left; display: block; text-align: center’>”;
    data += “‘.JText::_(“JSHOW”).’ <input style=’margin:0 auto;’ type=’checkbox’ value='” + images.image + “‘ “+showImage+” onchange=’showImage(this)’ />”;
    data += “</span>”;
    data += “<span onclick=’jaFormpopup(“#img-element-data-form”, ” + i + “, “” + images.image + “”); return false;’ class=’img-btn’ style=’float: right; text-align: center; display: block; cursor: pointer;’>’.JText::_(“EDIT”).’ </span>”;
    data += “</div>”;
    }
    data += “<div id=’img-element-data-form’ style=’display: none;’></div>”;
    }
    jQuery(boxID).html(data);
    jQuery(“#’.$jaGalleryId.'”).val(JSON.stringify(images));
    }

    function showImage(el){
    var showImage = jQuery(el).is(‘:checked’);
    var data = jQuery.parseJSON(jQuery(“#’.$jaGalleryId.'”).val());

    if(!data){
    data = [];
    }
    if(data.length > 0){
    for(var i = 0; i<data.length; i++){
    if(data[“image”] == jQuery(el).val()){
    data[“show”] = showImage;
    break;
    }
    }
    }
    jQuery(“#’.$jaGalleryId.'”).val(JSON.stringify(data));
    }

    function jaFormpopup(el, key, imgname){
    var form = jadataForm(key, imgname);
    jQuery(el).append(form);
    SqueezeBox.open($(“img-element-data-form-“+key),{
    handler:”adopt”,
    size:{
    x:800,
    y:321
    }
    });
    //update data for image form
    var data = jQuery(“#’.$jaGalleryId.'”).val();
    var jaimg = new Object();
    jaimg.title = “”;
    jaimg.link = “”;
    jaimg.description = “”;
    jaimg.class=””;
    jaimg.target=””;
    //query = “jarequest=images&task=validData&imgname=”+imgname+”&data=”+data;
    jQuery.ajax({
    url: location.href,
    data: {jarequest:”images”, task:”validData”, imgname:imgname, data:data},
    type: “post”,
    success: function(responseJSON){
    var jaResponse = jQuery.parseJSON(responseJSON);

    //alert(jaResponse.target);
    jQuery(“#img-element-data-form-“+key).find(“#imgtitle”).val(jaResponse.title);
    jQuery(“#img-element-data-form-“+key).find(“#imglink”).val(jaResponse.link);
    jQuery(“#img-element-data-form-“+key).find(“#imgdescription”).val(jaResponse.description);
    jQuery(“#img-element-data-form-“+key).find(“#imgclass”).val(jaResponse.class);
    jQuery(“#img-element-data-form-“+key).find(“#imgtarget”).val(jaResponse.target);
    }
    });
    }

    function jaCloseImgForm(key){
    SqueezeBox.close($(“img-element-data-form-“+key));
    }

    function jaUpdateImgData(key, imgname){

    var title = jQuery(“#img-element-data-form-“+key).find(“#imgtitle”).val();
    var link = jQuery(“#img-element-data-form-“+key).find(“#imglink”).val();
    var description = jQuery(“#img-element-data-form-“+key).find(“#imgdescription”).val();
    var imgclass = jQuery(“#img-element-data-form-“+key).find(“#imgclass”).val();
    var imgtarget = jQuery(“#img-element-data-form-“+key).find(“#imgtarget”).val();
    var data = jQuery.parseJSON(jQuery(“#’.$jaGalleryId.'”).val());

    //alert(imgtarget);

    if(!data){ data = [];}

    if(data.length > 0){
    var found = false;

    for(var i = 0; i<data.length; i++){
    if(data[“image”] == imgname){
    data[“title”] = title;
    data[“link”] = link;
    data[“description”] = description;
    data[“class”] = imgclass;
    data[“target”] = imgtarget;

    found = true;
    break;
    }
    }

    if(!found){
    data_add = new Object();
    data_add[“image”] = imgname;
    data_add[“title”] = title;
    data_add[“link”] = link;
    data_add[“description”] = description;
    data_add[“class”] = imgclass;
    data_add[“target”] = imgtarget;
    data.push(data_add);
    }
    } else {
    data_add = new Object();
    data_add[“image”] = imgname;
    data_add[“title”] = title;
    data_add[“link”] = link;
    data_add[“description”] = description;
    data_add[“class”] = imgclass;
    data_add[“target”] = imgtarget;
    data.push(data_add);
    }

    jQuery(“#’.$jaGalleryId.'”).val(JSON.stringify(data));

    jaCloseImgForm(key);
    }

    function jadataForm(key, imgname){

    //create form for image data
    var html = “”;
    html += “<div id=’img-element-data-form-“+key+”‘ class=’img-element-data-form’>”;
    html += “<fieldset class=’panelform’ >”;
    html += “<ul>”;
    html += “<li>”;
    html += “<label>’.JText::_(“JA_TITLE”).'</label>”;
    html += “<input type=’text’ name=’imgtitle’ id=’imgtitle’ value=” size=’50’ />”;
    html += “</li>”;

    html += “<li>”;
    html += “<label>’.JText::_(“JA_LINK”).'</label>”;
    html += “<input type=’text’ name=’imglink’ id=’imglink’ value=” size=’50’ />”;
    html += “</li>”;
    html += “<li>”;
    html += “<label>’.JText::_(“JA_CLASS”).'</label>”;
    html += “<input type=’text’ name=’imgclass’ id=’imgclass’ value=” size=’50’ />”;
    html += “</li>”;
    html += “<li>”;
    html += “<label>’.JText::_(“Target”).'</label>”;
    html += “<input type=’text’ name=’imgtarget’ id=’imgtarget’ value=” size=’50’ />”;
    html += “</li>”;
    html += “<li>”;
    html += “<label>’.JText::_(“JA_DESCRIPTION”).'</label>”;
    html += “<textarea rows=’6′ cols=’80’ name=’imgdescription’ id=’imgdescription’ ></textarea>”;
    html += “</li>”;

    html += “</ul>”;
    html += “<div class=’btn-image-data-popup’ style=’width: 100%; display: block; float: left; margin-top: 10px;’>”;
    html += “<input onclick=’jaUpdateImgData(“+key+”, “”+imgname+””); return false;’ type=’button’ value=”.JText::_(“UPDATE”).” >”;
    html += “<input onclick=’jaCloseImgForm(“+key+”); return false;’ type=’button’ value=”.JText::_(“CANCEL”).” >”;
    html += “</div>”;
    html += “</fieldset>”;
    html += “</div>”;

    return html;
    }
    ‘;
    $doc = JFactory::getDocument();
    $doc->addScriptDeclaration($js);
    return $button;
    }

    /*
    * Check data format for update data type from old version to json format
    * @string data string
    * @return boolean
    */
    function isJson($string)
    {
    return ((is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))))) ? true : false;
    }

    function convertFormatData($string,$folder=null)
    {
    $data = array();
    $description = $this->parseDescNew($string,$folder);

    if(!empty($description)){
    $i = 0;
    foreach($description as $key=>$v){
    $data[$i] = new stdClass();
    $data[$i]->image = $key;
    $data[$i]->title = “”;
    $data[$i]->link = isset($v[“url”])?$v[“url”]:”;
    $data[$i]->description = str_replace(array(“n”,”r”),”<br />”,$v[“caption”]);
    $data[$i]->class = isset($v[‘class’])?$v[‘class’]:”;
    $data[$i]->target = isset($v[‘target’])?$v[‘target’]:”;
    $data[$i]->show = isset($v[‘show’])?$v[‘show’]:”;
    $i++;
    }
    }
    if(!empty($data)){
    return json_encode($data);
    }
    return ”;
    }

    /**
    *
    * Parse description
    * @param string $description
    * @return array
    */
    function parseDescNew($description,$folder=null)
    {

    $regex = ‘#]*)]([^[]*)#m’;
    $description = str_replace(array(“{{“, “}}”), array(“<“, “>”), $description);
    preg_match_all($regex, $description, $matches, PREG_SET_ORDER);
    $publish = 0;
    $descriptionArray = array();
    foreach ($matches as $match) {
    $params = $this->parseParams($match[1]);

    if (is_array($params)) {
    $img = isset($params[‘img’]) ? trim($params[‘img’]) : ”;

    if (!$img)
    continue;
    $publish = 1;
    $dot = strrpos($img, ‘.’);
    $url = isset($params[‘url’]) ? trim($params[‘url’]) : ”;
    $class = isset($params[‘class’]) ? trim($params[‘class’]) : ”;
    $target = isset($params[‘target’]) ? trim($params[‘target’]) : ”;
    $show = isset($params[‘show’]) ? trim($params[‘show’]) : ”;
    $descriptionArray[$img] = array(‘url’ => $url, ‘caption’ => str_replace(“n”, “<br />”, trim($match[2])), ‘class’ => $class, ‘show’ => $show);
    }
    }

    return $descriptionArray;
    }

    /**
    * get parameters from configuration string.
    *
    * @param string $string;
    * @return array.
    */

    function parseParams($string)
    {
    $string = html_entity_decode($string, ENT_QUOTES);
    $regex = “/s*([^=s]+)s*=s*(‘([^’]*)’|”([^”]*)”|([^s]*))/”;
    $params = null;
    if (preg_match_all($regex, $string, $matches)) {
    for ($i = 0; $i < count($matches[1]); $i++) {
    $key = $matches[1][$i];
    $value = $matches[3][$i] ? $matches[3][$i] : ($matches[4][$i] ? $matches[4][$i] : $matches[5][$i]);
    $params[$key] = $value;
    }
    }
    return $params;
    }

    }[/PHP]

    so the alert with go.

Viewing 8 posts - 1 through 8 (of 8 total)

This topic contains 8 replies, has 2 voices, and was last updated by  chavan 10 years, 7 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum