Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $allImg = '';
- foreach($images as $val) :
- if($val->itemId != 0) :
- $title = ($val->getTitle() == null) ? Yii::t('app', 'SITE_NAME') : $val->getTitle();
- $val->year = ($val->year != null) ? $val->year.' год.' : '';
- $allImg .= "{img : '" . Url::to(['/images/default/download/', 'id' => $val->id]) . "', caption: '\"" . $title . "\", " . $val->getDesc() . ", " . $val->year . "', height: '64px', id: 'hash_" . $val->id . "'},";
- endif;
- endforeach;
- $url = Yii::$app->UrlManager->createUrl(['/site/select']);
- $t = Yii::t('app', 'SITE_NAME');
- $script = <<<JS
- var fotoDiv = $('.fotorama').fotorama({
- width: '100%',
- height: '75%',
- thumbratio: 'auto',
- hash: true,
- nav: 'thumbs',
- data: [
- $allImg
- ]
- })
- var fotorama = fotoDiv.data('fotorama')
- $("#email-form").on("change", function(){
- var data = $(this).serialize();
- $.ajax({
- url : '$url',
- type : 'POST',
- data : data,
- dataType : 'json',
- success : function(responce){
- var imagesArray = new Array();
- var countObj = responce.files.length
- if(countObj > 0){
- for(var i = 0; i < countObj; i++){
- if(responce.files[i].title == null){
- responce.files[i].title = "$t"
- }
- if(responce.files[i].description == null){
- responce.files[i].description = ""
- }
- if(responce.files[i].year == null){
- responce.files[i].year = ""
- }
- else{
- responce.files[i].year = responce.files[i].year + " год"
- }
- imagesArray.push({img: responce.files[i].img, id: "hash_" + responce.files[i].id,
- caption: "\"" + responce.files[i].title + "\", " + responce.files[i].description + ", " + responce.files[i].year});
- }
- }
- fotorama.load(
- imagesArray
- )
- }
- })
- })
- JS;
- $this->registerJs($script, View::POS_END);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement