Перейти к содержимому


Фотография
- - - - -

вывод заголовка полей


Лучший Ответ SmetDenis , 23 May 2014 - 13:50

Для этого придется переписать JS плагин, который отвечает за "клонирование"

Он находится тут media\zoo\elements\repeatable\repeatable.js

 

Если добавить форматирование файлу, то он будет выглядеть так

/* Copyright (C) YOOtheme GmbH, http://www.gnu.org/licenses/gpl.html GNU/GPL */
 
(function (e) {
    var t = function () {
    };
    e.extend(t.prototype, {name: "ElementRepeatable", options: {msgDeleteElement: null, msgSortElement: null}, initialize: function (t, a) {
        this.options = e.extend({}, this.options, a);
        var n = this;
        var i = t.find("ul.repeatable-list");
        var o = i.find("li.hidden").remove();
        var l = i.find("li.repeatable-element").length;
        i.find("li.repeatable-element").each(function () {
            n.attachButtons(e(this))
        });
        i.delegate("span.sort", "mousedown",function () {
            i.find(".more-options.show-advanced").removeClass("show-advanced")
        }).delegate("span.delete", "click",function () {
            e(this).closest("li.repeatable-element").fadeOut(200, function () {
                e(this).remove()
            })
        }).sortable({handle: "span.sort", placeholder: "repeatable-element dragging", axis: "y", opacity: 1, delay: 100, cursorAt: {top: 16}, tolerance: "pointer", containment: "parent", scroll: false, start: function (e, t) {
            t.item.addClass("ghost");
            t.placeholder.height(t.item.height() - 2);
            t.placeholder.width(t.item.find("div.repeatable-content").width() - 2)
        }, stop            : function (e, t) {
            t.item.removeClass("ghost")
        }});
        t.find("p.add a").bind("click", function () {
            var t = e("<li>").addClass("repeatable-element").html(o.html().replace(/(elements\[\S+])\[(-?\d+)\]/g, "$1[" + l++ + "]"));
            n.attachButtons(t);
            t.appendTo(i);
            t.find('input:not([type="radio"]), :not([type="checkbox"])').each(function () {
                if (e(this).val())e(this).val("")
            });
            t.children("div.repeatable-content").effect("highlight", {}, 1e3)
        })
    }, attachButtons           : function (t) {
        t.children().wrapAll(e("<div>").addClass("repeatable-content"));
        e("<span>").addClass("sort").attr("title", this.options.msgSortElement).appendTo(t);
        e("<span>").addClass("delete").attr("title", this.options.msgDeleteElement).appendTo(t)
    }});
    e.fn[t.prototype.name] = function () {
        var a = arguments;
        var n = a[0] ? a[0] : null;
        return this.each(function () {
            var i = e(this);
            if (t.prototype[n] && i.data(t.prototype.name) && n != "initialize") {
                i.data(t.prototype.name)[n].apply(i.data(t.prototype.name), Array.prototype.slice.call(a, 1))
            } else if (!n || e.isPlainObject(n)) {
                var o = new t;
                if (t.prototype["initialize"]) {
                    o.initialize.apply(o, e.merge([i], a))
                }
                i.data(t.prototype.name, o)
            } else {
                e.error("Method " + n + " does not exist on jQuery." + t.name)
            }
        })
    }
})(jQuery);

 

Клонирование находится тут

vh7_200x0.png

Перейти к сообщению


  • Закрытая тема Тема закрыта
Сообщений в теме: 4

#1 alexspi1

alexspi1

Отправлено 21 May 2014 - 12:54

создал по аналогии http://forum.jbzoo.c...achi-materiala/

 

всё вроде работает, не могу добиться что бы он рядом с полем выводил его название уже на сайте

строка вида

$html[] = $this->app->html->_('control.editrow', JText::_('Street'), 	$this->app->html->_('control.text', $this->getControlName('street'), $this->get('street'), 'size="60" maxlength="255"'));

не проходит слетает кодировка и стопорится

class Elementjbtext extends ElementRepeatable implements iRepeatSubmittable {

