This repository has been archived by the owner on Mar 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
77 changed files
with
375 additions
and
12,053 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,3 +92,6 @@ | |
font-size: 11px; | ||
} | ||
|
||
.fancybox-skin .comment-list-wrapper { | ||
margin: 20px 0 0 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.