app/assets/javascripts/cms/content_library.js in browsercms-3.5.7 vs app/assets/javascripts/cms/content_library.js in browsercms-4.0.0.alpha
- old
+ new
@@ -1,31 +1,31 @@
-jQuery(function($) {
+jQuery(function ($) {
//----- Helper Functions -----------------------------------------------------
//In all of this code, we are defining functions that we use later
//None of this actually manipulates the DOM in any way
//This is used to get the id part of an elementId
//For example, if you have section_node_5,
//you pass this 'section_node_5', 'section_node'
//and this returns 5
- var getId = function(elementId, s) {
+ var getId = function (elementId, s) {
return elementId.replace(s, '')
}
- var nodeOnDoubleClick = function() {
+ var nodeOnDoubleClick = function () {
if ($('#edit_button').hasClass('disabled')) {
//$('#view_button').click()
location.href = $('#view_button')[0].href
} else {
//$('#edit_button').click()
location.href = $('#edit_button')[0].href
}
}
- var addNodeOnDoubleClick = function() {
+ var addNodeOnDoubleClick = function () {
$('#blocks tr').dblclick(nodeOnDoubleClick)
}
//----- Init -----------------------------------------------------------------
//In other words, stuff that happens when the page loads
@@ -37,30 +37,30 @@
// Makes the toolbar for the Content table correctly work based on the selected row.
// I.e. Select a row, the 'View' button becomes active and the URL goes to the right path.
//
// Any element with class='cms-content-table' will have this applied to it.
-(function($) {
- $.fn.cmsContentToolbar = function() {
-
+(function ($) {
+ $.fn.cmsContentToolbar = function () {
var content_type = this.data('content_type')
var is_versioned = this.data('versioned')
var can_publish = this.data('can_publish')
var plural_title = this.data('plural_title')
$('table.data tbody tr').hover(
- function() {
+ function () {
$(this).addClass('hover')
},
- function() {
+ function () {
$(this).removeClass('hover')
- }).click(function() {
+ }).click(function () {
var view_path = $(this).data('view_path');
var edit_path = $(this).data('edit_path');
var delete_path = $(this).data('delete_path');
var new_path = $(this).data('new_path');
var versions_path = $(this).data('versions_path');
+ var preview_path = $(this).data('preview_path');
var publish_path = $(this).data('publish_path') + '?_redirect_to=' + location.href;
var status = $(this).data('status');
var editable = !$(this).hasClass("non-editable");
var publishable = !$(this).hasClass("non-publishable");
@@ -87,16 +87,35 @@
.attr('title', 'Are You Sure You Want To Delete This Record?');
}
}
if (can_publish) {
if (status == 'draft' && publishable) {
- $('#publish_button').removeClass('disabled').attr('href', publish_path);
+ $('#publish_button')
+ .attr('href', publish_path)
+ .enable_menu_button();
+ } else {
+ $('#publish_button')
+ .disable_menu_button();
}
}
+ if(preview_path){
+ $('#preview_button').attr('href', preview_path).enable_menu_button();
+ }
})
};
})(jQuery);
-$(function() {
+(function ($) {
+ $.fn.disable_menu_button = function () {
+ $(this).addClass('disabled');
+ $(this).attr("href", "#");
+ }
+ $.fn.enable_menu_button = function () {
+ $(this).removeClass('disabled');
+ return $(this);
+ }
+})(jQuery);
+
+$(function () {
$('.cms-content-table').cmsContentToolbar();
});