	/*
		Function: _hasValue
			Checks if the repeatables element's value is set.

	   Parameters:
			$params - render parameter

		Returns:
			Boolean - true, on success
	*/
	protected function _getSearchData() {
        $values = $this->_getValueList();
        $result = JString::trim(implode("\n", $values));

        return $result;
	}

	/*
		Function: _getSearchData
			Get repeatable elements search data.

		Returns:
			String - Search data
	*/


	/*
	   Function: _edit
	       Renders the repeatable edit form field.

	   Returns:
	       String - html
	*/
	protected function _edit() {
		$html = array();
$html[] = '<div>Адрес</div>';
	$html[] = $this->app->html->_('control.text', $this->getControlName('adress'), $this->get('adress', $this->config->get('default')), 'size="60" maxlength="255"');
$html[] = '<div>Секция</div>';
	$html[] = $this->app->html->_('control.text', $this->getControlName('section'), $this->get('section', $this->config->get('default')), 'size="60" maxlength="255"');
$html[] = '<div>тел</div>';
	$html[] = $this->app->html->_('control.text', $this->getControlName('tel'), $this->get('tel', $this->config->get('default')), 'size="60" maxlength="255"');
	
	return implode("\n", $html);
	}


	/*
		Function: _renderSubmission
			Renders the element in submission.

	   Parameters:
            $params - AppData submission parameters

		Returns:
			String - html
	*/
	public function _renderSubmission($params = array()) {
        return $this->_edit();
	}
	
	public function _render($params = array()) {
	    return '<div class="' .JText::_('adress'). '">'. $this->get('adress'). '</div>
	            <div class="' .JText::_('section'). '">'. $this->get('section'). '</div>
				<div class="' .JText::_('tel'). '">'. $this->get('tel'). '</div>';
	}
	
	protected function _hasValue($params = array()) {
		$adress = $this->get('adress');
                $value = $this->get('adress');
		$section = $this->get('section');
                $value = $this->get('section');
		$tel = $this->get('tel');
                $value = $this->get('tel');
		return !empty($adress) ||!empty($section)||!empty($tel);
	}
	
	protected function _getValueList()
    {
        return array(
            $this->get('adress'),
            $this->get('section'),
			$this->get('tel')
        );
    }
	
	    public function _validateSubmission($value, $params)
    {
        if ((int)$params->get('required')) {
            if (!JString::trim(implode(' ', $value->getArrayCopy()))) {
                throw new AppValidatorException('Field is empty');
            }
        }

        return $value->getArrayCopy();
    }

}	


  • 0

#2 SmetDenis

SmetDenis

Отправлено 22 May 2014 - 08:02

не проходит слетает кодировка и стопорится
 

 

Вы сохраняете файл в кодировке UTF-8 ?

Рекомендую использовать JText::_('LANG_KEY');


  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.


#3 alexspi1

alexspi1

Отправлено 22 May 2014 - 08:34

 

 

Вы сохраняете файл в кодировке UTF-8 ?

Рекомендую использовать JText::_('LANG_KEY');

 

utf-8 Без boom

вариант решения нашёл немного другой выложу может пригодится кому

файл xml

