mirror of https://github.com/abpframework/abp.git
11 changed files with 290 additions and 294 deletions
@ -1,93 +1,82 @@ |
|||||
(function () { |
(function () { |
||||
var l = abp.localization.getResource("CmsKit"); |
var l = abp.localization.getResource("CmsKit"); |
||||
|
|
||||
$(document).ready(function () { |
abp.widgets.CmsRating = function ($widget) { |
||||
abp.widgets.CmsRating = function ($widget) { |
var widgetManager = $widget.data("abp-widget-manager"); |
||||
var widgetManager = $widget.data("abp-widget-manager"); |
var $ratingArea = $widget.find(".cms-rating-area"); |
||||
var $ratingArea = $widget.find(".cms-rating-area"); |
|
||||
|
|
||||
function getFilters() { |
function getFilters() { |
||||
return { |
return { |
||||
entityType: $ratingArea.attr("data-entity-type"), |
entityType: $ratingArea.attr("data-entity-type"), |
||||
entityId: $ratingArea.attr("data-entity-id") |
entityId: $ratingArea.attr("data-entity-id") |
||||
}; |
}; |
||||
} |
} |
||||
|
|
||||
function registerCreateOfNewRating() { |
|
||||
$widget.find(".my-rating").each(function () { |
|
||||
var authenticated = $(this).attr("data-authenticated"); |
|
||||
|
|
||||
$(this).starRating({ |
|
||||
initialRating: 0, |
|
||||
starSize: 16, |
|
||||
emptyColor: '#eee', |
|
||||
hoverColor: '#ffc107', |
|
||||
activeColor: '#ffc107', |
|
||||
useGradient: false, |
|
||||
strokeWidth: 0, |
|
||||
disableAfterRate: true, |
|
||||
useFullStars: true, |
|
||||
readOnly: authenticated === "True", |
|
||||
onHover: function (currentIndex, currentRating, $el) { |
|
||||
$widget.find(".live-rating").text(currentIndex); |
|
||||
}, |
|
||||
onLeave: function (currentIndex, currentRating, $el) { |
|
||||
$widget.find(".live-rating").text(currentRating); |
|
||||
}, |
|
||||
callback: function (currentRating, $el) { |
|
||||
volo.cmsKit.public.ratings.ratingPublic.create( |
|
||||
$ratingArea.attr("data-entity-type"), |
|
||||
$ratingArea.attr("data-entity-id"), |
|
||||
{ |
|
||||
starCount: parseInt(currentRating) |
|
||||
} |
|
||||
).then(function () { |
|
||||
widgetManager.refresh($widget); |
|
||||
}) |
|
||||
} |
|
||||
}); |
|
||||
} |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
function registerUndoLink() { |
function registerCreateOfNewRating() { |
||||
$widget.find(".rating-undo-link").each(function () { |
$widget.find(".my-rating").each(function () { |
||||
$(this).on('click', '', function (e) { |
var authenticated = $(this).attr("data-authenticated"); |
||||
e.preventDefault(); |
|
||||
|
|
||||
abp.message.confirm(l("RatingUndoMessage"), function (ok) { |
$(this).starRating({ |
||||
if (ok) { |
initialRating: 0, |
||||
volo.cmsKit.public.ratings.ratingPublic.delete( |
starSize: 16, |
||||
$ratingArea.attr("data-entity-type"), |
emptyColor: '#eee', |
||||
$ratingArea.attr("data-entity-id") |
hoverColor: '#ffc107', |
||||
).then(function () { |
activeColor: '#ffc107', |
||||
widgetManager.refresh($widget); |
useGradient: false, |
||||
}); |
strokeWidth: 0, |
||||
} |
disableAfterRate: true, |
||||
}) |
useFullStars: true, |
||||
|
readOnly: authenticated === "True", |
||||
|
onHover: function (currentIndex, currentRating, $el) { |
||||
|
$widget.find(".live-rating").text(currentIndex); |
||||
|
}, |
||||
|
onLeave: function (currentIndex, currentRating, $el) { |
||||
|
$widget.find(".live-rating").text(currentRating); |
||||
|
}, |
||||
|
callback: function (currentRating, $el) { |
||||
|
volo.cmsKit.public.ratings.ratingPublic.create( |
||||
|
$ratingArea.attr("data-entity-type"), |
||||
|
$ratingArea.attr("data-entity-id"), |
||||
|
{ |
||||
|
starCount: parseInt(currentRating) |
||||
|
} |
||||
|
).then(function () { |
||||
|
widgetManager.refresh($widget); |
||||
|
}) |
||||
|
} |
||||
}); |
}); |
||||
}); |
} |
||||
} |
); |
||||
|
} |
||||
|
|
||||
function init() { |
function registerUndoLink() { |
||||
registerCreateOfNewRating(); |
$widget.find(".rating-undo-link").each(function () { |
||||
registerUndoLink(); |
$(this).on('click', '', function (e) { |
||||
} |
e.preventDefault(); |
||||
|
|
||||
return { |
abp.message.confirm(l("RatingUndoMessage"), function (ok) { |
||||
init: init, |
if (ok) { |
||||
getFilters: getFilters |
volo.cmsKit.public.ratings.ratingPublic.delete( |
||||
} |
$ratingArea.attr("data-entity-type"), |
||||
}; |
$ratingArea.attr("data-entity-id") |
||||
|
).then(function () { |
||||
$('.abp-widget-wrapper[data-widget-name="CmsRating"]') |
widgetManager.refresh($widget); |
||||
.each(function () { |
}); |
||||
var widgetManager = new abp.WidgetManager({ |
} |
||||
wrapper: $(this), |
}) |
||||
}); |
}); |
||||
|
|
||||
widgetManager.init($(this)); |
|
||||
}); |
}); |
||||
}); |
} |
||||
|
|
||||
|
function init() { |
||||
|
registerCreateOfNewRating(); |
||||
|
registerUndoLink(); |
||||
|
} |
||||
|
|
||||
|
return { |
||||
|
init: init, |
||||
|
getFilters: getFilters |
||||
|
} |
||||
|
}; |
||||
}) |
}) |
||||
(jQuery); |
(jQuery); |
||||
|
|||||
Loading…
Reference in new issue