Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'album_comments'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Sharov committed Nov 2, 2012
2 parents c5daf80 + cfb6d7e commit 662c9a3
Show file tree
Hide file tree
Showing 77 changed files with 375 additions and 12,053 deletions.
3 changes: 3 additions & 0 deletions css/site/comments.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,6 @@
font-size: 11px;
}

.fancybox-skin .comment-list-wrapper {
margin: 20px 0 0 0;
}
120 changes: 83 additions & 37 deletions js/comments/commentsPortlet.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,95 @@
$(function() {
var $loading_div = $('<div>загрузка комментариев...</div>').css('text-align', 'center');
var $comments_div = $('#comments-div');
var $comment_label = $('#comment-label');
$.widget('cmsUI.commentList', {
options: {
version: '0.2',
form_selector: '#comment-form',
label_selector: "#comment-label",
comments_list_selector: "#comments-div",
comments_list_url: "/comments/comment/list"
},
form : null,
label : null,
list : null,
_create:function()
{
var widget = this;
widget.form = $(widget.options.form_selector, widget.element);
widget.label = $(widget.options.label_selector, widget.element);
widget.list = $(widget.options.comments_list_selector, widget.element);

$comments_div.html($loading_div);
widget.setLoading();
widget._initAnswers();
widget._initForm();
if (widget.element.is(':visible'))
{
widget.loadCommentsList();
}
},
_initForm:function()
{
var widget = this;

loadCommentsList();
widget.form.submit(function()
{
var params = {};

$('a.answer').live('click', function() {
var comment_id = $(this).attr('comment_id');
var user_name = $(this).attr('user_name');
widget.form.find('input, textarea').each(function()
{
params[$(this).attr('name')] = $(this).val();
});

$("input[name='Comment[parent_id]']").val(comment_id);
$.post(widget.form.attr('action'), params, function(res)
{
widget.loadCommentsList();
$("textarea[name='Comment[text]']", widget.form).val("");
$("input[name='Comment[parent_id]']", widget.form).val("");
widget.label.html(widget.label.attr('label'));
});

$comment_label.html($comment_label.attr('label') + '<strong> → ' + user_name + '</strong>');
$('');

location.href = '#comment-form';
return false;
});

$('#comment-form').submit(function() {
var params = {};

$('#comment-form').find('input, textarea').each(function() {
params[$(this).attr('name')] = $(this).val();
return false;
});
},
_initAnswers: function()
{
var widget = this;
$('a.answer').live('click', function()
{
var comment_id = $(this).attr('comment_id');
var user_name = $(this).attr('user_name');

$.post('/comments/comment/create', params, function(res) {
loadCommentsList();
$("textarea[name='Comment[text]']").val("");
$("input[name='Comment[parent_id]']").val("");
$("#comment-label").html($("#comment-label").attr('label'));
});
$("input[name='Comment[parent_id]']", widget.form).val(comment_id);

return false;
});
widget.label.html(widget.label.attr('label') + '<strong> → ' + user_name + '</strong>');

function loadCommentsList() {
var object_id = $("input[name='Comment[object_id]']").val();
var model_id = $("input[name='Comment[model_id]']").val();

$.get('/comments/comment/list/object_id/' + object_id + '/model_id/' + model_id, function(html) {
$comments_div.html(html);
location.href = '#comment-form';
return false;
});
}
},
bindToLink: function(link)
{
var widget = this;
$("input[name='Comment[model_id]']", widget.form).val(link.data('model-id'));
$("input[name='Comment[object_id]']", widget.form).val(link.data('object-id'));
widget.options.comments_list_url = link.data('comments-url');

},
setLoading: function()
{
var widget = this;
var $loading_div = $('<div>Загрузка комментариев...</div>').css('text-align', 'center');
widget.list.html($loading_div);
},
loadCommentsList: function (opts)
{
//TODO: add cache! or make it outside?
var widget = this;
$.get( widget.options.comments_list_url, {
object_id : $("input[name='Comment[object_id]']", widget.form).val(),
model_id : $("input[name='Comment[model_id]']", widget.form).val()
},
function(html)
{
widget.list.html(html);
}, 'html'
);
}
});
64 changes: 0 additions & 64 deletions js/plugins/jsonRpc.js

This file was deleted.

31 changes: 31 additions & 0 deletions protected/components/ClientScript.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
class ClientScript extends CClientScript
{
/**
* add JSONP-supporting functionality
* using: $.getJSON('url?callback=?', function(html) {alert(html);});
* see(http://api.jquery.com/jQuery.getJSON/#jsonp)
* all registered scripts (non file) will evaluate on client automatically
*
* @param string $output
*/
public function render(&$output)
{
if (Yii::app()->request->getIsAjaxRequest() && isset($_GET['callback']))
{
$scripts = '';
foreach ($this->scripts as $pos)
{
foreach ($pos as $script)
{
$scripts .= $script;
}
}
$output = $scripts . "\n" . $_GET['callback'] . '("' . addslashes($output) . '")';
}
else
{
parent::render($output);
}
}
}
34 changes: 0 additions & 34 deletions protected/components/bootstrap/assets/less/accordion.less

This file was deleted.

65 changes: 0 additions & 65 deletions protected/components/bootstrap/assets/less/alerts.less

This file was deleted.

Loading

0 comments on commit 662c9a3

Please sign in to comment.