<?xml version="1.0" encoding="utf-8"?>
<element type="text" group="JBZoo" orderable="true">
	<name>JBZoo Text</name>
    <description>3 text</description>
    <author>JBZoo.com</author>
    <creationDate>2013 07</creationDate>
    <copyright>Copyright (C) JBZoo.com, All rights reserved.</copyright>
    <authorEmail>admin@jbzoo.com</authorEmail>
    <authorUrl>http://jbzoo.com</authorUrl>
    <version>1.0</version>
	<params>
		<param name="default" type="text" default="" label="Default" description="" />
		
	</params>
	<params group="render">
			<param name="adress" type="text" default="" label="Адрес" description="" />
      		<param name="section" type="text" default="" label="Секция" description="" />
      		<param name="tel" type="text" default="" label="Телефон" description="" />
		<param name="separated_by" type="zoolist" default="Space" label="Separated by" description="CHOOSE_SEPARATOR_REPEATED_ELEMENTS">
			<option name="Space"><![CDATA[separator=[ ]]]></option>
			<option name="Comma"><![CDATA[separator=[, ]]]></option>
			<option name="Hyphen"><![CDATA[separator=[ - ]]]></option>
			<option name="Pipe"><![CDATA[separator=[ | ]]]></option>
			<option name="Break"><![CDATA[separator=[<br />]]]></option>
			<option name="Span"><![CDATA[tag=[<span>%s</span>]]]></option>
			<option name="Paragraph"><![CDATA[tag=[<p>%s</p>]]]></option>
			<option name="Div"><![CDATA[tag=[<div>%s</div>]]]></option>
			<option name="List Item"><![CDATA[tag=[<li>%s</li>]]]></option>
			<option name="Unordered List"><![CDATA[tag=[<li>%s</li>] enclosing_tag=[<ul>%s</ul>]]]></option>
			<option name="Ordered List"><![CDATA[tag=[<li>%s</li>] enclosing_tag=[<ol>%s</ol>]]]></option>
			<option name="Warp Item"><![CDATA[tag=[<article class="item">%s</article>]]]></option>
			<option name="Blank"><![CDATA[tag=[%s]]]></option>
			<option name="UIkit Block"><![CDATA[tag=[<div class="uk-margin">%s</div>]]]></option>
			<option name="UIkit Article"><![CDATA[tag=[<article class="uk-article">%s</article>]]]></option>
			<option name="UIkit List"><![CDATA[tag=[<li>%s</li>] enclosing_tag=[<ul class="uk-list">%s</ul>]]]></option>
			<option name="UIkit List Line"><![CDATA[tag=[<li>%s</li>] enclosing_tag=[<ul class="uk-list uk-list-line">%s</ul>]]]></option>
		</param>
	</params>
</element>

файл php

<?php
/**
* @package   com_zoo
* @author    YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

// register ElementRepeatable class
App::getInstance('zoo')->loader->register('ElementRepeatable', 'elements:repeatable/repeatable.php');

/*
   Class: ElementIngr
       The text element class
*/
class Elementjbtext extends ElementRepeatable implements iRepeatSubmittable {

	/*
		Function: _hasValue
			Checks if the repeatables element's value is set.

	   Parameters:
			$params - render parameter

		Returns:
			Boolean - true, on success
	*/
	protected function _getSearchData() {
        $values = $this->_getValueList();
        $result = JString::trim(implode("\n", $values));

        return $result;
	}

	/*
		Function: _getSearchData
			Get repeatable elements search data.

		Returns:
			String - Search data
	*/


	/*
	   Function: _edit
	       Renders the repeatable edit form field.

	   Returns:
	       String - html
	*/
	protected function _edit() {
		$html = array();
$html[] = '<div>Адрес</div>';
	$html[] = $this->app->html->_('control.text', $this->getControlName('adress'), $this->get('adress', $this->config->get('default')), 'size="60" maxlength="255"');
$html[] = '<div>Секция</div>';
	$html[] = $this->app->html->_('control.text', $this->getControlName('section'), $this->get('section', $this->config->get('default')), 'size="60" maxlength="255"');
$html[] = '<div>тел</div>';
	$html[] = $this->app->html->_('control.text', $this->getControlName('tel'), $this->get('tel', $this->config->get('default')), 'size="60" maxlength="255"');
	
	return implode("\n", $html);
	}


	/*
		Function: _renderSubmission
			Renders the element in submission.

	   Parameters:
            $params - AppData submission parameters

		Returns:
			String - html
	*/
	public function _renderSubmission($params = array()) {
        return $this->_edit();
	}
	
	public function _render($params = array()) {
	    return '<div class="adr1"><div class="' .JText::_('adress'). '">Адрес : '. $this->get('adress'). '</div>
	            <div class="' .JText::_('section'). '">Секция : '. $this->get('section'). '</div>
				<div class="' .JText::_('tel'). '">Телефоны : '. $this->get('tel'). '</div></div>';
	}
	
	protected function _hasValue($params = array()) {
		$adress = $this->get('adress');
                $value = $this->get('adress');
		$section = $this->get('section');
                $value = $this->get('section');
		$tel = $this->get('tel');
                $value = $this->get('tel');
		return !empty($adress) ||!empty($section)||!empty($tel);
	}
	
	protected function _getValueList()
    {
        return array(
            $this->get('adress'),
            $this->get('section'),
			$this->get('tel')
        );
    }
	
	    public function _validateSubmission($value, $params)
    {
        if ((int)$params->get('required')) {
            if (!JString::trim(implode(' ', $value->getArrayCopy()))) {
                throw new AppValidatorException('Field is empty');
            }
        }

        return $value->getArrayCopy();
    }

}	


  • 0

#4 alexspi1

alexspi1

Отправлено 22 May 2014 - 09:26

появился ещё вопрос ка выполнить проверку сколько раз был клонирован(повторён) блок при заполнении, чтобы разные стили прикрутить?


  • 0

#5 SmetDenis

SmetDenis

Отправлено 23 May 2014 - 13:50   Лучший Ответ

Для этого придется переписать JS плагин, который отвечает за "клонирование"

Он находится тут media\zoo\elements\repeatable\repeatable.js

 

Если добавить форматирование файлу, то он будет выглядеть так

/* Copyright (C) YOOtheme GmbH, http://www.gnu.org/licenses/gpl.html GNU/GPL */
 
(function (e) {
    var t = function () {
    };
    e.extend(t.prototype, {name: "ElementRepeatable", options: {msgDeleteElement: null, msgSortElement: null}, initialize: function (t, a) {
        this.options = e.extend({}, this.options, a);
        var n = this;
        var i = t.find("ul.repeatable-list");
        var o = i.find("li.hidden").remove();
        var l = i.find("li.repeatable-element").length;
        i.find("li.repeatable-element").each(function () {
            n.attachButtons(e(this))
        });
        i.delegate("span.sort", "mousedown",function () {
            i.find(".more-options.show-advanced").removeClass("show-advanced")
        }).delegate("span.delete", "click",function () {
            e(this).closest("li.repeatable-element").fadeOut(200, function () {
                e(this).remove()
            })
        }).sortable({handle: "span.sort", placeholder: "repeatable-element dragging", axis: "y", opacity: 1, delay: 100, cursorAt: {top: 16}, tolerance: "pointer", containment: "parent", scroll: false, start: function (e, t) {
            t.item.addClass("ghost");
            t.placeholder.height(t.item.height() - 2);
            t.placeholder.width(t.item.find("div.repeatable-content").width() - 2)
        }, stop            : function (e, t) {
            t.item.removeClass("ghost")
        }});
        t.find("p.add a").bind("click", function () {
            var t = e("<li>").addClass("repeatable-element").html(o.html().replace(/(elements\[\S+])\[(-?\d+)\]/g, "$1[" + l++ + "]"));
            n.attachButtons(t);
            t.appendTo(i);
            t.find('input:not([type="radio"]), :not([type="checkbox"])').each(function () {
                if (e(this).val())e(this).val("")
            });
            t.children("div.repeatable-content").effect("highlight", {}, 1e3)
        })
    }, attachButtons           : function (t) {
        t.children().wrapAll(e("<div>").addClass("repeatable-content"));
        e("<span>").addClass("sort").attr("title", this.options.msgSortElement).appendTo(t);
        e("<span>").addClass("delete").attr("title", this.options.msgDeleteElement).appendTo(t)
    }});
    e.fn[t.prototype.name] = function () {
        var a = arguments;
        var n = a[0] ? a[0] : null;
        return this.each(function () {
            var i = e(this);
            if (t.prototype[n] && i.data(t.prototype.name) && n != "initialize") {
                i.data(t.prototype.name)[n].apply(i.data(t.prototype.name), Array.prototype.slice.call(a, 1))
            } else if (!n || e.isPlainObject(n)) {
                var o = new t;
                if (t.prototype["initialize"]) {
                    o.initialize.apply(o, e.merge([i], a))
                }
                i.data(t.prototype.name, o)
            } else {
                e.error("Method " + n + " does not exist on jQuery." + t.name)
            }
        })
    }
})(jQuery);

 

Клонирование находится тут

vh7_200x0.png


  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.





Click to return to top of page in style!